diff options
author | Sean Young <sean@mess.org> | 2017-09-23 10:41:13 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-14 10:35:16 -0500 |
commit | a60d64b15c20d178ba3a9bc3a542492b4ddeea70 (patch) | |
tree | 8b5e5086384e7868ce0357a2b5002a67ccfe0c63 | |
parent | 0d39ab0b628b38acf83506d36e9ec969055698df (diff) |
media: lirc: lirc interface should not be a raw decoder
The lirc user interface exists as a raw decoder, which does not make
much sense for transmit-only devices.
In addition, we want to have lirc char devices for devices which do not
use raw IR, i.e. scancode only devices.
Note that rc-code, lirc_dev, ir-lirc-codec are now calling functions of
each other, so they've been merged into one module rc-core to avoid
circular dependencies.
Since ir-lirc-codec no longer exists as separate codec module, there is no
need for RC_DRIVER_IR_RAW_TX type drivers to call ir_raw_event_register().
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/rc/Kconfig | 29 | ||||
-rw-r--r-- | drivers/media/rc/Makefile | 5 | ||||
-rw-r--r-- | drivers/media/rc/ir-lirc-codec.c | 135 | ||||
-rw-r--r-- | drivers/media/rc/ir-mce_kbd-decoder.c | 6 | ||||
-rw-r--r-- | drivers/media/rc/lirc_dev.c | 47 | ||||
-rw-r--r-- | drivers/media/rc/rc-core-priv.h | 45 | ||||
-rw-r--r-- | drivers/media/rc/rc-ir-raw.c | 24 | ||||
-rw-r--r-- | drivers/media/rc/rc-main.c | 52 | ||||
-rw-r--r-- | include/media/lirc_dev.h | 10 | ||||
-rw-r--r-- | include/media/rc-core.h | 33 |
10 files changed, 143 insertions, 243 deletions
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig index afb3456d4e20..0f863822889e 100644 --- a/drivers/media/rc/Kconfig +++ b/drivers/media/rc/Kconfig | |||
@@ -16,34 +16,21 @@ menuconfig RC_CORE | |||
16 | if RC_CORE | 16 | if RC_CORE |
17 | source "drivers/media/rc/keymaps/Kconfig" | 17 | source "drivers/media/rc/keymaps/Kconfig" |
18 | 18 | ||
19 | menuconfig RC_DECODERS | ||
20 | bool "Remote controller decoders" | ||
21 | depends on RC_CORE | ||
22 | default y | ||
23 | |||
24 | if RC_DECODERS | ||
25 | config LIRC | 19 | config LIRC |
26 | tristate "LIRC interface driver" | 20 | bool "LIRC user interface" |
27 | depends on RC_CORE | 21 | depends on RC_CORE |
28 | |||
29 | ---help--- | 22 | ---help--- |
30 | Enable this option to build the Linux Infrared Remote | 23 | Enable this option to enable the Linux Infrared Remote |
31 | Control (LIRC) core device interface driver. The LIRC | 24 | Control user interface (e.g. /dev/lirc*). This interface |
32 | interface passes raw IR to and from userspace, where the | 25 | passes raw IR to and from userspace, which is needed for |
33 | LIRC daemon handles protocol decoding for IR reception and | 26 | IR transmitting (aka "blasting") and for the lirc daemon. |
34 | encoding for IR transmitting (aka "blasting"). | ||
35 | 27 | ||
36 | config IR_LIRC_CODEC | 28 | menuconfig RC_DECODERS |
37 | tristate "Enable IR to LIRC bridge" | 29 | bool "Remote controller decoders" |
38 | depends on RC_CORE | 30 | depends on RC_CORE |
39 | depends on LIRC | ||
40 | default y | 31 | default y |
41 | 32 | ||
42 | ---help--- | 33 | if RC_DECODERS |
43 | Enable this option to pass raw IR to and from userspace via | ||
44 | the LIRC interface. | ||
45 | |||
46 | |||
47 | config IR_NEC_DECODER | 34 | config IR_NEC_DECODER |
48 | tristate "Enable IR raw decoder for the NEC protocol" | 35 | tristate "Enable IR raw decoder for the NEC protocol" |
49 | depends on RC_CORE | 36 | depends on RC_CORE |
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile index 10026477a677..081b34f97164 100644 --- a/drivers/media/rc/Makefile +++ b/drivers/media/rc/Makefile | |||
@@ -1,10 +1,10 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | rc-core-objs := rc-main.o rc-ir-raw.o | ||
3 | 2 | ||
4 | obj-y += keymaps/ | 3 | obj-y += keymaps/ |
5 | 4 | ||
6 | obj-$(CONFIG_RC_CORE) += rc-core.o | 5 | obj-$(CONFIG_RC_CORE) += rc-core.o |
7 | obj-$(CONFIG_LIRC) += lirc_dev.o | 6 | rc-core-y := rc-main.o rc-ir-raw.o |
7 | rc-core-$(CONFIG_LIRC) += lirc_dev.o ir-lirc-codec.o | ||
8 | obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o | 8 | obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o |
9 | obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o | 9 | obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o |
10 | obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o | 10 | obj-$(CONFIG_IR_RC6_DECODER) += ir-rc6-decoder.o |
@@ -13,7 +13,6 @@ obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o | |||
13 | obj-$(CONFIG_IR_SANYO_DECODER) += ir-sanyo-decoder.o | 13 | obj-$(CONFIG_IR_SANYO_DECODER) += ir-sanyo-decoder.o |
14 | obj-$(CONFIG_IR_SHARP_DECODER) += ir-sharp-decoder.o | 14 | obj-$(CONFIG_IR_SHARP_DECODER) += ir-sharp-decoder.o |
15 | obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o | 15 | obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o |
16 | obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o | ||
17 | obj-$(CONFIG_IR_XMP_DECODER) += ir-xmp-decoder.o | 16 | obj-$(CONFIG_IR_XMP_DECODER) += ir-xmp-decoder.o |
18 | 17 | ||
19 | # stand-alone IR receivers/transmitters | 18 | # stand-alone IR receivers/transmitters |
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index bdacbadac416..aec0109b1a69 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/wait.h> | 16 | #include <linux/wait.h> |
17 | #include <linux/module.h> | ||
18 | #include <media/lirc.h> | 17 | #include <media/lirc.h> |
19 | #include <media/lirc_dev.h> | 18 | #include <media/lirc_dev.h> |
20 | #include <media/rc-core.h> | 19 | #include <media/rc-core.h> |
@@ -23,21 +22,15 @@ | |||
23 | #define LIRCBUF_SIZE 256 | 22 | #define LIRCBUF_SIZE 256 |
24 | 23 | ||
25 | /** | 24 | /** |
26 | * ir_lirc_decode() - Send raw IR data to lirc_dev to be relayed to the | 25 | * ir_lirc_raw_event() - Send raw IR data to lirc to be relayed to userspace |
27 | * lircd userspace daemon for decoding. | 26 | * |
28 | * @dev: the struct rc_dev descriptor of the device | 27 | * @dev: the struct rc_dev descriptor of the device |
29 | * @ev: the struct ir_raw_event descriptor of the pulse/space | 28 | * @ev: the struct ir_raw_event descriptor of the pulse/space |
30 | * | ||
31 | * This function returns -EINVAL if the lirc interfaces aren't wired up. | ||
32 | */ | 29 | */ |
33 | static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) | 30 | void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev) |
34 | { | 31 | { |
35 | struct lirc_codec *lirc = &dev->raw->lirc; | ||
36 | int sample; | 32 | int sample; |
37 | 33 | ||
38 | if (!dev->raw->lirc.ldev || !dev->raw->lirc.ldev->buf) | ||
39 | return -EINVAL; | ||
40 | |||
41 | /* Packet start */ | 34 | /* Packet start */ |
42 | if (ev.reset) { | 35 | if (ev.reset) { |
43 | /* Userspace expects a long space event before the start of | 36 | /* Userspace expects a long space event before the start of |
@@ -56,15 +49,15 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) | |||
56 | /* Packet end */ | 49 | /* Packet end */ |
57 | } else if (ev.timeout) { | 50 | } else if (ev.timeout) { |
58 | 51 | ||
59 | if (lirc->gap) | 52 | if (dev->gap) |
60 | return 0; | 53 | return; |
61 | 54 | ||
62 | lirc->gap_start = ktime_get(); | 55 | dev->gap_start = ktime_get(); |
63 | lirc->gap = true; | 56 | dev->gap = true; |
64 | lirc->gap_duration = ev.duration; | 57 | dev->gap_duration = ev.duration; |
65 | 58 | ||
66 | if (!lirc->send_timeout_reports) | 59 | if (!dev->send_timeout_reports) |
67 | return 0; | 60 | return; |
68 | 61 | ||
69 | sample = LIRC_TIMEOUT(ev.duration / 1000); | 62 | sample = LIRC_TIMEOUT(ev.duration / 1000); |
70 | IR_dprintk(2, "timeout report (duration: %d)\n", sample); | 63 | IR_dprintk(2, "timeout report (duration: %d)\n", sample); |
@@ -72,21 +65,21 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) | |||
72 | /* Normal sample */ | 65 | /* Normal sample */ |
73 | } else { | 66 | } else { |
74 | 67 | ||
75 | if (lirc->gap) { | 68 | if (dev->gap) { |
76 | int gap_sample; | 69 | int gap_sample; |
77 | 70 | ||
78 | lirc->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), | 71 | dev->gap_duration += ktime_to_ns(ktime_sub(ktime_get(), |
79 | lirc->gap_start)); | 72 | dev->gap_start)); |
80 | 73 | ||
81 | /* Convert to ms and cap by LIRC_VALUE_MASK */ | 74 | /* Convert to ms and cap by LIRC_VALUE_MASK */ |
82 | do_div(lirc->gap_duration, 1000); | 75 | do_div(dev->gap_duration, 1000); |
83 | lirc->gap_duration = min(lirc->gap_duration, | 76 | dev->gap_duration = min_t(u64, dev->gap_duration, |
84 | (u64)LIRC_VALUE_MASK); | 77 | LIRC_VALUE_MASK); |
85 | 78 | ||
86 | gap_sample = LIRC_SPACE(lirc->gap_duration); | 79 | gap_sample = LIRC_SPACE(dev->gap_duration); |
87 | lirc_buffer_write(dev->raw->lirc.ldev->buf, | 80 | lirc_buffer_write(dev->lirc_dev->buf, |
88 | (unsigned char *)&gap_sample); | 81 | (unsigned char *)&gap_sample); |
89 | lirc->gap = false; | 82 | dev->gap = false; |
90 | } | 83 | } |
91 | 84 | ||
92 | sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) : | 85 | sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) : |
@@ -95,18 +88,16 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev) | |||
95 | TO_US(ev.duration), TO_STR(ev.pulse)); | 88 | TO_US(ev.duration), TO_STR(ev.pulse)); |
96 | } | 89 | } |
97 | 90 | ||
98 | lirc_buffer_write(dev->raw->lirc.ldev->buf, | 91 | lirc_buffer_write(dev->lirc_dev->buf, |
99 | (unsigned char *) &sample); | 92 | (unsigned char *) &sample); |
100 | wake_up(&dev->raw->lirc.ldev->buf->wait_poll); | ||
101 | 93 | ||
102 | return 0; | 94 | wake_up(&dev->lirc_dev->buf->wait_poll); |
103 | } | 95 | } |
104 | 96 | ||
105 | static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, | 97 | static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, |
106 | size_t n, loff_t *ppos) | 98 | size_t n, loff_t *ppos) |
107 | { | 99 | { |
108 | struct lirc_codec *lirc; | 100 | struct rc_dev *dev = file->private_data; |
109 | struct rc_dev *dev; | ||
110 | unsigned int *txbuf = NULL; | 101 | unsigned int *txbuf = NULL; |
111 | struct ir_raw_event *raw = NULL; | 102 | struct ir_raw_event *raw = NULL; |
112 | ssize_t ret = -EINVAL; | 103 | ssize_t ret = -EINVAL; |
@@ -118,22 +109,12 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, | |||
118 | 109 | ||
119 | start = ktime_get(); | 110 | start = ktime_get(); |
120 | 111 | ||
121 | lirc = lirc_get_pdata(file); | ||
122 | if (!lirc) | ||
123 | return -EFAULT; | ||
124 | |||
125 | dev = lirc->dev; | ||
126 | if (!dev) { | ||
127 | ret = -EFAULT; | ||
128 | goto out; | ||
129 | } | ||
130 | |||
131 | if (!dev->tx_ir) { | 112 | if (!dev->tx_ir) { |
132 | ret = -EINVAL; | 113 | ret = -EINVAL; |
133 | goto out; | 114 | goto out; |
134 | } | 115 | } |
135 | 116 | ||
136 | if (lirc->send_mode == LIRC_MODE_SCANCODE) { | 117 | if (dev->send_mode == LIRC_MODE_SCANCODE) { |
137 | struct lirc_scancode scan; | 118 | struct lirc_scancode scan; |
138 | 119 | ||
139 | if (n != sizeof(scan)) | 120 | if (n != sizeof(scan)) |
@@ -198,7 +179,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf, | |||
198 | if (ret < 0) | 179 | if (ret < 0) |
199 | goto out; | 180 | goto out; |
200 | 181 | ||
201 | if (lirc->send_mode == LIRC_MODE_SCANCODE) { | 182 | if (dev->send_mode == LIRC_MODE_SCANCODE) { |
202 | ret = n; | 183 | ret = n; |
203 | } else { | 184 | } else { |
204 | for (duration = i = 0; i < ret; i++) | 185 | for (duration = i = 0; i < ret; i++) |
@@ -228,20 +209,11 @@ out: | |||
228 | static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, | 209 | static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, |
229 | unsigned long arg) | 210 | unsigned long arg) |
230 | { | 211 | { |
231 | struct lirc_codec *lirc; | 212 | struct rc_dev *dev = filep->private_data; |
232 | struct rc_dev *dev; | ||
233 | u32 __user *argp = (u32 __user *)(arg); | 213 | u32 __user *argp = (u32 __user *)(arg); |
234 | int ret = 0; | 214 | int ret = 0; |
235 | __u32 val = 0, tmp; | 215 | __u32 val = 0, tmp; |
236 | 216 | ||
237 | lirc = lirc_get_pdata(filep); | ||
238 | if (!lirc) | ||
239 | return -EFAULT; | ||
240 | |||
241 | dev = lirc->dev; | ||
242 | if (!dev) | ||
243 | return -EFAULT; | ||
244 | |||
245 | if (_IOC_DIR(cmd) & _IOC_WRITE) { | 217 | if (_IOC_DIR(cmd) & _IOC_WRITE) { |
246 | ret = get_user(val, argp); | 218 | ret = get_user(val, argp); |
247 | if (ret) | 219 | if (ret) |
@@ -255,7 +227,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, | |||
255 | if (!dev->tx_ir) | 227 | if (!dev->tx_ir) |
256 | return -ENOTTY; | 228 | return -ENOTTY; |
257 | 229 | ||
258 | val = lirc->send_mode; | 230 | val = dev->send_mode; |
259 | break; | 231 | break; |
260 | 232 | ||
261 | case LIRC_SET_SEND_MODE: | 233 | case LIRC_SET_SEND_MODE: |
@@ -265,7 +237,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, | |||
265 | if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) | 237 | if (!(val == LIRC_MODE_PULSE || val == LIRC_MODE_SCANCODE)) |
266 | return -EINVAL; | 238 | return -EINVAL; |
267 | 239 | ||
268 | lirc->send_mode = val; | 240 | dev->send_mode = val; |
269 | return 0; | 241 | return 0; |
270 | 242 | ||
271 | /* TX settings */ | 243 | /* TX settings */ |
@@ -299,7 +271,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, | |||
299 | return -EINVAL; | 271 | return -EINVAL; |
300 | 272 | ||
301 | return dev->s_rx_carrier_range(dev, | 273 | return dev->s_rx_carrier_range(dev, |
302 | dev->raw->lirc.carrier_low, | 274 | dev->carrier_low, |
303 | val); | 275 | val); |
304 | 276 | ||
305 | case LIRC_SET_REC_CARRIER_RANGE: | 277 | case LIRC_SET_REC_CARRIER_RANGE: |
@@ -309,7 +281,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, | |||
309 | if (val <= 0) | 281 | if (val <= 0) |
310 | return -EINVAL; | 282 | return -EINVAL; |
311 | 283 | ||
312 | dev->raw->lirc.carrier_low = val; | 284 | dev->carrier_low = val; |
313 | return 0; | 285 | return 0; |
314 | 286 | ||
315 | case LIRC_GET_REC_RESOLUTION: | 287 | case LIRC_GET_REC_RESOLUTION: |
@@ -367,7 +339,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, | |||
367 | if (!dev->timeout) | 339 | if (!dev->timeout) |
368 | return -ENOTTY; | 340 | return -ENOTTY; |
369 | 341 | ||
370 | lirc->send_timeout_reports = !!val; | 342 | dev->send_timeout_reports = !!val; |
371 | break; | 343 | break; |
372 | 344 | ||
373 | default: | 345 | default: |
@@ -394,7 +366,7 @@ static const struct file_operations lirc_fops = { | |||
394 | .llseek = no_llseek, | 366 | .llseek = no_llseek, |
395 | }; | 367 | }; |
396 | 368 | ||
397 | static int ir_lirc_register(struct rc_dev *dev) | 369 | int ir_lirc_register(struct rc_dev *dev) |
398 | { | 370 | { |
399 | struct lirc_dev *ldev; | 371 | struct lirc_dev *ldev; |
400 | int rc = -ENOMEM; | 372 | int rc = -ENOMEM; |
@@ -436,7 +408,6 @@ static int ir_lirc_register(struct rc_dev *dev) | |||
436 | snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)", | 408 | snprintf(ldev->name, sizeof(ldev->name), "ir-lirc-codec (%s)", |
437 | dev->driver_name); | 409 | dev->driver_name); |
438 | ldev->features = features; | 410 | ldev->features = features; |
439 | ldev->data = &dev->raw->lirc; | ||
440 | ldev->buf = NULL; | 411 | ldev->buf = NULL; |
441 | ldev->chunk_size = sizeof(int); | 412 | ldev->chunk_size = sizeof(int); |
442 | ldev->buffer_size = LIRCBUF_SIZE; | 413 | ldev->buffer_size = LIRCBUF_SIZE; |
@@ -449,10 +420,8 @@ static int ir_lirc_register(struct rc_dev *dev) | |||
449 | if (rc < 0) | 420 | if (rc < 0) |
450 | goto out; | 421 | goto out; |
451 | 422 | ||
452 | dev->raw->lirc.send_mode = LIRC_MODE_PULSE; | 423 | dev->send_mode = LIRC_MODE_PULSE; |
453 | 424 | dev->lirc_dev = ldev; | |
454 | dev->raw->lirc.ldev = ldev; | ||
455 | dev->raw->lirc.dev = dev; | ||
456 | return 0; | 425 | return 0; |
457 | 426 | ||
458 | out: | 427 | out: |
@@ -460,40 +429,8 @@ out: | |||
460 | return rc; | 429 | return rc; |
461 | } | 430 | } |
462 | 431 | ||
463 | static int ir_lirc_unregister(struct rc_dev *dev) | 432 | void ir_lirc_unregister(struct rc_dev *dev) |
464 | { | ||
465 | struct lirc_codec *lirc = &dev->raw->lirc; | ||
466 | |||
467 | lirc_unregister_device(lirc->ldev); | ||
468 | lirc->ldev = NULL; | ||
469 | |||
470 | return 0; | ||
471 | } | ||
472 | |||
473 | static struct ir_raw_handler lirc_handler = { | ||
474 | .protocols = 0, | ||
475 | .decode = ir_lirc_decode, | ||
476 | .raw_register = ir_lirc_register, | ||
477 | .raw_unregister = ir_lirc_unregister, | ||
478 | }; | ||
479 | |||
480 | static int __init ir_lirc_codec_init(void) | ||
481 | { | 433 | { |
482 | ir_raw_handler_register(&lirc_handler); | 434 | lirc_unregister_device(dev->lirc_dev); |
483 | 435 | dev->lirc_dev = NULL; | |
484 | printk(KERN_INFO "IR LIRC bridge handler initialized\n"); | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | static void __exit ir_lirc_codec_exit(void) | ||
489 | { | ||
490 | ir_raw_handler_unregister(&lirc_handler); | ||
491 | } | 436 | } |
492 | |||
493 | module_init(ir_lirc_codec_init); | ||
494 | module_exit(ir_lirc_codec_exit); | ||
495 | |||
496 | MODULE_LICENSE("GPL"); | ||
497 | MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); | ||
498 | MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); | ||
499 | MODULE_DESCRIPTION("LIRC IR handler bridge"); | ||
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index dbc6e00bace2..2c9ee0c1f432 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c | |||
@@ -358,9 +358,6 @@ static int ir_mce_kbd_register(struct rc_dev *dev) | |||
358 | struct input_dev *idev; | 358 | struct input_dev *idev; |
359 | int i, ret; | 359 | int i, ret; |
360 | 360 | ||
361 | if (dev->driver_type == RC_DRIVER_IR_RAW_TX) | ||
362 | return 0; | ||
363 | |||
364 | idev = input_allocate_device(); | 361 | idev = input_allocate_device(); |
365 | if (!idev) | 362 | if (!idev) |
366 | return -ENOMEM; | 363 | return -ENOMEM; |
@@ -415,9 +412,6 @@ static int ir_mce_kbd_unregister(struct rc_dev *dev) | |||
415 | struct mce_kbd_dec *mce_kbd = &dev->raw->mce_kbd; | 412 | struct mce_kbd_dec *mce_kbd = &dev->raw->mce_kbd; |
416 | struct input_dev *idev = mce_kbd->idev; | 413 | struct input_dev *idev = mce_kbd->idev; |
417 | 414 | ||
418 | if (dev->driver_type == RC_DRIVER_IR_RAW_TX) | ||
419 | return 0; | ||
420 | |||
421 | del_timer_sync(&mce_kbd->rx_timeout); | 415 | del_timer_sync(&mce_kbd->rx_timeout); |
422 | input_unregister_device(idev); | 416 | input_unregister_device(idev); |
423 | 417 | ||
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index ef7e915dc9a2..3cc95deaa84e 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/cdev.h> | 26 | #include <linux/cdev.h> |
27 | #include <linux/idr.h> | 27 | #include <linux/idr.h> |
28 | 28 | ||
29 | #include <media/rc-core.h> | 29 | #include "rc-core-priv.h" |
30 | #include <media/lirc.h> | 30 | #include <media/lirc.h> |
31 | #include <media/lirc_dev.h> | 31 | #include <media/lirc_dev.h> |
32 | 32 | ||
@@ -236,7 +236,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file) | |||
236 | 236 | ||
237 | d->open++; | 237 | d->open++; |
238 | 238 | ||
239 | lirc_init_pdata(inode, file); | 239 | file->private_data = d->rdev; |
240 | nonseekable_open(inode, file); | 240 | nonseekable_open(inode, file); |
241 | mutex_unlock(&d->mutex); | 241 | mutex_unlock(&d->mutex); |
242 | 242 | ||
@@ -250,11 +250,12 @@ EXPORT_SYMBOL(lirc_dev_fop_open); | |||
250 | 250 | ||
251 | int lirc_dev_fop_close(struct inode *inode, struct file *file) | 251 | int lirc_dev_fop_close(struct inode *inode, struct file *file) |
252 | { | 252 | { |
253 | struct lirc_dev *d = file->private_data; | 253 | struct rc_dev *rcdev = file->private_data; |
254 | struct lirc_dev *d = rcdev->lirc_dev; | ||
254 | 255 | ||
255 | mutex_lock(&d->mutex); | 256 | mutex_lock(&d->mutex); |
256 | 257 | ||
257 | rc_close(d->rdev); | 258 | rc_close(rcdev); |
258 | d->open--; | 259 | d->open--; |
259 | 260 | ||
260 | mutex_unlock(&d->mutex); | 261 | mutex_unlock(&d->mutex); |
@@ -265,7 +266,8 @@ EXPORT_SYMBOL(lirc_dev_fop_close); | |||
265 | 266 | ||
266 | unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait) | 267 | unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait) |
267 | { | 268 | { |
268 | struct lirc_dev *d = file->private_data; | 269 | struct rc_dev *rcdev = file->private_data; |
270 | struct lirc_dev *d = rcdev->lirc_dev; | ||
269 | unsigned int ret; | 271 | unsigned int ret; |
270 | 272 | ||
271 | if (!d->attached) | 273 | if (!d->attached) |
@@ -290,7 +292,8 @@ EXPORT_SYMBOL(lirc_dev_fop_poll); | |||
290 | 292 | ||
291 | long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 293 | long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
292 | { | 294 | { |
293 | struct lirc_dev *d = file->private_data; | 295 | struct rc_dev *rcdev = file->private_data; |
296 | struct lirc_dev *d = rcdev->lirc_dev; | ||
294 | __u32 mode; | 297 | __u32 mode; |
295 | int result; | 298 | int result; |
296 | 299 | ||
@@ -349,7 +352,8 @@ ssize_t lirc_dev_fop_read(struct file *file, | |||
349 | size_t length, | 352 | size_t length, |
350 | loff_t *ppos) | 353 | loff_t *ppos) |
351 | { | 354 | { |
352 | struct lirc_dev *d = file->private_data; | 355 | struct rc_dev *rcdev = file->private_data; |
356 | struct lirc_dev *d = rcdev->lirc_dev; | ||
353 | unsigned char *buf; | 357 | unsigned char *buf; |
354 | int ret, written = 0; | 358 | int ret, written = 0; |
355 | DECLARE_WAITQUEUE(wait, current); | 359 | DECLARE_WAITQUEUE(wait, current); |
@@ -448,24 +452,7 @@ out_unlocked: | |||
448 | } | 452 | } |
449 | EXPORT_SYMBOL(lirc_dev_fop_read); | 453 | EXPORT_SYMBOL(lirc_dev_fop_read); |
450 | 454 | ||
451 | void lirc_init_pdata(struct inode *inode, struct file *file) | 455 | int __init lirc_dev_init(void) |
452 | { | ||
453 | struct lirc_dev *d = container_of(inode->i_cdev, struct lirc_dev, cdev); | ||
454 | |||
455 | file->private_data = d; | ||
456 | } | ||
457 | EXPORT_SYMBOL(lirc_init_pdata); | ||
458 | |||
459 | void *lirc_get_pdata(struct file *file) | ||
460 | { | ||
461 | struct lirc_dev *d = file->private_data; | ||
462 | |||
463 | return d->data; | ||
464 | } | ||
465 | EXPORT_SYMBOL(lirc_get_pdata); | ||
466 | |||
467 | |||
468 | static int __init lirc_dev_init(void) | ||
469 | { | 456 | { |
470 | int retval; | 457 | int retval; |
471 | 458 | ||
@@ -489,16 +476,8 @@ static int __init lirc_dev_init(void) | |||
489 | return 0; | 476 | return 0; |
490 | } | 477 | } |
491 | 478 | ||
492 | static void __exit lirc_dev_exit(void) | 479 | void __exit lirc_dev_exit(void) |
493 | { | 480 | { |
494 | class_destroy(lirc_class); | 481 | class_destroy(lirc_class); |
495 | unregister_chrdev_region(lirc_base_dev, LIRC_MAX_DEVICES); | 482 | unregister_chrdev_region(lirc_base_dev, LIRC_MAX_DEVICES); |
496 | pr_info("module unloaded\n"); | ||
497 | } | 483 | } |
498 | |||
499 | module_init(lirc_dev_init); | ||
500 | module_exit(lirc_dev_exit); | ||
501 | |||
502 | MODULE_DESCRIPTION("LIRC base driver module"); | ||
503 | MODULE_AUTHOR("Artur Lipowski"); | ||
504 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 6014f116cba2..face39c3a96c 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h | |||
@@ -12,6 +12,20 @@ | |||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <media/rc-core.h> | 13 | #include <media/rc-core.h> |
14 | 14 | ||
15 | /** | ||
16 | * rc_open - Opens a RC device | ||
17 | * | ||
18 | * @rdev: pointer to struct rc_dev. | ||
19 | */ | ||
20 | int rc_open(struct rc_dev *rdev); | ||
21 | |||
22 | /** | ||
23 | * rc_close - Closes a RC device | ||
24 | * | ||
25 | * @rdev: pointer to struct rc_dev. | ||
26 | */ | ||
27 | void rc_close(struct rc_dev *rdev); | ||
28 | |||
15 | struct ir_raw_handler { | 29 | struct ir_raw_handler { |
16 | struct list_head list; | 30 | struct list_head list; |
17 | 31 | ||
@@ -21,7 +35,7 @@ struct ir_raw_handler { | |||
21 | struct ir_raw_event *events, unsigned int max); | 35 | struct ir_raw_event *events, unsigned int max); |
22 | u32 carrier; | 36 | u32 carrier; |
23 | 37 | ||
24 | /* These two should only be used by the lirc decoder */ | 38 | /* These two should only be used by the mce kbd decoder */ |
25 | int (*raw_register)(struct rc_dev *dev); | 39 | int (*raw_register)(struct rc_dev *dev); |
26 | int (*raw_unregister)(struct rc_dev *dev); | 40 | int (*raw_unregister)(struct rc_dev *dev); |
27 | }; | 41 | }; |
@@ -95,17 +109,6 @@ struct ir_raw_event_ctrl { | |||
95 | unsigned count; | 109 | unsigned count; |
96 | unsigned wanted_bits; | 110 | unsigned wanted_bits; |
97 | } mce_kbd; | 111 | } mce_kbd; |
98 | struct lirc_codec { | ||
99 | struct rc_dev *dev; | ||
100 | struct lirc_dev *ldev; | ||
101 | int carrier_low; | ||
102 | |||
103 | ktime_t gap_start; | ||
104 | u64 gap_duration; | ||
105 | bool gap; | ||
106 | bool send_timeout_reports; | ||
107 | u8 send_mode; | ||
108 | } lirc; | ||
109 | struct xmp_dec { | 112 | struct xmp_dec { |
110 | int state; | 113 | int state; |
111 | unsigned count; | 114 | unsigned count; |
@@ -265,6 +268,24 @@ void ir_raw_load_modules(u64 *protocols); | |||
265 | void ir_raw_init(void); | 268 | void ir_raw_init(void); |
266 | 269 | ||
267 | /* | 270 | /* |
271 | * lirc interface | ||
272 | */ | ||
273 | #ifdef CONFIG_LIRC | ||
274 | int lirc_dev_init(void); | ||
275 | void lirc_dev_exit(void); | ||
276 | void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev); | ||
277 | int ir_lirc_register(struct rc_dev *dev); | ||
278 | void ir_lirc_unregister(struct rc_dev *dev); | ||
279 | #else | ||
280 | static inline int lirc_dev_init(void) { return 0; } | ||
281 | static inline void lirc_dev_exit(void) {} | ||
282 | static inline void ir_lirc_raw_event(struct rc_dev *dev, | ||
283 | struct ir_raw_event ev) { } | ||
284 | static inline int ir_lirc_register(struct rc_dev *dev) { return 0; } | ||
285 | static inline void ir_lirc_unregister(struct rc_dev *dev) { } | ||
286 | #endif | ||
287 | |||
288 | /* | ||
268 | * Decoder initialization code | 289 | * Decoder initialization code |
269 | * | 290 | * |
270 | * Those load logic are called during ir-core init, and automatically | 291 | * Those load logic are called during ir-core init, and automatically |
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 78638d1b73cc..3dabb783a1f0 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c | |||
@@ -31,6 +31,7 @@ static int ir_raw_event_thread(void *data) | |||
31 | if (raw->dev->enabled_protocols & | 31 | if (raw->dev->enabled_protocols & |
32 | handler->protocols || !handler->protocols) | 32 | handler->protocols || !handler->protocols) |
33 | handler->decode(raw->dev, ev); | 33 | handler->decode(raw->dev, ev); |
34 | ir_lirc_raw_event(raw->dev, ev); | ||
34 | raw->prev_ev = ev; | 35 | raw->prev_ev = ev; |
35 | } | 36 | } |
36 | mutex_unlock(&ir_raw_handler_lock); | 37 | mutex_unlock(&ir_raw_handler_lock); |
@@ -521,16 +522,9 @@ EXPORT_SYMBOL(ir_raw_encode_carrier); | |||
521 | */ | 522 | */ |
522 | int ir_raw_event_prepare(struct rc_dev *dev) | 523 | int ir_raw_event_prepare(struct rc_dev *dev) |
523 | { | 524 | { |
524 | static bool raw_init; /* 'false' default value, raw decoders loaded? */ | ||
525 | |||
526 | if (!dev) | 525 | if (!dev) |
527 | return -EINVAL; | 526 | return -EINVAL; |
528 | 527 | ||
529 | if (!raw_init) { | ||
530 | request_module("ir-lirc-codec"); | ||
531 | raw_init = true; | ||
532 | } | ||
533 | |||
534 | dev->raw = kzalloc(sizeof(*dev->raw), GFP_KERNEL); | 528 | dev->raw = kzalloc(sizeof(*dev->raw), GFP_KERNEL); |
535 | if (!dev->raw) | 529 | if (!dev->raw) |
536 | return -ENOMEM; | 530 | return -ENOMEM; |
@@ -548,19 +542,11 @@ int ir_raw_event_register(struct rc_dev *dev) | |||
548 | struct ir_raw_handler *handler; | 542 | struct ir_raw_handler *handler; |
549 | struct task_struct *thread; | 543 | struct task_struct *thread; |
550 | 544 | ||
551 | /* | 545 | thread = kthread_run(ir_raw_event_thread, dev->raw, "rc%u", dev->minor); |
552 | * raw transmitters do not need any event registration | 546 | if (IS_ERR(thread)) |
553 | * because the event is coming from userspace | 547 | return PTR_ERR(thread); |
554 | */ | ||
555 | if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { | ||
556 | thread = kthread_run(ir_raw_event_thread, dev->raw, "rc%u", | ||
557 | dev->minor); | ||
558 | 548 | ||
559 | if (IS_ERR(thread)) | 549 | dev->raw->thread = thread; |
560 | return PTR_ERR(thread); | ||
561 | |||
562 | dev->raw->thread = thread; | ||
563 | } | ||
564 | 550 | ||
565 | mutex_lock(&ir_raw_handler_lock); | 551 | mutex_lock(&ir_raw_handler_lock); |
566 | list_add_tail(&dev->raw->list, &ir_raw_client_list); | 552 | list_add_tail(&dev->raw->list, &ir_raw_client_list); |
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 29a90adb0f7c..56b322b3d325 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -846,7 +846,6 @@ int rc_open(struct rc_dev *rdev) | |||
846 | 846 | ||
847 | return rval; | 847 | return rval; |
848 | } | 848 | } |
849 | EXPORT_SYMBOL_GPL(rc_open); | ||
850 | 849 | ||
851 | static int ir_open(struct input_dev *idev) | 850 | static int ir_open(struct input_dev *idev) |
852 | { | 851 | { |
@@ -866,7 +865,6 @@ void rc_close(struct rc_dev *rdev) | |||
866 | mutex_unlock(&rdev->lock); | 865 | mutex_unlock(&rdev->lock); |
867 | } | 866 | } |
868 | } | 867 | } |
869 | EXPORT_SYMBOL_GPL(rc_close); | ||
870 | 868 | ||
871 | static void ir_close(struct input_dev *idev) | 869 | static void ir_close(struct input_dev *idev) |
872 | { | 870 | { |
@@ -941,23 +939,6 @@ struct rc_filter_attribute { | |||
941 | .mask = (_mask), \ | 939 | .mask = (_mask), \ |
942 | } | 940 | } |
943 | 941 | ||
944 | static bool lirc_is_present(void) | ||
945 | { | ||
946 | #if defined(CONFIG_LIRC_MODULE) | ||
947 | struct module *lirc; | ||
948 | |||
949 | mutex_lock(&module_mutex); | ||
950 | lirc = find_module("lirc_dev"); | ||
951 | mutex_unlock(&module_mutex); | ||
952 | |||
953 | return lirc ? true : false; | ||
954 | #elif defined(CONFIG_LIRC) | ||
955 | return true; | ||
956 | #else | ||
957 | return false; | ||
958 | #endif | ||
959 | } | ||
960 | |||
961 | /** | 942 | /** |
962 | * show_protocols() - shows the current IR protocol(s) | 943 | * show_protocols() - shows the current IR protocol(s) |
963 | * @device: the device descriptor | 944 | * @device: the device descriptor |
@@ -1002,8 +983,10 @@ static ssize_t show_protocols(struct device *device, | |||
1002 | allowed &= ~proto_names[i].type; | 983 | allowed &= ~proto_names[i].type; |
1003 | } | 984 | } |
1004 | 985 | ||
1005 | if (dev->driver_type == RC_DRIVER_IR_RAW && lirc_is_present()) | 986 | #ifdef CONFIG_LIRC |
987 | if (dev->driver_type == RC_DRIVER_IR_RAW) | ||
1006 | tmp += sprintf(tmp, "[lirc] "); | 988 | tmp += sprintf(tmp, "[lirc] "); |
989 | #endif | ||
1007 | 990 | ||
1008 | if (tmp != buf) | 991 | if (tmp != buf) |
1009 | tmp--; | 992 | tmp--; |
@@ -1759,8 +1742,7 @@ int rc_register_device(struct rc_dev *dev) | |||
1759 | dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp; | 1742 | dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp; |
1760 | dev->sysfs_groups[attr++] = NULL; | 1743 | dev->sysfs_groups[attr++] = NULL; |
1761 | 1744 | ||
1762 | if (dev->driver_type == RC_DRIVER_IR_RAW || | 1745 | if (dev->driver_type == RC_DRIVER_IR_RAW) { |
1763 | dev->driver_type == RC_DRIVER_IR_RAW_TX) { | ||
1764 | rc = ir_raw_event_prepare(dev); | 1746 | rc = ir_raw_event_prepare(dev); |
1765 | if (rc < 0) | 1747 | if (rc < 0) |
1766 | goto out_minor; | 1748 | goto out_minor; |
@@ -1787,19 +1769,28 @@ int rc_register_device(struct rc_dev *dev) | |||
1787 | goto out_dev; | 1769 | goto out_dev; |
1788 | } | 1770 | } |
1789 | 1771 | ||
1790 | if (dev->driver_type == RC_DRIVER_IR_RAW || | 1772 | /* Ensure that the lirc kfifo is setup before we start the thread */ |
1791 | dev->driver_type == RC_DRIVER_IR_RAW_TX) { | 1773 | if (dev->driver_type != RC_DRIVER_SCANCODE) { |
1792 | rc = ir_raw_event_register(dev); | 1774 | rc = ir_lirc_register(dev); |
1793 | if (rc < 0) | 1775 | if (rc < 0) |
1794 | goto out_rx; | 1776 | goto out_rx; |
1795 | } | 1777 | } |
1796 | 1778 | ||
1779 | if (dev->driver_type == RC_DRIVER_IR_RAW) { | ||
1780 | rc = ir_raw_event_register(dev); | ||
1781 | if (rc < 0) | ||
1782 | goto out_lirc; | ||
1783 | } | ||
1784 | |||
1797 | IR_dprintk(1, "Registered rc%u (driver: %s)\n", | 1785 | IR_dprintk(1, "Registered rc%u (driver: %s)\n", |
1798 | dev->minor, | 1786 | dev->minor, |
1799 | dev->driver_name ? dev->driver_name : "unknown"); | 1787 | dev->driver_name ? dev->driver_name : "unknown"); |
1800 | 1788 | ||
1801 | return 0; | 1789 | return 0; |
1802 | 1790 | ||
1791 | out_lirc: | ||
1792 | if (dev->driver_type != RC_DRIVER_SCANCODE) | ||
1793 | ir_lirc_unregister(dev); | ||
1803 | out_rx: | 1794 | out_rx: |
1804 | rc_free_rx_device(dev); | 1795 | rc_free_rx_device(dev); |
1805 | out_dev: | 1796 | out_dev: |
@@ -1853,6 +1844,9 @@ void rc_unregister_device(struct rc_dev *dev) | |||
1853 | 1844 | ||
1854 | rc_free_rx_device(dev); | 1845 | rc_free_rx_device(dev); |
1855 | 1846 | ||
1847 | if (dev->driver_type != RC_DRIVER_SCANCODE) | ||
1848 | ir_lirc_unregister(dev); | ||
1849 | |||
1856 | device_del(&dev->dev); | 1850 | device_del(&dev->dev); |
1857 | 1851 | ||
1858 | ida_simple_remove(&rc_ida, dev->minor); | 1852 | ida_simple_remove(&rc_ida, dev->minor); |
@@ -1875,6 +1869,13 @@ static int __init rc_core_init(void) | |||
1875 | return rc; | 1869 | return rc; |
1876 | } | 1870 | } |
1877 | 1871 | ||
1872 | rc = lirc_dev_init(); | ||
1873 | if (rc) { | ||
1874 | pr_err("rc_core: unable to init lirc\n"); | ||
1875 | class_unregister(&rc_class); | ||
1876 | return 0; | ||
1877 | } | ||
1878 | |||
1878 | led_trigger_register_simple("rc-feedback", &led_feedback); | 1879 | led_trigger_register_simple("rc-feedback", &led_feedback); |
1879 | rc_map_register(&empty_map); | 1880 | rc_map_register(&empty_map); |
1880 | 1881 | ||
@@ -1883,6 +1884,7 @@ static int __init rc_core_init(void) | |||
1883 | 1884 | ||
1884 | static void __exit rc_core_exit(void) | 1885 | static void __exit rc_core_exit(void) |
1885 | { | 1886 | { |
1887 | lirc_dev_exit(); | ||
1886 | class_unregister(&rc_class); | 1888 | class_unregister(&rc_class); |
1887 | led_trigger_unregister_simple(led_feedback); | 1889 | led_trigger_unregister_simple(led_feedback); |
1888 | rc_map_unregister(&empty_map); | 1890 | rc_map_unregister(&empty_map); |
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 0a03dd9e5a68..dd0c078796e8 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h | |||
@@ -121,7 +121,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, | |||
121 | * Only used if @rbuf is NULL. | 121 | * Only used if @rbuf is NULL. |
122 | * @chunk_size: Size of each FIFO buffer. | 122 | * @chunk_size: Size of each FIFO buffer. |
123 | * Only used if @rbuf is NULL. | 123 | * Only used if @rbuf is NULL. |
124 | * @data: private per-driver data | ||
125 | * @buf: if %NULL, lirc_dev will allocate and manage the buffer, | 124 | * @buf: if %NULL, lirc_dev will allocate and manage the buffer, |
126 | * otherwise allocated by the caller which will | 125 | * otherwise allocated by the caller which will |
127 | * have to write to the buffer by other means, like irq's | 126 | * have to write to the buffer by other means, like irq's |
@@ -146,7 +145,6 @@ struct lirc_dev { | |||
146 | struct lirc_buffer *buf; | 145 | struct lirc_buffer *buf; |
147 | bool buf_internal; | 146 | bool buf_internal; |
148 | 147 | ||
149 | void *data; | ||
150 | struct rc_dev *rdev; | 148 | struct rc_dev *rdev; |
151 | const struct file_operations *fops; | 149 | const struct file_operations *fops; |
152 | struct module *owner; | 150 | struct module *owner; |
@@ -168,14 +166,6 @@ int lirc_register_device(struct lirc_dev *d); | |||
168 | 166 | ||
169 | void lirc_unregister_device(struct lirc_dev *d); | 167 | void lirc_unregister_device(struct lirc_dev *d); |
170 | 168 | ||
171 | /* Must be called in the open fop before lirc_get_pdata() can be used */ | ||
172 | void lirc_init_pdata(struct inode *inode, struct file *file); | ||
173 | |||
174 | /* Returns the private data stored in the lirc_dev | ||
175 | * associated with the given device file pointer. | ||
176 | */ | ||
177 | void *lirc_get_pdata(struct file *file); | ||
178 | |||
179 | /* default file operations | 169 | /* default file operations |
180 | * used by drivers if they override only some operations | 170 | * used by drivers if they override only some operations |
181 | */ | 171 | */ |
diff --git a/include/media/rc-core.h b/include/media/rc-core.h index ca48632ec8e2..5d6e415c7acc 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/kfifo.h> | 20 | #include <linux/kfifo.h> |
21 | #include <linux/time.h> | 21 | #include <linux/time.h> |
22 | #include <linux/timer.h> | 22 | #include <linux/timer.h> |
23 | #include <media/lirc_dev.h> | ||
23 | #include <media/rc-map.h> | 24 | #include <media/rc-map.h> |
24 | 25 | ||
25 | extern int rc_core_debug; | 26 | extern int rc_core_debug; |
@@ -115,6 +116,15 @@ enum rc_filter_type { | |||
115 | * @max_timeout: maximum timeout supported by device | 116 | * @max_timeout: maximum timeout supported by device |
116 | * @rx_resolution : resolution (in ns) of input sampler | 117 | * @rx_resolution : resolution (in ns) of input sampler |
117 | * @tx_resolution: resolution (in ns) of output sampler | 118 | * @tx_resolution: resolution (in ns) of output sampler |
119 | * @lirc_dev: lirc char device | ||
120 | * @carrier_low: when setting the carrier range, first the low end must be | ||
121 | * set with an ioctl and then the high end with another ioctl | ||
122 | * @gap_start: time when gap starts | ||
123 | * @gap_duration: duration of initial gap | ||
124 | * @gap: true if we're in a gap | ||
125 | * @send_timeout_reports: report timeouts in lirc raw IR. | ||
126 | * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or | ||
127 | * LIRC_MODE_PULSE | ||
118 | * @change_protocol: allow changing the protocol used on hardware decoders | 128 | * @change_protocol: allow changing the protocol used on hardware decoders |
119 | * @open: callback to allow drivers to enable polling/irq when IR input device | 129 | * @open: callback to allow drivers to enable polling/irq when IR input device |
120 | * is opened. | 130 | * is opened. |
@@ -174,6 +184,15 @@ struct rc_dev { | |||
174 | u32 max_timeout; | 184 | u32 max_timeout; |
175 | u32 rx_resolution; | 185 | u32 rx_resolution; |
176 | u32 tx_resolution; | 186 | u32 tx_resolution; |
187 | #ifdef CONFIG_LIRC | ||
188 | struct lirc_dev *lirc_dev; | ||
189 | int carrier_low; | ||
190 | ktime_t gap_start; | ||
191 | u64 gap_duration; | ||
192 | bool gap; | ||
193 | bool send_timeout_reports; | ||
194 | u8 send_mode; | ||
195 | #endif | ||
177 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); | 196 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); |
178 | int (*open)(struct rc_dev *dev); | 197 | int (*open)(struct rc_dev *dev); |
179 | void (*close)(struct rc_dev *dev); | 198 | void (*close)(struct rc_dev *dev); |
@@ -248,20 +267,6 @@ int devm_rc_register_device(struct device *parent, struct rc_dev *dev); | |||
248 | */ | 267 | */ |
249 | void rc_unregister_device(struct rc_dev *dev); | 268 | void rc_unregister_device(struct rc_dev *dev); |
250 | 269 | ||
251 | /** | ||
252 | * rc_open - Opens a RC device | ||
253 | * | ||
254 | * @rdev: pointer to struct rc_dev. | ||
255 | */ | ||
256 | int rc_open(struct rc_dev *rdev); | ||
257 | |||
258 | /** | ||
259 | * rc_close - Closes a RC device | ||
260 | * | ||
261 | * @rdev: pointer to struct rc_dev. | ||
262 | */ | ||
263 | void rc_close(struct rc_dev *rdev); | ||
264 | |||
265 | void rc_repeat(struct rc_dev *dev); | 270 | void rc_repeat(struct rc_dev *dev); |
266 | void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode, | 271 | void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode, |
267 | u8 toggle); | 272 | u8 toggle); |