Commit 4e3599a5 authored by Steven Toth's avatar Steven Toth Committed by Mauro Carvalho Chehab

V4L/DVB (9256): cx22702: Checkpatch compliance

cx22702: Checkpatch compliance
Signed-off-by: default avatarSteven Toth <stoth@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 5c2a164a
...@@ -34,13 +34,12 @@ ...@@ -34,13 +34,12 @@
#include "dvb_frontend.h" #include "dvb_frontend.h"
#include "cx22702.h" #include "cx22702.h"
struct cx22702_state { struct cx22702_state {
struct i2c_adapter* i2c; struct i2c_adapter *i2c;
/* configuration settings */ /* configuration settings */
const struct cx22702_config* config; const struct cx22702_config *config;
struct dvb_frontend frontend; struct dvb_frontend frontend;
...@@ -49,10 +48,13 @@ struct cx22702_state { ...@@ -49,10 +48,13 @@ struct cx22702_state {
}; };
static int debug; static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Enable verbose debug messages");
#define dprintk if (debug) printk #define dprintk if (debug) printk
/* Register values to initialise the demod */ /* Register values to initialise the demod */
static u8 init_tab [] = { static u8 init_tab[] = {
0x00, 0x00, /* Stop aquisition */ 0x00, 0x00, /* Stop aquisition */
0x0B, 0x06, 0x0B, 0x06,
0x09, 0x01, 0x09, 0x01,
...@@ -80,65 +82,67 @@ static u8 init_tab [] = { ...@@ -80,65 +82,67 @@ static u8 init_tab [] = {
0xfd, 0x00, 0xfd, 0x00,
}; };
static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data) static int cx22702_writereg(struct cx22702_state *state, u8 reg, u8 data)
{ {
int ret; int ret;
u8 buf [] = { reg, data }; u8 buf[] = { reg, data };
struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; struct i2c_msg msg = {
.addr = state->config->demod_address, .flags = 0,
.buf = buf, .len = 2 };
ret = i2c_transfer(state->i2c, &msg, 1); ret = i2c_transfer(state->i2c, &msg, 1);
if (ret != 1) if (ret != 1)
printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", printk(KERN_ERR
"%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
__func__, reg, data, ret); __func__, reg, data, ret);
return (ret != 1) ? -1 : 0; return (ret != 1) ? -1 : 0;
} }
static u8 cx22702_readreg (struct cx22702_state* state, u8 reg) static u8 cx22702_readreg(struct cx22702_state *state, u8 reg)
{ {
int ret; int ret;
u8 b0 [] = { reg }; u8 b0[] = { reg };
u8 b1 [] = { 0 }; u8 b1[] = { 0 };
struct i2c_msg msg [] = { struct i2c_msg msg[] = {
{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, { .addr = state->config->demod_address, .flags = 0,
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; .buf = b0, .len = 1 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD,
.buf = b1, .len = 1 } };
ret = i2c_transfer(state->i2c, msg, 2); ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2) if (ret != 2)
printk("%s: readreg error (ret == %i)\n", __func__, ret); printk(KERN_ERR "%s: readreg error (ret == %i)\n",
__func__, ret);
return b1[0]; return b1[0];
} }
static int cx22702_set_inversion (struct cx22702_state *state, int inversion) static int cx22702_set_inversion(struct cx22702_state *state, int inversion)
{ {
u8 val; u8 val;
switch (inversion) { switch (inversion) {
case INVERSION_AUTO:
case INVERSION_AUTO: return -EOPNOTSUPP;
return -EOPNOTSUPP; case INVERSION_ON:
val = cx22702_readreg(state, 0x0C);
case INVERSION_ON: return cx22702_writereg(state, 0x0C, val | 0x01);
val = cx22702_readreg (state, 0x0C); case INVERSION_OFF:
return cx22702_writereg (state, 0x0C, val | 0x01); val = cx22702_readreg(state, 0x0C);
return cx22702_writereg(state, 0x0C, val & 0xfe);
case INVERSION_OFF: default:
val = cx22702_readreg (state, 0x0C); return -EINVAL;
return cx22702_writereg (state, 0x0C, val & 0xfe);
default:
return -EINVAL;
} }
} }
/* Retrieve the demod settings */ /* Retrieve the demod settings */
static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p) static int cx22702_get_tps(struct cx22702_state *state,
struct dvb_ofdm_parameters *p)
{ {
u8 val; u8 val;
...@@ -146,180 +150,281 @@ static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_paramet ...@@ -146,180 +150,281 @@ static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_paramet
if (!(cx22702_readreg(state, 0x0A) & 0x20)) if (!(cx22702_readreg(state, 0x0A) & 0x20))
return -EAGAIN; return -EAGAIN;
val = cx22702_readreg (state, 0x01); val = cx22702_readreg(state, 0x01);
switch( (val&0x18)>>3) { switch ((val & 0x18) >> 3) {
case 0: p->constellation = QPSK; break; case 0:
case 1: p->constellation = QAM_16; break; p->constellation = QPSK;
case 2: p->constellation = QAM_64; break; break;
case 1:
p->constellation = QAM_16;
break;
case 2:
p->constellation = QAM_64;
break;
} }
switch( val&0x07 ) { switch (val & 0x07) {
case 0: p->hierarchy_information = HIERARCHY_NONE; break; case 0:
case 1: p->hierarchy_information = HIERARCHY_1; break; p->hierarchy_information = HIERARCHY_NONE;
case 2: p->hierarchy_information = HIERARCHY_2; break; break;
case 3: p->hierarchy_information = HIERARCHY_4; break; case 1:
p->hierarchy_information = HIERARCHY_1;
break;
case 2:
p->hierarchy_information = HIERARCHY_2;
break;
case 3:
p->hierarchy_information = HIERARCHY_4;
break;
} }
val = cx22702_readreg (state, 0x02); val = cx22702_readreg(state, 0x02);
switch( (val&0x38)>>3 ) { switch ((val & 0x38) >> 3) {
case 0: p->code_rate_HP = FEC_1_2; break; case 0:
case 1: p->code_rate_HP = FEC_2_3; break; p->code_rate_HP = FEC_1_2;
case 2: p->code_rate_HP = FEC_3_4; break; break;
case 3: p->code_rate_HP = FEC_5_6; break; case 1:
case 4: p->code_rate_HP = FEC_7_8; break; p->code_rate_HP = FEC_2_3;
break;
case 2:
p->code_rate_HP = FEC_3_4;
break;
case 3:
p->code_rate_HP = FEC_5_6;
break;
case 4:
p->code_rate_HP = FEC_7_8;
break;
} }
switch( val&0x07 ) { switch (val & 0x07) {
case 0: p->code_rate_LP = FEC_1_2; break; case 0:
case 1: p->code_rate_LP = FEC_2_3; break; p->code_rate_LP = FEC_1_2;
case 2: p->code_rate_LP = FEC_3_4; break; break;
case 3: p->code_rate_LP = FEC_5_6; break; case 1:
case 4: p->code_rate_LP = FEC_7_8; break; p->code_rate_LP = FEC_2_3;
break;
case 2:
p->code_rate_LP = FEC_3_4;
break;
case 3:
p->code_rate_LP = FEC_5_6;
break;
case 4:
p->code_rate_LP = FEC_7_8;
break;
} }
val = cx22702_readreg(state, 0x03);
val = cx22702_readreg (state, 0x03); switch ((val & 0x0c) >> 2) {
switch( (val&0x0c)>>2 ) { case 0:
case 0: p->guard_interval = GUARD_INTERVAL_1_32; break; p->guard_interval = GUARD_INTERVAL_1_32;
case 1: p->guard_interval = GUARD_INTERVAL_1_16; break; break;
case 2: p->guard_interval = GUARD_INTERVAL_1_8; break; case 1:
case 3: p->guard_interval = GUARD_INTERVAL_1_4; break; p->guard_interval = GUARD_INTERVAL_1_16;
break;
case 2:
p->guard_interval = GUARD_INTERVAL_1_8;
break;
case 3:
p->guard_interval = GUARD_INTERVAL_1_4;
break;
} }
switch( val&0x03 ) { switch (val & 0x03) {
case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; case 0:
case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; p->transmission_mode = TRANSMISSION_MODE_2K;
break;
case 1:
p->transmission_mode = TRANSMISSION_MODE_8K;
break;
} }
return 0; return 0;
} }
static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) static int cx22702_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
dprintk ("%s(%d)\n", __func__, enable); dprintk("%s(%d)\n", __func__, enable);
if (enable) if (enable)
return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); return cx22702_writereg(state, 0x0D,
cx22702_readreg(state, 0x0D) & 0xfe);
else else
return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1); return cx22702_writereg(state, 0x0D,
cx22702_readreg(state, 0x0D) | 1);
} }
/* Talk to the demod, set the FEC, GUARD, QAM settings etc */ /* Talk to the demod, set the FEC, GUARD, QAM settings etc */
static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx22702_set_tps(struct dvb_frontend *fe,
struct dvb_frontend_parameters *p)
{ {
u8 val; u8 val;
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
if (fe->ops.tuner_ops.set_params) { if (fe->ops.tuner_ops.set_params) {
fe->ops.tuner_ops.set_params(fe, p); fe->ops.tuner_ops.set_params(fe, p);
if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);
} }
/* set inversion */ /* set inversion */
cx22702_set_inversion (state, p->inversion); cx22702_set_inversion(state, p->inversion);
/* set bandwidth */ /* set bandwidth */
switch(p->u.ofdm.bandwidth) { switch (p->u.ofdm.bandwidth) {
case BANDWIDTH_6_MHZ: case BANDWIDTH_6_MHZ:
cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 ); cx22702_writereg(state, 0x0C,
(cx22702_readreg(state, 0x0C) & 0xcf) | 0x20);
break; break;
case BANDWIDTH_7_MHZ: case BANDWIDTH_7_MHZ:
cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 ); cx22702_writereg(state, 0x0C,
(cx22702_readreg(state, 0x0C) & 0xcf) | 0x10);
break; break;
case BANDWIDTH_8_MHZ: case BANDWIDTH_8_MHZ:
cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf ); cx22702_writereg(state, 0x0C,
cx22702_readreg(state, 0x0C) & 0xcf);
break; break;
default: default:
dprintk ("%s: invalid bandwidth\n",__func__); dprintk("%s: invalid bandwidth\n", __func__);
return -EINVAL; return -EINVAL;
} }
p->u.ofdm.code_rate_LP = FEC_AUTO; /* temp hack as manual not working */
p->u.ofdm.code_rate_LP = FEC_AUTO; //temp hack as manual not working
/* use auto configuration? */ /* use auto configuration? */
if((p->u.ofdm.hierarchy_information==HIERARCHY_AUTO) || if ((p->u.ofdm.hierarchy_information == HIERARCHY_AUTO) ||
(p->u.ofdm.constellation==QAM_AUTO) || (p->u.ofdm.constellation == QAM_AUTO) ||
(p->u.ofdm.code_rate_HP==FEC_AUTO) || (p->u.ofdm.code_rate_HP == FEC_AUTO) ||
(p->u.ofdm.code_rate_LP==FEC_AUTO) || (p->u.ofdm.code_rate_LP == FEC_AUTO) ||
(p->u.ofdm.guard_interval==GUARD_INTERVAL_AUTO) || (p->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO) ||
(p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) { (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO)) {
/* TPS Source - use hardware driven values */ /* TPS Source - use hardware driven values */
cx22702_writereg(state, 0x06, 0x10); cx22702_writereg(state, 0x06, 0x10);
cx22702_writereg(state, 0x07, 0x9); cx22702_writereg(state, 0x07, 0x9);
cx22702_writereg(state, 0x08, 0xC1); cx22702_writereg(state, 0x08, 0xC1);
cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc ); cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B)
cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); & 0xfc);
cx22702_writereg(state, 0x0C,
(cx22702_readreg(state, 0x0C) & 0xBF) | 0x40);
cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */
dprintk("%s: Autodetecting\n",__func__); dprintk("%s: Autodetecting\n", __func__);
return 0; return 0;
} }
/* manually programmed values */ /* manually programmed values */
val=0; val = 0;
switch(p->u.ofdm.constellation) { switch (p->u.ofdm.constellation) {
case QPSK: val = (val&0xe7); break; case QPSK:
case QAM_16: val = (val&0xe7)|0x08; break; val = (val & 0xe7);
case QAM_64: val = (val&0xe7)|0x10; break; break;
default: case QAM_16:
dprintk ("%s: invalid constellation\n",__func__); val = (val & 0xe7) | 0x08;
return -EINVAL; break;
case QAM_64:
val = (val & 0xe7) | 0x10;
break;
default:
dprintk("%s: invalid constellation\n", __func__);
return -EINVAL;
} }
switch(p->u.ofdm.hierarchy_information) { switch (p->u.ofdm.hierarchy_information) {
case HIERARCHY_NONE: val = (val&0xf8); break; case HIERARCHY_NONE:
case HIERARCHY_1: val = (val&0xf8)|1; break; val = (val & 0xf8);
case HIERARCHY_2: val = (val&0xf8)|2; break; break;
case HIERARCHY_4: val = (val&0xf8)|3; break; case HIERARCHY_1:
default: val = (val & 0xf8) | 1;
dprintk ("%s: invalid hierarchy\n",__func__); break;
return -EINVAL; case HIERARCHY_2:
val = (val & 0xf8) | 2;
break;
case HIERARCHY_4:
val = (val & 0xf8) | 3;
break;
default:
dprintk("%s: invalid hierarchy\n", __func__);
return -EINVAL;
} }
cx22702_writereg (state, 0x06, val); cx22702_writereg(state, 0x06, val);
val=0; val = 0;
switch(p->u.ofdm.code_rate_HP) { switch (p->u.ofdm.code_rate_HP) {
case FEC_NONE: case FEC_NONE:
case FEC_1_2: val = (val&0xc7); break; case FEC_1_2:
case FEC_2_3: val = (val&0xc7)|0x08; break; val = (val & 0xc7);
case FEC_3_4: val = (val&0xc7)|0x10; break; break;
case FEC_5_6: val = (val&0xc7)|0x18; break; case FEC_2_3:
case FEC_7_8: val = (val&0xc7)|0x20; break; val = (val & 0xc7) | 0x08;
default: break;
dprintk ("%s: invalid code_rate_HP\n",__func__); case FEC_3_4:
return -EINVAL; val = (val & 0xc7) | 0x10;
break;
case FEC_5_6:
val = (val & 0xc7) | 0x18;
break;
case FEC_7_8:
val = (val & 0xc7) | 0x20;
break;
default:
dprintk("%s: invalid code_rate_HP\n", __func__);
return -EINVAL;
} }
switch(p->u.ofdm.code_rate_LP) { switch (p->u.ofdm.code_rate_LP) {
case FEC_NONE: case FEC_NONE:
case FEC_1_2: val = (val&0xf8); break; case FEC_1_2:
case FEC_2_3: val = (val&0xf8)|1; break; val = (val & 0xf8);
case FEC_3_4: val = (val&0xf8)|2; break; break;
case FEC_5_6: val = (val&0xf8)|3; break; case FEC_2_3:
case FEC_7_8: val = (val&0xf8)|4; break; val = (val & 0xf8) | 1;
default: break;
dprintk ("%s: invalid code_rate_LP\n",__func__); case FEC_3_4:
return -EINVAL; val = (val & 0xf8) | 2;
break;
case FEC_5_6:
val = (val & 0xf8) | 3;
break;
case FEC_7_8:
val = (val & 0xf8) | 4;
break;
default:
dprintk("%s: invalid code_rate_LP\n", __func__);
return -EINVAL;
} }
cx22702_writereg (state, 0x07, val); cx22702_writereg(state, 0x07, val);
val=0; val = 0;
switch(p->u.ofdm.guard_interval) { switch (p->u.ofdm.guard_interval) {
case GUARD_INTERVAL_1_32: val = (val&0xf3); break; case GUARD_INTERVAL_1_32:
case GUARD_INTERVAL_1_16: val = (val&0xf3)|0x04; break; val = (val & 0xf3);
case GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break; break;
case GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break; case GUARD_INTERVAL_1_16:
default: val = (val & 0xf3) | 0x04;
dprintk ("%s: invalid guard_interval\n",__func__); break;
return -EINVAL; case GUARD_INTERVAL_1_8:
val = (val & 0xf3) | 0x08;
break;
case GUARD_INTERVAL_1_4:
val = (val & 0xf3) | 0x0c;
break;
default:
dprintk("%s: invalid guard_interval\n", __func__);
return -EINVAL;
} }
switch(p->u.ofdm.transmission_mode) { switch (p->u.ofdm.transmission_mode) {
case TRANSMISSION_MODE_2K: val = (val&0xfc); break; case TRANSMISSION_MODE_2K:
case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break; val = (val & 0xfc);
default: break;
dprintk ("%s: invalid transmission_mode\n",__func__); case TRANSMISSION_MODE_8K:
return -EINVAL; val = (val & 0xfc) | 1;
break;
default:
dprintk("%s: invalid transmission_mode\n", __func__);
return -EINVAL;
} }
cx22702_writereg(state, 0x08, val); cx22702_writereg(state, 0x08, val);
cx22702_writereg(state, 0x0B, (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02 ); cx22702_writereg(state, 0x0B,
cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02);
cx22702_writereg(state, 0x0C,
(cx22702_readreg(state, 0x0C) & 0xBF) | 0x40);
/* Begin channel aquisition */ /* Begin channel aquisition */
cx22702_writereg(state, 0x00, 0x01); cx22702_writereg(state, 0x00, 0x01);
...@@ -329,109 +434,111 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet ...@@ -329,109 +434,111 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
/* Reset the demod hardware and reset all of the configuration registers /* Reset the demod hardware and reset all of the configuration registers
to a default state. */ to a default state. */
static int cx22702_init (struct dvb_frontend* fe) static int cx22702_init(struct dvb_frontend *fe)
{ {
int i; int i;
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
cx22702_writereg (state, 0x00, 0x02); cx22702_writereg(state, 0x00, 0x02);
msleep(10); msleep(10);
for (i=0; i<sizeof(init_tab); i+=2) for (i = 0; i < ARRAY_SIZE(init_tab); i += 2)
cx22702_writereg (state, init_tab[i], init_tab[i+1]); cx22702_writereg(state, init_tab[i], init_tab[i + 1]);
cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02); cx22702_writereg(state, 0xf8, (state->config->output_mode << 1)
& 0x02);
cx22702_i2c_gate_ctrl(fe, 0); cx22702_i2c_gate_ctrl(fe, 0);
return 0; return 0;
} }
static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status) static int cx22702_read_status(struct dvb_frontend *fe, fe_status_t *status)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
u8 reg0A; u8 reg0A;
u8 reg23; u8 reg23;
*status = 0; *status = 0;
reg0A = cx22702_readreg (state, 0x0A); reg0A = cx22702_readreg(state, 0x0A);
reg23 = cx22702_readreg (state, 0x23); reg23 = cx22702_readreg(state, 0x23);
dprintk ("%s: status demod=0x%02x agc=0x%02x\n" dprintk("%s: status demod=0x%02x agc=0x%02x\n"
,__func__,reg0A,reg23); , __func__, reg0A, reg23);
if(reg0A & 0x10) { if (reg0A & 0x10) {
*status |= FE_HAS_LOCK; *status |= FE_HAS_LOCK;
*status |= FE_HAS_VITERBI; *status |= FE_HAS_VITERBI;
*status |= FE_HAS_SYNC; *status |= FE_HAS_SYNC;
} }
if(reg0A & 0x20) if (reg0A & 0x20)
*status |= FE_HAS_CARRIER; *status |= FE_HAS_CARRIER;
if(reg23 < 0xf0) if (reg23 < 0xf0)
*status |= FE_HAS_SIGNAL; *status |= FE_HAS_SIGNAL;
return 0; return 0;
} }
static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber) static int cx22702_read_ber(struct dvb_frontend *fe, u32 *ber)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
if(cx22702_readreg (state, 0xE4) & 0x02) { if (cx22702_readreg(state, 0xE4) & 0x02) {
/* Realtime statistics */ /* Realtime statistics */
*ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7
| (cx22702_readreg (state, 0xDF)&0x7F); | (cx22702_readreg(state, 0xDF) & 0x7F);
} else { } else {
/* Averagtine statistics */ /* Averagtine statistics */
*ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 *ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7
| cx22702_readreg (state, 0xDF); | cx22702_readreg(state, 0xDF);
} }
return 0; return 0;
} }
static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) static int cx22702_read_signal_strength(struct dvb_frontend *fe,
u16 *signal_strength)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
u16 rs_ber = 0; u16 rs_ber = 0;
rs_ber = cx22702_readreg (state, 0x23); rs_ber = cx22702_readreg(state, 0x23);
*signal_strength = (rs_ber << 8) | rs_ber; *signal_strength = (rs_ber << 8) | rs_ber;
return 0; return 0;
} }
static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr) static int cx22702_read_snr(struct dvb_frontend *fe, u16 *snr)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
u16 rs_ber=0; u16 rs_ber = 0;
if(cx22702_readreg (state, 0xE4) & 0x02) { if (cx22702_readreg(state, 0xE4) & 0x02) {
/* Realtime statistics */ /* Realtime statistics */
rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7 rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 7
| (cx22702_readreg (state, 0xDF)& 0x7F); | (cx22702_readreg(state, 0xDF) & 0x7F);
} else { } else {
/* Averagine statistics */ /* Averagine statistics */
rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8 rs_ber = (cx22702_readreg(state, 0xDE) & 0x7F) << 8
| cx22702_readreg (state, 0xDF); | cx22702_readreg(state, 0xDF);
} }
*snr = ~rs_ber; *snr = ~rs_ber;
return 0; return 0;
} }
static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
u8 _ucblocks; u8 _ucblocks;
/* RS Uncorrectable Packet Count then reset */ /* RS Uncorrectable Packet Count then reset */
_ucblocks = cx22702_readreg (state, 0xE3); _ucblocks = cx22702_readreg(state, 0xE3);
if (state->prevUCBlocks < _ucblocks) if (state->prevUCBlocks < _ucblocks)
*ucblocks = (_ucblocks - state->prevUCBlocks); *ucblocks = (_ucblocks - state->prevUCBlocks);
else else
...@@ -441,34 +548,36 @@ static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) ...@@ -441,34 +548,36 @@ static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
return 0; return 0;
} }
static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx22702_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *p)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
u8 reg0C = cx22702_readreg (state, 0x0C); u8 reg0C = cx22702_readreg(state, 0x0C);
p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF; p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF;
return cx22702_get_tps (state, &p->u.ofdm); return cx22702_get_tps(state, &p->u.ofdm);
} }
static int cx22702_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) static int cx22702_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *tune)
{ {
tune->min_delay_ms = 1000; tune->min_delay_ms = 1000;
return 0; return 0;
} }
static void cx22702_release(struct dvb_frontend* fe) static void cx22702_release(struct dvb_frontend *fe)
{ {
struct cx22702_state* state = fe->demodulator_priv; struct cx22702_state *state = fe->demodulator_priv;
kfree(state); kfree(state);
} }
static struct dvb_frontend_ops cx22702_ops; static struct dvb_frontend_ops cx22702_ops;
struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, struct dvb_frontend *cx22702_attach(const struct cx22702_config *config,
struct i2c_adapter* i2c) struct i2c_adapter *i2c)
{ {
struct cx22702_state* state = NULL; struct cx22702_state *state = NULL;
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL);
...@@ -485,7 +594,8 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, ...@@ -485,7 +594,8 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
goto error; goto error;
/* create dvb_frontend */ /* create dvb_frontend */
memcpy(&state->frontend.ops, &cx22702_ops, sizeof(struct dvb_frontend_ops)); memcpy(&state->frontend.ops, &cx22702_ops,
sizeof(struct dvb_frontend_ops));
state->frontend.demodulator_priv = state; state->frontend.demodulator_priv = state;
return &state->frontend; return &state->frontend;
...@@ -493,6 +603,7 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, ...@@ -493,6 +603,7 @@ struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
kfree(state); kfree(state);
return NULL; return NULL;
} }
EXPORT_SYMBOL(cx22702_attach);
static struct dvb_frontend_ops cx22702_ops = { static struct dvb_frontend_ops cx22702_ops = {
...@@ -525,11 +636,6 @@ static struct dvb_frontend_ops cx22702_ops = { ...@@ -525,11 +636,6 @@ static struct dvb_frontend_ops cx22702_ops = {
.read_ucblocks = cx22702_read_ucblocks, .read_ucblocks = cx22702_read_ucblocks,
}; };
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Enable verbose debug messages");
MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver"); MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver");
MODULE_AUTHOR("Steven Toth"); MODULE_AUTHOR("Steven Toth");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
EXPORT_SYMBOL(cx22702_attach);
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
#include <linux/dvb/frontend.h> #include <linux/dvb/frontend.h>
struct cx22702_config struct cx22702_config {
{
/* the demodulator's i2c address */ /* the demodulator's i2c address */
u8 demod_address; u8 demod_address;
...@@ -41,16 +40,19 @@ struct cx22702_config ...@@ -41,16 +40,19 @@ struct cx22702_config
u8 output_mode; u8 output_mode;
}; };
#if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) && defined(MODULE)) #if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) \
extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, && defined(MODULE))
struct i2c_adapter* i2c); extern struct dvb_frontend *cx22702_attach(
const struct cx22702_config *config,
struct i2c_adapter *i2c);
#else #else
static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, static inline struct dvb_frontend *cx22702_attach(
struct i2c_adapter* i2c) const struct cx22702_config *config,
struct i2c_adapter *i2c)
{ {
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_CX22702 #endif
#endif // CX22702_H #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment