Loading drivers/media/dvb/frontends/cx24123.c +128 −100 Original line number Diff line number Diff line Loading @@ -33,7 +33,13 @@ #define XTAL 10111000 static int force_band; module_param(force_band, int, 0644); MODULE_PARM_DESC(force_band, "Force a specific band select "\ "(1-9, default:off)."); static int debug; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) Loading @@ -46,8 +52,7 @@ static int debug; } \ } while (0) struct cx24123_state { struct cx24123_state { struct i2c_adapter *i2c; const struct cx24123_config *config; Loading @@ -70,8 +75,7 @@ struct cx24123_state }; /* Various tuner defaults need to be established for a given symbol rate Sps */ static struct { static struct cx24123_AGC_val { u32 symbolrate_low; u32 symbolrate_high; u32 VCAprogdata; Loading Loading @@ -109,8 +113,7 @@ static struct * fixme: The bounds on the bands do not match the doc in real life. * fixme: Some of them have been moved, other might need adjustment. */ static struct { static struct cx24123_bandselect_val { u32 freq_low; u32 freq_high; u32 VCOdivider; Loading Loading @@ -249,7 +252,8 @@ static int cx24123_i2c_writereg(struct cx24123_state *state, /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { err = i2c_transfer(state->i2c, &msg, 1); if (err != 1) { printk("%s: writereg error(err == %i, reg == 0x%02x," " data == 0x%02x)\n", __func__, err, reg, data); return err; Loading Loading @@ -284,7 +288,8 @@ static int cx24123_i2c_readreg(struct cx24123_state *state, u8 i2c_addr, u8 reg) #define cx24123_writereg(state, reg, val) \ cx24123_i2c_writereg(state, state->config->demod_address, reg, val) static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) static int cx24123_set_inversion(struct cx24123_state *state, fe_spectral_inversion_t inversion) { u8 nom_reg = cx24123_readreg(state, 0x0e); u8 auto_reg = cx24123_readreg(state, 0x10); Loading @@ -311,7 +316,8 @@ static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_invers return 0; } static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) static int cx24123_get_inversion(struct cx24123_state *state, fe_spectral_inversion_t *inversion) { u8 val; Loading @@ -337,9 +343,11 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) /* Set the soft decision threshold */ if (fec == FEC_1_2) cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); else cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); switch (fec) { case FEC_1_2: Loading Loading @@ -433,9 +441,9 @@ static u32 cx24123_int_log2(u32 a, u32 b) { u32 exp, nearest = 0; u32 div = a / b; if(a % b >= b / 2) ++div; if(div < (1 << 31)) { if (a % b >= b / 2) ++div; if (div < (1 << 31)) { for (exp = 1; div > exp; nearest++) exp += exp; } Loading Loading @@ -500,7 +508,7 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f); cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff); cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); cx24123_writereg(state, 0x0a, ratio & 0xff); /* also set the demodulator sample gain */ sample_gain = cx24123_int_log2(sample_rate, srate); Loading @@ -514,10 +522,12 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) } /* * Based on the required frequency and symbolrate, the tuner AGC has to be configured * and the correct band selected. Calculate those values * Based on the required frequency and symbolrate, the tuner AGC has * to be configured and the correct band selected. * Calculate those values. */ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24123_pll_calculate(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct cx24123_state *state = fe->demodulator_priv; u32 ndiv = 0, adiv = 0, vco_div = 0; Loading @@ -525,6 +535,8 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa int pump = 2; int band = 0; int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); struct cx24123_bandselect_val *bsv = NULL; struct cx24123_AGC_val *agcv = NULL; /* Defaults for low freq, low rate */ state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; Loading @@ -532,58 +544,65 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa state->bandselectarg = cx24123_bandselect_vals[0].progdata; vco_div = cx24123_bandselect_vals[0].VCOdivider; /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */ for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) { if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; state->FILTune = cx24123_AGC_vals[i].FILTune; /* For the given symbol rate, determine the VCA, VGA and * FILTUNE programming bits */ for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) { agcv = &cx24123_AGC_vals[i]; if ((agcv->symbolrate_low <= p->u.qpsk.symbol_rate) && (agcv->symbolrate_high >= p->u.qpsk.symbol_rate)) { state->VCAarg = agcv->VCAprogdata; state->VGAarg = agcv->VGAprogdata; state->FILTune = agcv->FILTune; } } /* determine the band to use */ if(force_band < 1 || force_band > num_bands) { for (i = 0; i < num_bands; i++) { if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) if (force_band < 1 || force_band > num_bands) { for (i = 0; i < num_bands; i++) { bsv = &cx24123_bandselect_vals[i]; if ((bsv->freq_low <= p->frequency) && (bsv->freq_high >= p->frequency)) band = i; } } else } else band = force_band - 1; state->bandselectarg = cx24123_bandselect_vals[band].progdata; vco_div = cx24123_bandselect_vals[band].VCOdivider; /* determine the charge pump current */ if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) if (p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high) / 2) pump = 0x01; else pump = 0x02; /* Determine the N/A dividers for the requested lband freq (in kHz). */ /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */ ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; /* Note: the reference divider R=10, frequency is in KHz, * XTAL is in Hz */ ndiv = (((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; adiv = (((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; if (adiv == 0 && ndiv > 0) ndiv--; /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; /* control bits 11, refdiv 11, charge pump polarity 1, * charge pump current, ndiv, adiv */ state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; return 0; } /* * Tuner data is 21 bits long, must be left-aligned in data. * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip. * Tuner cx24109 is written through a dedicated 3wire interface * on the demod chip. */ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) static int cx24123_pll_writereg(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u32 data) { struct cx24123_state *state = fe->demodulator_priv; unsigned long timeout; Loading Loading @@ -620,7 +639,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par msleep(10); } /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ /* send the lower 5 bits of this byte, padded with 3 LBB, * wait for the send to be completed */ timeout = jiffies + msecs_to_jiffies(40); cx24123_writereg(state, 0x22, (data) & 0xff); while ((cx24123_readreg(state, 0x20) & 0x80)) { Loading @@ -639,7 +659,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par return 0; } static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24123_pll_tune(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct cx24123_state *state = fe->demodulator_priv; u8 val; Loading Loading @@ -699,11 +720,13 @@ static int cx24123_initfe(struct dvb_frontend* fe) /* Configure the demod to a good set of defaults */ for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); /* Set the LNB polarity */ if (state->config->lnb_polarity) cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); if (state->config->dont_use_pll) cx24123_repeater_mode(state, 1, 0); Loading @@ -711,7 +734,8 @@ static int cx24123_initfe(struct dvb_frontend* fe) return 0; } static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) static int cx24123_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) { struct cx24123_state *state = fe->demodulator_priv; u8 val; Loading Loading @@ -749,7 +773,8 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state) } } static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) static int cx24123_send_diseqc_msg(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) { struct cx24123_state *state = fe->demodulator_priv; int i, val, tone; Loading @@ -771,20 +796,21 @@ static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma cx24123_writereg(state, 0x2C + i, cmd->msg[i]); val = cx24123_readreg(state, 0x29); cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); /* wait for diseqc message to finish sending */ cx24123_wait_for_diseqc(state); /* restart continuous tone if enabled */ if (tone & 0x10) { if (tone & 0x10) cx24123_writereg(state, 0x29, tone & ~0x40); } return 0; } static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) static int cx24123_diseqc_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst) { struct cx24123_state *state = fe->demodulator_priv; int val, tone; Loading Loading @@ -814,9 +840,9 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); /* restart continuous tone if enabled */ if (tone & 0x10) { if (tone & 0x10) cx24123_writereg(state, 0x29, tone & ~0x40); } return 0; } Loading Loading @@ -853,8 +879,9 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) } /* * Configured to return the measurement of errors in blocks, because no UCBLOCKS value * is available, so this value doubles up to satisfy both measurements * Configured to return the measurement of errors in blocks, * because no UCBLOCKS value is available, so this value doubles up * to satisfy both measurements. */ static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) { Loading @@ -876,7 +903,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend *fe, { struct cx24123_state *state = fe->demodulator_priv; *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ /* larger = better */ *signal_strength = cx24123_readreg(state, 0x3b) << 8; dprintk("Signal strength = %d\n", *signal_strength); Loading Loading @@ -932,7 +960,8 @@ static int cx24123_set_frontend(struct dvb_frontend *fe, return 0; } static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24123_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct cx24123_state *state = fe->demodulator_priv; Loading Loading @@ -997,7 +1026,7 @@ static int cx24123_tune(struct dvb_frontend* fe, static int cx24123_get_algo(struct dvb_frontend *fe) { return 1; //FE_ALGO_HW return 1; /* FE_ALGO_HW */ } static void cx24123_release(struct dvb_frontend *fe) Loading Loading @@ -1057,15 +1086,20 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, /* check if the demod is there */ state->demod_rev = cx24123_readreg(state, 0x00); switch (state->demod_rev) { case 0xe1: info("detected CX24123C\n"); break; case 0xd1: info("detected CX24123\n"); break; case 0xe1: info("detected CX24123C\n"); break; case 0xd1: info("detected CX24123\n"); break; default: err("wrong demod revision: %x\n", state->demod_rev); goto error; } /* create dvb_frontend */ memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); state->frontend.demodulator_priv = state; /* create tuner i2c adapter */ Loading @@ -1090,6 +1124,7 @@ error: return NULL; } EXPORT_SYMBOL(cx24123_attach); static struct dvb_frontend_ops cx24123_ops = { Loading Loading @@ -1126,15 +1161,8 @@ static struct dvb_frontend_ops cx24123_ops = { .get_frontend_algo = cx24123_get_algo, }; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); module_param(force_band, int, 0644); MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ "CX24123/CX24109/CX24113 hardware"); MODULE_AUTHOR("Steven Toth"); MODULE_LICENSE("GPL"); EXPORT_SYMBOL(cx24123_attach); drivers/media/dvb/frontends/cx24123.h +5 −5 Original line number Diff line number Diff line Loading @@ -23,8 +23,7 @@ #include <linux/dvb/frontend.h> struct cx24123_config { struct cx24123_config { /* the demodulator's i2c address */ u8 demod_address; Loading @@ -39,7 +38,8 @@ struct cx24123_config void (*agc_callback) (struct dvb_frontend *); }; #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) \ && defined(MODULE)) extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, struct i2c_adapter *i2c); extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); Loading @@ -56,6 +56,6 @@ static struct i2c_adapter * printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } #endif // CONFIG_DVB_CX24123 #endif #endif /* CX24123_H */ Loading
drivers/media/dvb/frontends/cx24123.c +128 −100 Original line number Diff line number Diff line Loading @@ -33,7 +33,13 @@ #define XTAL 10111000 static int force_band; module_param(force_band, int, 0644); MODULE_PARM_DESC(force_band, "Force a specific band select "\ "(1-9, default:off)."); static int debug; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) Loading @@ -46,8 +52,7 @@ static int debug; } \ } while (0) struct cx24123_state { struct cx24123_state { struct i2c_adapter *i2c; const struct cx24123_config *config; Loading @@ -70,8 +75,7 @@ struct cx24123_state }; /* Various tuner defaults need to be established for a given symbol rate Sps */ static struct { static struct cx24123_AGC_val { u32 symbolrate_low; u32 symbolrate_high; u32 VCAprogdata; Loading Loading @@ -109,8 +113,7 @@ static struct * fixme: The bounds on the bands do not match the doc in real life. * fixme: Some of them have been moved, other might need adjustment. */ static struct { static struct cx24123_bandselect_val { u32 freq_low; u32 freq_high; u32 VCOdivider; Loading Loading @@ -249,7 +252,8 @@ static int cx24123_i2c_writereg(struct cx24123_state *state, /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { err = i2c_transfer(state->i2c, &msg, 1); if (err != 1) { printk("%s: writereg error(err == %i, reg == 0x%02x," " data == 0x%02x)\n", __func__, err, reg, data); return err; Loading Loading @@ -284,7 +288,8 @@ static int cx24123_i2c_readreg(struct cx24123_state *state, u8 i2c_addr, u8 reg) #define cx24123_writereg(state, reg, val) \ cx24123_i2c_writereg(state, state->config->demod_address, reg, val) static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) static int cx24123_set_inversion(struct cx24123_state *state, fe_spectral_inversion_t inversion) { u8 nom_reg = cx24123_readreg(state, 0x0e); u8 auto_reg = cx24123_readreg(state, 0x10); Loading @@ -311,7 +316,8 @@ static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_invers return 0; } static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) static int cx24123_get_inversion(struct cx24123_state *state, fe_spectral_inversion_t *inversion) { u8 val; Loading @@ -337,9 +343,11 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) /* Set the soft decision threshold */ if (fec == FEC_1_2) cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); else cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); switch (fec) { case FEC_1_2: Loading Loading @@ -433,9 +441,9 @@ static u32 cx24123_int_log2(u32 a, u32 b) { u32 exp, nearest = 0; u32 div = a / b; if(a % b >= b / 2) ++div; if(div < (1 << 31)) { if (a % b >= b / 2) ++div; if (div < (1 << 31)) { for (exp = 1; div > exp; nearest++) exp += exp; } Loading Loading @@ -500,7 +508,7 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f); cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff); cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); cx24123_writereg(state, 0x0a, ratio & 0xff); /* also set the demodulator sample gain */ sample_gain = cx24123_int_log2(sample_rate, srate); Loading @@ -514,10 +522,12 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) } /* * Based on the required frequency and symbolrate, the tuner AGC has to be configured * and the correct band selected. Calculate those values * Based on the required frequency and symbolrate, the tuner AGC has * to be configured and the correct band selected. * Calculate those values. */ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24123_pll_calculate(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct cx24123_state *state = fe->demodulator_priv; u32 ndiv = 0, adiv = 0, vco_div = 0; Loading @@ -525,6 +535,8 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa int pump = 2; int band = 0; int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); struct cx24123_bandselect_val *bsv = NULL; struct cx24123_AGC_val *agcv = NULL; /* Defaults for low freq, low rate */ state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; Loading @@ -532,58 +544,65 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa state->bandselectarg = cx24123_bandselect_vals[0].progdata; vco_div = cx24123_bandselect_vals[0].VCOdivider; /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */ for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) { if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; state->FILTune = cx24123_AGC_vals[i].FILTune; /* For the given symbol rate, determine the VCA, VGA and * FILTUNE programming bits */ for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) { agcv = &cx24123_AGC_vals[i]; if ((agcv->symbolrate_low <= p->u.qpsk.symbol_rate) && (agcv->symbolrate_high >= p->u.qpsk.symbol_rate)) { state->VCAarg = agcv->VCAprogdata; state->VGAarg = agcv->VGAprogdata; state->FILTune = agcv->FILTune; } } /* determine the band to use */ if(force_band < 1 || force_band > num_bands) { for (i = 0; i < num_bands; i++) { if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) if (force_band < 1 || force_band > num_bands) { for (i = 0; i < num_bands; i++) { bsv = &cx24123_bandselect_vals[i]; if ((bsv->freq_low <= p->frequency) && (bsv->freq_high >= p->frequency)) band = i; } } else } else band = force_band - 1; state->bandselectarg = cx24123_bandselect_vals[band].progdata; vco_div = cx24123_bandselect_vals[band].VCOdivider; /* determine the charge pump current */ if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) if (p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high) / 2) pump = 0x01; else pump = 0x02; /* Determine the N/A dividers for the requested lband freq (in kHz). */ /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */ ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; /* Note: the reference divider R=10, frequency is in KHz, * XTAL is in Hz */ ndiv = (((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; adiv = (((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; if (adiv == 0 && ndiv > 0) ndiv--; /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; /* control bits 11, refdiv 11, charge pump polarity 1, * charge pump current, ndiv, adiv */ state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; return 0; } /* * Tuner data is 21 bits long, must be left-aligned in data. * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip. * Tuner cx24109 is written through a dedicated 3wire interface * on the demod chip. */ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) static int cx24123_pll_writereg(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u32 data) { struct cx24123_state *state = fe->demodulator_priv; unsigned long timeout; Loading Loading @@ -620,7 +639,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par msleep(10); } /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ /* send the lower 5 bits of this byte, padded with 3 LBB, * wait for the send to be completed */ timeout = jiffies + msecs_to_jiffies(40); cx24123_writereg(state, 0x22, (data) & 0xff); while ((cx24123_readreg(state, 0x20) & 0x80)) { Loading @@ -639,7 +659,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par return 0; } static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24123_pll_tune(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct cx24123_state *state = fe->demodulator_priv; u8 val; Loading Loading @@ -699,11 +720,13 @@ static int cx24123_initfe(struct dvb_frontend* fe) /* Configure the demod to a good set of defaults */ for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); /* Set the LNB polarity */ if (state->config->lnb_polarity) cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); if (state->config->dont_use_pll) cx24123_repeater_mode(state, 1, 0); Loading @@ -711,7 +734,8 @@ static int cx24123_initfe(struct dvb_frontend* fe) return 0; } static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) static int cx24123_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) { struct cx24123_state *state = fe->demodulator_priv; u8 val; Loading Loading @@ -749,7 +773,8 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state) } } static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) static int cx24123_send_diseqc_msg(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) { struct cx24123_state *state = fe->demodulator_priv; int i, val, tone; Loading @@ -771,20 +796,21 @@ static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma cx24123_writereg(state, 0x2C + i, cmd->msg[i]); val = cx24123_readreg(state, 0x29); cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); /* wait for diseqc message to finish sending */ cx24123_wait_for_diseqc(state); /* restart continuous tone if enabled */ if (tone & 0x10) { if (tone & 0x10) cx24123_writereg(state, 0x29, tone & ~0x40); } return 0; } static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) static int cx24123_diseqc_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst) { struct cx24123_state *state = fe->demodulator_priv; int val, tone; Loading Loading @@ -814,9 +840,9 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); /* restart continuous tone if enabled */ if (tone & 0x10) { if (tone & 0x10) cx24123_writereg(state, 0x29, tone & ~0x40); } return 0; } Loading Loading @@ -853,8 +879,9 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) } /* * Configured to return the measurement of errors in blocks, because no UCBLOCKS value * is available, so this value doubles up to satisfy both measurements * Configured to return the measurement of errors in blocks, * because no UCBLOCKS value is available, so this value doubles up * to satisfy both measurements. */ static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) { Loading @@ -876,7 +903,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend *fe, { struct cx24123_state *state = fe->demodulator_priv; *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ /* larger = better */ *signal_strength = cx24123_readreg(state, 0x3b) << 8; dprintk("Signal strength = %d\n", *signal_strength); Loading Loading @@ -932,7 +960,8 @@ static int cx24123_set_frontend(struct dvb_frontend *fe, return 0; } static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24123_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct cx24123_state *state = fe->demodulator_priv; Loading Loading @@ -997,7 +1026,7 @@ static int cx24123_tune(struct dvb_frontend* fe, static int cx24123_get_algo(struct dvb_frontend *fe) { return 1; //FE_ALGO_HW return 1; /* FE_ALGO_HW */ } static void cx24123_release(struct dvb_frontend *fe) Loading Loading @@ -1057,15 +1086,20 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, /* check if the demod is there */ state->demod_rev = cx24123_readreg(state, 0x00); switch (state->demod_rev) { case 0xe1: info("detected CX24123C\n"); break; case 0xd1: info("detected CX24123\n"); break; case 0xe1: info("detected CX24123C\n"); break; case 0xd1: info("detected CX24123\n"); break; default: err("wrong demod revision: %x\n", state->demod_rev); goto error; } /* create dvb_frontend */ memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); state->frontend.demodulator_priv = state; /* create tuner i2c adapter */ Loading @@ -1090,6 +1124,7 @@ error: return NULL; } EXPORT_SYMBOL(cx24123_attach); static struct dvb_frontend_ops cx24123_ops = { Loading Loading @@ -1126,15 +1161,8 @@ static struct dvb_frontend_ops cx24123_ops = { .get_frontend_algo = cx24123_get_algo, }; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); module_param(force_band, int, 0644); MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ "CX24123/CX24109/CX24113 hardware"); MODULE_AUTHOR("Steven Toth"); MODULE_LICENSE("GPL"); EXPORT_SYMBOL(cx24123_attach);
drivers/media/dvb/frontends/cx24123.h +5 −5 Original line number Diff line number Diff line Loading @@ -23,8 +23,7 @@ #include <linux/dvb/frontend.h> struct cx24123_config { struct cx24123_config { /* the demodulator's i2c address */ u8 demod_address; Loading @@ -39,7 +38,8 @@ struct cx24123_config void (*agc_callback) (struct dvb_frontend *); }; #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) \ && defined(MODULE)) extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, struct i2c_adapter *i2c); extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); Loading @@ -56,6 +56,6 @@ static struct i2c_adapter * printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } #endif // CONFIG_DVB_CX24123 #endif #endif /* CX24123_H */