aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorDouglas Schilling Landgraf <dougsland@gmail.com>2008-04-17 20:41:10 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:41 -0400
commit6ea54d938b6f81baa0952a8b15d3e67e6c268b8f (patch)
tree3cda23563cf6f6f05927b7f7c61eaa6605a0e10d /drivers/media/video/em28xx/em28xx-video.c
parente6a353b0dc2686ae04805919e7a22430d2f1e29e (diff)
V4L/DVB (7607): CodingStyle fixes
Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c103
1 files changed, 58 insertions, 45 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index ffbc91f2ecbd..1ac90322d681 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1,5 +1,6 @@
1/* 1/*
2 em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB video capture devices 2 em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB
3 video capture devices
3 4
4 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> 5 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5 Markus Rechberger <mrechberger@gmail.com> 6 Markus Rechberger <mrechberger@gmail.com>
@@ -58,10 +59,13 @@ static unsigned int isoc_debug;
58module_param(isoc_debug, int, 0644); 59module_param(isoc_debug, int, 0644);
59MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]"); 60MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]");
60 61
61#define em28xx_isocdbg(fmt, arg...) do {\ 62#define em28xx_isocdbg(fmt, arg...) \
62 if (isoc_debug) \ 63do {\
64 if (isoc_debug) { \
63 printk(KERN_INFO "%s %s :"fmt, \ 65 printk(KERN_INFO "%s %s :"fmt, \
64 dev->name, __func__ , ##arg); } while (0) 66 dev->name, __func__ , ##arg); \
67 } \
68 } while (0)
65 69
66MODULE_AUTHOR(DRIVER_AUTHOR); 70MODULE_AUTHOR(DRIVER_AUTHOR);
67MODULE_DESCRIPTION(DRIVER_DESC); 71MODULE_DESCRIPTION(DRIVER_DESC);
@@ -84,8 +88,8 @@ MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
84MODULE_PARM_DESC(radio_nr, "radio device numbers"); 88MODULE_PARM_DESC(radio_nr, "radio device numbers");
85 89
86static unsigned int video_debug; 90static unsigned int video_debug;
87module_param(video_debug,int,0644); 91module_param(video_debug, int, 0644);
88MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); 92MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
89 93
90/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */ 94/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */
91static unsigned long em28xx_devused; 95static unsigned long em28xx_devused;
@@ -102,7 +106,7 @@ static struct v4l2_queryctrl em28xx_qctrl[] = {
102 .step = 0x1, 106 .step = 0x1,
103 .default_value = 0x1f, 107 .default_value = 0x1f,
104 .flags = 0, 108 .flags = 0,
105 },{ 109 }, {
106 .id = V4L2_CID_AUDIO_MUTE, 110 .id = V4L2_CID_AUDIO_MUTE,
107 .type = V4L2_CTRL_TYPE_BOOLEAN, 111 .type = V4L2_CTRL_TYPE_BOOLEAN,
108 .name = "Mute", 112 .name = "Mute",
@@ -390,7 +394,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
390 dev->mode = EM28XX_ANALOG_MODE; 394 dev->mode = EM28XX_ANALOG_MODE;
391 395
392 /* Ask tuner to go to analog mode */ 396 /* Ask tuner to go to analog mode */
393 memset (&f, 0, sizeof(f)); 397 memset(&f, 0, sizeof(f));
394 f.frequency = dev->ctl_freq; 398 f.frequency = dev->ctl_freq;
395 399
396 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); 400 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
@@ -483,7 +487,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
483 487
484} 488}
485 489
486static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb) 490static void buffer_release(struct videobuf_queue *vq,
491 struct videobuf_buffer *vb)
487{ 492{
488 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); 493 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb);
489 struct em28xx_fh *fh = vq->priv_data; 494 struct em28xx_fh *fh = vq->priv_data;
@@ -501,7 +506,7 @@ static struct videobuf_queue_ops em28xx_video_qops = {
501 .buf_release = buffer_release, 506 .buf_release = buffer_release,
502}; 507};
503 508
504/********************* v4l2 interface ******************************************/ 509/********************* v4l2 interface **************************************/
505 510
506/* 511/*
507 * em28xx_config() 512 * em28xx_config()
@@ -516,9 +521,9 @@ static int em28xx_config(struct em28xx *dev)
516 521
517 /* enable vbi capturing */ 522 /* enable vbi capturing */
518 523
519/* em28xx_write_regs_req(dev,0x00,0x0e,"\xC0",1); audio register */ 524/* em28xx_write_regs_req(dev, 0x00, 0x0e, "\xC0", 1); audio register */
520/* em28xx_write_regs_req(dev,0x00,0x0f,"\x80",1); clk register */ 525/* em28xx_write_regs_req(dev, 0x00, 0x0f, "\x80", 1); clk register */
521 em28xx_write_regs_req(dev,0x00,0x11,"\x51",1); 526 em28xx_write_regs_req(dev, 0x00, 0x11, "\x51", 1);
522 527
523 dev->mute = 1; /* maybe not the right place... */ 528 dev->mute = 1; /* maybe not the right place... */
524 dev->volume = 0x1f; 529 dev->volume = 0x1f;
@@ -557,12 +562,15 @@ static void video_mux(struct em28xx *dev, int index)
557 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 562 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
558 563
559 if (dev->has_msp34xx) { 564 if (dev->has_msp34xx) {
560 if (dev->i2s_speed) 565 if (dev->i2s_speed) {
561 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); 566 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ,
567 &dev->i2s_speed);
568 }
562 route.input = dev->ctl_ainput; 569 route.input = dev->ctl_ainput;
563 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); 570 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
564 /* Note: this is msp3400 specific */ 571 /* Note: this is msp3400 specific */
565 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); 572 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING,
573 &route);
566 } 574 }
567 575
568 em28xx_audio_analog_set(dev); 576 em28xx_audio_analog_set(dev);
@@ -802,7 +810,7 @@ out:
802 return rc; 810 return rc;
803} 811}
804 812
805static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) 813static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
806{ 814{
807 struct em28xx_fh *fh = priv; 815 struct em28xx_fh *fh = priv;
808 struct em28xx *dev = fh->dev; 816 struct em28xx *dev = fh->dev;
@@ -919,11 +927,11 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
919 927
920 index = dev->ctl_ainput; 928 index = dev->ctl_ainput;
921 929
922 if (index == 0) { 930 if (index == 0)
923 strcpy(a->name, "Television"); 931 strcpy(a->name, "Television");
924 } else { 932 else
925 strcpy(a->name, "Line In"); 933 strcpy(a->name, "Line In");
926 } 934
927 a->capability = V4L2_AUDCAP_STEREO; 935 a->capability = V4L2_AUDCAP_STEREO;
928 a->index = index; 936 a->index = index;
929 937
@@ -1501,7 +1509,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1501{ 1509{
1502 int minor = iminor(inode); 1510 int minor = iminor(inode);
1503 int errCode = 0, radio = 0; 1511 int errCode = 0, radio = 0;
1504 struct em28xx *h,*dev = NULL; 1512 struct em28xx *h, *dev = NULL;
1505 struct em28xx_fh *fh; 1513 struct em28xx_fh *fh;
1506 enum v4l2_buf_type fh_type = 0; 1514 enum v4l2_buf_type fh_type = 0;
1507 1515
@@ -1602,12 +1610,13 @@ static void em28xx_release_resources(struct em28xx *dev)
1602 usb_put_dev(dev->udev); 1610 usb_put_dev(dev->udev);
1603 1611
1604 /* Mark device as unused */ 1612 /* Mark device as unused */
1605 em28xx_devused&=~(1<<dev->devno); 1613 em28xx_devused &= ~(1<<dev->devno);
1606} 1614}
1607 1615
1608/* 1616/*
1609 * em28xx_v4l2_close() 1617 * em28xx_v4l2_close()
1610 * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls 1618 * stops streaming and deallocates all resources allocated by the v4l2
1619 * calls and ioctls
1611 */ 1620 */
1612static int em28xx_v4l2_close(struct inode *inode, struct file *filp) 1621static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
1613{ 1622{
@@ -1660,7 +1669,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
1660 * will allocate buffers when called for the first time 1669 * will allocate buffers when called for the first time
1661 */ 1670 */
1662static ssize_t 1671static ssize_t
1663em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, 1672em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
1664 loff_t *pos) 1673 loff_t *pos)
1665{ 1674{
1666 struct em28xx_fh *fh = filp->private_data; 1675 struct em28xx_fh *fh = filp->private_data;
@@ -1825,7 +1834,7 @@ static struct video_device em28xx_radio_template = {
1825#endif 1834#endif
1826}; 1835};
1827 1836
1828/******************************** usb interface *****************************************/ 1837/******************************** usb interface ******************************/
1829 1838
1830 1839
1831static LIST_HEAD(em28xx_extension_devlist); 1840static LIST_HEAD(em28xx_extension_devlist);
@@ -2088,22 +2097,24 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2088 ifnum = interface->altsetting[0].desc.bInterfaceNumber; 2097 ifnum = interface->altsetting[0].desc.bInterfaceNumber;
2089 2098
2090 /* Check to see next free device and mark as used */ 2099 /* Check to see next free device and mark as used */
2091 nr=find_first_zero_bit(&em28xx_devused,EM28XX_MAXBOARDS); 2100 nr = find_first_zero_bit(&em28xx_devused, EM28XX_MAXBOARDS);
2092 em28xx_devused|=1<<nr; 2101 em28xx_devused |= 1<<nr;
2093 2102
2094 /* Don't register audio interfaces */ 2103 /* Don't register audio interfaces */
2095 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 2104 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
2096 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n", 2105 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n",
2097 udev->descriptor.idVendor,udev->descriptor.idProduct, 2106 udev->descriptor.idVendor,
2107 udev->descriptor.idProduct,
2098 ifnum, 2108 ifnum,
2099 interface->altsetting[0].desc.bInterfaceClass); 2109 interface->altsetting[0].desc.bInterfaceClass);
2100 2110
2101 em28xx_devused&=~(1<<nr); 2111 em28xx_devused &= ~(1<<nr);
2102 return -ENODEV; 2112 return -ENODEV;
2103 } 2113 }
2104 2114
2105 em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n", 2115 em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n",
2106 udev->descriptor.idVendor,udev->descriptor.idProduct, 2116 udev->descriptor.idVendor,
2117 udev->descriptor.idProduct,
2107 ifnum, 2118 ifnum,
2108 interface->altsetting[0].desc.bInterfaceClass); 2119 interface->altsetting[0].desc.bInterfaceClass);
2109 2120
@@ -2113,18 +2124,19 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2113 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != 2124 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
2114 USB_ENDPOINT_XFER_ISOC) { 2125 USB_ENDPOINT_XFER_ISOC) {
2115 em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); 2126 em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n");
2116 em28xx_devused&=~(1<<nr); 2127 em28xx_devused &= ~(1<<nr);
2117 return -ENODEV; 2128 return -ENODEV;
2118 } 2129 }
2119 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 2130 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) {
2120 em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); 2131 em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n");
2121 em28xx_devused&=~(1<<nr); 2132 em28xx_devused &= ~(1<<nr);
2122 return -ENODEV; 2133 return -ENODEV;
2123 } 2134 }
2124 2135
2125 if (nr >= EM28XX_MAXBOARDS) { 2136 if (nr >= EM28XX_MAXBOARDS) {
2126 printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS); 2137 printk(DRIVER_NAME ": Supports only %i em28xx boards.\n",
2127 em28xx_devused&=~(1<<nr); 2138 EM28XX_MAXBOARDS);
2139 em28xx_devused &= ~(1<<nr);
2128 return -ENOMEM; 2140 return -ENOMEM;
2129 } 2141 }
2130 2142
@@ -2132,7 +2144,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2132 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 2144 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2133 if (dev == NULL) { 2145 if (dev == NULL) {
2134 em28xx_err(DRIVER_NAME ": out of memory!\n"); 2146 em28xx_err(DRIVER_NAME ": out of memory!\n");
2135 em28xx_devused&=~(1<<nr); 2147 em28xx_devused &= ~(1<<nr);
2136 return -ENOMEM; 2148 return -ENOMEM;
2137 } 2149 }
2138 2150
@@ -2156,14 +2168,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2156 /* compute alternate max packet sizes */ 2168 /* compute alternate max packet sizes */
2157 uif = udev->actconfig->interface[0]; 2169 uif = udev->actconfig->interface[0];
2158 2170
2159 dev->num_alt=uif->num_altsetting; 2171 dev->num_alt = uif->num_altsetting;
2160 em28xx_info("Alternate settings: %i\n",dev->num_alt); 2172 em28xx_info("Alternate settings: %i\n", dev->num_alt);
2161// dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* 2173/* dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* */
2162 dev->alt_max_pkt_size = kmalloc(32* 2174 dev->alt_max_pkt_size = kmalloc(32 * dev->num_alt, GFP_KERNEL);
2163 dev->num_alt,GFP_KERNEL); 2175
2164 if (dev->alt_max_pkt_size == NULL) { 2176 if (dev->alt_max_pkt_size == NULL) {
2165 em28xx_errdev("out of memory!\n"); 2177 em28xx_errdev("out of memory!\n");
2166 em28xx_devused&=~(1<<nr); 2178 em28xx_devused &= ~(1<<nr);
2167 kfree(dev); 2179 kfree(dev);
2168 return -ENOMEM; 2180 return -ENOMEM;
2169 } 2181 }
@@ -2173,11 +2185,11 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2173 wMaxPacketSize); 2185 wMaxPacketSize);
2174 dev->alt_max_pkt_size[i] = 2186 dev->alt_max_pkt_size[i] =
2175 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); 2187 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
2176 em28xx_info("Alternate setting %i, max size= %i\n",i, 2188 em28xx_info("Alternate setting %i, max size= %i\n", i,
2177 dev->alt_max_pkt_size[i]); 2189 dev->alt_max_pkt_size[i]);
2178 } 2190 }
2179 2191
2180 if ((card[nr]>=0)&&(card[nr]<em28xx_bcount)) 2192 if ((card[nr] >= 0) && (card[nr] < em28xx_bcount))
2181 dev->model = card[nr]; 2193 dev->model = card[nr];
2182 2194
2183 /* allocate device struct */ 2195 /* allocate device struct */
@@ -2213,7 +2225,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
2213 2225
2214 em28xx_info("disconnecting %s\n", dev->vdev->name); 2226 em28xx_info("disconnecting %s\n", dev->vdev->name);
2215 2227
2216 /* wait until all current v4l2 io is finished then deallocate resources */ 2228 /* wait until all current v4l2 io is finished then deallocate
2229 resources */
2217 mutex_lock(&dev->lock); 2230 mutex_lock(&dev->lock);
2218 2231
2219 wake_up_interruptible_all(&dev->open); 2232 wake_up_interruptible_all(&dev->open);