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.
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
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>
59 #if (__FreeBSD_version < 500000)
60 #include <machine/clock.h> /* for DELAY */
61 #include <pci/pcivar.h>
64 #include <sys/mutex.h>
65 #include <sys/selinfo.h>
66 #include <dev/pci/pcivar.h>
69 #include <machine/bus.h>
75 #include <dev/ic/bt8xx.h> /* NetBSD location of .h files */
76 #include <dev/pci/bktr/bktr_reg.h>
77 #include <dev/pci/bktr/bktr_core.h>
78 #include <dev/pci/bktr/bktr_tuner.h>
79 #include <dev/pci/bktr/bktr_card.h>
80 #include <dev/pci/bktr/bktr_audio.h>
82 #include <dev/bktr/ioctl_meteor.h>
83 #include <dev/bktr/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
84 #include <dev/bktr/bktr_reg.h>
85 #include <dev/bktr/bktr_core.h>
86 #include <dev/bktr/bktr_tuner.h>
87 #include <dev/bktr/bktr_card.h>
88 #include <dev/bktr/bktr_audio.h>
92 * Prototypes for the GV_BCTV2 specific functions.
94 void set_bctv2_audio( bktr_ptr_t bktr );
95 void bctv2_gpio_write( bktr_ptr_t bktr, int port, int val );
96 /*int bctv2_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */
100 * Reset any MSP34xx or TDA98xx audio devices.
102 void init_audio_devices( bktr_ptr_t bktr ) {
104 /* enable stereo if appropriate on TDA audio chip */
105 if ( bktr->card.dbx )
108 /* reset the MSP34xx stereo audio chip */
109 if ( bktr->card.msp3400c )
110 msp_dpl_reset( bktr, bktr->msp_addr );
112 /* reset the DPL35xx dolby audio chip */
113 if ( bktr->card.dpl3518a )
114 msp_dpl_reset( bktr, bktr->dpl_addr );
122 #define AUDIOMUX_DISCOVER_NOT
124 set_audio( bktr_ptr_t bktr, int cmd )
129 #if defined( AUDIOMUX_DISCOVER )
133 #endif /* AUDIOMUX_DISCOVER */
135 /* check for existance of audio MUXes */
136 if ( !bktr->card.audiomuxs[ 4 ] )
141 #ifdef BKTR_REVERSEMUTE
142 bktr->audio_mux_select = 3;
144 bktr->audio_mux_select = 0;
147 if (bktr->reverse_mute )
148 bktr->audio_mux_select = 0;
150 bktr->audio_mux_select = 3;
154 bktr->audio_mux_select = 1;
157 bktr->audio_mux_select = 2;
160 bktr->audio_mute_state = TRUE; /* set mute */
163 bktr->audio_mute_state = FALSE; /* clear mute */
166 printf("%s: audio cmd error %02x\n", bktr_name(bktr),
172 /* Most cards have a simple audio multiplexer to select the
173 * audio source. The I/O_GV card has a more advanced multiplexer
174 * and requires special handling.
176 if ( bktr->bt848_card == CARD_IO_BCTV2 ) {
177 set_bctv2_audio( bktr );
181 /* Proceed with the simpler audio multiplexer code for the majority
186 * Leave the upper bits of the GPIO port alone in case they control
187 * something like the dbx or teletext chips. This doesn't guarantee
188 * success, but follows the rule of least astonishment.
191 if ( bktr->audio_mute_state == TRUE ) {
192 #ifdef BKTR_REVERSEMUTE
198 if (bktr->reverse_mute )
205 idx = bktr->audio_mux_select;
208 temp = INL(bktr, BKTR_GPIO_DATA) & ~bktr->card.gpio_mux_bits;
209 #if defined( AUDIOMUX_DISCOVER )
210 OUTL(bktr, BKTR_GPIO_DATA, temp | (cmd & 0xff));
211 printf("%s: cmd: %d audio mux %x temp %x \n", bktr_name(bktr),
212 cmd, bktr->card.audiomuxs[ idx ], temp );
214 OUTL(bktr, BKTR_GPIO_DATA, temp | bktr->card.audiomuxs[ idx ]);
215 #endif /* AUDIOMUX_DISCOVER */
219 /* Some new Hauppauge cards do not have an audio mux */
220 /* Instead we use the MSP34xx chip to select TV audio, Line-In */
221 /* FM Radio and Mute */
222 /* Examples of this are the Hauppauge 44xxx MSP34xx models */
223 /* It is ok to drive both the mux and the MSP34xx chip. */
224 /* If there is no mux, the MSP does the switching of the audio source */
225 /* If there is a mux, it does the switching of the audio source */
227 if ((bktr->card.msp3400c) && (bktr->audio_mux_present == 0)) {
229 if (bktr->audio_mute_state == TRUE ) {
230 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x0000); /* volume to MUTE */
232 if(bktr->audio_mux_select == 0) { /* TV Tuner */
233 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
234 if (bktr->msp_source_selected != 0) msp_autodetect(bktr); /* setup TV audio mode */
235 bktr->msp_source_selected = 0;
237 if(bktr->audio_mux_select == 1) { /* Line In */
238 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
239 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */
240 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
241 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0000); /* DSP In = SC1_IN_L/R */
242 bktr->msp_source_selected = 1;
245 if(bktr->audio_mux_select == 2) { /* FM Radio */
246 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
247 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */
248 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
249 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0200); /* DSP In = SC2_IN_L/R */
250 bktr->msp_source_selected = 2;
264 temp_mute( bktr_ptr_t bktr, int flag )
266 static int muteState = FALSE;
268 if ( flag == TRUE ) {
269 muteState = bktr->audio_mute_state;
270 set_audio( bktr, AUDIO_MUTE ); /* prevent 'click' */
273 tsleep( BKTR_SLEEP, PZERO, "tuning", hz/8 );
274 if ( muteState == FALSE )
275 set_audio( bktr, AUDIO_UNMUTE );
279 /* address of BTSC/SAP decoder chip */
280 #define TDA9850_WADDR 0xb6
281 #define TDA9850_RADDR 0xb7
284 /* registers in the TDA9850 BTSC/dbx chip */
285 #define CON1ADDR 0x04
286 #define CON2ADDR 0x05
287 #define CON3ADDR 0x06
288 #define CON4ADDR 0x07
289 #define ALI1ADDR 0x08
290 #define ALI2ADDR 0x09
291 #define ALI3ADDR 0x0a
294 * initialise the dbx chip
295 * taken from the Linux bttv driver TDA9850 initialisation code
298 init_BTSC( bktr_ptr_t bktr )
300 i2cWrite(bktr, TDA9850_WADDR, CON1ADDR, 0x08); /* noise threshold st */
301 i2cWrite(bktr, TDA9850_WADDR, CON2ADDR, 0x08); /* noise threshold sap */
302 i2cWrite(bktr, TDA9850_WADDR, CON3ADDR, 0x40); /* stereo mode */
303 i2cWrite(bktr, TDA9850_WADDR, CON4ADDR, 0x07); /* 0 dB input gain? */
304 i2cWrite(bktr, TDA9850_WADDR, ALI1ADDR, 0x10); /* wideband alignment? */
305 i2cWrite(bktr, TDA9850_WADDR, ALI2ADDR, 0x10); /* spectral alignment? */
306 i2cWrite(bktr, TDA9850_WADDR, ALI3ADDR, 0x03);
311 * XXX FIXME: alot of work to be done here, this merely unmutes it.
314 set_BTSC( bktr_ptr_t bktr, int control )
316 return( i2cWrite( bktr, TDA9850_WADDR, CON3ADDR, control ) );
320 * CARD_GV_BCTV2 specific functions.
323 #define BCTV2_AUDIO_MAIN 0x10 /* main audio program */
324 #define BCTV2_AUDIO_SUB 0x20 /* sub audio program */
325 #define BCTV2_AUDIO_BOTH 0x30 /* main(L) + sub(R) program */
327 #define BCTV2_GPIO_REG0 1
328 #define BCTV2_GPIO_REG1 3
330 #define BCTV2_GR0_AUDIO_MODE 3
331 #define BCTV2_GR0_AUDIO_MAIN 0 /* main program */
332 #define BCTV2_GR0_AUDIO_SUB 3 /* sub program */
333 #define BCTV2_GR0_AUDIO_BOTH 1 /* main(L) + sub(R) */
334 #define BCTV2_GR0_AUDIO_MUTE 4 /* audio mute */
335 #define BCTV2_GR0_AUDIO_MONO 8 /* force mono */
338 set_bctv2_audio( bktr_ptr_t bktr )
342 switch (bktr->audio_mux_select) {
343 case 1: /* external */
344 case 2: /* internal */
345 bctv2_gpio_write(bktr, BCTV2_GPIO_REG1, 0);
348 bctv2_gpio_write(bktr, BCTV2_GPIO_REG1, 1);
351 /* switch (bktr->audio_sap_select) { */
352 switch (BCTV2_AUDIO_BOTH) {
353 case BCTV2_AUDIO_SUB:
354 data = BCTV2_GR0_AUDIO_SUB;
356 case BCTV2_AUDIO_BOTH:
357 data = BCTV2_GR0_AUDIO_BOTH;
359 case BCTV2_AUDIO_MAIN:
361 data = BCTV2_GR0_AUDIO_MAIN;
364 if (bktr->audio_mute_state == TRUE)
365 data |= BCTV2_GR0_AUDIO_MUTE;
367 bctv2_gpio_write(bktr, BCTV2_GPIO_REG0, data);
372 /* gpio_data bit assignment */
373 #define BCTV2_GPIO_ADDR_MASK 0x000300
374 #define BCTV2_GPIO_WE 0x000400
375 #define BCTV2_GPIO_OE 0x000800
376 #define BCTV2_GPIO_VAL_MASK 0x00f000
378 #define BCTV2_GPIO_PORT_MASK 3
379 #define BCTV2_GPIO_ADDR_SHIFT 8
380 #define BCTV2_GPIO_VAL_SHIFT 12
382 /* gpio_out_en value for read/write */
383 #define BCTV2_GPIO_OUT_RMASK 0x000f00
384 #define BCTV2_GPIO_OUT_WMASK 0x00ff00
386 #define BCTV2_BITS 100
389 bctv2_gpio_write( bktr_ptr_t bktr, int port, int val )
391 u_long data, outbits;
393 port &= BCTV2_GPIO_PORT_MASK;
397 data = ((val << BCTV2_GPIO_VAL_SHIFT) & BCTV2_GPIO_VAL_MASK) |
398 ((port << BCTV2_GPIO_ADDR_SHIFT) & BCTV2_GPIO_ADDR_MASK) |
399 BCTV2_GPIO_WE | BCTV2_GPIO_OE;
400 outbits = BCTV2_GPIO_OUT_WMASK;
405 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
406 OUTL(bktr, BKTR_GPIO_DATA, data);
407 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits);
409 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV2_GPIO_WE);
411 OUTL(bktr, BKTR_GPIO_DATA, data);
413 OUTL(bktr, BKTR_GPIO_DATA, ~0);
414 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
419 bctv2_gpio_read( bktr_ptr_t bktr, int port )
421 u_long data, outbits, ret;
423 port &= BCTV2_GPIO_PORT_MASK;
427 data = ((port << BCTV2_GPIO_ADDR_SHIFT) & BCTV2_GPIO_ADDR_MASK) |
428 BCTV2_GPIO_WE | BCTV2_GPIO_OE;
429 outbits = BCTV2_GPIO_OUT_RMASK;
434 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
435 OUTL(bktr, BKTR_GPIO_DATA, data);
436 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits);
438 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV2_GPIO_OE);
440 ret = INL(bktr, BKTR_GPIO_DATA);
442 OUTL(bktr, BKTR_GPIO_DATA, data);
444 OUTL(bktr, BKTR_GPIO_DATA, ~0);
445 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
446 return( (ret & BCTV2_GPIO_VAL_MASK) >> BCTV2_GPIO_VAL_SHIFT );
451 * setup the MSP34xx Stereo Audio Chip
452 * This uses the Auto Configuration Option on MSP3410D and MSP3415D chips
453 * and DBX mode selection for MSP3430G chips.
454 * For MSP3400C support, the full programming sequence is required and is
458 /* Read the MSP version string */
459 void msp_read_id( bktr_ptr_t bktr ){
461 rev1 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001e);
462 rev2 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001f);
464 sprintf(bktr->msp_version_string, "34%02d%c-%c%d",
465 (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
470 /* Configure the MSP chip to Auto-detect the audio format.
471 * For the MSP3430G, we use fast autodetect mode
472 * For the MSP3410/3415 there are two schemes for this
473 * a) Fast autodetection - the chip is put into autodetect mode, and the function
474 * returns immediatly. This works in most cases and is the Default Mode.
475 * b) Slow mode. The function sets the MSP3410/3415 chip, then waits for feedback from
476 * the chip and re-programs it if needed.
478 void msp_autodetect( bktr_ptr_t bktr ) {
480 #ifdef BKTR_NEW_MSP34XX_DRIVER
482 /* Just wake up the (maybe) sleeping thread, it'll do everything for us */
483 msp_wake_thread(bktr);
486 int auto_detect, loops;
489 /* MSP3430G - countries with mono and DBX stereo */
490 if (strncmp("3430G", bktr->msp_version_string, 5) == 0){
492 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0030,0x2003);/* Enable Auto format detection */
493 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/
494 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000E,0x2403);/* darned if I know */
495 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0320);/* Source select = (St or A) */
496 /* & Ch. Matrix = St */
497 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
501 /* MSP3415D SPECIAL CASE Use the Tuner's Mono audio ouput for the MSP */
502 /* (for Hauppauge 44xxx card with Tuner Type 0x2a) */
503 else if ( ( (strncmp("3415D", bktr->msp_version_string, 5) == 0)
504 &&(bktr->msp_use_mono_source == 1)
506 || (bktr->slow_msp_audio == 2) ){
507 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
508 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */
509 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
510 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0100); /* DSP In = MONO IN */
514 /* MSP3410/MSP3415 - countries with mono, stereo using 2 FM channels and NICAM */
515 /* FAST sound scheme */
516 else if (bktr->slow_msp_audio == 0) {
517 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
518 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Spkr Source = default(FM/AM) */
519 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
520 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
524 /* MSP3410/MSP3415 - European Countries where the fast MSP3410/3415 programming fails */
525 /* SLOW sound scheme */
526 else if ( bktr->slow_msp_audio == 1) {
527 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
528 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
530 /* wait for 0.5s max for terrestrial sound autodetection */
534 auto_detect = msp_dpl_read(bktr, bktr->msp_addr, 0x10, 0x007e);
536 } while (auto_detect > 0xff && loops < 50);
537 if (bootverbose)printf ("%s: Result of autodetect after %dms: %d\n",
538 bktr_name(bktr), loops*10, auto_detect);
540 /* Now set the audio baseband processing */
541 switch (auto_detect) {
542 case 0: /* no TV sound standard detected */
544 case 2: /* M Dual FM */
546 case 3: /* B/G Dual FM; German stereo */
547 /* Read the stereo detection value from DSP reg 0x0018 */
549 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
550 if (bootverbose)printf ("%s: Stereo reg 0x18 a: %d\n",
551 bktr_name(bktr), stereo);
553 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
554 if (bootverbose)printf ("%s: Stereo reg 0x18 b: %d\n",
555 bktr_name(bktr), stereo);
557 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
558 if (bootverbose)printf ("%s: Stereo reg 0x18 c: %d\n",
559 bktr_name(bktr), stereo);
560 if (stereo > 0x0100 && stereo < 0x8000) { /* Seems to be stereo */
561 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker set stereo*/
563 set spatial effect strength to 50% enlargement
564 set spatial effect mode b, stereo basewidth enlargment only
566 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f28);
567 } else if (stereo > 0x8000) { /* bilingual mode */
568 if (bootverbose) printf ("%s: Bilingual mode detected\n",
570 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Loudspeaker */
571 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x0000);/* all spatial effects off */
572 } else { /* must be mono */
573 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0030);/* Loudspeaker */
575 set spatial effect strength to 50% enlargement
576 set spatial effect mode a, stereo basewidth enlargment
577 and pseudo stereo effect with automatic high-pass filter
579 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f08);
582 /* The reset value for Channel matrix mode is FM/AM and SOUNDA/LEFT */
583 /* We would like STEREO instead val: 0x0020 */
584 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker */
585 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0009,0x0020);/* Headphone */
586 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000a,0x0020);/* SCART1 */
587 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0041,0x0020);/* SCART2 */
588 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000b,0x0020);/* I2S */
589 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000c,0x0020);/* Quasi-Peak Detector Source */
590 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000e,0x0001);
593 case 8: /* B/G FM NICAM */
594 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
596 case 9: /* L_AM NICAM or D/K*/
597 case 10: /* i-FM NICAM */
600 if (bootverbose) printf ("%s: Unknown autodetection result value: %d\n",
601 bktr_name(bktr), auto_detect);
607 /* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */
608 /* turn your speaker volume down low before trying this */
609 /* msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0014, 0x7f40); */
611 #endif /* BKTR_NEW_MSP34XX_DRIVER */
614 /* Read the DPL version string */
615 void dpl_read_id( bktr_ptr_t bktr ){
617 rev1 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001e);
618 rev2 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001f);
620 sprintf(bktr->dpl_version_string, "34%02d%c-%c%d",
621 ((rev2>>8)&0xff)-1, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f);
624 /* Configure the DPL chip to Auto-detect the audio format */
625 void dpl_autodetect( bktr_ptr_t bktr ) {
627 /* The following are empiric values tried from the DPL35xx data sheet */
628 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x000c,0x0320); /* quasi peak detector source dolby
629 lr 0x03xx; quasi peak detector matrix
631 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0040,0x0060); /* Surround decoder mode;
632 ADAPTIVE/3D-PANORAMA, that means two
633 speakers and no center speaker, all
634 channels L/R/C/S mixed to L and R */
635 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0041,0x0620); /* surround source matrix;I2S2/STEREO*/
636 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0042,0x1F00); /* surround delay 31ms max */
637 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0043,0x0000); /* automatic surround input balance */
638 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0044,0x4000); /* surround spatial effect 50%
640 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0045,0x5400); /* surround panorama effect 66%
641 recommended with PANORAMA mode
642 in 0x0040 set to panorama */