Webcam ugen iso transfer problems

Hans Petter Selasky hselasky at c2i.net
Sun May 11 17:10:35 UTC 2008


On Sunday 11 May 2008, Engineering wrote:
> 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);
>

Hi Sam,

How does the parsing code look?

Can you provide a Hexdump of the data you get from the ugen endpoint ?

for (i = 0; i != 240; i++)
{
	bytes = read(dev->isopipe,buf,count * wMaxPacketSize);
	if (bytes > 0) {
		...
	} else {
		break; /* detached */
	}
}

--HPS


More information about the freebsd-usb mailing list