diff options
author | Michel Daenzer <michel@tungstengraphics.com> | 2007-10-24 10:30:34 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2008-01-28 08:51:19 -0500 |
commit | 81e1a875505f2963f4d22f7e7ade39d764755f9b (patch) | |
tree | faa6f32b4b4bcc1d47cb61c67bb0ae5932bb14cf /drivers/hid/hid-input.c | |
parent | 3c684c8cd4d1a81004daa21f7ad3dad5119916e3 (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>
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r-- | drivers/hid/hid-input.c | 75 |
1 files changed, 38 insertions, 37 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 | ||
37 | static int hid_pb_fnmode = 1; | 37 | static int hid_apple_fnmode = 1; |
38 | module_param_named(pb_fnmode, hid_pb_fnmode, int, 0644); | 38 | module_param_named(pb_fnmode, hid_apple_fnmode, int, 0644); |
39 | MODULE_PARM_DESC(pb_fnmode, | 39 | MODULE_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 | ||
104 | static struct hidinput_key_translation powerbook_fn_keys[] = { | 104 | static 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 | ||
146 | static struct hidinput_key_translation powerbook_iso_keyboard[] = { | 146 | static 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 | ||
164 | static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, | 164 | static 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 | ||
232 | static void hidinput_pb_setup(struct input_dev *input) | 232 | static 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 |
250 | static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, | 250 | static 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 | ||
256 | static inline void hidinput_pb_setup(struct input_dev *input) | 257 | static 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) { |