···796 Defaults to the default architecture's huge page size797 if not specified.7980799 i8042.direct [HW] Put keyboard port into non-translated mode800 i8042.dumbkbd [HW] Pretend that controller can only read data from801 keyboard and cannot control its state
···796 Defaults to the default architecture's huge page size797 if not specified.798799+ i8042.debug [HW] Toggle i8042 debug mode800 i8042.direct [HW] Put keyboard port into non-translated mode801 i8042.dumbkbd [HW] Pretend that controller can only read data from802 keyboard and cannot control its state
···761static int __init analog_init(void)762{763 analog_parse_options();764+ return gameport_register_driver(&analog_drv);00765}766767static void __exit analog_exit(void)
+1-2
drivers/input/joystick/cobra.c
···263264static int __init cobra_init(void)265{266- gameport_register_driver(&cobra_drv);267- return 0;268}269270static void __exit cobra_exit(void)
···263264static int __init cobra_init(void)265{266+ return gameport_register_driver(&cobra_drv);0267}268269static void __exit cobra_exit(void)
+1-2
drivers/input/joystick/gf2k.c
···375376static int __init gf2k_init(void)377{378- gameport_register_driver(&gf2k_drv);379- return 0;380}381382static void __exit gf2k_exit(void)
···375376static int __init gf2k_init(void)377{378+ return gameport_register_driver(&gf2k_drv);0379}380381static void __exit gf2k_exit(void)
+1-2
drivers/input/joystick/grip.c
···426427static int __init grip_init(void)428{429- gameport_register_driver(&grip_drv);430- return 0;431}432433static void __exit grip_exit(void)
···426427static int __init grip_init(void)428{429+ return gameport_register_driver(&grip_drv);0430}431432static void __exit grip_exit(void)
+1-2
drivers/input/joystick/grip_mp.c
···689690static int __init grip_init(void)691{692- gameport_register_driver(&grip_drv);693- return 0;694}695696static void __exit grip_exit(void)
···689690static int __init grip_init(void)691{692+ return gameport_register_driver(&grip_drv);0693}694695static void __exit grip_exit(void)
+1-2
drivers/input/joystick/guillemot.c
···283284static int __init guillemot_init(void)285{286- gameport_register_driver(&guillemot_drv);287- return 0;288}289290static void __exit guillemot_exit(void)
···283284static int __init guillemot_init(void)285{286+ return gameport_register_driver(&guillemot_drv);0287}288289static void __exit guillemot_exit(void)
+1-2
drivers/input/joystick/interact.c
···317318static int __init interact_init(void)319{320- gameport_register_driver(&interact_drv);321- return 0;322}323324static void __exit interact_exit(void)
···317318static int __init interact_init(void)319{320+ return gameport_register_driver(&interact_drv);0321}322323static void __exit interact_exit(void)
+1-2
drivers/input/joystick/joydump.c
···161162static int __init joydump_init(void)163{164- gameport_register_driver(&joydump_drv);165- return 0;166}167168static void __exit joydump_exit(void)
···161162static int __init joydump_init(void)163{164+ return gameport_register_driver(&joydump_drv);0165}166167static void __exit joydump_exit(void)
+1-2
drivers/input/joystick/sidewinder.c
···818819static int __init sw_init(void)820{821- gameport_register_driver(&sw_drv);822- return 0;823}824825static void __exit sw_exit(void)
···818819static int __init sw_init(void)820{821+ return gameport_register_driver(&sw_drv);0822}823824static void __exit sw_exit(void)
+1-2
drivers/input/joystick/tmdc.c
···438439static int __init tmdc_init(void)440{441- gameport_register_driver(&tmdc_drv);442- return 0;443}444445static void __exit tmdc_exit(void)
···438439static int __init tmdc_init(void)440{441+ return gameport_register_driver(&tmdc_drv);0442}443444static void __exit tmdc_exit(void)
+10-20
drivers/input/keyboard/atkbd.c
···834}835836/*837- * Most special keys (Fn+F?) on Dell Latitudes do not generate release838 * events so we have to do it ourselves.839 */840-static void atkbd_latitude_keymap_fixup(struct atkbd *atkbd)841{842 const unsigned int forced_release_keys[] = {843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93,···1207{1208 struct input_dev *old_dev, *new_dev;1209 unsigned long value;1210- char *rest;1211 int err;1212 unsigned char old_extra, old_set;12131214 if (!atkbd->write)1215 return -EIO;12161217- value = simple_strtoul(buf, &rest, 10);1218- if (*rest || value > 1)1219 return -EINVAL;12201221 if (atkbd->extra != value) {···1262{1263 struct input_dev *old_dev, *new_dev;1264 unsigned long value;1265- char *rest;1266 int err;1267 unsigned char old_scroll;12681269- value = simple_strtoul(buf, &rest, 10);1270- if (*rest || value > 1)1271 return -EINVAL;12721273 if (atkbd->scroll != value) {···1306{1307 struct input_dev *old_dev, *new_dev;1308 unsigned long value;1309- char *rest;1310 int err;1311 unsigned char old_set, old_extra;13121313 if (!atkbd->write)1314 return -EIO;13151316- value = simple_strtoul(buf, &rest, 10);1317- if (*rest || (value != 2 && value != 3))1318 return -EINVAL;13191320 if (atkbd->set != value) {···1355{1356 struct input_dev *old_dev, *new_dev;1357 unsigned long value;1358- char *rest;1359 int err;1360 unsigned char old_softrepeat, old_softraw;13611362 if (!atkbd->write)1363 return -EIO;13641365- value = simple_strtoul(buf, &rest, 10);1366- if (*rest || value > 1)1367 return -EINVAL;13681369 if (atkbd->softrepeat != value) {···1405{1406 struct input_dev *old_dev, *new_dev;1407 unsigned long value;1408- char *rest;1409 int err;1410 unsigned char old_softraw;14111412- value = simple_strtoul(buf, &rest, 10);1413- if (*rest || value > 1)1414 return -EINVAL;14151416 if (atkbd->softraw != value) {···14511452static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {1453 {1454- .ident = "Dell Latitude series",1455 .matches = {1456 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),1457- DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"),1458 },1459 .callback = atkbd_setup_fixup,1460- .driver_data = atkbd_latitude_keymap_fixup,1461 },1462 {1463 .ident = "HP 2133",
···834}835836/*837+ * Most special keys (Fn+F?) on Dell laptops do not generate release838 * events so we have to do it ourselves.839 */840+static void atkbd_dell_laptop_keymap_fixup(struct atkbd *atkbd)841{842 const unsigned int forced_release_keys[] = {843 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93,···1207{1208 struct input_dev *old_dev, *new_dev;1209 unsigned long value;01210 int err;1211 unsigned char old_extra, old_set;12121213 if (!atkbd->write)1214 return -EIO;12151216+ if (strict_strtoul(buf, 10, &value) || value > 1)01217 return -EINVAL;12181219 if (atkbd->extra != value) {···1264{1265 struct input_dev *old_dev, *new_dev;1266 unsigned long value;01267 int err;1268 unsigned char old_scroll;12691270+ if (strict_strtoul(buf, 10, &value) || value > 1)01271 return -EINVAL;12721273 if (atkbd->scroll != value) {···1310{1311 struct input_dev *old_dev, *new_dev;1312 unsigned long value;01313 int err;1314 unsigned char old_set, old_extra;13151316 if (!atkbd->write)1317 return -EIO;13181319+ if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))01320 return -EINVAL;13211322 if (atkbd->set != value) {···1361{1362 struct input_dev *old_dev, *new_dev;1363 unsigned long value;01364 int err;1365 unsigned char old_softrepeat, old_softraw;13661367 if (!atkbd->write)1368 return -EIO;13691370+ if (strict_strtoul(buf, 10, &value) || value > 1)01371 return -EINVAL;13721373 if (atkbd->softrepeat != value) {···1413{1414 struct input_dev *old_dev, *new_dev;1415 unsigned long value;01416 int err;1417 unsigned char old_softraw;14181419+ if (strict_strtoul(buf, 10, &value) || value > 1)01420 return -EINVAL;14211422 if (atkbd->softraw != value) {···14611462static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {1463 {1464+ .ident = "Dell Laptop",1465 .matches = {1466 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),1467+ DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */1468 },1469 .callback = atkbd_setup_fixup,1470+ .driver_data = atkbd_dell_laptop_keymap_fixup,1471 },1472 {1473 .ident = "HP 2133",
+12-1
drivers/input/keyboard/bf54x-keys.c
···8 *9 *10 * Modified:11- * Copyright 2007 Analog Devices Inc.12 *13 * Bugs: Enter bugs at http://blackfin.uclinux.org/14 *···81 unsigned short *keycode;82 struct timer_list timer;83 unsigned int keyup_test_jiffies;00084};8586static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad,···363{364 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);3650000366 if (device_may_wakeup(&pdev->dev))367 enable_irq_wake(bf54x_kpad->irq);368···376static int bfin_kpad_resume(struct platform_device *pdev)377{378 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);0000379380 if (device_may_wakeup(&pdev->dev))381 disable_irq_wake(bf54x_kpad->irq);
···8 *9 *10 * Modified:11+ * Copyright 2007-2008 Analog Devices Inc.12 *13 * Bugs: Enter bugs at http://blackfin.uclinux.org/14 *···81 unsigned short *keycode;82 struct timer_list timer;83 unsigned int keyup_test_jiffies;84+ unsigned short kpad_msel;85+ unsigned short kpad_prescale;86+ unsigned short kpad_ctl;87};8889static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad,···360{361 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);362363+ bf54x_kpad->kpad_msel = bfin_read_KPAD_MSEL();364+ bf54x_kpad->kpad_prescale = bfin_read_KPAD_PRESCALE();365+ bf54x_kpad->kpad_ctl = bfin_read_KPAD_CTL();366+367 if (device_may_wakeup(&pdev->dev))368 enable_irq_wake(bf54x_kpad->irq);369···369static int bfin_kpad_resume(struct platform_device *pdev)370{371 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);372+373+ bfin_write_KPAD_MSEL(bf54x_kpad->kpad_msel);374+ bfin_write_KPAD_PRESCALE(bf54x_kpad->kpad_prescale);375+ bfin_write_KPAD_CTL(bf54x_kpad->kpad_ctl);376377 if (device_may_wakeup(&pdev->dev))378 disable_irq_wake(bf54x_kpad->irq);
+16-26
drivers/input/keyboard/gpio_keys.c
···36 struct gpio_button_data data[0];37};3839-static void gpio_keys_report_event(struct gpio_keys_button *button,40- struct input_dev *input)41{0042 unsigned int type = button->type ?: EV_KEY;43 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;44···51{52 struct gpio_button_data *data = (struct gpio_button_data *)_data;5354- gpio_keys_report_event(data->button, data->input);55}5657static irqreturn_t gpio_keys_isr(int irq, void *dev_id)58{59- struct platform_device *pdev = dev_id;60- struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;61- struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);62- int i;6364- for (i = 0; i < pdata->nbuttons; i++) {65- struct gpio_keys_button *button = &pdata->buttons[i];6667- if (irq == gpio_to_irq(button->gpio)) {68- struct gpio_button_data *bdata = &ddata->data[i];0006970- if (button->debounce_interval)71- mod_timer(&bdata->timer,72- jiffies +73- msecs_to_jiffies(button->debounce_interval));74- else75- gpio_keys_report_event(button, bdata->input);76-77- return IRQ_HANDLED;78- }79- }80-81- return IRQ_NONE;82}8384static int __devinit gpio_keys_probe(struct platform_device *pdev)···141 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |142 IRQF_TRIGGER_FALLING,143 button->desc ? button->desc : "gpio_keys",144- pdev);145 if (error) {146 pr_err("gpio-keys: Unable to claim irq %d; error %d\n",147 irq, error);···168169 fail2:170 while (--i >= 0) {171- free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev);172 if (pdata->buttons[i].debounce_interval)173 del_timer_sync(&ddata->data[i].timer);174 gpio_free(pdata->buttons[i].gpio);···193194 for (i = 0; i < pdata->nbuttons; i++) {195 int irq = gpio_to_irq(pdata->buttons[i].gpio);196- free_irq(irq, pdev);197 if (pdata->buttons[i].debounce_interval)198 del_timer_sync(&ddata->data[i].timer);199 gpio_free(pdata->buttons[i].gpio);
···36 struct gpio_button_data data[0];37};3839+static void gpio_keys_report_event(struct gpio_button_data *bdata)040{41+ struct gpio_keys_button *button = bdata->button;42+ struct input_dev *input = bdata->input;43 unsigned int type = button->type ?: EV_KEY;44 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;45···50{51 struct gpio_button_data *data = (struct gpio_button_data *)_data;5253+ gpio_keys_report_event(data);54}5556static irqreturn_t gpio_keys_isr(int irq, void *dev_id)57{58+ struct gpio_button_data *bdata = dev_id;59+ struct gpio_keys_button *button = bdata->button;006061+ BUG_ON(irq != gpio_to_irq(button->gpio));06263+ if (button->debounce_interval)64+ mod_timer(&bdata->timer,65+ jiffies + msecs_to_jiffies(button->debounce_interval));66+ else67+ gpio_keys_report_event(bdata);6869+ return IRQ_HANDLED;0000000000070}7172static int __devinit gpio_keys_probe(struct platform_device *pdev)···151 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |152 IRQF_TRIGGER_FALLING,153 button->desc ? button->desc : "gpio_keys",154+ bdata);155 if (error) {156 pr_err("gpio-keys: Unable to claim irq %d; error %d\n",157 irq, error);···178179 fail2:180 while (--i >= 0) {181+ free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);182 if (pdata->buttons[i].debounce_interval)183 del_timer_sync(&ddata->data[i].timer);184 gpio_free(pdata->buttons[i].gpio);···203204 for (i = 0; i < pdata->nbuttons; i++) {205 int irq = gpio_to_irq(pdata->buttons[i].gpio);206+ free_irq(irq, &ddata->data[i]);207 if (pdata->buttons[i].debounce_interval)208 del_timer_sync(&ddata->data[i].timer);209 gpio_free(pdata->buttons[i].gpio);
+13
drivers/input/misc/Kconfig
···180 To compile this driver as a module, choose M here: the module will be181 called yealink.1820000000000000183config INPUT_UINPUT184 tristate "User level driver support"185 help
···180 To compile this driver as a module, choose M here: the module will be181 called yealink.182183+config INPUT_CM109184+ tristate "C-Media CM109 USB I/O Controller"185+ depends on EXPERIMENTAL186+ depends on USB_ARCH_HAS_HCD187+ select USB188+ help189+ Say Y here if you want to enable keyboard and buzzer functions of the190+ C-Media CM109 usb phones. The audio part is enabled by the generic191+ usb sound driver, so you might want to enable that as well.192+193+ To compile this driver as a module, choose M here: the module will be194+ called cm109.195+196config INPUT_UINPUT197 tristate "User level driver support"198 help
···1/*2- * drivers/usb/input/map_to_7segment.h3- *4 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com>5 *6 * This program is free software; you can redistribute it and/or···34 * Usage:35 *36 * Register a map variable, and fill it with a character set:37- * static SEG7_DEFAULT_MAP(map_seg7);38 *39 *40 * Then use for conversion:
···1/*002 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com>3 *4 * This program is free software; you can redistribute it and/or···36 * Usage:37 *38 * Register a map variable, and fill it with a character set:39+ * static SEG7_DEFAULT_MAP(map_seg7);40 *41 *42 * Then use for conversion:
···9697 If unsure, say N.98000000000099config MOUSE_SERIAL100 tristate "Serial mouse"101 select SERIO
···9697 If unsure, say N.9899+config MOUSE_PS2_OLPC100+ bool "OLPC PS/2 mouse protocol extension"101+ depends on MOUSE_PS2 && OLPC102+ help103+ Say Y here if you have an OLPC XO-1 laptop (with built-in104+ PS/2 touchpad/tablet device). The manufacturer calls the105+ touchpad an HGPK.106+107+ If unsure, say N.108+109config MOUSE_SERIAL110 tristate "Serial mouse"111 select SERIO
···1+/*2+ * OLPC HGPK (XO-1) touchpad PS/2 mouse driver3+ *4+ * Copyright (c) 2006-2008 One Laptop Per Child5+ * Authors:6+ * Zephaniah E. Hull7+ * Andres Salomon <dilinger@debian.org>8+ *9+ * This driver is partly based on the ALPS driver, which is:10+ *11+ * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au>12+ * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>13+ * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru>14+ * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>15+ *16+ * This program is free software; you can redistribute it and/or modify17+ * it under the terms of the GNU General Public License version 2 as18+ * published by the Free Software Foundation.19+ */20+21+/*22+ * The spec from ALPS is available from23+ * <http://wiki.laptop.org/go/Touch_Pad/Tablet>. It refers to this24+ * device as HGPK (Hybrid GS, PT, and Keymatrix).25+ *26+ * The earliest versions of the device had simultaneous reporting; that27+ * was removed. After that, the device used the Advanced Mode GS/PT streaming28+ * stuff. That turned out to be too buggy to support, so we've finally29+ * switched to Mouse Mode (which utilizes only the center 1/3 of the touchpad).30+ */31+32+#define DEBUG33+#include <linux/input.h>34+#include <linux/serio.h>35+#include <linux/libps2.h>36+#include <linux/delay.h>37+#include <asm/olpc.h>38+39+#include "psmouse.h"40+#include "hgpk.h"41+42+static int tpdebug;43+module_param(tpdebug, int, 0644);44+MODULE_PARM_DESC(tpdebug, "enable debugging, dumping packets to KERN_DEBUG.");45+46+static int recalib_delta = 100;47+module_param(recalib_delta, int, 0644);48+MODULE_PARM_DESC(recalib_delta,49+ "packets containing a delta this large will cause a recalibration.");50+51+/*52+ * When the touchpad gets ultra-sensitive, one can keep their finger 1/2"53+ * above the pad and still have it send packets. This causes a jump cursor54+ * when one places their finger on the pad. We can probably detect the55+ * jump as we see a large deltas (>= 100px). In mouse mode, I've been56+ * unable to even come close to 100px deltas during normal usage, so I think57+ * this threshold is safe. If a large delta occurs, trigger a recalibration.58+ */59+static void hgpk_jumpy_hack(struct psmouse *psmouse, int x, int y)60+{61+ struct hgpk_data *priv = psmouse->private;62+63+ if (abs(x) > recalib_delta || abs(y) > recalib_delta) {64+ hgpk_err(psmouse, ">%dpx jump detected (%d,%d)\n",65+ recalib_delta, x, y);66+ /* My car gets forty rods to the hogshead and that's the67+ * way I likes it! */68+ psmouse_queue_work(psmouse, &priv->recalib_wq,69+ msecs_to_jiffies(1000));70+ }71+}72+73+/*74+ * We have no idea why this particular hardware bug occurs. The touchpad75+ * will randomly start spewing packets without anything touching the76+ * pad. This wouldn't necessarily be bad, but it's indicative of a77+ * severely miscalibrated pad; attempting to use the touchpad while it's78+ * spewing means the cursor will jump all over the place, and act "drunk".79+ *80+ * The packets that are spewed tend to all have deltas between -2 and 2, and81+ * the cursor will move around without really going very far. It will82+ * tend to end up in the same location; if we tally up the changes over83+ * 100 packets, we end up w/ a final delta of close to 0. This happens84+ * pretty regularly when the touchpad is spewing, and is pretty hard to85+ * manually trigger (at least for *my* fingers). So, it makes a perfect86+ * scheme for detecting spews.87+ */88+static void hgpk_spewing_hack(struct psmouse *psmouse,89+ int l, int r, int x, int y)90+{91+ struct hgpk_data *priv = psmouse->private;92+93+ /* ignore button press packets; many in a row could trigger94+ * a false-positive! */95+ if (l || r)96+ return;97+98+ priv->x_tally += x;99+ priv->y_tally += y;100+101+ if (++priv->count > 100) {102+ if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) {103+ hgpk_dbg(psmouse, "packet spew detected (%d,%d)\n",104+ priv->x_tally, priv->y_tally);105+ psmouse_queue_work(psmouse, &priv->recalib_wq,106+ msecs_to_jiffies(1000));107+ }108+ /* reset every 100 packets */109+ priv->count = 0;110+ priv->x_tally = 0;111+ priv->y_tally = 0;112+ }113+}114+115+/*116+ * HGPK Mouse Mode format (standard mouse format, sans middle button)117+ *118+ * byte 0: y-over x-over y-neg x-neg 1 0 swr swl119+ * byte 1: x7 x6 x5 x4 x3 x2 x1 x0120+ * byte 2: y7 y6 y5 y4 y3 y2 y1 y0121+ *122+ * swr/swl are the left/right buttons.123+ * x-neg/y-neg are the x and y delta negative bits124+ * x-over/y-over are the x and y overflow bits125+ */126+static int hgpk_validate_byte(unsigned char *packet)127+{128+ return (packet[0] & 0x0C) == 0x08;129+}130+131+static void hgpk_process_packet(struct psmouse *psmouse)132+{133+ struct input_dev *dev = psmouse->dev;134+ unsigned char *packet = psmouse->packet;135+ int x, y, left, right;136+137+ left = packet[0] & 1;138+ right = (packet[0] >> 1) & 1;139+140+ x = packet[1] - ((packet[0] << 4) & 0x100);141+ y = ((packet[0] << 3) & 0x100) - packet[2];142+143+ hgpk_jumpy_hack(psmouse, x, y);144+ hgpk_spewing_hack(psmouse, left, right, x, y);145+146+ if (tpdebug)147+ hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y);148+149+ input_report_key(dev, BTN_LEFT, left);150+ input_report_key(dev, BTN_RIGHT, right);151+152+ input_report_rel(dev, REL_X, x);153+ input_report_rel(dev, REL_Y, y);154+155+ input_sync(dev);156+}157+158+static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse)159+{160+ struct hgpk_data *priv = psmouse->private;161+162+ if (hgpk_validate_byte(psmouse->packet)) {163+ hgpk_dbg(psmouse, "%s: (%d) %02x %02x %02x\n",164+ __func__, psmouse->pktcnt, psmouse->packet[0],165+ psmouse->packet[1], psmouse->packet[2]);166+ return PSMOUSE_BAD_DATA;167+ }168+169+ if (psmouse->pktcnt >= psmouse->pktsize) {170+ hgpk_process_packet(psmouse);171+ return PSMOUSE_FULL_PACKET;172+ }173+174+ if (priv->recalib_window) {175+ if (time_before(jiffies, priv->recalib_window)) {176+ /*177+ * ugh, got a packet inside our recalibration178+ * window, schedule another recalibration.179+ */180+ hgpk_dbg(psmouse,181+ "packet inside calibration window, "182+ "queueing another recalibration\n");183+ psmouse_queue_work(psmouse, &priv->recalib_wq,184+ msecs_to_jiffies(1000));185+ }186+ priv->recalib_window = 0;187+ }188+189+ return PSMOUSE_GOOD_DATA;190+}191+192+static int hgpk_force_recalibrate(struct psmouse *psmouse)193+{194+ struct ps2dev *ps2dev = &psmouse->ps2dev;195+ struct hgpk_data *priv = psmouse->private;196+197+ /* C-series touchpads added the recalibrate command */198+ if (psmouse->model < HGPK_MODEL_C)199+ return 0;200+201+ /* we don't want to race with the irq handler, nor with resyncs */202+ psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);203+204+ /* start by resetting the device */205+ psmouse_reset(psmouse);206+207+ /* send the recalibrate request */208+ if (ps2_command(ps2dev, NULL, 0xf5) ||209+ ps2_command(ps2dev, NULL, 0xf5) ||210+ ps2_command(ps2dev, NULL, 0xe6) ||211+ ps2_command(ps2dev, NULL, 0xf5)) {212+ return -1;213+ }214+215+ /* according to ALPS, 150mS is required for recalibration */216+ msleep(150);217+218+ /* XXX: If a finger is down during this delay, recalibration will219+ * detect capacitance incorrectly. This is a hardware bug, and220+ * we don't have a good way to deal with it. The 2s window stuff221+ * (below) is our best option for now.222+ */223+224+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE))225+ return -1;226+227+ psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);228+229+ /* After we recalibrate, we shouldn't get any packets for 2s. If230+ * we do, it's likely that someone's finger was on the touchpad.231+ * If someone's finger *was* on the touchpad, it's probably232+ * miscalibrated. So, we should schedule another recalibration233+ */234+ priv->recalib_window = jiffies + msecs_to_jiffies(2000);235+236+ return 0;237+}238+239+/*240+ * This kills power to the touchpad; according to ALPS, current consumption241+ * goes down to 50uA after running this. To turn power back on, we drive242+ * MS-DAT low.243+ */244+static int hgpk_toggle_power(struct psmouse *psmouse, int enable)245+{246+ struct ps2dev *ps2dev = &psmouse->ps2dev;247+ int timeo;248+249+ /* Added on D-series touchpads */250+ if (psmouse->model < HGPK_MODEL_D)251+ return 0;252+253+ if (enable) {254+ psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);255+256+ /*257+ * Sending a byte will drive MS-DAT low; this will wake up258+ * the controller. Once we get an ACK back from it, it259+ * means we can continue with the touchpad re-init. ALPS260+ * tells us that 1s should be long enough, so set that as261+ * the upper bound.262+ */263+ for (timeo = 20; timeo > 0; timeo--) {264+ if (!ps2_sendbyte(&psmouse->ps2dev,265+ PSMOUSE_CMD_DISABLE, 20))266+ break;267+ msleep(50);268+ }269+270+ psmouse_reset(psmouse);271+272+ /* should be all set, enable the touchpad */273+ ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);274+ psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);275+276+ } else {277+ hgpk_dbg(psmouse, "Powering off touchpad.\n");278+ psmouse_set_state(psmouse, PSMOUSE_IGNORE);279+280+ if (ps2_command(ps2dev, NULL, 0xec) ||281+ ps2_command(ps2dev, NULL, 0xec) ||282+ ps2_command(ps2dev, NULL, 0xea)) {283+ return -1;284+ }285+286+ /* probably won't see an ACK, the touchpad will be off */287+ ps2_sendbyte(&psmouse->ps2dev, 0xec, 20);288+ }289+290+ return 0;291+}292+293+static int hgpk_poll(struct psmouse *psmouse)294+{295+ /* We can't poll, so always return failure. */296+ return -1;297+}298+299+static int hgpk_reconnect(struct psmouse *psmouse)300+{301+ /* During suspend/resume the ps2 rails remain powered. We don't want302+ * to do a reset because it's flush data out of buffers; however,303+ * earlier prototypes (B1) had some brokenness that required a reset. */304+ if (olpc_board_at_least(olpc_board(0xb2)))305+ if (psmouse->ps2dev.serio->dev.power.power_state.event !=306+ PM_EVENT_ON)307+ return 0;308+309+ psmouse_reset(psmouse);310+311+ return 0;312+}313+314+static ssize_t hgpk_show_powered(struct psmouse *psmouse, void *data, char *buf)315+{316+ struct hgpk_data *priv = psmouse->private;317+318+ return sprintf(buf, "%d\n", priv->powered);319+}320+321+static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data,322+ const char *buf, size_t count)323+{324+ struct hgpk_data *priv = psmouse->private;325+ unsigned long value;326+ int err;327+328+ err = strict_strtoul(buf, 10, &value);329+ if (err || value > 1)330+ return -EINVAL;331+332+ if (value != priv->powered) {333+ /*334+ * hgpk_toggle_power will deal w/ state so335+ * we're not racing w/ irq336+ */337+ err = hgpk_toggle_power(psmouse, value);338+ if (!err)339+ priv->powered = value;340+ }341+342+ return err ? err : count;343+}344+345+__PSMOUSE_DEFINE_ATTR(powered, S_IWUSR | S_IRUGO, NULL,346+ hgpk_show_powered, hgpk_set_powered, 0);347+348+static void hgpk_disconnect(struct psmouse *psmouse)349+{350+ struct hgpk_data *priv = psmouse->private;351+352+ device_remove_file(&psmouse->ps2dev.serio->dev,353+ &psmouse_attr_powered.dattr);354+ psmouse_reset(psmouse);355+ kfree(priv);356+}357+358+static void hgpk_recalib_work(struct work_struct *work)359+{360+ struct delayed_work *w = container_of(work, struct delayed_work, work);361+ struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);362+ struct psmouse *psmouse = priv->psmouse;363+364+ hgpk_dbg(psmouse, "recalibrating touchpad..\n");365+366+ if (hgpk_force_recalibrate(psmouse))367+ hgpk_err(psmouse, "recalibration failed!\n");368+}369+370+static int hgpk_register(struct psmouse *psmouse)371+{372+ struct input_dev *dev = psmouse->dev;373+ int err;374+375+ /* unset the things that psmouse-base sets which we don't have */376+ __clear_bit(BTN_MIDDLE, dev->keybit);377+378+ /* set the things we do have */379+ __set_bit(EV_KEY, dev->evbit);380+ __set_bit(EV_REL, dev->evbit);381+382+ __set_bit(REL_X, dev->relbit);383+ __set_bit(REL_Y, dev->relbit);384+385+ __set_bit(BTN_LEFT, dev->keybit);386+ __set_bit(BTN_RIGHT, dev->keybit);387+388+ /* register handlers */389+ psmouse->protocol_handler = hgpk_process_byte;390+ psmouse->poll = hgpk_poll;391+ psmouse->disconnect = hgpk_disconnect;392+ psmouse->reconnect = hgpk_reconnect;393+ psmouse->pktsize = 3;394+395+ /* Disable the idle resync. */396+ psmouse->resync_time = 0;397+ /* Reset after a lot of bad bytes. */398+ psmouse->resetafter = 1024;399+400+ err = device_create_file(&psmouse->ps2dev.serio->dev,401+ &psmouse_attr_powered.dattr);402+ if (err)403+ hgpk_err(psmouse, "Failed to create sysfs attribute\n");404+405+ return err;406+}407+408+int hgpk_init(struct psmouse *psmouse)409+{410+ struct hgpk_data *priv;411+ int err = -ENOMEM;412+413+ priv = kzalloc(sizeof(struct hgpk_data), GFP_KERNEL);414+ if (!priv)415+ goto alloc_fail;416+417+ psmouse->private = priv;418+ priv->psmouse = psmouse;419+ priv->powered = 1;420+ INIT_DELAYED_WORK(&priv->recalib_wq, hgpk_recalib_work);421+422+ err = psmouse_reset(psmouse);423+ if (err)424+ goto init_fail;425+426+ err = hgpk_register(psmouse);427+ if (err)428+ goto init_fail;429+430+ return 0;431+432+init_fail:433+ kfree(priv);434+alloc_fail:435+ return err;436+}437+438+static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)439+{440+ struct ps2dev *ps2dev = &psmouse->ps2dev;441+ unsigned char param[3];442+443+ /* E7, E7, E7, E9 gets us a 3 byte identifier */444+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||445+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||446+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||447+ ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {448+ return -EIO;449+ }450+451+ hgpk_dbg(psmouse, "ID: %02x %02x %02x", param[0], param[1], param[2]);452+453+ /* HGPK signature: 0x67, 0x00, 0x<model> */454+ if (param[0] != 0x67 || param[1] != 0x00)455+ return -ENODEV;456+457+ hgpk_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]);458+459+ return param[2];460+}461+462+int hgpk_detect(struct psmouse *psmouse, int set_properties)463+{464+ int version;465+466+ version = hgpk_get_model(psmouse);467+ if (version < 0)468+ return version;469+470+ if (set_properties) {471+ psmouse->vendor = "ALPS";472+ psmouse->name = "HGPK";473+ psmouse->model = version;474+ }475+476+ return 0;477+}
···577#define KEY_BRL_DOT9 0x1f9578#define KEY_BRL_DOT10 0x1fa5790000000000000580/* We avoid low common keys in module aliases so they don't get huge. */581#define KEY_MIN_INTERESTING KEY_MUTE582-#define KEY_MAX 0x1ff583#define KEY_CNT (KEY_MAX+1)584585/*
···577#define KEY_BRL_DOT9 0x1f9578#define KEY_BRL_DOT10 0x1fa579580+#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */581+#define KEY_NUMERIC_1 0x201 /* and other keypads */582+#define KEY_NUMERIC_2 0x202583+#define KEY_NUMERIC_3 0x203584+#define KEY_NUMERIC_4 0x204585+#define KEY_NUMERIC_5 0x205586+#define KEY_NUMERIC_6 0x206587+#define KEY_NUMERIC_7 0x207588+#define KEY_NUMERIC_8 0x208589+#define KEY_NUMERIC_9 0x209590+#define KEY_NUMERIC_STAR 0x20a591+#define KEY_NUMERIC_POUND 0x20b592+593/* We avoid low common keys in module aliases so they don't get huge. */594#define KEY_MIN_INTERESTING KEY_MUTE595+#define KEY_MAX 0x2ff596#define KEY_CNT (KEY_MAX+1)597598/*
···43 u16 debounce_tol; /* tolerance used for filtering */44 u16 debounce_rep; /* additional consecutive good readings45 * required after the first two */00046 int (*get_pendown_state)(void);47 int (*filter_init) (struct ads7846_platform_data *pdata,48 void **filter_data);
···43 u16 debounce_tol; /* tolerance used for filtering */44 u16 debounce_rep; /* additional consecutive good readings45 * required after the first two */46+ int gpio_pendown; /* the GPIO used to decide the pendown47+ * state if get_pendown_state == NULL48+ */49 int (*get_pendown_state)(void);50 int (*filter_init) (struct ads7846_platform_data *pdata,51 void **filter_data);