Discussion:
[linux-uvc-devel] usb_video.c: 0bda:579f Realtek - corrupted frames and low FPS of captured mjpeg video frames
Dmitrii Shcherbakov
2017-03-16 15:02:02 UTC
Permalink
Hi everybody,

I have a usb camera built into my laptop (hardware details here
https://paste.ubuntu.com/24126969/) and I am looking for some guidance
on how to debug it further - any feedback is highly appreciated.

I am aware that this hardware is probably buggy/does not follow the
UVC spec/vendor only cared about Windows etc.

I am trying to capture mjpeg-encoded video at various resolutions and
frame rates via ffmpeg using v4l2 and the uvc kernel driver.

Test results (kernel logs with uvc driver in verbose mode and ffmpeg
output are included):
https://paste.ubuntu.com/24126930/
https://paste.ubuntu.com/24126960/

uname -r
4.11.0-041100rc1-generic

Conclusions:
- using any resolution higher than 640x480 results in corrupted bottom
half of the image (grey and green artifacts)
- frame rate is low on any resolution, even when I specify 640x480
with 30 or 15 fps via v4l2 it is nowhere near that point

frame= 179 fps=7.7 q=-1.0 Lsize= 3882kB time=00:00:23.06
bitrate=1378.6kbits/s speed=0.994x

- the kernel log is filled with the following messages

мар 07 00:15:31 blade kernel: uvcvideo: uvc_v4l2_mmap
мар 07 00:15:31 blade kernel: uvcvideo: Allocated 5 URB buffers of
32x512 bytes each.
мар 07 00:15:31 blade kernel: uvcvideo: frame 1 stats: 0/0/1 packets,
0/0/1 pts (!early initial), 0/1 scr, last pts/stc/sof
6446951/6832111/975
мар 07 00:15:31 blade kernel: uvcvideo: Marking buffer as bad (error bit set).
мар 07 00:15:31 blade kernel: uvcvideo: Frame complete (FID bit toggled).
мар 07 00:15:31 blade kernel: uvcvideo: frame 2 stats: 0/0/1 packets,
0/0/1 pts (!early initial), 0/0 scr, last pts/stc/sof 3617775107/0/0
мар 07 00:15:31 blade kernel: uvcvideo: Marking buffer as bad (error bit set).
мар 07 00:15:31 blade kernel: uvcvideo: Frame complete (EOF found).
мар 07 00:15:31 blade kernel: uvcvideo: Dropping payload (out of sync).
мар 07 00:15:31 blade kernel: uvcvideo: frame 3 stats: 0/0/2 packets,
1/1/2 pts (!early initial), 0/1 scr, last pts/stc/sof
8413602/8799007/1106
мар 07 00:15:31 blade kernel: uvcvideo: Frame complete (EOF found).
мар 07 00:15:32 blade kernel: uvcvideo: Dropping payload (out of sync).
мар 07 00:15:32 blade kernel: uvcvideo: Marking buffer as bad (error bit set).
мар 07 00:15:32 blade kernel: uvcvideo: Dropping payload (out of sync).

- some entity types were not initialized at module loading time

мар 06 20:47:35 blade kernel: uvcvideo: Found UVC 1.00 device USB
Camera (0bda:579f)
мар 06 20:47:35 blade kernel: uvcvideo: Forcing device quirks to 0x80
by module parameter for testing purpose.
мар 06 20:47:35 blade kernel: uvcvideo: Please report required quirks
to the linux-uvc-devel mailing list.
мар 06 20:47:35 blade kernel: uvcvideo 1-7:1.0: Entity type for entity
Extension 4 was not initialized!
мар 06 20:47:35 blade kernel: uvcvideo 1-7:1.0: Entity type for entity
Processing 2 was not initialized!
мар 06 20:47:35 blade kernel: uvcvideo 1-7:1.0: Entity type for entity
Camera 1 was not initialized!
мар 06 20:47:35 blade kernel: usbcore: registered new interface driver uvcvideo

- tried different quirks non of which made any difference (I can try a
specific one or a combination if there are any ideas). I cannot
diagnose what it is so this was just random poking.

- a similar thread for XPS 12 with a Realtek webcam
https://www.spinics.net/lists/linux-media/msg73476.html

- the buffer is marked as bad in uvc_video_decode_start based upon a
UVC_STREAM_ERR flag:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/media/usb/uvc/uvc_video.c#n1004

If anybody has any pointers/suggestions, please let me know.

Thanks in advance!

Loading...