1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * The Virtual DTV test driver serves as a reference DVB driver and helps 4 * validate the existing APIs in the media subsystem. It can also aid 5 * developers working on userspace applications. 6 * 7 * Copyright (C) 2020 Daniel W. S. Almeida 8 * Based on the example driver written by Emard <emard@softhome.net> 9 */ 10 11 #ifndef VIDTV_DEMOD_H 12 #define VIDTV_DEMOD_H 13 14 #include <linux/dvb/frontend.h> 15 16 #include <media/dvb_frontend.h> 17 18 /** 19 * struct vidtv_demod_cnr_to_qual_s - Map CNR values to a given combination of 20 * modulation and fec_inner 21 * @modulation: see enum fe_modulation 22 * @fec: see enum fe_fec_rate 23 * 24 * This struct matches values for 'good' and 'ok' CNRs given the combination 25 * of modulation and fec_inner in use. We might simulate some noise if the 26 * signal quality is not too good. 27 * 28 * The values were taken from libdvbv5. 29 */ 30 struct vidtv_demod_cnr_to_qual_s { 31 u32 modulation; 32 u32 fec; 33 u32 cnr_ok; 34 u32 cnr_good; 35 }; 36 37 /** 38 * struct vidtv_demod_config - Configuration used to init the demod 39 * @drop_tslock_prob_on_low_snr: probability of losing the lock due to low snr 40 * @recover_tslock_prob_on_good_snr: probability of recovering when the signal 41 * improves 42 * 43 * The configuration used to init the demodulator module, usually filled 44 * by a bridge driver. For vidtv, this is filled by vidtv_bridge before the 45 * demodulator module is probed. 46 */ 47 struct vidtv_demod_config { 48 u8 drop_tslock_prob_on_low_snr; 49 u8 recover_tslock_prob_on_good_snr; 50 }; 51 52 /** 53 * struct vidtv_demod_state - The demodulator state 54 * @frontend: The frontend structure allocated by the demod. 55 * @config: The config used to init the demod. 56 * @poll_snr: The task responsible for periodically checking the simulated 57 * signal quality, eventually dropping or reacquiring the TS lock. 58 * @status: the demod status. 59 * @cold_start: Whether the demod has not been init yet. 60 * @poll_snr_thread_running: Whether the task responsible for periodically 61 * checking the simulated signal quality is running. 62 * @poll_snr_thread_restart: Whether we should restart the poll_snr task. 63 */ 64 struct vidtv_demod_state { 65 struct dvb_frontend frontend; 66 struct vidtv_demod_config config; 67 enum fe_status status; 68 u16 tuner_cnr; 69 }; 70 #endif // VIDTV_DEMOD_H 71