blob: 8c32288eebed45add98b5afb336a735b536b909d [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/*
23
24 This source file is specifically designed to interface with the
25 saa711x support that is available in the v4l available starting
26 with linux 2.6.15.
27
28*/
29
30#include "pvrusb2-video-v4l.h"
Mike Iselyd8554972006-06-26 20:58:46 -030031
32
Mike Isely6f956512009-03-07 00:43:26 -030033
Mike Iselyd8554972006-06-26 20:58:46 -030034#include "pvrusb2-hdw-internal.h"
35#include "pvrusb2-debug.h"
36#include <linux/videodev2.h>
37#include <media/v4l2-common.h>
38#include <media/saa7115.h>
39#include <linux/errno.h>
40#include <linux/slab.h>
41
Mike Iselyf5174af2007-11-26 02:07:26 -030042struct routing_scheme {
43 const int *def;
44 unsigned int cnt;
45};
46
47
48static const int routing_scheme0[] = {
49 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
50 /* In radio mode, we mute the video, but point at one
51 spot just to stay consistent */
52 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
53 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5,
54 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
55};
56
Mike Isely81e804c2009-06-20 14:55:31 -030057static const struct routing_scheme routing_def0 = {
58 .def = routing_scheme0,
59 .cnt = ARRAY_SIZE(routing_scheme0),
60};
61
Mike Isely2a6b6272009-03-15 17:53:29 -030062static const int routing_scheme1[] = {
63 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
64 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
65 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE3,
66 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, /* or SVIDEO0, it seems */
67};
68
Mike Isely81e804c2009-06-20 14:55:31 -030069static const struct routing_scheme routing_def1 = {
70 .def = routing_scheme1,
71 .cnt = ARRAY_SIZE(routing_scheme1),
72};
73
74static const struct routing_scheme *routing_schemes[] = {
75 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
76 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
Mike Iselyf5174af2007-11-26 02:07:26 -030077};
78
Mike Isely6f956512009-03-07 00:43:26 -030079void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
80{
Mike Isely27764722009-03-07 01:57:25 -030081 if (hdw->input_dirty || hdw->force_dirty) {
Mike Isely6f956512009-03-07 00:43:26 -030082 const struct routing_scheme *sp;
83 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
Hans Verkuil5325b422009-04-02 11:26:22 -030084 u32 input;
85
Mike Isely6f956512009-03-07 00:43:26 -030086 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
87 hdw->input_val);
88 if ((sid < ARRAY_SIZE(routing_schemes)) &&
Mike Isely81e804c2009-06-20 14:55:31 -030089 ((sp = routing_schemes[sid]) != NULL) &&
Mike Isely6f956512009-03-07 00:43:26 -030090 (hdw->input_val >= 0) &&
91 (hdw->input_val < sp->cnt)) {
Hans Verkuil5325b422009-04-02 11:26:22 -030092 input = sp->def[hdw->input_val];
Mike Isely6f956512009-03-07 00:43:26 -030093 } else {
94 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
95 "*** WARNING *** subdev v4l2 set_input:"
Mike Isely1e481cc2009-03-07 00:52:42 -030096 " Invalid routing scheme (%u)"
97 " and/or input (%d)",
Mike Isely6f956512009-03-07 00:43:26 -030098 sid, hdw->input_val);
99 return;
100 }
Hans Verkuil5325b422009-04-02 11:26:22 -0300101 sd->ops->video->s_routing(sd, input, 0, 0);
Mike Isely6f956512009-03-07 00:43:26 -0300102 }
103}
Mike Iselyd8554972006-06-26 20:58:46 -0300104
105
106/*
107 Stuff for Emacs to see, in order to encourage consistent editing style:
108 *** Local Variables: ***
109 *** mode: c ***
110 *** fill-column: 70 ***
111 *** tab-width: 8 ***
112 *** c-basic-offset: 8 ***
113 *** End: ***
114 */