Lines Matching +full:default +full:- +full:state
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * TerraTec Cinergy T2/qanu USB2 DVB-T adapter.
7 * Based on the dvb-usb-framework code and the
20 * convert linux-dvb frontend parameter set into TPS.
21 * See ETSI ETS-300744, section 4.6.2, table 9 for details.
26 * We replace erroneous fields by default TPS fields (the ones with value 0).
33 switch (op->code_rate_HP) { in compute_tps()
48 default: in compute_tps()
52 switch (op->code_rate_LP) { in compute_tps()
67 default: in compute_tps()
71 switch (op->modulation) { in compute_tps()
79 default: in compute_tps()
83 switch (op->transmission_mode) { in compute_tps()
88 default: in compute_tps()
92 switch (op->guard_interval) { in compute_tps()
103 default: in compute_tps()
107 switch (op->hierarchy) { in compute_tps()
118 default: in compute_tps()
138 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_read_status() local
141 mutex_lock(&state->data_mutex); in cinergyt2_fe_read_status()
142 state->data[0] = CINERGYT2_EP1_GET_TUNER_STATUS; in cinergyt2_fe_read_status()
144 ret = dvb_usb_generic_rw(state->d, state->data, 1, in cinergyt2_fe_read_status()
145 state->data, sizeof(state->status), 0); in cinergyt2_fe_read_status()
147 memcpy(&state->status, state->data, sizeof(state->status)); in cinergyt2_fe_read_status()
148 mutex_unlock(&state->data_mutex); in cinergyt2_fe_read_status()
155 if (0xffff - le16_to_cpu(state->status.gain) > 30) in cinergyt2_fe_read_status()
157 if (state->status.lock_bits & (1 << 6)) in cinergyt2_fe_read_status()
159 if (state->status.lock_bits & (1 << 5)) in cinergyt2_fe_read_status()
161 if (state->status.lock_bits & (1 << 4)) in cinergyt2_fe_read_status()
163 if (state->status.lock_bits & (1 << 1)) in cinergyt2_fe_read_status()
175 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_read_ber() local
177 *ber = le32_to_cpu(state->status.viterbi_error_rate); in cinergyt2_fe_read_ber()
183 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_read_unc_blocks() local
185 *unc = le32_to_cpu(state->status.uncorrected_block_count); in cinergyt2_fe_read_unc_blocks()
192 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_read_signal_strength() local
194 *strength = (0xffff - le16_to_cpu(state->status.gain)); in cinergyt2_fe_read_signal_strength()
200 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_read_snr() local
202 *snr = (state->status.snr << 8) | state->status.snr; in cinergyt2_fe_read_snr()
220 tune->min_delay_ms = 800; in cinergyt2_fe_get_tune_settings()
226 struct dtv_frontend_properties *fep = &fe->dtv_property_cache; in cinergyt2_fe_set_frontend()
227 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_set_frontend() local
231 mutex_lock(&state->data_mutex); in cinergyt2_fe_set_frontend()
233 param = (void *)state->data; in cinergyt2_fe_set_frontend()
234 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; in cinergyt2_fe_set_frontend()
235 param->tps = cpu_to_le16(compute_tps(fep)); in cinergyt2_fe_set_frontend()
236 param->freq = cpu_to_le32(fep->frequency / 1000); in cinergyt2_fe_set_frontend()
237 param->flags = 0; in cinergyt2_fe_set_frontend()
239 switch (fep->bandwidth_hz) { in cinergyt2_fe_set_frontend()
240 default: in cinergyt2_fe_set_frontend()
242 param->bandwidth = 8; in cinergyt2_fe_set_frontend()
245 param->bandwidth = 7; in cinergyt2_fe_set_frontend()
248 param->bandwidth = 6; in cinergyt2_fe_set_frontend()
252 err = dvb_usb_generic_rw(state->d, state->data, sizeof(*param), in cinergyt2_fe_set_frontend()
253 state->data, 2, 0); in cinergyt2_fe_set_frontend()
257 mutex_unlock(&state->data_mutex); in cinergyt2_fe_set_frontend()
263 struct cinergyt2_fe_state *state = fe->demodulator_priv; in cinergyt2_fe_release() local
264 kfree(state); in cinergyt2_fe_release()
276 s->d = d; in cinergyt2_fe_attach()
277 memcpy(&s->fe.ops, &cinergyt2_fe_ops, sizeof(struct dvb_frontend_ops)); in cinergyt2_fe_attach()
278 s->fe.demodulator_priv = s; in cinergyt2_fe_attach()
279 mutex_init(&s->data_mutex); in cinergyt2_fe_attach()
280 return &s->fe; in cinergyt2_fe_attach()