blob: 10ef1a2c13eac39adbff08bed37d1c4daa0390e6 [file] [log] [blame]
Mike Iselyd8554972006-06-26 20:58:46 -03001/*
2 *
Mike Iselyd8554972006-06-26 20:58:46 -03003 *
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#include "pvrusb2-audio.h"
23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h"
25#include <linux/videodev2.h>
26#include <media/msp3400.h>
27#include <media/v4l2-common.h>
28
Mike Isely6063a442009-03-06 23:48:42 -030029
Mike Iselyf5174af2007-11-26 02:07:26 -030030struct routing_scheme {
31 const int *def;
32 unsigned int cnt;
33};
34
35static const int routing_scheme0[] = {
36 [PVR2_CVAL_INPUT_TV] = MSP_INPUT_DEFAULT,
37 [PVR2_CVAL_INPUT_RADIO] = MSP_INPUT(MSP_IN_SCART2,
38 MSP_IN_TUNER1,
39 MSP_DSP_IN_SCART,
40 MSP_DSP_IN_SCART),
41 [PVR2_CVAL_INPUT_COMPOSITE] = MSP_INPUT(MSP_IN_SCART1,
42 MSP_IN_TUNER1,
43 MSP_DSP_IN_SCART,
44 MSP_DSP_IN_SCART),
45 [PVR2_CVAL_INPUT_SVIDEO] = MSP_INPUT(MSP_IN_SCART1,
46 MSP_IN_TUNER1,
47 MSP_DSP_IN_SCART,
48 MSP_DSP_IN_SCART),
49};
50
51static const struct routing_scheme routing_schemes[] = {
52 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = {
53 .def = routing_scheme0,
54 .cnt = ARRAY_SIZE(routing_scheme0),
55 },
56};
57
Mike Isely76891d62009-03-07 00:52:06 -030058void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
59{
Mike Isely27764722009-03-07 01:57:25 -030060 if (hdw->input_dirty || hdw->force_dirty) {
Mike Isely76891d62009-03-07 00:52:06 -030061 const struct routing_scheme *sp;
62 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
Hans Verkuil5325b422009-04-02 11:26:22 -030063 u32 input;
Mike Iselyd8554972006-06-26 20:58:46 -030064
Mike Isely76891d62009-03-07 00:52:06 -030065 pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo");
66
67 if ((sid < ARRAY_SIZE(routing_schemes)) &&
68 ((sp = routing_schemes + sid) != NULL) &&
69 (hdw->input_val >= 0) &&
70 (hdw->input_val < sp->cnt)) {
Hans Verkuil5325b422009-04-02 11:26:22 -030071 input = sp->def[hdw->input_val];
Mike Isely76891d62009-03-07 00:52:06 -030072 } else {
73 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
74 "*** WARNING *** subdev msp3400 set_input:"
75 " Invalid routing scheme (%u)"
76 " and/or input (%d)",
77 sid, hdw->input_val);
78 return;
79 }
Hans Verkuil5325b422009-04-02 11:26:22 -030080 sd->ops->audio->s_routing(sd, input,
81 MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0);
Mike Isely76891d62009-03-07 00:52:06 -030082 }
83}
Mike Iselyacd92d42009-03-06 23:32:02 -030084
Mike Iselyd8554972006-06-26 20:58:46 -030085/*
86 Stuff for Emacs to see, in order to encourage consistent editing style:
87 *** Local Variables: ***
88 *** mode: c ***
89 *** fill-column: 70 ***
90 *** tab-width: 8 ***
91 *** c-basic-offset: 8 ***
92 *** End: ***
93 */