diff options
author | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2005-11-09 00:38:52 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:31 -0500 |
commit | 9d4d9c05c807ab8a49ac0024987b223bb32c022d (patch) | |
tree | 6f2401a04654a11e2190ce610eab664693784a66 /drivers/media/video/em28xx | |
parent | 7f7e846ca552c4cf2e04b4666cea18dc26b36b59 (diff) |
[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: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-core.c | 9 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 45 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx.h | 4 |
3 files changed, 34 insertions, 24 deletions
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 5cc850666fd7..d54bc0127484 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -797,20 +797,19 @@ int em28xx_set_alternate(struct em28xx *dev) | |||
797 | dev->alt = alt; | 797 | dev->alt = alt; |
798 | if (dev->alt == 0) { | 798 | if (dev->alt == 0) { |
799 | int i; | 799 | int i; |
800 | for(i=0;i< EM28XX_MAX_ALT; i++) | 800 | for(i=0;i< dev->num_alt; i++) |
801 | if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt]) | 801 | if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt]) |
802 | dev->alt=i; | 802 | dev->alt=i; |
803 | } | 803 | } |
804 | 804 | ||
805 | if (dev->alt != prev_alt) { | 805 | if (dev->alt != prev_alt) { |
806 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; | 806 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; |
807 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u", dev->alt, | 807 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", dev->alt, |
808 | dev->max_pkt_size); | 808 | dev->max_pkt_size); |
809 | errCode = usb_set_interface(dev->udev, 0, dev->alt); | 809 | errCode = usb_set_interface(dev->udev, 0, dev->alt); |
810 | if (errCode < 0) { | 810 | if (errCode < 0) { |
811 | em28xx_errdev | 811 | em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", |
812 | ("cannot change alternate number to %d (error=%i)\n", | 812 | dev->alt, errCode); |
813 | dev->alt, errCode); | ||
814 | return errCode; | 813 | return errCode; |
815 | } | 814 | } |
816 | } | 815 | } |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 0bbfce03172d..57c1826b928e 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -53,8 +53,7 @@ MODULE_LICENSE("GPL"); | |||
53 | 53 | ||
54 | static LIST_HEAD(em28xx_devlist); | 54 | static LIST_HEAD(em28xx_devlist); |
55 | 55 | ||
56 | static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 56 | static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; |
57 | |||
58 | module_param_array(card, int, NULL, 0444); | 57 | module_param_array(card, int, NULL, 0444); |
59 | MODULE_PARM_DESC(card,"card type"); | 58 | MODULE_PARM_DESC(card,"card type"); |
60 | 59 | ||
@@ -1591,7 +1590,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1591 | int retval = -ENOMEM; | 1590 | int retval = -ENOMEM; |
1592 | int errCode, i; | 1591 | int errCode, i; |
1593 | unsigned int maxh, maxw; | 1592 | unsigned int maxh, maxw; |
1594 | struct usb_interface *uif; | ||
1595 | 1593 | ||
1596 | dev->udev = udev; | 1594 | dev->udev = udev; |
1597 | dev->model = model; | 1595 | dev->model = model; |
@@ -1651,17 +1649,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1651 | dev->vpic.depth = 16; | 1649 | dev->vpic.depth = 16; |
1652 | dev->vpic.palette = VIDEO_PALETTE_YUV422; | 1650 | dev->vpic.palette = VIDEO_PALETTE_YUV422; |
1653 | 1651 | ||
1654 | /* compute alternate max packet sizes */ | ||
1655 | uif = dev->udev->actconfig->interface[0]; | ||
1656 | dev->alt_max_pkt_size[0] = 0; | ||
1657 | for (i = 1; i <= EM28XX_MAX_ALT && i < uif->num_altsetting ; i++) { | ||
1658 | u16 tmp = | ||
1659 | le16_to_cpu(uif->altsetting[i].endpoint[1].desc. | ||
1660 | wMaxPacketSize); | ||
1661 | dev->alt_max_pkt_size[i] = | ||
1662 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
1663 | } | ||
1664 | |||
1665 | #ifdef CONFIG_MODULES | 1652 | #ifdef CONFIG_MODULES |
1666 | /* request some modules */ | 1653 | /* request some modules */ |
1667 | if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114) | 1654 | if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114) |
@@ -1756,6 +1743,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
1756 | { | 1743 | { |
1757 | const struct usb_endpoint_descriptor *endpoint; | 1744 | const struct usb_endpoint_descriptor *endpoint; |
1758 | struct usb_device *udev; | 1745 | struct usb_device *udev; |
1746 | struct usb_interface *uif; | ||
1759 | struct em28xx *dev = NULL; | 1747 | struct em28xx *dev = NULL; |
1760 | int retval = -ENODEV; | 1748 | int retval = -ENODEV; |
1761 | int model,i,nr,ifnum; | 1749 | int model,i,nr,ifnum; |
@@ -1795,7 +1783,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
1795 | nr=interface->minor; | 1783 | nr=interface->minor; |
1796 | 1784 | ||
1797 | if (nr>EM28XX_MAXBOARDS) { | 1785 | if (nr>EM28XX_MAXBOARDS) { |
1798 | printk ("em28xx: Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS); | 1786 | printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS); |
1799 | return -ENOMEM; | 1787 | return -ENOMEM; |
1800 | } | 1788 | } |
1801 | 1789 | ||
@@ -1807,6 +1795,28 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
1807 | } | 1795 | } |
1808 | memset(dev, 0, sizeof(*dev)); | 1796 | memset(dev, 0, sizeof(*dev)); |
1809 | 1797 | ||
1798 | /* compute alternate max packet sizes */ | ||
1799 | uif = udev->actconfig->interface[0]; | ||
1800 | |||
1801 | dev->num_alt=uif->num_altsetting; | ||
1802 | printk(DRIVER_NAME ": Alternate settings: %i\n",dev->num_alt); | ||
1803 | // dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* | ||
1804 | dev->alt_max_pkt_size = kmalloc(32* | ||
1805 | dev->num_alt,GFP_KERNEL); | ||
1806 | if (dev->alt_max_pkt_size == NULL) { | ||
1807 | em28xx_err(DRIVER_NAME ": out of memory!\n"); | ||
1808 | return -ENOMEM; | ||
1809 | } | ||
1810 | |||
1811 | for (i = 0; i < dev->num_alt ; i++) { | ||
1812 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. | ||
1813 | wMaxPacketSize); | ||
1814 | dev->alt_max_pkt_size[i] = | ||
1815 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
1816 | printk(DRIVER_NAME ": Alternate setting %i, max size= %i\n",i, | ||
1817 | dev->alt_max_pkt_size[i]); | ||
1818 | } | ||
1819 | |||
1810 | snprintf(dev->name, 29, "em28xx #%d", nr); | 1820 | snprintf(dev->name, 29, "em28xx #%d", nr); |
1811 | 1821 | ||
1812 | if ((card[nr]>=0)&&(card[nr]<em28xx_bcount)) | 1822 | if ((card[nr]>=0)&&(card[nr]<em28xx_bcount)) |
@@ -1876,11 +1886,12 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
1876 | 1886 | ||
1877 | up(&dev->lock); | 1887 | up(&dev->lock); |
1878 | 1888 | ||
1879 | if (!dev->users) | 1889 | if (!dev->users) { |
1890 | kfree(dev->alt_max_pkt_size); | ||
1880 | kfree(dev); | 1891 | kfree(dev); |
1892 | } | ||
1881 | 1893 | ||
1882 | up_write(&em28xx_disconnect); | 1894 | up_write(&em28xx_disconnect); |
1883 | |||
1884 | } | 1895 | } |
1885 | 1896 | ||
1886 | static struct usb_driver em28xx_usb_driver = { | 1897 | static struct usb_driver em28xx_usb_driver = { |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index d51f8c63bcf9..5c7a41ce69f3 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -63,7 +63,6 @@ | |||
63 | 63 | ||
64 | /* default alternate; 0 means choose the best */ | 64 | /* default alternate; 0 means choose the best */ |
65 | #define EM28XX_PINOUT 0 | 65 | #define EM28XX_PINOUT 0 |
66 | #define EM28XX_MAX_ALT 7 | ||
67 | 66 | ||
68 | #define EM28XX_INTERLACED_DEFAULT 1 | 67 | #define EM28XX_INTERLACED_DEFAULT 1 |
69 | 68 | ||
@@ -267,7 +266,8 @@ struct em28xx { | |||
267 | struct usb_device *udev; /* the usb device */ | 266 | struct usb_device *udev; /* the usb device */ |
268 | int alt; /* alternate */ | 267 | int alt; /* alternate */ |
269 | int max_pkt_size; /* max packet size of isoc transaction */ | 268 | int max_pkt_size; /* max packet size of isoc transaction */ |
270 | unsigned int alt_max_pkt_size[EM28XX_MAX_ALT + 1]; /* array of wMaxPacketSize */ | 269 | int num_alt; /* Number of alternative settings */ |
270 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | ||
271 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ | 271 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ |
272 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ | 272 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ |
273 | /* helper funcs that call usb_control_msg */ | 273 | /* helper funcs that call usb_control_msg */ |