diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-12-29 11:53:21 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-30 05:02:09 -0500 |
commit | 6d6a48e51fd3bcb40c5b88d0f9690ba960eedfd2 (patch) | |
tree | 6b82f8fd701489c898e9e50dd15336a59157cba6 /drivers/media/video/usbvision/usbvision-video.c | |
parent | 52cb0bf275debe4ec8950157f11b9d9f14447a88 (diff) |
[media] usbvision: coding style
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 328 |
1 files changed, 149 insertions, 179 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 375355a8fe1c..6083137f0bf8 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <linux/module.h> | 56 | #include <linux/module.h> |
57 | #include <linux/init.h> | 57 | #include <linux/init.h> |
58 | #include <linux/spinlock.h> | 58 | #include <linux/spinlock.h> |
59 | #include <asm/io.h> | 59 | #include <linux/io.h> |
60 | #include <linux/videodev2.h> | 60 | #include <linux/videodev2.h> |
61 | #include <linux/i2c.h> | 61 | #include <linux/i2c.h> |
62 | 62 | ||
@@ -70,8 +70,8 @@ | |||
70 | #include "usbvision.h" | 70 | #include "usbvision.h" |
71 | #include "usbvision-cards.h" | 71 | #include "usbvision-cards.h" |
72 | 72 | ||
73 | #define DRIVER_AUTHOR "Joerg Heckenbach <joerg@heckenbach-aw.de>,\ | 73 | #define DRIVER_AUTHOR "Joerg Heckenbach <joerg@heckenbach-aw.de>, \ |
74 | Dwaine Garden <DwaineGarden@rogers.com>" | 74 | Dwaine Garden <DwaineGarden@rogers.com>" |
75 | #define DRIVER_NAME "usbvision" | 75 | #define DRIVER_NAME "usbvision" |
76 | #define DRIVER_ALIAS "USBVision" | 76 | #define DRIVER_ALIAS "USBVision" |
77 | #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" | 77 | #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" |
@@ -82,9 +82,9 @@ | |||
82 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ | 82 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ |
83 | USBVISION_DRIVER_VERSION_MINOR,\ | 83 | USBVISION_DRIVER_VERSION_MINOR,\ |
84 | USBVISION_DRIVER_VERSION_PATCHLEVEL) | 84 | USBVISION_DRIVER_VERSION_PATCHLEVEL) |
85 | #define USBVISION_VERSION_STRING __stringify(USBVISION_DRIVER_VERSION_MAJOR)\ | 85 | #define USBVISION_VERSION_STRING __stringify(USBVISION_DRIVER_VERSION_MAJOR) \ |
86 | "." __stringify(USBVISION_DRIVER_VERSION_MINOR)\ | 86 | "." __stringify(USBVISION_DRIVER_VERSION_MINOR) \ |
87 | "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) | 87 | "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) |
88 | 88 | ||
89 | #define ENABLE_HEXDUMP 0 /* Enable if you need it */ | 89 | #define ENABLE_HEXDUMP 0 /* Enable if you need it */ |
90 | 90 | ||
@@ -96,16 +96,16 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL) | |||
96 | __func__, __LINE__ , ## args); \ | 96 | __func__, __LINE__ , ## args); \ |
97 | } | 97 | } |
98 | #else | 98 | #else |
99 | #define PDEBUG(level, fmt, args...) do {} while(0) | 99 | #define PDEBUG(level, fmt, args...) do {} while (0) |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #define DBG_IO 1<<1 | 102 | #define DBG_IO (1 << 1) |
103 | #define DBG_PROBE 1<<2 | 103 | #define DBG_PROBE (1 << 2) |
104 | #define DBG_MMAP 1<<3 | 104 | #define DBG_MMAP (1 << 3) |
105 | 105 | ||
106 | /* String operations */ | 106 | /* String operations */ |
107 | #define rmspace(str) while(*str==' ') str++; | 107 | #define rmspace(str) while (*str == ' ') str++; |
108 | #define goto2next(str) while(*str!=' ') str++; while(*str==' ') str++; | 108 | #define goto2next(str) while (*str != ' ') str++; while (*str == ' ') str++; |
109 | 109 | ||
110 | 110 | ||
111 | /* sequential number of usbvision device */ | 111 | /* sequential number of usbvision device */ |
@@ -205,7 +205,7 @@ static ssize_t show_hue(struct device *cd, | |||
205 | struct v4l2_control ctrl; | 205 | struct v4l2_control ctrl; |
206 | ctrl.id = V4L2_CID_HUE; | 206 | ctrl.id = V4L2_CID_HUE; |
207 | ctrl.value = 0; | 207 | ctrl.value = 0; |
208 | if(usbvision->user) | 208 | if (usbvision->user) |
209 | call_all(usbvision, core, g_ctrl, &ctrl); | 209 | call_all(usbvision, core, g_ctrl, &ctrl); |
210 | return sprintf(buf, "%d\n", ctrl.value); | 210 | return sprintf(buf, "%d\n", ctrl.value); |
211 | } | 211 | } |
@@ -220,7 +220,7 @@ static ssize_t show_contrast(struct device *cd, | |||
220 | struct v4l2_control ctrl; | 220 | struct v4l2_control ctrl; |
221 | ctrl.id = V4L2_CID_CONTRAST; | 221 | ctrl.id = V4L2_CID_CONTRAST; |
222 | ctrl.value = 0; | 222 | ctrl.value = 0; |
223 | if(usbvision->user) | 223 | if (usbvision->user) |
224 | call_all(usbvision, core, g_ctrl, &ctrl); | 224 | call_all(usbvision, core, g_ctrl, &ctrl); |
225 | return sprintf(buf, "%d\n", ctrl.value); | 225 | return sprintf(buf, "%d\n", ctrl.value); |
226 | } | 226 | } |
@@ -235,7 +235,7 @@ static ssize_t show_brightness(struct device *cd, | |||
235 | struct v4l2_control ctrl; | 235 | struct v4l2_control ctrl; |
236 | ctrl.id = V4L2_CID_BRIGHTNESS; | 236 | ctrl.id = V4L2_CID_BRIGHTNESS; |
237 | ctrl.value = 0; | 237 | ctrl.value = 0; |
238 | if(usbvision->user) | 238 | if (usbvision->user) |
239 | call_all(usbvision, core, g_ctrl, &ctrl); | 239 | call_all(usbvision, core, g_ctrl, &ctrl); |
240 | return sprintf(buf, "%d\n", ctrl.value); | 240 | return sprintf(buf, "%d\n", ctrl.value); |
241 | } | 241 | } |
@@ -250,7 +250,7 @@ static ssize_t show_saturation(struct device *cd, | |||
250 | struct v4l2_control ctrl; | 250 | struct v4l2_control ctrl; |
251 | ctrl.id = V4L2_CID_SATURATION; | 251 | ctrl.id = V4L2_CID_SATURATION; |
252 | ctrl.value = 0; | 252 | ctrl.value = 0; |
253 | if(usbvision->user) | 253 | if (usbvision->user) |
254 | call_all(usbvision, core, g_ctrl, &ctrl); | 254 | call_all(usbvision, core, g_ctrl, &ctrl); |
255 | return sprintf(buf, "%d\n", ctrl.value); | 255 | return sprintf(buf, "%d\n", ctrl.value); |
256 | } | 256 | } |
@@ -263,7 +263,7 @@ static ssize_t show_streaming(struct device *cd, | |||
263 | container_of(cd, struct video_device, dev); | 263 | container_of(cd, struct video_device, dev); |
264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
265 | return sprintf(buf, "%s\n", | 265 | return sprintf(buf, "%s\n", |
266 | YES_NO(usbvision->streaming==stream_on?1:0)); | 266 | YES_NO(usbvision->streaming == stream_on ? 1 : 0)); |
267 | } | 267 | } |
268 | static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); | 268 | static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); |
269 | 269 | ||
@@ -274,7 +274,7 @@ static ssize_t show_compression(struct device *cd, | |||
274 | container_of(cd, struct video_device, dev); | 274 | container_of(cd, struct video_device, dev); |
275 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 275 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
276 | return sprintf(buf, "%s\n", | 276 | return sprintf(buf, "%s\n", |
277 | YES_NO(usbvision->isoc_mode==ISOC_MODE_COMPRESS)); | 277 | YES_NO(usbvision->isoc_mode == ISOC_MODE_COMPRESS)); |
278 | } | 278 | } |
279 | static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); | 279 | static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); |
280 | 280 | ||
@@ -291,35 +291,36 @@ static DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); | |||
291 | static void usbvision_create_sysfs(struct video_device *vdev) | 291 | static void usbvision_create_sysfs(struct video_device *vdev) |
292 | { | 292 | { |
293 | int res; | 293 | int res; |
294 | |||
294 | if (!vdev) | 295 | if (!vdev) |
295 | return; | 296 | return; |
296 | do { | 297 | do { |
297 | res = device_create_file(&vdev->dev, &dev_attr_version); | 298 | res = device_create_file(&vdev->dev, &dev_attr_version); |
298 | if (res<0) | 299 | if (res < 0) |
299 | break; | 300 | break; |
300 | res = device_create_file(&vdev->dev, &dev_attr_model); | 301 | res = device_create_file(&vdev->dev, &dev_attr_model); |
301 | if (res<0) | 302 | if (res < 0) |
302 | break; | 303 | break; |
303 | res = device_create_file(&vdev->dev, &dev_attr_hue); | 304 | res = device_create_file(&vdev->dev, &dev_attr_hue); |
304 | if (res<0) | 305 | if (res < 0) |
305 | break; | 306 | break; |
306 | res = device_create_file(&vdev->dev, &dev_attr_contrast); | 307 | res = device_create_file(&vdev->dev, &dev_attr_contrast); |
307 | if (res<0) | 308 | if (res < 0) |
308 | break; | 309 | break; |
309 | res = device_create_file(&vdev->dev, &dev_attr_brightness); | 310 | res = device_create_file(&vdev->dev, &dev_attr_brightness); |
310 | if (res<0) | 311 | if (res < 0) |
311 | break; | 312 | break; |
312 | res = device_create_file(&vdev->dev, &dev_attr_saturation); | 313 | res = device_create_file(&vdev->dev, &dev_attr_saturation); |
313 | if (res<0) | 314 | if (res < 0) |
314 | break; | 315 | break; |
315 | res = device_create_file(&vdev->dev, &dev_attr_streaming); | 316 | res = device_create_file(&vdev->dev, &dev_attr_streaming); |
316 | if (res<0) | 317 | if (res < 0) |
317 | break; | 318 | break; |
318 | res = device_create_file(&vdev->dev, &dev_attr_compression); | 319 | res = device_create_file(&vdev->dev, &dev_attr_compression); |
319 | if (res<0) | 320 | if (res < 0) |
320 | break; | 321 | break; |
321 | res = device_create_file(&vdev->dev, &dev_attr_bridge); | 322 | res = device_create_file(&vdev->dev, &dev_attr_bridge); |
322 | if (res>=0) | 323 | if (res >= 0) |
323 | return; | 324 | return; |
324 | } while (0); | 325 | } while (0); |
325 | 326 | ||
@@ -363,7 +364,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
363 | else { | 364 | else { |
364 | /* Allocate memory for the scratch ring buffer */ | 365 | /* Allocate memory for the scratch ring buffer */ |
365 | err_code = usbvision_scratch_alloc(usbvision); | 366 | err_code = usbvision_scratch_alloc(usbvision); |
366 | if (isoc_mode==ISOC_MODE_COMPRESS) { | 367 | if (isoc_mode == ISOC_MODE_COMPRESS) { |
367 | /* Allocate intermediate decompression buffers | 368 | /* Allocate intermediate decompression buffers |
368 | only if needed */ | 369 | only if needed */ |
369 | err_code = usbvision_decompress_alloc(usbvision); | 370 | err_code = usbvision_decompress_alloc(usbvision); |
@@ -385,7 +386,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
385 | /* Send init sequence only once, it's large! */ | 386 | /* Send init sequence only once, it's large! */ |
386 | if (!usbvision->initialized) { | 387 | if (!usbvision->initialized) { |
387 | int setup_ok = 0; | 388 | int setup_ok = 0; |
388 | setup_ok = usbvision_setup(usbvision,isoc_mode); | 389 | setup_ok = usbvision_setup(usbvision, isoc_mode); |
389 | if (setup_ok) | 390 | if (setup_ok) |
390 | usbvision->initialized = 1; | 391 | usbvision->initialized = 1; |
391 | else | 392 | else |
@@ -396,7 +397,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
396 | usbvision_begin_streaming(usbvision); | 397 | usbvision_begin_streaming(usbvision); |
397 | err_code = usbvision_init_isoc(usbvision); | 398 | err_code = usbvision_init_isoc(usbvision); |
398 | /* device must be initialized before isoc transfer */ | 399 | /* device must be initialized before isoc transfer */ |
399 | usbvision_muxsel(usbvision,0); | 400 | usbvision_muxsel(usbvision, 0); |
400 | usbvision->user++; | 401 | usbvision->user++; |
401 | } else { | 402 | } else { |
402 | if (power_on_at_open) { | 403 | if (power_on_at_open) { |
@@ -463,7 +464,7 @@ static int usbvision_v4l2_close(struct file *file) | |||
463 | * | 464 | * |
464 | */ | 465 | */ |
465 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 466 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
466 | static int vidioc_g_register (struct file *file, void *priv, | 467 | static int vidioc_g_register(struct file *file, void *priv, |
467 | struct v4l2_dbg_register *reg) | 468 | struct v4l2_dbg_register *reg) |
468 | { | 469 | { |
469 | struct usb_usbvision *usbvision = video_drvdata(file); | 470 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -484,7 +485,7 @@ static int vidioc_g_register (struct file *file, void *priv, | |||
484 | return 0; | 485 | return 0; |
485 | } | 486 | } |
486 | 487 | ||
487 | static int vidioc_s_register (struct file *file, void *priv, | 488 | static int vidioc_s_register(struct file *file, void *priv, |
488 | struct v4l2_dbg_register *reg) | 489 | struct v4l2_dbg_register *reg) |
489 | { | 490 | { |
490 | struct usb_usbvision *usbvision = video_drvdata(file); | 491 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -493,7 +494,7 @@ static int vidioc_s_register (struct file *file, void *priv, | |||
493 | if (!v4l2_chip_match_host(®->match)) | 494 | if (!v4l2_chip_match_host(®->match)) |
494 | return -EINVAL; | 495 | return -EINVAL; |
495 | /* NT100x has a 8-bit register space */ | 496 | /* NT100x has a 8-bit register space */ |
496 | err_code = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | 497 | err_code = usbvision_write_reg(usbvision, reg->reg & 0xff, reg->val); |
497 | if (err_code < 0) { | 498 | if (err_code < 0) { |
498 | dev_err(&usbvision->vdev->dev, | 499 | dev_err(&usbvision->vdev->dev, |
499 | "%s: VIDIOC_DBG_S_REGISTER failed: error %d\n", | 500 | "%s: VIDIOC_DBG_S_REGISTER failed: error %d\n", |
@@ -504,7 +505,7 @@ static int vidioc_s_register (struct file *file, void *priv, | |||
504 | } | 505 | } |
505 | #endif | 506 | #endif |
506 | 507 | ||
507 | static int vidioc_querycap (struct file *file, void *priv, | 508 | static int vidioc_querycap(struct file *file, void *priv, |
508 | struct v4l2_capability *vc) | 509 | struct v4l2_capability *vc) |
509 | { | 510 | { |
510 | struct usb_usbvision *usbvision = video_drvdata(file); | 511 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -523,7 +524,7 @@ static int vidioc_querycap (struct file *file, void *priv, | |||
523 | return 0; | 524 | return 0; |
524 | } | 525 | } |
525 | 526 | ||
526 | static int vidioc_enum_input (struct file *file, void *priv, | 527 | static int vidioc_enum_input(struct file *file, void *priv, |
527 | struct v4l2_input *vi) | 528 | struct v4l2_input *vi) |
528 | { | 529 | { |
529 | struct usb_usbvision *usbvision = video_drvdata(file); | 530 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -531,14 +532,14 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
531 | 532 | ||
532 | if (vi->index >= usbvision->video_inputs) | 533 | if (vi->index >= usbvision->video_inputs) |
533 | return -EINVAL; | 534 | return -EINVAL; |
534 | if (usbvision->have_tuner) { | 535 | if (usbvision->have_tuner) |
535 | chan = vi->index; | 536 | chan = vi->index; |
536 | } else { | 537 | else |
537 | chan = vi->index + 1; /* skip Television string*/ | 538 | chan = vi->index + 1; /* skip Television string*/ |
538 | } | 539 | |
539 | /* Determine the requested input characteristics | 540 | /* Determine the requested input characteristics |
540 | specific for each usbvision card model */ | 541 | specific for each usbvision card model */ |
541 | switch(chan) { | 542 | switch (chan) { |
542 | case 0: | 543 | case 0: |
543 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { | 544 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { |
544 | strcpy(vi->name, "White Video Input"); | 545 | strcpy(vi->name, "White Video Input"); |
@@ -552,20 +553,18 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
552 | break; | 553 | break; |
553 | case 1: | 554 | case 1: |
554 | vi->type = V4L2_INPUT_TYPE_CAMERA; | 555 | vi->type = V4L2_INPUT_TYPE_CAMERA; |
555 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { | 556 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) |
556 | strcpy(vi->name, "Green Video Input"); | 557 | strcpy(vi->name, "Green Video Input"); |
557 | } else { | 558 | else |
558 | strcpy(vi->name, "Composite Video Input"); | 559 | strcpy(vi->name, "Composite Video Input"); |
559 | } | ||
560 | vi->std = V4L2_STD_PAL; | 560 | vi->std = V4L2_STD_PAL; |
561 | break; | 561 | break; |
562 | case 2: | 562 | case 2: |
563 | vi->type = V4L2_INPUT_TYPE_CAMERA; | 563 | vi->type = V4L2_INPUT_TYPE_CAMERA; |
564 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { | 564 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) |
565 | strcpy(vi->name, "Yellow Video Input"); | 565 | strcpy(vi->name, "Yellow Video Input"); |
566 | } else { | 566 | else |
567 | strcpy(vi->name, "S-Video Input"); | 567 | strcpy(vi->name, "S-Video Input"); |
568 | } | ||
569 | vi->std = V4L2_STD_PAL; | 568 | vi->std = V4L2_STD_PAL; |
570 | break; | 569 | break; |
571 | case 3: | 570 | case 3: |
@@ -577,7 +576,7 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
577 | return 0; | 576 | return 0; |
578 | } | 577 | } |
579 | 578 | ||
580 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) | 579 | static int vidioc_g_input(struct file *file, void *priv, unsigned int *input) |
581 | { | 580 | { |
582 | struct usb_usbvision *usbvision = video_drvdata(file); | 581 | struct usb_usbvision *usbvision = video_drvdata(file); |
583 | 582 | ||
@@ -585,7 +584,7 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) | |||
585 | return 0; | 584 | return 0; |
586 | } | 585 | } |
587 | 586 | ||
588 | static int vidioc_s_input (struct file *file, void *priv, unsigned int input) | 587 | static int vidioc_s_input(struct file *file, void *priv, unsigned int input) |
589 | { | 588 | { |
590 | struct usb_usbvision *usbvision = video_drvdata(file); | 589 | struct usb_usbvision *usbvision = video_drvdata(file); |
591 | 590 | ||
@@ -600,11 +599,11 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input) | |||
600 | return 0; | 599 | return 0; |
601 | } | 600 | } |
602 | 601 | ||
603 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | 602 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id) |
604 | { | 603 | { |
605 | struct usb_usbvision *usbvision = video_drvdata(file); | 604 | struct usb_usbvision *usbvision = video_drvdata(file); |
606 | 605 | ||
607 | usbvision->tvnorm_id=*id; | 606 | usbvision->tvnorm_id = *id; |
608 | 607 | ||
609 | call_all(usbvision, core, s_std, usbvision->tvnorm_id); | 608 | call_all(usbvision, core, s_std, usbvision->tvnorm_id); |
610 | /* propagate the change to the decoder */ | 609 | /* propagate the change to the decoder */ |
@@ -613,14 +612,14 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
613 | return 0; | 612 | return 0; |
614 | } | 613 | } |
615 | 614 | ||
616 | static int vidioc_g_tuner (struct file *file, void *priv, | 615 | static int vidioc_g_tuner(struct file *file, void *priv, |
617 | struct v4l2_tuner *vt) | 616 | struct v4l2_tuner *vt) |
618 | { | 617 | { |
619 | struct usb_usbvision *usbvision = video_drvdata(file); | 618 | struct usb_usbvision *usbvision = video_drvdata(file); |
620 | 619 | ||
621 | if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ | 620 | if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ |
622 | return -EINVAL; | 621 | return -EINVAL; |
623 | if(usbvision->radio) { | 622 | if (usbvision->radio) { |
624 | strcpy(vt->name, "Radio"); | 623 | strcpy(vt->name, "Radio"); |
625 | vt->type = V4L2_TUNER_RADIO; | 624 | vt->type = V4L2_TUNER_RADIO; |
626 | } else { | 625 | } else { |
@@ -632,7 +631,7 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
632 | return 0; | 631 | return 0; |
633 | } | 632 | } |
634 | 633 | ||
635 | static int vidioc_s_tuner (struct file *file, void *priv, | 634 | static int vidioc_s_tuner(struct file *file, void *priv, |
636 | struct v4l2_tuner *vt) | 635 | struct v4l2_tuner *vt) |
637 | { | 636 | { |
638 | struct usb_usbvision *usbvision = video_drvdata(file); | 637 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -646,23 +645,22 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
646 | return 0; | 645 | return 0; |
647 | } | 646 | } |
648 | 647 | ||
649 | static int vidioc_g_frequency (struct file *file, void *priv, | 648 | static int vidioc_g_frequency(struct file *file, void *priv, |
650 | struct v4l2_frequency *freq) | 649 | struct v4l2_frequency *freq) |
651 | { | 650 | { |
652 | struct usb_usbvision *usbvision = video_drvdata(file); | 651 | struct usb_usbvision *usbvision = video_drvdata(file); |
653 | 652 | ||
654 | freq->tuner = 0; /* Only one tuner */ | 653 | freq->tuner = 0; /* Only one tuner */ |
655 | if(usbvision->radio) { | 654 | if (usbvision->radio) |
656 | freq->type = V4L2_TUNER_RADIO; | 655 | freq->type = V4L2_TUNER_RADIO; |
657 | } else { | 656 | else |
658 | freq->type = V4L2_TUNER_ANALOG_TV; | 657 | freq->type = V4L2_TUNER_ANALOG_TV; |
659 | } | ||
660 | freq->frequency = usbvision->freq; | 658 | freq->frequency = usbvision->freq; |
661 | 659 | ||
662 | return 0; | 660 | return 0; |
663 | } | 661 | } |
664 | 662 | ||
665 | static int vidioc_s_frequency (struct file *file, void *priv, | 663 | static int vidioc_s_frequency(struct file *file, void *priv, |
666 | struct v4l2_frequency *freq) | 664 | struct v4l2_frequency *freq) |
667 | { | 665 | { |
668 | struct usb_usbvision *usbvision = video_drvdata(file); | 666 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -677,30 +675,27 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
677 | return 0; | 675 | return 0; |
678 | } | 676 | } |
679 | 677 | ||
680 | static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a) | 678 | static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) |
681 | { | 679 | { |
682 | struct usb_usbvision *usbvision = video_drvdata(file); | 680 | struct usb_usbvision *usbvision = video_drvdata(file); |
683 | 681 | ||
684 | if(usbvision->radio) { | 682 | if (usbvision->radio) |
685 | strcpy(a->name,"Radio"); | 683 | strcpy(a->name, "Radio"); |
686 | } else { | 684 | else |
687 | strcpy(a->name, "TV"); | 685 | strcpy(a->name, "TV"); |
688 | } | ||
689 | 686 | ||
690 | return 0; | 687 | return 0; |
691 | } | 688 | } |
692 | 689 | ||
693 | static int vidioc_s_audio (struct file *file, void *fh, | 690 | static int vidioc_s_audio(struct file *file, void *fh, |
694 | struct v4l2_audio *a) | 691 | struct v4l2_audio *a) |
695 | { | 692 | { |
696 | if(a->index) { | 693 | if (a->index) |
697 | return -EINVAL; | 694 | return -EINVAL; |
698 | } | ||
699 | |||
700 | return 0; | 695 | return 0; |
701 | } | 696 | } |
702 | 697 | ||
703 | static int vidioc_queryctrl (struct file *file, void *priv, | 698 | static int vidioc_queryctrl(struct file *file, void *priv, |
704 | struct v4l2_queryctrl *ctrl) | 699 | struct v4l2_queryctrl *ctrl) |
705 | { | 700 | { |
706 | struct usb_usbvision *usbvision = video_drvdata(file); | 701 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -713,52 +708,53 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
713 | return 0; | 708 | return 0; |
714 | } | 709 | } |
715 | 710 | ||
716 | static int vidioc_g_ctrl (struct file *file, void *priv, | 711 | static int vidioc_g_ctrl(struct file *file, void *priv, |
717 | struct v4l2_control *ctrl) | 712 | struct v4l2_control *ctrl) |
718 | { | 713 | { |
719 | struct usb_usbvision *usbvision = video_drvdata(file); | 714 | struct usb_usbvision *usbvision = video_drvdata(file); |
720 | call_all(usbvision, core, g_ctrl, ctrl); | ||
721 | 715 | ||
716 | call_all(usbvision, core, g_ctrl, ctrl); | ||
722 | return 0; | 717 | return 0; |
723 | } | 718 | } |
724 | 719 | ||
725 | static int vidioc_s_ctrl (struct file *file, void *priv, | 720 | static int vidioc_s_ctrl(struct file *file, void *priv, |
726 | struct v4l2_control *ctrl) | 721 | struct v4l2_control *ctrl) |
727 | { | 722 | { |
728 | struct usb_usbvision *usbvision = video_drvdata(file); | 723 | struct usb_usbvision *usbvision = video_drvdata(file); |
729 | call_all(usbvision, core, s_ctrl, ctrl); | ||
730 | 724 | ||
725 | call_all(usbvision, core, s_ctrl, ctrl); | ||
731 | return 0; | 726 | return 0; |
732 | } | 727 | } |
733 | 728 | ||
734 | static int vidioc_reqbufs (struct file *file, | 729 | static int vidioc_reqbufs(struct file *file, |
735 | void *priv, struct v4l2_requestbuffers *vr) | 730 | void *priv, struct v4l2_requestbuffers *vr) |
736 | { | 731 | { |
737 | struct usb_usbvision *usbvision = video_drvdata(file); | 732 | struct usb_usbvision *usbvision = video_drvdata(file); |
738 | int ret; | 733 | int ret; |
739 | 734 | ||
740 | RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES); | 735 | RESTRICT_TO_RANGE(vr->count, 1, USBVISION_NUMFRAMES); |
741 | 736 | ||
742 | /* Check input validity: | 737 | /* Check input validity: |
743 | the user must do a VIDEO CAPTURE and MMAP method. */ | 738 | the user must do a VIDEO CAPTURE and MMAP method. */ |
744 | if (vr->memory != V4L2_MEMORY_MMAP) | 739 | if (vr->memory != V4L2_MEMORY_MMAP) |
745 | return -EINVAL; | 740 | return -EINVAL; |
746 | 741 | ||
747 | if(usbvision->streaming == stream_on) { | 742 | if (usbvision->streaming == stream_on) { |
748 | if ((ret = usbvision_stream_interrupt(usbvision))) | 743 | ret = usbvision_stream_interrupt(usbvision); |
744 | if (ret) | ||
749 | return ret; | 745 | return ret; |
750 | } | 746 | } |
751 | 747 | ||
752 | usbvision_frames_free(usbvision); | 748 | usbvision_frames_free(usbvision); |
753 | usbvision_empty_framequeues(usbvision); | 749 | usbvision_empty_framequeues(usbvision); |
754 | vr->count = usbvision_frames_alloc(usbvision,vr->count); | 750 | vr->count = usbvision_frames_alloc(usbvision, vr->count); |
755 | 751 | ||
756 | usbvision->cur_frame = NULL; | 752 | usbvision->cur_frame = NULL; |
757 | 753 | ||
758 | return 0; | 754 | return 0; |
759 | } | 755 | } |
760 | 756 | ||
761 | static int vidioc_querybuf (struct file *file, | 757 | static int vidioc_querybuf(struct file *file, |
762 | void *priv, struct v4l2_buffer *vb) | 758 | void *priv, struct v4l2_buffer *vb) |
763 | { | 759 | { |
764 | struct usb_usbvision *usbvision = video_drvdata(file); | 760 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -766,48 +762,45 @@ static int vidioc_querybuf (struct file *file, | |||
766 | 762 | ||
767 | /* FIXME : must control | 763 | /* FIXME : must control |
768 | that buffers are mapped (VIDIOC_REQBUFS has been called) */ | 764 | that buffers are mapped (VIDIOC_REQBUFS has been called) */ |
769 | if(vb->index>=usbvision->num_frames) { | 765 | if (vb->index >= usbvision->num_frames) |
770 | return -EINVAL; | 766 | return -EINVAL; |
771 | } | ||
772 | /* Updating the corresponding frame state */ | 767 | /* Updating the corresponding frame state */ |
773 | vb->flags = 0; | 768 | vb->flags = 0; |
774 | frame = &usbvision->frame[vb->index]; | 769 | frame = &usbvision->frame[vb->index]; |
775 | if(frame->grabstate >= frame_state_ready) | 770 | if (frame->grabstate >= frame_state_ready) |
776 | vb->flags |= V4L2_BUF_FLAG_QUEUED; | 771 | vb->flags |= V4L2_BUF_FLAG_QUEUED; |
777 | if(frame->grabstate >= frame_state_done) | 772 | if (frame->grabstate >= frame_state_done) |
778 | vb->flags |= V4L2_BUF_FLAG_DONE; | 773 | vb->flags |= V4L2_BUF_FLAG_DONE; |
779 | if(frame->grabstate == frame_state_unused) | 774 | if (frame->grabstate == frame_state_unused) |
780 | vb->flags |= V4L2_BUF_FLAG_MAPPED; | 775 | vb->flags |= V4L2_BUF_FLAG_MAPPED; |
781 | vb->memory = V4L2_MEMORY_MMAP; | 776 | vb->memory = V4L2_MEMORY_MMAP; |
782 | 777 | ||
783 | vb->m.offset = vb->index*PAGE_ALIGN(usbvision->max_frame_size); | 778 | vb->m.offset = vb->index * PAGE_ALIGN(usbvision->max_frame_size); |
784 | 779 | ||
785 | vb->memory = V4L2_MEMORY_MMAP; | 780 | vb->memory = V4L2_MEMORY_MMAP; |
786 | vb->field = V4L2_FIELD_NONE; | 781 | vb->field = V4L2_FIELD_NONE; |
787 | vb->length = usbvision->curwidth* | 782 | vb->length = usbvision->curwidth * |
788 | usbvision->curheight* | 783 | usbvision->curheight * |
789 | usbvision->palette.bytes_per_pixel; | 784 | usbvision->palette.bytes_per_pixel; |
790 | vb->timestamp = usbvision->frame[vb->index].timestamp; | 785 | vb->timestamp = usbvision->frame[vb->index].timestamp; |
791 | vb->sequence = usbvision->frame[vb->index].sequence; | 786 | vb->sequence = usbvision->frame[vb->index].sequence; |
792 | return 0; | 787 | return 0; |
793 | } | 788 | } |
794 | 789 | ||
795 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | 790 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *vb) |
796 | { | 791 | { |
797 | struct usb_usbvision *usbvision = video_drvdata(file); | 792 | struct usb_usbvision *usbvision = video_drvdata(file); |
798 | struct usbvision_frame *frame; | 793 | struct usbvision_frame *frame; |
799 | unsigned long lock_flags; | 794 | unsigned long lock_flags; |
800 | 795 | ||
801 | /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ | 796 | /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ |
802 | if(vb->index>=usbvision->num_frames) { | 797 | if (vb->index >= usbvision->num_frames) |
803 | return -EINVAL; | 798 | return -EINVAL; |
804 | } | ||
805 | 799 | ||
806 | frame = &usbvision->frame[vb->index]; | 800 | frame = &usbvision->frame[vb->index]; |
807 | 801 | ||
808 | if (frame->grabstate != frame_state_unused) { | 802 | if (frame->grabstate != frame_state_unused) |
809 | return -EAGAIN; | 803 | return -EAGAIN; |
810 | } | ||
811 | 804 | ||
812 | /* Mark it as ready and enqueue frame */ | 805 | /* Mark it as ready and enqueue frame */ |
813 | frame->grabstate = frame_state_ready; | 806 | frame->grabstate = frame_state_ready; |
@@ -826,7 +819,7 @@ static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | |||
826 | return 0; | 819 | return 0; |
827 | } | 820 | } |
828 | 821 | ||
829 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | 822 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *vb) |
830 | { | 823 | { |
831 | struct usb_usbvision *usbvision = video_drvdata(file); | 824 | struct usb_usbvision *usbvision = video_drvdata(file); |
832 | int ret; | 825 | int ret; |
@@ -882,7 +875,7 @@ static int vidioc_streamoff(struct file *file, | |||
882 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 875 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
883 | return -EINVAL; | 876 | return -EINVAL; |
884 | 877 | ||
885 | if(usbvision->streaming == stream_on) { | 878 | if (usbvision->streaming == stream_on) { |
886 | usbvision_stream_interrupt(usbvision); | 879 | usbvision_stream_interrupt(usbvision); |
887 | /* Stop all video streamings */ | 880 | /* Stop all video streamings */ |
888 | call_all(usbvision, video, s_stream, 0); | 881 | call_all(usbvision, video, s_stream, 0); |
@@ -892,18 +885,17 @@ static int vidioc_streamoff(struct file *file, | |||
892 | return 0; | 885 | return 0; |
893 | } | 886 | } |
894 | 887 | ||
895 | static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | 888 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, |
896 | struct v4l2_fmtdesc *vfd) | 889 | struct v4l2_fmtdesc *vfd) |
897 | { | 890 | { |
898 | if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) { | 891 | if (vfd->index >= USBVISION_SUPPORTED_PALETTES - 1) |
899 | return -EINVAL; | 892 | return -EINVAL; |
900 | } | 893 | strcpy(vfd->description, usbvision_v4l2_format[vfd->index].desc); |
901 | strcpy(vfd->description,usbvision_v4l2_format[vfd->index].desc); | ||
902 | vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; | 894 | vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; |
903 | return 0; | 895 | return 0; |
904 | } | 896 | } |
905 | 897 | ||
906 | static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | 898 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
907 | struct v4l2_format *vf) | 899 | struct v4l2_format *vf) |
908 | { | 900 | { |
909 | struct usb_usbvision *usbvision = video_drvdata(file); | 901 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -911,32 +903,31 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | |||
911 | vf->fmt.pix.height = usbvision->curheight; | 903 | vf->fmt.pix.height = usbvision->curheight; |
912 | vf->fmt.pix.pixelformat = usbvision->palette.format; | 904 | vf->fmt.pix.pixelformat = usbvision->palette.format; |
913 | vf->fmt.pix.bytesperline = | 905 | vf->fmt.pix.bytesperline = |
914 | usbvision->curwidth*usbvision->palette.bytes_per_pixel; | 906 | usbvision->curwidth * usbvision->palette.bytes_per_pixel; |
915 | vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*usbvision->curheight; | 907 | vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline * usbvision->curheight; |
916 | vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 908 | vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
917 | vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ | 909 | vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ |
918 | 910 | ||
919 | return 0; | 911 | return 0; |
920 | } | 912 | } |
921 | 913 | ||
922 | static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, | 914 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
923 | struct v4l2_format *vf) | 915 | struct v4l2_format *vf) |
924 | { | 916 | { |
925 | struct usb_usbvision *usbvision = video_drvdata(file); | 917 | struct usb_usbvision *usbvision = video_drvdata(file); |
926 | int format_idx; | 918 | int format_idx; |
927 | 919 | ||
928 | /* Find requested format in available ones */ | 920 | /* Find requested format in available ones */ |
929 | for(format_idx=0;format_idx<USBVISION_SUPPORTED_PALETTES;format_idx++) { | 921 | for (format_idx = 0; format_idx < USBVISION_SUPPORTED_PALETTES; format_idx++) { |
930 | if(vf->fmt.pix.pixelformat == | 922 | if (vf->fmt.pix.pixelformat == |
931 | usbvision_v4l2_format[format_idx].format) { | 923 | usbvision_v4l2_format[format_idx].format) { |
932 | usbvision->palette = usbvision_v4l2_format[format_idx]; | 924 | usbvision->palette = usbvision_v4l2_format[format_idx]; |
933 | break; | 925 | break; |
934 | } | 926 | } |
935 | } | 927 | } |
936 | /* robustness */ | 928 | /* robustness */ |
937 | if(format_idx == USBVISION_SUPPORTED_PALETTES) { | 929 | if (format_idx == USBVISION_SUPPORTED_PALETTES) |
938 | return -EINVAL; | 930 | return -EINVAL; |
939 | } | ||
940 | RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); | 931 | RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); |
941 | RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); | 932 | RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); |
942 | 933 | ||
@@ -953,13 +944,14 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
953 | struct usb_usbvision *usbvision = video_drvdata(file); | 944 | struct usb_usbvision *usbvision = video_drvdata(file); |
954 | int ret; | 945 | int ret; |
955 | 946 | ||
956 | if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) { | 947 | ret = vidioc_try_fmt_vid_cap(file, priv, vf); |
948 | if (ret) | ||
957 | return ret; | 949 | return ret; |
958 | } | ||
959 | 950 | ||
960 | /* stop io in case it is already in progress */ | 951 | /* stop io in case it is already in progress */ |
961 | if(usbvision->streaming == stream_on) { | 952 | if (usbvision->streaming == stream_on) { |
962 | if ((ret = usbvision_stream_interrupt(usbvision))) | 953 | ret = usbvision_stream_interrupt(usbvision); |
954 | if (ret) | ||
963 | return ret; | 955 | return ret; |
964 | } | 956 | } |
965 | usbvision_frames_free(usbvision); | 957 | usbvision_frames_free(usbvision); |
@@ -979,8 +971,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
979 | struct usb_usbvision *usbvision = video_drvdata(file); | 971 | struct usb_usbvision *usbvision = video_drvdata(file); |
980 | int noblock = file->f_flags & O_NONBLOCK; | 972 | int noblock = file->f_flags & O_NONBLOCK; |
981 | unsigned long lock_flags; | 973 | unsigned long lock_flags; |
982 | 974 | int ret, i; | |
983 | int ret,i; | ||
984 | struct usbvision_frame *frame; | 975 | struct usbvision_frame *frame; |
985 | 976 | ||
986 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, | 977 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, |
@@ -992,15 +983,15 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
992 | /* This entry point is compatible with the mmap routines | 983 | /* This entry point is compatible with the mmap routines |
993 | so that a user can do either VIDIOC_QBUF/VIDIOC_DQBUF | 984 | so that a user can do either VIDIOC_QBUF/VIDIOC_DQBUF |
994 | to get frames or call read on the device. */ | 985 | to get frames or call read on the device. */ |
995 | if(!usbvision->num_frames) { | 986 | if (!usbvision->num_frames) { |
996 | /* First, allocate some frames to work with | 987 | /* First, allocate some frames to work with |
997 | if this has not been done with VIDIOC_REQBUF */ | 988 | if this has not been done with VIDIOC_REQBUF */ |
998 | usbvision_frames_free(usbvision); | 989 | usbvision_frames_free(usbvision); |
999 | usbvision_empty_framequeues(usbvision); | 990 | usbvision_empty_framequeues(usbvision); |
1000 | usbvision_frames_alloc(usbvision,USBVISION_NUMFRAMES); | 991 | usbvision_frames_alloc(usbvision, USBVISION_NUMFRAMES); |
1001 | } | 992 | } |
1002 | 993 | ||
1003 | if(usbvision->streaming != stream_on) { | 994 | if (usbvision->streaming != stream_on) { |
1004 | /* no stream is running, make it running ! */ | 995 | /* no stream is running, make it running ! */ |
1005 | usbvision->streaming = stream_on; | 996 | usbvision->streaming = stream_on; |
1006 | call_all(usbvision, video, s_stream, 1); | 997 | call_all(usbvision, video, s_stream, 1); |
@@ -1008,9 +999,9 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1008 | 999 | ||
1009 | /* Then, enqueue as many frames as possible | 1000 | /* Then, enqueue as many frames as possible |
1010 | (like a user of VIDIOC_QBUF would do) */ | 1001 | (like a user of VIDIOC_QBUF would do) */ |
1011 | for(i=0;i<usbvision->num_frames;i++) { | 1002 | for (i = 0; i < usbvision->num_frames; i++) { |
1012 | frame = &usbvision->frame[i]; | 1003 | frame = &usbvision->frame[i]; |
1013 | if(frame->grabstate == frame_state_unused) { | 1004 | if (frame->grabstate == frame_state_unused) { |
1014 | /* Mark it as ready and enqueue frame */ | 1005 | /* Mark it as ready and enqueue frame */ |
1015 | frame->grabstate = frame_state_ready; | 1006 | frame->grabstate = frame_state_ready; |
1016 | frame->scanstate = scan_state_scanning; | 1007 | frame->scanstate = scan_state_scanning; |
@@ -1029,7 +1020,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1029 | 1020 | ||
1030 | /* Then try to steal a frame (like a VIDIOC_DQBUF would do) */ | 1021 | /* Then try to steal a frame (like a VIDIOC_DQBUF would do) */ |
1031 | if (list_empty(&(usbvision->outqueue))) { | 1022 | if (list_empty(&(usbvision->outqueue))) { |
1032 | if(noblock) | 1023 | if (noblock) |
1033 | return -EAGAIN; | 1024 | return -EAGAIN; |
1034 | 1025 | ||
1035 | ret = wait_event_interruptible | 1026 | ret = wait_event_interruptible |
@@ -1059,9 +1050,8 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1059 | if ((count + frame->bytes_read) > (unsigned long)frame->scanlength) | 1050 | if ((count + frame->bytes_read) > (unsigned long)frame->scanlength) |
1060 | count = frame->scanlength - frame->bytes_read; | 1051 | count = frame->scanlength - frame->bytes_read; |
1061 | 1052 | ||
1062 | if (copy_to_user(buf, frame->data + frame->bytes_read, count)) { | 1053 | if (copy_to_user(buf, frame->data + frame->bytes_read, count)) |
1063 | return -EFAULT; | 1054 | return -EFAULT; |
1064 | } | ||
1065 | 1055 | ||
1066 | frame->bytes_read += count; | 1056 | frame->bytes_read += count; |
1067 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", | 1057 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", |
@@ -1069,12 +1059,12 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1069 | (unsigned long)count, frame->bytes_read); | 1059 | (unsigned long)count, frame->bytes_read); |
1070 | 1060 | ||
1071 | /* For now, forget the frame if it has not been read in one shot. */ | 1061 | /* For now, forget the frame if it has not been read in one shot. */ |
1072 | /* if (frame->bytes_read >= frame->scanlength) {*/ /* All data has been read */ | 1062 | /* if (frame->bytes_read >= frame->scanlength) {*/ /* All data has been read */ |
1073 | frame->bytes_read = 0; | 1063 | frame->bytes_read = 0; |
1074 | 1064 | ||
1075 | /* Mark it as available to be used again. */ | 1065 | /* Mark it as available to be used again. */ |
1076 | frame->grabstate = frame_state_unused; | 1066 | frame->grabstate = frame_state_unused; |
1077 | /* } */ | 1067 | /* } */ |
1078 | 1068 | ||
1079 | return count; | 1069 | return count; |
1080 | } | 1070 | } |
@@ -1089,9 +1079,8 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1089 | 1079 | ||
1090 | PDEBUG(DBG_MMAP, "mmap"); | 1080 | PDEBUG(DBG_MMAP, "mmap"); |
1091 | 1081 | ||
1092 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { | 1082 | if (!USBVISION_IS_OPERATIONAL(usbvision)) |
1093 | return -EFAULT; | 1083 | return -EFAULT; |
1094 | } | ||
1095 | 1084 | ||
1096 | if (!(vma->vm_flags & VM_WRITE) || | 1085 | if (!(vma->vm_flags & VM_WRITE) || |
1097 | size != PAGE_ALIGN(usbvision->max_frame_size)) { | 1086 | size != PAGE_ALIGN(usbvision->max_frame_size)) { |
@@ -1115,7 +1104,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1115 | 1104 | ||
1116 | pos = usbvision->frame[i].data; | 1105 | pos = usbvision->frame[i].data; |
1117 | while (size > 0) { | 1106 | while (size > 0) { |
1118 | |||
1119 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 1107 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
1120 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); | 1108 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); |
1121 | return -EAGAIN; | 1109 | return -EAGAIN; |
@@ -1145,9 +1133,8 @@ static int usbvision_radio_open(struct file *file) | |||
1145 | "%s: Someone tried to open an already opened USBVision Radio!\n", | 1133 | "%s: Someone tried to open an already opened USBVision Radio!\n", |
1146 | __func__); | 1134 | __func__); |
1147 | err_code = -EBUSY; | 1135 | err_code = -EBUSY; |
1148 | } | 1136 | } else { |
1149 | else { | 1137 | if (power_on_at_open) { |
1150 | if(power_on_at_open) { | ||
1151 | usbvision_reset_power_off_timer(usbvision); | 1138 | usbvision_reset_power_off_timer(usbvision); |
1152 | if (usbvision->power == 0) { | 1139 | if (usbvision->power == 0) { |
1153 | usbvision_power_on(usbvision); | 1140 | usbvision_power_on(usbvision); |
@@ -1190,12 +1177,12 @@ static int usbvision_radio_close(struct file *file) | |||
1190 | PDEBUG(DBG_IO, ""); | 1177 | PDEBUG(DBG_IO, ""); |
1191 | 1178 | ||
1192 | /* Set packet size to 0 */ | 1179 | /* Set packet size to 0 */ |
1193 | usbvision->iface_alt=0; | 1180 | usbvision->iface_alt = 0; |
1194 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, | 1181 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, |
1195 | usbvision->iface_alt); | 1182 | usbvision->iface_alt); |
1196 | 1183 | ||
1197 | usbvision_audio_off(usbvision); | 1184 | usbvision_audio_off(usbvision); |
1198 | usbvision->radio=0; | 1185 | usbvision->radio = 0; |
1199 | usbvision->user--; | 1186 | usbvision->user--; |
1200 | 1187 | ||
1201 | if (power_on_at_open) { | 1188 | if (power_on_at_open) { |
@@ -1222,7 +1209,7 @@ static const struct v4l2_file_operations usbvision_fops = { | |||
1222 | .read = usbvision_v4l2_read, | 1209 | .read = usbvision_v4l2_read, |
1223 | .mmap = usbvision_v4l2_mmap, | 1210 | .mmap = usbvision_v4l2_mmap, |
1224 | .unlocked_ioctl = video_ioctl2, | 1211 | .unlocked_ioctl = video_ioctl2, |
1225 | /* .poll = video_poll, */ | 1212 | /* .poll = video_poll, */ |
1226 | }; | 1213 | }; |
1227 | 1214 | ||
1228 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | 1215 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { |
@@ -1258,11 +1245,11 @@ static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | |||
1258 | 1245 | ||
1259 | static struct video_device usbvision_video_template = { | 1246 | static struct video_device usbvision_video_template = { |
1260 | .fops = &usbvision_fops, | 1247 | .fops = &usbvision_fops, |
1261 | .ioctl_ops = &usbvision_ioctl_ops, | 1248 | .ioctl_ops = &usbvision_ioctl_ops, |
1262 | .name = "usbvision-video", | 1249 | .name = "usbvision-video", |
1263 | .release = video_device_release, | 1250 | .release = video_device_release, |
1264 | .tvnorms = USBVISION_NORMS, | 1251 | .tvnorms = USBVISION_NORMS, |
1265 | .current_norm = V4L2_STD_PAL | 1252 | .current_norm = V4L2_STD_PAL |
1266 | }; | 1253 | }; |
1267 | 1254 | ||
1268 | 1255 | ||
@@ -1292,9 +1279,9 @@ static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { | |||
1292 | 1279 | ||
1293 | static struct video_device usbvision_radio_template = { | 1280 | static struct video_device usbvision_radio_template = { |
1294 | .fops = &usbvision_radio_fops, | 1281 | .fops = &usbvision_radio_fops, |
1295 | .name = "usbvision-radio", | 1282 | .name = "usbvision-radio", |
1296 | .release = video_device_release, | 1283 | .release = video_device_release, |
1297 | .ioctl_ops = &usbvision_radio_ioctl_ops, | 1284 | .ioctl_ops = &usbvision_radio_ioctl_ops, |
1298 | 1285 | ||
1299 | .tvnorms = USBVISION_NORMS, | 1286 | .tvnorms = USBVISION_NORMS, |
1300 | .current_norm = V4L2_STD_PAL | 1287 | .current_norm = V4L2_STD_PAL |
@@ -1315,9 +1302,8 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, | |||
1315 | } | 1302 | } |
1316 | 1303 | ||
1317 | vdev = video_device_alloc(); | 1304 | vdev = video_device_alloc(); |
1318 | if (NULL == vdev) { | 1305 | if (NULL == vdev) |
1319 | return NULL; | 1306 | return NULL; |
1320 | } | ||
1321 | *vdev = *vdev_template; | 1307 | *vdev = *vdev_template; |
1322 | vdev->lock = &usbvision->v4l2_lock; | 1308 | vdev->lock = &usbvision->v4l2_lock; |
1323 | vdev->v4l2_dev = &usbvision->v4l2_dev; | 1309 | vdev->v4l2_dev = &usbvision->v4l2_dev; |
@@ -1333,11 +1319,10 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision) | |||
1333 | if (usbvision->rdev) { | 1319 | if (usbvision->rdev) { |
1334 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", | 1320 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", |
1335 | video_device_node_name(usbvision->rdev)); | 1321 | video_device_node_name(usbvision->rdev)); |
1336 | if (video_is_registered(usbvision->rdev)) { | 1322 | if (video_is_registered(usbvision->rdev)) |
1337 | video_unregister_device(usbvision->rdev); | 1323 | video_unregister_device(usbvision->rdev); |
1338 | } else { | 1324 | else |
1339 | video_device_release(usbvision->rdev); | 1325 | video_device_release(usbvision->rdev); |
1340 | } | ||
1341 | usbvision->rdev = NULL; | 1326 | usbvision->rdev = NULL; |
1342 | } | 1327 | } |
1343 | 1328 | ||
@@ -1345,11 +1330,10 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision) | |||
1345 | if (usbvision->vdev) { | 1330 | if (usbvision->vdev) { |
1346 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", | 1331 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", |
1347 | video_device_node_name(usbvision->vdev)); | 1332 | video_device_node_name(usbvision->vdev)); |
1348 | if (video_is_registered(usbvision->vdev)) { | 1333 | if (video_is_registered(usbvision->vdev)) |
1349 | video_unregister_device(usbvision->vdev); | 1334 | video_unregister_device(usbvision->vdev); |
1350 | } else { | 1335 | else |
1351 | video_device_release(usbvision->vdev); | 1336 | video_device_release(usbvision->vdev); |
1352 | } | ||
1353 | usbvision->vdev = NULL; | 1337 | usbvision->vdev = NULL; |
1354 | } | 1338 | } |
1355 | } | 1339 | } |
@@ -1361,14 +1345,10 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) | |||
1361 | usbvision->vdev = usbvision_vdev_init(usbvision, | 1345 | usbvision->vdev = usbvision_vdev_init(usbvision, |
1362 | &usbvision_video_template, | 1346 | &usbvision_video_template, |
1363 | "USBVision Video"); | 1347 | "USBVision Video"); |
1364 | if (usbvision->vdev == NULL) { | 1348 | if (usbvision->vdev == NULL) |
1365 | goto err_exit; | 1349 | goto err_exit; |
1366 | } | 1350 | if (video_register_device(usbvision->vdev, VFL_TYPE_GRABBER, video_nr) < 0) |
1367 | if (video_register_device(usbvision->vdev, | ||
1368 | VFL_TYPE_GRABBER, | ||
1369 | video_nr)<0) { | ||
1370 | goto err_exit; | 1351 | goto err_exit; |
1371 | } | ||
1372 | printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", | 1352 | printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", |
1373 | usbvision->nr, video_device_node_name(usbvision->vdev)); | 1353 | usbvision->nr, video_device_node_name(usbvision->vdev)); |
1374 | 1354 | ||
@@ -1378,14 +1358,10 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) | |||
1378 | usbvision->rdev = usbvision_vdev_init(usbvision, | 1358 | usbvision->rdev = usbvision_vdev_init(usbvision, |
1379 | &usbvision_radio_template, | 1359 | &usbvision_radio_template, |
1380 | "USBVision Radio"); | 1360 | "USBVision Radio"); |
1381 | if (usbvision->rdev == NULL) { | 1361 | if (usbvision->rdev == NULL) |
1382 | goto err_exit; | 1362 | goto err_exit; |
1383 | } | 1363 | if (video_register_device(usbvision->rdev, VFL_TYPE_RADIO, radio_nr) < 0) |
1384 | if (video_register_device(usbvision->rdev, | ||
1385 | VFL_TYPE_RADIO, | ||
1386 | radio_nr)<0) { | ||
1387 | goto err_exit; | 1364 | goto err_exit; |
1388 | } | ||
1389 | printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n", | 1365 | printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n", |
1390 | usbvision->nr, video_device_node_name(usbvision->rdev)); | 1366 | usbvision->nr, video_device_node_name(usbvision->rdev)); |
1391 | } | 1367 | } |
@@ -1459,9 +1435,7 @@ static void usbvision_release(struct usb_usbvision *usbvision) | |||
1459 | usbvision_remove_sysfs(usbvision->vdev); | 1435 | usbvision_remove_sysfs(usbvision->vdev); |
1460 | usbvision_unregister_video(usbvision); | 1436 | usbvision_unregister_video(usbvision); |
1461 | 1437 | ||
1462 | if (usbvision->ctrl_urb) { | 1438 | usb_free_urb(usbvision->ctrl_urb); |
1463 | usb_free_urb(usbvision->ctrl_urb); | ||
1464 | } | ||
1465 | 1439 | ||
1466 | v4l2_device_unregister(&usbvision->v4l2_dev); | 1440 | v4l2_device_unregister(&usbvision->v4l2_dev); |
1467 | kfree(usbvision); | 1441 | kfree(usbvision); |
@@ -1520,25 +1494,24 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1520 | const struct usb_host_interface *interface; | 1494 | const struct usb_host_interface *interface; |
1521 | struct usb_usbvision *usbvision = NULL; | 1495 | struct usb_usbvision *usbvision = NULL; |
1522 | const struct usb_endpoint_descriptor *endpoint; | 1496 | const struct usb_endpoint_descriptor *endpoint; |
1523 | int model,i; | 1497 | int model, i; |
1524 | 1498 | ||
1525 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", | 1499 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", |
1526 | dev->descriptor.idVendor, | 1500 | dev->descriptor.idVendor, |
1527 | dev->descriptor.idProduct, ifnum); | 1501 | dev->descriptor.idProduct, ifnum); |
1528 | 1502 | ||
1529 | model = devid->driver_info; | 1503 | model = devid->driver_info; |
1530 | if ( (model<0) || (model>=usbvision_device_data_size) ) { | 1504 | if (model < 0 || model >= usbvision_device_data_size) { |
1531 | PDEBUG(DBG_PROBE, "model out of bounds %d",model); | 1505 | PDEBUG(DBG_PROBE, "model out of bounds %d", model); |
1532 | return -ENODEV; | 1506 | return -ENODEV; |
1533 | } | 1507 | } |
1534 | printk(KERN_INFO "%s: %s found\n", __func__, | 1508 | printk(KERN_INFO "%s: %s found\n", __func__, |
1535 | usbvision_device_data[model].model_string); | 1509 | usbvision_device_data[model].model_string); |
1536 | 1510 | ||
1537 | if (usbvision_device_data[model].interface >= 0) { | 1511 | if (usbvision_device_data[model].interface >= 0) |
1538 | interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; | 1512 | interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; |
1539 | } else { | 1513 | else |
1540 | interface = &dev->actconfig->interface[ifnum]->altsetting[0]; | 1514 | interface = &dev->actconfig->interface[ifnum]->altsetting[0]; |
1541 | } | ||
1542 | endpoint = &interface->endpoint[1].desc; | 1515 | endpoint = &interface->endpoint[1].desc; |
1543 | if (!usb_endpoint_xfer_isoc(endpoint)) { | 1516 | if (!usb_endpoint_xfer_isoc(endpoint)) { |
1544 | dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", | 1517 | dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", |
@@ -1559,33 +1532,31 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1559 | return -ENOMEM; | 1532 | return -ENOMEM; |
1560 | } | 1533 | } |
1561 | 1534 | ||
1562 | if (dev->descriptor.bNumConfigurations > 1) { | 1535 | if (dev->descriptor.bNumConfigurations > 1) |
1563 | usbvision->bridge_type = BRIDGE_NT1004; | 1536 | usbvision->bridge_type = BRIDGE_NT1004; |
1564 | } else if (model == DAZZLE_DVC_90_REV_1_SECAM) { | 1537 | else if (model == DAZZLE_DVC_90_REV_1_SECAM) |
1565 | usbvision->bridge_type = BRIDGE_NT1005; | 1538 | usbvision->bridge_type = BRIDGE_NT1005; |
1566 | } else { | 1539 | else |
1567 | usbvision->bridge_type = BRIDGE_NT1003; | 1540 | usbvision->bridge_type = BRIDGE_NT1003; |
1568 | } | ||
1569 | PDEBUG(DBG_PROBE, "bridge_type %d", usbvision->bridge_type); | 1541 | PDEBUG(DBG_PROBE, "bridge_type %d", usbvision->bridge_type); |
1570 | 1542 | ||
1571 | /* compute alternate max packet sizes */ | 1543 | /* compute alternate max packet sizes */ |
1572 | uif = dev->actconfig->interface[0]; | 1544 | uif = dev->actconfig->interface[0]; |
1573 | 1545 | ||
1574 | usbvision->num_alt=uif->num_altsetting; | 1546 | usbvision->num_alt = uif->num_altsetting; |
1575 | PDEBUG(DBG_PROBE, "Alternate settings: %i",usbvision->num_alt); | 1547 | PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt); |
1576 | usbvision->alt_max_pkt_size = kmalloc(32* | 1548 | usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); |
1577 | usbvision->num_alt,GFP_KERNEL); | ||
1578 | if (usbvision->alt_max_pkt_size == NULL) { | 1549 | if (usbvision->alt_max_pkt_size == NULL) { |
1579 | dev_err(&intf->dev, "usbvision: out of memory!\n"); | 1550 | dev_err(&intf->dev, "usbvision: out of memory!\n"); |
1580 | return -ENOMEM; | 1551 | return -ENOMEM; |
1581 | } | 1552 | } |
1582 | 1553 | ||
1583 | for (i = 0; i < usbvision->num_alt ; i++) { | 1554 | for (i = 0; i < usbvision->num_alt; i++) { |
1584 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. | 1555 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. |
1585 | wMaxPacketSize); | 1556 | wMaxPacketSize); |
1586 | usbvision->alt_max_pkt_size[i] = | 1557 | usbvision->alt_max_pkt_size[i] = |
1587 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1558 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1588 | PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i",i, | 1559 | PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i", i, |
1589 | usbvision->alt_max_pkt_size[i]); | 1560 | usbvision->alt_max_pkt_size[i]); |
1590 | } | 1561 | } |
1591 | 1562 | ||
@@ -1593,9 +1564,8 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1593 | usbvision->nr = usbvision_nr++; | 1564 | usbvision->nr = usbvision_nr++; |
1594 | 1565 | ||
1595 | usbvision->have_tuner = usbvision_device_data[model].tuner; | 1566 | usbvision->have_tuner = usbvision_device_data[model].tuner; |
1596 | if (usbvision->have_tuner) { | 1567 | if (usbvision->have_tuner) |
1597 | usbvision->tuner_type = usbvision_device_data[model].tuner_type; | 1568 | usbvision->tuner_type = usbvision_device_data[model].tuner_type; |
1598 | } | ||
1599 | 1569 | ||
1600 | usbvision->dev_model = model; | 1570 | usbvision->dev_model = model; |
1601 | usbvision->remove_pending = 0; | 1571 | usbvision->remove_pending = 0; |
@@ -1689,7 +1659,7 @@ static int __init usbvision_init(void) | |||
1689 | PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]"); | 1659 | PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]"); |
1690 | 1660 | ||
1691 | /* disable planar mode support unless compression enabled */ | 1661 | /* disable planar mode support unless compression enabled */ |
1692 | if (isoc_mode != ISOC_MODE_COMPRESS ) { | 1662 | if (isoc_mode != ISOC_MODE_COMPRESS) { |
1693 | /* FIXME : not the right way to set supported flag */ | 1663 | /* FIXME : not the right way to set supported flag */ |
1694 | usbvision_v4l2_format[6].supported = 0; /* V4L2_PIX_FMT_YVU420 */ | 1664 | usbvision_v4l2_format[6].supported = 0; /* V4L2_PIX_FMT_YVU420 */ |
1695 | usbvision_v4l2_format[7].supported = 0; /* V4L2_PIX_FMT_YUV422P */ | 1665 | usbvision_v4l2_format[7].supported = 0; /* V4L2_PIX_FMT_YUV422P */ |
@@ -1706,10 +1676,10 @@ static int __init usbvision_init(void) | |||
1706 | 1676 | ||
1707 | static void __exit usbvision_exit(void) | 1677 | static void __exit usbvision_exit(void) |
1708 | { | 1678 | { |
1709 | PDEBUG(DBG_PROBE, ""); | 1679 | PDEBUG(DBG_PROBE, ""); |
1710 | 1680 | ||
1711 | usb_deregister(&usbvision_driver); | 1681 | usb_deregister(&usbvision_driver); |
1712 | PDEBUG(DBG_PROBE, "success"); | 1682 | PDEBUG(DBG_PROBE, "success"); |
1713 | } | 1683 | } |
1714 | 1684 | ||
1715 | module_init(usbvision_init); | 1685 | module_init(usbvision_init); |