Lines Matching +full:p +full:- +full:state
1 // SPDX-License-Identifier: GPL-2.0
3 * ddbridge-sx8.c: Digital Devices MAX SX8 driver
11 #include "ddbridge-io.h"
12 #include "ddbridge-mci.h"
48 struct sx8 *state = fe->demodulator_priv; in release() local
49 struct mci_base *mci_base = state->mci.base; in release()
51 mci_base->count--; in release()
52 if (mci_base->count == 0) { in release()
53 list_del(&mci_base->mci_list); in release()
56 kfree(state); in release()
62 struct sx8 *state = fe->demodulator_priv; in get_info() local
67 cmd.demod = state->mci.demod; in get_info()
68 stat = ddb_mci_cmd(&state->mci, &cmd, &state->signal_info); in get_info()
74 struct sx8 *state = fe->demodulator_priv; in get_snr() local
75 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in get_snr() local
77 p->cnr.len = 1; in get_snr()
78 p->cnr.stat[0].scale = FE_SCALE_DECIBEL; in get_snr()
79 p->cnr.stat[0].svalue = in get_snr()
80 (s64)state->signal_info.dvbs2_signal_info.signal_to_noise in get_snr()
87 struct sx8 *state = fe->demodulator_priv; in get_strength() local
88 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in get_strength() local
91 str = 100000 - in get_strength()
92 (state->signal_info.dvbs2_signal_info.channel_power in get_strength()
94 p->strength.len = 1; in get_strength()
95 p->strength.stat[0].scale = FE_SCALE_DECIBEL; in get_strength()
96 p->strength.stat[0].svalue = str; in get_strength()
103 struct sx8 *state = fe->demodulator_priv; in read_status() local
108 cmd.demod = state->mci.demod; in read_status()
109 stat = ddb_mci_cmd(&state->mci, &cmd, &res); in read_status()
126 struct sx8 *state = fe->demodulator_priv; in mci_set_tuner() local
127 struct mci_base *mci_base = state->mci.base; in mci_set_tuner()
132 cmd.tuner = state->mci.tuner; in mci_set_tuner()
134 cmd.sx8_input_enable.flags = sx8_base->gain_mode[state->mci.tuner]; in mci_set_tuner()
135 return ddb_mci_cmd(&state->mci, &cmd, NULL); in mci_set_tuner()
140 struct sx8 *state = fe->demodulator_priv; in stop() local
141 struct mci_base *mci_base = state->mci.base; in stop()
144 u32 input = state->mci.tuner; in stop()
147 if (state->mci.demod != SX8_DEMOD_NONE) { in stop()
149 cmd.demod = state->mci.demod; in stop()
150 ddb_mci_cmd(&state->mci, &cmd, NULL); in stop()
151 if (sx8_base->iq_mode) { in stop()
153 cmd.demod = state->mci.demod; in stop()
155 ddb_mci_cmd(&state->mci, &cmd, NULL); in stop()
156 ddb_mci_config(&state->mci, SX8_TSCONFIG_MODE_NORMAL); in stop()
159 mutex_lock(&mci_base->tuner_lock); in stop()
160 sx8_base->tuner_use_count[input]--; in stop()
161 if (!sx8_base->tuner_use_count[input]) in stop()
163 if (state->mci.demod < SX8_DEMOD_NUM) { in stop()
164 sx8_base->demod_in_use[state->mci.demod] = 0; in stop()
165 state->mci.demod = SX8_DEMOD_NONE; in stop()
167 sx8_base->used_ldpc_bitrate[state->mci.nr] = 0; in stop()
168 sx8_base->iq_mode = 0; in stop()
169 mutex_unlock(&mci_base->tuner_lock); in stop()
170 state->started = 0; in stop()
176 struct sx8 *state = fe->demodulator_priv; in start() local
177 struct mci_base *mci_base = state->mci.base; in start()
179 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in start() local
183 u32 input = state->mci.tuner; in start()
185 int i = -1, stat = 0; in start()
187 if (p->symbol_rate >= (MCLK / 2)) in start()
190 return -EINVAL; in start()
202 mutex_lock(&mci_base->tuner_lock); in start()
203 if (sx8_base->iq_mode) { in start()
204 stat = -EBUSY; in start()
208 if (sx8_base->direct_mode) { in start()
209 if (p->symbol_rate >= MCLK / 2) { in start()
210 if (state->mci.nr < 4) in start()
211 i = state->mci.nr; in start()
213 i = state->mci.nr; in start()
217 used_ldpc_bitrate += sx8_base->used_ldpc_bitrate[i]; in start()
218 if (sx8_base->demod_in_use[i]) in start()
224 stat = -EBUSY; in start()
227 free_ldpc_bitrate = MAX_LDPC_BITRATE - used_ldpc_bitrate; in start()
231 while (p->symbol_rate * bits_per_symbol > free_ldpc_bitrate) in start()
232 bits_per_symbol--; in start()
234 stat = -EBUSY; in start()
238 modmask &= ((1 << (bits_per_symbol - 1)) - 1); in start()
240 stat = -EBUSY; in start()
244 i = (p->symbol_rate > (MCLK / 2)) ? 3 : 7; in start()
245 while (i >= 0 && sx8_base->demod_in_use[i]) in start()
246 i--; in start()
250 stat = -EBUSY; in start()
253 sx8_base->demod_in_use[i] = 1; in start()
254 sx8_base->used_ldpc_bitrate[state->mci.nr] = p->symbol_rate in start()
256 state->mci.demod = i; in start()
258 if (!sx8_base->tuner_use_count[input]) in start()
260 sx8_base->tuner_use_count[input]++; in start()
261 sx8_base->iq_mode = (ts_config > 1); in start()
263 mutex_unlock(&mci_base->tuner_lock); in start()
268 if (sx8_base->iq_mode) { in start()
270 cmd.demod = state->mci.demod; in start()
272 ddb_mci_cmd(&state->mci, &cmd, NULL); in start()
273 ddb_mci_config(&state->mci, ts_config); in start()
275 if (p->stream_id != NO_STREAM_ID_FILTER && p->stream_id != 0x80000000) in start()
277 dev_dbg(mci_base->dev, "MCI-%d: tuner=%d demod=%d\n", in start()
278 state->mci.nr, state->mci.tuner, state->mci.demod); in start()
283 cmd.dvbs2_search.frequency = p->frequency * 1000; in start()
284 cmd.dvbs2_search.symbol_rate = p->symbol_rate; in start()
286 p->scrambling_sequence_index | 0x80000000; in start()
288 (p->stream_id != NO_STREAM_ID_FILTER) ? p->stream_id : 0; in start()
289 cmd.tuner = state->mci.tuner; in start()
290 cmd.demod = state->mci.demod; in start()
291 cmd.output = state->mci.nr; in start()
292 if (p->stream_id == 0x80000000) in start()
294 stat = ddb_mci_cmd(&state->mci, &cmd, NULL); in start()
303 struct sx8 *state = fe->demodulator_priv; in start_iq() local
304 struct mci_base *mci_base = state->mci.base; in start_iq()
306 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in start_iq() local
309 u32 input = state->mci.tuner; in start_iq()
312 mutex_lock(&mci_base->tuner_lock); in start_iq()
313 if (sx8_base->iq_mode) { in start_iq()
314 stat = -EBUSY; in start_iq()
318 if (sx8_base->demod_in_use[i]) in start_iq()
321 stat = -EBUSY; in start_iq()
324 state->mci.demod = 0; in start_iq()
325 if (!sx8_base->tuner_use_count[input]) in start_iq()
327 sx8_base->tuner_use_count[input]++; in start_iq()
328 sx8_base->iq_mode = (ts_config > 1); in start_iq()
330 mutex_unlock(&mci_base->tuner_lock); in start_iq()
338 cmd.sx8_start_iq.frequency = p->frequency * 1000; in start_iq()
339 cmd.sx8_start_iq.symbol_rate = p->symbol_rate; in start_iq()
340 cmd.tuner = state->mci.tuner; in start_iq()
341 cmd.demod = state->mci.demod; in start_iq()
342 stat = ddb_mci_cmd(&state->mci, &cmd, NULL); in start_iq()
345 ddb_mci_config(&state->mci, ts_config); in start_iq()
352 struct sx8 *state = fe->demodulator_priv; in set_parameters() local
353 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in set_parameters() local
356 if (state->started) in set_parameters()
359 isi = p->stream_id; in set_parameters()
368 switch (p->modulation) { in set_parameters()
395 state->started = 1; in set_parameters()
396 state->first_time_lock = 1; in set_parameters()
397 state->signal_info.status = SX8_DEMOD_WAIT_SIGNAL; in set_parameters()
431 struct sx8 *state = fe->demodulator_priv; in set_input() local
432 struct mci_base *mci_base = state->mci.base; in set_input()
435 return -EINVAL; in set_input()
437 state->mci.tuner = input; in set_input()
438 dev_dbg(mci_base->dev, "MCI-%d: input=%d\n", state->mci.nr, input); in set_input()
445 .name = "Digital Devices MaxSX8 MCI DVB-S/S2/S2X",
464 struct sx8 *state = (struct sx8 *)mci; in init() local
466 state->mci.demod = SX8_DEMOD_NONE; in init()