26 static int mxl111sf_tuner_debug;
30 #define mxl_dbg(fmt, arg...) \
31 if (mxl111sf_tuner_debug) \
32 mxl_printk(KERN_DEBUG, fmt, ##arg)
52 return (state->
cfg->read_reg) ?
60 return (state->
cfg->write_reg) ?
68 return (state->
cfg->program_regs) ?
69 state->
cfg->program_regs(state->
mxl_state, ctrl_reg_info) :
76 return (state->
cfg->top_master_ctrl) ?
116 err(
"%s: invalid bandwidth setting!", __func__);
129 mxl_phy_tune_rf[0].
data = filt_bw;
132 mxl_phy_tune_rf[1].
data = (freq & 0xff);
133 mxl_phy_tune_rf[2].
data = (freq >> 8) & 0xff;
136 return mxl_phy_tune_rf;
147 mxl_dbg(
"(IF polarity = %d, IF freq = 0x%02x)",
148 state->
cfg->invert_spectrum, state->
cfg->if_freq);
151 ctrl = state->
cfg->invert_spectrum;
153 ctrl |= state->
cfg->if_freq;
165 if (MXL_IF_LO == state->
cfg->if_freq) {
167 iffcw = (
u16)(if_freq / (108 * 4096));
168 }
else if (MXL_IF_HI == state->
cfg->if_freq) {
170 iffcw = (
u16)(if_freq / (216 * 4096));
176 ctrl |= (iffcw >> 8);
190 ctrl = iffcw & 0x00ff;
208 mxl_dbg(
"(freq = %d, bw = 0x%x)", freq, bw);
216 ret = mxl111sf_tuner_read_reg(state,
MXL_MODE_REG, &mxl_mode);
221 reg_ctrl_array = mxl111sf_calc_phy_tune_regs(freq, bw);
225 ret = mxl111sf_tuner_program_regs(state, reg_ctrl_array);
231 mxl1x1sf_tuner_top_master_ctrl(state, 0);
232 mxl1x1sf_tuner_top_master_ctrl(state, 1);
233 mxl1x1sf_tuner_set_if_output_freq(state);
240 if (state->
cfg->ant_hunt)
241 state->
cfg->ant_hunt(fe);
260 *ref_synth_lock = ((data & 0x03) == 0x03) ? 1 : 0;
261 *rf_synth_lock = ((data & 0x0c) == 0x0c) ? 1 : 0;
277 static int mxl111sf_tuner_set_params(
struct dvb_frontend *fe)
307 err(
"%s: bandwidth not set!", __func__);
312 err(
"%s: modulation type not supported!", __func__);
315 ret = mxl1x1sf_tune_rf(fe, c->
frequency, bw);
338 static int mxl111sf_tuner_sleep(
struct dvb_frontend *fe)
354 int rf_locked, ref_locked,
ret;
358 ret = mxl1x1sf_tuner_get_lock_status(state, &rf_locked, &ref_locked);
361 mxl_info(
"%s%s", rf_locked ?
"rf locked " :
"",
362 ref_locked ?
"ref locked" :
"");
364 if ((rf_locked) || (ref_locked))
370 static int mxl111sf_get_rf_strength(
struct dvb_frontend *fe,
u16 *strength)
378 ret = mxl111sf_tuner_write_reg(state, 0x00, 0x02);
388 *strength = val1 | ((val2 & 0x07) << 8);
390 ret = mxl111sf_tuner_write_reg(state, 0x00, 0x00);
412 static int mxl111sf_tuner_get_if_frequency(
struct dvb_frontend *fe,
421 *frequency = 4000000;
424 *frequency = 4500000;
427 *frequency = 4570000;
430 *frequency = 5000000;
433 *frequency = 5380000;
436 *frequency = 6000000;
439 *frequency = 6280000;
442 *frequency = 7200000;
445 *frequency = 35250000;
448 *frequency = 36000000;
451 *frequency = 36150000;
454 *frequency = 44000000;
460 static int mxl111sf_tuner_release(
struct dvb_frontend *fe)
473 .name =
"MaxLinear MxL111SF",
481 .init = mxl111sf_tuner_init,
482 .sleep = mxl111sf_tuner_sleep,
484 .set_params = mxl111sf_tuner_set_params,
485 .get_status = mxl111sf_tuner_get_status,
486 .get_rf_strength = mxl111sf_get_rf_strength,
487 .get_frequency = mxl111sf_tuner_get_frequency,
488 .get_bandwidth = mxl111sf_tuner_get_bandwidth,
489 .get_if_frequency = mxl111sf_tuner_get_if_frequency,
490 .release = mxl111sf_tuner_release,
508 memcpy(&fe->
ops.tuner_ops, &mxl111sf_tuner_tuner_ops,