Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Fujitsu B-series Lifebook PS/2 TouchScreen driver |
| 3 | * |
| 4 | * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> |
| 5 | * Copyright (c) 2005 Kenan Esau <kenan.esau@conan.de> |
| 6 | * |
| 7 | * TouchScreen detection, absolute mode setting and packet layout is taken from |
| 8 | * Harald Hoyer's description of the device. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License version 2 as published by |
| 12 | * the Free Software Foundation. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/input.h> |
| 16 | #include <linux/serio.h> |
| 17 | #include <linux/libps2.h> |
| 18 | #include <linux/dmi.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 20 | |
| 21 | #include "psmouse.h" |
| 22 | #include "lifebook.h" |
| 23 | |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 24 | struct lifebook_data { |
| 25 | struct input_dev *dev2; /* Relative device */ |
| 26 | char phys[32]; |
| 27 | }; |
| 28 | |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 29 | static bool lifebook_present; |
| 30 | |
Dmitry Torokhov | e7afcd1 | 2007-04-12 01:36:25 -0400 | [diff] [blame] | 31 | static const char *desired_serio_phys; |
| 32 | |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 33 | static int lifebook_limit_serio3(const struct dmi_system_id *d) |
Dmitry Torokhov | e7afcd1 | 2007-04-12 01:36:25 -0400 | [diff] [blame] | 34 | { |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 35 | desired_serio_phys = "isa0060/serio3"; |
Dmitry Torokhov | e7afcd1 | 2007-04-12 01:36:25 -0400 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 39 | static bool lifebook_use_6byte_proto; |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 40 | |
Jeff Garzik | 1855256 | 2007-10-03 15:15:40 -0400 | [diff] [blame] | 41 | static int lifebook_set_6byte_proto(const struct dmi_system_id *d) |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 42 | { |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 43 | lifebook_use_6byte_proto = true; |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 47 | static const struct dmi_system_id __initconst lifebook_dmi_table[] = { |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 48 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 49 | /* FLORA-ie 55mi */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 50 | .matches = { |
| 51 | DMI_MATCH(DMI_PRODUCT_NAME, "FLORA-ie 55mi"), |
| 52 | }, |
| 53 | }, |
| 54 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 55 | /* LifeBook B */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 56 | .matches = { |
Jon Dodgson | 57b5e2a | 2010-01-28 00:07:45 -0800 | [diff] [blame] | 57 | DMI_MATCH(DMI_PRODUCT_NAME, "Lifebook B Series"), |
| 58 | }, |
| 59 | }, |
| 60 | { |
| 61 | /* LifeBook B */ |
| 62 | .matches = { |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 63 | DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B Series"), |
| 64 | }, |
| 65 | }, |
| 66 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 67 | /* Lifebook B */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 68 | .matches = { |
| 69 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK B Series"), |
| 70 | }, |
| 71 | }, |
| 72 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 73 | /* Lifebook B-2130 */ |
Dmitry Torokhov | 6b9ff69 | 2009-04-24 12:01:47 -0700 | [diff] [blame] | 74 | .matches = { |
| 75 | DMI_MATCH(DMI_BOARD_NAME, "ZEPHYR"), |
| 76 | }, |
| 77 | }, |
| 78 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 79 | /* Lifebook B213x/B2150 */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 80 | .matches = { |
| 81 | DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B2131/B2133/B2150"), |
| 82 | }, |
| 83 | }, |
| 84 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 85 | /* Zephyr */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 86 | .matches = { |
| 87 | DMI_MATCH(DMI_PRODUCT_NAME, "ZEPHYR"), |
| 88 | }, |
| 89 | }, |
| 90 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 91 | /* Panasonic CF-18 */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 92 | .matches = { |
| 93 | DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), |
| 94 | }, |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 95 | .callback = lifebook_limit_serio3, |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 96 | }, |
| 97 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 98 | /* Panasonic CF-28 */ |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 99 | .matches = { |
| 100 | DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"), |
| 101 | DMI_MATCH(DMI_PRODUCT_NAME, "CF-28"), |
| 102 | }, |
| 103 | .callback = lifebook_set_6byte_proto, |
| 104 | }, |
| 105 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 106 | /* Panasonic CF-29 */ |
Dmitry Torokhov | 43887ba | 2007-04-25 00:39:31 -0400 | [diff] [blame] | 107 | .matches = { |
| 108 | DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"), |
| 109 | DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"), |
| 110 | }, |
| 111 | .callback = lifebook_set_6byte_proto, |
| 112 | }, |
| 113 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 114 | /* Panasonic CF-72 */ |
Dmitry Torokhov | f76f672 | 2007-09-05 00:22:17 -0400 | [diff] [blame] | 115 | .matches = { |
| 116 | DMI_MATCH(DMI_PRODUCT_NAME, "CF-72"), |
| 117 | }, |
Abner Holsinger | b1e69aa | 2009-11-16 22:12:14 -0800 | [diff] [blame] | 118 | .callback = lifebook_set_6byte_proto, |
Dmitry Torokhov | f76f672 | 2007-09-05 00:22:17 -0400 | [diff] [blame] | 119 | }, |
| 120 | { |
Dmitry Torokhov | 9961e25 | 2009-12-04 10:24:20 -0800 | [diff] [blame] | 121 | /* Lifebook B142 */ |
Andrew Morton | b1b2965 | 2006-11-02 23:27:44 -0500 | [diff] [blame] | 122 | .matches = { |
| 123 | DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook B142"), |
| 124 | }, |
| 125 | }, |
| 126 | { } |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 127 | }; |
| 128 | |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 129 | void __init lifebook_module_init(void) |
| 130 | { |
| 131 | lifebook_present = dmi_check_system(lifebook_dmi_table); |
| 132 | } |
| 133 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 134 | static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse) |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 135 | { |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 136 | struct lifebook_data *priv = psmouse->private; |
| 137 | struct input_dev *dev1 = psmouse->dev; |
Dmitry Torokhov | e6b20d8 | 2007-07-20 00:29:14 -0400 | [diff] [blame] | 138 | struct input_dev *dev2 = priv ? priv->dev2 : NULL; |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 139 | unsigned char *packet = psmouse->packet; |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 140 | bool relative_packet = packet[0] & 0x08; |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 141 | |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 142 | if (relative_packet || !lifebook_use_6byte_proto) { |
| 143 | if (psmouse->pktcnt != 3) |
| 144 | return PSMOUSE_GOOD_DATA; |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 145 | } else { |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 146 | switch (psmouse->pktcnt) { |
| 147 | case 1: |
| 148 | return (packet[0] & 0xf8) == 0x00 ? |
| 149 | PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA; |
| 150 | case 2: |
| 151 | return PSMOUSE_GOOD_DATA; |
| 152 | case 3: |
| 153 | return ((packet[2] & 0x30) << 2) == (packet[2] & 0xc0) ? |
| 154 | PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA; |
| 155 | case 4: |
| 156 | return (packet[3] & 0xf8) == 0xc0 ? |
| 157 | PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA; |
| 158 | case 5: |
| 159 | return (packet[4] & 0xc0) == (packet[2] & 0xc0) ? |
| 160 | PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA; |
| 161 | case 6: |
| 162 | if (((packet[5] & 0x30) << 2) != (packet[5] & 0xc0)) |
| 163 | return PSMOUSE_BAD_DATA; |
| 164 | if ((packet[5] & 0xc0) != (packet[1] & 0xc0)) |
| 165 | return PSMOUSE_BAD_DATA; |
| 166 | break; /* report data */ |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | if (relative_packet) { |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 171 | if (!dev2) |
| 172 | printk(KERN_WARNING "lifebook.c: got relative packet " |
| 173 | "but no relative device set up\n"); |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 174 | } else { |
Dmitry Torokhov | 9b771ac | 2009-05-08 18:30:32 -0700 | [diff] [blame] | 175 | if (lifebook_use_6byte_proto) { |
| 176 | input_report_abs(dev1, ABS_X, |
| 177 | ((packet[1] & 0x3f) << 6) | (packet[2] & 0x3f)); |
| 178 | input_report_abs(dev1, ABS_Y, |
| 179 | 4096 - (((packet[4] & 0x3f) << 6) | (packet[5] & 0x3f))); |
| 180 | } else { |
| 181 | input_report_abs(dev1, ABS_X, |
| 182 | (packet[1] | ((packet[0] & 0x30) << 4))); |
| 183 | input_report_abs(dev1, ABS_Y, |
| 184 | 1024 - (packet[2] | ((packet[0] & 0xC0) << 2))); |
| 185 | } |
| 186 | input_report_key(dev1, BTN_TOUCH, packet[0] & 0x04); |
| 187 | input_sync(dev1); |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 188 | } |
| 189 | |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 190 | if (dev2) { |
| 191 | if (relative_packet) { |
| 192 | input_report_rel(dev2, REL_X, |
| 193 | ((packet[0] & 0x10) ? packet[1] - 256 : packet[1])); |
| 194 | input_report_rel(dev2, REL_Y, |
| 195 | -(int)((packet[0] & 0x20) ? packet[2] - 256 : packet[2])); |
| 196 | } |
| 197 | input_report_key(dev2, BTN_LEFT, packet[0] & 0x01); |
| 198 | input_report_key(dev2, BTN_RIGHT, packet[0] & 0x02); |
| 199 | input_sync(dev2); |
| 200 | } |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 201 | |
| 202 | return PSMOUSE_FULL_PACKET; |
| 203 | } |
| 204 | |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 205 | static int lifebook_absolute_mode(struct psmouse *psmouse) |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 206 | { |
| 207 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 208 | unsigned char param; |
| 209 | |
Dmitry Torokhov | 14e9414 | 2005-05-29 02:30:28 -0500 | [diff] [blame] | 210 | if (psmouse_reset(psmouse)) |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 211 | return -1; |
| 212 | |
Dmitry Torokhov | 14e9414 | 2005-05-29 02:30:28 -0500 | [diff] [blame] | 213 | /* |
Dmitry Torokhov | 0cc1770 | 2009-11-16 22:12:21 -0800 | [diff] [blame] | 214 | * Enable absolute output -- ps2_command fails always but if |
| 215 | * you leave this call out the touchsreen will never send |
| 216 | * absolute coordinates |
| 217 | */ |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 218 | param = lifebook_use_6byte_proto ? 0x08 : 0x07; |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 219 | ps2_command(ps2dev, ¶m, PSMOUSE_CMD_SETRES); |
| 220 | |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 221 | return 0; |
| 222 | } |
| 223 | |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 224 | static void lifebook_relative_mode(struct psmouse *psmouse) |
| 225 | { |
| 226 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 227 | unsigned char param = 0x06; |
| 228 | |
| 229 | ps2_command(ps2dev, ¶m, PSMOUSE_CMD_SETRES); |
| 230 | } |
| 231 | |
Dmitry Torokhov | a913829 | 2005-05-29 02:30:37 -0500 | [diff] [blame] | 232 | static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolution) |
| 233 | { |
Helge Deller | e38de67 | 2006-09-10 21:54:39 -0400 | [diff] [blame] | 234 | static const unsigned char params[] = { 0, 1, 2, 2, 3 }; |
| 235 | unsigned char p; |
Dmitry Torokhov | a913829 | 2005-05-29 02:30:37 -0500 | [diff] [blame] | 236 | |
| 237 | if (resolution == 0 || resolution > 400) |
| 238 | resolution = 400; |
| 239 | |
Helge Deller | e38de67 | 2006-09-10 21:54:39 -0400 | [diff] [blame] | 240 | p = params[resolution / 100]; |
| 241 | ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES); |
| 242 | psmouse->resolution = 50 << p; |
Dmitry Torokhov | a913829 | 2005-05-29 02:30:37 -0500 | [diff] [blame] | 243 | } |
| 244 | |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 245 | static void lifebook_disconnect(struct psmouse *psmouse) |
| 246 | { |
Andres Salomon | 653e91d | 2008-01-17 12:01:51 -0500 | [diff] [blame] | 247 | struct lifebook_data *priv = psmouse->private; |
| 248 | |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 249 | psmouse_reset(psmouse); |
Andres Salomon | 653e91d | 2008-01-17 12:01:51 -0500 | [diff] [blame] | 250 | if (priv) { |
| 251 | input_unregister_device(priv->dev2); |
| 252 | kfree(priv); |
| 253 | } |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 254 | psmouse->private = NULL; |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 255 | } |
| 256 | |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 257 | int lifebook_detect(struct psmouse *psmouse, bool set_properties) |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 258 | { |
Dmitry Torokhov | 7705d54 | 2009-12-03 23:21:14 -0800 | [diff] [blame] | 259 | if (!lifebook_present) |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 260 | return -1; |
| 261 | |
Dmitry Torokhov | e7afcd1 | 2007-04-12 01:36:25 -0400 | [diff] [blame] | 262 | if (desired_serio_phys && |
| 263 | strcmp(psmouse->ps2dev.serio->phys, desired_serio_phys)) |
| 264 | return -1; |
| 265 | |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 266 | if (set_properties) { |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 267 | psmouse->vendor = "Fujitsu"; |
| 268 | psmouse->name = "Lifebook TouchScreen"; |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 269 | } |
| 270 | |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 271 | return 0; |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 272 | } |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 273 | |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 274 | static int lifebook_create_relative_device(struct psmouse *psmouse) |
| 275 | { |
| 276 | struct input_dev *dev2; |
| 277 | struct lifebook_data *priv; |
| 278 | int error = -ENOMEM; |
| 279 | |
| 280 | priv = kzalloc(sizeof(struct lifebook_data), GFP_KERNEL); |
| 281 | dev2 = input_allocate_device(); |
| 282 | if (!priv || !dev2) |
| 283 | goto err_out; |
| 284 | |
| 285 | priv->dev2 = dev2; |
| 286 | snprintf(priv->phys, sizeof(priv->phys), |
| 287 | "%s/input1", psmouse->ps2dev.serio->phys); |
| 288 | |
| 289 | dev2->phys = priv->phys; |
| 290 | dev2->name = "PS/2 Touchpad"; |
| 291 | dev2->id.bustype = BUS_I8042; |
| 292 | dev2->id.vendor = 0x0002; |
| 293 | dev2->id.product = PSMOUSE_LIFEBOOK; |
| 294 | dev2->id.version = 0x0000; |
| 295 | dev2->dev.parent = &psmouse->ps2dev.serio->dev; |
| 296 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 297 | dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
| 298 | dev2->relbit[BIT_WORD(REL_X)] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
Dmitry Torokhov | 0cc1770 | 2009-11-16 22:12:21 -0800 | [diff] [blame] | 299 | dev2->keybit[BIT_WORD(BTN_LEFT)] = |
| 300 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 301 | |
| 302 | error = input_register_device(priv->dev2); |
| 303 | if (error) |
| 304 | goto err_out; |
| 305 | |
| 306 | psmouse->private = priv; |
| 307 | return 0; |
| 308 | |
| 309 | err_out: |
| 310 | input_free_device(dev2); |
| 311 | kfree(priv); |
| 312 | return error; |
| 313 | } |
| 314 | |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 315 | int lifebook_init(struct psmouse *psmouse) |
| 316 | { |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 317 | struct input_dev *dev1 = psmouse->dev; |
Dmitry Torokhov | 62e729b | 2007-10-12 14:19:50 -0400 | [diff] [blame] | 318 | int max_coord = lifebook_use_6byte_proto ? 4096 : 1024; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 319 | |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 320 | if (lifebook_absolute_mode(psmouse)) |
| 321 | return -1; |
| 322 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 323 | dev1->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 324 | dev1->relbit[0] = 0; |
Dmitry Torokhov | 0cc1770 | 2009-11-16 22:12:21 -0800 | [diff] [blame] | 325 | dev1->keybit[BIT_WORD(BTN_MOUSE)] = 0; |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 326 | dev1->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 327 | input_set_abs_params(dev1, ABS_X, 0, max_coord, 0, 0); |
| 328 | input_set_abs_params(dev1, ABS_Y, 0, max_coord, 0, 0); |
| 329 | |
| 330 | if (!desired_serio_phys) { |
| 331 | if (lifebook_create_relative_device(psmouse)) { |
| 332 | lifebook_relative_mode(psmouse); |
| 333 | return -1; |
| 334 | } |
| 335 | } |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 336 | |
| 337 | psmouse->protocol_handler = lifebook_process_byte; |
Dmitry Torokhov | a913829 | 2005-05-29 02:30:37 -0500 | [diff] [blame] | 338 | psmouse->set_resolution = lifebook_set_resolution; |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 339 | psmouse->disconnect = lifebook_disconnect; |
| 340 | psmouse->reconnect = lifebook_absolute_mode; |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 341 | |
Dmitry Torokhov | 2ebdcc6 | 2007-04-25 00:39:53 -0400 | [diff] [blame] | 342 | psmouse->model = lifebook_use_6byte_proto ? 6 : 3; |
| 343 | |
Dmitry Torokhov | 1b11879 | 2007-04-12 01:36:34 -0400 | [diff] [blame] | 344 | /* |
| 345 | * Use packet size = 3 even when using 6-byte protocol because |
| 346 | * that's what POLL will return on Lifebooks (according to spec). |
| 347 | */ |
Dmitry Torokhov | a15d60f | 2005-05-29 02:30:32 -0500 | [diff] [blame] | 348 | psmouse->pktsize = 3; |
| 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |