tech-multimedia archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: uvideo webcam on big-endian systems



On Mon, 2010-12-20 at 21:52 +0100, Frank Wille wrote:
> Yes. It's an iBook G4.
> 
> I also tested on my Pegasos2/G3 running ofppc a few days ago, which has uhci
> only. The system reacts with a spontaneous reboot when I try to read from
> /dev/video0.

Ouch. I have some suspicions about UHCI isoc too, but one thing at a
time.

> Streaming is problematic. Similar to the Pegasos my iBook reboots before the
> first frame can be shown when EHCI_DEBUG is enabled. All I got before the
> reboot is here:
> http://sun.hasenbraten.de/~frank/NetBSD/uvideo_stream.txt

Yeah, calling printf during interrupts isn't healthy. However, that
trace shows that data is coming in and being serviced by the ehci driver
correctly, which rules out a lot of ehci configuration code from being
the source of the fault.

I'm now interested in whether uvideo is reading sanely-shaped data from
USB transfers - could you disable EHCI_DEBUG, keep UVIDEO_DEBUG enabled,
and apply the attached patch. This should reveal what the uvideo layer
is doing with data that turns up (is it invalid, is it all
zero-lengthed).

> Here is a photo from the mplayer-window showing the pattern (without
> EHCI_DEBUG):
> http://sun.hasenbraten.de/~frank/NetBSD/uvideo_macppc.jpg

Yikes - I had imagined what you were seeing was the green shade mplayer
produces when it has no data, with the occasional line of something
else. However, that looks much more like you're getting blocks of
uninitialized memory on the screen.

This now looks like buffer mis-management is involved at some layer.

--
Thanks,
Jeremy

Index: uvideo.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/uvideo.c,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 uvideo.c
--- uvideo.c    3 Nov 2010 22:34:24 -0000       1.32
+++ uvideo.c    21 Dec 2010 10:15:10 -0000
@@ -1764,18 +1764,29 @@ uvideo_stream_recv_process(struct uvideo
        hdr = (uvideo_payload_header_t *)buf;
 
        if (hdr->bHeaderLength > UVIDEO_PAYLOAD_HEADER_SIZE ||
-           hdr->bHeaderLength < sizeof(uvideo_payload_header_t))
+           hdr->bHeaderLength < sizeof(uvideo_payload_header_t)) {
+               DPRINTF(("Bad UVC hdr len\n"));
                return USBD_INVAL;
-       if (hdr->bHeaderLength == len && !(hdr->bmHeaderInfo & UV_END_OF_FRAME))
+       } if (hdr->bHeaderLength == len && !(hdr->bmHeaderInfo & 
UV_END_OF_FRAME)) {
+               DPRINTF(("Short non-EOF frame\n"));
                return USBD_INVAL;
-       if (hdr->bmHeaderInfo & UV_ERROR)
+       } if (hdr->bmHeaderInfo & UV_ERROR) {
+               DPRINTF(("Device error\n"));
                return USBD_IOERROR;
+       }
 
        payload.data = buf + hdr->bHeaderLength;
        payload.size = len - hdr->bHeaderLength;
        payload.frameno = hdr->bmHeaderInfo & UV_FRAME_ID;
        payload.end_of_frame = hdr->bmHeaderInfo & UV_END_OF_FRAME;
 
+       if (payload.end_of_frame && payload.size == 0) {
+               /* Uninteresting - a blank microframe */
+               ;
+       } else {
+               DPRINTF(("D%X%s\n", payload.size, (payload.end_of_frame) ? "S" 
: ""));
+       }
+
        video_submit_payload(vs->vs_parent->sc_videodev, &payload);
 
        return USBD_NORMAL_COMPLETION;
@@ -1811,7 +1822,7 @@ uvideo_stream_recv_isoc_complete(usbd_xf
                usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
 
                if (count == 0) {
-                       /* DPRINTF(("uvideo: zero length transfer\n")); */
+                       DPRINTF(("uvideo: zero length transfer\n"));
                        goto next;
                }
                

Attachment: signature.asc
Description: This is a digitally signed message part



Home | Main Index | Thread Index | Old Index