Lines Matching +full:switch +full:- +full:freq +full:- +full:select

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Copyright (C) 2012 Hans-Frieder Vogt <hfvogt@gmx.net>
22 FC11_REG_VCOSEL, /* VCO select */
39 FC11_VCOSEL_2 = 0x08, /* VCO select 2 */
40 FC11_VCOSEL_1 = 0x10, /* VCO select 1 */
70 struct i2c_msg msg = { .addr = priv->addr, in fc0011_writereg()
73 if (i2c_transfer(priv->i2c, &msg, 1) != 1) { in fc0011_writereg()
74 dev_err(&priv->i2c->dev, in fc0011_writereg()
77 return -EIO; in fc0011_writereg()
87 { .addr = priv->addr, in fc0011_readreg()
89 { .addr = priv->addr, in fc0011_readreg()
93 if (i2c_transfer(priv->i2c, msg, 2) != 2) { in fc0011_readreg()
94 dev_err(&priv->i2c->dev, in fc0011_readreg()
96 return -EIO; in fc0011_readreg()
104 kfree(fe->tuner_priv); in fc0011_release()
105 fe->tuner_priv = NULL; in fc0011_release()
110 struct fc0011_priv *priv = fe->tuner_priv; in fc0011_init()
113 if (WARN_ON(!fe->callback)) in fc0011_init()
114 return -EINVAL; in fc0011_init()
116 err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER, in fc0011_init()
117 FC0011_FE_CALLBACK_POWER, priv->addr); in fc0011_init()
119 dev_err(&priv->i2c->dev, "Power-on callback failed\n"); in fc0011_init()
122 err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER, in fc0011_init()
123 FC0011_FE_CALLBACK_RESET, priv->addr); in fc0011_init()
125 dev_err(&priv->i2c->dev, "Reset callback failed\n"); in fc0011_init()
165 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in fc0011_set_params()
166 struct fc0011_priv *priv = fe->tuner_priv; in fc0011_set_params()
169 u32 freq = p->frequency / 1000; in fc0011_set_params() local
170 u32 bandwidth = p->bandwidth_hz / 1000; in fc0011_set_params()
186 return -EIO; in fc0011_set_params()
188 /* Set VCO freq and VCO div */ in fc0011_set_params()
189 if (freq < 54000) { in fc0011_set_params()
190 fvco = freq * 64; in fc0011_set_params()
192 } else if (freq < 108000) { in fc0011_set_params()
193 fvco = freq * 32; in fc0011_set_params()
195 } else if (freq < 216000) { in fc0011_set_params()
196 fvco = freq * 16; in fc0011_set_params()
198 } else if (freq < 432000) { in fc0011_set_params()
199 fvco = freq * 8; in fc0011_set_params()
202 fvco = freq * 4; in fc0011_set_params()
209 frac = fvco - xdiv * 18000; in fc0011_set_params()
222 if (fvco - xdiv * 18000 >= 9000) in fc0011_set_params()
225 fa = xdivr - fp * 8; in fc0011_set_params()
227 fp -= 1; in fc0011_set_params()
235 dev_warn(&priv->i2c->dev, in fc0011_set_params()
242 /* Select bandwidth */ in fc0011_set_params()
243 switch (bandwidth) { in fc0011_set_params()
250 dev_warn(&priv->i2c->dev, "Unsupported bandwidth %u kHz. Using 6000 kHz.\n", in fc0011_set_params()
259 /* Pre VCO select */ in fc0011_set_params()
274 if (freq < 45000) { in fc0011_set_params()
299 err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER, in fc0011_set_params()
300 FC0011_FE_CALLBACK_RESET, priv->addr); in fc0011_set_params()
302 dev_err(&priv->i2c->dev, "Failed to reset tuner\n"); in fc0011_set_params()
315 return -EIO; in fc0011_set_params()
326 dev_err(&priv->i2c->dev, in fc0011_set_params()
329 return -EIO; in fc0011_set_params()
333 switch (vco_sel) { in fc0011_set_params()
336 return -EINVAL; in fc0011_set_params()
423 …dev_dbg(&priv->i2c->dev, "Tuned to fa=%02X fp=%02X xin=%02X%02X vco=%02X vcosel=%02X vcocal=%02X(%… in fc0011_set_params()
433 priv->frequency = p->frequency; in fc0011_set_params()
434 priv->bandwidth = p->bandwidth_hz; in fc0011_set_params()
441 struct fc0011_priv *priv = fe->tuner_priv; in fc0011_get_frequency()
443 *frequency = priv->frequency; in fc0011_get_frequency()
457 struct fc0011_priv *priv = fe->tuner_priv; in fc0011_get_bandwidth()
459 *bandwidth = priv->bandwidth; in fc0011_get_bandwidth()
492 priv->i2c = i2c; in fc0011_attach()
493 priv->addr = config->i2c_address; in fc0011_attach()
495 fe->tuner_priv = priv; in fc0011_attach()
496 fe->ops.tuner_ops = fc0011_tuner_ops; in fc0011_attach()
498 dev_info(&priv->i2c->dev, "Fitipower FC0011 tuner attached\n"); in fc0011_attach()