aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2007-11-26 00:07:26 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:05 -0500
commitf5174af201f2e22c101bb02d06343e4bc5f056de (patch)
treea13e51ad387953b17f11360a5cb89d8abc0ea551 /drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
parentaaf7884db395332ae8474f3ea5bcdd39c0a941ea (diff)
V4L/DVB (6698): pvrusb2: Implement signal routing schemes
The exact routing of video and audio signals within a device is a device-specific attribute. Hauppauge devices do it one way; other types of device may route things differently. Unfortunately it is rather impractical to define chip-specific routing at the device attribute level, so instead what happens here is that "schemes" are defined. Each chip level interface implements its part of a given scheme and the scheme as a whole is made into a device specific attribute controlled via a table entry in pvrusb2-devattr.c. The only scheme defined here is for Hauppauge devices, but clearly this opens the door for other possibilities to follow. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c69
1 files changed, 50 insertions, 19 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index 2cca817e4144..b6714c41ea75 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -49,34 +49,65 @@ struct pvr2_v4l_cx2584x {
49}; 49};
50 50
51 51
52struct routing_scheme_item {
53 int vid;
54 int aud;
55};
56
57struct routing_scheme {
58 const struct routing_scheme_item *def;
59 unsigned int cnt;
60};
61
62static const struct routing_scheme_item routing_scheme0[] = {
63 [PVR2_CVAL_INPUT_TV] = {
64 .vid = CX25840_COMPOSITE7,
65 .aud = CX25840_AUDIO8,
66 },
67 [PVR2_CVAL_INPUT_RADIO] = { /* Treat the same as composite */
68 .vid = CX25840_COMPOSITE3,
69 .aud = CX25840_AUDIO_SERIAL,
70 },
71 [PVR2_CVAL_INPUT_COMPOSITE] = {
72 .vid = CX25840_COMPOSITE3,
73 .aud = CX25840_AUDIO_SERIAL,
74 },
75 [PVR2_CVAL_INPUT_SVIDEO] = {
76 .vid = CX25840_SVIDEO1,
77 .aud = CX25840_AUDIO_SERIAL,
78 },
79};
80
81static const struct routing_scheme routing_schemes[] = {
82 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = {
83 .def = routing_scheme0,
84 .cnt = ARRAY_SIZE(routing_scheme0),
85 },
86};
87
52static void set_input(struct pvr2_v4l_cx2584x *ctxt) 88static void set_input(struct pvr2_v4l_cx2584x *ctxt)
53{ 89{
54 struct pvr2_hdw *hdw = ctxt->hdw; 90 struct pvr2_hdw *hdw = ctxt->hdw;
55 struct v4l2_routing route; 91 struct v4l2_routing route;
56 enum cx25840_video_input vid_input; 92 enum cx25840_video_input vid_input;
57 enum cx25840_audio_input aud_input; 93 enum cx25840_audio_input aud_input;
94 const struct routing_scheme *sp;
95 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
58 96
59 memset(&route,0,sizeof(route)); 97 memset(&route,0,sizeof(route));
60 98
61 switch(hdw->input_val) { 99 if ((sid < ARRAY_SIZE(routing_schemes)) &&
62 case PVR2_CVAL_INPUT_TV: 100 ((sp = routing_schemes + sid) != 0) &&
63 vid_input = CX25840_COMPOSITE7; 101 (hdw->input_val >= 0) &&
64 aud_input = CX25840_AUDIO8; 102 (hdw->input_val < sp->cnt)) {
65 break; 103 vid_input = sp->def[hdw->input_val].vid;
66 case PVR2_CVAL_INPUT_RADIO: // Treat same as composite 104 aud_input = sp->def[hdw->input_val].aud;
67 case PVR2_CVAL_INPUT_COMPOSITE: 105 } else {
68 vid_input = CX25840_COMPOSITE3; 106 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
69 aud_input = CX25840_AUDIO_SERIAL; 107 "*** WARNING *** i2c cx2584x set_input:"
70 break; 108 " Invalid routing scheme (%u) and/or input (%d)",
71 case PVR2_CVAL_INPUT_SVIDEO: 109 sid,hdw->input_val);
72 vid_input = CX25840_SVIDEO1; 110 return;
73 aud_input = CX25840_AUDIO_SERIAL;
74 break;
75 default:
76 // Just set it to be composite input for now...
77 vid_input = CX25840_COMPOSITE3;
78 aud_input = CX25840_AUDIO_SERIAL;
79 break;
80 } 111 }
81 112
82 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx2584x set_input vid=0x%x aud=0x%x", 113 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx2584x set_input vid=0x%x aud=0x%x",