Commit 9d4d9c05 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Linus Torvalds

[PATCH] V4L: 920: fixed autodetection of max size by if alternate setting

- Fixed autodetection of max size by if alternate setting
- Fixed some debug messages
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7f7e846c
...@@ -797,19 +797,18 @@ int em28xx_set_alternate(struct em28xx *dev) ...@@ -797,19 +797,18 @@ int em28xx_set_alternate(struct em28xx *dev)
dev->alt = alt; dev->alt = alt;
if (dev->alt == 0) { if (dev->alt == 0) {
int i; int i;
for(i=0;i< EM28XX_MAX_ALT; i++) for(i=0;i< dev->num_alt; i++)
if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt]) if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt])
dev->alt=i; dev->alt=i;
} }
if (dev->alt != prev_alt) { if (dev->alt != prev_alt) {
dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt];
em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u", dev->alt, em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", dev->alt,
dev->max_pkt_size); dev->max_pkt_size);
errCode = usb_set_interface(dev->udev, 0, dev->alt); errCode = usb_set_interface(dev->udev, 0, dev->alt);
if (errCode < 0) { if (errCode < 0) {
em28xx_errdev em28xx_errdev ("cannot change alternate number to %d (error=%i)\n",
("cannot change alternate number to %d (error=%i)\n",
dev->alt, errCode); dev->alt, errCode);
return errCode; return errCode;
} }
......
...@@ -54,7 +54,6 @@ MODULE_LICENSE("GPL"); ...@@ -54,7 +54,6 @@ MODULE_LICENSE("GPL");
static LIST_HEAD(em28xx_devlist); static LIST_HEAD(em28xx_devlist);
static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
module_param_array(card, int, NULL, 0444); module_param_array(card, int, NULL, 0444);
MODULE_PARM_DESC(card,"card type"); MODULE_PARM_DESC(card,"card type");
...@@ -1591,7 +1590,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, ...@@ -1591,7 +1590,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
int retval = -ENOMEM; int retval = -ENOMEM;
int errCode, i; int errCode, i;
unsigned int maxh, maxw; unsigned int maxh, maxw;
struct usb_interface *uif;
dev->udev = udev; dev->udev = udev;
dev->model = model; dev->model = model;
...@@ -1651,17 +1649,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, ...@@ -1651,17 +1649,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
dev->vpic.depth = 16; dev->vpic.depth = 16;
dev->vpic.palette = VIDEO_PALETTE_YUV422; dev->vpic.palette = VIDEO_PALETTE_YUV422;
/* compute alternate max packet sizes */
uif = dev->udev->actconfig->interface[0];
dev->alt_max_pkt_size[0] = 0;
for (i = 1; i <= EM28XX_MAX_ALT && i < uif->num_altsetting ; i++) {
u16 tmp =
le16_to_cpu(uif->altsetting[i].endpoint[1].desc.
wMaxPacketSize);
dev->alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
}
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
/* request some modules */ /* request some modules */
if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114) if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
...@@ -1756,6 +1743,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -1756,6 +1743,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
{ {
const struct usb_endpoint_descriptor *endpoint; const struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev; struct usb_device *udev;
struct usb_interface *uif;
struct em28xx *dev = NULL; struct em28xx *dev = NULL;
int retval = -ENODEV; int retval = -ENODEV;
int model,i,nr,ifnum; int model,i,nr,ifnum;
...@@ -1795,7 +1783,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -1795,7 +1783,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
nr=interface->minor; nr=interface->minor;
if (nr>EM28XX_MAXBOARDS) { if (nr>EM28XX_MAXBOARDS) {
printk ("em28xx: Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS); printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1807,6 +1795,28 @@ static int em28xx_usb_probe(struct usb_interface *interface, ...@@ -1807,6 +1795,28 @@ static int em28xx_usb_probe(struct usb_interface *interface,
} }
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));
/* compute alternate max packet sizes */
uif = udev->actconfig->interface[0];
dev->num_alt=uif->num_altsetting;
printk(DRIVER_NAME ": Alternate settings: %i\n",dev->num_alt);
// dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)*
dev->alt_max_pkt_size = kmalloc(32*
dev->num_alt,GFP_KERNEL);
if (dev->alt_max_pkt_size == NULL) {
em28xx_err(DRIVER_NAME ": out of memory!\n");
return -ENOMEM;
}
for (i = 0; i < dev->num_alt ; i++) {
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc.
wMaxPacketSize);
dev->alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
printk(DRIVER_NAME ": Alternate setting %i, max size= %i\n",i,
dev->alt_max_pkt_size[i]);
}
snprintf(dev->name, 29, "em28xx #%d", nr); snprintf(dev->name, 29, "em28xx #%d", nr);
if ((card[nr]>=0)&&(card[nr]<em28xx_bcount)) if ((card[nr]>=0)&&(card[nr]<em28xx_bcount))
...@@ -1876,11 +1886,12 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) ...@@ -1876,11 +1886,12 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
up(&dev->lock); up(&dev->lock);
if (!dev->users) if (!dev->users) {
kfree(dev->alt_max_pkt_size);
kfree(dev); kfree(dev);
}
up_write(&em28xx_disconnect); up_write(&em28xx_disconnect);
} }
static struct usb_driver em28xx_usb_driver = { static struct usb_driver em28xx_usb_driver = {
......
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
/* default alternate; 0 means choose the best */ /* default alternate; 0 means choose the best */
#define EM28XX_PINOUT 0 #define EM28XX_PINOUT 0
#define EM28XX_MAX_ALT 7
#define EM28XX_INTERLACED_DEFAULT 1 #define EM28XX_INTERLACED_DEFAULT 1
...@@ -267,7 +266,8 @@ struct em28xx { ...@@ -267,7 +266,8 @@ struct em28xx {
struct usb_device *udev; /* the usb device */ struct usb_device *udev; /* the usb device */
int alt; /* alternate */ int alt; /* alternate */
int max_pkt_size; /* max packet size of isoc transaction */ int max_pkt_size; /* max packet size of isoc transaction */
unsigned int alt_max_pkt_size[EM28XX_MAX_ALT + 1]; /* array of wMaxPacketSize */ int num_alt; /* Number of alternative settings */
unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */
char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */
/* helper funcs that call usb_control_msg */ /* helper funcs that call usb_control_msg */
......
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