aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/dibusb-common.c
diff options
context:
space:
mode:
authorPatrick Boettcher <pb@linuxtv.org>2006-08-08 14:48:10 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 10:53:46 -0400
commitb7571f8d7e12cd70048331e6a0199a42dc995d99 (patch)
tree5a536abb2530f3bec89666ddebc457b35a1aba37 /drivers/media/dvb/dvb-usb/dibusb-common.c
parent74340b0a8bc60b400c7e5fe4950303aa6f914d16 (diff)
V4L/DVB: Complete rewrite of the DiB3000mc-driver
A complete rewrite of the DiB3000MC/P driver has been done. It is now much more easy to maintain and to get improvements inside. Additionally the tuning time has been reduced and the usage of the driver is much more understandable now. Signed-off-by: Patrick Boettcher <pboettcher@dibcom.fr> Signed-off-by: Francois KANOUNNIKOFF <fkanounnikoff@dibcom.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dibusb-common.c')
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c131
1 files changed, 117 insertions, 14 deletions
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 78a604dfadfc..390ced9ae4bc 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -131,9 +131,6 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
131 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 131 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
132 return -EAGAIN; 132 return -EAGAIN;
133 133
134 if (num > 2)
135 warn("more than 2 i2c messages at a time is not handled yet. TODO.");
136
137 for (i = 0; i < num; i++) { 134 for (i = 0; i < num; i++) {
138 /* write/read request */ 135 /* write/read request */
139 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { 136 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
@@ -168,31 +165,137 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
168} 165}
169EXPORT_SYMBOL(dibusb_read_eeprom_byte); 166EXPORT_SYMBOL(dibusb_read_eeprom_byte);
170 167
171static const struct dib3000p_agc_config dib3000p_agc_panasonic_env57h1xd5 = { 168/* 3000MC/P stuff */
172 { 0x51, 0x301d, 0x0, 0x1cc7, 0xdc29, 0x570a, 169// Config Adjacent channels Perf -cal22
173 0xbae1, 0x8ccd, 0x3b6d, 0x551d, 0xa, 0x951e } 170static struct dibx000_agc_config dib3000p_mt2060_agc_config = {
171 .band_caps = BAND_VHF | BAND_UHF,
172 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0),
173
174 .agc1_max = 48497,
175 .agc1_min = 23593,
176 .agc2_max = 46531,
177 .agc2_min = 24904,
178
179 .agc1_pt1 = 0x65,
180 .agc1_pt2 = 0x69,
181
182 .agc1_slope1 = 0x51,
183 .agc1_slope2 = 0x27,
184
185 .agc2_pt1 = 0,
186 .agc2_pt2 = 0x33,
187
188 .agc2_slope1 = 0x35,
189 .agc2_slope2 = 0x37,
174}; 190};
175 191
176static const struct dib3000p_agc_config dib3000p_agc_microtune_mt2060 = { 192static struct dib3000mc_config stk3000p_dib3000p_config = {
177 { 0x196, 0x301d, 0x0, 0x1cc7, 0xffff, 0x5c29, 193 &dib3000p_mt2060_agc_config,
178 0xa8f6, 0x5eb8, 0x65ff, 0x40ff, 0x8a, 0x1114 } 194
195 .max_time = 0x196,
196 .ln_adc_level = 0x1cc7,
197
198 .output_mpeg2_in_188_bytes = 1,
179}; 199};
180 200
181static struct mt2060_config stk3000p_mt2060_config = { 201static struct dibx000_agc_config dib3000p_panasonic_agc_config = {
182 .i2c_address = 0x60, 202 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0),
203
204 .agc1_max = 56361,
205 .agc1_min = 22282,
206 .agc2_max = 43254,
207 .agc2_min = 36045,
208
209 .agc1_pt1 = 0x65,
210 .agc1_pt2 = 0xff,
211
212 .agc1_slope1 = 0x40,
213 .agc1_slope2 = 0xff,
214
215 .agc2_pt1 = 0,
216 .agc2_pt2 = 0x8a,
217
218 .agc2_slope1 = 0x11,
219 .agc2_slope2 = 0x14,
220};
221
222static struct dib3000mc_config mod3000p_dib3000p_config = {
223 &dib3000p_panasonic_agc_config,
224
225 .max_time = 0x51,
226 .ln_adc_level = 0x1cc7,
227
228 .output_mpeg2_in_188_bytes = 1,
183}; 229};
184 230
185int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d) 231int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d)
186{ 232{
187 struct dib3000_config demod_cfg; 233 if (dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000P_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0) {
188 struct dibusb_state *st = d->priv; 234 if (d->priv != NULL) {
235 struct dibusb_state *st = d->priv;
236 st->ops.pid_parse = dib3000mc_pid_parse;
237 st->ops.pid_ctrl = dib3000mc_pid_control;
238 }
239 return 0;
240 }
189 return -ENODEV; 241 return -ENODEV;
190} 242}
191EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach); 243EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach);
192 244
245static struct mt2060_config stk3000p_mt2060_config = {
246 0x60
247};
248
193int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d) 249int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
194{ 250{
195 return -ENODEV; 251 struct dibusb_state *st = d->priv;
252 int ret;
253 u8 a,b;
254 u16 if1 = 1220;
255 struct i2c_adapter *tun_i2c;
256
257 // First IF calibration for Liteon Sticks
258 if (d->udev->descriptor.idVendor == USB_VID_LITEON &&
259 d->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) {
260
261 dibusb_read_eeprom_byte(d,0x7E,&a);
262 dibusb_read_eeprom_byte(d,0x7F,&b);
263
264 if (a == 0x00)
265 if1 += b;
266 else if (a == 0x80)
267 if1 -= b;
268 else
269 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b);
270
271 } else if (d->udev->descriptor.idVendor == USB_VID_DIBCOM &&
272 d->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) {
273 u8 desc;
274 dibusb_read_eeprom_byte(d, 7, &desc);
275 if (desc == 2) {
276 a = 127;
277 do {
278 dibusb_read_eeprom_byte(d, a, &desc);
279 a--;
280 } while (a > 7 && (desc == 0xff || desc == 0x00));
281 if (desc & 0x80)
282 if1 -= (0xff - desc);
283 else
284 if1 += desc;
285 }
286 }
287
288 tun_i2c = dib3000mc_get_tuner_i2c_master(d->fe, 1);
289 if ((ret = mt2060_attach(d->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) {
290 /* not found - use panasonic pll parameters */
291 if (dvb_pll_attach(d->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL)
292 return -ENOMEM;
293 } else {
294 st->mt2060_present = 1;
295 /* set the correct parameters for the dib3000p */
296 dib3000mc_set_config(d->fe, &stk3000p_dib3000p_config);
297 }
298 return 0;
196} 299}
197EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach); 300EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);
198 301