2 * 1. Redistributions of source code must retain the
3 * Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Amancio Hasty and
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * $FreeBSD: src/sys/dev/bktr/bktr_audio.c,v 1.16 2005/05/29 04:42:18 nyan Exp $
34 * $DragonFly: src/sys/dev/video/bktr/bktr_audio.c,v 1.10 2007/10/03 19:27:08 swildner Exp $
38 * This is part of the Driver for Video Capture Cards (Frame grabbers)
39 * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
41 * Copyright Roger Hardiman and Amancio Hasty.
43 * bktr_audio : This deals with controlling the audio on TV cards,
44 * controlling the Audio Multiplexer (audio source selector).
45 * controlling any MSP34xx stereo audio decoders.
46 * controlling any DPL35xx dolby surroud sound audio decoders.
47 * initialising TDA98xx audio devices.
51 #include "opt_bktr.h" /* Include any kernel config options */
53 #include <sys/param.h>
54 #include <sys/systm.h>
55 #include <sys/kernel.h>
57 #include <sys/selinfo.h>
59 #include <bus/pci/pcivar.h>
61 #include <dev/video/meteor/ioctl_meteor.h>
62 #include <dev/video/bktr/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
63 #include <dev/video/bktr/bktr_reg.h>
64 #include <dev/video/bktr/bktr_core.h>
65 #include <dev/video/bktr/bktr_tuner.h>
66 #include <dev/video/bktr/bktr_card.h>
67 #include <dev/video/bktr/bktr_audio.h>
70 * Prototypes for the GV_BCTV2 specific functions.
72 void set_bctv2_audio( bktr_ptr_t bktr
);
73 void bctv2_gpio_write( bktr_ptr_t bktr
, int port
, int val
);
74 /*int bctv2_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */
78 * Reset any MSP34xx or TDA98xx audio devices.
80 void init_audio_devices( bktr_ptr_t bktr
) {
82 /* enable stereo if appropriate on TDA audio chip */
86 /* reset the MSP34xx stereo audio chip */
87 if ( bktr
->card
.msp3400c
)
88 msp_dpl_reset( bktr
, bktr
->msp_addr
);
90 /* reset the DPL35xx dolby audio chip */
91 if ( bktr
->card
.dpl3518a
)
92 msp_dpl_reset( bktr
, bktr
->dpl_addr
);
100 #define AUDIOMUX_DISCOVER_NOT
102 set_audio( bktr_ptr_t bktr
, int cmd
)
107 #if defined( AUDIOMUX_DISCOVER )
111 #endif /* AUDIOMUX_DISCOVER */
113 /* check for existance of audio MUXes */
114 if ( !bktr
->card
.audiomuxs
[ 4 ] )
119 #ifdef BKTR_REVERSEMUTE
120 bktr
->audio_mux_select
= 3;
122 bktr
->audio_mux_select
= 0;
125 if (bktr
->reverse_mute
)
126 bktr
->audio_mux_select
= 0;
128 bktr
->audio_mux_select
= 3;
132 bktr
->audio_mux_select
= 1;
135 bktr
->audio_mux_select
= 2;
138 bktr
->audio_mute_state
= TRUE
; /* set mute */
141 bktr
->audio_mute_state
= FALSE
; /* clear mute */
144 kprintf("%s: audio cmd error %02x\n", bktr_name(bktr
),
150 /* Most cards have a simple audio multiplexer to select the
151 * audio source. The I/O_GV card has a more advanced multiplexer
152 * and requires special handling.
154 if ( bktr
->bt848_card
== CARD_IO_BCTV2
) {
155 set_bctv2_audio( bktr
);
159 /* Proceed with the simpler audio multiplexer code for the majority
164 * Leave the upper bits of the GPIO port alone in case they control
165 * something like the dbx or teletext chips. This doesn't guarantee
166 * success, but follows the rule of least astonishment.
169 if ( bktr
->audio_mute_state
== TRUE
) {
170 #ifdef BKTR_REVERSEMUTE
176 if (bktr
->reverse_mute
)
183 idx
= bktr
->audio_mux_select
;
186 temp
= INL(bktr
, BKTR_GPIO_DATA
) & ~bktr
->card
.gpio_mux_bits
;
187 #if defined( AUDIOMUX_DISCOVER )
188 OUTL(bktr
, BKTR_GPIO_DATA
, temp
| (cmd
& 0xff));
189 kprintf("%s: cmd: %d audio mux %x temp %x \n", bktr_name(bktr
),
190 cmd
, bktr
->card
.audiomuxs
[ idx
], temp
);
192 OUTL(bktr
, BKTR_GPIO_DATA
, temp
| bktr
->card
.audiomuxs
[ idx
]);
193 #endif /* AUDIOMUX_DISCOVER */
197 /* Some new Hauppauge cards do not have an audio mux */
198 /* Instead we use the MSP34xx chip to select TV audio, Line-In */
199 /* FM Radio and Mute */
200 /* Examples of this are the Hauppauge 44xxx MSP34xx models */
201 /* It is ok to drive both the mux and the MSP34xx chip. */
202 /* If there is no mux, the MSP does the switching of the audio source */
203 /* If there is a mux, it does the switching of the audio source */
205 if ((bktr
->card
.msp3400c
) && (bktr
->audio_mux_present
== 0)) {
207 if (bktr
->audio_mute_state
== TRUE
) {
208 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000, 0x0000); /* volume to MUTE */
210 if(bktr
->audio_mux_select
== 0) { /* TV Tuner */
211 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000, 0x7300); /* 0 db volume */
212 if (bktr
->msp_source_selected
!= 0) msp_autodetect(bktr
); /* setup TV audio mode */
213 bktr
->msp_source_selected
= 0;
215 if(bktr
->audio_mux_select
== 1) { /* Line In */
216 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000, 0x7300); /* 0 db volume */
217 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000d, 0x1900); /* scart prescale */
218 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
219 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0013, 0x0000); /* DSP In = SC1_IN_L/R */
220 bktr
->msp_source_selected
= 1;
223 if(bktr
->audio_mux_select
== 2) { /* FM Radio */
224 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000, 0x7300); /* 0 db volume */
225 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000d, 0x1900); /* scart prescale */
226 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
227 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0013, 0x0200); /* DSP In = SC2_IN_L/R */
228 bktr
->msp_source_selected
= 2;
242 temp_mute( bktr_ptr_t bktr
, int flag
)
244 static int muteState
= FALSE
;
246 if ( flag
== TRUE
) {
247 muteState
= bktr
->audio_mute_state
;
248 set_audio( bktr
, AUDIO_MUTE
); /* prevent 'click' */
251 tsleep( BKTR_SLEEP
, 0, "tuning", hz
/8 );
252 if ( muteState
== FALSE
)
253 set_audio( bktr
, AUDIO_UNMUTE
);
257 /* address of BTSC/SAP decoder chip */
258 #define TDA9850_WADDR 0xb6
259 #define TDA9850_RADDR 0xb7
262 /* registers in the TDA9850 BTSC/dbx chip */
263 #define CON1ADDR 0x04
264 #define CON2ADDR 0x05
265 #define CON3ADDR 0x06
266 #define CON4ADDR 0x07
267 #define ALI1ADDR 0x08
268 #define ALI2ADDR 0x09
269 #define ALI3ADDR 0x0a
272 * initialise the dbx chip
273 * taken from the Linux bttv driver TDA9850 initialisation code
276 init_BTSC( bktr_ptr_t bktr
)
278 i2cWrite(bktr
, TDA9850_WADDR
, CON1ADDR
, 0x08); /* noise threshold st */
279 i2cWrite(bktr
, TDA9850_WADDR
, CON2ADDR
, 0x08); /* noise threshold sap */
280 i2cWrite(bktr
, TDA9850_WADDR
, CON3ADDR
, 0x40); /* stereo mode */
281 i2cWrite(bktr
, TDA9850_WADDR
, CON4ADDR
, 0x07); /* 0 dB input gain? */
282 i2cWrite(bktr
, TDA9850_WADDR
, ALI1ADDR
, 0x10); /* wideband alignment? */
283 i2cWrite(bktr
, TDA9850_WADDR
, ALI2ADDR
, 0x10); /* spectral alignment? */
284 i2cWrite(bktr
, TDA9850_WADDR
, ALI3ADDR
, 0x03);
289 * XXX FIXME: alot of work to be done here, this merely unmutes it.
292 set_BTSC( bktr_ptr_t bktr
, int control
)
294 return( i2cWrite( bktr
, TDA9850_WADDR
, CON3ADDR
, control
) );
298 * CARD_GV_BCTV2 specific functions.
301 #define BCTV2_AUDIO_MAIN 0x10 /* main audio program */
302 #define BCTV2_AUDIO_SUB 0x20 /* sub audio program */
303 #define BCTV2_AUDIO_BOTH 0x30 /* main(L) + sub(R) program */
305 #define BCTV2_GPIO_REG0 1
306 #define BCTV2_GPIO_REG1 3
308 #define BCTV2_GR0_AUDIO_MODE 3
309 #define BCTV2_GR0_AUDIO_MAIN 0 /* main program */
310 #define BCTV2_GR0_AUDIO_SUB 3 /* sub program */
311 #define BCTV2_GR0_AUDIO_BOTH 1 /* main(L) + sub(R) */
312 #define BCTV2_GR0_AUDIO_MUTE 4 /* audio mute */
313 #define BCTV2_GR0_AUDIO_MONO 8 /* force mono */
316 set_bctv2_audio( bktr_ptr_t bktr
)
320 switch (bktr
->audio_mux_select
) {
321 case 1: /* external */
322 case 2: /* internal */
323 bctv2_gpio_write(bktr
, BCTV2_GPIO_REG1
, 0);
326 bctv2_gpio_write(bktr
, BCTV2_GPIO_REG1
, 1);
329 /* switch (bktr->audio_sap_select) { */
330 switch (BCTV2_AUDIO_BOTH
) {
331 case BCTV2_AUDIO_SUB
:
332 data
= BCTV2_GR0_AUDIO_SUB
;
334 case BCTV2_AUDIO_BOTH
:
335 data
= BCTV2_GR0_AUDIO_BOTH
;
337 case BCTV2_AUDIO_MAIN
:
339 data
= BCTV2_GR0_AUDIO_MAIN
;
342 if (bktr
->audio_mute_state
== TRUE
)
343 data
|= BCTV2_GR0_AUDIO_MUTE
;
345 bctv2_gpio_write(bktr
, BCTV2_GPIO_REG0
, data
);
350 /* gpio_data bit assignment */
351 #define BCTV2_GPIO_ADDR_MASK 0x000300
352 #define BCTV2_GPIO_WE 0x000400
353 #define BCTV2_GPIO_OE 0x000800
354 #define BCTV2_GPIO_VAL_MASK 0x00f000
356 #define BCTV2_GPIO_PORT_MASK 3
357 #define BCTV2_GPIO_ADDR_SHIFT 8
358 #define BCTV2_GPIO_VAL_SHIFT 12
360 /* gpio_out_en value for read/write */
361 #define BCTV2_GPIO_OUT_RMASK 0x000f00
362 #define BCTV2_GPIO_OUT_WMASK 0x00ff00
364 #define BCTV2_BITS 100
367 bctv2_gpio_write( bktr_ptr_t bktr
, int port
, int val
)
369 u_long data
, outbits
;
371 port
&= BCTV2_GPIO_PORT_MASK
;
375 data
= ((val
<< BCTV2_GPIO_VAL_SHIFT
) & BCTV2_GPIO_VAL_MASK
) |
376 ((port
<< BCTV2_GPIO_ADDR_SHIFT
) & BCTV2_GPIO_ADDR_MASK
) |
377 BCTV2_GPIO_WE
| BCTV2_GPIO_OE
;
378 outbits
= BCTV2_GPIO_OUT_WMASK
;
383 OUTL(bktr
, BKTR_GPIO_OUT_EN
, 0);
384 OUTL(bktr
, BKTR_GPIO_DATA
, data
);
385 OUTL(bktr
, BKTR_GPIO_OUT_EN
, outbits
);
387 OUTL(bktr
, BKTR_GPIO_DATA
, data
& ~BCTV2_GPIO_WE
);
389 OUTL(bktr
, BKTR_GPIO_DATA
, data
);
391 OUTL(bktr
, BKTR_GPIO_DATA
, ~0);
392 OUTL(bktr
, BKTR_GPIO_OUT_EN
, 0);
397 bctv2_gpio_read( bktr_ptr_t bktr, int port )
399 u_long data, outbits, ret;
401 port &= BCTV2_GPIO_PORT_MASK;
405 data = ((port << BCTV2_GPIO_ADDR_SHIFT) & BCTV2_GPIO_ADDR_MASK) |
406 BCTV2_GPIO_WE | BCTV2_GPIO_OE;
407 outbits = BCTV2_GPIO_OUT_RMASK;
412 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
413 OUTL(bktr, BKTR_GPIO_DATA, data);
414 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits);
416 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV2_GPIO_OE);
418 ret = INL(bktr, BKTR_GPIO_DATA);
420 OUTL(bktr, BKTR_GPIO_DATA, data);
422 OUTL(bktr, BKTR_GPIO_DATA, ~0);
423 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
424 return( (ret & BCTV2_GPIO_VAL_MASK) >> BCTV2_GPIO_VAL_SHIFT );
429 * setup the MSP34xx Stereo Audio Chip
430 * This uses the Auto Configuration Option on MSP3410D and MSP3415D chips
431 * and DBX mode selection for MSP3430G chips.
432 * For MSP3400C support, the full programming sequence is required and is
436 /* Read the MSP version string */
437 void msp_read_id( bktr_ptr_t bktr
){
439 rev1
= msp_dpl_read(bktr
, bktr
->msp_addr
, 0x12, 0x001e);
440 rev2
= msp_dpl_read(bktr
, bktr
->msp_addr
, 0x12, 0x001f);
442 ksprintf(bktr
->msp_version_string
, "34%02d%c-%c%d",
443 (rev2
>>8)&0xff, (rev1
&0xff)+'@', ((rev1
>>8)&0xff)+'@', rev2
&0x1f);
448 /* Configure the MSP chip to Auto-detect the audio format.
449 * For the MSP3430G, we use fast autodetect mode
450 * For the MSP3410/3415 there are two schemes for this
451 * a) Fast autodetection - the chip is put into autodetect mode, and the function
452 * returns immediatly. This works in most cases and is the Default Mode.
453 * b) Slow mode. The function sets the MSP3410/3415 chip, then waits for feedback from
454 * the chip and re-programs it if needed.
456 void msp_autodetect( bktr_ptr_t bktr
) {
458 #ifdef BKTR_NEW_MSP34XX_DRIVER
460 /* Just wake up the (maybe) sleeping thread, it'll do everything for us */
461 msp_wake_thread(bktr
);
464 int auto_detect
, loops
;
467 /* MSP3430G - countries with mono and DBX stereo */
468 if (strncmp("3430G", bktr
->msp_version_string
, 5) == 0){
470 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x10, 0x0030,0x2003);/* Enable Auto format detection */
471 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/
472 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000E,0x2403);/* darned if I know */
473 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008,0x0320);/* Source select = (St or A) */
474 /* & Ch. Matrix = St */
475 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
479 /* MSP3415D SPECIAL CASE Use the Tuner's Mono audio ouput for the MSP */
480 /* (for Hauppauge 44xxx card with Tuner Type 0x2a) */
481 else if ( ( (strncmp("3415D", bktr
->msp_version_string
, 5) == 0)
482 &&(bktr
->msp_use_mono_source
== 1)
484 || (bktr
->slow_msp_audio
== 2) ){
485 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000, 0x7300); /* 0 db volume */
486 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000d, 0x1900); /* scart prescale */
487 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
488 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0013, 0x0100); /* DSP In = MONO IN */
492 /* MSP3410/MSP3415 - countries with mono, stereo using 2 FM channels and NICAM */
493 /* FAST sound scheme */
494 else if (bktr
->slow_msp_audio
== 0) {
495 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
496 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008,0x0000);/* Spkr Source = default(FM/AM) */
497 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
498 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
502 /* MSP3410/MSP3415 - European Countries where the fast MSP3410/3415 programming fails */
503 /* SLOW sound scheme */
504 else if ( bktr
->slow_msp_audio
== 1) {
505 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
506 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
508 /* wait for 0.5s max for terrestrial sound autodetection */
512 auto_detect
= msp_dpl_read(bktr
, bktr
->msp_addr
, 0x10, 0x007e);
514 } while (auto_detect
> 0xff && loops
< 50);
515 if (bootverbose
)kprintf ("%s: Result of autodetect after %dms: %d\n",
516 bktr_name(bktr
), loops
*10, auto_detect
);
518 /* Now set the audio baseband processing */
519 switch (auto_detect
) {
520 case 0: /* no TV sound standard detected */
522 case 2: /* M Dual FM */
524 case 3: /* B/G Dual FM; German stereo */
525 /* Read the stereo detection value from DSP reg 0x0018 */
527 stereo
= msp_dpl_read(bktr
, bktr
->msp_addr
, 0x12, 0x0018);
528 if (bootverbose
)kprintf ("%s: Stereo reg 0x18 a: %d\n",
529 bktr_name(bktr
), stereo
);
531 stereo
= msp_dpl_read(bktr
, bktr
->msp_addr
, 0x12, 0x0018);
532 if (bootverbose
)kprintf ("%s: Stereo reg 0x18 b: %d\n",
533 bktr_name(bktr
), stereo
);
535 stereo
= msp_dpl_read(bktr
, bktr
->msp_addr
, 0x12, 0x0018);
536 if (bootverbose
)kprintf ("%s: Stereo reg 0x18 c: %d\n",
537 bktr_name(bktr
), stereo
);
538 if (stereo
> 0x0100 && stereo
< 0x8000) { /* Seems to be stereo */
539 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008,0x0020);/* Loudspeaker set stereo*/
541 set spatial effect strength to 50% enlargement
542 set spatial effect mode b, stereo basewidth enlargment only
544 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0005,0x3f28);
545 } else if (stereo
> 0x8000) { /* bilingual mode */
546 if (bootverbose
) kprintf ("%s: Bilingual mode detected\n",
548 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008,0x0000);/* Loudspeaker */
549 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0005,0x0000);/* all spatial effects off */
550 } else { /* must be mono */
551 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008,0x0030);/* Loudspeaker */
553 set spatial effect strength to 50% enlargement
554 set spatial effect mode a, stereo basewidth enlargment
555 and pseudo stereo effect with automatic high-pass filter
557 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0005,0x3f08);
560 /* The reset value for Channel matrix mode is FM/AM and SOUNDA/LEFT */
561 /* We would like STEREO instead val: 0x0020 */
562 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0008,0x0020);/* Loudspeaker */
563 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0009,0x0020);/* Headphone */
564 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000a,0x0020);/* SCART1 */
565 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x0041,0x0020);/* SCART2 */
566 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000b,0x0020);/* I2S */
567 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000c,0x0020);/* Quasi-Peak Detector Source */
568 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x12, 0x000e,0x0001);
571 case 8: /* B/G FM NICAM */
572 msp_dpl_write(bktr
, bktr
->msp_addr
, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
574 case 9: /* L_AM NICAM or D/K*/
575 case 10: /* i-FM NICAM */
578 if (bootverbose
) kprintf ("%s: Unknown autodetection result value: %d\n",
579 bktr_name(bktr
), auto_detect
);
585 /* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */
586 /* turn your speaker volume down low before trying this */
587 /* msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0014, 0x7f40); */
589 #endif /* BKTR_NEW_MSP34XX_DRIVER */
592 /* Read the DPL version string */
593 void dpl_read_id( bktr_ptr_t bktr
){
595 rev1
= msp_dpl_read(bktr
, bktr
->dpl_addr
, 0x12, 0x001e);
596 rev2
= msp_dpl_read(bktr
, bktr
->dpl_addr
, 0x12, 0x001f);
598 ksprintf(bktr
->dpl_version_string
, "34%02d%c-%c%d",
599 ((rev2
>>8)&0xff)-1, (rev1
&0xff)+'@', ((rev1
>>8)&0xff)+'@', rev2
&0x1f);
602 /* Configure the DPL chip to Auto-detect the audio format */
603 void dpl_autodetect( bktr_ptr_t bktr
) {
605 /* The following are empiric values tried from the DPL35xx data sheet */
606 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x000c,0x0320); /* quasi peak detector source dolby
607 lr 0x03xx; quasi peak detector matrix
609 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x0040,0x0060); /* Surround decoder mode;
610 ADAPTIVE/3D-PANORAMA, that means two
611 speakers and no center speaker, all
612 channels L/R/C/S mixed to L and R */
613 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x0041,0x0620); /* surround source matrix;I2S2/STEREO*/
614 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x0042,0x1F00); /* surround delay 31ms max */
615 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x0043,0x0000); /* automatic surround input balance */
616 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x0044,0x4000); /* surround spatial effect 50%
618 msp_dpl_write(bktr
, bktr
->dpl_addr
, 0x12, 0x0045,0x5400); /* surround panorama effect 66%
619 recommended with PANORAMA mode
620 in 0x0040 set to panorama */