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