V4L/DVB (10258): pvrusb2: Issue VIDIOC_INT_INIT to v4l2 modules when they first attach
authorMike Isely <isely@pobox.com>
Fri, 16 Jan 2009 06:06:02 +0000 (03:06 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:42:23 +0000 (12:42 -0300)
It appears that various v4l-dvb drivers are changing to require
explicit initialization before use.  This change to the pvrusb2 driver
implements an automatic issuance of VIDIOC_INT_INIT when a module is
bound to the driver, thus conforming to the new behavior.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
drivers/media/video/pvrusb2/pvrusb2-i2c-core.c

index 94a47718e88eb0dcd275f9c080d23440dfbdad85..4cf980c49d01cc8e7c185af0d08b19ad420c50fd 100644 (file)
 
 #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
 
-#define OP_STANDARD 0
-#define OP_AUDIOMODE 1
-#define OP_BCSH 2
-#define OP_VOLUME 3
-#define OP_FREQ 4
-#define OP_AUDIORATE 5
-#define OP_CROP 6
-#define OP_SIZE 7
-#define OP_LOG 8
+#define OP_INIT 0 /* MUST come first so it is run first */
+#define OP_STANDARD 1
+#define OP_AUDIOMODE 2
+#define OP_BCSH 3
+#define OP_VOLUME 4
+#define OP_FREQ 5
+#define OP_AUDIORATE 6
+#define OP_CROP 7
+#define OP_SIZE 8
+#define OP_LOG 9
 
 static const struct pvr2_i2c_op * const ops[] = {
+       [OP_INIT] = &pvr2_i2c_op_v4l2_init,
        [OP_STANDARD] = &pvr2_i2c_op_v4l2_standard,
        [OP_AUDIOMODE] = &pvr2_i2c_op_v4l2_audiomode,
        [OP_BCSH] = &pvr2_i2c_op_v4l2_bcsh,
@@ -56,7 +58,8 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
 {
        int id;
        id = cp->client->driver->id;
-       cp->ctl_mask = ((1 << OP_STANDARD) |
+       cp->ctl_mask = ((1 << OP_INIT) |
+                       (1 << OP_STANDARD) |
                        (1 << OP_AUDIOMODE) |
                        (1 << OP_BCSH) |
                        (1 << OP_VOLUME) |
index 16bb11902a522ef0881e44e47aacc4779c4a57e3..0f2885440f2f55252388dbb584470246b1132aa5 100644 (file)
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 
+static void execute_init(struct pvr2_hdw *hdw)
+{
+       u32 dummy = 0;
+       pvr2_trace(PVR2_TRACE_CHIPS, "i2c v4l2 init");
+       pvr2_i2c_core_cmd(hdw, VIDIOC_INT_INIT, &dummy);
+}
+
+
+const struct pvr2_i2c_op pvr2_i2c_op_v4l2_init = {
+       .update = execute_init,
+       .name = "v4l2_init",
+};
+
+
 static void set_standard(struct pvr2_hdw *hdw)
 {
        pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 set_standard");
index eb744a20610d4ec15d68f648626e268487172619..69a63f2a8a7be4897010b3c80bc1b2492291ea34 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "pvrusb2-i2c-core.h"
 
+extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_init;
 extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_standard;
 extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_radio;
 extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_bcsh;
index d6a35401fefb78186ad40e758003a4c34b77ce84..57a024737722d3bf165e73f5b7dcdae391b147ea 100644 (file)
@@ -763,7 +763,7 @@ int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw)
                if (!(msk & pm)) continue;
                pm &= ~msk;
                opf = pvr2_i2c_get_op(idx);
-               if (!opf) continue;
+               if (!(opf && opf->check)) continue;
                if (opf->check(hdw)) {
                        sm |= msk;
                }