aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/streamzap.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2010-10-29 15:08:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:37 -0500
commitd8b4b5822f51e2142b731b42c81e3f03eec475b2 (patch)
treefce9a9b7ca5031adc95fbd6be118352fb2527da5 /drivers/media/rc/streamzap.c
parent4c7b355df6e7f05304e05f6b7a286e59a5f1cc54 (diff)
[media] ir-core: make struct rc_dev the primary interface
This patch merges the ir_input_dev and ir_dev_props structs into a single struct called rc_dev. The drivers and various functions in rc-core used by the drivers are also changed to use rc_dev as the primary interface when dealing with rc-core. This means that the input_dev is abstracted away from the drivers which is necessary if we ever want to support multiple input devs per rc device. The new API is similar to what the input subsystem uses, i.e: rc_device_alloc() rc_device_free() rc_device_register() rc_device_unregister() [mchehab@redhat.com: Fix compilation on mceusb and cx231xx, due to merge conflicts] Signed-off-by: David Härdeman <david@hardeman.nu> Acked-by: Jarod Wilson <jarod@redhat.com> Tested-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/rc/streamzap.c')
-rw-r--r--drivers/media/rc/streamzap.c73
1 files changed, 28 insertions, 45 deletions
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index 3a20aef67d08..f05f5c173fdf 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -34,7 +34,6 @@
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/input.h>
38#include <linux/usb.h> 37#include <linux/usb.h>
39#include <linux/usb/input.h> 38#include <linux/usb/input.h>
40#include <media/ir-core.h> 39#include <media/ir-core.h>
@@ -86,13 +85,11 @@ enum StreamzapDecoderState {
86 85
87/* structure to hold our device specific stuff */ 86/* structure to hold our device specific stuff */
88struct streamzap_ir { 87struct streamzap_ir {
89
90 /* ir-core */ 88 /* ir-core */
91 struct ir_dev_props *props; 89 struct rc_dev *rdev;
92 90
93 /* core device info */ 91 /* core device info */
94 struct device *dev; 92 struct device *dev;
95 struct input_dev *idev;
96 93
97 /* usb */ 94 /* usb */
98 struct usb_device *usbdev; 95 struct usb_device *usbdev;
@@ -143,7 +140,7 @@ static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir)
143{ 140{
144 dev_dbg(sz->dev, "Storing %s with duration %u us\n", 141 dev_dbg(sz->dev, "Storing %s with duration %u us\n",
145 (rawir.pulse ? "pulse" : "space"), rawir.duration); 142 (rawir.pulse ? "pulse" : "space"), rawir.duration);
146 ir_raw_event_store_with_filter(sz->idev, &rawir); 143 ir_raw_event_store_with_filter(sz->rdev, &rawir);
147} 144}
148 145
149static void sz_push_full_pulse(struct streamzap_ir *sz, 146static void sz_push_full_pulse(struct streamzap_ir *sz,
@@ -271,11 +268,11 @@ static void streamzap_callback(struct urb *urb)
271 DEFINE_IR_RAW_EVENT(rawir); 268 DEFINE_IR_RAW_EVENT(rawir);
272 269
273 rawir.pulse = false; 270 rawir.pulse = false;
274 rawir.duration = sz->props->timeout; 271 rawir.duration = sz->rdev->timeout;
275 sz->idle = true; 272 sz->idle = true;
276 if (sz->timeout_enabled) 273 if (sz->timeout_enabled)
277 sz_push(sz, rawir); 274 sz_push(sz, rawir);
278 ir_raw_event_handle(sz->idev); 275 ir_raw_event_handle(sz->rdev);
279 } else { 276 } else {
280 sz_push_full_space(sz, sz->buf_in[i]); 277 sz_push_full_space(sz, sz->buf_in[i]);
281 } 278 }
@@ -298,57 +295,43 @@ static void streamzap_callback(struct urb *urb)
298 return; 295 return;
299} 296}
300 297
301static struct input_dev *streamzap_init_input_dev(struct streamzap_ir *sz) 298static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
302{ 299{
303 struct input_dev *idev; 300 struct rc_dev *rdev;
304 struct ir_dev_props *props;
305 struct device *dev = sz->dev; 301 struct device *dev = sz->dev;
306 int ret; 302 int ret;
307 303
308 idev = input_allocate_device(); 304 rdev = rc_allocate_device();
309 if (!idev) { 305 if (!rdev) {
310 dev_err(dev, "remote input dev allocation failed\n"); 306 dev_err(dev, "remote dev allocation failed\n");
311 goto idev_alloc_failed; 307 goto out;
312 }
313
314 props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL);
315 if (!props) {
316 dev_err(dev, "remote ir dev props allocation failed\n");
317 goto props_alloc_failed;
318 } 308 }
319 309
320 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared " 310 snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared "
321 "Receiver (%04x:%04x)", 311 "Receiver (%04x:%04x)",
322 le16_to_cpu(sz->usbdev->descriptor.idVendor), 312 le16_to_cpu(sz->usbdev->descriptor.idVendor),
323 le16_to_cpu(sz->usbdev->descriptor.idProduct)); 313 le16_to_cpu(sz->usbdev->descriptor.idProduct));
324
325 idev->name = sz->name;
326 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); 314 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys));
327 strlcat(sz->phys, "/input0", sizeof(sz->phys)); 315 strlcat(sz->phys, "/input0", sizeof(sz->phys));
328 idev->phys = sz->phys;
329
330 props->priv = sz;
331 props->driver_type = RC_DRIVER_IR_RAW;
332 props->allowed_protos = IR_TYPE_ALL;
333
334 sz->props = props;
335 316
336 usb_to_input_id(sz->usbdev, &idev->id); 317 rdev->input_name = sz->name;
337 idev->dev.parent = sz->dev; 318 rdev->input_phys = sz->phys;
319 rdev->priv = sz;
320 rdev->driver_type = RC_DRIVER_IR_RAW;
321 rdev->allowed_protos = IR_TYPE_ALL;
322 rdev->driver_name = DRIVER_NAME;
323 rdev->map_name = RC_MAP_STREAMZAP;
338 324
339 ret = ir_input_register(idev, RC_MAP_STREAMZAP, props, DRIVER_NAME); 325 ret = rc_register_device(rdev);
340 if (ret < 0) { 326 if (ret < 0) {
341 dev_err(dev, "remote input device register failed\n"); 327 dev_err(dev, "remote input device register failed\n");
342 goto irdev_failed; 328 goto out;
343 } 329 }
344 330
345 return idev; 331 return rdev;
346 332
347irdev_failed: 333out:
348 kfree(props); 334 rc_free_device(rdev);
349props_alloc_failed:
350 input_free_device(idev);
351idev_alloc_failed:
352 return NULL; 335 return NULL;
353} 336}
354 337
@@ -437,15 +420,15 @@ static int __devinit streamzap_probe(struct usb_interface *intf,
437 snprintf(name + strlen(name), sizeof(name) - strlen(name), 420 snprintf(name + strlen(name), sizeof(name) - strlen(name),
438 " %s", buf); 421 " %s", buf);
439 422
440 sz->idev = streamzap_init_input_dev(sz); 423 sz->rdev = streamzap_init_rc_dev(sz);
441 if (!sz->idev) 424 if (!sz->rdev)
442 goto input_dev_fail; 425 goto rc_dev_fail;
443 426
444 sz->idle = true; 427 sz->idle = true;
445 sz->decoder_state = PulseSpace; 428 sz->decoder_state = PulseSpace;
446 /* FIXME: don't yet have a way to set this */ 429 /* FIXME: don't yet have a way to set this */
447 sz->timeout_enabled = true; 430 sz->timeout_enabled = true;
448 sz->props->timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) & 431 sz->rdev->timeout = (((SZ_TIMEOUT * SZ_RESOLUTION * 1000) &
449 IR_MAX_DURATION) | 0x03000000); 432 IR_MAX_DURATION) | 0x03000000);
450 #if 0 433 #if 0
451 /* not yet supported, depends on patches from maxim */ 434 /* not yet supported, depends on patches from maxim */
@@ -476,7 +459,7 @@ static int __devinit streamzap_probe(struct usb_interface *intf,
476 459
477 return 0; 460 return 0;
478 461
479input_dev_fail: 462rc_dev_fail:
480 usb_free_urb(sz->urb_in); 463 usb_free_urb(sz->urb_in);
481free_buf_in: 464free_buf_in:
482 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); 465 usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in);
@@ -507,7 +490,7 @@ static void streamzap_disconnect(struct usb_interface *interface)
507 return; 490 return;
508 491
509 sz->usbdev = NULL; 492 sz->usbdev = NULL;
510 ir_input_unregister(sz->idev); 493 rc_unregister_device(sz->rdev);
511 usb_kill_urb(sz->urb_in); 494 usb_kill_urb(sz->urb_in);
512 usb_free_urb(sz->urb_in); 495 usb_free_urb(sz->urb_in);
513 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); 496 usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in);