blob: 88320900dbd4815affc177264613a474a3b4c206 [file] [log] [blame]
Mike Isely2a6b6272009-03-15 17:53:29 -03001/*
2 *
3 *
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/*
23
24 This source file is specifically designed to interface with the
25 v4l-dvb cs53l32a module.
26
27*/
28
29#include "pvrusb2-cs53l32a.h"
30
31
32#include "pvrusb2-hdw-internal.h"
33#include "pvrusb2-debug.h"
34#include <linux/videodev2.h>
35#include <media/v4l2-common.h>
36#include <linux/errno.h>
Mike Isely2a6b6272009-03-15 17:53:29 -030037
38struct routing_scheme {
39 const int *def;
40 unsigned int cnt;
41};
42
43
44static const int routing_scheme1[] = {
45 [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */
46 [PVR2_CVAL_INPUT_RADIO] = 2,
47 [PVR2_CVAL_INPUT_COMPOSITE] = 0,
48 [PVR2_CVAL_INPUT_SVIDEO] = 0,
49};
50
Mike Isely81e804c2009-06-20 14:55:31 -030051static const struct routing_scheme routing_def1 = {
52 .def = routing_scheme1,
53 .cnt = ARRAY_SIZE(routing_scheme1),
54};
55
56static const struct routing_scheme *routing_schemes[] = {
57 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
Mike Isely2a6b6272009-03-15 17:53:29 -030058};
59
60
61void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
62{
63 if (hdw->input_dirty || hdw->force_dirty) {
Mike Isely2a6b6272009-03-15 17:53:29 -030064 const struct routing_scheme *sp;
65 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
Hans Verkuil5325b422009-04-02 11:26:22 -030066 u32 input;
Mike Isely2a6b6272009-03-15 17:53:29 -030067 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
68 hdw->input_val);
Mike Isely90135c92009-06-20 14:57:24 -030069 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
70 routing_schemes[sid] : NULL;
71 if ((sp == NULL) ||
72 (hdw->input_val < 0) ||
73 (hdw->input_val >= sp->cnt)) {
Mike Isely2a6b6272009-03-15 17:53:29 -030074 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
75 "*** WARNING *** subdev v4l2 set_input:"
76 " Invalid routing scheme (%u)"
77 " and/or input (%d)",
78 sid, hdw->input_val);
79 return;
80 }
Mike Isely90135c92009-06-20 14:57:24 -030081 input = sp->def[hdw->input_val];
Hans Verkuil5325b422009-04-02 11:26:22 -030082 sd->ops->audio->s_routing(sd, input, 0, 0);
Mike Isely2a6b6272009-03-15 17:53:29 -030083 }
84}
85
86
87/*
88 Stuff for Emacs to see, in order to encourage consistent editing style:
89 *** Local Variables: ***
90 *** mode: c ***
91 *** fill-column: 70 ***
92 *** tab-width: 8 ***
93 *** c-basic-offset: 8 ***
94 *** End: ***
95 */