25 static int mxl111sf_demod_debug;
29 #define mxl_dbg(fmt, arg...) \
30 if (mxl111sf_demod_debug) \
31 mxl_printk(KERN_DEBUG, fmt, ##arg)
48 return (state->
cfg->read_reg) ?
56 return (state->
cfg->write_reg) ?
65 return (state->
cfg->program_regs) ?
66 state->
cfg->program_regs(state->
mxl_state, ctrl_reg_info) :
159 int ret = mxl111sf_demod_read_reg(state,
V6_CP_TPS_REG, &val);
282 return mxl111sf_demod_write_reg(state, 0x0e, 0xff);
287 static int mxl111sf_demod_set_frontend(
struct dvb_frontend *fe)
304 if (fe->
ops.tuner_ops.set_params) {
305 ret = fe->
ops.tuner_ops.set_params(fe);
310 ret = mxl111sf_demod_program_regs(state, phy_pll_patch);
313 ret = mxl1x1sf_demod_reset_irq_status(state);
333 return mxl111sf_demod_program_regs(state, reset_per_count);
339 static int mxl111sf_demod_read_ucblocks(
struct dvb_frontend *fe,
u32 *ucblocks)
342 u32 fec_per_count, fec_per_scale;
363 fec_per_scale = 1 <<
val;
365 fec_per_count *= fec_per_scale;
367 *ucblocks = fec_per_count;
372 #ifdef MXL111SF_DEMOD_ENABLE_CALCULATIONS
378 #define CALCULATE_BER(avg_errors, count) \
379 ((u32)(avg_errors * 4)/(count*64*188*8))
380 #define CALCULATE_SNR(data) \
381 ((u32)((10 * (u32)data / 64) - 2.5))
383 #define CALCULATE_BER(avg_errors, count) 0
384 #define CALCULATE_SNR(data) 0
434 int ret = mxl111sf_demod_calc_snr(state, snr);
443 static int mxl111sf_demod_read_status(
struct dvb_frontend *fe,
447 int ret,
locked, cr_lock, sync_lock, fec_lock;
451 ret = mxl1x1sf_demod_get_rs_lock_status(state, &locked);
454 ret = mxl1x1sf_demod_get_tps_lock_status(state, &cr_lock);
457 ret = mxl1x1sf_demod_get_sync_lock_status(state, &sync_lock);
460 ret = mxl1x1sf_demod_get_fec_lock_status(state, &fec_lock);
473 if ((locked) && (cr_lock) && (sync_lock))
479 static int mxl111sf_demod_read_signal_strength(
struct dvb_frontend *fe,
480 u16 *signal_strength)
486 mxl111sf_demod_calc_snr(state, &snr);
487 mxl1x1sf_demod_get_tps_modulation(state, &modulation);
489 switch (modulation) {
491 *signal_strength = (snr >= 1300) ?
492 min(65535, snr * 44) : snr * 38;
495 *signal_strength = (snr >= 1500) ?
496 min(65535, snr * 38) : snr * 33;
499 *signal_strength = (snr >= 2000) ?
500 min(65535, snr * 29) : snr * 25;
503 *signal_strength = 0;
510 static int mxl111sf_demod_get_frontend(
struct dvb_frontend *fe)
519 if (fe->
ops.tuner_ops.get_bandwidth)
521 if (fe->
ops.tuner_ops.get_frequency)
523 mxl1x1sf_demod_get_tps_code_rate(state, &p->
code_rate_HP);
524 mxl1x1sf_demod_get_tps_code_rate(state, &p->
code_rate_LP);
525 mxl1x1sf_demod_get_tps_modulation(state, &p->
modulation);
526 mxl1x1sf_demod_get_tps_guard_fft_mode(state,
528 mxl1x1sf_demod_get_tps_guard_interval(state,
530 mxl1x1sf_demod_get_tps_hierarchy(state,
537 int mxl111sf_demod_get_tune_settings(
struct dvb_frontend *fe,
544 static void mxl111sf_demod_release(
struct dvb_frontend *fe)
555 .name =
"MaxLinear MxL111SF DVB-T demodulator",
556 .frequency_min = 177000000,
557 .frequency_max = 858000000,
558 .frequency_stepsize = 166666,
566 .release = mxl111sf_demod_release,
568 .init = mxl111sf_init,
569 .i2c_gate_ctrl = mxl111sf_i2c_gate_ctrl,
571 .set_frontend = mxl111sf_demod_set_frontend,
572 .get_frontend = mxl111sf_demod_get_frontend,
573 .get_tune_settings = mxl111sf_demod_get_tune_settings,
574 .read_status = mxl111sf_demod_read_status,
575 .read_signal_strength = mxl111sf_demod_read_signal_strength,
576 .read_ber = mxl111sf_demod_read_ber,
577 .read_snr = mxl111sf_demod_read_snr,
578 .read_ucblocks = mxl111sf_demod_read_ucblocks,
595 memcpy(&state->
fe.ops, &mxl111sf_demod_ops,
598 state->
fe.demodulator_priv =
state;