/* current and next tuning parameters */
struct cx24120_tuning dcur;
struct cx24120_tuning dnxt;
+
+ fe_status_t fe_status;
};
/* Command message to firmware */
int ret;
u8 buf = 0;
struct i2c_msg msg[] = {
- { .addr = state->config->i2c_addr,
+ {
+ .addr = state->config->i2c_addr,
.flags = 0,
.len = 1,
.buf = ®
u16 *signal_strength)
{
struct cx24120_state *state = fe->demodulator_priv;
- struct cx24120_cmd cmd;
- int ret, sigstr_h, sigstr_l;
-
- cmd.id = CMD_READ_SNR;
- cmd.len = 1;
- cmd.arg[0] = 0x00;
-
- ret = cx24120_message_send(state, &cmd);
- if (ret != 0) {
- err("error reading signal strength\n");
- return -EREMOTEIO;
- }
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
- /* raw */
- sigstr_h = (cx24120_readreg(state, CX24120_REG_SIGSTR_H) >> 6) << 8;
- sigstr_l = cx24120_readreg(state, CX24120_REG_SIGSTR_L);
- dev_dbg(&state->i2c->dev, "%s: Signal strength from firmware= 0x%x\n",
- __func__, (sigstr_h | sigstr_l));
+ if (c->strength.stat[0].scale != FE_SCALE_RELATIVE)
+ *signal_strength = 0;
+ else
+ *signal_strength = c->strength.stat[0].uvalue;
- /* cooked */
- *signal_strength = ((sigstr_h | sigstr_l) << 5) & 0x0000ffff;
- dev_dbg(&state->i2c->dev, "%s: Signal strength= 0x%x\n",
+ dev_dbg(&state->i2c->dev, "%s: Signal strength from cache: 0x%x\n",
__func__, *signal_strength);
return 0;
struct cx24120_state *state = fe->demodulator_priv;
struct cx24120_cmd cmd;
- /* Yes, cmd.len is set to zero. The old driver
+ /*
+ * Yes, cmd.len is set to zero. The old driver
* didn't specify any len, but also had a
* memset 0 before every use of the cmd struct
* which would have set it to zero.
return -ETIMEDOUT;
}
-static void cx24120_get_stats(struct cx24120_state *state, fe_status_t status)
+static void cx24120_get_stats(struct cx24120_state *state)
{
struct dvb_frontend *fe = &state->frontend;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+ struct cx24120_cmd cmd;
int ret;
- u16 u16tmp;
+ u16 sig;
dev_dbg(&state->i2c->dev, "%s()\n", __func__);
/* signal strength */
- if (status & FE_HAS_SIGNAL) {
- ret = cx24120_read_signal_strength(fe, &u16tmp);
- if (ret != 0)
+ if (state->fe_status & FE_HAS_SIGNAL) {
+ cmd.id = CMD_READ_SNR;
+ cmd.len = 1;
+ cmd.arg[0] = 0x00;
+
+ ret = cx24120_message_send(state, &cmd);
+ if (ret != 0) {
+ err("error reading signal strength\n");
return;
+ }
+
+ /* raw */
+ sig = cx24120_readreg(state, CX24120_REG_SIGSTR_H) >> 6;
+ sig = sig << 8;
+ sig |= cx24120_readreg(state, CX24120_REG_SIGSTR_L);
+ dev_dbg(&state->i2c->dev,
+ "%s: Signal strength from firmware= 0x%x\n",
+ __func__, sig);
+
+ /* cooked */
+ sig = -100 * sig + 94324;
c->strength.stat[0].scale = FE_SCALE_RELATIVE;
- c->strength.stat[0].uvalue = u16tmp;
+ c->strength.stat[0].uvalue = sig;
} else {
c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
if (lock & CX24120_HAS_LOCK)
*status |= FE_HAS_LOCK;
- /* TODO: is FE_HAS_SYNC in the right place?
+ /*
+ * TODO: is FE_HAS_SYNC in the right place?
* Other cx241xx drivers have this slightly
- * different */
+ * different
+ */
- cx24120_get_stats(state, *status);
+ state->fe_status = *status;
+ cx24120_get_stats(state);
/* Set the clock once tuned in */
if (state->need_clock_set && *status & FE_HAS_LOCK) {
return 0;
}
-/* FEC & modulation lookup table
+/*
+ * FEC & modulation lookup table
* Used for decoding the REG_FECMODE register
* once tuned in.
*/
return 0;
}
-/* Clock ratios lookup table
+/*
+ * Clock ratios lookup table
*
* Values obtained from much larger table in old driver
* which had numerous entries which would never match.
*
* There's probably some way of calculating these but I
* can't determine the pattern
-*/
+ */
static struct cx24120_clock_ratios_table {
fe_delivery_system_t delsys;
fe_pilot_t pilot;
fe_code_rate_t fec;
u8 val;
} modfec_table[] = {
-/*delsys mod fec val */
+ /*delsys mod fec val */
{ SYS_DVBS, QPSK, FEC_1_2, 0x2e },
{ SYS_DVBS, QPSK, FEC_2_3, 0x2f },
{ SYS_DVBS, QPSK, FEC_3_4, 0x30 },
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct cx24120_state *state = fe->demodulator_priv;
u8 freq1, freq2, freq3;
- fe_status_t status;
dev_dbg(&state->i2c->dev, "%s()", __func__);
/* don't return empty data if we're not tuned in */
- cx24120_read_status(fe, &status);
- if ((status & FE_HAS_LOCK) == 0)
+ if ((state->fe_status & FE_HAS_LOCK) == 0)
return 0;
/* Get frequency */