Commit 01a665f6 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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.
parent c72b4fbb
...@@ -3647,7 +3647,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * ...@@ -3647,7 +3647,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
{ {
struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *dev = interface_to_usbdev(intf);
struct uvd *uvd = NULL; 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; int actInterface=-1, inactInterface=-1, maxPS=0;
__u8 ifnum = intf->altsetting->desc.bInterfaceNumber; __u8 ifnum = intf->altsetting->desc.bInterfaceNumber;
unsigned char video_ep = 0; unsigned char video_ep = 0;
...@@ -3718,7 +3718,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * ...@@ -3718,7 +3718,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
} while (0); } while (0);
/* Validate found interface: must have one ISO endpoint */ /* Validate found interface: must have one ISO endpoint */
nas = dev->actconfig->interface[ifnum]->num_altsetting; nas = intf->num_altsetting;
if (debug > 0) if (debug > 0)
info("Number of alternate settings=%d.", nas); info("Number of alternate settings=%d.", nas);
if (nas < 2) { if (nas < 2) {
...@@ -3726,11 +3726,12 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * ...@@ -3726,11 +3726,12 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
return -ENODEV; return -ENODEV;
} }
/* Validate all alternate settings */ /* 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_host_interface *interface;
const struct usb_endpoint_descriptor *endpoint; 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) { if (interface->desc.bNumEndpoints != 1) {
err("Interface %d. has %u. endpoints!", err("Interface %d. has %u. endpoints!",
ifnum, (unsigned)(interface->desc.bNumEndpoints)); ifnum, (unsigned)(interface->desc.bNumEndpoints));
......
...@@ -381,9 +381,15 @@ static int konicawc_start_data(struct uvd *uvd) ...@@ -381,9 +381,15 @@ static int konicawc_start_data(struct uvd *uvd)
int i, errFlag; int i, errFlag;
struct konicawc *cam = (struct konicawc *)uvd->user_data; struct konicawc *cam = (struct konicawc *)uvd->user_data;
int pktsz; 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; pktsz = interface->endpoint[1].desc.wMaxPacketSize;
DEBUG(1, "pktsz = %d", pktsz); DEBUG(1, "pktsz = %d", pktsz);
if (!CAMERA_IS_OPERATIONAL(uvd)) { if (!CAMERA_IS_OPERATIONAL(uvd)) {
...@@ -721,7 +727,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -721,7 +727,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
{ {
struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *dev = interface_to_usbdev(intf);
struct uvd *uvd = NULL; struct uvd *uvd = NULL;
int i, nas; int ix, i, nas;
int actInterface=-1, inactInterface=-1, maxPS=0; int actInterface=-1, inactInterface=-1, maxPS=0;
unsigned char video_ep = 0; unsigned char video_ep = 0;
...@@ -741,11 +747,12 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -741,11 +747,12 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
return -ENODEV; return -ENODEV;
} }
/* Validate all alternate settings */ /* 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_host_interface *interface;
const struct usb_endpoint_descriptor *endpoint; const struct usb_endpoint_descriptor *endpoint;
interface = &intf->altsetting[i]; interface = &intf->altsetting[ix];
i = interface->desc.bAlternateSetting;
if (interface->desc.bNumEndpoints != 2) { if (interface->desc.bNumEndpoints != 2) {
err("Interface %d. has %u. endpoints!", err("Interface %d. has %u. endpoints!",
interface->desc.bInterfaceNumber, interface->desc.bInterfaceNumber,
......
...@@ -5603,8 +5603,16 @@ ov518_configure(struct usb_ov511 *ov) ...@@ -5603,8 +5603,16 @@ ov518_configure(struct usb_ov511 *ov)
if (ov->bridge == BRG_OV518) if (ov->bridge == BRG_OV518)
{ {
struct usb_interface *ifp = ov->dev->config[0].interface[0]; struct usb_interface *ifp;
__u16 mxps = ifp->altsetting[7].endpoint[0].desc.wMaxPacketSize; 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 */ /* Some OV518s have packet numbering by default, some don't */
if (mxps == 897) if (mxps == 897)
...@@ -5805,7 +5813,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -5805,7 +5813,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
if (dev->descriptor.bNumConfigurations != 1) if (dev->descriptor.bNumConfigurations != 1)
return -ENODEV; return -ENODEV;
idesc = &intf->altsetting[0].desc; idesc = &intf->cur_altsetting->desc;
if (idesc->bInterfaceClass != 0xFF) if (idesc->bInterfaceClass != 0xFF)
return -ENODEV; return -ENODEV;
......
...@@ -789,7 +789,8 @@ static int pwc_isoc_init(struct pwc_device *pdev) ...@@ -789,7 +789,8 @@ static int pwc_isoc_init(struct pwc_device *pdev)
struct urb *urb; struct urb *urb;
int i, j, ret; int i, j, ret;
struct usb_host_interface *idesc; struct usb_interface *intf;
struct usb_host_interface *idesc = NULL;
if (pdev == NULL) if (pdev == NULL)
return -EFAULT; return -EFAULT;
...@@ -801,7 +802,9 @@ static int pwc_isoc_init(struct pwc_device *pdev) ...@@ -801,7 +802,9 @@ static int pwc_isoc_init(struct pwc_device *pdev)
/* Get the current alternate interface, adjust packet size */ /* Get the current alternate interface, adjust packet size */
if (!udev->actconfig) if (!udev->actconfig)
return -EFAULT; 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) if (!idesc)
return -EFAULT; return -EFAULT;
......
...@@ -1326,7 +1326,7 @@ static int se401_probe(struct usb_interface *intf, ...@@ -1326,7 +1326,7 @@ static int se401_probe(struct usb_interface *intf,
if (dev->descriptor.bNumConfigurations != 1) if (dev->descriptor.bNumConfigurations != 1)
return -ENODEV; return -ENODEV;
interface = &intf->altsetting[0].desc; interface = &intf->cur_altsetting->desc;
/* Is it an se401? */ /* Is it an se401? */
if (dev->descriptor.idVendor == 0x03e8 && if (dev->descriptor.idVendor == 0x03e8 &&
......
...@@ -513,7 +513,7 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -513,7 +513,7 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id
{ {
struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *dev = interface_to_usbdev(intf);
struct uvd *uvd = NULL; struct uvd *uvd = NULL;
int i, nas; int ix, i, nas;
int actInterface=-1, inactInterface=-1, maxPS=0; int actInterface=-1, inactInterface=-1, maxPS=0;
unsigned char video_ep = 0; unsigned char video_ep = 0;
...@@ -540,11 +540,12 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -540,11 +540,12 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id
return -ENODEV; return -ENODEV;
} }
/* Validate all alternate settings */ /* 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_host_interface *interface;
const struct usb_endpoint_descriptor *endpoint; const struct usb_endpoint_descriptor *endpoint;
interface = &intf->altsetting[i]; interface = &intf->altsetting[ix];
i = interface->desc.bAlternateSetting;
if (interface->desc.bNumEndpoints != 1) { if (interface->desc.bNumEndpoints != 1) {
err("Interface %d. has %u. endpoints!", err("Interface %d. has %u. endpoints!",
interface->desc.bInterfaceNumber, interface->desc.bInterfaceNumber,
......
...@@ -1303,7 +1303,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id) ...@@ -1303,7 +1303,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
printk(KERN_INFO "ViCam based webcam connected\n"); 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", DBG(KERN_DEBUG "Interface %d. has %u. endpoints!\n",
interface->desc.bInterfaceNumber, (unsigned) (interface->desc.bNumEndpoints)); interface->desc.bInterfaceNumber, (unsigned) (interface->desc.bNumEndpoints));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment