aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Daenzer <michel@tungstengraphics.com>2007-10-24 10:30:34 -0400
committerJiri Kosina <jkosina@suse.cz>2008-01-28 08:51:19 -0500
commit81e1a875505f2963f4d22f7e7ade39d764755f9b (patch)
treefaa6f32b4b4bcc1d47cb61c67bb0ae5932bb14cf
parent3c684c8cd4d1a81004daa21f7ad3dad5119916e3 (diff)
HID: Rename some code identifiers from PowerBook specific to Apple generic
Preserve identifiers exposed in build and run time configuration though in order not to break existing configurations. This is in preparation for adding support for Apple aluminum USB keyboards. Signed-off-by: Michel Daenzer <michel@tungstengraphics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-input.c75
-rw-r--r--drivers/hid/usbhid/hid-quirks.c26
-rw-r--r--include/linux/hid.h8
3 files changed, 55 insertions, 54 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 3a18ec45a71f..85803f183fcc 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -34,10 +34,10 @@
34#include <linux/hid.h> 34#include <linux/hid.h>
35#include <linux/hid-debug.h> 35#include <linux/hid-debug.h>
36 36
37static int hid_pb_fnmode = 1; 37static int hid_apple_fnmode = 1;
38module_param_named(pb_fnmode, hid_pb_fnmode, int, 0644); 38module_param_named(pb_fnmode, hid_apple_fnmode, int, 0644);
39MODULE_PARM_DESC(pb_fnmode, 39MODULE_PARM_DESC(pb_fnmode,
40 "Mode of fn key on PowerBooks (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst)"); 40 "Mode of fn key on Apple keyboards (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst)");
41 41
42#define unk KEY_UNKNOWN 42#define unk KEY_UNKNOWN
43 43
@@ -99,20 +99,20 @@ struct hidinput_key_translation {
99 u8 flags; 99 u8 flags;
100}; 100};
101 101
102#define POWERBOOK_FLAG_FKEY 0x01 102#define APPLE_FLAG_FKEY 0x01
103 103
104static struct hidinput_key_translation powerbook_fn_keys[] = { 104static struct hidinput_key_translation powerbook_fn_keys[] = {
105 { KEY_BACKSPACE, KEY_DELETE }, 105 { KEY_BACKSPACE, KEY_DELETE },
106 { KEY_F1, KEY_BRIGHTNESSDOWN, POWERBOOK_FLAG_FKEY }, 106 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
107 { KEY_F2, KEY_BRIGHTNESSUP, POWERBOOK_FLAG_FKEY }, 107 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
108 { KEY_F3, KEY_MUTE, POWERBOOK_FLAG_FKEY }, 108 { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
109 { KEY_F4, KEY_VOLUMEDOWN, POWERBOOK_FLAG_FKEY }, 109 { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
110 { KEY_F5, KEY_VOLUMEUP, POWERBOOK_FLAG_FKEY }, 110 { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
111 { KEY_F6, KEY_NUMLOCK, POWERBOOK_FLAG_FKEY }, 111 { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
112 { KEY_F7, KEY_SWITCHVIDEOMODE, POWERBOOK_FLAG_FKEY }, 112 { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
113 { KEY_F8, KEY_KBDILLUMTOGGLE, POWERBOOK_FLAG_FKEY }, 113 { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
114 { KEY_F9, KEY_KBDILLUMDOWN, POWERBOOK_FLAG_FKEY }, 114 { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
115 { KEY_F10, KEY_KBDILLUMUP, POWERBOOK_FLAG_FKEY }, 115 { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
116 { KEY_UP, KEY_PAGEUP }, 116 { KEY_UP, KEY_PAGEUP },
117 { KEY_DOWN, KEY_PAGEDOWN }, 117 { KEY_DOWN, KEY_PAGEDOWN },
118 { KEY_LEFT, KEY_HOME }, 118 { KEY_LEFT, KEY_HOME },
@@ -143,7 +143,7 @@ static struct hidinput_key_translation powerbook_numlock_keys[] = {
143 { } 143 { }
144}; 144};
145 145
146static struct hidinput_key_translation powerbook_iso_keyboard[] = { 146static struct hidinput_key_translation apple_iso_keyboard[] = {
147 { KEY_GRAVE, KEY_102ND }, 147 { KEY_GRAVE, KEY_102ND },
148 { KEY_102ND, KEY_GRAVE }, 148 { KEY_102ND, KEY_GRAVE },
149 { } 149 { }
@@ -161,39 +161,39 @@ static struct hidinput_key_translation *find_translation(struct hidinput_key_tra
161 return NULL; 161 return NULL;
162} 162}
163 163
164static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 164static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
165 struct hid_usage *usage, __s32 value) 165 struct hid_usage *usage, __s32 value)
166{ 166{
167 struct hidinput_key_translation *trans; 167 struct hidinput_key_translation *trans;
168 168
169 if (usage->code == KEY_FN) { 169 if (usage->code == KEY_FN) {
170 if (value) hid->quirks |= HID_QUIRK_POWERBOOK_FN_ON; 170 if (value) hid->quirks |= HID_QUIRK_APPLE_FN_ON;
171 else hid->quirks &= ~HID_QUIRK_POWERBOOK_FN_ON; 171 else hid->quirks &= ~HID_QUIRK_APPLE_FN_ON;
172 172
173 input_event(input, usage->type, usage->code, value); 173 input_event(input, usage->type, usage->code, value);
174 174
175 return 1; 175 return 1;
176 } 176 }
177 177
178 if (hid_pb_fnmode) { 178 if (hid_apple_fnmode) {
179 int do_translate; 179 int do_translate;
180 180
181 trans = find_translation(powerbook_fn_keys, usage->code); 181 trans = find_translation(powerbook_fn_keys, usage->code);
182 if (trans) { 182 if (trans) {
183 if (test_bit(usage->code, hid->pb_pressed_fn)) 183 if (test_bit(usage->code, hid->apple_pressed_fn))
184 do_translate = 1; 184 do_translate = 1;
185 else if (trans->flags & POWERBOOK_FLAG_FKEY) 185 else if (trans->flags & APPLE_FLAG_FKEY)
186 do_translate = 186 do_translate =
187 (hid_pb_fnmode == 2 && (hid->quirks & HID_QUIRK_POWERBOOK_FN_ON)) || 187 (hid_apple_fnmode == 2 && (hid->quirks & HID_QUIRK_APPLE_FN_ON)) ||
188 (hid_pb_fnmode == 1 && !(hid->quirks & HID_QUIRK_POWERBOOK_FN_ON)); 188 (hid_apple_fnmode == 1 && !(hid->quirks & HID_QUIRK_APPLE_FN_ON));
189 else 189 else
190 do_translate = (hid->quirks & HID_QUIRK_POWERBOOK_FN_ON); 190 do_translate = (hid->quirks & HID_QUIRK_APPLE_FN_ON);
191 191
192 if (do_translate) { 192 if (do_translate) {
193 if (value) 193 if (value)
194 set_bit(usage->code, hid->pb_pressed_fn); 194 set_bit(usage->code, hid->apple_pressed_fn);
195 else 195 else
196 clear_bit(usage->code, hid->pb_pressed_fn); 196 clear_bit(usage->code, hid->apple_pressed_fn);
197 197
198 input_event(input, usage->type, trans->to, value); 198 input_event(input, usage->type, trans->to, value);
199 199
@@ -218,8 +218,8 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
218 } 218 }
219 } 219 }
220 220
221 if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) { 221 if (hid->quirks & HID_QUIRK_APPLE_ISO_KEYBOARD) {
222 trans = find_translation(powerbook_iso_keyboard, usage->code); 222 trans = find_translation(apple_iso_keyboard, usage->code);
223 if (trans) { 223 if (trans) {
224 input_event(input, usage->type, trans->to, value); 224 input_event(input, usage->type, trans->to, value);
225 return 1; 225 return 1;
@@ -229,7 +229,7 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
229 return 0; 229 return 0;
230} 230}
231 231
232static void hidinput_pb_setup(struct input_dev *input) 232static void hidinput_apple_setup(struct input_dev *input)
233{ 233{
234 struct hidinput_key_translation *trans; 234 struct hidinput_key_translation *trans;
235 235
@@ -242,18 +242,19 @@ static void hidinput_pb_setup(struct input_dev *input)
242 for (trans = powerbook_numlock_keys; trans->from; trans++) 242 for (trans = powerbook_numlock_keys; trans->from; trans++)
243 set_bit(trans->to, input->keybit); 243 set_bit(trans->to, input->keybit);
244 244
245 for (trans = powerbook_iso_keyboard; trans->from; trans++) 245 for (trans = apple_iso_keyboard; trans->from; trans++)
246 set_bit(trans->to, input->keybit); 246 set_bit(trans->to, input->keybit);
247 247
248} 248}
249#else 249#else
250static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 250static inline int hidinput_apple_event(struct hid_device *hid,
251 struct hid_usage *usage, __s32 value) 251 struct input_dev *input,
252 struct hid_usage *usage, __s32 value)
252{ 253{
253 return 0; 254 return 0;
254} 255}
255 256
256static inline void hidinput_pb_setup(struct input_dev *input) 257static inline void hidinput_apple_setup(struct input_dev *input)
257{ 258{
258} 259}
259#endif 260#endif
@@ -797,14 +798,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
797 goto ignore; 798 goto ignore;
798 break; 799 break;
799 800
800 case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */ 801 case HID_UP_CUSTOM: /* Reported on Logitech and Apple USB keyboards */
801 802
802 set_bit(EV_REP, input->evbit); 803 set_bit(EV_REP, input->evbit);
803 switch(usage->hid & HID_USAGE) { 804 switch(usage->hid & HID_USAGE) {
804 case 0x003: 805 case 0x003:
805 /* The fn key on Apple PowerBooks */ 806 /* The fn key on Apple USB keyboards */
806 map_key_clear(KEY_FN); 807 map_key_clear(KEY_FN);
807 hidinput_pb_setup(input); 808 hidinput_apple_setup(input);
808 break; 809 break;
809 810
810 default: goto ignore; 811 default: goto ignore;
@@ -989,7 +990,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
989 return; 990 return;
990 } 991 }
991 992
992 if ((hid->quirks & HID_QUIRK_POWERBOOK_HAS_FN) && hidinput_pb_event(hid, input, usage, value)) 993 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
993 return; 994 return;
994 995
995 if (usage->hat_min < usage->hat_max || usage->hat_dir) { 996 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index a2552856476b..127f24a93b09 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -540,19 +540,19 @@ static const struct hid_blacklist {
540 540
541 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 541 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
542 542
543 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 543 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
544 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 544 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
545 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 545 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
546 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, 546 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD},
547 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 547 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
548 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 548 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
549 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, 549 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD},
550 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 550 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
551 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 551 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
552 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, 552 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD},
553 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 553 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
554 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 554 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
555 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 555 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
556 556
557 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, 557 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS },
558 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD, HID_QUIRK_RESET_LEDS }, 558 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD, HID_QUIRK_RESET_LEDS },
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 6e35b92b1d2c..833f2af8aab9 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -267,10 +267,10 @@ struct hid_item {
267#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100 267#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100
268#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200 268#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200
269#define HID_QUIRK_MIGHTYMOUSE 0x00000400 269#define HID_QUIRK_MIGHTYMOUSE 0x00000400
270#define HID_QUIRK_POWERBOOK_HAS_FN 0x00000800 270#define HID_QUIRK_APPLE_HAS_FN 0x00000800
271#define HID_QUIRK_POWERBOOK_FN_ON 0x00001000 271#define HID_QUIRK_APPLE_FN_ON 0x00001000
272#define HID_QUIRK_INVERT_HWHEEL 0x00002000 272#define HID_QUIRK_INVERT_HWHEEL 0x00002000
273#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00004000 273#define HID_QUIRK_APPLE_ISO_KEYBOARD 0x00004000
274#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000 274#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000
275#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 275#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000
276#define HID_QUIRK_IGNORE_MOUSE 0x00020000 276#define HID_QUIRK_IGNORE_MOUSE 0x00020000
@@ -469,7 +469,7 @@ struct hid_device { /* device report descriptor */
469 /* handler for raw output data, used by hidraw */ 469 /* handler for raw output data, used by hidraw */
470 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t); 470 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t);
471#ifdef CONFIG_USB_HIDINPUT_POWERBOOK 471#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
472 unsigned long pb_pressed_fn[BITS_TO_LONGS(KEY_CNT)]; 472 unsigned long apple_pressed_fn[BITS_TO_LONGS(KEY_CNT)];
473 unsigned long pb_pressed_numlock[BITS_TO_LONGS(KEY_CNT)]; 473 unsigned long pb_pressed_numlock[BITS_TO_LONGS(KEY_CNT)];
474#endif 474#endif
475}; 475};