Commit 2e802861 authored by Olivier Grenie's avatar Olivier Grenie Committed by Mauro Carvalho Chehab

[media] dib7000p/dib0090: update the driver

This patch intends to update the dib7000p and dib0090 driver in order to
improve the performances.
Signed-off-by: default avatarOlivier Grenie <olivier.grenie@dibcom.fr>
Signed-off-by: default avatarPatrick Boettcher <patrick.boettcher@dibcom.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent dd7aaa4d
...@@ -2092,6 +2092,14 @@ static int dib7090_agc_startup(struct dvb_frontend *fe, struct dvb_frontend_para ...@@ -2092,6 +2092,14 @@ static int dib7090_agc_startup(struct dvb_frontend *fe, struct dvb_frontend_para
return 0; return 0;
} }
static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
{
deb_info("AGC restart callback: %d", restart);
if (restart == 0) /* before AGC startup */
dib0090_set_dc_servo(fe, 1);
return 0;
}
static struct dib0090_wbd_slope dib7090_wbd_table[] = { static struct dib0090_wbd_slope dib7090_wbd_table[] = {
{ 380, 81, 850, 64, 540, 4}, { 380, 81, 850, 64, 540, 4},
{ 860, 51, 866, 21, 375, 4}, { 860, 51, 866, 21, 375, 4},
......
...@@ -1112,13 +1112,21 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe) ...@@ -1112,13 +1112,21 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
else else
dib0090_write_reg(state, 0x32, (0 << 11)); dib0090_write_reg(state, 0x32, (0 << 11));
dib0090_write_reg(state, 0x04, 0x01); dib0090_write_reg(state, 0x04, 0x03);
dib0090_write_reg(state, 0x39, (1 << 10)); dib0090_write_reg(state, 0x39, (1 << 10));
} }
} }
EXPORT_SYMBOL(dib0090_pwm_gain_reset); EXPORT_SYMBOL(dib0090_pwm_gain_reset);
void dib0090_set_dc_servo(struct dvb_frontend *fe, u8 DC_servo_cutoff)
{
struct dib0090_state *state = fe->tuner_priv;
if (DC_servo_cutoff < 4)
dib0090_write_reg(state, 0x04, DC_servo_cutoff);
}
EXPORT_SYMBOL(dib0090_set_dc_servo);
static u32 dib0090_get_slow_adc_val(struct dib0090_state *state) static u32 dib0090_get_slow_adc_val(struct dib0090_state *state)
{ {
u16 adc_val = dib0090_read_reg(state, 0x1d); u16 adc_val = dib0090_read_reg(state, 0x1d);
...@@ -1505,7 +1513,10 @@ static int dib0090_reset(struct dvb_frontend *fe) ...@@ -1505,7 +1513,10 @@ static int dib0090_reset(struct dvb_frontend *fe)
dib0090_set_EFUSE(state); dib0090_set_EFUSE(state);
/* Congigure in function of the crystal */ /* Congigure in function of the crystal */
if (state->config->io.clock_khz >= 24000) if (state->config->force_crystal_mode != 0)
dib0090_write_reg(state, 0x14,
state->config->force_crystal_mode & 3);
else if (state->config->io.clock_khz >= 24000)
dib0090_write_reg(state, 0x14, 1); dib0090_write_reg(state, 0x14, 1);
else else
dib0090_write_reg(state, 0x14, 2); dib0090_write_reg(state, 0x14, 2);
......
...@@ -71,6 +71,8 @@ struct dib0090_config { ...@@ -71,6 +71,8 @@ struct dib0090_config {
u8 fref_clock_ratio; u8 fref_clock_ratio;
u16 force_cband_input; u16 force_cband_input;
struct dib0090_wbd_slope *wbd; struct dib0090_wbd_slope *wbd;
u8 is_dib7090e;
u8 force_crystal_mode;
}; };
#if defined(CONFIG_DVB_TUNER_DIB0090) || (defined(CONFIG_DVB_TUNER_DIB0090_MODULE) && defined(MODULE)) #if defined(CONFIG_DVB_TUNER_DIB0090) || (defined(CONFIG_DVB_TUNER_DIB0090_MODULE) && defined(MODULE))
...@@ -83,6 +85,7 @@ extern int dib0090_gain_control(struct dvb_frontend *fe); ...@@ -83,6 +85,7 @@ extern int dib0090_gain_control(struct dvb_frontend *fe);
extern enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe); extern enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe);
extern int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state); extern int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state);
extern void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt); extern void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt);
extern void dib0090_set_dc_servo(struct dvb_frontend *fe, u8 DC_servo_cutoff);
#else #else
static inline struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0090_config *config) static inline struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0090_config *config)
{ {
...@@ -134,6 +137,11 @@ static inline void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u ...@@ -134,6 +137,11 @@ static inline void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u
{ {
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
} }
static inline void dib0090_set_dc_servo(struct dvb_frontend *fe, u8 DC_servo_cutoff)
{
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
}
#endif #endif
#endif #endif
...@@ -70,6 +70,8 @@ struct dib7000p_state { ...@@ -70,6 +70,8 @@ struct dib7000p_state {
u8 i2c_write_buffer[4]; u8 i2c_write_buffer[4];
u8 i2c_read_buffer[2]; u8 i2c_read_buffer[2];
struct mutex i2c_buffer_lock; struct mutex i2c_buffer_lock;
u8 input_mode_mpeg;
}; };
enum dib7000p_power_mode { enum dib7000p_power_mode {
...@@ -78,8 +80,18 @@ enum dib7000p_power_mode { ...@@ -78,8 +80,18 @@ enum dib7000p_power_mode {
DIB7000P_POWER_INTERFACE_ONLY, DIB7000P_POWER_INTERFACE_ONLY,
}; };
/* dib7090 specific fonctions */
#define MPEG_ON_DIBTX 1
#define DIV_ON_DIBTX 2
#define ADC_ON_DIBTX 3
#define DEMOUT_ON_HOSTBUS 4
#define DIBTX_ON_HOSTBUS 5
#define MPEG_ON_HOSTBUS 6
static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode); static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode);
static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff); static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff);
static void dib7090_setDibTxMux(struct dib7000p_state *state, int mode);
static void dib7090_setHostBusMux(struct dib7000p_state *state, int mode);
static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg) static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
{ {
...@@ -276,17 +288,23 @@ static int dib7000p_set_power_mode(struct dib7000p_state *state, enum dib7000p_p ...@@ -276,17 +288,23 @@ static int dib7000p_set_power_mode(struct dib7000p_state *state, enum dib7000p_p
dib7000p_write_word(state, 774, reg_774); dib7000p_write_word(state, 774, reg_774);
dib7000p_write_word(state, 775, reg_775); dib7000p_write_word(state, 775, reg_775);
dib7000p_write_word(state, 776, reg_776); dib7000p_write_word(state, 776, reg_776);
dib7000p_write_word(state, 899, reg_899);
dib7000p_write_word(state, 1280, reg_1280); dib7000p_write_word(state, 1280, reg_1280);
if (state->version != SOC7090)
dib7000p_write_word(state, 899, reg_899);
return 0; return 0;
} }
static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_adc_states no) static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_adc_states no)
{ {
u16 reg_908 = dib7000p_read_word(state, 908), reg_909 = dib7000p_read_word(state, 909); u16 reg_908 = 0, reg_909 = 0;
u16 reg; u16 reg;
if (state->version != SOC7090) {
reg_908 = dib7000p_read_word(state, 908);
reg_909 = dib7000p_read_word(state, 909);
}
switch (no) { switch (no) {
case DIBX000_SLOW_ADC_ON: case DIBX000_SLOW_ADC_ON:
if (state->version == SOC7090) { if (state->version == SOC7090) {
...@@ -342,8 +360,10 @@ static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_ad ...@@ -342,8 +360,10 @@ static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_ad
reg_909 |= (state->cfg.disable_sample_and_hold & 1) << 4; reg_909 |= (state->cfg.disable_sample_and_hold & 1) << 4;
reg_908 |= (state->cfg.enable_current_mirror & 1) << 7; reg_908 |= (state->cfg.enable_current_mirror & 1) << 7;
if (state->version != SOC7090) {
dib7000p_write_word(state, 908, reg_908); dib7000p_write_word(state, 908, reg_908);
dib7000p_write_word(state, 909, reg_909); dib7000p_write_word(state, 909, reg_909);
}
} }
static int dib7000p_set_bandwidth(struct dib7000p_state *state, u32 bw) static int dib7000p_set_bandwidth(struct dib7000p_state *state, u32 bw)
...@@ -519,7 +539,7 @@ static u16 dib7000p_defaults[] = { ...@@ -519,7 +539,7 @@ static u16 dib7000p_defaults[] = {
// auto search configuration // auto search configuration
3, 2, 3, 2,
0x0004, 0x0004,
0x1000, (1<<3)|(1<<11)|(1<<12)|(1<<13),
0x0814, /* Equal Lock */ 0x0814, /* Equal Lock */
12, 6, 12, 6,
...@@ -595,13 +615,6 @@ static u16 dib7000p_defaults[] = { ...@@ -595,13 +615,6 @@ static u16 dib7000p_defaults[] = {
1, 235, 1, 235,
0x0062, 0x0062,
2, 901,
0x0006,
(3 << 10) | (1 << 6),
1, 905,
0x2c8e,
0, 0,
}; };
...@@ -618,15 +631,18 @@ static int dib7000p_demod_reset(struct dib7000p_state *state) ...@@ -618,15 +631,18 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
dib7000p_write_word(state, 770, 0xffff); dib7000p_write_word(state, 770, 0xffff);
dib7000p_write_word(state, 771, 0xffff); dib7000p_write_word(state, 771, 0xffff);
dib7000p_write_word(state, 772, 0x001f); dib7000p_write_word(state, 772, 0x001f);
dib7000p_write_word(state, 898, 0x0003);
dib7000p_write_word(state, 1280, 0x001f - ((1 << 4) | (1 << 3))); dib7000p_write_word(state, 1280, 0x001f - ((1 << 4) | (1 << 3)));
dib7000p_write_word(state, 770, 0); dib7000p_write_word(state, 770, 0);
dib7000p_write_word(state, 771, 0); dib7000p_write_word(state, 771, 0);
dib7000p_write_word(state, 772, 0); dib7000p_write_word(state, 772, 0);
dib7000p_write_word(state, 898, 0);
dib7000p_write_word(state, 1280, 0); dib7000p_write_word(state, 1280, 0);
if (state->version != SOC7090) {
dib7000p_write_word(state, 898, 0x0003);
dib7000p_write_word(state, 898, 0);
}
/* default */ /* default */
dib7000p_reset_pll(state); dib7000p_reset_pll(state);
...@@ -640,7 +656,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state) ...@@ -640,7 +656,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
dib7000p_write_word(state, 42, (1<<5) | 3); /* P_iqc_thsat_ipc = 1 ; P_iqc_win2 = 3 */ dib7000p_write_word(state, 42, (1<<5) | 3); /* P_iqc_thsat_ipc = 1 ; P_iqc_win2 = 3 */
dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */
dib7000p_write_word(state, 44, 300); /* 300 fag P_iqc_dect_min = +280 */ dib7000p_write_word(state, 44, 300); /* 300 fag P_iqc_dect_min = +280 */
dib7000p_write_word(state, 273, (1<<6) | 30); dib7000p_write_word(state, 273, (0<<6) | 30);
} }
if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0) if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0)
dprintk("OUTPUT_MODE could not be reset."); dprintk("OUTPUT_MODE could not be reset.");
...@@ -655,7 +671,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state) ...@@ -655,7 +671,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
dib7000p_set_bandwidth(state, 8000); dib7000p_set_bandwidth(state, 8000);
if (state->version == SOC7090) { if (state->version == SOC7090) {
dib7000p_write_word(state, 36, 0x5755);/* P_iqc_impnc_on =1 & P_iqc_corr_inh = 1 for impulsive noise */ dib7000p_write_word(state, 36, 0x0755);/* P_iqc_impnc_on =1 & P_iqc_corr_inh = 1 for impulsive noise */
} else { } else {
if (state->cfg.tuner_is_baseband) if (state->cfg.tuner_is_baseband)
dib7000p_write_word(state, 36, 0x0755); dib7000p_write_word(state, 36, 0x0755);
...@@ -664,6 +680,11 @@ static int dib7000p_demod_reset(struct dib7000p_state *state) ...@@ -664,6 +680,11 @@ static int dib7000p_demod_reset(struct dib7000p_state *state)
} }
dib7000p_write_tab(state, dib7000p_defaults); dib7000p_write_tab(state, dib7000p_defaults);
if (state->version != SOC7090) {
dib7000p_write_word(state, 901, 0x0006);
dib7000p_write_word(state, 902, (3 << 10) | (1 << 6));
dib7000p_write_word(state, 905, 0x2c8e);
}
dib7000p_set_power_mode(state, DIB7000P_POWER_INTERFACE_ONLY); dib7000p_set_power_mode(state, DIB7000P_POWER_INTERFACE_ONLY);
...@@ -1080,9 +1101,12 @@ static int dib7000p_autosearch_start(struct dvb_frontend *demod, struct dvb_fron ...@@ -1080,9 +1101,12 @@ static int dib7000p_autosearch_start(struct dvb_frontend *demod, struct dvb_fron
dib7000p_set_channel(state, &schan, 7); dib7000p_set_channel(state, &schan, 7);
factor = BANDWIDTH_TO_KHZ(ch->u.ofdm.bandwidth); factor = BANDWIDTH_TO_KHZ(ch->u.ofdm.bandwidth);
if (factor >= 5000) if (factor >= 5000) {
factor = 1; if (state->version == SOC7090)
factor = 2;
else else
factor = 1;
} else
factor = 6; factor = 6;
value = 30 * internal * factor; value = 30 * internal * factor;
...@@ -1323,7 +1347,7 @@ static int dib7000p_sleep(struct dvb_frontend *demod) ...@@ -1323,7 +1347,7 @@ static int dib7000p_sleep(struct dvb_frontend *demod)
{ {
struct dib7000p_state *state = demod->demodulator_priv; struct dib7000p_state *state = demod->demodulator_priv;
if (state->version == SOC7090) if (state->version == SOC7090)
return dib7090_set_output_mode(demod, OUTMODE_HIGH_Z) | dib7000p_set_power_mode(state, DIB7000P_POWER_INTERFACE_ONLY); return dib7000p_set_power_mode(state, DIB7000P_POWER_INTERFACE_ONLY);
return dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) | dib7000p_set_power_mode(state, DIB7000P_POWER_INTERFACE_ONLY); return dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) | dib7000p_set_power_mode(state, DIB7000P_POWER_INTERFACE_ONLY);
} }
...@@ -1445,10 +1469,9 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa ...@@ -1445,10 +1469,9 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa
struct dib7000p_state *state = fe->demodulator_priv; struct dib7000p_state *state = fe->demodulator_priv;
int time, ret; int time, ret;
if (state->version == SOC7090) { if (state->version == SOC7090)
dib7090_set_diversity_in(fe, 0); dib7090_set_diversity_in(fe, 0);
dib7090_set_output_mode(fe, OUTMODE_HIGH_Z); else
} else
dib7000p_set_output_mode(state, OUTMODE_HIGH_Z); dib7000p_set_output_mode(state, OUTMODE_HIGH_Z);
/* maybe the parameter has been changed */ /* maybe the parameter has been changed */
...@@ -1485,9 +1508,13 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa ...@@ -1485,9 +1508,13 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa
ret = dib7000p_tune(fe, fep); ret = dib7000p_tune(fe, fep);
/* make this a config parameter */ /* make this a config parameter */
if (state->version == SOC7090) if (state->version == SOC7090) {
dib7090_set_output_mode(fe, state->cfg.output_mode); dib7090_set_output_mode(fe, state->cfg.output_mode);
else if (state->cfg.enMpegOutput == 0) {
dib7090_setDibTxMux(state, MPEG_ON_DIBTX);
dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS);
}
} else
dib7000p_set_output_mode(state, state->cfg.output_mode); dib7000p_set_output_mode(state, state->cfg.output_mode);
return ret; return ret;
...@@ -1933,10 +1960,10 @@ static int dib7090_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[] ...@@ -1933,10 +1960,10 @@ static int dib7090_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[]
apb_address = 915; apb_address = 915;
break; break;
case 0x27: case 0x27:
apb_address = 916; apb_address = 917;
break; break;
case 0x28: case 0x28:
apb_address = 917; apb_address = 916;
break; break;
case 0x1d: case 0x1d:
i = ((dib7000p_read_word(state, 72) >> 12) & 0x3); i = ((dib7000p_read_word(state, 72) >> 12) & 0x3);
...@@ -2031,12 +2058,7 @@ static u32 dib7090_calcSyncFreq(u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32 ...@@ -2031,12 +2058,7 @@ static u32 dib7090_calcSyncFreq(u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32
static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32 synchroMode, u32 syncWord, u32 syncSize) static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout, u32 insertExtSynchro, u32 synchroMode, u32 syncWord, u32 syncSize)
{ {
u8 index_buf;
u16 rx_copy_buf[22];
dprintk("Configure DibStream Tx"); dprintk("Configure DibStream Tx");
for (index_buf = 0; index_buf < 22; index_buf++)
rx_copy_buf[index_buf] = dib7000p_read_word(state, 1536+index_buf);
dib7000p_write_word(state, 1615, 1); dib7000p_write_word(state, 1615, 1);
dib7000p_write_word(state, 1603, P_Kin); dib7000p_write_word(state, 1603, P_Kin);
...@@ -2048,9 +2070,6 @@ static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout ...@@ -2048,9 +2070,6 @@ static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout
dib7000p_write_word(state, 1612, syncSize); dib7000p_write_word(state, 1612, syncSize);
dib7000p_write_word(state, 1615, 0); dib7000p_write_word(state, 1615, 0);
for (index_buf = 0; index_buf < 22; index_buf++)
dib7000p_write_word(state, 1536+index_buf, rx_copy_buf[index_buf]);
return 0; return 0;
} }
...@@ -2077,109 +2096,121 @@ static int dib7090_cfg_DibRx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout ...@@ -2077,109 +2096,121 @@ static int dib7090_cfg_DibRx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout
return 0; return 0;
} }
static int dib7090_enDivOnHostBus(struct dib7000p_state *state) static void dib7090_enMpegMux(struct dib7000p_state *state, int onoff)
{ {
u16 reg; u16 reg_1287 = dib7000p_read_word(state, 1287);
dprintk("Enable Diversity on host bus");
reg = (1 << 8) | (1 << 5);
dib7000p_write_word(state, 1288, reg);
return dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0);
}
static int dib7090_enAdcOnHostBus(struct dib7000p_state *state)
{
u16 reg;
dprintk("Enable ADC on host bus");
reg = (1 << 7) | (1 << 5);
dib7000p_write_word(state, 1288, reg);
return dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); switch (onoff) {
} case 1:
reg_1287 &= ~(1<<7);
static int dib7090_enMpegOnHostBus(struct dib7000p_state *state) break;
{ case 0:
u16 reg; reg_1287 |= (1<<7);
break;
dprintk("Enable Mpeg on host bus"); }
reg = (1 << 9) | (1 << 5);
dib7000p_write_word(state, 1288, reg);
return dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0);
}
static int dib7090_enMpegInput(struct dib7000p_state *state) dib7000p_write_word(state, 1287, reg_1287);
{
dprintk("Enable Mpeg input");
return dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); /*outputRate = 8 */
} }
static int dib7090_enMpegMux(struct dib7000p_state *state, u16 pulseWidth, u16 enSerialMode, u16 enSerialClkDiv2) static void dib7090_configMpegMux(struct dib7000p_state *state,
u16 pulseWidth, u16 enSerialMode, u16 enSerialClkDiv2)
{ {
u16 reg = (1 << 7) | ((pulseWidth & 0x1f) << 2) | ((enSerialMode & 0x1) << 1) | (enSerialClkDiv2 & 0x1);
dprintk("Enable Mpeg mux"); dprintk("Enable Mpeg mux");
dib7000p_write_word(state, 1287, reg);
reg &= ~(1 << 7); dib7090_enMpegMux(state, 0);
dib7000p_write_word(state, 1287, reg);
reg = (1 << 4); /* If the input mode is MPEG do not divide the serial clock */
dib7000p_write_word(state, 1288, reg); if ((enSerialMode == 1) && (state->input_mode_mpeg == 1))
enSerialClkDiv2 = 0;
return 0; dib7000p_write_word(state, 1287, ((pulseWidth & 0x1f) << 2)
| ((enSerialMode & 0x1) << 1)
| (enSerialClkDiv2 & 0x1));
dib7090_enMpegMux(state, 1);
} }
static int dib7090_disableMpegMux(struct dib7000p_state *state) static void dib7090_setDibTxMux(struct dib7000p_state *state, int mode)
{ {
u16 reg; u16 reg_1288 = dib7000p_read_word(state, 1288) & ~(0x7 << 7);
dprintk("Disable Mpeg mux");
dib7000p_write_word(state, 1288, 0);
reg = dib7000p_read_word(state, 1287);
reg &= ~(1 << 7);
dib7000p_write_word(state, 1287, reg);
return 0; switch (mode) {
case MPEG_ON_DIBTX:
dprintk("SET MPEG ON DIBSTREAM TX");
dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0);
reg_1288 |= (1<<9);
break;
case DIV_ON_DIBTX:
dprintk("SET DIV_OUT ON DIBSTREAM TX");
dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0);
reg_1288 |= (1<<8);
break;
case ADC_ON_DIBTX:
dprintk("SET ADC_OUT ON DIBSTREAM TX");
dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0);
reg_1288 |= (1<<7);
break;
default:
break;
}
dib7000p_write_word(state, 1288, reg_1288);
} }
static int dib7090_set_input_mode(struct dvb_frontend *fe, int mode) static void dib7090_setHostBusMux(struct dib7000p_state *state, int mode)
{ {
struct dib7000p_state *state = fe->demodulator_priv; u16 reg_1288 = dib7000p_read_word(state, 1288) & ~(0x7 << 4);
switch (mode) { switch (mode) {
case INPUT_MODE_DIVERSITY: case DEMOUT_ON_HOSTBUS:
dprintk("Enable diversity INPUT"); dprintk("SET DEM OUT OLD INTERF ON HOST BUS");
dib7090_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0); dib7090_enMpegMux(state, 0);
reg_1288 |= (1<<6);
break;
case DIBTX_ON_HOSTBUS:
dprintk("SET DIBSTREAM TX ON HOST BUS");
dib7090_enMpegMux(state, 0);
reg_1288 |= (1<<5);
break; break;
case INPUT_MODE_MPEG: case MPEG_ON_HOSTBUS:
dprintk("Enable Mpeg INPUT"); dprintk("SET MPEG MUX ON HOST BUS");
dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); /*outputRate = 8 */ reg_1288 |= (1<<4);
break; break;
case INPUT_MODE_OFF:
default: default:
dprintk("Disable INPUT");
dib7090_cfg_DibRx(state, 0, 0, 0, 0, 0, 0, 0);
break; break;
} }
return 0; dib7000p_write_word(state, 1288, reg_1288);
} }
static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff) int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff)
{ {
struct dib7000p_state *state = fe->demodulator_priv;
u16 reg_1287;
switch (onoff) { switch (onoff) {
case 0: /* only use the internal way - not the diversity input */ case 0: /* only use the internal way - not the diversity input */
dib7090_set_input_mode(fe, INPUT_MODE_MPEG); dprintk("%s mode OFF : by default Enable Mpeg INPUT", __func__);
dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0);
/* Do not divide the serial clock of MPEG MUX */
/* in SERIAL MODE in case input mode MPEG is used */
reg_1287 = dib7000p_read_word(state, 1287);
/* enSerialClkDiv2 == 1 ? */
if ((reg_1287 & 0x1) == 1) {
/* force enSerialClkDiv2 = 0 */
reg_1287 &= ~0x1;
dib7000p_write_word(state, 1287, reg_1287);
}
state->input_mode_mpeg = 1;
break; break;
case 1: /* both ways */ case 1: /* both ways */
case 2: /* only the diversity input */ case 2: /* only the diversity input */
dib7090_set_input_mode(fe, INPUT_MODE_DIVERSITY); dprintk("%s ON : Enable diversity INPUT", __func__);
dib7090_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0);
state->input_mode_mpeg = 0;
break; break;
} }
dib7000p_set_diversity_in(&state->demod, onoff);
return 0; return 0;
} }
...@@ -2204,69 +2235,63 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode) ...@@ -2204,69 +2235,63 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode)
case OUTMODE_MPEG2_SERIAL: case OUTMODE_MPEG2_SERIAL:
if (prefer_mpeg_mux_use) { if (prefer_mpeg_mux_use) {
dprintk("Sip 7090P setting output mode TS_SERIAL using Mpeg Mux"); dprintk("setting output mode TS_SERIAL using Mpeg Mux");
dib7090_enMpegOnHostBus(state); dib7090_configMpegMux(state, 3, 1, 1);
dib7090_enMpegInput(state); dib7090_setHostBusMux(state, MPEG_ON_HOSTBUS);
if (state->cfg.enMpegOutput == 1) } else {/* Use Smooth block */
dib7090_enMpegMux(state, 3, 1, 1); dprintk("setting output mode TS_SERIAL using Smooth bloc");
dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
} else { /* Use Smooth block */ outreg |= (2<<6) | (0 << 1);
dprintk("Sip 7090P setting output mode TS_SERIAL using Smooth bloc");
dib7090_disableMpegMux(state);
dib7000p_write_word(state, 1288, (1 << 6));
outreg |= (2 << 6) | (0 << 1);
} }
break; break;
case OUTMODE_MPEG2_PAR_GATED_CLK: case OUTMODE_MPEG2_PAR_GATED_CLK:
if (prefer_mpeg_mux_use) { if (prefer_mpeg_mux_use) {
dprintk("Sip 7090P setting output mode TS_PARALLEL_GATED using Mpeg Mux"); dprintk("setting output mode TS_PARALLEL_GATED using Mpeg Mux");
dib7090_enMpegOnHostBus(state); dib7090_configMpegMux(state, 2, 0, 0);
dib7090_enMpegInput(state); dib7090_setHostBusMux(state, MPEG_ON_HOSTBUS);
if (state->cfg.enMpegOutput == 1)
dib7090_enMpegMux(state, 2, 0, 0);
} else { /* Use Smooth block */ } else { /* Use Smooth block */
dprintk("Sip 7090P setting output mode TS_PARALLEL_GATED using Smooth block"); dprintk("setting output mode TS_PARALLEL_GATED using Smooth block");
dib7090_disableMpegMux(state); dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
dib7000p_write_word(state, 1288, (1 << 6)); outreg |= (0<<6);
outreg |= (0 << 6);
} }
break; break;
case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */ case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */
dprintk("Sip 7090P setting output mode TS_PARALLEL_CONT using Smooth block"); dprintk("setting output mode TS_PARALLEL_CONT using Smooth block");
dib7090_disableMpegMux(state); dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
dib7000p_write_word(state, 1288, (1 << 6)); outreg |= (1<<6);
outreg |= (1 << 6);
break; break;
case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */ case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */
dprintk("Sip 7090P setting output mode TS_FIFO using Smooth block"); dprintk("setting output mode TS_FIFO using Smooth block");
dib7090_disableMpegMux(state); dib7090_setHostBusMux(state, DEMOUT_ON_HOSTBUS);
dib7000p_write_word(state, 1288, (1 << 6)); outreg |= (5<<6);
outreg |= (5 << 6);
smo_mode |= (3 << 1); smo_mode |= (3 << 1);
fifo_threshold = 512; fifo_threshold = 512;
break; break;
case OUTMODE_DIVERSITY: case OUTMODE_DIVERSITY:
dprintk("Sip 7090P setting output mode MODE_DIVERSITY"); dprintk("setting output mode MODE_DIVERSITY");
dib7090_disableMpegMux(state); dib7090_setDibTxMux(state, DIV_ON_DIBTX);
dib7090_enDivOnHostBus(state); dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS);
break; break;
case OUTMODE_ANALOG_ADC: case OUTMODE_ANALOG_ADC:
dprintk("Sip 7090P setting output mode MODE_ANALOG_ADC"); dprintk("setting output mode MODE_ANALOG_ADC");
dib7090_enAdcOnHostBus(state); dib7090_setDibTxMux(state, ADC_ON_DIBTX);
dib7090_setHostBusMux(state, DIBTX_ON_HOSTBUS);
break; break;
} }
if (mode != OUTMODE_HIGH_Z)
outreg |= (1 << 10);
if (state->cfg.output_mpeg2_in_188_bytes) if (state->cfg.output_mpeg2_in_188_bytes)
smo_mode |= (1 << 5); smo_mode |= (1 << 5);
ret |= dib7000p_write_word(state, 235, smo_mode); ret |= dib7000p_write_word(state, 235, smo_mode);
ret |= dib7000p_write_word(state, 236, fifo_threshold); /* synchronous fread */ ret |= dib7000p_write_word(state, 236, fifo_threshold); /* synchronous fread */
ret |= dib7000p_write_word(state, 1286, outreg | (1 << 10)); /* allways set Dout active = 1 !!! */ ret |= dib7000p_write_word(state, 1286, outreg);
return ret; return ret;
} }
...@@ -2296,13 +2321,6 @@ int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff) ...@@ -2296,13 +2321,6 @@ int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff)
} }
EXPORT_SYMBOL(dib7090_tuner_sleep); EXPORT_SYMBOL(dib7090_tuner_sleep);
int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
{
dprintk("AGC restart callback: %d", restart);
return 0;
}
EXPORT_SYMBOL(dib7090_agc_restart);
int dib7090_get_adc_power(struct dvb_frontend *fe) int dib7090_get_adc_power(struct dvb_frontend *fe)
{ {
return dib7000p_get_adc_power(fe); return dib7000p_get_adc_power(fe);
......
...@@ -56,7 +56,6 @@ extern int dib7000p_pid_filter(struct dvb_frontend *, u8 id, u16 pid, u8 onoff); ...@@ -56,7 +56,6 @@ extern int dib7000p_pid_filter(struct dvb_frontend *, u8 id, u16 pid, u8 onoff);
extern int dib7000p_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff); extern int dib7000p_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff);
extern int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth_config *bw); extern int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth_config *bw);
extern u32 dib7000p_ctrl_timf(struct dvb_frontend *fe, u8 op, u32 timf); extern u32 dib7000p_ctrl_timf(struct dvb_frontend *fe, u8 op, u32 timf);
extern int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart);
extern int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff); extern int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff);
extern int dib7090_get_adc_power(struct dvb_frontend *fe); extern int dib7090_get_adc_power(struct dvb_frontend *fe);
extern struct i2c_adapter *dib7090_get_i2c_tuner(struct dvb_frontend *fe); extern struct i2c_adapter *dib7090_get_i2c_tuner(struct dvb_frontend *fe);
...@@ -122,12 +121,6 @@ static inline u32 dib7000p_ctrl_timf(struct dvb_frontend *fe, u8 op, u32 timf) ...@@ -122,12 +121,6 @@ static inline u32 dib7000p_ctrl_timf(struct dvb_frontend *fe, u8 op, u32 timf)
return 0; return 0;
} }
static inline int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart)
{
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
return -ENODEV;
}
static inline int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff) static inline int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff)
{ {
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment