]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/media/dvb-frontends/m88ds3103_priv.h
[media] m88ds3103: implement DVBv5 BER
[mirror_ubuntu-artful-kernel.git] / drivers / media / dvb-frontends / m88ds3103_priv.h
CommitLineData
395d00d1
AP
1/*
2 * Montage M88DS3103 demodulator driver
3 *
4 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
395d00d1
AP
15 */
16
17#ifndef M88DS3103_PRIV_H
18#define M88DS3103_PRIV_H
19
20#include "dvb_frontend.h"
21#include "m88ds3103.h"
22#include "dvb_math.h"
23#include <linux/firmware.h>
44b9055b 24#include <linux/i2c-mux.h>
3ae266f8 25#include <linux/math64.h>
395d00d1
AP
26
27#define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw"
f4df95bc 28#define M88RS6000_FIRMWARE "dvb-demod-m88rs6000.fw"
395d00d1 29#define M88DS3103_MCLK_KHZ 96000
f4df95bc 30#define M88RS6000_CHIP_ID 0x74
31#define M88DS3103_CHIP_ID 0x70
395d00d1
AP
32
33struct m88ds3103_priv {
34 struct i2c_adapter *i2c;
35 /* mutex needed due to own tuner I2C adapter */
36 struct mutex i2c_mutex;
37 const struct m88ds3103_config *cfg;
38 struct dvb_frontend fe;
39 fe_delivery_system_t delivery_system;
40 fe_status_t fe_status;
ce80d713 41 u32 dvbv3_ber; /* for old DVBv3 API read_ber */
395d00d1 42 bool warm; /* FW running */
44b9055b 43 struct i2c_adapter *i2c_adapter;
f4df95bc 44 /* auto detect chip id to do different config */
45 u8 chip_id;
46 /* main mclk is calculated for M88RS6000 dynamically */
47 u32 mclk_khz;
ce80d713
AP
48 u64 post_bit_error;
49 u64 post_bit_count;
395d00d1
AP
50};
51
52struct m88ds3103_reg_val {
53 u8 reg;
54 u8 val;
55};
56
57static const struct m88ds3103_reg_val m88ds3103_dvbs_init_reg_vals[] = {
58 {0x23, 0x07},
59 {0x08, 0x03},
60 {0x0c, 0x02},
61 {0x21, 0x54},
62 {0x25, 0x8a},
63 {0x27, 0x31},
64 {0x30, 0x08},
65 {0x31, 0x40},
66 {0x32, 0x32},
395d00d1
AP
67 {0x35, 0xff},
68 {0x3a, 0x00},
69 {0x37, 0x10},
70 {0x38, 0x10},
71 {0x39, 0x02},
72 {0x42, 0x60},
73 {0x4a, 0x80},
74 {0x4b, 0x04},
75 {0x4d, 0x91},
76 {0x5d, 0xc8},
77 {0x50, 0x36},
78 {0x51, 0x36},
79 {0x52, 0x36},
80 {0x53, 0x36},
dcaf0fbf 81 {0x56, 0x01},
395d00d1
AP
82 {0x63, 0x0f},
83 {0x64, 0x30},
84 {0x65, 0x40},
85 {0x68, 0x26},
86 {0x69, 0x4c},
87 {0x70, 0x20},
88 {0x71, 0x70},
89 {0x72, 0x04},
90 {0x73, 0x00},
91 {0x70, 0x40},
92 {0x71, 0x70},
93 {0x72, 0x04},
94 {0x73, 0x00},
95 {0x70, 0x60},
96 {0x71, 0x70},
97 {0x72, 0x04},
98 {0x73, 0x00},
99 {0x70, 0x80},
100 {0x71, 0x70},
101 {0x72, 0x04},
102 {0x73, 0x00},
103 {0x70, 0xa0},
104 {0x71, 0x70},
105 {0x72, 0x04},
106 {0x73, 0x00},
107 {0x70, 0x1f},
108 {0x76, 0x38},
109 {0x77, 0xa6},
110 {0x78, 0x0c},
111 {0x79, 0x80},
112 {0x7f, 0x14},
113 {0x7c, 0x00},
114 {0xae, 0x82},
115 {0x80, 0x64},
116 {0x81, 0x66},
117 {0x82, 0x44},
118 {0x85, 0x04},
119 {0xcd, 0xf4},
120 {0x90, 0x33},
121 {0xa0, 0x44},
122 {0xc0, 0x08},
123 {0xc3, 0x10},
124 {0xc4, 0x08},
125 {0xc5, 0xf0},
126 {0xc6, 0xff},
127 {0xc7, 0x00},
128 {0xc8, 0x1a},
129 {0xc9, 0x80},
130 {0xe0, 0xf8},
131 {0xe6, 0x8b},
132 {0xd0, 0x40},
133 {0xf8, 0x20},
134 {0xfa, 0x0f},
135 {0x00, 0x00},
136 {0xbd, 0x01},
137 {0xb8, 0x00},
138};
139
140static const struct m88ds3103_reg_val m88ds3103_dvbs2_init_reg_vals[] = {
141 {0x23, 0x07},
142 {0x08, 0x07},
143 {0x0c, 0x02},
144 {0x21, 0x54},
145 {0x25, 0x8a},
146 {0x27, 0x31},
147 {0x30, 0x08},
148 {0x32, 0x32},
395d00d1
AP
149 {0x35, 0xff},
150 {0x3a, 0x00},
151 {0x37, 0x10},
152 {0x38, 0x10},
153 {0x39, 0x02},
154 {0x42, 0x60},
155 {0x4a, 0x80},
156 {0x4b, 0x04},
157 {0x4d, 0x91},
158 {0x5d, 0xc8},
159 {0x50, 0x36},
160 {0x51, 0x36},
161 {0x52, 0x36},
162 {0x53, 0x36},
dcaf0fbf 163 {0x56, 0x01},
395d00d1
AP
164 {0x63, 0x0f},
165 {0x64, 0x10},
166 {0x65, 0x20},
167 {0x68, 0x46},
168 {0x69, 0xcd},
169 {0x70, 0x20},
170 {0x71, 0x70},
171 {0x72, 0x04},
172 {0x73, 0x00},
173 {0x70, 0x40},
174 {0x71, 0x70},
175 {0x72, 0x04},
176 {0x73, 0x00},
177 {0x70, 0x60},
178 {0x71, 0x70},
179 {0x72, 0x04},
180 {0x73, 0x00},
181 {0x70, 0x80},
182 {0x71, 0x70},
183 {0x72, 0x04},
184 {0x73, 0x00},
185 {0x70, 0xa0},
186 {0x71, 0x70},
187 {0x72, 0x04},
188 {0x73, 0x00},
189 {0x70, 0x1f},
190 {0x76, 0x38},
191 {0x77, 0xa6},
192 {0x78, 0x0c},
193 {0x79, 0x80},
194 {0x7f, 0x14},
195 {0x85, 0x08},
196 {0xcd, 0xf4},
197 {0x90, 0x33},
198 {0x86, 0x00},
199 {0x87, 0x0f},
200 {0x89, 0x00},
201 {0x8b, 0x44},
202 {0x8c, 0x66},
203 {0x9d, 0xc1},
204 {0x8a, 0x10},
205 {0xad, 0x40},
206 {0xa0, 0x44},
207 {0xc0, 0x08},
208 {0xc1, 0x10},
209 {0xc2, 0x08},
210 {0xc3, 0x10},
211 {0xc4, 0x08},
212 {0xc5, 0xf0},
213 {0xc6, 0xff},
214 {0xc7, 0x00},
215 {0xc8, 0x1a},
216 {0xc9, 0x80},
217 {0xca, 0x23},
218 {0xcb, 0x24},
219 {0xcc, 0xf4},
220 {0xce, 0x74},
221 {0x00, 0x00},
222 {0xbd, 0x01},
223 {0xb8, 0x00},
224};
225
f4df95bc 226static const struct m88ds3103_reg_val m88rs6000_dvbs_init_reg_vals[] = {
227 {0x23, 0x07},
228 {0x08, 0x03},
229 {0x0c, 0x02},
230 {0x20, 0x00},
231 {0x21, 0x54},
232 {0x25, 0x82},
233 {0x27, 0x31},
234 {0x30, 0x08},
235 {0x31, 0x40},
236 {0x32, 0x32},
237 {0x33, 0x35},
238 {0x35, 0xff},
239 {0x3a, 0x00},
240 {0x37, 0x10},
241 {0x38, 0x10},
242 {0x39, 0x02},
243 {0x42, 0x60},
244 {0x4a, 0x80},
245 {0x4b, 0x04},
246 {0x4d, 0x91},
247 {0x5d, 0xc8},
248 {0x50, 0x36},
249 {0x51, 0x36},
250 {0x52, 0x36},
251 {0x53, 0x36},
252 {0x63, 0x0f},
253 {0x64, 0x30},
254 {0x65, 0x40},
255 {0x68, 0x26},
256 {0x69, 0x4c},
257 {0x70, 0x20},
258 {0x71, 0x70},
259 {0x72, 0x04},
260 {0x73, 0x00},
261 {0x70, 0x40},
262 {0x71, 0x70},
263 {0x72, 0x04},
264 {0x73, 0x00},
265 {0x70, 0x60},
266 {0x71, 0x70},
267 {0x72, 0x04},
268 {0x73, 0x00},
269 {0x70, 0x80},
270 {0x71, 0x70},
271 {0x72, 0x04},
272 {0x73, 0x00},
273 {0x70, 0xa0},
274 {0x71, 0x70},
275 {0x72, 0x04},
276 {0x73, 0x00},
277 {0x70, 0x1f},
278 {0x76, 0x38},
279 {0x77, 0xa6},
280 {0x78, 0x0c},
281 {0x79, 0x80},
282 {0x7f, 0x14},
283 {0x7c, 0x00},
284 {0xae, 0x82},
285 {0x80, 0x64},
286 {0x81, 0x66},
287 {0x82, 0x44},
288 {0x85, 0x04},
289 {0xcd, 0xf4},
290 {0x90, 0x33},
291 {0xa0, 0x44},
292 {0xbe, 0x00},
293 {0xc0, 0x08},
294 {0xc3, 0x10},
295 {0xc4, 0x08},
296 {0xc5, 0xf0},
297 {0xc6, 0xff},
298 {0xc7, 0x00},
299 {0xc8, 0x1a},
300 {0xc9, 0x80},
301 {0xe0, 0xf8},
302 {0xe6, 0x8b},
303 {0xd0, 0x40},
304 {0xf8, 0x20},
305 {0xfa, 0x0f},
306 {0x00, 0x00},
307 {0xbd, 0x01},
308 {0xb8, 0x00},
309 {0x29, 0x11},
310};
311
312static const struct m88ds3103_reg_val m88rs6000_dvbs2_init_reg_vals[] = {
313 {0x23, 0x07},
314 {0x08, 0x07},
315 {0x0c, 0x02},
316 {0x20, 0x00},
317 {0x21, 0x54},
318 {0x25, 0x82},
319 {0x27, 0x31},
320 {0x30, 0x08},
321 {0x32, 0x32},
322 {0x33, 0x35},
323 {0x35, 0xff},
324 {0x3a, 0x00},
325 {0x37, 0x10},
326 {0x38, 0x10},
327 {0x39, 0x02},
328 {0x42, 0x60},
329 {0x4a, 0x80},
330 {0x4b, 0x04},
331 {0x4d, 0x91},
332 {0x5d, 0xc8},
333 {0x50, 0x36},
334 {0x51, 0x36},
335 {0x52, 0x36},
336 {0x53, 0x36},
337 {0x63, 0x0f},
338 {0x64, 0x10},
339 {0x65, 0x20},
340 {0x68, 0x46},
341 {0x69, 0xcd},
342 {0x70, 0x20},
343 {0x71, 0x70},
344 {0x72, 0x04},
345 {0x73, 0x00},
346 {0x70, 0x40},
347 {0x71, 0x70},
348 {0x72, 0x04},
349 {0x73, 0x00},
350 {0x70, 0x60},
351 {0x71, 0x70},
352 {0x72, 0x04},
353 {0x73, 0x00},
354 {0x70, 0x80},
355 {0x71, 0x70},
356 {0x72, 0x04},
357 {0x73, 0x00},
358 {0x70, 0xa0},
359 {0x71, 0x70},
360 {0x72, 0x04},
361 {0x73, 0x00},
362 {0x70, 0x1f},
363 {0x76, 0x38},
364 {0x77, 0xa6},
365 {0x78, 0x0c},
366 {0x79, 0x80},
367 {0x7f, 0x14},
368 {0x85, 0x08},
369 {0xcd, 0xf4},
370 {0x90, 0x33},
371 {0x86, 0x00},
372 {0x87, 0x0f},
373 {0x89, 0x00},
374 {0x8b, 0x44},
375 {0x8c, 0x66},
376 {0x9d, 0xc1},
377 {0x8a, 0x10},
378 {0xad, 0x40},
379 {0xa0, 0x44},
380 {0xbe, 0x00},
381 {0xc0, 0x08},
382 {0xc1, 0x10},
383 {0xc2, 0x08},
384 {0xc3, 0x10},
385 {0xc4, 0x08},
386 {0xc5, 0xf0},
387 {0xc6, 0xff},
388 {0xc7, 0x00},
389 {0xc8, 0x1a},
390 {0xc9, 0x80},
391 {0xca, 0x23},
392 {0xcb, 0x24},
393 {0xcc, 0xf4},
394 {0xce, 0x74},
395 {0x00, 0x00},
396 {0xbd, 0x01},
397 {0xb8, 0x00},
398 {0x29, 0x01},
399};
395d00d1 400#endif