Lines Matching +full:auto +full:- +full:i2c
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Frontend driver for mobile DVB-T demodulator DiBcom 3000M-B
6 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
15 * sources, on which this driver (and the dvb-dibusb) are based.
17 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
36 #define DRIVER_DESC "DiBcom 3000M-B DVB-T demodulator"
41 MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
56 { .addr = state->config.demod_address, .flags = 0, .buf = wb, .len = 2 }, in dib3000_read_reg()
57 { .addr = state->config.demod_address, .flags = I2C_M_RD, .buf = rb, .len = 2 }, in dib3000_read_reg()
60 if (i2c_transfer(state->i2c, msg, 2) != 2) in dib3000_read_reg()
61 deb_i2c("i2c read error\n"); in dib3000_read_reg()
63 deb_i2c("reading i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg, in dib3000_read_reg()
76 { .addr = state->config.demod_address, .flags = 0, .buf = b, .len = 4 } in dib3000_write_reg()
78 deb_i2c("writing i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,val,val); in dib3000_write_reg()
80 return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0; in dib3000_write_reg()
87 deb_srch("auto search succeeded\n"); in dib3000_search_status()
88 return 1; // auto search succeeded in dib3000_search_status()
90 deb_srch("auto search not successful\n"); in dib3000_search_status()
91 return 0; // auto search failed in dib3000_search_status()
94 deb_srch("auto search failed\n"); in dib3000_search_status()
95 return 0; // auto search failed in dib3000_search_status()
97 return -1; // try again in dib3000_search_status()
100 /* for auto search */
118 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_set_frontend()
119 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dib3000mb_set_frontend()
123 if (tuner && fe->ops.tuner_ops.set_params) { in dib3000mb_set_frontend()
124 fe->ops.tuner_ops.set_params(fe); in dib3000mb_set_frontend()
125 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); in dib3000mb_set_frontend()
127 switch (c->bandwidth_hz) { in dib3000mb_set_frontend()
141 return -EOPNOTSUPP; in dib3000mb_set_frontend()
144 return -EINVAL; in dib3000mb_set_frontend()
146 deb_setf("bandwidth: %d MHZ\n", c->bandwidth_hz / 1000000); in dib3000mb_set_frontend()
150 switch (c->transmission_mode) { in dib3000mb_set_frontend()
160 deb_setf("transmission mode: auto\n"); in dib3000mb_set_frontend()
163 return -EINVAL; in dib3000mb_set_frontend()
166 switch (c->guard_interval) { in dib3000mb_set_frontend()
184 deb_setf("guard auto\n"); in dib3000mb_set_frontend()
187 return -EINVAL; in dib3000mb_set_frontend()
190 switch (c->inversion) { in dib3000mb_set_frontend()
196 deb_setf("inversion auto\n"); in dib3000mb_set_frontend()
203 return -EINVAL; in dib3000mb_set_frontend()
206 switch (c->modulation) { in dib3000mb_set_frontend()
222 return -EINVAL; in dib3000mb_set_frontend()
224 switch (c->hierarchy) { in dib3000mb_set_frontend()
241 deb_setf("hierarchy: alpha=auto\n"); in dib3000mb_set_frontend()
244 return -EINVAL; in dib3000mb_set_frontend()
247 if (c->hierarchy == HIERARCHY_NONE) { in dib3000mb_set_frontend()
250 fe_cr = c->code_rate_HP; in dib3000mb_set_frontend()
251 } else if (c->hierarchy != HIERARCHY_AUTO) { in dib3000mb_set_frontend()
254 fe_cr = c->code_rate_LP; in dib3000mb_set_frontend()
281 deb_setf("fec: auto\n"); in dib3000mb_set_frontend()
284 return -EINVAL; in dib3000mb_set_frontend()
288 [c->transmission_mode == TRANSMISSION_MODE_AUTO] in dib3000mb_set_frontend()
289 [c->guard_interval == GUARD_INTERVAL_AUTO] in dib3000mb_set_frontend()
290 [c->inversion == INVERSION_AUTO]; in dib3000mb_set_frontend()
298 if (c->transmission_mode == TRANSMISSION_MODE_2K) { in dib3000mb_set_frontend()
299 if (c->guard_interval == GUARD_INTERVAL_1_8) { in dib3000mb_set_frontend()
326 /* something has to be auto searched */ in dib3000mb_set_frontend()
327 if (c->modulation == QAM_AUTO || in dib3000mb_set_frontend()
328 c->hierarchy == HIERARCHY_AUTO || in dib3000mb_set_frontend()
330 c->inversion == INVERSION_AUTO) { in dib3000mb_set_frontend()
366 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_fe_init()
444 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_get_frontend()
471 c->inversion = in dib3000mb_get_frontend()
476 deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, c->inversion); in dib3000mb_get_frontend()
481 c->modulation = QPSK; in dib3000mb_get_frontend()
485 c->modulation = QAM_16; in dib3000mb_get_frontend()
489 c->modulation = QAM_64; in dib3000mb_get_frontend()
499 cr = &c->code_rate_LP; in dib3000mb_get_frontend()
500 c->code_rate_HP = FEC_NONE; in dib3000mb_get_frontend()
504 c->hierarchy = HIERARCHY_NONE; in dib3000mb_get_frontend()
508 c->hierarchy = HIERARCHY_1; in dib3000mb_get_frontend()
512 c->hierarchy = HIERARCHY_2; in dib3000mb_get_frontend()
516 c->hierarchy = HIERARCHY_4; in dib3000mb_get_frontend()
527 cr = &c->code_rate_HP; in dib3000mb_get_frontend()
528 c->code_rate_LP = FEC_NONE; in dib3000mb_get_frontend()
529 c->hierarchy = HIERARCHY_NONE; in dib3000mb_get_frontend()
564 c->guard_interval = GUARD_INTERVAL_1_32; in dib3000mb_get_frontend()
568 c->guard_interval = GUARD_INTERVAL_1_16; in dib3000mb_get_frontend()
572 c->guard_interval = GUARD_INTERVAL_1_8; in dib3000mb_get_frontend()
576 c->guard_interval = GUARD_INTERVAL_1_4; in dib3000mb_get_frontend()
587 c->transmission_mode = TRANSMISSION_MODE_2K; in dib3000mb_get_frontend()
591 c->transmission_mode = TRANSMISSION_MODE_8K; in dib3000mb_get_frontend()
605 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_read_status()
637 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_read_ber()
643 /* see dib3000-watch dvb-apps for exact calcuations of signal_strength and snr */
646 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_read_signal_strength()
654 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_read_snr()
664 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_read_unc_blocks()
672 struct dib3000_state* state = fe->demodulator_priv; in dib3000mb_sleep()
680 tune->min_delay_ms = 800; in dib3000mb_fe_get_tune_settings()
696 struct dib3000_state *state = fe->demodulator_priv; in dib3000mb_release()
703 struct dib3000_state *state = fe->demodulator_priv; in dib3000mb_pid_control()
711 struct dib3000_state *state = fe->demodulator_priv; in dib3000mb_fifo_control()
724 struct dib3000_state *state = fe->demodulator_priv; in dib3000mb_pid_parse()
732 struct dib3000_state *state = fe->demodulator_priv; in dib3000mb_tuner_pass_ctrl()
744 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops) in dib3000mb_attach() argument
754 state->i2c = i2c; in dib3000mb_attach()
755 memcpy(&state->config,config,sizeof(struct dib3000_config)); in dib3000mb_attach()
765 memcpy(&state->frontend.ops, &dib3000mb_ops, sizeof(struct dvb_frontend_ops)); in dib3000mb_attach()
766 state->frontend.demodulator_priv = state; in dib3000mb_attach()
769 xfer_ops->pid_parse = dib3000mb_pid_parse; in dib3000mb_attach()
770 xfer_ops->fifo_ctrl = dib3000mb_fifo_control; in dib3000mb_attach()
771 xfer_ops->pid_ctrl = dib3000mb_pid_control; in dib3000mb_attach()
772 xfer_ops->tuner_pass_ctrl = dib3000mb_tuner_pass_ctrl; in dib3000mb_attach()
774 return &state->frontend; in dib3000mb_attach()
784 .name = "DiBcom 3000M-B DVB-T",