psp-uvc-usb-video-class icon indicating copy to clipboard operation
psp-uvc-usb-video-class copied to clipboard

Windows 10: Device cannot start

Open stranno opened this issue 5 years ago • 11 comments

Hey xerpi.

I'm trying this plugin on PSP1001 + 6.61 ME 2.3. Both VSH + GAME plugins activated. Windows 10 LTSC + Privacy "Camera" Settings Enabled. Official Dual Shock 3 cable (never had any problems with it) + different USB 2.0/3.0 ports.

And I'm getting USB Video Device, under Cameras group, with exclamation mark (This device cannot start. (Code 10) An invalid parameter was passed to a service or function).

vita-usvc-usb-video-class works perfectly fine tho.

Any idea? Thank you.

stranno avatar Sep 28 '20 18:09 stranno

I think the problem is that I'm not setting an Interface Association Descriptor (IAD), which is mandatory per the UVC spec. You can see the difference here: PSP (https://pastebin.com/raw/Ex59Hzvy) vs PSVita (https://pastebin.com/raw/rBvzgFuU). As you can see the PSP one is missing:

    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass         14 Video
      bFunctionSubClass       3 Video Interface Collection
      bFunctionProtocol       0 
      iFunction               0 

For that, we need to hook the pspusb module and inject IAD.

xerpi avatar Sep 28 '20 23:09 xerpi

I works on Android using USB Camera software. I guess it requires less header/info than Windows UVC.

Is the debug info scrolling through the screen normal? 😄

With hooking the descriptor to usb module I assume you have to do that change, or can I change that in the code?

Thanks again.

stranno avatar Sep 29 '20 13:09 stranno

Set https://github.com/xerpi/psp-uvc-usb-video-class/blob/master/src/main.c#L11 to 0 to disable the debug logging.

Regarding IAD, we have to reverse-engineer the USB module usb.prx (decrypt 6.6X modules and use Ghidra) to find and understand the function that writes and serializes all the descriptors in a buffer that is sent to the USB hardware. Then we can hook that function and memmove and memcpy IAD to that buffer. This is what I do on the PSVita plugin: https://github.com/xerpi/vita-udcd-uvc/blob/master/src/main.c#L947

xerpi avatar Sep 29 '20 13:09 xerpi

I think I've found the function that we are looking for, in 6.61 OFW usb.prx. ~It is at offset 0x00008440, and takes a UsbDriver *driver as a parameter. It is called during sceUsbStart.~

EDIT: I correct myself: it's at offset 0x000019c0 and takes 2 parameters: the first one is struct ConfigDescriptor *config and the second one is byte *buffer where the Configuration Descriptor is serialized into.

xerpi avatar Sep 29 '20 14:09 xerpi

Thank you. I will wait for the push then.

Great work 👍

stranno avatar Sep 29 '20 18:09 stranno

I think I've found a clean way to include the IAD without having to hook anything :) Can you try the latest code in master?

xerpi avatar Sep 29 '20 20:09 xerpi

This time I'm not getting the 'Camera' tab and, instead, the exclamation mark is in USB Composite Device, under 'USB Controllers'.

This device cannot start. (Code 10) STATUS_DEVICE_DATA_ERROR

Device USB\VID_054C&PID_1337\0487B0543E0C09E0 was configured. Driver Name: usb.inf Class Guid: {36fc9e60-c465-11cf-8056-444553540000} Driver Date: 06/21/2006 Driver Version: 10.0.17763.1432 Driver Provider: Microsoft Driver Section: Composite.Dev.NT Driver Rank: 0xFF2003 Matching Device Id: USB\COMPOSITE Outranked Drivers: Device Updated: false Parent Device: USB\ROOT_HUB30\4&92b3c53&0&0

Device USB\VID_054C&PID_1337\0487B0543E0C09E0 was started. Driver Name: usb.inf Class Guid: {36fc9e60-c465-11cf-8056-444553540000} Service: usbccgp Lower Filters: Upper Filters:

USB Camera on Android still works fine.

photo6025819093606708366

stranno avatar Sep 29 '20 20:09 stranno

@xerpi Update: Fixed! (partially).

With your latest change I'm getting two USB Video Devices. One correctly detected under Cameras tab, the other still marked with an exclamation mark under Other devices.

OdGECmd1f7

But the first one works perfecly fine on OBS or VirtualDub.

Screenshot 2020-10-04 11-58-29

Only issues left: 1) If you turn off the screen (both Backlight Auto-Off or using the slider) the PSP turns off. 2) That extra device. 3) A custom PSP UVC ID would be great, like PSVita on Vita, instead of 'USB Video Device'.

stranno avatar Oct 04 '20 10:10 stranno

Can you try with 0.2? https://github.com/xerpi/psp-uvc-usb-video-class/releases

xerpi avatar Oct 04 '20 10:10 xerpi

Yes, I've also noticed that second extra "Unknown device" that appears. I'm sure it's due to the dummy USB interface I'm adding: https://github.com/xerpi/psp-uvc-usb-video-class/blob/master/include/usb_descriptors.h#L224 Maybe we could try to play with its values a bit to see if we make it Windows completely ignore.

And regarding the custom string descriptors, yeah that would be nice but I doubt I'll continue working on this very often.. so I'd really like if other devs could help improve it :)

xerpi avatar Oct 04 '20 10:10 xerpi

Sorry. I didn't get the notification. Yes. 0.2 worked fine, as the last build I tried.

I'm afraid I can't help you with this other than testing and reporting issues. Good luck with your future projects 👍

stranno avatar Oct 05 '20 23:10 stranno