diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2006-09-28 00:46:49 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:34:51 -0500 |
commit | 26f48eaa9e57a3436fc049f30241256dda002de5 (patch) | |
tree | 71a222da749f3c7bd80e888163bdc0231fbd2aab | |
parent | e2adbecf72d54515b66f8631813ec49069669d5e (diff) |
V4L/DVB (5131): M920x: more cleanups
Some cleanups and suggestions from Patrick Boettcher.
Dropped the mutex in m9206_rc_query using #if 0, because
M9206_CORE, M9206_I2C, M9206_FILTER and M9206_FW can be accessed
concurrently.
Thanks to both Aapo Tahkola and Patrick Boettcher.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/dvb/dvb-usb/m920x.c | 104 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/m920x.h | 12 |
2 files changed, 51 insertions, 65 deletions
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c index 197bc29bcb84..14b32ff40ed5 100644 --- a/drivers/media/dvb/dvb-usb/m920x.c +++ b/drivers/media/dvb/dvb-usb/m920x.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include "qt1010.h" | 16 | #include "qt1010.h" |
17 | 17 | ||
18 | /* debug */ | 18 | /* debug */ |
19 | int dvb_usb_m920x_debug; | 19 | static int dvb_usb_m920x_debug; |
20 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); | 20 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); |
21 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 21 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
22 | 22 | ||
@@ -85,8 +85,6 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
85 | int i, ret = 0; | 85 | int i, ret = 0; |
86 | u8 rc_state[2]; | 86 | u8 rc_state[2]; |
87 | 87 | ||
88 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | ||
89 | return -EAGAIN; | ||
90 | 88 | ||
91 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) | 89 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) |
92 | goto unlock; | 90 | goto unlock; |
@@ -128,7 +126,6 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
128 | *state = REMOTE_NO_KEY_PRESSED; | 126 | *state = REMOTE_NO_KEY_PRESSED; |
129 | 127 | ||
130 | unlock: | 128 | unlock: |
131 | mutex_unlock(&d->i2c_mutex); | ||
132 | 129 | ||
133 | return ret; | 130 | return ret; |
134 | } | 131 | } |
@@ -240,8 +237,6 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe) | |||
240 | return 0; | 237 | return 0; |
241 | } | 238 | } |
242 | 239 | ||
243 | struct mt352_state; | ||
244 | |||
245 | static struct mt352_config megasky_mt352_config = { | 240 | static struct mt352_config megasky_mt352_config = { |
246 | .demod_address = 0x1e, | 241 | .demod_address = 0x1e, |
247 | .no_tuner = 1, | 242 | .no_tuner = 1, |
@@ -267,52 +262,7 @@ static int megasky_tuner_attach(struct dvb_usb_adapter *adap) | |||
267 | return 0; | 262 | return 0; |
268 | } | 263 | } |
269 | 264 | ||
270 | /* DVB USB Driver stuff */ | 265 | static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid) |
271 | static struct dvb_usb_device_properties megasky_properties; | ||
272 | |||
273 | static int m920x_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
274 | { | ||
275 | struct usb_device *udev = interface_to_usbdev(intf); | ||
276 | struct dvb_usb_device *d; | ||
277 | struct usb_host_interface *alt; | ||
278 | struct dvb_usb_device_properties props; | ||
279 | int ret; | ||
280 | |||
281 | memcpy(&props, &megasky_properties, sizeof(struct dvb_usb_device_properties)); | ||
282 | |||
283 | /* Hardware pid filtering isn't quite perfect so dont use unless have to. */ | ||
284 | if (udev->speed == USB_SPEED_FULL) | ||
285 | props.caps |= DVB_USB_ADAP_HAS_PID_FILTER | | ||
286 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF; | ||
287 | |||
288 | if ((ret = dvb_usb_device_init(intf, &props, THIS_MODULE, &d)) == 0) { | ||
289 | deb_rc("probed!\n"); | ||
290 | |||
291 | alt = usb_altnum_to_altsetting(intf, 1); | ||
292 | if (alt == NULL) { | ||
293 | deb_rc("not alt found!\n"); | ||
294 | return -ENODEV; | ||
295 | } | ||
296 | |||
297 | ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting); | ||
298 | if (ret < 0) | ||
299 | return ret; | ||
300 | |||
301 | deb_rc("Changed to alternate setting!\n"); | ||
302 | |||
303 | if ((ret = m9206_rc_init(d->udev)) != 0) | ||
304 | return ret; | ||
305 | } | ||
306 | return ret; | ||
307 | } | ||
308 | |||
309 | static struct usb_device_id m920x_table [] = { | ||
310 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, | ||
311 | { } /* Terminating entry */ | ||
312 | }; | ||
313 | MODULE_DEVICE_TABLE (usb, m920x_table); | ||
314 | |||
315 | static int set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid) | ||
316 | { | 266 | { |
317 | int ret = 0; | 267 | int ret = 0; |
318 | 268 | ||
@@ -341,14 +291,14 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap) | |||
341 | enabled = 0; | 291 | enabled = 0; |
342 | 292 | ||
343 | /* Disable all filters */ | 293 | /* Disable all filters */ |
344 | if ((ret = set_filter(adap, 0x81, 1, enabled)) != 0) | 294 | if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0) |
345 | return ret; | 295 | return ret; |
346 | 296 | ||
347 | for (i = 0; i < M9206_MAX_FILTERS; i++) | 297 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
348 | if ((ret = set_filter(adap, 0x81, i + 2, 0)) != 0) | 298 | if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0) |
349 | return ret; | 299 | return ret; |
350 | 300 | ||
351 | if ((ret = set_filter(adap, 0x82, 0, 0x0)) != 0) | 301 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0) |
352 | return ret; | 302 | return ret; |
353 | 303 | ||
354 | /* Set */ | 304 | /* Set */ |
@@ -357,14 +307,14 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap) | |||
357 | if (m->filters[i] == 0) | 307 | if (m->filters[i] == 0) |
358 | continue; | 308 | continue; |
359 | 309 | ||
360 | if ((ret = set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) | 310 | if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) |
361 | return ret; | 311 | return ret; |
362 | 312 | ||
363 | filter++; | 313 | filter++; |
364 | } | 314 | } |
365 | } | 315 | } |
366 | 316 | ||
367 | if ((ret = set_filter(adap, 0x82, 0, 0x02f5)) != 0) | 317 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0) |
368 | return ret; | 318 | return ret; |
369 | 319 | ||
370 | return ret; | 320 | return ret; |
@@ -450,6 +400,42 @@ static int m9206_firmware_download(struct usb_device *udev, const struct firmwar | |||
450 | return ret; | 400 | return ret; |
451 | } | 401 | } |
452 | 402 | ||
403 | /* DVB USB Driver stuff */ | ||
404 | static struct dvb_usb_device_properties megasky_properties; | ||
405 | |||
406 | static int m920x_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
407 | { | ||
408 | struct dvb_usb_device *d; | ||
409 | struct usb_host_interface *alt; | ||
410 | int ret; | ||
411 | |||
412 | if ((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) { | ||
413 | deb_rc("probed!\n"); | ||
414 | |||
415 | alt = usb_altnum_to_altsetting(intf, 1); | ||
416 | if (alt == NULL) { | ||
417 | deb_rc("not alt found!\n"); | ||
418 | return -ENODEV; | ||
419 | } | ||
420 | |||
421 | ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting); | ||
422 | if (ret < 0) | ||
423 | return ret; | ||
424 | |||
425 | deb_rc("Changed to alternate setting!\n"); | ||
426 | |||
427 | if ((ret = m9206_rc_init(d->udev)) != 0) | ||
428 | return ret; | ||
429 | } | ||
430 | return ret; | ||
431 | } | ||
432 | |||
433 | static struct usb_device_id m920x_table [] = { | ||
434 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, | ||
435 | { } /* Terminating entry */ | ||
436 | }; | ||
437 | MODULE_DEVICE_TABLE (usb, m920x_table); | ||
438 | |||
453 | static struct dvb_usb_device_properties megasky_properties = { | 439 | static struct dvb_usb_device_properties megasky_properties = { |
454 | .usb_ctrl = DEVICE_SPECIFIC, | 440 | .usb_ctrl = DEVICE_SPECIFIC, |
455 | .firmware = "dvb-usb-megasky-02.fw", | 441 | .firmware = "dvb-usb-megasky-02.fw", |
@@ -465,7 +451,9 @@ static struct dvb_usb_device_properties megasky_properties = { | |||
465 | .identify_state = megasky_identify_state, | 451 | .identify_state = megasky_identify_state, |
466 | .num_adapters = 1, | 452 | .num_adapters = 1, |
467 | .adapter = {{ | 453 | .adapter = {{ |
468 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 454 | .caps = DVB_USB_IS_AN_I2C_ADAPTER | DVB_USB_ADAP_HAS_PID_FILTER | |
455 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
456 | |||
469 | .pid_filter_count = 8, | 457 | .pid_filter_count = 8, |
470 | .pid_filter = m9206_pid_filter, | 458 | .pid_filter = m9206_pid_filter, |
471 | .pid_filter_ctrl = m9206_pid_filter_ctrl, | 459 | .pid_filter_ctrl = m9206_pid_filter_ctrl, |
diff --git a/drivers/media/dvb/dvb-usb/m920x.h b/drivers/media/dvb/dvb-usb/m920x.h index 709b7d205b6d..597df11e6ea0 100644 --- a/drivers/media/dvb/dvb-usb/m920x.h +++ b/drivers/media/dvb/dvb-usb/m920x.h | |||
@@ -4,15 +4,14 @@ | |||
4 | #define DVB_USB_LOG_PREFIX "m920x" | 4 | #define DVB_USB_LOG_PREFIX "m920x" |
5 | #include "dvb-usb.h" | 5 | #include "dvb-usb.h" |
6 | 6 | ||
7 | extern int dvb_usb_m920x_debug; | ||
8 | #define deb_rc(args...) dprintk(dvb_usb_m920x_debug,0x01,args) | 7 | #define deb_rc(args...) dprintk(dvb_usb_m920x_debug,0x01,args) |
9 | 8 | ||
10 | #define M9206_CORE 0x22 | 9 | #define M9206_CORE 0x22 |
11 | #define M9206_RC_STATE 0xff51 | 10 | #define M9206_RC_STATE 0xff51 |
12 | #define M9206_RC_KEY 0xff52 | 11 | #define M9206_RC_KEY 0xff52 |
13 | #define M9206_RC_INIT1 0xff54 | 12 | #define M9206_RC_INIT1 0xff54 |
14 | #define M9206_RC_INIT2 0xff55 | 13 | #define M9206_RC_INIT2 0xff55 |
15 | #define M9206_FW_GO 0xff69 | 14 | #define M9206_FW_GO 0xff69 |
16 | 15 | ||
17 | #define M9206_I2C 0x23 | 16 | #define M9206_I2C 0x23 |
18 | #define M9206_FILTER 0x25 | 17 | #define M9206_FILTER 0x25 |
@@ -24,5 +23,4 @@ struct m9206_state { | |||
24 | int filtering_enabled; | 23 | int filtering_enabled; |
25 | int rep_count; | 24 | int rep_count; |
26 | }; | 25 | }; |
27 | |||
28 | #endif | 26 | #endif |