linux/drivers/hid/hid-apple.c
<<
>>
Prefs
   1/*
   2 *  USB HID quirks support for Linux
   3 *
   4 *  Copyright (c) 1999 Andreas Gal
   5 *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
   6 *  Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
   7 *  Copyright (c) 2006-2007 Jiri Kosina
   8 *  Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
   9 */
  10
  11/*
  12 * This program is free software; you can redistribute it and/or modify it
  13 * under the terms of the GNU General Public License as published by the Free
  14 * Software Foundation; either version 2 of the License, or (at your option)
  15 * any later version.
  16 */
  17
  18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  19
  20#include <linux/device.h>
  21#include <linux/hid.h>
  22#include <linux/module.h>
  23#include <linux/slab.h>
  24
  25#include "hid-ids.h"
  26
  27#define APPLE_RDESC_JIS         0x0001
  28#define APPLE_IGNORE_MOUSE      0x0002
  29#define APPLE_HAS_FN            0x0004
  30#define APPLE_HIDDEV            0x0008
  31#define APPLE_ISO_KEYBOARD      0x0010
  32#define APPLE_MIGHTYMOUSE       0x0020
  33#define APPLE_INVERT_HWHEEL     0x0040
  34#define APPLE_IGNORE_HIDINPUT   0x0080
  35#define APPLE_NUMLOCK_EMULATION 0x0100
  36
  37#define APPLE_FLAG_FKEY         0x01
  38
  39static unsigned int fnmode = 1;
  40module_param(fnmode, uint, 0644);
  41MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
  42                "[1] = fkeyslast, 2 = fkeysfirst)");
  43
  44static unsigned int iso_layout = 1;
  45module_param(iso_layout, uint, 0644);
  46MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
  47                "(0 = disabled, [1] = enabled)");
  48
  49struct apple_sc {
  50        unsigned long quirks;
  51        unsigned int fn_on;
  52        DECLARE_BITMAP(pressed_fn, KEY_CNT);
  53        DECLARE_BITMAP(pressed_numlock, KEY_CNT);
  54};
  55
  56struct apple_key_translation {
  57        u16 from;
  58        u16 to;
  59        u8 flags;
  60};
  61
  62static const struct apple_key_translation macbookair_fn_keys[] = {
  63        { KEY_BACKSPACE, KEY_DELETE },
  64        { KEY_ENTER,    KEY_INSERT },
  65        { KEY_F1,       KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
  66        { KEY_F2,       KEY_BRIGHTNESSUP,   APPLE_FLAG_FKEY },
  67        { KEY_F3,       KEY_SCALE,          APPLE_FLAG_FKEY },
  68        { KEY_F4,       KEY_DASHBOARD,      APPLE_FLAG_FKEY },
  69        { KEY_F6,       KEY_PREVIOUSSONG,   APPLE_FLAG_FKEY },
  70        { KEY_F7,       KEY_PLAYPAUSE,      APPLE_FLAG_FKEY },
  71        { KEY_F8,       KEY_NEXTSONG,       APPLE_FLAG_FKEY },
  72        { KEY_F9,       KEY_MUTE,           APPLE_FLAG_FKEY },
  73        { KEY_F10,      KEY_VOLUMEDOWN,     APPLE_FLAG_FKEY },
  74        { KEY_F11,      KEY_VOLUMEUP,       APPLE_FLAG_FKEY },
  75        { KEY_F12,      KEY_EJECTCD,        APPLE_FLAG_FKEY },
  76        { KEY_UP,       KEY_PAGEUP },
  77        { KEY_DOWN,     KEY_PAGEDOWN },
  78        { KEY_LEFT,     KEY_HOME },
  79        { KEY_RIGHT,    KEY_END },
  80        { }
  81};
  82
  83static const struct apple_key_translation apple_fn_keys[] = {
  84        { KEY_BACKSPACE, KEY_DELETE },
  85        { KEY_ENTER,    KEY_INSERT },
  86        { KEY_F1,       KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
  87        { KEY_F2,       KEY_BRIGHTNESSUP,   APPLE_FLAG_FKEY },
  88        { KEY_F3,       KEY_SCALE,          APPLE_FLAG_FKEY },
  89        { KEY_F4,       KEY_DASHBOARD,      APPLE_FLAG_FKEY },
  90        { KEY_F5,       KEY_KBDILLUMDOWN,   APPLE_FLAG_FKEY },
  91        { KEY_F6,       KEY_KBDILLUMUP,     APPLE_FLAG_FKEY },
  92        { KEY_F7,       KEY_PREVIOUSSONG,   APPLE_FLAG_FKEY },
  93        { KEY_F8,       KEY_PLAYPAUSE,      APPLE_FLAG_FKEY },
  94        { KEY_F9,       KEY_NEXTSONG,       APPLE_FLAG_FKEY },
  95        { KEY_F10,      KEY_MUTE,           APPLE_FLAG_FKEY },
  96        { KEY_F11,      KEY_VOLUMEDOWN,     APPLE_FLAG_FKEY },
  97        { KEY_F12,      KEY_VOLUMEUP,       APPLE_FLAG_FKEY },
  98        { KEY_UP,       KEY_PAGEUP },
  99        { KEY_DOWN,     KEY_PAGEDOWN },
 100        { KEY_LEFT,     KEY_HOME },
 101        { KEY_RIGHT,    KEY_END },
 102        { }
 103};
 104
 105static const struct apple_key_translation powerbook_fn_keys[] = {
 106        { KEY_BACKSPACE, KEY_DELETE },
 107        { KEY_F1,       KEY_BRIGHTNESSDOWN,     APPLE_FLAG_FKEY },
 108        { KEY_F2,       KEY_BRIGHTNESSUP,       APPLE_FLAG_FKEY },
 109        { KEY_F3,       KEY_MUTE,               APPLE_FLAG_FKEY },
 110        { KEY_F4,       KEY_VOLUMEDOWN,         APPLE_FLAG_FKEY },
 111        { KEY_F5,       KEY_VOLUMEUP,           APPLE_FLAG_FKEY },
 112        { KEY_F6,       KEY_NUMLOCK,            APPLE_FLAG_FKEY },
 113        { KEY_F7,       KEY_SWITCHVIDEOMODE,    APPLE_FLAG_FKEY },
 114        { KEY_F8,       KEY_KBDILLUMTOGGLE,     APPLE_FLAG_FKEY },
 115        { KEY_F9,       KEY_KBDILLUMDOWN,       APPLE_FLAG_FKEY },
 116        { KEY_F10,      KEY_KBDILLUMUP,         APPLE_FLAG_FKEY },
 117        { KEY_UP,       KEY_PAGEUP },
 118        { KEY_DOWN,     KEY_PAGEDOWN },
 119        { KEY_LEFT,     KEY_HOME },
 120        { KEY_RIGHT,    KEY_END },
 121        { }
 122};
 123
 124static const struct apple_key_translation powerbook_numlock_keys[] = {
 125        { KEY_J,        KEY_KP1 },
 126        { KEY_K,        KEY_KP2 },
 127        { KEY_L,        KEY_KP3 },
 128        { KEY_U,        KEY_KP4 },
 129        { KEY_I,        KEY_KP5 },
 130        { KEY_O,        KEY_KP6 },
 131        { KEY_7,        KEY_KP7 },
 132        { KEY_8,        KEY_KP8 },
 133        { KEY_9,        KEY_KP9 },
 134        { KEY_M,        KEY_KP0 },
 135        { KEY_DOT,      KEY_KPDOT },
 136        { KEY_SLASH,    KEY_KPPLUS },
 137        { KEY_SEMICOLON, KEY_KPMINUS },
 138        { KEY_P,        KEY_KPASTERISK },
 139        { KEY_MINUS,    KEY_KPEQUAL },
 140        { KEY_0,        KEY_KPSLASH },
 141        { KEY_F6,       KEY_NUMLOCK },
 142        { KEY_KPENTER,  KEY_KPENTER },
 143        { KEY_BACKSPACE, KEY_BACKSPACE },
 144        { }
 145};
 146
 147static const struct apple_key_translation apple_iso_keyboard[] = {
 148        { KEY_GRAVE,    KEY_102ND },
 149        { KEY_102ND,    KEY_GRAVE },
 150        { }
 151};
 152
 153static const struct apple_key_translation *apple_find_translation(
 154                const struct apple_key_translation *table, u16 from)
 155{
 156        const struct apple_key_translation *trans;
 157
 158        /* Look for the translation */
 159        for (trans = table; trans->from; trans++)
 160                if (trans->from == from)
 161                        return trans;
 162
 163        return NULL;
 164}
 165
 166static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
 167                struct hid_usage *usage, __s32 value)
 168{
 169        struct apple_sc *asc = hid_get_drvdata(hid);
 170        const struct apple_key_translation *trans, *table;
 171
 172        if (usage->code == KEY_FN) {
 173                asc->fn_on = !!value;
 174                input_event(input, usage->type, usage->code, value);
 175                return 1;
 176        }
 177
 178        if (fnmode) {
 179                int do_translate;
 180
 181                if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
 182                                hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
 183                        table = macbookair_fn_keys;
 184                else if (hid->product < 0x21d || hid->product >= 0x300)
 185                        table = powerbook_fn_keys;
 186                else
 187                        table = apple_fn_keys;
 188
 189                trans = apple_find_translation (table, usage->code);
 190
 191                if (trans) {
 192                        if (test_bit(usage->code, asc->pressed_fn))
 193                                do_translate = 1;
 194                        else if (trans->flags & APPLE_FLAG_FKEY)
 195                                do_translate = (fnmode == 2 && asc->fn_on) ||
 196                                        (fnmode == 1 && !asc->fn_on);
 197                        else
 198                                do_translate = asc->fn_on;
 199
 200                        if (do_translate) {
 201                                if (value)
 202                                        set_bit(usage->code, asc->pressed_fn);
 203                                else
 204                                        clear_bit(usage->code, asc->pressed_fn);
 205
 206                                input_event(input, usage->type, trans->to,
 207                                                value);
 208
 209                                return 1;
 210                        }
 211                }
 212
 213                if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
 214                                (test_bit(usage->code, asc->pressed_numlock) ||
 215                                test_bit(LED_NUML, input->led))) {
 216                        trans = apple_find_translation(powerbook_numlock_keys,
 217                                        usage->code);
 218
 219                        if (trans) {
 220                                if (value)
 221                                        set_bit(usage->code,
 222                                                        asc->pressed_numlock);
 223                                else
 224                                        clear_bit(usage->code,
 225                                                        asc->pressed_numlock);
 226
 227                                input_event(input, usage->type, trans->to,
 228                                                value);
 229                        }
 230
 231                        return 1;
 232                }
 233        }
 234
 235        if (iso_layout) {
 236                if (asc->quirks & APPLE_ISO_KEYBOARD) {
 237                        trans = apple_find_translation(apple_iso_keyboard, usage->code);
 238                        if (trans) {
 239                                input_event(input, usage->type, trans->to, value);
 240                                return 1;
 241                        }
 242                }
 243        }
 244
 245        return 0;
 246}
 247
 248static int apple_event(struct hid_device *hdev, struct hid_field *field,
 249                struct hid_usage *usage, __s32 value)
 250{
 251        struct apple_sc *asc = hid_get_drvdata(hdev);
 252
 253        if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
 254                        !usage->type)
 255                return 0;
 256
 257        if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
 258                        usage->code == REL_HWHEEL) {
 259                input_event(field->hidinput->input, usage->type, usage->code,
 260                                -value);
 261                return 1;
 262        }
 263
 264        if ((asc->quirks & APPLE_HAS_FN) &&
 265                        hidinput_apple_event(hdev, field->hidinput->input,
 266                                usage, value))
 267                return 1;
 268
 269
 270        return 0;
 271}
 272
 273/*
 274 * MacBook JIS keyboard has wrong logical maximum
 275 */
 276static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 277                unsigned int *rsize)
 278{
 279        struct apple_sc *asc = hid_get_drvdata(hdev);
 280
 281        if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
 282                        rdesc[53] == 0x65 && rdesc[59] == 0x65) {
 283                hid_info(hdev,
 284                         "fixing up MacBook JIS keyboard report descriptor\n");
 285                rdesc[53] = rdesc[59] = 0xe7;
 286        }
 287        return rdesc;
 288}
 289
 290static void apple_setup_input(struct input_dev *input)
 291{
 292        const struct apple_key_translation *trans;
 293
 294        set_bit(KEY_NUMLOCK, input->keybit);
 295
 296        /* Enable all needed keys */
 297        for (trans = apple_fn_keys; trans->from; trans++)
 298                set_bit(trans->to, input->keybit);
 299
 300        for (trans = powerbook_fn_keys; trans->from; trans++)
 301                set_bit(trans->to, input->keybit);
 302
 303        for (trans = powerbook_numlock_keys; trans->from; trans++)
 304                set_bit(trans->to, input->keybit);
 305
 306        for (trans = apple_iso_keyboard; trans->from; trans++)
 307                set_bit(trans->to, input->keybit);
 308}
 309
 310static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 311                struct hid_field *field, struct hid_usage *usage,
 312                unsigned long **bit, int *max)
 313{
 314        if (usage->hid == (HID_UP_CUSTOM | 0x0003)) {
 315                /* The fn key on Apple USB keyboards */
 316                set_bit(EV_REP, hi->input->evbit);
 317                hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
 318                apple_setup_input(hi->input);
 319                return 1;
 320        }
 321
 322        /* we want the hid layer to go through standard path (set and ignore) */
 323        return 0;
 324}
 325
 326static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
 327                struct hid_field *field, struct hid_usage *usage,
 328                unsigned long **bit, int *max)
 329{
 330        struct apple_sc *asc = hid_get_drvdata(hdev);
 331
 332        if (asc->quirks & APPLE_MIGHTYMOUSE) {
 333                if (usage->hid == HID_GD_Z)
 334                        hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
 335                else if (usage->code == BTN_1)
 336                        hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
 337                else if (usage->code == BTN_2)
 338                        hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
 339        }
 340
 341        return 0;
 342}
 343
 344static int apple_probe(struct hid_device *hdev,
 345                const struct hid_device_id *id)
 346{
 347        unsigned long quirks = id->driver_data;
 348        struct apple_sc *asc;
 349        unsigned int connect_mask = HID_CONNECT_DEFAULT;
 350        int ret;
 351
 352        asc = kzalloc(sizeof(*asc), GFP_KERNEL);
 353        if (asc == NULL) {
 354                hid_err(hdev, "can't alloc apple descriptor\n");
 355                return -ENOMEM;
 356        }
 357
 358        asc->quirks = quirks;
 359
 360        hid_set_drvdata(hdev, asc);
 361
 362        ret = hid_parse(hdev);
 363        if (ret) {
 364                hid_err(hdev, "parse failed\n");
 365                goto err_free;
 366        }
 367
 368        if (quirks & APPLE_HIDDEV)
 369                connect_mask |= HID_CONNECT_HIDDEV_FORCE;
 370        if (quirks & APPLE_IGNORE_HIDINPUT)
 371                connect_mask &= ~HID_CONNECT_HIDINPUT;
 372
 373        ret = hid_hw_start(hdev, connect_mask);
 374        if (ret) {
 375                hid_err(hdev, "hw start failed\n");
 376                goto err_free;
 377        }
 378
 379        return 0;
 380err_free:
 381        kfree(asc);
 382        return ret;
 383}
 384
 385static void apple_remove(struct hid_device *hdev)
 386{
 387        hid_hw_stop(hdev);
 388        kfree(hid_get_drvdata(hdev));
 389}
 390
 391static const struct hid_device_id apple_devices[] = {
 392        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
 393                .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
 394
 395        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
 396                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 397        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
 398                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 399        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
 400                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 401        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
 402                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 403                        APPLE_ISO_KEYBOARD },
 404        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
 405                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 406        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
 407                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 408        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
 409                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 410                        APPLE_ISO_KEYBOARD },
 411        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
 412                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 413                        APPLE_RDESC_JIS },
 414        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
 415                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 416        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
 417                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 418                        APPLE_ISO_KEYBOARD },
 419        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
 420                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 421                        APPLE_RDESC_JIS },
 422        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
 423                .driver_data = APPLE_HAS_FN },
 424        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
 425                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 426        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
 427                .driver_data = APPLE_HAS_FN },
 428        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
 429                .driver_data = APPLE_HAS_FN },
 430        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
 431                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 432        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
 433                .driver_data = APPLE_HAS_FN },
 434        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
 435                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 436        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
 437                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 438                        APPLE_ISO_KEYBOARD },
 439        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
 440                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 441                        APPLE_RDESC_JIS },
 442        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
 443                .driver_data = APPLE_HAS_FN },
 444        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
 445                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 446        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
 447                .driver_data = APPLE_HAS_FN },
 448        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
 449                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 450        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
 451                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 452                        APPLE_ISO_KEYBOARD },
 453        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
 454                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 455                        APPLE_ISO_KEYBOARD },
 456        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
 457                                USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
 458                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 459        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
 460                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 461        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
 462                .driver_data = APPLE_HAS_FN },
 463        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
 464                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 465        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
 466                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 467        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
 468                .driver_data = APPLE_HAS_FN },
 469        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
 470                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 471        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
 472                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 473        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
 474                .driver_data = APPLE_HAS_FN },
 475        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
 476                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 477        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
 478                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 479        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
 480                .driver_data = APPLE_HAS_FN },
 481        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
 482                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 483        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
 484                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 485        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
 486                .driver_data = APPLE_HAS_FN },
 487        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
 488                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 489        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
 490                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 491        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
 492                .driver_data = APPLE_HAS_FN },
 493        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
 494                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 495        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
 496                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 497        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
 498                .driver_data = APPLE_HAS_FN },
 499        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
 500                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 501        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
 502                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 503        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
 504                .driver_data = APPLE_HAS_FN },
 505        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
 506                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 507        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
 508                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 509        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
 510                .driver_data = APPLE_HAS_FN },
 511        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
 512                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 513        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
 514                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 515        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
 516                .driver_data = APPLE_HAS_FN },
 517        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
 518                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 519        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
 520                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 521        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
 522                .driver_data = APPLE_HAS_FN },
 523        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
 524                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 525        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
 526                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 527        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
 528                .driver_data = APPLE_HAS_FN },
 529        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
 530                .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
 531        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
 532                .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
 533        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
 534                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 535        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
 536                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
 537                        APPLE_ISO_KEYBOARD },
 538        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
 539                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 540        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
 541                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 542        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
 543                .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 544
 545        { }
 546};
 547MODULE_DEVICE_TABLE(hid, apple_devices);
 548
 549static struct hid_driver apple_driver = {
 550        .name = "apple",
 551        .id_table = apple_devices,
 552        .report_fixup = apple_report_fixup,
 553        .probe = apple_probe,
 554        .remove = apple_remove,
 555        .event = apple_event,
 556        .input_mapping = apple_input_mapping,
 557        .input_mapped = apple_input_mapped,
 558};
 559module_hid_driver(apple_driver);
 560
 561MODULE_LICENSE("GPL");
 562
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.