aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvision/usbvision-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index cfbfda47ec4f..ae5f42562c0c 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -230,7 +230,7 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
230 ctrl.value = 0; 230 ctrl.value = 0;
231 if(usbvision->user) 231 if(usbvision->user)
232 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 232 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
233 return sprintf(buf, "%d\n", ctrl.value >> 8); 233 return sprintf(buf, "%d\n", ctrl.value);
234} 234}
235static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); 235static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
236 236
@@ -243,7 +243,7 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
243 ctrl.value = 0; 243 ctrl.value = 0;
244 if(usbvision->user) 244 if(usbvision->user)
245 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 245 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
246 return sprintf(buf, "%d\n", ctrl.value >> 8); 246 return sprintf(buf, "%d\n", ctrl.value);
247} 247}
248static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); 248static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
249 249
@@ -256,7 +256,7 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
256 ctrl.value = 0; 256 ctrl.value = 0;
257 if(usbvision->user) 257 if(usbvision->user)
258 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 258 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
259 return sprintf(buf, "%d\n", ctrl.value >> 8); 259 return sprintf(buf, "%d\n", ctrl.value);
260} 260}
261static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); 261static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
262 262
@@ -269,7 +269,7 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
269 ctrl.value = 0; 269 ctrl.value = 0;
270 if(usbvision->user) 270 if(usbvision->user)
271 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 271 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
272 return sprintf(buf, "%d\n", ctrl.value >> 8); 272 return sprintf(buf, "%d\n", ctrl.value);
273} 273}
274static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); 274static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
275 275
@@ -776,8 +776,8 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
776 case VIDIOC_G_CTRL: 776 case VIDIOC_G_CTRL:
777 { 777 {
778 struct v4l2_control *ctrl = arg; 778 struct v4l2_control *ctrl = arg;
779 PDEBUG(DBG_IOCTL,"VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
780 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); 779 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl);
780 PDEBUG(DBG_IOCTL,"VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
781 return 0; 781 return 0;
782 } 782 }
783 case VIDIOC_S_CTRL: 783 case VIDIOC_S_CTRL:
@@ -1243,6 +1243,13 @@ static int usbvision_radio_open(struct inode *inode, struct file *file)
1243 } 1243 }
1244 } 1244 }
1245 1245
1246 /* Alternate interface 1 is is the biggest frame size */
1247 errCode = usbvision_set_alternate(usbvision);
1248 if (errCode < 0) {
1249 usbvision->last_error = errCode;
1250 return -EBUSY;
1251 }
1252
1246 // If so far no errors then we shall start the radio 1253 // If so far no errors then we shall start the radio
1247 usbvision->radio = 1; 1254 usbvision->radio = 1;
1248 call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type); 1255 call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type);
@@ -1274,6 +1281,11 @@ static int usbvision_radio_close(struct inode *inode, struct file *file)
1274 1281
1275 down(&usbvision->lock); 1282 down(&usbvision->lock);
1276 1283
1284 /* Set packet size to 0 */
1285 usbvision->ifaceAlt=0;
1286 errCode = usb_set_interface(usbvision->dev, usbvision->iface,
1287 usbvision->ifaceAlt);
1288
1277 usbvision_audio_off(usbvision); 1289 usbvision_audio_off(usbvision);
1278 usbvision->radio=0; 1290 usbvision->radio=0;
1279 usbvision->user--; 1291 usbvision->user--;
@@ -1765,15 +1777,17 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
1765 */ 1777 */
1766static int __devinit usbvision_probe(struct usb_interface *intf, const struct usb_device_id *devid) 1778static int __devinit usbvision_probe(struct usb_interface *intf, const struct usb_device_id *devid)
1767{ 1779{
1768 struct usb_device *dev = interface_to_usbdev(intf); 1780 struct usb_device *dev = usb_get_dev(interface_to_usbdev(intf));
1781 struct usb_interface *uif;
1769 __u8 ifnum = intf->altsetting->desc.bInterfaceNumber; 1782 __u8 ifnum = intf->altsetting->desc.bInterfaceNumber;
1770 const struct usb_host_interface *interface; 1783 const struct usb_host_interface *interface;
1771 struct usb_usbvision *usbvision = NULL; 1784 struct usb_usbvision *usbvision = NULL;
1772 const struct usb_endpoint_descriptor *endpoint; 1785 const struct usb_endpoint_descriptor *endpoint;
1773 int model; 1786 int model,i;
1774 1787
1775 PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", 1788 PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u",
1776 dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum); 1789 dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum);
1790
1777 /* Is it an USBVISION video dev? */ 1791 /* Is it an USBVISION video dev? */
1778 model = 0; 1792 model = 0;
1779 for(model = 0; usbvision_device_data[model].idVendor; model++) { 1793 for(model = 0; usbvision_device_data[model].idVendor; model++) {
@@ -1800,7 +1814,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
1800 endpoint = &interface->endpoint[1].desc; 1814 endpoint = &interface->endpoint[1].desc;
1801 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC) { 1815 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_ISOC) {
1802 err("%s: interface %d. has non-ISO endpoint!", __FUNCTION__, ifnum); 1816 err("%s: interface %d. has non-ISO endpoint!", __FUNCTION__, ifnum);
1803 err("%s: Endpoint attribures %d", __FUNCTION__, endpoint->bmAttributes); 1817 err("%s: Endpoint attributes %d", __FUNCTION__, endpoint->bmAttributes);
1804 return -ENODEV; 1818 return -ENODEV;
1805 } 1819 }
1806 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 1820 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) {
@@ -1827,6 +1841,28 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
1827 1841
1828 down(&usbvision->lock); 1842 down(&usbvision->lock);
1829 1843
1844 /* compute alternate max packet sizes */
1845 uif = dev->actconfig->interface[0];
1846
1847 usbvision->num_alt=uif->num_altsetting;
1848 PDEBUG(DBG_PROBE, "Alternate settings: %i",usbvision->num_alt);
1849 usbvision->alt_max_pkt_size = kmalloc(32*
1850 usbvision->num_alt,GFP_KERNEL);
1851 if (usbvision->alt_max_pkt_size == NULL) {
1852 err("usbvision: out of memory!\n");
1853 return -ENOMEM;
1854 }
1855
1856 for (i = 0; i < usbvision->num_alt ; i++) {
1857 u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc.
1858 wMaxPacketSize);
1859 usbvision->alt_max_pkt_size[i] =
1860 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
1861 PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i",i,
1862 usbvision->alt_max_pkt_size[i]);
1863 }
1864
1865
1830 usbvision->nr = usbvision_nr++; 1866 usbvision->nr = usbvision_nr++;
1831 1867
1832 usbvision->have_tuner = usbvision_device_data[model].Tuner; 1868 usbvision->have_tuner = usbvision_device_data[model].Tuner;
@@ -1839,8 +1875,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
1839 usbvision->DevModel = model; 1875 usbvision->DevModel = model;
1840 usbvision->remove_pending = 0; 1876 usbvision->remove_pending = 0;
1841 usbvision->iface = ifnum; 1877 usbvision->iface = ifnum;
1842 usbvision->ifaceAltInactive = 0; 1878 usbvision->ifaceAlt = 0;
1843 usbvision->ifaceAltActive = 1;
1844 usbvision->video_endp = endpoint->bEndpointAddress; 1879 usbvision->video_endp = endpoint->bEndpointAddress;
1845 usbvision->isocPacketSize = 0; 1880 usbvision->isocPacketSize = 0;
1846 usbvision->usb_bandwidth = 0; 1881 usbvision->usb_bandwidth = 0;