bktr_audio.c revision 67306
1/* $FreeBSD: head/sys/dev/bktr/bktr_audio.c 67306 2000-10-19 07:33:28Z roger $ */ 2/* 3 * This is part of the Driver for Video Capture Cards (Frame grabbers) 4 * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879 5 * chipset. 6 * Copyright Roger Hardiman and Amancio Hasty. 7 * 8 * bktr_audio : This deals with controlling the audio on TV cards, 9 * controlling the Audio Multiplexer (audio source selector). 10 * controlling any MSP34xx stereo audio decoders. 11 * controlling any DPL35xx dolby surroud sound audio decoders. 12 * initialising TDA98xx audio devices. 13 * 14 */ 15 16/* 17 * 1. Redistributions of source code must retain the 18 * Copyright (c) 1997 Amancio Hasty, 1999 Roger Hardiman 19 * All rights reserved. 20 * 21 * Redistribution and use in source and binary forms, with or without 22 * modification, are permitted provided that the following conditions 23 * are met: 24 * 1. Redistributions of source code must retain the above copyright 25 * notice, this list of conditions and the following disclaimer. 26 * 2. Redistributions in binary form must reproduce the above copyright 27 * notice, this list of conditions and the following disclaimer in the 28 * documentation and/or other materials provided with the distribution. 29 * 3. All advertising materials mentioning features or use of this software 30 * must display the following acknowledgement: 31 * This product includes software developed by Amancio Hasty and 32 * Roger Hardiman 33 * 4. The name of the author may not be used to endorse or promote products 34 * derived from this software without specific prior written permission. 35 * 36 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 37 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 38 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 39 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 40 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 42 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 45 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 46 * POSSIBILITY OF SUCH DAMAGE. 47 */ 48 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/kernel.h> 52#include <sys/vnode.h> 53 54#ifdef __FreeBSD__ 55 56#if (__FreeBSD_version < 500000) 57#include <machine/clock.h> /* for DELAY */ 58#endif 59 60#include <pci/pcivar.h> 61 62#if (__FreeBSD_version >=300000) 63#include <machine/bus_memio.h> /* for bus space */ 64#include <machine/bus.h> 65#include <sys/bus.h> 66#endif 67#endif 68 69#ifdef __NetBSD__ 70#include <sys/proc.h> 71#include <dev/ic/bt8xx.h> /* NetBSD location of .h files */ 72#include <dev/pci/bktr/bktr_reg.h> 73#include <dev/pci/bktr/bktr_core.h> 74#include <dev/pci/bktr/bktr_tuner.h> 75#include <dev/pci/bktr/bktr_card.h> 76#include <dev/pci/bktr/bktr_audio.h> 77#else 78#include <machine/ioctl_meteor.h> /* Traditional location of .h files */ 79#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */ 80#include <dev/bktr/bktr_reg.h> 81#include <dev/bktr/bktr_core.h> 82#include <dev/bktr/bktr_tuner.h> 83#include <dev/bktr/bktr_card.h> 84#include <dev/bktr/bktr_audio.h> 85#endif 86 87/* 88 * Prototypes for the GV_BCTV specific functions. 89 */ 90void set_bctv_audio( bktr_ptr_t bktr ); 91void bctv_gpio_write( bktr_ptr_t bktr, int port, int val ); 92/*int bctv_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */ 93 94 95 96/* 97 * init_audio_devices 98 * Reset any MSP34xx or TDA98xx audio devices. 99 */ 100void init_audio_devices( bktr_ptr_t bktr ) { 101 102 /* enable stereo if appropriate on TDA audio chip */ 103 if ( bktr->card.dbx ) 104 init_BTSC( bktr ); 105 106 /* reset the MSP34xx stereo audio chip */ 107 if ( bktr->card.msp3400c ) 108 msp_dpl_reset( bktr, bktr->msp_addr ); 109 110 /* reset the DPL35xx dolby audio chip */ 111 if ( bktr->card.dpl3518a ) 112 msp_dpl_reset( bktr, bktr->dpl_addr ); 113 114} 115 116 117/* 118 * 119 */ 120#define AUDIOMUX_DISCOVER_NOT 121int 122set_audio( bktr_ptr_t bktr, int cmd ) 123{ 124 u_long temp; 125 volatile u_char idx; 126 127#if defined( AUDIOMUX_DISCOVER ) 128 if ( cmd >= 200 ) 129 cmd -= 200; 130 else 131#endif /* AUDIOMUX_DISCOVER */ 132 133 /* check for existance of audio MUXes */ 134 if ( !bktr->card.audiomuxs[ 4 ] ) 135 return( -1 ); 136 137 switch (cmd) { 138 case AUDIO_TUNER: 139#ifdef BKTR_REVERSEMUTE 140 bktr->audio_mux_select = 3; 141#else 142 bktr->audio_mux_select = 0; 143#endif 144 145 if (bktr->reverse_mute ) 146 bktr->audio_mux_select = 0; 147 else 148 bktr->audio_mux_select = 3; 149 150 break; 151 case AUDIO_EXTERN: 152 bktr->audio_mux_select = 1; 153 break; 154 case AUDIO_INTERN: 155 bktr->audio_mux_select = 2; 156 break; 157 case AUDIO_MUTE: 158 bktr->audio_mute_state = TRUE; /* set mute */ 159 break; 160 case AUDIO_UNMUTE: 161 bktr->audio_mute_state = FALSE; /* clear mute */ 162 break; 163 default: 164 printf("%s: audio cmd error %02x\n", bktr_name(bktr), 165 cmd); 166 return( -1 ); 167 } 168 169 170 /* Most cards have a simple audio multiplexer to select the 171 * audio source. The I/O_GV card has a more advanced multiplexer 172 * and requires special handling. 173 */ 174 if ( bktr->bt848_card == CARD_IO_GV ) { 175 set_bctv_audio( bktr ); 176 return( 0 ); 177 } 178 179 /* Proceed with the simpler audio multiplexer code for the majority 180 * of Bt848 cards. 181 */ 182 183 /* 184 * Leave the upper bits of the GPIO port alone in case they control 185 * something like the dbx or teletext chips. This doesn't guarantee 186 * success, but follows the rule of least astonishment. 187 */ 188 189 if ( bktr->audio_mute_state == TRUE ) { 190#ifdef BKTR_REVERSEMUTE 191 idx = 0; 192#else 193 idx = 3; 194#endif 195 196 if (bktr->reverse_mute ) 197 idx = 3; 198 else 199 idx = 0; 200 201 } 202 else 203 idx = bktr->audio_mux_select; 204 205 temp = INL(bktr, BKTR_GPIO_DATA) & ~bktr->card.gpio_mux_bits; 206#if defined( AUDIOMUX_DISCOVER ) 207 OUTL(bktr, BKTR_GPIO_DATA, temp | (cmd & 0xff)); 208 printf("%s: cmd: %d audio mux %x temp %x \n", bktr_name(bktr), 209 cmd, bktr->card.audiomuxs[ idx ], temp ); 210#else 211 OUTL(bktr, BKTR_GPIO_DATA, temp | bktr->card.audiomuxs[ idx ]); 212#endif /* AUDIOMUX_DISCOVER */ 213 214 return( 0 ); 215} 216 217 218/* 219 * 220 */ 221void 222temp_mute( bktr_ptr_t bktr, int flag ) 223{ 224 static int muteState = FALSE; 225 226 if ( flag == TRUE ) { 227 muteState = bktr->audio_mute_state; 228 set_audio( bktr, AUDIO_MUTE ); /* prevent 'click' */ 229 } 230 else { 231 tsleep( BKTR_SLEEP, PZERO, "tuning", hz/8 ); 232 if ( muteState == FALSE ) 233 set_audio( bktr, AUDIO_UNMUTE ); 234 } 235} 236 237/* address of BTSC/SAP decoder chip */ 238#define TDA9850_WADDR 0xb6 239#define TDA9850_RADDR 0xb7 240 241 242/* registers in the TDA9850 BTSC/dbx chip */ 243#define CON1ADDR 0x04 244#define CON2ADDR 0x05 245#define CON3ADDR 0x06 246#define CON4ADDR 0x07 247#define ALI1ADDR 0x08 248#define ALI2ADDR 0x09 249#define ALI3ADDR 0x0a 250 251/* 252 * initialise the dbx chip 253 * taken from the Linux bttv driver TDA9850 initialisation code 254 */ 255void 256init_BTSC( bktr_ptr_t bktr ) 257{ 258 i2cWrite(bktr, TDA9850_WADDR, CON1ADDR, 0x08); /* noise threshold st */ 259 i2cWrite(bktr, TDA9850_WADDR, CON2ADDR, 0x08); /* noise threshold sap */ 260 i2cWrite(bktr, TDA9850_WADDR, CON3ADDR, 0x40); /* stereo mode */ 261 i2cWrite(bktr, TDA9850_WADDR, CON4ADDR, 0x07); /* 0 dB input gain? */ 262 i2cWrite(bktr, TDA9850_WADDR, ALI1ADDR, 0x10); /* wideband alignment? */ 263 i2cWrite(bktr, TDA9850_WADDR, ALI2ADDR, 0x10); /* spectral alignment? */ 264 i2cWrite(bktr, TDA9850_WADDR, ALI3ADDR, 0x03); 265} 266 267/* 268 * setup the dbx chip 269 * XXX FIXME: alot of work to be done here, this merely unmutes it. 270 */ 271int 272set_BTSC( bktr_ptr_t bktr, int control ) 273{ 274 return( i2cWrite( bktr, TDA9850_WADDR, CON3ADDR, control ) ); 275} 276 277/* 278 * CARD_GV_BCTV specific functions. 279 */ 280 281#define BCTV_AUDIO_MAIN 0x10 /* main audio program */ 282#define BCTV_AUDIO_SUB 0x20 /* sub audio program */ 283#define BCTV_AUDIO_BOTH 0x30 /* main(L) + sub(R) program */ 284 285#define BCTV_GPIO_REG0 1 286#define BCTV_GPIO_REG1 3 287 288#define BCTV_GR0_AUDIO_MODE 3 289#define BCTV_GR0_AUDIO_MAIN 0 /* main program */ 290#define BCTV_GR0_AUDIO_SUB 3 /* sub program */ 291#define BCTV_GR0_AUDIO_BOTH 1 /* main(L) + sub(R) */ 292#define BCTV_GR0_AUDIO_MUTE 4 /* audio mute */ 293#define BCTV_GR0_AUDIO_MONO 8 /* force mono */ 294 295void 296set_bctv_audio( bktr_ptr_t bktr ) 297{ 298 int data; 299 300 switch (bktr->audio_mux_select) { 301 case 1: /* external */ 302 case 2: /* internal */ 303 bctv_gpio_write(bktr, BCTV_GPIO_REG1, 0); 304 break; 305 default: /* tuner */ 306 bctv_gpio_write(bktr, BCTV_GPIO_REG1, 1); 307 break; 308 } 309/* switch (bktr->audio_sap_select) { */ 310 switch (BCTV_AUDIO_BOTH) { 311 case BCTV_AUDIO_SUB: 312 data = BCTV_GR0_AUDIO_SUB; 313 break; 314 case BCTV_AUDIO_BOTH: 315 data = BCTV_GR0_AUDIO_BOTH; 316 break; 317 case BCTV_AUDIO_MAIN: 318 default: 319 data = BCTV_GR0_AUDIO_MAIN; 320 break; 321 } 322 if (bktr->audio_mute_state == TRUE) 323 data |= BCTV_GR0_AUDIO_MUTE; 324 325 bctv_gpio_write(bktr, BCTV_GPIO_REG0, data); 326 327 return; 328} 329 330/* gpio_data bit assignment */ 331#define BCTV_GPIO_ADDR_MASK 0x000300 332#define BCTV_GPIO_WE 0x000400 333#define BCTV_GPIO_OE 0x000800 334#define BCTV_GPIO_VAL_MASK 0x00f000 335 336#define BCTV_GPIO_PORT_MASK 3 337#define BCTV_GPIO_ADDR_SHIFT 8 338#define BCTV_GPIO_VAL_SHIFT 12 339 340/* gpio_out_en value for read/write */ 341#define BCTV_GPIO_OUT_RMASK 0x000f00 342#define BCTV_GPIO_OUT_WMASK 0x00ff00 343 344#define BCTV_BITS 100 345 346void 347bctv_gpio_write( bktr_ptr_t bktr, int port, int val ) 348{ 349 u_long data, outbits; 350 351 port &= BCTV_GPIO_PORT_MASK; 352 switch (port) { 353 case 1: 354 case 3: 355 data = ((val << BCTV_GPIO_VAL_SHIFT) & BCTV_GPIO_VAL_MASK) | 356 ((port << BCTV_GPIO_ADDR_SHIFT) & BCTV_GPIO_ADDR_MASK) | 357 BCTV_GPIO_WE | BCTV_GPIO_OE; 358 outbits = BCTV_GPIO_OUT_WMASK; 359 break; 360 default: 361 return; 362 } 363 OUTL(bktr, BKTR_GPIO_OUT_EN, 0); 364 OUTL(bktr, BKTR_GPIO_DATA, data); 365 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits); 366 DELAY(BCTV_BITS); 367 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV_GPIO_WE); 368 DELAY(BCTV_BITS); 369 OUTL(bktr, BKTR_GPIO_DATA, data); 370 DELAY(BCTV_BITS); 371 OUTL(bktr, BKTR_GPIO_DATA, ~0); 372 OUTL(bktr, BKTR_GPIO_OUT_EN, 0); 373} 374 375/* Not yet used 376int 377bctv_gpio_read( bktr_ptr_t bktr, int port ) 378{ 379 u_long data, outbits, ret; 380 381 port &= BCTV_GPIO_PORT_MASK; 382 switch (port) { 383 case 1: 384 case 3: 385 data = ((port << BCTV_GPIO_ADDR_SHIFT) & BCTV_GPIO_ADDR_MASK) | 386 BCTV_GPIO_WE | BCTV_GPIO_OE; 387 outbits = BCTV_GPIO_OUT_RMASK; 388 break; 389 default: 390 return( -1 ); 391 } 392 OUTL(bktr, BKTR_GPIO_OUT_EN, 0); 393 OUTL(bktr, BKTR_GPIO_DATA, data); 394 OUTL(bktr, BKTR_GPIO_OUT_EN, outbits); 395 DELAY(BCTV_BITS); 396 OUTL(bktr, BKTR_GPIO_DATA, data & ~BCTV_GPIO_OE); 397 DELAY(BCTV_BITS); 398 ret = INL(bktr, BKTR_GPIO_DATA); 399 DELAY(BCTV_BITS); 400 OUTL(bktr, BKTR_GPIO_DATA, data); 401 DELAY(BCTV_BITS); 402 OUTL(bktr, BKTR_GPIO_DATA, ~0); 403 OUTL(bktr, BKTR_GPIO_OUT_EN, 0); 404 return( (ret & BCTV_GPIO_VAL_MASK) >> BCTV_GPIO_VAL_SHIFT ); 405} 406*/ 407 408/* 409 * setup the MSP34xx Stereo Audio Chip 410 * This uses the Auto Configuration Option on MSP3410D and MSP3415D chips 411 * and DBX mode selection for MSP3430G chips. 412 * For MSP3400C support, the full programming sequence is required and is 413 * not yet supported. 414 */ 415 416/* Read the MSP version string */ 417void msp_read_id( bktr_ptr_t bktr ){ 418 int rev1=0, rev2=0; 419 rev1 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001e); 420 rev2 = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x001f); 421 422 sprintf(bktr->msp_version_string, "34%02d%c-%c%d", 423 (rev2>>8)&0xff, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f); 424 425} 426 427 428/* Configure the MSP chip to Auto-detect the audio format. 429 * For the MSP3430G, we use fast autodetect mode 430 * For the MSP3410/3415 there are two schemes for this 431 * a) Fast autodetection - the chip is put into autodetect mode, and the function 432 * returns immediatly. This works in most cases and is the Default Mode. 433 * b) Slow mode. The function sets the MSP3410/3415 chip, then waits for feedback from 434 * the chip and re-programs it if needed. 435 */ 436void msp_autodetect( bktr_ptr_t bktr ) { 437 int auto_detect, loops; 438 int stereo; 439 440 /* MSP3430G - countries with mono and DBX stereo */ 441 if (strncmp("3430G", bktr->msp_version_string, 5) == 0){ 442 443 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0030,0x2003);/* Enable Auto format detection */ 444 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/ 445 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000E,0x2403);/* darned if I know */ 446 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0320);/* Source select = (St or A) */ 447 /* & Ch. Matrix = St */ 448 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */ 449 } 450 451 452 /* MSP3410/MSP3415 - countries with mono, stereo using 2 FM channels and NICAM */ 453 /* FAST sound scheme */ 454 if ( (strncmp("3430G", bktr->msp_version_string, 5) != 0) 455 && (bktr->slow_msp_audio == 0) ){ 456 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */ 457 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */ 458 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */ 459 } 460 461 462 /* MSP3410/MSP3415 - European Countries where the fast MSP3410/3415 programming fails */ 463 /* SLOW sound scheme */ 464 if ( (strncmp("3430G", bktr->msp_version_string, 5) != 0) 465 && (bktr->slow_msp_audio == 1) ){ 466 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */ 467 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */ 468 469 /* wait for 0.5s max for terrestrial sound autodetection */ 470 loops = 10; 471 do { 472 DELAY(100000); 473 auto_detect = msp_dpl_read(bktr, bktr->msp_addr, 0x10, 0x007e); 474 loops++; 475 } while (auto_detect > 0xff && loops < 50); 476 if (bootverbose)printf ("%s: Result of autodetect after %dms: %d\n", 477 bktr_name(bktr), loops*10, auto_detect); 478 479 /* Now set the audio baseband processing */ 480 switch (auto_detect) { 481 case 0: /* no TV sound standard detected */ 482 break; 483 case 2: /* M Dual FM */ 484 break; 485 case 3: /* B/G Dual FM; German stereo */ 486 /* Read the stereo detection value from DSP reg 0x0018 */ 487 DELAY(20000); 488 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018); 489 if (bootverbose)printf ("%s: Stereo reg 0x18 a: %d\n", 490 bktr_name(bktr), stereo); 491 DELAY(20000); 492 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018); 493 if (bootverbose)printf ("%s: Stereo reg 0x18 b: %d\n", 494 bktr_name(bktr), stereo); 495 DELAY(20000); 496 stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018); 497 if (bootverbose)printf ("%s: Stereo reg 0x18 c: %d\n", 498 bktr_name(bktr), stereo); 499 if (stereo > 0x0100 && stereo < 0x8000) { /* Seems to be stereo */ 500 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker set stereo*/ 501 /* 502 set spatial effect strength to 50% enlargement 503 set spatial effect mode b, stereo basewidth enlargment only 504 */ 505 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f28); 506 } else if (stereo > 0x8000) { /* bilingual mode */ 507 if (bootverbose) printf ("%s: Bilingual mode detected\n", 508 bktr_name(bktr)); 509 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Loudspeaker */ 510 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x0000);/* all spatial effects off */ 511 } else { /* must be mono */ 512 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0030);/* Loudspeaker */ 513 /* 514 set spatial effect strength to 50% enlargement 515 set spatial effect mode a, stereo basewidth enlargment 516 and pseudo stereo effect with automatic high-pass filter 517 */ 518 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f08); 519 } 520#if 0 521 /* The reset value for Channel matrix mode is FM/AM and SOUNDA/LEFT */ 522 /* We would like STEREO instead val: 0x0020 */ 523 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker */ 524 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0009,0x0020);/* Headphone */ 525 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000a,0x0020);/* SCART1 */ 526 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0041,0x0020);/* SCART2 */ 527 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000b,0x0020);/* I2S */ 528 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000c,0x0020);/* Quasi-Peak Detector Source */ 529 msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000e,0x0001); 530#endif 531 break; 532 case 8: /* B/G FM NICAM */ 533 msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */ 534 break; 535 case 9: /* L_AM NICAM or D/K*/ 536 case 10: /* i-FM NICAM */ 537 break; 538 default: 539 if (bootverbose) printf ("%s: Unknown autodetection result value: %d\n", 540 bktr_name(bktr), auto_detect); 541 } 542 543 } 544 545 546 /* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */ 547 /* turn your speaker volume down low before trying this */ 548 /* msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0014, 0x7f40); */ 549} 550 551/* Read the DPL version string */ 552void dpl_read_id( bktr_ptr_t bktr ){ 553 int rev1=0, rev2=0; 554 rev1 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001e); 555 rev2 = msp_dpl_read(bktr, bktr->dpl_addr, 0x12, 0x001f); 556 557 sprintf(bktr->dpl_version_string, "34%02d%c-%c%d", 558 ((rev2>>8)&0xff)-1, (rev1&0xff)+'@', ((rev1>>8)&0xff)+'@', rev2&0x1f); 559} 560 561/* Configure the DPL chip to Auto-detect the audio format */ 562void dpl_autodetect( bktr_ptr_t bktr ) { 563 564 /* The following are empiric values tried from the DPL35xx data sheet */ 565 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x000c,0x0320); /* quasi peak detector source dolby 566 lr 0x03xx; quasi peak detector matrix 567 stereo 0xXX20 */ 568 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0040,0x0060); /* Surround decoder mode; 569 ADAPTIVE/3D-PANORAMA, that means two 570 speakers and no center speaker, all 571 channels L/R/C/S mixed to L and R */ 572 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0041,0x0620); /* surround source matrix;I2S2/STEREO*/ 573 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0042,0x1F00); /* surround delay 31ms max */ 574 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0043,0x0000); /* automatic surround input balance */ 575 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0044,0x4000); /* surround spatial effect 50% 576 recommended*/ 577 msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0045,0x5400); /* surround panorama effect 66% 578 recommended with PANORAMA mode 579 in 0x0040 set to panorama */ 580} 581 582