V4L/DVB (11182): pvrusb2: Tie in cx25840 sub-device support
authorMike Isely <isely@pobox.com>
Sat, 7 Mar 2009 03:54:02 +0000 (00:54 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:37 +0000 (12:43 -0300)
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.h
drivers/media/video/pvrusb2/pvrusb2-hdw.c

index 9494c6a5b5d82f7f775df093baedb6b95dc6448d..9df3623a3e4c49405c394f9d163367f89b066bbe 100644 (file)
 #include <linux/errno.h>
 #include <linux/slab.h>
 
-struct pvr2_v4l_cx2584x {
-       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_item {
        int vid;
@@ -110,6 +102,15 @@ static const struct routing_scheme routing_schemes[] = {
        },
 };
 
+struct pvr2_v4l_cx2584x {
+       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_cx2584x *ctxt)
 {
        struct pvr2_hdw *hdw = ctxt->hdw;
@@ -321,6 +322,41 @@ int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *hdw,
 }
 
 
+void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
+{
+       if (hdw->input_dirty) {
+               struct v4l2_routing route;
+               enum cx25840_video_input vid_input;
+               enum cx25840_audio_input aud_input;
+               const struct routing_scheme *sp;
+               unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
+
+               memset(&route, 0, sizeof(route));
+
+               if ((sid < ARRAY_SIZE(routing_schemes)) &&
+                   ((sp = routing_schemes + sid) != NULL) &&
+                   (hdw->input_val >= 0) &&
+                   (hdw->input_val < sp->cnt)) {
+                       vid_input = sp->def[hdw->input_val].vid;
+                       aud_input = sp->def[hdw->input_val].aud;
+               } else {
+                       pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+                                  "*** WARNING *** subdev cx2584x set_input:"
+                                  " Invalid routing scheme (%u)"
+                                  " and/or input (%d)",
+                                  sid, hdw->input_val);
+                       return;
+               }
+
+               pvr2_trace(PVR2_TRACE_CHIPS,
+                          "i2c cx2584x set_input vid=0x%x aud=0x%x",
+                          vid_input, aud_input);
+               route.input = (u32)vid_input;
+               sd->ops->video->s_routing(sd, &route);
+               route.input = (u32)aud_input;
+               sd->ops->audio->s_routing(sd, &route);
+       }
+}
 
 
 
index f664f5942002feeb5934848bd49f018f8546c7df..e48ce808bfe5fd093f1db3eb97cc30f9c4efbbfa 100644 (file)
 int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
 
 
+#include "pvrusb2-hdw-internal.h"
+
+void pvr2_cx25840_subdev_update(struct pvr2_hdw *, struct v4l2_subdev *sd);
+
+
 #endif /* __PVRUSB2_CX2584X_V4L_H */
 
 /*
index ff7af062002b3db8c3ce454154691dd8d654559e..1158021b1e12b831071186c673eb3c90d967975f 100644 (file)
@@ -38,6 +38,7 @@
 #include "pvrusb2-fx2-cmd.h"
 #include "pvrusb2-wm8775.h"
 #include "pvrusb2-video-v4l.h"
+#include "pvrusb2-cx2584x-v4l.h"
 #include "pvrusb2-audio.h"
 
 #define TV_MIN_FREQ     55250000L
@@ -115,6 +116,7 @@ static const pvr2_subdev_update_func pvr2_module_update_functions[] = {
        [PVR2_CLIENT_ID_WM8775] = pvr2_wm8775_subdev_update,
        [PVR2_CLIENT_ID_SAA7115] = pvr2_saa7115_subdev_update,
        [PVR2_CLIENT_ID_MSP3400] = pvr2_msp3400_subdev_update,
+       [PVR2_CLIENT_ID_CX25840] = pvr2_cx25840_subdev_update,
 };
 
 static const char *module_names[] = {