1 // SPDX-License-Identifier: GPL-2.0
3 * Handlers for board audio hooks, split from bttv-cards
5 * Copyright (c) 2006 Mauro Carvalho Chehab <mchehab@kernel.org>
8 #include "bttv-audio-hook.h"
10 #include <linux/delay.h>
12 /* ----------------------------------------------------------------------- */
15 void winview_volume(struct bttv
*btv
, __u16 volume
)
17 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
18 int bits_out
, loops
, vol
, data
;
20 /* 32 levels logarithmic */
21 vol
= 32 - ((volume
>>11));
23 bits_out
= (PT2254_DBS_IN_2
>>(vol
%5));
25 bits_out
|= (PT2254_DBS_IN_10
>>(vol
/5));
26 bits_out
|= PT2254_L_CHANNEL
| PT2254_R_CHANNEL
;
28 data
&= ~(WINVIEW_PT2254_CLK
| WINVIEW_PT2254_DATA
|
29 WINVIEW_PT2254_STROBE
);
30 for (loops
= 17; loops
>= 0 ; loops
--) {
31 if (bits_out
& (1<<loops
))
32 data
|= WINVIEW_PT2254_DATA
;
34 data
&= ~WINVIEW_PT2254_DATA
;
37 data
|= WINVIEW_PT2254_CLK
;
40 data
&= ~WINVIEW_PT2254_CLK
;
43 data
|= WINVIEW_PT2254_STROBE
;
44 data
&= ~WINVIEW_PT2254_DATA
;
47 data
&= ~WINVIEW_PT2254_STROBE
;
51 /* ----------------------------------------------------------------------- */
52 /* mono/stereo control for various cards (which don't use i2c chips but */
53 /* connect something to the GPIO pins */
55 void gvbctv3pci_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
60 /* Not much to do here */
61 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
62 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
63 V4L2_TUNER_SUB_STEREO
|
64 V4L2_TUNER_SUB_LANG1
|
70 gpio_inout(0x300, 0x300);
72 case V4L2_TUNER_MODE_LANG1
:
76 case V4L2_TUNER_MODE_LANG2
:
79 case V4L2_TUNER_MODE_STEREO
:
83 gpio_bits(0x300, con
);
86 void gvbctv5pci_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
88 unsigned int val
, con
;
96 case V4L2_TUNER_MODE_LANG2
:
99 case V4L2_TUNER_MODE_LANG1_LANG2
:
106 if (con
!= (val
& 0x300)) {
107 gpio_bits(0x300, con
);
109 bttv_gpio_tracking(btv
, "gvbctv5pci");
112 switch (val
& 0x70) {
114 t
->rxsubchans
= V4L2_TUNER_SUB_LANG1
| V4L2_TUNER_SUB_LANG2
;
115 t
->audmode
= V4L2_TUNER_MODE_LANG1_LANG2
;
118 t
->rxsubchans
= V4L2_TUNER_SUB_LANG2
;
119 t
->audmode
= V4L2_TUNER_MODE_LANG1_LANG2
;
122 t
->rxsubchans
= V4L2_TUNER_SUB_LANG1
;
123 t
->audmode
= V4L2_TUNER_MODE_LANG1_LANG2
;
126 t
->rxsubchans
= V4L2_TUNER_SUB_STEREO
;
127 t
->audmode
= V4L2_TUNER_MODE_STEREO
;
130 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
;
131 t
->audmode
= V4L2_TUNER_MODE_MONO
;
134 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
135 V4L2_TUNER_SUB_STEREO
|
136 V4L2_TUNER_SUB_LANG1
|
137 V4L2_TUNER_SUB_LANG2
;
138 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
144 * Mario Medina Nussbaum <medisoft@alohabbs.org.mx>
145 * I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo,
146 * 0xdde enables mono and 0xccd enables sap
148 * Petr Vandrovec <VANDROVE@vc.cvut.cz>
149 * P.S.: At least mask in line above is wrong - GPIO pins 3,2 select
150 * input/output sound connection, so both must be set for output mode.
152 * Looks like it's needed only for the "tvphone", the "tvphone 98"
153 * handles this with a tda9840
157 void avermedia_tvphone_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
162 /* Not much to do here */
163 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
164 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
165 V4L2_TUNER_SUB_STEREO
|
166 V4L2_TUNER_SUB_LANG1
|
167 V4L2_TUNER_SUB_LANG2
;
172 switch (t
->audmode
) {
173 case V4L2_TUNER_MODE_LANG2
: /* SAP */
176 case V4L2_TUNER_MODE_STEREO
:
182 gpio_bits(0x03, val
);
184 bttv_gpio_tracking(btv
, "avermedia");
188 void avermedia_tv_stereo_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
193 /* Not much to do here */
194 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
195 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
196 V4L2_TUNER_SUB_STEREO
|
197 V4L2_TUNER_SUB_LANG1
|
198 V4L2_TUNER_SUB_LANG2
;
203 switch (t
->audmode
) {
204 case V4L2_TUNER_MODE_LANG2
: /* SAP */
207 case V4L2_TUNER_MODE_STEREO
:
214 btaor(val
, ~0x03, BT848_GPIO_DATA
);
216 bttv_gpio_tracking(btv
, "avermedia");
219 /* Lifetec 9415 handling */
221 void lt9415_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
225 if (gpio_read() & 0x4000) {
226 t
->audmode
= V4L2_TUNER_MODE_MONO
;
231 /* Not much to do here */
232 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
233 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
234 V4L2_TUNER_SUB_STEREO
|
235 V4L2_TUNER_SUB_LANG1
|
236 V4L2_TUNER_SUB_LANG2
;
241 switch (t
->audmode
) {
242 case V4L2_TUNER_MODE_LANG2
: /* A2 SAP */
245 case V4L2_TUNER_MODE_STEREO
: /* A2 stereo */
253 gpio_bits(0x0880, val
);
255 bttv_gpio_tracking(btv
, "lt9415");
258 /* TDA9821 on TerraTV+ Bt848, Bt878 */
259 void terratv_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
261 unsigned int con
= 0;
264 /* Not much to do here */
265 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
266 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
267 V4L2_TUNER_SUB_STEREO
|
268 V4L2_TUNER_SUB_LANG1
|
269 V4L2_TUNER_SUB_LANG2
;
274 gpio_inout(0x180000, 0x180000);
275 switch (t
->audmode
) {
276 case V4L2_TUNER_MODE_LANG2
:
279 case V4L2_TUNER_MODE_STEREO
:
286 gpio_bits(0x180000, con
);
288 bttv_gpio_tracking(btv
, "terratv");
292 void winfast2000_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
299 /*btor (0xc32000, BT848_GPIO_OUT_EN);*/
300 switch (t
->audmode
) {
301 case V4L2_TUNER_MODE_MONO
:
302 case V4L2_TUNER_MODE_LANG1
:
305 case V4L2_TUNER_MODE_LANG2
: /* SAP */
308 case V4L2_TUNER_MODE_STEREO
:
315 gpio_bits(0x430000, val
);
317 bttv_gpio_tracking(btv
, "winfast2000");
321 * Dariusz Kowalewski <darekk@automex.pl>
322 * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM
323 * revision 9B has on-board TDA9874A sound decoder).
325 * Note: There are card variants without tda9874a. Forcing the "stereo sound route"
326 * will mute this cards.
328 void pvbt878p9b_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
330 unsigned int val
= 0;
336 /* Not much to do here */
337 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
338 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
339 V4L2_TUNER_SUB_STEREO
|
340 V4L2_TUNER_SUB_LANG1
|
341 V4L2_TUNER_SUB_LANG2
;
346 switch (t
->audmode
) {
347 case V4L2_TUNER_MODE_MONO
:
350 case V4L2_TUNER_MODE_LANG1
:
351 case V4L2_TUNER_MODE_LANG2
:
352 case V4L2_TUNER_MODE_STEREO
:
359 gpio_bits(0x03, val
);
361 bttv_gpio_tracking(btv
, "pvbt878p9b");
365 * Dariusz Kowalewski <darekk@automex.pl>
366 * sound control for FlyVideo 2000S (with tda9874 decoder)
367 * based on pvbt878p9b_audio() - this is not tested, please fix!!!
369 void fv2000s_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
377 /* Not much to do here */
378 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
379 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
380 V4L2_TUNER_SUB_STEREO
|
381 V4L2_TUNER_SUB_LANG1
|
382 V4L2_TUNER_SUB_LANG2
;
387 switch (t
->audmode
) {
388 case V4L2_TUNER_MODE_MONO
:
391 case V4L2_TUNER_MODE_LANG1
:
392 case V4L2_TUNER_MODE_LANG2
:
393 case V4L2_TUNER_MODE_STEREO
:
394 val
= 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */
399 gpio_bits(0x1800, val
);
401 bttv_gpio_tracking(btv
, "fv2000s");
405 * sound control for Canopus WinDVR PCI
406 * Masaki Suzuki <masaki@btree.org>
408 void windvr_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
413 /* Not much to do here */
414 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
415 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
416 V4L2_TUNER_SUB_STEREO
|
417 V4L2_TUNER_SUB_LANG1
|
418 V4L2_TUNER_SUB_LANG2
;
423 switch (t
->audmode
) {
424 case V4L2_TUNER_MODE_MONO
:
427 case V4L2_TUNER_MODE_LANG2
:
434 gpio_bits(0x140000, val
);
436 bttv_gpio_tracking(btv
, "windvr");
440 * sound control for AD-TVK503
441 * Hiroshi Takekawa <sian@big.or.jp>
443 void adtvk503_audio(struct bttv
*btv
, struct v4l2_tuner
*t
, int set
)
445 unsigned int con
= 0xffffff;
447 /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */
450 /* Not much to do here */
451 t
->audmode
= V4L2_TUNER_MODE_LANG1
;
452 t
->rxsubchans
= V4L2_TUNER_SUB_MONO
|
453 V4L2_TUNER_SUB_STEREO
|
454 V4L2_TUNER_SUB_LANG1
|
455 V4L2_TUNER_SUB_LANG2
;
460 /* btor(***, BT848_GPIO_OUT_EN); */
461 switch (t
->audmode
) {
462 case V4L2_TUNER_MODE_LANG1
:
465 case V4L2_TUNER_MODE_LANG2
:
468 case V4L2_TUNER_MODE_STEREO
:
471 case V4L2_TUNER_MODE_MONO
:
478 gpio_bits(0x1e0000, con
);
480 bttv_gpio_tracking(btv
, "adtvk503");