static void msp3400c_setmode(bktr_ptr_t client, int type) { struct msp3400c *msp = client->msp3400c_info; int i; dprintk("msp3400: setmode: %d\n",type); msp->mode = type; msp->stereo = VIDEO_SOUND_MONO; msp3400c_write(client,I2C_MSP3400C_DEM, 0x00bb, /* ad_cv */ msp_init_data[type].ad_cv); for (i = 5; i >= 0; i--) /* fir 1 */ msp3400c_write(client,I2C_MSP3400C_DEM, 0x0001, msp_init_data[type].fir1[i]); msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0004); /* fir 2 */ msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0040); msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, 0x0000); for (i = 5; i >= 0; i--) msp3400c_write(client,I2C_MSP3400C_DEM, 0x0005, msp_init_data[type].fir2[i]); msp3400c_write(client,I2C_MSP3400C_DEM, 0x0083, /* MODE_REG */ msp_init_data[type].mode_reg); msp3400c_setcarrier(client, msp_init_data[type].cdo1, msp_init_data[type].cdo2); msp3400c_write(client,I2C_MSP3400C_DEM, 0x0056, 0); /*LOAD_REG_1/2*/ if (client->dolby) { msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008, 0x0520); /* I2S1 */ msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009, 0x0620); /* I2S2 */ msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b, msp_init_data[type].dfp_src); } else { msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008, msp_init_data[type].dfp_src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009, msp_init_data[type].dfp_src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b, msp_init_data[type].dfp_src); } msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a, msp_init_data[type].dfp_src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, msp_init_data[type].dfp_matrix); if (msp->nicam) { /* nicam prescale */ msp3400c_write(client,I2C_MSP3400C_DFP, 0x0010, 0x5a00); /* was: 0x3000 */ } }
void msp3400c_setmode(struct i2c_client *client, int type) { struct msp_state *state = i2c_get_clientdata(client); int i; v4l_dbg(1, msp_debug, client, "setmode: %d\n", type); state->mode = type; state->audmode = V4L2_TUNER_MODE_MONO; state->rxsubchans = V4L2_TUNER_SUB_MONO; msp_write_dem(client, 0x00bb, msp3400c_init_data[type].ad_cv); for (i = 5; i >= 0; i--) /* fir 1 */ msp_write_dem(client, 0x0001, msp3400c_init_data[type].fir1[i]); msp_write_dem(client, 0x0005, 0x0004); /* fir 2 */ msp_write_dem(client, 0x0005, 0x0040); msp_write_dem(client, 0x0005, 0x0000); for (i = 5; i >= 0; i--) msp_write_dem(client, 0x0005, msp3400c_init_data[type].fir2[i]); msp_write_dem(client, 0x0083, msp3400c_init_data[type].mode_reg); msp3400c_setcarrier(client, msp3400c_init_data[type].cdo1, msp3400c_init_data[type].cdo2); msp_write_dem(client, 0x0056, 0); /*LOAD_REG_1/2*/ if (msp_dolby) { msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */ msp_write_dsp(client, 0x0009, 0x0620); /* I2S2 */ msp_write_dsp(client, 0x000b, msp3400c_init_data[type].dsp_src); } else { msp_write_dsp(client, 0x0008, msp3400c_init_data[type].dsp_src); msp_write_dsp(client, 0x0009, msp3400c_init_data[type].dsp_src); msp_write_dsp(client, 0x000b, msp3400c_init_data[type].dsp_src); } msp_write_dsp(client, 0x000a, msp3400c_init_data[type].dsp_src); msp_write_dsp(client, 0x000e, msp3400c_init_data[type].dsp_matrix); if (state->has_nicam) { /* nicam prescale */ msp_write_dsp(client, 0x0010, 0x5a00); /* was: 0x3000 */ } }
/* turn on/off nicam + stereo */ static void msp3400c_setstereo(bktr_ptr_t client, int mode) { static char *strmode[] = { "0", "mono", "stereo", "3", "lang1", "5", "6", "7", "lang2" }; struct msp3400c *msp = client->msp3400c_info; int nicam=0; /* channel source: FM/AM or nicam */ int src=0; /* switch demodulator */ switch (msp->mode) { case MSP_MODE_FM_TERRA: dprintk("msp3400: FM setstereo: %s\n",strmode[mode]); msp3400c_setcarrier(client,msp->second,msp->main); switch (mode) { case VIDEO_SOUND_STEREO: msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3001); break; case VIDEO_SOUND_MONO: case VIDEO_SOUND_LANG1: case VIDEO_SOUND_LANG2: msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3000); break; } break; case MSP_MODE_FM_SAT: dprintk("msp3400: SAT setstereo: %s\n",strmode[mode]); switch (mode) { case VIDEO_SOUND_MONO: msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); break; case VIDEO_SOUND_STEREO: msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02)); break; case VIDEO_SOUND_LANG1: msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); break; case VIDEO_SOUND_LANG2: msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); break; } break; case MSP_MODE_FM_NICAM1: case MSP_MODE_FM_NICAM2: case MSP_MODE_AM_NICAM: dprintk("msp3400: NICAM setstereo: %s\n",strmode[mode]); msp3400c_setcarrier(client,msp->second,msp->main); if (msp->nicam_on) nicam=0x0100; break; case MSP_MODE_BTSC: dprintk("msp3400: BTSC setstereo: %s\n",strmode[mode]); nicam=0x0300; break; case MSP_MODE_EXTERN: dprintk("msp3400: extern setstereo: %s\n",strmode[mode]); nicam = 0x0200; break; case MSP_MODE_FM_RADIO: dprintk("msp3400: FM-Radio setstereo: %s\n",strmode[mode]); break; default: dprintk("msp3400: mono setstereo\n"); return; } /* switch audio */ switch (mode) { case VIDEO_SOUND_STEREO: src = 0x0020 | nicam; #if 0 /* spatial effect */ msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000); #endif break; case VIDEO_SOUND_MONO: if (msp->mode == MSP_MODE_AM_NICAM) { dprintk("msp3400: switching to AM mono\n"); /* AM mono decoding is handled by tuner, not MSP chip */ /* SCART switching control register */ msp3400c_set_scart(client,SCART_MONO,0); src = 0x0200; break; } case VIDEO_SOUND_LANG1: src = 0x0000 | nicam; break; case VIDEO_SOUND_LANG2: src = 0x0010 | nicam; break; } dprintk("msp3400: setstereo final source/matrix = 0x%x\n", src); if (client->dolby) { msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,0x0520); msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,0x0620); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src); } else { msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src); } }
//----------------------------- msp3400c_setstereo ----------------------------- static void msp3400c_setstereo(struct i2c_client *client, int mode) { /* static char *strmode[16] = { #if __GNUC__ >= 3 [ 0 ... 15 ] = "invalid", #endif [ VIDEO_SOUND_MONO ] = "mono", [ VIDEO_SOUND_STEREO ] = "stereo", [ VIDEO_SOUND_LANG1 ] = "lang1", [ VIDEO_SOUND_LANG2 ] = "lang2", }; */ struct msp3400c *msp = (struct msp3400c*) i2c_get_clientdata(client); int nicam=0; /* channel source: FM/AM or nicam */ int src=0; /* switch demodulator */ switch (msp->mode) { case MSP_MODE_FM_TERRA: CPK(dprintk(KERN_DEBUG "msp3400: FM setstereo: %s\n",strmode[mode])); msp3400c_setcarrier(client,msp->second,msp->main); switch (mode) { case VIDEO_SOUND_STEREO: msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3001); break; case VIDEO_SOUND_MONO: case VIDEO_SOUND_LANG1: case VIDEO_SOUND_LANG2: msp3400c_write(client,I2C_MSP3400C_DFP, 0x000e, 0x3000); break; } break; case MSP_MODE_FM_SAT: CPK(dprintk(KERN_DEBUG "msp3400: SAT setstereo: %s\n",strmode[mode])); switch (mode) { case VIDEO_SOUND_MONO: msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); break; case VIDEO_SOUND_STEREO: msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02)); break; case VIDEO_SOUND_LANG1: msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); break; case VIDEO_SOUND_LANG2: msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); break; } break; case MSP_MODE_FM_NICAM1: case MSP_MODE_FM_NICAM2: case MSP_MODE_AM_NICAM: CPK(dprintk(KERN_DEBUG "msp3400: NICAM setstereo: %s\n",strmode[mode])); msp3400c_setcarrier(client,msp->second,msp->main); if (msp->nicam_on) nicam=0x0100; break; case MSP_MODE_BTSC: CPK(dprintk(KERN_DEBUG "msp3400: BTSC setstereo: %s\n",strmode[mode])); nicam=0x0300; break; case MSP_MODE_EXTERN: CPK(dprintk(KERN_DEBUG "msp3400: extern setstereo: %s\n",strmode[mode])); nicam = 0x0200; break; case MSP_MODE_FM_RADIO: CPK(dprintk(KERN_DEBUG "msp3400: FM-Radio setstereo: %s\n",strmode[mode])); break; default: CPK(dprintk(KERN_DEBUG "msp3400: mono setstereo\n")); return; } /* switch audio */ switch (mode) { case VIDEO_SOUND_STEREO: src = 0x0020 | nicam; #if 0 /* spatial effect */ msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000); #endif break; case VIDEO_SOUND_MONO: if (msp->mode == MSP_MODE_AM_NICAM) { CPK(dprintk("msp3400: switching to AM mono\n")); /* AM mono decoding is handled by tuner, not MSP chip */ /* SCART switching control register */ msp3400c_set_scart(client,SCART_MONO,0); src = 0x0200; break; } case VIDEO_SOUND_LANG1: src = 0x0000 | nicam; break; case VIDEO_SOUND_LANG2: src = 0x0010 | nicam; break; } CPK(dprintk(KERN_DEBUG "msp3400: setstereo final source/matrix = 0x%x\n", src)); if (dolby) { msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,0x0520); msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,0x0620); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src); } else { msp3400c_write(client,I2C_MSP3400C_DFP, 0x0008,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x0009,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000a,src); msp3400c_write(client,I2C_MSP3400C_DFP, 0x000b,src); } }
/* turn on/off nicam + stereo */ void msp3400c_setstereo(struct i2c_client *client, int mode) { static char *strmode[] = { "mono", "stereo", "lang2", "lang1" }; struct msp_state *state = i2c_get_clientdata(client); int nicam = 0; /* channel source: FM/AM or nicam */ int src = 0; if (state->opmode == OPMODE_AUTOSELECT) { /* this method would break everything, let's make sure * it's never called */ v4l_dbg(1, msp_debug, client, "setstereo called with mode=%d instead of set_source (ignored)\n", mode); return; } /* switch demodulator */ switch (state->mode) { case MSP_MODE_FM_TERRA: v4l_dbg(1, msp_debug, client, "FM setstereo: %s\n", strmode[mode]); msp3400c_setcarrier(client, state->second, state->main); switch (mode) { case V4L2_TUNER_MODE_STEREO: msp_write_dsp(client, 0x000e, 0x3001); break; case V4L2_TUNER_MODE_MONO: case V4L2_TUNER_MODE_LANG1: case V4L2_TUNER_MODE_LANG2: msp_write_dsp(client, 0x000e, 0x3000); break; } break; case MSP_MODE_FM_SAT: v4l_dbg(1, msp_debug, client, "SAT setstereo: %s\n", strmode[mode]); switch (mode) { case V4L2_TUNER_MODE_MONO: msp3400c_setcarrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5)); break; case V4L2_TUNER_MODE_STEREO: msp3400c_setcarrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02)); break; case V4L2_TUNER_MODE_LANG1: msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); break; case V4L2_TUNER_MODE_LANG2: msp3400c_setcarrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02)); break; } break; case MSP_MODE_FM_NICAM1: case MSP_MODE_FM_NICAM2: case MSP_MODE_AM_NICAM: v4l_dbg(1, msp_debug, client, "NICAM setstereo: %s\n",strmode[mode]); msp3400c_setcarrier(client,state->second,state->main); if (state->nicam_on) nicam=0x0100; break; case MSP_MODE_BTSC: v4l_dbg(1, msp_debug, client, "BTSC setstereo: %s\n",strmode[mode]); nicam=0x0300; break; case MSP_MODE_EXTERN: v4l_dbg(1, msp_debug, client, "extern setstereo: %s\n",strmode[mode]); nicam = 0x0200; break; case MSP_MODE_FM_RADIO: v4l_dbg(1, msp_debug, client, "FM-Radio setstereo: %s\n",strmode[mode]); break; default: v4l_dbg(1, msp_debug, client, "mono setstereo\n"); return; } /* switch audio */ switch (mode) { case V4L2_TUNER_MODE_STEREO: src = 0x0020 | nicam; break; case V4L2_TUNER_MODE_MONO: if (state->mode == MSP_MODE_AM_NICAM) { v4l_dbg(1, msp_debug, client, "switching to AM mono\n"); /* AM mono decoding is handled by tuner, not MSP chip */ /* SCART switching control register */ msp_set_scart(client, SCART_MONO, 0); src = 0x0200; break; } case V4L2_TUNER_MODE_LANG1: src = 0x0000 | nicam; break; case V4L2_TUNER_MODE_LANG2: src = 0x0010 | nicam; break; } v4l_dbg(1, msp_debug, client, "setstereo final source/matrix = 0x%x\n", src); if (msp_dolby) { msp_write_dsp(client, 0x0008, 0x0520); msp_write_dsp(client, 0x0009, 0x0620); msp_write_dsp(client, 0x000a, src); msp_write_dsp(client, 0x000b, src); } else { msp_write_dsp(client, 0x0008, src); msp_write_dsp(client, 0x0009, src); msp_write_dsp(client, 0x000a, src); msp_write_dsp(client, 0x000b, src); msp_write_dsp(client, 0x000c, src); if (state->has_scart23_in_scart2_out) msp_write_dsp(client, 0x0041, src); } }