V4L/DVB (9260): cx24123: Checkpatch compliance
cx24123: Checkpatch compliance Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
b431c61642
commit
93504abfeb
@@ -33,7 +33,13 @@
|
|||||||
#define XTAL 10111000
|
#define XTAL 10111000
|
||||||
|
|
||||||
static int force_band;
|
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;
|
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 info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0)
|
||||||
#define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0)
|
#define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0)
|
||||||
@@ -46,10 +52,9 @@ static int debug;
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
struct cx24123_state
|
struct cx24123_state {
|
||||||
{
|
struct i2c_adapter *i2c;
|
||||||
struct i2c_adapter* i2c;
|
const struct cx24123_config *config;
|
||||||
const struct cx24123_config* config;
|
|
||||||
|
|
||||||
struct dvb_frontend frontend;
|
struct dvb_frontend frontend;
|
||||||
|
|
||||||
@@ -70,8 +75,7 @@ struct cx24123_state
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Various tuner defaults need to be established for a given symbol rate Sps */
|
/* 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_low;
|
||||||
u32 symbolrate_high;
|
u32 symbolrate_high;
|
||||||
u32 VCAprogdata;
|
u32 VCAprogdata;
|
||||||
@@ -109,8 +113,7 @@ static struct
|
|||||||
* fixme: The bounds on the bands do not match the doc in real life.
|
* 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.
|
* fixme: Some of them have been moved, other might need adjustment.
|
||||||
*/
|
*/
|
||||||
static struct
|
static struct cx24123_bandselect_val {
|
||||||
{
|
|
||||||
u32 freq_low;
|
u32 freq_low;
|
||||||
u32 freq_high;
|
u32 freq_high;
|
||||||
u32 VCOdivider;
|
u32 VCOdivider;
|
||||||
@@ -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); */
|
/* 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,"
|
printk("%s: writereg error(err == %i, reg == 0x%02x,"
|
||||||
" data == 0x%02x)\n", __func__, err, reg, data);
|
" data == 0x%02x)\n", __func__, err, reg, data);
|
||||||
return err;
|
return err;
|
||||||
@@ -284,7 +288,8 @@ static int cx24123_i2c_readreg(struct cx24123_state *state, u8 i2c_addr, u8 reg)
|
|||||||
#define cx24123_writereg(state, reg, val) \
|
#define cx24123_writereg(state, reg, val) \
|
||||||
cx24123_i2c_writereg(state, state->config->demod_address, 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 nom_reg = cx24123_readreg(state, 0x0e);
|
||||||
u8 auto_reg = cx24123_readreg(state, 0x10);
|
u8 auto_reg = cx24123_readreg(state, 0x10);
|
||||||
@@ -311,7 +316,8 @@ static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_invers
|
|||||||
return 0;
|
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;
|
u8 val;
|
||||||
|
|
||||||
@@ -328,18 +334,20 @@ static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_invers
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
|
static int cx24123_set_fec(struct cx24123_state *state, fe_code_rate_t fec)
|
||||||
{
|
{
|
||||||
u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07;
|
u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07;
|
||||||
|
|
||||||
if ( (fec < FEC_NONE) || (fec > FEC_AUTO) )
|
if ((fec < FEC_NONE) || (fec > FEC_AUTO))
|
||||||
fec = FEC_AUTO;
|
fec = FEC_AUTO;
|
||||||
|
|
||||||
/* Set the soft decision threshold */
|
/* Set the soft decision threshold */
|
||||||
if(fec == FEC_1_2)
|
if (fec == FEC_1_2)
|
||||||
cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01);
|
cx24123_writereg(state, 0x43,
|
||||||
|
cx24123_readreg(state, 0x43) | 0x01);
|
||||||
else
|
else
|
||||||
cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01);
|
cx24123_writereg(state, 0x43,
|
||||||
|
cx24123_readreg(state, 0x43) & ~0x01);
|
||||||
|
|
||||||
switch (fec) {
|
switch (fec) {
|
||||||
case FEC_1_2:
|
case FEC_1_2:
|
||||||
@@ -388,11 +396,11 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec)
|
static int cx24123_get_fec(struct cx24123_state *state, fe_code_rate_t *fec)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = cx24123_readreg (state, 0x1b);
|
ret = cx24123_readreg(state, 0x1b);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = ret & 0x07;
|
ret = ret & 0x07;
|
||||||
@@ -433,16 +441,16 @@ static u32 cx24123_int_log2(u32 a, u32 b)
|
|||||||
{
|
{
|
||||||
u32 exp, nearest = 0;
|
u32 exp, nearest = 0;
|
||||||
u32 div = a / b;
|
u32 div = a / b;
|
||||||
if(a % b >= b / 2) ++div;
|
if (a % b >= b / 2)
|
||||||
if(div < (1 << 31))
|
++div;
|
||||||
{
|
if (div < (1 << 31)) {
|
||||||
for(exp = 1; div > exp; nearest++)
|
for (exp = 1; div > exp; nearest++)
|
||||||
exp += exp;
|
exp += exp;
|
||||||
}
|
}
|
||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)
|
static int cx24123_set_symbolrate(struct cx24123_state *state, u32 srate)
|
||||||
{
|
{
|
||||||
u32 tmp, sample_rate, ratio, sample_gain;
|
u32 tmp, sample_rate, ratio, sample_gain;
|
||||||
u8 pll_mult;
|
u8 pll_mult;
|
||||||
@@ -498,9 +506,9 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)
|
|||||||
|
|
||||||
cx24123_writereg(state, 0x01, pll_mult * 6);
|
cx24123_writereg(state, 0x01, pll_mult * 6);
|
||||||
|
|
||||||
cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f );
|
cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f);
|
||||||
cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff );
|
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 */
|
/* also set the demodulator sample gain */
|
||||||
sample_gain = cx24123_int_log2(sample_rate, srate);
|
sample_gain = cx24123_int_log2(sample_rate, srate);
|
||||||
@@ -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
|
* Based on the required frequency and symbolrate, the tuner AGC has
|
||||||
* and the correct band selected. Calculate those values
|
* 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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
u32 ndiv = 0, adiv = 0, vco_div = 0;
|
u32 ndiv = 0, adiv = 0, vco_div = 0;
|
||||||
@@ -525,6 +535,8 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
|
|||||||
int pump = 2;
|
int pump = 2;
|
||||||
int band = 0;
|
int band = 0;
|
||||||
int num_bands = ARRAY_SIZE(cx24123_bandselect_vals);
|
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 */
|
/* Defaults for low freq, low rate */
|
||||||
state->VCAarg = cx24123_AGC_vals[0].VCAprogdata;
|
state->VCAarg = cx24123_AGC_vals[0].VCAprogdata;
|
||||||
@@ -532,58 +544,65 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
|
|||||||
state->bandselectarg = cx24123_bandselect_vals[0].progdata;
|
state->bandselectarg = cx24123_bandselect_vals[0].progdata;
|
||||||
vco_div = cx24123_bandselect_vals[0].VCOdivider;
|
vco_div = cx24123_bandselect_vals[0].VCOdivider;
|
||||||
|
|
||||||
/* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */
|
/* For the given symbol rate, determine the VCA, VGA and
|
||||||
for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++)
|
* 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) &&
|
agcv = &cx24123_AGC_vals[i];
|
||||||
(cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) {
|
if ((agcv->symbolrate_low <= p->u.qpsk.symbol_rate) &&
|
||||||
state->VCAarg = cx24123_AGC_vals[i].VCAprogdata;
|
(agcv->symbolrate_high >= p->u.qpsk.symbol_rate)) {
|
||||||
state->VGAarg = cx24123_AGC_vals[i].VGAprogdata;
|
state->VCAarg = agcv->VCAprogdata;
|
||||||
state->FILTune = cx24123_AGC_vals[i].FILTune;
|
state->VGAarg = agcv->VGAprogdata;
|
||||||
|
state->FILTune = agcv->FILTune;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine the band to use */
|
/* determine the band to use */
|
||||||
if(force_band < 1 || force_band > num_bands)
|
if (force_band < 1 || force_band > num_bands) {
|
||||||
{
|
for (i = 0; i < num_bands; i++) {
|
||||||
for (i = 0; i < num_bands; i++)
|
bsv = &cx24123_bandselect_vals[i];
|
||||||
{
|
if ((bsv->freq_low <= p->frequency) &&
|
||||||
if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) &&
|
(bsv->freq_high >= p->frequency))
|
||||||
(cx24123_bandselect_vals[i].freq_high >= p->frequency) )
|
|
||||||
band = i;
|
band = i;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
band = force_band - 1;
|
band = force_band - 1;
|
||||||
|
|
||||||
state->bandselectarg = cx24123_bandselect_vals[band].progdata;
|
state->bandselectarg = cx24123_bandselect_vals[band].progdata;
|
||||||
vco_div = cx24123_bandselect_vals[band].VCOdivider;
|
vco_div = cx24123_bandselect_vals[band].VCOdivider;
|
||||||
|
|
||||||
/* determine the charge pump current */
|
/* 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;
|
pump = 0x01;
|
||||||
else
|
else
|
||||||
pump = 0x02;
|
pump = 0x02;
|
||||||
|
|
||||||
/* Determine the N/A dividers for the requested lband freq (in kHz). */
|
/* 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 */
|
/* Note: the reference divider R=10, frequency is in KHz,
|
||||||
ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff;
|
* XTAL is in Hz */
|
||||||
adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f;
|
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)
|
if (adiv == 0 && ndiv > 0)
|
||||||
ndiv--;
|
ndiv--;
|
||||||
|
|
||||||
/* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */
|
/* control bits 11, refdiv 11, charge pump polarity 1,
|
||||||
state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv;
|
* charge pump current, ndiv, adiv */
|
||||||
|
state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) |
|
||||||
|
(pump << 14) | (ndiv << 5) | adiv;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tuner data is 21 bits long, must be left-aligned in data.
|
* 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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
@@ -610,7 +629,7 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
|
|||||||
|
|
||||||
/* send another 8 bytes, wait for the send to be completed */
|
/* send another 8 bytes, wait for the send to be completed */
|
||||||
timeout = jiffies + msecs_to_jiffies(40);
|
timeout = jiffies + msecs_to_jiffies(40);
|
||||||
cx24123_writereg(state, 0x22, (data>>8) & 0xff );
|
cx24123_writereg(state, 0x22, (data >> 8) & 0xff);
|
||||||
while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
|
while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
|
||||||
if (time_after(jiffies, timeout)) {
|
if (time_after(jiffies, timeout)) {
|
||||||
err("%s: demodulator is not responding, "\
|
err("%s: demodulator is not responding, "\
|
||||||
@@ -620,9 +639,10 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
|
|||||||
msleep(10);
|
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);
|
timeout = jiffies + msecs_to_jiffies(40);
|
||||||
cx24123_writereg(state, 0x22, (data) & 0xff );
|
cx24123_writereg(state, 0x22, (data) & 0xff);
|
||||||
while ((cx24123_readreg(state, 0x20) & 0x80)) {
|
while ((cx24123_readreg(state, 0x20) & 0x80)) {
|
||||||
if (time_after(jiffies, timeout)) {
|
if (time_after(jiffies, timeout)) {
|
||||||
err("%s: demodulator is not responding," \
|
err("%s: demodulator is not responding," \
|
||||||
@@ -639,7 +659,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
|
|||||||
return 0;
|
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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
u8 val;
|
u8 val;
|
||||||
@@ -690,7 +711,7 @@ static int cx24123_repeater_mode(struct cx24123_state *state, u8 mode, u8 start)
|
|||||||
return cx24123_writereg(state, 0x23, r);
|
return cx24123_writereg(state, 0x23, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_initfe(struct dvb_frontend* fe)
|
static int cx24123_initfe(struct dvb_frontend *fe)
|
||||||
{
|
{
|
||||||
struct cx24123_state *state = fe->demodulator_priv;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
int i;
|
int i;
|
||||||
@@ -699,19 +720,22 @@ static int cx24123_initfe(struct dvb_frontend* fe)
|
|||||||
|
|
||||||
/* Configure the demod to a good set of defaults */
|
/* Configure the demod to a good set of defaults */
|
||||||
for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++)
|
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 */
|
/* Set the LNB polarity */
|
||||||
if(state->config->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)
|
if (state->config->dont_use_pll)
|
||||||
cx24123_repeater_mode(state, 1, 0);
|
cx24123_repeater_mode(state, 1, 0);
|
||||||
|
|
||||||
return 0;
|
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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
u8 val;
|
u8 val;
|
||||||
@@ -740,7 +764,7 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state)
|
|||||||
{
|
{
|
||||||
unsigned long timeout = jiffies + msecs_to_jiffies(200);
|
unsigned long timeout = jiffies + msecs_to_jiffies(200);
|
||||||
while (!(cx24123_readreg(state, 0x29) & 0x40)) {
|
while (!(cx24123_readreg(state, 0x29) & 0x40)) {
|
||||||
if(time_after(jiffies, timeout)) {
|
if (time_after(jiffies, timeout)) {
|
||||||
err("%s: diseqc queue not ready, " \
|
err("%s: diseqc queue not ready, " \
|
||||||
"command may be lost.\n", __func__);
|
"command may be lost.\n", __func__);
|
||||||
break;
|
break;
|
||||||
@@ -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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
int i, val, tone;
|
int i, val, tone;
|
||||||
@@ -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]);
|
cx24123_writereg(state, 0x2C + i, cmd->msg[i]);
|
||||||
|
|
||||||
val = cx24123_readreg(state, 0x29);
|
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 */
|
/* wait for diseqc message to finish sending */
|
||||||
cx24123_wait_for_diseqc(state);
|
cx24123_wait_for_diseqc(state);
|
||||||
|
|
||||||
/* restart continuous tone if enabled */
|
/* restart continuous tone if enabled */
|
||||||
if (tone & 0x10) {
|
if (tone & 0x10)
|
||||||
cx24123_writereg(state, 0x29, tone & ~0x40);
|
cx24123_writereg(state, 0x29, tone & ~0x40);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
int val, tone;
|
int val, tone;
|
||||||
@@ -814,13 +840,13 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
|
|||||||
cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb);
|
cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb);
|
||||||
|
|
||||||
/* restart continuous tone if enabled */
|
/* restart continuous tone if enabled */
|
||||||
if (tone & 0x10) {
|
if (tone & 0x10)
|
||||||
cx24123_writereg(state, 0x29, tone & ~0x40);
|
cx24123_writereg(state, 0x29, tone & ~0x40);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
|
static int cx24123_read_status(struct dvb_frontend *fe, fe_status_t *status)
|
||||||
{
|
{
|
||||||
struct cx24123_state *state = fe->demodulator_priv;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
int sync = cx24123_readreg(state, 0x14);
|
int sync = cx24123_readreg(state, 0x14);
|
||||||
@@ -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
|
* Configured to return the measurement of errors in blocks,
|
||||||
* is available, so this value doubles up to satisfy both measurements
|
* 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)
|
static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber)
|
||||||
{
|
{
|
||||||
@@ -876,7 +903,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend *fe,
|
|||||||
{
|
{
|
||||||
struct cx24123_state *state = fe->demodulator_priv;
|
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);
|
dprintk("Signal strength = %d\n", *signal_strength);
|
||||||
|
|
||||||
@@ -907,7 +935,7 @@ static int cx24123_set_frontend(struct dvb_frontend *fe,
|
|||||||
if (state->config->set_ts_params)
|
if (state->config->set_ts_params)
|
||||||
state->config->set_ts_params(fe, 0);
|
state->config->set_ts_params(fe, 0);
|
||||||
|
|
||||||
state->currentfreq=p->frequency;
|
state->currentfreq = p->frequency;
|
||||||
state->currentsymbolrate = p->u.qpsk.symbol_rate;
|
state->currentsymbolrate = p->u.qpsk.symbol_rate;
|
||||||
|
|
||||||
cx24123_set_inversion(state, p->inversion);
|
cx24123_set_inversion(state, p->inversion);
|
||||||
@@ -932,7 +960,8 @@ static int cx24123_set_frontend(struct dvb_frontend *fe,
|
|||||||
return 0;
|
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;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
|
|
||||||
@@ -952,7 +981,7 @@ static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
|
static int cx24123_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
|
||||||
{
|
{
|
||||||
struct cx24123_state *state = fe->demodulator_priv;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
u8 val;
|
u8 val;
|
||||||
@@ -977,8 +1006,8 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx24123_tune(struct dvb_frontend* fe,
|
static int cx24123_tune(struct dvb_frontend *fe,
|
||||||
struct dvb_frontend_parameters* params,
|
struct dvb_frontend_parameters *params,
|
||||||
unsigned int mode_flags,
|
unsigned int mode_flags,
|
||||||
unsigned int *delay,
|
unsigned int *delay,
|
||||||
fe_status_t *status)
|
fe_status_t *status)
|
||||||
@@ -997,12 +1026,12 @@ static int cx24123_tune(struct dvb_frontend* fe,
|
|||||||
|
|
||||||
static int cx24123_get_algo(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)
|
static void cx24123_release(struct dvb_frontend *fe)
|
||||||
{
|
{
|
||||||
struct cx24123_state* state = fe->demodulator_priv;
|
struct cx24123_state *state = fe->demodulator_priv;
|
||||||
dprintk("\n");
|
dprintk("\n");
|
||||||
i2c_del_adapter(&state->tuner_i2c_adapter);
|
i2c_del_adapter(&state->tuner_i2c_adapter);
|
||||||
kfree(state);
|
kfree(state);
|
||||||
@@ -1013,7 +1042,7 @@ static int cx24123_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap,
|
|||||||
{
|
{
|
||||||
struct cx24123_state *state = i2c_get_adapdata(i2c_adap);
|
struct cx24123_state *state = i2c_get_adapdata(i2c_adap);
|
||||||
/* this repeater closes after the first stop */
|
/* this repeater closes after the first stop */
|
||||||
cx24123_repeater_mode(state, 1, 1);
|
cx24123_repeater_mode(state, 1, 1);
|
||||||
return i2c_transfer(state->i2c, msg, num);
|
return i2c_transfer(state->i2c, msg, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1037,8 +1066,8 @@ EXPORT_SYMBOL(cx24123_get_tuner_i2c_adapter);
|
|||||||
|
|
||||||
static struct dvb_frontend_ops cx24123_ops;
|
static struct dvb_frontend_ops cx24123_ops;
|
||||||
|
|
||||||
struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
|
struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
|
||||||
struct i2c_adapter* i2c)
|
struct i2c_adapter *i2c)
|
||||||
{
|
{
|
||||||
struct cx24123_state *state =
|
struct cx24123_state *state =
|
||||||
kzalloc(sizeof(struct cx24123_state), GFP_KERNEL);
|
kzalloc(sizeof(struct cx24123_state), GFP_KERNEL);
|
||||||
@@ -1057,20 +1086,25 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
|
|||||||
/* check if the demod is there */
|
/* check if the demod is there */
|
||||||
state->demod_rev = cx24123_readreg(state, 0x00);
|
state->demod_rev = cx24123_readreg(state, 0x00);
|
||||||
switch (state->demod_rev) {
|
switch (state->demod_rev) {
|
||||||
case 0xe1: info("detected CX24123C\n"); break;
|
case 0xe1:
|
||||||
case 0xd1: info("detected CX24123\n"); break;
|
info("detected CX24123C\n");
|
||||||
|
break;
|
||||||
|
case 0xd1:
|
||||||
|
info("detected CX24123\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
err("wrong demod revision: %x\n", state->demod_rev);
|
err("wrong demod revision: %x\n", state->demod_rev);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create dvb_frontend */
|
/* 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;
|
state->frontend.demodulator_priv = state;
|
||||||
|
|
||||||
/* create tuner i2c adapter */
|
/* create tuner i2c adapter */
|
||||||
if (config->dont_use_pll)
|
if (config->dont_use_pll)
|
||||||
cx24123_repeater_mode(state, 1, 0);
|
cx24123_repeater_mode(state, 1, 0);
|
||||||
|
|
||||||
strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus",
|
strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus",
|
||||||
sizeof(state->tuner_i2c_adapter.name));
|
sizeof(state->tuner_i2c_adapter.name));
|
||||||
@@ -1079,7 +1113,7 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
|
|||||||
state->tuner_i2c_adapter.algo_data = NULL;
|
state->tuner_i2c_adapter.algo_data = NULL;
|
||||||
i2c_set_adapdata(&state->tuner_i2c_adapter, state);
|
i2c_set_adapdata(&state->tuner_i2c_adapter, state);
|
||||||
if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) {
|
if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) {
|
||||||
err("tuner i2c bus could not be initialized\n");
|
err("tuner i2c bus could not be initialized\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,6 +1124,7 @@ error:
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(cx24123_attach);
|
||||||
|
|
||||||
static struct dvb_frontend_ops cx24123_ops = {
|
static struct dvb_frontend_ops cx24123_ops = {
|
||||||
|
|
||||||
@@ -1126,15 +1161,8 @@ static struct dvb_frontend_ops cx24123_ops = {
|
|||||||
.get_frontend_algo = cx24123_get_algo,
|
.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 " \
|
MODULE_DESCRIPTION("DVB Frontend module for Conexant " \
|
||||||
"CX24123/CX24109/CX24113 hardware");
|
"CX24123/CX24109/CX24113 hardware");
|
||||||
MODULE_AUTHOR("Steven Toth");
|
MODULE_AUTHOR("Steven Toth");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
EXPORT_SYMBOL(cx24123_attach);
|
|
||||||
|
@@ -23,13 +23,12 @@
|
|||||||
|
|
||||||
#include <linux/dvb/frontend.h>
|
#include <linux/dvb/frontend.h>
|
||||||
|
|
||||||
struct cx24123_config
|
struct cx24123_config {
|
||||||
{
|
|
||||||
/* the demodulator's i2c address */
|
/* the demodulator's i2c address */
|
||||||
u8 demod_address;
|
u8 demod_address;
|
||||||
|
|
||||||
/* Need to set device param for start_dma */
|
/* Need to set device param for start_dma */
|
||||||
int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
|
int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured);
|
||||||
|
|
||||||
/* 0 = LNB voltage normal, 1 = LNB voltage inverted */
|
/* 0 = LNB voltage normal, 1 = LNB voltage inverted */
|
||||||
int lnb_polarity;
|
int lnb_polarity;
|
||||||
@@ -39,7 +38,8 @@ struct cx24123_config
|
|||||||
void (*agc_callback) (struct dvb_frontend *);
|
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,
|
extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
|
||||||
struct i2c_adapter *i2c);
|
struct i2c_adapter *i2c);
|
||||||
extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *);
|
extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *);
|
||||||
@@ -56,6 +56,6 @@ static struct i2c_adapter *
|
|||||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif // CONFIG_DVB_CX24123
|
#endif
|
||||||
|
|
||||||
#endif /* CX24123_H */
|
#endif /* CX24123_H */
|
||||||
|
Reference in New Issue
Block a user