2 * SPDX-License-Identifier: BSD-4-Clause
4 * 1. Redistributions of source code must retain the
5 * Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Amancio Hasty and
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD$");
40 * This is part of the Driver for Video Capture Cards (Frame grabbers)
41 * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
43 * Copyright Roger Hardiman and Amancio Hasty.
45 * bktr_audio : This deals with controlling the audio on TV cards,
46 * controlling the Audio Multiplexer (audio source selector).
47 * controlling any MSP34xx stereo audio decoders.
48 * controlling any DPL35xx dolby surroud sound audio decoders.
49 * initialising TDA98xx audio devices.
53 #include "opt_bktr.h" /* Include any kernel config options */
55 #include <sys/param.h>
56 #include <sys/systm.h>
57 #include <sys/kernel.h>
61 #if (__FreeBSD_version < 500000)
62 #include <machine/clock.h> /* for DELAY */
63 #include <pci/pcivar.h>
66 #include <sys/mutex.h>
67 #include <sys/selinfo.h>
68 #include <dev/pci/pcivar.h>
71 #include <machine/bus.h>
77 #include <dev/ic/bt8xx.h> /* NetBSD location of .h files */
78 #include <dev/pci/bktr/bktr_reg.h>
79 #include <dev/pci/bktr/bktr_core.h>
80 #include <dev/pci/bktr/bktr_tuner.h>
81 #include <dev/pci/bktr/bktr_card.h>
82 #include <dev/pci/bktr/bktr_audio.h>
84 #include <dev/bktr/ioctl_meteor.h>
85 #include <dev/bktr/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
86 #include <dev/bktr/bktr_reg.h>
87 #include <dev/bktr/bktr_core.h>
88 #include <dev/bktr/bktr_tuner.h>
89 #include <dev/bktr/bktr_card.h>
90 #include <dev/bktr/bktr_audio.h>
94 * Prototypes for the GV_BCTV2 specific functions.
96 void set_bctv2_audio( bktr_ptr_t bktr );
97 void bctv2_gpio_write( bktr_ptr_t bktr, int port, int val );
98 /*int bctv2_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */
102 * Reset any MSP34xx or TDA98xx audio devices.
104 void init_audio_devices( bktr_ptr_t bktr ) {
106 /* enable stereo if appropriate on TDA audio chip */
107 if ( bktr->card.dbx )
110 /* reset the MSP34xx stereo audio chip */
111 if ( bktr->card.msp3400c )
112 msp_dpl_reset( bktr, bktr->msp_addr );
114 /* reset the DPL35xx dolby audio chip */
115 if ( bktr->card.dpl3518a )
116 msp_dpl_reset( bktr, bktr->dpl_addr );
124 #define AUDIOMUX_DISCOVER_NOT
126 set_audio( bktr_ptr_t bktr, int cmd )
131 #if defined( AUDIOMUX_DISCOVER )
135 #endif /* AUDIOMUX_DISCOVER */
137 /* check for existence of audio MUXes */
138 if ( !bktr->card.audiomuxs[ 4 ] )
143 #ifdef BKTR_REVERSEMUTE
144 bktr->audio_mux_select = 3;
146 bktr->audio_mux_select = 0;
149 if (bktr->reverse_mute )
150 bktr->audio_mux_select = 0;
152 bktr->audio_mux_select = 3;
156 bktr->audio_mux_select = 1;
159 bktr->audio_mux_select = 2;
162 bktr->audio_mute_state = TRUE; /* set mute */
165 bktr->audio_mute_state = FALSE; /* clear mute */
168 printf("%s: audio cmd error %02x\n", bktr_name(bktr),
174 /* Most cards have a simple audio multiplexer to select the
175 * audio source. The I/O_GV card has a more advanced multiplexer
176 * and requires special handling.
178 if ( bktr->bt848_card == CARD_IO_BCTV2 ) {
179 set_bctv2_audio( bktr );
183 /* Proceed with the simpler audio multiplexer code for the majority
188 * Leave the upper bits of the GPIO port alone in case they control
189 * something like the dbx or teletext chips. This doesn't guarantee
190 * success, but follows the rule of least astonishment.
193 if ( bktr->audio_mute_state == TRUE ) {
194 #ifdef BKTR_REVERSEMUTE
200 if (bktr->reverse_mute )
207 idx = bktr->audio_mux_select;
210 temp = INL(bktr, BKTR_GPIO_DATA) & ~bktr->card.gpio_mux_bits;
211 #if defined( AUDIOMUX_DISCOVER )
212 OUTL(bktr, BKTR_GPIO_DATA, temp | (cmd & 0xff));
213 printf("%s: cmd: %d audio mux %x temp %x \n", bktr_name(bktr),
214 cmd, bktr->card.audiomuxs[ idx ], temp );
216 OUTL(bktr, BKTR_GPIO_DATA, temp | bktr->card.audiomuxs[ idx ]);
217 #endif /* AUDIOMUX_DISCOVER */
221 /* Some new Hauppauge cards do not have an audio mux */
222 /* Instead we use the MSP34xx chip to select TV audio, Line-In */
223 /* FM Radio and Mute */
224 /* Examples of this are the Hauppauge 44xxx MSP34xx models */
225 /* It is ok to drive both the mux and the MSP34xx chip. */
226 /* If there is no mux, the MSP does the switching of the audio source */
227 /* If there is a mux, it does the switching of the audio source */
229 if ((bktr->card.msp3400c) && (bktr->audio_mux_present == 0)) {
231 if (bktr->audio_mute_state == TRUE ) {
232 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x0000); /* volume to MUTE */
234 if(bktr->audio_mux_select == 0) { /* TV Tuner */
235 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
236 if (bktr->msp_source_selected != 0) msp_autodetect(bktr); /* setup TV audio mode */
237 bktr->msp_source_selected = 0;
239 if(bktr->audio_mux_select == 1) { /* Line In */
240 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
241 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */
242 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
243 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0000); /* DSP In = SC1_IN_L/R */
244 bktr->msp_source_selected = 1;
247 if(bktr->audio_mux_select == 2) { /* FM Radio */
248 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
249 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */
250 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
251 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0200); /* DSP In = SC2_IN_L/R */
252 bktr->msp_source_selected = 2;
266 temp_mute( bktr_ptr_t bktr, int flag )
268 static int muteState = FALSE;
270 if ( flag == TRUE ) {
271 muteState = bktr->audio_mute_state;
272 set_audio( bktr, AUDIO_MUTE ); /* prevent 'click' */
275 tsleep( BKTR_SLEEP, PZERO, "tuning", hz/8 );
276 if ( muteState == FALSE )
277 set_audio( bktr, AUDIO_UNMUTE );
281 /* address of BTSC/SAP decoder chip */
282 #define TDA9850_WADDR 0xb6
283 #define TDA9850_RADDR 0xb7
286 /* registers in the TDA9850 BTSC/dbx chip */
287 #define CON1ADDR 0x04
288 #define CON2ADDR 0x05
289 #define CON3ADDR 0x06
290 #define CON4ADDR 0x07
291 #define ALI1ADDR 0x08
292 #define ALI2ADDR 0x09
293 #define ALI3ADDR 0x0a
296 * initialise the dbx chip
297 * taken from the Linux bttv driver TDA9850 initialisation code
300 init_BTSC( bktr_ptr_t bktr )
302 i2cWrite(bktr, TDA9850_WADDR, CON1ADDR, 0x08); /* noise threshold st */
303 i2cWrite(bktr, TDA9850_WADDR, CON2ADDR, 0x08); /* noise threshold sap */
304 i2cWrite(bktr, TDA9850_WADDR, CON3ADDR, 0x40); /* stereo mode */
305 i2cWrite(bktr, TDA9850_WADDR, CON4ADDR, 0x07); /* 0 dB input gain? */
306 i2cWrite(bktr, TDA9850_WADDR, ALI1ADDR, 0x10); /* wideband alignment? */
307 i2cWrite(bktr, TDA9850_WADDR, ALI2ADDR, 0x10); /* spectral alignment? */
308 i2cWrite(bktr, TDA9850_WADDR, ALI3ADDR, 0x03);
313 * XXX FIXME: a lot of work to be done here, this merely unmutes it.
316 set_BTSC( bktr_ptr_t bktr, int control )
318 return( i2cWrite( bktr, TDA9850_WADDR, CON3ADDR, control ) );
322 * CARD_GV_BCTV2 specific functions.
325 #define BCTV2_AUDIO_MAIN 0x10 /* main audio program */
326 #define BCTV2_AUDIO_SUB 0x20 /* sub audio program */
327 #define BCTV2_AUDIO_BOTH 0x30 /* main(L) + sub(R) program */
329 #define BCTV2_GPIO_REG0 1
330 #define BCTV2_GPIO_REG1 3
332 #define BCTV2_GR0_AUDIO_MODE 3
333 #define BCTV2_GR0_AUDIO_MAIN 0 /* main program */
334 #define BCTV2_GR0_AUDIO_SUB 3 /* sub program */
335 #define BCTV2_GR0_AUDIO_BOTH 1 /* main(L) + sub(R) */
336 #define BCTV2_GR0_AUDIO_MUTE 4 /* audio mute */
337 #define BCTV2_GR0_AUDIO_MONO 8 /* force mono */
340 set_bctv2_audio( bktr_ptr_t bktr )
344 switch (bktr->audio_mux_select) {
345 case 1: /* external */
346 case 2: /* internal */
347 bctv2_gpio_write(bktr, BCTV2_GPIO_REG1, 0);
350 bctv2_gpio_write(bktr, BCTV2_GPIO_REG1, 1);
353 /* switch (bktr->audio_sap_select) { */
354 switch (BCTV2_AUDIO_BOTH) {
355 case BCTV2_AUDIO_SUB:
356 data = BCTV2_GR0_AUDIO_SUB;
358 case BCTV2_AUDIO_BOTH:
359 data = BCTV2_GR0_AUDIO_BOTH;
361 case BCTV2_AUDIO_MAIN:
363 data = BCTV2_GR0_AUDIO_MAIN;
366 if (bktr->audio_mute_state == TRUE)
367 data |= BCTV2_GR0_AUDIO_MUTE;
369 bctv2_gpio_write(bktr, BCTV2_GPIO_REG0, data);
374 /* gpio_data bit assignment */
375 #define BCTV2_GPIO_ADDR_MASK 0x000300
376 #define BCTV2_GPIO_WE 0x000400
377 #define BCTV2_GPIO_OE 0x000800
378 #define BCTV2_GPIO_VAL_MASK 0x00f000
380 #define BCTV2_GPIO_PORT_MASK 3
381 #define BCTV2_GPIO_ADDR_SHIFT 8
382 #define BCTV2_GPIO_VAL_SHIFT 12
384 /* gpio_out_en value for read/write */
385 #define BCTV2_GPIO_OUT_RMASK 0x000f00
386 #define BCTV2_GPIO_OUT_WMASK 0x00ff00
388 #define BCTV2_BITS 100
391 bctv2_gpio_write( bktr_ptr_t bktr, int port, int val )
393 u_long data, outbits;
395 port &= BCTV2_GPIO_PORT_MASK;
399 data = ((val << BCTV2_GPIO_VAL_SHIFT) & BCTV2_GPIO_VAL_MASK) |
400 ((port << BCTV2_GPIO_ADDR_SHIFT) & BCTV2_GPIO_ADDR_MASK) |
401 BCTV2_GPIO_WE | BCTV2_GPIO_OE;
402 outbits = BCTV2_GPIO_OUT_WMASK;
407 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
408 OUTL(bktr, BKTR_GPIO_DATA, data);
409 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits);
411 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV2_GPIO_WE);
413 OUTL(bktr, BKTR_GPIO_DATA, data);
415 OUTL(bktr, BKTR_GPIO_DATA, ~0);
416 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
421 bctv2_gpio_read( bktr_ptr_t bktr, int port )
423 u_long data, outbits, ret;
425 port &= BCTV2_GPIO_PORT_MASK;
429 data = ((port << BCTV2_GPIO_ADDR_SHIFT) & BCTV2_GPIO_ADDR_MASK) |
430 BCTV2_GPIO_WE | BCTV2_GPIO_OE;
431 outbits = BCTV2_GPIO_OUT_RMASK;
436 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
437 OUTL(bktr, BKTR_GPIO_DATA, data);
438 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits);
440 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV2_GPIO_OE);
442 ret = INL(bktr, BKTR_GPIO_DATA);
444 OUTL(bktr, BKTR_GPIO_DATA, data);
446 OUTL(bktr, BKTR_GPIO_DATA, ~0);
447 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
448 return( (ret & BCTV2_GPIO_VAL_MASK) >> BCTV2_GPIO_VAL_SHIFT );
453 * setup the MSP34xx Stereo Audio Chip
454 * This uses the Auto Configuration Option on MSP3410D and MSP3415D chips
455 * and DBX mode selection for MSP3430G chips.
456 * For MSP3400C support, the full programming sequence is required and is
460 /* Read the MSP version string */
461 void msp_read_id( bktr_ptr_t bktr ){
463 rev1 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001e);
464 rev2 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001f);
466 sprintf(bktr->msp_version_string, "34%02d%c-%c%d",
467 (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
472 /* Configure the MSP chip to Auto-detect the audio format.
473 * For the MSP3430G, we use fast autodetect mode
474 * For the MSP3410/3415 there are two schemes for this
475 * a) Fast autodetection - the chip is put into autodetect mode, and the function
476 * returns immediately. This works in most cases and is the Default Mode.
477 * b) Slow mode. The function sets the MSP3410/3415 chip, then waits for feedback from
478 * the chip and re-programs it if needed.
480 void msp_autodetect( bktr_ptr_t bktr ) {
482 #ifdef BKTR_NEW_MSP34XX_DRIVER
484 /* Just wake up the (maybe) sleeping thread, it'll do everything for us */
485 msp_wake_thread(bktr);
488 int auto_detect, loops;
491 /* MSP3430G - countries with mono and DBX stereo */
492 if (strncmp("3430G", bktr->msp_version_string, 5) == 0){
494 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0030,0x2003);/* Enable Auto format detection */
495 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/
496 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000E,0x2403);/* darned if I know */
497 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0320);/* Source select = (St or A) */
498 /* & Ch. Matrix = St */
499 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
503 /* MSP3415D SPECIAL CASE Use the Tuner's Mono audio output for the MSP */
504 /* (for Hauppauge 44xxx card with Tuner Type 0x2a) */
505 else if ( ( (strncmp("3415D", bktr->msp_version_string, 5) == 0)
506 &&(bktr->msp_use_mono_source == 1)
508 || (bktr->slow_msp_audio == 2) ){
509 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
510 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */
511 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
512 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0100); /* DSP In = MONO IN */
516 /* MSP3410/MSP3415 - countries with mono, stereo using 2 FM channels and NICAM */
517 /* FAST sound scheme */
518 else if (bktr->slow_msp_audio == 0) {
519 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
520 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Spkr Source = default(FM/AM) */
521 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
522 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
526 /* MSP3410/MSP3415 - European Countries where the fast MSP3410/3415 programming fails */
527 /* SLOW sound scheme */
528 else if ( bktr->slow_msp_audio == 1) {
529 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
530 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
532 /* wait for 0.5s max for terrestrial sound autodetection */
536 auto_detect = msp_dpl_read(bktr, bktr->msp_addr, 0x10, 0x007e);
538 } while (auto_detect > 0xff && loops < 50);
539 if (bootverbose)printf ("%s: Result of autodetect after %dms: %d\n",
540 bktr_name(bktr), loops*10, auto_detect);
542 /* Now set the audio baseband processing */
543 switch (auto_detect) {
544 case 0: /* no TV sound standard detected */
546 case 2: /* M Dual FM */
548 case 3: /* B/G Dual FM; German stereo */
549 /* Read the stereo detection value from DSP reg 0x0018 */
551 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
552 if (bootverbose)printf ("%s: Stereo reg 0x18 a: %d\n",
553 bktr_name(bktr), stereo);
555 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
556 if (bootverbose)printf ("%s: Stereo reg 0x18 b: %d\n",
557 bktr_name(bktr), stereo);
559 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
560 if (bootverbose)printf ("%s: Stereo reg 0x18 c: %d\n",
561 bktr_name(bktr), stereo);
562 if (stereo > 0x0100 && stereo < 0x8000) { /* Seems to be stereo */
563 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker set stereo*/
565 set spatial effect strength to 50% enlargement
566 set spatial effect mode b, stereo basewidth enlargement only
568 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f28);
569 } else if (stereo > 0x8000) { /* bilingual mode */
570 if (bootverbose) printf ("%s: Bilingual mode detected\n",
572 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Loudspeaker */
573 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x0000);/* all spatial effects off */
574 } else { /* must be mono */
575 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0030);/* Loudspeaker */
577 set spatial effect strength to 50% enlargement
578 set spatial effect mode a, stereo basewidth enlargement
579 and pseudo stereo effect with automatic high-pass filter
581 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f08);
584 /* The reset value for Channel matrix mode is FM/AM and SOUNDA/LEFT */
585 /* We would like STEREO instead val: 0x0020 */
586 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker */
587 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0009,0x0020);/* Headphone */
588 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000a,0x0020);/* SCART1 */
589 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0041,0x0020);/* SCART2 */
590 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000b,0x0020);/* I2S */
591 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000c,0x0020);/* Quasi-Peak Detector Source */
592 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000e,0x0001);
595 case 8: /* B/G FM NICAM */
596 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
598 case 9: /* L_AM NICAM or D/K*/
599 case 10: /* i-FM NICAM */
602 if (bootverbose) printf ("%s: Unknown autodetection result value: %d\n",
603 bktr_name(bktr), auto_detect);
609 /* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */
610 /* turn your speaker volume down low before trying this */
611 /* msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0014, 0x7f40); */
613 #endif /* BKTR_NEW_MSP34XX_DRIVER */
616 /* Read the DPL version string */
617 void dpl_read_id( bktr_ptr_t bktr ){
619 rev1 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001e);
620 rev2 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001f);
622 sprintf(bktr->dpl_version_string, "34%02d%c-%c%d",
623 ((rev2>>8)&0xff)-1, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
626 /* Configure the DPL chip to Auto-detect the audio format */
627 void dpl_autodetect( bktr_ptr_t bktr ) {
629 /* The following are empiric values tried from the DPL35xx data sheet */
630 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x000c,0x0320); /* quasi peak detector source dolby
631 lr 0x03xx; quasi peak detector matrix
633 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0040,0x0060); /* Surround decoder mode;
634 ADAPTIVE/3D-PANORAMA, that means two
635 speakers and no center speaker, all
636 channels L/R/C/S mixed to L and R */
637 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0041,0x0620); /* surround source matrix;I2S2/STEREO*/
638 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0042,0x1F00); /* surround delay 31ms max */
639 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0043,0x0000); /* automatic surround input balance */
640 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0044,0x4000); /* surround spatial effect 50%
642 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0045,0x5400); /* surround panorama effect 66%
643 recommended with PANORAMA mode
644 in 0x0040 set to panorama */