Commit | Line | Data |
---|---|---|
d855497e MI |
1 | /* |
2 | * | |
d855497e MI |
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 | cx2584x, in kernels 2.6.16 or newer. | |
26 | ||
27 | */ | |
28 | ||
29 | #include "pvrusb2-cx2584x-v4l.h" | |
30 | #include "pvrusb2-video-v4l.h" | |
d855497e MI |
31 | |
32 | ||
33 | #include "pvrusb2-hdw-internal.h" | |
34 | #include "pvrusb2-debug.h" | |
35 | #include <media/cx25840.h> | |
36 | #include <linux/videodev2.h> | |
37 | #include <media/v4l2-common.h> | |
38 | #include <linux/errno.h> | |
39 | #include <linux/slab.h> | |
40 | ||
d855497e | 41 | |
f5174af2 MI |
42 | struct routing_scheme_item { |
43 | int vid; | |
44 | int aud; | |
45 | }; | |
46 | ||
47 | struct routing_scheme { | |
48 | const struct routing_scheme_item *def; | |
49 | unsigned int cnt; | |
50 | }; | |
51 | ||
52 | static const struct routing_scheme_item routing_scheme0[] = { | |
53 | [PVR2_CVAL_INPUT_TV] = { | |
54 | .vid = CX25840_COMPOSITE7, | |
55 | .aud = CX25840_AUDIO8, | |
56 | }, | |
57 | [PVR2_CVAL_INPUT_RADIO] = { /* Treat the same as composite */ | |
58 | .vid = CX25840_COMPOSITE3, | |
59 | .aud = CX25840_AUDIO_SERIAL, | |
60 | }, | |
61 | [PVR2_CVAL_INPUT_COMPOSITE] = { | |
62 | .vid = CX25840_COMPOSITE3, | |
63 | .aud = CX25840_AUDIO_SERIAL, | |
64 | }, | |
65 | [PVR2_CVAL_INPUT_SVIDEO] = { | |
66 | .vid = CX25840_SVIDEO1, | |
67 | .aud = CX25840_AUDIO_SERIAL, | |
68 | }, | |
69 | }; | |
70 | ||
81e804c9 MI |
71 | static const struct routing_scheme routing_def0 = { |
72 | .def = routing_scheme0, | |
73 | .cnt = ARRAY_SIZE(routing_scheme0), | |
74 | }; | |
75 | ||
9e2e3aeb MI |
76 | /* Specific to gotview device */ |
77 | static const struct routing_scheme_item routing_schemegv[] = { | |
78 | [PVR2_CVAL_INPUT_TV] = { | |
79 | .vid = CX25840_COMPOSITE2, | |
80 | .aud = CX25840_AUDIO5, | |
81 | }, | |
1df59f0b MI |
82 | [PVR2_CVAL_INPUT_RADIO] = { |
83 | /* line-in is used for radio and composite. A GPIO is | |
84 | used to switch between the two choices. */ | |
9e2e3aeb MI |
85 | .vid = CX25840_COMPOSITE1, |
86 | .aud = CX25840_AUDIO_SERIAL, | |
87 | }, | |
88 | [PVR2_CVAL_INPUT_COMPOSITE] = { | |
89 | .vid = CX25840_COMPOSITE1, | |
90 | .aud = CX25840_AUDIO_SERIAL, | |
91 | }, | |
92 | [PVR2_CVAL_INPUT_SVIDEO] = { | |
93 | .vid = (CX25840_SVIDEO_LUMA3|CX25840_SVIDEO_CHROMA4), | |
94 | .aud = CX25840_AUDIO_SERIAL, | |
95 | }, | |
96 | }; | |
97 | ||
81e804c9 MI |
98 | static const struct routing_scheme routing_defgv = { |
99 | .def = routing_schemegv, | |
100 | .cnt = ARRAY_SIZE(routing_schemegv), | |
101 | }; | |
102 | ||
103 | static const struct routing_scheme *routing_schemes[] = { | |
104 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, | |
105 | [PVR2_ROUTING_SCHEME_GOTVIEW] = &routing_defgv, | |
f5174af2 MI |
106 | }; |
107 | ||
634ba268 MI |
108 | void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
109 | { | |
5e430ca5 | 110 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update..."); |
27764726 | 111 | if (hdw->input_dirty || hdw->force_dirty) { |
634ba268 MI |
112 | enum cx25840_video_input vid_input; |
113 | enum cx25840_audio_input aud_input; | |
114 | const struct routing_scheme *sp; | |
115 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | |
116 | ||
634ba268 | 117 | if ((sid < ARRAY_SIZE(routing_schemes)) && |
81e804c9 | 118 | ((sp = routing_schemes[sid]) != NULL) && |
634ba268 MI |
119 | (hdw->input_val >= 0) && |
120 | (hdw->input_val < sp->cnt)) { | |
121 | vid_input = sp->def[hdw->input_val].vid; | |
122 | aud_input = sp->def[hdw->input_val].aud; | |
123 | } else { | |
124 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | |
125 | "*** WARNING *** subdev cx2584x set_input:" | |
126 | " Invalid routing scheme (%u)" | |
127 | " and/or input (%d)", | |
128 | sid, hdw->input_val); | |
129 | return; | |
130 | } | |
131 | ||
132 | pvr2_trace(PVR2_TRACE_CHIPS, | |
5e430ca5 | 133 | "subdev cx2584x set_input vid=0x%x aud=0x%x", |
634ba268 | 134 | vid_input, aud_input); |
5325b427 HV |
135 | sd->ops->video->s_routing(sd, (u32)vid_input, 0, 0); |
136 | sd->ops->audio->s_routing(sd, (u32)aud_input, 0, 0); | |
634ba268 MI |
137 | } |
138 | } | |
d855497e MI |
139 | |
140 | ||
acd92d40 | 141 | |
d855497e MI |
142 | /* |
143 | Stuff for Emacs to see, in order to encourage consistent editing style: | |
144 | *** Local Variables: *** | |
145 | *** mode: c *** | |
146 | *** fill-column: 70 *** | |
147 | *** tab-width: 8 *** | |
148 | *** c-basic-offset: 8 *** | |
149 | *** End: *** | |
150 | */ |