Lines Matching refs:s

26 	struct e4000 *s = fe->tuner_priv;  in e4000_init()  local
29 dev_dbg(&s->client->dev, "\n"); in e4000_init()
32 ret = regmap_write(s->regmap, 0x02, 0x40); in e4000_init()
35 ret = regmap_write(s->regmap, 0x00, 0x01); in e4000_init()
40 ret = regmap_write(s->regmap, 0x06, 0x00); in e4000_init()
44 ret = regmap_write(s->regmap, 0x7a, 0x96); in e4000_init()
49 ret = regmap_bulk_write(s->regmap, 0x7e, "\x01\xfe", 2); in e4000_init()
53 ret = regmap_write(s->regmap, 0x82, 0x00); in e4000_init()
57 ret = regmap_write(s->regmap, 0x24, 0x05); in e4000_init()
61 ret = regmap_bulk_write(s->regmap, 0x87, "\x20\x01", 2); in e4000_init()
65 ret = regmap_bulk_write(s->regmap, 0x9f, "\x7f\x07", 2); in e4000_init()
70 ret = regmap_write(s->regmap, 0x2d, 0x1f); in e4000_init()
74 ret = regmap_bulk_write(s->regmap, 0x70, "\x01\x01", 2); in e4000_init()
79 ret = regmap_write(s->regmap, 0x1a, 0x17); in e4000_init()
83 ret = regmap_write(s->regmap, 0x1f, 0x1a); in e4000_init()
87 s->active = true; in e4000_init()
90 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_init()
97 struct e4000 *s = fe->tuner_priv; in e4000_sleep() local
100 dev_dbg(&s->client->dev, "\n"); in e4000_sleep()
102 s->active = false; in e4000_sleep()
104 ret = regmap_write(s->regmap, 0x00, 0x00); in e4000_sleep()
109 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_sleep()
116 struct e4000 *s = fe->tuner_priv; in e4000_set_params() local
123 dev_dbg(&s->client->dev, in e4000_set_params()
128 ret = regmap_write(s->regmap, 0x1a, 0x00); in e4000_set_params()
144 pll_n = div_u64_rem(f_vco, s->clock, &pll_f); in e4000_set_params()
145 sigma_delta = div_u64(0x10000ULL * pll_f, s->clock); in e4000_set_params()
152 dev_dbg(&s->client->dev, "f_vco=%llu pll div=%d sigma_delta=%04x\n", in e4000_set_params()
155 ret = regmap_bulk_write(s->regmap, 0x09, buf, 5); in e4000_set_params()
170 ret = regmap_write(s->regmap, 0x10, e400_lna_filter_lut[i].val); in e4000_set_params()
188 ret = regmap_bulk_write(s->regmap, 0x11, buf, 2); in e4000_set_params()
203 ret = regmap_write(s->regmap, 0x07, e4000_band_lut[i].reg07_val); in e4000_set_params()
207 ret = regmap_write(s->regmap, 0x78, e4000_band_lut[i].reg78_val); in e4000_set_params()
214 ret = regmap_bulk_write(s->regmap, 0x15, "\x00\x7e\x24", 3); in e4000_set_params()
216 ret = regmap_bulk_write(s->regmap, 0x15, "\x00\x7f", 2); in e4000_set_params()
218 ret = regmap_bulk_write(s->regmap, 0x15, "\x01", 1); in e4000_set_params()
220 ret = regmap_bulk_write(s->regmap, 0x16, "\x7e", 1); in e4000_set_params()
225 ret = regmap_write(s->regmap, 0x29, 0x01); in e4000_set_params()
229 ret = regmap_bulk_read(s->regmap, 0x2a, buf, 3); in e4000_set_params()
240 ret = regmap_bulk_write(s->regmap, 0x50, q_data, 4); in e4000_set_params()
244 ret = regmap_bulk_write(s->regmap, 0x60, i_data, 4); in e4000_set_params()
249 ret = regmap_write(s->regmap, 0x1a, 0x17); in e4000_set_params()
254 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_set_params()
261 struct e4000 *s = fe->tuner_priv; in e4000_get_if_frequency() local
263 dev_dbg(&s->client->dev, "\n"); in e4000_get_if_frequency()
273 struct e4000 *s = fe->tuner_priv; in e4000_set_lna_gain() local
277 dev_dbg(&s->client->dev, "lna auto=%d->%d val=%d->%d\n", in e4000_set_lna_gain()
278 s->lna_gain_auto->cur.val, s->lna_gain_auto->val, in e4000_set_lna_gain()
279 s->lna_gain->cur.val, s->lna_gain->val); in e4000_set_lna_gain()
281 if (s->lna_gain_auto->val && s->if_gain_auto->cur.val) in e4000_set_lna_gain()
283 else if (s->lna_gain_auto->val) in e4000_set_lna_gain()
285 else if (s->if_gain_auto->cur.val) in e4000_set_lna_gain()
290 ret = regmap_write(s->regmap, 0x1a, u8tmp); in e4000_set_lna_gain()
294 if (s->lna_gain_auto->val == false) { in e4000_set_lna_gain()
295 ret = regmap_write(s->regmap, 0x14, s->lna_gain->val); in e4000_set_lna_gain()
301 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_set_lna_gain()
308 struct e4000 *s = fe->tuner_priv; in e4000_set_mixer_gain() local
312 dev_dbg(&s->client->dev, "mixer auto=%d->%d val=%d->%d\n", in e4000_set_mixer_gain()
313 s->mixer_gain_auto->cur.val, s->mixer_gain_auto->val, in e4000_set_mixer_gain()
314 s->mixer_gain->cur.val, s->mixer_gain->val); in e4000_set_mixer_gain()
316 if (s->mixer_gain_auto->val) in e4000_set_mixer_gain()
321 ret = regmap_write(s->regmap, 0x20, u8tmp); in e4000_set_mixer_gain()
325 if (s->mixer_gain_auto->val == false) { in e4000_set_mixer_gain()
326 ret = regmap_write(s->regmap, 0x15, s->mixer_gain->val); in e4000_set_mixer_gain()
332 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_set_mixer_gain()
339 struct e4000 *s = fe->tuner_priv; in e4000_set_if_gain() local
344 dev_dbg(&s->client->dev, "if auto=%d->%d val=%d->%d\n", in e4000_set_if_gain()
345 s->if_gain_auto->cur.val, s->if_gain_auto->val, in e4000_set_if_gain()
346 s->if_gain->cur.val, s->if_gain->val); in e4000_set_if_gain()
348 if (s->if_gain_auto->val && s->lna_gain_auto->cur.val) in e4000_set_if_gain()
350 else if (s->lna_gain_auto->cur.val) in e4000_set_if_gain()
352 else if (s->if_gain_auto->val) in e4000_set_if_gain()
357 ret = regmap_write(s->regmap, 0x1a, u8tmp); in e4000_set_if_gain()
361 if (s->if_gain_auto->val == false) { in e4000_set_if_gain()
362 buf[0] = e4000_if_gain_lut[s->if_gain->val].reg16_val; in e4000_set_if_gain()
363 buf[1] = e4000_if_gain_lut[s->if_gain->val].reg17_val; in e4000_set_if_gain()
364 ret = regmap_bulk_write(s->regmap, 0x16, buf, 2); in e4000_set_if_gain()
370 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_set_if_gain()
377 struct e4000 *s = fe->tuner_priv; in e4000_pll_lock() local
381 ret = regmap_read(s->regmap, 0x07, &utmp); in e4000_pll_lock()
385 s->pll_lock->val = (utmp & 0x01); in e4000_pll_lock()
388 dev_dbg(&s->client->dev, "failed=%d\n", ret); in e4000_pll_lock()
395 struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl); in e4000_g_volatile_ctrl() local
398 if (!s->active) in e4000_g_volatile_ctrl()
403 ret = e4000_pll_lock(s->fe); in e4000_g_volatile_ctrl()
406 dev_dbg(&s->client->dev, "unknown ctrl: id=%d name=%s\n", in e4000_g_volatile_ctrl()
416 struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl); in e4000_s_ctrl() local
417 struct dvb_frontend *fe = s->fe; in e4000_s_ctrl()
421 if (!s->active) in e4000_s_ctrl()
427 c->bandwidth_hz = s->bandwidth->val; in e4000_s_ctrl()
428 ret = e4000_set_params(s->fe); in e4000_s_ctrl()
432 ret = e4000_set_lna_gain(s->fe); in e4000_s_ctrl()
436 ret = e4000_set_mixer_gain(s->fe); in e4000_s_ctrl()
440 ret = e4000_set_if_gain(s->fe); in e4000_s_ctrl()
443 dev_dbg(&s->client->dev, "unknown ctrl: id=%d name=%s\n", in e4000_s_ctrl()
480 struct e4000 *s; in e4000_probe() local
489 s = kzalloc(sizeof(struct e4000), GFP_KERNEL); in e4000_probe()
490 if (!s) { in e4000_probe()
496 s->clock = cfg->clock; in e4000_probe()
497 s->client = client; in e4000_probe()
498 s->fe = cfg->fe; in e4000_probe()
499 s->regmap = devm_regmap_init_i2c(client, &regmap_config); in e4000_probe()
500 if (IS_ERR(s->regmap)) { in e4000_probe()
501 ret = PTR_ERR(s->regmap); in e4000_probe()
506 ret = regmap_read(s->regmap, 0x02, &utmp); in e4000_probe()
510 dev_dbg(&s->client->dev, "chip id=%02x\n", utmp); in e4000_probe()
518 ret = regmap_write(s->regmap, 0x00, 0x00); in e4000_probe()
524 v4l2_ctrl_handler_init(&s->hdl, 9); in e4000_probe()
525 s->bandwidth_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
527 s->bandwidth = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
529 v4l2_ctrl_auto_cluster(2, &s->bandwidth_auto, 0, false); in e4000_probe()
530 s->lna_gain_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
532 s->lna_gain = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
534 v4l2_ctrl_auto_cluster(2, &s->lna_gain_auto, 0, false); in e4000_probe()
535 s->mixer_gain_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
537 s->mixer_gain = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
539 v4l2_ctrl_auto_cluster(2, &s->mixer_gain_auto, 0, false); in e4000_probe()
540 s->if_gain_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
542 s->if_gain = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
544 v4l2_ctrl_auto_cluster(2, &s->if_gain_auto, 0, false); in e4000_probe()
545 s->pll_lock = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops, in e4000_probe()
547 if (s->hdl.error) { in e4000_probe()
548 ret = s->hdl.error; in e4000_probe()
549 dev_err(&s->client->dev, "Could not initialize controls\n"); in e4000_probe()
550 v4l2_ctrl_handler_free(&s->hdl); in e4000_probe()
554 s->sd.ctrl_handler = &s->hdl; in e4000_probe()
557 dev_info(&s->client->dev, "Elonics E4000 successfully identified\n"); in e4000_probe()
559 fe->tuner_priv = s; in e4000_probe()
563 v4l2_set_subdevdata(&s->sd, client); in e4000_probe()
564 i2c_set_clientdata(client, &s->sd); in e4000_probe()
570 kfree(s); in e4000_probe()
579 struct e4000 *s = container_of(sd, struct e4000, sd); in e4000_remove() local
580 struct dvb_frontend *fe = s->fe; in e4000_remove()
585 v4l2_ctrl_handler_free(&s->hdl); in e4000_remove()
589 kfree(s); in e4000_remove()