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