aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/m920x.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-01-23 13:00:42 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:54 -0500
commite16c1f55642d79a80c45ace7603b284975559e78 (patch)
tree30c0f259d81da8ba7e4d1538c365a403fff673d9 /drivers/media/dvb/dvb-usb/m920x.c
parentfa94805d0316e7706d2ce0273a9c58688482c9f6 (diff)
V4L/DVB (5141): M920x: group tuner / demod callback functions together
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/m920x.c')
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c125
1 files changed, 63 insertions, 62 deletions
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 585d0e350d4a..816c7129ed98 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -199,65 +199,6 @@ static struct i2c_algorithm m9206_i2c_algo = {
199 .functionality = m9206_i2c_func, 199 .functionality = m9206_i2c_func,
200}; 200};
201 201
202/* Callbacks for DVB USB */
203static int megasky_identify_state(struct usb_device *udev,
204 struct dvb_usb_device_properties *props,
205 struct dvb_usb_device_description **desc,
206 int *cold)
207{
208 struct usb_host_interface *alt;
209
210 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
211 *cold = (alt == NULL) ? 1 : 0;
212
213 return 0;
214}
215
216static int megasky_mt352_demod_init(struct dvb_frontend *fe)
217{
218 u8 config[] = { CONFIG, 0x3d };
219 u8 clock[] = { CLOCK_CTL, 0x30 };
220 u8 reset[] = { RESET, 0x80 };
221 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
222 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
223 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
224 u8 unk1[] = { 0x93, 0x1a };
225 u8 unk2[] = { 0xb5, 0x7a };
226
227 mt352_write(fe, config, ARRAY_SIZE(config));
228 mt352_write(fe, clock, ARRAY_SIZE(clock));
229 mt352_write(fe, reset, ARRAY_SIZE(reset));
230 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
231 mt352_write(fe, agc, ARRAY_SIZE(agc));
232 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
233 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
234 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
235
236 deb_rc("Demod init!\n");
237
238 return 0;
239}
240
241static struct mt352_config megasky_mt352_config = {
242 .demod_address = 0x1e,
243 .no_tuner = 1,
244 .demod_init = megasky_mt352_demod_init,
245};
246
247static int megasky_frontend_attach(struct dvb_usb_adapter *adap)
248{
249 struct m9206_state *m = adap->dev->priv;
250
251 deb_rc("megasky_frontend_attach!\n");
252
253 m->i2c_r[M9206_I2C_DEMOD].addr = megasky_mt352_config.demod_address;
254 m->i2c_r[M9206_I2C_DEMOD].magic = 0x1f;
255
256 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL)
257 return -EIO;
258
259 return 0;
260}
261 202
262static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, 203static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx,
263 int pid) 204 int pid)
@@ -400,11 +341,71 @@ static int m9206_firmware_download(struct usb_device *udev,
400 return ret; 341 return ret;
401} 342}
402 343
344/* Callbacks for DVB USB */
345static int megasky_identify_state(struct usb_device *udev,
346 struct dvb_usb_device_properties *props,
347 struct dvb_usb_device_description **desc,
348 int *cold)
349{
350 struct usb_host_interface *alt;
351
352 alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1);
353 *cold = (alt == NULL) ? 1 : 0;
354
355 return 0;
356}
357
358static int megasky_mt352_demod_init(struct dvb_frontend *fe)
359{
360 u8 config[] = { CONFIG, 0x3d };
361 u8 clock[] = { CLOCK_CTL, 0x30 };
362 u8 reset[] = { RESET, 0x80 };
363 u8 adc_ctl[] = { ADC_CTL_1, 0x40 };
364 u8 agc[] = { AGC_TARGET, 0x1c, 0x20 };
365 u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 };
366 u8 unk1[] = { 0x93, 0x1a };
367 u8 unk2[] = { 0xb5, 0x7a };
368
369 mt352_write(fe, config, ARRAY_SIZE(config));
370 mt352_write(fe, clock, ARRAY_SIZE(clock));
371 mt352_write(fe, reset, ARRAY_SIZE(reset));
372 mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl));
373 mt352_write(fe, agc, ARRAY_SIZE(agc));
374 mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc));
375 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
376 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
377
378 deb_rc("Demod init!\n");
379
380 return 0;
381}
382
383static struct mt352_config megasky_mt352_config = {
384 .demod_address = 0x1e,
385 .no_tuner = 1,
386 .demod_init = megasky_mt352_demod_init,
387};
388
389static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap)
390{
391 struct m9206_state *m = adap->dev->priv;
392
393 deb_rc("megasky_frontend_attach!\n");
394
395 m->i2c_r[M9206_I2C_DEMOD].addr = megasky_mt352_config.demod_address;
396 m->i2c_r[M9206_I2C_DEMOD].magic = 0x1f;
397
398 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL)
399 return -EIO;
400
401 return 0;
402}
403
403static struct qt1010_config megasky_qt1010_config = { 404static struct qt1010_config megasky_qt1010_config = {
404 .i2c_address = 0xc4 405 .i2c_address = 0xc4
405}; 406};
406 407
407static int megasky_tuner_attach(struct dvb_usb_adapter *adap) 408static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
408{ 409{
409 struct m9206_state *m = adap->dev->priv; 410 struct m9206_state *m = adap->dev->priv;
410 411
@@ -478,8 +479,8 @@ static struct dvb_usb_device_properties megasky_properties = {
478 .pid_filter = m9206_pid_filter, 479 .pid_filter = m9206_pid_filter,
479 .pid_filter_ctrl = m9206_pid_filter_ctrl, 480 .pid_filter_ctrl = m9206_pid_filter_ctrl,
480 481
481 .frontend_attach = megasky_frontend_attach, 482 .frontend_attach = megasky_mt352_frontend_attach,
482 .tuner_attach = megasky_tuner_attach, 483 .tuner_attach = megasky_qt1010_tuner_attach,
483 484
484 .stream = { 485 .stream = {
485 .type = USB_BULK, 486 .type = USB_BULK,