Hi,

I'm programming an emulated UVC webcam in QEMU and I've found a little
problem.

While I'm trying to send a bulk payload made from a JPEG sized 5809
bytes, uvcvideo never detects the payload ends and continue asking
frames until buffer (~53KiB) overflows.

I attach the code snippet that generates the payload (code is under
GLPv2) as snippet.c

Trace from uvcvideo as dmesg.txt

Crash of uvccapture as uvccapture.txt

I've checked the specifications and I'm unable to find what I'm doing
wrong or how should be done the payload to get it working.

Any help will be thanked.

Regards,
Natalia Portillo

else if(p->devep == 2) // IN endpoint 2 (video data)
			{
				if(first_bulk_packet)
				{
					DPRINTF("usb-uvc: First video packet p->len %d bytes (64)\n", p->len);
					for(i=0;i<24;i++)
						printf("0x%02X ", frame[i]);
					printf("\n");
					p->data[0] = 2;
					p->data[1] = 0x82 & frame_id;
					memcpy((p->data)+2,frame,62);
					ret = 64;
					first_bulk_packet=0;
					frame = frame + 62;
					frame_remaining_bytes = frame_remaining_bytes - 62;
				}
				else if(frame_remaining_bytes<=64)
				{
					DPRINTF("usb-uvc: Last video packet p->len %d bytes (%d)\n", p->len, frame_remaining_bytes);
					for(i=0;i<24;i++)
						printf("0x%02X ", frame[i]);
					printf("\n");
					memcpy(p->data,frame,frame_remaining_bytes); 
					ret = frame_remaining_bytes;
					first_bulk_packet=1;
					frame_id = frame_id ^ 1;
					frame = frame_start;
					frame_remaining_bytes = frame_length;
					DPRINTF("usb-uvc: frame addr 0x%08X", frame);
				}
				else
				{
					DPRINTF("usb-uvc: Video packet p->len %d bytes (64)\n", p->len);
					for(i=0;i<24;i++)
						printf("0x%02X ", frame[i]);
					printf("\n");
					memcpy(p->data,frame,64);
					frame = frame+64;
					frame_remaining_bytes = frame_remaining_bytes-64;
					ret = 64;
				}
			}
r...@debian:~# uvccapture
 format asked unavailable get width 176 height 144 
ioctl querycontrol error 22 
ioctl querycontrol error 22 
ioctl querycontrol error 22 
*** glibc detected *** uvccapture: free(): invalid next size (normal): 
0x085172f0 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6(+0x6c104)[0xb76b9104]
/lib/i686/cmov/libc.so.6(+0x6d983)[0xb76ba983]
/lib/i686/cmov/libc.so.6(cfree+0x6d)[0xb76bd96d]
uvccapture[0x804a353]
uvccapture[0x80498f0]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7663c85]
uvccapture[0x8048bc1]
======= Memory map: ========
08048000-0804c000 r-xp 00000000 08:01 28786673   /usr/bin/uvccapture
0804c000-0804d000 rw-p 00003000 08:01 28786673   /usr/bin/uvccapture
08517000-08538000 rw-p 00000000 00:00 0          [heap]
b7500000-b7521000 rw-p 00000000 00:00 0 
b7521000-b7600000 ---p 00000000 00:00 0 
b762d000-b764a000 r-xp 00000000 08:01 16987594   /lib/libgcc_s.so.1
b764a000-b764b000 rw-p 0001c000 08:01 16987594   /lib/libgcc_s.so.1
b764b000-b764d000 rw-p 00000000 00:00 0 
b764d000-b7793000 r-xp 00000000 08:01 195780     /lib/i686/cmov/libc-2.11.1.so
b7793000-b7795000 r--p 00146000 08:01 195780     /lib/i686/cmov/libc-2.11.1.so
b7795000-b7796000 rw-p 00148000 08:01 195780     /lib/i686/cmov/libc-2.11.1.so
b7796000-b7799000 rw-p 00000000 00:00 0 
b7799000-b77b8000 r-xp 00000000 08:01 412590     /usr/lib/libjpeg.so.62.0.0
b77b8000-b77b9000 rw-p 0001e000 08:01 412590     /usr/lib/libjpeg.so.62.0.0
b77c9000-b77cb000 rw-p 00000000 00:00 0 
b77cb000-b77cc000 r-xp 00000000 00:00 0          [vdso]
b77cc000-b77e8000 r-xp 00000000 08:01 16839934   /lib/ld-2.11.1.so
b77e8000-b77e9000 r--p 0001b000 08:01 16839934   /lib/ld-2.11.1.so
b77e9000-b77ea000 rw-p 0001c000 08:01 16839934   /lib/ld-2.11.1.so
bfaa8000-bfabd000 rw-p 00000000 00:00 0          [stack]
Exiting...
Aborted

[   56.142980] uvcvideo: Control 0x00980901 not found.
[   56.143020] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCTRL)
[   56.143027] uvcvideo: Control 0x00980902 not found.
[   56.143039] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCTRL)
[   56.143045] uvcvideo: Control 0x00980913 not found.
[   56.143070] uvcvideo: uvc_v4l2_ioctl(VIDIOC_STREAMON)
[   56.151168] uvcvideo: uvc_v4l2_ioctl(VIDIOC_DQBUF)
[   57.260706] uvcvideo: Frame complete (overflow).
[   57.302511] uvcvideo: Frame complete (overflow).
[   57.336522] uvcvideo: Frame complete (overflow).
[   57.336598] uvcvideo: Dequeuing buffer 0 (3, 52850 bytes).
[   57.336678] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QBUF)
[   57.336685] uvcvideo: Queuing buffer 0.
[   57.372937] uvcvideo: uvc_v4l2_ioctl(VIDIOC_STREAMOFF)
[   57.734405] uvcvideo: uvc_v4l2_release
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to