Skip to content

Commit

Permalink
Improve SET_INTERFACE
Browse files Browse the repository at this point in the history
  • Loading branch information
xerpi committed Jul 14, 2019
1 parent 7b4fc8c commit 1a285a0
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ static void uvc_handle_video_streaming_req_recv(const SceUdcdEP0DeviceRequest *r
uvc_probe_control_setting.bFormatIndex = streaming_control->bFormatIndex;
uvc_probe_control_setting.bFrameIndex = streaming_control->bFrameIndex;
uvc_probe_control_setting.dwFrameInterval = streaming_control->dwFrameInterval;

LOG("Probe SET_CUR, bFormatIndex: %d\n", uvc_probe_control_setting.bFormatIndex);

LOG("Probe SET_CUR, bFormatIndex: %d, bmFramingInfo: %x\n",
uvc_probe_control_setting.bFormatIndex,
uvc_probe_control_setting.bmFramingInfo);
break;
}
break;
Expand All @@ -208,8 +208,9 @@ static void uvc_handle_video_streaming_req_recv(const SceUdcdEP0DeviceRequest *r
uvc_probe_control_setting.bFormatIndex = streaming_control->bFormatIndex;
uvc_probe_control_setting.bFrameIndex = streaming_control->bFrameIndex;
uvc_probe_control_setting.dwFrameInterval = streaming_control->dwFrameInterval;

LOG("Commit SET_CUR, bFormatIndex: %d\n", uvc_probe_control_setting.bFormatIndex);
LOG("Commit SET_CUR, bFormatIndex: %d, bmFramingInfo: %x\n",
uvc_probe_control_setting.bFormatIndex,
uvc_probe_control_setting.bmFramingInfo);

stream = 1;
ksceKernelSetEventFlag(uvc_event_flag_id, 1);
Expand Down Expand Up @@ -257,12 +258,16 @@ static void uvc_handle_video_streaming_req(const SceUdcdEP0DeviceRequest *req)
case UVC_GET_MIN:
case UVC_GET_MAX:
case UVC_GET_DEF:
LOG("Probe GET_DEF, bFormatIndex: %d\n", uvc_probe_control_setting_default.bFormatIndex);
LOG("Probe GET_DEF, bFormatIndex: %d, bmFramingInfo: %x\n",
uvc_probe_control_setting_default.bFormatIndex,
uvc_probe_control_setting_default.bmFramingInfo);
usb_ep0_req_send(&uvc_probe_control_setting_default,
sizeof(uvc_probe_control_setting_default));
break;
case UVC_GET_CUR:
LOG("Probe GET_CUR, bFormatIndex: %d\n", uvc_probe_control_setting.bFormatIndex);
LOG("Probe GET_CUR, bFormatIndex: %d, bmFramingInfo: %x\n",
uvc_probe_control_setting.bFormatIndex,
uvc_probe_control_setting.bmFramingInfo);
usb_ep0_req_send(&uvc_probe_control_setting,
sizeof(uvc_probe_control_setting));
break;
Expand Down Expand Up @@ -301,10 +306,24 @@ static void uvc_handle_video_abort(void)
}
}

static void uvc_handle_set_interface(const SceUdcdEP0DeviceRequest *req)
{
LOG("uvc_handle_set_interface\n");

/* MAC OS sends Set Interface Alternate Setting 0 command after
* stopping to stream. This application needs to stop streaming. */
if ((req->wIndex == STREAM_INTERFACE) && (req->wValue == 0))
uvc_handle_video_abort();
}

static void uvc_handle_clear_feature(const SceUdcdEP0DeviceRequest *req)
{
LOG("uvc_handle_clear_feature\n");

/* Windows OS sends Clear Feature Request after it stops streaming,
* however MAC OS sends clear feature request right after it sends a
* Commit -> SET_CUR request. Hence, stop streaming only of streaming
* has started. */
switch (req->wValue) {
case USB_FEATURE_ENDPOINT_HALT:
if ((req->wIndex & USB_ENDPOINT_ADDRESS_MASK) ==
Expand Down Expand Up @@ -350,6 +369,15 @@ static int uvc_udcd_process_request(int recipient, int arg, SceUdcdEP0DeviceRequ
break;
}
break;
case USB_CTRLTYPE_DIR_HOST2DEVICE |
USB_CTRLTYPE_TYPE_STANDARD |
USB_CTRLTYPE_REC_INTERFACE: /* 0x01 */
switch (req->bRequest) {
case USB_REQ_SET_INTERFACE:
uvc_handle_set_interface(req);
break;
}
break;
case USB_CTRLTYPE_DIR_HOST2DEVICE |
USB_CTRLTYPE_TYPE_STANDARD |
USB_CTRLTYPE_REC_ENDPOINT: /* 0x02 */
Expand Down

0 comments on commit 1a285a0

Please sign in to comment.