aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/m920x.c
diff options
context:
space:
mode:
authorAapo Tahkola <aet@rasterburn.org>2007-03-05 16:54:27 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:44:41 -0400
commit480ac761729349f9005d2c6dce6076f7e33de3bc (patch)
tree9acab58f11e0e1f5ca2f3e7433bb29d577f46c8b /drivers/media/dvb/dvb-usb/m920x.c
parent26a154c355cceba66ff13b383aa2019c28dbc685 (diff)
V4L/DVB (5425): M920x: rework driver code to allow for different devices
Signed-off-by: Aapo Tahkola <aet@rasterburn.org> 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.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 92f76c918c79..1d3cbc1b2653 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -67,16 +67,18 @@ static inline int m9206_write(struct usb_device *udev, u8 request,
67 return ret; 67 return ret;
68} 68}
69 69
70static int m9206_rc_init(struct usb_device *udev) 70static int m9206_init(struct dvb_usb_device *d)
71{ 71{
72 int ret = 0; 72 int ret = 0;
73 73
74 /* Remote controller init. */ 74 /* Remote controller init. */
75 if ((ret = m9206_write(udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) 75 if (d->props.rc_query) {
76 return ret; 76 if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0)
77 return ret;
77 78
78 if ((ret = m9206_write(udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) 79 if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0)
79 return ret; 80 return ret;
81 }
80 82
81 return ret; 83 return ret;
82} 84}
@@ -94,9 +96,9 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
94 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) 96 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
95 goto unlock; 97 goto unlock;
96 98
97 for (i = 0; i < ARRAY_SIZE(megasky_rc_keys); i++) 99 for (i = 0; i < d->props.rc_key_map_size; i++)
98 if (megasky_rc_keys[i].data == rc_state[1]) { 100 if (d->props.rc_key_map[i].data == rc_state[1]) {
99 *event = megasky_rc_keys[i].event; 101 *event = d->props.rc_key_map[i].event;
100 102
101 switch(rc_state[0]) { 103 switch(rc_state[0]) {
102 case 0x80: 104 case 0x80:
@@ -412,25 +414,28 @@ static int m920x_probe(struct usb_interface *intf,
412 struct usb_host_interface *alt; 414 struct usb_host_interface *alt;
413 int ret; 415 int ret;
414 416
415 if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) { 417 deb_rc("Probed!\n");
416 deb_rc("probed!\n");
417 418
418 alt = usb_altnum_to_altsetting(intf, 1); 419 if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0)
419 if (alt == NULL) { 420 goto found;
420 deb_rc("not alt found!\n");
421 return -ENODEV;
422 }
423
424 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
425 alt->desc.bAlternateSetting);
426 if (ret < 0)
427 return ret;
428 421
429 deb_rc("Changed to alternate setting!\n"); 422 return ret;
430 423
431 if ((ret = m9206_rc_init(d->udev)) != 0) 424found:
432 return ret; 425 alt = usb_altnum_to_altsetting(intf, 1);
426 if (alt == NULL) {
427 deb_rc("No alt found!\n");
428 return -ENODEV;
433 } 429 }
430
431 ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber,
432 alt->desc.bAlternateSetting);
433 if (ret < 0)
434 return ret;
435
436 if ((ret = m9206_init(d)) != 0)
437 return ret;
438
434 return ret; 439 return ret;
435} 440}
436 441