static void mxl111sf_demod_release(struct dvb_frontend *fe) { struct mxl111sf_demod_state *state = fe->demodulator_priv; mxl_dbg("()"); kfree(state); fe->demodulator_priv = NULL; }
static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe) { struct dtv_frontend_properties *p = &fe->dtv_property_cache; struct mxl111sf_demod_state *state = fe->demodulator_priv; mxl_dbg("()"); #if 0 p->inversion = /* FIXME */ ? INVERSION_ON : INVERSION_OFF; #endif if (fe->ops.tuner_ops.get_bandwidth) fe->ops.tuner_ops.get_bandwidth(fe, &p->bandwidth_hz); if (fe->ops.tuner_ops.get_frequency) fe->ops.tuner_ops.get_frequency(fe, &p->frequency); mxl1x1sf_demod_get_tps_code_rate(state, &p->code_rate_HP); mxl1x1sf_demod_get_tps_code_rate(state, &p->code_rate_LP); mxl1x1sf_demod_get_tps_modulation(state, &p->modulation); mxl1x1sf_demod_get_tps_guard_fft_mode(state, &p->transmission_mode); mxl1x1sf_demod_get_tps_guard_interval(state, &p->guard_interval); mxl1x1sf_demod_get_tps_hierarchy(state, &p->hierarchy); return 0; }
static int mxl111sf_demod_set_frontend(struct dvb_frontend *fe) { struct mxl111sf_demod_state *state = fe->demodulator_priv; int ret = 0; struct mxl111sf_reg_ctrl_info phy_pll_patch[] = { {0x00, 0xff, 0x01}, /* change page to 1 */ {0x40, 0xff, 0x05}, {0x40, 0xff, 0x01}, {0x41, 0xff, 0xca}, {0x41, 0xff, 0xc0}, {0x00, 0xff, 0x00}, /* change page to 0 */ {0, 0, 0} }; mxl_dbg("()"); if (fe->ops.tuner_ops.set_params) { ret = fe->ops.tuner_ops.set_params(fe); if (mxl_fail(ret)) goto fail; msleep(50); } ret = mxl111sf_demod_program_regs(state, phy_pll_patch); mxl_fail(ret); msleep(50); ret = mxl1x1sf_demod_reset_irq_status(state); mxl_fail(ret); msleep(100); fail: return ret; }
static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct mxl111sf_demod_state *state = fe->demodulator_priv; mxl_dbg("()"); #if 0 p->inversion = /* FIXME */ ? INVERSION_ON : INVERSION_OFF; #endif if (fe->ops.tuner_ops.get_bandwidth) fe->ops.tuner_ops.get_bandwidth(fe, &p->u.ofdm.bandwidth); if (fe->ops.tuner_ops.get_frequency) fe->ops.tuner_ops.get_frequency(fe, &p->frequency); mxl1x1sf_demod_get_tps_code_rate(state, &p->u.ofdm.code_rate_HP); mxl1x1sf_demod_get_tps_code_rate(state, &p->u.ofdm.code_rate_LP); mxl1x1sf_demod_get_tps_constellation(state, &p->u.ofdm.constellation); mxl1x1sf_demod_get_tps_guard_fft_mode(state, &p->u.ofdm.transmission_mode); mxl1x1sf_demod_get_tps_guard_interval(state, &p->u.ofdm.guard_interval); mxl1x1sf_demod_get_tps_hierarchy(state, &p->u.ofdm.hierarchy_information); return 0; }
static int mxl111sf_tuner_release(struct dvb_frontend *fe) { struct mxl111sf_tuner_state *state = fe->tuner_priv; mxl_dbg("()"); kfree(state); fe->tuner_priv = NULL; return 0; }
static int mxl111sf_tuner_set_params(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; u32 delsys = c->delivery_system; struct mxl111sf_tuner_state *state = fe->tuner_priv; int ret; u8 bw; mxl_dbg("()"); switch (delsys) { case SYS_ATSC: case SYS_ATSCMH: bw = 0; /* ATSC */ break; case SYS_DVBC_ANNEX_B: bw = 1; /* US CABLE */ break; case SYS_DVBT: switch (c->bandwidth_hz) { case 6000000: bw = 6; break; case 7000000: bw = 7; break; case 8000000: bw = 8; break; default: err("%s: bandwidth not set!", __func__); return -EINVAL; } break; default: err("%s: modulation type not supported!", __func__); return -EINVAL; } ret = mxl1x1sf_tune_rf(fe, c->frequency, bw); if (mxl_fail(ret)) goto fail; state->frequency = c->frequency; state->bandwidth = c->bandwidth_hz; fail: return ret; }
static int mxl1x1sf_tune_rf(struct dvb_frontend *fe, u32 freq, u8 bw) { struct mxl111sf_tuner_state *state = fe->tuner_priv; static struct mxl111sf_reg_ctrl_info *reg_ctrl_array; int ret; u8 mxl_mode; mxl_dbg("(freq = %d, bw = 0x%x)", freq, bw); /* stop tune */ ret = mxl111sf_tuner_write_reg(state, START_TUNE_REG, 0); if (mxl_fail(ret)) goto fail; /* check device mode */ ret = mxl111sf_tuner_read_reg(state, MXL_MODE_REG, &mxl_mode); if (mxl_fail(ret)) goto fail; /* Fill out registers for channel tune */ reg_ctrl_array = mxl111sf_calc_phy_tune_regs(freq, bw); if (!reg_ctrl_array) return -EINVAL; ret = mxl111sf_tuner_program_regs(state, reg_ctrl_array); if (mxl_fail(ret)) goto fail; if ((mxl_mode & MXL_DEV_MODE_MASK) == MXL_TUNER_MODE) { /* IF tuner mode only */ mxl1x1sf_tuner_top_master_ctrl(state, 0); mxl1x1sf_tuner_top_master_ctrl(state, 1); mxl1x1sf_tuner_set_if_output_freq(state); } ret = mxl111sf_tuner_write_reg(state, START_TUNE_REG, 1); if (mxl_fail(ret)) goto fail; if (state->cfg->ant_hunt) state->cfg->ant_hunt(fe); fail: return ret; }
struct dvb_frontend *mxl111sf_demod_attach(struct mxl111sf_state *mxl_state, const struct mxl111sf_demod_config *cfg) { struct mxl111sf_demod_state *state = NULL; mxl_dbg("()"); state = kzalloc(sizeof(struct mxl111sf_demod_state), GFP_KERNEL); if (state == NULL) return NULL; state->mxl_state = mxl_state; state->cfg = cfg; memcpy(&state->fe.ops, &mxl111sf_demod_ops, sizeof(struct dvb_frontend_ops)); state->fe.demodulator_priv = state; return &state->fe; }
struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe, struct mxl111sf_state *mxl_state, struct mxl111sf_tuner_config *cfg) { struct mxl111sf_tuner_state *state = NULL; mxl_dbg("()"); state = kzalloc(sizeof(struct mxl111sf_tuner_state), GFP_KERNEL); if (state == NULL) return NULL; state->mxl_state = mxl_state; state->cfg = cfg; memcpy(&fe->ops.tuner_ops, &mxl111sf_tuner_tuner_ops, sizeof(struct dvb_tuner_ops)); fe->tuner_priv = state; return fe; }
static int mxl1x1sf_tuner_set_if_output_freq(struct mxl111sf_tuner_state *state) { int ret; u8 ctrl; #if 0 u16 iffcw; u32 if_freq; #endif mxl_dbg("(IF polarity = %d, IF freq = 0x%02x)", state->cfg->invert_spectrum, state->cfg->if_freq); /* set IF polarity */ ctrl = state->cfg->invert_spectrum; ctrl |= state->cfg->if_freq; ret = mxl111sf_tuner_write_reg(state, V6_TUNER_IF_SEL_REG, ctrl); if (mxl_fail(ret)) goto fail; #if 0 if_freq /= 1000000; /* do round */ if_freq += 0.5; if (MXL_IF_LO == state->cfg->if_freq) { ctrl = 0x08; iffcw = (u16)(if_freq / (108 * 4096)); } else if (MXL_IF_HI == state->cfg->if_freq) { ctrl = 0x08; iffcw = (u16)(if_freq / (216 * 4096)); } else { ctrl = 0; iffcw = 0; } ctrl |= (iffcw >> 8); #endif ret = mxl111sf_tuner_read_reg(state, V6_TUNER_IF_FCW_BYP_REG, &ctrl); if (mxl_fail(ret)) goto fail; ctrl &= 0xf0; ctrl |= 0x90; ret = mxl111sf_tuner_write_reg(state, V6_TUNER_IF_FCW_BYP_REG, ctrl); if (mxl_fail(ret)) goto fail; #if 0 ctrl = iffcw & 0x00ff; #endif ret = mxl111sf_tuner_write_reg(state, V6_TUNER_IF_FCW_REG, ctrl); if (mxl_fail(ret)) goto fail; state->if_freq = state->cfg->if_freq; fail: return ret; }