struct af9013_state {
struct i2c_adapter *i2c;
struct dvb_frontend fe;
- struct af9013_config config;
+ u8 i2c_addr;
+ u32 clk;
+ u8 tuner;
+ u32 if_frequency;
+ u8 ts_mode;
+ bool spec_inv;
+ u8 api_version[4];
+ u8 gpio[4];
/* tuner/demod RF and IF AGC limits used for signal strength calc */
u8 signal_strength_en, rf_50, rf_80, if_50, if_80;
u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[1] = {
{
- .addr = priv->config.i2c_addr,
+ .addr = priv->i2c_addr,
.flags = 0,
.len = 3 + len,
.buf = buf,
u8 buf[3];
struct i2c_msg msg[2] = {
{
- .addr = priv->config.i2c_addr,
+ .addr = priv->i2c_addr,
.flags = 0,
.len = 3,
.buf = buf,
}, {
- .addr = priv->config.i2c_addr,
+ .addr = priv->i2c_addr,
.flags = I2C_M_RD,
.len = len,
.buf = val,
int ret, i;
u8 mbox = (0 << 7)|(0 << 6)|(1 << 1)|(1 << 0);
- if ((priv->config.ts_mode == AF9013_TS_USB) &&
+ if ((priv->ts_mode == AF9013_TS_USB) &&
((reg & 0xff00) != 0xff00) && ((reg & 0xff00) != 0xae00)) {
mbox |= ((len - 1) << 2);
ret = af9013_wr_regs_i2c(priv, mbox, reg, val, len);
int ret, i;
u8 mbox = (0 << 7)|(0 << 6)|(1 << 1)|(0 << 0);
- if ((priv->config.ts_mode == AF9013_TS_USB) &&
+ if ((priv->ts_mode == AF9013_TS_USB) &&
((reg & 0xff00) != 0xff00) && ((reg & 0xff00) != 0xae00)) {
mbox |= ((len - 1) << 2);
ret = af9013_rd_regs_i2c(priv, mbox, reg, val, len);
/* program CFOE coefficients */
if (c->bandwidth_hz != state->bandwidth_hz) {
for (i = 0; i < ARRAY_SIZE(coeff_lut); i++) {
- if (coeff_lut[i].clock == state->config.clock &&
+ if (coeff_lut[i].clock == state->clk &&
coeff_lut[i].bandwidth_hz == c->bandwidth_hz) {
break;
}
if (fe->ops.tuner_ops.get_if_frequency)
fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
else
- if_frequency = state->config.if_frequency;
+ if_frequency = state->if_frequency;
dev_dbg(&state->i2c->dev, "%s: if_frequency=%d\n",
__func__, if_frequency);
sampling_freq = if_frequency;
- while (sampling_freq > (state->config.clock / 2))
- sampling_freq -= state->config.clock;
+ while (sampling_freq > (state->clk / 2))
+ sampling_freq -= state->clk;
if (sampling_freq < 0) {
sampling_freq *= -1;
- spec_inv = state->config.spec_inv;
+ spec_inv = state->spec_inv;
} else {
- spec_inv = !state->config.spec_inv;
+ spec_inv = !state->spec_inv;
}
- freq_cw = af9013_div(state, sampling_freq, state->config.clock,
+ freq_cw = af9013_div(state, sampling_freq, state->clk,
23);
if (spec_inv)
goto err;
/* write API version to firmware */
- ret = af9013_wr_regs(state, 0x9bf2, state->config.api_version, 4);
+ ret = af9013_wr_regs(state, 0x9bf2, state->api_version, 4);
if (ret)
goto err;
/* program ADC control */
- switch (state->config.clock) {
+ switch (state->clk) {
case 28800000: /* 28.800 MHz */
tmp = 0;
break;
return -EINVAL;
}
- adc_cw = af9013_div(state, state->config.clock, 1000000ul, 19);
+ adc_cw = af9013_div(state, state->clk, 1000000ul, 19);
buf[0] = (adc_cw >> 0) & 0xff;
buf[1] = (adc_cw >> 8) & 0xff;
buf[2] = (adc_cw >> 16) & 0xff;
goto err;
/* settings for mp2if */
- if (state->config.ts_mode == AF9013_TS_USB) {
+ if (state->ts_mode == AF9013_TS_USB) {
/* AF9015 split PSB to 1.5k + 0.5k */
ret = af9013_wr_reg_bits(state, 0xd50b, 2, 1, 1);
if (ret)
/* load tuner specific settings */
dev_dbg(&state->i2c->dev, "%s: load tuner specific settings\n",
__func__);
- switch (state->config.tuner) {
+ switch (state->tuner) {
case AF9013_TUNER_MXL5003D:
len = ARRAY_SIZE(tuner_init_mxl5003d);
init = tuner_init_mxl5003d;
}
/* TS mode */
- ret = af9013_wr_reg_bits(state, 0xd500, 1, 2, state->config.ts_mode);
+ ret = af9013_wr_reg_bits(state, 0xd500, 1, 2, state->ts_mode);
if (ret)
goto err;
if (state->i2c_gate_state == enable)
return 0;
- if (state->config.ts_mode == AF9013_TS_USB)
+ if (state->ts_mode == AF9013_TS_USB)
ret = af9013_wr_reg_bits(state, 0xd417, 3, 1, enable);
else
ret = af9013_wr_reg_bits(state, 0xd607, 2, 1, enable);
/* setup the state */
state->i2c = i2c;
- memcpy(&state->config, config, sizeof(struct af9013_config));
+ state->i2c_addr = config->i2c_addr;
+ state->clk = config->clock;
+ state->tuner = config->tuner;
+ state->if_frequency = config->if_frequency;
+ state->ts_mode = config->ts_mode;
+ state->spec_inv = config->spec_inv;
+ memcpy(&state->api_version, config->api_version, sizeof(state->api_version));
+ memcpy(&state->gpio, config->gpio, sizeof(state->gpio));
/* download firmware */
- if (state->config.ts_mode != AF9013_TS_USB) {
+ if (state->ts_mode != AF9013_TS_USB) {
ret = af9013_download_firmware(state);
if (ret)
goto err;
KBUILD_MODNAME, buf[0], buf[1], buf[2], buf[3]);
/* set GPIOs */
- for (i = 0; i < sizeof(state->config.gpio); i++) {
- ret = af9013_set_gpio(state, i, state->config.gpio[i]);
+ for (i = 0; i < sizeof(state->gpio); i++) {
+ ret = af9013_set_gpio(state, i, state->gpio[i]);
if (ret)
goto err;
}