diff options
Diffstat (limited to 'drivers/media/dvb/frontends/dib3000mc.c')
-rw-r--r-- | drivers/media/dvb/frontends/dib3000mc.c | 170 |
1 files changed, 104 insertions, 66 deletions
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c index 054d7e6d9662..cbbe2c2f05dc 100644 --- a/drivers/media/dvb/frontends/dib3000mc.c +++ b/drivers/media/dvb/frontends/dib3000mc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for DiBcom DiB3000MC/P-demodulator. | 2 | * Driver for DiBcom DiB3000MC/P-demodulator. |
3 | * | 3 | * |
4 | * Copyright (C) 2004-6 DiBcom (http://www.dibcom.fr/) | 4 | * Copyright (C) 2004-7 DiBcom (http://www.dibcom.fr/) |
5 | * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) | 5 | * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) |
6 | * | 6 | * |
7 | * This code is partially based on the previous dib3000mc.c . | 7 | * This code is partially based on the previous dib3000mc.c . |
@@ -26,7 +26,7 @@ static int debug; | |||
26 | module_param(debug, int, 0644); | 26 | module_param(debug, int, 0644); |
27 | MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); | 27 | MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); |
28 | 28 | ||
29 | #define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB3000MC/P:"); printk(args); } } while (0) | 29 | #define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB3000MC/P:"); printk(args); printk("\n"); } } while (0) |
30 | 30 | ||
31 | struct dib3000mc_state { | 31 | struct dib3000mc_state { |
32 | struct dvb_frontend demod; | 32 | struct dvb_frontend demod; |
@@ -71,7 +71,6 @@ static int dib3000mc_write_word(struct dib3000mc_state *state, u16 reg, u16 val) | |||
71 | return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; | 71 | return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | |||
75 | static int dib3000mc_identify(struct dib3000mc_state *state) | 74 | static int dib3000mc_identify(struct dib3000mc_state *state) |
76 | { | 75 | { |
77 | u16 value; | 76 | u16 value; |
@@ -92,7 +91,7 @@ static int dib3000mc_identify(struct dib3000mc_state *state) | |||
92 | return 0; | 91 | return 0; |
93 | } | 92 | } |
94 | 93 | ||
95 | static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, u8 update_offset) | 94 | static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u32 bw, u8 update_offset) |
96 | { | 95 | { |
97 | u32 timf; | 96 | u32 timf; |
98 | 97 | ||
@@ -103,7 +102,7 @@ static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, | |||
103 | } else | 102 | } else |
104 | timf = state->timf; | 103 | timf = state->timf; |
105 | 104 | ||
106 | timf *= (BW_INDEX_TO_KHZ(bw) / 1000); | 105 | timf *= (bw / 1000); |
107 | 106 | ||
108 | if (update_offset) { | 107 | if (update_offset) { |
109 | s16 tim_offs = dib3000mc_read_word(state, 416); | 108 | s16 tim_offs = dib3000mc_read_word(state, 416); |
@@ -111,17 +110,17 @@ static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, | |||
111 | if (tim_offs & 0x2000) | 110 | if (tim_offs & 0x2000) |
112 | tim_offs -= 0x4000; | 111 | tim_offs -= 0x4000; |
113 | 112 | ||
114 | if (nfft == 0) | 113 | if (nfft == TRANSMISSION_MODE_2K) |
115 | tim_offs *= 4; | 114 | tim_offs *= 4; |
116 | 115 | ||
117 | timf += tim_offs; | 116 | timf += tim_offs; |
118 | state->timf = timf / (BW_INDEX_TO_KHZ(bw) / 1000); | 117 | state->timf = timf / (bw / 1000); |
119 | } | 118 | } |
120 | 119 | ||
121 | dprintk("timf: %d\n", timf); | 120 | dprintk("timf: %d\n", timf); |
122 | 121 | ||
123 | dib3000mc_write_word(state, 23, timf >> 16); | 122 | dib3000mc_write_word(state, 23, (u16) (timf >> 16)); |
124 | dib3000mc_write_word(state, 24, timf & 0xffff); | 123 | dib3000mc_write_word(state, 24, (u16) (timf ) & 0xffff); |
125 | 124 | ||
126 | return 0; | 125 | return 0; |
127 | } | 126 | } |
@@ -209,31 +208,30 @@ static int dib3000mc_set_output_mode(struct dib3000mc_state *state, int mode) | |||
209 | return ret; | 208 | return ret; |
210 | } | 209 | } |
211 | 210 | ||
212 | static int dib3000mc_set_bandwidth(struct dvb_frontend *demod, u8 bw) | 211 | static int dib3000mc_set_bandwidth(struct dib3000mc_state *state, u32 bw) |
213 | { | 212 | { |
214 | struct dib3000mc_state *state = demod->demodulator_priv; | ||
215 | u16 bw_cfg[6] = { 0 }; | 213 | u16 bw_cfg[6] = { 0 }; |
216 | u16 imp_bw_cfg[3] = { 0 }; | 214 | u16 imp_bw_cfg[3] = { 0 }; |
217 | u16 reg; | 215 | u16 reg; |
218 | 216 | ||
219 | /* settings here are for 27.7MHz */ | 217 | /* settings here are for 27.7MHz */ |
220 | switch (bw) { | 218 | switch (bw) { |
221 | case BANDWIDTH_8_MHZ: | 219 | case 8000: |
222 | bw_cfg[0] = 0x0019; bw_cfg[1] = 0x5c30; bw_cfg[2] = 0x0054; bw_cfg[3] = 0x88a0; bw_cfg[4] = 0x01a6; bw_cfg[5] = 0xab20; | 220 | bw_cfg[0] = 0x0019; bw_cfg[1] = 0x5c30; bw_cfg[2] = 0x0054; bw_cfg[3] = 0x88a0; bw_cfg[4] = 0x01a6; bw_cfg[5] = 0xab20; |
223 | imp_bw_cfg[0] = 0x04db; imp_bw_cfg[1] = 0x00db; imp_bw_cfg[2] = 0x00b7; | 221 | imp_bw_cfg[0] = 0x04db; imp_bw_cfg[1] = 0x00db; imp_bw_cfg[2] = 0x00b7; |
224 | break; | 222 | break; |
225 | 223 | ||
226 | case BANDWIDTH_7_MHZ: | 224 | case 7000: |
227 | bw_cfg[0] = 0x001c; bw_cfg[1] = 0xfba5; bw_cfg[2] = 0x0060; bw_cfg[3] = 0x9c25; bw_cfg[4] = 0x01e3; bw_cfg[5] = 0x0cb7; | 225 | bw_cfg[0] = 0x001c; bw_cfg[1] = 0xfba5; bw_cfg[2] = 0x0060; bw_cfg[3] = 0x9c25; bw_cfg[4] = 0x01e3; bw_cfg[5] = 0x0cb7; |
228 | imp_bw_cfg[0] = 0x04c0; imp_bw_cfg[1] = 0x00c0; imp_bw_cfg[2] = 0x00a0; | 226 | imp_bw_cfg[0] = 0x04c0; imp_bw_cfg[1] = 0x00c0; imp_bw_cfg[2] = 0x00a0; |
229 | break; | 227 | break; |
230 | 228 | ||
231 | case BANDWIDTH_6_MHZ: | 229 | case 6000: |
232 | bw_cfg[0] = 0x0021; bw_cfg[1] = 0xd040; bw_cfg[2] = 0x0070; bw_cfg[3] = 0xb62b; bw_cfg[4] = 0x0233; bw_cfg[5] = 0x8ed5; | 230 | bw_cfg[0] = 0x0021; bw_cfg[1] = 0xd040; bw_cfg[2] = 0x0070; bw_cfg[3] = 0xb62b; bw_cfg[4] = 0x0233; bw_cfg[5] = 0x8ed5; |
233 | imp_bw_cfg[0] = 0x04a5; imp_bw_cfg[1] = 0x00a5; imp_bw_cfg[2] = 0x0089; | 231 | imp_bw_cfg[0] = 0x04a5; imp_bw_cfg[1] = 0x00a5; imp_bw_cfg[2] = 0x0089; |
234 | break; | 232 | break; |
235 | 233 | ||
236 | case 255 /* BANDWIDTH_5_MHZ */: | 234 | case 5000: |
237 | bw_cfg[0] = 0x0028; bw_cfg[1] = 0x9380; bw_cfg[2] = 0x0087; bw_cfg[3] = 0x4100; bw_cfg[4] = 0x02a4; bw_cfg[5] = 0x4500; | 235 | bw_cfg[0] = 0x0028; bw_cfg[1] = 0x9380; bw_cfg[2] = 0x0087; bw_cfg[3] = 0x4100; bw_cfg[4] = 0x02a4; bw_cfg[5] = 0x4500; |
238 | imp_bw_cfg[0] = 0x0489; imp_bw_cfg[1] = 0x0089; imp_bw_cfg[2] = 0x0072; | 236 | imp_bw_cfg[0] = 0x0489; imp_bw_cfg[1] = 0x0089; imp_bw_cfg[2] = 0x0072; |
239 | break; | 237 | break; |
@@ -257,7 +255,7 @@ static int dib3000mc_set_bandwidth(struct dvb_frontend *demod, u8 bw) | |||
257 | dib3000mc_write_word(state, reg, imp_bw_cfg[reg - 55]); | 255 | dib3000mc_write_word(state, reg, imp_bw_cfg[reg - 55]); |
258 | 256 | ||
259 | // Timing configuration | 257 | // Timing configuration |
260 | dib3000mc_set_timing(state, 0, bw, 0); | 258 | dib3000mc_set_timing(state, TRANSMISSION_MODE_2K, bw, 0); |
261 | 259 | ||
262 | return 0; | 260 | return 0; |
263 | } | 261 | } |
@@ -276,7 +274,7 @@ static void dib3000mc_set_impulse_noise(struct dib3000mc_state *state, u8 mode, | |||
276 | for (i = 58; i < 87; i++) | 274 | for (i = 58; i < 87; i++) |
277 | dib3000mc_write_word(state, i, impulse_noise_val[i-58]); | 275 | dib3000mc_write_word(state, i, impulse_noise_val[i-58]); |
278 | 276 | ||
279 | if (nfft == 1) { | 277 | if (nfft == TRANSMISSION_MODE_8K) { |
280 | dib3000mc_write_word(state, 58, 0x3b); | 278 | dib3000mc_write_word(state, 58, 0x3b); |
281 | dib3000mc_write_word(state, 84, 0x00); | 279 | dib3000mc_write_word(state, 84, 0x00); |
282 | dib3000mc_write_word(state, 85, 0x8200); | 280 | dib3000mc_write_word(state, 85, 0x8200); |
@@ -376,7 +374,7 @@ static int dib3000mc_init(struct dvb_frontend *demod) | |||
376 | // P_search_maxtrial=1 | 374 | // P_search_maxtrial=1 |
377 | dib3000mc_write_word(state, 5, 1); | 375 | dib3000mc_write_word(state, 5, 1); |
378 | 376 | ||
379 | dib3000mc_set_bandwidth(&state->demod, BANDWIDTH_8_MHZ); | 377 | dib3000mc_set_bandwidth(state, 8000); |
380 | 378 | ||
381 | // div_lock_mask | 379 | // div_lock_mask |
382 | dib3000mc_write_word(state, 4, 0x814); | 380 | dib3000mc_write_word(state, 4, 0x814); |
@@ -397,7 +395,7 @@ static int dib3000mc_init(struct dvb_frontend *demod) | |||
397 | dib3000mc_write_word(state, 180, 0x2FF0); | 395 | dib3000mc_write_word(state, 180, 0x2FF0); |
398 | 396 | ||
399 | // Impulse noise configuration | 397 | // Impulse noise configuration |
400 | dib3000mc_set_impulse_noise(state, 0, 1); | 398 | dib3000mc_set_impulse_noise(state, 0, TRANSMISSION_MODE_8K); |
401 | 399 | ||
402 | // output mode set-up | 400 | // output mode set-up |
403 | dib3000mc_set_output_mode(state, OUTMODE_HIGH_Z); | 401 | dib3000mc_set_output_mode(state, OUTMODE_HIGH_Z); |
@@ -423,13 +421,13 @@ static void dib3000mc_set_adp_cfg(struct dib3000mc_state *state, s16 qam) | |||
423 | { | 421 | { |
424 | u16 cfg[4] = { 0 },reg; | 422 | u16 cfg[4] = { 0 },reg; |
425 | switch (qam) { | 423 | switch (qam) { |
426 | case 0: | 424 | case QPSK: |
427 | cfg[0] = 0x099a; cfg[1] = 0x7fae; cfg[2] = 0x0333; cfg[3] = 0x7ff0; | 425 | cfg[0] = 0x099a; cfg[1] = 0x7fae; cfg[2] = 0x0333; cfg[3] = 0x7ff0; |
428 | break; | 426 | break; |
429 | case 1: | 427 | case QAM_16: |
430 | cfg[0] = 0x023d; cfg[1] = 0x7fdf; cfg[2] = 0x00a4; cfg[3] = 0x7ff0; | 428 | cfg[0] = 0x023d; cfg[1] = 0x7fdf; cfg[2] = 0x00a4; cfg[3] = 0x7ff0; |
431 | break; | 429 | break; |
432 | case 2: | 430 | case QAM_64: |
433 | cfg[0] = 0x0148; cfg[1] = 0x7ff0; cfg[2] = 0x00a4; cfg[3] = 0x7ff8; | 431 | cfg[0] = 0x0148; cfg[1] = 0x7ff0; cfg[2] = 0x00a4; cfg[3] = 0x7ff8; |
434 | break; | 432 | break; |
435 | } | 433 | } |
@@ -437,11 +435,11 @@ static void dib3000mc_set_adp_cfg(struct dib3000mc_state *state, s16 qam) | |||
437 | dib3000mc_write_word(state, reg, cfg[reg - 129]); | 435 | dib3000mc_write_word(state, reg, cfg[reg - 129]); |
438 | } | 436 | } |
439 | 437 | ||
440 | static void dib3000mc_set_channel_cfg(struct dib3000mc_state *state, struct dibx000_ofdm_channel *chan, u16 seq) | 438 | static void dib3000mc_set_channel_cfg(struct dib3000mc_state *state, struct dvb_frontend_parameters *ch, u16 seq) |
441 | { | 439 | { |
442 | u16 tmp; | 440 | u16 value; |
443 | 441 | dib3000mc_set_bandwidth(state, BANDWIDTH_TO_KHZ(ch->u.ofdm.bandwidth)); | |
444 | dib3000mc_set_timing(state, chan->nfft, chan->Bw, 0); | 442 | dib3000mc_set_timing(state, ch->u.ofdm.transmission_mode, BANDWIDTH_TO_KHZ(ch->u.ofdm.bandwidth), 0); |
445 | 443 | ||
446 | // if (boost) | 444 | // if (boost) |
447 | // dib3000mc_write_word(state, 100, (11 << 6) + 6); | 445 | // dib3000mc_write_word(state, 100, (11 << 6) + 6); |
@@ -455,7 +453,7 @@ static void dib3000mc_set_channel_cfg(struct dib3000mc_state *state, struct dibx | |||
455 | dib3000mc_write_word(state, 26, 0x6680); | 453 | dib3000mc_write_word(state, 26, 0x6680); |
456 | dib3000mc_write_word(state, 29, 0x1273); | 454 | dib3000mc_write_word(state, 29, 0x1273); |
457 | dib3000mc_write_word(state, 33, 5); | 455 | dib3000mc_write_word(state, 33, 5); |
458 | dib3000mc_set_adp_cfg(state, 1); | 456 | dib3000mc_set_adp_cfg(state, QAM_16); |
459 | dib3000mc_write_word(state, 133, 15564); | 457 | dib3000mc_write_word(state, 133, 15564); |
460 | 458 | ||
461 | dib3000mc_write_word(state, 12 , 0x0); | 459 | dib3000mc_write_word(state, 12 , 0x0); |
@@ -470,52 +468,98 @@ static void dib3000mc_set_channel_cfg(struct dib3000mc_state *state, struct dibx | |||
470 | dib3000mc_write_word(state, 97,0); | 468 | dib3000mc_write_word(state, 97,0); |
471 | dib3000mc_write_word(state, 98,0); | 469 | dib3000mc_write_word(state, 98,0); |
472 | 470 | ||
473 | dib3000mc_set_impulse_noise(state, 0, chan->nfft); | 471 | dib3000mc_set_impulse_noise(state, 0, ch->u.ofdm.transmission_mode); |
474 | |||
475 | tmp = ((chan->nfft & 0x1) << 7) | (chan->guard << 5) | (chan->nqam << 3) | chan->vit_alpha; | ||
476 | dib3000mc_write_word(state, 0, tmp); | ||
477 | 472 | ||
473 | value = 0; | ||
474 | switch (ch->u.ofdm.transmission_mode) { | ||
475 | case TRANSMISSION_MODE_2K: value |= (0 << 7); break; | ||
476 | default: | ||
477 | case TRANSMISSION_MODE_8K: value |= (1 << 7); break; | ||
478 | } | ||
479 | switch (ch->u.ofdm.guard_interval) { | ||
480 | case GUARD_INTERVAL_1_32: value |= (0 << 5); break; | ||
481 | case GUARD_INTERVAL_1_16: value |= (1 << 5); break; | ||
482 | case GUARD_INTERVAL_1_4: value |= (3 << 5); break; | ||
483 | default: | ||
484 | case GUARD_INTERVAL_1_8: value |= (2 << 5); break; | ||
485 | } | ||
486 | switch (ch->u.ofdm.constellation) { | ||
487 | case QPSK: value |= (0 << 3); break; | ||
488 | case QAM_16: value |= (1 << 3); break; | ||
489 | default: | ||
490 | case QAM_64: value |= (2 << 3); break; | ||
491 | } | ||
492 | switch (HIERARCHY_1) { | ||
493 | case HIERARCHY_2: value |= 2; break; | ||
494 | case HIERARCHY_4: value |= 4; break; | ||
495 | default: | ||
496 | case HIERARCHY_1: value |= 1; break; | ||
497 | } | ||
498 | dib3000mc_write_word(state, 0, value); | ||
478 | dib3000mc_write_word(state, 5, (1 << 8) | ((seq & 0xf) << 4)); | 499 | dib3000mc_write_word(state, 5, (1 << 8) | ((seq & 0xf) << 4)); |
479 | 500 | ||
480 | tmp = (chan->vit_hrch << 4) | (chan->vit_select_hp); | 501 | value = 0; |
481 | if (!chan->vit_hrch || (chan->vit_hrch && chan->vit_select_hp)) | 502 | if (ch->u.ofdm.hierarchy_information == 1) |
482 | tmp |= chan->vit_code_rate_hp << 1; | 503 | value |= (1 << 4); |
483 | else | 504 | if (1 == 1) |
484 | tmp |= chan->vit_code_rate_lp << 1; | 505 | value |= 1; |
485 | dib3000mc_write_word(state, 181, tmp); | 506 | switch ((ch->u.ofdm.hierarchy_information == 0 || 1 == 1) ? ch->u.ofdm.code_rate_HP : ch->u.ofdm.code_rate_LP) { |
507 | case FEC_2_3: value |= (2 << 1); break; | ||
508 | case FEC_3_4: value |= (3 << 1); break; | ||
509 | case FEC_5_6: value |= (5 << 1); break; | ||
510 | case FEC_7_8: value |= (7 << 1); break; | ||
511 | default: | ||
512 | case FEC_1_2: value |= (1 << 1); break; | ||
513 | } | ||
514 | dib3000mc_write_word(state, 181, value); | ||
486 | 515 | ||
487 | // diversity synchro delay | 516 | // diversity synchro delay add 50% SFN margin |
488 | tmp = dib3000mc_read_word(state, 180) & 0x000f; | 517 | switch (ch->u.ofdm.transmission_mode) { |
489 | tmp |= ((chan->nfft == 0) ? 64 : 256) * ((1 << (chan->guard)) * 3 / 2) << 4; // add 50% SFN margin | 518 | case TRANSMISSION_MODE_8K: value = 256; break; |
490 | dib3000mc_write_word(state, 180, tmp); | 519 | case TRANSMISSION_MODE_2K: |
520 | default: value = 64; break; | ||
521 | } | ||
522 | switch (ch->u.ofdm.guard_interval) { | ||
523 | case GUARD_INTERVAL_1_16: value *= 2; break; | ||
524 | case GUARD_INTERVAL_1_8: value *= 4; break; | ||
525 | case GUARD_INTERVAL_1_4: value *= 8; break; | ||
526 | default: | ||
527 | case GUARD_INTERVAL_1_32: value *= 1; break; | ||
528 | } | ||
529 | value <<= 4; | ||
530 | value |= dib3000mc_read_word(state, 180) & 0x000f; | ||
531 | dib3000mc_write_word(state, 180, value); | ||
491 | 532 | ||
492 | // restart demod | 533 | // restart demod |
493 | tmp = dib3000mc_read_word(state, 0); | 534 | value = dib3000mc_read_word(state, 0); |
494 | dib3000mc_write_word(state, 0, tmp | (1 << 9)); | 535 | dib3000mc_write_word(state, 0, value | (1 << 9)); |
495 | dib3000mc_write_word(state, 0, tmp); | 536 | dib3000mc_write_word(state, 0, value); |
496 | 537 | ||
497 | msleep(30); | 538 | msleep(30); |
498 | 539 | ||
499 | dib3000mc_set_impulse_noise(state, state->cfg->impulse_noise_mode, chan->nfft); | 540 | dib3000mc_set_impulse_noise(state, state->cfg->impulse_noise_mode, ch->u.ofdm.transmission_mode); |
500 | } | 541 | } |
501 | 542 | ||
502 | static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dibx000_ofdm_channel *chan) | 543 | static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dvb_frontend_parameters *chan) |
503 | { | 544 | { |
504 | struct dib3000mc_state *state = demod->demodulator_priv; | 545 | struct dib3000mc_state *state = demod->demodulator_priv; |
505 | u16 reg; | 546 | u16 reg; |
506 | // u32 val; | 547 | // u32 val; |
507 | struct dibx000_ofdm_channel fchan; | 548 | struct dvb_frontend_parameters schan; |
508 | 549 | ||
509 | INIT_OFDM_CHANNEL(&fchan); | 550 | schan = *chan; |
510 | fchan = *chan; | ||
511 | 551 | ||
552 | /* TODO what is that ? */ | ||
512 | 553 | ||
513 | /* a channel for autosearch */ | 554 | /* a channel for autosearch */ |
514 | fchan.nfft = 1; fchan.guard = 0; fchan.nqam = 2; | 555 | schan.u.ofdm.transmission_mode = TRANSMISSION_MODE_8K; |
515 | fchan.vit_alpha = 1; fchan.vit_code_rate_hp = 2; fchan.vit_code_rate_lp = 2; | 556 | schan.u.ofdm.guard_interval = GUARD_INTERVAL_1_32; |
516 | fchan.vit_hrch = 0; fchan.vit_select_hp = 1; | 557 | schan.u.ofdm.constellation = QAM_64; |
558 | schan.u.ofdm.code_rate_HP = FEC_2_3; | ||
559 | schan.u.ofdm.code_rate_LP = FEC_2_3; | ||
560 | schan.u.ofdm.hierarchy_information = 0; | ||
517 | 561 | ||
518 | dib3000mc_set_channel_cfg(state, &fchan, 11); | 562 | dib3000mc_set_channel_cfg(state, &schan, 11); |
519 | 563 | ||
520 | reg = dib3000mc_read_word(state, 0); | 564 | reg = dib3000mc_read_word(state, 0); |
521 | dib3000mc_write_word(state, 0, reg | (1 << 8)); | 565 | dib3000mc_write_word(state, 0, reg | (1 << 8)); |
@@ -539,7 +583,7 @@ static int dib3000mc_autosearch_is_irq(struct dvb_frontend *demod) | |||
539 | return 0; // still pending | 583 | return 0; // still pending |
540 | } | 584 | } |
541 | 585 | ||
542 | static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channel *ch) | 586 | static int dib3000mc_tune(struct dvb_frontend *demod, struct dvb_frontend_parameters *ch) |
543 | { | 587 | { |
544 | struct dib3000mc_state *state = demod->demodulator_priv; | 588 | struct dib3000mc_state *state = demod->demodulator_priv; |
545 | 589 | ||
@@ -549,9 +593,8 @@ static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channe | |||
549 | // activates isi | 593 | // activates isi |
550 | dib3000mc_write_word(state, 29, 0x1073); | 594 | dib3000mc_write_word(state, 29, 0x1073); |
551 | 595 | ||
552 | dib3000mc_set_adp_cfg(state, (u8)ch->nqam); | 596 | dib3000mc_set_adp_cfg(state, (uint8_t)ch->u.ofdm.constellation); |
553 | 597 | if (ch->u.ofdm.transmission_mode == TRANSMISSION_MODE_8K) { | |
554 | if (ch->nfft == 1) { | ||
555 | dib3000mc_write_word(state, 26, 38528); | 598 | dib3000mc_write_word(state, 26, 38528); |
556 | dib3000mc_write_word(state, 33, 8); | 599 | dib3000mc_write_word(state, 33, 8); |
557 | } else { | 600 | } else { |
@@ -560,7 +603,7 @@ static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channe | |||
560 | } | 603 | } |
561 | 604 | ||
562 | if (dib3000mc_read_word(state, 509) & 0x80) | 605 | if (dib3000mc_read_word(state, 509) & 0x80) |
563 | dib3000mc_set_timing(state, ch->nfft, ch->Bw, 1); | 606 | dib3000mc_set_timing(state, ch->u.ofdm.transmission_mode, BANDWIDTH_TO_KHZ(ch->u.ofdm.bandwidth), 1); |
564 | 607 | ||
565 | return 0; | 608 | return 0; |
566 | } | 609 | } |
@@ -632,13 +675,9 @@ static int dib3000mc_set_frontend(struct dvb_frontend* fe, | |||
632 | struct dvb_frontend_parameters *fep) | 675 | struct dvb_frontend_parameters *fep) |
633 | { | 676 | { |
634 | struct dib3000mc_state *state = fe->demodulator_priv; | 677 | struct dib3000mc_state *state = fe->demodulator_priv; |
635 | struct dibx000_ofdm_channel ch; | ||
636 | |||
637 | INIT_OFDM_CHANNEL(&ch); | ||
638 | FEP2DIB(fep,&ch); | ||
639 | 678 | ||
640 | state->current_bandwidth = fep->u.ofdm.bandwidth; | 679 | state->current_bandwidth = fep->u.ofdm.bandwidth; |
641 | dib3000mc_set_bandwidth(fe, fep->u.ofdm.bandwidth); | 680 | dib3000mc_set_bandwidth(state, BANDWIDTH_TO_KHZ(fep->u.ofdm.bandwidth)); |
642 | 681 | ||
643 | if (fe->ops.tuner_ops.set_params) { | 682 | if (fe->ops.tuner_ops.set_params) { |
644 | fe->ops.tuner_ops.set_params(fe, fep); | 683 | fe->ops.tuner_ops.set_params(fe, fep); |
@@ -651,7 +690,7 @@ static int dib3000mc_set_frontend(struct dvb_frontend* fe, | |||
651 | fep->u.ofdm.code_rate_HP == FEC_AUTO) { | 690 | fep->u.ofdm.code_rate_HP == FEC_AUTO) { |
652 | int i = 100, found; | 691 | int i = 100, found; |
653 | 692 | ||
654 | dib3000mc_autosearch_start(fe, &ch); | 693 | dib3000mc_autosearch_start(fe, fep); |
655 | do { | 694 | do { |
656 | msleep(1); | 695 | msleep(1); |
657 | found = dib3000mc_autosearch_is_irq(fe); | 696 | found = dib3000mc_autosearch_is_irq(fe); |
@@ -662,13 +701,12 @@ static int dib3000mc_set_frontend(struct dvb_frontend* fe, | |||
662 | return 0; // no channel found | 701 | return 0; // no channel found |
663 | 702 | ||
664 | dib3000mc_get_frontend(fe, fep); | 703 | dib3000mc_get_frontend(fe, fep); |
665 | FEP2DIB(fep,&ch); | ||
666 | } | 704 | } |
667 | 705 | ||
668 | /* make this a config parameter */ | 706 | /* make this a config parameter */ |
669 | dib3000mc_set_output_mode(state, OUTMODE_MPEG2_FIFO); | 707 | dib3000mc_set_output_mode(state, OUTMODE_MPEG2_FIFO); |
670 | 708 | ||
671 | return dib3000mc_tune(fe, &ch); | 709 | return dib3000mc_tune(fe, fep); |
672 | } | 710 | } |
673 | 711 | ||
674 | static int dib3000mc_read_status(struct dvb_frontend *fe, fe_status_t *stat) | 712 | static int dib3000mc_read_status(struct dvb_frontend *fe, fe_status_t *stat) |