diff options
author | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2005-11-09 00:37:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:17 -0500 |
commit | 596d92d5128d308b5a79f21c3e72c87f5fc7e58b (patch) | |
tree | 3957529296b0765e7979f205a9dd0bce7de1eb7a /drivers/media/video/em28xx/em28xx-video.c | |
parent | 2b5200a7b19a53969db68c97d379339592ca6a4f (diff) |
[PATCH] v4l: 767: included support for em2800
- Included support for em2800.
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.c | 73 |
1 files changed, 55 insertions, 18 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 7e4114ea15f9..d3a959b9ee64 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | em2820-video.c - driver for Empia EM2820/2840 USB video capture devices | 2 | em2820-video.c - driver for Empia EM2800/EM2820/2840 USB video capture devices |
3 | 3 | ||
4 | Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> | 4 | Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> |
5 | Ludovico Cavedon <cavedon@sssup.it> | 5 | Ludovico Cavedon <cavedon@sssup.it> |
@@ -50,6 +50,11 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
50 | MODULE_DESCRIPTION(DRIVER_DESC); | 50 | MODULE_DESCRIPTION(DRIVER_DESC); |
51 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
52 | 52 | ||
53 | static unsigned int card[] = {[0 ... (EM2820_MAXBOARDS - 1)] = UNSET }; | ||
54 | |||
55 | module_param_array(card, int, NULL, 0444); | ||
56 | MODULE_PARM_DESC(card,"card type"); | ||
57 | |||
53 | static int tuner = -1; | 58 | static int tuner = -1; |
54 | module_param(tuner, int, 0444); | 59 | module_param(tuner, int, 0444); |
55 | MODULE_PARM_DESC(tuner, "tuner type"); | 60 | MODULE_PARM_DESC(tuner, "tuner type"); |
@@ -1081,7 +1086,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp, | |||
1081 | struct v4l2_cropcap *cc = arg; | 1086 | struct v4l2_cropcap *cc = arg; |
1082 | 1087 | ||
1083 | if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1088 | if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1084 | return EINVAL; | 1089 | return -EINVAL; |
1085 | cc->bounds.left = 0; | 1090 | cc->bounds.left = 0; |
1086 | cc->bounds.top = 0; | 1091 | cc->bounds.top = 0; |
1087 | cc->bounds.width = dev->width; | 1092 | cc->bounds.width = dev->width; |
@@ -1520,21 +1525,12 @@ static struct file_operations em2820_v4l_fops = { | |||
1520 | static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, | 1525 | static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, |
1521 | int minor, int model) | 1526 | int minor, int model) |
1522 | { | 1527 | { |
1523 | struct em2820 *dev; | 1528 | struct em2820 *dev = *devhandle; |
1524 | int retval = -ENOMEM; | 1529 | int retval = -ENOMEM; |
1525 | int errCode, i; | 1530 | int errCode, i; |
1526 | unsigned int maxh, maxw; | 1531 | unsigned int maxh, maxw; |
1527 | struct usb_interface *uif; | 1532 | struct usb_interface *uif; |
1528 | 1533 | ||
1529 | /* allocate memory for our device state and initialize it */ | ||
1530 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | ||
1531 | if (dev == NULL) { | ||
1532 | em2820_err(DRIVER_NAME ": out of memory!\n"); | ||
1533 | return -ENOMEM; | ||
1534 | } | ||
1535 | memset(dev, 0x00, sizeof(*dev)); | ||
1536 | |||
1537 | snprintf(dev->name, 29, "em2820 #%d", minor); | ||
1538 | dev->udev = udev; | 1534 | dev->udev = udev; |
1539 | dev->model = model; | 1535 | dev->model = model; |
1540 | init_MUTEX(&dev->lock); | 1536 | init_MUTEX(&dev->lock); |
@@ -1545,6 +1541,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, | |||
1545 | dev->em2820_read_reg_req_len = em2820_read_reg_req_len; | 1541 | dev->em2820_read_reg_req_len = em2820_read_reg_req_len; |
1546 | dev->em2820_write_regs_req = em2820_write_regs_req; | 1542 | dev->em2820_write_regs_req = em2820_write_regs_req; |
1547 | dev->em2820_read_reg_req = em2820_read_reg_req; | 1543 | dev->em2820_read_reg_req = em2820_read_reg_req; |
1544 | dev->is_em2800 = em2820_boards[model].is_em2800; | ||
1548 | dev->has_tuner = em2820_boards[model].has_tuner; | 1545 | dev->has_tuner = em2820_boards[model].has_tuner; |
1549 | dev->has_msp34xx = em2820_boards[model].has_msp34xx; | 1546 | dev->has_msp34xx = em2820_boards[model].has_msp34xx; |
1550 | dev->tda9887_conf = em2820_boards[model].tda9887_conf; | 1547 | dev->tda9887_conf = em2820_boards[model].tda9887_conf; |
@@ -1595,7 +1592,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, | |||
1595 | /* compute alternate max packet sizes */ | 1592 | /* compute alternate max packet sizes */ |
1596 | uif = dev->udev->actconfig->interface[0]; | 1593 | uif = dev->udev->actconfig->interface[0]; |
1597 | dev->alt_max_pkt_size[0] = 0; | 1594 | dev->alt_max_pkt_size[0] = 0; |
1598 | for (i = 1; i <= EM2820_MAX_ALT; i++) { | 1595 | for (i = 1; i <= EM2820_MAX_ALT && i < uif->num_altsetting ; i++) { |
1599 | u16 tmp = | 1596 | u16 tmp = |
1600 | le16_to_cpu(uif->altsetting[i].endpoint[1].desc. | 1597 | le16_to_cpu(uif->altsetting[i].endpoint[1].desc. |
1601 | wMaxPacketSize); | 1598 | wMaxPacketSize); |
@@ -1688,7 +1685,6 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, | |||
1688 | em2820_info("V4L2 device registered as /dev/video%d\n", | 1685 | em2820_info("V4L2 device registered as /dev/video%d\n", |
1689 | dev->vdev->minor); | 1686 | dev->vdev->minor); |
1690 | 1687 | ||
1691 | *devhandle = dev; | ||
1692 | return 0; | 1688 | return 0; |
1693 | } | 1689 | } |
1694 | 1690 | ||
@@ -1703,27 +1699,68 @@ static int em2820_usb_probe(struct usb_interface *interface, | |||
1703 | struct usb_device *udev; | 1699 | struct usb_device *udev; |
1704 | struct em2820 *dev = NULL; | 1700 | struct em2820 *dev = NULL; |
1705 | int retval = -ENODEV; | 1701 | int retval = -ENODEV; |
1702 | int model,i,nr; | ||
1706 | 1703 | ||
1707 | udev = usb_get_dev(interface_to_usbdev(interface)); | 1704 | udev = usb_get_dev(interface_to_usbdev(interface)); |
1708 | endpoint = &interface->cur_altsetting->endpoint[1].desc; | 1705 | endpoint = &interface->cur_altsetting->endpoint[1].desc; |
1709 | 1706 | ||
1707 | /* Don't register audio interfaces */ | ||
1708 | if (interface->altsetting[1].desc.bInterfaceClass == USB_CLASS_AUDIO) | ||
1709 | return -ENODEV; | ||
1710 | |||
1710 | /* check if the the device has the iso in endpoint at the correct place */ | 1711 | /* check if the the device has the iso in endpoint at the correct place */ |
1711 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != | 1712 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != |
1712 | USB_ENDPOINT_XFER_ISOC) { | 1713 | USB_ENDPOINT_XFER_ISOC) { |
1713 | /* em2820_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); */ | 1714 | em2820_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); |
1714 | return -ENODEV; | 1715 | return -ENODEV; |
1715 | } | 1716 | } |
1716 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { | 1717 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { |
1717 | /* em2820_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); */ | 1718 | em2820_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); |
1718 | return -ENODEV; | 1719 | return -ENODEV; |
1719 | } | 1720 | } |
1720 | 1721 | ||
1722 | model=id->driver_info; | ||
1723 | nr=interface->minor; | ||
1724 | |||
1725 | if (nr>EM2820_MAXBOARDS) { | ||
1726 | printk ("em2820: Supports only %i em28xx boards.\n",EM2820_MAXBOARDS); | ||
1727 | return -ENOMEM; | ||
1728 | } | ||
1729 | |||
1730 | /* allocate memory for our device state and initialize it */ | ||
1731 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | ||
1732 | if (dev == NULL) { | ||
1733 | em2820_err(DRIVER_NAME ": out of memory!\n"); | ||
1734 | return -ENOMEM; | ||
1735 | } | ||
1736 | memset(dev, 0, sizeof(*dev)); | ||
1737 | |||
1738 | snprintf(dev->name, 29, "em2820 #%d", nr); | ||
1739 | |||
1740 | if ((card[nr]>=0)&&(card[nr]<em2820_bcount)) | ||
1741 | model=card[nr]; | ||
1742 | |||
1743 | if ((model==EM2800_BOARD_UNKNOWN)||(model==EM2820_BOARD_UNKNOWN)) { | ||
1744 | printk( "%s: Your board has no eeprom inside it and thus can't\n" | ||
1745 | "%s: be autodetected. Please pass card=<n> insmod option to\n" | ||
1746 | "%s: workaround that. Redirect complaints to the vendor of\n" | ||
1747 | "%s: the TV card. Best regards,\n" | ||
1748 | "%s: -- tux\n", | ||
1749 | dev->name,dev->name,dev->name,dev->name,dev->name); | ||
1750 | printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", | ||
1751 | dev->name); | ||
1752 | for (i = 0; i < em2820_bcount; i++) { | ||
1753 | printk("%s: card=%d -> %s\n", | ||
1754 | dev->name, i, em2820_boards[i].name); | ||
1755 | } | ||
1756 | } | ||
1757 | |||
1721 | /* allocate device struct */ | 1758 | /* allocate device struct */ |
1722 | retval = em2820_init_dev(&dev, udev, interface->minor, id->driver_info); | 1759 | retval = em2820_init_dev(&dev, udev, nr, model); |
1723 | if (retval) | 1760 | if (retval) |
1724 | return retval; | 1761 | return retval; |
1725 | 1762 | ||
1726 | em2820_info("Found %s\n", em2820_boards[id->driver_info].name); | 1763 | em2820_info("Found %s\n", em2820_boards[model].name); |
1727 | 1764 | ||
1728 | /* save our data pointer in this interface device */ | 1765 | /* save our data pointer in this interface device */ |
1729 | usb_set_intfdata(interface, dev); | 1766 | usb_set_intfdata(interface, dev); |