Lines Matching +full:signal +full:- +full:guard
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Support for Legend Silicon GB20600 (a.k.a DMB-TH) demodulator
7 * Copyright (C) 2007-2009 David T.L. Wong <davidtlwong@gmail.com>
35 MODULE_PARM_DESC(fake_signal_str, "fake signal strength for LGS8913."
36 "Signal strength calculation is slow.(default:on).");
46 msg.addr = priv->config->demod_address; in lgs8gxx_write_reg()
47 if (priv->config->prod != LGS8GXX_PROD_LGS8G75 && reg >= 0xC0) in lgs8gxx_write_reg()
53 ret = i2c_transfer(priv->i2c, &msg, 1); in lgs8gxx_write_reg()
59 return (ret != 1) ? -1 : 0; in lgs8gxx_write_reg()
74 dev_addr = priv->config->demod_address; in lgs8gxx_read_reg()
75 if (priv->config->prod != LGS8GXX_PROD_LGS8G75 && reg >= 0xC0) in lgs8gxx_read_reg()
79 ret = i2c_transfer(priv->i2c, msg, 2); in lgs8gxx_read_reg()
82 return -1; in lgs8gxx_read_reg()
120 const struct lgs8gxx_config *config = priv->config; in lgs8gxx_set_ad_mode()
126 ((config->ext_adc) ? 0x80 : 0x00) | in lgs8gxx_set_ad_mode()
127 ((config->if_neg_center) ? 0x04 : 0x00) | in lgs8gxx_set_ad_mode()
128 ((config->if_freq == 0) ? 0x08 : 0x00) | /* Baseband */ in lgs8gxx_set_ad_mode()
129 ((config->adc_signed) ? 0x02 : 0x00) | in lgs8gxx_set_ad_mode()
130 ((config->if_neg_edge) ? 0x01 : 0x00); in lgs8gxx_set_ad_mode()
132 if (config->ext_adc && in lgs8gxx_set_ad_mode()
133 (config->prod == LGS8GXX_PROD_LGS8G52)) { in lgs8gxx_set_ad_mode()
148 if_clk = priv->config->if_clk_freq; in lgs8gxx_set_if_freq()
163 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_set_if_freq()
185 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_get_afc_phase()
194 reg_addr--; in lgs8gxx_get_afc_phase()
198 val *= priv->config->if_clk_freq; in lgs8gxx_get_afc_phase()
207 u8 prod = priv->config->prod; in lgs8gxx_set_mode_auto()
245 if (priv->config->prod == LGS8GXX_PROD_LGS8G52) in lgs8gxx_set_mode_auto()
255 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_set_mode_manual()
281 /* turn off auto-detect; manual settings */ in lgs8gxx_set_mode_manual()
283 if (priv->config->prod == LGS8GXX_PROD_LGS8913) in lgs8gxx_set_mode_manual()
300 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_is_locked()
307 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_is_locked()
320 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_wait_ca_lock()
342 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_is_autodetect_finished()
371 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_autolock_gi()
408 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_auto_detect()
412 /* Guard Interval */ in lgs8gxx_auto_detect()
445 if (priv->config->prod != LGS8GXX_PROD_LGS8G75) { in lgs8gxx_auto_detect()
462 err = -1; in lgs8gxx_auto_detect()
482 if (priv->config->prod == LGS8GXX_PROD_LGS8913) { in lgs8gxx_auto_lock()
489 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_auto_lock()
497 if (priv->config->prod == LGS8GXX_PROD_LGS8913) in lgs8gxx_auto_lock()
507 priv->curr_gi = 945; break; in lgs8gxx_auto_lock()
509 priv->curr_gi = 595; break; in lgs8gxx_auto_lock()
511 priv->curr_gi = 420; break; in lgs8gxx_auto_lock()
513 priv->curr_gi = 945; break; in lgs8gxx_auto_lock()
523 reg_addr = (priv->config->prod == LGS8GXX_PROD_LGS8G75) ? 0x30 : 0xC2; in lgs8gxx_set_mpeg_mode()
540 /* A/D input peak-to-peak voltage range */
546 if (priv->config->prod != LGS8GXX_PROD_LGS8G75) in lgs8g75_set_adc_vpp()
583 rc = request_firmware(&fw, LGS8GXX_FIRMWARE, &priv->i2c->dev); in lgs8g75_init_data()
597 for (i = 0; i < fw->size; i++) { in lgs8g75_init_data()
601 lgs8gxx_write_reg(priv, 0x3C, fw->data[i]); in lgs8g75_init_data()
613 (struct lgs8gxx_state *)fe->demodulator_priv; in lgs8gxx_init()
614 const struct lgs8gxx_config *config = priv->config; in lgs8gxx_init()
622 if (config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_init()
623 lgs8g75_set_adc_vpp(priv, config->adc_vpp); in lgs8gxx_init()
626 err = lgs8gxx_set_mpeg_mode(priv, config->serial_ts, in lgs8gxx_init()
627 config->ts_clk_pol, in lgs8gxx_init()
628 config->ts_clk_gated); in lgs8gxx_init()
630 return -EIO; in lgs8gxx_init()
632 if (config->prod == LGS8GXX_PROD_LGS8913) in lgs8gxx_init()
634 lgs8gxx_set_if_freq(priv, priv->config->if_freq); in lgs8gxx_init()
642 struct lgs8gxx_state *state = fe->demodulator_priv; in lgs8gxx_release()
651 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_write()
654 return -EINVAL; in lgs8gxx_write()
661 struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache; in lgs8gxx_set_fe()
662 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_set_fe()
667 if (fe->ops.tuner_ops.set_params) { in lgs8gxx_set_fe()
668 fe->ops.tuner_ops.set_params(fe); in lgs8gxx_set_fe()
669 if (fe->ops.i2c_gate_ctrl) in lgs8gxx_set_fe()
670 fe->ops.i2c_gate_ctrl(fe, 0); in lgs8gxx_set_fe()
681 fe_params->bandwidth_hz = 8000000; in lgs8gxx_set_fe()
683 fe_params->code_rate_HP = FEC_AUTO; in lgs8gxx_set_fe()
684 fe_params->code_rate_LP = FEC_AUTO; in lgs8gxx_set_fe()
686 fe_params->modulation = QAM_AUTO; in lgs8gxx_set_fe()
689 fe_params->transmission_mode = TRANSMISSION_MODE_AUTO; in lgs8gxx_set_fe()
691 /* guard interval */ in lgs8gxx_set_fe()
692 fe_params->guard_interval = GUARD_INTERVAL_AUTO; in lgs8gxx_set_fe()
695 fe_params->hierarchy = HIERARCHY_NONE; in lgs8gxx_set_fe()
705 fesettings->min_delay_ms = 800; in lgs8gxx_get_tune_settings()
706 fesettings->step_size = 0; in lgs8gxx_get_tune_settings()
707 fesettings->max_drift = 0; in lgs8gxx_get_tune_settings()
714 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_read_status()
723 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_read_status()
732 return -EIO; in lgs8gxx_read_status()
737 if (priv->config->prod == LGS8GXX_PROD_LGS8913) { in lgs8gxx_read_status()
754 static int lgs8gxx_read_signal_agc(struct lgs8gxx_state *priv, u16 *signal) in lgs8gxx_read_signal_agc() argument
784 *signal = cat * 65535 / 5; in lgs8gxx_read_signal_agc()
789 static int lgs8913_read_signal_strength(struct lgs8gxx_state *priv, u16 *signal) in lgs8913_read_signal_strength() argument
794 u16 i, gi = priv->curr_gi; in lgs8913_read_signal_strength()
800 return -EIO; in lgs8913_read_signal_strength()
804 dprintk("Fake signal strength\n"); in lgs8913_read_signal_strength()
805 *signal = 0x7FFF; in lgs8913_read_signal_strength()
807 *signal = 0; in lgs8913_read_signal_strength()
823 *signal = max_strength; in lgs8913_read_signal_strength()
824 dprintk("%s: signal=0x%02X\n", __func__, *signal); in lgs8913_read_signal_strength()
832 static int lgs8g75_read_signal_strength(struct lgs8gxx_state *priv, u16 *signal) in lgs8g75_read_signal_strength() argument
845 *signal = v; in lgs8g75_read_signal_strength()
846 dprintk("%s: signal=0x%02X\n", __func__, *signal); in lgs8g75_read_signal_strength()
851 static int lgs8gxx_read_signal_strength(struct dvb_frontend *fe, u16 *signal) in lgs8gxx_read_signal_strength() argument
853 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_read_signal_strength()
855 if (priv->config->prod == LGS8GXX_PROD_LGS8913) in lgs8gxx_read_signal_strength()
856 return lgs8913_read_signal_strength(priv, signal); in lgs8gxx_read_signal_strength()
857 else if (priv->config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_read_signal_strength()
858 return lgs8g75_read_signal_strength(priv, signal); in lgs8gxx_read_signal_strength()
860 return lgs8gxx_read_signal_agc(priv, signal); in lgs8gxx_read_signal_strength()
865 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_read_snr()
869 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_read_snr()
874 *snr = 256 - t; in lgs8gxx_read_snr()
892 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in packet_counter_start()
912 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in packet_counter_stop()
923 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_read_ber()
934 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) { in lgs8gxx_read_ber()
942 lgs8gxx_read_reg(priv, reg_total+3-i, &t); in lgs8gxx_read_ber()
947 lgs8gxx_read_reg(priv, reg_err+3-i, &t); in lgs8gxx_read_ber()
963 struct lgs8gxx_state *priv = fe->demodulator_priv; in lgs8gxx_i2c_gate_ctrl()
965 if (priv->config->tuner_address == 0) in lgs8gxx_i2c_gate_ctrl()
968 u8 v = 0x80 | priv->config->tuner_address; in lgs8gxx_i2c_gate_ctrl()
977 .name = "Legend Silicon LGS8913/LGS8GXX DMB-TH",
1019 priv->config = config; in lgs8gxx_attach()
1020 priv->i2c = i2c; in lgs8gxx_attach()
1025 __func__, priv->config->demod_address); in lgs8gxx_attach()
1031 memcpy(&priv->frontend.ops, &lgs8gxx_ops, in lgs8gxx_attach()
1033 priv->frontend.demodulator_priv = priv; in lgs8gxx_attach()
1035 if (config->prod == LGS8GXX_PROD_LGS8G75) in lgs8gxx_attach()
1038 return &priv->frontend; in lgs8gxx_attach()
1048 MODULE_DESCRIPTION("Legend Silicon LGS8913/LGS8GXX DMB-TH demodulator driver");