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