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 #include <media/dvb_frontend.h> 16 17 /** 18 * struct vidtv_demod_cnr_to_qual_s - Map CNR values to a given combination of 19 * modulation and fec_inner 20 * @modulation: see enum fe_modulation 21 * @fec: see enum fe_fec_rate 22 * 23 * This struct matches values for 'good' and 'ok' CNRs given the combination 24 * of modulation and fec_inner in use. We might simulate some noise if the 25 * signal quality is not too good. 26 * 27 * The values were taken from libdvbv5. 28 */ 29 struct vidtv_demod_cnr_to_qual_s { 30 u32 modulation; 31 u32 fec; 32 u32 cnr_ok; 33 u32 cnr_good; 34 }; 35 36 /** 37 * struct vidtv_demod_config - Configuration used to init the demod 38 * @drop_tslock_prob_on_low_snr: probability of losing the lock due to low snr 39 * @recover_tslock_prob_on_good_snr: probability of recovering when the signal 40 * improves 41 * 42 * The configuration used to init the demodulator module, usually filled 43 * by a bridge driver. For vidtv, this is filled by vidtv_bridge before the 44 * demodulator module is probed. 45 */ 46 struct vidtv_demod_config { 47 u8 drop_tslock_prob_on_low_snr; 48 u8 recover_tslock_prob_on_good_snr; 49 }; 50 51 /** 52 * struct vidtv_demod_state - The demodulator state 53 * @frontend: The frontend structure allocated by the demod. 54 * @config: The config used to init the demod. 55 * @poll_snr: The task responsible for periodically checking the simulated 56 * signal quality, eventually dropping or reacquiring the TS lock. 57 * @status: the demod status. 58 * @cold_start: Whether the demod has not been init yet. 59 * @poll_snr_thread_running: Whether the task responsible for periodically 60 * checking the simulated signal quality is running. 61 * @poll_snr_thread_restart: Whether we should restart the poll_snr task. 62 */ 63 struct vidtv_demod_state { 64 struct dvb_frontend frontend; 65 struct vidtv_demod_config config; 66 enum fe_status status; 67 u16 tuner_cnr; 68 }; 69 #endif // VIDTV_DEMOD_H 70