Move them from core code to separate driver.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/hid/Kconfig | 14 ++
drivers/hid/Makefile | 1 +
drivers/hid/hid-apple.c | 494 +++++++++++++++++++++++++++++++++++++++
drivers/hid/hid-core.c | 33 +++-
drivers/hid/hid-input-quirks.c | 8 -
drivers/hid/hid-input.c | 218 +-----------------
drivers/hid/usbhid/Kconfig | 11 -
drivers/hid/usbhid/hid-quirks.c | 43 ----
include/linux/hid.h | 11 -
net/bluetooth/hidp/core.c | 22 --
10 files changed, 542 insertions(+), 313 deletions(-)
create mode 100644 drivers/hid/hid-apple.c
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 066e8c0..9a9fd7d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -78,6 +78,20 @@ config HID_LOGITECH
Support for some Logitech devices which breaks less or more
HID specification.
+config HID_APPLE
+ tristate "Apple"
+ default m
+ depends on (USB_HID || BT_HIDP)
+ ---help---
+ Support for some Apple devices which less or more break
+ HID specification.
+
+ Say Y here if you want support for the special keys (Fn, Numlock) on
+ Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB
+ keyboards.
+
+ If unsure, say N.
+
endmenu
endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index cae036b..8a5cbbe 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -9,6 +9,7 @@ hid-$(CONFIG_HID_DEBUG) += hid-debug.o
hid-$(CONFIG_HIDRAW) += hidraw.o
obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
+obj-$(CONFIG_HID_APPLE) += hid-apple.o
obj-$(CONFIG_USB_HID) += usbhid/
obj-$(CONFIG_USB_MOUSE) += usbhid/
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
new file mode 100644
index 0000000..55792ed
--- /dev/null
+++ b/drivers/hid/hid-apple.c
@@ -0,0 +1,494 @@
+/*
+ * USB HID quirks support for Linux
+ *
+ * Copyright (c) 1999 Andreas Gal
+ * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
+ * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
+ * Copyright (c) 2006-2007 Jiri Kosina
+ * Copyright (c) 2007 Paul Walmsley
+ * Copyright (c) 2008 Jiri Slaby <jslaby@suse.cz>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/autoconf.h>
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+
+#include "hid-ids.h"
+
+/* to simplify the tests throughout the code */
+#ifdef CONFIG_BT_HIDP_MODULE
+#define CONFIG_BT_HIDP 1
+#endif
+#ifdef CONFIG_USB_HID_MODULE
+#define CONFIG_USB_HID 1
+#endif
+
+#define APPLE_RDESC_JIS 0x0001
+#define APPLE_IGNORE_MOUSE 0x0002
+#define APPLE_HAS_FN 0x0004
+#define APPLE_FN_ON 0x0008 /* is fn pressed? */
+#define APPLE_HIDDEV 0x0010
+#define APPLE_ISO_KEYBOARD 0x0020
+#define APPLE_MIGHTYMOUSE 0x0040
+#define APPLE_INVERT_HWHEEL 0x0080
+#define APPLE_IGNORE_HIDINPUT 0x0100
+
+#define APPLE_FLAG_FKEY 0x01
+
+static unsigned int fnmode = 1;
+module_param(fnmode, uint, 0644);
+MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
+ "[1] = fkeyslast, 2 = fkeysfirst)");
+
+struct apple_sc {
+ unsigned long quirks;
+ DECLARE_BITMAP(pressed_fn, KEY_CNT);
+ DECLARE_BITMAP(pressed_numlock, KEY_CNT);
+};
+
+struct apple_key_translation {
+ u16 from;
+ u16 to;
+ u8 flags;
+};
+
+static struct apple_key_translation apple_fn_keys[] = {
+ { KEY_BACKSPACE, KEY_DELETE },
+ { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
+ { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
+ { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Expos