#define CX24120_REG_REVISION 0xff /* Chip revision (ro) */
-
/* Command messages */
enum command_message_id {
CMD_VCO_SET = 0x10, /* cmd.len = 12; */
u8 pilot_val;
};
-
/* Private state */
struct cx24120_state {
struct i2c_adapter *i2c;
u8 cold_init;
u8 mpeg_enabled;
+ u8 need_clock_set;
/* current and next tuning parameters */
struct cx24120_tuning dcur;
struct cx24120_tuning dnxt;
-};
+ fe_status_t fe_status;
+};
/* Command message to firmware */
struct cx24120_cmd {
u8 arg[CX24120_MAX_CMD_LEN];
};
-
/* Read single register */
static int cx24120_readreg(struct cx24120_state *state, u8 reg)
{
int ret;
u8 buf = 0;
struct i2c_msg msg[] = {
- { .addr = state->config->i2c_addr,
+ {
+ .addr = state->config->i2c_addr,
.flags = 0,
.len = 1,
.buf = ®
return buf;
}
-
/* Write single register */
static int cx24120_writereg(struct cx24120_state *state, u8 reg, u8 data)
{
ret = i2c_transfer(state->i2c, &msg, 1);
if (ret != 1) {
err("Write error: i2c_write error(err == %i, 0x%02x: 0x%02x)\n",
- ret, reg, data);
+ ret, reg, data);
return ret;
}
return 0;
}
-
/* Write multiple registers in chunks of i2c_wr_max-sized buffers */
-static int cx24120_writeregN(struct cx24120_state *state,
- u8 reg, const u8 *values, u16 len, u8 incr)
+static int cx24120_writeregs(struct cx24120_state *state,
+ u8 reg, const u8 *values, u16 len, u8 incr)
{
int ret;
u16 max = state->config->i2c_wr_max > 0 ?
};
msg.buf = kmalloc(max + 1, GFP_KERNEL);
- if (msg.buf == NULL)
+ if (!msg.buf)
return -ENOMEM;
while (len) {
dev_dbg(&state->i2c->dev,
"%s: reg=0x%02x; data=%*ph\n",
- __func__, reg, msg.len, msg.buf+1);
+ __func__, reg, msg.len - 1, msg.buf + 1);
}
ret = 0;
return ret;
}
-
static struct dvb_frontend_ops cx24120_ops;
struct dvb_frontend *cx24120_attach(const struct cx24120_config *config,
- struct i2c_adapter *i2c)
+ struct i2c_adapter *i2c)
{
- struct cx24120_state *state = NULL;
+ struct cx24120_state *state;
int demod_rev;
info("Conexant cx24120/cx24118 - DVBS/S2 Satellite demod/tuner\n");
- state = kzalloc(sizeof(struct cx24120_state), GFP_KERNEL);
- if (state == NULL) {
+ state = kzalloc(sizeof(*state), GFP_KERNEL);
+ if (!state) {
err("Unable to allocate memory for cx24120_state\n");
goto error;
}
info("Demod cx24120 rev. 0x05 detected.\n");
break;
default:
- err("Unsupported demod revision: 0x%x detected.\n",
- demod_rev);
+ err("Unsupported demod revision: 0x%x detected.\n", demod_rev);
goto error;
}
return err;
}
-
static int cx24120_read_snr(struct dvb_frontend *fe, u16 *snr)
{
struct cx24120_state *state = fe->demodulator_priv;
- *snr = (cx24120_readreg(state, CX24120_REG_QUALITY_H)<<8) |
+ *snr = (cx24120_readreg(state, CX24120_REG_QUALITY_H) << 8) |
(cx24120_readreg(state, CX24120_REG_QUALITY_L));
- dev_dbg(&state->i2c->dev, "%s: read SNR index = %d\n",
- __func__, *snr);
+ dev_dbg(&state->i2c->dev, "%s: read SNR index = %d\n", __func__, *snr);
return 0;
}
-
static int cx24120_read_ber(struct dvb_frontend *fe, u32 *ber)
{
struct cx24120_state *state = fe->demodulator_priv;
*ber = (cx24120_readreg(state, CX24120_REG_BER_HH) << 24) |
(cx24120_readreg(state, CX24120_REG_BER_HL) << 16) |
- (cx24120_readreg(state, CX24120_REG_BER_LH) << 8) |
+ (cx24120_readreg(state, CX24120_REG_BER_LH) << 8) |
cx24120_readreg(state, CX24120_REG_BER_LL);
- dev_dbg(&state->i2c->dev, "%s: read BER index = %d\n",
- __func__, *ber);
+ dev_dbg(&state->i2c->dev, "%s: read BER index = %d\n", __func__, *ber);
return 0;
}
static int cx24120_msg_mpeg_output_global_config(struct cx24120_state *state,
- u8 flag);
+ u8 flag);
/* Check if we're running a command that needs to disable mpeg out */
static void cx24120_check_cmd(struct cx24120_state *state, u8 id)
case CMD_DISEQC_MSG2:
case CMD_SETVOLTAGE:
case CMD_SETTONE:
+ case CMD_DISEQC_BURST:
cx24120_msg_mpeg_output_global_config(state, 0);
/* Old driver would do a msleep(100) here */
default:
}
}
-
/* Send a message to the firmware */
static int cx24120_message_send(struct cx24120_state *state,
- struct cx24120_cmd *cmd)
+ struct cx24120_cmd *cmd)
{
int ret, ficus;
}
ret = cx24120_writereg(state, CX24120_REG_CMD_START, cmd->id);
- ret = cx24120_writeregN(state, CX24120_REG_CMD_ARGS, &cmd->arg[0],
+ ret = cx24120_writeregs(state, CX24120_REG_CMD_ARGS, &cmd->arg[0],
cmd->len, 1);
ret = cx24120_writereg(state, CX24120_REG_CMD_END, 0x01);
/* Send a message and fill arg[] with the results */
static int cx24120_message_sendrcv(struct cx24120_state *state,
- struct cx24120_cmd *cmd, u8 numreg)
+ struct cx24120_cmd *cmd, u8 numreg)
{
int ret, i;
/* Read numreg registers starting from register cmd->len */
for (i = 0; i < numreg; i++)
- cmd->arg[i] = cx24120_readreg(state, (cmd->len+i+1));
+ cmd->arg[i] = cx24120_readreg(state, (cmd->len + i + 1));
return 0;
}
-
-
static int cx24120_read_signal_strength(struct dvb_frontend *fe,
- u16 *signal_strength)
+ 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",
- __func__, *signal_strength);
+ dev_dbg(&state->i2c->dev, "%s: Signal strength from cache: 0x%x\n",
+ __func__, *signal_strength);
return 0;
}
-
static int cx24120_msg_mpeg_output_global_config(struct cx24120_state *state,
- u8 enable)
+ u8 enable)
{
struct cx24120_cmd cmd;
int ret;
if (ret != 0) {
dev_dbg(&state->i2c->dev,
"%s: Failed to set MPEG output to %s\n",
- __func__,
- (enable)?"enabled":"disabled");
+ __func__, enable ? "enabled" : "disabled");
return ret;
}
state->mpeg_enabled = enable;
dev_dbg(&state->i2c->dev, "%s: MPEG output %s\n",
- __func__,
- (enable)?"enabled":"disabled");
+ __func__, enable ? "enabled" : "disabled");
return 0;
}
-
static int cx24120_msg_mpeg_output_config(struct cx24120_state *state, u8 seq)
{
struct cx24120_cmd cmd;
cmd.id = CMD_MPEG_INIT;
cmd.len = 7;
- cmd.arg[0] = seq; /* sequental number - can be 0,1,2 */
+ cmd.arg[0] = seq; /* sequental number - can be 0,1,2 */
cmd.arg[1] = ((i.x1 & 0x01) << 1) | ((i.x1 >> 1) & 0x01);
cmd.arg[2] = 0x05;
cmd.arg[3] = 0x02;
return cx24120_message_send(state, &cmd);
}
-
static int cx24120_diseqc_send_burst(struct dvb_frontend *fe,
- fe_sec_mini_cmd_t burst)
+ fe_sec_mini_cmd_t burst)
{
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.
cmd.arg[0] = 0x00;
if (burst)
cmd.arg[1] = 0x01;
+
dev_dbg(&state->i2c->dev, "%s: burst sent.\n", __func__);
return cx24120_message_send(state, &cmd);
}
-
static int cx24120_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
{
struct cx24120_state *state = fe->demodulator_priv;
struct cx24120_cmd cmd;
- dev_dbg(&state->i2c->dev, "%s(%d)\n",
- __func__, tone);
+ dev_dbg(&state->i2c->dev, "%s(%d)\n", __func__, tone);
if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) {
err("Invalid tone=%d\n", tone);
cmd.arg[0] = 0x00;
cmd.arg[1] = 0x00;
cmd.arg[2] = 0x00;
- cmd.arg[3] = (tone == SEC_TONE_ON)?0x01:0x00;
+ cmd.arg[3] = (tone == SEC_TONE_ON) ? 0x01 : 0x00;
return cx24120_message_send(state, &cmd);
}
-
static int cx24120_set_voltage(struct dvb_frontend *fe,
- fe_sec_voltage_t voltage)
+ fe_sec_voltage_t voltage)
{
struct cx24120_state *state = fe->demodulator_priv;
struct cx24120_cmd cmd;
- dev_dbg(&state->i2c->dev, "%s(%d)\n",
- __func__, voltage);
+ dev_dbg(&state->i2c->dev, "%s(%d)\n", __func__, voltage);
cmd.id = CMD_SETVOLTAGE;
cmd.len = 2;
cmd.arg[0] = 0x00;
- cmd.arg[1] = (voltage == SEC_VOLTAGE_18)?0x01:0x00;
+ cmd.arg[1] = (voltage == SEC_VOLTAGE_18) ? 0x01 : 0x00;
return cx24120_message_send(state, &cmd);
}
-
static int cx24120_send_diseqc_msg(struct dvb_frontend *fe,
- struct dvb_diseqc_master_cmd *d)
+ struct dvb_diseqc_master_cmd *d)
{
struct cx24120_state *state = fe->demodulator_priv;
struct cx24120_cmd cmd;
return -ETIMEDOUT;
}
+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 sig;
+
+ dev_dbg(&state->i2c->dev, "%s()\n", __func__);
+
+ /* signal strength */
+ 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 = sig;
+ } else {
+ c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+ }
+
+ /* FIXME: add CNR */
+
+ /* FIXME: add UCB/BER */
+}
+
+static void cx24120_set_clock_ratios(struct dvb_frontend *fe);
/* Read current tuning status */
static int cx24120_read_status(struct dvb_frontend *fe, fe_status_t *status)
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
+ */
+
+ state->fe_status = *status;
+ cx24120_get_stats(state);
+
+ /* Set the clock once tuned in */
+ if (state->need_clock_set && *status & FE_HAS_LOCK) {
+ /* Set clock ratios */
+ cx24120_set_clock_ratios(fe);
+
+ /* Old driver would do a msleep(200) here */
+
+ /* Renable mpeg output */
+ if (!state->mpeg_enabled)
+ cx24120_msg_mpeg_output_global_config(state, 1);
+
+ state->need_clock_set = 0;
+ }
return 0;
}
-
-/* FEC & modulation lookup table
+/*
+ * FEC & modulation lookup table
* Used for decoding the REG_FECMODE register
* once tuned in.
*/
{ SYS_DVBS2, PSK_8, FEC_9_10, 0x11 },
};
-
/* Retrieve current fec, modulation & pilot values */
static int cx24120_get_fec(struct dvb_frontend *fe)
{
struct cx24120_state *state = fe->demodulator_priv;
int idx;
int ret;
- int GettedFEC;
+ int fec;
dev_dbg(&state->i2c->dev, "%s()\n", __func__);
ret = cx24120_readreg(state, CX24120_REG_FECMODE);
- GettedFEC = ret & 0x3f; /* Lower 6 bits */
+ fec = ret & 0x3f; /* Lower 6 bits */
- dev_dbg(&state->i2c->dev, "%s: Get FEC: %d\n", __func__, GettedFEC);
+ dev_dbg(&state->i2c->dev, "%s: Get FEC: %d\n", __func__, fec);
for (idx = 0; idx < ARRAY_SIZE(modfec_lookup_table); idx++) {
if (modfec_lookup_table[idx].delsys != state->dcur.delsys)
continue;
- if (modfec_lookup_table[idx].val != GettedFEC)
+ if (modfec_lookup_table[idx].val != fec)
continue;
break; /* found */
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;
{ SYS_DVBS, PILOT_OFF, QPSK, FEC_7_8, 1068144, 610368, 448 },
};
-
/* Set clock ratio from lookup table */
static void cx24120_set_clock_ratios(struct dvb_frontend *fe)
{
cx24120_message_send(state, &cmd);
}
-
/* Set inversion value */
static int cx24120_set_inversion(struct cx24120_state *state,
- fe_spectral_inversion_t inversion)
+ fe_spectral_inversion_t inversion)
{
- dev_dbg(&state->i2c->dev, "%s(%d)\n",
- __func__, inversion);
+ dev_dbg(&state->i2c->dev, "%s(%d)\n", __func__, inversion);
switch (inversion) {
case INVERSION_OFF:
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 },
};
/* Set fec_val & fec_mask values from delsys, modulation & fec */
-static int cx24120_set_fec(struct cx24120_state *state,
- fe_modulation_t mod, fe_code_rate_t fec)
+static int cx24120_set_fec(struct cx24120_state *state, fe_modulation_t mod,
+ fe_code_rate_t fec)
{
int idx;
- dev_dbg(&state->i2c->dev,
- "%s(0x%02x,0x%02x)\n", __func__, mod, fec);
+ dev_dbg(&state->i2c->dev, "%s(0x%02x,0x%02x)\n", __func__, mod, fec);
state->dnxt.fec = fec;
return 0;
}
-
/* Set pilot */
-static int cx24120_set_pilot(struct cx24120_state *state,
- fe_pilot_t pilot) {
-
+static int cx24120_set_pilot(struct cx24120_state *state, fe_pilot_t pilot)
+{
dev_dbg(&state->i2c->dev, "%s(%d)\n", __func__, pilot);
/* Pilot only valid in DVBS2 */
return 0;
}
-
/* Overwrite the current tuning params, we are about to tune */
static void cx24120_clone_params(struct dvb_frontend *fe)
{
state->dcur = state->dnxt;
}
-
-/* Table of time to tune for different symrates */
-static struct cx24120_symrate_delay {
- fe_delivery_system_t delsys;
- u32 symrate; /* Check for >= this symrate */
- u32 delay; /* Timeout in ms */
-} symrates_delay_table[] = {
- { SYS_DVBS, 10000000, 400 },
- { SYS_DVBS, 8000000, 2000 },
- { SYS_DVBS, 6000000, 5000 },
- { SYS_DVBS, 3000000, 10000 },
- { SYS_DVBS, 0, 15000 },
- { SYS_DVBS2, 10000000, 600 }, /* DVBS2 needs a little longer */
- { SYS_DVBS2, 8000000, 2000 }, /* (so these might need bumping too) */
- { SYS_DVBS2, 6000000, 5000 },
- { SYS_DVBS2, 3000000, 10000 },
- { SYS_DVBS2, 0, 15000 },
-};
-
-
static int cx24120_set_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct cx24120_state *state = fe->demodulator_priv;
struct cx24120_cmd cmd;
int ret;
- int delay_cnt, sd_idx = 0;
- fe_status_t status;
switch (c->delivery_system) {
case SYS_DVBS2:
"%s: Inversion = %d (val = 0x%02x)\n", __func__,
state->dcur.inversion, state->dcur.inversion_val);
+ /* Flag that clock needs to be set after tune */
+ state->need_clock_set = 1;
+
/* Tune in */
cmd.id = CMD_TUNEREQUEST;
cmd.len = 15;
cmd.arg[1] = (state->dcur.frequency & 0xff0000) >> 16;
cmd.arg[2] = (state->dcur.frequency & 0x00ff00) >> 8;
cmd.arg[3] = (state->dcur.frequency & 0x0000ff);
- cmd.arg[4] = ((state->dcur.symbol_rate/1000) & 0xff00) >> 8;
- cmd.arg[5] = ((state->dcur.symbol_rate/1000) & 0x00ff);
+ cmd.arg[4] = ((state->dcur.symbol_rate / 1000) & 0xff00) >> 8;
+ cmd.arg[5] = ((state->dcur.symbol_rate / 1000) & 0x00ff);
cmd.arg[6] = state->dcur.inversion;
cmd.arg[7] = state->dcur.fec_val | state->dcur.pilot_val;
cmd.arg[8] = CX24120_SEARCH_RANGE_KHZ >> 8;
ret |= state->dcur.ratediv;
ret = cx24120_writereg(state, CX24120_REG_RATEDIV, ret);
- /* Default time to tune */
- delay_cnt = 500;
-
- /* Establish time to tune from symrates_delay_table */
- for (sd_idx = 0; sd_idx < ARRAY_SIZE(symrates_delay_table); sd_idx++) {
- if (state->dcur.delsys != symrates_delay_table[sd_idx].delsys)
- continue;
- if (c->symbol_rate < symrates_delay_table[sd_idx].symrate)
- continue;
-
- /* found */
- delay_cnt = symrates_delay_table[sd_idx].delay;
- dev_dbg(&state->i2c->dev, "%s: Found symrate delay = %d\n",
- __func__, delay_cnt);
- break;
- }
-
- /* Wait for tuning */
- while (delay_cnt >= 0) {
- cx24120_read_status(fe, &status);
- if (status & FE_HAS_LOCK)
- goto tuned;
- msleep(20);
- delay_cnt -= 20;
- }
-
- /* Fail to tune */
- dev_dbg(&state->i2c->dev, "%s: Tuning failed\n", __func__);
-
- return -EINVAL;
-
-tuned:
- dev_dbg(&state->i2c->dev, "%s: Tuning successful\n", __func__);
-
- /* Set clock ratios */
- cx24120_set_clock_ratios(fe);
-
- /* Old driver would do a msleep(200) here */
-
- /* Renable mpeg output */
- if (!state->mpeg_enabled)
- cx24120_msg_mpeg_output_global_config(state, 1);
-
return 0;
}
-
-/* Calculate vco from config */
-static u64 cx24120_calculate_vco(struct cx24120_state *state)
+/* Set vco from config */
+static int cx24120_set_vco(struct cx24120_state *state)
{
- u32 vco;
- u64 inv_vco, res, xxyyzz;
+ struct cx24120_cmd cmd;
+ u32 nxtal_khz, vco;
+ u64 inv_vco;
u32 xtal_khz = state->config->xtal_khz;
- xxyyzz = 0x400000000ULL;
- vco = xtal_khz * 10 * 4;
- inv_vco = xxyyzz / vco;
- res = xxyyzz % vco;
-
- if (inv_vco > xtal_khz * 10 * 2)
- ++inv_vco;
+ nxtal_khz = xtal_khz * 4;
+ vco = nxtal_khz * 10;
+ inv_vco = DIV_ROUND_CLOSEST_ULL(0x400000000ULL, vco);
dev_dbg(&state->i2c->dev,
- "%s: xtal=%d, vco=%d, inv_vco=%lld, res=%lld\n",
- __func__, xtal_khz, vco, inv_vco, res);
+ "%s: xtal=%d, vco=%d, inv_vco=%lld\n",
+ __func__, xtal_khz, vco, inv_vco);
- return inv_vco;
-}
+ cmd.id = CMD_VCO_SET;
+ cmd.len = 12;
+ cmd.arg[0] = (vco >> 16) & 0xff;
+ cmd.arg[1] = (vco >> 8) & 0xff;
+ cmd.arg[2] = vco & 0xff;
+ cmd.arg[3] = (inv_vco >> 8) & 0xff;
+ cmd.arg[4] = (inv_vco) & 0xff;
+ cmd.arg[5] = 0x03;
+ cmd.arg[6] = (nxtal_khz >> 8) & 0xff;
+ cmd.arg[7] = nxtal_khz & 0xff;
+ cmd.arg[8] = 0x06;
+ cmd.arg[9] = 0x03;
+ cmd.arg[10] = (xtal_khz >> 16) & 0xff;
+ cmd.arg[11] = xtal_khz & 0xff;
+ return cx24120_message_send(state, &cmd);
+}
int cx24120_init(struct dvb_frontend *fe)
{
const struct firmware *fw;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct cx24120_state *state = fe->demodulator_priv;
struct cx24120_cmd cmd;
u8 ret, ret_EA, reg1;
- u64 inv_vco;
int reset_result;
int i;
ret = state->config->request_firmware(fe, &fw, CX24120_FIRMWARE);
if (ret) {
- err("Could not load firmware (%s): %d\n",
- CX24120_FIRMWARE, ret);
+ err("Could not load firmware (%s): %d\n", CX24120_FIRMWARE,
+ ret);
return ret;
}
ret = cx24120_writereg(state, 0xf7, 0x81);
ret = cx24120_writereg(state, 0xf8, 0x00);
ret = cx24120_writereg(state, 0xf9, 0x00);
- ret = cx24120_writeregN(state, 0xfa, fw->data, (fw->size - 1), 0x00);
+ ret = cx24120_writeregs(state, 0xfa, fw->data, (fw->size - 1), 0x00);
ret = cx24120_writereg(state, 0xf7, 0xc0);
ret = cx24120_writereg(state, 0xe0, 0x00);
ret = (fw->size - 2) & 0x00ff;
if (reset_result != 0)
return reset_result;
-
/* Start tuner */
cmd.id = CMD_START_TUNER;
cmd.len = 3;
}
/* Set VCO */
- inv_vco = cx24120_calculate_vco(state);
-
- cmd.id = CMD_VCO_SET;
- cmd.len = 12;
- cmd.arg[0] = 0x06;
- cmd.arg[1] = 0x2b;
- cmd.arg[2] = 0xd8;
- cmd.arg[3] = (inv_vco >> 8) & 0xff;
- cmd.arg[4] = (inv_vco) & 0xff;
- cmd.arg[5] = 0x03;
- cmd.arg[6] = 0x9d;
- cmd.arg[7] = 0xfc;
- cmd.arg[8] = 0x06;
- cmd.arg[9] = 0x03;
- cmd.arg[10] = 0x27;
- cmd.arg[11] = 0x7f;
-
- if (cx24120_message_send(state, &cmd)) {
+ ret = cx24120_set_vco(state);
+ if (ret != 0) {
err("Error set VCO! :(\n");
- return -EREMOTEIO;
+ return ret;
}
-
/* set bandwidth */
cmd.id = CMD_BANDWIDTH;
cmd.len = 12;
}
dev_dbg(&state->i2c->dev, "%s: Tuner initialised correctly.\n",
- __func__);
-
+ __func__);
/* Initialise mpeg outputs */
ret = cx24120_writereg(state, 0xeb, 0x0a);
return -EREMOTEIO;
}
-
/* ???? */
cmd.id = CMD_TUNER_INIT;
cmd.len = 3;
return -EREMOTEIO;
}
-
/* Firmware CMD 35: Get firmware version */
cmd.id = CMD_FWVERSION;
cmd.len = 1;
}
info("FW version %i.%i.%i.%i\n", vers[0], vers[1], vers[2], vers[3]);
+ /* init stats here in order signal app which stats are supported */
+ c->strength.len = 1;
+ c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+
state->cold_init = 1;
return 0;
}
-
static int cx24120_tune(struct dvb_frontend *fe, bool re_tune,
- unsigned int mode_flags, unsigned int *delay, fe_status_t *status)
+ unsigned int mode_flags, unsigned int *delay,
+ fe_status_t *status)
{
struct cx24120_state *state = fe->demodulator_priv;
int ret;
return cx24120_read_status(fe, status);
}
-
-
static int cx24120_get_algo(struct dvb_frontend *fe)
{
return DVBFE_ALGO_HW;
}
-
static int cx24120_sleep(struct dvb_frontend *fe)
{
return 0;
}
-
-/*static int cx24120_wakeup(struct dvb_frontend *fe)
- * {
- * return 0;
- * }
-*/
-
-
static int cx24120_get_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
dev_dbg(&state->i2c->dev, "%s()", __func__);
/* don't return empty data if we're not tuned in */
- if (state->mpeg_enabled)
+ if ((state->fe_status & FE_HAS_LOCK) == 0)
return 0;
/* Get frequency */
return 0;
}
-
static void cx24120_release(struct dvb_frontend *fe)
{
struct cx24120_state *state = fe->demodulator_priv;
kfree(state);
}
-
static int cx24120_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{
struct cx24120_state *state = fe->demodulator_priv;
*ucblocks = (cx24120_readreg(state, CX24120_REG_UCB_H) << 8) |
cx24120_readreg(state, CX24120_REG_UCB_L);
- dev_dbg(&state->i2c->dev, "%s: Blocks = %d\n",
- __func__, *ucblocks);
+ dev_dbg(&state->i2c->dev, "%s: Blocks = %d\n", __func__, *ucblocks);
return 0;
}
-
static struct dvb_frontend_ops cx24120_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 },
.info = {