V4L/DVB (11194): pvrusb2: Implement mechanism to force a full sub-device update
[pandora-kernel.git] / drivers / media / video / pvrusb2 / pvrusb2-video-v4l.c
index 2433a31..4e0c088 100644 (file)
@@ -1,6 +1,5 @@
 /*
  *
- *  $Id$
  *
  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
  *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
 */
 
 #include "pvrusb2-video-v4l.h"
-#include "pvrusb2-i2c-cmd-v4l2.h"
 
 
+#include "pvrusb2-i2c-cmd-v4l2.h"
+
 #include "pvrusb2-hdw-internal.h"
 #include "pvrusb2-debug.h"
 #include <linux/videodev2.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 
-struct pvr2_v4l_decoder {
-       struct pvr2_i2c_handler handler;
-       struct pvr2_decoder_ctrl ctrl;
-       struct pvr2_i2c_client *client;
-       struct pvr2_hdw *hdw;
-       unsigned long stale_mask;
-};
-
-
 struct routing_scheme {
        const int *def;
        unsigned int cnt;
@@ -71,6 +62,16 @@ static const struct routing_scheme routing_schemes[] = {
        },
 };
 
+struct pvr2_v4l_decoder {
+       struct pvr2_i2c_handler handler;
+       struct pvr2_decoder_ctrl ctrl;
+       struct pvr2_i2c_client *client;
+       struct pvr2_hdw *hdw;
+       unsigned long stale_mask;
+};
+
+
+
 static void set_input(struct pvr2_v4l_decoder *ctxt)
 {
        struct pvr2_hdw *hdw = ctxt->hdw;
@@ -246,6 +247,31 @@ int pvr2_i2c_decoder_v4l_setup(struct pvr2_hdw *hdw,
 }
 
 
+void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
+{
+       if (hdw->input_dirty || hdw->force_dirty) {
+               struct v4l2_routing route;
+               const struct routing_scheme *sp;
+               unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
+               pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
+                          hdw->input_val);
+               if ((sid < ARRAY_SIZE(routing_schemes)) &&
+                   ((sp = routing_schemes + sid) != NULL) &&
+                   (hdw->input_val >= 0) &&
+                   (hdw->input_val < sp->cnt)) {
+                       route.input = sp->def[hdw->input_val];
+               } else {
+                       pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+                                  "*** WARNING *** subdev v4l2 set_input:"
+                                  " Invalid routing scheme (%u)"
+                                  " and/or input (%d)",
+                                  sid, hdw->input_val);
+                       return;
+               }
+               route.output = 0;
+               sd->ops->video->s_routing(sd, &route);
+       }
+}
 
 
 /*