aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c399
1 files changed, 182 insertions, 217 deletions
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index da422e7793ad..f225701f16fd 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * USB USBVISION Video device driver 0.9.8.3cvs (For Kernel 2.4.19-2.4.32 + 2.6.0-2.6.16) 2 * USB USBVISION Video device driver 0.9.8.3cvs (For Kernel 2.4.19-2.4.32 + 2.6.0-2.6.16)
3 * 3 *
4 * 4 *
5 * 5 *
6 * Copyright (c) 1999-2005 Joerg Heckenbach <joerg@heckenbach-aw.de> 6 * Copyright (c) 1999-2005 Joerg Heckenbach <joerg@heckenbach-aw.de>
7 * 7 *
@@ -181,7 +181,7 @@
181 * June 2, 2004 - 0.9.6 Dwaine Garden 181 * June 2, 2004 - 0.9.6 Dwaine Garden
182 * - Fixed sourceforge.net cvs repository. 182 * - Fixed sourceforge.net cvs repository.
183 * - Added #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,26) for .owner to help compiling under kernels 2.4.x which do not have the i2c v2.8.x updates. 183 * - Added #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,26) for .owner to help compiling under kernels 2.4.x which do not have the i2c v2.8.x updates.
184 * - Added device Hauppauge WinTv-USB III (PAL) FM Model 597 to usbvision.h 184 * - Added device Hauppauge WinTv-USB III (PAL) FM Model 597 to usbvision.h
185 * 185 *
186 * July 1, 2004 -0.9.6 Dwaine Garden 186 * July 1, 2004 -0.9.6 Dwaine Garden
187 * - Patch was submitted by Hal Finkel to fix the problem with the tuner not working under kernel 2.6.7. 187 * - Patch was submitted by Hal Finkel to fix the problem with the tuner not working under kernel 2.6.7.
@@ -206,7 +206,7 @@
206 * - Changed usbvision_muxsel to address the problem with black & white s-video output for NT1004 devices with saa7114 video decoder. Thanks to Emmanuel for the patch and testing. 206 * - Changed usbvision_muxsel to address the problem with black & white s-video output for NT1004 devices with saa7114 video decoder. Thanks to Emmanuel for the patch and testing.
207 * - Fixed up SECAM devices which could not properly output video. Changes to usbmuxsel. Thanks to Emmanuel for the patch and everyone with a SECAM device which help test. 207 * - Fixed up SECAM devices which could not properly output video. Changes to usbmuxsel. Thanks to Emmanuel for the patch and everyone with a SECAM device which help test.
208 * - Removed some commented out code. Clean up. 208 * - Removed some commented out code. Clean up.
209 * - Tried to fix up the annoying empty directories in the sourceforge.net cvs. Fuck it up again. 8*( 209 * - Tried to fix up the annoying empty directories in the sourceforge.net cvs. Fuck it up again. 8*(
210 * 210 *
211 * November 15, 2004 - 0.9.8 Dwaine Garden 211 * November 15, 2004 - 0.9.8 Dwaine Garden
212 * - Release new tar - 0.9.8 on sourceforge.net 212 * - Release new tar - 0.9.8 on sourceforge.net
@@ -228,7 +228,7 @@
228 * - Better support for mythtv. 228 * - Better support for mythtv.
229 * 229 *
230 * January 2, 2005 - 0.9.8.1cvs Dwaine Garden 230 * January 2, 2005 - 0.9.8.1cvs Dwaine Garden
231 * - Setup that you can specify which device is used for video. Default is auto detect next available device number eg. /dev/videoX 231 * - Setup that you can specify which device is used for video. Default is auto detect next available device number eg. /dev/videoX
232 * - Setup that you can specify which device is used for radio. Default is auto detect next available device number eg. /dev/radioX 232 * - Setup that you can specify which device is used for radio. Default is auto detect next available device number eg. /dev/radioX
233 * - usb_unlink_urb() is deprecated for synchronous unlinks. Using usb_kill_urb instead. 233 * - usb_unlink_urb() is deprecated for synchronous unlinks. Using usb_kill_urb instead.
234 * - usbvision_kvirt_to_pa is deprecated. Removed. 234 * - usbvision_kvirt_to_pa is deprecated. Removed.
@@ -251,39 +251,39 @@
251 * April 20, 2005 - 0.9.8.2cvs Dwaine Garden 251 * April 20, 2005 - 0.9.8.2cvs Dwaine Garden
252 * - Release lock in usbvision_v4l_read_done. -Thanks to nplanel for the patch. 252 * - Release lock in usbvision_v4l_read_done. -Thanks to nplanel for the patch.
253 * - Additional comments to the driver. 253 * - Additional comments to the driver.
254 * - Fixed some spelling mistakes. 8*) 254 * - Fixed some spelling mistakes. 8*)
255 * 255 *
256 * April 23, 2005 - 0.9.8.2cvs Joerg Heckenbach 256 * April 23, 2005 - 0.9.8.2cvs Joerg Heckenbach
257 * - Found bug in usbvision line counting. Now there should be no spurious lines in the image any longer. 257 * - Found bug in usbvision line counting. Now there should be no spurious lines in the image any longer.
258 * - Swapped usbvision_register_video and usbvision_configure_video to fix problem with PowerOnAtOpen=0. 258 * - Swapped usbvision_register_video and usbvision_configure_video to fix problem with PowerOnAtOpen=0.
259 * Thanks to Erwan Velu 259 * Thanks to Erwan Velu
260 * 260 *
261 * April 26, 2005 - 0.9.8.2cvs Joerg Heckenbach 261 * April 26, 2005 - 0.9.8.2cvs Joerg Heckenbach
262 * - Fixed problem with rmmod module and oppses. Replaced vfree(usbvision->overlay_base) with iounmap(usbvision->overlay_base). 262 * - Fixed problem with rmmod module and oppses. Replaced vfree(usbvision->overlay_base) with iounmap(usbvision->overlay_base).
263 * - Added function usb_get_dev(dev) and ; To help with unloading the module multiple times without crashing. 263 * - Added function usb_get_dev(dev) and ; To help with unloading the module multiple times without crashing.
264 * (Keep the reference count in kobjects correct) 264 * (Keep the reference count in kobjects correct)
265 * 265 *
266 * June 14, 2005 - 0.9.8.2cvs Dwaine 266 * June 14, 2005 - 0.9.8.2cvs Dwaine
267 * - Missed a change in saa7113.c for checking kernel version. Added conditional if's. 267 * - Missed a change in saa7113.c for checking kernel version. Added conditional if's.
268 * 268 *
269 * June 15, 2005 - 0.9.8.2cvs Dwaine 269 * June 15, 2005 - 0.9.8.2cvs Dwaine
270 * - Added new device WinTV device VendorId 0573 and ProductId 4d29. 270 * - Added new device WinTV device VendorId 0573 and ProductId 4d29.
271 * - Hacked some support for newer NT1005 devices. This devices only seem to have one configuration, not multiple configurations like the NT1004. 271 * - Hacked some support for newer NT1005 devices. This devices only seem to have one configuration, not multiple configurations like the NT1004.
272 * 272 *
273 * June 29, 2005 - 0.9.8.2cvs Dwaine 273 * June 29, 2005 - 0.9.8.2cvs Dwaine
274 * - Added new device WinTV device VendorId 0573 and ProductId 4d37. 274 * - Added new device WinTV device VendorId 0573 and ProductId 4d37.
275 * - Because of the first empty entry in usbvision_table, modutils failed to create the necessary entries for modules.usbmap. 275 * - Because of the first empty entry in usbvision_table, modutils failed to create the necessary entries for modules.usbmap.
276 * This means hotplug won't work for usbvision. Thanks to Gary Ng. 276 * This means hotplug won't work for usbvision. Thanks to Gary Ng.
277 * - Sent an e-mail to the maintainer of usb.ids. New devices identified need to be added. 277 * - Sent an e-mail to the maintainer of usb.ids. New devices identified need to be added.
278 * - Fixed compile error with saa7113 under kernel 2.6.12. 278 * - Fixed compile error with saa7113 under kernel 2.6.12.
279 * 279 *
280 * July 6, 2005 - 0.9.8.2cvs Dwaine 280 * July 6, 2005 - 0.9.8.2cvs Dwaine
281 * - Patch submitted by Gary Ng for two additional procfs entries. Device Input and Frequency setting. 281 * - Patch submitted by Gary Ng for two additional procfs entries. Device Input and Frequency setting.
282 * 282 *
283 * July 12, 2005 - 0.9.8.2cvs Dwaine 283 * July 12, 2005 - 0.9.8.2cvs Dwaine
284 * - New tuner identified for some devices it's called TCL_MFPE05. This tuner uses the same API as tuner 38 in tuner.c. 284 * - New tuner identified for some devices it's called TCL_MFPE05. This tuner uses the same API as tuner 38 in tuner.c.
285 * - Thanks to lynx31 for contacting Hauppage and asking them. 285 * - Thanks to lynx31 for contacting Hauppage and asking them.
286 * - I have no clue as to which devices use this new tuner, so people will have to contact me and tell me. 286 * - I have no clue as to which devices use this new tuner, so people will have to contact me and tell me.
287 * 287 *
288 * July 21, 2005 - 0.9.8.2cvs Dwaine 288 * July 21, 2005 - 0.9.8.2cvs Dwaine
289 * - Patched usbvision.c with missing ifdef kernversion statement so the module will compile with older kernels and v4l. 289 * - Patched usbvision.c with missing ifdef kernversion statement so the module will compile with older kernels and v4l.
@@ -305,11 +305,11 @@
305 * -Changed number of bytes for i2c write to 4 as per the NT100X spec sheet. Thanks to Merlum for finding it. 305 * -Changed number of bytes for i2c write to 4 as per the NT100X spec sheet. Thanks to Merlum for finding it.
306 * -Remove the radio option for device Hauppauge WinTV USB device Model 40219 Rev E189. This device does not have a FM radio. Thanks to Shadwell. 306 * -Remove the radio option for device Hauppauge WinTV USB device Model 40219 Rev E189. This device does not have a FM radio. Thanks to Shadwell.
307 * -Added radio option for device Hauppauge WinTV USB device Model 40219 Rev E189 again. Just got an e-mail indicating their device has one. 8*) 307 * -Added radio option for device Hauppauge WinTV USB device Model 40219 Rev E189 again. Just got an e-mail indicating their device has one. 8*)
308 * 308 *
309 * Aug 27, 2006 - 0.9.8.3cvs Dwaine 309 * Aug 27, 2006 - 0.9.8.3cvs Dwaine
310 * -Changed ifdef statement so the usbvision driver will compile with kernels at 2.6.12. 310 * -Changed ifdef statement so the usbvision driver will compile with kernels at 2.6.12.
311 * -Updated readme files for new updated tuner list for v4l devices. 311 * -Updated readme files for new updated tuner list for v4l devices.
312 * 312 *
313 * 313 *
314 * 314 *
315 * TODO: 315 * TODO:
@@ -351,8 +351,8 @@
351#define USBVISION_VERSION __stringify(USBVISION_DRIVER_VERSION_MAJOR) "." __stringify(USBVISION_DRIVER_VERSION_MINOR) "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) " " USBVISION_DRIVER_VERSION_COMMENT 351#define USBVISION_VERSION __stringify(USBVISION_DRIVER_VERSION_MAJOR) "." __stringify(USBVISION_DRIVER_VERSION_MINOR) "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) " " USBVISION_DRIVER_VERSION_COMMENT
352#define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,USBVISION_DRIVER_VERSION_MINOR,USBVISION_DRIVER_VERSION_PATCHLEVEL) 352#define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,USBVISION_DRIVER_VERSION_MINOR,USBVISION_DRIVER_VERSION_PATCHLEVEL)
353 353
354#include <media/saa7115.h> 354#include <media/saa7115.h>
355#include <media/v4l2-common.h> 355#include <media/v4l2-common.h>
356#include <media/tuner.h> 356#include <media/tuner.h>
357#include <media/audiochip.h> 357#include <media/audiochip.h>
358 358
@@ -427,14 +427,14 @@ enum {
427}; 427};
428 428
429static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = { 429static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = {
430 { 1, 1, 8, V4L2_PIX_FMT_GREY , "GREY" }, 430 { 1, 1, 8, V4L2_PIX_FMT_GREY , "GREY" },
431 { 1, 2, 16, V4L2_PIX_FMT_RGB565 , "RGB565" }, 431 { 1, 2, 16, V4L2_PIX_FMT_RGB565 , "RGB565" },
432 { 1, 3, 24, V4L2_PIX_FMT_RGB24 , "RGB24" }, 432 { 1, 3, 24, V4L2_PIX_FMT_RGB24 , "RGB24" },
433 { 1, 4, 32, V4L2_PIX_FMT_RGB32 , "RGB32" }, 433 { 1, 4, 32, V4L2_PIX_FMT_RGB32 , "RGB32" },
434 { 1, 2, 16, V4L2_PIX_FMT_RGB555 , "RGB555" }, 434 { 1, 2, 16, V4L2_PIX_FMT_RGB555 , "RGB555" },
435 { 1, 2, 16, V4L2_PIX_FMT_YUYV , "YUV422" }, 435 { 1, 2, 16, V4L2_PIX_FMT_YUYV , "YUV422" },
436 { 1, 2, 12, V4L2_PIX_FMT_YVU420 , "YUV420P" }, // 1.5 ! 436 { 1, 2, 12, V4L2_PIX_FMT_YVU420 , "YUV420P" }, // 1.5 !
437 { 1, 2, 16, V4L2_PIX_FMT_YUV422P , "YUV422P" } 437 { 1, 2, 16, V4L2_PIX_FMT_YUV422P , "YUV422P" }
438}; 438};
439 439
440 440
@@ -448,11 +448,6 @@ static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = {
448#define DEFAULT_SCRATCH_BUF_SIZE (0x20000) // 128kB memory scratch buffer 448#define DEFAULT_SCRATCH_BUF_SIZE (0x20000) // 128kB memory scratch buffer
449static const int scratch_buf_size = DEFAULT_SCRATCH_BUF_SIZE; 449static const int scratch_buf_size = DEFAULT_SCRATCH_BUF_SIZE;
450 450
451static int init_brightness = 128; // Initalize the brightness of the video device
452static int init_contrast = 192; // Initalize the contrast of the video device
453static int init_saturation = 128; // Initalize the staturation mode of the video device
454static int init_hue = 128; // Initalize the Hue settings of the video device
455
456// Function prototypes 451// Function prototypes
457static int usbvision_restart_isoc(struct usb_usbvision *usbvision); 452static int usbvision_restart_isoc(struct usb_usbvision *usbvision);
458static int usbvision_begin_streaming(struct usb_usbvision *usbvision); 453static int usbvision_begin_streaming(struct usb_usbvision *usbvision);
@@ -466,9 +461,9 @@ static int usbvision_unrequest_intra (struct usb_usbvision *usbvision);
466static int usbvision_adjust_compression (struct usb_usbvision *usbvision); 461static int usbvision_adjust_compression (struct usb_usbvision *usbvision);
467static int usbvision_measure_bandwidth (struct usb_usbvision *usbvision); 462static int usbvision_measure_bandwidth (struct usb_usbvision *usbvision);
468static void usbvision_release(struct usb_usbvision *usbvision); 463static void usbvision_release(struct usb_usbvision *usbvision);
469static int usbvision_set_input(struct usb_usbvision *usbvision); 464static int usbvision_set_input(struct usb_usbvision *usbvision);
470static int usbvision_set_output(struct usb_usbvision *usbvision, int width, int height); 465static int usbvision_set_output(struct usb_usbvision *usbvision, int width, int height);
471static void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd, void *arg); 466static void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd, void *arg);
472 467
473 468
474// Bit flags (options) 469// Bit flags (options)
@@ -488,8 +483,8 @@ static int adjustCompression = 1; // Set the compression to be adaptive
488static int dga = 1; // Set the default Direct Graphic Access 483static int dga = 1; // Set the default Direct Graphic Access
489static int PowerOnAtOpen = 1; // Set the default device to power on at startup 484static int PowerOnAtOpen = 1; // Set the default device to power on at startup
490static int SwitchSVideoInput = 0; // To help people with Black and White output with using s-video input. Some cables and input device are wired differently. 485static int SwitchSVideoInput = 0; // To help people with Black and White output with using s-video input. Some cables and input device are wired differently.
491static int video_nr = -1; // Sequential Number of Video Device 486static int video_nr = -1; // Sequential Number of Video Device
492static int radio_nr = -1; // Sequential Number of Radio Device 487static int radio_nr = -1; // Sequential Number of Radio Device
493static int vbi_nr = -1; // Sequential Number of VBI Device 488static int vbi_nr = -1; // Sequential Number of VBI Device
494static char *CustomDevice=NULL; // Set as nothing.... 489static char *CustomDevice=NULL; // Set as nothing....
495 490
@@ -515,10 +510,10 @@ MODULE_PARM(adjustCompression, "i"); // Grab the compression to be adaptive
515MODULE_PARM(dga, "i"); // Grab the Direct Graphic Access 510MODULE_PARM(dga, "i"); // Grab the Direct Graphic Access
516MODULE_PARM(PowerOnAtOpen, "i"); // Grab the device to power on at startup 511MODULE_PARM(PowerOnAtOpen, "i"); // Grab the device to power on at startup
517MODULE_PARM(SwitchSVideoInput, "i"); // To help people with Black and White output with using s-video input. Some cables and input device are wired differently. 512MODULE_PARM(SwitchSVideoInput, "i"); // To help people with Black and White output with using s-video input. Some cables and input device are wired differently.
518MODULE_PARM(video_nr, "i"); // video_nr option allows to specify a certain /dev/videoX device (like /dev/video0 or /dev/video1 ...) 513MODULE_PARM(video_nr, "i"); // video_nr option allows to specify a certain /dev/videoX device (like /dev/video0 or /dev/video1 ...)
519MODULE_PARM(radio_nr, "i"); // radio_nr option allows to specify a certain /dev/radioX device (like /dev/radio0 or /dev/radio1 ...) 514MODULE_PARM(radio_nr, "i"); // radio_nr option allows to specify a certain /dev/radioX device (like /dev/radio0 or /dev/radio1 ...)
520MODULE_PARM(vbi_nr, "i"); // vbi_nr option allows to specify a certain /dev/vbiX device (like /dev/vbi0 or /dev/vbi1 ...) 515MODULE_PARM(vbi_nr, "i"); // vbi_nr option allows to specify a certain /dev/vbiX device (like /dev/vbi0 or /dev/vbi1 ...)
521MODULE_PARM(CustomDevice, "s"); // .... CustomDevice 516MODULE_PARM(CustomDevice, "s"); // .... CustomDevice
522#endif 517#endif
523 518
524MODULE_PARM_DESC(flags, " Set the default Overlay Display mode of the device driver. Default: 0 (Off)"); 519MODULE_PARM_DESC(flags, " Set the default Overlay Display mode of the device driver. Default: 0 (Off)");
@@ -539,7 +534,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
539MODULE_DESCRIPTION(DRIVER_DESC); 534MODULE_DESCRIPTION(DRIVER_DESC);
540MODULE_LICENSE(DRIVER_LICENSE); 535MODULE_LICENSE(DRIVER_LICENSE);
541 MODULE_VERSION(DRIVER_VERSION); 536 MODULE_VERSION(DRIVER_VERSION);
542 MODULE_ALIAS(DRIVER_ALIAS); 537 MODULE_ALIAS(DRIVER_ALIAS);
543 538
544#ifdef MODULE 539#ifdef MODULE
545static unsigned int autoload = 1; 540static unsigned int autoload = 1;
@@ -549,8 +544,8 @@ static unsigned int autoload = 0;
549 544
550 545
551/****************************************************************************************/ 546/****************************************************************************************/
552/* SYSFS Code - Copied from the stv680.c usb module. */ 547/* SYSFS Code - Copied from the stv680.c usb module. */
553/* Device information is located at /sys/class/video4linux/video0 */ 548/* Device information is located at /sys/class/video4linux/video0 */
554/* Device parameters information is located at /sys/module/usbvision */ 549/* Device parameters information is located at /sys/module/usbvision */
555/* Device USB Information is located at /sys/bus/usb/drivers/USBVision Video Grabber */ 550/* Device USB Information is located at /sys/bus/usb/drivers/USBVision Video Grabber */
556/****************************************************************************************/ 551/****************************************************************************************/
@@ -567,79 +562,79 @@ static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd)
567static ssize_t show_version(struct class_device *cd, char *buf) 562static ssize_t show_version(struct class_device *cd, char *buf)
568{ 563{
569 return sprintf(buf, "%s\n", DRIVER_VERSION); 564 return sprintf(buf, "%s\n", DRIVER_VERSION);
570} 565}
571static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); 566static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
572 567
573static ssize_t show_model(struct class_device *class_dev, char *buf) 568static ssize_t show_model(struct class_device *class_dev, char *buf)
574{ 569{
575 struct video_device *vdev = to_video_device(class_dev); 570 struct video_device *vdev = to_video_device(class_dev);
576 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 571 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
577 return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString); 572 return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString);
578} 573}
579static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); 574static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
580 575
581static ssize_t show_hue(struct class_device *class_dev, char *buf) 576static ssize_t show_hue(struct class_device *class_dev, char *buf)
582{ 577{
583 struct video_device *vdev = to_video_device(class_dev); 578 struct video_device *vdev = to_video_device(class_dev);
584 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 579 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
585 return sprintf(buf, "%d\n", usbvision->hue >> 8); 580 return sprintf(buf, "%d\n", usbvision->hue >> 8);
586} 581}
587static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); 582static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
588 583
589static ssize_t show_contrast(struct class_device *class_dev, char *buf) 584static ssize_t show_contrast(struct class_device *class_dev, char *buf)
590{ 585{
591 struct video_device *vdev = to_video_device(class_dev); 586 struct video_device *vdev = to_video_device(class_dev);
592 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 587 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
593 return sprintf(buf, "%d\n", usbvision->contrast >> 8); 588 return sprintf(buf, "%d\n", usbvision->contrast >> 8);
594} 589}
595static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); 590static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
596 591
597static ssize_t show_brightness(struct class_device *class_dev, char *buf) 592static ssize_t show_brightness(struct class_device *class_dev, char *buf)
598{ 593{
599 struct video_device *vdev = to_video_device(class_dev); 594 struct video_device *vdev = to_video_device(class_dev);
600 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 595 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
601 return sprintf(buf, "%d\n", usbvision->brightness >> 8); 596 return sprintf(buf, "%d\n", usbvision->brightness >> 8);
602} 597}
603static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); 598static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
604 599
605static ssize_t show_saturation(struct class_device *class_dev, char *buf) 600static ssize_t show_saturation(struct class_device *class_dev, char *buf)
606{ 601{
607 struct video_device *vdev = to_video_device(class_dev); 602 struct video_device *vdev = to_video_device(class_dev);
608 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 603 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
609 return sprintf(buf, "%d\n", usbvision->saturation >> 8); 604 return sprintf(buf, "%d\n", usbvision->saturation >> 8);
610} 605}
611static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); 606static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
612 607
613static ssize_t show_streaming(struct class_device *class_dev, char *buf) 608static ssize_t show_streaming(struct class_device *class_dev, char *buf)
614{ 609{
615 struct video_device *vdev = to_video_device(class_dev); 610 struct video_device *vdev = to_video_device(class_dev);
616 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 611 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
617 return sprintf(buf, "%s\n", YES_NO(usbvision->streaming)); 612 return sprintf(buf, "%s\n", YES_NO(usbvision->streaming));
618} 613}
619static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); 614static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL);
620 615
621static ssize_t show_overlay(struct class_device *class_dev, char *buf) 616static ssize_t show_overlay(struct class_device *class_dev, char *buf)
622{ 617{
623 struct video_device *vdev = to_video_device(class_dev); 618 struct video_device *vdev = to_video_device(class_dev);
624 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 619 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
625 return sprintf(buf, "%s\n", YES_NO(usbvision->overlay)); 620 return sprintf(buf, "%s\n", YES_NO(usbvision->overlay));
626} 621}
627static CLASS_DEVICE_ATTR(overlay, S_IRUGO, show_overlay, NULL); 622static CLASS_DEVICE_ATTR(overlay, S_IRUGO, show_overlay, NULL);
628 623
629static ssize_t show_compression(struct class_device *class_dev, char *buf) 624static ssize_t show_compression(struct class_device *class_dev, char *buf)
630{ 625{
631 struct video_device *vdev = to_video_device(class_dev); 626 struct video_device *vdev = to_video_device(class_dev);
632 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 627 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
633 return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); 628 return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
634} 629}
635static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); 630static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL);
636 631
637static ssize_t show_device_bridge(struct class_device *class_dev, char *buf) 632static ssize_t show_device_bridge(struct class_device *class_dev, char *buf)
638{ 633{
639 struct video_device *vdev = to_video_device(class_dev); 634 struct video_device *vdev = to_video_device(class_dev);
640 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 635 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
641 return sprintf(buf, "%d\n", usbvision->bridgeType); 636 return sprintf(buf, "%d\n", usbvision->bridgeType);
642} 637}
643static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); 638static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL);
644 639
645static void usbvision_create_sysfs(struct video_device *vdev) 640static void usbvision_create_sysfs(struct video_device *vdev)
@@ -1195,9 +1190,9 @@ void usbvision_osd_stats(struct usb_usbvision *usbvision,
1195 * 1190 *
1196 * Parameters: 1191 * Parameters:
1197 * fullframe: if TRUE then entire frame is filled, otherwise the procedure 1192 * fullframe: if TRUE then entire frame is filled, otherwise the procedure
1198 * continues from the current scanline. 1193 * continues from the current scanline.
1199 * pmode 0: fill the frame with solid blue color (like on VCR or TV) 1194 * pmode 0: fill the frame with solid blue color (like on VCR or TV)
1200 * 1: Draw a colored grid 1195 * 1: Draw a colored grid
1201 * 1196 *
1202 */ 1197 */
1203void usbvision_testpattern(struct usb_usbvision *usbvision, int fullframe, 1198void usbvision_testpattern(struct usb_usbvision *usbvision, int fullframe,
@@ -1608,7 +1603,7 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
1608 1603
1609 if (overlay) { 1604 if (overlay) {
1610 frame = &usbvision->overlay_frame; 1605 frame = &usbvision->overlay_frame;
1611 imageSize = frame->frmwidth * frame->frmheight; 1606 imageSize = frame->frmwidth * frame->frmheight;
1612 if (usbvision->overlay_base == NULL) { 1607 if (usbvision->overlay_base == NULL) {
1613 //video_buffer is not set yet 1608 //video_buffer is not set yet
1614 return ParseState_NextFrame; 1609 return ParseState_NextFrame;
@@ -1618,26 +1613,26 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
1618 } 1613 }
1619 else { 1614 else {
1620 frame = &usbvision->frame[usbvision->curFrameNum]; 1615 frame = &usbvision->frame[usbvision->curFrameNum];
1621 imageSize = frame->frmwidth * frame->frmheight; 1616 imageSize = frame->frmwidth * frame->frmheight;
1622 if ( (frame->v4l2_format.format == V4L2_PIX_FMT_YUV422P) || 1617 if ( (frame->v4l2_format.format == V4L2_PIX_FMT_YUV422P) ||
1623 (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) ) 1618 (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) )
1624 { // this is a planar format 1619 { // this is a planar format
1625 //... v4l2_linesize not used here. 1620 //... v4l2_linesize not used here.
1626 f = frame->data + (frame->width * frame->curline); 1621 f = frame->data + (frame->width * frame->curline);
1627 } else 1622 } else
1628 f = frame->data + (frame->v4l2_linesize * frame->curline); 1623 f = frame->data + (frame->v4l2_linesize * frame->curline);
1629 1624
1630 if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV){ //initialise u and v pointers 1625 if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV){ //initialise u and v pointers
1631 // get base of u and b planes add halfoffset 1626 // get base of u and b planes add halfoffset
1632 1627
1633 u = frame->data 1628 u = frame->data
1634 + imageSize 1629 + imageSize
1635 + (frame->frmwidth >>1) * frame->curline ; 1630 + (frame->frmwidth >>1) * frame->curline ;
1636 v = u + (imageSize >>1 ); 1631 v = u + (imageSize >>1 );
1637 1632
1638 } else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420){ 1633 } else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420){
1639 1634
1640 v = frame->data + imageSize + ((frame->curline* (frame->width))>>2) ; 1635 v = frame->data + imageSize + ((frame->curline* (frame->width))>>2) ;
1641 u = v + (imageSize >>2) ; 1636 u = v + (imageSize >>2) ;
1642 } 1637 }
1643 } 1638 }
@@ -1687,7 +1682,7 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
1687 return ParseState_NextFrame; 1682 return ParseState_NextFrame;
1688 } 1683 }
1689 1684
1690 bytes_per_pixel = frame->v4l2_format.bytes_per_pixel; 1685 bytes_per_pixel = frame->v4l2_format.bytes_per_pixel;
1691 clipmask_index = frame->curline * MAX_FRAME_WIDTH; 1686 clipmask_index = frame->curline * MAX_FRAME_WIDTH;
1692 1687
1693 scratch_get(usbvision, StripData, StripLen); 1688 scratch_get(usbvision, StripData, StripLen);
@@ -1723,7 +1718,7 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
1723 if (BlockPos > StripLen) { 1718 if (BlockPos > StripLen) {
1724 usbvision->stripLenErrors++; 1719 usbvision->stripLenErrors++;
1725 } 1720 }
1726 1721
1727 for (Idx = 0; Idx < IdxEnd; Idx++) { 1722 for (Idx = 0; Idx < IdxEnd; Idx++) {
1728 if((overlay) && (clipped_pixel(clipmask_index))) { 1723 if((overlay) && (clipped_pixel(clipmask_index))) {
1729 f += bytes_per_pixel; 1724 f += bytes_per_pixel;
@@ -1741,15 +1736,15 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
1741 } 1736 }
1742 else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) { 1737 else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) {
1743 *f++ = Y [Idx]; 1738 *f++ = Y [Idx];
1744 if ( !(( Idx & 0x01 ) | ( frame->curline & 0x01 )) ){ 1739 if ( !(( Idx & 0x01 ) | ( frame->curline & 0x01 )) ){
1745 1740
1746/* only need do this for 1 in 4 pixels */ 1741/* only need do this for 1 in 4 pixels */
1747/* intraframe buffer is YUV420 format */ 1742/* intraframe buffer is YUV420 format */
1748 1743
1749 *u++ = U[Idx >>1]; 1744 *u++ = U[Idx >>1];
1750 *v++ = V[Idx >>1]; 1745 *v++ = V[Idx >>1];
1751 } 1746 }
1752 1747
1753 } 1748 }
1754 else { 1749 else {
1755 YUV_TO_RGB_BY_THE_BOOK(Y[Idx], U[Idx/2], V[Idx/2], rv, gv, bv); 1750 YUV_TO_RGB_BY_THE_BOOK(Y[Idx], U[Idx/2], V[Idx/2], rv, gv, bv);
@@ -1780,12 +1775,12 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
1780 } 1775 }
1781 clipmask_index++; 1776 clipmask_index++;
1782 } 1777 }
1783 /* Deal with non-integer no. of bytes for YUV420P */ 1778 /* Deal with non-integer no. of bytes for YUV420P */
1784 if (frame->v4l2_format.format != V4L2_PIX_FMT_YVU420 ) 1779 if (frame->v4l2_format.format != V4L2_PIX_FMT_YVU420 )
1785 *pcopylen += frame->v4l2_linesize; 1780 *pcopylen += frame->v4l2_linesize;
1786 else 1781 else
1787 *pcopylen += frame->curline & 0x01 ? frame->v4l2_linesize : frame->v4l2_linesize << 1; 1782 *pcopylen += frame->curline & 0x01 ? frame->v4l2_linesize : frame->v4l2_linesize << 1;
1788 1783
1789 frame->curline += 1; 1784 frame->curline += 1;
1790 1785
1791 if (frame->curline >= frame->frmheight) { 1786 if (frame->curline >= frame->frmheight) {
@@ -1846,7 +1841,7 @@ static enum ParseState usbvision_parse_lines_420(struct usb_usbvision *usbvision
1846 /* Make sure there's enough data for the entire line */ 1841 /* Make sure there's enough data for the entire line */
1847 /* In this mode usbvision transfer 3 bytes for every 2 pixels */ 1842 /* In this mode usbvision transfer 3 bytes for every 2 pixels */
1848 /* I need two lines to decode the color */ 1843 /* I need two lines to decode the color */
1849 bytes_per_pixel = frame->v4l2_format.bytes_per_pixel; 1844 bytes_per_pixel = frame->v4l2_format.bytes_per_pixel;
1850 stretch_bytes = (usbvision->stretch_width - 1) * bytes_per_pixel; 1845 stretch_bytes = (usbvision->stretch_width - 1) * bytes_per_pixel;
1851 clipmask_even_index = frame->curline * MAX_FRAME_WIDTH; 1846 clipmask_even_index = frame->curline * MAX_FRAME_WIDTH;
1852 clipmask_odd_index = clipmask_even_index + MAX_FRAME_WIDTH; 1847 clipmask_odd_index = clipmask_even_index + MAX_FRAME_WIDTH;
@@ -2276,7 +2271,7 @@ static void usbvision_isocIrq(struct urb *urb, struct pt_regs *regs)
2276 urb->iso_frame_desc[i].status = 0; 2271 urb->iso_frame_desc[i].status = 0;
2277 urb->iso_frame_desc[i].actual_length = 0; 2272 urb->iso_frame_desc[i].actual_length = 0;
2278 } 2273 }
2279 urb->status = 0; 2274 urb->status = 0;
2280 urb->dev = usbvision->dev; 2275 urb->dev = usbvision->dev;
2281 errCode = usb_submit_urb (urb, GFP_ATOMIC); 2276 errCode = usb_submit_urb (urb, GFP_ATOMIC);
2282 2277
@@ -2562,10 +2557,10 @@ static int attach_inform(struct i2c_client *client)
2562 } 2557 }
2563 if ((usbvision->have_tuner) && (usbvision->tuner_type != -1)) { 2558 if ((usbvision->have_tuner) && (usbvision->tuner_type != -1)) {
2564 tun_addr.mode_mask = T_ANALOG_TV; 2559 tun_addr.mode_mask = T_ANALOG_TV;
2565 tun_addr.type = usbvision->tuner_type; 2560 tun_addr.type = usbvision->tuner_type;
2566 tun_addr.addr = ADDR_UNSET; 2561 tun_addr.addr = ADDR_UNSET;
2567 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); 2562 client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr);
2568 2563
2569 call_i2c_clients(usbvision, VIDIOC_S_INPUT, &usbvision->input.index); 2564 call_i2c_clients(usbvision, VIDIOC_S_INPUT, &usbvision->input.index);
2570 } 2565 }
2571 // FIXME : need to add a call VIDIOC_S_CTRL for each control 2566 // FIXME : need to add a call VIDIOC_S_CTRL for each control
@@ -2733,7 +2728,7 @@ static int usbvision_i2c_write(void *data, unsigned char addr, char *buf,
2733 int retval; 2728 int retval;
2734 int wrcount = 0; 2729 int wrcount = 0;
2735 int count; 2730 int count;
2736 int maxLen = 4; 2731 int maxLen = 4;
2737 struct usb_usbvision *usbvision = (struct usb_usbvision *) data; 2732 struct usb_usbvision *usbvision = (struct usb_usbvision *) data;
2738 2733
2739 while (len > 0) { 2734 while (len > 0) {
@@ -2841,7 +2836,7 @@ static int usbvision_init_i2c(struct usb_usbvision *usbvision)
2841 break; 2836 break;
2842 } 2837 }
2843 if (usbvision_device_data[usbvision->DevModel].Tuner == 1) { 2838 if (usbvision_device_data[usbvision->DevModel].Tuner == 1) {
2844 request_module("tuner"); 2839 request_module("tuner");
2845 } 2840 }
2846 } 2841 }
2847#endif 2842#endif
@@ -3001,7 +2996,7 @@ static int usbvision_set_output(struct usb_usbvision *usbvision, int width,
3001 } 2996 }
3002 2997
3003 if (usbvision->input.std & V4L2_STD_625_50) { 2998 if (usbvision->input.std & V4L2_STD_625_50) {
3004 frameDrop = frameRate * 32 / 25 - 1; 2999 frameDrop = frameRate * 32 / 25 - 1;
3005 } 3000 }
3006 else if (usbvision->input.std & V4L2_STD_525_60) { 3001 else if (usbvision->input.std & V4L2_STD_525_60) {
3007 frameDrop = frameRate * 32 / 30 - 1; 3002 frameDrop = frameRate * 32 / 30 - 1;
@@ -3042,7 +3037,7 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
3042 value[2] = 0x00; // Reg.46 Force intra mode on all new frames 3037 value[2] = 0x00; // Reg.46 Force intra mode on all new frames
3043 value[3] = 0x00; // Reg.47 FORCE_UP <- 0 normal operation (not force) 3038 value[3] = 0x00; // Reg.47 FORCE_UP <- 0 normal operation (not force)
3044 value[4] = 0xA2; // Reg.48 BUF_THR I'm not sure if this does something in not compressed mode. 3039 value[4] = 0xA2; // Reg.48 BUF_THR I'm not sure if this does something in not compressed mode.
3045 value[5] = 0x00; // Reg.49 DVI_YUV This has nothing to do with compression 3040 value[5] = 0x00; // Reg.49 DVI_YUV This has nothing to do with compression
3046 3041
3047 //catched values for NT1004 3042 //catched values for NT1004
3048 // value[0] = 0xFF; // Never apply intra mode automatically 3043 // value[0] = 0xFF; // Never apply intra mode automatically
@@ -3196,7 +3191,7 @@ static int usbvision_set_input(struct usb_usbvision *usbvision)
3196 dvi_yuv_value = usbvision_device_data[usbvision->DevModel].Dvi_yuv & 0xff; 3191 dvi_yuv_value = usbvision_device_data[usbvision->DevModel].Dvi_yuv & 0xff;
3197 } 3192 }
3198 else if(usbvision_device_data[usbvision->DevModel].Codec == CODEC_SAA7113) { 3193 else if(usbvision_device_data[usbvision->DevModel].Codec == CODEC_SAA7113) {
3199 /* This changes as the fine sync control changes. Further investigation necessary */ 3194 /* This changes as the fine sync control changes. Further investigation necessary */
3200 dvi_yuv_value = 0x06; 3195 dvi_yuv_value = 0x06;
3201 } 3196 }
3202 3197
@@ -3313,7 +3308,7 @@ static void usbvision_powerOffTimer(unsigned long data)
3313 del_timer(&usbvision->powerOffTimer); 3308 del_timer(&usbvision->powerOffTimer);
3314 INIT_WORK(&usbvision->powerOffWork, call_usbvision_power_off, usbvision); 3309 INIT_WORK(&usbvision->powerOffWork, call_usbvision_power_off, usbvision);
3315 (void) schedule_work(&usbvision->powerOffWork); 3310 (void) schedule_work(&usbvision->powerOffWork);
3316 3311
3317} 3312}
3318 3313
3319 3314
@@ -3421,7 +3416,7 @@ static int usbvision_setup(struct usb_usbvision *usbvision)
3421 usbvision_set_input(usbvision); 3416 usbvision_set_input(usbvision);
3422 usbvision_set_output(usbvision, MAX_USB_WIDTH, MAX_USB_HEIGHT); 3417 usbvision_set_output(usbvision, MAX_USB_WIDTH, MAX_USB_HEIGHT);
3423 usbvision_restart_isoc(usbvision); 3418 usbvision_restart_isoc(usbvision);
3424 3419
3425 /* cosas del PCM */ 3420 /* cosas del PCM */
3426 return USBVISION_IS_OPERATIONAL(usbvision); 3421 return USBVISION_IS_OPERATIONAL(usbvision);
3427} 3422}
@@ -3532,12 +3527,12 @@ static void usbvision_stop_isoc(struct usb_usbvision *usbvision)
3532 usb_kill_urb(usbvision->sbuf[bufIdx].urb); 3527 usb_kill_urb(usbvision->sbuf[bufIdx].urb);
3533 usb_free_urb(usbvision->sbuf[bufIdx].urb); 3528 usb_free_urb(usbvision->sbuf[bufIdx].urb);
3534 usbvision->sbuf[bufIdx].urb = NULL; 3529 usbvision->sbuf[bufIdx].urb = NULL;
3535 } 3530 }
3536 3531
3537 3532
3538 PDEBUG(DBG_ISOC, "%s: streaming=0\n", __FUNCTION__); 3533 PDEBUG(DBG_ISOC, "%s: streaming=0\n", __FUNCTION__);
3539 usbvision->streaming = 0; 3534 usbvision->streaming = 0;
3540 3535
3541 3536
3542 if (!usbvision->remove_pending) { 3537 if (!usbvision->remove_pending) {
3543 3538
@@ -3615,7 +3610,7 @@ static int usbvision_new_frame(struct usb_usbvision *usbvision, int framenum)
3615static int usbvision_muxsel(struct usb_usbvision *usbvision, int channel, int norm) 3610static int usbvision_muxsel(struct usb_usbvision *usbvision, int channel, int norm)
3616{ 3611{
3617 int mode[4]; 3612 int mode[4];
3618 int audio[]= {1, 0, 0, 0}; 3613 int audio[]= {1, 0, 0, 0};
3619 struct v4l2_routing route; 3614 struct v4l2_routing route;
3620 //channel 0 is TV with audiochannel 1 (tuner mono) 3615 //channel 0 is TV with audiochannel 1 (tuner mono)
3621 //channel 1 is Composite with audio channel 0 (line in) 3616 //channel 1 is Composite with audio channel 0 (line in)
@@ -3636,7 +3631,7 @@ static int usbvision_muxsel(struct usb_usbvision *usbvision, int channel, int no
3636 3631
3637 // set the new channel 3632 // set the new channel
3638 // Regular USB TV Tuners -> channel: 0 = Television, 1 = Composite, 2 = S-Video 3633 // Regular USB TV Tuners -> channel: 0 = Television, 1 = Composite, 2 = S-Video
3639 // Four video input devices -> channel: 0 = Chan White, 1 = Chan Green, 2 = Chan Yellow, 3 = Chan Red 3634 // Four video input devices -> channel: 0 = Chan White, 1 = Chan Green, 2 = Chan Yellow, 3 = Chan Red
3640 3635
3641 switch (usbvision_device_data[usbvision->DevModel].Codec) { 3636 switch (usbvision_device_data[usbvision->DevModel].Codec) {
3642 case CODEC_SAA7113: 3637 case CODEC_SAA7113:
@@ -3646,10 +3641,10 @@ static int usbvision_muxsel(struct usb_usbvision *usbvision, int channel, int no
3646 else { 3641 else {
3647 mode[2] = 7; 3642 mode[2] = 7;
3648 } 3643 }
3649 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { 3644 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
3650 mode[0] = 0; mode[1] = 2; mode[3] = 3; // Special for four input devices 3645 mode[0] = 0; mode[1] = 2; mode[3] = 3; // Special for four input devices
3651 } 3646 }
3652 else { 3647 else {
3653 mode[0] = 0; mode[1] = 2; //modes for regular saa7113 devices 3648 mode[0] = 0; mode[1] = 2; //modes for regular saa7113 devices
3654 } 3649 }
3655 break; 3650 break;
@@ -3748,7 +3743,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
3748 err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size); 3743 err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size);
3749 errCode = -ENOMEM; 3744 errCode = -ENOMEM;
3750 } 3745 }
3751 3746
3752 } 3747 }
3753 if (errCode) { 3748 if (errCode) {
3754 /* Have to free all that memory */ 3749 /* Have to free all that memory */
@@ -3940,8 +3935,8 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
3940 case 0: 3935 case 0:
3941 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { 3936 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
3942 strcpy(vi->name, "White Video Input"); 3937 strcpy(vi->name, "White Video Input");
3943 } 3938 }
3944 else { 3939 else {
3945 strcpy(vi->name, "Television"); 3940 strcpy(vi->name, "Television");
3946 vi->type = V4L2_INPUT_TYPE_TUNER; 3941 vi->type = V4L2_INPUT_TYPE_TUNER;
3947 vi->audioset = 1; 3942 vi->audioset = 1;
@@ -3950,30 +3945,30 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
3950 } 3945 }
3951 break; 3946 break;
3952 case 1: 3947 case 1:
3953 vi->type = V4L2_INPUT_TYPE_CAMERA; 3948 vi->type = V4L2_INPUT_TYPE_CAMERA;
3954 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { 3949 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
3955 strcpy(vi->name, "Green Video Input"); 3950 strcpy(vi->name, "Green Video Input");
3956 } 3951 }
3957 else { 3952 else {
3958 strcpy(vi->name, "Composite Video Input"); 3953 strcpy(vi->name, "Composite Video Input");
3959 } 3954 }
3960 vi->std = V4L2_STD_PAL; 3955 vi->std = V4L2_STD_PAL;
3961 break; 3956 break;
3962 case 2: 3957 case 2:
3963 vi->type = V4L2_INPUT_TYPE_CAMERA; 3958 vi->type = V4L2_INPUT_TYPE_CAMERA;
3964 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { 3959 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
3965 strcpy(vi->name, "Yellow Video Input"); 3960 strcpy(vi->name, "Yellow Video Input");
3966 } 3961 }
3967 else { 3962 else {
3968 strcpy(vi->name, "S-Video Input"); 3963 strcpy(vi->name, "S-Video Input");
3969 } 3964 }
3970 vi->std = V4L2_STD_PAL; 3965 vi->std = V4L2_STD_PAL;
3971 break; 3966 break;
3972 case 3: 3967 case 3:
3973 vi->type = V4L2_INPUT_TYPE_CAMERA; 3968 vi->type = V4L2_INPUT_TYPE_CAMERA;
3974 strcpy(vi->name, "Red Video Input"); 3969 strcpy(vi->name, "Red Video Input");
3975 vi->std = V4L2_STD_PAL; 3970 vi->std = V4L2_STD_PAL;
3976 break; 3971 break;
3977 } 3972 }
3978 PDEBUG(DBG_IOCTL, "VIDIOC_ENUMINPUT name=%s:%d tuners=%d type=%d norm=%x", vi->name, vi->index, vi->tuner,vi->type,(int)vi->std); 3973 PDEBUG(DBG_IOCTL, "VIDIOC_ENUMINPUT name=%s:%d tuners=%d type=%d norm=%x", vi->name, vi->index, vi->tuner,vi->type,(int)vi->std);
3979 return 0; 3974 return 0;
@@ -4008,13 +4003,13 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4008 } 4003 }
4009 return 0; 4004 return 0;
4010 } 4005 }
4011 case VIDIOC_G_INPUT: 4006 case VIDIOC_G_INPUT:
4012 { 4007 {
4013 int *input = arg; 4008 int *input = arg;
4014 *input = usbvision->input.index; 4009 *input = usbvision->input.index;
4015 return 0; 4010 return 0;
4016 } 4011 }
4017 case VIDIOC_S_INPUT: 4012 case VIDIOC_S_INPUT:
4018 { 4013 {
4019 int *input = arg; 4014 int *input = arg;
4020 if ((*input >= usbvision->video_inputs) || (*input < 0) ) 4015 if ((*input >= usbvision->video_inputs) || (*input < 0) )
@@ -4028,14 +4023,14 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4028 up(&usbvision->lock); 4023 up(&usbvision->lock);
4029 return 0; 4024 return 0;
4030 } 4025 }
4031 case VIDIOC_G_STD: 4026 case VIDIOC_G_STD:
4032 { 4027 {
4033 v4l2_std_id *std = arg; 4028 v4l2_std_id *std = arg;
4034 *std = usbvision->input.std; 4029 *std = usbvision->input.std;
4035 PDEBUG(DBG_IOCTL, "VIDIOC_G_STD std_id=%x", (unsigned)*std); 4030 PDEBUG(DBG_IOCTL, "VIDIOC_G_STD std_id=%x", (unsigned)*std);
4036 return 0; 4031 return 0;
4037 } 4032 }
4038 case VIDIOC_S_STD: 4033 case VIDIOC_S_STD:
4039 { 4034 {
4040 v4l2_std_id *std = arg; 4035 v4l2_std_id *std = arg;
4041 4036
@@ -4049,7 +4044,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4049 PDEBUG(DBG_IOCTL, "VIDIOC_S_STD std_id=%x", (unsigned)*std); 4044 PDEBUG(DBG_IOCTL, "VIDIOC_S_STD std_id=%x", (unsigned)*std);
4050 return 0; 4045 return 0;
4051 } 4046 }
4052 case VIDIOC_G_TUNER: 4047 case VIDIOC_G_TUNER:
4053 { 4048 {
4054 struct v4l2_tuner *vt = arg; 4049 struct v4l2_tuner *vt = arg;
4055 struct v4l2_tuner status; 4050 struct v4l2_tuner status;
@@ -4118,55 +4113,35 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4118 // FIXME: void function ??? 4113 // FIXME: void function ???
4119 return 0; 4114 return 0;
4120 } 4115 }
4121 case VIDIOC_QUERYCTRL: 4116 case VIDIOC_QUERYCTRL:
4122 { 4117 {
4123 struct v4l2_queryctrl *qc = arg; 4118 struct v4l2_queryctrl *ctrl = arg;
4124 switch(qc->id) { 4119 int id=ctrl->id;
4125 case V4L2_CID_BRIGHTNESS: 4120
4126 case V4L2_CID_HUE: 4121 memset(ctrl,0,sizeof(*ctrl));
4127 case V4L2_CID_SATURATION: 4122 ctrl->id=id;
4128 case V4L2_CID_CONTRAST: 4123
4129 case V4L2_CID_AUDIO_VOLUME: 4124 i2c_clients_command(&usbvision->i2c_adap, cmd, arg);
4130 case V4L2_CID_AUDIO_MUTE: 4125
4131 return v4l2_ctrl_query_fill_std(qc); 4126 if (ctrl->type)
4132 break; 4127 return 0;
4133 default: 4128 else
4134 return -EINVAL; 4129 return -EINVAL;
4135 } 4130
4136 return 0; 4131 PDEBUG(DBG_IOCTL,"VIDIOC_QUERYCTRL id=%x value=%x",ctrl->id,ctrl->type);
4137 } 4132 }
4138 case VIDIOC_G_CTRL: 4133 case VIDIOC_G_CTRL:
4139 { 4134 {
4140 struct v4l2_control *ctrl = arg; 4135 struct v4l2_control *ctrl = arg;
4141 4136
4142 switch (ctrl->id) { 4137 PDEBUG(DBG_IOCTL,"VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
4143 case V4L2_CID_BRIGHTNESS: 4138 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl);
4144 ctrl->value = usbvision->brightness;
4145 break;
4146 case V4L2_CID_CONTRAST:
4147 ctrl->value = usbvision->contrast;
4148 break;
4149 case V4L2_CID_SATURATION:
4150 ctrl->value = usbvision->saturation;
4151 break;
4152 case V4L2_CID_HUE:
4153 ctrl->value = usbvision->hue;
4154 break;
4155 case V4L2_CID_AUDIO_VOLUME:
4156 /* ctrl->value = usbvision->volume; */
4157 break;
4158 case V4L2_CID_AUDIO_MUTE:
4159 ctrl->value = usbvision->AudioMute;
4160 break;
4161 default:
4162 return -EINVAL;
4163 }
4164 PDEBUG(DBG_IOCTL, "VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
4165 return 0; 4139 return 0;
4166 } 4140 }
4167 case VIDIOC_S_CTRL: 4141 case VIDIOC_S_CTRL:
4168 { 4142 {
4169 struct v4l2_control *ctrl = arg; 4143 struct v4l2_control *ctrl = arg;
4144
4170 PDEBUG(DBG_IOCTL, "VIDIOC_S_CTRL id=%x value=%x",ctrl->id,ctrl->value); 4145 PDEBUG(DBG_IOCTL, "VIDIOC_S_CTRL id=%x value=%x",ctrl->id,ctrl->value);
4171 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); 4146 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl);
4172 return 0; 4147 return 0;
@@ -4213,7 +4188,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4213 vb->sequence = usbvision->frame_num; 4188 vb->sequence = usbvision->frame_num;
4214 return 0; 4189 return 0;
4215 } 4190 }
4216 case VIDIOC_QBUF: // VIDIOCMCAPTURE + VIDIOCSYNC 4191 case VIDIOC_QBUF: // VIDIOCMCAPTURE + VIDIOCSYNC
4217 { 4192 {
4218 struct v4l2_buffer *vb = arg; 4193 struct v4l2_buffer *vb = arg;
4219 struct usbvision_frame *frame; 4194 struct usbvision_frame *frame;
@@ -4308,7 +4283,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4308 case VIDIOC_STREAMON: 4283 case VIDIOC_STREAMON:
4309 { 4284 {
4310 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; 4285 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
4311 call_i2c_clients(usbvision,VIDIOC_STREAMON , &b); 4286 call_i2c_clients(usbvision,VIDIOC_STREAMON , &b);
4312 return 0; 4287 return 0;
4313 } 4288 }
4314 case VIDIOC_STREAMOFF: 4289 case VIDIOC_STREAMOFF:
@@ -4323,7 +4298,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4323 up(&usbvision->lock); 4298 up(&usbvision->lock);
4324 return 0; 4299 return 0;
4325 } 4300 }
4326 case VIDIOC_G_FBUF: 4301 case VIDIOC_G_FBUF:
4327 { 4302 {
4328 struct v4l2_framebuffer *vb = arg; 4303 struct v4l2_framebuffer *vb = arg;
4329 4304
@@ -4389,7 +4364,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4389 if ( (dga == 0) && 4364 if ( (dga == 0) &&
4390 (vfd->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) && 4365 (vfd->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) &&
4391 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) && 4366 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) &&
4392 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) { 4367 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) {
4393 return -EINVAL; 4368 return -EINVAL;
4394 } 4369 }
4395 if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) { 4370 if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) {
@@ -4403,11 +4378,11 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4403 case VIDIOC_G_FMT: 4378 case VIDIOC_G_FMT:
4404 { 4379 {
4405 struct v4l2_format *vf = arg; 4380 struct v4l2_format *vf = arg;
4406 4381
4407 if ( (dga == 0) && 4382 if ( (dga == 0) &&
4408 (vf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) && 4383 (vf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) &&
4409 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) && 4384 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) &&
4410 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) { 4385 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) {
4411 return -EINVAL; 4386 return -EINVAL;
4412 } 4387 }
4413 down(&usbvision->lock); 4388 down(&usbvision->lock);
@@ -4417,7 +4392,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4417 vf->fmt.win.w.left, vf->fmt.win.w.top, vf->fmt.win.w.width, vf->fmt.win.w.height, vf->fmt.win.chromakey, vf->fmt.win.clipcount); 4392 vf->fmt.win.w.left, vf->fmt.win.w.top, vf->fmt.win.w.width, vf->fmt.win.w.height, vf->fmt.win.chromakey, vf->fmt.win.clipcount);
4418 return 0; 4393 return 0;
4419 } 4394 }
4420 case VIDIOC_S_FMT: 4395 case VIDIOC_S_FMT:
4421 { 4396 {
4422 struct v4l2_format *vf = arg; 4397 struct v4l2_format *vf = arg;
4423 struct v4l2_clip *vc=NULL; 4398 struct v4l2_clip *vc=NULL;
@@ -4426,7 +4401,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4426 if ( (dga == 0) && 4401 if ( (dga == 0) &&
4427 (vf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) && 4402 (vf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) &&
4428 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) && 4403 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) &&
4429 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) { 4404 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) {
4430 return -EINVAL; 4405 return -EINVAL;
4431 } 4406 }
4432 if(vf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) { 4407 if(vf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY) {
@@ -4518,10 +4493,10 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
4518 case VIDIOC_OVERLAY: 4493 case VIDIOC_OVERLAY:
4519 { 4494 {
4520 int *v = arg; 4495 int *v = arg;
4521 4496
4522 if ( (dga == 0) && 4497 if ( (dga == 0) &&
4523 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) && 4498 (usbvision->palette.format != V4L2_PIX_FMT_YVU420) &&
4524 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) { 4499 (usbvision->palette.format != V4L2_PIX_FMT_YUV422P) ) {
4525 PDEBUG(DBG_IOCTL, "VIDIOC_OVERLAY DGA disabled"); 4500 PDEBUG(DBG_IOCTL, "VIDIOC_OVERLAY DGA disabled");
4526 return -EINVAL; 4501 return -EINVAL;
4527 } 4502 }
@@ -4609,7 +4584,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char *buf,
4609 goto usbvision_v4l2_read_done; 4584 goto usbvision_v4l2_read_done;
4610 } 4585 }
4611 PDEBUG(DBG_IO, "Waiting frame grabbing"); 4586 PDEBUG(DBG_IO, "Waiting frame grabbing");
4612 rc = wait_event_interruptible(frame->wq, (frame->grabstate == FrameState_Done) || 4587 rc = wait_event_interruptible(frame->wq, (frame->grabstate == FrameState_Done) ||
4613 (frame->grabstate == FrameState_Error)); 4588 (frame->grabstate == FrameState_Error));
4614 if (rc) { 4589 if (rc) {
4615 goto usbvision_v4l2_read_done; 4590 goto usbvision_v4l2_read_done;
@@ -4670,11 +4645,11 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
4670 4645
4671 pos = (unsigned long) usbvision->fbuf; 4646 pos = (unsigned long) usbvision->fbuf;
4672 while (size > 0) { 4647 while (size > 0) {
4673 4648
4674// Really ugly.... 4649// Really ugly....
4675 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) //Compatibility for 2.6.10+ kernels 4650 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) //Compatibility for 2.6.10+ kernels
4676 page = vmalloc_to_pfn((void *)pos); 4651 page = vmalloc_to_pfn((void *)pos);
4677 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { 4652 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
4678 return -EAGAIN; 4653 return -EAGAIN;
4679 } 4654 }
4680 #else //Compatibility for 2.6.0 - 2.6.9 kernels 4655 #else //Compatibility for 2.6.0 - 2.6.9 kernels
@@ -4791,7 +4766,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4791 /*************************** 4766 /***************************
4792 * V4L2 IOCTLs * 4767 * V4L2 IOCTLs *
4793 ***************************/ 4768 ***************************/
4794 case VIDIOC_QUERYCAP: 4769 case VIDIOC_QUERYCAP:
4795 { 4770 {
4796 struct v4l2_capability *vc=arg; 4771 struct v4l2_capability *vc=arg;
4797 memset(vc, 0, sizeof(struct v4l2_capability)); 4772 memset(vc, 0, sizeof(struct v4l2_capability));
@@ -4803,7 +4778,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4803 PDEBUG(DBG_RIO, "%s: VIDIOC_QUERYCAP", __FUNCTION__); 4778 PDEBUG(DBG_RIO, "%s: VIDIOC_QUERYCAP", __FUNCTION__);
4804 return 0; 4779 return 0;
4805 } 4780 }
4806 case VIDIOC_QUERYCTRL: 4781 case VIDIOC_QUERYCTRL:
4807 { 4782 {
4808 struct v4l2_queryctrl *qc = arg; 4783 struct v4l2_queryctrl *qc = arg;
4809 switch(qc->id) 4784 switch(qc->id)
@@ -4817,7 +4792,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4817 } 4792 }
4818 return 0; 4793 return 0;
4819 } 4794 }
4820 case VIDIOC_G_CTRL: 4795 case VIDIOC_G_CTRL:
4821 { 4796 {
4822 struct v4l2_control *ctrl = arg; 4797 struct v4l2_control *ctrl = arg;
4823 PDEBUG(DBG_IOCTL, "VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value); 4798 PDEBUG(DBG_IOCTL, "VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
@@ -4833,7 +4808,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4833 } 4808 }
4834 return 0; 4809 return 0;
4835 } 4810 }
4836 case VIDIOC_S_CTRL: 4811 case VIDIOC_S_CTRL:
4837 { 4812 {
4838 struct v4l2_control *ctrl = arg; 4813 struct v4l2_control *ctrl = arg;
4839 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); 4814 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl);
@@ -4841,7 +4816,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4841 PDEBUG(DBG_RIO, "%s: VIDIOC_S_CTRL id=%x value=%x", __FUNCTION__,ctrl->id,ctrl->value); 4816 PDEBUG(DBG_RIO, "%s: VIDIOC_S_CTRL id=%x value=%x", __FUNCTION__,ctrl->id,ctrl->value);
4842 return 0; 4817 return 0;
4843 } 4818 }
4844 case VIDIOC_G_TUNER: 4819 case VIDIOC_G_TUNER:
4845 { 4820 {
4846 struct v4l2_tuner *vt = arg; 4821 struct v4l2_tuner *vt = arg;
4847 4822
@@ -4862,7 +4837,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4862 PDEBUG(DBG_RIO, "%s: VIDIOC_G_TUNER signal=%d", __FUNCTION__, vt->signal); 4837 PDEBUG(DBG_RIO, "%s: VIDIOC_G_TUNER signal=%d", __FUNCTION__, vt->signal);
4863 return 0; 4838 return 0;
4864 } 4839 }
4865 case VIDIOC_S_TUNER: 4840 case VIDIOC_S_TUNER:
4866 { 4841 {
4867 struct v4l2_tuner *vt = arg; 4842 struct v4l2_tuner *vt = arg;
4868 4843
@@ -4873,7 +4848,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4873 PDEBUG(DBG_RIO, "%s: VIDIOC_S_TUNER", __FUNCTION__); 4848 PDEBUG(DBG_RIO, "%s: VIDIOC_S_TUNER", __FUNCTION__);
4874 return 0; 4849 return 0;
4875 } 4850 }
4876 case VIDIOC_G_AUDIO: 4851 case VIDIOC_G_AUDIO:
4877 { 4852 {
4878 struct v4l2_audio *va = arg; 4853 struct v4l2_audio *va = arg;
4879 memset(va,0, sizeof(va)); 4854 memset(va,0, sizeof(va));
@@ -4882,7 +4857,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4882 PDEBUG(DBG_IOCTL, "VIDIOC_G_AUDIO"); 4857 PDEBUG(DBG_IOCTL, "VIDIOC_G_AUDIO");
4883 return 0; 4858 return 0;
4884 } 4859 }
4885 case VIDIOC_S_AUDIO: 4860 case VIDIOC_S_AUDIO:
4886 { 4861 {
4887 struct v4l2_audio *v = arg; 4862 struct v4l2_audio *v = arg;
4888 if(v->index) { 4863 if(v->index) {
@@ -4892,7 +4867,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4892 // FIXME: void function ??? 4867 // FIXME: void function ???
4893 return 0; 4868 return 0;
4894 } 4869 }
4895 case VIDIOC_G_FREQUENCY: 4870 case VIDIOC_G_FREQUENCY:
4896 { 4871 {
4897 struct v4l2_frequency *freq = arg; 4872 struct v4l2_frequency *freq = arg;
4898 freq->tuner = 0; // Only one tuner 4873 freq->tuner = 0; // Only one tuner
@@ -4901,7 +4876,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4901 PDEBUG(DBG_RIO, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)freq->frequency); 4876 PDEBUG(DBG_RIO, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)freq->frequency);
4902 return 0; 4877 return 0;
4903 } 4878 }
4904 case VIDIOC_S_FREQUENCY: 4879 case VIDIOC_S_FREQUENCY:
4905 { 4880 {
4906 struct v4l2_frequency *freq = arg; 4881 struct v4l2_frequency *freq = arg;
4907 usbvision->freq = freq->frequency; 4882 usbvision->freq = freq->frequency;
@@ -4913,7 +4888,7 @@ static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file,
4913 /*************************** 4888 /***************************
4914 * V4L1 IOCTLs * 4889 * V4L1 IOCTLs *
4915 ***************************/ 4890 ***************************/
4916 case VIDIOCGCAP: 4891 case VIDIOCGCAP:
4917 { 4892 {
4918 struct video_capability *vc = arg; 4893 struct video_capability *vc = arg;
4919 4894
@@ -5227,18 +5202,8 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
5227 5202
5228 if (usbvision == NULL) 5203 if (usbvision == NULL)
5229 return; 5204 return;
5230
5231 model = usbvision->DevModel;
5232 5205
5233 RESTRICT_TO_RANGE(init_brightness, 0, 255); 5206 model = usbvision->DevModel;
5234 RESTRICT_TO_RANGE(init_contrast, 0, 255);
5235 RESTRICT_TO_RANGE(init_saturation, 0, 255);
5236 RESTRICT_TO_RANGE(init_hue, 0, 255);
5237
5238 usbvision->saturation = init_saturation << 8;
5239 usbvision->hue = init_hue << 8;
5240 usbvision->brightness = init_brightness << 8;
5241 usbvision->contrast = init_contrast << 8;
5242 usbvision->depth = 24; 5207 usbvision->depth = 24;
5243 usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24; 5208 usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24;
5244 5209
@@ -5393,7 +5358,7 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
5393 } 5358 }
5394 usbvision->vbi = NULL; 5359 usbvision->vbi = NULL;
5395 } 5360 }
5396 5361
5397 // Radio Device: 5362 // Radio Device:
5398 if (usbvision->rdev) { 5363 if (usbvision->rdev) {
5399 PDEBUG(DBG_PROBE, "unregister /dev/radio%d [v4l2]", usbvision->rdev->minor & 0x1f); 5364 PDEBUG(DBG_PROBE, "unregister /dev/radio%d [v4l2]", usbvision->rdev->minor & 0x1f);
@@ -5444,7 +5409,7 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
5444 } 5409 }
5445 info("USBVision[%d]: registered USBVision Radio device /dev/radio%d [v4l2]", usbvision->nr, usbvision->rdev->minor & 0x1f); 5410 info("USBVision[%d]: registered USBVision Radio device /dev/radio%d [v4l2]", usbvision->nr, usbvision->rdev->minor & 0x1f);
5446 } 5411 }
5447 // vbi Device: 5412 // vbi Device:
5448 if (usbvision_device_data[usbvision->DevModel].vbi) { 5413 if (usbvision_device_data[usbvision->DevModel].vbi) {
5449 usbvision->vbi = usbvision_vdev_init(usbvision, &usbvision_vbi_template, "USBVision VBI"); 5414 usbvision->vbi = usbvision_vdev_init(usbvision, &usbvision_vbi_template, "USBVision VBI");
5450 if (usbvision->vdev == NULL) { 5415 if (usbvision->vdev == NULL) {
@@ -5575,10 +5540,10 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
5575 /* Is it an USBVISION video dev? */ 5540 /* Is it an USBVISION video dev? */
5576 model = 0; 5541 model = 0;
5577 for(model = 0; usbvision_device_data[model].idVendor; model++) { 5542 for(model = 0; usbvision_device_data[model].idVendor; model++) {
5578 if (le16_to_cpu(dev->descriptor.idVendor) != usbvision_device_data[model].idVendor) { 5543 if (le16_to_cpu(dev->descriptor.idVendor) != usbvision_device_data[model].idVendor) {
5579 continue; 5544 continue;
5580 } 5545 }
5581 if (le16_to_cpu(dev->descriptor.idProduct) != usbvision_device_data[model].idProduct) { 5546 if (le16_to_cpu(dev->descriptor.idProduct) != usbvision_device_data[model].idProduct) {
5582 continue; 5547 continue;
5583 } 5548 }
5584 5549
@@ -5607,7 +5572,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
5607 } 5572 }
5608 5573
5609 usb_get_dev(dev); 5574 usb_get_dev(dev);
5610 5575
5611 if ((usbvision = usbvision_alloc(dev)) == NULL) { 5576 if ((usbvision = usbvision_alloc(dev)) == NULL) {
5612 err("%s: couldn't allocate USBVision struct", __FUNCTION__); 5577 err("%s: couldn't allocate USBVision struct", __FUNCTION__);
5613 return -ENOMEM; 5578 return -ENOMEM;
@@ -5617,7 +5582,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
5617 } 5582 }
5618 else if (usbvision_device_data[model].ModelString == "Dazzle Fusion Model DVC-90 Rev 1 (SECAM)") { 5583 else if (usbvision_device_data[model].ModelString == "Dazzle Fusion Model DVC-90 Rev 1 (SECAM)") {
5619 usbvision->bridgeType = BRIDGE_NT1005; 5584 usbvision->bridgeType = BRIDGE_NT1005;
5620 } 5585 }
5621 else { 5586 else {
5622 usbvision->bridgeType = BRIDGE_NT1003; 5587 usbvision->bridgeType = BRIDGE_NT1003;
5623 } 5588 }
@@ -5649,7 +5614,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, const struct us
5649 5614
5650 5615
5651 usb_set_intfdata (intf, usbvision); 5616 usb_set_intfdata (intf, usbvision);
5652 usbvision_create_sysfs(usbvision->vdev); 5617 usbvision_create_sysfs(usbvision->vdev);
5653 5618
5654 PDEBUG(DBG_PROBE, "success"); 5619 PDEBUG(DBG_PROBE, "success");
5655 return 0; 5620 return 0;
@@ -5724,7 +5689,7 @@ void customdevice_process(void)
5724 if(CustomDevice) 5689 if(CustomDevice)
5725 { 5690 {
5726 char *parse=CustomDevice; 5691 char *parse=CustomDevice;
5727 5692
5728 PDEBUG(DBG_PROBE, "CustomDevide=%s", CustomDevice); 5693 PDEBUG(DBG_PROBE, "CustomDevide=%s", CustomDevice);
5729 5694
5730 /*format is CustomDevice="0x0573 0x4D31 0 7113 3 PAL 1 1 1 5 -1 -1 -1 -1 -1" 5695 /*format is CustomDevice="0x0573 0x4D31 0 7113 3 PAL 1 1 1 5 -1 -1 -1 -1 -1"
@@ -5743,9 +5708,9 @@ void customdevice_process(void)
5743 usbvision_device_data[0].X_Offset; 5708 usbvision_device_data[0].X_Offset;
5744 usbvision_device_data[0].Y_Offset; 5709 usbvision_device_data[0].Y_Offset;
5745 usbvision_device_data[0].Dvi_yuv; 5710 usbvision_device_data[0].Dvi_yuv;
5746 usbvision_device_data[0].ModelString; 5711 usbvision_device_data[0].ModelString;
5747 */ 5712 */
5748 5713
5749 rmspace(parse); 5714 rmspace(parse);
5750 usbvision_device_data[0].ModelString="USBVISION Custom Device"; 5715 usbvision_device_data[0].ModelString="USBVISION Custom Device";
5751 5716
@@ -5852,12 +5817,12 @@ static int __init usbvision_init(void)
5852 PDEBUG(DBG_FUNC, "FUNC debugging is enabled"); 5817 PDEBUG(DBG_FUNC, "FUNC debugging is enabled");
5853 PDEBUG(DBG_I2C, "I2C debugging is enabled"); 5818 PDEBUG(DBG_I2C, "I2C debugging is enabled");
5854 5819
5855 /* disable planar mode support unless compression enabled */ 5820 /* disable planar mode support unless compression enabled */
5856 if (isocMode != ISOC_MODE_COMPRESS ) { 5821 if (isocMode != ISOC_MODE_COMPRESS ) {
5857 // FIXME : not the right way to set supported flag 5822 // FIXME : not the right way to set supported flag
5858 usbvision_v4l2_format[6].supported = 0; // V4L2_PIX_FMT_YVU420 5823 usbvision_v4l2_format[6].supported = 0; // V4L2_PIX_FMT_YVU420
5859 usbvision_v4l2_format[7].supported = 0; // V4L2_PIX_FMT_YUV422P 5824 usbvision_v4l2_format[7].supported = 0; // V4L2_PIX_FMT_YUV422P
5860 } 5825 }
5861 5826
5862 customdevice_process(); 5827 customdevice_process();
5863 5828