xerpi / vita-udcd-uvc

PSVita UDCD USB Video Class plugin
461 stars 23 forks source link

Fix black screen on MacOS #72

Closed xfangfang closed 3 years ago

xfangfang commented 3 years ago

I got this error message from Console.app:

[guid:0x14230000054c1337] BulkStreamHandler Illegal Header Length of 16 was > 12. Dropping 0 bytes already accumulated

So I changed the UVC_PAYLOAD_HEADER_SIZE from 16 to 12, and it seems everything is working perfectly.

Only test for MacOS 10.15.

obs

xfangfang commented 3 years ago

It doesn't seem perfect. The video is offset by 12 pixels to - X. (under 960*544)

xerpi commented 3 years ago

Wow, I can't believe this was what was causing issues on macOS!

Can you try with UVC_PAYLOAD_HEADER_SIZE 8?

xfangfang commented 3 years ago

Doesn't work, the offset changed to 8. I also test with UVC_PAYLOAD_HEADER_SIZE 2 , and it doesn't work. This happens not only on MacOS, but also on my Android phone, so it may also happen on the other systems.(after change UVC_PAYLOAD_HEADER_SIZE)

xerpi commented 3 years ago

I've checked the UVC 1.1 spec (USB_Video_Payload_Uncompressed_1.1.pdf) and the header is indeed 12 bytes: image You can also see "12 bytes" mentioned explicitly in: https://dri.freedesktop.org/docs/drm/media/uapi/v4l/pixfmt-meta-uvc.html

I think the problem with 12 is that the HW's colorspace converter (ksceIftuCsc) can't write to 12-bytes aligned address.

xerpi commented 3 years ago

Also checking USB_Video_FAQ_1.1.pdf: image

xfangfang commented 3 years ago

So setting UVC_PAYLOAD_HEADER_SIZE to 2 for MacOS is the easiest way to handle it? Only two columns of pixels have problems.

xerpi commented 3 years ago

I think the problem is that ksceIftuCsc expects the output address to be aligned to 16 or so.

xfangfang commented 3 years ago

Well, it doesn't seem to be very easy to fix this problem. I'll close this PR first and see if there is any solution on MacOS.

xerpi commented 3 years ago

@xfangfang I've updated master with a new commit, can you test if it works properly on macOS?

xfangfang commented 3 years ago

I have tried for a long time and failed. It seems that I need to learn more about C.😀

xerpi commented 3 years ago

It is a bit tricky, you can check the details here: https://github.com/xerpi/vita-udcd-uvc/commit/c4a9e38a5284eb61f122c2fc5f22890f31fdfec5

xfangfang commented 3 years ago

Thank you. When I saw the code, I understood. I didn't think uvc_frame_req_submit_phycont can be used in this way before. I'm actually curious about how the header files used by this plug-in were created, such as:psp2kern/lowio/iftu.h There's no documentation, right?

xerpi commented 3 years ago

@xfangfang Correct, there's no official documentation for that, not even for official PSVita developers since IFTU is kernel space. I managed to understand the usage and parameters of functions by reverse engineering SceLowio. I also documented the registers here: https://wiki.henkaku.xyz/vita/IFTU_Registers

xfangfang commented 3 years ago

Thank you very much. I'll take a look at this document. I hope I can be as good as you one day.

xerpi commented 3 years ago

You can find more info here: https://wiki.henkaku.xyz/vita/SceLowio

xfangfang commented 3 years ago

👌