[Patch] Fix USBVision handling of VIDIOC_QUERYCTRL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There's a better (and recommended) way for handling VIDIOC_QUERYCTRL.
This patch will fix the issue where the hardware control values were invalid and stops the SAA7115 module from complaining about invalid values.

saa7115 4-0024: invalid brightness setting 32768
saa7115 4-0024: invalid contrast setting 49152
saa7115 4-0024: invalid hue setting 32768
saa7115 4-0024: invalid saturation setting 32768

Signed-off by: Dwaine Garden
diff -U 3 -H -d -r -N -- usbvision_v4l2a/linux/drivers/media/video/usbvision/usbvision-core.c usbvision_v4l2b/linux/drivers/media/video/usbvision/usbvision-core.c
--- usbvision_v4l2a/linux/drivers/media/video/usbvision/usbvision-core.c	2006-10-26 19:56:23.000000000 -0400
+++ usbvision_v4l2b/linux/drivers/media/video/usbvision/usbvision-core.c	2006-10-27 00:18:32.000000000 -0400
@@ -455,11 +455,6 @@
 #define DEFAULT_SCRATCH_BUF_SIZE	(0x20000)		// 128kB memory scratch buffer
 static const int scratch_buf_size = DEFAULT_SCRATCH_BUF_SIZE;
 
-static int init_brightness = 128;	// Initalize the brightness of the video device
-static int init_contrast = 192;		// Initalize the contrast of the video device
-static int init_saturation = 128;	// Initalize the staturation mode of the video device
-static int init_hue = 128;		// Initalize the Hue settings of the video device
-
 // Function prototypes
 static int usbvision_restart_isoc(struct usb_usbvision *usbvision);
 static int usbvision_begin_streaming(struct usb_usbvision *usbvision);
@@ -4375,53 +4370,33 @@
 		}
 	        case VIDIOC_QUERYCTRL:
 		{
-			struct v4l2_queryctrl *qc = arg;
-			switch(qc->id) {
-			case V4L2_CID_BRIGHTNESS:
-			case V4L2_CID_HUE:
-			case V4L2_CID_SATURATION:
-			case V4L2_CID_CONTRAST:
-			case V4L2_CID_AUDIO_VOLUME:
-			case V4L2_CID_AUDIO_MUTE:
-				return v4l2_ctrl_query_fill_std(qc);
-				break;
-			default:
+			struct v4l2_queryctrl *ctrl = arg;
+			int id=ctrl->id;
+
+			memset(ctrl,0,sizeof(*ctrl));
+			ctrl->id=id;
+
+			i2c_clients_command(&usbvision->i2c_adap, cmd, arg);
+
+			if (ctrl->type)
+				return 0;
+			else
 				return -EINVAL;
-			}
-			return 0;
+
+			PDEBUG(DBG_IOCTL,"VIDIOC_QUERYCTRL id=%x value=%x",ctrl->id,ctrl->type);
 		}
 		case VIDIOC_G_CTRL:
 		{
 			struct v4l2_control *ctrl = arg;
 
-			switch (ctrl->id) {
-			case V4L2_CID_BRIGHTNESS:
-				ctrl->value = usbvision->brightness;
-				break;
-			case V4L2_CID_CONTRAST:
-				ctrl->value = usbvision->contrast;
-				break;
-			case V4L2_CID_SATURATION:
-				ctrl->value = usbvision->saturation;
-				break;
-			case V4L2_CID_HUE:
-				ctrl->value = usbvision->hue;
-				break;
-			case V4L2_CID_AUDIO_VOLUME:
-				/* 	ctrl->value = usbvision->volume; */
-				break;
-			case V4L2_CID_AUDIO_MUTE:
-				ctrl->value = usbvision->AudioMute;
-				break;
-			default:
-				return -EINVAL;
-			}
-			PDEBUG(DBG_IOCTL, "VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
+			PDEBUG(DBG_IOCTL,"VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value);
+			call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl);
 			return 0;
 		}
 		case VIDIOC_S_CTRL:
 		{
 			struct v4l2_control *ctrl = arg;
+
 			PDEBUG(DBG_IOCTL, "VIDIOC_S_CTRL id=%x value=%x",ctrl->id,ctrl->value);
 			call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl);
 			return 0;
@@ -5559,16 +5534,6 @@
 		return;
 		
 	model = usbvision->DevModel;
-
-	RESTRICT_TO_RANGE(init_brightness, 0, 255);
-	RESTRICT_TO_RANGE(init_contrast, 0, 255);
-	RESTRICT_TO_RANGE(init_saturation, 0, 255);
-	RESTRICT_TO_RANGE(init_hue, 0, 255);
-	
-	usbvision->saturation = init_saturation << 8;
-	usbvision->hue = init_hue << 8;
-	usbvision->brightness = init_brightness << 8;
-	usbvision->contrast = init_contrast << 8;
 	usbvision->depth = 24;
 	usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24;
 
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux