Lines Matching +full:i2c +full:- +full:gate
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2012 Hans-Frieder Vogt <hfvogt@gmx.net>
11 #include "fc0013-priv.h"
17 .addr = priv->addr, .flags = 0, .buf = buf, .len = 2 in fc0013_writereg()
20 if (i2c_transfer(priv->i2c, &msg, 1) != 1) { in fc0013_writereg()
21 err("I2C write reg failed, reg: %02x, val: %02x", reg, val); in fc0013_writereg()
22 return -EREMOTEIO; in fc0013_writereg()
30 { .addr = priv->addr, .flags = 0, .buf = ®, .len = 1 }, in fc0013_readreg()
31 { .addr = priv->addr, .flags = I2C_M_RD, .buf = val, .len = 1 }, in fc0013_readreg()
34 if (i2c_transfer(priv->i2c, msg, 2) != 2) { in fc0013_readreg()
35 err("I2C read reg failed, reg: %02x", reg); in fc0013_readreg()
36 return -EREMOTEIO; in fc0013_readreg()
43 kfree(fe->tuner_priv); in fc0013_release()
44 fe->tuner_priv = NULL; in fc0013_release()
49 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_init()
65 0xfc, /* reg. 0x0c: depending on AGC Up-Down mode, may need 0xf8 */ in fc0013_init()
73 0x50, /* reg. 0x14: DVB-t High Gain, UHF. in fc0013_init()
78 switch (priv->xtal_freq) { in fc0013_init()
88 if (priv->dual_master) in fc0013_init()
91 if (fe->ops.i2c_gate_ctrl) in fc0013_init()
92 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_init()
100 if (fe->ops.i2c_gate_ctrl) in fc0013_init()
101 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_init()
117 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_rc_cal_add()
122 if (fe->ops.i2c_gate_ctrl) in fc0013_rc_cal_add()
123 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_rc_cal_add()
153 if (fe->ops.i2c_gate_ctrl) in fc0013_rc_cal_add()
154 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_rc_cal_add()
162 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_rc_cal_reset()
165 if (fe->ops.i2c_gate_ctrl) in fc0013_rc_cal_reset()
166 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_rc_cal_reset()
172 if (fe->ops.i2c_gate_ctrl) in fc0013_rc_cal_reset()
173 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_rc_cal_reset()
211 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_set_params()
213 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in fc0013_set_params()
214 u32 freq = p->frequency / 1000; in fc0013_set_params()
215 u32 delsys = p->delivery_system; in fc0013_set_params()
221 if (fe->callback) { in fc0013_set_params()
222 ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER, in fc0013_set_params()
228 switch (priv->xtal_freq) { in fc0013_set_params()
241 if (fe->ops.i2c_gate_ctrl) in fc0013_set_params()
242 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_set_params()
356 if ((f_vco - xdiv * xtal_freq_khz_2) >= (xtal_freq_khz_2 / 2)) in fc0013_set_params()
360 am = (unsigned char)(xdiv - (8 * pm)); in fc0013_set_params()
364 reg[2] = pm - 1; in fc0013_set_params()
380 xin = (unsigned short)(f_vco - (f_vco / xtal_freq_khz_2) * xtal_freq_khz_2); in fc0013_set_params()
390 switch (p->bandwidth_hz) { in fc0013_set_params()
403 return -EINVAL; in fc0013_set_params()
430 /* VCO Re-Calibration if needed */ in fc0013_set_params()
464 priv->frequency = p->frequency; in fc0013_set_params()
465 priv->bandwidth = p->bandwidth_hz; in fc0013_set_params()
468 if (fe->ops.i2c_gate_ctrl) in fc0013_set_params()
469 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_set_params()
477 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_get_frequency()
478 *frequency = priv->frequency; in fc0013_get_frequency()
491 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_get_bandwidth()
492 *bandwidth = priv->bandwidth; in fc0013_get_bandwidth()
496 #define INPUT_ADC_LEVEL -8
500 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_get_rf_strength()
506 -63, -58, -99, -73, in fc0013_get_rf_strength()
507 -63, -65, -54, -60, in fc0013_get_rf_strength()
516 if (fe->ops.i2c_gate_ctrl) in fc0013_get_rf_strength()
517 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_get_rf_strength()
533 if (fe->ops.i2c_gate_ctrl) in fc0013_get_rf_strength()
534 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_get_rf_strength()
538 tot_agc_gain = (abs((int_temp >> 5) - 7) - 2 + in fc0013_get_rf_strength()
540 power = INPUT_ADC_LEVEL - tot_agc_gain - int_lna / 10; in fc0013_get_rf_strength()
544 else if (power < -95) in fc0013_get_rf_strength()
551 ret = -1; in fc0013_get_rf_strength()
557 if (fe->ops.i2c_gate_ctrl) in fc0013_get_rf_strength()
558 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_get_rf_strength()
588 struct i2c_adapter *i2c, u8 i2c_address, int dual_master, in fc0013_attach() argument
597 priv->i2c = i2c; in fc0013_attach()
598 priv->dual_master = dual_master; in fc0013_attach()
599 priv->addr = i2c_address; in fc0013_attach()
600 priv->xtal_freq = xtal_freq; in fc0013_attach()
604 fe->tuner_priv = priv; in fc0013_attach()
606 memcpy(&fe->ops.tuner_ops, &fc0013_tuner_ops, in fc0013_attach()
614 MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");