aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPatrick Boettcher <pb@linuxtv.org>2006-09-19 11:51:53 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-10-03 14:12:50 -0400
commit01b4bf31ce6ca6c1de31c773fa281a34fd98ff87 (patch)
tree5537513572c911ee125e45f4ed6109c7d75167ea /drivers
parentd535cfa776b091a95ca88ba560a9d296cb1570fd (diff)
V4L/DVB (4652): Misc fixes for DiB3000MC and Nova-T 500
- make the timing frequency update work. - fix AGC calibration for Nova-T 500 Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c2
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c81
2 files changed, 35 insertions, 48 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 58ecc8ff858a..182051011c91 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -25,7 +25,7 @@ static struct mt2060_config bristol_mt2060_config[2] = {
25 25
26static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = { 26static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
27 .band_caps = BAND_VHF | BAND_UHF, 27 .band_caps = BAND_VHF | BAND_UHF,
28 .setup = (0 << 15) | (0 << 14) | (0 << 13) | (0 << 12) | (29 << 0), 28 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
29 29
30 .agc1_max = 42598, 30 .agc1_max = 42598,
31 .agc1_min = 17694, 31 .agc1_min = 17694,
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index 60e10dba3684..0b051c7d5cd7 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -37,6 +37,8 @@ struct dib3000mc_state {
37 37
38 struct dibx000_i2c_master i2c_master; 38 struct dibx000_i2c_master i2c_master;
39 39
40 u32 timf;
41
40 fe_bandwidth_t current_bandwidth; 42 fe_bandwidth_t current_bandwidth;
41 43
42 u16 dev_id; 44 u16 dev_id;
@@ -92,50 +94,31 @@ static int dib3000mc_identify(struct dib3000mc_state *state)
92 94
93static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, u8 update_offset) 95static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, u8 update_offset)
94{ 96{
95/* 97 u32 timf;
96 u32 timf_msb, timf_lsb, i;
97 int tim_sgn ;
98 LUInt comp1, comp2, comp ;
99// u32 tim_offset ;
100 comp = 27700 * BW_INDEX_TO_KHZ(bw) / 1000;
101 timf_msb = (comp >> 16) & 0x00FF;
102 timf_lsb = comp & 0xFFFF;
103
104 // Update the timing offset ;
105 if (update_offset) {
106 if (state->timing_offset_comp_done == 0) {
107 usleep(200000);
108 state->timing_offset_comp_done = 1;
109 }
110 tim_offset = dib3000mc_read_word(state, 416);
111 if ((tim_offset & 0x2000) == 0x2000)
112 tim_offset |= 0xC000; // PB: This only works if tim_offset is s16 - weird
113
114 if (nfft == 0)
115 tim_offset = tim_offset << 2; // PB: Do not store the offset for different things in one variable
116 state->timing_offset += tim_offset;
117 }
118 tim_offset = state->timing_offset;
119 98
120 if (tim_offset < 0) { 99 if (state->timf == 0) {
121 tim_sgn = 1; 100 timf = 1384402; // default value for 8MHz
122 tim_offset = -tim_offset; 101 if (update_offset)
102 msleep(200); // first time we do an update
123 } else 103 } else
124 tim_sgn = 0; 104 timf = state->timf;
125 105
126 comp1 = tim_offset * timf_lsb; 106 timf *= (BW_INDEX_TO_KHZ(bw) / 1000);
127 comp2 = tim_offset * timf_msb;
128 comp = ((comp1 >> 16) + comp2) >> 7;
129 107
130 if (tim_sgn == 0) 108 if (update_offset) {
131 comp = timf_msb * (1<<16) + timf_lsb + comp; 109 s16 tim_offs = dib3000mc_read_word(state, 416);
132 else 110
133 comp = timf_msb * (1<<16) + timf_lsb - comp; 111 if (tim_offs & 0x2000)
112 tim_offs -= 0x4000;
113
114 if (nfft == 0)
115 tim_offs *= 4;
116
117 timf += tim_offs;
118 state->timf = timf / (BW_INDEX_TO_KHZ(bw) / 1000);
119 }
134 120
135 timf_msb = (comp>>16)&0xFF ; 121 dprintk("timf: %d\n", timf);
136 timf_lsb = comp&0xFFFF;
137*/
138 u32 timf = 1384402 * (BW_INDEX_TO_KHZ(bw) / 1000);
139 122
140 dib3000mc_write_word(state, 23, timf >> 16); 123 dib3000mc_write_word(state, 23, timf >> 16);
141 dib3000mc_write_word(state, 24, timf & 0xffff); 124 dib3000mc_write_word(state, 24, timf & 0xffff);
@@ -143,15 +126,18 @@ static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw,
143 return 0; 126 return 0;
144} 127}
145 128
146static int dib3000mc_setup_pwm3_state(struct dib3000mc_state *state) 129static int dib3000mc_setup_pwm_state(struct dib3000mc_state *state)
147{ 130{
131 u16 reg_51, reg_52 = state->cfg->agc->setup & 0xfefb;
148 if (state->cfg->pwm3_inversion) { 132 if (state->cfg->pwm3_inversion) {
149 dib3000mc_write_word(state, 51, (2 << 14) | (0 << 10) | (7 << 6) | (2 << 2) | (2 << 0)); 133 reg_51 = (2 << 14) | (0 << 10) | (7 << 6) | (2 << 2) | (2 << 0);
150 dib3000mc_write_word(state, 52, (0 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (2 << 0)); 134 reg_52 |= (1 << 2);
151 } else { 135 } else {
152 dib3000mc_write_word(state, 51, (2 << 14) | (4 << 10) | (7 << 6) | (2 << 2) | (2 << 0)); 136 reg_51 = (2 << 14) | (4 << 10) | (7 << 6) | (2 << 2) | (2 << 0);
153 dib3000mc_write_word(state, 52, (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0)); 137 reg_52 |= (1 << 8);
154 } 138 }
139 dib3000mc_write_word(state, 51, reg_51);
140 dib3000mc_write_word(state, 52, reg_52);
155 141
156 if (state->cfg->use_pwm3) 142 if (state->cfg->use_pwm3)
157 dib3000mc_write_word(state, 245, (1 << 3) | (1 << 0)); 143 dib3000mc_write_word(state, 245, (1 << 3) | (1 << 0));
@@ -350,7 +336,7 @@ static int dib3000mc_init(struct dvb_frontend *demod)
350 dib3000mc_write_word(state, 50, 0x8000); 336 dib3000mc_write_word(state, 50, 0x8000);
351 337
352 // agc setup misc 338 // agc setup misc
353 dib3000mc_setup_pwm3_state(state); 339 dib3000mc_setup_pwm_state(state);
354 340
355 // P_agc_counter_lock 341 // P_agc_counter_lock
356 dib3000mc_write_word(state, 53, 0x87); 342 dib3000mc_write_word(state, 53, 0x87);
@@ -539,6 +525,7 @@ static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dibx000
539 525
540 reg = dib3000mc_read_word(state, 0); 526 reg = dib3000mc_read_word(state, 0);
541 dib3000mc_write_word(state, 0, reg | (1 << 8)); 527 dib3000mc_write_word(state, 0, reg | (1 << 8));
528 dib3000mc_read_word(state, 511);
542 dib3000mc_write_word(state, 0, reg); 529 dib3000mc_write_word(state, 0, reg);
543 530
544 return 0; 531 return 0;
@@ -578,8 +565,8 @@ static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channe
578 dib3000mc_write_word(state, 33, 6); 565 dib3000mc_write_word(state, 33, 6);
579 } 566 }
580 567
581 // if (lock) 568 if (dib3000mc_read_word(state, 509) & 0x80)
582 // dib3000mc_set_timing(state, ch->nfft, ch->Bw, 1); 569 dib3000mc_set_timing(state, ch->nfft, ch->Bw, 1);
583 570
584 return 0; 571 return 0;
585} 572}