Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Generic linux-input device driver for keyboard devices |
| 3 | * |
| 4 | * Copyright (c) 2001 Brian S. Julin |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions, and the following disclaimer, |
| 12 | * without modification. |
| 13 | * 2. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * Alternatively, this software may be distributed under the terms of the |
| 17 | * GNU General Public License ("GPL"). |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR |
| 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 28 | * |
| 29 | * References: |
| 30 | * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <linux/hil.h> |
| 35 | #include <linux/input.h> |
| 36 | #include <linux/serio.h> |
| 37 | #include <linux/kernel.h> |
| 38 | #include <linux/module.h> |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 39 | #include <linux/completion.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/slab.h> |
| 41 | #include <linux/pci_ids.h> |
| 42 | |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 43 | #define PREFIX "HIL: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 46 | MODULE_DESCRIPTION("HIL keyboard/mouse driver"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | MODULE_LICENSE("Dual BSD/GPL"); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 48 | MODULE_ALIAS("serio:ty03pr25id00ex*"); /* HIL keyboard */ |
| 49 | MODULE_ALIAS("serio:ty03pr25id0Fex*"); /* HIL mouse */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 51 | #define HIL_PACKET_MAX_LENGTH 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | #define HIL_KBD_SET1_UPBIT 0x01 |
| 54 | #define HIL_KBD_SET1_SHIFT 1 |
Helge Deller | 3acaf54 | 2007-02-28 23:51:19 -0500 | [diff] [blame] | 55 | static unsigned int hil_kbd_set1[HIL_KEYCODES_SET1_TBLSIZE] __read_mostly = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { HIL_KEYCODES_SET1 }; |
| 57 | |
| 58 | #define HIL_KBD_SET2_UPBIT 0x01 |
| 59 | #define HIL_KBD_SET2_SHIFT 1 |
| 60 | /* Set2 is user defined */ |
| 61 | |
| 62 | #define HIL_KBD_SET3_UPBIT 0x80 |
| 63 | #define HIL_KBD_SET3_SHIFT 0 |
Helge Deller | 3acaf54 | 2007-02-28 23:51:19 -0500 | [diff] [blame] | 64 | static unsigned int hil_kbd_set3[HIL_KEYCODES_SET3_TBLSIZE] __read_mostly = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { HIL_KEYCODES_SET3 }; |
| 66 | |
Helge Deller | 3acaf54 | 2007-02-28 23:51:19 -0500 | [diff] [blame] | 67 | static const char hil_language[][16] = { HIL_LOCALE_MAP }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 69 | struct hil_dev { |
Helge Deller | 102c8c7 | 2006-03-26 07:41:55 -0700 | [diff] [blame] | 70 | struct input_dev *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | struct serio *serio; |
| 72 | |
| 73 | /* Input buffer and index for packets from HIL bus. */ |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 74 | hil_packet data[HIL_PACKET_MAX_LENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | int idx4; /* four counts per packet */ |
| 76 | |
| 77 | /* Raw device info records from HIL bus, see hil.h for fields. */ |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 78 | char idd[HIL_PACKET_MAX_LENGTH]; /* DID byte and IDD record */ |
| 79 | char rsc[HIL_PACKET_MAX_LENGTH]; /* RSC record */ |
| 80 | char exd[HIL_PACKET_MAX_LENGTH]; /* EXD record */ |
| 81 | char rnm[HIL_PACKET_MAX_LENGTH + 1]; /* RNM record + NULL term. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 83 | struct completion cmd_done; |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 84 | |
| 85 | bool is_pointer; |
| 86 | /* Extra device details needed for pointing devices. */ |
| 87 | unsigned int nbtn, naxes; |
| 88 | unsigned int btnmap[7]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 91 | static bool hil_dev_is_command_response(hil_packet p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 93 | if ((p & ~HIL_CMDCT_POL) == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) |
| 94 | return false; |
| 95 | |
| 96 | if ((p & ~HIL_CMDCT_RPL) == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) |
| 97 | return false; |
| 98 | |
| 99 | return true; |
| 100 | } |
| 101 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 102 | static void hil_dev_handle_command_response(struct hil_dev *dev) |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 103 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | hil_packet p; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 105 | char *buf; |
| 106 | int i, idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 108 | idx = dev->idx4 / 4; |
| 109 | p = dev->data[idx - 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | switch (p & HIL_PKT_DATA_MASK) { |
| 112 | case HIL_CMD_IDD: |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 113 | buf = dev->idd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | case HIL_CMD_RSC: |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 117 | buf = dev->rsc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | case HIL_CMD_EXD: |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 121 | buf = dev->exd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | case HIL_CMD_RNM: |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 125 | dev->rnm[HIL_PACKET_MAX_LENGTH] = 0; |
| 126 | buf = dev->rnm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | default: |
| 130 | /* These occur when device isn't present */ |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 131 | if (p != (HIL_ERR_INT | HIL_PKT_CMD)) { |
| 132 | /* Anything else we'd like to know about. */ |
| 133 | printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); |
| 134 | } |
| 135 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 138 | for (i = 0; i < idx; i++) |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 139 | buf[i] = dev->data[i] & HIL_PKT_DATA_MASK; |
| 140 | for (; i < HIL_PACKET_MAX_LENGTH; i++) |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 141 | buf[i] = 0; |
| 142 | out: |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 143 | complete(&dev->cmd_done); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 146 | static void hil_dev_handle_kbd_events(struct hil_dev *kbd) |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 147 | { |
| 148 | struct input_dev *dev = kbd->dev; |
| 149 | int idx = kbd->idx4 / 4; |
| 150 | int i; |
| 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) { |
| 153 | case HIL_POL_CHARTYPE_NONE: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 154 | return; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | case HIL_POL_CHARTYPE_ASCII: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 157 | for (i = 1; i < idx - 1; i++) |
| 158 | input_report_key(dev, kbd->data[i] & 0x7f, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | case HIL_POL_CHARTYPE_RSVD1: |
| 162 | case HIL_POL_CHARTYPE_RSVD2: |
| 163 | case HIL_POL_CHARTYPE_BINARY: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 164 | for (i = 1; i < idx - 1; i++) |
| 165 | input_report_key(dev, kbd->data[i], 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | case HIL_POL_CHARTYPE_SET1: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 169 | for (i = 1; i < idx - 1; i++) { |
| 170 | unsigned int key = kbd->data[i]; |
| 171 | int up = key & HIL_KBD_SET1_UPBIT; |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | key &= (~HIL_KBD_SET1_UPBIT & 0xff); |
| 174 | key = hil_kbd_set1[key >> HIL_KBD_SET1_SHIFT]; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 175 | input_report_key(dev, key, !up); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | } |
| 177 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | case HIL_POL_CHARTYPE_SET2: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 180 | for (i = 1; i < idx - 1; i++) { |
| 181 | unsigned int key = kbd->data[i]; |
| 182 | int up = key & HIL_KBD_SET2_UPBIT; |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | key &= (~HIL_KBD_SET1_UPBIT & 0xff); |
| 185 | key = key >> HIL_KBD_SET2_SHIFT; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 186 | input_report_key(dev, key, !up); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | break; |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 189 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | case HIL_POL_CHARTYPE_SET3: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 191 | for (i = 1; i < idx - 1; i++) { |
| 192 | unsigned int key = kbd->data[i]; |
| 193 | int up = key & HIL_KBD_SET3_UPBIT; |
| 194 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | key &= (~HIL_KBD_SET1_UPBIT & 0xff); |
| 196 | key = hil_kbd_set3[key >> HIL_KBD_SET3_SHIFT]; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 197 | input_report_key(dev, key, !up); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | break; |
| 200 | } |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 201 | |
| 202 | input_sync(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 205 | static void hil_dev_handle_ptr_events(struct hil_dev *ptr) |
| 206 | { |
| 207 | struct input_dev *dev = ptr->dev; |
| 208 | int idx = ptr->idx4 / 4; |
| 209 | hil_packet p = ptr->data[idx - 1]; |
| 210 | int i, cnt, laxis; |
| 211 | bool absdev, ax16; |
| 212 | |
| 213 | if ((p & HIL_CMDCT_POL) != idx - 1) { |
| 214 | printk(KERN_WARNING PREFIX |
| 215 | "Malformed poll packet %x (idx = %i)\n", p, idx); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | i = (p & HIL_POL_AXIS_ALT) ? 3 : 0; |
| 220 | laxis = (p & HIL_POL_NUM_AXES_MASK) + i; |
| 221 | |
| 222 | ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */ |
| 223 | absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS; |
| 224 | |
| 225 | for (cnt = 1; i < laxis; i++) { |
| 226 | unsigned int lo, hi, val; |
| 227 | |
| 228 | lo = ptr->data[cnt++] & HIL_PKT_DATA_MASK; |
| 229 | hi = ax16 ? (ptr->data[cnt++] & HIL_PKT_DATA_MASK) : 0; |
| 230 | |
| 231 | if (absdev) { |
| 232 | val = lo + (hi << 8); |
| 233 | #ifdef TABLET_AUTOADJUST |
Dmitry Torokhov | 77edf0c | 2010-08-17 21:22:13 -0700 | [diff] [blame] | 234 | if (val < input_abs_get_min(dev, ABS_X + i)) |
Daniel Mack | 987a6c0 | 2010-08-02 20:15:17 -0700 | [diff] [blame] | 235 | input_abs_set_min(dev, ABS_X + i, val); |
Dmitry Torokhov | 77edf0c | 2010-08-17 21:22:13 -0700 | [diff] [blame] | 236 | if (val > input_abs_get_max(dev, ABS_X + i)) |
Daniel Mack | b84ae4a1 | 2010-08-12 09:22:18 -0700 | [diff] [blame] | 237 | input_abs_set_max(dev, ABS_X + i, val); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 238 | #endif |
Daniel Mack | 987a6c0 | 2010-08-02 20:15:17 -0700 | [diff] [blame] | 239 | if (i % 3) |
Dmitry Torokhov | 77edf0c | 2010-08-17 21:22:13 -0700 | [diff] [blame] | 240 | val = input_abs_get_max(dev, ABS_X + i) - val; |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 241 | input_report_abs(dev, ABS_X + i, val); |
| 242 | } else { |
Daniel Mack | 987a6c0 | 2010-08-02 20:15:17 -0700 | [diff] [blame] | 243 | val = (int) (((int8_t) lo) | ((int8_t) hi << 8)); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 244 | if (i % 3) |
| 245 | val *= -1; |
| 246 | input_report_rel(dev, REL_X + i, val); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | while (cnt < idx - 1) { |
| 251 | unsigned int btn = ptr->data[cnt++]; |
| 252 | int up = btn & 1; |
| 253 | |
| 254 | btn &= 0xfe; |
| 255 | if (btn == 0x8e) |
| 256 | continue; /* TODO: proximity == touch? */ |
| 257 | if (btn > 0x8c || btn < 0x80) |
| 258 | continue; |
| 259 | btn = (btn - 0x80) >> 1; |
| 260 | btn = ptr->btnmap[btn]; |
| 261 | input_report_key(dev, btn, !up); |
| 262 | } |
| 263 | |
| 264 | input_sync(dev); |
| 265 | } |
| 266 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 267 | static void hil_dev_process_err(struct hil_dev *dev) |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 268 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | printk(KERN_WARNING PREFIX "errored HIL packet\n"); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 270 | dev->idx4 = 0; |
| 271 | complete(&dev->cmd_done); /* just in case somebody is waiting */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 274 | static irqreturn_t hil_dev_interrupt(struct serio *serio, |
Helge Deller | ffd51f4 | 2007-02-28 23:51:29 -0500 | [diff] [blame] | 275 | unsigned char data, unsigned int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | { |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 277 | struct hil_dev *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | hil_packet packet; |
| 279 | int idx; |
| 280 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 281 | dev = serio_get_drvdata(serio); |
| 282 | BUG_ON(dev == NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 284 | if (dev->idx4 >= HIL_PACKET_MAX_LENGTH * sizeof(hil_packet)) { |
| 285 | hil_dev_process_err(dev); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 286 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 288 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 289 | idx = dev->idx4 / 4; |
| 290 | if (!(dev->idx4 % 4)) |
| 291 | dev->data[idx] = 0; |
| 292 | packet = dev->data[idx]; |
| 293 | packet |= ((hil_packet)data) << ((3 - (dev->idx4 % 4)) * 8); |
| 294 | dev->data[idx] = packet; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | /* Records of N 4-byte hil_packets must terminate with a command. */ |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 297 | if ((++dev->idx4 % 4) == 0) { |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 298 | if ((packet & 0xffff0000) != HIL_ERR_INT) { |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 299 | hil_dev_process_err(dev); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 300 | } else if (packet & HIL_PKT_CMD) { |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 301 | if (hil_dev_is_command_response(packet)) |
| 302 | hil_dev_handle_command_response(dev); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 303 | else if (dev->is_pointer) |
| 304 | hil_dev_handle_ptr_events(dev); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 305 | else |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 306 | hil_dev_handle_kbd_events(dev); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 307 | dev->idx4 = 0; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 308 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 310 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | return IRQ_HANDLED; |
| 312 | } |
| 313 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 314 | static void hil_dev_disconnect(struct serio *serio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | { |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 316 | struct hil_dev *dev = serio_get_drvdata(serio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 318 | BUG_ON(dev == NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | serio_close(serio); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 321 | input_unregister_device(dev->dev); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 322 | serio_set_drvdata(serio, NULL); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 323 | kfree(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 326 | static void hil_dev_keyboard_setup(struct hil_dev *kbd) |
| 327 | { |
| 328 | struct input_dev *input_dev = kbd->dev; |
| 329 | uint8_t did = kbd->idd[0]; |
| 330 | int i; |
| 331 | |
| 332 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
| 333 | input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | |
| 334 | BIT_MASK(LED_SCROLLL); |
| 335 | |
| 336 | for (i = 0; i < 128; i++) { |
| 337 | __set_bit(hil_kbd_set1[i], input_dev->keybit); |
| 338 | __set_bit(hil_kbd_set3[i], input_dev->keybit); |
| 339 | } |
| 340 | __clear_bit(KEY_RESERVED, input_dev->keybit); |
| 341 | |
| 342 | input_dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
| 343 | input_dev->keycodesize = sizeof(hil_kbd_set1[0]); |
| 344 | input_dev->keycode = hil_kbd_set1; |
| 345 | |
| 346 | input_dev->name = strlen(kbd->rnm) ? kbd->rnm : "HIL keyboard"; |
| 347 | input_dev->phys = "hpkbd/input0"; |
| 348 | |
| 349 | printk(KERN_INFO PREFIX "HIL keyboard found (did = 0x%02x, lang = %s)\n", |
| 350 | did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]); |
| 351 | } |
| 352 | |
| 353 | static void hil_dev_pointer_setup(struct hil_dev *ptr) |
| 354 | { |
| 355 | struct input_dev *input_dev = ptr->dev; |
| 356 | uint8_t did = ptr->idd[0]; |
| 357 | uint8_t *idd = ptr->idd + 1; |
| 358 | unsigned int naxsets = HIL_IDD_NUM_AXSETS(*idd); |
| 359 | unsigned int i, btntype; |
| 360 | const char *txt; |
| 361 | |
| 362 | ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); |
| 363 | |
| 364 | switch (did & HIL_IDD_DID_TYPE_MASK) { |
| 365 | case HIL_IDD_DID_TYPE_REL: |
| 366 | input_dev->evbit[0] = BIT_MASK(EV_REL); |
| 367 | |
| 368 | for (i = 0; i < ptr->naxes; i++) |
| 369 | __set_bit(REL_X + i, input_dev->relbit); |
| 370 | |
| 371 | for (i = 3; naxsets > 1 && i < ptr->naxes + 3; i++) |
| 372 | __set_bit(REL_X + i, input_dev->relbit); |
| 373 | |
| 374 | txt = "relative"; |
| 375 | break; |
| 376 | |
| 377 | case HIL_IDD_DID_TYPE_ABS: |
| 378 | input_dev->evbit[0] = BIT_MASK(EV_ABS); |
| 379 | |
| 380 | for (i = 0; i < ptr->naxes; i++) |
| 381 | input_set_abs_params(input_dev, ABS_X + i, |
| 382 | 0, HIL_IDD_AXIS_MAX(idd, i), 0, 0); |
| 383 | |
| 384 | for (i = 3; naxsets > 1 && i < ptr->naxes + 3; i++) |
| 385 | input_set_abs_params(input_dev, ABS_X + i, |
| 386 | 0, HIL_IDD_AXIS_MAX(idd, i - 3), 0, 0); |
| 387 | |
| 388 | #ifdef TABLET_AUTOADJUST |
| 389 | for (i = 0; i < ABS_MAX; i++) { |
Dmitry Torokhov | 77edf0c | 2010-08-17 21:22:13 -0700 | [diff] [blame] | 390 | int diff = input_abs_get_max(input_dev, ABS_X + i) / 10; |
Daniel Mack | 987a6c0 | 2010-08-02 20:15:17 -0700 | [diff] [blame] | 391 | input_abs_set_min(input_dev, ABS_X + i, |
Dmitry Torokhov | 77edf0c | 2010-08-17 21:22:13 -0700 | [diff] [blame] | 392 | input_abs_get_min(input_dev, ABS_X + i) + diff); |
Daniel Mack | b84ae4a1 | 2010-08-12 09:22:18 -0700 | [diff] [blame] | 393 | input_abs_set_max(input_dev, ABS_X + i, |
Dmitry Torokhov | 77edf0c | 2010-08-17 21:22:13 -0700 | [diff] [blame] | 394 | input_abs_get_max(input_dev, ABS_X + i) - diff); |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 395 | } |
| 396 | #endif |
| 397 | |
| 398 | txt = "absolute"; |
| 399 | break; |
| 400 | |
| 401 | default: |
| 402 | BUG(); |
| 403 | } |
| 404 | |
| 405 | ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); |
| 406 | if (ptr->nbtn) |
| 407 | input_dev->evbit[0] |= BIT_MASK(EV_KEY); |
| 408 | |
| 409 | btntype = BTN_MISC; |
| 410 | if ((did & HIL_IDD_DID_ABS_TABLET_MASK) == HIL_IDD_DID_ABS_TABLET) |
| 411 | #ifdef TABLET_SIMULATES_MOUSE |
| 412 | btntype = BTN_TOUCH; |
| 413 | #else |
| 414 | btntype = BTN_DIGI; |
| 415 | #endif |
| 416 | if ((did & HIL_IDD_DID_ABS_TSCREEN_MASK) == HIL_IDD_DID_ABS_TSCREEN) |
| 417 | btntype = BTN_TOUCH; |
| 418 | |
| 419 | if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE) |
| 420 | btntype = BTN_MOUSE; |
| 421 | |
| 422 | for (i = 0; i < ptr->nbtn; i++) { |
| 423 | __set_bit(btntype | i, input_dev->keybit); |
| 424 | ptr->btnmap[i] = btntype | i; |
| 425 | } |
| 426 | |
| 427 | if (btntype == BTN_MOUSE) { |
| 428 | /* Swap buttons 2 and 3 */ |
| 429 | ptr->btnmap[1] = BTN_MIDDLE; |
| 430 | ptr->btnmap[2] = BTN_RIGHT; |
| 431 | } |
| 432 | |
| 433 | input_dev->name = strlen(ptr->rnm) ? ptr->rnm : "HIL pointer device"; |
| 434 | |
| 435 | printk(KERN_INFO PREFIX |
| 436 | "HIL pointer device found (did: 0x%02x, axis: %s)\n", |
| 437 | did, txt); |
| 438 | printk(KERN_INFO PREFIX |
| 439 | "HIL pointer has %i buttons and %i sets of %i axes\n", |
| 440 | ptr->nbtn, naxsets, ptr->naxes); |
| 441 | } |
| 442 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 443 | static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | { |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 445 | struct hil_dev *dev; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 446 | struct input_dev *input_dev; |
| 447 | uint8_t did, *idd; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 448 | int error; |
Dmitry Torokhov | 95d465f | 2006-04-02 00:08:05 -0500 | [diff] [blame] | 449 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 450 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 451 | input_dev = input_allocate_device(); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 452 | if (!dev || !input_dev) { |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 453 | error = -ENOMEM; |
| 454 | goto bail0; |
| 455 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 457 | dev->serio = serio; |
| 458 | dev->dev = input_dev; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 459 | |
| 460 | error = serio_open(serio, drv); |
| 461 | if (error) |
Dmitry Torokhov | 95d465f | 2006-04-02 00:08:05 -0500 | [diff] [blame] | 462 | goto bail0; |
| 463 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 464 | serio_set_drvdata(serio, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
| 466 | /* Get device info. MLC driver supplies devid/status/etc. */ |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 467 | init_completion(&dev->cmd_done); |
Dmitry Torokhov | dd0d544 | 2009-08-05 00:30:26 -0700 | [diff] [blame] | 468 | serio_write(serio, 0); |
| 469 | serio_write(serio, 0); |
| 470 | serio_write(serio, HIL_PKT_CMD >> 8); |
| 471 | serio_write(serio, HIL_CMD_IDD); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 472 | error = wait_for_completion_killable(&dev->cmd_done); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 473 | if (error) |
| 474 | goto bail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
Nicholas Mc Guire | cceeb87 | 2014-12-26 15:41:42 -0800 | [diff] [blame] | 476 | reinit_completion(&dev->cmd_done); |
Dmitry Torokhov | dd0d544 | 2009-08-05 00:30:26 -0700 | [diff] [blame] | 477 | serio_write(serio, 0); |
| 478 | serio_write(serio, 0); |
| 479 | serio_write(serio, HIL_PKT_CMD >> 8); |
| 480 | serio_write(serio, HIL_CMD_RSC); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 481 | error = wait_for_completion_killable(&dev->cmd_done); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 482 | if (error) |
| 483 | goto bail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
Nicholas Mc Guire | cceeb87 | 2014-12-26 15:41:42 -0800 | [diff] [blame] | 485 | reinit_completion(&dev->cmd_done); |
Dmitry Torokhov | dd0d544 | 2009-08-05 00:30:26 -0700 | [diff] [blame] | 486 | serio_write(serio, 0); |
| 487 | serio_write(serio, 0); |
| 488 | serio_write(serio, HIL_PKT_CMD >> 8); |
| 489 | serio_write(serio, HIL_CMD_RNM); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 490 | error = wait_for_completion_killable(&dev->cmd_done); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 491 | if (error) |
| 492 | goto bail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Nicholas Mc Guire | cceeb87 | 2014-12-26 15:41:42 -0800 | [diff] [blame] | 494 | reinit_completion(&dev->cmd_done); |
Dmitry Torokhov | dd0d544 | 2009-08-05 00:30:26 -0700 | [diff] [blame] | 495 | serio_write(serio, 0); |
| 496 | serio_write(serio, 0); |
| 497 | serio_write(serio, HIL_PKT_CMD >> 8); |
| 498 | serio_write(serio, HIL_CMD_EXD); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 499 | error = wait_for_completion_killable(&dev->cmd_done); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 500 | if (error) |
| 501 | goto bail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 503 | did = dev->idd[0]; |
| 504 | idd = dev->idd + 1; |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 505 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | switch (did & HIL_IDD_DID_TYPE_MASK) { |
| 507 | case HIL_IDD_DID_TYPE_KB_INTEGRAL: |
| 508 | case HIL_IDD_DID_TYPE_KB_ITF: |
| 509 | case HIL_IDD_DID_TYPE_KB_RSVD: |
| 510 | case HIL_IDD_DID_TYPE_CHAR: |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 511 | if (HIL_IDD_NUM_BUTTONS(idd) || |
| 512 | HIL_IDD_NUM_AXES_PER_SET(*idd)) { |
| 513 | printk(KERN_INFO PREFIX |
| 514 | "combo devices are not supported.\n"); |
| 515 | goto bail1; |
| 516 | } |
| 517 | |
| 518 | dev->is_pointer = false; |
| 519 | hil_dev_keyboard_setup(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | break; |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 521 | |
| 522 | case HIL_IDD_DID_TYPE_REL: |
| 523 | case HIL_IDD_DID_TYPE_ABS: |
| 524 | dev->is_pointer = true; |
| 525 | hil_dev_pointer_setup(dev); |
| 526 | break; |
| 527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | default: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 529 | goto bail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | } |
| 531 | |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 532 | input_dev->id.bustype = BUS_HIL; |
| 533 | input_dev->id.vendor = PCI_VENDOR_ID_HP; |
| 534 | input_dev->id.product = 0x0001; /* TODO: get from kbd->rsc */ |
| 535 | input_dev->id.version = 0x0100; /* TODO: get from kbd->rsc */ |
| 536 | input_dev->dev.parent = &serio->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 538 | if (!dev->is_pointer) { |
| 539 | serio_write(serio, 0); |
| 540 | serio_write(serio, 0); |
| 541 | serio_write(serio, HIL_PKT_CMD >> 8); |
| 542 | /* Enable Keyswitch Autorepeat 1 */ |
| 543 | serio_write(serio, HIL_CMD_EK1); |
| 544 | /* No need to wait for completion */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | } |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 546 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 547 | error = input_register_device(input_dev); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 548 | if (error) |
| 549 | goto bail1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | |
Matthew Wilcox | 6ab0f5c | 2005-10-21 22:58:51 -0400 | [diff] [blame] | 551 | return 0; |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 552 | |
| 553 | bail1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | serio_close(serio); |
Matthew Wilcox | d668da8 | 2006-04-03 13:44:17 +0000 | [diff] [blame] | 555 | serio_set_drvdata(serio, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | bail0: |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 557 | input_free_device(input_dev); |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 558 | kfree(dev); |
Dmitry Torokhov | 6777f01 | 2009-08-07 23:17:46 -0700 | [diff] [blame] | 559 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Arvind Yadav | ea6aba4 | 2017-08-18 17:09:21 -0700 | [diff] [blame] | 562 | static const struct serio_device_id hil_dev_ids[] = { |
Matthew Wilcox | 6ab0f5c | 2005-10-21 22:58:51 -0400 | [diff] [blame] | 563 | { |
| 564 | .type = SERIO_HIL_MLC, |
| 565 | .proto = SERIO_HIL, |
| 566 | .id = SERIO_ANY, |
| 567 | .extra = SERIO_ANY, |
| 568 | }, |
| 569 | { 0 } |
| 570 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
Dzianis Kahanovich | 05e93a7 | 2010-09-29 18:38:10 -0700 | [diff] [blame] | 572 | MODULE_DEVICE_TABLE(serio, hil_dev_ids); |
| 573 | |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 574 | static struct serio_driver hil_serio_drv = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | .driver = { |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 576 | .name = "hil_dev", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | }, |
Dmitry Torokhov | fa71c60 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 578 | .description = "HP HIL keyboard/mouse/tablet driver", |
Dmitry Torokhov | 1437dc3 | 2009-08-07 23:17:47 -0700 | [diff] [blame] | 579 | .id_table = hil_dev_ids, |
| 580 | .connect = hil_dev_connect, |
| 581 | .disconnect = hil_dev_disconnect, |
| 582 | .interrupt = hil_dev_interrupt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | }; |
| 584 | |
Axel Lin | 65ac9f7 | 2012-04-03 23:50:17 -0700 | [diff] [blame] | 585 | module_serio_driver(hil_serio_drv); |