aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s2255drv.c
diff options
context:
space:
mode:
authorDean Anderson <dean@sensoray.com>2008-06-30 20:28:34 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:24:32 -0400
commit3f8d6f73da4332b4ff4150b9bae8e5f680bcbbde (patch)
treeffc19a9e1f416a75519c02b1ad58b818da707d58 /drivers/media/video/s2255drv.c
parent91a1d912f61b91e44336efe100a2bd0821777e24 (diff)
V4L/DVB (8317): Sensoray 2255 V4l driver checkpatch fixes
This patch fixes some coding style issues. It also fixes a NULL de-reference on driver unload. The permissions for the module parameters were changed to 0644. Signed-off-by: Dean Anderson <dean@sensoray.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/s2255drv.c')
-rw-r--r--drivers/media/video/s2255drv.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 6d5fbad95c29..04eb2c3fabd8 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -67,17 +67,17 @@
67/* maximum time for DSP to start responding after last FW word loaded(ms) */ 67/* maximum time for DSP to start responding after last FW word loaded(ms) */
68#define S2255_DSP_BOOTTIME 400 68#define S2255_DSP_BOOTTIME 400
69/* maximum time to wait for firmware to load (ms) */ 69/* maximum time to wait for firmware to load (ms) */
70#define S2255_LOAD_TIMEOUT (5000+S2255_DSP_BOOTTIME) 70#define S2255_LOAD_TIMEOUT (5000 + S2255_DSP_BOOTTIME)
71#define S2255_DEF_BUFS 16 71#define S2255_DEF_BUFS 16
72#define MAX_CHANNELS 4 72#define MAX_CHANNELS 4
73#define FRAME_MARKER 0x2255DA4AL 73#define FRAME_MARKER 0x2255DA4AL
74#define MAX_PIPE_USBBLOCK (40*1024) 74#define MAX_PIPE_USBBLOCK (40 * 1024)
75#define DEFAULT_PIPE_USBBLOCK (16*1024) 75#define DEFAULT_PIPE_USBBLOCK (16 * 1024)
76#define MAX_CHANNELS 4 76#define MAX_CHANNELS 4
77#define MAX_PIPE_BUFFERS 1 77#define MAX_PIPE_BUFFERS 1
78#define SYS_FRAMES 4 78#define SYS_FRAMES 4
79/* maximum size is PAL full size plus room for the marker header(s) */ 79/* maximum size is PAL full size plus room for the marker header(s) */
80#define SYS_FRAMES_MAXSIZE (720*288*2*2 + 4096) 80#define SYS_FRAMES_MAXSIZE (720 * 288 * 2 * 2 + 4096)
81#define DEF_USB_BLOCK (4096) 81#define DEF_USB_BLOCK (4096)
82#define LINE_SZ_4CIFS_NTSC 640 82#define LINE_SZ_4CIFS_NTSC 640
83#define LINE_SZ_2CIFS_NTSC 640 83#define LINE_SZ_2CIFS_NTSC 640
@@ -168,7 +168,7 @@ struct s2255_bufferi {
168 168
169#define DEF_MODEI_NTSC_CONT {FORMAT_NTSC, DEF_SCALE, DEF_COLOR, \ 169#define DEF_MODEI_NTSC_CONT {FORMAT_NTSC, DEF_SCALE, DEF_COLOR, \
170 DEF_FDEC, DEF_BRIGHT, DEF_CONTRAST, DEF_SATURATION, \ 170 DEF_FDEC, DEF_BRIGHT, DEF_CONTRAST, DEF_SATURATION, \
171 DEF_HUE, 0, DEF_USB_BLOCK, 0 } 171 DEF_HUE, 0, DEF_USB_BLOCK, 0}
172 172
173struct s2255_dmaqueue { 173struct s2255_dmaqueue {
174 struct list_head active; 174 struct list_head active;
@@ -275,6 +275,10 @@ struct s2255_fh {
275 struct s2255_mode mode; 275 struct s2255_mode mode;
276}; 276};
277 277
278/*
279 * TODO: fixme S2255_MAX_USERS. Do not limit open driver handles.
280 * Limit V4L to one stream at a time.
281 */
278#define S2255_MAX_USERS 1 282#define S2255_MAX_USERS 1
279 283
280#define CUR_USB_FWVER 774 /* current cypress EEPROM firmware version */ 284#define CUR_USB_FWVER 774 /* current cypress EEPROM firmware version */
@@ -293,7 +297,7 @@ struct s2255_fh {
293#define PREFIX_SIZE 512 297#define PREFIX_SIZE 512
294 298
295/* Channels on box are in reverse order */ 299/* Channels on box are in reverse order */
296static unsigned long G_chnmap[MAX_CHANNELS] = { 3, 2, 1, 0 }; 300static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};
297 301
298static LIST_HEAD(s2255_devlist); 302static LIST_HEAD(s2255_devlist);
299 303
@@ -329,11 +333,11 @@ static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
329/* start video number */ 333/* start video number */
330static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ 334static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
331 335
332module_param(debug, int, 0); 336module_param(debug, int, 0644);
333MODULE_PARM_DESC(debug, "Debug level(0-100) default 0"); 337MODULE_PARM_DESC(debug, "Debug level(0-100) default 0");
334module_param(vid_limit, int, 0); 338module_param(vid_limit, int, 0644);
335MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)"); 339MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)");
336module_param(video_nr, int, 0); 340module_param(video_nr, int, 0644);
337MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)"); 341MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)");
338 342
339/* USB device table */ 343/* USB device table */
@@ -437,7 +441,10 @@ static int norm_minh(struct video_device *vdev)
437} 441}
438 442
439 443
440/* converts 2255 planar format to yuyv or uyvy */ 444/*
445 * TODO: fixme: move YUV reordering to hardware
446 * converts 2255 planar format to yuyv or uyvy
447 */
441static void planar422p_to_yuv_packed(const unsigned char *in, 448static void planar422p_to_yuv_packed(const unsigned char *in,
442 unsigned char *out, 449 unsigned char *out,
443 int width, int height, 450 int width, int height,
@@ -502,7 +509,7 @@ static void s2255_fwchunk_complete(struct urb *urb)
502 struct usb_device *udev = urb->dev; 509 struct usb_device *udev = urb->dev;
503 int len; 510 int len;
504 dprintk(100, "udev %p urb %p", udev, urb); 511 dprintk(100, "udev %p urb %p", udev, urb);
505 512 /* TODO: fixme. reflect change in status */
506 if (urb->status) { 513 if (urb->status) {
507 dev_err(&udev->dev, "URB failed with status %d", urb->status); 514 dev_err(&udev->dev, "URB failed with status %d", urb->status);
508 return; 515 return;
@@ -682,7 +689,7 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
682 if (0 == *count) 689 if (0 == *count)
683 *count = S2255_DEF_BUFS; 690 *count = S2255_DEF_BUFS;
684 691
685 while (*size * *count > vid_limit * 1024 * 1024) 692 while (*size * (*count) > vid_limit * 1024 * 1024)
686 (*count)--; 693 (*count)--;
687 694
688 return 0; 695 return 0;
@@ -789,7 +796,7 @@ static int res_get(struct s2255_dev *dev, struct s2255_fh *fh)
789 796
790static int res_locked(struct s2255_dev *dev, struct s2255_fh *fh) 797static int res_locked(struct s2255_dev *dev, struct s2255_fh *fh)
791{ 798{
792 return (dev->resources[fh->channel]); 799 return dev->resources[fh->channel];
793} 800}
794 801
795static void res_free(struct s2255_dev *dev, struct s2255_fh *fh) 802static void res_free(struct s2255_dev *dev, struct s2255_fh *fh)
@@ -806,7 +813,8 @@ static int vidioc_querycap(struct file *file, void *priv,
806 struct s2255_dev *dev = fh->dev; 813 struct s2255_dev *dev = fh->dev;
807 strlcpy(cap->driver, "s2255", sizeof(cap->driver)); 814 strlcpy(cap->driver, "s2255", sizeof(cap->driver));
808 strlcpy(cap->card, "s2255", sizeof(cap->card)); 815 strlcpy(cap->card, "s2255", sizeof(cap->card));
809 strlcpy(cap->bus_info, dev_name(&dev->udev->dev), sizeof(cap->bus_info)); 816 strlcpy(cap->bus_info, dev_name(&dev->udev->dev),
817 sizeof(cap->bus_info));
810 cap->version = S2255_VERSION; 818 cap->version = S2255_VERSION;
811 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; 819 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
812 return 0; 820 return 0;
@@ -839,8 +847,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
839 f->fmt.pix.pixelformat = fh->fmt->fourcc; 847 f->fmt.pix.pixelformat = fh->fmt->fourcc;
840 f->fmt.pix.bytesperline = f->fmt.pix.width * (fh->fmt->depth >> 3); 848 f->fmt.pix.bytesperline = f->fmt.pix.width * (fh->fmt->depth >> 3);
841 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 849 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
842 850 return 0;
843 return (0);
844} 851}
845 852
846static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, 853static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
@@ -961,7 +968,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
961 ret = vidioc_try_fmt_vid_cap(file, fh, f); 968 ret = vidioc_try_fmt_vid_cap(file, fh, f);
962 969
963 if (ret < 0) 970 if (ret < 0)
964 return (ret); 971 return ret;
965 972
966 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 973 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
967 974
@@ -1336,7 +1343,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1336 inp->type = V4L2_INPUT_TYPE_CAMERA; 1343 inp->type = V4L2_INPUT_TYPE_CAMERA;
1337 inp->std = S2255_NORMS; 1344 inp->std = S2255_NORMS;
1338 strlcpy(inp->name, "Camera", sizeof(inp->name)); 1345 strlcpy(inp->name, "Camera", sizeof(inp->name));
1339 return (0); 1346 return 0;
1340} 1347}
1341 1348
1342static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) 1349static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
@@ -1360,7 +1367,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1360 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) 1367 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
1361 if (qc->id && qc->id == s2255_qctrl[i].id) { 1368 if (qc->id && qc->id == s2255_qctrl[i].id) {
1362 memcpy(qc, &(s2255_qctrl[i]), sizeof(*qc)); 1369 memcpy(qc, &(s2255_qctrl[i]), sizeof(*qc));
1363 return (0); 1370 return 0;
1364 } 1371 }
1365 1372
1366 dprintk(4, "query_ctrl -EINVAL %d\n", qc->id); 1373 dprintk(4, "query_ctrl -EINVAL %d\n", qc->id);
@@ -1375,7 +1382,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
1375 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) 1382 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
1376 if (ctrl->id == s2255_qctrl[i].id) { 1383 if (ctrl->id == s2255_qctrl[i].id) {
1377 ctrl->value = qctl_regs[i]; 1384 ctrl->value = qctl_regs[i];
1378 return (0); 1385 return 0;
1379 } 1386 }
1380 dprintk(4, "g_ctrl -EINVAL\n"); 1387 dprintk(4, "g_ctrl -EINVAL\n");
1381 1388
@@ -1395,7 +1402,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1395 if (ctrl->id == s2255_qctrl[i].id) { 1402 if (ctrl->id == s2255_qctrl[i].id) {
1396 if (ctrl->value < s2255_qctrl[i].minimum || 1403 if (ctrl->value < s2255_qctrl[i].minimum ||
1397 ctrl->value > s2255_qctrl[i].maximum) 1404 ctrl->value > s2255_qctrl[i].maximum)
1398 return (-ERANGE); 1405 return -ERANGE;
1399 1406
1400 qctl_regs[i] = ctrl->value; 1407 qctl_regs[i] = ctrl->value;
1401 /* update the mode to the corresponding value */ 1408 /* update the mode to the corresponding value */
@@ -1571,6 +1578,11 @@ static void s2255_destroy(struct kref *kref)
1571 usb_free_urb(dev->fw_data->fw_urb); 1578 usb_free_urb(dev->fw_data->fw_urb);
1572 dev->fw_data->fw_urb = NULL; 1579 dev->fw_data->fw_urb = NULL;
1573 } 1580 }
1581 /*
1582 * TODO: fixme(above, below): potentially leaving timers alive.
1583 * do not ignore timeout below if
1584 * it occurs.
1585 */
1574 1586
1575 /* make sure we aren't waiting for the DSP */ 1587 /* make sure we aren't waiting for the DSP */
1576 if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_LOADED_DSPWAIT) { 1588 if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_LOADED_DSPWAIT) {
@@ -1582,15 +1594,12 @@ static void s2255_destroy(struct kref *kref)
1582 } 1594 }
1583 1595
1584 if (dev->fw_data) { 1596 if (dev->fw_data) {
1597 if (dev->fw_data->fw)
1598 release_firmware(dev->fw_data->fw);
1585 kfree(dev->fw_data->pfw_data); 1599 kfree(dev->fw_data->pfw_data);
1586 kfree(dev->fw_data); 1600 kfree(dev->fw_data);
1587 } 1601 }
1588 1602
1589 if (dev->fw_data->fw) {
1590 release_firmware(dev->fw_data->fw);
1591 dev->fw_data->fw = NULL;
1592 }
1593
1594 usb_put_dev(dev->udev); 1603 usb_put_dev(dev->udev);
1595 dprintk(1, "%s", __func__); 1604 dprintk(1, "%s", __func__);
1596 kfree(dev); 1605 kfree(dev);