Greg:

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.

Alan Stern


===== drivers/usb/media/ibmcam.c 1.25 vs edited =====
--- 1.25/drivers/usb/media/ibmcam.c     Mon Aug  4 13:47:06 2003
+++ edited/drivers/usb/media/ibmcam.c   Wed Apr 21 16:32:00 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));
===== drivers/usb/media/konicawc.c 1.37 vs edited =====
--- 1.37/drivers/usb/media/konicawc.c   Mon Aug  4 13:47:06 2003
+++ edited/drivers/usb/media/konicawc.c Wed Apr 21 16:41:57 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,
===== drivers/usb/media/ov511.c 1.62 vs edited =====
--- 1.62/drivers/usb/media/ov511.c      Wed Sep  3 11:47:18 2003
+++ edited/drivers/usb/media/ov511.c    Thu Apr 22 11:40:56 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;
===== drivers/usb/media/pwc-if.c 1.49 vs edited =====
--- 1.49/drivers/usb/media/pwc-if.c     Tue Dec 30 13:25:13 2003
+++ edited/drivers/usb/media/pwc-if.c   Wed Apr 21 16:18:47 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;
 
===== drivers/usb/media/se401.c 1.53 vs edited =====
--- 1.53/drivers/usb/media/se401.c      Mon Apr  5 12:19:15 2004
+++ edited/drivers/usb/media/se401.c    Wed Apr 21 16:21:19 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 &&
===== drivers/usb/media/ultracam.c 1.20 vs edited =====
--- 1.20/drivers/usb/media/ultracam.c   Mon Jun  9 13:37:17 2003
+++ edited/drivers/usb/media/ultracam.c Wed Apr 21 16:26:45 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,
===== drivers/usb/media/vicam.c 1.62 vs edited =====
--- 1.62/drivers/usb/media/vicam.c      Fri Jan 30 01:39:05 2004
+++ edited/drivers/usb/media/vicam.c    Thu Apr 22 11:41:49 2004
@@ -1292,7 +1292,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));



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to