xref: /linux/drivers/media/dvb-frontends/stv0367_priv.h (revision 870b7fdc660b38c4e1bd8bf48e62aa352ddf8f42)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * stv0367_priv.h
4  *
5  * Driver for ST STV0367 DVB-T & DVB-C demodulator IC.
6  *
7  * Copyright (C) ST Microelectronics.
8  * Copyright (C) 2010,2011 NetUP Inc.
9  * Copyright (C) 2010,2011 Igor M. Liplianin <liplianin@netup.ru>
10  */
11 /* Common driver error constants */
12 
13 #ifndef STV0367_PRIV_H
14 #define STV0367_PRIV_H
15 
16 #ifndef TRUE
17     #define TRUE (1 == 1)
18 #endif
19 #ifndef FALSE
20     #define FALSE (!TRUE)
21 #endif
22 
23 #ifndef NULL
24 #define NULL 0
25 #endif
26 
27 /* MACRO definitions */
28 #ifndef MIN
29 #define MAX(X, Y) ((X) >= (Y) ? (X) : (Y))
30 #define MIN(X, Y) ((X) <= (Y) ? (X) : (Y))
31 #endif
32 
33 #define INRANGE(X, Y, Z) \
34 	((((X) <= (Y)) && ((Y) <= (Z))) || \
35 	(((Z) <= (Y)) && ((Y) <= (X))) ? 1 : 0)
36 
37 #ifndef MAKEWORD
38 #define MAKEWORD(X, Y) (((X) << 8) + (Y))
39 #endif
40 
41 #define LSB(X) (((X) & 0xff))
42 #define MSB(Y) (((Y) >> 8) & 0xff)
43 #define MMSB(Y)(((Y) >> 16) & 0xff)
44 
45 enum stv0367_ter_signal_type {
46 	FE_TER_NOAGC = 0,
47 	FE_TER_AGCOK = 5,
48 	FE_TER_NOTPS = 6,
49 	FE_TER_TPSOK = 7,
50 	FE_TER_NOSYMBOL = 8,
51 	FE_TER_BAD_CPQ = 9,
52 	FE_TER_PRFOUNDOK = 10,
53 	FE_TER_NOPRFOUND = 11,
54 	FE_TER_LOCKOK = 12,
55 	FE_TER_NOLOCK = 13,
56 	FE_TER_SYMBOLOK = 15,
57 	FE_TER_CPAMPOK = 16,
58 	FE_TER_NOCPAMP = 17,
59 	FE_TER_SWNOK = 18
60 };
61 
62 enum stv0367_ts_mode {
63 	STV0367_OUTPUTMODE_DEFAULT,
64 	STV0367_SERIAL_PUNCT_CLOCK,
65 	STV0367_SERIAL_CONT_CLOCK,
66 	STV0367_PARALLEL_PUNCT_CLOCK,
67 	STV0367_DVBCI_CLOCK
68 };
69 
70 enum stv0367_clk_pol {
71 	STV0367_CLOCKPOLARITY_DEFAULT,
72 	STV0367_RISINGEDGE_CLOCK,
73 	STV0367_FALLINGEDGE_CLOCK
74 };
75 
76 enum stv0367_ter_bw {
77 	FE_TER_CHAN_BW_6M = 6,
78 	FE_TER_CHAN_BW_7M = 7,
79 	FE_TER_CHAN_BW_8M = 8
80 };
81 
82 #if 0
83 enum FE_TER_Rate_TPS {
84 	FE_TER_TPS_1_2 = 0,
85 	FE_TER_TPS_2_3 = 1,
86 	FE_TER_TPS_3_4 = 2,
87 	FE_TER_TPS_5_6 = 3,
88 	FE_TER_TPS_7_8 = 4
89 };
90 #endif
91 
92 enum stv0367_ter_mode {
93 	FE_TER_MODE_2K,
94 	FE_TER_MODE_8K,
95 	FE_TER_MODE_4K
96 };
97 #if 0
98 enum FE_TER_Hierarchy_Alpha {
99 	FE_TER_HIER_ALPHA_NONE,	/* Regular modulation */
100 	FE_TER_HIER_ALPHA_1,	/* Hierarchical modulation a = 1*/
101 	FE_TER_HIER_ALPHA_2,	/* Hierarchical modulation a = 2*/
102 	FE_TER_HIER_ALPHA_4	/* Hierarchical modulation a = 4*/
103 };
104 #endif
105 enum stv0367_ter_hierarchy {
106 	FE_TER_HIER_NONE,	/*Hierarchy None*/
107 	FE_TER_HIER_LOW_PRIO,	/*Hierarchy : Low Priority*/
108 	FE_TER_HIER_HIGH_PRIO,	/*Hierarchy : High Priority*/
109 	FE_TER_HIER_PRIO_ANY	/*Hierarchy  :Any*/
110 };
111 
112 #if 0
113 enum fe_stv0367_ter_spec {
114 	FE_TER_INVERSION_NONE = 0,
115 	FE_TER_INVERSION = 1,
116 	FE_TER_INVERSION_AUTO = 2,
117 	FE_TER_INVERSION_UNK  = 4
118 };
119 #endif
120 
121 enum stv0367_ter_if_iq_mode {
122 	FE_TER_NORMAL_IF_TUNER = 0,
123 	FE_TER_LONGPATH_IF_TUNER = 1,
124 	FE_TER_IQ_TUNER = 2
125 
126 };
127 
128 #if 0
129 enum FE_TER_FECRate {
130 	FE_TER_FEC_NONE = 0x00,	/* no FEC rate specified */
131 	FE_TER_FEC_ALL = 0xFF,	 /* Logical OR of all FECs */
132 	FE_TER_FEC_1_2 = 1,
133 	FE_TER_FEC_2_3 = (1 << 1),
134 	FE_TER_FEC_3_4 = (1 << 2),
135 	FE_TER_FEC_4_5 = (1 << 3),
136 	FE_TER_FEC_5_6 = (1 << 4),
137 	FE_TER_FEC_6_7 = (1 << 5),
138 	FE_TER_FEC_7_8 = (1 << 6),
139 	FE_TER_FEC_8_9 = (1 << 7)
140 };
141 
142 enum FE_TER_Rate {
143 	FE_TER_FE_1_2 = 0,
144 	FE_TER_FE_2_3 = 1,
145 	FE_TER_FE_3_4 = 2,
146 	FE_TER_FE_5_6 = 3,
147 	FE_TER_FE_6_7 = 4,
148 	FE_TER_FE_7_8 = 5
149 };
150 #endif
151 
152 enum stv0367_ter_force {
153 	FE_TER_FORCENONE = 0,
154 	FE_TER_FORCE_M_G = 1
155 };
156 
157 enum  stv0367cab_mod {
158 	FE_CAB_MOD_QAM4,
159 	FE_CAB_MOD_QAM16,
160 	FE_CAB_MOD_QAM32,
161 	FE_CAB_MOD_QAM64,
162 	FE_CAB_MOD_QAM128,
163 	FE_CAB_MOD_QAM256,
164 	FE_CAB_MOD_QAM512,
165 	FE_CAB_MOD_QAM1024
166 };
167 #if 0
168 enum {
169 	FE_CAB_FEC_A = 1,	/* J83 Annex A */
170 	FE_CAB_FEC_B = (1 << 1),/* J83 Annex B */
171 	FE_CAB_FEC_C = (1 << 2)	/* J83 Annex C */
172 } FE_CAB_FECType_t;
173 #endif
174 struct stv0367_cab_signal_info {
175 	int locked;
176 	u32 frequency; /* kHz */
177 	u32 symbol_rate; /* Mbds */
178 	enum stv0367cab_mod modulation;
179 	enum fe_spectral_inversion spect_inv;
180 	s32 Power_dBmx10;	/* Power of the RF signal (dBm x 10) */
181 	u32	CN_dBx10;	/* Carrier to noise ratio (dB x 10) */
182 	u32	BER;		/* Bit error rate (x 10000000)	*/
183 };
184 
185 enum stv0367_cab_signal_type {
186 	FE_CAB_NOTUNER,
187 	FE_CAB_NOAGC,
188 	FE_CAB_NOSIGNAL,
189 	FE_CAB_NOTIMING,
190 	FE_CAB_TIMINGOK,
191 	FE_CAB_NOCARRIER,
192 	FE_CAB_CARRIEROK,
193 	FE_CAB_NOBLIND,
194 	FE_CAB_BLINDOK,
195 	FE_CAB_NODEMOD,
196 	FE_CAB_DEMODOK,
197 	FE_CAB_DATAOK
198 };
199 
200 #endif
201