First pass at integrating LIRC into the input subsystem
Subsystems (3)
PATCH 1/1 First pass at integrating LIRC into the input subsystem
My hardware consists of a GPIO input pin with a timer attached. The pin is set to generate an interrupt each time the input signal changes state. I take the timing data from each pulse and pass it into the core IR decode function. The decode function is running a state machine in parallel for each IR protocol. When a state machine detects a valid set of pulses it sends out three input messages as part of a transaction. The first is the detected protocol, second the address, third the command.
User space IR drivers can use the existing input event submission mechanism to get events into the input queue.
To transmit three input IOCTLs need to be implemented. Set frequency, enable transmitters, send data. Send data can take three parameters equivalent to the three from the event messages. A small library can be used to turn these three parameters into timing data for the specific protocols. I don't have transmit hardware in my system.
I've tested the driver and it works. The state machines will need some tuning. They don't handle repeats correctly and they may not be splitting address and command properly.
Jon Smirl
<[email protected]>
--- drivers/input/Kconfig | 2 drivers/input/Makefile | 3 drivers/input/input.c | 4 + drivers/input/ir-core.c | 294 +++++++++++++++++++++++++++++++++++++++++++++ drivers/input/ir/Kconfig | 20 +++ drivers/input/ir/Makefile | 6 + drivers/input/ir/ir-gpt.c | 214 +++++++++++++++++++++++++++++++++ 7 files changed, 542 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 create mode 100644 drivers/input/ir/ir-gpt.c
arch/powerpc/boot/dts/dspeak01.dts +8 -11
@@ -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 */ >; }; };
drivers/input/Kconfig +2 -0
@@ -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
@@ -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/input.c +4 -0
@@ -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 +294 -0
294 lines not on this page · raw message
drivers/input/ir/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# +# 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 + +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 new file +6 -0
@@ -0,0 +1,6 @@ +# Makefile for the ir drivers. +# + +# 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
include/linux/input.h +48 -0
77 lines not on this page · raw message