[kernel/f14/master] - Update AppleIR patch to work, and support the enter key on newer remotes

Bastien Nocera hadess at fedoraproject.org
Fri Sep 10 15:12:14 UTC 2010


commit ea6d873cc2d9e8111960a7d8ec4c905a8584494d
Author: Bastien Nocera <hadess at hadess.net>
Date:   Fri Sep 10 16:11:56 2010 +0100

    - Update AppleIR patch to work, and support the enter key on
      newer remotes

 add-appleir-usb-driver.patch |  223 +++++++++++++++++++++++++++++-------------
 kernel.spec                  |    6 +-
 2 files changed, 162 insertions(+), 67 deletions(-)
---
diff --git a/add-appleir-usb-driver.patch b/add-appleir-usb-driver.patch
index 821d200..210f289 100644
--- a/add-appleir-usb-driver.patch
+++ b/add-appleir-usb-driver.patch
@@ -1,47 +1,38 @@
-commit 92c912df2a0725d719263357176f98b2201a2acd
-Author: Bastien Nocera <hadess at hadess.net>
-Date:   Wed Apr 21 14:51:58 2010 +0100
+From e11e9e78799a7641fe0dc5289f35f2604a4b71a3 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess at hadess.net>
+Date: Sun, 17 Jan 2010 00:40:15 +0000
+Subject: [PATCH] Input: add appleir USB driver
 
-    Input: add appleir USB driver
-    
-    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
-    
-    Signed-off-by: Bastien Nocera <hadess at hadess.net>
+This driver was originally written by James McKenzie, updated by
+Greg Kroah-Hartman, further updated by myself, with suspend support
+added.
 
-commit 6ffcbf68913840e9e882db14441576ffee6eba0c
-Author: Bastien Nocera <hadess at hadess.net>
-Date:   Fri Apr 16 17:19:50 2010 +0100
+More recent versions of the IR receiver are also supported through
+a patch by Alex Karpenko. The patch also adds support for the 2nd
+and 5th generation of the controller, and the menu key on newer
+brushed metal remotes.
 
-    Add HID_QUIRK_HIDDEV_FORCE and HID_QUIRK_NO_IGNORE
-    
-    Add two quirks to make it possible for usbhid module options to
-    override whether a device is ignored (HID_QUIRK_NO_IGNORE) and
-    whether to connect a hiddev device (HID_QUIRK_HIDDEV_FORCE).
-    
-    Passing HID_QUIRK_NO_IGNORE for your device means that it will
-    not be ignored by the HID layer, even if present in a blacklist.
-    
-    HID_QUIRK_HIDDEV_FORCE will force the creation of a hiddev for that
-    device, making it accessible from user-space.
-    
-    Tested with an Apple IR Receiver, switching it from using appleir
-    to using lirc's macmini driver.
-    
-    Signed-off-by: Bastien Nocera <hadess at hadess.net>
+Tested on a MacbookAir1,1
+
+Signed-off-by: Bastien Nocera <hadess at hadess.net>
+---
+ Documentation/input/appleir.txt |   46 ++++
+ drivers/hid/hid-apple.c         |    4 -
+ drivers/hid/hid-core.c          |    7 +-
+ drivers/hid/hid-ids.h           |    5 +-
+ drivers/input/misc/Kconfig      |   13 +
+ drivers/input/misc/Makefile     |    1 +
+ drivers/input/misc/appleir.c    |  519 +++++++++++++++++++++++++++++++++++++++
+ 7 files changed, 588 insertions(+), 7 deletions(-)
+ create mode 100644 Documentation/input/appleir.txt
+ create mode 100644 drivers/input/misc/appleir.c
 
 diff --git a/Documentation/input/appleir.txt b/Documentation/input/appleir.txt
 new file mode 100644
-index 0000000..0267a4b
+index 0000000..db637fb
 --- /dev/null
 +++ b/Documentation/input/appleir.txt
-@@ -0,0 +1,45 @@
+@@ -0,0 +1,46 @@
 +Apple IR receiver Driver (appleir)
 +----------------------------------
 +	Copyright (C) 2009 Bastien Nocera <hadess at hadess.net>
@@ -58,7 +49,8 @@ index 0000000..0267a4b
 +James McKenzie (original driver)
 +Alex Karpenko (05ac:8242 support)
 +Greg Kroah-Hartman (cleanups and original submission)
-+Bastien Nocera (further cleanups and suspend support)
++Bastien Nocera (further cleanups, brushed metal "enter"
++button support and suspend support)
 +
 +Supported hardware
 +------------------
@@ -66,11 +58,11 @@ index 0000000..0267a4b
 +- All Apple laptops and desktops from 2005 onwards, except:
 +  - the unibody Macbook (2009)
 +  - Mac Pro (all versions)
-+- Apple TV (all revisions)
++- Apple TV (all revisions prior to September 2010)
 +
-+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.
++The remote will only support the 6 (old white) or 7 (brushed metal) buttons
++of the 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
 +------------------------------------------------
@@ -88,10 +80,10 @@ index 0000000..0267a4b
 +This should force the creation of a hiddev device for the receiver, and
 +make it usable under lirc.
 diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
-index 5b4d66d..b0e1811 100644
+index bba05d0..0059d5a 100644
 --- a/drivers/hid/hid-apple.c
 +++ b/drivers/hid/hid-apple.c
-@@ -353,10 +353,6 @@ static void apple_remove(struct hid_device *hdev)
+@@ -361,10 +361,6 @@ static void apple_remove(struct hid_device *hdev)
  }
  
  static const struct hid_device_id apple_devices[] = {
@@ -102,23 +94,53 @@ index 5b4d66d..b0e1811 100644
  	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
  		.driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
  
+diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
+index baa25ad..abc5bd7 100644
+--- a/drivers/hid/hid-core.c
++++ b/drivers/hid/hid-core.c
+@@ -1244,8 +1244,6 @@ static const struct hid_device_id hid_blacklist[] = {
+ #if defined(CONFIG_HID_ACRUX_FF) || defined(CONFIG_HID_ACRUX_FF_MODULE)
+ 	{ HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) },
+ #endif
+-	{ 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_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
+ 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
+@@ -1577,6 +1575,11 @@ 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_IRCONTROL2) },
++	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL3) },
++	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
++	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL5) },
+ 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT)},
+ 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
+ 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
 diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
-index 793691f..9255c1a 100644
+index 11af537..360a5ca 100644
 --- a/drivers/hid/hid-ids.h
 +++ b/drivers/hid/hid-ids.h
-@@ -93,6 +93,7 @@
+@@ -100,8 +100,11 @@
  #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS   0x023b
  #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY	0x030a
  #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY	0x030b
+-#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL	0x8241
 +#define USB_DEVICE_ID_APPLE_IRCONTROL	0x8240
- #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL	0x8241
++#define USB_DEVICE_ID_APPLE_IRCONTROL2	0x1440
++#define USB_DEVICE_ID_APPLE_IRCONTROL3	0x8241
  #define USB_DEVICE_ID_APPLE_IRCONTROL4	0x8242
++#define USB_DEVICE_ID_APPLE_IRCONTROL5	0x8243
  
+ #define USB_VENDOR_ID_ASUS		0x0486
+ #define USB_DEVICE_ID_ASUS_T91MT	0x0185
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
-index 16ec523..4340986 100644
+index 60de906..2f2f2e7 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
-@@ -149,6 +149,19 @@ config INPUT_KEYSPAN_REMOTE
+@@ -209,6 +209,19 @@ config INPUT_KEYSPAN_REMOTE
  	  To compile this driver as a module, choose M here: the module will
  	  be called keyspan_remote.
  
@@ -130,7 +152,7 @@ index 16ec523..4340986 100644
 +	  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.
++	  used in the Apple TV set-top box prior to the 2010 model.
 +
 +	  To compile this driver as a module, choose M here: the module will
 +	  be called appleir.
@@ -139,12 +161,12 @@ index 16ec523..4340986 100644
  	tristate "Griffin PowerMate and Contour Jog support"
  	depends on USB_ARCH_HAS_HCD
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
-index a8b8485..041e6f5 100644
+index 1fe1f6c..d5ef2b9 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
-@@ -5,6 +5,7 @@
- obj-$(CONFIG_INPUT_AD714X_I2C)		+= ad714x-i2c.o
- obj-$(CONFIG_INPUT_AD714X_SPI)		+= ad714x-spi.o
+@@ -13,6 +13,7 @@ obj-$(CONFIG_INPUT_ADXL34X)		+= adxl34x.o
+ obj-$(CONFIG_INPUT_ADXL34X_I2C)		+= adxl34x-i2c.o
+ obj-$(CONFIG_INPUT_ADXL34X_SPI)		+= adxl34x-spi.o
  obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
 +obj-$(CONFIG_INPUT_APPLEIR)		+= appleir.o
  obj-$(CONFIG_INPUT_ATI_REMOTE)		+= ati_remote.o
@@ -152,10 +174,10 @@ index a8b8485..041e6f5 100644
  obj-$(CONFIG_INPUT_ATLAS_BTNS)		+= atlas_btns.o
 diff --git a/drivers/input/misc/appleir.c b/drivers/input/misc/appleir.c
 new file mode 100644
-index 0000000..cff4df6
+index 0000000..3817a3c
 --- /dev/null
 +++ b/drivers/input/misc/appleir.c
-@@ -0,0 +1,453 @@
+@@ -0,0 +1,519 @@
 +/*
 + * appleir: USB driver for the apple ir device
 + *
@@ -194,12 +216,14 @@ index 0000000..cff4df6
 +
 +#define USB_VENDOR_ID_APPLE			0x05ac
 +#define USB_DEVICE_ID_APPLE_IRCONTROL		0x8240
-+#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL	0x8241
++#define USB_DEVICE_ID_APPLE_IRCONTROL2		0x1440
++#define USB_DEVICE_ID_APPLE_IRCONTROL3		0x8241
 +#define USB_DEVICE_ID_APPLE_IRCONTROL4		0x8242
++#define USB_DEVICE_ID_APPLE_IRCONTROL5		0x8243
 +
 +#define URB_SIZE	32
 +
-+#define MAX_KEYS	8
++#define MAX_KEYS	9
 +#define MAX_KEYS_MASK	(MAX_KEYS - 1)
 +
 +#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
@@ -239,6 +263,13 @@ index 0000000..cff4df6
 +/* 25 87 ee 47 02 	menu */
 +/* 26 87 ee 47 ** 	for key repeat (** is the code of the key being held) */
 +
++/* Bastien Nocera's "new" remote */
++/* 25 87 ee 91 5f	followed by
++ * 25 87 ee 91 05	gives you >"
++ *
++ * 25 87 ee 91 5c	followed by
++ * 25 87 ee 91 05	gives you the middle button */
++
 +static const unsigned short appleir_key_table[] = {
 +	KEY_RESERVED,
 +	KEY_MENU,
@@ -247,6 +278,7 @@ index 0000000..cff4df6
 +	KEY_BACK,
 +	KEY_VOLUMEUP,
 +	KEY_VOLUMEDOWN,
++	KEY_ENTER,
 +	KEY_RESERVED,
 +};
 +
@@ -260,6 +292,7 @@ index 0000000..cff4df6
 +	struct urb *urb;
 +	struct timer_list key_up_timer;
 +	int current_key;
++	int prev_key_idx;
 +	char phys[32];
 +};
 +
@@ -272,8 +305,10 @@ index 0000000..cff4df6
 +
 +static struct usb_device_id appleir_ids[] = {
 +	{ USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
-+	{ USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) },
++	{ USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL2) },
++	{ USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL3) },
 +	{ USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
++	{ USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL5) },
 +	{}
 +};
 +MODULE_DEVICE_TABLE(usb, appleir_ids);
@@ -286,7 +321,43 @@ index 0000000..cff4df6
 +
 +	for (i = 0; i < len; ++i)
 +		printk(" %02x", data[i]);
-+	printk("\n");
++	printk(" (should be command %d)\n", (data[4] >> 1) & MAX_KEYS_MASK);
++}
++
++static int get_key(int data)
++{
++	switch (data) {
++	case 0x02:
++	case 0x03:
++		/* menu */
++		return 1;
++	case 0x04:
++	case 0x05:
++		/* >" */
++		return 2;
++	case 0x06:
++	case 0x07:
++		/* >> */
++		return 3;
++	case 0x08:
++	case 0x09:
++		/* << */
++		return 4;
++	case 0x0a:
++	case 0x0b:
++		/* + */
++		return 5;
++	case 0x0c:
++	case 0x0d:
++		/* - */
++		return 6;
++	case 0x5c:
++		/* Middle button, on newer remotes,
++		 * part of a 2 packet-command */
++		return -7;
++	default:
++		return -1;
++	}
 +}
 +
 +static void key_up(struct appleir *appleir, int key)
@@ -331,20 +402,37 @@ index 0000000..cff4df6
 +		return;
 +
 +	if (!memcmp(data, keydown, sizeof(keydown))) {
++		int index;
++
 +		/* 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 = appleir->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 */
-+		mod_timer(&appleir->key_up_timer, jiffies + HZ / 8);
-+
-+		return;
++		/* Handle dual packet commands */
++		if (appleir->prev_key_idx > 0)
++			index = appleir->prev_key_idx;
++		else
++			index = get_key(data[4]);
++
++		if (index > 0) {
++			appleir->current_key = appleir->keymap[index];
++
++			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 */
++			mod_timer(&appleir->key_up_timer, jiffies + HZ / 8);
++			appleir->prev_key_idx = 0;
++			return;
++		} else if (index == -7) {
++			/* Remember key for next packet */
++			appleir->prev_key_idx = 0 - index;
++			return;
++		}
 +	}
 +
++	appleir->prev_key_idx = 0;
++
 +	if (!memcmp(data, keyrepeat, sizeof(keyrepeat))) {
 +		key_down(appleir, appleir->current_key);
 +		/* Remote doesn't do key up, either pull them up, in the test
@@ -609,3 +697,6 @@ index 0000000..cff4df6
 +
 +module_init(appleir_init);
 +module_exit(appleir_exit);
+-- 
+1.7.2.2
+
diff --git a/kernel.spec b/kernel.spec
index cccddb1..c7f8bdd 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -48,7 +48,7 @@ Summary: The Linux kernel
 # reset this by hand to 1 (or to 0 and then use rpmdev-bumpspec).
 # scripts/rebase.sh should be made to do that for you, actually.
 #
-%global baserelease 23
+%global baserelease 25
 %global fedora_build %{baserelease}
 
 # base_sublevel is the kernel version we're starting with and patching
@@ -1928,6 +1928,10 @@ fi
 # and build.
 
 %changelog
+* Fri Sep 10 2010 Bastien Nocera <bnocera at redhat.com> - 2.6.35.4-25
+- Update AppleIR patch to work, and support the enter key on
+  newer remotes
+
 * Fri Sep 10 2010 Chuck Ebbert <cebbert at redhat.com>
 - Disable asynchronous suspend by default.
 


More information about the scm-commits mailing list