Lines Matching +full:auto +full:- +full:i2c

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Sony Ascot3E DVB-T/T2/C/C2 tuner driver
31 struct i2c_adapter *i2c; member
76 ASCOT2E_OFFSET(-8), ASCOT2E_OFFSET(-6), ASCOT2E_BW_6, 0x0B, 0x00 },
78 ASCOT2E_OFFSET(-8), ASCOT2E_OFFSET(-6), ASCOT2E_BW_6, 0x0B, 0x00 },
80 ASCOT2E_OFFSET(-6), ASCOT2E_OFFSET(-4), ASCOT2E_BW_7, 0x0B, 0x00 },
82 ASCOT2E_OFFSET(-4), ASCOT2E_OFFSET(-2), ASCOT2E_BW_8, 0x0B, 0x00 },
84 ASCOT2E_OFFSET(-10), ASCOT2E_OFFSET(-16), ASCOT2E_BW_1_7, 0x0B, 0x00 },
86 ASCOT2E_OFFSET(-8), ASCOT2E_OFFSET(-6), ASCOT2E_BW_6, 0x0B, 0x00 },
88 ASCOT2E_OFFSET(-8), ASCOT2E_OFFSET(-6), ASCOT2E_BW_6, 0x0B, 0x00 },
90 ASCOT2E_OFFSET(-6), ASCOT2E_OFFSET(-4), ASCOT2E_BW_7, 0x0B, 0x00 },
92 ASCOT2E_OFFSET(-4), ASCOT2E_OFFSET(-2), ASCOT2E_BW_8, 0x0B, 0x00 },
94 ASCOT2E_OFFSET(-6), ASCOT2E_OFFSET(-8), ASCOT2E_BW_6, 0x09, 0x00 },
96 ASCOT2E_OFFSET(-2), ASCOT2E_OFFSET(-1), ASCOT2E_BW_8, 0x09, 0x00 },
98 ASCOT2E_OFFSET(-6), ASCOT2E_OFFSET(-4), ASCOT2E_BW_6, 0x09, 0x00 },
100 ASCOT2E_OFFSET(-2), ASCOT2E_OFFSET(2), ASCOT2E_BW_8, 0x09, 0x00 }
106 dev_dbg(&priv->i2c->dev, "ascot2e: I2C %s reg 0x%02x size %d\n", in ascot2e_i2c_debug()
108 print_hex_dump_bytes("ascot2e: I2C data: ", in ascot2e_i2c_debug()
119 .addr = priv->i2c_address, in ascot2e_write_regs()
127 dev_warn(&priv->i2c->dev,"wr reg=%04x: len=%d is too big!\n", in ascot2e_write_regs()
129 return -E2BIG; in ascot2e_write_regs()
135 ret = i2c_transfer(priv->i2c, msg, 1); in ascot2e_write_regs()
137 ret = -EREMOTEIO; in ascot2e_write_regs()
139 dev_warn(&priv->i2c->dev, in ascot2e_write_regs()
140 "%s: i2c wr failed=%d reg=%02x len=%d\n", in ascot2e_write_regs()
160 .addr = priv->i2c_address, in ascot2e_read_regs()
165 .addr = priv->i2c_address, in ascot2e_read_regs()
172 ret = i2c_transfer(priv->i2c, &msg[0], 1); in ascot2e_read_regs()
174 ret = -EREMOTEIO; in ascot2e_read_regs()
176 dev_warn(&priv->i2c->dev, in ascot2e_read_regs()
177 "%s: I2C rw failed=%d addr=%02x reg=%02x\n", in ascot2e_read_regs()
178 KBUILD_MODNAME, ret, priv->i2c_address, reg); in ascot2e_read_regs()
181 ret = i2c_transfer(priv->i2c, &msg[1], 1); in ascot2e_read_regs()
183 ret = -EREMOTEIO; in ascot2e_read_regs()
185 dev_warn(&priv->i2c->dev, in ascot2e_read_regs()
186 "%s: i2c rd failed=%d addr=%02x reg=%02x\n", in ascot2e_read_regs()
187 KBUILD_MODNAME, ret, priv->i2c_address, reg); in ascot2e_read_regs()
218 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); in ascot2e_enter_power_save()
219 if (priv->state == STATE_SLEEP) in ascot2e_enter_power_save()
225 priv->state = STATE_SLEEP; in ascot2e_enter_power_save()
233 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); in ascot2e_leave_power_save()
234 if (priv->state == STATE_ACTIVE) in ascot2e_leave_power_save()
238 priv->state = STATE_ACTIVE; in ascot2e_leave_power_save()
244 struct ascot2e_priv *priv = fe->tuner_priv; in ascot2e_init()
246 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); in ascot2e_init()
252 struct ascot2e_priv *priv = fe->tuner_priv; in ascot2e_release()
254 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); in ascot2e_release()
255 kfree(fe->tuner_priv); in ascot2e_release()
256 fe->tuner_priv = NULL; in ascot2e_release()
261 struct ascot2e_priv *priv = fe->tuner_priv; in ascot2e_sleep()
263 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); in ascot2e_sleep()
271 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in ascot2e_get_tv_system()
272 struct ascot2e_priv *priv = fe->tuner_priv; in ascot2e_get_tv_system()
274 if (p->delivery_system == SYS_DVBT) { in ascot2e_get_tv_system()
275 if (p->bandwidth_hz <= 5000000) in ascot2e_get_tv_system()
277 else if (p->bandwidth_hz <= 6000000) in ascot2e_get_tv_system()
279 else if (p->bandwidth_hz <= 7000000) in ascot2e_get_tv_system()
281 else if (p->bandwidth_hz <= 8000000) in ascot2e_get_tv_system()
285 p->bandwidth_hz = 8000000; in ascot2e_get_tv_system()
287 } else if (p->delivery_system == SYS_DVBT2) { in ascot2e_get_tv_system()
288 if (p->bandwidth_hz <= 5000000) in ascot2e_get_tv_system()
290 else if (p->bandwidth_hz <= 6000000) in ascot2e_get_tv_system()
292 else if (p->bandwidth_hz <= 7000000) in ascot2e_get_tv_system()
294 else if (p->bandwidth_hz <= 8000000) in ascot2e_get_tv_system()
298 p->bandwidth_hz = 8000000; in ascot2e_get_tv_system()
300 } else if (p->delivery_system == SYS_DVBC_ANNEX_A) { in ascot2e_get_tv_system()
301 if (p->bandwidth_hz <= 6000000) in ascot2e_get_tv_system()
303 else if (p->bandwidth_hz <= 8000000) in ascot2e_get_tv_system()
306 dev_dbg(&priv->i2c->dev, in ascot2e_get_tv_system()
308 __func__, (int)system, p->delivery_system, p->bandwidth_hz); in ascot2e_get_tv_system()
317 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in ascot2e_set_params()
318 struct ascot2e_priv *priv = fe->tuner_priv; in ascot2e_set_params()
320 dev_dbg(&priv->i2c->dev, "%s(): tune frequency %dkHz\n", in ascot2e_set_params()
321 __func__, p->frequency / 1000); in ascot2e_set_params()
325 dev_dbg(&priv->i2c->dev, "%s(): unknown DTV system\n", in ascot2e_set_params()
327 return -EINVAL; in ascot2e_set_params()
329 if (priv->set_tuner) in ascot2e_set_params()
330 priv->set_tuner(priv->set_tuner_data, 1); in ascot2e_set_params()
331 frequency = roundup(p->frequency / 1000, 25); in ascot2e_set_params()
332 if (priv->state == STATE_SLEEP) in ascot2e_set_params()
349 /* 0x06 - 0x0F */ in ascot2e_set_params()
382 /* RF_GAIN auto control enable */ in ascot2e_set_params()
387 /* RF_GAIN auto control disable */ in ascot2e_set_params()
398 * 0x45 - 0x47 in ascot2e_set_params()
400 * RF_LNA_DIST1-5, RF_LNA_CM in ascot2e_set_params()
413 /* 0x49 - 0x4A in ascot2e_set_params()
421 * RFAGC fast mode / RFAGC auto control enable in ascot2e_set_params()
430 /* 0x10 - 0x14 */ in ascot2e_set_params()
447 priv->frequency = frequency; in ascot2e_set_params()
453 struct ascot2e_priv *priv = fe->tuner_priv; in ascot2e_get_frequency()
455 *frequency = priv->frequency * 1000; in ascot2e_get_frequency()
475 struct i2c_adapter *i2c) in ascot2e_attach() argument
483 priv->i2c_address = (config->i2c_address >> 1); in ascot2e_attach()
484 priv->i2c = i2c; in ascot2e_attach()
485 priv->set_tuner_data = config->set_tuner_priv; in ascot2e_attach()
486 priv->set_tuner = config->set_tuner_callback; in ascot2e_attach()
488 if (fe->ops.i2c_gate_ctrl) in ascot2e_attach()
489 fe->ops.i2c_gate_ctrl(fe, 1); in ascot2e_attach()
499 /* RFVGA optimization setting (RF_DIST0 - RF_DIST2) */ in ascot2e_attach()
523 priv->state = STATE_SLEEP; in ascot2e_attach()
525 if (fe->ops.i2c_gate_ctrl) in ascot2e_attach()
526 fe->ops.i2c_gate_ctrl(fe, 0); in ascot2e_attach()
528 memcpy(&fe->ops.tuner_ops, &ascot2e_tuner_ops, in ascot2e_attach()
530 fe->tuner_priv = priv; in ascot2e_attach()
531 dev_info(&priv->i2c->dev, in ascot2e_attach()
532 "Sony ASCOT2E attached on addr=%x at I2C adapter %p\n", in ascot2e_attach()
533 priv->i2c_address, priv->i2c); in ascot2e_attach()