Skip to contentSkip to conversation

Implementation of IR support using the input subsystem

RFC PATCH In review Jon Smirl 2 participants 7 messages Sep 29, 2008

Subsystems (3)
lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

cover Implementation of IR support using the input subsystem

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 drivers/input/ir/ir-gpt.c
 create mode 100644 drivers/input/ir/ir-mceusb2.c
Signature · 2 lines
Jon Smirl
[email protected]
author
#1 lore raw

RFC PATCH 1/4 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.

Received IR messages generate event in the input queue. IR messages are sent using an input IOCTL.

Jon Smirl
<[email protected]>

---
 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
drivers/input/Kconfig +2 -0
index 747633c..780d321 100644
@@ -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"
drivers/input/Makefile +2 -1
index 6a1049b..da47340 100644
@@ -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
 
drivers/input/evdev.c +55 -0

85 lines not on this page · raw message

drivers/input/input.c +4 -0
index c13ced3..2159be8 100644
@@ -240,6 +240,10 @@ static void input_handle_event(struct input_dev *dev,
 	case EV_PWR:
 		disposition = INPUT_PASS_TO_ALL;
 		break;
+
+	case EV_IR:
+		disposition = INPUT_PASS_TO_ALL;
+		break;
 	}
 
 	if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN)
drivers/input/ir-core.c new file +523 -0

523 lines not on this page · raw message

drivers/input/ir/Kconfig new file +14 -0
new file mode 100644
index 0000000..8afd2d6
@@ -0,0 +1,14 @@
+#
+# LIRC driver(s) configuration
+#
+menuconfig INPUT_IR
+	bool "Infrared Remote (IR) receiver/transmitter drivers"
+	default n
+	help
+	  Say Y here, and all supported Infrared Remote Control IR
+	  receiver and transmitter drivers will be displayed. The receiver drivers
+	  allow control of your Linux system via remote control.
+
+if INPUT_IR
+
+endif
drivers/input/ir/Makefile new file +5 -0
new file mode 100644
index 0000000..08e6954
@@ -0,0 +1,5 @@
+# Makefile for the ir drivers.
+#
+
+# Each configuration option enables a list of files.
+
include/linux/input.h +70 -0

105 lines not on this page · raw message

author
#2 lore raw

RFC PATCH 2/4 Example of PowerPC device tree support for GPT based IR

In reply to Jon Smirl
---
 arch/powerpc/boot/dts/dspeak01.dts |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)
arch/powerpc/boot/dts/dspeak01.dts +8 -11
index 1d10f0a..cbb22a1 100644
@@ -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	   */
 				 >;
 		};
 	};
author
#3 lore raw

RFC PATCH 3/4 GPT driver for in-kernel IR support.

In reply to Jon Smirl

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
drivers/input/ir/Kconfig +6 -0
index 8afd2d6..b80ab31 100644
@@ -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
drivers/input/ir/Makefile +1 -0
index 08e6954..7082f1d 100644
@@ -3,3 +3,4 @@
 
 # Each configuration option enables a list of files.
 
+obj-$(CONFIG_IR_GPT)		+= ir-gpt.o
drivers/input/ir/ir-gpt.c new file +214 -0

214 lines not on this page · raw message

author
#4 lore raw

RFC PATCH 4/4 Microsoft mceusb2 driver for in-kernel IR subsystem

In reply to Jon Smirl

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
drivers/input/ir/Kconfig +6 -0
index b80ab31..29657d0 100644
@@ -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
drivers/input/ir/Makefile +1 -0
index 7082f1d..780de6c 100644
@@ -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
drivers/input/ir/ir-mceusb2.c new file +729 -0

729 lines not on this page · raw message

#5 lore raw
In reply to Jon Smirl
Quoted 11 lines · Jon Smirl

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.

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

author
#6 lore raw
Quoted 23 lines · Maxim Levitsky
Quoted 12 lines · Jon Smirl

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.

Quoted 8 lines

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.

Quoted 8 lines

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?

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 universal remote controls wouldn't work.

Quoted 11 lines

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

Signature · 2 lines
Jon Smirl
[email protected]