[PATCH] driver support for VIDIOC_QUERYSTD and enhanced VIDIOC_ENUMINPUT for WinTV PVR-150

Sigmund Augdal <[email protected]>
Newsgroups gmane.comp.video.video4linux
Message-ID <[email protected]>
Attached is a patch that contains driver side changes to implement the
features that were added to v4l2-ctl by my two previous patches. It is based
on an old kernel and is only tested for one single capture card, so this
patch is provided for reference only, not for inclusion into the drivers as
is.

Best regards

Sigmund Augdal

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
pvr150_enuminput_querystd.patch (application/octet-stream, 3.4 KB)
diff -urp -x '*.ko' -x '*.mod.*' -x '*.cmd' -x '*.o' linux-2.6.24-snaptv-r4683/drivers/media/video/cx25840/cx25840-core.c linux-analog-improvement/drivers/media/video/cx25840/cx25840-core.c
--- linux-2.6.24-snaptv-r4683/drivers/media/video/cx25840/cx25840-core.c	2009-04-28 15:29:12.000000000 +0300
+++ linux-analog-improvement/drivers/media/video/cx25840/cx25840-core.c	2009-10-21 16:40:47.856413722 +0300
@@ -567,13 +567,13 @@ static int set_v4lstd(struct i2c_client 
 	return 0;
 }
 
-v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
+static v4l2_std_id cx25840_get_v4lstd_internal(struct i2c_client * client, int autodetect)
 {
 	struct cx25840_state *state = i2c_get_clientdata(client);
 	/* check VID_FMT_SEL first */
 	u8 fmt = cx25840_read(client, 0x400) & 0xf;
 
-	if (!fmt) {
+	if (!fmt || autodetect) {
 		/* check AFD_FMT_STAT if set to autodetect */
 		fmt = cx25840_read(client, 0x40d) & 0xf;
 	}
@@ -599,6 +599,11 @@ v4l2_std_id cx25840_get_v4lstd(struct i2
 	}
 }
 
+v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
+{
+    return cx25840_get_v4lstd_internal(client, 0);
+}
+
 /* ----------------------------------------------------------------------- */
 
 static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
@@ -983,6 +988,7 @@ static int cx25840_command(struct i2c_cl
 	struct cx25840_state *state = i2c_get_clientdata(client);
 	struct v4l2_tuner *vt = arg;
 	struct v4l2_routing *route = arg;
+	struct v4l2_input *vin = arg;
 
 	/* ignore these commands */
 	switch (cmd) {
@@ -1103,6 +1109,17 @@ static int cx25840_command(struct i2c_cl
 		state->radio = 0;
 		return set_v4lstd(client, *(v4l2_std_id *)arg);
 
+	case VIDIOC_QUERYSTD:
+		*(v4l2_std_id *)arg = cx25840_get_v4lstd_internal(client, 1);
+		break;
+
+	case VIDIOC_ENUMINPUT:
+		/* Assuming the driver will only propagate the ioctl here if it allready checked that the asked for index is the currently selected index, so we need not bother with routing and such */
+		if (!(cx25840_read(client, 0x40e) & 0x20)) {
+			vin->status = V4L2_IN_ST_NO_SIGNAL;
+		}
+		break;
+
 	case AUDC_SET_RADIO:
 		state->radio = 1;
 		break;
diff -urp -x '*.ko' -x '*.mod.*' -x '*.cmd' -x '*.o' linux-2.6.24-snaptv-r4683/drivers/media/video/ivtv/ivtv-ioctl.c linux-analog-improvement/drivers/media/video/ivtv/ivtv-ioctl.c
--- linux-2.6.24-snaptv-r4683/drivers/media/video/ivtv/ivtv-ioctl.c	2009-04-28 15:29:12.000000000 +0300
+++ linux-analog-improvement/drivers/media/video/ivtv/ivtv-ioctl.c	2009-10-21 16:41:48.054778199 +0300
@@ -797,9 +797,14 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, s
 
 	case VIDIOC_ENUMINPUT:{
 		struct v4l2_input *vin = arg;
+		int ret;
 
 		/* set it to defaults from our table */
-		return ivtv_get_input(itv, vin->index, vin);
+		ret = ivtv_get_input(itv, vin->index, vin);
+		if (vin->index == itv->active_input) {
+			ivtv_call_i2c_clients(itv, VIDIOC_ENUMINPUT, vin);
+		}
+		return ret;
 	}
 
 	case VIDIOC_ENUMOUTPUT:{
@@ -1080,6 +1085,12 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, s
 		break;
 	}
 
+	case VIDIOC_QUERYSTD: {
+		struct v4l2_std_id *std = arg;
+		ivtv_call_i2c_clients(itv, VIDIOC_QUERYSTD, std);
+		break;
+	}
+
 	case VIDIOC_S_TUNER: {	/* Setting tuner can only set audio mode */
 		struct v4l2_tuner *vt = arg;
 
@@ -1651,6 +1662,7 @@ static int ivtv_v4l2_do_ioctl(struct ino
 	case VIDIOC_S_FREQUENCY:
 	case VIDIOC_ENUMSTD:
 	case VIDIOC_G_STD:
+	case VIDIOC_QUERYSTD:
 	case VIDIOC_S_STD:
 	case VIDIOC_S_TUNER:
 	case VIDIOC_G_TUNER:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.