static int msp3400c_write(bktr_ptr_t client, int dev, int addr, int val) { /* use our own */ msp_dpl_write(client, client->msp_addr, dev, addr, val); return(0); }
/* Configure the DPL chip to Auto-detect the audio format */ void dpl_autodetect( bktr_ptr_t bktr ) { /* The following are empiric values tried from the DPL35xx data sheet */ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x000c,0x0320); /* quasi peak detector source dolby lr 0x03xx; quasi peak detector matrix stereo 0xXX20 */ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0040,0x0060); /* Surround decoder mode; ADAPTIVE/3D-PANORAMA, that means two speakers and no center speaker, all channels L/R/C/S mixed to L and R */ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0041,0x0620); /* surround source matrix;I2S2/STEREO*/ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0042,0x1F00); /* surround delay 31ms max */ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0043,0x0000); /* automatic surround input balance */ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0044,0x4000); /* surround spatial effect 50% recommended*/ msp_dpl_write(bktr, bktr->dpl_addr, 0x12, 0x0045,0x5400); /* surround panorama effect 66% recommended with PANORAMA mode in 0x0040 set to panorama */ }
/* Configure the MSP chip to Auto-detect the audio format. * For the MSP3430G, we use fast autodetect mode * For the MSP3410/3415 there are two schemes for this * a) Fast autodetection - the chip is put into autodetect mode, and the function * returns immediatly. This works in most cases and is the Default Mode. * b) Slow mode. The function sets the MSP3410/3415 chip, then waits for feedback from * the chip and re-programs it if needed. */ void msp_autodetect( bktr_ptr_t bktr ) { #ifdef BKTR_NEW_MSP34XX_DRIVER /* Just wake up the (maybe) sleeping thread, it'll do everything for us */ msp_wake_thread(bktr); #else int auto_detect, loops; int stereo; /* MSP3430G - countries with mono and DBX stereo */ if (strncmp("3430G", bktr->msp_version_string, 5) == 0){ msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0030,0x2003);/* Enable Auto format detection */ msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000E,0x2403);/* darned if I know */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0320);/* Source select = (St or A) */ /* & Ch. Matrix = St */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */ } /* MSP3415D SPECIAL CASE Use the Tuner's Mono audio ouput for the MSP */ /* (for Hauppauge 44xxx card with Tuner Type 0x2a) */ else if ( ( (strncmp("3415D", bktr->msp_version_string, 5) == 0) &&(bktr->msp_use_mono_source == 1) ) || (bktr->slow_msp_audio == 2) ){ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0100); /* DSP In = MONO IN */ } /* MSP3410/MSP3415 - countries with mono, stereo using 2 FM channels and NICAM */ /* FAST sound scheme */ else if (bktr->slow_msp_audio == 0) { msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Spkr Source = default(FM/AM) */ msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */ msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */ } /* MSP3410/MSP3415 - European Countries where the fast MSP3410/3415 programming fails */ /* SLOW sound scheme */ else if ( bktr->slow_msp_audio == 1) { msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */ msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */ /* wait for 0.5s max for terrestrial sound autodetection */ loops = 10; do { DELAY(100000); auto_detect = msp_dpl_read(bktr, bktr->msp_addr, 0x10, 0x007e); loops++; } while (auto_detect > 0xff && loops < 50); if (bootverbose)printf ("%s: Result of autodetect after %dms: %d\n", bktr_name(bktr), loops*10, auto_detect); /* Now set the audio baseband processing */ switch (auto_detect) { case 0: /* no TV sound standard detected */ break; case 2: /* M Dual FM */ break; case 3: /* B/G Dual FM; German stereo */ /* Read the stereo detection value from DSP reg 0x0018 */ DELAY(20000); stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018); if (bootverbose)printf ("%s: Stereo reg 0x18 a: %d\n", bktr_name(bktr), stereo); DELAY(20000); stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018); if (bootverbose)printf ("%s: Stereo reg 0x18 b: %d\n", bktr_name(bktr), stereo); DELAY(20000); stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018); if (bootverbose)printf ("%s: Stereo reg 0x18 c: %d\n", bktr_name(bktr), stereo); if (stereo > 0x0100 && stereo < 0x8000) { /* Seems to be stereo */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker set stereo*/ /* set spatial effect strength to 50% enlargement set spatial effect mode b, stereo basewidth enlargment only */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f28); } else if (stereo > 0x8000) { /* bilingual mode */ if (bootverbose) printf ("%s: Bilingual mode detected\n", bktr_name(bktr)); msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Loudspeaker */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x0000);/* all spatial effects off */ } else { /* must be mono */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0030);/* Loudspeaker */ /* set spatial effect strength to 50% enlargement set spatial effect mode a, stereo basewidth enlargment and pseudo stereo effect with automatic high-pass filter */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f08); } #if 0 /* The reset value for Channel matrix mode is FM/AM and SOUNDA/LEFT */ /* We would like STEREO instead val: 0x0020 */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0009,0x0020);/* Headphone */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000a,0x0020);/* SCART1 */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0041,0x0020);/* SCART2 */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000b,0x0020);/* I2S */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000c,0x0020);/* Quasi-Peak Detector Source */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000e,0x0001); #endif break; case 8: /* B/G FM NICAM */ msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */ break; case 9: /* L_AM NICAM or D/K*/ case 10: /* i-FM NICAM */ break; default: if (bootverbose) printf ("%s: Unknown autodetection result value: %d\n", bktr_name(bktr), auto_detect); } } /* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */ /* turn your speaker volume down low before trying this */ /* msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0014, 0x7f40); */ #endif /* BKTR_NEW_MSP34XX_DRIVER */ }
int set_audio( bktr_ptr_t bktr, int cmd ) { u_long temp; volatile u_char idx; #if defined( AUDIOMUX_DISCOVER ) if ( cmd >= 200 ) cmd -= 200; else #endif /* AUDIOMUX_DISCOVER */ /* check for existance of audio MUXes */ if ( !bktr->card.audiomuxs[ 4 ] ) return( -1 ); switch (cmd) { case AUDIO_TUNER: #ifdef BKTR_REVERSEMUTE bktr->audio_mux_select = 3; #else bktr->audio_mux_select = 0; #endif if (bktr->reverse_mute ) bktr->audio_mux_select = 0; else bktr->audio_mux_select = 3; break; case AUDIO_EXTERN: bktr->audio_mux_select = 1; break; case AUDIO_INTERN: bktr->audio_mux_select = 2; break; case AUDIO_MUTE: bktr->audio_mute_state = TRUE; /* set mute */ break; case AUDIO_UNMUTE: bktr->audio_mute_state = FALSE; /* clear mute */ break; default: printf("%s: audio cmd error %02x\n", bktr_name(bktr), cmd); return( -1 ); } /* Most cards have a simple audio multiplexer to select the * audio source. The I/O_GV card has a more advanced multiplexer * and requires special handling. */ if ( bktr->bt848_card == CARD_IO_BCTV2 ) { set_bctv2_audio( bktr ); return( 0 ); } /* Proceed with the simpler audio multiplexer code for the majority * of Bt848 cards. */ /* * Leave the upper bits of the GPIO port alone in case they control * something like the dbx or teletext chips. This doesn't guarantee * success, but follows the rule of least astonishment. */ if ( bktr->audio_mute_state == TRUE ) { #ifdef BKTR_REVERSEMUTE idx = 0; #else idx = 3; #endif if (bktr->reverse_mute ) idx = 3; else idx = 0; } else idx = bktr->audio_mux_select; temp = INL(bktr, BKTR_GPIO_DATA) & ~bktr->card.gpio_mux_bits; #if defined( AUDIOMUX_DISCOVER ) OUTL(bktr, BKTR_GPIO_DATA, temp | (cmd & 0xff)); printf("%s: cmd: %d audio mux %x temp %x \n", bktr_name(bktr), cmd, bktr->card.audiomuxs[ idx ], temp ); #else OUTL(bktr, BKTR_GPIO_DATA, temp | bktr->card.audiomuxs[ idx ]); #endif /* AUDIOMUX_DISCOVER */ /* Some new Hauppauge cards do not have an audio mux */ /* Instead we use the MSP34xx chip to select TV audio, Line-In */ /* FM Radio and Mute */ /* Examples of this are the Hauppauge 44xxx MSP34xx models */ /* It is ok to drive both the mux and the MSP34xx chip. */ /* If there is no mux, the MSP does the switching of the audio source */ /* If there is a mux, it does the switching of the audio source */ if ((bktr->card.msp3400c) && (bktr->audio_mux_present == 0)) { if (bktr->audio_mute_state == TRUE ) { msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x0000); /* volume to MUTE */ } else { if(bktr->audio_mux_select == 0) { /* TV Tuner */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */ if (bktr->msp_source_selected != 0) msp_autodetect(bktr); /* setup TV audio mode */ bktr->msp_source_selected = 0; } if(bktr->audio_mux_select == 1) { /* Line In */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0000); /* DSP In = SC1_IN_L/R */ bktr->msp_source_selected = 1; } if(bktr->audio_mux_select == 2) { /* FM Radio */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x1900); /* scart prescale */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */ msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0200); /* DSP In = SC2_IN_L/R */ bktr->msp_source_selected = 2; } } } return( 0 ); }