ChangeSet 1.1371.759.22, 2004/04/23 16:40:35-07:00, stern@rowland.harvard.edu [PATCH] USB: Altsetting updates for USB media drivers This patch implements the new altsetting regime for the drivers under usb/media. Not much needed to be changed. I'm unable to test any of the changes, but at least they compile all right (except that I didn't even try to compile the pwc driver since it's marked BROKEN). The stv680 and w9968cf drivers still include an assumption that they are bound to interface number 0. Since that the drivers are fairly tightly linked to a specific kind of device I didn't try to change those assumptions, but maybe they should be changed. drivers/usb/media/ibmcam.c | 9 +++++---- drivers/usb/media/konicawc.c | 17 ++++++++++++----- drivers/usb/media/ov511.c | 14 +++++++++++--- drivers/usb/media/pwc-if.c | 7 +++++-- drivers/usb/media/se401.c | 2 +- drivers/usb/media/ultracam.c | 7 ++++--- drivers/usb/media/vicam.c | 2 +- 7 files changed, 39 insertions(+), 19 deletions(-) diff -Nru a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c --- a/drivers/usb/media/ibmcam.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/ibmcam.c Fri May 14 15:33:06 2004 @@ -3647,7 +3647,7 @@ { struct usb_device *dev = interface_to_usbdev(intf); struct uvd *uvd = NULL; - int i, nas, model=0, canvasX=0, canvasY=0; + int ix, i, nas, model=0, canvasX=0, canvasY=0; int actInterface=-1, inactInterface=-1, maxPS=0; __u8 ifnum = intf->altsetting->desc.bInterfaceNumber; unsigned char video_ep = 0; @@ -3718,7 +3718,7 @@ } while (0); /* Validate found interface: must have one ISO endpoint */ - nas = dev->actconfig->interface[ifnum]->num_altsetting; + nas = intf->num_altsetting; if (debug > 0) info("Number of alternate settings=%d.", nas); if (nas < 2) { @@ -3726,11 +3726,12 @@ return -ENODEV; } /* Validate all alternate settings */ - for (i=0; i < nas; i++) { + for (ix=0; ix < nas; ix++) { const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; - interface = &dev->actconfig->interface[ifnum]->altsetting[i]; + interface = &intf->altsetting[ix]; + i = interface->desc.bAlternateSetting; if (interface->desc.bNumEndpoints != 1) { err("Interface %d. has %u. endpoints!", ifnum, (unsigned)(interface->desc.bNumEndpoints)); diff -Nru a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c --- a/drivers/usb/media/konicawc.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/konicawc.c Fri May 14 15:33:06 2004 @@ -381,9 +381,15 @@ int i, errFlag; struct konicawc *cam = (struct konicawc *)uvd->user_data; int pktsz; - struct usb_host_interface *interface; + struct usb_interface *intf; + struct usb_host_interface *interface = NULL; - interface = &dev->actconfig->interface[uvd->iface]->altsetting[spd_to_iface[cam->speed]]; + intf = usb_ifnum_to_if(dev, uvd->iface); + if (intf) + interface = usb_altnum_to_altsetting(intf, + spd_to_iface[cam->speed]); + if (!interface) + return -ENXIO; pktsz = interface->endpoint[1].desc.wMaxPacketSize; DEBUG(1, "pktsz = %d", pktsz); if (!CAMERA_IS_OPERATIONAL(uvd)) { @@ -721,7 +727,7 @@ { struct usb_device *dev = interface_to_usbdev(intf); struct uvd *uvd = NULL; - int i, nas; + int ix, i, nas; int actInterface=-1, inactInterface=-1, maxPS=0; unsigned char video_ep = 0; @@ -741,11 +747,12 @@ return -ENODEV; } /* Validate all alternate settings */ - for (i=0; i < nas; i++) { + for (ix=0; ix < nas; ix++) { const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; - interface = &intf->altsetting[i]; + interface = &intf->altsetting[ix]; + i = interface->desc.bAlternateSetting; if (interface->desc.bNumEndpoints != 2) { err("Interface %d. has %u. endpoints!", interface->desc.bInterfaceNumber, diff -Nru a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c --- a/drivers/usb/media/ov511.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/ov511.c Fri May 14 15:33:06 2004 @@ -5603,8 +5603,16 @@ if (ov->bridge == BRG_OV518) { - struct usb_interface *ifp = ov->dev->config[0].interface[0]; - __u16 mxps = ifp->altsetting[7].endpoint[0].desc.wMaxPacketSize; + struct usb_interface *ifp; + struct usb_host_interface *alt; + __u16 mxps = 0; + + ifp = usb_ifnum_to_if(ov->dev, 0); + if (ifp) { + alt = usb_altnum_to_altsetting(ifp, 7); + if (alt) + mxps = alt->endpoint[0].desc.wMaxPacketSize; + } /* Some OV518s have packet numbering by default, some don't */ if (mxps == 897) @@ -5805,7 +5813,7 @@ if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - idesc = &intf->altsetting[0].desc; + idesc = &intf->cur_altsetting->desc; if (idesc->bInterfaceClass != 0xFF) return -ENODEV; diff -Nru a/drivers/usb/media/pwc-if.c b/drivers/usb/media/pwc-if.c --- a/drivers/usb/media/pwc-if.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/pwc-if.c Fri May 14 15:33:06 2004 @@ -789,7 +789,8 @@ struct urb *urb; int i, j, ret; - struct usb_host_interface *idesc; + struct usb_interface *intf; + struct usb_host_interface *idesc = NULL; if (pdev == NULL) return -EFAULT; @@ -801,7 +802,9 @@ /* Get the current alternate interface, adjust packet size */ if (!udev->actconfig) return -EFAULT; - idesc = &udev->actconfig->interface[0]->altsetting[pdev->valternate]; + intf = usb_ifnum_to_if(udev, 0); + if (intf) + idesc = usb_altnum_to_altsetting(intf, pdev->valternate); if (!idesc) return -EFAULT; diff -Nru a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c --- a/drivers/usb/media/se401.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/se401.c Fri May 14 15:33:06 2004 @@ -1326,7 +1326,7 @@ if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - interface = &intf->altsetting[0].desc; + interface = &intf->cur_altsetting->desc; /* Is it an se401? */ if (dev->descriptor.idVendor == 0x03e8 && diff -Nru a/drivers/usb/media/ultracam.c b/drivers/usb/media/ultracam.c --- a/drivers/usb/media/ultracam.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/ultracam.c Fri May 14 15:33:06 2004 @@ -513,7 +513,7 @@ { struct usb_device *dev = interface_to_usbdev(intf); struct uvd *uvd = NULL; - int i, nas; + int ix, i, nas; int actInterface=-1, inactInterface=-1, maxPS=0; unsigned char video_ep = 0; @@ -540,11 +540,12 @@ return -ENODEV; } /* Validate all alternate settings */ - for (i=0; i < nas; i++) { + for (ix=0; ix < nas; ix++) { const struct usb_host_interface *interface; const struct usb_endpoint_descriptor *endpoint; - interface = &intf->altsetting[i]; + interface = &intf->altsetting[ix]; + i = interface->desc.bAlternateSetting; if (interface->desc.bNumEndpoints != 1) { err("Interface %d. has %u. endpoints!", interface->desc.bInterfaceNumber, diff -Nru a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c --- a/drivers/usb/media/vicam.c Fri May 14 15:33:06 2004 +++ b/drivers/usb/media/vicam.c Fri May 14 15:33:06 2004 @@ -1303,7 +1303,7 @@ printk(KERN_INFO "ViCam based webcam connected\n"); - interface = &intf->altsetting[0]; + interface = intf->cur_altsetting; DBG(KERN_DEBUG "Interface %d. has %u. endpoints!\n", interface->desc.bInterfaceNumber, (unsigned) (interface->desc.bNumEndpoints));