diff options
Diffstat (limited to 'v4l/mt352.c')
-rw-r--r-- | v4l/mt352.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/v4l/mt352.c b/v4l/mt352.c index fe9ff3505..8019db1b8 100644 --- a/v4l/mt352.c +++ b/v4l/mt352.c @@ -41,13 +41,12 @@ #include "mt352.h" struct mt352_state { - struct i2c_adapter* i2c; - struct dvb_frontend_ops ops; /* configuration settings */ const struct mt352_config* config; + int status; struct dvb_frontend frontend; }; @@ -81,7 +80,7 @@ int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen) return 0; } -static u8 mt352_read_register(struct mt352_state* state, u8 reg) +static int mt352_read_register(struct mt352_state* state, u8 reg) { int ret,i; u8 b0 [] = { reg }; @@ -102,9 +101,11 @@ static u8 mt352_read_register(struct mt352_state* state, u8 reg) __FUNCTION__, i+1); } - if (ret != 2) + if (ret != 2) { printk(KERN_WARNING "%s: readreg error (ret == %i)\n", __FUNCTION__, ret); + return -1; + } return b1[0]; } @@ -114,7 +115,6 @@ static int mt352_sleep(struct dvb_frontend* fe) static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 }; mt352_write(fe, mt352_softdown, sizeof(mt352_softdown)); - return 0; } @@ -287,8 +287,8 @@ static int mt352_set_parameters(struct dvb_frontend* fe, buf[1] = msb(tps); /* TPS_GIVEN_(1|0) */ buf[2] = lsb(tps); -// buf[3] = 0x50; // old - buf[3] = 0xf4; // pinnacle + buf[3] = 0x50; // old +// buf[3] = 0xf4; // pinnacle mt352_calc_nominal_rate(state, op->bandwidth, buf+4); mt352_calc_input_freq(state, buf+6); @@ -435,29 +435,44 @@ static int mt352_get_parameters(struct dvb_frontend* fe, static int mt352_read_status(struct dvb_frontend* fe, fe_status_t* status) { struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv; - u8 r; + int r0,r1,r3; + + r0 = mt352_read_register (state, STATUS_0); + r1 = mt352_read_register (state, STATUS_1); + r3 = mt352_read_register (state, STATUS_3); + if (-1 == r0 || -1 == r1 || -1 == r3) { + /* hmm, read failure. use last as fallback */ + *status = state->status; + return 0; + } *status = 0; - r = mt352_read_register (state, STATUS_0); - if (r & (1 << 4)) - *status = FE_HAS_CARRIER; - if (r & (1 << 1)) - *status |= FE_HAS_VITERBI; - if (r & (1 << 5)) - *status |= FE_HAS_LOCK; - - r = mt352_read_register (state, STATUS_1); - if (r & (1 << 1)) - *status |= FE_HAS_SYNC; - - r = mt352_read_register (state, STATUS_3); - if (r & (1 << 6)) - *status |= FE_HAS_SIGNAL; + if (r0 & (1 << 4)) + *status |= FE_HAS_CARRIER; + if (r0 & (1 << 1)) + *status |= FE_HAS_VITERBI; + if (r0 & (1 << 5)) + *status |= FE_HAS_LOCK; + if (r1 & (1 << 1)) + *status |= FE_HAS_SYNC; + if (r3 & (1 << 6)) + *status |= FE_HAS_SIGNAL; if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) != (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) *status &= ~FE_HAS_LOCK; + if (debug && state->status != *status) { + printk("%s:%s%s%s%s%s\n", __FUNCTION__, + *status & FE_HAS_CARRIER ? " CARRIER" : "", + *status & FE_HAS_VITERBI ? " VITERBI" : "", + *status & FE_HAS_LOCK ? " LOCK" : "", + *status & FE_HAS_SYNC ? " SYNC" : "", + *status & FE_HAS_SIGNAL ? " SIGNAL" : ""); + + } + state->status = *status; + return 0; } |