Skip to content

Commit

Permalink
V4L/DVB (5960): Add module parameter to enable SFN workaround
Browse files Browse the repository at this point in the history
In some areas in the world the broadcasters are not using the same
cellid for each transmitter in a SFN. The DiBcom has problems with
that setup. The module parameter buggy_sfn_workaround makes it re-usable.

Signed-off-by: Matt Doran <matt.doran@papercut.biz>
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Matt Doran authored and Mauro Carvalho Chehab committed Oct 10, 2007
1 parent 8779737 commit 8f6956c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
22 changes: 17 additions & 5 deletions drivers/media/dvb/frontends/dib3000mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

#include <linux/kernel.h>
#include <linux/i2c.h>
//#include <linux/init.h>
//#include <linux/delay.h>
//#include <linux/string.h>
//#include <linux/slab.h>

#include "dvb_frontend.h"

Expand All @@ -26,6 +22,10 @@ static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");

static int buggy_sfn_workaround;
module_param(buggy_sfn_workaround, int, 0644);
MODULE_PARM_DESC(debug, "Enable work-around for buggy SFNs (default: 0)");

#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB3000MC/P:"); printk(args); printk("\n"); } } while (0)

struct dib3000mc_state {
Expand All @@ -42,6 +42,8 @@ struct dib3000mc_state {
fe_bandwidth_t current_bandwidth;

u16 dev_id;

u8 sfn_workaround_active :1;
};

static u16 dib3000mc_read_word(struct dib3000mc_state *state, u16 reg)
Expand Down Expand Up @@ -591,7 +593,14 @@ static int dib3000mc_tune(struct dvb_frontend *demod, struct dvb_frontend_parame
dib3000mc_set_channel_cfg(state, ch, 0);

// activates isi
dib3000mc_write_word(state, 29, 0x1073);
if (state->sfn_workaround_active) {
dprintk("SFN workaround is active\n");
dib3000mc_write_word(state, 29, 0x1273);
dib3000mc_write_word(state, 108, 0x4000); // P_pha3_force_pha_shift
} else {
dib3000mc_write_word(state, 29, 0x1073);
dib3000mc_write_word(state, 108, 0x0000); // P_pha3_force_pha_shift
}

dib3000mc_set_adp_cfg(state, (u8)ch->u.ofdm.constellation);
if (ch->u.ofdm.transmission_mode == TRANSMISSION_MODE_8K) {
Expand Down Expand Up @@ -679,6 +688,9 @@ static int dib3000mc_set_frontend(struct dvb_frontend* fe,
state->current_bandwidth = fep->u.ofdm.bandwidth;
dib3000mc_set_bandwidth(state, BANDWIDTH_TO_KHZ(fep->u.ofdm.bandwidth));

/* maybe the parameter has been changed */
state->sfn_workaround_active = buggy_sfn_workaround;

if (fe->ops.tuner_ops.set_params) {
fe->ops.tuner_ops.set_params(fe, fep);
msleep(100);
Expand Down
21 changes: 19 additions & 2 deletions drivers/media/dvb/frontends/dib7000p.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");

static int buggy_sfn_workaround;
module_param(buggy_sfn_workaround, int, 0644);
MODULE_PARM_DESC(debug, "Enable work-around for buggy SFNs (default: 0)");

#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB7000P: "); printk(args); printk("\n"); } } while (0)

struct dib7000p_state {
Expand All @@ -44,6 +48,8 @@ struct dib7000p_state {

u16 gpio_dir;
u16 gpio_val;

u8 sfn_workaround_active :1;
};

enum dib7000p_power_mode {
Expand Down Expand Up @@ -751,8 +757,8 @@ static void dib7000p_set_channel(struct dib7000p_state *state, struct dvb_fronte

/* offset loop parameters */
dib7000p_write_word(state, 26, 0x6680); // timf(6xxx)
dib7000p_write_word(state, 29, 0x1273); // isi inh1273 on1073
dib7000p_write_word(state, 32, 0x0003); // pha_off_max(xxx3)
dib7000p_write_word(state, 29, 0x1273); // isi
dib7000p_write_word(state, 33, 0x0005); // sfreq(xxx5)

/* P_dvsy_sync_wait */
Expand Down Expand Up @@ -959,7 +965,15 @@ static int dib7000p_tune(struct dvb_frontend *demod, struct dvb_frontend_paramet
msleep(45);

/* P_ctrl_inh_cor=0, P_ctrl_alpha_cor=4, P_ctrl_inh_isi=0, P_ctrl_alpha_isi=3, P_ctrl_inh_cor4=1, P_ctrl_alpha_cor4=3 */
dib7000p_write_word(state, 29, (0 << 14) | (4 << 10) | (0 << 9) | (3 << 5) | (1 << 4) | (0x3));
tmp = (0 << 14) | (4 << 10) | (0 << 9) | (3 << 5) | (1 << 4) | (0x3);
if (state->sfn_workaround_active) {
dprintk( "SFN workaround is active");
tmp |= (1 << 9);
dib7000p_write_word(state, 166, 0x4000); // P_pha3_force_pha_shift
} else {
dib7000p_write_word(state, 166, 0x0000); // P_pha3_force_pha_shift
}
dib7000p_write_word(state, 29, tmp);

// never achieved a lock with that bandwidth so far - wait for osc-freq to update
if (state->timf == 0)
Expand Down Expand Up @@ -1119,6 +1133,9 @@ static int dib7000p_set_frontend(struct dvb_frontend* fe,
state->current_bandwidth = fep->u.ofdm.bandwidth;
dib7000p_set_bandwidth(state, BANDWIDTH_TO_KHZ(fep->u.ofdm.bandwidth));

/* maybe the parameter has been changed */
state->sfn_workaround_active = buggy_sfn_workaround;

if (fe->ops.tuner_ops.set_params)
fe->ops.tuner_ops.set_params(fe, fep);

Expand Down

0 comments on commit 8f6956c

Please sign in to comment.