Lines Matching +full:default +full:- +full:state

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for Zarlink DVB-T ZL10353 demodulator
41 struct zl10353_state *state = fe->demodulator_priv; in zl10353_single_write() local
43 struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0, in zl10353_single_write()
45 int err = i2c_transfer(state->i2c, &msg, 1); in zl10353_single_write()
56 for (i = 0; i < ilen - 1; i++) in zl10353_write()
63 static int zl10353_read_register(struct zl10353_state *state, u8 reg) in zl10353_read_register() argument
68 struct i2c_msg msg[2] = { { .addr = state->config.demod_address, in zl10353_read_register()
71 { .addr = state->config.demod_address, in zl10353_read_register()
75 ret = i2c_transfer(state->i2c, msg, 2); in zl10353_read_register()
88 struct zl10353_state *state = fe->demodulator_priv; in zl10353_dump_regs() local
99 ret = zl10353_read_register(state, reg); in zl10353_dump_regs()
103 printk(KERN_CONT " --"); in zl10353_dump_regs()
114 struct zl10353_state *state = fe->demodulator_priv; in zl10353_calc_nominal_rate() local
119 if (state->config.adc_clock) in zl10353_calc_nominal_rate()
120 adc_clock = state->config.adc_clock; in zl10353_calc_nominal_rate()
133 struct zl10353_state *state = fe->demodulator_priv; in zl10353_calc_input_freq() local
139 if (state->config.adc_clock) in zl10353_calc_input_freq()
140 adc_clock = state->config.adc_clock; in zl10353_calc_input_freq()
141 if (state->config.if2) in zl10353_calc_input_freq()
142 if2 = state->config.if2; in zl10353_calc_input_freq()
147 ife = adc_clock - (if2 % adc_clock); in zl10353_calc_input_freq()
149 ife = adc_clock - ife; in zl10353_calc_input_freq()
152 *input_freq = -value; in zl10353_calc_input_freq()
155 __func__, if2, ife, adc_clock, -(int)value, *input_freq); in zl10353_calc_input_freq()
168 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in zl10353_set_parameters()
169 struct zl10353_state *state = fe->demodulator_priv; in zl10353_set_parameters() local
174 state->frequency = c->frequency; in zl10353_set_parameters()
184 if (c->transmission_mode != TRANSMISSION_MODE_AUTO) in zl10353_set_parameters()
186 if (c->guard_interval != GUARD_INTERVAL_AUTO) in zl10353_set_parameters()
190 switch (c->bandwidth_hz) { in zl10353_set_parameters()
202 default: in zl10353_set_parameters()
203 c->bandwidth_hz = 8000000; in zl10353_set_parameters()
211 zl10353_calc_nominal_rate(fe, c->bandwidth_hz, &nominal_rate); in zl10353_set_parameters()
214 state->bandwidth = c->bandwidth_hz; in zl10353_set_parameters()
221 switch (c->code_rate_HP) { in zl10353_set_parameters()
237 default: in zl10353_set_parameters()
238 return -EINVAL; in zl10353_set_parameters()
241 switch (c->code_rate_LP) { in zl10353_set_parameters()
258 if (c->hierarchy == HIERARCHY_AUTO || in zl10353_set_parameters()
259 c->hierarchy == HIERARCHY_NONE) in zl10353_set_parameters()
262 default: in zl10353_set_parameters()
263 return -EINVAL; in zl10353_set_parameters()
266 switch (c->modulation) { in zl10353_set_parameters()
276 default: in zl10353_set_parameters()
277 return -EINVAL; in zl10353_set_parameters()
280 switch (c->transmission_mode) { in zl10353_set_parameters()
287 default: in zl10353_set_parameters()
288 return -EINVAL; in zl10353_set_parameters()
291 switch (c->guard_interval) { in zl10353_set_parameters()
304 default: in zl10353_set_parameters()
305 return -EINVAL; in zl10353_set_parameters()
308 switch (c->hierarchy) { in zl10353_set_parameters()
321 default: in zl10353_set_parameters()
322 return -EINVAL; in zl10353_set_parameters()
328 if (fe->ops.i2c_gate_ctrl) in zl10353_set_parameters()
329 fe->ops.i2c_gate_ctrl(fe, 0); in zl10353_set_parameters()
336 if (state->config.no_tuner) { in zl10353_set_parameters()
337 if (fe->ops.tuner_ops.set_params) { in zl10353_set_parameters()
338 fe->ops.tuner_ops.set_params(fe); in zl10353_set_parameters()
339 if (fe->ops.i2c_gate_ctrl) in zl10353_set_parameters()
340 fe->ops.i2c_gate_ctrl(fe, 0); in zl10353_set_parameters()
342 } else if (fe->ops.tuner_ops.calc_regs) { in zl10353_set_parameters()
343 fe->ops.tuner_ops.calc_regs(fe, pllbuf + 1, 5); in zl10353_set_parameters()
351 if (state->config.no_tuner || fe->ops.tuner_ops.calc_regs == NULL) in zl10353_set_parameters()
362 struct zl10353_state *state = fe->demodulator_priv; in zl10353_get_parameters() local
376 s6 = zl10353_read_register(state, STATUS_6); in zl10353_get_parameters()
377 s9 = zl10353_read_register(state, STATUS_9); in zl10353_get_parameters()
379 return -EREMOTEIO; in zl10353_get_parameters()
381 return -EINVAL; /* no FE or TPS lock */ in zl10353_get_parameters()
383 tps = zl10353_read_register(state, TPS_RECEIVED_1) << 8 | in zl10353_get_parameters()
384 zl10353_read_register(state, TPS_RECEIVED_0); in zl10353_get_parameters()
386 c->code_rate_HP = tps_fec_to_api[(tps >> 7) & 7]; in zl10353_get_parameters()
387 c->code_rate_LP = tps_fec_to_api[(tps >> 4) & 7]; in zl10353_get_parameters()
391 c->modulation = QPSK; in zl10353_get_parameters()
394 c->modulation = QAM_16; in zl10353_get_parameters()
397 c->modulation = QAM_64; in zl10353_get_parameters()
399 default: in zl10353_get_parameters()
400 c->modulation = QAM_AUTO; in zl10353_get_parameters()
404 c->transmission_mode = (tps & 0x01) ? TRANSMISSION_MODE_8K : in zl10353_get_parameters()
409 c->guard_interval = GUARD_INTERVAL_1_32; in zl10353_get_parameters()
412 c->guard_interval = GUARD_INTERVAL_1_16; in zl10353_get_parameters()
415 c->guard_interval = GUARD_INTERVAL_1_8; in zl10353_get_parameters()
418 c->guard_interval = GUARD_INTERVAL_1_4; in zl10353_get_parameters()
420 default: in zl10353_get_parameters()
421 c->guard_interval = GUARD_INTERVAL_AUTO; in zl10353_get_parameters()
427 c->hierarchy = HIERARCHY_NONE; in zl10353_get_parameters()
430 c->hierarchy = HIERARCHY_1; in zl10353_get_parameters()
433 c->hierarchy = HIERARCHY_2; in zl10353_get_parameters()
436 c->hierarchy = HIERARCHY_4; in zl10353_get_parameters()
438 default: in zl10353_get_parameters()
439 c->hierarchy = HIERARCHY_AUTO; in zl10353_get_parameters()
443 c->frequency = state->frequency; in zl10353_get_parameters()
444 c->bandwidth_hz = state->bandwidth; in zl10353_get_parameters()
445 c->inversion = INVERSION_AUTO; in zl10353_get_parameters()
452 struct zl10353_state *state = fe->demodulator_priv; in zl10353_read_status() local
455 if ((s6 = zl10353_read_register(state, STATUS_6)) < 0) in zl10353_read_status()
456 return -EREMOTEIO; in zl10353_read_status()
457 if ((s7 = zl10353_read_register(state, STATUS_7)) < 0) in zl10353_read_status()
458 return -EREMOTEIO; in zl10353_read_status()
459 if ((s8 = zl10353_read_register(state, STATUS_8)) < 0) in zl10353_read_status()
460 return -EREMOTEIO; in zl10353_read_status()
483 struct zl10353_state *state = fe->demodulator_priv; in zl10353_read_ber() local
485 *ber = zl10353_read_register(state, RS_ERR_CNT_2) << 16 | in zl10353_read_ber()
486 zl10353_read_register(state, RS_ERR_CNT_1) << 8 | in zl10353_read_ber()
487 zl10353_read_register(state, RS_ERR_CNT_0); in zl10353_read_ber()
494 struct zl10353_state *state = fe->demodulator_priv; in zl10353_read_signal_strength() local
496 u16 signal = zl10353_read_register(state, AGC_GAIN_1) << 10 | in zl10353_read_signal_strength()
497 zl10353_read_register(state, AGC_GAIN_0) << 2 | 3; in zl10353_read_signal_strength()
506 struct zl10353_state *state = fe->demodulator_priv; in zl10353_read_snr() local
512 _snr = zl10353_read_register(state, SNR); in zl10353_read_snr()
520 struct zl10353_state *state = fe->demodulator_priv; in zl10353_read_ucblocks() local
523 ubl = zl10353_read_register(state, RS_UBC_1) << 8 | in zl10353_read_ucblocks()
524 zl10353_read_register(state, RS_UBC_0); in zl10353_read_ucblocks()
526 state->ucblocks += ubl; in zl10353_read_ucblocks()
527 *ucblocks = state->ucblocks; in zl10353_read_ucblocks()
536 fe_tune_settings->min_delay_ms = 1000; in zl10353_get_tune_settings()
537 fe_tune_settings->step_size = 0; in zl10353_get_tune_settings()
538 fe_tune_settings->max_drift = 0; in zl10353_get_tune_settings()
545 struct zl10353_state *state = fe->demodulator_priv; in zl10353_init() local
550 if (state->config.parallel_ts) in zl10353_init()
552 if (state->config.clock_ctl_1) in zl10353_init()
553 zl10353_reset_attach[3] = state->config.clock_ctl_1; in zl10353_init()
554 if (state->config.pll_0) in zl10353_init()
555 zl10353_reset_attach[4] = state->config.pll_0; in zl10353_init()
558 if (zl10353_read_register(state, 0x50) != zl10353_reset_attach[1] || in zl10353_init()
559 zl10353_read_register(state, 0x51) != zl10353_reset_attach[2]) { in zl10353_init()
571 struct zl10353_state *state = fe->demodulator_priv; in zl10353_i2c_gate_ctrl() local
574 if (state->config.disable_i2c_gate_ctrl) { in zl10353_i2c_gate_ctrl()
588 struct zl10353_state *state = fe->demodulator_priv; in zl10353_release() local
589 kfree(state); in zl10353_release()
597 struct zl10353_state *state = NULL; in zl10353_attach() local
600 /* allocate memory for the internal state */ in zl10353_attach()
601 state = kzalloc(sizeof(struct zl10353_state), GFP_KERNEL); in zl10353_attach()
602 if (state == NULL) in zl10353_attach()
605 /* setup the state */ in zl10353_attach()
606 state->i2c = i2c; in zl10353_attach()
607 memcpy(&state->config, config, sizeof(struct zl10353_config)); in zl10353_attach()
610 id = zl10353_read_register(state, CHIP_ID); in zl10353_attach()
615 memcpy(&state->frontend.ops, &zl10353_ops, sizeof(struct dvb_frontend_ops)); in zl10353_attach()
616 state->frontend.demodulator_priv = state; in zl10353_attach()
618 return &state->frontend; in zl10353_attach()
620 kfree(state); in zl10353_attach()
627 .name = "Zarlink ZL10353 DVB-T",
659 MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
662 MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off).");
664 MODULE_DESCRIPTION("Zarlink ZL10353 DVB-T demodulator driver");