diff options
author | Mike Isely <isely@pobox.com> | 2007-11-26 00:07:26 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:03:05 -0500 |
commit | f5174af201f2e22c101bb02d06343e4bc5f056de (patch) | |
tree | a13e51ad387953b17f11360a5cb89d8abc0ea551 /drivers/media/video/pvrusb2/pvrusb2-audio.c | |
parent | aaf7884db395332ae8474f3ea5bcdd39c0a941ea (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-audio.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-audio.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c index 379645e481c6..9a7c8e9c3e8b 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-audio.c +++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c | |||
@@ -35,34 +35,58 @@ struct pvr2_msp3400_handler { | |||
35 | }; | 35 | }; |
36 | 36 | ||
37 | 37 | ||
38 | |||
39 | struct routing_scheme { | ||
40 | const int *def; | ||
41 | unsigned int cnt; | ||
42 | }; | ||
43 | |||
44 | static const int routing_scheme0[] = { | ||
45 | [PVR2_CVAL_INPUT_TV] = MSP_INPUT_DEFAULT, | ||
46 | [PVR2_CVAL_INPUT_RADIO] = MSP_INPUT(MSP_IN_SCART2, | ||
47 | MSP_IN_TUNER1, | ||
48 | MSP_DSP_IN_SCART, | ||
49 | MSP_DSP_IN_SCART), | ||
50 | [PVR2_CVAL_INPUT_COMPOSITE] = MSP_INPUT(MSP_IN_SCART1, | ||
51 | MSP_IN_TUNER1, | ||
52 | MSP_DSP_IN_SCART, | ||
53 | MSP_DSP_IN_SCART), | ||
54 | [PVR2_CVAL_INPUT_SVIDEO] = MSP_INPUT(MSP_IN_SCART1, | ||
55 | MSP_IN_TUNER1, | ||
56 | MSP_DSP_IN_SCART, | ||
57 | MSP_DSP_IN_SCART), | ||
58 | }; | ||
59 | |||
60 | static const struct routing_scheme routing_schemes[] = { | ||
61 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = { | ||
62 | .def = routing_scheme0, | ||
63 | .cnt = ARRAY_SIZE(routing_scheme0), | ||
64 | }, | ||
65 | }; | ||
66 | |||
38 | /* This function selects the correct audio input source */ | 67 | /* This function selects the correct audio input source */ |
39 | static void set_stereo(struct pvr2_msp3400_handler *ctxt) | 68 | static void set_stereo(struct pvr2_msp3400_handler *ctxt) |
40 | { | 69 | { |
41 | struct pvr2_hdw *hdw = ctxt->hdw; | 70 | struct pvr2_hdw *hdw = ctxt->hdw; |
42 | struct v4l2_routing route; | 71 | struct v4l2_routing route; |
72 | const struct routing_scheme *sp; | ||
73 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | ||
43 | 74 | ||
44 | pvr2_trace(PVR2_TRACE_CHIPS,"i2c msp3400 v4l2 set_stereo"); | 75 | pvr2_trace(PVR2_TRACE_CHIPS,"i2c msp3400 v4l2 set_stereo"); |
45 | 76 | ||
46 | route.input = MSP_INPUT_DEFAULT; | 77 | if ((sid < ARRAY_SIZE(routing_schemes)) && |
47 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); | 78 | ((sp = routing_schemes + sid) != 0) && |
48 | switch (hdw->input_val) { | 79 | (hdw->input_val >= 0) && |
49 | case PVR2_CVAL_INPUT_TV: | 80 | (hdw->input_val < sp->cnt)) { |
50 | break; | 81 | route.input = sp->def[hdw->input_val]; |
51 | case PVR2_CVAL_INPUT_RADIO: | 82 | } else { |
52 | /* Assume that msp34xx also handle FM decoding, in which case | 83 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
53 | we're still using the tuner. */ | 84 | "*** WARNING *** i2c msp3400 v4l2 set_stereo:" |
54 | /* HV: actually it is more likely to be the SCART2 input if | 85 | " Invalid routing scheme (%u) and/or input (%d)", |
55 | the ivtv experience is any indication. */ | 86 | sid,hdw->input_val); |
56 | route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, | 87 | return; |
57 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | ||
58 | break; | ||
59 | case PVR2_CVAL_INPUT_SVIDEO: | ||
60 | case PVR2_CVAL_INPUT_COMPOSITE: | ||
61 | /* SCART 1 input */ | ||
62 | route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, | ||
63 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | ||
64 | break; | ||
65 | } | 88 | } |
89 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); | ||
66 | pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route); | 90 | pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route); |
67 | } | 91 | } |
68 | 92 | ||