2 * Frontend driver for mobile DVB-T demodulator DiBcom 3000M-B
3 * DiBcom (http://www.dibcom.fr/)
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
7 * based on GPL code from DibCom, which has
9 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation, version 2.
17 * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
18 * sources, on which this driver (and the dvb-dibusb) are based.
20 * see Documentation/dvb/README.dibusb for more information
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/moduleparam.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/string.h>
30 #include <linux/slab.h>
32 #include "dib3000-common.h"
33 #include "dib3000mb_priv.h"
36 /* Version information */
37 #define DRIVER_VERSION "0.1"
38 #define DRIVER_DESC "DiBcom 3000M-B DVB-T demodulator"
39 #define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
41 #ifdef CONFIG_DVB_DIBCOM_DEBUG
43 module_param(debug, int, 0644);
44 MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
46 #define deb_info(args...) dprintk(0x01,args)
47 #define deb_xfer(args...) dprintk(0x02,args)
48 #define deb_setf(args...) dprintk(0x04,args)
49 #define deb_getf(args...) dprintk(0x08,args)
51 static int dib3000mb_get_frontend(struct dvb_frontend* fe,
52 struct dvb_frontend_parameters *fep);
54 static int dib3000mb_set_frontend(struct dvb_frontend* fe,
55 struct dvb_frontend_parameters *fep, int tuner)
57 struct dib3000_state* state = fe->demodulator_priv;
58 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
59 fe_code_rate_t fe_cr = FEC_NONE;
60 int search_state, seq;
62 if (tuner && fe->ops.tuner_ops.set_params) {
63 fe->ops.tuner_ops.set_params(fe, fep);
64 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
66 deb_setf("bandwidth: ");
67 switch (ofdm->bandwidth) {
70 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
71 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
75 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]);
76 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz);
80 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]);
81 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz);
86 err("unkown bandwidth value.");
90 wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
92 deb_setf("transmission mode: ");
93 switch (ofdm->transmission_mode) {
94 case TRANSMISSION_MODE_2K:
96 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K);
98 case TRANSMISSION_MODE_8K:
100 wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_8K);
102 case TRANSMISSION_MODE_AUTO:
110 switch (ofdm->guard_interval) {
111 case GUARD_INTERVAL_1_32:
113 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32);
115 case GUARD_INTERVAL_1_16:
117 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_16);
119 case GUARD_INTERVAL_1_8:
121 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_8);
123 case GUARD_INTERVAL_1_4:
125 wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_4);
127 case GUARD_INTERVAL_AUTO:
134 deb_setf("inversion: ");
135 switch (fep->inversion) {
138 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF);
145 wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_ON);
151 deb_setf("constellation: ");
152 switch (ofdm->constellation) {
155 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK);
159 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_16QAM);
163 wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_64QAM);
170 deb_setf("hierachy: ");
171 switch (ofdm->hierarchy_information) {
176 deb_setf("alpha=1\n");
177 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_1);
180 deb_setf("alpha=2\n");
181 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_2);
184 deb_setf("alpha=4\n");
185 wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_4);
188 deb_setf("alpha=auto\n");
194 deb_setf("hierarchy: ");
195 if (ofdm->hierarchy_information == HIERARCHY_NONE) {
197 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF);
198 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP);
199 fe_cr = ofdm->code_rate_HP;
200 } else if (ofdm->hierarchy_information != HIERARCHY_AUTO) {
202 wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON);
203 wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP);
204 fe_cr = ofdm->code_rate_LP;
210 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_1_2);
214 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_2_3);
218 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_3_4);
222 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_5_6);
226 wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_7_8);
239 [ofdm->transmission_mode == TRANSMISSION_MODE_AUTO]
240 [ofdm->guard_interval == GUARD_INTERVAL_AUTO]
241 [fep->inversion == INVERSION_AUTO];
243 deb_setf("seq? %d\n", seq);
245 wr(DIB3000MB_REG_SEQ, seq);
247 wr(DIB3000MB_REG_ISI, seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE);
249 if (ofdm->transmission_mode == TRANSMISSION_MODE_2K) {
250 if (ofdm->guard_interval == GUARD_INTERVAL_1_8) {
251 wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_2K_1_8);
253 wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_DEFAULT);
256 wr(DIB3000MB_REG_UNK_121, DIB3000MB_UNK_121_2K);
258 wr(DIB3000MB_REG_UNK_121, DIB3000MB_UNK_121_DEFAULT);
261 wr(DIB3000MB_REG_MOBILE_ALGO, DIB3000MB_MOBILE_ALGO_OFF);
262 wr(DIB3000MB_REG_MOBILE_MODE_QAM, DIB3000MB_MOBILE_MODE_QAM_OFF);
263 wr(DIB3000MB_REG_MOBILE_MODE, DIB3000MB_MOBILE_MODE_OFF);
265 wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_high);
267 wr(DIB3000MB_REG_ISI, DIB3000MB_ISI_ACTIVATE);
269 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AGC + DIB3000MB_RESTART_CTRL);
270 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_OFF);
272 /* wait for AGC lock */
275 wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low);
277 /* something has to be auto searched */
278 if (ofdm->constellation == QAM_AUTO ||
279 ofdm->hierarchy_information == HIERARCHY_AUTO ||
281 fep->inversion == INVERSION_AUTO) {
284 deb_setf("autosearch enabled.\n");
286 wr(DIB3000MB_REG_ISI, DIB3000MB_ISI_INHIBIT);
288 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AUTO_SEARCH);
289 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_OFF);
291 while ((search_state =
292 dib3000_search_status(
293 rd(DIB3000MB_REG_AS_IRQ_PENDING),
294 rd(DIB3000MB_REG_LOCK2_VALUE))) < 0 && as_count++ < 100)
297 deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);
299 if (search_state == 1) {
300 struct dvb_frontend_parameters feps;
301 if (dib3000mb_get_frontend(fe, &feps) == 0) {
302 deb_setf("reading tuning data from frontend succeeded.\n");
303 return dib3000mb_set_frontend(fe, &feps, 0);
308 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_CTRL);
309 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_OFF);
315 static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
317 struct dib3000_state* state = fe->demodulator_priv;
319 deb_info("dib3000mb is getting up.\n");
320 wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_UP);
322 wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AGC);
324 wr(DIB3000MB_REG_RESET_DEVICE, DIB3000MB_RESET_DEVICE);
325 wr(DIB3000MB_REG_RESET_DEVICE, DIB3000MB_RESET_DEVICE_RST);
327 wr(DIB3000MB_REG_CLOCK, DIB3000MB_CLOCK_DEFAULT);
329 wr(DIB3000MB_REG_ELECT_OUT_MODE, DIB3000MB_ELECT_OUT_MODE_ON);
331 wr(DIB3000MB_REG_DDS_FREQ_MSB, DIB3000MB_DDS_FREQ_MSB);
332 wr(DIB3000MB_REG_DDS_FREQ_LSB, DIB3000MB_DDS_FREQ_LSB);
334 wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
336 wr_foreach(dib3000mb_reg_impulse_noise,
337 dib3000mb_impulse_noise_values[DIB3000MB_IMPNOISE_OFF]);
339 wr_foreach(dib3000mb_reg_agc_gain, dib3000mb_default_agc_gain);
341 wr(DIB3000MB_REG_PHASE_NOISE, DIB3000MB_PHASE_NOISE_DEFAULT);
343 wr_foreach(dib3000mb_reg_phase_noise, dib3000mb_default_noise_phase);
345 wr_foreach(dib3000mb_reg_lock_duration, dib3000mb_default_lock_duration);
347 wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low);
349 wr(DIB3000MB_REG_LOCK0_MASK, DIB3000MB_LOCK0_DEFAULT);
350 wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
351 wr(DIB3000MB_REG_LOCK2_MASK, DIB3000MB_LOCK2_DEFAULT);
352 wr(DIB3000MB_REG_SEQ, dib3000_seq[1][1][1]);
354 wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
356 wr(DIB3000MB_REG_UNK_68, DIB3000MB_UNK_68);
357 wr(DIB3000MB_REG_UNK_69, DIB3000MB_UNK_69);
358 wr(DIB3000MB_REG_UNK_71, DIB3000MB_UNK_71);
359 wr(DIB3000MB_REG_UNK_77, DIB3000MB_UNK_77);
360 wr(DIB3000MB_REG_UNK_78, DIB3000MB_UNK_78);
361 wr(DIB3000MB_REG_ISI, DIB3000MB_ISI_INHIBIT);
362 wr(DIB3000MB_REG_UNK_92, DIB3000MB_UNK_92);
363 wr(DIB3000MB_REG_UNK_96, DIB3000MB_UNK_96);
364 wr(DIB3000MB_REG_UNK_97, DIB3000MB_UNK_97);
365 wr(DIB3000MB_REG_UNK_106, DIB3000MB_UNK_106);
366 wr(DIB3000MB_REG_UNK_107, DIB3000MB_UNK_107);
367 wr(DIB3000MB_REG_UNK_108, DIB3000MB_UNK_108);
368 wr(DIB3000MB_REG_UNK_122, DIB3000MB_UNK_122);
369 wr(DIB3000MB_REG_MOBILE_MODE_QAM, DIB3000MB_MOBILE_MODE_QAM_OFF);
370 wr(DIB3000MB_REG_BERLEN, DIB3000MB_BERLEN_DEFAULT);
372 wr_foreach(dib3000mb_reg_filter_coeffs, dib3000mb_filter_coeffs);
374 wr(DIB3000MB_REG_MOBILE_ALGO, DIB3000MB_MOBILE_ALGO_ON);
375 wr(DIB3000MB_REG_MULTI_DEMOD_MSB, DIB3000MB_MULTI_DEMOD_MSB);
376 wr(DIB3000MB_REG_MULTI_DEMOD_LSB, DIB3000MB_MULTI_DEMOD_LSB);
378 wr(DIB3000MB_REG_OUTPUT_MODE, DIB3000MB_OUTPUT_MODE_SLAVE);
380 wr(DIB3000MB_REG_FIFO_142, DIB3000MB_FIFO_142);
381 wr(DIB3000MB_REG_MPEG2_OUT_MODE, DIB3000MB_MPEG2_OUT_MODE_188);
382 wr(DIB3000MB_REG_PID_PARSE, DIB3000MB_PID_PARSE_ACTIVATE);
383 wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_INHIBIT);
384 wr(DIB3000MB_REG_FIFO_146, DIB3000MB_FIFO_146);
385 wr(DIB3000MB_REG_FIFO_147, DIB3000MB_FIFO_147);
387 wr(DIB3000MB_REG_DATA_IN_DIVERSITY, DIB3000MB_DATA_DIVERSITY_IN_OFF);
392 static int dib3000mb_get_frontend(struct dvb_frontend* fe,
393 struct dvb_frontend_parameters *fep)
395 struct dib3000_state* state = fe->demodulator_priv;
396 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
399 int inv_test1,inv_test2;
400 u32 dds_val, threshold = 0x800000;
402 if (!rd(DIB3000MB_REG_TPS_LOCK))
405 dds_val = ((rd(DIB3000MB_REG_DDS_VALUE_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_VALUE_LSB);
406 deb_getf("DDS_VAL: %x %x %x",dds_val, rd(DIB3000MB_REG_DDS_VALUE_MSB), rd(DIB3000MB_REG_DDS_VALUE_LSB));
407 if (dds_val < threshold)
409 else if (dds_val == threshold)
414 dds_val = ((rd(DIB3000MB_REG_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_FREQ_LSB);
415 deb_getf("DDS_FREQ: %x %x %x",dds_val, rd(DIB3000MB_REG_DDS_FREQ_MSB), rd(DIB3000MB_REG_DDS_FREQ_LSB));
416 if (dds_val < threshold)
418 else if (dds_val == threshold)
424 ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
425 ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
426 INVERSION_ON : INVERSION_OFF;
428 deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion);
430 switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) {
431 case DIB3000_CONSTELLATION_QPSK:
433 ofdm->constellation = QPSK;
435 case DIB3000_CONSTELLATION_16QAM:
437 ofdm->constellation = QAM_16;
439 case DIB3000_CONSTELLATION_64QAM:
441 ofdm->constellation = QAM_64;
444 err("Unexpected constellation returned by TPS (%d)", tps_val);
447 deb_getf("TPS: %d\n", tps_val);
449 if (rd(DIB3000MB_REG_TPS_HRCH)) {
450 deb_getf("HRCH ON\n");
451 cr = &ofdm->code_rate_LP;
452 ofdm->code_rate_HP = FEC_NONE;
453 switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) {
454 case DIB3000_ALPHA_0:
455 deb_getf("HIERARCHY_NONE ");
456 ofdm->hierarchy_information = HIERARCHY_NONE;
458 case DIB3000_ALPHA_1:
459 deb_getf("HIERARCHY_1 ");
460 ofdm->hierarchy_information = HIERARCHY_1;
462 case DIB3000_ALPHA_2:
463 deb_getf("HIERARCHY_2 ");
464 ofdm->hierarchy_information = HIERARCHY_2;
466 case DIB3000_ALPHA_4:
467 deb_getf("HIERARCHY_4 ");
468 ofdm->hierarchy_information = HIERARCHY_4;
471 err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
474 deb_getf("TPS: %d\n", tps_val);
476 tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP);
478 deb_getf("HRCH OFF\n");
479 cr = &ofdm->code_rate_HP;
480 ofdm->code_rate_LP = FEC_NONE;
481 ofdm->hierarchy_information = HIERARCHY_NONE;
483 tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP);
487 case DIB3000_FEC_1_2:
488 deb_getf("FEC_1_2 ");
491 case DIB3000_FEC_2_3:
492 deb_getf("FEC_2_3 ");
495 case DIB3000_FEC_3_4:
496 deb_getf("FEC_3_4 ");
499 case DIB3000_FEC_5_6:
500 deb_getf("FEC_5_6 ");
503 case DIB3000_FEC_7_8:
504 deb_getf("FEC_7_8 ");
508 err("Unexpected FEC returned by TPS (%d)", tps_val);
511 deb_getf("TPS: %d\n",tps_val);
513 switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) {
514 case DIB3000_GUARD_TIME_1_32:
515 deb_getf("GUARD_INTERVAL_1_32 ");
516 ofdm->guard_interval = GUARD_INTERVAL_1_32;
518 case DIB3000_GUARD_TIME_1_16:
519 deb_getf("GUARD_INTERVAL_1_16 ");
520 ofdm->guard_interval = GUARD_INTERVAL_1_16;
522 case DIB3000_GUARD_TIME_1_8:
523 deb_getf("GUARD_INTERVAL_1_8 ");
524 ofdm->guard_interval = GUARD_INTERVAL_1_8;
526 case DIB3000_GUARD_TIME_1_4:
527 deb_getf("GUARD_INTERVAL_1_4 ");
528 ofdm->guard_interval = GUARD_INTERVAL_1_4;
531 err("Unexpected Guard Time returned by TPS (%d)", tps_val);
534 deb_getf("TPS: %d\n", tps_val);
536 switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) {
537 case DIB3000_TRANSMISSION_MODE_2K:
538 deb_getf("TRANSMISSION_MODE_2K ");
539 ofdm->transmission_mode = TRANSMISSION_MODE_2K;
541 case DIB3000_TRANSMISSION_MODE_8K:
542 deb_getf("TRANSMISSION_MODE_8K ");
543 ofdm->transmission_mode = TRANSMISSION_MODE_8K;
546 err("unexpected transmission mode return by TPS (%d)", tps_val);
549 deb_getf("TPS: %d\n", tps_val);
554 static int dib3000mb_read_status(struct dvb_frontend* fe, fe_status_t *stat)
556 struct dib3000_state* state = fe->demodulator_priv;
560 if (rd(DIB3000MB_REG_AGC_LOCK))
561 *stat |= FE_HAS_SIGNAL;
562 if (rd(DIB3000MB_REG_CARRIER_LOCK))
563 *stat |= FE_HAS_CARRIER;
564 if (rd(DIB3000MB_REG_VIT_LCK))
565 *stat |= FE_HAS_VITERBI;
566 if (rd(DIB3000MB_REG_TS_SYNC_LOCK))
567 *stat |= (FE_HAS_SYNC | FE_HAS_LOCK);
569 deb_getf("actual status is %2x\n",*stat);
571 deb_getf("autoval: tps: %d, qam: %d, hrch: %d, alpha: %d, hp: %d, lp: %d, guard: %d, fft: %d cell: %d\n",
572 rd(DIB3000MB_REG_TPS_LOCK),
573 rd(DIB3000MB_REG_TPS_QAM),
574 rd(DIB3000MB_REG_TPS_HRCH),
575 rd(DIB3000MB_REG_TPS_VIT_ALPHA),
576 rd(DIB3000MB_REG_TPS_CODE_RATE_HP),
577 rd(DIB3000MB_REG_TPS_CODE_RATE_LP),
578 rd(DIB3000MB_REG_TPS_GUARD_TIME),
579 rd(DIB3000MB_REG_TPS_FFT),
580 rd(DIB3000MB_REG_TPS_CELL_ID));
582 //*stat = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
586 static int dib3000mb_read_ber(struct dvb_frontend* fe, u32 *ber)
588 struct dib3000_state* state = fe->demodulator_priv;
590 *ber = ((rd(DIB3000MB_REG_BER_MSB) << 16) | rd(DIB3000MB_REG_BER_LSB));
594 /* see dib3000-watch dvb-apps for exact calcuations of signal_strength and snr */
595 static int dib3000mb_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
597 struct dib3000_state* state = fe->demodulator_priv;
599 *strength = rd(DIB3000MB_REG_SIGNAL_POWER) * 0xffff / 0x170;
603 static int dib3000mb_read_snr(struct dvb_frontend* fe, u16 *snr)
605 struct dib3000_state* state = fe->demodulator_priv;
606 short sigpow = rd(DIB3000MB_REG_SIGNAL_POWER);
607 int icipow = ((rd(DIB3000MB_REG_NOISE_POWER_MSB) & 0xff) << 16) |
608 rd(DIB3000MB_REG_NOISE_POWER_LSB);
609 *snr = (sigpow << 8) / ((icipow > 0) ? icipow : 1);
613 static int dib3000mb_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
615 struct dib3000_state* state = fe->demodulator_priv;
617 *unc = rd(DIB3000MB_REG_PACKET_ERROR_RATE);
621 static int dib3000mb_sleep(struct dvb_frontend* fe)
623 struct dib3000_state* state = fe->demodulator_priv;
624 deb_info("dib3000mb is going to bed.\n");
625 wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_DOWN);
629 static int dib3000mb_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
631 tune->min_delay_ms = 800;
635 static int dib3000mb_fe_init_nonmobile(struct dvb_frontend* fe)
637 return dib3000mb_fe_init(fe, 0);
640 static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep)
642 return dib3000mb_set_frontend(fe, fep, 1);
645 static void dib3000mb_release(struct dvb_frontend* fe)
647 struct dib3000_state *state = fe->demodulator_priv;
651 /* pid filter and transfer stuff */
652 static int dib3000mb_pid_control(struct dvb_frontend *fe,int index, int pid,int onoff)
654 struct dib3000_state *state = fe->demodulator_priv;
655 pid = (onoff ? pid | DIB3000_ACTIVATE_PID_FILTERING : 0);
656 wr(index+DIB3000MB_REG_FIRST_PID,pid);
660 static int dib3000mb_fifo_control(struct dvb_frontend *fe, int onoff)
662 struct dib3000_state *state = fe->demodulator_priv;
664 deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
666 wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_ACTIVATE);
668 wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_INHIBIT);
673 static int dib3000mb_pid_parse(struct dvb_frontend *fe, int onoff)
675 struct dib3000_state *state = fe->demodulator_priv;
676 deb_xfer("%s pid parsing\n",onoff ? "enabling" : "disabling");
677 wr(DIB3000MB_REG_PID_PARSE,onoff);
681 static int dib3000mb_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr)
683 struct dib3000_state *state = fe->demodulator_priv;
685 wr(DIB3000MB_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr));
687 wr(DIB3000MB_REG_TUNER, DIB3000_TUNER_WRITE_DISABLE(pll_addr));
692 static struct dvb_frontend_ops dib3000mb_ops;
694 struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
695 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
697 struct dib3000_state* state = NULL;
699 /* allocate memory for the internal state */
700 state = kzalloc(sizeof(struct dib3000_state), GFP_KERNEL);
704 /* setup the state */
706 memcpy(&state->config,config,sizeof(struct dib3000_config));
708 /* check for the correct demod */
709 if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
712 if (rd(DIB3000_REG_DEVICE_ID) != DIB3000MB_DEVICE_ID)
715 /* create dvb_frontend */
716 memcpy(&state->frontend.ops, &dib3000mb_ops, sizeof(struct dvb_frontend_ops));
717 state->frontend.demodulator_priv = state;
719 /* set the xfer operations */
720 xfer_ops->pid_parse = dib3000mb_pid_parse;
721 xfer_ops->fifo_ctrl = dib3000mb_fifo_control;
722 xfer_ops->pid_ctrl = dib3000mb_pid_control;
723 xfer_ops->tuner_pass_ctrl = dib3000mb_tuner_pass_ctrl;
725 return &state->frontend;
732 static struct dvb_frontend_ops dib3000mb_ops = {
735 .name = "DiBcom 3000M-B DVB-T",
737 .frequency_min = 44250000,
738 .frequency_max = 867250000,
739 .frequency_stepsize = 62500,
740 .caps = FE_CAN_INVERSION_AUTO |
741 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
742 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
743 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
744 FE_CAN_TRANSMISSION_MODE_AUTO |
745 FE_CAN_GUARD_INTERVAL_AUTO |
747 FE_CAN_HIERARCHY_AUTO,
750 .release = dib3000mb_release,
752 .init = dib3000mb_fe_init_nonmobile,
753 .sleep = dib3000mb_sleep,
755 .set_frontend = dib3000mb_set_frontend_and_tuner,
756 .get_frontend = dib3000mb_get_frontend,
757 .get_tune_settings = dib3000mb_fe_get_tune_settings,
759 .read_status = dib3000mb_read_status,
760 .read_ber = dib3000mb_read_ber,
761 .read_signal_strength = dib3000mb_read_signal_strength,
762 .read_snr = dib3000mb_read_snr,
763 .read_ucblocks = dib3000mb_read_unc_blocks,
766 MODULE_AUTHOR(DRIVER_AUTHOR);
767 MODULE_DESCRIPTION(DRIVER_DESC);
768 MODULE_LICENSE("GPL");
770 EXPORT_SYMBOL(dib3000mb_attach);