Input: add appleir USB driver
Subsystems (3)
PATCH 1/1 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, with suspend support added.
More recent versions of the IR receiver are also supported through a patch by Alex Karpenko.
Tested on a MacbookAir1,1
--- Documentation/input/appleir.txt | 46 ++++ drivers/hid/hid-apple.c | 4 - drivers/hid/hid-core.c | 5 +- drivers/hid/hid-ids.h | 1 + drivers/input/misc/Kconfig | 13 + drivers/input/misc/Makefile | 1 + drivers/input/misc/appleir.c | 477 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 541 insertions(+), 6 deletions(-) create mode 100644 Documentation/input/appleir.txt create mode 100644 drivers/input/misc/appleir.c
Documentation/input/appleir.txt new file +46 -0
@@ -0,0 +1,46 @@ +Apple IR receiver Driver (appleir) +---------------------------------- + Copyright (C) 2009 Bastien Nocera <[email protected]> + +The appleir driver is a kernel input driver to handle Apple's IR +receivers (and associated remotes) in the kernel. + +The driver is an input driver which only handles "official" remotes +as built and sold by Apple. + +Authors +------- + +James McKenzie (original driver) +Alex Karpenko (05ac:8242 support) +Greg Kroah-Hartman (cleanups and original submission) +Bastien Nocera (further cleanups and suspend support) + +Supported hardware +------------------ + +- All Apple laptops and desktops from 2005 onwards, except: + - the unibody Macbook (2009) + - Mac Pro (all versions) +- Apple TV (all revisions) + +The remote will only support the 6 buttons of the original remotes +as sold by Apple. See the next section if you want to use other remotes +or want to use lirc with the device instead of the kernel driver. + +Using lirc (native) instead of the kernel driver +------------------------------------------------ + +First, you will need to disable the kernel driver for the receiver. + +This can be achieved by passing quirks to the usbhid driver. +The quirk line would be: +usbhid.quirks=0x05ac:0x8242:0x08 + +With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV" + +This should force the creation of a hiddev device for the receiver, and +make it usable under lirc. +
drivers/hid/hid-apple.c +0 -4
@@ -353,10 +353,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 +3 -2
@@ -1250,8 +1250,6 @@ EXPORT_SYMBOL_GPL(hid_disconnect);static const struct hid_device_id hid_blacklist[] = { {HID_USB_DEVICE (USB_VENDOR_ID_A4TECH ,USB_DEVICE_ID_A4TECH_WCP32PU ) }, {HID_USB_DEVICE (USB_VENDOR_ID_A4TECH ,USB_DEVICE_ID_A4TECH_X5_005D ) }, - {HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,USB_DEVICE_ID_APPLE_ATV_IRCONTROL ) }, - {HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,USB_DEVICE_ID_APPLE_IRCONTROL4 ) }, {HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,USB_DEVICE_ID_APPLE_MIGHTYMOUSE ) }, {HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI ) }, {HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,USB_DEVICE_ID_APPLE_FOUNTAIN_ISO ) },
@@ -1540,6 +1538,9 @@ 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_ATV_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
@@ -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 +13 -0
@@ -149,6 +149,19 @@ 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. This receiver is also + used in the Apple TV set-top box. + + 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
@@ -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 +477 -0
477 lines not on this page · raw message
Signature · 1 line
1.6.6
Documentation/input/appleir.txt line 42
Quoted 9 lines · Bastien Nocera
Documentation/input/appleir.txt new file +9
-0+First, you will need to disable the kernel driver for the receiver. + +This can be achieved by passing quirks to the usbhid driver. +The quirk line would be: +usbhid.quirks=0x05ac:0x8242:0x08 + +With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV"
I am afraid this is not true, 0x08 is HID_QUIRK_NOGET.
We currently don't have dynamic quirk for forcing HIDDEV creation from the module parameter.
drivers/input/misc/appleir.c line 184
Quoted 10 lines
drivers/input/misc/appleir.c new file +10
-0+if (!memcmp (data, keydown,sizeof (keydown))) { +/*If we already have a key down, take it up before marking */ +/*this one down */ +if (appleir->current_key) +key_up (appleir, appleir->current_key); + appleir->current_key = keymap[(data[4 ] >>1 ) &MAX_KEYS_MASK ]; + +key_down (appleir, appleir->current_key); +/*remote doesn't do key up, either pull them up, in the test */ +/*above, or here set a timer which pulls them up after 1/8 s */
Could you please place spaces after the comment starters?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Quoted 14 lines · Jiri Kosina
Documentation/input/appleir.txt line 42
Quoted 9 lines · Bastien Nocera
Documentation/input/appleir.txt new file +9
-0+First, you will need to disable the kernel driver for the receiver. + +This can be achieved by passing quirks to the usbhid driver. +The quirk line would be: +usbhid.quirks=0x05ac:0x8242:0x08 + +With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV"I am afraid this is not true,
0x08isHID_QUIRK_NOGET.
Quoted 2 lines
We currently don't have dynamic quirk for forcing HIDDEV creation from the module parameter.
Right. Any chance to change that?
Quoted 4 lines
Quoted 4 lines
drivers/input/misc/appleir.c new file +4
-0+if (!memcmp (data, keydown,sizeof (keydown))) { +/*If we already have a key down, take it up before marking */ +/*this one down */ +if (appleir->current_key)
Quoted 8 lines
drivers/input/misc/appleir.c line 184
Quoted 6 lines
drivers/input/misc/appleir.c new file +6
-0+key_up (appleir, appleir->current_key); + appleir->current_key = keymap[(data[4 ] >>1 ) &MAX_KEYS_MASK ]; + +key_down (appleir, appleir->current_key); +/*remote doesn't do key up, either pull them up, in the test */ +/*above, or here set a timer which pulls them up after 1/8 s */ Could you please place spaces after the comment starters?
I've done that on my local copy. I'm now trying to get in touch with Matthew Garrett so he can help me out with the suspend parts of the patch. I'll resubmit when that's done.
Cheers
Quoted 10 lines · Bastien Nocera
Quoted 8 lines
Documentation/input/appleir.txt line 42
Quoted 3 lines
Documentation/input/appleir.txt new file +3
-0+With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV"I am afraid this is not true,
0x08isHID_QUIRK_NOGET.We currently don't have dynamic quirk for forcing HIDDEV creation from the module parameter.
Right. Any chance to change that?
This particular one might actually make enough sense to be added (although I am really trying to avoid quirk additions completely), for backwards compatibility reasons.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/input/misc/appleir.c new file +4
-0+if (!memcmp (data, keydown,sizeof (keydown))) { +/*If we already have a key down, take it up before marking */ +/*this one down */ +if (appleir->current_key)Quoted 8 lines
drivers/input/misc/appleir.c line 184
Quoted 6 lines
drivers/input/misc/appleir.c new file +6
-0+key_up (appleir, appleir->current_key); + appleir->current_key = keymap[(data[4 ] >>1 ) &MAX_KEYS_MASK ]; + +key_down (appleir, appleir->current_key); +/*remote doesn't do key up, either pull them up, in the test */ +/*above, or here set a timer which pulls them up after 1/8 s */ Could you please place spaces after the comment starters?
Quoted 3 lines
I've done that on my local copy. I'm now trying to get in touch with Matthew Garrett so he can help me out with the suspend parts of the patch. I'll resubmit when that's done.
OK, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Quoted 8 lines · Jiri Kosina
Quoted 6 lines · Bastien Nocera
Quoted 6 lines
Documentation/input/appleir.txt line 42
Quoted 3 lines
Documentation/input/appleir.txt new file +3
-0+With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV"I am afraid this is not true,
0x08isHID_QUIRK_NOGET.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
We currently don't have dynamic quirk for forcing HIDDEV creation from the module parameter.
Right. Any chance to change that?
This particular one might actually make enough sense to be added (although I am really trying to avoid quirk additions completely), for backwards compatibility reasons.
Should I remove the comments there altogether then? That kind of defeats my "but you can use lirc with some tweaks" argument, even though I still think that those people needing more keys would be in the minority...
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/input/misc/appleir.c line 184
Quoted 10 lines
drivers/input/misc/appleir.c new file +10
-0+if (!memcmp (data, keydown,sizeof (keydown))) { +/*If we already have a key down, take it up before marking */ +/*this one down */ +if (appleir->current_key) +key_up (appleir, appleir->current_key); + appleir->current_key = keymap[(data[4 ] >>1 ) &MAX_KEYS_MASK ]; + +key_down (appleir, appleir->current_key); +/*remote doesn't do key up, either pull them up, in the test */ +/*above, or here set a timer which pulls them up after 1/8 s */ Could you please place spaces after the comment starters?
Quoted 5 lines
Quoted 3 lines
I've done that on my local copy. I'm now trying to get in touch with Matthew Garrett so he can help me out with the suspend parts of the patch. I'll resubmit when that's done.
OK, thanks.
Jarod gave me a hand, and the problem is the same as with the bcm5974 driver, the platform reset_resume will work just fine.
Updated patch coming up.
Cheers
Quoted 11 lines · Bastien Nocera
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Documentation/input/appleir.txt line 42
Quoted 3 lines
Documentation/input/appleir.txt new file +3
-0+With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV"I am afraid this is not true,
0x08isHID_QUIRK_NOGET.We currently don't have dynamic quirk for forcing HIDDEV creation from the module parameter.
Right. Any chance to change that?
Quoted 7 lines
Quoted 3 lines
This particular one might actually make enough sense to be added (although I am really trying to avoid quirk additions completely), for backwards compatibility reasons.
Should I remove the comments there altogether then? That kind of defeats my "but you can use lirc with some tweaks" argument, even though I still think that those people needing more keys would be in the minority...
I rather though that we could/should (re-)introduce the HID_QUIRK_HIDDEV quirks so that it could still be applied manually.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Quoted 17 lines · Jiri Kosina
Quoted 15 lines · Bastien Nocera
Quoted 14 lines
Quoted 10 lines
Quoted 8 lines
Documentation/input/appleir.txt line 42
Quoted 3 lines
Documentation/input/appleir.txt new file +3
-0+With 0x05ac being the vendor ID (Apple, you shouldn't need to change this) +With 0x8242 being the product ID (check the output of lsusb for your hardware) +And 0x08 being "HID_CONNECT_HIDDEV"I am afraid this is not true,
0x08isHID_QUIRK_NOGET.We currently don't have dynamic quirk for forcing HIDDEV creation from the module parameter.
Right. Any chance to change that?
This particular one might actually make enough sense to be added (although I am really trying to avoid quirk additions completely), for backwards compatibility reasons.
Quoted 6 lines
Quoted 3 lines
Should I remove the comments there altogether then? That kind of defeats my "but you can use lirc with some tweaks" argument, even though I still think that those people needing more keys would be in the minority...
I rather though that we could/should (re-)introduce the
HID_QUIRK_HIDDEVquirks so that it could still be applied manually.
The interaction between the HID and the input layer isn't really my forte (well, the kernel's not my forte :).
Wouldn't we have some trouble getting the HID layer provide a hiddev device for the receiver, whilst being serviced by an input driver?
I wouldn't mind trying to port the driver to be a full HID driver, and enable hiddev all the time on it. We just wouldn't do anything in the input part if the hiddev device was claimed, and parse the raw_report from the device otherwise.
Opinions? If it's a good idea, I'd be interested in some examples in devices that do their own raw_report event parsing, instead of letting the hid layer handle it.