Skip to contentSkip to conversation

Apple IR receiver driver

PATCH In review Bastien Nocera 3 participants 9 messages Jan 18, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Apple IR receiver driver

Heya,

This is an update of the patches sent by Greg [1].

I believe I fixed one of the problems mentioned by Tino (the suspend support, though my testing was blighted by the fact that resuming *without* the driver doesn't work so well with the latest input tree, it works fine with the stock Fedora kernels).

The other problem mentioned by Tino was the fact that some people would want to use LIRC to use different remotes and have access to more keys. This can be achieved by using usbhid.quirks. I could certainly document that for both lirc and in the kernel.

A couple of things:
- Not certain about the suspend code
- Should the Apple TV receiver be handled in the same way? (the LIRC driver works on all 3 revisions of the IR receiver)
- Where should I document the work-around to use lirc in both LIRC and the kernel?

The main features of using a kernel driver are:
- Out-of-the-box support, just like in MacOS X, with the "recommended" remote controller. This is similar to how the ATI remotes are handled.
- On my hacking TODO list are the ability to report flat batteries through kobject_uevent to user space, and binding support (so as to filter out all the remotes apart from the "paired" one)

Let me know of any problems

Cheers

[1]: http://thread.gmane.org/gmane.linux.kernel/680590/

Quoted 1 line

From eadd1424ef1657b4666a4e3e3f0862024dec591a Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Sun, 17 Jan 2010 00:40:15 +0000
Subject: [PATCH 1/2] [PATCH] Input: add appleir USB driver

From: Bastien Nocera <[email protected]>

This driver was originally written by James McKenzie, updated by Greg Kroah-Hartman, further updated by myself.

More recent versions of the IR receiver are also supported through a patch by Alex Karpenko.

Tested on a MacbookAir1,1

---
 drivers/hid/hid-apple.c      |    2 -
 drivers/hid/hid-core.c       |    2 +
 drivers/hid/hid-ids.h        |    1 +
 drivers/input/misc/Kconfig   |   12 ++
 drivers/input/misc/Makefile  |    1 +
 drivers/input/misc/appleir.c |  378 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 394 insertions(+), 2 deletions(-)
 create mode 100644 drivers/input/misc/appleir.c
drivers/hid/hid-apple.c +0 -2
index 4b96e7a..12fe9c6 100644
@@ -355,8 +355,6 @@ static void apple_remove(struct hid_device *hdev)
 static const struct hid_device_id apple_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL),
 		.driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4),
-		.driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
 		.driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
 
drivers/hid/hid-core.c +2 -0
index 80792d3..3773f69 100644
@@ -1540,6 +1540,8 @@ static const struct hid_device_id hid_ignore_list[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
drivers/hid/hid-ids.h +1 -0
index 3839340..8b29a88 100644
@@ -90,6 +90,7 @@
 #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS	0x0238
 #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY	0x030a
 #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY	0x030b
+#define USB_DEVICE_ID_APPLE_IRCONTROL	0x8240
 #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL	0x8241
 #define USB_DEVICE_ID_APPLE_IRCONTROL4	0x8242
 
drivers/input/misc/Kconfig +12 -0
index 16ec523..b46e3f1 100644
@@ -149,6 +149,18 @@ config INPUT_KEYSPAN_REMOTE
 	  To compile this driver as a module, choose M here: the module will
 	  be called keyspan_remote.
 
+config INPUT_APPLEIR
+	tristate "Apple infrared receiver (built in)"
+	depends on USB_ARCH_HAS_HCD
+	select USB
+	help
+	  Say Y here if you want to use a Apple infrared remote control. All
+	  the Apple computers from 2005 onwards include such a port, except
+	  the unibody Macbook (2009), and Mac Pros.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called appleir.
+
 config INPUT_POWERMATE
 	tristate "Griffin PowerMate and Contour Jog support"
 	depends on USB_ARCH_HAS_HCD
drivers/input/misc/Makefile +1 -0
index a8b8485..041e6f5 100644
@@ -5,6 +5,7 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
+obj-$(CONFIG_INPUT_APPLEIR)		+= appleir.o
 obj-$(CONFIG_INPUT_ATI_REMOTE)		+= ati_remote.o
 obj-$(CONFIG_INPUT_ATI_REMOTE2)		+= ati_remote2.o
 obj-$(CONFIG_INPUT_ATLAS_BTNS)		+= atlas_btns.o
drivers/input/misc/appleir.c new file +378 -0

378 lines not on this page · raw message

Signature · 1 line
1.6.5.2
Quoted 1 line

From 39309f376a988b7a5c37e9ef82e9cd6c87af2e97 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Mon, 18 Jan 2010 13:57:03 +0000
Subject: [PATCH 2/2] [appleir] Add suspend support

Close the connection to the device and kill the timer when suspending, and undo those changes on resume.

---
 drivers/input/misc/appleir.c |  120 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 112 insertions(+), 8 deletions(-)
drivers/input/misc/appleir.c +112 -8

160 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#1 lore raw

On Mon, Jan 18, 2010 at 14:14:25 +0000, Bastien Nocera wrote:

[...]

drivers/hid/hid-core.c static const struct hid_device_id hid_ignore_list[] = { · line 1547

Quoted 11 lines
drivers/hid/hid-core.c +2 -0
@@ -1540,6 +1540,8 @@ static const struct hid_device_id hid_ignore_list[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },

My impression is that this would break existing lirc setups that use the macmini lirc userspace driver which relies on a HID device, right?

Regards,
Tino

#2 lore raw
Quoted 4 lines · Tino Keitel

On Mon, Jan 18, 2010 at 14:14:25 +0000, Bastien Nocera wrote:

[...]

Quoted 14 lines

drivers/hid/hid-core.c static const struct hid_device_id hid_ignore_list[] = { · line 1547

Quoted 11 lines
drivers/hid/hid-core.c +2 -0
@@ -1540,6 +1540,8 @@ static const struct hid_device_id hid_ignore_list[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },

My impression is that this would break existing lirc setups that use the macmini lirc userspace driver which relies on a HID device, right?

Yes, which I mentioned could be worked around using usbhid.quirks on boot (if you need the extra key definitions), or using lirc's uinput driver (if you're using the stock hardware).

#3 lore raw
Quoted 2 lines · Bastien Nocera

Yes, which I mentioned could be worked around using usbhid.quirks on boot (if you need the extra key definitions), or using lirc's uinput

What exactly do you mean with "using usbhid.quirks on boot"?

Regards,
Tino

#4 lore raw
Quoted 5 lines · Tino Keitel
Quoted 2 lines · Bastien Nocera

Yes, which I mentioned could be worked around using usbhid.quirks on boot (if you need the extra key definitions), or using lirc's uinput

What exactly do you mean with "using usbhid.quirks on boot"?

Pass something along those lines:
usbhid.quirks=0xVID:0xPID:0xQUIRK
on the kernel command-line, and the appleir won't pick up the device, and the current quirks would be restored.

Given that I seriously doubt there's very many people interested in using "non-standard" remotes with those receivers, it would make most users' life easier (and I doubt that the people that have the hardware bothered setting up lirc on their systems...).

Cheers

#5 lore raw
Quoted 4 lines · Bastien Nocera

Pass something along those lines:
usbhid.quirks=0xVID:0xPID:0xQUIRK
on the kernel command-line, and the appleir won't pick up the device, and the current quirks would be restored.

So I guess this would be usbhid.quirks=0x05ac:0x8240:0xsomething.

The remaining question is what "something" should be.

Quoted 4 lines

Given that I seriously doubt there's very many people interested in using "non-standard" remotes with those receivers, it would make most users' life easier (and I doubt that the people that have the hardware bothered setting up lirc on their systems...).

IMHO "non-standard" remotes are interesting especially with this remote, because the vendor supplied remote has only six keys.

Is there really no way to make the quirk only effective if the appleir driver is active?

Regards,
Tino

#6 lore raw
Quoted 9 lines · Tino Keitel
Quoted 4 lines · Bastien Nocera

Pass something along those lines:
usbhid.quirks=0xVID:0xPID:0xQUIRK
on the kernel command-line, and the appleir won't pick up the device, and the current quirks would be restored.

So I guess this would be usbhid.quirks=0x05ac:0x8240:0xsomething.

The remaining question is what "something" should be.

The mask for HIDDEV and HIDINPUT_IGNORE (which I don't know on top of my head, and will only lookup if Dmitry thinks documentation is required).

Quoted 7 lines
Quoted 4 lines

Given that I seriously doubt there's very many people interested in using "non-standard" remotes with those receivers, it would make most users' life easier (and I doubt that the people that have the hardware bothered setting up lirc on their systems...).

IMHO "non-standard" remotes are interesting especially with this remote, because the vendor supplied remote has only six keys.

Yes, and I don't know of anyone using the non-standard remotes with this receiver, and they could still do it with a bit of tweaking (which would be necessary to setup the other keys anyway).

Quoted 2 lines

Is there really no way to make the quirk only effective if the appleir driver is active?

Not easily, no, though the quirks should soon be changeable at run-time, so you could potentially not even have to reboot.

Cheers

#7 lore raw
Quoted 7 lines · Bastien Nocera
Quoted 6 lines · Tino Keitel
Quoted 4 lines · Bastien Nocera

Pass something along those lines:
usbhid.quirks=0xVID:0xPID:0xQUIRK
on the kernel command-line, and the appleir won't pick up the device, and the current quirks would be restored.

Quoted 6 lines
Quoted 3 lines

So I guess this would be usbhid.quirks=0x05ac:0x8240:0xsomething.

The remaining question is what "something" should be.

The mask for HIDDEV and HIDINPUT_IGNORE (which I don't know on top of my head, and will only lookup if Dmitry thinks documentation is required).

HID_QUIRK_IGNORE, iirc, is 0x4.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

Given that I seriously doubt there's very many people interested in using "non-standard" remotes with those receivers, it would make most users' life easier (and I doubt that the people that have the hardware bothered setting up lirc on their systems...).

IMHO "non-standard" remotes are interesting especially with this remote, because the vendor supplied remote has only six keys.

Yes, and I don't know of anyone using the non-standard remotes with this receiver, and they could still do it with a bit of tweaking (which would be necessary to setup the other keys anyway).

The most common non-standard remote I've heard of people using is a Logitech Harmony remote, which they program 6 buttons at a time, then cycle to the next code set, program 6 more, rinse, repeat, etc.

Signature · 2 lines
Jarod Wilson
[email protected]
#8 lore raw

On Mon, Jan 18, 2010 at 11:39:54 -0500, Jarod Wilson wrote:

[...]

Quoted 3 lines

The most common non-standard remote I've heard of people using is a Logitech Harmony remote, which they program 6 buttons at a time, then cycle to the next code set, program 6 more, rinse, repeat, etc.

That's how I did it, with some random learning remote made by Sony. It should work with most learning remotes.

Regards,
Tino