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