diff options
-rw-r--r-- | drivers/media/video/bt8xx/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-audio-hook.c | 390 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-audio-hook.h | 23 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-cards.c | 399 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv.h | 2 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttvp.h | 3 |
6 files changed, 420 insertions, 399 deletions
diff --git a/drivers/media/video/bt8xx/Makefile b/drivers/media/video/bt8xx/Makefile index a096a03418aa..924d216d9570 100644 --- a/drivers/media/video/bt8xx/Makefile +++ b/drivers/media/video/bt8xx/Makefile | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ | 5 | bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ |
6 | bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \ | 6 | bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \ |
7 | bttv-input.o | 7 | bttv-input.o bttv-audio-hook.o |
8 | 8 | ||
9 | obj-$(CONFIG_VIDEO_BT848) += bttv.o | 9 | obj-$(CONFIG_VIDEO_BT848) += bttv.o |
10 | 10 | ||
diff --git a/drivers/media/video/bt8xx/bttv-audio-hook.c b/drivers/media/video/bt8xx/bttv-audio-hook.c new file mode 100644 index 000000000000..1e7fcaa259eb --- /dev/null +++ b/drivers/media/video/bt8xx/bttv-audio-hook.c | |||
@@ -0,0 +1,390 @@ | |||
1 | /* | ||
2 | * Handlers for board audio hooks, splitted from bttv-cards | ||
3 | * | ||
4 | * Copyright (c) 2006 Mauro Carvalho Chehab (mchehab@infradead.org) | ||
5 | * This code is placed under the terms of the GNU General Public License | ||
6 | */ | ||
7 | |||
8 | /* ----------------------------------------------------------------------- */ | ||
9 | /* winview */ | ||
10 | |||
11 | #include "bttvp.h" | ||
12 | #include <linux/videodev.h> | ||
13 | |||
14 | static void winview_audio(struct bttv *btv, struct video_audio *v, int set) | ||
15 | { | ||
16 | /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */ | ||
17 | int bits_out, loops, vol, data; | ||
18 | |||
19 | if (!set) { | ||
20 | /* Fixed by Leandro Lucarella <luca@linuxmendoza.org.ar (07/31/01) */ | ||
21 | v->flags |= VIDEO_AUDIO_VOLUME; | ||
22 | return; | ||
23 | } | ||
24 | |||
25 | /* 32 levels logarithmic */ | ||
26 | vol = 32 - ((v->volume>>11)); | ||
27 | /* units */ | ||
28 | bits_out = (PT2254_DBS_IN_2>>(vol%5)); | ||
29 | /* tens */ | ||
30 | bits_out |= (PT2254_DBS_IN_10>>(vol/5)); | ||
31 | bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL; | ||
32 | data = gpio_read(); | ||
33 | data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA| | ||
34 | WINVIEW_PT2254_STROBE); | ||
35 | for (loops = 17; loops >= 0 ; loops--) { | ||
36 | if (bits_out & (1<<loops)) | ||
37 | data |= WINVIEW_PT2254_DATA; | ||
38 | else | ||
39 | data &= ~WINVIEW_PT2254_DATA; | ||
40 | gpio_write(data); | ||
41 | udelay(5); | ||
42 | data |= WINVIEW_PT2254_CLK; | ||
43 | gpio_write(data); | ||
44 | udelay(5); | ||
45 | data &= ~WINVIEW_PT2254_CLK; | ||
46 | gpio_write(data); | ||
47 | } | ||
48 | data |= WINVIEW_PT2254_STROBE; | ||
49 | data &= ~WINVIEW_PT2254_DATA; | ||
50 | gpio_write(data); | ||
51 | udelay(10); | ||
52 | data &= ~WINVIEW_PT2254_STROBE; | ||
53 | gpio_write(data); | ||
54 | } | ||
55 | |||
56 | /* ----------------------------------------------------------------------- */ | ||
57 | /* mono/stereo control for various cards (which don't use i2c chips but */ | ||
58 | /* connect something to the GPIO pins */ | ||
59 | |||
60 | static void | ||
61 | gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set) | ||
62 | { | ||
63 | unsigned int con = 0; | ||
64 | |||
65 | if (set) { | ||
66 | gpio_inout(0x300, 0x300); | ||
67 | if (v->mode & VIDEO_SOUND_LANG1) | ||
68 | con = 0x000; | ||
69 | if (v->mode & VIDEO_SOUND_LANG2) | ||
70 | con = 0x300; | ||
71 | if (v->mode & VIDEO_SOUND_STEREO) | ||
72 | con = 0x200; | ||
73 | /* if (v->mode & VIDEO_SOUND_MONO) | ||
74 | * con = 0x100; */ | ||
75 | gpio_bits(0x300, con); | ||
76 | } else { | ||
77 | v->mode = VIDEO_SOUND_STEREO | | ||
78 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static void | ||
83 | gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set) | ||
84 | { | ||
85 | unsigned int val, con; | ||
86 | |||
87 | if (btv->radio_user) | ||
88 | return; | ||
89 | |||
90 | val = gpio_read(); | ||
91 | if (set) { | ||
92 | con = 0x000; | ||
93 | if (v->mode & VIDEO_SOUND_LANG2) { | ||
94 | if (v->mode & VIDEO_SOUND_LANG1) { | ||
95 | /* LANG1 + LANG2 */ | ||
96 | con = 0x100; | ||
97 | } | ||
98 | else { | ||
99 | /* LANG2 */ | ||
100 | con = 0x300; | ||
101 | } | ||
102 | } | ||
103 | if (con != (val & 0x300)) { | ||
104 | gpio_bits(0x300, con); | ||
105 | if (bttv_gpio) | ||
106 | bttv_gpio_tracking(btv,"gvbctv5pci"); | ||
107 | } | ||
108 | } else { | ||
109 | switch (val & 0x70) { | ||
110 | case 0x10: | ||
111 | v->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
112 | break; | ||
113 | case 0x30: | ||
114 | v->mode = VIDEO_SOUND_LANG2; | ||
115 | break; | ||
116 | case 0x50: | ||
117 | v->mode = VIDEO_SOUND_LANG1; | ||
118 | break; | ||
119 | case 0x60: | ||
120 | v->mode = VIDEO_SOUND_STEREO; | ||
121 | break; | ||
122 | case 0x70: | ||
123 | v->mode = VIDEO_SOUND_MONO; | ||
124 | break; | ||
125 | default: | ||
126 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
127 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /* | ||
133 | * Mario Medina Nussbaum <medisoft@alohabbs.org.mx> | ||
134 | * I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo, | ||
135 | * 0xdde enables mono and 0xccd enables sap | ||
136 | * | ||
137 | * Petr Vandrovec <VANDROVE@vc.cvut.cz> | ||
138 | * P.S.: At least mask in line above is wrong - GPIO pins 3,2 select | ||
139 | * input/output sound connection, so both must be set for output mode. | ||
140 | * | ||
141 | * Looks like it's needed only for the "tvphone", the "tvphone 98" | ||
142 | * handles this with a tda9840 | ||
143 | * | ||
144 | */ | ||
145 | static void | ||
146 | avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set) | ||
147 | { | ||
148 | int val = 0; | ||
149 | |||
150 | if (set) { | ||
151 | if (v->mode & VIDEO_SOUND_LANG2) /* SAP */ | ||
152 | val = 0x02; | ||
153 | if (v->mode & VIDEO_SOUND_STEREO) | ||
154 | val = 0x01; | ||
155 | if (val) { | ||
156 | gpio_bits(0x03,val); | ||
157 | if (bttv_gpio) | ||
158 | bttv_gpio_tracking(btv,"avermedia"); | ||
159 | } | ||
160 | } else { | ||
161 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
162 | VIDEO_SOUND_LANG1; | ||
163 | return; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | static void | ||
168 | avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, int set) | ||
169 | { | ||
170 | int val = 0; | ||
171 | |||
172 | if (set) { | ||
173 | if (v->mode & VIDEO_SOUND_LANG2) /* SAP */ | ||
174 | val = 0x01; | ||
175 | if (v->mode & VIDEO_SOUND_STEREO) /* STEREO */ | ||
176 | val = 0x02; | ||
177 | btaor(val, ~0x03, BT848_GPIO_DATA); | ||
178 | if (bttv_gpio) | ||
179 | bttv_gpio_tracking(btv,"avermedia"); | ||
180 | } else { | ||
181 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
182 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
183 | return; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | /* Lifetec 9415 handling */ | ||
188 | static void | ||
189 | lt9415_audio(struct bttv *btv, struct video_audio *v, int set) | ||
190 | { | ||
191 | int val = 0; | ||
192 | |||
193 | if (gpio_read() & 0x4000) { | ||
194 | v->mode = VIDEO_SOUND_MONO; | ||
195 | return; | ||
196 | } | ||
197 | |||
198 | if (set) { | ||
199 | if (v->mode & VIDEO_SOUND_LANG2) /* A2 SAP */ | ||
200 | val = 0x0080; | ||
201 | if (v->mode & VIDEO_SOUND_STEREO) /* A2 stereo */ | ||
202 | val = 0x0880; | ||
203 | if ((v->mode & VIDEO_SOUND_LANG1) || | ||
204 | (v->mode & VIDEO_SOUND_MONO)) | ||
205 | val = 0; | ||
206 | gpio_bits(0x0880, val); | ||
207 | if (bttv_gpio) | ||
208 | bttv_gpio_tracking(btv,"lt9415"); | ||
209 | } else { | ||
210 | /* autodetect doesn't work with this card :-( */ | ||
211 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
212 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
213 | return; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | /* TDA9821 on TerraTV+ Bt848, Bt878 */ | ||
218 | static void | ||
219 | terratv_audio(struct bttv *btv, struct video_audio *v, int set) | ||
220 | { | ||
221 | unsigned int con = 0; | ||
222 | |||
223 | if (set) { | ||
224 | gpio_inout(0x180000,0x180000); | ||
225 | if (v->mode & VIDEO_SOUND_LANG2) | ||
226 | con = 0x080000; | ||
227 | if (v->mode & VIDEO_SOUND_STEREO) | ||
228 | con = 0x180000; | ||
229 | gpio_bits(0x180000, con); | ||
230 | if (bttv_gpio) | ||
231 | bttv_gpio_tracking(btv,"terratv"); | ||
232 | } else { | ||
233 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
234 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | static void | ||
239 | winfast2000_audio(struct bttv *btv, struct video_audio *v, int set) | ||
240 | { | ||
241 | unsigned long val = 0; | ||
242 | |||
243 | if (set) { | ||
244 | /*btor (0xc32000, BT848_GPIO_OUT_EN);*/ | ||
245 | if (v->mode & VIDEO_SOUND_MONO) /* Mono */ | ||
246 | val = 0x420000; | ||
247 | if (v->mode & VIDEO_SOUND_LANG1) /* Mono */ | ||
248 | val = 0x420000; | ||
249 | if (v->mode & VIDEO_SOUND_LANG2) /* SAP */ | ||
250 | val = 0x410000; | ||
251 | if (v->mode & VIDEO_SOUND_STEREO) /* Stereo */ | ||
252 | val = 0x020000; | ||
253 | if (val) { | ||
254 | gpio_bits(0x430000, val); | ||
255 | if (bttv_gpio) | ||
256 | bttv_gpio_tracking(btv,"winfast2000"); | ||
257 | } | ||
258 | } else { | ||
259 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
260 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * Dariusz Kowalewski <darekk@automex.pl> | ||
266 | * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM | ||
267 | * revision 9B has on-board TDA9874A sound decoder). | ||
268 | * | ||
269 | * Note: There are card variants without tda9874a. Forcing the "stereo sound route" | ||
270 | * will mute this cards. | ||
271 | */ | ||
272 | static void | ||
273 | pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set) | ||
274 | { | ||
275 | unsigned int val = 0; | ||
276 | |||
277 | if (btv->radio_user) | ||
278 | return; | ||
279 | |||
280 | if (set) { | ||
281 | if (v->mode & VIDEO_SOUND_MONO) { | ||
282 | val = 0x01; | ||
283 | } | ||
284 | if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) | ||
285 | || (v->mode & VIDEO_SOUND_STEREO)) { | ||
286 | val = 0x02; | ||
287 | } | ||
288 | if (val) { | ||
289 | gpio_bits(0x03,val); | ||
290 | if (bttv_gpio) | ||
291 | bttv_gpio_tracking(btv,"pvbt878p9b"); | ||
292 | } | ||
293 | } else { | ||
294 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
295 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | /* | ||
300 | * Dariusz Kowalewski <darekk@automex.pl> | ||
301 | * sound control for FlyVideo 2000S (with tda9874 decoder) | ||
302 | * based on pvbt878p9b_audio() - this is not tested, please fix!!! | ||
303 | */ | ||
304 | static void | ||
305 | fv2000s_audio(struct bttv *btv, struct video_audio *v, int set) | ||
306 | { | ||
307 | unsigned int val = 0xffff; | ||
308 | |||
309 | if (btv->radio_user) | ||
310 | return; | ||
311 | |||
312 | if (set) { | ||
313 | if (v->mode & VIDEO_SOUND_MONO) { | ||
314 | val = 0x0000; | ||
315 | } | ||
316 | if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) | ||
317 | || (v->mode & VIDEO_SOUND_STEREO)) { | ||
318 | val = 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */ | ||
319 | } | ||
320 | if (val != 0xffff) { | ||
321 | gpio_bits(0x1800, val); | ||
322 | if (bttv_gpio) | ||
323 | bttv_gpio_tracking(btv,"fv2000s"); | ||
324 | } | ||
325 | } else { | ||
326 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
327 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | /* | ||
332 | * sound control for Canopus WinDVR PCI | ||
333 | * Masaki Suzuki <masaki@btree.org> | ||
334 | */ | ||
335 | static void | ||
336 | windvr_audio(struct bttv *btv, struct video_audio *v, int set) | ||
337 | { | ||
338 | unsigned long val = 0; | ||
339 | |||
340 | if (set) { | ||
341 | if (v->mode & VIDEO_SOUND_MONO) | ||
342 | val = 0x040000; | ||
343 | if (v->mode & VIDEO_SOUND_LANG1) | ||
344 | val = 0; | ||
345 | if (v->mode & VIDEO_SOUND_LANG2) | ||
346 | val = 0x100000; | ||
347 | if (v->mode & VIDEO_SOUND_STEREO) | ||
348 | val = 0; | ||
349 | if (val) { | ||
350 | gpio_bits(0x140000, val); | ||
351 | if (bttv_gpio) | ||
352 | bttv_gpio_tracking(btv,"windvr"); | ||
353 | } | ||
354 | } else { | ||
355 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
356 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
357 | } | ||
358 | } | ||
359 | |||
360 | /* | ||
361 | * sound control for AD-TVK503 | ||
362 | * Hiroshi Takekawa <sian@big.or.jp> | ||
363 | */ | ||
364 | static void | ||
365 | adtvk503_audio(struct bttv *btv, struct video_audio *v, int set) | ||
366 | { | ||
367 | unsigned int con = 0xffffff; | ||
368 | |||
369 | /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */ | ||
370 | |||
371 | if (set) { | ||
372 | /* btor(***, BT848_GPIO_OUT_EN); */ | ||
373 | if (v->mode & VIDEO_SOUND_LANG1) | ||
374 | con = 0x00000000; | ||
375 | if (v->mode & VIDEO_SOUND_LANG2) | ||
376 | con = 0x00180000; | ||
377 | if (v->mode & VIDEO_SOUND_STEREO) | ||
378 | con = 0x00000000; | ||
379 | if (v->mode & VIDEO_SOUND_MONO) | ||
380 | con = 0x00060000; | ||
381 | if (con != 0xffffff) { | ||
382 | gpio_bits(0x1e0000,con); | ||
383 | if (bttv_gpio) | ||
384 | bttv_gpio_tracking(btv, "adtvk503"); | ||
385 | } | ||
386 | } else { | ||
387 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
388 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
389 | } | ||
390 | } | ||
diff --git a/drivers/media/video/bt8xx/bttv-audio-hook.h b/drivers/media/video/bt8xx/bttv-audio-hook.h new file mode 100644 index 000000000000..9770cacc17b9 --- /dev/null +++ b/drivers/media/video/bt8xx/bttv-audio-hook.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * Handlers for board audio hooks, splitted from bttv-cards | ||
3 | * | ||
4 | * Copyright (c) 2006 Mauro Carvalho Chehab (mchehab@infradead.org) | ||
5 | * This code is placed under the terms of the GNU General Public License | ||
6 | */ | ||
7 | |||
8 | #include "bttvp.h" | ||
9 | |||
10 | static void winview_audio(struct bttv *btv, struct video_audio *v, int set); | ||
11 | static void lt9415_audio(struct bttv *btv, struct video_audio *v, int set); | ||
12 | static void avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, | ||
13 | int set); | ||
14 | static void avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, | ||
15 | int set); | ||
16 | static void terratv_audio(struct bttv *btv, struct video_audio *v, int set); | ||
17 | static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set); | ||
18 | static void gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set); | ||
19 | static void winfast2000_audio(struct bttv *btv, struct video_audio *v, int set); | ||
20 | static void pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set); | ||
21 | static void fv2000s_audio(struct bttv *btv, struct video_audio *v, int set); | ||
22 | static void windvr_audio(struct bttv *btv, struct video_audio *v, int set); | ||
23 | static void adtvk503_audio(struct bttv *btv, struct video_audio *v, int set); | ||
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index 6a2d37258820..78e5e29748ac 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "bttvp.h" | 39 | #include "bttvp.h" |
40 | #include <media/v4l2-common.h> | 40 | #include <media/v4l2-common.h> |
41 | #include <media/tvaudio.h> | 41 | #include <media/tvaudio.h> |
42 | #include "bttv-audio-hook.h" | ||
42 | 43 | ||
43 | /* fwd decl */ | 44 | /* fwd decl */ |
44 | static void boot_msp34xx(struct bttv *btv, int pin); | 45 | static void boot_msp34xx(struct bttv *btv, int pin); |
@@ -50,20 +51,6 @@ static void modtec_eeprom(struct bttv *btv); | |||
50 | static void init_PXC200(struct bttv *btv); | 51 | static void init_PXC200(struct bttv *btv); |
51 | static void init_RTV24(struct bttv *btv); | 52 | static void init_RTV24(struct bttv *btv); |
52 | 53 | ||
53 | static void winview_audio(struct bttv *btv, struct video_audio *v, int set); | ||
54 | static void lt9415_audio(struct bttv *btv, struct video_audio *v, int set); | ||
55 | static void avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, | ||
56 | int set); | ||
57 | static void avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, | ||
58 | int set); | ||
59 | static void terratv_audio(struct bttv *btv, struct video_audio *v, int set); | ||
60 | static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set); | ||
61 | static void gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set); | ||
62 | static void winfast2000_audio(struct bttv *btv, struct video_audio *v, int set); | ||
63 | static void pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set); | ||
64 | static void fv2000s_audio(struct bttv *btv, struct video_audio *v, int set); | ||
65 | static void windvr_audio(struct bttv *btv, struct video_audio *v, int set); | ||
66 | static void adtvk503_audio(struct bttv *btv, struct video_audio *v, int set); | ||
67 | static void rv605_muxsel(struct bttv *btv, unsigned int input); | 54 | static void rv605_muxsel(struct bttv *btv, unsigned int input); |
68 | static void eagle_muxsel(struct bttv *btv, unsigned int input); | 55 | static void eagle_muxsel(struct bttv *btv, unsigned int input); |
69 | static void xguard_muxsel(struct bttv *btv, unsigned int input); | 56 | static void xguard_muxsel(struct bttv *btv, unsigned int input); |
@@ -3954,7 +3941,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv) | |||
3954 | void bttv_tda9880_setnorm(struct bttv *btv, int norm) | 3941 | void bttv_tda9880_setnorm(struct bttv *btv, int norm) |
3955 | { | 3942 | { |
3956 | /* fix up our card entry */ | 3943 | /* fix up our card entry */ |
3957 | if(norm==VIDEO_MODE_NTSC) { | 3944 | if(norm==V4L2_STD_NTSC) { |
3958 | bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomux[TVAUDIO_INPUT_TUNER]=0x957fff; | 3945 | bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomux[TVAUDIO_INPUT_TUNER]=0x957fff; |
3959 | bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomute=0x957fff; | 3946 | bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomute=0x957fff; |
3960 | bttv_tvcards[BTTV_BOARD_VOODOOTV_200].gpiomux[TVAUDIO_INPUT_TUNER]=0x957fff; | 3947 | bttv_tvcards[BTTV_BOARD_VOODOOTV_200].gpiomux[TVAUDIO_INPUT_TUNER]=0x957fff; |
@@ -4323,388 +4310,6 @@ void tea5757_set_freq(struct bttv *btv, unsigned short freq) | |||
4323 | tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */ | 4310 | tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */ |
4324 | } | 4311 | } |
4325 | 4312 | ||
4326 | |||
4327 | /* ----------------------------------------------------------------------- */ | ||
4328 | /* winview */ | ||
4329 | |||
4330 | static void winview_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4331 | { | ||
4332 | /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */ | ||
4333 | int bits_out, loops, vol, data; | ||
4334 | |||
4335 | if (!set) { | ||
4336 | /* Fixed by Leandro Lucarella <luca@linuxmendoza.org.ar (07/31/01) */ | ||
4337 | v->flags |= VIDEO_AUDIO_VOLUME; | ||
4338 | return; | ||
4339 | } | ||
4340 | |||
4341 | /* 32 levels logarithmic */ | ||
4342 | vol = 32 - ((v->volume>>11)); | ||
4343 | /* units */ | ||
4344 | bits_out = (PT2254_DBS_IN_2>>(vol%5)); | ||
4345 | /* tens */ | ||
4346 | bits_out |= (PT2254_DBS_IN_10>>(vol/5)); | ||
4347 | bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL; | ||
4348 | data = gpio_read(); | ||
4349 | data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA| | ||
4350 | WINVIEW_PT2254_STROBE); | ||
4351 | for (loops = 17; loops >= 0 ; loops--) { | ||
4352 | if (bits_out & (1<<loops)) | ||
4353 | data |= WINVIEW_PT2254_DATA; | ||
4354 | else | ||
4355 | data &= ~WINVIEW_PT2254_DATA; | ||
4356 | gpio_write(data); | ||
4357 | udelay(5); | ||
4358 | data |= WINVIEW_PT2254_CLK; | ||
4359 | gpio_write(data); | ||
4360 | udelay(5); | ||
4361 | data &= ~WINVIEW_PT2254_CLK; | ||
4362 | gpio_write(data); | ||
4363 | } | ||
4364 | data |= WINVIEW_PT2254_STROBE; | ||
4365 | data &= ~WINVIEW_PT2254_DATA; | ||
4366 | gpio_write(data); | ||
4367 | udelay(10); | ||
4368 | data &= ~WINVIEW_PT2254_STROBE; | ||
4369 | gpio_write(data); | ||
4370 | } | ||
4371 | |||
4372 | /* ----------------------------------------------------------------------- */ | ||
4373 | /* mono/stereo control for various cards (which don't use i2c chips but */ | ||
4374 | /* connect something to the GPIO pins */ | ||
4375 | |||
4376 | static void | ||
4377 | gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4378 | { | ||
4379 | unsigned int con = 0; | ||
4380 | |||
4381 | if (set) { | ||
4382 | gpio_inout(0x300, 0x300); | ||
4383 | if (v->mode & VIDEO_SOUND_LANG1) | ||
4384 | con = 0x000; | ||
4385 | if (v->mode & VIDEO_SOUND_LANG2) | ||
4386 | con = 0x300; | ||
4387 | if (v->mode & VIDEO_SOUND_STEREO) | ||
4388 | con = 0x200; | ||
4389 | /* if (v->mode & VIDEO_SOUND_MONO) | ||
4390 | * con = 0x100; */ | ||
4391 | gpio_bits(0x300, con); | ||
4392 | } else { | ||
4393 | v->mode = VIDEO_SOUND_STEREO | | ||
4394 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4395 | } | ||
4396 | } | ||
4397 | |||
4398 | static void | ||
4399 | gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4400 | { | ||
4401 | unsigned int val, con; | ||
4402 | |||
4403 | if (btv->radio_user) | ||
4404 | return; | ||
4405 | |||
4406 | val = gpio_read(); | ||
4407 | if (set) { | ||
4408 | con = 0x000; | ||
4409 | if (v->mode & VIDEO_SOUND_LANG2) { | ||
4410 | if (v->mode & VIDEO_SOUND_LANG1) { | ||
4411 | /* LANG1 + LANG2 */ | ||
4412 | con = 0x100; | ||
4413 | } | ||
4414 | else { | ||
4415 | /* LANG2 */ | ||
4416 | con = 0x300; | ||
4417 | } | ||
4418 | } | ||
4419 | if (con != (val & 0x300)) { | ||
4420 | gpio_bits(0x300, con); | ||
4421 | if (bttv_gpio) | ||
4422 | bttv_gpio_tracking(btv,"gvbctv5pci"); | ||
4423 | } | ||
4424 | } else { | ||
4425 | switch (val & 0x70) { | ||
4426 | case 0x10: | ||
4427 | v->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4428 | break; | ||
4429 | case 0x30: | ||
4430 | v->mode = VIDEO_SOUND_LANG2; | ||
4431 | break; | ||
4432 | case 0x50: | ||
4433 | v->mode = VIDEO_SOUND_LANG1; | ||
4434 | break; | ||
4435 | case 0x60: | ||
4436 | v->mode = VIDEO_SOUND_STEREO; | ||
4437 | break; | ||
4438 | case 0x70: | ||
4439 | v->mode = VIDEO_SOUND_MONO; | ||
4440 | break; | ||
4441 | default: | ||
4442 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4443 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4444 | } | ||
4445 | } | ||
4446 | } | ||
4447 | |||
4448 | /* | ||
4449 | * Mario Medina Nussbaum <medisoft@alohabbs.org.mx> | ||
4450 | * I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo, | ||
4451 | * 0xdde enables mono and 0xccd enables sap | ||
4452 | * | ||
4453 | * Petr Vandrovec <VANDROVE@vc.cvut.cz> | ||
4454 | * P.S.: At least mask in line above is wrong - GPIO pins 3,2 select | ||
4455 | * input/output sound connection, so both must be set for output mode. | ||
4456 | * | ||
4457 | * Looks like it's needed only for the "tvphone", the "tvphone 98" | ||
4458 | * handles this with a tda9840 | ||
4459 | * | ||
4460 | */ | ||
4461 | static void | ||
4462 | avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4463 | { | ||
4464 | int val = 0; | ||
4465 | |||
4466 | if (set) { | ||
4467 | if (v->mode & VIDEO_SOUND_LANG2) /* SAP */ | ||
4468 | val = 0x02; | ||
4469 | if (v->mode & VIDEO_SOUND_STEREO) | ||
4470 | val = 0x01; | ||
4471 | if (val) { | ||
4472 | gpio_bits(0x03,val); | ||
4473 | if (bttv_gpio) | ||
4474 | bttv_gpio_tracking(btv,"avermedia"); | ||
4475 | } | ||
4476 | } else { | ||
4477 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4478 | VIDEO_SOUND_LANG1; | ||
4479 | return; | ||
4480 | } | ||
4481 | } | ||
4482 | |||
4483 | static void | ||
4484 | avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4485 | { | ||
4486 | int val = 0; | ||
4487 | |||
4488 | if (set) { | ||
4489 | if (v->mode & VIDEO_SOUND_LANG2) /* SAP */ | ||
4490 | val = 0x01; | ||
4491 | if (v->mode & VIDEO_SOUND_STEREO) /* STEREO */ | ||
4492 | val = 0x02; | ||
4493 | btaor(val, ~0x03, BT848_GPIO_DATA); | ||
4494 | if (bttv_gpio) | ||
4495 | bttv_gpio_tracking(btv,"avermedia"); | ||
4496 | } else { | ||
4497 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4498 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4499 | return; | ||
4500 | } | ||
4501 | } | ||
4502 | |||
4503 | /* Lifetec 9415 handling */ | ||
4504 | static void | ||
4505 | lt9415_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4506 | { | ||
4507 | int val = 0; | ||
4508 | |||
4509 | if (gpio_read() & 0x4000) { | ||
4510 | v->mode = VIDEO_SOUND_MONO; | ||
4511 | return; | ||
4512 | } | ||
4513 | |||
4514 | if (set) { | ||
4515 | if (v->mode & VIDEO_SOUND_LANG2) /* A2 SAP */ | ||
4516 | val = 0x0080; | ||
4517 | if (v->mode & VIDEO_SOUND_STEREO) /* A2 stereo */ | ||
4518 | val = 0x0880; | ||
4519 | if ((v->mode & VIDEO_SOUND_LANG1) || | ||
4520 | (v->mode & VIDEO_SOUND_MONO)) | ||
4521 | val = 0; | ||
4522 | gpio_bits(0x0880, val); | ||
4523 | if (bttv_gpio) | ||
4524 | bttv_gpio_tracking(btv,"lt9415"); | ||
4525 | } else { | ||
4526 | /* autodetect doesn't work with this card :-( */ | ||
4527 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4528 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4529 | return; | ||
4530 | } | ||
4531 | } | ||
4532 | |||
4533 | /* TDA9821 on TerraTV+ Bt848, Bt878 */ | ||
4534 | static void | ||
4535 | terratv_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4536 | { | ||
4537 | unsigned int con = 0; | ||
4538 | |||
4539 | if (set) { | ||
4540 | gpio_inout(0x180000,0x180000); | ||
4541 | if (v->mode & VIDEO_SOUND_LANG2) | ||
4542 | con = 0x080000; | ||
4543 | if (v->mode & VIDEO_SOUND_STEREO) | ||
4544 | con = 0x180000; | ||
4545 | gpio_bits(0x180000, con); | ||
4546 | if (bttv_gpio) | ||
4547 | bttv_gpio_tracking(btv,"terratv"); | ||
4548 | } else { | ||
4549 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4550 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4551 | } | ||
4552 | } | ||
4553 | |||
4554 | static void | ||
4555 | winfast2000_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4556 | { | ||
4557 | unsigned long val = 0; | ||
4558 | |||
4559 | if (set) { | ||
4560 | /*btor (0xc32000, BT848_GPIO_OUT_EN);*/ | ||
4561 | if (v->mode & VIDEO_SOUND_MONO) /* Mono */ | ||
4562 | val = 0x420000; | ||
4563 | if (v->mode & VIDEO_SOUND_LANG1) /* Mono */ | ||
4564 | val = 0x420000; | ||
4565 | if (v->mode & VIDEO_SOUND_LANG2) /* SAP */ | ||
4566 | val = 0x410000; | ||
4567 | if (v->mode & VIDEO_SOUND_STEREO) /* Stereo */ | ||
4568 | val = 0x020000; | ||
4569 | if (val) { | ||
4570 | gpio_bits(0x430000, val); | ||
4571 | if (bttv_gpio) | ||
4572 | bttv_gpio_tracking(btv,"winfast2000"); | ||
4573 | } | ||
4574 | } else { | ||
4575 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4576 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4577 | } | ||
4578 | } | ||
4579 | |||
4580 | /* | ||
4581 | * Dariusz Kowalewski <darekk@automex.pl> | ||
4582 | * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM | ||
4583 | * revision 9B has on-board TDA9874A sound decoder). | ||
4584 | * | ||
4585 | * Note: There are card variants without tda9874a. Forcing the "stereo sound route" | ||
4586 | * will mute this cards. | ||
4587 | */ | ||
4588 | static void | ||
4589 | pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4590 | { | ||
4591 | unsigned int val = 0; | ||
4592 | |||
4593 | if (btv->radio_user) | ||
4594 | return; | ||
4595 | |||
4596 | if (set) { | ||
4597 | if (v->mode & VIDEO_SOUND_MONO) { | ||
4598 | val = 0x01; | ||
4599 | } | ||
4600 | if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) | ||
4601 | || (v->mode & VIDEO_SOUND_STEREO)) { | ||
4602 | val = 0x02; | ||
4603 | } | ||
4604 | if (val) { | ||
4605 | gpio_bits(0x03,val); | ||
4606 | if (bttv_gpio) | ||
4607 | bttv_gpio_tracking(btv,"pvbt878p9b"); | ||
4608 | } | ||
4609 | } else { | ||
4610 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4611 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4612 | } | ||
4613 | } | ||
4614 | |||
4615 | /* | ||
4616 | * Dariusz Kowalewski <darekk@automex.pl> | ||
4617 | * sound control for FlyVideo 2000S (with tda9874 decoder) | ||
4618 | * based on pvbt878p9b_audio() - this is not tested, please fix!!! | ||
4619 | */ | ||
4620 | static void | ||
4621 | fv2000s_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4622 | { | ||
4623 | unsigned int val = 0xffff; | ||
4624 | |||
4625 | if (btv->radio_user) | ||
4626 | return; | ||
4627 | |||
4628 | if (set) { | ||
4629 | if (v->mode & VIDEO_SOUND_MONO) { | ||
4630 | val = 0x0000; | ||
4631 | } | ||
4632 | if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2)) | ||
4633 | || (v->mode & VIDEO_SOUND_STEREO)) { | ||
4634 | val = 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */ | ||
4635 | } | ||
4636 | if (val != 0xffff) { | ||
4637 | gpio_bits(0x1800, val); | ||
4638 | if (bttv_gpio) | ||
4639 | bttv_gpio_tracking(btv,"fv2000s"); | ||
4640 | } | ||
4641 | } else { | ||
4642 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4643 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4644 | } | ||
4645 | } | ||
4646 | |||
4647 | /* | ||
4648 | * sound control for Canopus WinDVR PCI | ||
4649 | * Masaki Suzuki <masaki@btree.org> | ||
4650 | */ | ||
4651 | static void | ||
4652 | windvr_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4653 | { | ||
4654 | unsigned long val = 0; | ||
4655 | |||
4656 | if (set) { | ||
4657 | if (v->mode & VIDEO_SOUND_MONO) | ||
4658 | val = 0x040000; | ||
4659 | if (v->mode & VIDEO_SOUND_LANG1) | ||
4660 | val = 0; | ||
4661 | if (v->mode & VIDEO_SOUND_LANG2) | ||
4662 | val = 0x100000; | ||
4663 | if (v->mode & VIDEO_SOUND_STEREO) | ||
4664 | val = 0; | ||
4665 | if (val) { | ||
4666 | gpio_bits(0x140000, val); | ||
4667 | if (bttv_gpio) | ||
4668 | bttv_gpio_tracking(btv,"windvr"); | ||
4669 | } | ||
4670 | } else { | ||
4671 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4672 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4673 | } | ||
4674 | } | ||
4675 | |||
4676 | /* | ||
4677 | * sound control for AD-TVK503 | ||
4678 | * Hiroshi Takekawa <sian@big.or.jp> | ||
4679 | */ | ||
4680 | static void | ||
4681 | adtvk503_audio(struct bttv *btv, struct video_audio *v, int set) | ||
4682 | { | ||
4683 | unsigned int con = 0xffffff; | ||
4684 | |||
4685 | /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */ | ||
4686 | |||
4687 | if (set) { | ||
4688 | /* btor(***, BT848_GPIO_OUT_EN); */ | ||
4689 | if (v->mode & VIDEO_SOUND_LANG1) | ||
4690 | con = 0x00000000; | ||
4691 | if (v->mode & VIDEO_SOUND_LANG2) | ||
4692 | con = 0x00180000; | ||
4693 | if (v->mode & VIDEO_SOUND_STEREO) | ||
4694 | con = 0x00000000; | ||
4695 | if (v->mode & VIDEO_SOUND_MONO) | ||
4696 | con = 0x00060000; | ||
4697 | if (con != 0xffffff) { | ||
4698 | gpio_bits(0x1e0000,con); | ||
4699 | if (bttv_gpio) | ||
4700 | bttv_gpio_tracking(btv, "adtvk503"); | ||
4701 | } | ||
4702 | } else { | ||
4703 | v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO | | ||
4704 | VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | ||
4705 | } | ||
4706 | } | ||
4707 | |||
4708 | /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas] | 4313 | /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas] |
4709 | * | 4314 | * |
4710 | * This is needed because rv605 don't use a normal multiplex, but a crosspoint | 4315 | * This is needed because rv605 don't use a normal multiplex, but a crosspoint |
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h index 19e75d50a107..2edef15ba35c 100644 --- a/drivers/media/video/bt8xx/bttv.h +++ b/drivers/media/video/bt8xx/bttv.h | |||
@@ -241,7 +241,9 @@ struct tvcard | |||
241 | unsigned int radio_addr; | 241 | unsigned int radio_addr; |
242 | 242 | ||
243 | unsigned int has_radio; | 243 | unsigned int has_radio; |
244 | #ifdef CONFIG_VIDEO_V4L1 | ||
244 | void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); | 245 | void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); |
246 | #endif | ||
245 | void (*muxsel_hook)(struct bttv *btv, unsigned int input); | 247 | void (*muxsel_hook)(struct bttv *btv, unsigned int input); |
246 | }; | 248 | }; |
247 | 249 | ||
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h index 37b96a54f90e..fdd78f8b1dc3 100644 --- a/drivers/media/video/bt8xx/bttvp.h +++ b/drivers/media/video/bt8xx/bttvp.h | |||
@@ -336,8 +336,9 @@ struct bttv { | |||
336 | /* old gpio interface */ | 336 | /* old gpio interface */ |
337 | wait_queue_head_t gpioq; | 337 | wait_queue_head_t gpioq; |
338 | int shutdown; | 338 | int shutdown; |
339 | #ifdef CONFIG_VIDEO_V4L1 | ||
339 | void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); | 340 | void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set); |
340 | 341 | #endif | |
341 | /* new gpio interface */ | 342 | /* new gpio interface */ |
342 | spinlock_t gpio_lock; | 343 | spinlock_t gpio_lock; |
343 | 344 | ||