Webcam ugen iso transfer problems

Engineering ee at athyriogames.com
Sun May 11 16:20:37 UTC 2008


Hello

I am having much trouble trying to read isochronous data from a UVC webcam.
I understand that a full driver is being worked on right now, but I'd love
to be able to get my 'mini-driver' which only does one frame rate working in
the meantime.

I have updated the USB stack with Hans Petter Selasky's work, and am now
able to get data. The problem is, much of the YUV data seems to be missing.

I have just run tests through all of the Alt Interfaces, and have some
results.

I am just setting the cam to 160x120 uncompressed, and trying to get the
stream

In each case, I try to set the buffer to wMaxPacketSize * 400 (ugen seems to
collect 50 * 8 packets)

I notice at the faster interfaces, the ugen Frame Size no longer matches
wMaxPacketSize.

This should give me 12 byte stream headers, and lots of YUV data. I read the
results as a 2 channel raw file in Photoshop. I discarded the 2nd channel
(UV) for clarity, so the 12 bytes headers become 6 bytes, which you can see
in the png files.

the basic test code loop is

dev->isopipe = open(pipename,O_RDONLY);
(set the buffer size, timeout, short XFER)
FILE *f;
f = fopen("/usr/src/sys/dev/usb/test.raw","wb");
int i;
int bytes;
for(i = 0;i<210;i++)
{
	bytes = read(dev->isopipe,uvcbuf,UVCBUFSIZE); // 42240
	if (bytes > 0)
	{
		fwrite(&uvcbuf,bytes,1,f);
		zinfo("read %d bytes\n",bytes);
	}
}
fclose(f);

Basic setup info...

VS_FRAME_UNCOMPRESSED
 length 50
 type 24
 subtype 05
 frame_index 5
 capabilities 0
 width 160
 height 120
 minbitrate 38400
 maxbitrate 1152000
 max_video_frame_buffer_size 38400
 default_frame_interval 333333
 frame_interval_type 6
 frame_interval[0] 333333

USB_DO_REQUEST SEND...length = 34
USB_DO_REQUEST RECV...length = 34
UVC Stream probe
 bmHint 01
 bFormatIndex 1
 bFrameIndex 5
 dwFrameInterval 333333
 wKeyFrameRate 1
 wPFrameRate 1
 wCompQuality 10000
 wCompWindowSize 0
 wDelay 34055
 dwMaxVideoFrameSize 42240
 dwMaxPayloadTransferSize 1600
 dwClockFrequency 1852381070
 bmFramingInfo B2
 bPreferedVersion 175
 bMinVersion 250
 bMaxVersion 180

Alt Interface 1:
Setting altinterface to 1:1
Getting altinterface for 1
00 00 00 00 01 00 00 00 01 00 00 00
Getting interface description
 bLength 09
 bDescriptorType 04
 bInterfaceNumber 01
 bAlternateSetting 01
 bNumEndpoints 01
 bInterfaceClass 0E
 bInterfaceSubClass 02
 bInterfaceProtocol 00
 iInterface 00
Getting endpoint description
 bLength 07
 bDescriptorType 05
 bEndpointAddress 81
 bmAttributes 05
 wMaxPacketSize 0080 (128)
 bInterfaceSubClass 01

Opening isopipe /dev/ugen0.1...
returned 5
Setting buffer size 51200
Setting short xfer...
Setting timeout to 1
ugen Frame size 128
ugen Buffer size 51200
dev->MaxPacketSize = 128
dev->endpoint = 81

result:
www.athyriogames.com/ai1.png


Alt Interface 2:
Setting altinterface to 1:2
Getting altinterface for 1
00 00 00 00 01 00 00 00 02 00 00 00
Getting interface description
 bLength 09
 bDescriptorType 04
 bInterfaceNumber 01
 bAlternateSetting 02
 bNumEndpoints 01
 bInterfaceClass 0E
 bInterfaceSubClass 02
 bInterfaceProtocol 00
 iInterface 00
Getting endpoint description
 bLength 07
 bDescriptorType 05
 bEndpointAddress 81
 bmAttributes 05
 wMaxPacketSize 0100 (256)
 bInterfaceSubClass 01
Opening isopipe /dev/ugen0.1...
returned 5
Setting buffer size 102400
Setting short xfer...
Setting timeout to 1
ugen Frame size 256
ugen Buffer size 102400
dev->MaxPacketSize = 256
dev->endpoint = 81
result:
www.athyriogames.com/ai2.png

Alt Interface 3:
Setting altinterface to 1:3
Getting altinterface for 1
00 00 00 00 01 00 00 00 03 00 00 00
Getting interface description
 bLength 09
 bDescriptorType 04
 bInterfaceNumber 01
 bAlternateSetting 03
 bNumEndpoints 01
 bInterfaceClass 0E
 bInterfaceSubClass 02
 bInterfaceProtocol 00
 iInterface 00
Getting endpoint description
 bLength 07
 bDescriptorType 05
 bEndpointAddress 81
 bmAttributes 05
 wMaxPacketSize 0320 (800)
 bInterfaceSubClass 01
Opening isopipe /dev/ugen0.1...
returned 5
Setting short xfer...
Setting timeout to 1
ugen Frame size 800
ugen Buffer size 65536
dev->MaxPacketSize = 800
dev->endpoint = 81
result:
www.athyriogames.com/ai3.png

Alt Interface 4:
Setting altinterface to 1:4
Getting altinterface for 1
00 00 00 00 01 00 00 00 04 00 00 00
Getting interface description
 bLength 09
 bDescriptorType 04
 bInterfaceNumber 01
 bAlternateSetting 04
 bNumEndpoints 01
 bInterfaceClass 0E
 bInterfaceSubClass 02
 bInterfaceProtocol 00
 iInterface 00
Getting endpoint description
 bLength 07
 bDescriptorType 05
 bEndpointAddress 81
 bmAttributes 05
 wMaxPacketSize 0B20 (2848)
 bInterfaceSubClass 01
Opening isopipe /dev/ugen0.1...
returned 5
Setting buffer size 1139200
Setting short xfer...
Setting timeout to 1
ugen Frame size 1600
ugen Buffer size 262144
dev->MaxPacketSize = 2848
dev->endpoint = 81
result:
www.athyriogames.com/ai4.png

Alt Interface 3:
Setting altinterface to 1:5
Getting altinterface for 1
00 00 00 00 01 00 00 00 05 00 00 00
Getting interface description
 bLength 09
 bDescriptorType 04
 bInterfaceNumber 01
 bAlternateSetting 05
 bNumEndpoints 01
 bInterfaceClass 0E
 bInterfaceSubClass 02
 bInterfaceProtocol 00
 iInterface 00
Getting endpoint description
 bLength 07
 bDescriptorType 05
 bEndpointAddress 81
 bmAttributes 05
 wMaxPacketSize 1320 (4896)
 bInterfaceSubClass 01
Opening isopipe /dev/ugen0.1...
returned 5
Setting buffer size 1958400
Setting short xfer...
Setting timeout to 1
ugen Frame size 2400
ugen Buffer size 262144
dev->MaxPacketSize = 4896
dev->endpoint = 81
result:
www.athyriogames.com/ai5.png



Alt Interface 6:
Setting altinterface to 1:6
Getting altinterface for 1
00 00 00 00 01 00 00 00 06 00 00 00
Getting interface description
 bLength 09
 bDescriptorType 04
 bInterfaceNumber 01
 bAlternateSetting 06
 bNumEndpoints 01
 bInterfaceClass 0E
 bInterfaceSubClass 02
 bInterfaceProtocol 00
 iInterface 00
Getting endpoint description
 bLength 07
 bDescriptorType 05
 bEndpointAddress 81
 bmAttributes 05
 wMaxPacketSize 1400 (5120)
 bInterfaceSubClass 01
Opening isopipe /dev/ugen0.1...
returned 5
Setting buffer size 2048000
Setting short xfer...
Setting timeout to 1
ugen Frame size 3072
ugen Buffer size 262144
dev->MaxPacketSize = 5120
dev->endpoint = 81
result:
www.athyriogames.com/ai6.png


Thank you for any help you can give me
Sam



More information about the freebsd-usb mailing list