···94949595Note that the device never signals overflow condition.96969797+For protocol version 2 devices when the trackpoint is used, and no fingers9898+are on the touchpad, the M R L bits signal the combined status of both the9999+pointingstick and touchpad buttons.100100+97101ALPS Absolute Mode - Protocol Version 198102--------------------------------------99103···111107ALPS Absolute Mode - Protocol Version 2112108---------------------------------------113109114114- byte 0: 1 ? ? ? 1 ? ? ?110110+ byte 0: 1 ? ? ? 1 PSM PSR PSL115111 byte 1: 0 x6 x5 x4 x3 x2 x1 x0116112 byte 2: 0 x10 x9 x8 x7 ? fin ges117113 byte 3: 0 y9 y8 y7 1 M R L···119115 byte 5: 0 z6 z5 z4 z3 z2 z1 z0120116121117Protocol Version 2 DualPoint devices send standard PS/2 mouse packets for122122-the DualPoint Stick.118118+the DualPoint Stick. For non interleaved dualpoint devices the pointingstick119119+buttons get reported separately in the PSM, PSR and PSL bits.123120124121Dualpoint device -- interleaved packet format125122---------------------------------------------
···23232424/* #define DEBUG */25252626-#define pr_fmt(fmt) KBUILD_BASENAME ": " fmt2727-2826#include <linux/input.h>2927#include <linux/module.h>3028#include <linux/mutex.h>···114116115117 if (effect->type < FF_EFFECT_MIN || effect->type > FF_EFFECT_MAX ||116118 !test_bit(effect->type, dev->ffbit)) {117117- pr_debug("invalid or not supported effect type in upload\n");119119+ dev_dbg(&dev->dev, "invalid or not supported effect type in upload\n");118120 return -EINVAL;119121 }120122···122124 (effect->u.periodic.waveform < FF_WAVEFORM_MIN ||123125 effect->u.periodic.waveform > FF_WAVEFORM_MAX ||124126 !test_bit(effect->u.periodic.waveform, dev->ffbit))) {125125- pr_debug("invalid or not supported wave form in upload\n");127127+ dev_dbg(&dev->dev, "invalid or not supported wave form in upload\n");126128 return -EINVAL;127129 }128130···244246 struct ff_device *ff = dev->ff;245247 int i;246248247247- pr_debug("flushing now\n");249249+ dev_dbg(&dev->dev, "flushing now\n");248250249251 mutex_lock(&ff->mutex);250252···314316 int i;315317316318 if (!max_effects) {317317- pr_err("cannot allocate device without any effects\n");319319+ dev_err(&dev->dev, "cannot allocate device without any effects\n");318320 return -EINVAL;319321 }320322
+20-1
drivers/input/joystick/xpad.c
···3131 * - the iForce driver drivers/char/joystick/iforce.c3232 * - the skeleton-driver drivers/usb/usb-skeleton.c3333 * - Xbox 360 information http://www.free60.org/wiki/Gamepad3434+ * - Xbox One information https://github.com/quantus/xbox-one-controller-protocol3435 *3536 * Thanks to:3637 * - ITO Takayuki for providing essential xpad information on his website3738 * - Vojtech Pavlik - iforce driver / input subsystem3839 * - Greg Kroah-Hartman - usb-skeleton driver3940 * - XBOX Linux project - extra USB id's4141+ * - Pekka Pöyry (quantus) - Xbox One controller reverse engineering4042 *4143 * TODO:4244 * - fine tune axes (especially trigger axes)···830828831829 return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);832830831831+ case XTYPE_XBOXONE:832832+ xpad->odata[0] = 0x09; /* activate rumble */833833+ xpad->odata[1] = 0x08;834834+ xpad->odata[2] = 0x00;835835+ xpad->odata[3] = 0x08; /* continuous effect */836836+ xpad->odata[4] = 0x00; /* simple rumble mode */837837+ xpad->odata[5] = 0x03; /* L and R actuator only */838838+ xpad->odata[6] = 0x00; /* TODO: LT actuator */839839+ xpad->odata[7] = 0x00; /* TODO: RT actuator */840840+ xpad->odata[8] = strong / 256; /* left actuator */841841+ xpad->odata[9] = weak / 256; /* right actuator */842842+ xpad->odata[10] = 0x80; /* length of pulse */843843+ xpad->odata[11] = 0x00; /* stop period of pulse */844844+ xpad->irq_out->transfer_buffer_length = 12;845845+846846+ return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);847847+833848 default:834849 dev_dbg(&xpad->dev->dev,835850 "%s - rumble command sent to unsupported xpad type: %d\n",···860841861842static int xpad_init_ff(struct usb_xpad *xpad)862843{863863- if (xpad->xtype == XTYPE_UNKNOWN || xpad->xtype == XTYPE_XBOXONE)844844+ if (xpad->xtype == XTYPE_UNKNOWN)864845 return 0;865846866847 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
+2-2
drivers/input/keyboard/lm8333.c
···11/*22 * LM8333 keypad driver33- * Copyright (C) 2012 Wolfram Sang, Pengutronix <w.sang@pengutronix.de>33+ * Copyright (C) 2012 Wolfram Sang, Pengutronix <kernel@pengutronix.de>44 *55 * This program is free software; you can redistribute it and/or modify66 * it under the terms of the GNU General Public License as published by···231231};232232module_i2c_driver(lm8333_driver);233233234234-MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");234234+MODULE_AUTHOR("Wolfram Sang <kernel@pengutronix.de>");235235MODULE_DESCRIPTION("LM8333 keyboard driver");236236MODULE_LICENSE("GPL v2");
+12
drivers/input/mouse/Kconfig
···149149150150 If unsure, say Y.151151152152+config MOUSE_PS2_VMMOUSE153153+ bool "Virtual mouse (vmmouse)"154154+ depends on MOUSE_PS2 && X86 && HYPERVISOR_GUEST155155+ help156156+ Say Y here if you are running under control of VMware hypervisor157157+ (ESXi, Workstation or Fusion). Also make sure that when you enable158158+ this option, you remove the xf86-input-vmmouse user-space driver159159+ or upgrade it to at least xf86-input-vmmouse 13.0.1, which doesn't160160+ load in the presence of an in-kernel vmmouse driver.161161+162162+ If unsure, say N.163163+152164config MOUSE_SERIAL153165 tristate "Serial mouse"154166 select SERIO
···103103 PSMOUSE_SYNAPTICS_RELATIVE,104104 PSMOUSE_CYPRESS,105105 PSMOUSE_FOCALTECH,106106+ PSMOUSE_VMMOUSE,106107 PSMOUSE_AUTO /* This one should always be last */107108};108109
+508
drivers/input/mouse/vmmouse.c
···11+/*22+ * Driver for Virtual PS/2 Mouse on VMware and QEMU hypervisors.33+ *44+ * Copyright (C) 2014, VMware, Inc. All Rights Reserved.55+ *66+ * This program is free software; you can redistribute it and/or modify it77+ * under the terms of the GNU General Public License version 2 as published by88+ * the Free Software Foundation.99+ *1010+ * Twin device code is hugely inspired by the ALPS driver.1111+ * Authors:1212+ * Dmitry Torokhov <dmitry.torokhov@gmail.com>1313+ * Thomas Hellstrom <thellstrom@vmware.com>1414+ */1515+1616+#include <linux/input.h>1717+#include <linux/serio.h>1818+#include <linux/libps2.h>1919+#include <linux/slab.h>2020+#include <linux/module.h>2121+#include <asm/hypervisor.h>2222+2323+#include "psmouse.h"2424+#include "vmmouse.h"2525+2626+#define VMMOUSE_PROTO_MAGIC 0x564D5868U2727+#define VMMOUSE_PROTO_PORT 0x56582828+2929+/*3030+ * Main commands supported by the vmmouse hypervisor port.3131+ */3232+#define VMMOUSE_PROTO_CMD_GETVERSION 103333+#define VMMOUSE_PROTO_CMD_ABSPOINTER_DATA 393434+#define VMMOUSE_PROTO_CMD_ABSPOINTER_STATUS 403535+#define VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND 413636+#define VMMOUSE_PROTO_CMD_ABSPOINTER_RESTRICT 863737+3838+/*3939+ * Subcommands for VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND4040+ */4141+#define VMMOUSE_CMD_ENABLE 0x45414552U4242+#define VMMOUSE_CMD_DISABLE 0x000000f5U4343+#define VMMOUSE_CMD_REQUEST_RELATIVE 0x4c455252U4444+#define VMMOUSE_CMD_REQUEST_ABSOLUTE 0x53424152U4545+4646+#define VMMOUSE_ERROR 0xffff0000U4747+4848+#define VMMOUSE_VERSION_ID 0x3442554aU4949+5050+#define VMMOUSE_RELATIVE_PACKET 0x00010000U5151+5252+#define VMMOUSE_LEFT_BUTTON 0x205353+#define VMMOUSE_RIGHT_BUTTON 0x105454+#define VMMOUSE_MIDDLE_BUTTON 0x085555+5656+/*5757+ * VMMouse Restrict command5858+ */5959+#define VMMOUSE_RESTRICT_ANY 0x006060+#define VMMOUSE_RESTRICT_CPL0 0x016161+#define VMMOUSE_RESTRICT_IOPL 0x026262+6363+#define VMMOUSE_MAX_X 0xFFFF6464+#define VMMOUSE_MAX_Y 0xFFFF6565+6666+#define VMMOUSE_VENDOR "VMware"6767+#define VMMOUSE_NAME "VMMouse"6868+6969+/**7070+ * struct vmmouse_data - private data structure for the vmmouse driver7171+ *7272+ * @abs_dev: "Absolute" device used to report absolute mouse movement.7373+ * @phys: Physical path for the absolute device.7474+ * @dev_name: Name attribute name for the absolute device.7575+ */7676+struct vmmouse_data {7777+ struct input_dev *abs_dev;7878+ char phys[32];7979+ char dev_name[128];8080+};8181+8282+/**8383+ * Hypervisor-specific bi-directional communication channel8484+ * implementing the vmmouse protocol. Should never execute on8585+ * bare metal hardware.8686+ */8787+#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4) \8888+({ \8989+ unsigned long __dummy1, __dummy2; \9090+ __asm__ __volatile__ ("inl %%dx" : \9191+ "=a"(out1), \9292+ "=b"(out2), \9393+ "=c"(out3), \9494+ "=d"(out4), \9595+ "=S"(__dummy1), \9696+ "=D"(__dummy2) : \9797+ "a"(VMMOUSE_PROTO_MAGIC), \9898+ "b"(in1), \9999+ "c"(VMMOUSE_PROTO_CMD_##cmd), \100100+ "d"(VMMOUSE_PROTO_PORT) : \101101+ "memory"); \102102+})103103+104104+/**105105+ * vmmouse_report_button - report button state on the correct input device106106+ *107107+ * @psmouse: Pointer to the psmouse struct108108+ * @abs_dev: The absolute input device109109+ * @rel_dev: The relative input device110110+ * @pref_dev: The preferred device for reporting111111+ * @code: Button code112112+ * @value: Button value113113+ *114114+ * Report @value and @code on @pref_dev, unless the button is already115115+ * pressed on the other device, in which case the state is reported on that116116+ * device.117117+ */118118+static void vmmouse_report_button(struct psmouse *psmouse,119119+ struct input_dev *abs_dev,120120+ struct input_dev *rel_dev,121121+ struct input_dev *pref_dev,122122+ unsigned int code, int value)123123+{124124+ if (test_bit(code, abs_dev->key))125125+ pref_dev = abs_dev;126126+ else if (test_bit(code, rel_dev->key))127127+ pref_dev = rel_dev;128128+129129+ input_report_key(pref_dev, code, value);130130+}131131+132132+/**133133+ * vmmouse_report_events - process events on the vmmouse communications channel134134+ *135135+ * @psmouse: Pointer to the psmouse struct136136+ *137137+ * This function pulls events from the vmmouse communications channel and138138+ * reports them on the correct (absolute or relative) input device. When the139139+ * communications channel is drained, or if we've processed more than 255140140+ * psmouse commands, the function returns PSMOUSE_FULL_PACKET. If there is a141141+ * host- or synchronization error, the function returns PSMOUSE_BAD_DATA in142142+ * the hope that the caller will reset the communications channel.143143+ */144144+static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse)145145+{146146+ struct input_dev *rel_dev = psmouse->dev;147147+ struct vmmouse_data *priv = psmouse->private;148148+ struct input_dev *abs_dev = priv->abs_dev;149149+ struct input_dev *pref_dev;150150+ u32 status, x, y, z;151151+ u32 dummy1, dummy2, dummy3;152152+ unsigned int queue_length;153153+ unsigned int count = 255;154154+155155+ while (count--) {156156+ /* See if we have motion data. */157157+ VMMOUSE_CMD(ABSPOINTER_STATUS, 0,158158+ status, dummy1, dummy2, dummy3);159159+ if ((status & VMMOUSE_ERROR) == VMMOUSE_ERROR) {160160+ psmouse_err(psmouse, "failed to fetch status data\n");161161+ /*162162+ * After a few attempts this will result in163163+ * reconnect.164164+ */165165+ return PSMOUSE_BAD_DATA;166166+ }167167+168168+ queue_length = status & 0xffff;169169+ if (queue_length == 0)170170+ break;171171+172172+ if (queue_length % 4) {173173+ psmouse_err(psmouse, "invalid queue length\n");174174+ return PSMOUSE_BAD_DATA;175175+ }176176+177177+ /* Now get it */178178+ VMMOUSE_CMD(ABSPOINTER_DATA, 4, status, x, y, z);179179+180180+ /*181181+ * And report what we've got. Prefer to report button182182+ * events on the same device where we report motion events.183183+ * This doesn't work well with the mouse wheel, though. See184184+ * below. Ideally we would want to report that on the185185+ * preferred device as well.186186+ */187187+ if (status & VMMOUSE_RELATIVE_PACKET) {188188+ pref_dev = rel_dev;189189+ input_report_rel(rel_dev, REL_X, (s32)x);190190+ input_report_rel(rel_dev, REL_Y, -(s32)y);191191+ } else {192192+ pref_dev = abs_dev;193193+ input_report_abs(abs_dev, ABS_X, x);194194+ input_report_abs(abs_dev, ABS_Y, y);195195+ }196196+197197+ /* Xorg seems to ignore wheel events on absolute devices */198198+ input_report_rel(rel_dev, REL_WHEEL, -(s8)((u8) z));199199+200200+ vmmouse_report_button(psmouse, abs_dev, rel_dev,201201+ pref_dev, BTN_LEFT,202202+ status & VMMOUSE_LEFT_BUTTON);203203+ vmmouse_report_button(psmouse, abs_dev, rel_dev,204204+ pref_dev, BTN_RIGHT,205205+ status & VMMOUSE_RIGHT_BUTTON);206206+ vmmouse_report_button(psmouse, abs_dev, rel_dev,207207+ pref_dev, BTN_MIDDLE,208208+ status & VMMOUSE_MIDDLE_BUTTON);209209+ input_sync(abs_dev);210210+ input_sync(rel_dev);211211+ }212212+213213+ return PSMOUSE_FULL_PACKET;214214+}215215+216216+/**217217+ * vmmouse_process_byte - process data on the ps/2 channel218218+ *219219+ * @psmouse: Pointer to the psmouse struct220220+ *221221+ * When the ps/2 channel indicates that there is vmmouse data available,222222+ * call vmmouse channel processing. Otherwise, continue to accept bytes. If223223+ * there is a synchronization or communication data error, return224224+ * PSMOUSE_BAD_DATA in the hope that the caller will reset the mouse.225225+ */226226+static psmouse_ret_t vmmouse_process_byte(struct psmouse *psmouse)227227+{228228+ unsigned char *packet = psmouse->packet;229229+230230+ switch (psmouse->pktcnt) {231231+ case 1:232232+ return (packet[0] & 0x8) == 0x8 ?233233+ PSMOUSE_GOOD_DATA : PSMOUSE_BAD_DATA;234234+235235+ case 2:236236+ return PSMOUSE_GOOD_DATA;237237+238238+ default:239239+ return vmmouse_report_events(psmouse);240240+ }241241+}242242+243243+/**244244+ * vmmouse_disable - Disable vmmouse245245+ *246246+ * @psmouse: Pointer to the psmouse struct247247+ *248248+ * Tries to disable vmmouse mode.249249+ */250250+static void vmmouse_disable(struct psmouse *psmouse)251251+{252252+ u32 status;253253+ u32 dummy1, dummy2, dummy3, dummy4;254254+255255+ VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_DISABLE,256256+ dummy1, dummy2, dummy3, dummy4);257257+258258+ VMMOUSE_CMD(ABSPOINTER_STATUS, 0,259259+ status, dummy1, dummy2, dummy3);260260+261261+ if ((status & VMMOUSE_ERROR) != VMMOUSE_ERROR)262262+ psmouse_warn(psmouse, "failed to disable vmmouse device\n");263263+}264264+265265+/**266266+ * vmmouse_enable - Enable vmmouse and request absolute mode.267267+ *268268+ * @psmouse: Pointer to the psmouse struct269269+ *270270+ * Tries to enable vmmouse mode. Performs basic checks and requests271271+ * absolute vmmouse mode.272272+ * Returns 0 on success, -ENODEV on failure.273273+ */274274+static int vmmouse_enable(struct psmouse *psmouse)275275+{276276+ u32 status, version;277277+ u32 dummy1, dummy2, dummy3, dummy4;278278+279279+ /*280280+ * Try enabling the device. If successful, we should be able to281281+ * read valid version ID back from it.282282+ */283283+ VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_ENABLE,284284+ dummy1, dummy2, dummy3, dummy4);285285+286286+ /*287287+ * See if version ID can be retrieved.288288+ */289289+ VMMOUSE_CMD(ABSPOINTER_STATUS, 0, status, dummy1, dummy2, dummy3);290290+ if ((status & 0x0000ffff) == 0) {291291+ psmouse_dbg(psmouse, "empty flags - assuming no device\n");292292+ return -ENXIO;293293+ }294294+295295+ VMMOUSE_CMD(ABSPOINTER_DATA, 1 /* single item */,296296+ version, dummy1, dummy2, dummy3);297297+ if (version != VMMOUSE_VERSION_ID) {298298+ psmouse_dbg(psmouse, "Unexpected version value: %u vs %u\n",299299+ (unsigned) version, VMMOUSE_VERSION_ID);300300+ vmmouse_disable(psmouse);301301+ return -ENXIO;302302+ }303303+304304+ /*305305+ * Restrict ioport access, if possible.306306+ */307307+ VMMOUSE_CMD(ABSPOINTER_RESTRICT, VMMOUSE_RESTRICT_CPL0,308308+ dummy1, dummy2, dummy3, dummy4);309309+310310+ VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_REQUEST_ABSOLUTE,311311+ dummy1, dummy2, dummy3, dummy4);312312+313313+ return 0;314314+}315315+316316+/*317317+ * Array of supported hypervisors.318318+ */319319+static const struct hypervisor_x86 *vmmouse_supported_hypervisors[] = {320320+ &x86_hyper_vmware,321321+#ifdef CONFIG_KVM_GUEST322322+ &x86_hyper_kvm,323323+#endif324324+};325325+326326+/**327327+ * vmmouse_check_hypervisor - Check if we're running on a supported hypervisor328328+ */329329+static bool vmmouse_check_hypervisor(void)330330+{331331+ int i;332332+333333+ for (i = 0; i < ARRAY_SIZE(vmmouse_supported_hypervisors); i++)334334+ if (vmmouse_supported_hypervisors[i] == x86_hyper)335335+ return true;336336+337337+ return false;338338+}339339+340340+/**341341+ * vmmouse_detect - Probe whether vmmouse is available342342+ *343343+ * @psmouse: Pointer to the psmouse struct344344+ * @set_properties: Whether to set psmouse name and vendor345345+ *346346+ * Returns 0 if vmmouse channel is available. Negative error code if not.347347+ */348348+int vmmouse_detect(struct psmouse *psmouse, bool set_properties)349349+{350350+ u32 response, version, dummy1, dummy2;351351+352352+ if (!vmmouse_check_hypervisor()) {353353+ psmouse_dbg(psmouse,354354+ "VMMouse not running on supported hypervisor.\n");355355+ return -ENXIO;356356+ }357357+358358+ if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {359359+ psmouse_dbg(psmouse, "VMMouse port in use.\n");360360+ return -EBUSY;361361+ }362362+363363+ /* Check if the device is present */364364+ response = ~VMMOUSE_PROTO_MAGIC;365365+ VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2);366366+ if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) {367367+ release_region(VMMOUSE_PROTO_PORT, 4);368368+ return -ENXIO;369369+ }370370+371371+ if (set_properties) {372372+ psmouse->vendor = VMMOUSE_VENDOR;373373+ psmouse->name = VMMOUSE_NAME;374374+ psmouse->model = version;375375+ }376376+377377+ release_region(VMMOUSE_PROTO_PORT, 4);378378+379379+ return 0;380380+}381381+382382+/**383383+ * vmmouse_disconnect - Take down vmmouse driver384384+ *385385+ * @psmouse: Pointer to the psmouse struct386386+ *387387+ * Takes down vmmouse driver and frees resources set up in vmmouse_init().388388+ */389389+static void vmmouse_disconnect(struct psmouse *psmouse)390390+{391391+ struct vmmouse_data *priv = psmouse->private;392392+393393+ vmmouse_disable(psmouse);394394+ psmouse_reset(psmouse);395395+ input_unregister_device(priv->abs_dev);396396+ kfree(priv);397397+ release_region(VMMOUSE_PROTO_PORT, 4);398398+}399399+400400+/**401401+ * vmmouse_reconnect - Reset the ps/2 - and vmmouse connections402402+ *403403+ * @psmouse: Pointer to the psmouse struct404404+ *405405+ * Attempts to reset the mouse connections. Returns 0 on success and406406+ * -1 on failure.407407+ */408408+static int vmmouse_reconnect(struct psmouse *psmouse)409409+{410410+ int error;411411+412412+ psmouse_reset(psmouse);413413+ vmmouse_disable(psmouse);414414+ error = vmmouse_enable(psmouse);415415+ if (error) {416416+ psmouse_err(psmouse,417417+ "Unable to re-enable mouse when reconnecting, err: %d\n",418418+ error);419419+ return error;420420+ }421421+422422+ return 0;423423+}424424+425425+/**426426+ * vmmouse_init - Initialize the vmmouse driver427427+ *428428+ * @psmouse: Pointer to the psmouse struct429429+ *430430+ * Requests the device and tries to enable vmmouse mode.431431+ * If successful, sets up the input device for relative movement events.432432+ * It also allocates another input device and sets it up for absolute motion433433+ * events. Returns 0 on success and -1 on failure.434434+ */435435+int vmmouse_init(struct psmouse *psmouse)436436+{437437+ struct vmmouse_data *priv;438438+ struct input_dev *rel_dev = psmouse->dev, *abs_dev;439439+ int error;440440+441441+ if (!request_region(VMMOUSE_PROTO_PORT, 4, "vmmouse")) {442442+ psmouse_dbg(psmouse, "VMMouse port in use.\n");443443+ return -EBUSY;444444+ }445445+446446+ psmouse_reset(psmouse);447447+ error = vmmouse_enable(psmouse);448448+ if (error)449449+ goto release_region;450450+451451+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);452452+ abs_dev = input_allocate_device();453453+ if (!priv || !abs_dev) {454454+ error = -ENOMEM;455455+ goto init_fail;456456+ }457457+458458+ priv->abs_dev = abs_dev;459459+ psmouse->private = priv;460460+461461+ input_set_capability(rel_dev, EV_REL, REL_WHEEL);462462+463463+ /* Set up and register absolute device */464464+ snprintf(priv->phys, sizeof(priv->phys), "%s/input1",465465+ psmouse->ps2dev.serio->phys);466466+467467+ /* Mimic name setup for relative device in psmouse-base.c */468468+ snprintf(priv->dev_name, sizeof(priv->dev_name), "%s %s %s",469469+ VMMOUSE_PSNAME, VMMOUSE_VENDOR, VMMOUSE_NAME);470470+ abs_dev->phys = priv->phys;471471+ abs_dev->name = priv->dev_name;472472+ abs_dev->id.bustype = BUS_I8042;473473+ abs_dev->id.vendor = 0x0002;474474+ abs_dev->id.product = PSMOUSE_VMMOUSE;475475+ abs_dev->id.version = psmouse->model;476476+ abs_dev->dev.parent = &psmouse->ps2dev.serio->dev;477477+478478+ error = input_register_device(priv->abs_dev);479479+ if (error)480480+ goto init_fail;481481+482482+ /* Set absolute device capabilities */483483+ input_set_capability(abs_dev, EV_KEY, BTN_LEFT);484484+ input_set_capability(abs_dev, EV_KEY, BTN_RIGHT);485485+ input_set_capability(abs_dev, EV_KEY, BTN_MIDDLE);486486+ input_set_capability(abs_dev, EV_ABS, ABS_X);487487+ input_set_capability(abs_dev, EV_ABS, ABS_Y);488488+ input_set_abs_params(abs_dev, ABS_X, 0, VMMOUSE_MAX_X, 0, 0);489489+ input_set_abs_params(abs_dev, ABS_Y, 0, VMMOUSE_MAX_Y, 0, 0);490490+491491+ psmouse->protocol_handler = vmmouse_process_byte;492492+ psmouse->disconnect = vmmouse_disconnect;493493+ psmouse->reconnect = vmmouse_reconnect;494494+495495+ return 0;496496+497497+init_fail:498498+ vmmouse_disable(psmouse);499499+ psmouse_reset(psmouse);500500+ input_free_device(abs_dev);501501+ kfree(priv);502502+ psmouse->private = NULL;503503+504504+release_region:505505+ release_region(VMMOUSE_PROTO_PORT, 4);506506+507507+ return error;508508+}
+30
drivers/input/mouse/vmmouse.h
···11+/*22+ * Driver for Virtual PS/2 Mouse on VMware and QEMU hypervisors.33+ *44+ * Copyright (C) 2014, VMware, Inc. All Rights Reserved.55+ *66+ * This program is free software; you can redistribute it and/or modify it77+ * under the terms of the GNU General Public License version 2 as published by88+ * the Free Software Foundation.99+ */1010+1111+#ifndef _VMMOUSE_H1212+#define _VMMOUSE_H1313+1414+#ifdef CONFIG_MOUSE_PS2_VMMOUSE1515+#define VMMOUSE_PSNAME "VirtualPS/2"1616+1717+int vmmouse_detect(struct psmouse *psmouse, bool set_properties);1818+int vmmouse_init(struct psmouse *psmouse);1919+#else2020+static inline int vmmouse_detect(struct psmouse *psmouse, bool set_properties)2121+{2222+ return -ENOSYS;2323+}2424+static inline int vmmouse_init(struct psmouse *psmouse)2525+{2626+ return -ENOSYS;2727+}2828+#endif2929+3030+#endif
+130-11
drivers/input/touchscreen/atmel_mxt_ts.c
···1414 *1515 */16161717+#include <linux/acpi.h>1818+#include <linux/dmi.h>1719#include <linux/module.h>1820#include <linux/init.h>1921#include <linux/completion.h>···23732371}2374237223752373#ifdef CONFIG_OF23762376-static struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)23742374+static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)23772375{23782376 struct mxt_platform_data *pdata;23792377 u32 *keymap;···23812379 int proplen, i, ret;2382238023832381 if (!client->dev.of_node)23842384- return ERR_PTR(-ENODEV);23822382+ return ERR_PTR(-ENOENT);2385238323862384 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);23872385 if (!pdata)···24122410 return pdata;24132411}24142412#else24152415-static struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)24132413+static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)24162414{24172417- dev_dbg(&client->dev, "No platform data specified\n");24182418- return ERR_PTR(-EINVAL);24152415+ return ERR_PTR(-ENOENT);24192416}24202417#endif24182418+24192419+#ifdef CONFIG_ACPI24202420+24212421+struct mxt_acpi_platform_data {24222422+ const char *hid;24232423+ struct mxt_platform_data pdata;24242424+};24252425+24262426+static unsigned int samus_touchpad_buttons[] = {24272427+ KEY_RESERVED,24282428+ KEY_RESERVED,24292429+ KEY_RESERVED,24302430+ BTN_LEFT24312431+};24322432+24332433+static struct mxt_acpi_platform_data samus_platform_data[] = {24342434+ {24352435+ /* Touchpad */24362436+ .hid = "ATML0000",24372437+ .pdata = {24382438+ .t19_num_keys = ARRAY_SIZE(samus_touchpad_buttons),24392439+ .t19_keymap = samus_touchpad_buttons,24402440+ },24412441+ },24422442+ {24432443+ /* Touchscreen */24442444+ .hid = "ATML0001",24452445+ },24462446+ { }24472447+};24482448+24492449+static const struct dmi_system_id mxt_dmi_table[] = {24502450+ {24512451+ /* 2015 Google Pixel */24522452+ .ident = "Chromebook Pixel 2",24532453+ .matches = {24542454+ DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),24552455+ DMI_MATCH(DMI_PRODUCT_NAME, "Samus"),24562456+ },24572457+ .driver_data = samus_platform_data,24582458+ },24592459+ { }24602460+};24612461+24622462+static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client)24632463+{24642464+ struct acpi_device *adev;24652465+ const struct dmi_system_id *system_id;24662466+ const struct mxt_acpi_platform_data *acpi_pdata;24672467+24682468+ /*24692469+ * Ignore ACPI devices representing bootloader mode.24702470+ *24712471+ * This is a bit of a hack: Google Chromebook BIOS creates ACPI24722472+ * devices for both application and bootloader modes, but we are24732473+ * interested in application mode only (if device is in bootloader24742474+ * mode we'll end up switching into application anyway). So far24752475+ * application mode addresses were all above 0x40, so we'll use it24762476+ * as a threshold.24772477+ */24782478+ if (client->addr < 0x40)24792479+ return ERR_PTR(-ENXIO);24802480+24812481+ adev = ACPI_COMPANION(&client->dev);24822482+ if (!adev)24832483+ return ERR_PTR(-ENOENT);24842484+24852485+ system_id = dmi_first_match(mxt_dmi_table);24862486+ if (!system_id)24872487+ return ERR_PTR(-ENOENT);24882488+24892489+ acpi_pdata = system_id->driver_data;24902490+ if (!acpi_pdata)24912491+ return ERR_PTR(-ENOENT);24922492+24932493+ while (acpi_pdata->hid) {24942494+ if (!strcmp(acpi_device_hid(adev), acpi_pdata->hid))24952495+ return &acpi_pdata->pdata;24962496+24972497+ acpi_pdata++;24982498+ }24992499+25002500+ return ERR_PTR(-ENOENT);25012501+}25022502+#else25032503+static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client)25042504+{25052505+ return ERR_PTR(-ENOENT);25062506+}25072507+#endif25082508+25092509+static const struct mxt_platform_data *25102510+mxt_get_platform_data(struct i2c_client *client)25112511+{25122512+ const struct mxt_platform_data *pdata;25132513+25142514+ pdata = dev_get_platdata(&client->dev);25152515+ if (pdata)25162516+ return pdata;25172517+25182518+ pdata = mxt_parse_dt(client);25192519+ if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT)25202520+ return pdata;25212521+25222522+ pdata = mxt_parse_acpi(client);25232523+ if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT)25242524+ return pdata;25252525+25262526+ dev_err(&client->dev, "No platform data specified\n");25272527+ return ERR_PTR(-EINVAL);25282528+}2421252924222530static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)24232531{···25352423 const struct mxt_platform_data *pdata;25362424 int error;2537242525382538- pdata = dev_get_platdata(&client->dev);25392539- if (!pdata) {25402540- pdata = mxt_parse_dt(client);25412541- if (IS_ERR(pdata))25422542- return PTR_ERR(pdata);25432543- }24262426+ pdata = mxt_get_platform_data(client);24272427+ if (IS_ERR(pdata))24282428+ return PTR_ERR(pdata);2544242925452430 data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL);25462431 if (!data) {···26452536};26462537MODULE_DEVICE_TABLE(of, mxt_of_match);2647253825392539+#ifdef CONFIG_ACPI25402540+static const struct acpi_device_id mxt_acpi_id[] = {25412541+ { "ATML0000", 0 }, /* Touchpad */25422542+ { "ATML0001", 0 }, /* Touchscreen */25432543+ { }25442544+};25452545+MODULE_DEVICE_TABLE(acpi, mxt_acpi_id);25462546+#endif25472547+26482548static const struct i2c_device_id mxt_id[] = {26492549 { "qt602240_ts", 0 },26502550 { "atmel_mxt_ts", 0 },···26682550 .name = "atmel_mxt_ts",26692551 .owner = THIS_MODULE,26702552 .of_match_table = of_match_ptr(mxt_of_match),25532553+ .acpi_match_table = ACPI_PTR(mxt_acpi_id),26712554 .pm = &mxt_pm_ops,26722555 },26732556 .probe = mxt_probe,
+1-1
drivers/input/touchscreen/elants_i2c.c
···699699 char *fw_name;700700 int error;701701702702- fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%4x.bin", ts->hw_version);702702+ fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%04x.bin", ts->hw_version);703703 if (!fw_name)704704 return -ENOMEM;705705