aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-11-09 00:38:52 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:31 -0500
commit9d4d9c05c807ab8a49ac0024987b223bb32c022d (patch)
tree6f2401a04654a11e2190ce610eab664693784a66 /drivers/media/video/em28xx/em28xx-video.c
parent7f7e846ca552c4cf2e04b4666cea18dc26b36b59 (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/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c45
1 files changed, 28 insertions, 17 deletions
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
54static LIST_HEAD(em28xx_devlist); 54static LIST_HEAD(em28xx_devlist);
55 55
56static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; 56static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
57
58module_param_array(card, int, NULL, 0444); 57module_param_array(card, int, NULL, 0444);
59MODULE_PARM_DESC(card,"card type"); 58MODULE_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
1886static struct usb_driver em28xx_usb_driver = { 1897static struct usb_driver em28xx_usb_driver = {