blob: a777b4b944eb368f17ebe360ae37b989c2718e19 [file] [log] [blame]
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001/*
2 * Afatech AF9033 demodulator driver
3 *
4 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "af9033_priv.h"
23
24struct af9033_state {
25 struct i2c_adapter *i2c;
26 struct dvb_frontend fe;
27 struct af9033_config cfg;
28
29 u32 bandwidth_hz;
30 bool ts_mode_parallel;
31 bool ts_mode_serial;
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -030032
33 u32 ber;
34 u32 ucb;
35 unsigned long last_stat_check;
Antti Palosaari4b64bb22012-03-30 08:21:25 -030036};
37
38/* write multiple registers */
39static int af9033_wr_regs(struct af9033_state *state, u32 reg, const u8 *val,
40 int len)
41{
42 int ret;
43 u8 buf[3 + len];
44 struct i2c_msg msg[1] = {
45 {
46 .addr = state->cfg.i2c_addr,
47 .flags = 0,
48 .len = sizeof(buf),
49 .buf = buf,
50 }
51 };
52
53 buf[0] = (reg >> 16) & 0xff;
54 buf[1] = (reg >> 8) & 0xff;
55 buf[2] = (reg >> 0) & 0xff;
56 memcpy(&buf[3], val, len);
57
58 ret = i2c_transfer(state->i2c, msg, 1);
59 if (ret == 1) {
60 ret = 0;
61 } else {
Antti Palosaari0a73f2d2012-09-12 20:23:42 -030062 dev_warn(&state->i2c->dev, "%s: i2c wr failed=%d reg=%06x " \
63 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
Antti Palosaari4b64bb22012-03-30 08:21:25 -030064 ret = -EREMOTEIO;
65 }
66
67 return ret;
68}
69
70/* read multiple registers */
71static int af9033_rd_regs(struct af9033_state *state, u32 reg, u8 *val, int len)
72{
73 int ret;
74 u8 buf[3] = { (reg >> 16) & 0xff, (reg >> 8) & 0xff,
75 (reg >> 0) & 0xff };
76 struct i2c_msg msg[2] = {
77 {
78 .addr = state->cfg.i2c_addr,
79 .flags = 0,
80 .len = sizeof(buf),
81 .buf = buf
82 }, {
83 .addr = state->cfg.i2c_addr,
84 .flags = I2C_M_RD,
85 .len = len,
86 .buf = val
87 }
88 };
89
90 ret = i2c_transfer(state->i2c, msg, 2);
91 if (ret == 2) {
92 ret = 0;
93 } else {
Antti Palosaari0a73f2d2012-09-12 20:23:42 -030094 dev_warn(&state->i2c->dev, "%s: i2c rd failed=%d reg=%06x " \
95 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
Antti Palosaari4b64bb22012-03-30 08:21:25 -030096 ret = -EREMOTEIO;
97 }
98
99 return ret;
100}
101
102
103/* write single register */
104static int af9033_wr_reg(struct af9033_state *state, u32 reg, u8 val)
105{
106 return af9033_wr_regs(state, reg, &val, 1);
107}
108
109/* read single register */
110static int af9033_rd_reg(struct af9033_state *state, u32 reg, u8 *val)
111{
112 return af9033_rd_regs(state, reg, val, 1);
113}
114
115/* write single register with mask */
116static int af9033_wr_reg_mask(struct af9033_state *state, u32 reg, u8 val,
117 u8 mask)
118{
119 int ret;
120 u8 tmp;
121
122 /* no need for read if whole reg is written */
123 if (mask != 0xff) {
124 ret = af9033_rd_regs(state, reg, &tmp, 1);
125 if (ret)
126 return ret;
127
128 val &= mask;
129 tmp &= ~mask;
130 val |= tmp;
131 }
132
133 return af9033_wr_regs(state, reg, &val, 1);
134}
135
136/* read single register with mask */
137static int af9033_rd_reg_mask(struct af9033_state *state, u32 reg, u8 *val,
138 u8 mask)
139{
140 int ret, i;
141 u8 tmp;
142
143 ret = af9033_rd_regs(state, reg, &tmp, 1);
144 if (ret)
145 return ret;
146
147 tmp &= mask;
148
149 /* find position of the first bit */
150 for (i = 0; i < 8; i++) {
151 if ((mask >> i) & 0x01)
152 break;
153 }
154 *val = tmp >> i;
155
156 return 0;
157}
158
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300159/* write reg val table using reg addr auto increment */
160static int af9033_wr_reg_val_tab(struct af9033_state *state,
161 const struct reg_val *tab, int tab_len)
162{
163 int ret, i, j;
164 u8 buf[tab_len];
165
166 dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
167
168 for (i = 0, j = 0; i < tab_len; i++) {
169 buf[j] = tab[i].val;
170
171 if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1) {
172 ret = af9033_wr_regs(state, tab[i].reg - j, buf, j + 1);
173 if (ret < 0)
174 goto err;
175
176 j = 0;
177 } else {
178 j++;
179 }
180 }
181
182 return 0;
183
184err:
185 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
186
187 return ret;
188}
189
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300190static u32 af9033_div(struct af9033_state *state, u32 a, u32 b, u32 x)
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300191{
192 u32 r = 0, c = 0, i;
193
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300194 dev_dbg(&state->i2c->dev, "%s: a=%d b=%d x=%d\n", __func__, a, b, x);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300195
196 if (a > b) {
197 c = a / b;
198 a = a - c * b;
199 }
200
201 for (i = 0; i < x; i++) {
202 if (a >= b) {
203 r += 1;
204 a -= b;
205 }
206 a <<= 1;
207 r <<= 1;
208 }
209 r = (c << (u32)x) + r;
210
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300211 dev_dbg(&state->i2c->dev, "%s: a=%d b=%d x=%d r=%d r=%x\n",
212 __func__, a, b, x, r, r);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300213
214 return r;
215}
216
217static void af9033_release(struct dvb_frontend *fe)
218{
219 struct af9033_state *state = fe->demodulator_priv;
220
221 kfree(state);
222}
223
224static int af9033_init(struct dvb_frontend *fe)
225{
226 struct af9033_state *state = fe->demodulator_priv;
227 int ret, i, len;
228 const struct reg_val *init;
229 u8 buf[4];
230 u32 adc_cw, clock_cw;
231 struct reg_val_mask tab[] = {
232 { 0x80fb24, 0x00, 0x08 },
233 { 0x80004c, 0x00, 0xff },
234 { 0x00f641, state->cfg.tuner, 0xff },
235 { 0x80f5ca, 0x01, 0x01 },
236 { 0x80f715, 0x01, 0x01 },
237 { 0x00f41f, 0x04, 0x04 },
238 { 0x00f41a, 0x01, 0x01 },
239 { 0x80f731, 0x00, 0x01 },
240 { 0x00d91e, 0x00, 0x01 },
241 { 0x00d919, 0x00, 0x01 },
242 { 0x80f732, 0x00, 0x01 },
243 { 0x00d91f, 0x00, 0x01 },
244 { 0x00d91a, 0x00, 0x01 },
245 { 0x80f730, 0x00, 0x01 },
246 { 0x80f778, 0x00, 0xff },
247 { 0x80f73c, 0x01, 0x01 },
248 { 0x80f776, 0x00, 0x01 },
249 { 0x00d8fd, 0x01, 0xff },
250 { 0x00d830, 0x01, 0xff },
251 { 0x00d831, 0x00, 0xff },
252 { 0x00d832, 0x00, 0xff },
253 { 0x80f985, state->ts_mode_serial, 0x01 },
254 { 0x80f986, state->ts_mode_parallel, 0x01 },
255 { 0x00d827, 0x00, 0xff },
256 { 0x00d829, 0x00, 0xff },
Antti Palosaari4902bb32013-01-07 09:48:03 -0300257 { 0x800045, state->cfg.adc_multiplier, 0xff },
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300258 };
259
260 /* program clock control */
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300261 clock_cw = af9033_div(state, state->cfg.clock, 1000000ul, 19ul);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300262 buf[0] = (clock_cw >> 0) & 0xff;
263 buf[1] = (clock_cw >> 8) & 0xff;
264 buf[2] = (clock_cw >> 16) & 0xff;
265 buf[3] = (clock_cw >> 24) & 0xff;
266
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300267 dev_dbg(&state->i2c->dev, "%s: clock=%d clock_cw=%08x\n",
268 __func__, state->cfg.clock, clock_cw);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300269
270 ret = af9033_wr_regs(state, 0x800025, buf, 4);
271 if (ret < 0)
272 goto err;
273
274 /* program ADC control */
275 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
276 if (clock_adc_lut[i].clock == state->cfg.clock)
277 break;
278 }
279
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300280 adc_cw = af9033_div(state, clock_adc_lut[i].adc, 1000000ul, 19ul);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300281 buf[0] = (adc_cw >> 0) & 0xff;
282 buf[1] = (adc_cw >> 8) & 0xff;
283 buf[2] = (adc_cw >> 16) & 0xff;
284
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300285 dev_dbg(&state->i2c->dev, "%s: adc=%d adc_cw=%06x\n",
286 __func__, clock_adc_lut[i].adc, adc_cw);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300287
288 ret = af9033_wr_regs(state, 0x80f1cd, buf, 3);
289 if (ret < 0)
290 goto err;
291
292 /* program register table */
293 for (i = 0; i < ARRAY_SIZE(tab); i++) {
294 ret = af9033_wr_reg_mask(state, tab[i].reg, tab[i].val,
295 tab[i].mask);
296 if (ret < 0)
297 goto err;
298 }
299
300 /* settings for TS interface */
301 if (state->cfg.ts_mode == AF9033_TS_MODE_USB) {
302 ret = af9033_wr_reg_mask(state, 0x80f9a5, 0x00, 0x01);
303 if (ret < 0)
304 goto err;
305
306 ret = af9033_wr_reg_mask(state, 0x80f9b5, 0x01, 0x01);
307 if (ret < 0)
308 goto err;
309 } else {
310 ret = af9033_wr_reg_mask(state, 0x80f990, 0x00, 0x01);
311 if (ret < 0)
312 goto err;
313
314 ret = af9033_wr_reg_mask(state, 0x80f9b5, 0x00, 0x01);
315 if (ret < 0)
316 goto err;
317 }
318
319 /* load OFSM settings */
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300320 dev_dbg(&state->i2c->dev, "%s: load ofsm settings\n", __func__);
Antti Palosaarife8eece2013-02-03 13:39:55 -0300321 switch (state->cfg.tuner) {
322 case AF9033_TUNER_IT9135_38:
323 case AF9033_TUNER_IT9135_51:
324 case AF9033_TUNER_IT9135_52:
Antti Palosaari463c3992013-03-07 00:03:06 -0300325 len = ARRAY_SIZE(ofsm_init_it9135_v1);
326 init = ofsm_init_it9135_v1;
327 break;
Antti Palosaarife8eece2013-02-03 13:39:55 -0300328 case AF9033_TUNER_IT9135_60:
329 case AF9033_TUNER_IT9135_61:
330 case AF9033_TUNER_IT9135_62:
Antti Palosaari463c3992013-03-07 00:03:06 -0300331 len = ARRAY_SIZE(ofsm_init_it9135_v2);
332 init = ofsm_init_it9135_v2;
Antti Palosaarife8eece2013-02-03 13:39:55 -0300333 break;
334 default:
335 len = ARRAY_SIZE(ofsm_init);
336 init = ofsm_init;
337 break;
338 }
339
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300340 ret = af9033_wr_reg_val_tab(state, init, len);
341 if (ret < 0)
342 goto err;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300343
344 /* load tuner specific settings */
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300345 dev_dbg(&state->i2c->dev, "%s: load tuner specific settings\n",
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300346 __func__);
347 switch (state->cfg.tuner) {
348 case AF9033_TUNER_TUA9001:
349 len = ARRAY_SIZE(tuner_init_tua9001);
350 init = tuner_init_tua9001;
351 break;
Michael Büschffc501f2012-04-02 12:18:36 -0300352 case AF9033_TUNER_FC0011:
353 len = ARRAY_SIZE(tuner_init_fc0011);
354 init = tuner_init_fc0011;
355 break;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300356 case AF9033_TUNER_MXL5007T:
357 len = ARRAY_SIZE(tuner_init_mxl5007t);
358 init = tuner_init_mxl5007t;
359 break;
Gianluca Gennarice1fe372012-04-02 17:25:14 -0300360 case AF9033_TUNER_TDA18218:
361 len = ARRAY_SIZE(tuner_init_tda18218);
362 init = tuner_init_tda18218;
363 break;
Oliver Schinagld67ceb32012-09-20 14:57:17 -0300364 case AF9033_TUNER_FC2580:
365 len = ARRAY_SIZE(tuner_init_fc2580);
366 init = tuner_init_fc2580;
367 break;
Antti Palosaarie713ad12012-12-02 18:47:00 -0300368 case AF9033_TUNER_FC0012:
369 len = ARRAY_SIZE(tuner_init_fc0012);
370 init = tuner_init_fc0012;
371 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300372 case AF9033_TUNER_IT9135_38:
Antti Palosaaria72cbb72013-03-07 21:17:55 -0300373 len = ARRAY_SIZE(tuner_init_it9135_38);
374 init = tuner_init_it9135_38;
375 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300376 case AF9033_TUNER_IT9135_51:
Antti Palosaaribb2e12a2013-03-07 21:25:16 -0300377 len = ARRAY_SIZE(tuner_init_it9135_51);
378 init = tuner_init_it9135_51;
379 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300380 case AF9033_TUNER_IT9135_52:
Antti Palosaari22d729f2013-03-07 21:29:05 -0300381 len = ARRAY_SIZE(tuner_init_it9135_52);
382 init = tuner_init_it9135_52;
383 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300384 case AF9033_TUNER_IT9135_60:
Antti Palosaaria49f53a2013-03-07 21:38:00 -0300385 len = ARRAY_SIZE(tuner_init_it9135_60);
386 init = tuner_init_it9135_60;
387 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300388 case AF9033_TUNER_IT9135_61:
Antti Palosaari85211322013-03-07 21:44:30 -0300389 len = ARRAY_SIZE(tuner_init_it9135_61);
390 init = tuner_init_it9135_61;
391 break;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300392 case AF9033_TUNER_IT9135_62:
Antti Palosaaridc4a2c42013-03-07 21:47:20 -0300393 len = ARRAY_SIZE(tuner_init_it9135_62);
394 init = tuner_init_it9135_62;
Antti Palosaari4902bb32013-01-07 09:48:03 -0300395 break;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300396 default:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300397 dev_dbg(&state->i2c->dev, "%s: unsupported tuner ID=%d\n",
398 __func__, state->cfg.tuner);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300399 ret = -ENODEV;
400 goto err;
401 }
402
Antti Palosaari3bf5e552013-03-08 16:54:09 -0300403 ret = af9033_wr_reg_val_tab(state, init, len);
404 if (ret < 0)
405 goto err;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300406
Jose Alberto Reguero98059922012-09-23 16:48:47 -0300407 if (state->cfg.ts_mode == AF9033_TS_MODE_SERIAL) {
408 ret = af9033_wr_reg_mask(state, 0x00d91c, 0x01, 0x01);
409 if (ret < 0)
410 goto err;
Antti Palosaaribf97b632012-12-08 22:51:19 -0300411
Jose Alberto Reguero98059922012-09-23 16:48:47 -0300412 ret = af9033_wr_reg_mask(state, 0x00d917, 0x00, 0x01);
413 if (ret < 0)
414 goto err;
Antti Palosaaribf97b632012-12-08 22:51:19 -0300415
Jose Alberto Reguero98059922012-09-23 16:48:47 -0300416 ret = af9033_wr_reg_mask(state, 0x00d916, 0x00, 0x01);
417 if (ret < 0)
418 goto err;
419 }
420
Antti Palosaari086991d2013-03-07 22:18:56 -0300421 switch (state->cfg.tuner) {
422 case AF9033_TUNER_IT9135_60:
423 case AF9033_TUNER_IT9135_61:
424 case AF9033_TUNER_IT9135_62:
425 ret = af9033_wr_reg(state, 0x800000, 0x01);
426 if (ret < 0)
427 goto err;
428 }
429
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300430 state->bandwidth_hz = 0; /* force to program all parameters */
431
432 return 0;
433
434err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300435 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300436
437 return ret;
438}
439
440static int af9033_sleep(struct dvb_frontend *fe)
441{
442 struct af9033_state *state = fe->demodulator_priv;
443 int ret, i;
444 u8 tmp;
445
446 ret = af9033_wr_reg(state, 0x80004c, 1);
447 if (ret < 0)
448 goto err;
449
450 ret = af9033_wr_reg(state, 0x800000, 0);
451 if (ret < 0)
452 goto err;
453
454 for (i = 100, tmp = 1; i && tmp; i--) {
455 ret = af9033_rd_reg(state, 0x80004c, &tmp);
456 if (ret < 0)
457 goto err;
458
459 usleep_range(200, 10000);
460 }
461
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300462 dev_dbg(&state->i2c->dev, "%s: loop=%d\n", __func__, i);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300463
464 if (i == 0) {
465 ret = -ETIMEDOUT;
466 goto err;
467 }
468
469 ret = af9033_wr_reg_mask(state, 0x80fb24, 0x08, 0x08);
470 if (ret < 0)
471 goto err;
472
473 /* prevent current leak (?) */
474 if (state->cfg.ts_mode == AF9033_TS_MODE_SERIAL) {
475 /* enable parallel TS */
476 ret = af9033_wr_reg_mask(state, 0x00d917, 0x00, 0x01);
477 if (ret < 0)
478 goto err;
479
480 ret = af9033_wr_reg_mask(state, 0x00d916, 0x01, 0x01);
481 if (ret < 0)
482 goto err;
483 }
484
485 return 0;
486
487err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300488 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300489
490 return ret;
491}
492
493static int af9033_get_tune_settings(struct dvb_frontend *fe,
494 struct dvb_frontend_tune_settings *fesettings)
495{
Antti Palosaarife8eece2013-02-03 13:39:55 -0300496 /* 800 => 2000 because IT9135 v2 is slow to gain lock */
497 fesettings->min_delay_ms = 2000;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300498 fesettings->step_size = 0;
499 fesettings->max_drift = 0;
500
501 return 0;
502}
503
504static int af9033_set_frontend(struct dvb_frontend *fe)
505{
506 struct af9033_state *state = fe->demodulator_priv;
507 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300508 int ret, i, spec_inv, sampling_freq;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300509 u8 tmp, buf[3], bandwidth_reg_val;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300510 u32 if_frequency, freq_cw, adc_freq;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300511
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300512 dev_dbg(&state->i2c->dev, "%s: frequency=%d bandwidth_hz=%d\n",
513 __func__, c->frequency, c->bandwidth_hz);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300514
515 /* check bandwidth */
516 switch (c->bandwidth_hz) {
517 case 6000000:
518 bandwidth_reg_val = 0x00;
519 break;
520 case 7000000:
521 bandwidth_reg_val = 0x01;
522 break;
523 case 8000000:
524 bandwidth_reg_val = 0x02;
525 break;
526 default:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300527 dev_dbg(&state->i2c->dev, "%s: invalid bandwidth_hz\n",
528 __func__);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300529 ret = -EINVAL;
530 goto err;
531 }
532
533 /* program tuner */
534 if (fe->ops.tuner_ops.set_params)
535 fe->ops.tuner_ops.set_params(fe);
536
537 /* program CFOE coefficients */
538 if (c->bandwidth_hz != state->bandwidth_hz) {
539 for (i = 0; i < ARRAY_SIZE(coeff_lut); i++) {
540 if (coeff_lut[i].clock == state->cfg.clock &&
541 coeff_lut[i].bandwidth_hz == c->bandwidth_hz) {
542 break;
543 }
544 }
545 ret = af9033_wr_regs(state, 0x800001,
546 coeff_lut[i].val, sizeof(coeff_lut[i].val));
547 }
548
549 /* program frequency control */
550 if (c->bandwidth_hz != state->bandwidth_hz) {
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300551 spec_inv = state->cfg.spec_inv ? -1 : 1;
552
553 for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
554 if (clock_adc_lut[i].clock == state->cfg.clock)
555 break;
556 }
557 adc_freq = clock_adc_lut[i].adc;
558
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300559 /* get used IF frequency */
560 if (fe->ops.tuner_ops.get_if_frequency)
561 fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
562 else
563 if_frequency = 0;
564
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300565 sampling_freq = if_frequency;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300566
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300567 while (sampling_freq > (adc_freq / 2))
568 sampling_freq -= adc_freq;
569
570 if (sampling_freq >= 0)
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300571 spec_inv *= -1;
572 else
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300573 sampling_freq *= -1;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300574
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300575 freq_cw = af9033_div(state, sampling_freq, adc_freq, 23ul);
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300576
577 if (spec_inv == -1)
Hans-Frieder Vogt182b9672012-10-03 05:25:40 -0300578 freq_cw = 0x800000 - freq_cw;
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300579
Antti Palosaari4902bb32013-01-07 09:48:03 -0300580 if (state->cfg.adc_multiplier == AF9033_ADC_MULTIPLIER_2X)
Hans-Frieder Vogt540fd4b2012-04-02 14:18:16 -0300581 freq_cw /= 2;
582
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300583 buf[0] = (freq_cw >> 0) & 0xff;
584 buf[1] = (freq_cw >> 8) & 0xff;
585 buf[2] = (freq_cw >> 16) & 0x7f;
Antti Palosaarife8eece2013-02-03 13:39:55 -0300586
587 /* FIXME: there seems to be calculation error here... */
588 if (if_frequency == 0)
589 buf[2] = 0;
590
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300591 ret = af9033_wr_regs(state, 0x800029, buf, 3);
592 if (ret < 0)
593 goto err;
594
595 state->bandwidth_hz = c->bandwidth_hz;
596 }
597
598 ret = af9033_wr_reg_mask(state, 0x80f904, bandwidth_reg_val, 0x03);
599 if (ret < 0)
600 goto err;
601
602 ret = af9033_wr_reg(state, 0x800040, 0x00);
603 if (ret < 0)
604 goto err;
605
606 ret = af9033_wr_reg(state, 0x800047, 0x00);
607 if (ret < 0)
608 goto err;
609
610 ret = af9033_wr_reg_mask(state, 0x80f999, 0x00, 0x01);
611 if (ret < 0)
612 goto err;
613
614 if (c->frequency <= 230000000)
615 tmp = 0x00; /* VHF */
616 else
617 tmp = 0x01; /* UHF */
618
619 ret = af9033_wr_reg(state, 0x80004b, tmp);
620 if (ret < 0)
621 goto err;
622
623 ret = af9033_wr_reg(state, 0x800000, 0x00);
624 if (ret < 0)
625 goto err;
626
627 return 0;
628
629err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300630 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300631
632 return ret;
633}
634
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300635static int af9033_get_frontend(struct dvb_frontend *fe)
636{
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300637 struct af9033_state *state = fe->demodulator_priv;
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300638 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300639 int ret;
640 u8 buf[8];
641
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300642 dev_dbg(&state->i2c->dev, "%s:\n", __func__);
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300643
644 /* read all needed registers */
645 ret = af9033_rd_regs(state, 0x80f900, buf, sizeof(buf));
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300646 if (ret < 0)
647 goto err;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300648
649 switch ((buf[0] >> 0) & 3) {
650 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300651 c->transmission_mode = TRANSMISSION_MODE_2K;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300652 break;
653 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300654 c->transmission_mode = TRANSMISSION_MODE_8K;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300655 break;
656 }
657
658 switch ((buf[1] >> 0) & 3) {
659 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300660 c->guard_interval = GUARD_INTERVAL_1_32;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300661 break;
662 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300663 c->guard_interval = GUARD_INTERVAL_1_16;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300664 break;
665 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300666 c->guard_interval = GUARD_INTERVAL_1_8;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300667 break;
668 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300669 c->guard_interval = GUARD_INTERVAL_1_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300670 break;
671 }
672
673 switch ((buf[2] >> 0) & 7) {
674 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300675 c->hierarchy = HIERARCHY_NONE;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300676 break;
677 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300678 c->hierarchy = HIERARCHY_1;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300679 break;
680 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300681 c->hierarchy = HIERARCHY_2;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300682 break;
683 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300684 c->hierarchy = HIERARCHY_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300685 break;
686 }
687
688 switch ((buf[3] >> 0) & 3) {
689 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300690 c->modulation = QPSK;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300691 break;
692 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300693 c->modulation = QAM_16;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300694 break;
695 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300696 c->modulation = QAM_64;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300697 break;
698 }
699
700 switch ((buf[4] >> 0) & 3) {
701 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300702 c->bandwidth_hz = 6000000;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300703 break;
704 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300705 c->bandwidth_hz = 7000000;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300706 break;
707 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300708 c->bandwidth_hz = 8000000;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300709 break;
710 }
711
712 switch ((buf[6] >> 0) & 7) {
713 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300714 c->code_rate_HP = FEC_1_2;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300715 break;
716 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300717 c->code_rate_HP = FEC_2_3;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300718 break;
719 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300720 c->code_rate_HP = FEC_3_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300721 break;
722 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300723 c->code_rate_HP = FEC_5_6;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300724 break;
725 case 4:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300726 c->code_rate_HP = FEC_7_8;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300727 break;
728 case 5:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300729 c->code_rate_HP = FEC_NONE;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300730 break;
731 }
732
733 switch ((buf[7] >> 0) & 7) {
734 case 0:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300735 c->code_rate_LP = FEC_1_2;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300736 break;
737 case 1:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300738 c->code_rate_LP = FEC_2_3;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300739 break;
740 case 2:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300741 c->code_rate_LP = FEC_3_4;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300742 break;
743 case 3:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300744 c->code_rate_LP = FEC_5_6;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300745 break;
746 case 4:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300747 c->code_rate_LP = FEC_7_8;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300748 break;
749 case 5:
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300750 c->code_rate_LP = FEC_NONE;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300751 break;
752 }
753
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300754 return 0;
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300755
Antti Palosaaride7f14fc2012-04-05 21:14:32 -0300756err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300757 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Gianluca Gennari0a4df232012-04-05 12:47:19 -0300758
759 return ret;
760}
761
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300762static int af9033_read_status(struct dvb_frontend *fe, fe_status_t *status)
763{
764 struct af9033_state *state = fe->demodulator_priv;
765 int ret;
766 u8 tmp;
767
768 *status = 0;
769
770 /* radio channel status, 0=no result, 1=has signal, 2=no signal */
771 ret = af9033_rd_reg(state, 0x800047, &tmp);
772 if (ret < 0)
773 goto err;
774
775 /* has signal */
776 if (tmp == 0x01)
777 *status |= FE_HAS_SIGNAL;
778
779 if (tmp != 0x02) {
780 /* TPS lock */
781 ret = af9033_rd_reg_mask(state, 0x80f5a9, &tmp, 0x01);
782 if (ret < 0)
783 goto err;
784
785 if (tmp)
786 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
787 FE_HAS_VITERBI;
788
789 /* full lock */
790 ret = af9033_rd_reg_mask(state, 0x80f999, &tmp, 0x01);
791 if (ret < 0)
792 goto err;
793
794 if (tmp)
795 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
796 FE_HAS_VITERBI | FE_HAS_SYNC |
797 FE_HAS_LOCK;
798 }
799
800 return 0;
801
802err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300803 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300804
805 return ret;
806}
807
808static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
809{
Antti Palosaarie898ef62012-04-01 12:50:02 -0300810 struct af9033_state *state = fe->demodulator_priv;
811 int ret, i, len;
812 u8 buf[3], tmp;
813 u32 snr_val;
814 const struct val_snr *uninitialized_var(snr_lut);
815
816 /* read value */
817 ret = af9033_rd_regs(state, 0x80002c, buf, 3);
818 if (ret < 0)
819 goto err;
820
821 snr_val = (buf[2] << 16) | (buf[1] << 8) | buf[0];
822
823 /* read current modulation */
824 ret = af9033_rd_reg(state, 0x80f903, &tmp);
825 if (ret < 0)
826 goto err;
827
828 switch ((tmp >> 0) & 3) {
829 case 0:
830 len = ARRAY_SIZE(qpsk_snr_lut);
831 snr_lut = qpsk_snr_lut;
832 break;
833 case 1:
834 len = ARRAY_SIZE(qam16_snr_lut);
835 snr_lut = qam16_snr_lut;
836 break;
837 case 2:
838 len = ARRAY_SIZE(qam64_snr_lut);
839 snr_lut = qam64_snr_lut;
840 break;
841 default:
842 goto err;
843 }
844
845 for (i = 0; i < len; i++) {
846 tmp = snr_lut[i].snr;
847
848 if (snr_val < snr_lut[i].val)
849 break;
850 }
851
852 *snr = tmp * 10; /* dB/10 */
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300853
854 return 0;
Antti Palosaarie898ef62012-04-01 12:50:02 -0300855
856err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300857 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaarie898ef62012-04-01 12:50:02 -0300858
859 return ret;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300860}
861
862static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
863{
864 struct af9033_state *state = fe->demodulator_priv;
865 int ret;
866 u8 strength2;
867
868 /* read signal strength of 0-100 scale */
869 ret = af9033_rd_reg(state, 0x800048, &strength2);
870 if (ret < 0)
871 goto err;
872
873 /* scale value to 0x0000-0xffff */
874 *strength = strength2 * 0xffff / 100;
875
876 return 0;
877
878err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300879 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300880
881 return ret;
882}
883
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300884static int af9033_update_ch_stat(struct af9033_state *state)
885{
886 int ret = 0;
887 u32 err_cnt, bit_cnt;
888 u16 abort_cnt;
889 u8 buf[7];
890
891 /* only update data every half second */
892 if (time_after(jiffies, state->last_stat_check + msecs_to_jiffies(500))) {
893 ret = af9033_rd_regs(state, 0x800032, buf, sizeof(buf));
894 if (ret < 0)
895 goto err;
896 /* in 8 byte packets? */
897 abort_cnt = (buf[1] << 8) + buf[0];
898 /* in bits */
899 err_cnt = (buf[4] << 16) + (buf[3] << 8) + buf[2];
900 /* in 8 byte packets? always(?) 0x2710 = 10000 */
901 bit_cnt = (buf[6] << 8) + buf[5];
902
903 if (bit_cnt < abort_cnt) {
904 abort_cnt = 1000;
905 state->ber = 0xffffffff;
906 } else {
907 /* 8 byte packets, that have not been rejected already */
908 bit_cnt -= (u32)abort_cnt;
909 if (bit_cnt == 0) {
910 state->ber = 0xffffffff;
911 } else {
912 err_cnt -= (u32)abort_cnt * 8 * 8;
913 bit_cnt *= 8 * 8;
914 state->ber = err_cnt * (0xffffffff / bit_cnt);
915 }
916 }
917 state->ucb += abort_cnt;
918 state->last_stat_check = jiffies;
919 }
920
921 return 0;
922err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300923 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
924
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300925 return ret;
926}
927
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300928static int af9033_read_ber(struct dvb_frontend *fe, u32 *ber)
929{
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300930 struct af9033_state *state = fe->demodulator_priv;
931 int ret;
932
933 ret = af9033_update_ch_stat(state);
934 if (ret < 0)
935 return ret;
936
937 *ber = state->ber;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300938
939 return 0;
940}
941
942static int af9033_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
943{
Hans-Frieder Vogt47eafa52012-04-07 10:34:34 -0300944 struct af9033_state *state = fe->demodulator_priv;
945 int ret;
946
947 ret = af9033_update_ch_stat(state);
948 if (ret < 0)
949 return ret;
950
951 *ucblocks = state->ucb;
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300952
953 return 0;
954}
955
956static int af9033_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
957{
958 struct af9033_state *state = fe->demodulator_priv;
959 int ret;
960
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300961 dev_dbg(&state->i2c->dev, "%s: enable=%d\n", __func__, enable);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300962
963 ret = af9033_wr_reg_mask(state, 0x00fa04, enable, 0x01);
964 if (ret < 0)
965 goto err;
966
967 return 0;
968
969err:
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300970 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300971
972 return ret;
973}
974
975static struct dvb_frontend_ops af9033_ops;
976
977struct dvb_frontend *af9033_attach(const struct af9033_config *config,
978 struct i2c_adapter *i2c)
979{
980 int ret;
981 struct af9033_state *state;
982 u8 buf[8];
983
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300984 dev_dbg(&i2c->dev, "%s:\n", __func__);
Antti Palosaari4b64bb22012-03-30 08:21:25 -0300985
986 /* allocate memory for the internal state */
987 state = kzalloc(sizeof(struct af9033_state), GFP_KERNEL);
988 if (state == NULL)
989 goto err;
990
991 /* setup the state */
992 state->i2c = i2c;
993 memcpy(&state->cfg, config, sizeof(struct af9033_config));
994
Antti Palosaari8e8a5ac2012-04-01 14:13:36 -0300995 if (state->cfg.clock != 12000000) {
Antti Palosaari0a73f2d2012-09-12 20:23:42 -0300996 dev_err(&state->i2c->dev, "%s: af9033: unsupported clock=%d, " \
997 "only 12000000 Hz is supported currently\n",
998 KBUILD_MODNAME, state->cfg.clock);
Antti Palosaari8e8a5ac2012-04-01 14:13:36 -0300999 goto err;
1000 }
1001
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001002 /* firmware version */
1003 ret = af9033_rd_regs(state, 0x0083e9, &buf[0], 4);
1004 if (ret < 0)
1005 goto err;
1006
1007 ret = af9033_rd_regs(state, 0x804191, &buf[4], 4);
1008 if (ret < 0)
1009 goto err;
1010
Antti Palosaari0a73f2d2012-09-12 20:23:42 -03001011 dev_info(&state->i2c->dev, "%s: firmware version: LINK=%d.%d.%d.%d " \
1012 "OFDM=%d.%d.%d.%d\n", KBUILD_MODNAME, buf[0], buf[1],
1013 buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001014
Antti Palosaari0c13c542013-03-07 23:13:31 -03001015 /* sleep */
1016 switch (state->cfg.tuner) {
1017 case AF9033_TUNER_IT9135_38:
1018 case AF9033_TUNER_IT9135_51:
1019 case AF9033_TUNER_IT9135_52:
1020 case AF9033_TUNER_IT9135_60:
1021 case AF9033_TUNER_IT9135_61:
1022 case AF9033_TUNER_IT9135_62:
1023 /* IT9135 did not like to sleep at that early */
1024 break;
1025 default:
Antti Palosaari4902bb32013-01-07 09:48:03 -03001026 ret = af9033_wr_reg(state, 0x80004c, 1);
1027 if (ret < 0)
1028 goto err;
1029
1030 ret = af9033_wr_reg(state, 0x800000, 0);
1031 if (ret < 0)
1032 goto err;
1033 }
Antti Palosaari12897dc2012-09-16 22:26:57 -03001034
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001035 /* configure internal TS mode */
1036 switch (state->cfg.ts_mode) {
1037 case AF9033_TS_MODE_PARALLEL:
1038 state->ts_mode_parallel = true;
1039 break;
1040 case AF9033_TS_MODE_SERIAL:
1041 state->ts_mode_serial = true;
1042 break;
1043 case AF9033_TS_MODE_USB:
1044 /* usb mode for AF9035 */
1045 default:
1046 break;
1047 }
1048
1049 /* create dvb_frontend */
1050 memcpy(&state->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops));
1051 state->fe.demodulator_priv = state;
1052
1053 return &state->fe;
1054
1055err:
1056 kfree(state);
1057 return NULL;
1058}
1059EXPORT_SYMBOL(af9033_attach);
1060
1061static struct dvb_frontend_ops af9033_ops = {
1062 .delsys = { SYS_DVBT },
1063 .info = {
1064 .name = "Afatech AF9033 (DVB-T)",
1065 .frequency_min = 174000000,
1066 .frequency_max = 862000000,
1067 .frequency_stepsize = 250000,
1068 .frequency_tolerance = 0,
1069 .caps = FE_CAN_FEC_1_2 |
1070 FE_CAN_FEC_2_3 |
1071 FE_CAN_FEC_3_4 |
1072 FE_CAN_FEC_5_6 |
1073 FE_CAN_FEC_7_8 |
1074 FE_CAN_FEC_AUTO |
1075 FE_CAN_QPSK |
1076 FE_CAN_QAM_16 |
1077 FE_CAN_QAM_64 |
1078 FE_CAN_QAM_AUTO |
1079 FE_CAN_TRANSMISSION_MODE_AUTO |
1080 FE_CAN_GUARD_INTERVAL_AUTO |
1081 FE_CAN_HIERARCHY_AUTO |
1082 FE_CAN_RECOVER |
1083 FE_CAN_MUTE_TS
1084 },
1085
1086 .release = af9033_release,
1087
1088 .init = af9033_init,
1089 .sleep = af9033_sleep,
1090
1091 .get_tune_settings = af9033_get_tune_settings,
1092 .set_frontend = af9033_set_frontend,
Gianluca Gennari0a4df232012-04-05 12:47:19 -03001093 .get_frontend = af9033_get_frontend,
Antti Palosaari4b64bb22012-03-30 08:21:25 -03001094
1095 .read_status = af9033_read_status,
1096 .read_snr = af9033_read_snr,
1097 .read_signal_strength = af9033_read_signal_strength,
1098 .read_ber = af9033_read_ber,
1099 .read_ucblocks = af9033_read_ucblocks,
1100
1101 .i2c_gate_ctrl = af9033_i2c_gate_ctrl,
1102};
1103
1104MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1105MODULE_DESCRIPTION("Afatech AF9033 DVB-T demodulator driver");
1106MODULE_LICENSE("GPL");