Lines Matching +full:multi +full:- +full:purpose
4 * Copyright (C) 2012 Hans-Frieder Vogt <hfvogt@gmx.net>
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 #include "fc0012-priv.h"
24 .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = 2 in fc0012_writereg()
27 if (i2c_transfer(priv->i2c, &msg, 1) != 1) { in fc0012_writereg()
28 dev_err(&priv->i2c->dev, in fc0012_writereg()
31 return -EREMOTEIO; in fc0012_writereg()
39 { .addr = priv->cfg->i2c_address, .flags = 0, in fc0012_readreg()
41 { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, in fc0012_readreg()
45 if (i2c_transfer(priv->i2c, msg, 2) != 2) { in fc0012_readreg()
46 dev_err(&priv->i2c->dev, in fc0012_readreg()
49 return -EREMOTEIO; in fc0012_readreg()
56 kfree(fe->tuner_priv); in fc0012_release()
57 fe->tuner_priv = NULL; in fc0012_release()
62 struct fc0012_priv *priv = fe->tuner_priv; in fc0012_init()
79 0xfc, /* reg. 0x0c: depending on AGC Up-Down mode, may need 0xf8 */ in fc0012_init()
80 0x02, /* reg. 0x0d: AGC Not Forcing & LNA Forcing, 0x02 for DVB-T */ in fc0012_init()
92 switch (priv->cfg->xtal_freq) { in fc0012_init()
102 if (priv->cfg->dual_master) in fc0012_init()
105 if (priv->cfg->loop_through) in fc0012_init()
108 if (fe->ops.i2c_gate_ctrl) in fc0012_init()
109 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0012_init()
117 if (fe->ops.i2c_gate_ctrl) in fc0012_init()
118 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0012_init()
121 dev_err(&priv->i2c->dev, "%s: fc0012_writereg failed: %d\n", in fc0012_init()
129 struct fc0012_priv *priv = fe->tuner_priv; in fc0012_set_params()
131 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in fc0012_set_params()
132 u32 freq = p->frequency / 1000; in fc0012_set_params()
133 u32 delsys = p->delivery_system; in fc0012_set_params()
134 unsigned char reg[7], am, pm, multi, tmp; in fc0012_set_params() local
139 if (fe->callback) { in fc0012_set_params()
140 ret = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER, in fc0012_set_params()
146 switch (priv->cfg->xtal_freq) { in fc0012_set_params()
161 multi = 96; in fc0012_set_params()
165 multi = 64; in fc0012_set_params()
169 multi = 48; in fc0012_set_params()
173 multi = 32; in fc0012_set_params()
177 multi = 24; in fc0012_set_params()
181 multi = 16; in fc0012_set_params()
185 multi = 12; in fc0012_set_params()
189 multi = 8; in fc0012_set_params()
193 multi = 6; in fc0012_set_params()
197 multi = 4; in fc0012_set_params()
202 f_vco = freq * multi; in fc0012_set_params()
212 if ((f_vco - xdiv * xtal_freq_khz_2) >= (xtal_freq_khz_2 / 2)) in fc0012_set_params()
216 am = (unsigned char)(xdiv - (8 * pm)); in fc0012_set_params()
220 reg[2] = pm - 1; in fc0012_set_params()
236 xin = (unsigned short)(f_vco - (f_vco / xtal_freq_khz_2) * xtal_freq_khz_2); in fc0012_set_params()
246 switch (p->bandwidth_hz) { in fc0012_set_params()
258 dev_err(&priv->i2c->dev, "%s: modulation type not supported!\n", in fc0012_set_params()
260 return -EINVAL; in fc0012_set_params()
266 if (fe->ops.i2c_gate_ctrl) in fc0012_set_params()
267 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0012_set_params()
280 /* VCO Re-Calibration if needed */ in fc0012_set_params()
314 priv->frequency = p->frequency; in fc0012_set_params()
315 priv->bandwidth = p->bandwidth_hz; in fc0012_set_params()
318 if (fe->ops.i2c_gate_ctrl) in fc0012_set_params()
319 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0012_set_params()
321 dev_warn(&priv->i2c->dev, "%s: %s failed: %d\n", in fc0012_set_params()
328 struct fc0012_priv *priv = fe->tuner_priv; in fc0012_get_frequency()
329 *frequency = priv->frequency; in fc0012_get_frequency()
335 *frequency = 0; /* Zero-IF */ in fc0012_get_if_frequency()
341 struct fc0012_priv *priv = fe->tuner_priv; in fc0012_get_bandwidth()
342 *bandwidth = priv->bandwidth; in fc0012_get_bandwidth()
346 #define INPUT_ADC_LEVEL -8
350 struct fc0012_priv *priv = fe->tuner_priv; in fc0012_get_rf_strength()
356 -63, -58, -99, -73, in fc0012_get_rf_strength()
357 -63, -65, -54, -60, in fc0012_get_rf_strength()
366 if (fe->ops.i2c_gate_ctrl) in fc0012_get_rf_strength()
367 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in fc0012_get_rf_strength()
383 if (fe->ops.i2c_gate_ctrl) in fc0012_get_rf_strength()
384 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0012_get_rf_strength()
388 tot_agc_gain = (abs((int_temp >> 5) - 7) - 2 + in fc0012_get_rf_strength()
390 power = INPUT_ADC_LEVEL - tot_agc_gain - int_lna / 10; in fc0012_get_rf_strength()
394 else if (power < -95) in fc0012_get_rf_strength()
401 ret = -1; in fc0012_get_rf_strength()
407 if (fe->ops.i2c_gate_ctrl) in fc0012_get_rf_strength()
408 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in fc0012_get_rf_strength()
411 dev_warn(&priv->i2c->dev, "%s: %s failed: %d\n", in fc0012_get_rf_strength()
444 if (fe->ops.i2c_gate_ctrl) in fc0012_attach()
445 fe->ops.i2c_gate_ctrl(fe, 1); in fc0012_attach()
449 ret = -ENOMEM; in fc0012_attach()
450 dev_err(&i2c->dev, "%s: kzalloc() failed\n", KBUILD_MODNAME); in fc0012_attach()
454 priv->cfg = cfg; in fc0012_attach()
455 priv->i2c = i2c; in fc0012_attach()
462 dev_dbg(&i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); in fc0012_attach()
468 ret = -ENODEV; in fc0012_attach()
472 dev_info(&i2c->dev, "%s: Fitipower FC0012 successfully identified\n", in fc0012_attach()
475 if (priv->cfg->loop_through) { in fc0012_attach()
485 if (priv->cfg->clock_out) { in fc0012_attach()
491 fe->tuner_priv = priv; in fc0012_attach()
492 memcpy(&fe->ops.tuner_ops, &fc0012_tuner_ops, in fc0012_attach()
496 if (fe->ops.i2c_gate_ctrl) in fc0012_attach()
497 fe->ops.i2c_gate_ctrl(fe, 0); in fc0012_attach()
500 dev_dbg(&i2c->dev, "%s: failed: %d\n", __func__, ret); in fc0012_attach()
510 MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");