Hi Laurent,
I make some changes in your drivers to support bulk:

1. in f_uvc.c, delete uvc_streaming_intf alt1 for iso video since bulk
doesn't need alt1 :
static struct usb_interface_descriptor uvc_streaming_intf_alt0 __initdata =
{
    .bLength        = USB_DT_INTERFACE_SIZE,
    .bDescriptorType    = USB_DT_INTERFACE,
    .bInterfaceNumber   = UVC_INTF_VIDEO_STREAMING,
    .bAlternateSetting  = 0,
//  .bNumEndpoints      = 0,
    .bNumEndpoints      = 1,
    .bInterfaceClass    = USB_CLASS_VIDEO,
    .bInterfaceSubClass = 0x02,
    .bInterfaceProtocol = 0x00,
    .iInterface     = 0,
};

+/*
static struct usb_interface_descriptor uvc_streaming_intf_alt1 __initdata =
{
    .bLength        = USB_DT_INTERFACE_SIZE,
    .bDescriptorType    = USB_DT_INTERFACE,
    .bInterfaceNumber   = UVC_INTF_VIDEO_STREAMING,
    .bAlternateSetting  = 1,
    .bNumEndpoints      = 1,
    .bInterfaceClass    = USB_CLASS_VIDEO,
    .bInterfaceSubClass = 0x02,
    .bInterfaceProtocol = 0x00,
    .iInterface     = 0,
};
+*/
static struct usb_endpoint_descriptor uvc_streaming_ep = {
    .bLength        = USB_DT_ENDPOINT_SIZE,
    .bDescriptorType    = USB_DT_ENDPOINT,
    .bEndpointAddress   = USB_DIR_IN,
    .bmAttributes       = USB_ENDPOINT_XFER_BULK,
    .wMaxPacketSize     = cpu_to_le16(512),
//  .bInterval      = 1,
};

static const struct usb_descriptor_header * const uvc_fs_streaming[] = {
//  (struct usb_descriptor_header *) &uvc_streaming_intf_alt1,
    (struct usb_descriptor_header *) &uvc_streaming_ep,
    NULL,
};

static const struct usb_descriptor_header * const uvc_hs_streaming[] = {
//  (struct usb_descriptor_header *) &uvc_streaming_intf_alt1,
    (struct usb_descriptor_header *) &uvc_streaming_ep,
    NULL,
};

2.in uvc_video.c, I didn't find you have any chance to initialize
video->max_payload_size and move to bulk mode, then i added one line :
+   video->max_payload_size = 512;

    if (video->max_payload_size) {
        video->encode = uvc_video_encode_bulk;
        video->payload_size = 0;
    } else {
        video->encode = uvc_video_encode_isoc;
    }

Now windows can detect the webcam and even enable video stream, but image is
not right.

Then i need your help about the right init value for video->max_payload_size
in uvc_video.c, and point out the right value for dwMaxPayloadTransferSize in
userspace program uvc_gadget.c too:
static void
uvc_events_init(struct uvc_device *dev)
{
    struct v4l2_event_subscription sub;

    uvc_fill_streaming_control(dev, &dev->probe, 0, 0);
    uvc_fill_streaming_control(dev, &dev->commit, 0, 0);

    if (dev->bulk) {
        /* FIXME Crude hack, must be negotiated with the driver. */
        dev->probe.dwMaxPayloadTransferSize = 16 * 1024;
        dev->commit.dwMaxPayloadTransferSize = 16 * 1024;
    }

    memset(&sub, 0, sizeof sub);
    sub.type = UVC_EVENT_SETUP;
    ioctl(dev->fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
    sub.type = UVC_EVENT_DATA;
    ioctl(dev->fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
    sub.type = UVC_EVENT_STREAMON;
    ioctl(dev->fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
    sub.type = UVC_EVENT_STREAMOFF;
    ioctl(dev->fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
}

You said "FIXME Crude hack, must be negotiated with the driver", do you mean
16*1024 should be the value of video->max_payload_size in uvc_video.c?

Can you try your best to give us more information about bulk since you have
already had some bulk codes in both drivers and userspace utilities?

Thanks
Barry

On Sat, Jan 8, 2011 at 11:22 AM, Barry Song <21cn...@gmail.com> wrote:

> Hi Laurent,
> Thanks for your reply.
>
> On 1/8/11, Laurent Pinchart <laurent.pinch...@ideasonboard.com> wrote:
> > Hi Barry,
> >
> > On Wednesday 05 January 2011 07:57:46 Barry Song wrote:
> >> Hi All,
> >> Most USB device controller drivers don't support ISO endpoints,
> >
> > Really ? What controller are you talking about ?
> For example samsung S3C:
> drivers/usb/gadget/s3c-hsotg.c:
>        switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
>        case USB_ENDPOINT_XFER_ISOC:
>                dev_err(hsotg->dev, "no current ISOC support\n");
>                ret = -EINVAL;
>                goto out;
> >
> >> but BULK is almost supported by all. Has anybody changed UVC gadget to
> >> support BULK mode?
> >
> > I haven't tried bulk mode recently, but I know I got it working some time
> > ago
> > (maybe with a different code base though).
> Yes. i have tried to change ISO to BULK, but i haven't made the bulk
> mode gadget work yet. Do you still remember what you have changed? Or
> can you find the codes and share with me?
> >
> > --
> > Regards,
> >
> > Laurent Pinchart
> >
> Thanks
> Barry
>



-- 
Barry Song, Linux Kernel Developer
http://21cnbao.blog.51cto.com
_______________________________________________
Linux-uvc-devel mailing list
Linux-uvc-devel@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to