summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-11-06 05:50:01 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-11-06 05:50:01 +0000
commit94aacf31922e599622b662c95ffe5fb5cccf372d (patch)
tree8a934fa0523e34ce638f1b077db4a977ef9ad028 /linux/drivers/media/video/em28xx
parent0ca5f95393da32065c0ed630d5e4d4c9c749c5c8 (diff)
downloadmediapointer-dvb-s2-94aacf31922e599622b662c95ffe5fb5cccf372d.tar.gz
mediapointer-dvb-s2-94aacf31922e599622b662c95ffe5fb5cccf372d.tar.bz2
- Fixed autodetection of max size by if alternate setting
- Fixed some debug messages Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'linux/drivers/media/video/em28xx')
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-core.c13
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c60
-rw-r--r--linux/drivers/media/video/em28xx/em28xx.h4
3 files changed, 51 insertions, 26 deletions
diff --git a/linux/drivers/media/video/em28xx/em28xx-core.c b/linux/drivers/media/video/em28xx/em28xx-core.c
index 5b71078e5..8491dbd0a 100644
--- a/linux/drivers/media/video/em28xx/em28xx-core.c
+++ b/linux/drivers/media/video/em28xx/em28xx-core.c
@@ -806,20 +806,20 @@ int em28xx_set_alternate(struct em28xx *dev)
if (dev->alt == 0) {
int i;
#if 1 /* Always try to get the maximum size value */
- 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])
dev->alt=i;
#endif
#if 0 /* Should be dependent of horizontal size */
if(dev->is_em2800){ /* always use the max packet size for em2800 based devices */
- 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])
dev->alt=i;
}else{
unsigned int min_pkt_size = dev->field_size / 137; /* FIXME: empiric magic number */
em28xx_coredbg("minimum isoc packet size: %u", min_pkt_size);
dev->alt = 7;
- for (i = 1; i < EM28XX_MAX_ALT; i += 2) /* FIXME: skip even alternate: why do they not work? */
+ for (i = 0; i < dev->num_alt; i ++)
if (dev->alt_max_pkt_size[i] >= min_pkt_size) {
dev->alt = i;
break;
@@ -830,13 +830,12 @@ int em28xx_set_alternate(struct em28xx *dev)
if (dev->alt != prev_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);
errCode = usb_set_interface(dev->udev, 0, dev->alt);
if (errCode < 0) {
- em28xx_errdev
- ("cannot change alternate number to %d (error=%i)\n",
- dev->alt, errCode);
+ em28xx_errdev ("cannot change alternate number to %d (error=%i)\n",
+ dev->alt, errCode);
return errCode;
}
}
diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c
index 1bc651269..da91cf83a 100644
--- a/linux/drivers/media/video/em28xx/em28xx-video.c
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c
@@ -53,17 +53,31 @@ MODULE_LICENSE("GPL");
static LIST_HEAD(em28xx_devlist);
-static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
-
+static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
+#if 0
+static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
+#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
MODULE_PARM(card,"1-" __stringify(EM28XX_MAXBOARDS) "i");
+#if 0
+MODULE_PARM(video_nr,"1-" __stringify(EM28XX_MAXBOARDS) "i");
+#endif
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
static int dummy;
module_param_array(card, int, dummy, 0444);
+#if 0
+module_param_array(video_nr, int, dummy, 0444);
+#endif
#else
module_param_array(card, int, NULL, 0444);
+#if 0
+module_param_array(video_nr, int, dummy, 0444);
+#endif
#endif
MODULE_PARM_DESC(card,"card type");
+#if 0
+MODULE_PARM_DESC(video_nr,"video device numbers");
+#endif
static int tuner = -1;
module_param(tuner, int, 0444);
@@ -1746,7 +1760,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
int retval = -ENOMEM;
int errCode, i;
unsigned int maxh, maxw;
- struct usb_interface *uif;
dev->udev = udev;
dev->model = model;
@@ -1806,17 +1819,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
dev->vpic.depth = 16;
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
/* request some modules */
if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
@@ -1935,6 +1937,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
{
const struct usb_endpoint_descriptor *endpoint;
struct usb_device *udev;
+ struct usb_interface *uif;
struct em28xx *dev = NULL;
int retval = -ENODEV;
int model,i,nr,ifnum;
@@ -1974,7 +1977,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
nr=interface->minor;
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;
}
@@ -1986,6 +1989,28 @@ static int em28xx_usb_probe(struct usb_interface *interface,
}
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);
if ((card[nr]>=0)&&(card[nr]<em28xx_bcount))
@@ -2055,11 +2080,12 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
up(&dev->lock);
- if (!dev->users)
+ if (!dev->users) {
+ kfree(dev->alt_max_pkt_size);
kfree(dev);
+ }
up_write(&em28xx_disconnect);
-
}
static struct usb_driver em28xx_usb_driver = {
diff --git a/linux/drivers/media/video/em28xx/em28xx.h b/linux/drivers/media/video/em28xx/em28xx.h
index e71ccea38..d6bbfb11f 100644
--- a/linux/drivers/media/video/em28xx/em28xx.h
+++ b/linux/drivers/media/video/em28xx/em28xx.h
@@ -64,7 +64,6 @@
/* default alternate; 0 means choose the best */
#define EM28XX_PINOUT 0
-#define EM28XX_MAX_ALT 7
#define EM28XX_INTERLACED_DEFAULT 1
@@ -268,7 +267,8 @@ struct em28xx {
struct usb_device *udev; /* the usb device */
int alt; /* alternate */
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 */
char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */
/* helper funcs that call usb_control_msg */