Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / media / dvb / frontends / hd29l2_priv.h
blobba16dc3ec2bdf04143cb1bb24608bb1a4ee9b380
1 /*
2 * HDIC HD29L2 DMB-TH demodulator driver
4 * Copyright (C) 2011 Metropolia University of Applied Sciences, Electria R&D
6 * Author: Antti Palosaari <crope@iki.fi>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef HD29L2_PRIV
24 #define HD29L2_PRIV
26 #include <linux/dvb/version.h>
27 #include "dvb_frontend.h"
28 #include "dvb_math.h"
29 #include "hd29l2.h"
31 #define LOG_PREFIX "hd29l2"
33 #undef dbg
34 #define dbg(f, arg...) \
35 if (hd29l2_debug) \
36 printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
37 #undef err
38 #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg)
39 #undef info
40 #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
41 #undef warn
42 #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg)
44 #define HD29L2_XTAL 30400000 /* Hz */
47 #define HD29L2_QAM4NR 0x00
48 #define HD29L2_QAM4 0x01
49 #define HD29L2_QAM16 0x02
50 #define HD29L2_QAM32 0x03
51 #define HD29L2_QAM64 0x04
53 #define HD29L2_CODE_RATE_04 0x00
54 #define HD29L2_CODE_RATE_06 0x08
55 #define HD29L2_CODE_RATE_08 0x10
57 #define HD29L2_PN945 0x00
58 #define HD29L2_PN595 0x01
59 #define HD29L2_PN420 0x02
61 #define HD29L2_CARRIER_SINGLE 0x00
62 #define HD29L2_CARRIER_MULTI 0x01
64 #define HD29L2_INTERLEAVER_720 0x00
65 #define HD29L2_INTERLEAVER_420 0x01
67 struct reg_val {
68 u8 reg;
69 u8 val;
72 struct reg_mod_vals {
73 u8 reg;
74 u8 val[5];
77 struct hd29l2_priv {
78 struct i2c_adapter *i2c;
79 struct dvb_frontend fe;
80 struct hd29l2_config cfg;
81 u8 tuner_i2c_addr_programmed:1;
83 fe_status_t fe_status;
86 static const struct reg_mod_vals reg_mod_vals_tab[] = {
87 /* REG, QAM4NR, QAM4,QAM16,QAM32,QAM64 */
88 { 0x01, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
89 { 0x02, { 0x07, 0x07, 0x07, 0x07, 0x07 } },
90 { 0x03, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
91 { 0x04, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
92 { 0x05, { 0x61, 0x60, 0x60, 0x61, 0x60 } },
93 { 0x06, { 0xff, 0xff, 0xff, 0xff, 0xff } },
94 { 0x07, { 0xff, 0xff, 0xff, 0xff, 0xff } },
95 { 0x08, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
96 { 0x09, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
97 { 0x0a, { 0x15, 0x15, 0x03, 0x03, 0x03 } },
98 { 0x0d, { 0x78, 0x78, 0x88, 0x78, 0x78 } },
99 { 0x0e, { 0xa0, 0x90, 0xa0, 0xa0, 0xa0 } },
100 { 0x0f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
101 { 0x10, { 0xa0, 0xa0, 0x58, 0x38, 0x38 } },
102 { 0x11, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
103 { 0x12, { 0x5a, 0x5a, 0x5a, 0x5a, 0x5a } },
104 { 0x13, { 0xa2, 0xa2, 0xa2, 0xa2, 0xa2 } },
105 { 0x17, { 0x40, 0x40, 0x40, 0x40, 0x40 } },
106 { 0x18, { 0x21, 0x21, 0x42, 0x52, 0x42 } },
107 { 0x19, { 0x21, 0x21, 0x62, 0x72, 0x62 } },
108 { 0x1a, { 0x32, 0x43, 0xa9, 0xb9, 0xa9 } },
109 { 0x1b, { 0x32, 0x43, 0xb9, 0xd8, 0xb9 } },
110 { 0x1c, { 0x02, 0x02, 0x03, 0x02, 0x03 } },
111 { 0x1d, { 0x0c, 0x0c, 0x01, 0x02, 0x02 } },
112 { 0x1e, { 0x02, 0x02, 0x02, 0x01, 0x02 } },
113 { 0x1f, { 0x02, 0x02, 0x01, 0x02, 0x04 } },
114 { 0x20, { 0x01, 0x02, 0x01, 0x01, 0x01 } },
115 { 0x21, { 0x08, 0x08, 0x0a, 0x0a, 0x0a } },
116 { 0x22, { 0x06, 0x06, 0x04, 0x05, 0x05 } },
117 { 0x23, { 0x06, 0x06, 0x05, 0x03, 0x05 } },
118 { 0x24, { 0x08, 0x08, 0x05, 0x07, 0x07 } },
119 { 0x25, { 0x16, 0x10, 0x10, 0x0a, 0x10 } },
120 { 0x26, { 0x14, 0x14, 0x04, 0x04, 0x04 } },
121 { 0x27, { 0x58, 0x58, 0x58, 0x5c, 0x58 } },
122 { 0x28, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
123 { 0x29, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
124 { 0x2a, { 0x08, 0x0a, 0x08, 0x08, 0x08 } },
125 { 0x2b, { 0x08, 0x08, 0x08, 0x08, 0x08 } },
126 { 0x2c, { 0x06, 0x06, 0x06, 0x06, 0x06 } },
127 { 0x2d, { 0x05, 0x06, 0x06, 0x06, 0x06 } },
128 { 0x2e, { 0x21, 0x21, 0x21, 0x21, 0x21 } },
129 { 0x2f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
130 { 0x30, { 0x14, 0x14, 0x14, 0x14, 0x14 } },
131 { 0x33, { 0xb7, 0xb7, 0xb7, 0xb7, 0xb7 } },
132 { 0x34, { 0x81, 0x81, 0x81, 0x81, 0x81 } },
133 { 0x35, { 0x80, 0x80, 0x80, 0x80, 0x80 } },
134 { 0x37, { 0x70, 0x70, 0x70, 0x70, 0x70 } },
135 { 0x38, { 0x04, 0x04, 0x02, 0x02, 0x02 } },
136 { 0x39, { 0x07, 0x07, 0x05, 0x05, 0x05 } },
137 { 0x3a, { 0x06, 0x06, 0x06, 0x06, 0x06 } },
138 { 0x3b, { 0x03, 0x03, 0x03, 0x03, 0x03 } },
139 { 0x3c, { 0x07, 0x06, 0x04, 0x04, 0x04 } },
140 { 0x3d, { 0xf0, 0xf0, 0xf0, 0xf0, 0x80 } },
141 { 0x3e, { 0x60, 0x60, 0x60, 0x60, 0xff } },
142 { 0x3f, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
143 { 0x40, { 0x5b, 0x5b, 0x5b, 0x57, 0x50 } },
144 { 0x41, { 0x30, 0x30, 0x30, 0x30, 0x18 } },
145 { 0x42, { 0x20, 0x20, 0x20, 0x00, 0x30 } },
146 { 0x43, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
147 { 0x44, { 0x3f, 0x3f, 0x3f, 0x3f, 0x3f } },
148 { 0x45, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
149 { 0x46, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
150 { 0x47, { 0x00, 0x00, 0x95, 0x00, 0x95 } },
151 { 0x48, { 0xc0, 0xc0, 0xc0, 0xc0, 0xc0 } },
152 { 0x49, { 0xc0, 0xc0, 0xc0, 0xc0, 0xc0 } },
153 { 0x4a, { 0x40, 0x40, 0x33, 0x11, 0x11 } },
154 { 0x4b, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
155 { 0x4c, { 0x40, 0x40, 0x99, 0x11, 0x11 } },
156 { 0x4d, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
157 { 0x4e, { 0x40, 0x40, 0x66, 0x77, 0x77 } },
158 { 0x4f, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
159 { 0x50, { 0x40, 0x40, 0x88, 0x33, 0x11 } },
160 { 0x51, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
161 { 0x52, { 0x40, 0x40, 0x88, 0x02, 0x02 } },
162 { 0x53, { 0x40, 0x40, 0x00, 0x02, 0x02 } },
163 { 0x54, { 0x00, 0x00, 0x88, 0x33, 0x33 } },
164 { 0x55, { 0x40, 0x40, 0x00, 0x00, 0x00 } },
165 { 0x56, { 0x00, 0x00, 0x00, 0x0b, 0x00 } },
166 { 0x57, { 0x40, 0x40, 0x0a, 0x0b, 0x0a } },
167 { 0x58, { 0xaa, 0x00, 0x00, 0x00, 0x00 } },
168 { 0x59, { 0x7a, 0x40, 0x02, 0x02, 0x02 } },
169 { 0x5a, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
170 { 0x5b, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
171 { 0x5c, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
172 { 0x5d, { 0x18, 0x18, 0x01, 0x01, 0x01 } },
173 { 0x5e, { 0xc0, 0xc0, 0xc0, 0xff, 0xc0 } },
174 { 0x5f, { 0xc0, 0xc0, 0xc0, 0xff, 0xc0 } },
175 { 0x60, { 0x40, 0x40, 0x00, 0x30, 0x30 } },
176 { 0x61, { 0x40, 0x40, 0x10, 0x30, 0x30 } },
177 { 0x62, { 0x40, 0x40, 0x00, 0x30, 0x30 } },
178 { 0x63, { 0x40, 0x40, 0x05, 0x30, 0x30 } },
179 { 0x64, { 0x40, 0x40, 0x06, 0x00, 0x30 } },
180 { 0x65, { 0x40, 0x40, 0x06, 0x08, 0x30 } },
181 { 0x66, { 0x40, 0x40, 0x00, 0x00, 0x20 } },
182 { 0x67, { 0x40, 0x40, 0x01, 0x04, 0x20 } },
183 { 0x68, { 0x00, 0x00, 0x30, 0x00, 0x20 } },
184 { 0x69, { 0xa0, 0xa0, 0x00, 0x08, 0x20 } },
185 { 0x6a, { 0x00, 0x00, 0x30, 0x00, 0x25 } },
186 { 0x6b, { 0xa0, 0xa0, 0x00, 0x06, 0x25 } },
187 { 0x6c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
188 { 0x6d, { 0xa0, 0x60, 0x0c, 0x03, 0x0c } },
189 { 0x6e, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
190 { 0x6f, { 0xa0, 0x60, 0x04, 0x01, 0x04 } },
191 { 0x70, { 0x58, 0x58, 0xaa, 0xaa, 0xaa } },
192 { 0x71, { 0x58, 0x58, 0xaa, 0xaa, 0xaa } },
193 { 0x72, { 0x58, 0x58, 0xff, 0xff, 0xff } },
194 { 0x73, { 0x58, 0x58, 0xff, 0xff, 0xff } },
195 { 0x74, { 0x06, 0x06, 0x09, 0x05, 0x05 } },
196 { 0x75, { 0x06, 0x06, 0x0a, 0x10, 0x10 } },
197 { 0x76, { 0x10, 0x10, 0x06, 0x0a, 0x0a } },
198 { 0x77, { 0x12, 0x18, 0x28, 0x10, 0x28 } },
199 { 0x78, { 0xf8, 0xf8, 0xf8, 0xf8, 0xf8 } },
200 { 0x79, { 0x15, 0x15, 0x03, 0x03, 0x03 } },
201 { 0x7a, { 0x02, 0x02, 0x01, 0x04, 0x03 } },
202 { 0x7b, { 0x01, 0x02, 0x03, 0x03, 0x03 } },
203 { 0x7c, { 0x28, 0x28, 0x28, 0x28, 0x28 } },
204 { 0x7f, { 0x25, 0x92, 0x5f, 0x17, 0x2d } },
205 { 0x80, { 0x64, 0x64, 0x64, 0x74, 0x64 } },
206 { 0x83, { 0x06, 0x03, 0x04, 0x04, 0x04 } },
207 { 0x84, { 0xff, 0xff, 0xff, 0xff, 0xff } },
208 { 0x85, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
209 { 0x86, { 0x00, 0x00, 0x11, 0x11, 0x11 } },
210 { 0x87, { 0x03, 0x03, 0x03, 0x03, 0x03 } },
211 { 0x88, { 0x09, 0x09, 0x09, 0x09, 0x09 } },
212 { 0x89, { 0x20, 0x20, 0x30, 0x20, 0x20 } },
213 { 0x8a, { 0x03, 0x03, 0x02, 0x03, 0x02 } },
214 { 0x8b, { 0x00, 0x07, 0x09, 0x00, 0x09 } },
215 { 0x8c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
216 { 0x8d, { 0x4f, 0x4f, 0x4f, 0x3f, 0x4f } },
217 { 0x8e, { 0xf0, 0xf0, 0x60, 0xf0, 0xa0 } },
218 { 0x8f, { 0xe8, 0xe8, 0xe8, 0xe8, 0xe8 } },
219 { 0x90, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
220 { 0x91, { 0x40, 0x40, 0x70, 0x70, 0x10 } },
221 { 0x92, { 0x00, 0x00, 0x00, 0x00, 0x04 } },
222 { 0x93, { 0x60, 0x60, 0x60, 0x60, 0x60 } },
223 { 0x94, { 0x00, 0x00, 0x00, 0x00, 0x03 } },
224 { 0x95, { 0x09, 0x09, 0x47, 0x47, 0x47 } },
225 { 0x96, { 0x80, 0xa0, 0xa0, 0x40, 0xa0 } },
226 { 0x97, { 0x60, 0x60, 0x60, 0x60, 0x60 } },
227 { 0x98, { 0x50, 0x50, 0x50, 0x30, 0x50 } },
228 { 0x99, { 0x10, 0x10, 0x10, 0x10, 0x10 } },
229 { 0x9a, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
230 { 0x9b, { 0x40, 0x40, 0x40, 0x30, 0x40 } },
231 { 0x9c, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
232 { 0xa0, { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 } },
233 { 0xa1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
234 { 0xa2, { 0x30, 0x30, 0x00, 0x30, 0x00 } },
235 { 0xa3, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
236 { 0xa4, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
237 { 0xa5, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
238 { 0xa6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
239 { 0xa7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
240 { 0xa8, { 0x77, 0x77, 0x77, 0x77, 0x77 } },
241 { 0xa9, { 0x02, 0x02, 0x02, 0x02, 0x02 } },
242 { 0xaa, { 0x40, 0x40, 0x40, 0x40, 0x40 } },
243 { 0xac, { 0x1f, 0x1f, 0x1f, 0x1f, 0x1f } },
244 { 0xad, { 0x14, 0x14, 0x14, 0x14, 0x14 } },
245 { 0xae, { 0x78, 0x78, 0x78, 0x78, 0x78 } },
246 { 0xaf, { 0x06, 0x06, 0x06, 0x06, 0x07 } },
247 { 0xb0, { 0x1b, 0x1b, 0x1b, 0x19, 0x1b } },
248 { 0xb1, { 0x18, 0x17, 0x17, 0x18, 0x17 } },
249 { 0xb2, { 0x35, 0x82, 0x82, 0x38, 0x82 } },
250 { 0xb3, { 0xb6, 0xce, 0xc7, 0x5c, 0xb0 } },
251 { 0xb4, { 0x3f, 0x3e, 0x3e, 0x3f, 0x3e } },
252 { 0xb5, { 0x70, 0x58, 0x50, 0x68, 0x50 } },
253 { 0xb6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
254 { 0xb7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
255 { 0xb8, { 0x03, 0x03, 0x01, 0x01, 0x01 } },
256 { 0xb9, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
257 { 0xba, { 0x06, 0x06, 0x0a, 0x05, 0x0a } },
258 { 0xbb, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
259 { 0xbc, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
260 { 0xbd, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
261 { 0xbe, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
262 { 0xbf, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
263 { 0xc0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
264 { 0xc1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
265 { 0xc2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
266 { 0xc3, { 0x00, 0x00, 0x88, 0x66, 0x88 } },
267 { 0xc4, { 0x10, 0x10, 0x00, 0x00, 0x00 } },
268 { 0xc5, { 0x00, 0x00, 0x44, 0x60, 0x44 } },
269 { 0xc6, { 0x10, 0x0a, 0x00, 0x00, 0x00 } },
270 { 0xc7, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
271 { 0xc8, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
272 { 0xc9, { 0x90, 0x04, 0x00, 0x00, 0x00 } },
273 { 0xca, { 0x90, 0x08, 0x01, 0x01, 0x01 } },
274 { 0xcb, { 0xa0, 0x04, 0x00, 0x44, 0x00 } },
275 { 0xcc, { 0xa0, 0x10, 0x03, 0x00, 0x03 } },
276 { 0xcd, { 0x06, 0x06, 0x06, 0x05, 0x06 } },
277 { 0xce, { 0x05, 0x05, 0x01, 0x01, 0x01 } },
278 { 0xcf, { 0x40, 0x20, 0x18, 0x18, 0x18 } },
279 { 0xd0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
280 { 0xd1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
281 { 0xd2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
282 { 0xd3, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
283 { 0xd4, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
284 { 0xd5, { 0x05, 0x05, 0x05, 0x03, 0x05 } },
285 { 0xd6, { 0xac, 0x22, 0xca, 0x8f, 0xca } },
286 { 0xd7, { 0x20, 0x20, 0x20, 0x20, 0x20 } },
287 { 0xd8, { 0x01, 0x01, 0x01, 0x01, 0x01 } },
288 { 0xd9, { 0x00, 0x00, 0x0f, 0x00, 0x0f } },
289 { 0xda, { 0x00, 0xff, 0xff, 0x0e, 0xff } },
290 { 0xdb, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
291 { 0xdc, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
292 { 0xdd, { 0x05, 0x05, 0x05, 0x05, 0x05 } },
293 { 0xde, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
294 { 0xdf, { 0x42, 0x42, 0x44, 0x44, 0x04 } },
295 { 0xe0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
296 { 0xe1, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
297 { 0xe2, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
298 { 0xe3, { 0x00, 0x00, 0x26, 0x06, 0x26 } },
299 { 0xe4, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
300 { 0xe5, { 0x01, 0x0a, 0x01, 0x01, 0x01 } },
301 { 0xe6, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
302 { 0xe7, { 0x08, 0x08, 0x08, 0x08, 0x08 } },
303 { 0xe8, { 0x63, 0x63, 0x63, 0x63, 0x63 } },
304 { 0xe9, { 0x59, 0x59, 0x59, 0x59, 0x59 } },
305 { 0xea, { 0x80, 0x80, 0x20, 0x80, 0x80 } },
306 { 0xeb, { 0x37, 0x37, 0x78, 0x37, 0x77 } },
307 { 0xec, { 0x1f, 0x1f, 0x25, 0x25, 0x25 } },
308 { 0xed, { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a } },
309 { 0xee, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
310 { 0xef, { 0x70, 0x70, 0x58, 0x38, 0x58 } },
311 { 0xf0, { 0x00, 0x00, 0x00, 0x00, 0x00 } },
314 #endif /* HD29L2_PRIV */