Second pass at implementing evdev support for IR. The goal of in-kernel IR is to integrate IR events into the evdev input event queue and maintain ordering of events from all input devices.
Note that user space IR device drivers can use the existing support in evdev to inject events into the input queue.
Send and receive are implemented. Received IR messages are decoded and sent to user space as input messages. Send is done via an IOCTL on the input device.
Two drivers are supplied. mceusb2 implements send and receive support for the Microsoft USB IR dongle.
The GPT driver implements receive only support for a GPT pin - GPT is a GPIO with a timer attached.
Encoders and decoders have not been written for all protocols. Repeat is not handled for any protocol.
I'm looking for help. There are 15 more existing LIRC drivers.
---
Jon Smirl (4):
Microsoft mceusb2 driver for in-kernel IR subsystem
GPT driver for in-kernel IR support.
Example of PowerPC device tree support for GPT based IR
Changes to core input subsystem to allow send and receive of IR messages. Encode and decode state machines are provided for common IR porotocols such as Sony, JVC, NEC, Philips, etc.
arch/powerpc/boot/dts/dspeak01.dts | 19 -
drivers/input/Kconfig | 2
drivers/input/Makefile | 3
drivers/input/evdev.c | 55 +++
drivers/input/input.c | 4
drivers/input/ir-core.c | 523 ++++++++++++++++++++++++++
drivers/input/ir/Kconfig | 26 +
drivers/input/ir/Makefile | 7
drivers/input/ir/ir-gpt.c | 214 +++++++++++
drivers/input/ir/ir-mceusb2.c | 729 ++++++++++++++++++++++++++++++++++++
include/linux/input.h | 70 +++
11 files changed, 1640 insertions(+), 12 deletions(-)
create mode 100644 drivers/input/ir-core.c
create mode 100644 drivers/input/ir/Kconfig
create mode 100644 drivers/input/ir/Makefile
create mode 100644 ...Received IR messages generate event in the input queue.
IR messages are sent using an input IOCTL.
Jon Smirl
<jonsmirl@gmail.com>
---
drivers/input/Kconfig | 2
drivers/input/Makefile | 3
drivers/input/evdev.c | 55 +++++
drivers/input/input.c | 4
drivers/input/ir-core.c | 523 +++++++++++++++++++++++++++++++++++++++++++++
drivers/input/ir/Kconfig | 14 +
drivers/input/ir/Makefile | 5
include/linux/input.h | 70 ++++++
8 files changed, 675 insertions(+), 1 deletions(-)
create mode 100644 drivers/input/ir-core.c
create mode 100644 drivers/input/ir/Kconfig
create mode 100644 drivers/input/ir/Makefile
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 747633c..780d321 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -172,6 +172,8 @@ source "drivers/input/touchscreen/Kconfig"
source "drivers/input/misc/Kconfig"
+source "drivers/input/ir/Kconfig"
+
endif
menu "Hardware I/O ports"
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 6a1049b..da47340 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -5,7 +5,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_INPUT) += input-core.o
-input-core-objs := input.o ff-core.o
+input-core-objs := input.o ff-core.o ir-core.o
obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
@@ -21,6 +21,7 @@ obj-$(CONFIG_INPUT_JOYSTICK) += joystick/
obj-$(CONFIG_INPUT_TABLET) += tablet/
obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/
obj-$(CONFIG_INPUT_MISC) += misc/
+obj-$(CONFIG_INPUT_IR) += ir/
obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3524bef..7a3f935 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -329,6 +329,14 @@ struct ff_effect_compat {
} u;
};
+struct ir_command_compat {
+ __u32 protocol;
+ __u32 device;
+ __u32 ...---
arch/powerpc/boot/dts/dspeak01.dts | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/arch/powerpc/boot/dts/dspeak01.dts b/arch/powerpc/boot/dts/dspeak01.dts
index 1d10f0a..cbb22a1 100644
--- a/arch/powerpc/boot/dts/dspeak01.dts
+++ b/arch/powerpc/boot/dts/dspeak01.dts
@@ -131,16 +131,6 @@
#gpio-cells = <2>;
};
- gpt7: timer@670 { /* General Purpose Timer in GPIO mode */
- compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
- cell-index = <7>;
- reg = <0x670 0x10>;
- interrupts = <0x1 0x10 0x0>;
- interrupt-parent = <&mpc5200_pic>;
- gpio-controller;
- #gpio-cells = <2>;
- };
-
rtc@800 { // Real time clock
compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
device_type = "rtc";
@@ -328,6 +318,14 @@
reg = <0x8000 0x4000>;
};
+ ir0: timer@670 { /* General Purpose Timer 6 in Input mode */
+ compatible = "gpt-ir";
+ cell-index = <7>;
+ reg = <0x670 0x10>;
+ interrupts = <0x1 0x10 0x0>;
+ interrupt-parent = <&mpc5200_pic>;
+ };
+
/* This is only an example device to show the usage of gpios. It maps all available
* gpios to the "gpio-provider" device.
*/
@@ -345,7 +343,6 @@
&gpt4 0 0 /* timer4 61c x2-16 */
&gpt5 0 0 /* timer5 44c x7-11 */
&gpt6 0 0 /* timer6 60c x8-15 */
- &gpt7 0 0 /* timer7 36a x17-9 */
>;
};
};
--
GPT is a GPIO pin that is cable able of measuring the lenght of pulses.
GPTs are common on embedded systems
---
drivers/input/ir/Kconfig | 6 +
drivers/input/ir/Makefile | 1
drivers/input/ir/ir-gpt.c | 214 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 221 insertions(+), 0 deletions(-)
create mode 100644 drivers/input/ir/ir-gpt.c
diff --git a/drivers/input/ir/Kconfig b/drivers/input/ir/Kconfig
index 8afd2d6..b80ab31 100644
--- a/drivers/input/ir/Kconfig
+++ b/drivers/input/ir/Kconfig
@@ -11,4 +11,10 @@ menuconfig INPUT_IR
if INPUT_IR
+config IR_GPT
+ tristate "GPT Based IR Receiver"
+ default m
+ help
+ Driver for GPT-based IR receiver found on Digispeaker
+
endif
diff --git a/drivers/input/ir/Makefile b/drivers/input/ir/Makefile
index 08e6954..7082f1d 100644
--- a/drivers/input/ir/Makefile
+++ b/drivers/input/ir/Makefile
@@ -3,3 +3,4 @@
# Each configuration option enables a list of files.
+obj-$(CONFIG_IR_GPT) += ir-gpt.o
diff --git a/drivers/input/ir/ir-gpt.c b/drivers/input/ir/ir-gpt.c
new file mode 100644
index 0000000..445ff27
--- /dev/null
+++ b/drivers/input/ir/ir-gpt.c
@@ -0,0 +1,214 @@
+/*
+ * GPT timer based IR device
+ *
+ * Copyright (C) 2008 Jon Smirl <jonsmirl@gmail.com>
+ */
+
+#define DEBUG
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#include <linux/input.h>
+#include <asm/io.h>
+#include <asm/mpc52xx.h>
+
+#define MAX_SAMPLES 200
+
+struct ir_gpt {
+ int irq;
+ struct mpc52xx_gpt __iomem *regs;
+ spinlock_t lock;
+ struct work_struct queue;
+ int head, tail, previous;
+ unsigned int samples[MAX_SAMPLES];
+ struct input_dev *input;
+};
+
+static void ir_event(struct work_struct *work)
+{
+ unsigned long flags;
+ int delta, count;
+ unsigned int sample, wrap, bit;
+ struct ir_gpt *ir_gpt = container_of(work, struct ir_gpt, queue);
+
+ while (1) ...USB device commonly found on Microsoft Media Center boxes. Hardware can send and recieve at all common IR frequencies - 36K, 38K, 40K, 56K --- drivers/input/ir/Kconfig | 6 drivers/input/ir/Makefile | 1 drivers/input/ir/ir-mceusb2.c | 729 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 736 insertions(+), 0 deletions(-) create mode 100644 drivers/input/ir/ir-mceusb2.c diff --git a/drivers/input/ir/Kconfig b/drivers/input/ir/Kconfig index b80ab31..29657d0 100644 --- a/drivers/input/ir/Kconfig +++ b/drivers/input/ir/Kconfig @@ -16,5 +16,11 @@ config IR_GPT default m help Driver for GPT-based IR receiver found on Digispeaker + +config IR_MCEUSB2 + tristate "Microsoft Media Center Ed. Receiver, v2" + default m + help + Driver for the Microsoft Media Center Ed. Receiver, v2 endif diff --git a/drivers/input/ir/Makefile b/drivers/input/ir/Makefile index 7082f1d..780de6c 100644 --- a/drivers/input/ir/Makefile +++ b/drivers/input/ir/Makefile @@ -4,3 +4,4 @@ # Each configuration option enables a list of files. obj-$(CONFIG_IR_GPT) += ir-gpt.o +obj-$(CONFIG_IR_MCEUSB2) += ir-mceusb2.o diff --git a/drivers/input/ir/ir-mceusb2.c b/drivers/input/ir/ir-mceusb2.c new file mode 100644 index 0000000..14f5a53 --- /dev/null +++ b/drivers/input/ir/ir-mceusb2.c @@ -0,0 +1,729 @@ +/* + * LIRC driver for Philips eHome USB Infrared Transceiver + * and the Microsoft MCE 2005 Remote Control + * + * (C) by Martin A. Blatter <martin_a_blatter@yahoo.com> + * + * Transmitter support and reception code cleanup. + * (C) by Daniel Melander <lirc@rajidae.se> + * + * Derived from ATI USB driver by Paul Miller and the original + * MCE USB driver by Dan Corti + * + * This driver will only work reliably with kernel version 2.6.10 + * or higher, probably because of differences in USB device enumeration + * in the kernel code. Device initialization fails most of the time + * with earlier kernel versions. + * + ...
Hi, One thing worries me, there are bazillion of different IR protocols, but in-kernel decode support will mean that only handful of known protocols will work. Suppose I take an old remote which has some unknown protocol. I want to be able to teach the system to listen to it. But how this can be done if protocols are hard coded? I think that it would be much better to pass raw ir codes to userspace, and make it deal with bazillion protocols, and you can always make it auto learn too, and save results in configuration file. My .02 cents. Best regards, Maxim Levitsky --
There's not a bazillion different protocols. For example thirty different vendors may use the NEC encoding. They will each use a unique device number and their own commands. While each of the thirty vendors may assign different device/command codes they are all still using the NEC encoding. These remotes won't trigger the other devices because the device fields won't match. This code only converts raw IR timing of NEC/etc encoding into device/command. User space has to then figure out how to interpret device/command. Christoph has pointed out that their are some more obscure encodings from RCMM, Grundig, Bang&Olufsen, Goldstar, Serial, Denon, RECS80, and Motorola that are different than the common ones at http://www.sbprojects.com. It takes about 1KB of code to add an encoding. We could make an "extra encoding" module for these obscure ones. You can't have an infinite variety of encodings or table based -- Jon Smirl jonsmirl@gmail.com --
