Lines Matching +full:i2c +full:- +full:gate

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2012 Hans-Frieder Vogt <[email protected]>
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 = &reg, .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()
147 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_set_params()
149 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in fc0013_set_params()
150 u32 freq = p->frequency / 1000; in fc0013_set_params()
151 u32 delsys = p->delivery_system; in fc0013_set_params()
157 if (fe->callback) { in fc0013_set_params()
158 ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER, in fc0013_set_params()
164 switch (priv->xtal_freq) { in fc0013_set_params()
177 if (fe->ops.i2c_gate_ctrl) in fc0013_set_params()
178 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_set_params()
292 if ((f_vco - xdiv * xtal_freq_khz_2) >= (xtal_freq_khz_2 / 2)) in fc0013_set_params()
296 am = (unsigned char)(xdiv - (8 * pm)); in fc0013_set_params()
300 reg[2] = pm - 1; in fc0013_set_params()
316 xin = (unsigned short)(f_vco - (f_vco / xtal_freq_khz_2) * xtal_freq_khz_2); in fc0013_set_params()
326 switch (p->bandwidth_hz) { in fc0013_set_params()
339 return -EINVAL; in fc0013_set_params()
366 /* VCO Re-Calibration if needed */ in fc0013_set_params()
400 priv->frequency = p->frequency; in fc0013_set_params()
401 priv->bandwidth = p->bandwidth_hz; in fc0013_set_params()
404 if (fe->ops.i2c_gate_ctrl) in fc0013_set_params()
405 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_set_params()
413 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_get_frequency()
414 *frequency = priv->frequency; in fc0013_get_frequency()
427 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_get_bandwidth()
428 *bandwidth = priv->bandwidth; in fc0013_get_bandwidth()
432 #define INPUT_ADC_LEVEL -8
436 struct fc0013_priv *priv = fe->tuner_priv; in fc0013_get_rf_strength()
442 -63, -58, -99, -73, in fc0013_get_rf_strength()
443 -63, -65, -54, -60, in fc0013_get_rf_strength()
452 if (fe->ops.i2c_gate_ctrl) in fc0013_get_rf_strength()
453 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0013_get_rf_strength()
469 if (fe->ops.i2c_gate_ctrl) in fc0013_get_rf_strength()
470 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_get_rf_strength()
474 tot_agc_gain = (abs((int_temp >> 5) - 7) - 2 + in fc0013_get_rf_strength()
476 power = INPUT_ADC_LEVEL - tot_agc_gain - int_lna / 10; in fc0013_get_rf_strength()
480 else if (power < -95) in fc0013_get_rf_strength()
487 ret = -1; in fc0013_get_rf_strength()
493 if (fe->ops.i2c_gate_ctrl) in fc0013_get_rf_strength()
494 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0013_get_rf_strength()
524 struct i2c_adapter *i2c, u8 i2c_address, int dual_master, in fc0013_attach() argument
533 priv->i2c = i2c; in fc0013_attach()
534 priv->dual_master = dual_master; in fc0013_attach()
535 priv->addr = i2c_address; in fc0013_attach()
536 priv->xtal_freq = xtal_freq; in fc0013_attach()
540 fe->tuner_priv = priv; in fc0013_attach()
542 memcpy(&fe->ops.tuner_ops, &fc0013_tuner_ops, in fc0013_attach()
550 MODULE_AUTHOR("Hans-Frieder Vogt <[email protected]>");