Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: xerpi/vita-udcd-uvc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.6
Choose a base ref
...
head repository: xerpi/vita-udcd-uvc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 4 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 22, 2020

  1. Increase initial delay to 15s

    xerpi committed Sep 22, 2020
    Copy the full SHA
    5d04481 View commit details
  2. Fix UVC payload size to be 12B as per UVC spec

    It was set to 16B but the UVC spec requires it to be <=12.
    Change it to 12B, but IFTU UVC requieres 16B buffers so
    add padding to the uvc_frame struct.
    xerpi committed Sep 22, 2020
    Copy the full SHA
    c4a9e38 View commit details

Commits on Mar 14, 2022

  1. Create FUNDING.yml

    xerpi authored Mar 14, 2022
    Copy the full SHA
    909825f View commit details

Commits on Feb 25, 2024

  1. Update for latest vitasdk

    xerpi committed Feb 25, 2024
    Copy the full SHA
    93d8850 View commit details
Showing with 17 additions and 8 deletions.
  1. +1 −0 .github/FUNDING.yml
  2. +16 −8 src/main.c
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: xerpi
24 changes: 16 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@

#define MAX_UVC_VIDEO_FRAME_SIZE VIDEO_FRAME_SIZE_NV12(1280, 720)

#define UVC_PAYLOAD_HEADER_SIZE 16
#define UVC_PAYLOAD_HEADER_SIZE 12
#define UVC_PAYLOAD_SIZE(frame_size) (UVC_PAYLOAD_HEADER_SIZE + (frame_size))
#define MAX_UVC_PAYLOAD_TRANSFER_SIZE UVC_PAYLOAD_SIZE(MAX_UVC_VIDEO_FRAME_SIZE)

@@ -69,7 +69,13 @@ typedef struct SceIftuPlaneState_updated {
unsigned int crop_right;
} SceIftuPlaneState_updated;

/*
* We want the data field (raw pixel data) to be aligned to 16B for the IFTU CSC to work properly.
* It seems the USB controller is fine with data aligned to 4B (starts reading from header field).
*/
#define UVC_FRAME_PADDING_SIZE (16 - UVC_PAYLOAD_HEADER_SIZE)
struct uvc_frame {
unsigned char padding[UVC_FRAME_PADDING_SIZE];
unsigned char header[UVC_PAYLOAD_HEADER_SIZE];
unsigned char data[];
} __attribute__((packed));
@@ -134,8 +140,6 @@ static int usb_ep0_req_send(const void *data, unsigned int size)
.physicalAddress = NULL
};

ksceKernelCpuDcacheAndL2WritebackRange(data, size);

return ksceUdcdReqSend(&req);
}

@@ -161,7 +165,7 @@ static int usb_ep0_enqueue_recv_for_req(const SceUdcdEP0DeviceRequest *ep0_req)
.physicalAddress = NULL
};

ksceKernelCpuDcacheAndL2WritebackInvalidateRange(pending_recv.buffer,
ksceKernelDcacheInvalidateRange(pending_recv.buffer,
pending_recv.ep0_req.wLength);

return ksceUdcdReqRecv(&req);
@@ -306,6 +310,8 @@ static void uvc_handle_video_streaming_req(const SceUdcdEP0DeviceRequest *req)
LOG("Probe GET_CUR, bFormatIndex: %d, bmFramingInfo: %x\n",
uvc_probe_control_setting.bFormatIndex,
uvc_probe_control_setting.bmFramingInfo);
ksceKernelDcacheCleanRange(&uvc_probe_control_setting,
sizeof(uvc_probe_control_setting));
usb_ep0_req_send(&uvc_probe_control_setting,
sizeof(uvc_probe_control_setting));
break;
@@ -321,6 +327,8 @@ static void uvc_handle_video_streaming_req(const SceUdcdEP0DeviceRequest *req)
case UVC_GET_LEN:
break;
case UVC_GET_CUR:
ksceKernelDcacheCleanRange(&uvc_probe_control_setting,
sizeof(uvc_probe_control_setting));
usb_ep0_req_send(&uvc_probe_control_setting,
sizeof(uvc_probe_control_setting));
break;
@@ -534,7 +542,7 @@ static unsigned int uvc_frame_transfer(struct uvc_frame *frame,
if (eof)
frame->header[1] |= UVC_STREAM_EOF;

ret = uvc_frame_req_submit_phycont(frame, frame_size);
ret = uvc_frame_req_submit_phycont(frame->header, frame_size);
if (ret < 0) {
LOG("Error sending frame: 0x%08X\n", ret);
return ret;
@@ -697,7 +705,7 @@ static int send_frame(void)
static int last_frame_index = 0;
if (uvc_frame_buffer_uid < 0 || cur_frame_index != last_frame_index) {
uvc_frame_term();
ret = uvc_frame_init(VIDEO_FRAME_SIZE_NV12(dst_width, dst_height));
ret = uvc_frame_init(UVC_FRAME_PADDING_SIZE + VIDEO_FRAME_SIZE_NV12(dst_width, dst_height));
if (ret < 0) {
LOG("Error allocating the UVC frame (0x%08X)\n", ret);
return ret;
@@ -858,7 +866,7 @@ int uvc_start(void)
/*
* Wait until LiveArea is more or less ready.
*/
ksceKernelDelayThreadCB(5 * 1000 * 1000);
ksceKernelDelayThreadCB(15 * 1000 * 1000);
#endif

ret = ksceUdcdDeactivate();
@@ -952,7 +960,7 @@ static int SceUdcd_sub_01E1128C_hook_func(const SceUdcdConfigDescriptor *config_

dst->wTotalLength += sizeof(interface_association_descriptor);

ksceKernelCpuDcacheAndL2WritebackRange(desc_data, dst->wTotalLength);
ksceKernelDcacheCleanRange(desc_data, dst->wTotalLength);
}

return ret;