Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:
"Items of note:

- evdev users can now limit or mask the kind of events they will
receive. This will allow applications such as power manager or
network manager to only be woken when user presses special keys
such as KEY_POWER or KEY_WIFI and not be bothered with ordinary
key presses coming from keyboard

- support for FocalTech FT6236 touchscreen controller

- support for ROHM BU21023/24 touchscreen controller

- edt-ft5x06 touchscreen driver got a face lift and can now be used
with FT5506

- support for Google Fiber TV Box remote controls

- improvements in xpad driver (with more to come)

- several parport-based drivers have been switched to the new device
model

- other miscellaneous driver improvements"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (70 commits)
HID: hid-gfrm: avoid warning for input_configured API change
HID: hid-input: allow input_configured callback return errors
Input: evdev - fix bug in checking duplicate clock change request
Input: add userio module
Input: evdev - add event-mask API
Input: snvs_pwrkey - remove duplicated semicolon
HID: hid-gfrm: Google Fiber TV Box remote controls
Input: e3x0-button - update Kconfig description
Input: tegra-kbc - drop use of IRQF_NO_SUSPEND flag
Input: tegra-kbc - enable support for the standard "wakeup-source" property
Input: xen - check return value of xenbus_printf
Input: hp_sdc_rtc - fix y2038 problem in proc_show
Input: nomadik-ske-keypad - fix a trivial typo
Input: xpad - fix clash of presence handling with LED setting
Input: edt-ft5x06 - work around FT5506 firmware bug
Input: edt-ft5x06 - add support for FT5506
Input: edt-ft5x06 - add support for different max support points
Input: edt-ft5x06 - use max support points to determine how much to read
Input: rotary-encoder - add support for quarter-period mode
Input: rotary-encoder - use of_property_read_bool
...

+4545 -2281
+32
Documentation/devicetree/bindings/input/da9062-onkey.txt
··· 1 + * Dialog DA9062/63 OnKey Module 2 + 3 + This module is part of the DA9062/DA9063. For more details about entire 4 + chips see Documentation/devicetree/bindings/mfd/da9062.txt and 5 + Documentation/devicetree/bindings/mfd/da9063.txt 6 + 7 + This module provides KEY_POWER, KEY_SLEEP and events. 8 + 9 + Required properties: 10 + 11 + - compatible: should be one of: 12 + dlg,da9062-onkey 13 + dlg,da9063-onkey 14 + 15 + Optional properties: 16 + 17 + - dlg,disable-key-power : Disable power-down using a long key-press. If this 18 + entry exists the OnKey driver will remove support for the KEY_POWER key 19 + press. If this entry does not exist then by default the key-press 20 + triggered power down is enabled and the OnKey will support both KEY_POWER 21 + and KEY_SLEEP. 22 + 23 + Example: 24 + 25 + pmic0: da9062@58 { 26 + 27 + onkey { 28 + compatible = "dlg,da9063-onkey"; 29 + dlg,disable-key-power; 30 + }; 31 + 32 + };
+8 -1
Documentation/devicetree/bindings/input/gpio-keys-polled.txt
··· 13 13 14 14 - gpios: OF device-tree gpio specification. 15 15 - label: Descriptive name of the key. 16 - - linux,code: Keycode to emit. 16 + - linux,code: Key / Axis code to emit. 17 17 18 18 Optional subnode-properties: 19 19 - linux,input-type: Specify event type this button/key generates. 20 20 If not specified defaults to <1> == EV_KEY. 21 + - linux,input-value: If linux,input-type is EV_ABS or EV_REL then this 22 + value is sent for events this button generates when pressed. 23 + EV_ABS/EV_REL axis will generate an event with a value of 0 when 24 + all buttons with linux,input-type == type and linux,code == axis 25 + are released. This value is interpreted as a signed 32 bit value, 26 + e.g. to make a button generate a value of -1 use: 27 + linux,input-value = <0xffffffff>; /* -1 */ 21 28 - debounce-interval: Debouncing interval time in milliseconds. 22 29 If not specified defaults to 5. 23 30 - wakeup-source: Boolean, button can wake-up the system.
+10
Documentation/devicetree/bindings/input/rotary-encoder.txt
··· 14 14 device, hence no steps need to be passed. 15 15 - rotary-encoder,rollover: Automatic rollove when the rotary value becomes 16 16 greater than the specified steps or smaller than 0. For absolute axis only. 17 + - rotary-encoder,steps-per-period: Number of steps (stable states) per period. 18 + The values have the following meaning: 19 + 1: Full-period mode (default) 20 + 2: Half-period mode 21 + 4: Quarter-period mode 22 + - wakeup-source: Boolean, rotary encoder can wake up the system. 23 + 24 + Deprecated properties: 17 25 - rotary-encoder,half-period: Makes the driver work on half-period mode. 26 + This property is deprecated. Instead, a 'steps-per-period ' value should 27 + be used, such as "rotary-encoder,steps-per-period = <2>". 18 28 19 29 See Documentation/input/rotary-encoder.txt for more information. 20 30
+5 -3
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
··· 5 5 FT5206GE1 2.8" .. 3.8" 6 6 FT5306DE4 4.3" .. 7" 7 7 FT5406EE8 7" .. 8.9" 8 + FT5506EEG 7" .. 8.9" 8 9 9 10 The software interface is identical for all those chips, so that 10 11 currently there is no need for the driver to distinguish between the ··· 18 17 - compatible: "edt,edt-ft5206" 19 18 or: "edt,edt-ft5306" 20 19 or: "edt,edt-ft5406" 20 + or: "edt,edt-ft5506" 21 21 22 22 - reg: I2C slave address of the chip (0x38) 23 23 - interrupt-parent: a phandle pointing to the interrupt controller ··· 51 49 pinctrl-names = "default"; 52 50 pinctrl-0 = <&edt_ft5x06_pins>; 53 51 interrupt-parent = <&gpio2>; 54 - interrupts = <5 0>; 55 - reset-gpios = <&gpio2 6 1>; 56 - wake-gpios = <&gpio4 9 0>; 52 + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; 53 + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; 54 + wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>; 57 55 };
+35
Documentation/devicetree/bindings/input/touchscreen/focaltech-ft6236.txt
··· 1 + * FocalTech FT6236 I2C touchscreen controller 2 + 3 + Required properties: 4 + - compatible : "focaltech,ft6236" 5 + - reg : I2C slave address of the chip (0x38) 6 + - interrupt-parent : a phandle pointing to the interrupt controller 7 + serving the interrupt for this chip 8 + - interrupts : interrupt specification for the touch controller 9 + interrupt 10 + - reset-gpios : GPIO specification for the RSTN input 11 + - touchscreen-size-x : horizontal resolution of touchscreen (in pixels) 12 + - touchscreen-size-y : vertical resolution of touchscreen (in pixels) 13 + 14 + Optional properties: 15 + - touchscreen-fuzz-x : horizontal noise value of the absolute input 16 + device (in pixels) 17 + - touchscreen-fuzz-y : vertical noise value of the absolute input 18 + device (in pixels) 19 + - touchscreen-inverted-x : X axis is inverted (boolean) 20 + - touchscreen-inverted-y : Y axis is inverted (boolean) 21 + - touchscreen-swapped-x-y: X and Y axis are swapped (boolean) 22 + Swapping is done after inverting the axis 23 + 24 + Example: 25 + 26 + ft6x06@38 { 27 + compatible = "focaltech,ft6236"; 28 + reg = <0x38>; 29 + interrupt-parent = <&gpio>; 30 + interrupts = <23 2>; 31 + touchscreen-size-x = <320>; 32 + touchscreen-size-y = <480>; 33 + touchscreen-inverted-x; 34 + touchscreen-swapped-x-y; 35 + };
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 82 82 excito Excito 83 83 fcs Fairchild Semiconductor 84 84 firefly Firefly 85 + focaltech FocalTech Systems Co.,Ltd 85 86 fsl Freescale Semiconductor 86 87 GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc. 87 88 gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
+7 -2
Documentation/input/rotary-encoder.txt
··· 9 9 and by triggering on falling and rising edges, the turn direction can 10 10 be determined. 11 11 12 - Some encoders have both outputs low in stable states, whereas others also have 13 - a stable state with both outputs high (half-period mode). 12 + Some encoders have both outputs low in stable states, others also have 13 + a stable state with both outputs high (half-period mode) and some have 14 + a stable state in all steps (quarter-period mode). 14 15 15 16 The phase diagram of these two outputs look like this: 16 17 ··· 32 31 33 32 |<-->| 34 33 one step (half-period mode) 34 + 35 + |<>| 36 + one step (quarter-period mode) 35 37 36 38 For more information, please see 37 39 https://en.wikipedia.org/wiki/Rotary_encoder ··· 113 109 .inverted_a = 0, 114 110 .inverted_b = 0, 115 111 .half_period = false, 112 + .wakeup_source = false, 116 113 }; 117 114 118 115 static struct platform_device rotary_encoder_device = {
+70
Documentation/input/userio.txt
··· 1 + The userio Protocol 2 + (c) 2015 Stephen Chandler Paul <thatslyude@gmail.com> 3 + Sponsored by Red Hat 4 + -------------------------------------------------------------------------------- 5 + 6 + 1. Introduction 7 + ~~~~~~~~~~~~~~~ 8 + This module is intended to try to make the lives of input driver developers 9 + easier by allowing them to test various serio devices (mainly the various 10 + touchpads found on laptops) without having to have the physical device in front 11 + of them. userio accomplishes this by allowing any privileged userspace program 12 + to directly interact with the kernel's serio driver and control a virtual serio 13 + port from there. 14 + 15 + 2. Usage overview 16 + ~~~~~~~~~~~~~~~~~ 17 + In order to interact with the userio kernel module, one simply opens the 18 + /dev/userio character device in their applications. Commands are sent to the 19 + kernel module by writing to the device, and any data received from the serio 20 + driver is read as-is from the /dev/userio device. All of the structures and 21 + macros you need to interact with the device are defined in <linux/userio.h> and 22 + <linux/serio.h>. 23 + 24 + 3. Command Structure 25 + ~~~~~~~~~~~~~~~~~~~~ 26 + The struct used for sending commands to /dev/userio is as follows: 27 + 28 + struct userio_cmd { 29 + __u8 type; 30 + __u8 data; 31 + }; 32 + 33 + "type" describes the type of command that is being sent. This can be any one 34 + of the USERIO_CMD macros defined in <linux/userio.h>. "data" is the argument 35 + that goes along with the command. In the event that the command doesn't have an 36 + argument, this field can be left untouched and will be ignored by the kernel. 37 + Each command should be sent by writing the struct directly to the character 38 + device. In the event that the command you send is invalid, an error will be 39 + returned by the character device and a more descriptive error will be printed 40 + to the kernel log. Only one command can be sent at a time, any additional data 41 + written to the character device after the initial command will be ignored. 42 + To close the virtual serio port, just close /dev/userio. 43 + 44 + 4. Commands 45 + ~~~~~~~~~~~ 46 + 47 + 4.1 USERIO_CMD_REGISTER 48 + ~~~~~~~~~~~~~~~~~~~~~~~ 49 + Registers the port with the serio driver and begins transmitting data back and 50 + forth. Registration can only be performed once a port type is set with 51 + USERIO_CMD_SET_PORT_TYPE. Has no argument. 52 + 53 + 4.2 USERIO_CMD_SET_PORT_TYPE 54 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 + Sets the type of port we're emulating, where "data" is the port type being 56 + set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042 57 + would set the port type to be a normal PS/2 port. 58 + 59 + 4.3 USERIO_CMD_SEND_INTERRUPT 60 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 + Sends an interrupt through the virtual serio port to the serio driver, where 62 + "data" is the interrupt data being sent. 63 + 64 + 5. Userspace tools 65 + ~~~~~~~~~~~~~~~~~~ 66 + The userio userspace tools are able to record PS/2 devices using some of the 67 + debugging information from i8042, and play back the devices on /dev/userio. The 68 + latest version of these tools can be found at: 69 + 70 + https://github.com/Lyude/ps2emu
+6
MAINTAINERS
··· 11306 11306 F: drivers/media/v4l2-core/videobuf2-* 11307 11307 F: include/media/videobuf2-* 11308 11308 11309 + VIRTUAL SERIO DEVICE DRIVER 11310 + M: Stephen Chandler Paul <thatslyude@gmail.com> 11311 + S: Maintained 11312 + F: drivers/input/serio/userio.c 11313 + F: include/uapi/linux/userio.h 11314 + 11309 11315 VIRTIO CONSOLE DRIVER 11310 11316 M: Amit Shah <amit.shah@redhat.com> 11311 11317 L: virtualization@lists.linux-foundation.org
+1 -1
arch/arm/boot/dts/am437x-sk-evm.dts
··· 502 502 503 503 reg = <0x38>; 504 504 interrupt-parent = <&gpio0>; 505 - interrupts = <31 0>; 505 + interrupts = <31 IRQ_TYPE_EDGE_FALLING>; 506 506 507 507 reset-gpios = <&gpio1 28 GPIO_ACTIVE_LOW>; 508 508
+2 -1
arch/arm/boot/dts/imx28-tx28.dts
··· 13 13 /dts-v1/; 14 14 #include "imx28.dtsi" 15 15 #include <dt-bindings/gpio/gpio.h> 16 + #include <dt-bindings/interrupt-controller/irq.h> 16 17 17 18 / { 18 19 model = "Ka-Ro electronics TX28 module"; ··· 325 324 pinctrl-names = "default"; 326 325 pinctrl-0 = <&tx28_edt_ft5x06_pins>; 327 326 interrupt-parent = <&gpio2>; 328 - interrupts = <5 0>; 327 + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; 329 328 reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; 330 329 wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>; 331 330 };
+2 -1
arch/arm/boot/dts/imx53-tx53-x03x.dts
··· 12 12 /dts-v1/; 13 13 #include "imx53-tx53.dtsi" 14 14 #include <dt-bindings/input/input.h> 15 + #include <dt-bindings/interrupt-controller/irq.h> 15 16 #include <dt-bindings/pwm/pwm.h> 16 17 17 18 / { ··· 217 216 pinctrl-names = "default"; 218 217 pinctrl-0 = <&pinctrl_edt_ft5x06_1>; 219 218 interrupt-parent = <&gpio6>; 220 - interrupts = <15 0>; 219 + interrupts = <15 IRQ_TYPE_EDGE_FALLING>; 221 220 reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>; 222 221 wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>; 223 222 };
+2 -1
arch/arm/boot/dts/imx6qdl-tx6.dtsi
··· 11 11 12 12 #include <dt-bindings/gpio/gpio.h> 13 13 #include <dt-bindings/input/input.h> 14 + #include <dt-bindings/interrupt-controller/irq.h> 14 15 #include <dt-bindings/pwm/pwm.h> 15 16 16 17 / { ··· 273 272 pinctrl-names = "default"; 274 273 pinctrl-0 = <&pinctrl_edt_ft5x06>; 275 274 interrupt-parent = <&gpio6>; 276 - interrupts = <15 0>; 275 + interrupts = <15 IRQ_TYPE_EDGE_FALLING>; 277 276 reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>; 278 277 wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>; 279 278 linux,wakeup;
+6
drivers/hid/Kconfig
··· 257 257 ---help--- 258 258 Support for Gembird JPD-DualForce 2. 259 259 260 + config HID_GFRM 261 + tristate "Google Fiber TV Box remote control support" 262 + depends on HID 263 + ---help--- 264 + Support for Google Fiber TV Box remote controls 265 + 260 266 config HID_HOLTEK 261 267 tristate "Holtek HID devices" 262 268 depends on USB_HID
+1
drivers/hid/Makefile
··· 37 37 obj-$(CONFIG_HID_ELO) += hid-elo.o 38 38 obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 39 39 obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o 40 + obj-$(CONFIG_HID_GFRM) += hid-gfrm.o 40 41 obj-$(CONFIG_HID_GT683R) += hid-gt683r.o 41 42 obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 42 43 obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o
+3 -1
drivers/hid/hid-appleir.c
··· 256 256 return 0; 257 257 } 258 258 259 - static void appleir_input_configured(struct hid_device *hid, 259 + static int appleir_input_configured(struct hid_device *hid, 260 260 struct hid_input *hidinput) 261 261 { 262 262 struct input_dev *input_dev = hidinput->input; ··· 275 275 for (i = 0; i < ARRAY_SIZE(appleir_key_table); i++) 276 276 set_bit(appleir->keymap[i], input_dev->keybit); 277 277 clear_bit(KEY_RESERVED, input_dev->keybit); 278 + 279 + return 0; 278 280 } 279 281 280 282 static int appleir_input_mapping(struct hid_device *hid,
+3 -1
drivers/hid/hid-elo.c
··· 37 37 module_param(use_fw_quirk, bool, S_IRUGO); 38 38 MODULE_PARM_DESC(use_fw_quirk, "Do periodic pokes for broken M firmwares (default = true)"); 39 39 40 - static void elo_input_configured(struct hid_device *hdev, 40 + static int elo_input_configured(struct hid_device *hdev, 41 41 struct hid_input *hidinput) 42 42 { 43 43 struct input_dev *input = hidinput->input; ··· 45 45 set_bit(BTN_TOUCH, input->keybit); 46 46 set_bit(ABS_PRESSURE, input->absbit); 47 47 input_set_abs_params(input, ABS_PRESSURE, 0, 256, 0, 0); 48 + 49 + return 0; 48 50 } 49 51 50 52 static void elo_process_data(struct input_dev *input, const u8 *data, int size)
+159
drivers/hid/hid-gfrm.c
··· 1 + /* 2 + * HID driver for Google Fiber TV Box remote controls 3 + * 4 + * Copyright (c) 2014-2015 Google Inc. 5 + * 6 + * Author: Petri Gynther <pgynther@google.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the Free 10 + * Software Foundation; either version 2 of the License, or (at your option) 11 + * any later version. 12 + */ 13 + #include <linux/device.h> 14 + #include <linux/hid.h> 15 + #include <linux/input.h> 16 + #include <linux/module.h> 17 + 18 + #include "hid-ids.h" 19 + 20 + #define GFRM100 1 /* Google Fiber GFRM100 (Bluetooth classic) */ 21 + #define GFRM200 2 /* Google Fiber GFRM200 (Bluetooth LE) */ 22 + 23 + #define GFRM100_SEARCH_KEY_REPORT_ID 0xF7 24 + #define GFRM100_SEARCH_KEY_DOWN 0x0 25 + #define GFRM100_SEARCH_KEY_AUDIO_DATA 0x1 26 + #define GFRM100_SEARCH_KEY_UP 0x2 27 + 28 + static u8 search_key_dn[3] = {0x40, 0x21, 0x02}; 29 + static u8 search_key_up[3] = {0x40, 0x00, 0x00}; 30 + 31 + static int gfrm_input_mapping(struct hid_device *hdev, struct hid_input *hi, 32 + struct hid_field *field, struct hid_usage *usage, 33 + unsigned long **bit, int *max) 34 + { 35 + unsigned long hdev_type = (unsigned long) hid_get_drvdata(hdev); 36 + 37 + if (hdev_type == GFRM100) { 38 + if (usage->hid == (HID_UP_CONSUMER | 0x4)) { 39 + /* Consumer.0004 -> KEY_INFO */ 40 + hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_INFO); 41 + return 1; 42 + } 43 + 44 + if (usage->hid == (HID_UP_CONSUMER | 0x41)) { 45 + /* Consumer.0041 -> KEY_OK */ 46 + hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_OK); 47 + return 1; 48 + } 49 + } 50 + 51 + return 0; 52 + } 53 + 54 + static int gfrm_raw_event(struct hid_device *hdev, struct hid_report *report, 55 + u8 *data, int size) 56 + { 57 + unsigned long hdev_type = (unsigned long) hid_get_drvdata(hdev); 58 + int ret = 0; 59 + 60 + if (hdev_type != GFRM100) 61 + return 0; 62 + 63 + if (size < 2 || data[0] != GFRM100_SEARCH_KEY_REPORT_ID) 64 + return 0; 65 + 66 + /* 67 + * Convert GFRM100 Search key reports into Consumer.0221 (Key.Search) 68 + * reports. Ignore audio data. 69 + */ 70 + switch (data[1]) { 71 + case GFRM100_SEARCH_KEY_DOWN: 72 + ret = hid_report_raw_event(hdev, HID_INPUT_REPORT, search_key_dn, 73 + sizeof(search_key_dn), 1); 74 + break; 75 + 76 + case GFRM100_SEARCH_KEY_AUDIO_DATA: 77 + break; 78 + 79 + case GFRM100_SEARCH_KEY_UP: 80 + ret = hid_report_raw_event(hdev, HID_INPUT_REPORT, search_key_up, 81 + sizeof(search_key_up), 1); 82 + break; 83 + 84 + default: 85 + break; 86 + } 87 + 88 + return (ret < 0) ? ret : -1; 89 + } 90 + 91 + static int gfrm_input_configured(struct hid_device *hid, struct hid_input *hidinput) 92 + { 93 + /* 94 + * Enable software autorepeat with: 95 + * - repeat delay: 400 msec 96 + * - repeat period: 100 msec 97 + */ 98 + input_enable_softrepeat(hidinput->input, 400, 100); 99 + return 0; 100 + } 101 + 102 + static int gfrm_probe(struct hid_device *hdev, const struct hid_device_id *id) 103 + { 104 + int ret; 105 + 106 + hid_set_drvdata(hdev, (void *) id->driver_data); 107 + 108 + ret = hid_parse(hdev); 109 + if (ret) 110 + goto done; 111 + 112 + if (id->driver_data == GFRM100) { 113 + /* 114 + * GFRM100 HID Report Descriptor does not describe the Search 115 + * key reports. Thus, we need to add it manually here, so that 116 + * those reports reach gfrm_raw_event() from hid_input_report(). 117 + */ 118 + if (!hid_register_report(hdev, HID_INPUT_REPORT, 119 + GFRM100_SEARCH_KEY_REPORT_ID)) { 120 + ret = -ENOMEM; 121 + goto done; 122 + } 123 + } 124 + 125 + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 126 + done: 127 + return ret; 128 + } 129 + 130 + static void gfrm_remove(struct hid_device *hdev) 131 + { 132 + hid_hw_stop(hdev); 133 + hid_set_drvdata(hdev, NULL); 134 + } 135 + 136 + static const struct hid_device_id gfrm_devices[] = { 137 + { HID_BLUETOOTH_DEVICE(0x58, 0x2000), 138 + .driver_data = GFRM100 }, 139 + { HID_BLUETOOTH_DEVICE(0x471, 0x2210), 140 + .driver_data = GFRM200 }, 141 + { } 142 + }; 143 + MODULE_DEVICE_TABLE(hid, gfrm_devices); 144 + 145 + static struct hid_driver gfrm_driver = { 146 + .name = "gfrm", 147 + .id_table = gfrm_devices, 148 + .probe = gfrm_probe, 149 + .remove = gfrm_remove, 150 + .input_mapping = gfrm_input_mapping, 151 + .raw_event = gfrm_raw_event, 152 + .input_configured = gfrm_input_configured, 153 + }; 154 + 155 + module_hid_driver(gfrm_driver); 156 + 157 + MODULE_AUTHOR("Petri Gynther <pgynther@google.com>"); 158 + MODULE_DESCRIPTION("Google Fiber TV Box remote control driver"); 159 + MODULE_LICENSE("GPL");
+6 -4
drivers/hid/hid-input.c
··· 1510 1510 * UGCI) cram a lot of unrelated inputs into the 1511 1511 * same interface. */ 1512 1512 hidinput->report = report; 1513 - if (drv->input_configured) 1514 - drv->input_configured(hid, hidinput); 1513 + if (drv->input_configured && 1514 + drv->input_configured(hid, hidinput)) 1515 + goto out_cleanup; 1515 1516 if (input_register_device(hidinput->input)) 1516 1517 goto out_cleanup; 1517 1518 hidinput = NULL; ··· 1533 1532 } 1534 1533 1535 1534 if (hidinput) { 1536 - if (drv->input_configured) 1537 - drv->input_configured(hid, hidinput); 1535 + if (drv->input_configured && 1536 + drv->input_configured(hid, hidinput)) 1537 + goto out_cleanup; 1538 1538 if (input_register_device(hidinput->input)) 1539 1539 goto out_cleanup; 1540 1540 }
+3 -1
drivers/hid/hid-lenovo.c
··· 848 848 hid_hw_stop(hdev); 849 849 } 850 850 851 - static void lenovo_input_configured(struct hid_device *hdev, 851 + static int lenovo_input_configured(struct hid_device *hdev, 852 852 struct hid_input *hi) 853 853 { 854 854 switch (hdev->product) { ··· 863 863 } 864 864 break; 865 865 } 866 + 867 + return 0; 866 868 } 867 869 868 870
+3 -1
drivers/hid/hid-logitech-hidpp.c
··· 1160 1160 m560_populate_input(hidpp, input, origin_is_hid_core); 1161 1161 } 1162 1162 1163 - static void hidpp_input_configured(struct hid_device *hdev, 1163 + static int hidpp_input_configured(struct hid_device *hdev, 1164 1164 struct hid_input *hidinput) 1165 1165 { 1166 1166 struct hidpp_device *hidpp = hid_get_drvdata(hdev); 1167 1167 struct input_dev *input = hidinput->input; 1168 1168 1169 1169 hidpp_populate_input(hidpp, input, true); 1170 + 1171 + return 0; 1170 1172 } 1171 1173 1172 1174 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
+6 -2
drivers/hid/hid-magicmouse.c
··· 471 471 return 0; 472 472 } 473 473 474 - static void magicmouse_input_configured(struct hid_device *hdev, 474 + static int magicmouse_input_configured(struct hid_device *hdev, 475 475 struct hid_input *hi) 476 476 477 477 { 478 478 struct magicmouse_sc *msc = hid_get_drvdata(hdev); 479 + int ret; 479 480 480 - int ret = magicmouse_setup_input(msc->input, hdev); 481 + ret = magicmouse_setup_input(msc->input, hdev); 481 482 if (ret) { 482 483 hid_err(hdev, "magicmouse setup input failed (%d)\n", ret); 483 484 /* clean msc->input to notify probe() of the failure */ 484 485 msc->input = NULL; 486 + return ret; 485 487 } 488 + 489 + return 0; 486 490 } 487 491 488 492
+15 -5
drivers/hid/hid-multitouch.c
··· 725 725 mt_sync_frame(td, report->field[0]->hidinput->input); 726 726 } 727 727 728 - static void mt_touch_input_configured(struct hid_device *hdev, 728 + static int mt_touch_input_configured(struct hid_device *hdev, 729 729 struct hid_input *hi) 730 730 { 731 731 struct mt_device *td = hid_get_drvdata(hdev); 732 732 struct mt_class *cls = &td->mtclass; 733 733 struct input_dev *input = hi->input; 734 + int ret; 734 735 735 736 if (!td->maxcontacts) 736 737 td->maxcontacts = MT_DEFAULT_MAXCONTACT; ··· 753 752 if (td->is_buttonpad) 754 753 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 755 754 756 - input_mt_init_slots(input, td->maxcontacts, td->mt_flags); 755 + ret = input_mt_init_slots(input, td->maxcontacts, td->mt_flags); 756 + if (ret) 757 + return ret; 757 758 758 759 td->mt_flags = 0; 760 + return 0; 759 761 } 760 762 761 763 static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, ··· 934 930 cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE; 935 931 } 936 932 937 - static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi) 933 + static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) 938 934 { 939 935 struct mt_device *td = hid_get_drvdata(hdev); 940 936 char *name; 941 937 const char *suffix = NULL; 942 938 struct hid_field *field = hi->report->field[0]; 939 + int ret; 943 940 944 - if (hi->report->id == td->mt_report_id) 945 - mt_touch_input_configured(hdev, hi); 941 + if (hi->report->id == td->mt_report_id) { 942 + ret = mt_touch_input_configured(hdev, hi); 943 + if (ret) 944 + return ret; 945 + } 946 946 947 947 /* 948 948 * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" ··· 997 989 hi->input->name = name; 998 990 } 999 991 } 992 + 993 + return 0; 1000 994 } 1001 995 1002 996 static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
+4 -2
drivers/hid/hid-ntrig.c
··· 859 859 return 1; 860 860 } 861 861 862 - static void ntrig_input_configured(struct hid_device *hid, 862 + static int ntrig_input_configured(struct hid_device *hid, 863 863 struct hid_input *hidinput) 864 864 865 865 { 866 866 struct input_dev *input = hidinput->input; 867 867 868 868 if (hidinput->report->maxfield < 1) 869 - return; 869 + return 0; 870 870 871 871 switch (hidinput->report->field[0]->application) { 872 872 case HID_DG_PEN: ··· 890 890 "N-Trig MultiTouch"; 891 891 break; 892 892 } 893 + 894 + return 0; 893 895 } 894 896 895 897 static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
+7 -4
drivers/hid/hid-rmi.c
··· 1173 1173 return 0; 1174 1174 } 1175 1175 1176 - static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi) 1176 + static int rmi_input_configured(struct hid_device *hdev, struct hid_input *hi) 1177 1177 { 1178 1178 struct rmi_data *data = hid_get_drvdata(hdev); 1179 1179 struct input_dev *input = hi->input; ··· 1185 1185 hid_dbg(hdev, "Opening low level driver\n"); 1186 1186 ret = hid_hw_open(hdev); 1187 1187 if (ret) 1188 - return; 1188 + return ret; 1189 1189 1190 1190 if (!(data->device_flags & RMI_DEVICE)) 1191 - return; 1191 + return 0; 1192 1192 1193 1193 /* Allow incoming hid reports */ 1194 1194 hid_device_io_start(hdev); ··· 1228 1228 input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 0x0f, 0, 0); 1229 1229 input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 0x0f, 0, 0); 1230 1230 1231 - input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER); 1231 + ret = input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER); 1232 + if (ret < 0) 1233 + goto exit; 1232 1234 1233 1235 if (data->button_count) { 1234 1236 __set_bit(EV_KEY, input->evbit); ··· 1246 1244 exit: 1247 1245 hid_device_io_stop(hdev); 1248 1246 hid_hw_close(hdev); 1247 + return ret; 1249 1248 } 1250 1249 1251 1250 static int rmi_input_mapping(struct hid_device *hdev,
+10 -3
drivers/hid/hid-sony.c
··· 1360 1360 return 0; 1361 1361 } 1362 1362 1363 - static void sony_input_configured(struct hid_device *hdev, 1363 + static int sony_input_configured(struct hid_device *hdev, 1364 1364 struct hid_input *hidinput) 1365 1365 { 1366 1366 struct sony_sc *sc = hid_get_drvdata(hdev); 1367 + int ret; 1367 1368 1368 1369 /* 1369 1370 * The Dualshock 4 touchpad supports 2 touches and has a 1370 1371 * resolution of 1920x942 (44.86 dots/mm). 1371 1372 */ 1372 1373 if (sc->quirks & DUALSHOCK4_CONTROLLER) { 1373 - if (sony_register_touchpad(hidinput, 2, 1920, 942) != 0) 1374 + ret = sony_register_touchpad(hidinput, 2, 1920, 942); 1375 + if (ret) { 1374 1376 hid_err(sc->hdev, 1375 - "Unable to initialize multi-touch slots\n"); 1377 + "Unable to initialize multi-touch slots: %d\n", 1378 + ret); 1379 + return ret; 1380 + } 1376 1381 } 1382 + 1383 + return 0; 1377 1384 } 1378 1385 1379 1386 /*
+4 -2
drivers/hid/hid-uclogic.c
··· 731 731 return 0; 732 732 } 733 733 734 - static void uclogic_input_configured(struct hid_device *hdev, 734 + static int uclogic_input_configured(struct hid_device *hdev, 735 735 struct hid_input *hi) 736 736 { 737 737 char *name; ··· 741 741 742 742 /* no report associated (HID_QUIRK_MULTI_INPUT not set) */ 743 743 if (!hi->report) 744 - return; 744 + return 0; 745 745 746 746 field = hi->report->field[0]; 747 747 ··· 774 774 hi->input->name = name; 775 775 } 776 776 } 777 + 778 + return 0; 777 779 } 778 780 779 781 /**
+251 -19
drivers/input/evdev.c
··· 56 56 struct fasync_struct *fasync; 57 57 struct evdev *evdev; 58 58 struct list_head node; 59 - int clk_type; 59 + unsigned int clk_type; 60 60 bool revoked; 61 + unsigned long *evmasks[EV_CNT]; 61 62 unsigned int bufsize; 62 63 struct input_event buffer[]; 63 64 }; 65 + 66 + static size_t evdev_get_mask_cnt(unsigned int type) 67 + { 68 + static const size_t counts[EV_CNT] = { 69 + /* EV_SYN==0 is EV_CNT, _not_ SYN_CNT, see EVIOCGBIT */ 70 + [EV_SYN] = EV_CNT, 71 + [EV_KEY] = KEY_CNT, 72 + [EV_REL] = REL_CNT, 73 + [EV_ABS] = ABS_CNT, 74 + [EV_MSC] = MSC_CNT, 75 + [EV_SW] = SW_CNT, 76 + [EV_LED] = LED_CNT, 77 + [EV_SND] = SND_CNT, 78 + [EV_FF] = FF_CNT, 79 + }; 80 + 81 + return (type < EV_CNT) ? counts[type] : 0; 82 + } 83 + 84 + /* requires the buffer lock to be held */ 85 + static bool __evdev_is_filtered(struct evdev_client *client, 86 + unsigned int type, 87 + unsigned int code) 88 + { 89 + unsigned long *mask; 90 + size_t cnt; 91 + 92 + /* EV_SYN and unknown codes are never filtered */ 93 + if (type == EV_SYN || type >= EV_CNT) 94 + return false; 95 + 96 + /* first test whether the type is filtered */ 97 + mask = client->evmasks[0]; 98 + if (mask && !test_bit(type, mask)) 99 + return true; 100 + 101 + /* unknown values are never filtered */ 102 + cnt = evdev_get_mask_cnt(type); 103 + if (!cnt || code >= cnt) 104 + return false; 105 + 106 + mask = client->evmasks[type]; 107 + return mask && !test_bit(code, mask); 108 + } 64 109 65 110 /* flush queued events of type @type, caller must hold client->buffer_lock */ 66 111 static void __evdev_flush_queue(struct evdev_client *client, unsigned int type) ··· 191 146 static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid) 192 147 { 193 148 unsigned long flags; 194 - 195 - if (client->clk_type == clkid) 196 - return 0; 149 + unsigned int clk_type; 197 150 198 151 switch (clkid) { 199 152 200 153 case CLOCK_REALTIME: 201 - client->clk_type = EV_CLK_REAL; 154 + clk_type = EV_CLK_REAL; 202 155 break; 203 156 case CLOCK_MONOTONIC: 204 - client->clk_type = EV_CLK_MONO; 157 + clk_type = EV_CLK_MONO; 205 158 break; 206 159 case CLOCK_BOOTTIME: 207 - client->clk_type = EV_CLK_BOOT; 160 + clk_type = EV_CLK_BOOT; 208 161 break; 209 162 default: 210 163 return -EINVAL; 211 164 } 212 165 213 - /* 214 - * Flush pending events and queue SYN_DROPPED event, 215 - * but only if the queue is not empty. 216 - */ 217 - spin_lock_irqsave(&client->buffer_lock, flags); 166 + if (client->clk_type != clk_type) { 167 + client->clk_type = clk_type; 218 168 219 - if (client->head != client->tail) { 220 - client->packet_head = client->head = client->tail; 221 - __evdev_queue_syn_dropped(client); 169 + /* 170 + * Flush pending events and queue SYN_DROPPED event, 171 + * but only if the queue is not empty. 172 + */ 173 + spin_lock_irqsave(&client->buffer_lock, flags); 174 + 175 + if (client->head != client->tail) { 176 + client->packet_head = client->head = client->tail; 177 + __evdev_queue_syn_dropped(client); 178 + } 179 + 180 + spin_unlock_irqrestore(&client->buffer_lock, flags); 222 181 } 223 - 224 - spin_unlock_irqrestore(&client->buffer_lock, flags); 225 182 226 183 return 0; 227 184 } ··· 273 226 spin_lock(&client->buffer_lock); 274 227 275 228 for (v = vals; v != vals + count; v++) { 229 + if (__evdev_is_filtered(client, v->type, v->code)) 230 + continue; 231 + 232 + if (v->type == EV_SYN && v->code == SYN_REPORT) { 233 + /* drop empty SYN_REPORT */ 234 + if (client->packet_head == client->head) 235 + continue; 236 + 237 + wakeup = true; 238 + } 239 + 276 240 event.type = v->type; 277 241 event.code = v->code; 278 242 event.value = v->value; 279 243 __pass_event(client, &event); 280 - if (v->type == EV_SYN && v->code == SYN_REPORT) 281 - wakeup = true; 282 244 } 283 245 284 246 spin_unlock(&client->buffer_lock); ··· 466 410 { 467 411 struct evdev_client *client = file->private_data; 468 412 struct evdev *evdev = client->evdev; 413 + unsigned int i; 469 414 470 415 mutex_lock(&evdev->mutex); 471 416 evdev_ungrab(evdev, client); 472 417 mutex_unlock(&evdev->mutex); 473 418 474 419 evdev_detach_client(evdev, client); 420 + 421 + for (i = 0; i < EV_CNT; ++i) 422 + kfree(client->evmasks[i]); 475 423 476 424 kvfree(client); 477 425 ··· 687 627 688 628 return len; 689 629 } 630 + 631 + static int bits_from_user(unsigned long *bits, unsigned int maxbit, 632 + unsigned int maxlen, const void __user *p, int compat) 633 + { 634 + int len, i; 635 + 636 + if (compat) { 637 + if (maxlen % sizeof(compat_long_t)) 638 + return -EINVAL; 639 + 640 + len = BITS_TO_LONGS_COMPAT(maxbit) * sizeof(compat_long_t); 641 + if (len > maxlen) 642 + len = maxlen; 643 + 644 + for (i = 0; i < len / sizeof(compat_long_t); i++) 645 + if (copy_from_user((compat_long_t *) bits + 646 + i + 1 - ((i % 2) << 1), 647 + (compat_long_t __user *) p + i, 648 + sizeof(compat_long_t))) 649 + return -EFAULT; 650 + if (i % 2) 651 + *((compat_long_t *) bits + i - 1) = 0; 652 + 653 + } else { 654 + if (maxlen % sizeof(long)) 655 + return -EINVAL; 656 + 657 + len = BITS_TO_LONGS(maxbit) * sizeof(long); 658 + if (len > maxlen) 659 + len = maxlen; 660 + 661 + if (copy_from_user(bits, p, len)) 662 + return -EFAULT; 663 + } 664 + 665 + return len; 666 + } 667 + 690 668 #else 669 + 691 670 static int bits_to_user(unsigned long *bits, unsigned int maxbit, 692 671 unsigned int maxlen, void __user *p, int compat) 693 672 { ··· 739 640 740 641 return copy_to_user(p, bits, len) ? -EFAULT : len; 741 642 } 643 + 644 + static int bits_from_user(unsigned long *bits, unsigned int maxbit, 645 + unsigned int maxlen, const void __user *p, int compat) 646 + { 647 + size_t chunk_size = compat ? sizeof(compat_long_t) : sizeof(long); 648 + int len; 649 + 650 + if (maxlen % chunk_size) 651 + return -EINVAL; 652 + 653 + len = compat ? BITS_TO_LONGS_COMPAT(maxbit) : BITS_TO_LONGS(maxbit); 654 + len *= chunk_size; 655 + if (len > maxlen) 656 + len = maxlen; 657 + 658 + return copy_from_user(bits, p, len) ? -EFAULT : len; 659 + } 660 + 742 661 #endif /* __BIG_ENDIAN */ 743 662 744 663 #else ··· 770 653 len = maxlen; 771 654 772 655 return copy_to_user(p, bits, len) ? -EFAULT : len; 656 + } 657 + 658 + static int bits_from_user(unsigned long *bits, unsigned int maxbit, 659 + unsigned int maxlen, const void __user *p, int compat) 660 + { 661 + int len; 662 + 663 + if (maxlen % sizeof(long)) 664 + return -EINVAL; 665 + 666 + len = BITS_TO_LONGS(maxbit) * sizeof(long); 667 + if (len > maxlen) 668 + len = maxlen; 669 + 670 + return copy_from_user(bits, p, len) ? -EFAULT : len; 773 671 } 774 672 775 673 #endif /* CONFIG_COMPAT */ ··· 981 849 return 0; 982 850 } 983 851 852 + /* must be called with evdev-mutex held */ 853 + static int evdev_set_mask(struct evdev_client *client, 854 + unsigned int type, 855 + const void __user *codes, 856 + u32 codes_size, 857 + int compat) 858 + { 859 + unsigned long flags, *mask, *oldmask; 860 + size_t cnt; 861 + int error; 862 + 863 + /* we allow unknown types and 'codes_size > size' for forward-compat */ 864 + cnt = evdev_get_mask_cnt(type); 865 + if (!cnt) 866 + return 0; 867 + 868 + mask = kcalloc(sizeof(unsigned long), BITS_TO_LONGS(cnt), GFP_KERNEL); 869 + if (!mask) 870 + return -ENOMEM; 871 + 872 + error = bits_from_user(mask, cnt - 1, codes_size, codes, compat); 873 + if (error < 0) { 874 + kfree(mask); 875 + return error; 876 + } 877 + 878 + spin_lock_irqsave(&client->buffer_lock, flags); 879 + oldmask = client->evmasks[type]; 880 + client->evmasks[type] = mask; 881 + spin_unlock_irqrestore(&client->buffer_lock, flags); 882 + 883 + kfree(oldmask); 884 + 885 + return 0; 886 + } 887 + 888 + /* must be called with evdev-mutex held */ 889 + static int evdev_get_mask(struct evdev_client *client, 890 + unsigned int type, 891 + void __user *codes, 892 + u32 codes_size, 893 + int compat) 894 + { 895 + unsigned long *mask; 896 + size_t cnt, size, xfer_size; 897 + int i; 898 + int error; 899 + 900 + /* we allow unknown types and 'codes_size > size' for forward-compat */ 901 + cnt = evdev_get_mask_cnt(type); 902 + size = sizeof(unsigned long) * BITS_TO_LONGS(cnt); 903 + xfer_size = min_t(size_t, codes_size, size); 904 + 905 + if (cnt > 0) { 906 + mask = client->evmasks[type]; 907 + if (mask) { 908 + error = bits_to_user(mask, cnt - 1, 909 + xfer_size, codes, compat); 910 + if (error < 0) 911 + return error; 912 + } else { 913 + /* fake mask with all bits set */ 914 + for (i = 0; i < xfer_size; i++) 915 + if (put_user(0xffU, (u8 __user *)codes + i)) 916 + return -EFAULT; 917 + } 918 + } 919 + 920 + if (xfer_size < codes_size) 921 + if (clear_user(codes + xfer_size, codes_size - xfer_size)) 922 + return -EFAULT; 923 + 924 + return 0; 925 + } 926 + 984 927 static long evdev_do_ioctl(struct file *file, unsigned int cmd, 985 928 void __user *p, int compat_mode) 986 929 { ··· 1063 856 struct evdev *evdev = client->evdev; 1064 857 struct input_dev *dev = evdev->handle.dev; 1065 858 struct input_absinfo abs; 859 + struct input_mask mask; 1066 860 struct ff_effect effect; 1067 861 int __user *ip = (int __user *)p; 1068 862 unsigned int i, t, u, v; ··· 1124 916 return -EINVAL; 1125 917 else 1126 918 return evdev_revoke(evdev, client, file); 919 + 920 + case EVIOCGMASK: { 921 + void __user *codes_ptr; 922 + 923 + if (copy_from_user(&mask, p, sizeof(mask))) 924 + return -EFAULT; 925 + 926 + codes_ptr = (void __user *)(unsigned long)mask.codes_ptr; 927 + return evdev_get_mask(client, 928 + mask.type, codes_ptr, mask.codes_size, 929 + compat_mode); 930 + } 931 + 932 + case EVIOCSMASK: { 933 + const void __user *codes_ptr; 934 + 935 + if (copy_from_user(&mask, p, sizeof(mask))) 936 + return -EFAULT; 937 + 938 + codes_ptr = (const void __user *)(unsigned long)mask.codes_ptr; 939 + return evdev_set_mask(client, 940 + mask.type, codes_ptr, mask.codes_size, 941 + compat_mode); 942 + } 1127 943 1128 944 case EVIOCSCLOCKID: 1129 945 if (copy_from_user(&i, p, sizeof(unsigned int)))
+7 -2
drivers/input/ff-core.c
··· 273 273 274 274 switch (code) { 275 275 case FF_GAIN: 276 - if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff) 276 + if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffffU) 277 277 break; 278 278 279 279 ff->set_gain(dev, value); 280 280 break; 281 281 282 282 case FF_AUTOCENTER: 283 - if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff) 283 + if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffffU) 284 284 break; 285 285 286 286 ff->set_autocenter(dev, value); ··· 315 315 316 316 if (!max_effects) { 317 317 dev_err(&dev->dev, "cannot allocate device without any effects\n"); 318 + return -EINVAL; 319 + } 320 + 321 + if (max_effects > FF_MAX_EFFECTS) { 322 + dev_err(&dev->dev, "cannot allocate more than FF_MAX_EFFECTS effects\n"); 318 323 return -EINVAL; 319 324 } 320 325
+19 -6
drivers/input/input.c
··· 2045 2045 } 2046 2046 2047 2047 /** 2048 + * input_enable_softrepeat - enable software autorepeat 2049 + * @dev: input device 2050 + * @delay: repeat delay 2051 + * @period: repeat period 2052 + * 2053 + * Enable software autorepeat on the input device. 2054 + */ 2055 + void input_enable_softrepeat(struct input_dev *dev, int delay, int period) 2056 + { 2057 + dev->timer.data = (unsigned long) dev; 2058 + dev->timer.function = input_repeat_key; 2059 + dev->rep[REP_DELAY] = delay; 2060 + dev->rep[REP_PERIOD] = period; 2061 + } 2062 + EXPORT_SYMBOL(input_enable_softrepeat); 2063 + 2064 + /** 2048 2065 * input_register_device - register device with input core 2049 2066 * @dev: device to be registered 2050 2067 * ··· 2125 2108 * If delay and period are pre-set by the driver, then autorepeating 2126 2109 * is handled by the driver itself and we don't do it in input.c. 2127 2110 */ 2128 - if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { 2129 - dev->timer.data = (long) dev; 2130 - dev->timer.function = input_repeat_key; 2131 - dev->rep[REP_DELAY] = 250; 2132 - dev->rep[REP_PERIOD] = 33; 2133 - } 2111 + if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) 2112 + input_enable_softrepeat(dev, 250, 33); 2134 2113 2135 2114 if (!dev->getkeycode) 2136 2115 dev->getkeycode = input_default_getkeycode;
+6 -16
drivers/input/joydev.c
··· 444 444 len = min(len, sizeof(joydev->abspam)); 445 445 446 446 /* Validate the map. */ 447 - abspam = kmalloc(len, GFP_KERNEL); 448 - if (!abspam) 449 - return -ENOMEM; 450 - 451 - if (copy_from_user(abspam, argp, len)) { 452 - retval = -EFAULT; 453 - goto out; 454 - } 447 + abspam = memdup_user(argp, len); 448 + if (IS_ERR(abspam)) 449 + return PTR_ERR(abspam); 455 450 456 451 for (i = 0; i < joydev->nabs; i++) { 457 452 if (abspam[i] > ABS_MAX) { ··· 475 480 len = min(len, sizeof(joydev->keypam)); 476 481 477 482 /* Validate the map. */ 478 - keypam = kmalloc(len, GFP_KERNEL); 479 - if (!keypam) 480 - return -ENOMEM; 481 - 482 - if (copy_from_user(keypam, argp, len)) { 483 - retval = -EFAULT; 484 - goto out; 485 - } 483 + keypam = memdup_user(argp, len); 484 + if (IS_ERR(keypam)) 485 + return PTR_ERR(keypam); 486 486 487 487 for (i = 0; i < joydev->nkey; i++) { 488 488 if (keypam[i] > KEY_MAX || keypam[i] < BTN_MISC) {
+58 -55
drivers/input/joystick/db9.c
··· 48 48 }; 49 49 50 50 #define DB9_MAX_PORTS 3 51 - static struct db9_config db9_cfg[DB9_MAX_PORTS] __initdata; 51 + static struct db9_config db9_cfg[DB9_MAX_PORTS]; 52 52 53 53 module_param_array_named(dev, db9_cfg[0].args, int, &db9_cfg[0].nargs, 0); 54 54 MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)"); ··· 106 106 struct pardevice *pd; 107 107 int mode; 108 108 int used; 109 + int parportno; 109 110 struct mutex mutex; 110 111 char phys[DB9_MAX_DEVICES][32]; 111 112 }; ··· 554 553 mutex_unlock(&db9->mutex); 555 554 } 556 555 557 - static struct db9 __init *db9_probe(int parport, int mode) 556 + static void db9_attach(struct parport *pp) 558 557 { 559 558 struct db9 *db9; 560 559 const struct db9_mode_data *db9_mode; 561 - struct parport *pp; 562 560 struct pardevice *pd; 563 561 struct input_dev *input_dev; 564 - int i, j; 565 - int err; 562 + int i, j, port_idx; 563 + int mode; 564 + struct pardev_cb db9_parport_cb; 565 + 566 + for (port_idx = 0; port_idx < DB9_MAX_PORTS; port_idx++) { 567 + if (db9_cfg[port_idx].nargs == 0 || 568 + db9_cfg[port_idx].args[DB9_ARG_PARPORT] < 0) 569 + continue; 570 + 571 + if (db9_cfg[port_idx].args[DB9_ARG_PARPORT] == pp->number) 572 + break; 573 + } 574 + 575 + if (port_idx == DB9_MAX_PORTS) { 576 + pr_debug("Not using parport%d.\n", pp->number); 577 + return; 578 + } 579 + 580 + mode = db9_cfg[port_idx].args[DB9_ARG_MODE]; 566 581 567 582 if (mode < 1 || mode >= DB9_MAX_PAD || !db9_modes[mode].n_buttons) { 568 583 printk(KERN_ERR "db9.c: Bad device type %d\n", mode); 569 - err = -EINVAL; 570 - goto err_out; 584 + return; 571 585 } 572 586 573 587 db9_mode = &db9_modes[mode]; 574 588 575 - pp = parport_find_number(parport); 576 - if (!pp) { 577 - printk(KERN_ERR "db9.c: no such parport\n"); 578 - err = -ENODEV; 579 - goto err_out; 580 - } 581 - 582 589 if (db9_mode->bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) { 583 590 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); 584 - err = -EINVAL; 585 - goto err_put_pp; 591 + return; 586 592 } 587 593 588 - pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 594 + db9_parport_cb.flags = PARPORT_FLAG_EXCL; 595 + 596 + pd = parport_register_dev_model(pp, "db9", &db9_parport_cb, port_idx); 589 597 if (!pd) { 590 598 printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n"); 591 - err = -EBUSY; 592 - goto err_put_pp; 599 + return; 593 600 } 594 601 595 602 db9 = kzalloc(sizeof(struct db9), GFP_KERNEL); 596 - if (!db9) { 597 - printk(KERN_ERR "db9.c: Not enough memory\n"); 598 - err = -ENOMEM; 603 + if (!db9) 599 604 goto err_unreg_pardev; 600 - } 601 605 602 606 mutex_init(&db9->mutex); 603 607 db9->pd = pd; 604 608 db9->mode = mode; 609 + db9->parportno = pp->number; 605 610 init_timer(&db9->timer); 606 611 db9->timer.data = (long) db9; 607 612 db9->timer.function = db9_timer; ··· 617 610 db9->dev[i] = input_dev = input_allocate_device(); 618 611 if (!input_dev) { 619 612 printk(KERN_ERR "db9.c: Not enough memory for input device\n"); 620 - err = -ENOMEM; 621 613 goto err_unreg_devs; 622 614 } 623 615 ··· 645 639 input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0); 646 640 } 647 641 648 - err = input_register_device(input_dev); 649 - if (err) 642 + if (input_register_device(input_dev)) 650 643 goto err_free_dev; 651 644 } 652 645 653 - parport_put_port(pp); 654 - return db9; 646 + db9_base[port_idx] = db9; 647 + return; 655 648 656 649 err_free_dev: 657 650 input_free_device(db9->dev[i]); ··· 660 655 kfree(db9); 661 656 err_unreg_pardev: 662 657 parport_unregister_device(pd); 663 - err_put_pp: 664 - parport_put_port(pp); 665 - err_out: 666 - return ERR_PTR(err); 667 658 } 668 659 669 - static void db9_remove(struct db9 *db9) 660 + static void db9_detach(struct parport *port) 670 661 { 671 662 int i; 663 + struct db9 *db9; 664 + 665 + for (i = 0; i < DB9_MAX_PORTS; i++) { 666 + if (db9_base[i] && db9_base[i]->parportno == port->number) 667 + break; 668 + } 669 + 670 + if (i == DB9_MAX_PORTS) 671 + return; 672 + 673 + db9 = db9_base[i]; 674 + db9_base[i] = NULL; 672 675 673 676 for (i = 0; i < min(db9_modes[db9->mode].n_pads, DB9_MAX_DEVICES); i++) 674 677 input_unregister_device(db9->dev[i]); ··· 684 671 kfree(db9); 685 672 } 686 673 674 + static struct parport_driver db9_parport_driver = { 675 + .name = "db9", 676 + .match_port = db9_attach, 677 + .detach = db9_detach, 678 + .devmodel = true, 679 + }; 680 + 687 681 static int __init db9_init(void) 688 682 { 689 683 int i; 690 684 int have_dev = 0; 691 - int err = 0; 692 685 693 686 for (i = 0; i < DB9_MAX_PORTS; i++) { 694 687 if (db9_cfg[i].nargs == 0 || db9_cfg[i].args[DB9_ARG_PARPORT] < 0) ··· 702 683 703 684 if (db9_cfg[i].nargs < 2) { 704 685 printk(KERN_ERR "db9.c: Device type must be specified.\n"); 705 - err = -EINVAL; 706 - break; 707 - } 708 - 709 - db9_base[i] = db9_probe(db9_cfg[i].args[DB9_ARG_PARPORT], 710 - db9_cfg[i].args[DB9_ARG_MODE]); 711 - if (IS_ERR(db9_base[i])) { 712 - err = PTR_ERR(db9_base[i]); 713 - break; 686 + return -EINVAL; 714 687 } 715 688 716 689 have_dev = 1; 717 690 } 718 691 719 - if (err) { 720 - while (--i >= 0) 721 - if (db9_base[i]) 722 - db9_remove(db9_base[i]); 723 - return err; 724 - } 692 + if (!have_dev) 693 + return -ENODEV; 725 694 726 - return have_dev ? 0 : -ENODEV; 695 + return parport_register_driver(&db9_parport_driver); 727 696 } 728 697 729 698 static void __exit db9_exit(void) 730 699 { 731 - int i; 732 - 733 - for (i = 0; i < DB9_MAX_PORTS; i++) 734 - if (db9_base[i]) 735 - db9_remove(db9_base[i]); 700 + parport_unregister_driver(&db9_parport_driver); 736 701 } 737 702 738 703 module_init(db9_init);
+55 -48
drivers/input/joystick/gamecon.c
··· 53 53 unsigned int nargs; 54 54 }; 55 55 56 - static struct gc_config gc_cfg[GC_MAX_PORTS] __initdata; 56 + static struct gc_config gc_cfg[GC_MAX_PORTS]; 57 57 58 58 module_param_array_named(map, gc_cfg[0].args, int, &gc_cfg[0].nargs, 0); 59 59 MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)"); ··· 92 92 struct timer_list timer; 93 93 int pad_count[GC_MAX]; 94 94 int used; 95 + int parportno; 95 96 struct mutex mutex; 96 97 }; 97 98 ··· 305 304 return 0; 306 305 } 307 306 308 - static int __init gc_n64_init_ff(struct input_dev *dev, int i) 307 + static int gc_n64_init_ff(struct input_dev *dev, int i) 309 308 { 310 309 struct gc_subdev *sdev; 311 310 int err; ··· 812 811 mutex_unlock(&gc->mutex); 813 812 } 814 813 815 - static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) 814 + static int gc_setup_pad(struct gc *gc, int idx, int pad_type) 816 815 { 817 816 struct gc_pad *pad = &gc->pads[idx]; 818 817 struct input_dev *input_dev; ··· 927 926 return err; 928 927 } 929 928 930 - static struct gc __init *gc_probe(int parport, int *pads, int n_pads) 929 + static void gc_attach(struct parport *pp) 931 930 { 932 931 struct gc *gc; 933 - struct parport *pp; 934 932 struct pardevice *pd; 935 - int i; 933 + int i, port_idx; 936 934 int count = 0; 937 - int err; 935 + int *pads, n_pads; 936 + struct pardev_cb gc_parport_cb; 938 937 939 - pp = parport_find_number(parport); 940 - if (!pp) { 941 - pr_err("no such parport %d\n", parport); 942 - err = -EINVAL; 943 - goto err_out; 938 + for (port_idx = 0; port_idx < GC_MAX_PORTS; port_idx++) { 939 + if (gc_cfg[port_idx].nargs == 0 || gc_cfg[port_idx].args[0] < 0) 940 + continue; 941 + 942 + if (gc_cfg[port_idx].args[0] == pp->number) 943 + break; 944 944 } 945 945 946 - pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 946 + if (port_idx == GC_MAX_PORTS) { 947 + pr_debug("Not using parport%d.\n", pp->number); 948 + return; 949 + } 950 + pads = gc_cfg[port_idx].args + 1; 951 + n_pads = gc_cfg[port_idx].nargs - 1; 952 + 953 + gc_parport_cb.flags = PARPORT_FLAG_EXCL; 954 + 955 + pd = parport_register_dev_model(pp, "gamecon", &gc_parport_cb, 956 + port_idx); 947 957 if (!pd) { 948 958 pr_err("parport busy already - lp.o loaded?\n"); 949 - err = -EBUSY; 950 - goto err_put_pp; 959 + return; 951 960 } 952 961 953 962 gc = kzalloc(sizeof(struct gc), GFP_KERNEL); 954 963 if (!gc) { 955 964 pr_err("Not enough memory\n"); 956 - err = -ENOMEM; 957 965 goto err_unreg_pardev; 958 966 } 959 967 960 968 mutex_init(&gc->mutex); 961 969 gc->pd = pd; 970 + gc->parportno = pp->number; 962 971 setup_timer(&gc->timer, gc_timer, (long) gc); 963 972 964 973 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) { 965 974 if (!pads[i]) 966 975 continue; 967 976 968 - err = gc_setup_pad(gc, i, pads[i]); 969 - if (err) 977 + if (gc_setup_pad(gc, i, pads[i])) 970 978 goto err_unreg_devs; 971 979 972 980 count++; ··· 983 973 984 974 if (count == 0) { 985 975 pr_err("No valid devices specified\n"); 986 - err = -EINVAL; 987 976 goto err_free_gc; 988 977 } 989 978 990 - parport_put_port(pp); 991 - return gc; 979 + gc_base[port_idx] = gc; 980 + return; 992 981 993 982 err_unreg_devs: 994 983 while (--i >= 0) ··· 997 988 kfree(gc); 998 989 err_unreg_pardev: 999 990 parport_unregister_device(pd); 1000 - err_put_pp: 1001 - parport_put_port(pp); 1002 - err_out: 1003 - return ERR_PTR(err); 1004 991 } 1005 992 1006 - static void gc_remove(struct gc *gc) 993 + static void gc_detach(struct parport *port) 1007 994 { 1008 995 int i; 996 + struct gc *gc; 997 + 998 + for (i = 0; i < GC_MAX_PORTS; i++) { 999 + if (gc_base[i] && gc_base[i]->parportno == port->number) 1000 + break; 1001 + } 1002 + 1003 + if (i == GC_MAX_PORTS) 1004 + return; 1005 + 1006 + gc = gc_base[i]; 1007 + gc_base[i] = NULL; 1009 1008 1010 1009 for (i = 0; i < GC_MAX_DEVICES; i++) 1011 1010 if (gc->pads[i].dev) ··· 1022 1005 kfree(gc); 1023 1006 } 1024 1007 1008 + static struct parport_driver gc_parport_driver = { 1009 + .name = "gamecon", 1010 + .match_port = gc_attach, 1011 + .detach = gc_detach, 1012 + .devmodel = true, 1013 + }; 1014 + 1025 1015 static int __init gc_init(void) 1026 1016 { 1027 1017 int i; 1028 1018 int have_dev = 0; 1029 - int err = 0; 1030 1019 1031 1020 for (i = 0; i < GC_MAX_PORTS; i++) { 1032 1021 if (gc_cfg[i].nargs == 0 || gc_cfg[i].args[0] < 0) ··· 1040 1017 1041 1018 if (gc_cfg[i].nargs < 2) { 1042 1019 pr_err("at least one device must be specified\n"); 1043 - err = -EINVAL; 1044 - break; 1045 - } 1046 - 1047 - gc_base[i] = gc_probe(gc_cfg[i].args[0], 1048 - gc_cfg[i].args + 1, gc_cfg[i].nargs - 1); 1049 - if (IS_ERR(gc_base[i])) { 1050 - err = PTR_ERR(gc_base[i]); 1051 - break; 1020 + return -EINVAL; 1052 1021 } 1053 1022 1054 1023 have_dev = 1; 1055 1024 } 1056 1025 1057 - if (err) { 1058 - while (--i >= 0) 1059 - if (gc_base[i]) 1060 - gc_remove(gc_base[i]); 1061 - return err; 1062 - } 1026 + if (!have_dev) 1027 + return -ENODEV; 1063 1028 1064 - return have_dev ? 0 : -ENODEV; 1029 + return parport_register_driver(&gc_parport_driver); 1065 1030 } 1066 1031 1067 1032 static void __exit gc_exit(void) 1068 1033 { 1069 - int i; 1070 - 1071 - for (i = 0; i < GC_MAX_PORTS; i++) 1072 - if (gc_base[i]) 1073 - gc_remove(gc_base[i]); 1034 + parport_unregister_driver(&gc_parport_driver); 1074 1035 } 1075 1036 1076 1037 module_init(gc_init);
+54 -50
drivers/input/joystick/turbografx.c
··· 49 49 unsigned int nargs; 50 50 }; 51 51 52 - static struct tgfx_config tgfx_cfg[TGFX_MAX_PORTS] __initdata; 52 + static struct tgfx_config tgfx_cfg[TGFX_MAX_PORTS]; 53 53 54 54 module_param_array_named(map, tgfx_cfg[0].args, int, &tgfx_cfg[0].nargs, 0); 55 55 MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>"); ··· 81 81 char phys[TGFX_MAX_DEVICES][32]; 82 82 int sticks; 83 83 int used; 84 + int parportno; 84 85 struct mutex sem; 85 86 } *tgfx_base[TGFX_MAX_PORTS]; 86 87 ··· 157 156 * tgfx_probe() probes for tg gamepads. 158 157 */ 159 158 160 - static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) 159 + static void tgfx_attach(struct parport *pp) 161 160 { 162 161 struct tgfx *tgfx; 163 162 struct input_dev *input_dev; 164 - struct parport *pp; 165 163 struct pardevice *pd; 166 - int i, j; 167 - int err; 164 + int i, j, port_idx; 165 + int *n_buttons, n_devs; 166 + struct pardev_cb tgfx_parport_cb; 168 167 169 - pp = parport_find_number(parport); 170 - if (!pp) { 171 - printk(KERN_ERR "turbografx.c: no such parport\n"); 172 - err = -EINVAL; 173 - goto err_out; 168 + for (port_idx = 0; port_idx < TGFX_MAX_PORTS; port_idx++) { 169 + if (tgfx_cfg[port_idx].nargs == 0 || 170 + tgfx_cfg[port_idx].args[0] < 0) 171 + continue; 172 + if (tgfx_cfg[port_idx].args[0] == pp->number) 173 + break; 174 174 } 175 175 176 - pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 176 + if (port_idx == TGFX_MAX_PORTS) { 177 + pr_debug("Not using parport%d.\n", pp->number); 178 + return; 179 + } 180 + n_buttons = tgfx_cfg[port_idx].args + 1; 181 + n_devs = tgfx_cfg[port_idx].nargs - 1; 182 + 183 + tgfx_parport_cb.flags = PARPORT_FLAG_EXCL; 184 + 185 + pd = parport_register_dev_model(pp, "turbografx", &tgfx_parport_cb, 186 + port_idx); 177 187 if (!pd) { 178 - printk(KERN_ERR "turbografx.c: parport busy already - lp.o loaded?\n"); 179 - err = -EBUSY; 180 - goto err_put_pp; 188 + pr_err("parport busy already - lp.o loaded?\n"); 189 + return; 181 190 } 182 191 183 192 tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); 184 193 if (!tgfx) { 185 194 printk(KERN_ERR "turbografx.c: Not enough memory\n"); 186 - err = -ENOMEM; 187 195 goto err_unreg_pardev; 188 196 } 189 197 190 198 mutex_init(&tgfx->sem); 191 199 tgfx->pd = pd; 200 + tgfx->parportno = pp->number; 192 201 init_timer(&tgfx->timer); 193 202 tgfx->timer.data = (long) tgfx; 194 203 tgfx->timer.function = tgfx_timer; ··· 209 198 210 199 if (n_buttons[i] > ARRAY_SIZE(tgfx_buttons)) { 211 200 printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); 212 - err = -EINVAL; 213 201 goto err_unreg_devs; 214 202 } 215 203 216 204 tgfx->dev[i] = input_dev = input_allocate_device(); 217 205 if (!input_dev) { 218 206 printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); 219 - err = -ENOMEM; 220 207 goto err_unreg_devs; 221 208 } 222 209 ··· 243 234 for (j = 0; j < n_buttons[i]; j++) 244 235 set_bit(tgfx_buttons[j], input_dev->keybit); 245 236 246 - err = input_register_device(tgfx->dev[i]); 247 - if (err) 237 + if (input_register_device(tgfx->dev[i])) 248 238 goto err_free_dev; 249 239 } 250 240 251 241 if (!tgfx->sticks) { 252 242 printk(KERN_ERR "turbografx.c: No valid devices specified\n"); 253 - err = -EINVAL; 254 243 goto err_free_tgfx; 255 244 } 256 245 257 - parport_put_port(pp); 258 - return tgfx; 246 + tgfx_base[port_idx] = tgfx; 247 + return; 259 248 260 249 err_free_dev: 261 250 input_free_device(tgfx->dev[i]); ··· 265 258 kfree(tgfx); 266 259 err_unreg_pardev: 267 260 parport_unregister_device(pd); 268 - err_put_pp: 269 - parport_put_port(pp); 270 - err_out: 271 - return ERR_PTR(err); 272 261 } 273 262 274 - static void tgfx_remove(struct tgfx *tgfx) 263 + static void tgfx_detach(struct parport *port) 275 264 { 276 265 int i; 266 + struct tgfx *tgfx; 267 + 268 + for (i = 0; i < TGFX_MAX_PORTS; i++) { 269 + if (tgfx_base[i] && tgfx_base[i]->parportno == port->number) 270 + break; 271 + } 272 + 273 + if (i == TGFX_MAX_PORTS) 274 + return; 275 + 276 + tgfx = tgfx_base[i]; 277 + tgfx_base[i] = NULL; 277 278 278 279 for (i = 0; i < TGFX_MAX_DEVICES; i++) 279 280 if (tgfx->dev[i]) ··· 290 275 kfree(tgfx); 291 276 } 292 277 278 + static struct parport_driver tgfx_parport_driver = { 279 + .name = "turbografx", 280 + .match_port = tgfx_attach, 281 + .detach = tgfx_detach, 282 + .devmodel = true, 283 + }; 284 + 293 285 static int __init tgfx_init(void) 294 286 { 295 287 int i; 296 288 int have_dev = 0; 297 - int err = 0; 298 289 299 290 for (i = 0; i < TGFX_MAX_PORTS; i++) { 300 291 if (tgfx_cfg[i].nargs == 0 || tgfx_cfg[i].args[0] < 0) ··· 308 287 309 288 if (tgfx_cfg[i].nargs < 2) { 310 289 printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n"); 311 - err = -EINVAL; 312 - break; 313 - } 314 - 315 - tgfx_base[i] = tgfx_probe(tgfx_cfg[i].args[0], 316 - tgfx_cfg[i].args + 1, 317 - tgfx_cfg[i].nargs - 1); 318 - if (IS_ERR(tgfx_base[i])) { 319 - err = PTR_ERR(tgfx_base[i]); 320 - break; 290 + return -EINVAL; 321 291 } 322 292 323 293 have_dev = 1; 324 294 } 325 295 326 - if (err) { 327 - while (--i >= 0) 328 - if (tgfx_base[i]) 329 - tgfx_remove(tgfx_base[i]); 330 - return err; 331 - } 296 + if (!have_dev) 297 + return -ENODEV; 332 298 333 - return have_dev ? 0 : -ENODEV; 299 + return parport_register_driver(&tgfx_parport_driver); 334 300 } 335 301 336 302 static void __exit tgfx_exit(void) 337 303 { 338 - int i; 339 - 340 - for (i = 0; i < TGFX_MAX_PORTS; i++) 341 - if (tgfx_base[i]) 342 - tgfx_remove(tgfx_base[i]); 304 + parport_unregister_driver(&tgfx_parport_driver); 343 305 } 344 306 345 307 module_init(tgfx_init);
+37 -27
drivers/input/joystick/walkera0701.c
··· 200 200 parport_release(w->pardevice); 201 201 } 202 202 203 - static int walkera0701_connect(struct walkera_dev *w, int parport) 203 + static void walkera0701_attach(struct parport *pp) 204 204 { 205 - int error; 205 + struct pardev_cb walkera0701_parport_cb; 206 + struct walkera_dev *w = &w_dev; 206 207 207 - w->parport = parport_find_number(parport); 208 - if (!w->parport) { 209 - pr_err("parport %d does not exist\n", parport); 210 - return -ENODEV; 208 + if (pp->number != walkera0701_pp_no) { 209 + pr_debug("Not using parport%d.\n", pp->number); 210 + return; 211 211 } 212 212 213 - if (w->parport->irq == -1) { 213 + if (pp->irq == -1) { 214 214 pr_err("parport %d does not have interrupt assigned\n", 215 - parport); 216 - error = -EINVAL; 217 - goto err_put_parport; 215 + pp->number); 216 + return; 218 217 } 219 218 220 - w->pardevice = parport_register_device(w->parport, "walkera0701", 221 - NULL, NULL, walkera0701_irq_handler, 222 - PARPORT_DEV_EXCL, w); 219 + w->parport = pp; 220 + 221 + walkera0701_parport_cb.flags = PARPORT_FLAG_EXCL; 222 + walkera0701_parport_cb.irq_func = walkera0701_irq_handler; 223 + walkera0701_parport_cb.private = w; 224 + 225 + w->pardevice = parport_register_dev_model(pp, "walkera0701", 226 + &walkera0701_parport_cb, 0); 227 + 223 228 if (!w->pardevice) { 224 229 pr_err("failed to register parport device\n"); 225 - error = -EIO; 226 - goto err_put_parport; 230 + return; 227 231 } 228 232 229 233 if (parport_negotiate(w->pardevice->port, IEEE1284_MODE_COMPAT)) { 230 234 pr_err("failed to negotiate parport mode\n"); 231 - error = -EIO; 232 235 goto err_unregister_device; 233 236 } 234 237 ··· 241 238 w->input_dev = input_allocate_device(); 242 239 if (!w->input_dev) { 243 240 pr_err("failed to allocate input device\n"); 244 - error = -ENOMEM; 245 241 goto err_unregister_device; 246 242 } 247 243 ··· 267 265 input_set_abs_params(w->input_dev, ABS_RUDDER, -512, 512, 0, 0); 268 266 input_set_abs_params(w->input_dev, ABS_MISC, -512, 512, 0, 0); 269 267 270 - error = input_register_device(w->input_dev); 271 - if (error) { 268 + if (input_register_device(w->input_dev)) { 272 269 pr_err("failed to register input device\n"); 273 270 goto err_free_input_dev; 274 271 } 275 272 276 - return 0; 273 + return; 277 274 278 275 err_free_input_dev: 279 276 input_free_device(w->input_dev); 280 277 err_unregister_device: 281 278 parport_unregister_device(w->pardevice); 282 - err_put_parport: 283 - parport_put_port(w->parport); 284 - return error; 285 279 } 286 280 287 - static void walkera0701_disconnect(struct walkera_dev *w) 281 + static void walkera0701_detach(struct parport *port) 288 282 { 283 + struct walkera_dev *w = &w_dev; 284 + 285 + if (!w->pardevice || w->parport->number != port->number) 286 + return; 287 + 289 288 input_unregister_device(w->input_dev); 290 289 parport_unregister_device(w->pardevice); 291 - parport_put_port(w->parport); 290 + w->parport = NULL; 292 291 } 292 + 293 + static struct parport_driver walkera0701_parport_driver = { 294 + .name = "walkera0701", 295 + .match_port = walkera0701_attach, 296 + .detach = walkera0701_detach, 297 + .devmodel = true, 298 + }; 293 299 294 300 static int __init walkera0701_init(void) 295 301 { 296 - return walkera0701_connect(&w_dev, walkera0701_pp_no); 302 + return parport_register_driver(&walkera0701_parport_driver); 297 303 } 298 304 299 305 static void __exit walkera0701_exit(void) 300 306 { 301 - walkera0701_disconnect(&w_dev); 307 + parport_unregister_driver(&walkera0701_parport_driver); 302 308 } 303 309 304 310 module_init(walkera0701_init);
+278 -254
drivers/input/joystick/xpad.c
··· 125 125 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX }, 126 126 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, 127 127 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE }, 128 + { 0x045e, 0x02dd, "Microsoft X-Box One pad (Covert Forces)", 0, XTYPE_XBOXONE }, 128 129 { 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 129 130 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 130 131 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, ··· 205 204 { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 }, 206 205 { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 }, 207 206 { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 }, 208 - { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", 0, XTYPE_XBOX360 }, 207 + { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 209 208 { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 }, 210 209 { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 }, 211 210 { 0x24c6, 0x5500, "Hori XBOX 360 EX 2 with Turbo", 0, XTYPE_XBOX360 }, ··· 242 241 BTN_TL2, BTN_TR2, /* triggers left/right */ 243 242 -1 244 243 }; 245 - 246 244 247 245 static const signed short xpad360_btn[] = { /* buttons for x360 controller */ 248 246 BTN_TL, BTN_TR, /* Button LB/RB */ ··· 328 328 unsigned char *idata; /* input data */ 329 329 dma_addr_t idata_dma; 330 330 331 - struct urb *bulk_out; 332 - unsigned char *bdata; 333 - 334 331 struct urb *irq_out; /* urb for interrupt out report */ 335 332 unsigned char *odata; /* output data */ 336 333 dma_addr_t odata_dma; ··· 341 344 342 345 int mapping; /* map d-pad to buttons or to axes */ 343 346 int xtype; /* type of xbox device */ 344 - unsigned long led_no; /* led to lit on xbox360 controllers */ 347 + int pad_nr; /* the order x360 pads were attached */ 348 + const char *name; /* name of the device */ 345 349 }; 346 350 347 351 /* ··· 354 356 * The used report descriptor was taken from ITO Takayukis website: 355 357 * http://euc.jp/periphs/xbox-controller.ja.html 356 358 */ 357 - 358 359 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) 359 360 { 360 361 struct input_dev *dev = xpad->dev; ··· 436 439 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); 437 440 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); 438 441 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); 439 - } else { 442 + } 443 + 444 + /* 445 + * This should be a simple else block. However historically 446 + * xbox360w has mapped DPAD to buttons while xbox360 did not. This 447 + * made no sense, but now we can not just switch back and have to 448 + * support both behaviors. 449 + */ 450 + if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || 451 + xpad->xtype == XTYPE_XBOX360W) { 440 452 input_report_abs(dev, ABS_HAT0X, 441 453 !!(data[2] & 0x08) - !!(data[2] & 0x04)); 442 454 input_report_abs(dev, ABS_HAT0Y, ··· 511 505 * 01.1 - Pad state (Bytes 4+) valid 512 506 * 513 507 */ 514 - 515 508 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) 516 509 { 517 510 /* Presence change */ 518 511 if (data[0] & 0x08) { 519 512 if (data[1] & 0x80) { 520 513 xpad->pad_present = 1; 521 - usb_submit_urb(xpad->bulk_out, GFP_ATOMIC); 522 514 /* 523 515 * Light up the segment corresponding to 524 516 * controller number. ··· 678 674 __func__, retval); 679 675 } 680 676 681 - static void xpad_bulk_out(struct urb *urb) 682 - { 683 - struct usb_xpad *xpad = urb->context; 684 - struct device *dev = &xpad->intf->dev; 685 - 686 - switch (urb->status) { 687 - case 0: 688 - /* success */ 689 - break; 690 - case -ECONNRESET: 691 - case -ENOENT: 692 - case -ESHUTDOWN: 693 - /* this urb is terminated, clean up */ 694 - dev_dbg(dev, "%s - urb shutting down with status: %d\n", 695 - __func__, urb->status); 696 - break; 697 - default: 698 - dev_dbg(dev, "%s - nonzero urb status received: %d\n", 699 - __func__, urb->status); 700 - } 701 - } 702 - 703 677 static void xpad_irq_out(struct urb *urb) 704 678 { 705 679 struct usb_xpad *xpad = urb->context; ··· 768 786 } 769 787 } 770 788 789 + static int xpad_inquiry_pad_presence(struct usb_xpad *xpad) 790 + { 791 + int retval; 792 + 793 + mutex_lock(&xpad->odata_mutex); 794 + 795 + xpad->odata[0] = 0x08; 796 + xpad->odata[1] = 0x00; 797 + xpad->odata[2] = 0x0F; 798 + xpad->odata[3] = 0xC0; 799 + xpad->odata[4] = 0x00; 800 + xpad->odata[5] = 0x00; 801 + xpad->odata[6] = 0x00; 802 + xpad->odata[7] = 0x00; 803 + xpad->odata[8] = 0x00; 804 + xpad->odata[9] = 0x00; 805 + xpad->odata[10] = 0x00; 806 + xpad->odata[11] = 0x00; 807 + xpad->irq_out->transfer_buffer_length = 12; 808 + 809 + retval = usb_submit_urb(xpad->irq_out, GFP_KERNEL); 810 + 811 + mutex_unlock(&xpad->odata_mutex); 812 + 813 + return retval; 814 + } 815 + 771 816 #ifdef CONFIG_JOYSTICK_XPAD_FF 772 817 static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) 773 818 { 774 819 struct usb_xpad *xpad = input_get_drvdata(dev); 820 + __u16 strong; 821 + __u16 weak; 775 822 776 - if (effect->type == FF_RUMBLE) { 777 - __u16 strong = effect->u.rumble.strong_magnitude; 778 - __u16 weak = effect->u.rumble.weak_magnitude; 823 + if (effect->type != FF_RUMBLE) 824 + return 0; 779 825 780 - switch (xpad->xtype) { 826 + strong = effect->u.rumble.strong_magnitude; 827 + weak = effect->u.rumble.weak_magnitude; 781 828 782 - case XTYPE_XBOX: 783 - xpad->odata[0] = 0x00; 784 - xpad->odata[1] = 0x06; 785 - xpad->odata[2] = 0x00; 786 - xpad->odata[3] = strong / 256; /* left actuator */ 787 - xpad->odata[4] = 0x00; 788 - xpad->odata[5] = weak / 256; /* right actuator */ 789 - xpad->irq_out->transfer_buffer_length = 6; 829 + switch (xpad->xtype) { 830 + case XTYPE_XBOX: 831 + xpad->odata[0] = 0x00; 832 + xpad->odata[1] = 0x06; 833 + xpad->odata[2] = 0x00; 834 + xpad->odata[3] = strong / 256; /* left actuator */ 835 + xpad->odata[4] = 0x00; 836 + xpad->odata[5] = weak / 256; /* right actuator */ 837 + xpad->irq_out->transfer_buffer_length = 6; 838 + break; 790 839 791 - return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 840 + case XTYPE_XBOX360: 841 + xpad->odata[0] = 0x00; 842 + xpad->odata[1] = 0x08; 843 + xpad->odata[2] = 0x00; 844 + xpad->odata[3] = strong / 256; /* left actuator? */ 845 + xpad->odata[4] = weak / 256; /* right actuator? */ 846 + xpad->odata[5] = 0x00; 847 + xpad->odata[6] = 0x00; 848 + xpad->odata[7] = 0x00; 849 + xpad->irq_out->transfer_buffer_length = 8; 850 + break; 792 851 793 - case XTYPE_XBOX360: 794 - xpad->odata[0] = 0x00; 795 - xpad->odata[1] = 0x08; 796 - xpad->odata[2] = 0x00; 797 - xpad->odata[3] = strong / 256; /* left actuator? */ 798 - xpad->odata[4] = weak / 256; /* right actuator? */ 799 - xpad->odata[5] = 0x00; 800 - xpad->odata[6] = 0x00; 801 - xpad->odata[7] = 0x00; 802 - xpad->irq_out->transfer_buffer_length = 8; 852 + case XTYPE_XBOX360W: 853 + xpad->odata[0] = 0x00; 854 + xpad->odata[1] = 0x01; 855 + xpad->odata[2] = 0x0F; 856 + xpad->odata[3] = 0xC0; 857 + xpad->odata[4] = 0x00; 858 + xpad->odata[5] = strong / 256; 859 + xpad->odata[6] = weak / 256; 860 + xpad->odata[7] = 0x00; 861 + xpad->odata[8] = 0x00; 862 + xpad->odata[9] = 0x00; 863 + xpad->odata[10] = 0x00; 864 + xpad->odata[11] = 0x00; 865 + xpad->irq_out->transfer_buffer_length = 12; 866 + break; 803 867 804 - return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 868 + case XTYPE_XBOXONE: 869 + xpad->odata[0] = 0x09; /* activate rumble */ 870 + xpad->odata[1] = 0x08; 871 + xpad->odata[2] = 0x00; 872 + xpad->odata[3] = 0x08; /* continuous effect */ 873 + xpad->odata[4] = 0x00; /* simple rumble mode */ 874 + xpad->odata[5] = 0x03; /* L and R actuator only */ 875 + xpad->odata[6] = 0x00; /* TODO: LT actuator */ 876 + xpad->odata[7] = 0x00; /* TODO: RT actuator */ 877 + xpad->odata[8] = strong / 256; /* left actuator */ 878 + xpad->odata[9] = weak / 256; /* right actuator */ 879 + xpad->odata[10] = 0x80; /* length of pulse */ 880 + xpad->odata[11] = 0x00; /* stop period of pulse */ 881 + xpad->irq_out->transfer_buffer_length = 12; 882 + break; 805 883 806 - case XTYPE_XBOX360W: 807 - xpad->odata[0] = 0x00; 808 - xpad->odata[1] = 0x01; 809 - xpad->odata[2] = 0x0F; 810 - xpad->odata[3] = 0xC0; 811 - xpad->odata[4] = 0x00; 812 - xpad->odata[5] = strong / 256; 813 - xpad->odata[6] = weak / 256; 814 - xpad->odata[7] = 0x00; 815 - xpad->odata[8] = 0x00; 816 - xpad->odata[9] = 0x00; 817 - xpad->odata[10] = 0x00; 818 - xpad->odata[11] = 0x00; 819 - xpad->irq_out->transfer_buffer_length = 12; 820 - 821 - return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 822 - 823 - case XTYPE_XBOXONE: 824 - xpad->odata[0] = 0x09; /* activate rumble */ 825 - xpad->odata[1] = 0x08; 826 - xpad->odata[2] = 0x00; 827 - xpad->odata[3] = 0x08; /* continuous effect */ 828 - xpad->odata[4] = 0x00; /* simple rumble mode */ 829 - xpad->odata[5] = 0x03; /* L and R actuator only */ 830 - xpad->odata[6] = 0x00; /* TODO: LT actuator */ 831 - xpad->odata[7] = 0x00; /* TODO: RT actuator */ 832 - xpad->odata[8] = strong / 256; /* left actuator */ 833 - xpad->odata[9] = weak / 256; /* right actuator */ 834 - xpad->odata[10] = 0x80; /* length of pulse */ 835 - xpad->odata[11] = 0x00; /* stop period of pulse */ 836 - xpad->irq_out->transfer_buffer_length = 12; 837 - 838 - return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 839 - 840 - default: 841 - dev_dbg(&xpad->dev->dev, 842 - "%s - rumble command sent to unsupported xpad type: %d\n", 843 - __func__, xpad->xtype); 844 - return -1; 845 - } 884 + default: 885 + dev_dbg(&xpad->dev->dev, 886 + "%s - rumble command sent to unsupported xpad type: %d\n", 887 + __func__, xpad->xtype); 888 + return -EINVAL; 846 889 } 847 890 848 - return 0; 891 + return usb_submit_urb(xpad->irq_out, GFP_ATOMIC); 849 892 } 850 893 851 894 static int xpad_init_ff(struct usb_xpad *xpad) ··· 889 882 890 883 #if defined(CONFIG_JOYSTICK_XPAD_LEDS) 891 884 #include <linux/leds.h> 885 + #include <linux/idr.h> 886 + 887 + static DEFINE_IDA(xpad_pad_seq); 892 888 893 889 struct xpad_led { 894 890 char name[16]; ··· 900 890 }; 901 891 902 892 /** 893 + * set the LEDs on Xbox360 / Wireless Controllers 903 894 * @param command 904 895 * 0: off 905 896 * 1: all blink, then previous setting ··· 953 942 mutex_unlock(&xpad->odata_mutex); 954 943 } 955 944 945 + /* 946 + * Light up the segment corresponding to the pad number on 947 + * Xbox 360 Controllers. 948 + */ 956 949 static void xpad_identify_controller(struct usb_xpad *xpad) 957 950 { 958 - /* Light up the segment corresponding to controller number */ 959 - xpad_send_led_command(xpad, (xpad->led_no % 4) + 2); 951 + xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2); 960 952 } 961 953 962 954 static void xpad_led_set(struct led_classdev *led_cdev, ··· 973 959 974 960 static int xpad_led_probe(struct usb_xpad *xpad) 975 961 { 976 - static atomic_t led_seq = ATOMIC_INIT(-1); 977 962 struct xpad_led *led; 978 963 struct led_classdev *led_cdev; 979 964 int error; ··· 984 971 if (!led) 985 972 return -ENOMEM; 986 973 987 - xpad->led_no = atomic_inc_return(&led_seq); 974 + xpad->pad_nr = ida_simple_get(&xpad_pad_seq, 0, 0, GFP_KERNEL); 975 + if (xpad->pad_nr < 0) { 976 + error = xpad->pad_nr; 977 + goto err_free_mem; 978 + } 988 979 989 - snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no); 980 + snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); 990 981 led->xpad = xpad; 991 982 992 983 led_cdev = &led->led_cdev; ··· 998 981 led_cdev->brightness_set = xpad_led_set; 999 982 1000 983 error = led_classdev_register(&xpad->udev->dev, led_cdev); 1001 - if (error) { 1002 - kfree(led); 1003 - xpad->led = NULL; 1004 - return error; 984 + if (error) 985 + goto err_free_id; 986 + 987 + if (xpad->xtype == XTYPE_XBOX360) { 988 + /* 989 + * Light up the segment corresponding to controller 990 + * number on wired devices. On wireless we'll do that 991 + * when they respond to "presence" packet. 992 + */ 993 + xpad_identify_controller(xpad); 1005 994 } 1006 995 1007 - /* Light up the segment corresponding to controller number */ 1008 - xpad_identify_controller(xpad); 1009 - 1010 996 return 0; 997 + 998 + err_free_id: 999 + ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); 1000 + err_free_mem: 1001 + kfree(led); 1002 + xpad->led = NULL; 1003 + return error; 1011 1004 } 1012 1005 1013 1006 static void xpad_led_disconnect(struct usb_xpad *xpad) ··· 1026 999 1027 1000 if (xpad_led) { 1028 1001 led_classdev_unregister(&xpad_led->led_cdev); 1002 + ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); 1029 1003 kfree(xpad_led); 1030 1004 } 1031 1005 } ··· 1035 1007 static void xpad_led_disconnect(struct usb_xpad *xpad) { } 1036 1008 static void xpad_identify_controller(struct usb_xpad *xpad) { } 1037 1009 #endif 1038 - 1039 1010 1040 1011 static int xpad_open(struct input_dev *dev) 1041 1012 { ··· 1095 1068 } 1096 1069 } 1097 1070 1098 - static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) 1071 + static void xpad_deinit_input(struct usb_xpad *xpad) 1099 1072 { 1100 - struct usb_device *udev = interface_to_usbdev(intf); 1101 - struct usb_xpad *xpad; 1073 + xpad_led_disconnect(xpad); 1074 + input_unregister_device(xpad->dev); 1075 + } 1076 + 1077 + static int xpad_init_input(struct usb_xpad *xpad) 1078 + { 1102 1079 struct input_dev *input_dev; 1103 - struct usb_endpoint_descriptor *ep_irq_in; 1104 - int ep_irq_in_idx; 1105 1080 int i, error; 1106 1081 1107 - for (i = 0; xpad_device[i].idVendor; i++) { 1108 - if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && 1109 - (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) 1110 - break; 1111 - } 1112 - 1113 - if (xpad_device[i].xtype == XTYPE_XBOXONE && 1114 - intf->cur_altsetting->desc.bInterfaceNumber != 0) { 1115 - /* 1116 - * The Xbox One controller lists three interfaces all with the 1117 - * same interface class, subclass and protocol. Differentiate by 1118 - * interface number. 1119 - */ 1120 - return -ENODEV; 1121 - } 1122 - 1123 - xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); 1124 1082 input_dev = input_allocate_device(); 1125 - if (!xpad || !input_dev) { 1126 - error = -ENOMEM; 1127 - goto fail1; 1128 - } 1129 - 1130 - xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, 1131 - GFP_KERNEL, &xpad->idata_dma); 1132 - if (!xpad->idata) { 1133 - error = -ENOMEM; 1134 - goto fail1; 1135 - } 1136 - 1137 - xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); 1138 - if (!xpad->irq_in) { 1139 - error = -ENOMEM; 1140 - goto fail2; 1141 - } 1142 - 1143 - xpad->udev = udev; 1144 - xpad->intf = intf; 1145 - xpad->mapping = xpad_device[i].mapping; 1146 - xpad->xtype = xpad_device[i].xtype; 1147 - 1148 - if (xpad->xtype == XTYPE_UNKNOWN) { 1149 - if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { 1150 - if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) 1151 - xpad->xtype = XTYPE_XBOX360W; 1152 - else 1153 - xpad->xtype = XTYPE_XBOX360; 1154 - } else 1155 - xpad->xtype = XTYPE_XBOX; 1156 - 1157 - if (dpad_to_buttons) 1158 - xpad->mapping |= MAP_DPAD_TO_BUTTONS; 1159 - if (triggers_to_buttons) 1160 - xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; 1161 - if (sticks_to_null) 1162 - xpad->mapping |= MAP_STICKS_TO_NULL; 1163 - } 1083 + if (!input_dev) 1084 + return -ENOMEM; 1164 1085 1165 1086 xpad->dev = input_dev; 1166 - usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 1167 - strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 1168 - 1169 - input_dev->name = xpad_device[i].name; 1087 + input_dev->name = xpad->name; 1170 1088 input_dev->phys = xpad->phys; 1171 - usb_to_input_id(udev, &input_dev->id); 1172 - input_dev->dev.parent = &intf->dev; 1089 + usb_to_input_id(xpad->udev, &input_dev->id); 1090 + input_dev->dev.parent = &xpad->intf->dev; 1173 1091 1174 1092 input_set_drvdata(input_dev, xpad); 1175 1093 1176 1094 input_dev->open = xpad_open; 1177 1095 input_dev->close = xpad_close; 1178 1096 1179 - input_dev->evbit[0] = BIT_MASK(EV_KEY); 1097 + __set_bit(EV_KEY, input_dev->evbit); 1180 1098 1181 1099 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 1182 - input_dev->evbit[0] |= BIT_MASK(EV_ABS); 1100 + __set_bit(EV_ABS, input_dev->evbit); 1183 1101 /* set up axes */ 1184 1102 for (i = 0; xpad_abs[i] >= 0; i++) 1185 1103 xpad_set_up_abs(input_dev, xpad_abs[i]); ··· 1147 1175 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 1148 1176 for (i = 0; xpad_btn_pad[i] >= 0; i++) 1149 1177 __set_bit(xpad_btn_pad[i], input_dev->keybit); 1150 - } else { 1178 + } 1179 + 1180 + /* 1181 + * This should be a simple else block. However historically 1182 + * xbox360w has mapped DPAD to buttons while xbox360 did not. This 1183 + * made no sense, but now we can not just switch back and have to 1184 + * support both behaviors. 1185 + */ 1186 + if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || 1187 + xpad->xtype == XTYPE_XBOX360W) { 1151 1188 for (i = 0; xpad_abs_pad[i] >= 0; i++) 1152 1189 xpad_set_up_abs(input_dev, xpad_abs_pad[i]); 1153 1190 } ··· 1169 1188 xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); 1170 1189 } 1171 1190 1172 - error = xpad_init_output(intf, xpad); 1173 - if (error) 1174 - goto fail3; 1175 - 1176 1191 error = xpad_init_ff(xpad); 1177 1192 if (error) 1178 - goto fail4; 1193 + goto err_free_input; 1179 1194 1180 1195 error = xpad_led_probe(xpad); 1181 1196 if (error) 1182 - goto fail5; 1197 + goto err_destroy_ff; 1198 + 1199 + error = input_register_device(xpad->dev); 1200 + if (error) 1201 + goto err_disconnect_led; 1202 + 1203 + return 0; 1204 + 1205 + err_disconnect_led: 1206 + xpad_led_disconnect(xpad); 1207 + err_destroy_ff: 1208 + input_ff_destroy(input_dev); 1209 + err_free_input: 1210 + input_free_device(input_dev); 1211 + return error; 1212 + } 1213 + 1214 + static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) 1215 + { 1216 + struct usb_device *udev = interface_to_usbdev(intf); 1217 + struct usb_xpad *xpad; 1218 + struct usb_endpoint_descriptor *ep_irq_in; 1219 + int ep_irq_in_idx; 1220 + int i, error; 1221 + 1222 + for (i = 0; xpad_device[i].idVendor; i++) { 1223 + if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && 1224 + (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) 1225 + break; 1226 + } 1227 + 1228 + if (xpad_device[i].xtype == XTYPE_XBOXONE && 1229 + intf->cur_altsetting->desc.bInterfaceNumber != 0) { 1230 + /* 1231 + * The Xbox One controller lists three interfaces all with the 1232 + * same interface class, subclass and protocol. Differentiate by 1233 + * interface number. 1234 + */ 1235 + return -ENODEV; 1236 + } 1237 + 1238 + xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); 1239 + if (!xpad) 1240 + return -ENOMEM; 1241 + 1242 + usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 1243 + strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 1244 + 1245 + xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, 1246 + GFP_KERNEL, &xpad->idata_dma); 1247 + if (!xpad->idata) { 1248 + error = -ENOMEM; 1249 + goto err_free_mem; 1250 + } 1251 + 1252 + xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); 1253 + if (!xpad->irq_in) { 1254 + error = -ENOMEM; 1255 + goto err_free_idata; 1256 + } 1257 + 1258 + xpad->udev = udev; 1259 + xpad->intf = intf; 1260 + xpad->mapping = xpad_device[i].mapping; 1261 + xpad->xtype = xpad_device[i].xtype; 1262 + xpad->name = xpad_device[i].name; 1263 + 1264 + if (xpad->xtype == XTYPE_UNKNOWN) { 1265 + if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { 1266 + if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) 1267 + xpad->xtype = XTYPE_XBOX360W; 1268 + else 1269 + xpad->xtype = XTYPE_XBOX360; 1270 + } else { 1271 + xpad->xtype = XTYPE_XBOX; 1272 + } 1273 + 1274 + if (dpad_to_buttons) 1275 + xpad->mapping |= MAP_DPAD_TO_BUTTONS; 1276 + if (triggers_to_buttons) 1277 + xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; 1278 + if (sticks_to_null) 1279 + xpad->mapping |= MAP_STICKS_TO_NULL; 1280 + } 1281 + 1282 + error = xpad_init_output(intf, xpad); 1283 + if (error) 1284 + goto err_free_in_urb; 1183 1285 1184 1286 /* Xbox One controller has in/out endpoints swapped. */ 1185 1287 ep_irq_in_idx = xpad->xtype == XTYPE_XBOXONE ? 1 : 0; ··· 1275 1211 xpad->irq_in->transfer_dma = xpad->idata_dma; 1276 1212 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1277 1213 1278 - error = input_register_device(xpad->dev); 1279 - if (error) 1280 - goto fail6; 1281 - 1282 1214 usb_set_intfdata(intf, xpad); 1283 1215 1216 + error = xpad_init_input(xpad); 1217 + if (error) 1218 + goto err_deinit_output; 1219 + 1284 1220 if (xpad->xtype == XTYPE_XBOX360W) { 1285 - /* 1286 - * Setup the message to set the LEDs on the 1287 - * controller when it shows up 1288 - */ 1289 - xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); 1290 - if (!xpad->bulk_out) { 1291 - error = -ENOMEM; 1292 - goto fail7; 1293 - } 1294 - 1295 - xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); 1296 - if (!xpad->bdata) { 1297 - error = -ENOMEM; 1298 - goto fail8; 1299 - } 1300 - 1301 - xpad->bdata[2] = 0x08; 1302 - switch (intf->cur_altsetting->desc.bInterfaceNumber) { 1303 - case 0: 1304 - xpad->bdata[3] = 0x42; 1305 - break; 1306 - case 2: 1307 - xpad->bdata[3] = 0x43; 1308 - break; 1309 - case 4: 1310 - xpad->bdata[3] = 0x44; 1311 - break; 1312 - case 6: 1313 - xpad->bdata[3] = 0x45; 1314 - } 1315 - 1316 - ep_irq_in = &intf->cur_altsetting->endpoint[1].desc; 1317 - if (usb_endpoint_is_bulk_out(ep_irq_in)) { 1318 - usb_fill_bulk_urb(xpad->bulk_out, udev, 1319 - usb_sndbulkpipe(udev, 1320 - ep_irq_in->bEndpointAddress), 1321 - xpad->bdata, XPAD_PKT_LEN, 1322 - xpad_bulk_out, xpad); 1323 - } else { 1324 - usb_fill_int_urb(xpad->bulk_out, udev, 1325 - usb_sndintpipe(udev, 1326 - ep_irq_in->bEndpointAddress), 1327 - xpad->bdata, XPAD_PKT_LEN, 1328 - xpad_bulk_out, xpad, 0); 1329 - } 1330 - 1331 1221 /* 1332 1222 * Submit the int URB immediately rather than waiting for open 1333 1223 * because we get status messages from the device whether ··· 1292 1274 xpad->irq_in->dev = xpad->udev; 1293 1275 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); 1294 1276 if (error) 1295 - goto fail9; 1296 - } 1277 + goto err_deinit_input; 1297 1278 1279 + /* 1280 + * Send presence packet. 1281 + * This will force the controller to resend connection packets. 1282 + * This is useful in the case we activate the module after the 1283 + * adapter has been plugged in, as it won't automatically 1284 + * send us info about the controllers. 1285 + */ 1286 + error = xpad_inquiry_pad_presence(xpad); 1287 + if (error) 1288 + goto err_kill_in_urb; 1289 + } 1298 1290 return 0; 1299 1291 1300 - fail9: kfree(xpad->bdata); 1301 - fail8: usb_free_urb(xpad->bulk_out); 1302 - fail7: input_unregister_device(input_dev); 1303 - input_dev = NULL; 1304 - fail6: xpad_led_disconnect(xpad); 1305 - fail5: if (input_dev) 1306 - input_ff_destroy(input_dev); 1307 - fail4: xpad_deinit_output(xpad); 1308 - fail3: usb_free_urb(xpad->irq_in); 1309 - fail2: usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 1310 - fail1: input_free_device(input_dev); 1292 + err_kill_in_urb: 1293 + usb_kill_urb(xpad->irq_in); 1294 + err_deinit_input: 1295 + xpad_deinit_input(xpad); 1296 + err_deinit_output: 1297 + xpad_deinit_output(xpad); 1298 + err_free_in_urb: 1299 + usb_free_urb(xpad->irq_in); 1300 + err_free_idata: 1301 + usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 1302 + err_free_mem: 1311 1303 kfree(xpad); 1312 1304 return error; 1313 1305 ··· 1327 1299 { 1328 1300 struct usb_xpad *xpad = usb_get_intfdata (intf); 1329 1301 1330 - xpad_led_disconnect(xpad); 1331 - input_unregister_device(xpad->dev); 1302 + xpad_deinit_input(xpad); 1332 1303 xpad_deinit_output(xpad); 1333 1304 1334 1305 if (xpad->xtype == XTYPE_XBOX360W) { 1335 - usb_kill_urb(xpad->bulk_out); 1336 - usb_free_urb(xpad->bulk_out); 1337 1306 usb_kill_urb(xpad->irq_in); 1338 1307 } 1339 1308 ··· 1338 1313 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, 1339 1314 xpad->idata, xpad->idata_dma); 1340 1315 1341 - kfree(xpad->bdata); 1342 1316 kfree(xpad); 1343 1317 1344 1318 usb_set_intfdata(intf, NULL);
+1 -1
drivers/input/keyboard/Kconfig
··· 516 516 module will be called samsung-keypad. 517 517 518 518 config KEYBOARD_GOLDFISH_EVENTS 519 - depends on GOLDFISH 519 + depends on GOLDFISH || COMPILE_TEST 520 520 tristate "Generic Input Event device for Goldfish" 521 521 help 522 522 Say Y here to get an input event device for the Goldfish virtual
+7 -1
drivers/input/keyboard/gpio_keys.c
··· 341 341 const struct gpio_keys_button *button = bdata->button; 342 342 struct input_dev *input = bdata->input; 343 343 unsigned int type = button->type ?: EV_KEY; 344 - int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; 344 + int state = gpio_get_value_cansleep(button->gpio); 345 345 346 + if (state < 0) { 347 + dev_err(input->dev.parent, "failed to get gpio state\n"); 348 + return; 349 + } 350 + 351 + state = (state ? 1 : 0) ^ button->active_low; 346 352 if (type == EV_ABS) { 347 353 if (state) 348 354 input_event(input, type, button->code, button->value);
+79 -9
drivers/input/keyboard/gpio_keys_polled.c
··· 40 40 struct input_polled_dev *poll_dev; 41 41 struct device *dev; 42 42 const struct gpio_keys_platform_data *pdata; 43 + unsigned long rel_axis_seen[BITS_TO_LONGS(REL_CNT)]; 44 + unsigned long abs_axis_seen[BITS_TO_LONGS(ABS_CNT)]; 43 45 struct gpio_keys_button_data data[0]; 44 46 }; 45 47 46 - static void gpio_keys_polled_check_state(struct input_dev *input, 48 + static void gpio_keys_button_event(struct input_polled_dev *dev, 49 + struct gpio_keys_button *button, 50 + int state) 51 + { 52 + struct gpio_keys_polled_dev *bdev = dev->private; 53 + struct input_dev *input = dev->input; 54 + unsigned int type = button->type ?: EV_KEY; 55 + 56 + if (type == EV_REL) { 57 + if (state) { 58 + input_event(input, type, button->code, button->value); 59 + __set_bit(button->code, bdev->rel_axis_seen); 60 + } 61 + } else if (type == EV_ABS) { 62 + if (state) { 63 + input_event(input, type, button->code, button->value); 64 + __set_bit(button->code, bdev->abs_axis_seen); 65 + } 66 + } else { 67 + input_event(input, type, button->code, state); 68 + input_sync(input); 69 + } 70 + } 71 + 72 + static void gpio_keys_polled_check_state(struct input_polled_dev *dev, 47 73 struct gpio_keys_button *button, 48 74 struct gpio_keys_button_data *bdata) 49 75 { ··· 80 54 else 81 55 state = !!gpiod_get_value(button->gpiod); 82 56 83 - if (state != bdata->last_state) { 84 - unsigned int type = button->type ?: EV_KEY; 57 + gpio_keys_button_event(dev, button, state); 85 58 86 - input_event(input, type, button->code, state); 87 - input_sync(input); 59 + if (state != bdata->last_state) { 88 60 bdata->count = 0; 89 61 bdata->last_state = state; 90 62 } ··· 95 71 struct input_dev *input = dev->input; 96 72 int i; 97 73 74 + memset(bdev->rel_axis_seen, 0, sizeof(bdev->rel_axis_seen)); 75 + memset(bdev->abs_axis_seen, 0, sizeof(bdev->abs_axis_seen)); 76 + 98 77 for (i = 0; i < pdata->nbuttons; i++) { 99 78 struct gpio_keys_button_data *bdata = &bdev->data[i]; 100 79 101 - if (bdata->count < bdata->threshold) 80 + if (bdata->count < bdata->threshold) { 102 81 bdata->count++; 103 - else 104 - gpio_keys_polled_check_state(input, &pdata->buttons[i], 82 + gpio_keys_button_event(dev, &pdata->buttons[i], 83 + bdata->last_state); 84 + } else { 85 + gpio_keys_polled_check_state(dev, &pdata->buttons[i], 105 86 bdata); 87 + } 106 88 } 89 + 90 + for_each_set_bit(i, input->relbit, REL_CNT) { 91 + if (!test_bit(i, bdev->rel_axis_seen)) 92 + input_event(input, EV_REL, i, 0); 93 + } 94 + 95 + for_each_set_bit(i, input->absbit, ABS_CNT) { 96 + if (!test_bit(i, bdev->abs_axis_seen)) 97 + input_event(input, EV_ABS, i, 0); 98 + } 99 + 100 + input_sync(input); 107 101 } 108 102 109 103 static void gpio_keys_polled_open(struct input_polled_dev *dev) ··· 194 152 &button->type)) 195 153 button->type = EV_KEY; 196 154 155 + if (fwnode_property_read_u32(child, "linux,input-value", 156 + (u32 *)&button->value)) 157 + button->value = 1; 158 + 197 159 button->wakeup = 198 160 fwnode_property_read_bool(child, "wakeup-source") || 199 161 /* legacy name */ ··· 212 166 return ERR_PTR(-EINVAL); 213 167 214 168 return pdata; 169 + } 170 + 171 + static void gpio_keys_polled_set_abs_params(struct input_dev *input, 172 + const struct gpio_keys_platform_data *pdata, unsigned int code) 173 + { 174 + int i, min = 0, max = 0; 175 + 176 + for (i = 0; i < pdata->nbuttons; i++) { 177 + struct gpio_keys_button *button = &pdata->buttons[i]; 178 + 179 + if (button->type != EV_ABS || button->code != code) 180 + continue; 181 + 182 + if (button->value < min) 183 + min = button->value; 184 + if (button->value > max) 185 + max = button->value; 186 + } 187 + input_set_abs_params(input, code, min, max, 0, 0); 215 188 } 216 189 217 190 static const struct of_device_id gpio_keys_polled_of_match[] = { ··· 339 274 pdata->poll_interval); 340 275 341 276 input_set_capability(input, type, button->code); 277 + if (type == EV_ABS) 278 + gpio_keys_polled_set_abs_params(input, pdata, 279 + button->code); 342 280 } 343 281 344 282 bdev->poll_dev = poll_dev; ··· 358 290 359 291 /* report initial state of the buttons */ 360 292 for (i = 0; i < pdata->nbuttons; i++) 361 - gpio_keys_polled_check_state(input, &pdata->buttons[i], 293 + gpio_keys_polled_check_state(poll_dev, &pdata->buttons[i], 362 294 &bdev->data[i]); 295 + 296 + input_sync(input); 363 297 364 298 return 0; 365 299 }
+1 -1
drivers/input/keyboard/nomadik-ske-keypad.c
··· 54 54 /** 55 55 * struct ske_keypad - data structure used by keypad driver 56 56 * @irq: irq no 57 - * @reg_base: ske regsiters base address 57 + * @reg_base: ske registers base address 58 58 * @input: pointer to input device object 59 59 * @board: keypad platform device 60 60 * @keymap: matrix scan code table for keycodes
+1 -2
drivers/input/keyboard/snvs_pwrkey.c
··· 110 110 if (!pdata) 111 111 return -ENOMEM; 112 112 113 - pdata->snvs = syscon_regmap_lookup_by_phandle(np, "regmap");; 114 - 113 + pdata->snvs = syscon_regmap_lookup_by_phandle(np, "regmap"); 115 114 if (!pdata->snvs) { 116 115 dev_err(&pdev->dev, "Can't get snvs syscon\n"); 117 116 return -ENODEV;
+3 -2
drivers/input/keyboard/tegra-kbc.c
··· 517 517 if (of_find_property(np, "nvidia,needs-ghost-filter", NULL)) 518 518 kbc->use_ghost_filter = true; 519 519 520 - if (of_find_property(np, "nvidia,wakeup-source", NULL)) 520 + if (of_property_read_bool(np, "wakeup-source") || 521 + of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */ 521 522 kbc->wakeup = true; 522 523 523 524 if (!of_get_property(np, "nvidia,kbc-row-pins", &proplen)) { ··· 706 705 input_set_drvdata(kbc->idev, kbc); 707 706 708 707 err = devm_request_irq(&pdev->dev, kbc->irq, tegra_kbc_isr, 709 - IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc); 708 + IRQF_TRIGGER_HIGH, pdev->name, kbc); 710 709 if (err) { 711 710 dev_err(&pdev->dev, "failed to request keyboard IRQ\n"); 712 711 return err;
+6 -6
drivers/input/misc/Kconfig
··· 94 94 module will be called bma150. 95 95 96 96 config INPUT_E3X0_BUTTON 97 - tristate "NI Ettus Research USRP E3x0 Button support." 97 + tristate "NI Ettus Research USRP E3xx Button support." 98 98 default n 99 99 help 100 100 Say Y here to enable support for the NI Ettus Research 101 - USRP E3x0 Button. 101 + USRP E3xx Button. 102 102 103 103 To compile this driver as a module, choose M here: the 104 104 module will be called e3x0_button. ··· 599 599 will be called da9055_onkey. 600 600 601 601 config INPUT_DA9063_ONKEY 602 - tristate "Dialog DA9063 OnKey" 603 - depends on MFD_DA9063 602 + tristate "Dialog DA9062/63 OnKey" 603 + depends on MFD_DA9063 || MFD_DA9062 604 604 help 605 - Support the ONKEY of Dialog DA9063 Power Management IC as an 606 - input device reporting power button statue. 605 + Support the ONKEY of Dialog DA9063 and DA9062 Power Management ICs 606 + as an input device capable of reporting the power button status. 607 607 608 608 To compile this driver as a module, choose M here: the module 609 609 will be called da9063_onkey.
-10
drivers/input/misc/ad714x-i2c.c
··· 85 85 return 0; 86 86 } 87 87 88 - static int ad714x_i2c_remove(struct i2c_client *client) 89 - { 90 - struct ad714x_chip *chip = i2c_get_clientdata(client); 91 - 92 - ad714x_remove(chip); 93 - 94 - return 0; 95 - } 96 - 97 88 static const struct i2c_device_id ad714x_id[] = { 98 89 { "ad7142_captouch", 0 }, 99 90 { "ad7143_captouch", 0 }, ··· 101 110 .pm = &ad714x_i2c_pm, 102 111 }, 103 112 .probe = ad714x_i2c_probe, 104 - .remove = ad714x_i2c_remove, 105 113 .id_table = ad714x_id, 106 114 }; 107 115
-10
drivers/input/misc/ad714x-spi.c
··· 101 101 return 0; 102 102 } 103 103 104 - static int ad714x_spi_remove(struct spi_device *spi) 105 - { 106 - struct ad714x_chip *chip = spi_get_drvdata(spi); 107 - 108 - ad714x_remove(chip); 109 - 110 - return 0; 111 - } 112 - 113 104 static struct spi_driver ad714x_spi_driver = { 114 105 .driver = { 115 106 .name = "ad714x_captouch", 116 107 .pm = &ad714x_spi_pm, 117 108 }, 118 109 .probe = ad714x_spi_probe, 119 - .remove = ad714x_spi_remove, 120 110 }; 121 111 122 112 module_spi_driver(ad714x_spi_driver);
+79 -129
drivers/input/misc/ad714x.c
··· 960 960 return IRQ_HANDLED; 961 961 } 962 962 963 - #define MAX_DEVICE_NUM 8 964 963 struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, 965 964 ad714x_read_t read, ad714x_write_t write) 966 965 { 967 - int i, alloc_idx; 966 + int i; 968 967 int error; 969 - struct input_dev *input[MAX_DEVICE_NUM]; 968 + struct input_dev *input; 970 969 971 970 struct ad714x_platform_data *plat_data = dev_get_platdata(dev); 972 971 struct ad714x_chip *ad714x; ··· 981 982 if (irq <= 0) { 982 983 dev_err(dev, "IRQ not configured!\n"); 983 984 error = -EINVAL; 984 - goto err_out; 985 + return ERR_PTR(error); 985 986 } 986 987 987 988 if (dev_get_platdata(dev) == NULL) { 988 989 dev_err(dev, "platform data for ad714x doesn't exist\n"); 989 990 error = -EINVAL; 990 - goto err_out; 991 + return ERR_PTR(error); 991 992 } 992 993 993 - ad714x = kzalloc(sizeof(*ad714x) + sizeof(*ad714x->sw) + 994 - sizeof(*sd_drv) * plat_data->slider_num + 995 - sizeof(*wl_drv) * plat_data->wheel_num + 996 - sizeof(*tp_drv) * plat_data->touchpad_num + 997 - sizeof(*bt_drv) * plat_data->button_num, GFP_KERNEL); 994 + ad714x = devm_kzalloc(dev, sizeof(*ad714x) + sizeof(*ad714x->sw) + 995 + sizeof(*sd_drv) * plat_data->slider_num + 996 + sizeof(*wl_drv) * plat_data->wheel_num + 997 + sizeof(*tp_drv) * plat_data->touchpad_num + 998 + sizeof(*bt_drv) * plat_data->button_num, 999 + GFP_KERNEL); 998 1000 if (!ad714x) { 999 1001 error = -ENOMEM; 1000 - goto err_out; 1002 + return ERR_PTR(error); 1001 1003 } 1002 - 1003 1004 ad714x->hw = plat_data; 1004 1005 1005 1006 drv_mem = ad714x + 1; ··· 1021 1022 1022 1023 error = ad714x_hw_detect(ad714x); 1023 1024 if (error) 1024 - goto err_free_mem; 1025 + return ERR_PTR(error); 1025 1026 1026 1027 /* initialize and request sw/hw resources */ 1027 1028 1028 1029 ad714x_hw_init(ad714x); 1029 1030 mutex_init(&ad714x->mutex); 1030 1031 1031 - /* 1032 - * Allocate and register AD714X input device 1033 - */ 1034 - alloc_idx = 0; 1035 - 1036 1032 /* a slider uses one input_dev instance */ 1037 1033 if (ad714x->hw->slider_num > 0) { 1038 1034 struct ad714x_slider_plat *sd_plat = ad714x->hw->slider; 1039 1035 1040 1036 for (i = 0; i < ad714x->hw->slider_num; i++) { 1041 - sd_drv[i].input = input[alloc_idx] = input_allocate_device(); 1042 - if (!input[alloc_idx]) { 1043 - error = -ENOMEM; 1044 - goto err_free_dev; 1045 - } 1037 + input = devm_input_allocate_device(dev); 1038 + if (!input) 1039 + return ERR_PTR(-ENOMEM); 1046 1040 1047 - __set_bit(EV_ABS, input[alloc_idx]->evbit); 1048 - __set_bit(EV_KEY, input[alloc_idx]->evbit); 1049 - __set_bit(ABS_X, input[alloc_idx]->absbit); 1050 - __set_bit(BTN_TOUCH, input[alloc_idx]->keybit); 1051 - input_set_abs_params(input[alloc_idx], 1041 + __set_bit(EV_ABS, input->evbit); 1042 + __set_bit(EV_KEY, input->evbit); 1043 + __set_bit(ABS_X, input->absbit); 1044 + __set_bit(BTN_TOUCH, input->keybit); 1045 + input_set_abs_params(input, 1052 1046 ABS_X, 0, sd_plat->max_coord, 0, 0); 1053 1047 1054 - input[alloc_idx]->id.bustype = bus_type; 1055 - input[alloc_idx]->id.product = ad714x->product; 1056 - input[alloc_idx]->id.version = ad714x->version; 1057 - input[alloc_idx]->name = "ad714x_captouch_slider"; 1058 - input[alloc_idx]->dev.parent = dev; 1048 + input->id.bustype = bus_type; 1049 + input->id.product = ad714x->product; 1050 + input->id.version = ad714x->version; 1051 + input->name = "ad714x_captouch_slider"; 1052 + input->dev.parent = dev; 1059 1053 1060 - error = input_register_device(input[alloc_idx]); 1054 + error = input_register_device(input); 1061 1055 if (error) 1062 - goto err_free_dev; 1056 + return ERR_PTR(error); 1063 1057 1064 - alloc_idx++; 1058 + sd_drv[i].input = input; 1065 1059 } 1066 1060 } 1067 1061 ··· 1063 1071 struct ad714x_wheel_plat *wl_plat = ad714x->hw->wheel; 1064 1072 1065 1073 for (i = 0; i < ad714x->hw->wheel_num; i++) { 1066 - wl_drv[i].input = input[alloc_idx] = input_allocate_device(); 1067 - if (!input[alloc_idx]) { 1068 - error = -ENOMEM; 1069 - goto err_free_dev; 1070 - } 1074 + input = devm_input_allocate_device(dev); 1075 + if (!input) 1076 + return ERR_PTR(-ENOMEM); 1071 1077 1072 - __set_bit(EV_KEY, input[alloc_idx]->evbit); 1073 - __set_bit(EV_ABS, input[alloc_idx]->evbit); 1074 - __set_bit(ABS_WHEEL, input[alloc_idx]->absbit); 1075 - __set_bit(BTN_TOUCH, input[alloc_idx]->keybit); 1076 - input_set_abs_params(input[alloc_idx], 1078 + __set_bit(EV_KEY, input->evbit); 1079 + __set_bit(EV_ABS, input->evbit); 1080 + __set_bit(ABS_WHEEL, input->absbit); 1081 + __set_bit(BTN_TOUCH, input->keybit); 1082 + input_set_abs_params(input, 1077 1083 ABS_WHEEL, 0, wl_plat->max_coord, 0, 0); 1078 1084 1079 - input[alloc_idx]->id.bustype = bus_type; 1080 - input[alloc_idx]->id.product = ad714x->product; 1081 - input[alloc_idx]->id.version = ad714x->version; 1082 - input[alloc_idx]->name = "ad714x_captouch_wheel"; 1083 - input[alloc_idx]->dev.parent = dev; 1085 + input->id.bustype = bus_type; 1086 + input->id.product = ad714x->product; 1087 + input->id.version = ad714x->version; 1088 + input->name = "ad714x_captouch_wheel"; 1089 + input->dev.parent = dev; 1084 1090 1085 - error = input_register_device(input[alloc_idx]); 1091 + error = input_register_device(input); 1086 1092 if (error) 1087 - goto err_free_dev; 1093 + return ERR_PTR(error); 1088 1094 1089 - alloc_idx++; 1095 + wl_drv[i].input = input; 1090 1096 } 1091 1097 } 1092 1098 ··· 1093 1103 struct ad714x_touchpad_plat *tp_plat = ad714x->hw->touchpad; 1094 1104 1095 1105 for (i = 0; i < ad714x->hw->touchpad_num; i++) { 1096 - tp_drv[i].input = input[alloc_idx] = input_allocate_device(); 1097 - if (!input[alloc_idx]) { 1098 - error = -ENOMEM; 1099 - goto err_free_dev; 1100 - } 1106 + input = devm_input_allocate_device(dev); 1107 + if (!input) 1108 + return ERR_PTR(-ENOMEM); 1101 1109 1102 - __set_bit(EV_ABS, input[alloc_idx]->evbit); 1103 - __set_bit(EV_KEY, input[alloc_idx]->evbit); 1104 - __set_bit(ABS_X, input[alloc_idx]->absbit); 1105 - __set_bit(ABS_Y, input[alloc_idx]->absbit); 1106 - __set_bit(BTN_TOUCH, input[alloc_idx]->keybit); 1107 - input_set_abs_params(input[alloc_idx], 1110 + __set_bit(EV_ABS, input->evbit); 1111 + __set_bit(EV_KEY, input->evbit); 1112 + __set_bit(ABS_X, input->absbit); 1113 + __set_bit(ABS_Y, input->absbit); 1114 + __set_bit(BTN_TOUCH, input->keybit); 1115 + input_set_abs_params(input, 1108 1116 ABS_X, 0, tp_plat->x_max_coord, 0, 0); 1109 - input_set_abs_params(input[alloc_idx], 1117 + input_set_abs_params(input, 1110 1118 ABS_Y, 0, tp_plat->y_max_coord, 0, 0); 1111 1119 1112 - input[alloc_idx]->id.bustype = bus_type; 1113 - input[alloc_idx]->id.product = ad714x->product; 1114 - input[alloc_idx]->id.version = ad714x->version; 1115 - input[alloc_idx]->name = "ad714x_captouch_pad"; 1116 - input[alloc_idx]->dev.parent = dev; 1120 + input->id.bustype = bus_type; 1121 + input->id.product = ad714x->product; 1122 + input->id.version = ad714x->version; 1123 + input->name = "ad714x_captouch_pad"; 1124 + input->dev.parent = dev; 1117 1125 1118 - error = input_register_device(input[alloc_idx]); 1126 + error = input_register_device(input); 1119 1127 if (error) 1120 - goto err_free_dev; 1128 + return ERR_PTR(error); 1121 1129 1122 - alloc_idx++; 1130 + tp_drv[i].input = input; 1123 1131 } 1124 1132 } 1125 1133 ··· 1125 1137 if (ad714x->hw->button_num > 0) { 1126 1138 struct ad714x_button_plat *bt_plat = ad714x->hw->button; 1127 1139 1128 - input[alloc_idx] = input_allocate_device(); 1129 - if (!input[alloc_idx]) { 1140 + input = devm_input_allocate_device(dev); 1141 + if (!input) { 1130 1142 error = -ENOMEM; 1131 - goto err_free_dev; 1143 + return ERR_PTR(error); 1132 1144 } 1133 1145 1134 - __set_bit(EV_KEY, input[alloc_idx]->evbit); 1146 + __set_bit(EV_KEY, input->evbit); 1135 1147 for (i = 0; i < ad714x->hw->button_num; i++) { 1136 - bt_drv[i].input = input[alloc_idx]; 1137 - __set_bit(bt_plat[i].keycode, input[alloc_idx]->keybit); 1148 + bt_drv[i].input = input; 1149 + __set_bit(bt_plat[i].keycode, input->keybit); 1138 1150 } 1139 1151 1140 - input[alloc_idx]->id.bustype = bus_type; 1141 - input[alloc_idx]->id.product = ad714x->product; 1142 - input[alloc_idx]->id.version = ad714x->version; 1143 - input[alloc_idx]->name = "ad714x_captouch_button"; 1144 - input[alloc_idx]->dev.parent = dev; 1152 + input->id.bustype = bus_type; 1153 + input->id.product = ad714x->product; 1154 + input->id.version = ad714x->version; 1155 + input->name = "ad714x_captouch_button"; 1156 + input->dev.parent = dev; 1145 1157 1146 - error = input_register_device(input[alloc_idx]); 1158 + error = input_register_device(input); 1147 1159 if (error) 1148 - goto err_free_dev; 1149 - 1150 - alloc_idx++; 1160 + return ERR_PTR(error); 1151 1161 } 1152 1162 1153 1163 irqflags = plat_data->irqflags ?: IRQF_TRIGGER_FALLING; 1154 1164 irqflags |= IRQF_ONESHOT; 1155 1165 1156 - error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread, 1157 - irqflags, "ad714x_captouch", ad714x); 1166 + error = devm_request_threaded_irq(dev, ad714x->irq, NULL, 1167 + ad714x_interrupt_thread, 1168 + irqflags, "ad714x_captouch", ad714x); 1158 1169 if (error) { 1159 1170 dev_err(dev, "can't allocate irq %d\n", ad714x->irq); 1160 - goto err_unreg_dev; 1171 + return ERR_PTR(error); 1161 1172 } 1162 1173 1163 1174 return ad714x; 1164 - 1165 - err_free_dev: 1166 - dev_err(dev, "failed to setup AD714x input device %i\n", alloc_idx); 1167 - input_free_device(input[alloc_idx]); 1168 - err_unreg_dev: 1169 - while (--alloc_idx >= 0) 1170 - input_unregister_device(input[alloc_idx]); 1171 - err_free_mem: 1172 - kfree(ad714x); 1173 - err_out: 1174 - return ERR_PTR(error); 1175 1175 } 1176 1176 EXPORT_SYMBOL(ad714x_probe); 1177 - 1178 - void ad714x_remove(struct ad714x_chip *ad714x) 1179 - { 1180 - struct ad714x_platform_data *hw = ad714x->hw; 1181 - struct ad714x_driver_data *sw = ad714x->sw; 1182 - int i; 1183 - 1184 - free_irq(ad714x->irq, ad714x); 1185 - 1186 - /* unregister and free all input devices */ 1187 - 1188 - for (i = 0; i < hw->slider_num; i++) 1189 - input_unregister_device(sw->slider[i].input); 1190 - 1191 - for (i = 0; i < hw->wheel_num; i++) 1192 - input_unregister_device(sw->wheel[i].input); 1193 - 1194 - for (i = 0; i < hw->touchpad_num; i++) 1195 - input_unregister_device(sw->touchpad[i].input); 1196 - 1197 - if (hw->button_num) 1198 - input_unregister_device(sw->button[0].input); 1199 - 1200 - kfree(ad714x); 1201 - } 1202 - EXPORT_SYMBOL(ad714x_remove); 1203 1177 1204 1178 #ifdef CONFIG_PM 1205 1179 int ad714x_disable(struct ad714x_chip *ad714x)
-1
drivers/input/misc/ad714x.h
··· 50 50 int ad714x_enable(struct ad714x_chip *ad714x); 51 51 struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq, 52 52 ad714x_read_t read, ad714x_write_t write); 53 - void ad714x_remove(struct ad714x_chip *ad714x); 54 53 55 54 #endif
+104 -25
drivers/input/misc/da9063_onkey.c
··· 1 1 /* 2 - * OnKey device driver for DA9063 2 + * OnKey device driver for DA9063 and DA9062 PMICs 3 3 * Copyright (C) 2015 Dialog Semiconductor Ltd. 4 4 * 5 5 * This program is free software; you can redistribute it and/or ··· 24 24 #include <linux/mfd/da9063/core.h> 25 25 #include <linux/mfd/da9063/pdata.h> 26 26 #include <linux/mfd/da9063/registers.h> 27 + #include <linux/mfd/da9062/core.h> 28 + #include <linux/mfd/da9062/registers.h> 29 + 30 + struct da906x_chip_config { 31 + /* REGS */ 32 + int onkey_status; 33 + int onkey_pwr_signalling; 34 + int onkey_fault_log; 35 + int onkey_shutdown; 36 + /* MASKS */ 37 + int onkey_nonkey_mask; 38 + int onkey_nonkey_lock_mask; 39 + int onkey_key_reset_mask; 40 + int onkey_shutdown_mask; 41 + /* NAMES */ 42 + const char *name; 43 + }; 27 44 28 45 struct da9063_onkey { 29 - struct da9063 *hw; 30 46 struct delayed_work work; 31 47 struct input_dev *input; 32 48 struct device *dev; 49 + struct regmap *regmap; 50 + const struct da906x_chip_config *config; 51 + char phys[32]; 33 52 bool key_power; 53 + }; 54 + 55 + static const struct da906x_chip_config da9063_regs = { 56 + /* REGS */ 57 + .onkey_status = DA9063_REG_STATUS_A, 58 + .onkey_pwr_signalling = DA9063_REG_CONTROL_B, 59 + .onkey_fault_log = DA9063_REG_FAULT_LOG, 60 + .onkey_shutdown = DA9063_REG_CONTROL_F, 61 + /* MASKS */ 62 + .onkey_nonkey_mask = DA9063_NONKEY, 63 + .onkey_nonkey_lock_mask = DA9063_NONKEY_LOCK, 64 + .onkey_key_reset_mask = DA9063_KEY_RESET, 65 + .onkey_shutdown_mask = DA9063_SHUTDOWN, 66 + /* NAMES */ 67 + .name = DA9063_DRVNAME_ONKEY, 68 + }; 69 + 70 + static const struct da906x_chip_config da9062_regs = { 71 + /* REGS */ 72 + .onkey_status = DA9062AA_STATUS_A, 73 + .onkey_pwr_signalling = DA9062AA_CONTROL_B, 74 + .onkey_fault_log = DA9062AA_FAULT_LOG, 75 + .onkey_shutdown = DA9062AA_CONTROL_F, 76 + /* MASKS */ 77 + .onkey_nonkey_mask = DA9062AA_NONKEY_MASK, 78 + .onkey_nonkey_lock_mask = DA9062AA_NONKEY_LOCK_MASK, 79 + .onkey_key_reset_mask = DA9062AA_KEY_RESET_MASK, 80 + .onkey_shutdown_mask = DA9062AA_SHUTDOWN_MASK, 81 + /* NAMES */ 82 + .name = "da9062-onkey", 83 + }; 84 + 85 + static const struct of_device_id da9063_compatible_reg_id_table[] = { 86 + { .compatible = "dlg,da9063-onkey", .data = &da9063_regs }, 87 + { .compatible = "dlg,da9062-onkey", .data = &da9062_regs }, 88 + { }, 34 89 }; 35 90 36 91 static void da9063_poll_on(struct work_struct *work) 37 92 { 38 - struct da9063_onkey *onkey = container_of(work, struct da9063_onkey, 39 - work.work); 93 + struct da9063_onkey *onkey = container_of(work, 94 + struct da9063_onkey, 95 + work.work); 96 + const struct da906x_chip_config *config = onkey->config; 40 97 unsigned int val; 41 98 int fault_log = 0; 42 99 bool poll = true; 43 100 int error; 44 101 45 102 /* Poll to see when the pin is released */ 46 - error = regmap_read(onkey->hw->regmap, DA9063_REG_STATUS_A, &val); 103 + error = regmap_read(onkey->regmap, 104 + config->onkey_status, 105 + &val); 47 106 if (error) { 48 107 dev_err(onkey->dev, 49 108 "Failed to read ON status: %d\n", error); 50 109 goto err_poll; 51 110 } 52 111 53 - if (!(val & DA9063_NONKEY)) { 54 - error = regmap_update_bits(onkey->hw->regmap, 55 - DA9063_REG_CONTROL_B, 56 - DA9063_NONKEY_LOCK, 0); 112 + if (!(val & config->onkey_nonkey_mask)) { 113 + error = regmap_update_bits(onkey->regmap, 114 + config->onkey_pwr_signalling, 115 + config->onkey_nonkey_lock_mask, 116 + 0); 57 117 if (error) { 58 118 dev_err(onkey->dev, 59 119 "Failed to reset the Key Delay %d\n", error); ··· 130 70 * If the fault log KEY_RESET is detected, then clear it 131 71 * and shut down the system. 132 72 */ 133 - error = regmap_read(onkey->hw->regmap, 134 - DA9063_REG_FAULT_LOG, &fault_log); 73 + error = regmap_read(onkey->regmap, 74 + config->onkey_fault_log, 75 + &fault_log); 135 76 if (error) { 136 77 dev_warn(&onkey->input->dev, 137 78 "Cannot read FAULT_LOG: %d\n", error); 138 - } else if (fault_log & DA9063_KEY_RESET) { 139 - error = regmap_write(onkey->hw->regmap, 140 - DA9063_REG_FAULT_LOG, 141 - DA9063_KEY_RESET); 79 + } else if (fault_log & config->onkey_key_reset_mask) { 80 + error = regmap_write(onkey->regmap, 81 + config->onkey_fault_log, 82 + config->onkey_key_reset_mask); 142 83 if (error) { 143 84 dev_warn(&onkey->input->dev, 144 85 "Cannot reset KEY_RESET fault log: %d\n", ··· 149 88 * and then send shutdown command 150 89 */ 151 90 dev_dbg(&onkey->input->dev, 152 - "Sending SHUTDOWN to DA9063 ...\n"); 153 - error = regmap_write(onkey->hw->regmap, 154 - DA9063_REG_CONTROL_F, 155 - DA9063_SHUTDOWN); 91 + "Sending SHUTDOWN to DA9063 ...\n"); 92 + error = regmap_write(onkey->regmap, 93 + config->onkey_shutdown, 94 + config->onkey_shutdown_mask); 156 95 if (error) 157 96 dev_err(&onkey->input->dev, 158 97 "Cannot SHUTDOWN DA9063: %d\n", ··· 168 107 static irqreturn_t da9063_onkey_irq_handler(int irq, void *data) 169 108 { 170 109 struct da9063_onkey *onkey = data; 110 + const struct da906x_chip_config *config = onkey->config; 171 111 unsigned int val; 172 112 int error; 173 113 174 - error = regmap_read(onkey->hw->regmap, DA9063_REG_STATUS_A, &val); 175 - if (onkey->key_power && !error && (val & DA9063_NONKEY)) { 114 + error = regmap_read(onkey->regmap, 115 + config->onkey_status, 116 + &val); 117 + if (onkey->key_power && !error && (val & config->onkey_nonkey_mask)) { 176 118 input_report_key(onkey->input, KEY_POWER, 1); 177 119 input_sync(onkey->input); 178 120 schedule_delayed_work(&onkey->work, 0); ··· 203 139 struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); 204 140 struct da9063_pdata *pdata = dev_get_platdata(da9063->dev); 205 141 struct da9063_onkey *onkey; 142 + const struct of_device_id *match; 206 143 int irq; 207 144 int error; 145 + 146 + match = of_match_node(da9063_compatible_reg_id_table, 147 + pdev->dev.of_node); 148 + if (!match) 149 + return -ENXIO; 208 150 209 151 onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey), 210 152 GFP_KERNEL); ··· 219 149 return -ENOMEM; 220 150 } 221 151 152 + onkey->config = match->data; 222 153 onkey->dev = &pdev->dev; 223 - onkey->hw = da9063; 154 + 155 + onkey->regmap = dev_get_regmap(pdev->dev.parent, NULL); 156 + if (!onkey->regmap) { 157 + dev_err(&pdev->dev, "Parent regmap unavailable.\n"); 158 + return -ENXIO; 159 + } 224 160 225 161 if (pdata) 226 162 onkey->key_power = pdata->key_power; ··· 241 165 return -ENOMEM; 242 166 } 243 167 244 - onkey->input->name = DA9063_DRVNAME_ONKEY; 245 - onkey->input->phys = DA9063_DRVNAME_ONKEY "/input0"; 168 + onkey->input->name = onkey->config->name; 169 + snprintf(onkey->phys, sizeof(onkey->phys), "%s/input0", 170 + onkey->config->name); 171 + onkey->input->phys = onkey->phys; 246 172 onkey->input->dev.parent = &pdev->dev; 247 173 248 174 if (onkey->key_power) ··· 294 216 .probe = da9063_onkey_probe, 295 217 .driver = { 296 218 .name = DA9063_DRVNAME_ONKEY, 219 + .of_match_table = da9063_compatible_reg_id_table, 297 220 }, 298 221 }; 299 222 module_platform_driver(da9063_onkey_driver); 300 223 301 224 MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>"); 302 - MODULE_DESCRIPTION("Onkey device driver for Dialog DA9063"); 225 + MODULE_DESCRIPTION("Onkey device driver for Dialog DA9063 and DA9062"); 303 226 MODULE_LICENSE("GPL"); 304 227 MODULE_ALIAS("platform:" DA9063_DRVNAME_ONKEY);
+26 -26
drivers/input/misc/hp_sdc_rtc.c
··· 198 198 199 199 200 200 /* Read the i8042 real-time clock */ 201 - static inline int hp_sdc_rtc_read_rt(struct timeval *res) { 201 + static inline int hp_sdc_rtc_read_rt(struct timespec64 *res) { 202 202 int64_t raw; 203 203 uint32_t tenms; 204 204 unsigned int days; ··· 209 209 tenms = (uint32_t)raw & 0xffffff; 210 210 days = (unsigned int)(raw >> 24) & 0xffff; 211 211 212 - res->tv_usec = (suseconds_t)(tenms % 100) * 10000; 213 - res->tv_sec = (time_t)(tenms / 100) + days * 86400; 212 + res->tv_nsec = (long)(tenms % 100) * 10000 * 1000; 213 + res->tv_sec = (tenms / 100) + (time64_t)days * 86400; 214 214 215 215 return 0; 216 216 } 217 217 218 218 219 219 /* Read the i8042 fast handshake timer */ 220 - static inline int hp_sdc_rtc_read_fhs(struct timeval *res) { 220 + static inline int hp_sdc_rtc_read_fhs(struct timespec64 *res) { 221 221 int64_t raw; 222 222 unsigned int tenms; 223 223 ··· 226 226 227 227 tenms = (unsigned int)raw & 0xffff; 228 228 229 - res->tv_usec = (suseconds_t)(tenms % 100) * 10000; 230 - res->tv_sec = (time_t)(tenms / 100); 229 + res->tv_nsec = (long)(tenms % 100) * 10000 * 1000; 230 + res->tv_sec = (time64_t)(tenms / 100); 231 231 232 232 return 0; 233 233 } 234 234 235 235 236 236 /* Read the i8042 match timer (a.k.a. alarm) */ 237 - static inline int hp_sdc_rtc_read_mt(struct timeval *res) { 237 + static inline int hp_sdc_rtc_read_mt(struct timespec64 *res) { 238 238 int64_t raw; 239 239 uint32_t tenms; 240 240 ··· 243 243 244 244 tenms = (uint32_t)raw & 0xffffff; 245 245 246 - res->tv_usec = (suseconds_t)(tenms % 100) * 10000; 247 - res->tv_sec = (time_t)(tenms / 100); 246 + res->tv_nsec = (long)(tenms % 100) * 10000 * 1000; 247 + res->tv_sec = (time64_t)(tenms / 100); 248 248 249 249 return 0; 250 250 } 251 251 252 252 253 253 /* Read the i8042 delay timer */ 254 - static inline int hp_sdc_rtc_read_dt(struct timeval *res) { 254 + static inline int hp_sdc_rtc_read_dt(struct timespec64 *res) { 255 255 int64_t raw; 256 256 uint32_t tenms; 257 257 ··· 260 260 261 261 tenms = (uint32_t)raw & 0xffffff; 262 262 263 - res->tv_usec = (suseconds_t)(tenms % 100) * 10000; 264 - res->tv_sec = (time_t)(tenms / 100); 263 + res->tv_nsec = (long)(tenms % 100) * 10000 * 1000; 264 + res->tv_sec = (time64_t)(tenms / 100); 265 265 266 266 return 0; 267 267 } 268 268 269 269 270 270 /* Read the i8042 cycle timer (a.k.a. periodic) */ 271 - static inline int hp_sdc_rtc_read_ct(struct timeval *res) { 271 + static inline int hp_sdc_rtc_read_ct(struct timespec64 *res) { 272 272 int64_t raw; 273 273 uint32_t tenms; 274 274 ··· 277 277 278 278 tenms = (uint32_t)raw & 0xffffff; 279 279 280 - res->tv_usec = (suseconds_t)(tenms % 100) * 10000; 281 - res->tv_sec = (time_t)(tenms / 100); 280 + res->tv_nsec = (long)(tenms % 100) * 10000 * 1000; 281 + res->tv_sec = (time64_t)(tenms / 100); 282 282 283 283 return 0; 284 284 } ··· 433 433 #define YN(bit) ("no") 434 434 #define NY(bit) ("yes") 435 435 struct rtc_time tm; 436 - struct timeval tv; 436 + struct timespec64 tv; 437 437 438 438 memset(&tm, 0, sizeof(struct rtc_time)); 439 439 ··· 452 452 if (hp_sdc_rtc_read_rt(&tv)) { 453 453 seq_puts(m, "i8042 rtc\t: READ FAILED!\n"); 454 454 } else { 455 - seq_printf(m, "i8042 rtc\t: %ld.%02d seconds\n", 456 - tv.tv_sec, (int)tv.tv_usec/1000); 455 + seq_printf(m, "i8042 rtc\t: %lld.%02ld seconds\n", 456 + (s64)tv.tv_sec, (long)tv.tv_nsec/1000000L); 457 457 } 458 458 459 459 if (hp_sdc_rtc_read_fhs(&tv)) { 460 460 seq_puts(m, "handshake\t: READ FAILED!\n"); 461 461 } else { 462 - seq_printf(m, "handshake\t: %ld.%02d seconds\n", 463 - tv.tv_sec, (int)tv.tv_usec/1000); 462 + seq_printf(m, "handshake\t: %lld.%02ld seconds\n", 463 + (s64)tv.tv_sec, (long)tv.tv_nsec/1000000L); 464 464 } 465 465 466 466 if (hp_sdc_rtc_read_mt(&tv)) { 467 467 seq_puts(m, "alarm\t\t: READ FAILED!\n"); 468 468 } else { 469 - seq_printf(m, "alarm\t\t: %ld.%02d seconds\n", 470 - tv.tv_sec, (int)tv.tv_usec/1000); 469 + seq_printf(m, "alarm\t\t: %lld.%02ld seconds\n", 470 + (s64)tv.tv_sec, (long)tv.tv_nsec/1000000L); 471 471 } 472 472 473 473 if (hp_sdc_rtc_read_dt(&tv)) { 474 474 seq_puts(m, "delay\t\t: READ FAILED!\n"); 475 475 } else { 476 - seq_printf(m, "delay\t\t: %ld.%02d seconds\n", 477 - tv.tv_sec, (int)tv.tv_usec/1000); 476 + seq_printf(m, "delay\t\t: %lld.%02ld seconds\n", 477 + (s64)tv.tv_sec, (long)tv.tv_nsec/1000000L); 478 478 } 479 479 480 480 if (hp_sdc_rtc_read_ct(&tv)) { 481 481 seq_puts(m, "periodic\t: READ FAILED!\n"); 482 482 } else { 483 - seq_printf(m, "periodic\t: %ld.%02d seconds\n", 484 - tv.tv_sec, (int)tv.tv_usec/1000); 483 + seq_printf(m, "periodic\t: %lld.%02ld seconds\n", 484 + (s64)tv.tv_sec, (long)tv.tv_nsec/1000000L); 485 485 } 486 486 487 487 seq_printf(m,
+1 -2
drivers/input/misc/kxtj9.c
··· 635 635 struct i2c_client *client = to_i2c_client(dev); 636 636 struct kxtj9_data *tj9 = i2c_get_clientdata(client); 637 637 struct input_dev *input_dev = tj9->input_dev; 638 - int retval = 0; 639 638 640 639 mutex_lock(&input_dev->mutex); 641 640 ··· 642 643 kxtj9_enable(tj9); 643 644 644 645 mutex_unlock(&input_dev->mutex); 645 - return retval; 646 + return 0; 646 647 } 647 648 648 649 static SIMPLE_DEV_PM_OPS(kxtj9_pm_ops, kxtj9_suspend, kxtj9_resume);
+120 -9
drivers/input/misc/rotary_encoder.c
··· 26 26 #include <linux/of.h> 27 27 #include <linux/of_platform.h> 28 28 #include <linux/of_gpio.h> 29 + #include <linux/pm.h> 29 30 30 31 #define DRV_NAME "rotary-encoder" 31 32 ··· 143 142 return IRQ_HANDLED; 144 143 } 145 144 145 + static irqreturn_t rotary_encoder_quarter_period_irq(int irq, void *dev_id) 146 + { 147 + struct rotary_encoder *encoder = dev_id; 148 + unsigned char sum; 149 + int state; 150 + 151 + state = rotary_encoder_get_state(encoder->pdata); 152 + 153 + /* 154 + * We encode the previous and the current state using a byte. 155 + * The previous state in the MSB nibble, the current state in the LSB 156 + * nibble. Then use a table to decide the direction of the turn. 157 + */ 158 + sum = (encoder->last_stable << 4) + state; 159 + switch (sum) { 160 + case 0x31: 161 + case 0x10: 162 + case 0x02: 163 + case 0x23: 164 + encoder->dir = 0; /* clockwise */ 165 + break; 166 + 167 + case 0x13: 168 + case 0x01: 169 + case 0x20: 170 + case 0x32: 171 + encoder->dir = 1; /* counter-clockwise */ 172 + break; 173 + 174 + default: 175 + /* 176 + * Ignore all other values. This covers the case when the 177 + * state didn't change (a spurious interrupt) and the 178 + * cases where the state changed by two steps, making it 179 + * impossible to tell the direction. 180 + * 181 + * In either case, don't report any event and save the 182 + * state for later. 183 + */ 184 + goto out; 185 + } 186 + 187 + rotary_encoder_report_event(encoder); 188 + 189 + out: 190 + encoder->last_stable = state; 191 + return IRQ_HANDLED; 192 + } 193 + 146 194 #ifdef CONFIG_OF 147 195 static const struct of_device_id rotary_encoder_of_match[] = { 148 196 { .compatible = "rotary-encoder", }, ··· 206 156 struct device_node *np = dev->of_node; 207 157 struct rotary_encoder_platform_data *pdata; 208 158 enum of_gpio_flags flags; 159 + int error; 209 160 210 161 if (!of_id || !np) 211 162 return NULL; ··· 225 174 pdata->gpio_b = of_get_gpio_flags(np, 1, &flags); 226 175 pdata->inverted_b = flags & OF_GPIO_ACTIVE_LOW; 227 176 228 - pdata->relative_axis = !!of_get_property(np, 229 - "rotary-encoder,relative-axis", NULL); 230 - pdata->rollover = !!of_get_property(np, 231 - "rotary-encoder,rollover", NULL); 232 - pdata->half_period = !!of_get_property(np, 233 - "rotary-encoder,half-period", NULL); 177 + pdata->relative_axis = 178 + of_property_read_bool(np, "rotary-encoder,relative-axis"); 179 + pdata->rollover = of_property_read_bool(np, "rotary-encoder,rollover"); 180 + 181 + error = of_property_read_u32(np, "rotary-encoder,steps-per-period", 182 + &pdata->steps_per_period); 183 + if (error) { 184 + /* 185 + * The 'half-period' property has been deprecated, you must use 186 + * 'steps-per-period' and set an appropriate value, but we still 187 + * need to parse it to maintain compatibility. 188 + */ 189 + if (of_property_read_bool(np, "rotary-encoder,half-period")) { 190 + pdata->steps_per_period = 2; 191 + } else { 192 + /* Fallback to one step per period behavior */ 193 + pdata->steps_per_period = 1; 194 + } 195 + } 196 + 197 + pdata->wakeup_source = of_property_read_bool(np, "wakeup-source"); 234 198 235 199 return pdata; 236 200 } ··· 316 250 encoder->irq_a = gpio_to_irq(pdata->gpio_a); 317 251 encoder->irq_b = gpio_to_irq(pdata->gpio_b); 318 252 319 - /* request the IRQs */ 320 - if (pdata->half_period) { 253 + switch (pdata->steps_per_period) { 254 + case 4: 255 + handler = &rotary_encoder_quarter_period_irq; 256 + encoder->last_stable = rotary_encoder_get_state(pdata); 257 + break; 258 + case 2: 321 259 handler = &rotary_encoder_half_period_irq; 322 260 encoder->last_stable = rotary_encoder_get_state(pdata); 323 - } else { 261 + break; 262 + case 1: 324 263 handler = &rotary_encoder_irq; 264 + break; 265 + default: 266 + dev_err(dev, "'%d' is not a valid steps-per-period value\n", 267 + pdata->steps_per_period); 268 + err = -EINVAL; 269 + goto exit_free_gpio_b; 325 270 } 326 271 327 272 err = request_irq(encoder->irq_a, handler, ··· 356 279 dev_err(dev, "failed to register input device\n"); 357 280 goto exit_free_irq_b; 358 281 } 282 + 283 + device_init_wakeup(&pdev->dev, pdata->wakeup_source); 359 284 360 285 platform_set_drvdata(pdev, encoder); 361 286 ··· 385 306 struct rotary_encoder *encoder = platform_get_drvdata(pdev); 386 307 const struct rotary_encoder_platform_data *pdata = encoder->pdata; 387 308 309 + device_init_wakeup(&pdev->dev, false); 310 + 388 311 free_irq(encoder->irq_a, encoder); 389 312 free_irq(encoder->irq_b, encoder); 390 313 gpio_free(pdata->gpio_a); ··· 401 320 return 0; 402 321 } 403 322 323 + #ifdef CONFIG_PM_SLEEP 324 + static int rotary_encoder_suspend(struct device *dev) 325 + { 326 + struct rotary_encoder *encoder = dev_get_drvdata(dev); 327 + 328 + if (device_may_wakeup(dev)) { 329 + enable_irq_wake(encoder->irq_a); 330 + enable_irq_wake(encoder->irq_b); 331 + } 332 + 333 + return 0; 334 + } 335 + 336 + static int rotary_encoder_resume(struct device *dev) 337 + { 338 + struct rotary_encoder *encoder = dev_get_drvdata(dev); 339 + 340 + if (device_may_wakeup(dev)) { 341 + disable_irq_wake(encoder->irq_a); 342 + disable_irq_wake(encoder->irq_b); 343 + } 344 + 345 + return 0; 346 + } 347 + #endif 348 + 349 + static SIMPLE_DEV_PM_OPS(rotary_encoder_pm_ops, 350 + rotary_encoder_suspend, rotary_encoder_resume); 351 + 404 352 static struct platform_driver rotary_encoder_driver = { 405 353 .probe = rotary_encoder_probe, 406 354 .remove = rotary_encoder_remove, 407 355 .driver = { 408 356 .name = DRV_NAME, 357 + .pm = &rotary_encoder_pm_ops, 409 358 .of_match_table = of_match_ptr(rotary_encoder_of_match), 410 359 } 411 360 };
+8 -2
drivers/input/misc/xen-kbdfront.c
··· 129 129 130 130 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0) 131 131 abs = 0; 132 - if (abs) 133 - xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1"); 132 + if (abs) { 133 + ret = xenbus_printf(XBT_NIL, dev->nodename, 134 + "request-abs-pointer", "1"); 135 + if (ret) { 136 + pr_warning("xenkbd: can't request abs-pointer"); 137 + abs = 0; 138 + } 139 + } 134 140 135 141 /* keyboard */ 136 142 kbd = input_allocate_device();
+14
drivers/input/serio/Kconfig
··· 292 292 To compile this driver as a module, choose M here: the 293 293 module will be called sun4i-ps2. 294 294 295 + config USERIO 296 + tristate "User space serio port driver support" 297 + help 298 + Say Y here if you want to support user level drivers for serio 299 + subsystem accessible under char device 10:240 - /dev/userio. Using 300 + this facility userspace programs can implement serio ports that 301 + will be used by the standard in-kernel serio consumer drivers, 302 + such as psmouse and atkbd. 303 + 304 + To compile this driver as a module, choose M here: the module will be 305 + called userio. 306 + 307 + If you are unsure, say N. 308 + 295 309 endif
+1
drivers/input/serio/Makefile
··· 30 30 obj-$(CONFIG_SERIO_OLPC_APSP) += olpc_apsp.o 31 31 obj-$(CONFIG_HYPERV_KEYBOARD) += hyperv-keyboard.o 32 32 obj-$(CONFIG_SERIO_SUN4I_PS2) += sun4i-ps2.o 33 + obj-$(CONFIG_USERIO) += userio.o
+39 -20
drivers/input/serio/parkbd.c
··· 141 141 parkbd_last = jiffies; 142 142 } 143 143 144 - static int parkbd_getport(void) 144 + static int parkbd_getport(struct parport *pp) 145 145 { 146 - struct parport *pp; 146 + struct pardev_cb parkbd_parport_cb; 147 147 148 - pp = parport_find_number(parkbd_pp_no); 148 + parkbd_parport_cb.irq_func = parkbd_interrupt; 149 + parkbd_parport_cb.flags = PARPORT_FLAG_EXCL; 149 150 150 - if (pp == NULL) { 151 - printk(KERN_ERR "parkbd: no such parport\n"); 152 - return -ENODEV; 153 - } 154 - 155 - parkbd_dev = parport_register_device(pp, "parkbd", NULL, NULL, parkbd_interrupt, PARPORT_DEV_EXCL, NULL); 156 - parport_put_port(pp); 151 + parkbd_dev = parport_register_dev_model(pp, "parkbd", 152 + &parkbd_parport_cb, 0); 157 153 158 154 if (!parkbd_dev) 159 155 return -ENODEV; ··· 179 183 return serio; 180 184 } 181 185 182 - static int __init parkbd_init(void) 186 + static void parkbd_attach(struct parport *pp) 183 187 { 184 - int err; 188 + if (pp->number != parkbd_pp_no) { 189 + pr_debug("Not using parport%d.\n", pp->number); 190 + return; 191 + } 185 192 186 - err = parkbd_getport(); 187 - if (err) 188 - return err; 193 + if (parkbd_getport(pp)) 194 + return; 189 195 190 196 parkbd_port = parkbd_allocate_serio(); 191 197 if (!parkbd_port) { 192 198 parport_release(parkbd_dev); 193 199 parport_unregister_device(parkbd_dev); 194 - return -ENOMEM; 200 + return; 195 201 } 196 202 197 203 parkbd_writelines(3); ··· 203 205 printk(KERN_INFO "serio: PARKBD %s adapter on %s\n", 204 206 parkbd_mode ? "AT" : "XT", parkbd_dev->port->name); 205 207 206 - return 0; 208 + return; 209 + } 210 + 211 + static void parkbd_detach(struct parport *port) 212 + { 213 + if (!parkbd_port || port->number != parkbd_pp_no) 214 + return; 215 + 216 + parport_release(parkbd_dev); 217 + serio_unregister_port(parkbd_port); 218 + parport_unregister_device(parkbd_dev); 219 + parkbd_port = NULL; 220 + } 221 + 222 + static struct parport_driver parkbd_parport_driver = { 223 + .name = "parkbd", 224 + .match_port = parkbd_attach, 225 + .detach = parkbd_detach, 226 + .devmodel = true, 227 + }; 228 + 229 + static int __init parkbd_init(void) 230 + { 231 + return parport_register_driver(&parkbd_parport_driver); 207 232 } 208 233 209 234 static void __exit parkbd_exit(void) 210 235 { 211 - parport_release(parkbd_dev); 212 - serio_unregister_port(parkbd_port); 213 - parport_unregister_device(parkbd_dev); 236 + parport_unregister_driver(&parkbd_parport_driver); 214 237 } 215 238 216 239 module_init(parkbd_init);
+285
drivers/input/serio/userio.c
··· 1 + /* 2 + * userio kernel serio device emulation module 3 + * Copyright (C) 2015 Red Hat 4 + * Copyright (C) 2015 Stephen Chandler Paul <thatslyude@gmail.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU Lesser General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or (at 9 + * your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, but 12 + * WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 + * General Public License for more details. 15 + */ 16 + 17 + #include <linux/circ_buf.h> 18 + #include <linux/mutex.h> 19 + #include <linux/module.h> 20 + #include <linux/init.h> 21 + #include <linux/kernel.h> 22 + #include <linux/serio.h> 23 + #include <linux/slab.h> 24 + #include <linux/fs.h> 25 + #include <linux/miscdevice.h> 26 + #include <linux/sched.h> 27 + #include <linux/poll.h> 28 + #include <uapi/linux/userio.h> 29 + 30 + #define USERIO_NAME "userio" 31 + #define USERIO_BUFSIZE 16 32 + 33 + static struct miscdevice userio_misc; 34 + 35 + struct userio_device { 36 + struct serio *serio; 37 + struct mutex mutex; 38 + 39 + bool running; 40 + 41 + u8 head; 42 + u8 tail; 43 + 44 + spinlock_t buf_lock; 45 + unsigned char buf[USERIO_BUFSIZE]; 46 + 47 + wait_queue_head_t waitq; 48 + }; 49 + 50 + /** 51 + * userio_device_write - Write data from serio to a userio device in userspace 52 + * @id: The serio port for the userio device 53 + * @val: The data to write to the device 54 + */ 55 + static int userio_device_write(struct serio *id, unsigned char val) 56 + { 57 + struct userio_device *userio = id->port_data; 58 + unsigned long flags; 59 + 60 + spin_lock_irqsave(&userio->buf_lock, flags); 61 + 62 + userio->buf[userio->head] = val; 63 + userio->head = (userio->head + 1) % USERIO_BUFSIZE; 64 + 65 + if (userio->head == userio->tail) 66 + dev_warn(userio_misc.this_device, 67 + "Buffer overflowed, userio client isn't keeping up"); 68 + 69 + spin_unlock_irqrestore(&userio->buf_lock, flags); 70 + 71 + wake_up_interruptible(&userio->waitq); 72 + 73 + return 0; 74 + } 75 + 76 + static int userio_char_open(struct inode *inode, struct file *file) 77 + { 78 + struct userio_device *userio; 79 + 80 + userio = kzalloc(sizeof(struct userio_device), GFP_KERNEL); 81 + if (!userio) 82 + return -ENOMEM; 83 + 84 + mutex_init(&userio->mutex); 85 + spin_lock_init(&userio->buf_lock); 86 + init_waitqueue_head(&userio->waitq); 87 + 88 + userio->serio = kzalloc(sizeof(struct serio), GFP_KERNEL); 89 + if (!userio->serio) { 90 + kfree(userio); 91 + return -ENOMEM; 92 + } 93 + 94 + userio->serio->write = userio_device_write; 95 + userio->serio->port_data = userio; 96 + 97 + file->private_data = userio; 98 + 99 + return 0; 100 + } 101 + 102 + static int userio_char_release(struct inode *inode, struct file *file) 103 + { 104 + struct userio_device *userio = file->private_data; 105 + 106 + if (userio->running) { 107 + /* 108 + * Don't free the serio port here, serio_unregister_port() 109 + * does it for us. 110 + */ 111 + serio_unregister_port(userio->serio); 112 + } else { 113 + kfree(userio->serio); 114 + } 115 + 116 + kfree(userio); 117 + 118 + return 0; 119 + } 120 + 121 + static ssize_t userio_char_read(struct file *file, char __user *user_buffer, 122 + size_t count, loff_t *ppos) 123 + { 124 + struct userio_device *userio = file->private_data; 125 + int error; 126 + size_t nonwrap_len, copylen; 127 + unsigned char buf[USERIO_BUFSIZE]; 128 + unsigned long flags; 129 + 130 + /* 131 + * By the time we get here, the data that was waiting might have 132 + * been taken by another thread. Grab the buffer lock and check if 133 + * there's still any data waiting, otherwise repeat this process 134 + * until we have data (unless the file descriptor is non-blocking 135 + * of course). 136 + */ 137 + for (;;) { 138 + spin_lock_irqsave(&userio->buf_lock, flags); 139 + 140 + nonwrap_len = CIRC_CNT_TO_END(userio->head, 141 + userio->tail, 142 + USERIO_BUFSIZE); 143 + copylen = min(nonwrap_len, count); 144 + if (copylen) { 145 + memcpy(buf, &userio->buf[userio->tail], copylen); 146 + userio->tail = (userio->tail + copylen) % 147 + USERIO_BUFSIZE; 148 + } 149 + 150 + spin_unlock_irqrestore(&userio->buf_lock, flags); 151 + 152 + if (nonwrap_len) 153 + break; 154 + 155 + /* buffer was/is empty */ 156 + if (file->f_flags & O_NONBLOCK) 157 + return -EAGAIN; 158 + 159 + /* 160 + * count == 0 is special - no IO is done but we check 161 + * for error conditions (see above). 162 + */ 163 + if (count == 0) 164 + return 0; 165 + 166 + error = wait_event_interruptible(userio->waitq, 167 + userio->head != userio->tail); 168 + if (error) 169 + return error; 170 + } 171 + 172 + if (copylen) 173 + if (copy_to_user(user_buffer, buf, copylen)) 174 + return -EFAULT; 175 + 176 + return copylen; 177 + } 178 + 179 + static ssize_t userio_char_write(struct file *file, const char __user *buffer, 180 + size_t count, loff_t *ppos) 181 + { 182 + struct userio_device *userio = file->private_data; 183 + struct userio_cmd cmd; 184 + int error; 185 + 186 + if (count != sizeof(cmd)) { 187 + dev_warn(userio_misc.this_device, "Invalid payload size\n"); 188 + return -EINVAL; 189 + } 190 + 191 + if (copy_from_user(&cmd, buffer, sizeof(cmd))) 192 + return -EFAULT; 193 + 194 + error = mutex_lock_interruptible(&userio->mutex); 195 + if (error) 196 + return error; 197 + 198 + switch (cmd.type) { 199 + case USERIO_CMD_REGISTER: 200 + if (!userio->serio->id.type) { 201 + dev_warn(userio_misc.this_device, 202 + "No port type given on /dev/userio\n"); 203 + 204 + error = -EINVAL; 205 + goto out; 206 + } 207 + 208 + if (userio->running) { 209 + dev_warn(userio_misc.this_device, 210 + "Begin command sent, but we're already running\n"); 211 + error = -EBUSY; 212 + goto out; 213 + } 214 + 215 + userio->running = true; 216 + serio_register_port(userio->serio); 217 + break; 218 + 219 + case USERIO_CMD_SET_PORT_TYPE: 220 + if (userio->running) { 221 + dev_warn(userio_misc.this_device, 222 + "Can't change port type on an already running userio instance\n"); 223 + error = -EBUSY; 224 + goto out; 225 + } 226 + 227 + userio->serio->id.type = cmd.data; 228 + break; 229 + 230 + case USERIO_CMD_SEND_INTERRUPT: 231 + if (!userio->running) { 232 + dev_warn(userio_misc.this_device, 233 + "The device must be registered before sending interrupts\n"); 234 + error = -ENODEV; 235 + goto out; 236 + } 237 + 238 + serio_interrupt(userio->serio, cmd.data, 0); 239 + break; 240 + 241 + default: 242 + error = -EOPNOTSUPP; 243 + goto out; 244 + } 245 + 246 + out: 247 + mutex_unlock(&userio->mutex); 248 + return error ?: count; 249 + } 250 + 251 + static unsigned int userio_char_poll(struct file *file, poll_table *wait) 252 + { 253 + struct userio_device *userio = file->private_data; 254 + 255 + poll_wait(file, &userio->waitq, wait); 256 + 257 + if (userio->head != userio->tail) 258 + return POLLIN | POLLRDNORM; 259 + 260 + return 0; 261 + } 262 + 263 + static const struct file_operations userio_fops = { 264 + .owner = THIS_MODULE, 265 + .open = userio_char_open, 266 + .release = userio_char_release, 267 + .read = userio_char_read, 268 + .write = userio_char_write, 269 + .poll = userio_char_poll, 270 + .llseek = no_llseek, 271 + }; 272 + 273 + static struct miscdevice userio_misc = { 274 + .fops = &userio_fops, 275 + .minor = USERIO_MINOR, 276 + .name = USERIO_NAME, 277 + }; 278 + module_driver(userio_misc, misc_register, misc_deregister); 279 + 280 + MODULE_ALIAS_MISCDEV(USERIO_MINOR); 281 + MODULE_ALIAS("devname:" USERIO_NAME); 282 + 283 + MODULE_AUTHOR("Stephen Chandler Paul <thatslyude@gmail.com>"); 284 + MODULE_DESCRIPTION("Virtual Serio Device Support"); 285 + MODULE_LICENSE("GPL");
+24
drivers/input/touchscreen/Kconfig
··· 295 295 To compile this driver as a module, choose M here: the 296 296 module will be called egalax_ts. 297 297 298 + config TOUCHSCREEN_FT6236 299 + tristate "FT6236 I2C touchscreen" 300 + depends on I2C 301 + depends on GPIOLIB || COMPILE_TEST 302 + help 303 + Say Y here to enable support for the I2C connected FT6x06 and 304 + FT6x36 family of capacitive touchscreen drivers. 305 + 306 + If unsure, say N. 307 + 308 + To compile this driver as a module, choose M here: the 309 + module will be called ft6236. 310 + 298 311 config TOUCHSCREEN_FUJITSU 299 312 tristate "Fujitsu serial touchscreen" 300 313 select SERIO ··· 1077 1064 1078 1065 To compile this driver as a module, choose M here: the 1079 1066 module will be called colibri_vf50_ts. 1067 + 1068 + config TOUCHSCREEN_ROHM_BU21023 1069 + tristate "ROHM BU21023/24 Dual touch support resistive touchscreens" 1070 + depends on I2C 1071 + help 1072 + Say Y here if you have a touchscreen using ROHM BU21023/24. 1073 + 1074 + If unsure, say N. 1075 + 1076 + To compile this driver as a module, choose M here: the 1077 + module will be called bu21023_ts. 1080 1078 1081 1079 endif
+2
drivers/input/touchscreen/Makefile
··· 35 35 obj-$(CONFIG_TOUCHSCREEN_ELAN) += elants_i2c.o 36 36 obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o 37 37 obj-$(CONFIG_TOUCHSCREEN_EGALAX) += egalax_ts.o 38 + obj-$(CONFIG_TOUCHSCREEN_FT6236) += ft6236.o 38 39 obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o 39 40 obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o 40 41 obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o ··· 88 87 obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o 89 88 obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o 90 89 obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50) += colibri-vf50-ts.o 90 + obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o
+1 -3
drivers/input/touchscreen/ads7846.c
··· 529 529 530 530 ts->hwmon = hwmon_device_register_with_groups(&spi->dev, spi->modalias, 531 531 ts, ads7846_attr_groups); 532 - if (IS_ERR(ts->hwmon)) 533 - return PTR_ERR(ts->hwmon); 534 532 535 - return 0; 533 + return PTR_ERR_OR_ZERO(ts->hwmon); 536 534 } 537 535 538 536 static void ads784x_hwmon_unregister(struct spi_device *spi,
+1 -6
drivers/input/touchscreen/auo-pixcir-ts.c
··· 399 399 static int auo_pixcir_input_open(struct input_dev *dev) 400 400 { 401 401 struct auo_pixcir_ts *ts = input_get_drvdata(dev); 402 - int ret; 403 402 404 - ret = auo_pixcir_start(ts); 405 - if (ret) 406 - return ret; 407 - 408 - return 0; 403 + return auo_pixcir_start(ts); 409 404 } 410 405 411 406 static void auo_pixcir_input_close(struct input_dev *dev)
+1 -4
drivers/input/touchscreen/cyttsp4_i2c.c
··· 50 50 ts = cyttsp4_probe(&cyttsp4_i2c_bus_ops, &client->dev, client->irq, 51 51 CYTTSP4_I2C_DATA_SIZE); 52 52 53 - if (IS_ERR(ts)) 54 - return PTR_ERR(ts); 55 - 56 - return 0; 53 + return PTR_ERR_OR_ZERO(ts); 57 54 } 58 55 59 56 static int cyttsp4_i2c_remove(struct i2c_client *client)
+95 -153
drivers/input/touchscreen/edt-ft5x06.c
··· 27 27 28 28 #include <linux/module.h> 29 29 #include <linux/ratelimit.h> 30 + #include <linux/irq.h> 30 31 #include <linux/interrupt.h> 31 32 #include <linux/input.h> 32 33 #include <linux/i2c.h> ··· 35 34 #include <linux/delay.h> 36 35 #include <linux/debugfs.h> 37 36 #include <linux/slab.h> 38 - #include <linux/gpio.h> 39 - #include <linux/of_gpio.h> 37 + #include <linux/gpio/consumer.h> 40 38 #include <linux/input/mt.h> 41 39 #include <linux/input/touchscreen.h> 42 - #include <linux/input/edt-ft5x06.h> 43 - 44 - #define MAX_SUPPORT_POINTS 5 40 + #include <linux/of_device.h> 45 41 46 42 #define WORK_REGISTER_THRESHOLD 0x00 47 43 #define WORK_REGISTER_REPORT_RATE 0x08 ··· 89 91 u16 num_x; 90 92 u16 num_y; 91 93 92 - int reset_pin; 93 - int irq_pin; 94 - int wake_pin; 94 + struct gpio_desc *reset_gpio; 95 + struct gpio_desc *wake_gpio; 95 96 96 97 #if defined(CONFIG_DEBUG_FS) 97 98 struct dentry *debug_dir; ··· 104 107 int gain; 105 108 int offset; 106 109 int report_rate; 110 + int max_support_points; 107 111 108 112 char name[EDT_NAME_LEN]; 109 113 110 114 struct edt_reg_addr reg_addr; 111 115 enum edt_ver version; 116 + }; 117 + 118 + struct edt_i2c_chip_data { 119 + int max_support_points; 112 120 }; 113 121 114 122 static int edt_ft5x06_ts_readwrite(struct i2c_client *client, ··· 172 170 struct edt_ft5x06_ts_data *tsdata = dev_id; 173 171 struct device *dev = &tsdata->client->dev; 174 172 u8 cmd; 175 - u8 rdbuf[29]; 173 + u8 rdbuf[63]; 176 174 int i, type, x, y, id; 177 - int offset, tplen, datalen; 175 + int offset, tplen, datalen, crclen; 178 176 int error; 179 177 180 178 switch (tsdata->version) { ··· 182 180 cmd = 0xf9; /* tell the controller to send touch data */ 183 181 offset = 5; /* where the actual touch data starts */ 184 182 tplen = 4; /* data comes in so called frames */ 185 - datalen = 26; /* how much bytes to listen for */ 183 + crclen = 1; /* length of the crc data */ 186 184 break; 187 185 188 186 case M09: 189 - cmd = 0x02; 190 - offset = 1; 187 + cmd = 0x0; 188 + offset = 3; 191 189 tplen = 6; 192 - datalen = 29; 190 + crclen = 0; 193 191 break; 194 192 195 193 default: ··· 197 195 } 198 196 199 197 memset(rdbuf, 0, sizeof(rdbuf)); 198 + datalen = tplen * tsdata->max_support_points + offset + crclen; 200 199 201 200 error = edt_ft5x06_ts_readwrite(tsdata->client, 202 201 sizeof(cmd), &cmd, ··· 222 219 goto out; 223 220 } 224 221 225 - for (i = 0; i < MAX_SUPPORT_POINTS; i++) { 222 + for (i = 0; i < tsdata->max_support_points; i++) { 226 223 u8 *buf = &rdbuf[i * tplen + offset]; 227 224 bool down; 228 225 ··· 755 752 756 753 #endif /* CONFIG_DEBUGFS */ 757 754 758 - static int edt_ft5x06_ts_reset(struct i2c_client *client, 759 - struct edt_ft5x06_ts_data *tsdata) 760 - { 761 - int error; 762 - 763 - if (gpio_is_valid(tsdata->wake_pin)) { 764 - error = devm_gpio_request_one(&client->dev, 765 - tsdata->wake_pin, GPIOF_OUT_INIT_LOW, 766 - "edt-ft5x06 wake"); 767 - if (error) { 768 - dev_err(&client->dev, 769 - "Failed to request GPIO %d as wake pin, error %d\n", 770 - tsdata->wake_pin, error); 771 - return error; 772 - } 773 - 774 - msleep(5); 775 - gpio_set_value(tsdata->wake_pin, 1); 776 - } 777 - if (gpio_is_valid(tsdata->reset_pin)) { 778 - /* this pulls reset down, enabling the low active reset */ 779 - error = devm_gpio_request_one(&client->dev, 780 - tsdata->reset_pin, GPIOF_OUT_INIT_LOW, 781 - "edt-ft5x06 reset"); 782 - if (error) { 783 - dev_err(&client->dev, 784 - "Failed to request GPIO %d as reset pin, error %d\n", 785 - tsdata->reset_pin, error); 786 - return error; 787 - } 788 - 789 - msleep(5); 790 - gpio_set_value(tsdata->reset_pin, 1); 791 - msleep(300); 792 - } 793 - 794 - return 0; 795 - } 796 - 797 755 static int edt_ft5x06_ts_identify(struct i2c_client *client, 798 756 struct edt_ft5x06_ts_data *tsdata, 799 757 char *fw_version) ··· 814 850 return 0; 815 851 } 816 852 817 - #define EDT_ATTR_CHECKSET(name, reg) \ 818 - do { \ 819 - if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ 820 - pdata->name <= edt_ft5x06_attr_##name.limit_high) \ 821 - edt_ft5x06_register_write(tsdata, reg, pdata->name); \ 822 - } while (0) 823 - 824 - #define EDT_GET_PROP(name, reg) { \ 825 - u32 val; \ 826 - if (of_property_read_u32(np, #name, &val) == 0) \ 827 - edt_ft5x06_register_write(tsdata, reg, val); \ 828 - } 829 - 830 - static void edt_ft5x06_ts_get_dt_defaults(struct device_node *np, 831 - struct edt_ft5x06_ts_data *tsdata) 853 + static void edt_ft5x06_ts_get_defaults(struct device *dev, 854 + struct edt_ft5x06_ts_data *tsdata) 832 855 { 833 856 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; 857 + u32 val; 858 + int error; 834 859 835 - EDT_GET_PROP(threshold, reg_addr->reg_threshold); 836 - EDT_GET_PROP(gain, reg_addr->reg_gain); 837 - EDT_GET_PROP(offset, reg_addr->reg_offset); 838 - } 860 + error = device_property_read_u32(dev, "threshold", &val); 861 + if (!error) 862 + reg_addr->reg_threshold = val; 839 863 840 - static void 841 - edt_ft5x06_ts_get_defaults(struct edt_ft5x06_ts_data *tsdata, 842 - const struct edt_ft5x06_platform_data *pdata) 843 - { 844 - struct edt_reg_addr *reg_addr = &tsdata->reg_addr; 864 + error = device_property_read_u32(dev, "gain", &val); 865 + if (!error) 866 + reg_addr->reg_gain = val; 845 867 846 - if (!pdata->use_parameters) 847 - return; 848 - 849 - /* pick up defaults from the platform data */ 850 - EDT_ATTR_CHECKSET(threshold, reg_addr->reg_threshold); 851 - EDT_ATTR_CHECKSET(gain, reg_addr->reg_gain); 852 - EDT_ATTR_CHECKSET(offset, reg_addr->reg_offset); 853 - if (reg_addr->reg_report_rate != NO_REGISTER) 854 - EDT_ATTR_CHECKSET(report_rate, reg_addr->reg_report_rate); 868 + error = device_property_read_u32(dev, "offset", &val); 869 + if (!error) 870 + reg_addr->reg_offset = val; 855 871 } 856 872 857 873 static void ··· 875 931 } 876 932 } 877 933 878 - #ifdef CONFIG_OF 879 - static int edt_ft5x06_i2c_ts_probe_dt(struct device *dev, 880 - struct edt_ft5x06_ts_data *tsdata) 881 - { 882 - struct device_node *np = dev->of_node; 883 - 884 - /* 885 - * irq_pin is not needed for DT setup. 886 - * irq is associated via 'interrupts' property in DT 887 - */ 888 - tsdata->irq_pin = -EINVAL; 889 - tsdata->reset_pin = of_get_named_gpio(np, "reset-gpios", 0); 890 - tsdata->wake_pin = of_get_named_gpio(np, "wake-gpios", 0); 891 - 892 - return 0; 893 - } 894 - #else 895 - static inline int edt_ft5x06_i2c_ts_probe_dt(struct device *dev, 896 - struct edt_ft5x06_ts_data *tsdata) 897 - { 898 - return -ENODEV; 899 - } 900 - #endif 901 - 902 934 static int edt_ft5x06_ts_probe(struct i2c_client *client, 903 935 const struct i2c_device_id *id) 904 936 { 905 - const struct edt_ft5x06_platform_data *pdata = 906 - dev_get_platdata(&client->dev); 937 + const struct edt_i2c_chip_data *chip_data; 907 938 struct edt_ft5x06_ts_data *tsdata; 908 939 struct input_dev *input; 940 + unsigned long irq_flags; 909 941 int error; 910 942 char fw_version[EDT_NAME_LEN]; 911 943 ··· 893 973 return -ENOMEM; 894 974 } 895 975 896 - if (!pdata) { 897 - error = edt_ft5x06_i2c_ts_probe_dt(&client->dev, tsdata); 898 - if (error) { 899 - dev_err(&client->dev, 900 - "DT probe failed and no platform data present\n"); 901 - return error; 902 - } 903 - } else { 904 - tsdata->reset_pin = pdata->reset_pin; 905 - tsdata->irq_pin = pdata->irq_pin; 906 - tsdata->wake_pin = -EINVAL; 976 + chip_data = of_device_get_match_data(&client->dev); 977 + if (!chip_data) 978 + chip_data = (const struct edt_i2c_chip_data *)id->driver_data; 979 + if (!chip_data || !chip_data->max_support_points) { 980 + dev_err(&client->dev, "invalid or missing chip data\n"); 981 + return -EINVAL; 907 982 } 908 983 909 - error = edt_ft5x06_ts_reset(client, tsdata); 910 - if (error) 911 - return error; 984 + tsdata->max_support_points = chip_data->max_support_points; 912 985 913 - if (gpio_is_valid(tsdata->irq_pin)) { 914 - error = devm_gpio_request_one(&client->dev, tsdata->irq_pin, 915 - GPIOF_IN, "edt-ft5x06 irq"); 916 - if (error) { 917 - dev_err(&client->dev, 918 - "Failed to request GPIO %d, error %d\n", 919 - tsdata->irq_pin, error); 920 - return error; 921 - } 986 + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, 987 + "reset", GPIOD_OUT_HIGH); 988 + if (IS_ERR(tsdata->reset_gpio)) { 989 + error = PTR_ERR(tsdata->reset_gpio); 990 + dev_err(&client->dev, 991 + "Failed to request GPIO reset pin, error %d\n", error); 992 + return error; 993 + } 994 + 995 + tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev, 996 + "wake", GPIOD_OUT_LOW); 997 + if (IS_ERR(tsdata->wake_gpio)) { 998 + error = PTR_ERR(tsdata->wake_gpio); 999 + dev_err(&client->dev, 1000 + "Failed to request GPIO wake pin, error %d\n", error); 1001 + return error; 1002 + } 1003 + 1004 + if (tsdata->wake_gpio) { 1005 + usleep_range(5000, 6000); 1006 + gpiod_set_value_cansleep(tsdata->wake_gpio, 1); 1007 + } 1008 + 1009 + if (tsdata->reset_gpio) { 1010 + usleep_range(5000, 6000); 1011 + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); 1012 + msleep(300); 922 1013 } 923 1014 924 1015 input = devm_input_allocate_device(&client->dev); ··· 950 1019 } 951 1020 952 1021 edt_ft5x06_ts_set_regs(tsdata); 953 - 954 - if (!pdata) 955 - edt_ft5x06_ts_get_dt_defaults(client->dev.of_node, tsdata); 956 - else 957 - edt_ft5x06_ts_get_defaults(tsdata, pdata); 958 - 1022 + edt_ft5x06_ts_get_defaults(&client->dev, tsdata); 959 1023 edt_ft5x06_ts_get_parameters(tsdata); 960 1024 961 1025 dev_dbg(&client->dev, ··· 966 1040 input_set_abs_params(input, ABS_MT_POSITION_Y, 967 1041 0, tsdata->num_y * 64 - 1, 0, 0); 968 1042 969 - if (!pdata) 970 - touchscreen_parse_properties(input, true); 1043 + touchscreen_parse_properties(input, true); 971 1044 972 - error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT); 1045 + error = input_mt_init_slots(input, tsdata->max_support_points, 1046 + INPUT_MT_DIRECT); 973 1047 if (error) { 974 1048 dev_err(&client->dev, "Unable to init MT slots.\n"); 975 1049 return error; ··· 978 1052 input_set_drvdata(input, tsdata); 979 1053 i2c_set_clientdata(client, tsdata); 980 1054 981 - error = devm_request_threaded_irq(&client->dev, client->irq, NULL, 982 - edt_ft5x06_ts_isr, 983 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 1055 + irq_flags = irq_get_trigger_type(client->irq); 1056 + if (irq_flags == IRQF_TRIGGER_NONE) 1057 + irq_flags = IRQF_TRIGGER_FALLING; 1058 + irq_flags |= IRQF_ONESHOT; 1059 + 1060 + error = devm_request_threaded_irq(&client->dev, client->irq, 1061 + NULL, edt_ft5x06_ts_isr, irq_flags, 984 1062 client->name, tsdata); 985 1063 if (error) { 986 1064 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); ··· 1004 1074 1005 1075 dev_dbg(&client->dev, 1006 1076 "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n", 1007 - client->irq, tsdata->wake_pin, tsdata->reset_pin); 1077 + client->irq, 1078 + tsdata->wake_gpio ? desc_to_gpio(tsdata->wake_gpio) : -1, 1079 + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); 1008 1080 1009 1081 return 0; 1010 1082 ··· 1048 1116 static SIMPLE_DEV_PM_OPS(edt_ft5x06_ts_pm_ops, 1049 1117 edt_ft5x06_ts_suspend, edt_ft5x06_ts_resume); 1050 1118 1119 + static const struct edt_i2c_chip_data edt_ft5x06_data = { 1120 + .max_support_points = 5, 1121 + }; 1122 + 1123 + static const struct edt_i2c_chip_data edt_ft5506_data = { 1124 + .max_support_points = 10, 1125 + }; 1126 + 1051 1127 static const struct i2c_device_id edt_ft5x06_ts_id[] = { 1052 - { "edt-ft5x06", 0, }, 1128 + { .name = "edt-ft5x06", .driver_data = (long)&edt_ft5x06_data }, 1129 + { .name = "edt-ft5506", .driver_data = (long)&edt_ft5506_data }, 1053 1130 { /* sentinel */ } 1054 1131 }; 1055 1132 MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id); 1056 1133 1057 1134 #ifdef CONFIG_OF 1058 1135 static const struct of_device_id edt_ft5x06_of_match[] = { 1059 - { .compatible = "edt,edt-ft5206", }, 1060 - { .compatible = "edt,edt-ft5306", }, 1061 - { .compatible = "edt,edt-ft5406", }, 1136 + { .compatible = "edt,edt-ft5206", .data = &edt_ft5x06_data }, 1137 + { .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data }, 1138 + { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data }, 1139 + { .compatible = "edt,edt-ft5506", .data = &edt_ft5506_data }, 1062 1140 { /* sentinel */ } 1063 1141 }; 1064 1142 MODULE_DEVICE_TABLE(of, edt_ft5x06_of_match);
+326
drivers/input/touchscreen/ft6236.c
··· 1 + /* 2 + * FocalTech FT6236 TouchScreen driver. 3 + * 4 + * Copyright (c) 2010 Focal tech Ltd. 5 + * 6 + * This software is licensed under the terms of the GNU General Public 7 + * License version 2, as published by the Free Software Foundation, and 8 + * may be copied, distributed, and modified under those terms. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/delay.h> 17 + #include <linux/gpio/consumer.h> 18 + #include <linux/i2c.h> 19 + #include <linux/input.h> 20 + #include <linux/input/mt.h> 21 + #include <linux/interrupt.h> 22 + #include <linux/module.h> 23 + #include <linux/property.h> 24 + 25 + #define FT6236_MAX_TOUCH_POINTS 2 26 + 27 + #define FT6236_REG_TH_GROUP 0x80 28 + #define FT6236_REG_PERIODACTIVE 0x88 29 + #define FT6236_REG_LIB_VER_H 0xa1 30 + #define FT6236_REG_LIB_VER_L 0xa2 31 + #define FT6236_REG_CIPHER 0xa3 32 + #define FT6236_REG_FIRMID 0xa6 33 + #define FT6236_REG_FOCALTECH_ID 0xa8 34 + #define FT6236_REG_RELEASE_CODE_ID 0xaf 35 + 36 + #define FT6236_EVENT_PRESS_DOWN 0 37 + #define FT6236_EVENT_LIFT_UP 1 38 + #define FT6236_EVENT_CONTACT 2 39 + #define FT6236_EVENT_NO_EVENT 3 40 + 41 + struct ft6236_data { 42 + struct i2c_client *client; 43 + struct input_dev *input; 44 + struct gpio_desc *reset_gpio; 45 + u32 max_x; 46 + u32 max_y; 47 + bool invert_x; 48 + bool invert_y; 49 + bool swap_xy; 50 + }; 51 + 52 + /* 53 + * This struct is a touchpoint as stored in hardware. Note that the id, 54 + * as well as the event, are stored in the upper nybble of the hi byte. 55 + */ 56 + struct ft6236_touchpoint { 57 + union { 58 + u8 xhi; 59 + u8 event; 60 + }; 61 + u8 xlo; 62 + union { 63 + u8 yhi; 64 + u8 id; 65 + }; 66 + u8 ylo; 67 + u8 weight; 68 + u8 misc; 69 + } __packed; 70 + 71 + /* This packet represents the register map as read from offset 0 */ 72 + struct ft6236_packet { 73 + u8 dev_mode; 74 + u8 gest_id; 75 + u8 touches; 76 + struct ft6236_touchpoint points[FT6236_MAX_TOUCH_POINTS]; 77 + } __packed; 78 + 79 + static int ft6236_read(struct i2c_client *client, u8 reg, u8 len, void *data) 80 + { 81 + int error; 82 + 83 + error = i2c_smbus_read_i2c_block_data(client, reg, len, data); 84 + if (error < 0) 85 + return error; 86 + 87 + if (error != len) 88 + return -EIO; 89 + 90 + return 0; 91 + } 92 + 93 + static irqreturn_t ft6236_interrupt(int irq, void *dev_id) 94 + { 95 + struct ft6236_data *ft6236 = dev_id; 96 + struct device *dev = &ft6236->client->dev; 97 + struct input_dev *input = ft6236->input; 98 + struct ft6236_packet buf; 99 + u8 touches; 100 + int i, error; 101 + 102 + error = ft6236_read(ft6236->client, 0, sizeof(buf), &buf); 103 + if (error) { 104 + dev_err(dev, "read touchdata failed %d\n", error); 105 + return IRQ_HANDLED; 106 + } 107 + 108 + touches = buf.touches & 0xf; 109 + if (touches > FT6236_MAX_TOUCH_POINTS) { 110 + dev_dbg(dev, 111 + "%d touch points reported, only %d are supported\n", 112 + touches, FT6236_MAX_TOUCH_POINTS); 113 + touches = FT6236_MAX_TOUCH_POINTS; 114 + } 115 + 116 + for (i = 0; i < touches; i++) { 117 + struct ft6236_touchpoint *point = &buf.points[i]; 118 + u16 x = ((point->xhi & 0xf) << 8) | buf.points[i].xlo; 119 + u16 y = ((point->yhi & 0xf) << 8) | buf.points[i].ylo; 120 + u8 event = point->event >> 6; 121 + u8 id = point->id >> 4; 122 + bool act = (event == FT6236_EVENT_PRESS_DOWN || 123 + event == FT6236_EVENT_CONTACT); 124 + 125 + input_mt_slot(input, id); 126 + input_mt_report_slot_state(input, MT_TOOL_FINGER, act); 127 + if (!act) 128 + continue; 129 + 130 + if (ft6236->invert_x) 131 + x = ft6236->max_x - x; 132 + 133 + if (ft6236->invert_y) 134 + y = ft6236->max_y - y; 135 + 136 + if (ft6236->swap_xy) { 137 + input_report_abs(input, ABS_MT_POSITION_X, y); 138 + input_report_abs(input, ABS_MT_POSITION_Y, x); 139 + } else { 140 + input_report_abs(input, ABS_MT_POSITION_X, x); 141 + input_report_abs(input, ABS_MT_POSITION_Y, y); 142 + } 143 + } 144 + 145 + input_mt_sync_frame(input); 146 + input_sync(input); 147 + 148 + return IRQ_HANDLED; 149 + } 150 + 151 + static u8 ft6236_debug_read_byte(struct ft6236_data *ft6236, u8 reg) 152 + { 153 + struct i2c_client *client = ft6236->client; 154 + u8 val = 0; 155 + int error; 156 + 157 + error = ft6236_read(client, reg, 1, &val); 158 + if (error) 159 + dev_dbg(&client->dev, 160 + "error reading register 0x%02x: %d\n", reg, error); 161 + 162 + return val; 163 + } 164 + 165 + static void ft6236_debug_info(struct ft6236_data *ft6236) 166 + { 167 + struct device *dev = &ft6236->client->dev; 168 + 169 + dev_dbg(dev, "Touch threshold is %d\n", 170 + ft6236_debug_read_byte(ft6236, FT6236_REG_TH_GROUP) * 4); 171 + dev_dbg(dev, "Report rate is %dHz\n", 172 + ft6236_debug_read_byte(ft6236, FT6236_REG_PERIODACTIVE) * 10); 173 + dev_dbg(dev, "Firmware library version 0x%02x%02x\n", 174 + ft6236_debug_read_byte(ft6236, FT6236_REG_LIB_VER_H), 175 + ft6236_debug_read_byte(ft6236, FT6236_REG_LIB_VER_L)); 176 + dev_dbg(dev, "Firmware version 0x%02x\n", 177 + ft6236_debug_read_byte(ft6236, FT6236_REG_FIRMID)); 178 + dev_dbg(dev, "Chip vendor ID 0x%02x\n", 179 + ft6236_debug_read_byte(ft6236, FT6236_REG_CIPHER)); 180 + dev_dbg(dev, "CTPM vendor ID 0x%02x\n", 181 + ft6236_debug_read_byte(ft6236, FT6236_REG_FOCALTECH_ID)); 182 + dev_dbg(dev, "Release code version 0x%02x\n", 183 + ft6236_debug_read_byte(ft6236, FT6236_REG_RELEASE_CODE_ID)); 184 + } 185 + 186 + static void ft6236_reset(struct ft6236_data *ft6236) 187 + { 188 + if (!ft6236->reset_gpio) 189 + return; 190 + 191 + gpiod_set_value_cansleep(ft6236->reset_gpio, 1); 192 + usleep_range(5000, 20000); 193 + gpiod_set_value_cansleep(ft6236->reset_gpio, 0); 194 + msleep(300); 195 + } 196 + 197 + static int ft6236_probe(struct i2c_client *client, 198 + const struct i2c_device_id *id) 199 + { 200 + struct device *dev = &client->dev; 201 + struct ft6236_data *ft6236; 202 + struct input_dev *input; 203 + u32 fuzz_x = 0, fuzz_y = 0; 204 + u8 val; 205 + int error; 206 + 207 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 208 + return -ENXIO; 209 + 210 + if (!client->irq) { 211 + dev_err(dev, "irq is missing\n"); 212 + return -EINVAL; 213 + } 214 + 215 + ft6236 = devm_kzalloc(dev, sizeof(*ft6236), GFP_KERNEL); 216 + if (!ft6236) 217 + return -ENOMEM; 218 + 219 + ft6236->client = client; 220 + ft6236->reset_gpio = devm_gpiod_get_optional(dev, "reset", 221 + GPIOD_OUT_LOW); 222 + if (IS_ERR(ft6236->reset_gpio)) { 223 + error = PTR_ERR(ft6236->reset_gpio); 224 + if (error != -EPROBE_DEFER) 225 + dev_err(dev, "error getting reset gpio: %d\n", error); 226 + return error; 227 + } 228 + 229 + ft6236_reset(ft6236); 230 + 231 + /* verify that the controller is present */ 232 + error = ft6236_read(client, 0x00, 1, &val); 233 + if (error) { 234 + dev_err(dev, "failed to read from controller: %d\n", error); 235 + return error; 236 + } 237 + 238 + ft6236_debug_info(ft6236); 239 + 240 + input = devm_input_allocate_device(dev); 241 + if (!input) 242 + return -ENOMEM; 243 + 244 + ft6236->input = input; 245 + input->name = client->name; 246 + input->id.bustype = BUS_I2C; 247 + 248 + if (device_property_read_u32(dev, "touchscreen-size-x", 249 + &ft6236->max_x) || 250 + device_property_read_u32(dev, "touchscreen-size-y", 251 + &ft6236->max_y)) { 252 + dev_err(dev, "touchscreen-size-x and/or -y missing\n"); 253 + return -EINVAL; 254 + } 255 + 256 + device_property_read_u32(dev, "touchscreen-fuzz-x", &fuzz_x); 257 + device_property_read_u32(dev, "touchscreen-fuzz-y", &fuzz_y); 258 + ft6236->invert_x = device_property_read_bool(dev, 259 + "touchscreen-inverted-x"); 260 + ft6236->invert_y = device_property_read_bool(dev, 261 + "touchscreen-inverted-y"); 262 + ft6236->swap_xy = device_property_read_bool(dev, 263 + "touchscreen-swapped-x-y"); 264 + 265 + if (ft6236->swap_xy) { 266 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, 267 + ft6236->max_y, fuzz_y, 0); 268 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 269 + ft6236->max_x, fuzz_x, 0); 270 + } else { 271 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, 272 + ft6236->max_x, fuzz_x, 0); 273 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 274 + ft6236->max_y, fuzz_y, 0); 275 + } 276 + 277 + error = input_mt_init_slots(input, FT6236_MAX_TOUCH_POINTS, 278 + INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); 279 + if (error) 280 + return error; 281 + 282 + error = devm_request_threaded_irq(dev, client->irq, NULL, 283 + ft6236_interrupt, IRQF_ONESHOT, 284 + client->name, ft6236); 285 + if (error) { 286 + dev_err(dev, "request irq %d failed: %d\n", client->irq, error); 287 + return error; 288 + } 289 + 290 + error = input_register_device(input); 291 + if (error) { 292 + dev_err(dev, "failed to register input device: %d\n", error); 293 + return error; 294 + } 295 + 296 + return 0; 297 + } 298 + 299 + #ifdef CONFIG_OF 300 + static const struct of_device_id ft6236_of_match[] = { 301 + { .compatible = "focaltech,ft6236", }, 302 + { } 303 + }; 304 + MODULE_DEVICE_TABLE(of, ft6236_of_match); 305 + #endif 306 + 307 + static const struct i2c_device_id ft6236_id[] = { 308 + { "ft6236", }, 309 + { } 310 + }; 311 + MODULE_DEVICE_TABLE(i2c, ft6236_id); 312 + 313 + static struct i2c_driver ft6236_driver = { 314 + .driver = { 315 + .name = "ft6236", 316 + .of_match_table = of_match_ptr(ft6236_of_match), 317 + }, 318 + .probe = ft6236_probe, 319 + .id_table = ft6236_id, 320 + }; 321 + module_i2c_driver(ft6236_driver); 322 + 323 + MODULE_AUTHOR("Sean Cross <xobs@kosagi.com>"); 324 + MODULE_AUTHOR("Noralf Trønnes <noralf@tronnes.org>"); 325 + MODULE_DESCRIPTION("FocalTech FT6236 TouchScreen driver"); 326 + MODULE_LICENSE("GPL v2");
-12
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 377 377 goto unlock; 378 378 } 379 379 } 380 - 381 - enable_irq_wake(client->irq); 382 380 } else if (input->users) { 383 381 ret = pixcir_stop(ts); 384 382 } ··· 397 399 mutex_lock(&input->mutex); 398 400 399 401 if (device_may_wakeup(&client->dev)) { 400 - disable_irq_wake(client->irq); 401 402 402 403 if (!input->users) { 403 404 ret = pixcir_stop(ts); ··· 561 564 return error; 562 565 563 566 i2c_set_clientdata(client, tsdata); 564 - device_init_wakeup(&client->dev, 1); 565 - 566 - return 0; 567 - } 568 - 569 - static int pixcir_i2c_ts_remove(struct i2c_client *client) 570 - { 571 - device_init_wakeup(&client->dev, 0); 572 567 573 568 return 0; 574 569 } ··· 598 609 .of_match_table = of_match_ptr(pixcir_of_match), 599 610 }, 600 611 .probe = pixcir_i2c_ts_probe, 601 - .remove = pixcir_i2c_ts_remove, 602 612 .id_table = pixcir_i2c_ts_id, 603 613 }; 604 614
+1218
drivers/input/touchscreen/rohm_bu21023.c
··· 1 + /* 2 + * ROHM BU21023/24 Dual touch support resistive touch screen driver 3 + * Copyright (C) 2012 ROHM CO.,LTD. 4 + * 5 + * This software is licensed under the terms of the GNU General Public 6 + * License version 2, as published by the Free Software Foundation, and 7 + * may be copied, distributed, and modified under those terms. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + */ 14 + #include <linux/delay.h> 15 + #include <linux/firmware.h> 16 + #include <linux/i2c.h> 17 + #include <linux/input.h> 18 + #include <linux/input/mt.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/module.h> 21 + #include <linux/slab.h> 22 + 23 + #define BU21023_NAME "bu21023_ts" 24 + #define BU21023_FIRMWARE_NAME "bu21023.bin" 25 + 26 + #define MAX_CONTACTS 2 27 + 28 + #define AXIS_ADJUST 4 29 + #define AXIS_OFFSET 8 30 + 31 + #define FIRMWARE_BLOCK_SIZE 32U 32 + #define FIRMWARE_RETRY_MAX 4 33 + 34 + #define SAMPLING_DELAY 12 /* msec */ 35 + 36 + #define CALIBRATION_RETRY_MAX 6 37 + 38 + #define ROHM_TS_ABS_X_MIN 40 39 + #define ROHM_TS_ABS_X_MAX 990 40 + #define ROHM_TS_ABS_Y_MIN 160 41 + #define ROHM_TS_ABS_Y_MAX 920 42 + #define ROHM_TS_DISPLACEMENT_MAX 0 /* zero for infinite */ 43 + 44 + /* 45 + * BU21023GUL/BU21023MUV/BU21024FV-M registers map 46 + */ 47 + #define VADOUT_YP_H 0x00 48 + #define VADOUT_YP_L 0x01 49 + #define VADOUT_XP_H 0x02 50 + #define VADOUT_XP_L 0x03 51 + #define VADOUT_YN_H 0x04 52 + #define VADOUT_YN_L 0x05 53 + #define VADOUT_XN_H 0x06 54 + #define VADOUT_XN_L 0x07 55 + 56 + #define PRM1_X_H 0x08 57 + #define PRM1_X_L 0x09 58 + #define PRM1_Y_H 0x0a 59 + #define PRM1_Y_L 0x0b 60 + #define PRM2_X_H 0x0c 61 + #define PRM2_X_L 0x0d 62 + #define PRM2_Y_H 0x0e 63 + #define PRM2_Y_L 0x0f 64 + 65 + #define MLT_PRM_MONI_X 0x10 66 + #define MLT_PRM_MONI_Y 0x11 67 + 68 + #define DEBUG_MONI_1 0x12 69 + #define DEBUG_MONI_2 0x13 70 + 71 + #define VADOUT_ZX_H 0x14 72 + #define VADOUT_ZX_L 0x15 73 + #define VADOUT_ZY_H 0x16 74 + #define VADOUT_ZY_L 0x17 75 + 76 + #define Z_PARAM_H 0x18 77 + #define Z_PARAM_L 0x19 78 + 79 + /* 80 + * Value for VADOUT_*_L 81 + */ 82 + #define VADOUT_L_MASK 0x01 83 + 84 + /* 85 + * Value for PRM*_*_L 86 + */ 87 + #define PRM_L_MASK 0x01 88 + 89 + #define POS_X1_H 0x20 90 + #define POS_X1_L 0x21 91 + #define POS_Y1_H 0x22 92 + #define POS_Y1_L 0x23 93 + #define POS_X2_H 0x24 94 + #define POS_X2_L 0x25 95 + #define POS_Y2_H 0x26 96 + #define POS_Y2_L 0x27 97 + 98 + /* 99 + * Value for POS_*_L 100 + */ 101 + #define POS_L_MASK 0x01 102 + 103 + #define TOUCH 0x28 104 + #define TOUCH_DETECT 0x01 105 + 106 + #define TOUCH_GESTURE 0x29 107 + #define SINGLE_TOUCH 0x01 108 + #define DUAL_TOUCH 0x03 109 + #define TOUCH_MASK 0x03 110 + #define CALIBRATION_REQUEST 0x04 111 + #define CALIBRATION_STATUS 0x08 112 + #define CALIBRATION_MASK 0x0c 113 + #define GESTURE_SPREAD 0x10 114 + #define GESTURE_PINCH 0x20 115 + #define GESTURE_ROTATE_R 0x40 116 + #define GESTURE_ROTATE_L 0x80 117 + 118 + #define INT_STATUS 0x2a 119 + #define INT_MASK 0x3d 120 + #define INT_CLEAR 0x3e 121 + 122 + /* 123 + * Values for INT_* 124 + */ 125 + #define COORD_UPDATE 0x01 126 + #define CALIBRATION_DONE 0x02 127 + #define SLEEP_IN 0x04 128 + #define SLEEP_OUT 0x08 129 + #define PROGRAM_LOAD_DONE 0x10 130 + #define ERROR 0x80 131 + #define INT_ALL 0x9f 132 + 133 + #define ERR_STATUS 0x2b 134 + #define ERR_MASK 0x3f 135 + 136 + /* 137 + * Values for ERR_* 138 + */ 139 + #define ADC_TIMEOUT 0x01 140 + #define CPU_TIMEOUT 0x02 141 + #define CALIBRATION_ERR 0x04 142 + #define PROGRAM_LOAD_ERR 0x10 143 + 144 + #define COMMON_SETUP1 0x30 145 + #define PROGRAM_LOAD_HOST 0x02 146 + #define PROGRAM_LOAD_EEPROM 0x03 147 + #define CENSOR_4PORT 0x04 148 + #define CENSOR_8PORT 0x00 /* Not supported by BU21023 */ 149 + #define CALIBRATION_TYPE_DEFAULT 0x08 150 + #define CALIBRATION_TYPE_SPECIAL 0x00 151 + #define INT_ACTIVE_HIGH 0x10 152 + #define INT_ACTIVE_LOW 0x00 153 + #define AUTO_CALIBRATION 0x40 154 + #define MANUAL_CALIBRATION 0x00 155 + #define COMMON_SETUP1_DEFAULT 0x4e 156 + 157 + #define COMMON_SETUP2 0x31 158 + #define MAF_NONE 0x00 159 + #define MAF_1SAMPLE 0x01 160 + #define MAF_3SAMPLES 0x02 161 + #define MAF_5SAMPLES 0x03 162 + #define INV_Y 0x04 163 + #define INV_X 0x08 164 + #define SWAP_XY 0x10 165 + 166 + #define COMMON_SETUP3 0x32 167 + #define EN_SLEEP 0x01 168 + #define EN_MULTI 0x02 169 + #define EN_GESTURE 0x04 170 + #define EN_INTVL 0x08 171 + #define SEL_STEP 0x10 172 + #define SEL_MULTI 0x20 173 + #define SEL_TBL_DEFAULT 0x40 174 + 175 + #define INTERVAL_TIME 0x33 176 + #define INTERVAL_TIME_DEFAULT 0x10 177 + 178 + #define STEP_X 0x34 179 + #define STEP_X_DEFAULT 0x41 180 + 181 + #define STEP_Y 0x35 182 + #define STEP_Y_DEFAULT 0x8d 183 + 184 + #define OFFSET_X 0x38 185 + #define OFFSET_X_DEFAULT 0x0c 186 + 187 + #define OFFSET_Y 0x39 188 + #define OFFSET_Y_DEFAULT 0x0c 189 + 190 + #define THRESHOLD_TOUCH 0x3a 191 + #define THRESHOLD_TOUCH_DEFAULT 0xa0 192 + 193 + #define THRESHOLD_GESTURE 0x3b 194 + #define THRESHOLD_GESTURE_DEFAULT 0x17 195 + 196 + #define SYSTEM 0x40 197 + #define ANALOG_POWER_ON 0x01 198 + #define ANALOG_POWER_OFF 0x00 199 + #define CPU_POWER_ON 0x02 200 + #define CPU_POWER_OFF 0x00 201 + 202 + #define FORCE_CALIBRATION 0x42 203 + #define FORCE_CALIBRATION_ON 0x01 204 + #define FORCE_CALIBRATION_OFF 0x00 205 + 206 + #define CPU_FREQ 0x50 /* 10 / (reg + 1) MHz */ 207 + #define CPU_FREQ_10MHZ 0x00 208 + #define CPU_FREQ_5MHZ 0x01 209 + #define CPU_FREQ_1MHZ 0x09 210 + 211 + #define EEPROM_ADDR 0x51 212 + 213 + #define CALIBRATION_ADJUST 0x52 214 + #define CALIBRATION_ADJUST_DEFAULT 0x00 215 + 216 + #define THRESHOLD_SLEEP_IN 0x53 217 + 218 + #define EVR_XY 0x56 219 + #define EVR_XY_DEFAULT 0x10 220 + 221 + #define PRM_SWOFF_TIME 0x57 222 + #define PRM_SWOFF_TIME_DEFAULT 0x04 223 + 224 + #define PROGRAM_VERSION 0x5f 225 + 226 + #define ADC_CTRL 0x60 227 + #define ADC_DIV_MASK 0x1f /* The minimum value is 4 */ 228 + #define ADC_DIV_DEFAULT 0x08 229 + 230 + #define ADC_WAIT 0x61 231 + #define ADC_WAIT_DEFAULT 0x0a 232 + 233 + #define SWCONT 0x62 234 + #define SWCONT_DEFAULT 0x0f 235 + 236 + #define EVR_X 0x63 237 + #define EVR_X_DEFAULT 0x86 238 + 239 + #define EVR_Y 0x64 240 + #define EVR_Y_DEFAULT 0x64 241 + 242 + #define TEST1 0x65 243 + #define DUALTOUCH_STABILIZE_ON 0x01 244 + #define DUALTOUCH_STABILIZE_OFF 0x00 245 + #define DUALTOUCH_REG_ON 0x20 246 + #define DUALTOUCH_REG_OFF 0x00 247 + 248 + #define CALIBRATION_REG1 0x68 249 + #define CALIBRATION_REG1_DEFAULT 0xd9 250 + 251 + #define CALIBRATION_REG2 0x69 252 + #define CALIBRATION_REG2_DEFAULT 0x36 253 + 254 + #define CALIBRATION_REG3 0x6a 255 + #define CALIBRATION_REG3_DEFAULT 0x32 256 + 257 + #define EX_ADDR_H 0x70 258 + #define EX_ADDR_L 0x71 259 + #define EX_WDAT 0x72 260 + #define EX_RDAT 0x73 261 + #define EX_CHK_SUM1 0x74 262 + #define EX_CHK_SUM2 0x75 263 + #define EX_CHK_SUM3 0x76 264 + 265 + struct rohm_ts_data { 266 + struct i2c_client *client; 267 + struct input_dev *input; 268 + 269 + bool initialized; 270 + 271 + unsigned int contact_count[MAX_CONTACTS + 1]; 272 + int finger_count; 273 + 274 + u8 setup2; 275 + }; 276 + 277 + /* 278 + * rohm_i2c_burst_read - execute combined I2C message for ROHM BU21023/24 279 + * @client: Handle to ROHM BU21023/24 280 + * @start: Where to start read address from ROHM BU21023/24 281 + * @buf: Where to store read data from ROHM BU21023/24 282 + * @len: How many bytes to read 283 + * 284 + * Returns negative errno, else zero on success. 285 + * 286 + * Note 287 + * In BU21023/24 burst read, stop condition is needed after "address write". 288 + * Therefore, transmission is performed in 2 steps. 289 + */ 290 + static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf, 291 + size_t len) 292 + { 293 + struct i2c_adapter *adap = client->adapter; 294 + struct i2c_msg msg[2]; 295 + int i, ret = 0; 296 + 297 + msg[0].addr = client->addr; 298 + msg[0].flags = 0; 299 + msg[0].len = 1; 300 + msg[0].buf = &start; 301 + 302 + msg[1].addr = client->addr; 303 + msg[1].flags = I2C_M_RD; 304 + msg[1].len = len; 305 + msg[1].buf = buf; 306 + 307 + i2c_lock_adapter(adap); 308 + 309 + for (i = 0; i < 2; i++) { 310 + if (__i2c_transfer(adap, &msg[i], 1) < 0) { 311 + ret = -EIO; 312 + break; 313 + } 314 + } 315 + 316 + i2c_unlock_adapter(adap); 317 + 318 + return ret; 319 + } 320 + 321 + static int rohm_ts_manual_calibration(struct rohm_ts_data *ts) 322 + { 323 + struct i2c_client *client = ts->client; 324 + struct device *dev = &client->dev; 325 + u8 buf[33]; /* for PRM1_X_H(0x08)-TOUCH(0x28) */ 326 + 327 + int retry; 328 + bool success = false; 329 + bool first_time = true; 330 + bool calibration_done; 331 + 332 + u8 reg1, reg2, reg3; 333 + s32 reg1_orig, reg2_orig, reg3_orig; 334 + s32 val; 335 + 336 + int calib_x = 0, calib_y = 0; 337 + int reg_x, reg_y; 338 + int err_x, err_y; 339 + 340 + int error, error2; 341 + int i; 342 + 343 + reg1_orig = i2c_smbus_read_byte_data(client, CALIBRATION_REG1); 344 + if (reg1_orig < 0) 345 + return reg1_orig; 346 + 347 + reg2_orig = i2c_smbus_read_byte_data(client, CALIBRATION_REG2); 348 + if (reg2_orig < 0) 349 + return reg2_orig; 350 + 351 + reg3_orig = i2c_smbus_read_byte_data(client, CALIBRATION_REG3); 352 + if (reg3_orig < 0) 353 + return reg3_orig; 354 + 355 + error = i2c_smbus_write_byte_data(client, INT_MASK, 356 + COORD_UPDATE | SLEEP_IN | SLEEP_OUT | 357 + PROGRAM_LOAD_DONE); 358 + if (error) 359 + goto out; 360 + 361 + error = i2c_smbus_write_byte_data(client, TEST1, 362 + DUALTOUCH_STABILIZE_ON); 363 + if (error) 364 + goto out; 365 + 366 + for (retry = 0; retry < CALIBRATION_RETRY_MAX; retry++) { 367 + /* wait 2 sampling for update */ 368 + mdelay(2 * SAMPLING_DELAY); 369 + 370 + #define READ_CALIB_BUF(reg) buf[((reg) - PRM1_X_H)] 371 + 372 + error = rohm_i2c_burst_read(client, PRM1_X_H, buf, sizeof(buf)); 373 + if (error) 374 + goto out; 375 + 376 + if (READ_CALIB_BUF(TOUCH) & TOUCH_DETECT) 377 + continue; 378 + 379 + if (first_time) { 380 + /* generate calibration parameter */ 381 + calib_x = ((int)READ_CALIB_BUF(PRM1_X_H) << 2 | 382 + READ_CALIB_BUF(PRM1_X_L)) - AXIS_OFFSET; 383 + calib_y = ((int)READ_CALIB_BUF(PRM1_Y_H) << 2 | 384 + READ_CALIB_BUF(PRM1_Y_L)) - AXIS_OFFSET; 385 + 386 + error = i2c_smbus_write_byte_data(client, TEST1, 387 + DUALTOUCH_STABILIZE_ON | DUALTOUCH_REG_ON); 388 + if (error) 389 + goto out; 390 + 391 + first_time = false; 392 + } else { 393 + /* generate adjustment parameter */ 394 + err_x = (int)READ_CALIB_BUF(PRM1_X_H) << 2 | 395 + READ_CALIB_BUF(PRM1_X_L); 396 + err_y = (int)READ_CALIB_BUF(PRM1_Y_H) << 2 | 397 + READ_CALIB_BUF(PRM1_Y_L); 398 + 399 + /* X axis ajust */ 400 + if (err_x <= 4) 401 + calib_x -= AXIS_ADJUST; 402 + else if (err_x >= 60) 403 + calib_x += AXIS_ADJUST; 404 + 405 + /* Y axis ajust */ 406 + if (err_y <= 4) 407 + calib_y -= AXIS_ADJUST; 408 + else if (err_y >= 60) 409 + calib_y += AXIS_ADJUST; 410 + } 411 + 412 + /* generate calibration setting value */ 413 + reg_x = calib_x + ((calib_x & 0x200) << 1); 414 + reg_y = calib_y + ((calib_y & 0x200) << 1); 415 + 416 + /* convert for register format */ 417 + reg1 = reg_x >> 3; 418 + reg2 = (reg_y & 0x7) << 4 | (reg_x & 0x7); 419 + reg3 = reg_y >> 3; 420 + 421 + error = i2c_smbus_write_byte_data(client, 422 + CALIBRATION_REG1, reg1); 423 + if (error) 424 + goto out; 425 + 426 + error = i2c_smbus_write_byte_data(client, 427 + CALIBRATION_REG2, reg2); 428 + if (error) 429 + goto out; 430 + 431 + error = i2c_smbus_write_byte_data(client, 432 + CALIBRATION_REG3, reg3); 433 + if (error) 434 + goto out; 435 + 436 + /* 437 + * force calibration sequcence 438 + */ 439 + error = i2c_smbus_write_byte_data(client, FORCE_CALIBRATION, 440 + FORCE_CALIBRATION_OFF); 441 + if (error) 442 + goto out; 443 + 444 + error = i2c_smbus_write_byte_data(client, FORCE_CALIBRATION, 445 + FORCE_CALIBRATION_ON); 446 + if (error) 447 + goto out; 448 + 449 + /* clear all interrupts */ 450 + error = i2c_smbus_write_byte_data(client, INT_CLEAR, 0xff); 451 + if (error) 452 + goto out; 453 + 454 + /* 455 + * Wait for the status change of calibration, max 10 sampling 456 + */ 457 + calibration_done = false; 458 + 459 + for (i = 0; i < 10; i++) { 460 + mdelay(SAMPLING_DELAY); 461 + 462 + val = i2c_smbus_read_byte_data(client, TOUCH_GESTURE); 463 + if (!(val & CALIBRATION_MASK)) { 464 + calibration_done = true; 465 + break; 466 + } else if (val < 0) { 467 + error = val; 468 + goto out; 469 + } 470 + } 471 + 472 + if (calibration_done) { 473 + val = i2c_smbus_read_byte_data(client, INT_STATUS); 474 + if (val == CALIBRATION_DONE) { 475 + success = true; 476 + break; 477 + } else if (val < 0) { 478 + error = val; 479 + goto out; 480 + } 481 + } else { 482 + dev_warn(dev, "calibration timeout\n"); 483 + } 484 + } 485 + 486 + if (!success) { 487 + error = i2c_smbus_write_byte_data(client, CALIBRATION_REG1, 488 + reg1_orig); 489 + if (error) 490 + goto out; 491 + 492 + error = i2c_smbus_write_byte_data(client, CALIBRATION_REG2, 493 + reg2_orig); 494 + if (error) 495 + goto out; 496 + 497 + error = i2c_smbus_write_byte_data(client, CALIBRATION_REG3, 498 + reg3_orig); 499 + if (error) 500 + goto out; 501 + 502 + /* calibration data enable */ 503 + error = i2c_smbus_write_byte_data(client, TEST1, 504 + DUALTOUCH_STABILIZE_ON | 505 + DUALTOUCH_REG_ON); 506 + if (error) 507 + goto out; 508 + 509 + /* wait 10 sampling */ 510 + mdelay(10 * SAMPLING_DELAY); 511 + 512 + error = -EBUSY; 513 + } 514 + 515 + out: 516 + error2 = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL); 517 + if (!error2) 518 + /* Clear all interrupts */ 519 + error2 = i2c_smbus_write_byte_data(client, INT_CLEAR, 0xff); 520 + 521 + return error ? error : error2; 522 + } 523 + 524 + static const unsigned int untouch_threshold[3] = { 0, 1, 5 }; 525 + static const unsigned int single_touch_threshold[3] = { 0, 0, 4 }; 526 + static const unsigned int dual_touch_threshold[3] = { 10, 8, 0 }; 527 + 528 + static irqreturn_t rohm_ts_soft_irq(int irq, void *dev_id) 529 + { 530 + struct rohm_ts_data *ts = dev_id; 531 + struct i2c_client *client = ts->client; 532 + struct input_dev *input_dev = ts->input; 533 + struct device *dev = &client->dev; 534 + 535 + u8 buf[10]; /* for POS_X1_H(0x20)-TOUCH_GESTURE(0x29) */ 536 + 537 + struct input_mt_pos pos[MAX_CONTACTS]; 538 + int slots[MAX_CONTACTS]; 539 + u8 touch_flags; 540 + unsigned int threshold; 541 + int finger_count = -1; 542 + int prev_finger_count = ts->finger_count; 543 + int count; 544 + int error; 545 + int i; 546 + 547 + error = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL); 548 + if (error) 549 + return IRQ_HANDLED; 550 + 551 + /* Clear all interrupts */ 552 + error = i2c_smbus_write_byte_data(client, INT_CLEAR, 0xff); 553 + if (error) 554 + return IRQ_HANDLED; 555 + 556 + #define READ_POS_BUF(reg) buf[((reg) - POS_X1_H)] 557 + 558 + error = rohm_i2c_burst_read(client, POS_X1_H, buf, sizeof(buf)); 559 + if (error) 560 + return IRQ_HANDLED; 561 + 562 + touch_flags = READ_POS_BUF(TOUCH_GESTURE) & TOUCH_MASK; 563 + if (touch_flags) { 564 + /* generate coordinates */ 565 + pos[0].x = ((s16)READ_POS_BUF(POS_X1_H) << 2) | 566 + READ_POS_BUF(POS_X1_L); 567 + pos[0].y = ((s16)READ_POS_BUF(POS_Y1_H) << 2) | 568 + READ_POS_BUF(POS_Y1_L); 569 + pos[1].x = ((s16)READ_POS_BUF(POS_X2_H) << 2) | 570 + READ_POS_BUF(POS_X2_L); 571 + pos[1].y = ((s16)READ_POS_BUF(POS_Y2_H) << 2) | 572 + READ_POS_BUF(POS_Y2_L); 573 + } 574 + 575 + switch (touch_flags) { 576 + case 0: 577 + threshold = untouch_threshold[prev_finger_count]; 578 + if (++ts->contact_count[0] >= threshold) 579 + finger_count = 0; 580 + break; 581 + 582 + case SINGLE_TOUCH: 583 + threshold = single_touch_threshold[prev_finger_count]; 584 + if (++ts->contact_count[1] >= threshold) 585 + finger_count = 1; 586 + 587 + if (finger_count == 1) { 588 + if (pos[1].x != 0 && pos[1].y != 0) { 589 + pos[0].x = pos[1].x; 590 + pos[0].y = pos[1].y; 591 + pos[1].x = 0; 592 + pos[1].y = 0; 593 + } 594 + } 595 + break; 596 + 597 + case DUAL_TOUCH: 598 + threshold = dual_touch_threshold[prev_finger_count]; 599 + if (++ts->contact_count[2] >= threshold) 600 + finger_count = 2; 601 + break; 602 + 603 + default: 604 + dev_dbg(dev, 605 + "Three or more touches are not supported\n"); 606 + return IRQ_HANDLED; 607 + } 608 + 609 + if (finger_count >= 0) { 610 + if (prev_finger_count != finger_count) { 611 + count = ts->contact_count[finger_count]; 612 + memset(ts->contact_count, 0, sizeof(ts->contact_count)); 613 + ts->contact_count[finger_count] = count; 614 + } 615 + 616 + input_mt_assign_slots(input_dev, slots, pos, 617 + finger_count, ROHM_TS_DISPLACEMENT_MAX); 618 + 619 + for (i = 0; i < finger_count; i++) { 620 + input_mt_slot(input_dev, slots[i]); 621 + input_mt_report_slot_state(input_dev, 622 + MT_TOOL_FINGER, true); 623 + input_report_abs(input_dev, 624 + ABS_MT_POSITION_X, pos[i].x); 625 + input_report_abs(input_dev, 626 + ABS_MT_POSITION_Y, pos[i].y); 627 + } 628 + 629 + input_mt_sync_frame(input_dev); 630 + input_mt_report_pointer_emulation(input_dev, true); 631 + input_sync(input_dev); 632 + 633 + ts->finger_count = finger_count; 634 + } 635 + 636 + if (READ_POS_BUF(TOUCH_GESTURE) & CALIBRATION_REQUEST) { 637 + error = rohm_ts_manual_calibration(ts); 638 + if (error) 639 + dev_warn(dev, "manual calibration failed: %d\n", 640 + error); 641 + } 642 + 643 + i2c_smbus_write_byte_data(client, INT_MASK, 644 + CALIBRATION_DONE | SLEEP_OUT | SLEEP_IN | 645 + PROGRAM_LOAD_DONE); 646 + 647 + return IRQ_HANDLED; 648 + } 649 + 650 + static int rohm_ts_load_firmware(struct i2c_client *client, 651 + const char *firmware_name) 652 + { 653 + struct device *dev = &client->dev; 654 + const struct firmware *fw; 655 + s32 status; 656 + unsigned int offset, len, xfer_len; 657 + unsigned int retry = 0; 658 + int error, error2; 659 + 660 + error = request_firmware(&fw, firmware_name, dev); 661 + if (error) { 662 + dev_err(dev, "unable to retrieve firmware %s: %d\n", 663 + firmware_name, error); 664 + return error; 665 + } 666 + 667 + error = i2c_smbus_write_byte_data(client, INT_MASK, 668 + COORD_UPDATE | CALIBRATION_DONE | 669 + SLEEP_IN | SLEEP_OUT); 670 + if (error) 671 + goto out; 672 + 673 + do { 674 + if (retry) { 675 + dev_warn(dev, "retrying firmware load\n"); 676 + 677 + /* settings for retry */ 678 + error = i2c_smbus_write_byte_data(client, EX_WDAT, 0); 679 + if (error) 680 + goto out; 681 + } 682 + 683 + error = i2c_smbus_write_byte_data(client, EX_ADDR_H, 0); 684 + if (error) 685 + goto out; 686 + 687 + error = i2c_smbus_write_byte_data(client, EX_ADDR_L, 0); 688 + if (error) 689 + goto out; 690 + 691 + error = i2c_smbus_write_byte_data(client, COMMON_SETUP1, 692 + COMMON_SETUP1_DEFAULT); 693 + if (error) 694 + goto out; 695 + 696 + /* firmware load to the device */ 697 + offset = 0; 698 + len = fw->size; 699 + 700 + while (len) { 701 + xfer_len = min(FIRMWARE_BLOCK_SIZE, len); 702 + 703 + error = i2c_smbus_write_i2c_block_data(client, EX_WDAT, 704 + xfer_len, &fw->data[offset]); 705 + if (error) 706 + goto out; 707 + 708 + len -= xfer_len; 709 + offset += xfer_len; 710 + } 711 + 712 + /* check firmware load result */ 713 + status = i2c_smbus_read_byte_data(client, INT_STATUS); 714 + if (status < 0) { 715 + error = status; 716 + goto out; 717 + } 718 + 719 + /* clear all interrupts */ 720 + error = i2c_smbus_write_byte_data(client, INT_CLEAR, 0xff); 721 + if (error) 722 + goto out; 723 + 724 + if (status == PROGRAM_LOAD_DONE) 725 + break; 726 + 727 + error = -EIO; 728 + } while (++retry >= FIRMWARE_RETRY_MAX); 729 + 730 + out: 731 + error2 = i2c_smbus_write_byte_data(client, INT_MASK, INT_ALL); 732 + 733 + release_firmware(fw); 734 + 735 + return error ? error : error2; 736 + } 737 + 738 + static ssize_t swap_xy_show(struct device *dev, struct device_attribute *attr, 739 + char *buf) 740 + { 741 + struct i2c_client *client = to_i2c_client(dev); 742 + struct rohm_ts_data *ts = i2c_get_clientdata(client); 743 + 744 + return sprintf(buf, "%d\n", !!(ts->setup2 & SWAP_XY)); 745 + } 746 + 747 + static ssize_t swap_xy_store(struct device *dev, struct device_attribute *attr, 748 + const char *buf, size_t count) 749 + { 750 + struct i2c_client *client = to_i2c_client(dev); 751 + struct rohm_ts_data *ts = i2c_get_clientdata(client); 752 + unsigned int val; 753 + int error; 754 + 755 + error = kstrtouint(buf, 0, &val); 756 + if (error) 757 + return error; 758 + 759 + error = mutex_lock_interruptible(&ts->input->mutex); 760 + if (error) 761 + return error; 762 + 763 + if (val) 764 + ts->setup2 |= SWAP_XY; 765 + else 766 + ts->setup2 &= ~SWAP_XY; 767 + 768 + if (ts->initialized) 769 + error = i2c_smbus_write_byte_data(ts->client, COMMON_SETUP2, 770 + ts->setup2); 771 + 772 + mutex_unlock(&ts->input->mutex); 773 + 774 + return error ? error : count; 775 + } 776 + 777 + static ssize_t inv_x_show(struct device *dev, struct device_attribute *attr, 778 + char *buf) 779 + { 780 + struct i2c_client *client = to_i2c_client(dev); 781 + struct rohm_ts_data *ts = i2c_get_clientdata(client); 782 + 783 + return sprintf(buf, "%d\n", !!(ts->setup2 & INV_X)); 784 + } 785 + 786 + static ssize_t inv_x_store(struct device *dev, struct device_attribute *attr, 787 + const char *buf, size_t count) 788 + { 789 + struct i2c_client *client = to_i2c_client(dev); 790 + struct rohm_ts_data *ts = i2c_get_clientdata(client); 791 + unsigned int val; 792 + int error; 793 + 794 + error = kstrtouint(buf, 0, &val); 795 + if (error) 796 + return error; 797 + 798 + error = mutex_lock_interruptible(&ts->input->mutex); 799 + if (error) 800 + return error; 801 + 802 + if (val) 803 + ts->setup2 |= INV_X; 804 + else 805 + ts->setup2 &= ~INV_X; 806 + 807 + if (ts->initialized) 808 + error = i2c_smbus_write_byte_data(ts->client, COMMON_SETUP2, 809 + ts->setup2); 810 + 811 + mutex_unlock(&ts->input->mutex); 812 + 813 + return error ? error : count; 814 + } 815 + 816 + static ssize_t inv_y_show(struct device *dev, struct device_attribute *attr, 817 + char *buf) 818 + { 819 + struct i2c_client *client = to_i2c_client(dev); 820 + struct rohm_ts_data *ts = i2c_get_clientdata(client); 821 + 822 + return sprintf(buf, "%d\n", !!(ts->setup2 & INV_Y)); 823 + } 824 + 825 + static ssize_t inv_y_store(struct device *dev, struct device_attribute *attr, 826 + const char *buf, size_t count) 827 + { 828 + struct i2c_client *client = to_i2c_client(dev); 829 + struct rohm_ts_data *ts = i2c_get_clientdata(client); 830 + unsigned int val; 831 + int error; 832 + 833 + error = kstrtouint(buf, 0, &val); 834 + if (error) 835 + return error; 836 + 837 + error = mutex_lock_interruptible(&ts->input->mutex); 838 + if (error) 839 + return error; 840 + 841 + if (val) 842 + ts->setup2 |= INV_Y; 843 + else 844 + ts->setup2 &= ~INV_Y; 845 + 846 + if (ts->initialized) 847 + error = i2c_smbus_write_byte_data(client, COMMON_SETUP2, 848 + ts->setup2); 849 + 850 + mutex_unlock(&ts->input->mutex); 851 + 852 + return error ? error : count; 853 + } 854 + 855 + static DEVICE_ATTR_RW(swap_xy); 856 + static DEVICE_ATTR_RW(inv_x); 857 + static DEVICE_ATTR_RW(inv_y); 858 + 859 + static struct attribute *rohm_ts_attrs[] = { 860 + &dev_attr_swap_xy.attr, 861 + &dev_attr_inv_x.attr, 862 + &dev_attr_inv_y.attr, 863 + NULL, 864 + }; 865 + 866 + static const struct attribute_group rohm_ts_attr_group = { 867 + .attrs = rohm_ts_attrs, 868 + }; 869 + 870 + static int rohm_ts_device_init(struct i2c_client *client, u8 setup2) 871 + { 872 + struct device *dev = &client->dev; 873 + int error; 874 + 875 + disable_irq(client->irq); 876 + 877 + /* 878 + * Wait 200usec for reset 879 + */ 880 + udelay(200); 881 + 882 + /* Release analog reset */ 883 + error = i2c_smbus_write_byte_data(client, SYSTEM, 884 + ANALOG_POWER_ON | CPU_POWER_OFF); 885 + if (error) 886 + return error; 887 + 888 + /* Waiting for the analog warm-up, max. 200usec */ 889 + udelay(200); 890 + 891 + /* clear all interrupts */ 892 + error = i2c_smbus_write_byte_data(client, INT_CLEAR, 0xff); 893 + if (error) 894 + return error; 895 + 896 + error = i2c_smbus_write_byte_data(client, EX_WDAT, 0); 897 + if (error) 898 + return error; 899 + 900 + error = i2c_smbus_write_byte_data(client, COMMON_SETUP1, 0); 901 + if (error) 902 + return error; 903 + 904 + error = i2c_smbus_write_byte_data(client, COMMON_SETUP2, setup2); 905 + if (error) 906 + return error; 907 + 908 + error = i2c_smbus_write_byte_data(client, COMMON_SETUP3, 909 + SEL_TBL_DEFAULT | EN_MULTI); 910 + if (error) 911 + return error; 912 + 913 + error = i2c_smbus_write_byte_data(client, THRESHOLD_GESTURE, 914 + THRESHOLD_GESTURE_DEFAULT); 915 + if (error) 916 + return error; 917 + 918 + error = i2c_smbus_write_byte_data(client, INTERVAL_TIME, 919 + INTERVAL_TIME_DEFAULT); 920 + if (error) 921 + return error; 922 + 923 + error = i2c_smbus_write_byte_data(client, CPU_FREQ, CPU_FREQ_10MHZ); 924 + if (error) 925 + return error; 926 + 927 + error = i2c_smbus_write_byte_data(client, PRM_SWOFF_TIME, 928 + PRM_SWOFF_TIME_DEFAULT); 929 + if (error) 930 + return error; 931 + 932 + error = i2c_smbus_write_byte_data(client, ADC_CTRL, ADC_DIV_DEFAULT); 933 + if (error) 934 + return error; 935 + 936 + error = i2c_smbus_write_byte_data(client, ADC_WAIT, ADC_WAIT_DEFAULT); 937 + if (error) 938 + return error; 939 + 940 + /* 941 + * Panel setup, these values change with the panel. 942 + */ 943 + error = i2c_smbus_write_byte_data(client, STEP_X, STEP_X_DEFAULT); 944 + if (error) 945 + return error; 946 + 947 + error = i2c_smbus_write_byte_data(client, STEP_Y, STEP_Y_DEFAULT); 948 + if (error) 949 + return error; 950 + 951 + error = i2c_smbus_write_byte_data(client, OFFSET_X, OFFSET_X_DEFAULT); 952 + if (error) 953 + return error; 954 + 955 + error = i2c_smbus_write_byte_data(client, OFFSET_Y, OFFSET_Y_DEFAULT); 956 + if (error) 957 + return error; 958 + 959 + error = i2c_smbus_write_byte_data(client, THRESHOLD_TOUCH, 960 + THRESHOLD_TOUCH_DEFAULT); 961 + if (error) 962 + return error; 963 + 964 + error = i2c_smbus_write_byte_data(client, EVR_XY, EVR_XY_DEFAULT); 965 + if (error) 966 + return error; 967 + 968 + error = i2c_smbus_write_byte_data(client, EVR_X, EVR_X_DEFAULT); 969 + if (error) 970 + return error; 971 + 972 + error = i2c_smbus_write_byte_data(client, EVR_Y, EVR_Y_DEFAULT); 973 + if (error) 974 + return error; 975 + 976 + /* Fixed value settings */ 977 + error = i2c_smbus_write_byte_data(client, CALIBRATION_ADJUST, 978 + CALIBRATION_ADJUST_DEFAULT); 979 + if (error) 980 + return error; 981 + 982 + error = i2c_smbus_write_byte_data(client, SWCONT, SWCONT_DEFAULT); 983 + if (error) 984 + return error; 985 + 986 + error = i2c_smbus_write_byte_data(client, TEST1, 987 + DUALTOUCH_STABILIZE_ON | 988 + DUALTOUCH_REG_ON); 989 + if (error) 990 + return error; 991 + 992 + error = rohm_ts_load_firmware(client, BU21023_FIRMWARE_NAME); 993 + if (error) { 994 + dev_err(dev, "failed to load firmware: %d\n", error); 995 + return error; 996 + } 997 + 998 + /* 999 + * Manual calibration results are not changed in same environment. 1000 + * If the force calibration is performed, 1001 + * the controller will not require calibration request interrupt 1002 + * when the typical values are set to the calibration registers. 1003 + */ 1004 + error = i2c_smbus_write_byte_data(client, CALIBRATION_REG1, 1005 + CALIBRATION_REG1_DEFAULT); 1006 + if (error) 1007 + return error; 1008 + 1009 + error = i2c_smbus_write_byte_data(client, CALIBRATION_REG2, 1010 + CALIBRATION_REG2_DEFAULT); 1011 + if (error) 1012 + return error; 1013 + 1014 + error = i2c_smbus_write_byte_data(client, CALIBRATION_REG3, 1015 + CALIBRATION_REG3_DEFAULT); 1016 + if (error) 1017 + return error; 1018 + 1019 + error = i2c_smbus_write_byte_data(client, FORCE_CALIBRATION, 1020 + FORCE_CALIBRATION_OFF); 1021 + if (error) 1022 + return error; 1023 + 1024 + error = i2c_smbus_write_byte_data(client, FORCE_CALIBRATION, 1025 + FORCE_CALIBRATION_ON); 1026 + if (error) 1027 + return error; 1028 + 1029 + /* Clear all interrupts */ 1030 + error = i2c_smbus_write_byte_data(client, INT_CLEAR, 0xff); 1031 + if (error) 1032 + return error; 1033 + 1034 + /* Enable coordinates update interrupt */ 1035 + error = i2c_smbus_write_byte_data(client, INT_MASK, 1036 + CALIBRATION_DONE | SLEEP_OUT | 1037 + SLEEP_IN | PROGRAM_LOAD_DONE); 1038 + if (error) 1039 + return error; 1040 + 1041 + error = i2c_smbus_write_byte_data(client, ERR_MASK, 1042 + PROGRAM_LOAD_ERR | CPU_TIMEOUT | 1043 + ADC_TIMEOUT); 1044 + if (error) 1045 + return error; 1046 + 1047 + /* controller CPU power on */ 1048 + error = i2c_smbus_write_byte_data(client, SYSTEM, 1049 + ANALOG_POWER_ON | CPU_POWER_ON); 1050 + 1051 + enable_irq(client->irq); 1052 + 1053 + return error; 1054 + } 1055 + 1056 + static int rohm_ts_power_off(struct i2c_client *client) 1057 + { 1058 + int error; 1059 + 1060 + error = i2c_smbus_write_byte_data(client, SYSTEM, 1061 + ANALOG_POWER_ON | CPU_POWER_OFF); 1062 + if (error) { 1063 + dev_err(&client->dev, 1064 + "failed to power off device CPU: %d\n", error); 1065 + return error; 1066 + } 1067 + 1068 + error = i2c_smbus_write_byte_data(client, SYSTEM, 1069 + ANALOG_POWER_OFF | CPU_POWER_OFF); 1070 + if (error) 1071 + dev_err(&client->dev, 1072 + "failed to power off the device: %d\n", error); 1073 + 1074 + return error; 1075 + } 1076 + 1077 + static int rohm_ts_open(struct input_dev *input_dev) 1078 + { 1079 + struct rohm_ts_data *ts = input_get_drvdata(input_dev); 1080 + struct i2c_client *client = ts->client; 1081 + int error; 1082 + 1083 + if (!ts->initialized) { 1084 + error = rohm_ts_device_init(client, ts->setup2); 1085 + if (error) { 1086 + dev_err(&client->dev, 1087 + "device initialization failed: %d\n", error); 1088 + return error; 1089 + } 1090 + 1091 + ts->initialized = true; 1092 + } 1093 + 1094 + return 0; 1095 + } 1096 + 1097 + static void rohm_ts_close(struct input_dev *input_dev) 1098 + { 1099 + struct rohm_ts_data *ts = input_get_drvdata(input_dev); 1100 + 1101 + rohm_ts_power_off(ts->client); 1102 + 1103 + ts->initialized = false; 1104 + } 1105 + 1106 + static void rohm_ts_remove_sysfs_group(void *_dev) 1107 + { 1108 + struct device *dev = _dev; 1109 + 1110 + sysfs_remove_group(&dev->kobj, &rohm_ts_attr_group); 1111 + } 1112 + 1113 + static int rohm_bu21023_i2c_probe(struct i2c_client *client, 1114 + const struct i2c_device_id *id) 1115 + { 1116 + struct device *dev = &client->dev; 1117 + struct rohm_ts_data *ts; 1118 + struct input_dev *input; 1119 + int error; 1120 + 1121 + if (!client->irq) { 1122 + dev_err(dev, "IRQ is not assigned\n"); 1123 + return -EINVAL; 1124 + } 1125 + 1126 + if (!client->adapter->algo->master_xfer) { 1127 + dev_err(dev, "I2C level transfers not supported\n"); 1128 + return -EOPNOTSUPP; 1129 + } 1130 + 1131 + /* Turn off CPU just in case */ 1132 + error = rohm_ts_power_off(client); 1133 + if (error) 1134 + return error; 1135 + 1136 + ts = devm_kzalloc(dev, sizeof(struct rohm_ts_data), GFP_KERNEL); 1137 + if (!ts) 1138 + return -ENOMEM; 1139 + 1140 + ts->client = client; 1141 + ts->setup2 = MAF_1SAMPLE; 1142 + i2c_set_clientdata(client, ts); 1143 + 1144 + input = devm_input_allocate_device(dev); 1145 + if (!input) 1146 + return -ENOMEM; 1147 + 1148 + input->name = BU21023_NAME; 1149 + input->id.bustype = BUS_I2C; 1150 + input->open = rohm_ts_open; 1151 + input->close = rohm_ts_close; 1152 + 1153 + ts->input = input; 1154 + input_set_drvdata(input, ts); 1155 + 1156 + input_set_abs_params(input, ABS_MT_POSITION_X, 1157 + ROHM_TS_ABS_X_MIN, ROHM_TS_ABS_X_MAX, 0, 0); 1158 + input_set_abs_params(input, ABS_MT_POSITION_Y, 1159 + ROHM_TS_ABS_Y_MIN, ROHM_TS_ABS_Y_MAX, 0, 0); 1160 + 1161 + error = input_mt_init_slots(input, MAX_CONTACTS, 1162 + INPUT_MT_DIRECT | INPUT_MT_TRACK | 1163 + INPUT_MT_DROP_UNUSED); 1164 + if (error) { 1165 + dev_err(dev, "failed to multi touch slots initialization\n"); 1166 + return error; 1167 + } 1168 + 1169 + error = devm_request_threaded_irq(dev, client->irq, 1170 + NULL, rohm_ts_soft_irq, 1171 + IRQF_ONESHOT, client->name, ts); 1172 + if (error) { 1173 + dev_err(dev, "failed to request IRQ: %d\n", error); 1174 + return error; 1175 + } 1176 + 1177 + error = input_register_device(input); 1178 + if (error) { 1179 + dev_err(dev, "failed to register input device: %d\n", error); 1180 + return error; 1181 + } 1182 + 1183 + error = sysfs_create_group(&dev->kobj, &rohm_ts_attr_group); 1184 + if (error) { 1185 + dev_err(dev, "failed to create sysfs group: %d\n", error); 1186 + return error; 1187 + } 1188 + 1189 + error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev); 1190 + if (error) { 1191 + rohm_ts_remove_sysfs_group(dev); 1192 + dev_err(&client->dev, 1193 + "Failed to add sysfs cleanup action: %d\n", 1194 + error); 1195 + return error; 1196 + } 1197 + 1198 + return error; 1199 + } 1200 + 1201 + static const struct i2c_device_id rohm_bu21023_i2c_id[] = { 1202 + { BU21023_NAME, 0 }, 1203 + { /* sentinel */ } 1204 + }; 1205 + MODULE_DEVICE_TABLE(i2c, rohm_bu21023_i2c_id); 1206 + 1207 + static struct i2c_driver rohm_bu21023_i2c_driver = { 1208 + .driver = { 1209 + .name = BU21023_NAME, 1210 + }, 1211 + .probe = rohm_bu21023_i2c_probe, 1212 + .id_table = rohm_bu21023_i2c_id, 1213 + }; 1214 + module_i2c_driver(rohm_bu21023_i2c_driver); 1215 + 1216 + MODULE_DESCRIPTION("ROHM BU21023/24 Touchscreen driver"); 1217 + MODULE_LICENSE("GPL v2"); 1218 + MODULE_AUTHOR("ROHM Co., Ltd.");
+1 -8
drivers/input/touchscreen/tps6507x-ts.c
··· 50 50 51 51 static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data) 52 52 { 53 - int err; 54 - 55 - err = tsc->mfd->read_dev(tsc->mfd, reg, 1, data); 56 - 57 - if (err) 58 - return err; 59 - 60 - return 0; 53 + return tsc->mfd->read_dev(tsc->mfd, reg, 1, data); 61 54 } 62 55 63 56 static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data)
+1 -6
drivers/input/touchscreen/zforce_ts.c
··· 599 599 static int zforce_input_open(struct input_dev *dev) 600 600 { 601 601 struct zforce_ts *ts = input_get_drvdata(dev); 602 - int ret; 603 602 604 - ret = zforce_start(ts); 605 - if (ret) 606 - return ret; 607 - 608 - return 0; 603 + return zforce_start(ts); 609 604 } 610 605 611 606 static void zforce_input_close(struct input_dev *dev)
+1 -509
include/dt-bindings/input/input.h
··· 9 9 #ifndef _DT_BINDINGS_INPUT_INPUT_H 10 10 #define _DT_BINDINGS_INPUT_INPUT_H 11 11 12 - #define KEY_RESERVED 0 13 - #define KEY_ESC 1 14 - #define KEY_1 2 15 - #define KEY_2 3 16 - #define KEY_3 4 17 - #define KEY_4 5 18 - #define KEY_5 6 19 - #define KEY_6 7 20 - #define KEY_7 8 21 - #define KEY_8 9 22 - #define KEY_9 10 23 - #define KEY_0 11 24 - #define KEY_MINUS 12 25 - #define KEY_EQUAL 13 26 - #define KEY_BACKSPACE 14 27 - #define KEY_TAB 15 28 - #define KEY_Q 16 29 - #define KEY_W 17 30 - #define KEY_E 18 31 - #define KEY_R 19 32 - #define KEY_T 20 33 - #define KEY_Y 21 34 - #define KEY_U 22 35 - #define KEY_I 23 36 - #define KEY_O 24 37 - #define KEY_P 25 38 - #define KEY_LEFTBRACE 26 39 - #define KEY_RIGHTBRACE 27 40 - #define KEY_ENTER 28 41 - #define KEY_LEFTCTRL 29 42 - #define KEY_A 30 43 - #define KEY_S 31 44 - #define KEY_D 32 45 - #define KEY_F 33 46 - #define KEY_G 34 47 - #define KEY_H 35 48 - #define KEY_J 36 49 - #define KEY_K 37 50 - #define KEY_L 38 51 - #define KEY_SEMICOLON 39 52 - #define KEY_APOSTROPHE 40 53 - #define KEY_GRAVE 41 54 - #define KEY_LEFTSHIFT 42 55 - #define KEY_BACKSLASH 43 56 - #define KEY_Z 44 57 - #define KEY_X 45 58 - #define KEY_C 46 59 - #define KEY_V 47 60 - #define KEY_B 48 61 - #define KEY_N 49 62 - #define KEY_M 50 63 - #define KEY_COMMA 51 64 - #define KEY_DOT 52 65 - #define KEY_SLASH 53 66 - #define KEY_RIGHTSHIFT 54 67 - #define KEY_KPASTERISK 55 68 - #define KEY_LEFTALT 56 69 - #define KEY_SPACE 57 70 - #define KEY_CAPSLOCK 58 71 - #define KEY_F1 59 72 - #define KEY_F2 60 73 - #define KEY_F3 61 74 - #define KEY_F4 62 75 - #define KEY_F5 63 76 - #define KEY_F6 64 77 - #define KEY_F7 65 78 - #define KEY_F8 66 79 - #define KEY_F9 67 80 - #define KEY_F10 68 81 - #define KEY_NUMLOCK 69 82 - #define KEY_SCROLLLOCK 70 83 - #define KEY_KP7 71 84 - #define KEY_KP8 72 85 - #define KEY_KP9 73 86 - #define KEY_KPMINUS 74 87 - #define KEY_KP4 75 88 - #define KEY_KP5 76 89 - #define KEY_KP6 77 90 - #define KEY_KPPLUS 78 91 - #define KEY_KP1 79 92 - #define KEY_KP2 80 93 - #define KEY_KP3 81 94 - #define KEY_KP0 82 95 - #define KEY_KPDOT 83 96 - 97 - #define KEY_ZENKAKUHANKAKU 85 98 - #define KEY_102ND 86 99 - #define KEY_F11 87 100 - #define KEY_F12 88 101 - #define KEY_RO 89 102 - #define KEY_KATAKANA 90 103 - #define KEY_HIRAGANA 91 104 - #define KEY_HENKAN 92 105 - #define KEY_KATAKANAHIRAGANA 93 106 - #define KEY_MUHENKAN 94 107 - #define KEY_KPJPCOMMA 95 108 - #define KEY_KPENTER 96 109 - #define KEY_RIGHTCTRL 97 110 - #define KEY_KPSLASH 98 111 - #define KEY_SYSRQ 99 112 - #define KEY_RIGHTALT 100 113 - #define KEY_LINEFEED 101 114 - #define KEY_HOME 102 115 - #define KEY_UP 103 116 - #define KEY_PAGEUP 104 117 - #define KEY_LEFT 105 118 - #define KEY_RIGHT 106 119 - #define KEY_END 107 120 - #define KEY_DOWN 108 121 - #define KEY_PAGEDOWN 109 122 - #define KEY_INSERT 110 123 - #define KEY_DELETE 111 124 - #define KEY_MACRO 112 125 - #define KEY_MUTE 113 126 - #define KEY_VOLUMEDOWN 114 127 - #define KEY_VOLUMEUP 115 128 - #define KEY_POWER 116 /* SC System Power Down */ 129 - #define KEY_KPEQUAL 117 130 - #define KEY_KPPLUSMINUS 118 131 - #define KEY_PAUSE 119 132 - #define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ 133 - 134 - #define KEY_KPCOMMA 121 135 - #define KEY_HANGEUL 122 136 - #define KEY_HANGUEL KEY_HANGEUL 137 - #define KEY_HANJA 123 138 - #define KEY_YEN 124 139 - #define KEY_LEFTMETA 125 140 - #define KEY_RIGHTMETA 126 141 - #define KEY_COMPOSE 127 142 - 143 - #define KEY_STOP 128 /* AC Stop */ 144 - #define KEY_AGAIN 129 145 - #define KEY_PROPS 130 /* AC Properties */ 146 - #define KEY_UNDO 131 /* AC Undo */ 147 - #define KEY_FRONT 132 148 - #define KEY_COPY 133 /* AC Copy */ 149 - #define KEY_OPEN 134 /* AC Open */ 150 - #define KEY_PASTE 135 /* AC Paste */ 151 - #define KEY_FIND 136 /* AC Search */ 152 - #define KEY_CUT 137 /* AC Cut */ 153 - #define KEY_HELP 138 /* AL Integrated Help Center */ 154 - #define KEY_MENU 139 /* Menu (show menu) */ 155 - #define KEY_CALC 140 /* AL Calculator */ 156 - #define KEY_SETUP 141 157 - #define KEY_SLEEP 142 /* SC System Sleep */ 158 - #define KEY_WAKEUP 143 /* System Wake Up */ 159 - #define KEY_FILE 144 /* AL Local Machine Browser */ 160 - #define KEY_SENDFILE 145 161 - #define KEY_DELETEFILE 146 162 - #define KEY_XFER 147 163 - #define KEY_PROG1 148 164 - #define KEY_PROG2 149 165 - #define KEY_WWW 150 /* AL Internet Browser */ 166 - #define KEY_MSDOS 151 167 - #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ 168 - #define KEY_SCREENLOCK KEY_COFFEE 169 - #define KEY_DIRECTION 153 170 - #define KEY_CYCLEWINDOWS 154 171 - #define KEY_MAIL 155 172 - #define KEY_BOOKMARKS 156 /* AC Bookmarks */ 173 - #define KEY_COMPUTER 157 174 - #define KEY_BACK 158 /* AC Back */ 175 - #define KEY_FORWARD 159 /* AC Forward */ 176 - #define KEY_CLOSECD 160 177 - #define KEY_EJECTCD 161 178 - #define KEY_EJECTCLOSECD 162 179 - #define KEY_NEXTSONG 163 180 - #define KEY_PLAYPAUSE 164 181 - #define KEY_PREVIOUSSONG 165 182 - #define KEY_STOPCD 166 183 - #define KEY_RECORD 167 184 - #define KEY_REWIND 168 185 - #define KEY_PHONE 169 /* Media Select Telephone */ 186 - #define KEY_ISO 170 187 - #define KEY_CONFIG 171 /* AL Consumer Control Configuration */ 188 - #define KEY_HOMEPAGE 172 /* AC Home */ 189 - #define KEY_REFRESH 173 /* AC Refresh */ 190 - #define KEY_EXIT 174 /* AC Exit */ 191 - #define KEY_MOVE 175 192 - #define KEY_EDIT 176 193 - #define KEY_SCROLLUP 177 194 - #define KEY_SCROLLDOWN 178 195 - #define KEY_KPLEFTPAREN 179 196 - #define KEY_KPRIGHTPAREN 180 197 - #define KEY_NEW 181 /* AC New */ 198 - #define KEY_REDO 182 /* AC Redo/Repeat */ 199 - 200 - #define KEY_F13 183 201 - #define KEY_F14 184 202 - #define KEY_F15 185 203 - #define KEY_F16 186 204 - #define KEY_F17 187 205 - #define KEY_F18 188 206 - #define KEY_F19 189 207 - #define KEY_F20 190 208 - #define KEY_F21 191 209 - #define KEY_F22 192 210 - #define KEY_F23 193 211 - #define KEY_F24 194 212 - 213 - #define KEY_PLAYCD 200 214 - #define KEY_PAUSECD 201 215 - #define KEY_PROG3 202 216 - #define KEY_PROG4 203 217 - #define KEY_DASHBOARD 204 /* AL Dashboard */ 218 - #define KEY_SUSPEND 205 219 - #define KEY_CLOSE 206 /* AC Close */ 220 - #define KEY_PLAY 207 221 - #define KEY_FASTFORWARD 208 222 - #define KEY_BASSBOOST 209 223 - #define KEY_PRINT 210 /* AC Print */ 224 - #define KEY_HP 211 225 - #define KEY_CAMERA 212 226 - #define KEY_SOUND 213 227 - #define KEY_QUESTION 214 228 - #define KEY_EMAIL 215 229 - #define KEY_CHAT 216 230 - #define KEY_SEARCH 217 231 - #define KEY_CONNECT 218 232 - #define KEY_FINANCE 219 /* AL Checkbook/Finance */ 233 - #define KEY_SPORT 220 234 - #define KEY_SHOP 221 235 - #define KEY_ALTERASE 222 236 - #define KEY_CANCEL 223 /* AC Cancel */ 237 - #define KEY_BRIGHTNESSDOWN 224 238 - #define KEY_BRIGHTNESSUP 225 239 - #define KEY_MEDIA 226 240 - 241 - #define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video 242 - outputs (Monitor/LCD/TV-out/etc) */ 243 - #define KEY_KBDILLUMTOGGLE 228 244 - #define KEY_KBDILLUMDOWN 229 245 - #define KEY_KBDILLUMUP 230 246 - 247 - #define KEY_SEND 231 /* AC Send */ 248 - #define KEY_REPLY 232 /* AC Reply */ 249 - #define KEY_FORWARDMAIL 233 /* AC Forward Msg */ 250 - #define KEY_SAVE 234 /* AC Save */ 251 - #define KEY_DOCUMENTS 235 252 - 253 - #define KEY_BATTERY 236 254 - 255 - #define KEY_BLUETOOTH 237 256 - #define KEY_WLAN 238 257 - #define KEY_UWB 239 258 - 259 - #define KEY_UNKNOWN 240 260 - 261 - #define KEY_VIDEO_NEXT 241 /* drive next video source */ 262 - #define KEY_VIDEO_PREV 242 /* drive previous video source */ 263 - #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ 264 - #define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ 265 - #define KEY_DISPLAY_OFF 245 /* display device to off state */ 266 - 267 - #define KEY_WIMAX 246 268 - #define KEY_RFKILL 247 /* Key that controls all radios */ 269 - 270 - #define KEY_MICMUTE 248 /* Mute / unmute the microphone */ 271 - 272 - /* Code 255 is reserved for special needs of AT keyboard driver */ 273 - 274 - #define BTN_MISC 0x100 275 - #define BTN_0 0x100 276 - #define BTN_1 0x101 277 - #define BTN_2 0x102 278 - #define BTN_3 0x103 279 - #define BTN_4 0x104 280 - #define BTN_5 0x105 281 - #define BTN_6 0x106 282 - #define BTN_7 0x107 283 - #define BTN_8 0x108 284 - #define BTN_9 0x109 285 - 286 - #define BTN_MOUSE 0x110 287 - #define BTN_LEFT 0x110 288 - #define BTN_RIGHT 0x111 289 - #define BTN_MIDDLE 0x112 290 - #define BTN_SIDE 0x113 291 - #define BTN_EXTRA 0x114 292 - #define BTN_FORWARD 0x115 293 - #define BTN_BACK 0x116 294 - #define BTN_TASK 0x117 295 - 296 - #define BTN_JOYSTICK 0x120 297 - #define BTN_TRIGGER 0x120 298 - #define BTN_THUMB 0x121 299 - #define BTN_THUMB2 0x122 300 - #define BTN_TOP 0x123 301 - #define BTN_TOP2 0x124 302 - #define BTN_PINKIE 0x125 303 - #define BTN_BASE 0x126 304 - #define BTN_BASE2 0x127 305 - #define BTN_BASE3 0x128 306 - #define BTN_BASE4 0x129 307 - #define BTN_BASE5 0x12a 308 - #define BTN_BASE6 0x12b 309 - #define BTN_DEAD 0x12f 310 - 311 - #define BTN_GAMEPAD 0x130 312 - #define BTN_SOUTH 0x130 313 - #define BTN_A BTN_SOUTH 314 - #define BTN_EAST 0x131 315 - #define BTN_B BTN_EAST 316 - #define BTN_C 0x132 317 - #define BTN_NORTH 0x133 318 - #define BTN_X BTN_NORTH 319 - #define BTN_WEST 0x134 320 - #define BTN_Y BTN_WEST 321 - #define BTN_Z 0x135 322 - #define BTN_TL 0x136 323 - #define BTN_TR 0x137 324 - #define BTN_TL2 0x138 325 - #define BTN_TR2 0x139 326 - #define BTN_SELECT 0x13a 327 - #define BTN_START 0x13b 328 - #define BTN_MODE 0x13c 329 - #define BTN_THUMBL 0x13d 330 - #define BTN_THUMBR 0x13e 331 - 332 - #define BTN_DIGI 0x140 333 - #define BTN_TOOL_PEN 0x140 334 - #define BTN_TOOL_RUBBER 0x141 335 - #define BTN_TOOL_BRUSH 0x142 336 - #define BTN_TOOL_PENCIL 0x143 337 - #define BTN_TOOL_AIRBRUSH 0x144 338 - #define BTN_TOOL_FINGER 0x145 339 - #define BTN_TOOL_MOUSE 0x146 340 - #define BTN_TOOL_LENS 0x147 341 - #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ 342 - #define BTN_TOUCH 0x14a 343 - #define BTN_STYLUS 0x14b 344 - #define BTN_STYLUS2 0x14c 345 - #define BTN_TOOL_DOUBLETAP 0x14d 346 - #define BTN_TOOL_TRIPLETAP 0x14e 347 - #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ 348 - 349 - #define BTN_WHEEL 0x150 350 - #define BTN_GEAR_DOWN 0x150 351 - #define BTN_GEAR_UP 0x151 352 - 353 - #define KEY_OK 0x160 354 - #define KEY_SELECT 0x161 355 - #define KEY_GOTO 0x162 356 - #define KEY_CLEAR 0x163 357 - #define KEY_POWER2 0x164 358 - #define KEY_OPTION 0x165 359 - #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ 360 - #define KEY_TIME 0x167 361 - #define KEY_VENDOR 0x168 362 - #define KEY_ARCHIVE 0x169 363 - #define KEY_PROGRAM 0x16a /* Media Select Program Guide */ 364 - #define KEY_CHANNEL 0x16b 365 - #define KEY_FAVORITES 0x16c 366 - #define KEY_EPG 0x16d 367 - #define KEY_PVR 0x16e /* Media Select Home */ 368 - #define KEY_MHP 0x16f 369 - #define KEY_LANGUAGE 0x170 370 - #define KEY_TITLE 0x171 371 - #define KEY_SUBTITLE 0x172 372 - #define KEY_ANGLE 0x173 373 - #define KEY_ZOOM 0x174 374 - #define KEY_MODE 0x175 375 - #define KEY_KEYBOARD 0x176 376 - #define KEY_SCREEN 0x177 377 - #define KEY_PC 0x178 /* Media Select Computer */ 378 - #define KEY_TV 0x179 /* Media Select TV */ 379 - #define KEY_TV2 0x17a /* Media Select Cable */ 380 - #define KEY_VCR 0x17b /* Media Select VCR */ 381 - #define KEY_VCR2 0x17c /* VCR Plus */ 382 - #define KEY_SAT 0x17d /* Media Select Satellite */ 383 - #define KEY_SAT2 0x17e 384 - #define KEY_CD 0x17f /* Media Select CD */ 385 - #define KEY_TAPE 0x180 /* Media Select Tape */ 386 - #define KEY_RADIO 0x181 387 - #define KEY_TUNER 0x182 /* Media Select Tuner */ 388 - #define KEY_PLAYER 0x183 389 - #define KEY_TEXT 0x184 390 - #define KEY_DVD 0x185 /* Media Select DVD */ 391 - #define KEY_AUX 0x186 392 - #define KEY_MP3 0x187 393 - #define KEY_AUDIO 0x188 /* AL Audio Browser */ 394 - #define KEY_VIDEO 0x189 /* AL Movie Browser */ 395 - #define KEY_DIRECTORY 0x18a 396 - #define KEY_LIST 0x18b 397 - #define KEY_MEMO 0x18c /* Media Select Messages */ 398 - #define KEY_CALENDAR 0x18d 399 - #define KEY_RED 0x18e 400 - #define KEY_GREEN 0x18f 401 - #define KEY_YELLOW 0x190 402 - #define KEY_BLUE 0x191 403 - #define KEY_CHANNELUP 0x192 /* Channel Increment */ 404 - #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ 405 - #define KEY_FIRST 0x194 406 - #define KEY_LAST 0x195 /* Recall Last */ 407 - #define KEY_AB 0x196 408 - #define KEY_NEXT 0x197 409 - #define KEY_RESTART 0x198 410 - #define KEY_SLOW 0x199 411 - #define KEY_SHUFFLE 0x19a 412 - #define KEY_BREAK 0x19b 413 - #define KEY_PREVIOUS 0x19c 414 - #define KEY_DIGITS 0x19d 415 - #define KEY_TEEN 0x19e 416 - #define KEY_TWEN 0x19f 417 - #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ 418 - #define KEY_GAMES 0x1a1 /* Media Select Games */ 419 - #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ 420 - #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ 421 - #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ 422 - #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ 423 - #define KEY_EDITOR 0x1a6 /* AL Text Editor */ 424 - #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ 425 - #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ 426 - #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ 427 - #define KEY_DATABASE 0x1aa /* AL Database App */ 428 - #define KEY_NEWS 0x1ab /* AL Newsreader */ 429 - #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ 430 - #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ 431 - #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ 432 - #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ 433 - #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ 434 - #define KEY_LOGOFF 0x1b1 /* AL Logoff */ 435 - 436 - #define KEY_DOLLAR 0x1b2 437 - #define KEY_EURO 0x1b3 438 - 439 - #define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ 440 - #define KEY_FRAMEFORWARD 0x1b5 441 - #define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ 442 - #define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ 443 - #define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */ 444 - #define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */ 445 - #define KEY_IMAGES 0x1ba /* AL Image Browser */ 446 - 447 - #define KEY_DEL_EOL 0x1c0 448 - #define KEY_DEL_EOS 0x1c1 449 - #define KEY_INS_LINE 0x1c2 450 - #define KEY_DEL_LINE 0x1c3 451 - 452 - #define KEY_FN 0x1d0 453 - #define KEY_FN_ESC 0x1d1 454 - #define KEY_FN_F1 0x1d2 455 - #define KEY_FN_F2 0x1d3 456 - #define KEY_FN_F3 0x1d4 457 - #define KEY_FN_F4 0x1d5 458 - #define KEY_FN_F5 0x1d6 459 - #define KEY_FN_F6 0x1d7 460 - #define KEY_FN_F7 0x1d8 461 - #define KEY_FN_F8 0x1d9 462 - #define KEY_FN_F9 0x1da 463 - #define KEY_FN_F10 0x1db 464 - #define KEY_FN_F11 0x1dc 465 - #define KEY_FN_F12 0x1dd 466 - #define KEY_FN_1 0x1de 467 - #define KEY_FN_2 0x1df 468 - #define KEY_FN_D 0x1e0 469 - #define KEY_FN_E 0x1e1 470 - #define KEY_FN_F 0x1e2 471 - #define KEY_FN_S 0x1e3 472 - #define KEY_FN_B 0x1e4 473 - 474 - #define KEY_BRL_DOT1 0x1f1 475 - #define KEY_BRL_DOT2 0x1f2 476 - #define KEY_BRL_DOT3 0x1f3 477 - #define KEY_BRL_DOT4 0x1f4 478 - #define KEY_BRL_DOT5 0x1f5 479 - #define KEY_BRL_DOT6 0x1f6 480 - #define KEY_BRL_DOT7 0x1f7 481 - #define KEY_BRL_DOT8 0x1f8 482 - #define KEY_BRL_DOT9 0x1f9 483 - #define KEY_BRL_DOT10 0x1fa 484 - 485 - #define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ 486 - #define KEY_NUMERIC_1 0x201 /* and other keypads */ 487 - #define KEY_NUMERIC_2 0x202 488 - #define KEY_NUMERIC_3 0x203 489 - #define KEY_NUMERIC_4 0x204 490 - #define KEY_NUMERIC_5 0x205 491 - #define KEY_NUMERIC_6 0x206 492 - #define KEY_NUMERIC_7 0x207 493 - #define KEY_NUMERIC_8 0x208 494 - #define KEY_NUMERIC_9 0x209 495 - #define KEY_NUMERIC_STAR 0x20a 496 - #define KEY_NUMERIC_POUND 0x20b 497 - 498 - #define KEY_CAMERA_FOCUS 0x210 499 - #define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 500 - 501 - #define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */ 502 - #define KEY_TOUCHPAD_ON 0x213 503 - #define KEY_TOUCHPAD_OFF 0x214 504 - 505 - #define KEY_CAMERA_ZOOMIN 0x215 506 - #define KEY_CAMERA_ZOOMOUT 0x216 507 - #define KEY_CAMERA_UP 0x217 508 - #define KEY_CAMERA_DOWN 0x218 509 - #define KEY_CAMERA_LEFT 0x219 510 - #define KEY_CAMERA_RIGHT 0x21a 511 - 512 - #define KEY_ATTENDANT_ON 0x21b 513 - #define KEY_ATTENDANT_OFF 0x21c 514 - #define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ 515 - #define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ 516 - 517 - #define BTN_DPAD_UP 0x220 518 - #define BTN_DPAD_DOWN 0x221 519 - #define BTN_DPAD_LEFT 0x222 520 - #define BTN_DPAD_RIGHT 0x223 12 + #include "linux-event-codes.h" 521 13 522 14 #define MATRIX_KEY(row, col, code) \ 523 15 ((((row) & 0xFF) << 24) | (((col) & 0xFF) << 16) | ((code) & 0xFFFF))
+2 -2
include/linux/hid.h
··· 698 698 int (*input_mapped)(struct hid_device *hdev, 699 699 struct hid_input *hidinput, struct hid_field *field, 700 700 struct hid_usage *usage, unsigned long **bit, int *max); 701 - void (*input_configured)(struct hid_device *hdev, 702 - struct hid_input *hidinput); 701 + int (*input_configured)(struct hid_device *hdev, 702 + struct hid_input *hidinput); 703 703 void (*feature_mapping)(struct hid_device *hdev, 704 704 struct hid_field *field, 705 705 struct hid_usage *usage);
+2
include/linux/input.h
··· 469 469 int input_set_keycode(struct input_dev *dev, 470 470 const struct input_keymap_entry *ke); 471 471 472 + void input_enable_softrepeat(struct input_dev *dev, int delay, int period); 473 + 472 474 extern struct class input_class; 473 475 474 476 /**
-24
include/linux/input/edt-ft5x06.h
··· 1 - #ifndef _EDT_FT5X06_H 2 - #define _EDT_FT5X06_H 3 - 4 - /* 5 - * Copyright (c) 2012 Simon Budig, <simon.budig@kernelconcepts.de> 6 - * 7 - * This program is free software; you can redistribute it and/or modify it 8 - * under the terms of the GNU General Public License version 2 as published by 9 - * the Free Software Foundation. 10 - */ 11 - 12 - struct edt_ft5x06_platform_data { 13 - int irq_pin; 14 - int reset_pin; 15 - 16 - /* startup defaults for operational parameters */ 17 - bool use_parameters; 18 - u8 gain; 19 - u8 threshold; 20 - u8 offset; 21 - u8 report_rate; 22 - }; 23 - 24 - #endif /* _EDT_FT5X06_H */
+1
include/linux/miscdevice.h
··· 49 49 #define LOOP_CTRL_MINOR 237 50 50 #define VHOST_NET_MINOR 238 51 51 #define UHID_MINOR 239 52 + #define USERIO_MINOR 240 52 53 #define MISC_DYNAMIC_MINOR 255 53 54 54 55 struct device;
+2 -1
include/linux/rotary_encoder.h
··· 8 8 unsigned int gpio_b; 9 9 unsigned int inverted_a; 10 10 unsigned int inverted_b; 11 + unsigned int steps_per_period; 11 12 bool relative_axis; 12 13 bool rollover; 13 - bool half_period; 14 + bool wakeup_source; 14 15 }; 15 16 16 17 #endif /* __ROTARY_ENCODER_H__ */
+1
include/uapi/linux/Kbuild
··· 191 191 header-y += in.h 192 192 header-y += inotify.h 193 193 header-y += input.h 194 + header-y += input-event-codes.h 194 195 header-y += in_route.h 195 196 header-y += ioctl.h 196 197 header-y += ip6_tunnel.h
+805
include/uapi/linux/input-event-codes.h
··· 1 + /* 2 + * Input event codes 3 + * 4 + * *** IMPORTANT *** 5 + * This file is not only included from C-code but also from devicetree source 6 + * files. As such this file MUST only contain comments and defines. 7 + * 8 + * Copyright (c) 1999-2002 Vojtech Pavlik 9 + * Copyright (c) 2015 Hans de Goede <hdegoede@redhat.com> 10 + * 11 + * This program is free software; you can redistribute it and/or modify it 12 + * under the terms of the GNU General Public License version 2 as published by 13 + * the Free Software Foundation. 14 + */ 15 + #ifndef _UAPI_INPUT_EVENT_CODES_H 16 + #define _UAPI_INPUT_EVENT_CODES_H 17 + 18 + /* 19 + * Device properties and quirks 20 + */ 21 + 22 + #define INPUT_PROP_POINTER 0x00 /* needs a pointer */ 23 + #define INPUT_PROP_DIRECT 0x01 /* direct input devices */ 24 + #define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ 25 + #define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ 26 + #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ 27 + #define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ 28 + #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ 29 + 30 + #define INPUT_PROP_MAX 0x1f 31 + #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) 32 + 33 + /* 34 + * Event types 35 + */ 36 + 37 + #define EV_SYN 0x00 38 + #define EV_KEY 0x01 39 + #define EV_REL 0x02 40 + #define EV_ABS 0x03 41 + #define EV_MSC 0x04 42 + #define EV_SW 0x05 43 + #define EV_LED 0x11 44 + #define EV_SND 0x12 45 + #define EV_REP 0x14 46 + #define EV_FF 0x15 47 + #define EV_PWR 0x16 48 + #define EV_FF_STATUS 0x17 49 + #define EV_MAX 0x1f 50 + #define EV_CNT (EV_MAX+1) 51 + 52 + /* 53 + * Synchronization events. 54 + */ 55 + 56 + #define SYN_REPORT 0 57 + #define SYN_CONFIG 1 58 + #define SYN_MT_REPORT 2 59 + #define SYN_DROPPED 3 60 + #define SYN_MAX 0xf 61 + #define SYN_CNT (SYN_MAX+1) 62 + 63 + /* 64 + * Keys and buttons 65 + * 66 + * Most of the keys/buttons are modeled after USB HUT 1.12 67 + * (see http://www.usb.org/developers/hidpage). 68 + * Abbreviations in the comments: 69 + * AC - Application Control 70 + * AL - Application Launch Button 71 + * SC - System Control 72 + */ 73 + 74 + #define KEY_RESERVED 0 75 + #define KEY_ESC 1 76 + #define KEY_1 2 77 + #define KEY_2 3 78 + #define KEY_3 4 79 + #define KEY_4 5 80 + #define KEY_5 6 81 + #define KEY_6 7 82 + #define KEY_7 8 83 + #define KEY_8 9 84 + #define KEY_9 10 85 + #define KEY_0 11 86 + #define KEY_MINUS 12 87 + #define KEY_EQUAL 13 88 + #define KEY_BACKSPACE 14 89 + #define KEY_TAB 15 90 + #define KEY_Q 16 91 + #define KEY_W 17 92 + #define KEY_E 18 93 + #define KEY_R 19 94 + #define KEY_T 20 95 + #define KEY_Y 21 96 + #define KEY_U 22 97 + #define KEY_I 23 98 + #define KEY_O 24 99 + #define KEY_P 25 100 + #define KEY_LEFTBRACE 26 101 + #define KEY_RIGHTBRACE 27 102 + #define KEY_ENTER 28 103 + #define KEY_LEFTCTRL 29 104 + #define KEY_A 30 105 + #define KEY_S 31 106 + #define KEY_D 32 107 + #define KEY_F 33 108 + #define KEY_G 34 109 + #define KEY_H 35 110 + #define KEY_J 36 111 + #define KEY_K 37 112 + #define KEY_L 38 113 + #define KEY_SEMICOLON 39 114 + #define KEY_APOSTROPHE 40 115 + #define KEY_GRAVE 41 116 + #define KEY_LEFTSHIFT 42 117 + #define KEY_BACKSLASH 43 118 + #define KEY_Z 44 119 + #define KEY_X 45 120 + #define KEY_C 46 121 + #define KEY_V 47 122 + #define KEY_B 48 123 + #define KEY_N 49 124 + #define KEY_M 50 125 + #define KEY_COMMA 51 126 + #define KEY_DOT 52 127 + #define KEY_SLASH 53 128 + #define KEY_RIGHTSHIFT 54 129 + #define KEY_KPASTERISK 55 130 + #define KEY_LEFTALT 56 131 + #define KEY_SPACE 57 132 + #define KEY_CAPSLOCK 58 133 + #define KEY_F1 59 134 + #define KEY_F2 60 135 + #define KEY_F3 61 136 + #define KEY_F4 62 137 + #define KEY_F5 63 138 + #define KEY_F6 64 139 + #define KEY_F7 65 140 + #define KEY_F8 66 141 + #define KEY_F9 67 142 + #define KEY_F10 68 143 + #define KEY_NUMLOCK 69 144 + #define KEY_SCROLLLOCK 70 145 + #define KEY_KP7 71 146 + #define KEY_KP8 72 147 + #define KEY_KP9 73 148 + #define KEY_KPMINUS 74 149 + #define KEY_KP4 75 150 + #define KEY_KP5 76 151 + #define KEY_KP6 77 152 + #define KEY_KPPLUS 78 153 + #define KEY_KP1 79 154 + #define KEY_KP2 80 155 + #define KEY_KP3 81 156 + #define KEY_KP0 82 157 + #define KEY_KPDOT 83 158 + 159 + #define KEY_ZENKAKUHANKAKU 85 160 + #define KEY_102ND 86 161 + #define KEY_F11 87 162 + #define KEY_F12 88 163 + #define KEY_RO 89 164 + #define KEY_KATAKANA 90 165 + #define KEY_HIRAGANA 91 166 + #define KEY_HENKAN 92 167 + #define KEY_KATAKANAHIRAGANA 93 168 + #define KEY_MUHENKAN 94 169 + #define KEY_KPJPCOMMA 95 170 + #define KEY_KPENTER 96 171 + #define KEY_RIGHTCTRL 97 172 + #define KEY_KPSLASH 98 173 + #define KEY_SYSRQ 99 174 + #define KEY_RIGHTALT 100 175 + #define KEY_LINEFEED 101 176 + #define KEY_HOME 102 177 + #define KEY_UP 103 178 + #define KEY_PAGEUP 104 179 + #define KEY_LEFT 105 180 + #define KEY_RIGHT 106 181 + #define KEY_END 107 182 + #define KEY_DOWN 108 183 + #define KEY_PAGEDOWN 109 184 + #define KEY_INSERT 110 185 + #define KEY_DELETE 111 186 + #define KEY_MACRO 112 187 + #define KEY_MUTE 113 188 + #define KEY_VOLUMEDOWN 114 189 + #define KEY_VOLUMEUP 115 190 + #define KEY_POWER 116 /* SC System Power Down */ 191 + #define KEY_KPEQUAL 117 192 + #define KEY_KPPLUSMINUS 118 193 + #define KEY_PAUSE 119 194 + #define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ 195 + 196 + #define KEY_KPCOMMA 121 197 + #define KEY_HANGEUL 122 198 + #define KEY_HANGUEL KEY_HANGEUL 199 + #define KEY_HANJA 123 200 + #define KEY_YEN 124 201 + #define KEY_LEFTMETA 125 202 + #define KEY_RIGHTMETA 126 203 + #define KEY_COMPOSE 127 204 + 205 + #define KEY_STOP 128 /* AC Stop */ 206 + #define KEY_AGAIN 129 207 + #define KEY_PROPS 130 /* AC Properties */ 208 + #define KEY_UNDO 131 /* AC Undo */ 209 + #define KEY_FRONT 132 210 + #define KEY_COPY 133 /* AC Copy */ 211 + #define KEY_OPEN 134 /* AC Open */ 212 + #define KEY_PASTE 135 /* AC Paste */ 213 + #define KEY_FIND 136 /* AC Search */ 214 + #define KEY_CUT 137 /* AC Cut */ 215 + #define KEY_HELP 138 /* AL Integrated Help Center */ 216 + #define KEY_MENU 139 /* Menu (show menu) */ 217 + #define KEY_CALC 140 /* AL Calculator */ 218 + #define KEY_SETUP 141 219 + #define KEY_SLEEP 142 /* SC System Sleep */ 220 + #define KEY_WAKEUP 143 /* System Wake Up */ 221 + #define KEY_FILE 144 /* AL Local Machine Browser */ 222 + #define KEY_SENDFILE 145 223 + #define KEY_DELETEFILE 146 224 + #define KEY_XFER 147 225 + #define KEY_PROG1 148 226 + #define KEY_PROG2 149 227 + #define KEY_WWW 150 /* AL Internet Browser */ 228 + #define KEY_MSDOS 151 229 + #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ 230 + #define KEY_SCREENLOCK KEY_COFFEE 231 + #define KEY_ROTATE_DISPLAY 153 /* Display orientation for e.g. tablets */ 232 + #define KEY_DIRECTION KEY_ROTATE_DISPLAY 233 + #define KEY_CYCLEWINDOWS 154 234 + #define KEY_MAIL 155 235 + #define KEY_BOOKMARKS 156 /* AC Bookmarks */ 236 + #define KEY_COMPUTER 157 237 + #define KEY_BACK 158 /* AC Back */ 238 + #define KEY_FORWARD 159 /* AC Forward */ 239 + #define KEY_CLOSECD 160 240 + #define KEY_EJECTCD 161 241 + #define KEY_EJECTCLOSECD 162 242 + #define KEY_NEXTSONG 163 243 + #define KEY_PLAYPAUSE 164 244 + #define KEY_PREVIOUSSONG 165 245 + #define KEY_STOPCD 166 246 + #define KEY_RECORD 167 247 + #define KEY_REWIND 168 248 + #define KEY_PHONE 169 /* Media Select Telephone */ 249 + #define KEY_ISO 170 250 + #define KEY_CONFIG 171 /* AL Consumer Control Configuration */ 251 + #define KEY_HOMEPAGE 172 /* AC Home */ 252 + #define KEY_REFRESH 173 /* AC Refresh */ 253 + #define KEY_EXIT 174 /* AC Exit */ 254 + #define KEY_MOVE 175 255 + #define KEY_EDIT 176 256 + #define KEY_SCROLLUP 177 257 + #define KEY_SCROLLDOWN 178 258 + #define KEY_KPLEFTPAREN 179 259 + #define KEY_KPRIGHTPAREN 180 260 + #define KEY_NEW 181 /* AC New */ 261 + #define KEY_REDO 182 /* AC Redo/Repeat */ 262 + 263 + #define KEY_F13 183 264 + #define KEY_F14 184 265 + #define KEY_F15 185 266 + #define KEY_F16 186 267 + #define KEY_F17 187 268 + #define KEY_F18 188 269 + #define KEY_F19 189 270 + #define KEY_F20 190 271 + #define KEY_F21 191 272 + #define KEY_F22 192 273 + #define KEY_F23 193 274 + #define KEY_F24 194 275 + 276 + #define KEY_PLAYCD 200 277 + #define KEY_PAUSECD 201 278 + #define KEY_PROG3 202 279 + #define KEY_PROG4 203 280 + #define KEY_DASHBOARD 204 /* AL Dashboard */ 281 + #define KEY_SUSPEND 205 282 + #define KEY_CLOSE 206 /* AC Close */ 283 + #define KEY_PLAY 207 284 + #define KEY_FASTFORWARD 208 285 + #define KEY_BASSBOOST 209 286 + #define KEY_PRINT 210 /* AC Print */ 287 + #define KEY_HP 211 288 + #define KEY_CAMERA 212 289 + #define KEY_SOUND 213 290 + #define KEY_QUESTION 214 291 + #define KEY_EMAIL 215 292 + #define KEY_CHAT 216 293 + #define KEY_SEARCH 217 294 + #define KEY_CONNECT 218 295 + #define KEY_FINANCE 219 /* AL Checkbook/Finance */ 296 + #define KEY_SPORT 220 297 + #define KEY_SHOP 221 298 + #define KEY_ALTERASE 222 299 + #define KEY_CANCEL 223 /* AC Cancel */ 300 + #define KEY_BRIGHTNESSDOWN 224 301 + #define KEY_BRIGHTNESSUP 225 302 + #define KEY_MEDIA 226 303 + 304 + #define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video 305 + outputs (Monitor/LCD/TV-out/etc) */ 306 + #define KEY_KBDILLUMTOGGLE 228 307 + #define KEY_KBDILLUMDOWN 229 308 + #define KEY_KBDILLUMUP 230 309 + 310 + #define KEY_SEND 231 /* AC Send */ 311 + #define KEY_REPLY 232 /* AC Reply */ 312 + #define KEY_FORWARDMAIL 233 /* AC Forward Msg */ 313 + #define KEY_SAVE 234 /* AC Save */ 314 + #define KEY_DOCUMENTS 235 315 + 316 + #define KEY_BATTERY 236 317 + 318 + #define KEY_BLUETOOTH 237 319 + #define KEY_WLAN 238 320 + #define KEY_UWB 239 321 + 322 + #define KEY_UNKNOWN 240 323 + 324 + #define KEY_VIDEO_NEXT 241 /* drive next video source */ 325 + #define KEY_VIDEO_PREV 242 /* drive previous video source */ 326 + #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ 327 + #define KEY_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual 328 + brightness control is off, 329 + rely on ambient */ 330 + #define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO 331 + #define KEY_DISPLAY_OFF 245 /* display device to off state */ 332 + 333 + #define KEY_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */ 334 + #define KEY_WIMAX KEY_WWAN 335 + #define KEY_RFKILL 247 /* Key that controls all radios */ 336 + 337 + #define KEY_MICMUTE 248 /* Mute / unmute the microphone */ 338 + 339 + /* Code 255 is reserved for special needs of AT keyboard driver */ 340 + 341 + #define BTN_MISC 0x100 342 + #define BTN_0 0x100 343 + #define BTN_1 0x101 344 + #define BTN_2 0x102 345 + #define BTN_3 0x103 346 + #define BTN_4 0x104 347 + #define BTN_5 0x105 348 + #define BTN_6 0x106 349 + #define BTN_7 0x107 350 + #define BTN_8 0x108 351 + #define BTN_9 0x109 352 + 353 + #define BTN_MOUSE 0x110 354 + #define BTN_LEFT 0x110 355 + #define BTN_RIGHT 0x111 356 + #define BTN_MIDDLE 0x112 357 + #define BTN_SIDE 0x113 358 + #define BTN_EXTRA 0x114 359 + #define BTN_FORWARD 0x115 360 + #define BTN_BACK 0x116 361 + #define BTN_TASK 0x117 362 + 363 + #define BTN_JOYSTICK 0x120 364 + #define BTN_TRIGGER 0x120 365 + #define BTN_THUMB 0x121 366 + #define BTN_THUMB2 0x122 367 + #define BTN_TOP 0x123 368 + #define BTN_TOP2 0x124 369 + #define BTN_PINKIE 0x125 370 + #define BTN_BASE 0x126 371 + #define BTN_BASE2 0x127 372 + #define BTN_BASE3 0x128 373 + #define BTN_BASE4 0x129 374 + #define BTN_BASE5 0x12a 375 + #define BTN_BASE6 0x12b 376 + #define BTN_DEAD 0x12f 377 + 378 + #define BTN_GAMEPAD 0x130 379 + #define BTN_SOUTH 0x130 380 + #define BTN_A BTN_SOUTH 381 + #define BTN_EAST 0x131 382 + #define BTN_B BTN_EAST 383 + #define BTN_C 0x132 384 + #define BTN_NORTH 0x133 385 + #define BTN_X BTN_NORTH 386 + #define BTN_WEST 0x134 387 + #define BTN_Y BTN_WEST 388 + #define BTN_Z 0x135 389 + #define BTN_TL 0x136 390 + #define BTN_TR 0x137 391 + #define BTN_TL2 0x138 392 + #define BTN_TR2 0x139 393 + #define BTN_SELECT 0x13a 394 + #define BTN_START 0x13b 395 + #define BTN_MODE 0x13c 396 + #define BTN_THUMBL 0x13d 397 + #define BTN_THUMBR 0x13e 398 + 399 + #define BTN_DIGI 0x140 400 + #define BTN_TOOL_PEN 0x140 401 + #define BTN_TOOL_RUBBER 0x141 402 + #define BTN_TOOL_BRUSH 0x142 403 + #define BTN_TOOL_PENCIL 0x143 404 + #define BTN_TOOL_AIRBRUSH 0x144 405 + #define BTN_TOOL_FINGER 0x145 406 + #define BTN_TOOL_MOUSE 0x146 407 + #define BTN_TOOL_LENS 0x147 408 + #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ 409 + #define BTN_TOUCH 0x14a 410 + #define BTN_STYLUS 0x14b 411 + #define BTN_STYLUS2 0x14c 412 + #define BTN_TOOL_DOUBLETAP 0x14d 413 + #define BTN_TOOL_TRIPLETAP 0x14e 414 + #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ 415 + 416 + #define BTN_WHEEL 0x150 417 + #define BTN_GEAR_DOWN 0x150 418 + #define BTN_GEAR_UP 0x151 419 + 420 + #define KEY_OK 0x160 421 + #define KEY_SELECT 0x161 422 + #define KEY_GOTO 0x162 423 + #define KEY_CLEAR 0x163 424 + #define KEY_POWER2 0x164 425 + #define KEY_OPTION 0x165 426 + #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ 427 + #define KEY_TIME 0x167 428 + #define KEY_VENDOR 0x168 429 + #define KEY_ARCHIVE 0x169 430 + #define KEY_PROGRAM 0x16a /* Media Select Program Guide */ 431 + #define KEY_CHANNEL 0x16b 432 + #define KEY_FAVORITES 0x16c 433 + #define KEY_EPG 0x16d 434 + #define KEY_PVR 0x16e /* Media Select Home */ 435 + #define KEY_MHP 0x16f 436 + #define KEY_LANGUAGE 0x170 437 + #define KEY_TITLE 0x171 438 + #define KEY_SUBTITLE 0x172 439 + #define KEY_ANGLE 0x173 440 + #define KEY_ZOOM 0x174 441 + #define KEY_MODE 0x175 442 + #define KEY_KEYBOARD 0x176 443 + #define KEY_SCREEN 0x177 444 + #define KEY_PC 0x178 /* Media Select Computer */ 445 + #define KEY_TV 0x179 /* Media Select TV */ 446 + #define KEY_TV2 0x17a /* Media Select Cable */ 447 + #define KEY_VCR 0x17b /* Media Select VCR */ 448 + #define KEY_VCR2 0x17c /* VCR Plus */ 449 + #define KEY_SAT 0x17d /* Media Select Satellite */ 450 + #define KEY_SAT2 0x17e 451 + #define KEY_CD 0x17f /* Media Select CD */ 452 + #define KEY_TAPE 0x180 /* Media Select Tape */ 453 + #define KEY_RADIO 0x181 454 + #define KEY_TUNER 0x182 /* Media Select Tuner */ 455 + #define KEY_PLAYER 0x183 456 + #define KEY_TEXT 0x184 457 + #define KEY_DVD 0x185 /* Media Select DVD */ 458 + #define KEY_AUX 0x186 459 + #define KEY_MP3 0x187 460 + #define KEY_AUDIO 0x188 /* AL Audio Browser */ 461 + #define KEY_VIDEO 0x189 /* AL Movie Browser */ 462 + #define KEY_DIRECTORY 0x18a 463 + #define KEY_LIST 0x18b 464 + #define KEY_MEMO 0x18c /* Media Select Messages */ 465 + #define KEY_CALENDAR 0x18d 466 + #define KEY_RED 0x18e 467 + #define KEY_GREEN 0x18f 468 + #define KEY_YELLOW 0x190 469 + #define KEY_BLUE 0x191 470 + #define KEY_CHANNELUP 0x192 /* Channel Increment */ 471 + #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ 472 + #define KEY_FIRST 0x194 473 + #define KEY_LAST 0x195 /* Recall Last */ 474 + #define KEY_AB 0x196 475 + #define KEY_NEXT 0x197 476 + #define KEY_RESTART 0x198 477 + #define KEY_SLOW 0x199 478 + #define KEY_SHUFFLE 0x19a 479 + #define KEY_BREAK 0x19b 480 + #define KEY_PREVIOUS 0x19c 481 + #define KEY_DIGITS 0x19d 482 + #define KEY_TEEN 0x19e 483 + #define KEY_TWEN 0x19f 484 + #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ 485 + #define KEY_GAMES 0x1a1 /* Media Select Games */ 486 + #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ 487 + #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ 488 + #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ 489 + #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ 490 + #define KEY_EDITOR 0x1a6 /* AL Text Editor */ 491 + #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ 492 + #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ 493 + #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ 494 + #define KEY_DATABASE 0x1aa /* AL Database App */ 495 + #define KEY_NEWS 0x1ab /* AL Newsreader */ 496 + #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ 497 + #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ 498 + #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ 499 + #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ 500 + #define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE 501 + #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ 502 + #define KEY_LOGOFF 0x1b1 /* AL Logoff */ 503 + 504 + #define KEY_DOLLAR 0x1b2 505 + #define KEY_EURO 0x1b3 506 + 507 + #define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ 508 + #define KEY_FRAMEFORWARD 0x1b5 509 + #define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ 510 + #define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ 511 + #define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */ 512 + #define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */ 513 + #define KEY_IMAGES 0x1ba /* AL Image Browser */ 514 + 515 + #define KEY_DEL_EOL 0x1c0 516 + #define KEY_DEL_EOS 0x1c1 517 + #define KEY_INS_LINE 0x1c2 518 + #define KEY_DEL_LINE 0x1c3 519 + 520 + #define KEY_FN 0x1d0 521 + #define KEY_FN_ESC 0x1d1 522 + #define KEY_FN_F1 0x1d2 523 + #define KEY_FN_F2 0x1d3 524 + #define KEY_FN_F3 0x1d4 525 + #define KEY_FN_F4 0x1d5 526 + #define KEY_FN_F5 0x1d6 527 + #define KEY_FN_F6 0x1d7 528 + #define KEY_FN_F7 0x1d8 529 + #define KEY_FN_F8 0x1d9 530 + #define KEY_FN_F9 0x1da 531 + #define KEY_FN_F10 0x1db 532 + #define KEY_FN_F11 0x1dc 533 + #define KEY_FN_F12 0x1dd 534 + #define KEY_FN_1 0x1de 535 + #define KEY_FN_2 0x1df 536 + #define KEY_FN_D 0x1e0 537 + #define KEY_FN_E 0x1e1 538 + #define KEY_FN_F 0x1e2 539 + #define KEY_FN_S 0x1e3 540 + #define KEY_FN_B 0x1e4 541 + 542 + #define KEY_BRL_DOT1 0x1f1 543 + #define KEY_BRL_DOT2 0x1f2 544 + #define KEY_BRL_DOT3 0x1f3 545 + #define KEY_BRL_DOT4 0x1f4 546 + #define KEY_BRL_DOT5 0x1f5 547 + #define KEY_BRL_DOT6 0x1f6 548 + #define KEY_BRL_DOT7 0x1f7 549 + #define KEY_BRL_DOT8 0x1f8 550 + #define KEY_BRL_DOT9 0x1f9 551 + #define KEY_BRL_DOT10 0x1fa 552 + 553 + #define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ 554 + #define KEY_NUMERIC_1 0x201 /* and other keypads */ 555 + #define KEY_NUMERIC_2 0x202 556 + #define KEY_NUMERIC_3 0x203 557 + #define KEY_NUMERIC_4 0x204 558 + #define KEY_NUMERIC_5 0x205 559 + #define KEY_NUMERIC_6 0x206 560 + #define KEY_NUMERIC_7 0x207 561 + #define KEY_NUMERIC_8 0x208 562 + #define KEY_NUMERIC_9 0x209 563 + #define KEY_NUMERIC_STAR 0x20a 564 + #define KEY_NUMERIC_POUND 0x20b 565 + #define KEY_NUMERIC_A 0x20c /* Phone key A - HUT Telephony 0xb9 */ 566 + #define KEY_NUMERIC_B 0x20d 567 + #define KEY_NUMERIC_C 0x20e 568 + #define KEY_NUMERIC_D 0x20f 569 + 570 + #define KEY_CAMERA_FOCUS 0x210 571 + #define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 572 + 573 + #define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */ 574 + #define KEY_TOUCHPAD_ON 0x213 575 + #define KEY_TOUCHPAD_OFF 0x214 576 + 577 + #define KEY_CAMERA_ZOOMIN 0x215 578 + #define KEY_CAMERA_ZOOMOUT 0x216 579 + #define KEY_CAMERA_UP 0x217 580 + #define KEY_CAMERA_DOWN 0x218 581 + #define KEY_CAMERA_LEFT 0x219 582 + #define KEY_CAMERA_RIGHT 0x21a 583 + 584 + #define KEY_ATTENDANT_ON 0x21b 585 + #define KEY_ATTENDANT_OFF 0x21c 586 + #define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ 587 + #define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ 588 + 589 + #define BTN_DPAD_UP 0x220 590 + #define BTN_DPAD_DOWN 0x221 591 + #define BTN_DPAD_LEFT 0x222 592 + #define BTN_DPAD_RIGHT 0x223 593 + 594 + #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ 595 + 596 + #define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ 597 + #define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ 598 + #define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */ 599 + #define KEY_CONTROLPANEL 0x243 /* AL Control Panel */ 600 + #define KEY_APPSELECT 0x244 /* AL Select Task/Application */ 601 + #define KEY_SCREENSAVER 0x245 /* AL Screen Saver */ 602 + #define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ 603 + 604 + #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ 605 + #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ 606 + 607 + #define KEY_KBDINPUTASSIST_PREV 0x260 608 + #define KEY_KBDINPUTASSIST_NEXT 0x261 609 + #define KEY_KBDINPUTASSIST_PREVGROUP 0x262 610 + #define KEY_KBDINPUTASSIST_NEXTGROUP 0x263 611 + #define KEY_KBDINPUTASSIST_ACCEPT 0x264 612 + #define KEY_KBDINPUTASSIST_CANCEL 0x265 613 + 614 + #define BTN_TRIGGER_HAPPY 0x2c0 615 + #define BTN_TRIGGER_HAPPY1 0x2c0 616 + #define BTN_TRIGGER_HAPPY2 0x2c1 617 + #define BTN_TRIGGER_HAPPY3 0x2c2 618 + #define BTN_TRIGGER_HAPPY4 0x2c3 619 + #define BTN_TRIGGER_HAPPY5 0x2c4 620 + #define BTN_TRIGGER_HAPPY6 0x2c5 621 + #define BTN_TRIGGER_HAPPY7 0x2c6 622 + #define BTN_TRIGGER_HAPPY8 0x2c7 623 + #define BTN_TRIGGER_HAPPY9 0x2c8 624 + #define BTN_TRIGGER_HAPPY10 0x2c9 625 + #define BTN_TRIGGER_HAPPY11 0x2ca 626 + #define BTN_TRIGGER_HAPPY12 0x2cb 627 + #define BTN_TRIGGER_HAPPY13 0x2cc 628 + #define BTN_TRIGGER_HAPPY14 0x2cd 629 + #define BTN_TRIGGER_HAPPY15 0x2ce 630 + #define BTN_TRIGGER_HAPPY16 0x2cf 631 + #define BTN_TRIGGER_HAPPY17 0x2d0 632 + #define BTN_TRIGGER_HAPPY18 0x2d1 633 + #define BTN_TRIGGER_HAPPY19 0x2d2 634 + #define BTN_TRIGGER_HAPPY20 0x2d3 635 + #define BTN_TRIGGER_HAPPY21 0x2d4 636 + #define BTN_TRIGGER_HAPPY22 0x2d5 637 + #define BTN_TRIGGER_HAPPY23 0x2d6 638 + #define BTN_TRIGGER_HAPPY24 0x2d7 639 + #define BTN_TRIGGER_HAPPY25 0x2d8 640 + #define BTN_TRIGGER_HAPPY26 0x2d9 641 + #define BTN_TRIGGER_HAPPY27 0x2da 642 + #define BTN_TRIGGER_HAPPY28 0x2db 643 + #define BTN_TRIGGER_HAPPY29 0x2dc 644 + #define BTN_TRIGGER_HAPPY30 0x2dd 645 + #define BTN_TRIGGER_HAPPY31 0x2de 646 + #define BTN_TRIGGER_HAPPY32 0x2df 647 + #define BTN_TRIGGER_HAPPY33 0x2e0 648 + #define BTN_TRIGGER_HAPPY34 0x2e1 649 + #define BTN_TRIGGER_HAPPY35 0x2e2 650 + #define BTN_TRIGGER_HAPPY36 0x2e3 651 + #define BTN_TRIGGER_HAPPY37 0x2e4 652 + #define BTN_TRIGGER_HAPPY38 0x2e5 653 + #define BTN_TRIGGER_HAPPY39 0x2e6 654 + #define BTN_TRIGGER_HAPPY40 0x2e7 655 + 656 + /* We avoid low common keys in module aliases so they don't get huge. */ 657 + #define KEY_MIN_INTERESTING KEY_MUTE 658 + #define KEY_MAX 0x2ff 659 + #define KEY_CNT (KEY_MAX+1) 660 + 661 + /* 662 + * Relative axes 663 + */ 664 + 665 + #define REL_X 0x00 666 + #define REL_Y 0x01 667 + #define REL_Z 0x02 668 + #define REL_RX 0x03 669 + #define REL_RY 0x04 670 + #define REL_RZ 0x05 671 + #define REL_HWHEEL 0x06 672 + #define REL_DIAL 0x07 673 + #define REL_WHEEL 0x08 674 + #define REL_MISC 0x09 675 + #define REL_MAX 0x0f 676 + #define REL_CNT (REL_MAX+1) 677 + 678 + /* 679 + * Absolute axes 680 + */ 681 + 682 + #define ABS_X 0x00 683 + #define ABS_Y 0x01 684 + #define ABS_Z 0x02 685 + #define ABS_RX 0x03 686 + #define ABS_RY 0x04 687 + #define ABS_RZ 0x05 688 + #define ABS_THROTTLE 0x06 689 + #define ABS_RUDDER 0x07 690 + #define ABS_WHEEL 0x08 691 + #define ABS_GAS 0x09 692 + #define ABS_BRAKE 0x0a 693 + #define ABS_HAT0X 0x10 694 + #define ABS_HAT0Y 0x11 695 + #define ABS_HAT1X 0x12 696 + #define ABS_HAT1Y 0x13 697 + #define ABS_HAT2X 0x14 698 + #define ABS_HAT2Y 0x15 699 + #define ABS_HAT3X 0x16 700 + #define ABS_HAT3Y 0x17 701 + #define ABS_PRESSURE 0x18 702 + #define ABS_DISTANCE 0x19 703 + #define ABS_TILT_X 0x1a 704 + #define ABS_TILT_Y 0x1b 705 + #define ABS_TOOL_WIDTH 0x1c 706 + 707 + #define ABS_VOLUME 0x20 708 + 709 + #define ABS_MISC 0x28 710 + 711 + #define ABS_MT_SLOT 0x2f /* MT slot being modified */ 712 + #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ 713 + #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ 714 + #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ 715 + #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ 716 + #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ 717 + #define ABS_MT_POSITION_X 0x35 /* Center X touch position */ 718 + #define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ 719 + #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ 720 + #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 721 + #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 722 + #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 723 + #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ 724 + #define ABS_MT_TOOL_X 0x3c /* Center X tool position */ 725 + #define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ 726 + 727 + 728 + #define ABS_MAX 0x3f 729 + #define ABS_CNT (ABS_MAX+1) 730 + 731 + /* 732 + * Switch events 733 + */ 734 + 735 + #define SW_LID 0x00 /* set = lid shut */ 736 + #define SW_TABLET_MODE 0x01 /* set = tablet mode */ 737 + #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ 738 + #define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" 739 + set = radio enabled */ 740 + #define SW_RADIO SW_RFKILL_ALL /* deprecated */ 741 + #define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ 742 + #define SW_DOCK 0x05 /* set = plugged into dock */ 743 + #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ 744 + #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ 745 + #define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ 746 + #define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */ 747 + #define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */ 748 + #define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ 749 + #define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ 750 + #define SW_LINEIN_INSERT 0x0d /* set = inserted */ 751 + #define SW_MUTE_DEVICE 0x0e /* set = device disabled */ 752 + #define SW_MAX 0x0f 753 + #define SW_CNT (SW_MAX+1) 754 + 755 + /* 756 + * Misc events 757 + */ 758 + 759 + #define MSC_SERIAL 0x00 760 + #define MSC_PULSELED 0x01 761 + #define MSC_GESTURE 0x02 762 + #define MSC_RAW 0x03 763 + #define MSC_SCAN 0x04 764 + #define MSC_TIMESTAMP 0x05 765 + #define MSC_MAX 0x07 766 + #define MSC_CNT (MSC_MAX+1) 767 + 768 + /* 769 + * LEDs 770 + */ 771 + 772 + #define LED_NUML 0x00 773 + #define LED_CAPSL 0x01 774 + #define LED_SCROLLL 0x02 775 + #define LED_COMPOSE 0x03 776 + #define LED_KANA 0x04 777 + #define LED_SLEEP 0x05 778 + #define LED_SUSPEND 0x06 779 + #define LED_MUTE 0x07 780 + #define LED_MISC 0x08 781 + #define LED_MAIL 0x09 782 + #define LED_CHARGING 0x0a 783 + #define LED_MAX 0x0f 784 + #define LED_CNT (LED_MAX+1) 785 + 786 + /* 787 + * Autorepeat values 788 + */ 789 + 790 + #define REP_DELAY 0x00 791 + #define REP_PERIOD 0x01 792 + #define REP_MAX 0x01 793 + #define REP_CNT (REP_MAX+1) 794 + 795 + /* 796 + * Sounds 797 + */ 798 + 799 + #define SND_CLICK 0x00 800 + #define SND_BELL 0x01 801 + #define SND_TONE 0x02 802 + #define SND_MAX 0x07 803 + #define SND_CNT (SND_MAX+1) 804 + 805 + #endif
+66 -784
include/uapi/linux/input.h
··· 16 16 #include <linux/types.h> 17 17 #endif 18 18 19 + #include "input-event-codes.h" 19 20 20 21 /* 21 22 * The event structure itself ··· 98 97 __u8 scancode[32]; 99 98 }; 100 99 100 + struct input_mask { 101 + __u32 type; 102 + __u32 codes_size; 103 + __u64 codes_ptr; 104 + }; 105 + 101 106 #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 102 107 #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 103 108 #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ ··· 154 147 #define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */ 155 148 #define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */ 156 149 157 - #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ 150 + #define EVIOCSFF _IOW('E', 0x80, struct ff_effect) /* send a force effect to a force feedback device */ 158 151 #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 159 152 #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ 160 153 161 154 #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 162 155 #define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */ 163 156 164 - #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 165 - 166 - /* 167 - * Device properties and quirks 168 - */ 169 - 170 - #define INPUT_PROP_POINTER 0x00 /* needs a pointer */ 171 - #define INPUT_PROP_DIRECT 0x01 /* direct input devices */ 172 - #define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ 173 - #define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ 174 - #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ 175 - #define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ 176 - #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ 177 - 178 - #define INPUT_PROP_MAX 0x1f 179 - #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) 180 - 181 - /* 182 - * Event types 183 - */ 184 - 185 - #define EV_SYN 0x00 186 - #define EV_KEY 0x01 187 - #define EV_REL 0x02 188 - #define EV_ABS 0x03 189 - #define EV_MSC 0x04 190 - #define EV_SW 0x05 191 - #define EV_LED 0x11 192 - #define EV_SND 0x12 193 - #define EV_REP 0x14 194 - #define EV_FF 0x15 195 - #define EV_PWR 0x16 196 - #define EV_FF_STATUS 0x17 197 - #define EV_MAX 0x1f 198 - #define EV_CNT (EV_MAX+1) 199 - 200 - /* 201 - * Synchronization events. 202 - */ 203 - 204 - #define SYN_REPORT 0 205 - #define SYN_CONFIG 1 206 - #define SYN_MT_REPORT 2 207 - #define SYN_DROPPED 3 208 - #define SYN_MAX 0xf 209 - #define SYN_CNT (SYN_MAX+1) 210 - 211 - /* 212 - * Keys and buttons 157 + /** 158 + * EVIOCGMASK - Retrieve current event mask 213 159 * 214 - * Most of the keys/buttons are modeled after USB HUT 1.12 215 - * (see http://www.usb.org/developers/hidpage). 216 - * Abbreviations in the comments: 217 - * AC - Application Control 218 - * AL - Application Launch Button 219 - * SC - System Control 160 + * This ioctl allows user to retrieve the current event mask for specific 161 + * event type. The argument must be of type "struct input_mask" and 162 + * specifies the event type to query, the address of the receive buffer and 163 + * the size of the receive buffer. 164 + * 165 + * The event mask is a per-client mask that specifies which events are 166 + * forwarded to the client. Each event code is represented by a single bit 167 + * in the event mask. If the bit is set, the event is passed to the client 168 + * normally. Otherwise, the event is filtered and will never be queued on 169 + * the client's receive buffer. 170 + * 171 + * Event masks do not affect global state of the input device. They only 172 + * affect the file descriptor they are applied to. 173 + * 174 + * The default event mask for a client has all bits set, i.e. all events 175 + * are forwarded to the client. If the kernel is queried for an unknown 176 + * event type or if the receive buffer is larger than the number of 177 + * event codes known to the kernel, the kernel returns all zeroes for those 178 + * codes. 179 + * 180 + * At maximum, codes_size bytes are copied. 181 + * 182 + * This ioctl may fail with ENODEV in case the file is revoked, EFAULT 183 + * if the receive-buffer points to invalid memory, or EINVAL if the kernel 184 + * does not implement the ioctl. 220 185 */ 186 + #define EVIOCGMASK _IOR('E', 0x92, struct input_mask) /* Get event-masks */ 221 187 222 - #define KEY_RESERVED 0 223 - #define KEY_ESC 1 224 - #define KEY_1 2 225 - #define KEY_2 3 226 - #define KEY_3 4 227 - #define KEY_4 5 228 - #define KEY_5 6 229 - #define KEY_6 7 230 - #define KEY_7 8 231 - #define KEY_8 9 232 - #define KEY_9 10 233 - #define KEY_0 11 234 - #define KEY_MINUS 12 235 - #define KEY_EQUAL 13 236 - #define KEY_BACKSPACE 14 237 - #define KEY_TAB 15 238 - #define KEY_Q 16 239 - #define KEY_W 17 240 - #define KEY_E 18 241 - #define KEY_R 19 242 - #define KEY_T 20 243 - #define KEY_Y 21 244 - #define KEY_U 22 245 - #define KEY_I 23 246 - #define KEY_O 24 247 - #define KEY_P 25 248 - #define KEY_LEFTBRACE 26 249 - #define KEY_RIGHTBRACE 27 250 - #define KEY_ENTER 28 251 - #define KEY_LEFTCTRL 29 252 - #define KEY_A 30 253 - #define KEY_S 31 254 - #define KEY_D 32 255 - #define KEY_F 33 256 - #define KEY_G 34 257 - #define KEY_H 35 258 - #define KEY_J 36 259 - #define KEY_K 37 260 - #define KEY_L 38 261 - #define KEY_SEMICOLON 39 262 - #define KEY_APOSTROPHE 40 263 - #define KEY_GRAVE 41 264 - #define KEY_LEFTSHIFT 42 265 - #define KEY_BACKSLASH 43 266 - #define KEY_Z 44 267 - #define KEY_X 45 268 - #define KEY_C 46 269 - #define KEY_V 47 270 - #define KEY_B 48 271 - #define KEY_N 49 272 - #define KEY_M 50 273 - #define KEY_COMMA 51 274 - #define KEY_DOT 52 275 - #define KEY_SLASH 53 276 - #define KEY_RIGHTSHIFT 54 277 - #define KEY_KPASTERISK 55 278 - #define KEY_LEFTALT 56 279 - #define KEY_SPACE 57 280 - #define KEY_CAPSLOCK 58 281 - #define KEY_F1 59 282 - #define KEY_F2 60 283 - #define KEY_F3 61 284 - #define KEY_F4 62 285 - #define KEY_F5 63 286 - #define KEY_F6 64 287 - #define KEY_F7 65 288 - #define KEY_F8 66 289 - #define KEY_F9 67 290 - #define KEY_F10 68 291 - #define KEY_NUMLOCK 69 292 - #define KEY_SCROLLLOCK 70 293 - #define KEY_KP7 71 294 - #define KEY_KP8 72 295 - #define KEY_KP9 73 296 - #define KEY_KPMINUS 74 297 - #define KEY_KP4 75 298 - #define KEY_KP5 76 299 - #define KEY_KP6 77 300 - #define KEY_KPPLUS 78 301 - #define KEY_KP1 79 302 - #define KEY_KP2 80 303 - #define KEY_KP3 81 304 - #define KEY_KP0 82 305 - #define KEY_KPDOT 83 306 - 307 - #define KEY_ZENKAKUHANKAKU 85 308 - #define KEY_102ND 86 309 - #define KEY_F11 87 310 - #define KEY_F12 88 311 - #define KEY_RO 89 312 - #define KEY_KATAKANA 90 313 - #define KEY_HIRAGANA 91 314 - #define KEY_HENKAN 92 315 - #define KEY_KATAKANAHIRAGANA 93 316 - #define KEY_MUHENKAN 94 317 - #define KEY_KPJPCOMMA 95 318 - #define KEY_KPENTER 96 319 - #define KEY_RIGHTCTRL 97 320 - #define KEY_KPSLASH 98 321 - #define KEY_SYSRQ 99 322 - #define KEY_RIGHTALT 100 323 - #define KEY_LINEFEED 101 324 - #define KEY_HOME 102 325 - #define KEY_UP 103 326 - #define KEY_PAGEUP 104 327 - #define KEY_LEFT 105 328 - #define KEY_RIGHT 106 329 - #define KEY_END 107 330 - #define KEY_DOWN 108 331 - #define KEY_PAGEDOWN 109 332 - #define KEY_INSERT 110 333 - #define KEY_DELETE 111 334 - #define KEY_MACRO 112 335 - #define KEY_MUTE 113 336 - #define KEY_VOLUMEDOWN 114 337 - #define KEY_VOLUMEUP 115 338 - #define KEY_POWER 116 /* SC System Power Down */ 339 - #define KEY_KPEQUAL 117 340 - #define KEY_KPPLUSMINUS 118 341 - #define KEY_PAUSE 119 342 - #define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ 343 - 344 - #define KEY_KPCOMMA 121 345 - #define KEY_HANGEUL 122 346 - #define KEY_HANGUEL KEY_HANGEUL 347 - #define KEY_HANJA 123 348 - #define KEY_YEN 124 349 - #define KEY_LEFTMETA 125 350 - #define KEY_RIGHTMETA 126 351 - #define KEY_COMPOSE 127 352 - 353 - #define KEY_STOP 128 /* AC Stop */ 354 - #define KEY_AGAIN 129 355 - #define KEY_PROPS 130 /* AC Properties */ 356 - #define KEY_UNDO 131 /* AC Undo */ 357 - #define KEY_FRONT 132 358 - #define KEY_COPY 133 /* AC Copy */ 359 - #define KEY_OPEN 134 /* AC Open */ 360 - #define KEY_PASTE 135 /* AC Paste */ 361 - #define KEY_FIND 136 /* AC Search */ 362 - #define KEY_CUT 137 /* AC Cut */ 363 - #define KEY_HELP 138 /* AL Integrated Help Center */ 364 - #define KEY_MENU 139 /* Menu (show menu) */ 365 - #define KEY_CALC 140 /* AL Calculator */ 366 - #define KEY_SETUP 141 367 - #define KEY_SLEEP 142 /* SC System Sleep */ 368 - #define KEY_WAKEUP 143 /* System Wake Up */ 369 - #define KEY_FILE 144 /* AL Local Machine Browser */ 370 - #define KEY_SENDFILE 145 371 - #define KEY_DELETEFILE 146 372 - #define KEY_XFER 147 373 - #define KEY_PROG1 148 374 - #define KEY_PROG2 149 375 - #define KEY_WWW 150 /* AL Internet Browser */ 376 - #define KEY_MSDOS 151 377 - #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ 378 - #define KEY_SCREENLOCK KEY_COFFEE 379 - #define KEY_ROTATE_DISPLAY 153 /* Display orientation for e.g. tablets */ 380 - #define KEY_DIRECTION KEY_ROTATE_DISPLAY 381 - #define KEY_CYCLEWINDOWS 154 382 - #define KEY_MAIL 155 383 - #define KEY_BOOKMARKS 156 /* AC Bookmarks */ 384 - #define KEY_COMPUTER 157 385 - #define KEY_BACK 158 /* AC Back */ 386 - #define KEY_FORWARD 159 /* AC Forward */ 387 - #define KEY_CLOSECD 160 388 - #define KEY_EJECTCD 161 389 - #define KEY_EJECTCLOSECD 162 390 - #define KEY_NEXTSONG 163 391 - #define KEY_PLAYPAUSE 164 392 - #define KEY_PREVIOUSSONG 165 393 - #define KEY_STOPCD 166 394 - #define KEY_RECORD 167 395 - #define KEY_REWIND 168 396 - #define KEY_PHONE 169 /* Media Select Telephone */ 397 - #define KEY_ISO 170 398 - #define KEY_CONFIG 171 /* AL Consumer Control Configuration */ 399 - #define KEY_HOMEPAGE 172 /* AC Home */ 400 - #define KEY_REFRESH 173 /* AC Refresh */ 401 - #define KEY_EXIT 174 /* AC Exit */ 402 - #define KEY_MOVE 175 403 - #define KEY_EDIT 176 404 - #define KEY_SCROLLUP 177 405 - #define KEY_SCROLLDOWN 178 406 - #define KEY_KPLEFTPAREN 179 407 - #define KEY_KPRIGHTPAREN 180 408 - #define KEY_NEW 181 /* AC New */ 409 - #define KEY_REDO 182 /* AC Redo/Repeat */ 410 - 411 - #define KEY_F13 183 412 - #define KEY_F14 184 413 - #define KEY_F15 185 414 - #define KEY_F16 186 415 - #define KEY_F17 187 416 - #define KEY_F18 188 417 - #define KEY_F19 189 418 - #define KEY_F20 190 419 - #define KEY_F21 191 420 - #define KEY_F22 192 421 - #define KEY_F23 193 422 - #define KEY_F24 194 423 - 424 - #define KEY_PLAYCD 200 425 - #define KEY_PAUSECD 201 426 - #define KEY_PROG3 202 427 - #define KEY_PROG4 203 428 - #define KEY_DASHBOARD 204 /* AL Dashboard */ 429 - #define KEY_SUSPEND 205 430 - #define KEY_CLOSE 206 /* AC Close */ 431 - #define KEY_PLAY 207 432 - #define KEY_FASTFORWARD 208 433 - #define KEY_BASSBOOST 209 434 - #define KEY_PRINT 210 /* AC Print */ 435 - #define KEY_HP 211 436 - #define KEY_CAMERA 212 437 - #define KEY_SOUND 213 438 - #define KEY_QUESTION 214 439 - #define KEY_EMAIL 215 440 - #define KEY_CHAT 216 441 - #define KEY_SEARCH 217 442 - #define KEY_CONNECT 218 443 - #define KEY_FINANCE 219 /* AL Checkbook/Finance */ 444 - #define KEY_SPORT 220 445 - #define KEY_SHOP 221 446 - #define KEY_ALTERASE 222 447 - #define KEY_CANCEL 223 /* AC Cancel */ 448 - #define KEY_BRIGHTNESSDOWN 224 449 - #define KEY_BRIGHTNESSUP 225 450 - #define KEY_MEDIA 226 451 - 452 - #define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video 453 - outputs (Monitor/LCD/TV-out/etc) */ 454 - #define KEY_KBDILLUMTOGGLE 228 455 - #define KEY_KBDILLUMDOWN 229 456 - #define KEY_KBDILLUMUP 230 457 - 458 - #define KEY_SEND 231 /* AC Send */ 459 - #define KEY_REPLY 232 /* AC Reply */ 460 - #define KEY_FORWARDMAIL 233 /* AC Forward Msg */ 461 - #define KEY_SAVE 234 /* AC Save */ 462 - #define KEY_DOCUMENTS 235 463 - 464 - #define KEY_BATTERY 236 465 - 466 - #define KEY_BLUETOOTH 237 467 - #define KEY_WLAN 238 468 - #define KEY_UWB 239 469 - 470 - #define KEY_UNKNOWN 240 471 - 472 - #define KEY_VIDEO_NEXT 241 /* drive next video source */ 473 - #define KEY_VIDEO_PREV 242 /* drive previous video source */ 474 - #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ 475 - #define KEY_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual 476 - brightness control is off, 477 - rely on ambient */ 478 - #define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO 479 - #define KEY_DISPLAY_OFF 245 /* display device to off state */ 480 - 481 - #define KEY_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */ 482 - #define KEY_WIMAX KEY_WWAN 483 - #define KEY_RFKILL 247 /* Key that controls all radios */ 484 - 485 - #define KEY_MICMUTE 248 /* Mute / unmute the microphone */ 486 - 487 - /* Code 255 is reserved for special needs of AT keyboard driver */ 488 - 489 - #define BTN_MISC 0x100 490 - #define BTN_0 0x100 491 - #define BTN_1 0x101 492 - #define BTN_2 0x102 493 - #define BTN_3 0x103 494 - #define BTN_4 0x104 495 - #define BTN_5 0x105 496 - #define BTN_6 0x106 497 - #define BTN_7 0x107 498 - #define BTN_8 0x108 499 - #define BTN_9 0x109 500 - 501 - #define BTN_MOUSE 0x110 502 - #define BTN_LEFT 0x110 503 - #define BTN_RIGHT 0x111 504 - #define BTN_MIDDLE 0x112 505 - #define BTN_SIDE 0x113 506 - #define BTN_EXTRA 0x114 507 - #define BTN_FORWARD 0x115 508 - #define BTN_BACK 0x116 509 - #define BTN_TASK 0x117 510 - 511 - #define BTN_JOYSTICK 0x120 512 - #define BTN_TRIGGER 0x120 513 - #define BTN_THUMB 0x121 514 - #define BTN_THUMB2 0x122 515 - #define BTN_TOP 0x123 516 - #define BTN_TOP2 0x124 517 - #define BTN_PINKIE 0x125 518 - #define BTN_BASE 0x126 519 - #define BTN_BASE2 0x127 520 - #define BTN_BASE3 0x128 521 - #define BTN_BASE4 0x129 522 - #define BTN_BASE5 0x12a 523 - #define BTN_BASE6 0x12b 524 - #define BTN_DEAD 0x12f 525 - 526 - #define BTN_GAMEPAD 0x130 527 - #define BTN_SOUTH 0x130 528 - #define BTN_A BTN_SOUTH 529 - #define BTN_EAST 0x131 530 - #define BTN_B BTN_EAST 531 - #define BTN_C 0x132 532 - #define BTN_NORTH 0x133 533 - #define BTN_X BTN_NORTH 534 - #define BTN_WEST 0x134 535 - #define BTN_Y BTN_WEST 536 - #define BTN_Z 0x135 537 - #define BTN_TL 0x136 538 - #define BTN_TR 0x137 539 - #define BTN_TL2 0x138 540 - #define BTN_TR2 0x139 541 - #define BTN_SELECT 0x13a 542 - #define BTN_START 0x13b 543 - #define BTN_MODE 0x13c 544 - #define BTN_THUMBL 0x13d 545 - #define BTN_THUMBR 0x13e 546 - 547 - #define BTN_DIGI 0x140 548 - #define BTN_TOOL_PEN 0x140 549 - #define BTN_TOOL_RUBBER 0x141 550 - #define BTN_TOOL_BRUSH 0x142 551 - #define BTN_TOOL_PENCIL 0x143 552 - #define BTN_TOOL_AIRBRUSH 0x144 553 - #define BTN_TOOL_FINGER 0x145 554 - #define BTN_TOOL_MOUSE 0x146 555 - #define BTN_TOOL_LENS 0x147 556 - #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ 557 - #define BTN_TOUCH 0x14a 558 - #define BTN_STYLUS 0x14b 559 - #define BTN_STYLUS2 0x14c 560 - #define BTN_TOOL_DOUBLETAP 0x14d 561 - #define BTN_TOOL_TRIPLETAP 0x14e 562 - #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ 563 - 564 - #define BTN_WHEEL 0x150 565 - #define BTN_GEAR_DOWN 0x150 566 - #define BTN_GEAR_UP 0x151 567 - 568 - #define KEY_OK 0x160 569 - #define KEY_SELECT 0x161 570 - #define KEY_GOTO 0x162 571 - #define KEY_CLEAR 0x163 572 - #define KEY_POWER2 0x164 573 - #define KEY_OPTION 0x165 574 - #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ 575 - #define KEY_TIME 0x167 576 - #define KEY_VENDOR 0x168 577 - #define KEY_ARCHIVE 0x169 578 - #define KEY_PROGRAM 0x16a /* Media Select Program Guide */ 579 - #define KEY_CHANNEL 0x16b 580 - #define KEY_FAVORITES 0x16c 581 - #define KEY_EPG 0x16d 582 - #define KEY_PVR 0x16e /* Media Select Home */ 583 - #define KEY_MHP 0x16f 584 - #define KEY_LANGUAGE 0x170 585 - #define KEY_TITLE 0x171 586 - #define KEY_SUBTITLE 0x172 587 - #define KEY_ANGLE 0x173 588 - #define KEY_ZOOM 0x174 589 - #define KEY_MODE 0x175 590 - #define KEY_KEYBOARD 0x176 591 - #define KEY_SCREEN 0x177 592 - #define KEY_PC 0x178 /* Media Select Computer */ 593 - #define KEY_TV 0x179 /* Media Select TV */ 594 - #define KEY_TV2 0x17a /* Media Select Cable */ 595 - #define KEY_VCR 0x17b /* Media Select VCR */ 596 - #define KEY_VCR2 0x17c /* VCR Plus */ 597 - #define KEY_SAT 0x17d /* Media Select Satellite */ 598 - #define KEY_SAT2 0x17e 599 - #define KEY_CD 0x17f /* Media Select CD */ 600 - #define KEY_TAPE 0x180 /* Media Select Tape */ 601 - #define KEY_RADIO 0x181 602 - #define KEY_TUNER 0x182 /* Media Select Tuner */ 603 - #define KEY_PLAYER 0x183 604 - #define KEY_TEXT 0x184 605 - #define KEY_DVD 0x185 /* Media Select DVD */ 606 - #define KEY_AUX 0x186 607 - #define KEY_MP3 0x187 608 - #define KEY_AUDIO 0x188 /* AL Audio Browser */ 609 - #define KEY_VIDEO 0x189 /* AL Movie Browser */ 610 - #define KEY_DIRECTORY 0x18a 611 - #define KEY_LIST 0x18b 612 - #define KEY_MEMO 0x18c /* Media Select Messages */ 613 - #define KEY_CALENDAR 0x18d 614 - #define KEY_RED 0x18e 615 - #define KEY_GREEN 0x18f 616 - #define KEY_YELLOW 0x190 617 - #define KEY_BLUE 0x191 618 - #define KEY_CHANNELUP 0x192 /* Channel Increment */ 619 - #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ 620 - #define KEY_FIRST 0x194 621 - #define KEY_LAST 0x195 /* Recall Last */ 622 - #define KEY_AB 0x196 623 - #define KEY_NEXT 0x197 624 - #define KEY_RESTART 0x198 625 - #define KEY_SLOW 0x199 626 - #define KEY_SHUFFLE 0x19a 627 - #define KEY_BREAK 0x19b 628 - #define KEY_PREVIOUS 0x19c 629 - #define KEY_DIGITS 0x19d 630 - #define KEY_TEEN 0x19e 631 - #define KEY_TWEN 0x19f 632 - #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ 633 - #define KEY_GAMES 0x1a1 /* Media Select Games */ 634 - #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ 635 - #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ 636 - #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ 637 - #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ 638 - #define KEY_EDITOR 0x1a6 /* AL Text Editor */ 639 - #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ 640 - #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ 641 - #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ 642 - #define KEY_DATABASE 0x1aa /* AL Database App */ 643 - #define KEY_NEWS 0x1ab /* AL Newsreader */ 644 - #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ 645 - #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ 646 - #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ 647 - #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ 648 - #define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE 649 - #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ 650 - #define KEY_LOGOFF 0x1b1 /* AL Logoff */ 651 - 652 - #define KEY_DOLLAR 0x1b2 653 - #define KEY_EURO 0x1b3 654 - 655 - #define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ 656 - #define KEY_FRAMEFORWARD 0x1b5 657 - #define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ 658 - #define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ 659 - #define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */ 660 - #define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */ 661 - #define KEY_IMAGES 0x1ba /* AL Image Browser */ 662 - 663 - #define KEY_DEL_EOL 0x1c0 664 - #define KEY_DEL_EOS 0x1c1 665 - #define KEY_INS_LINE 0x1c2 666 - #define KEY_DEL_LINE 0x1c3 667 - 668 - #define KEY_FN 0x1d0 669 - #define KEY_FN_ESC 0x1d1 670 - #define KEY_FN_F1 0x1d2 671 - #define KEY_FN_F2 0x1d3 672 - #define KEY_FN_F3 0x1d4 673 - #define KEY_FN_F4 0x1d5 674 - #define KEY_FN_F5 0x1d6 675 - #define KEY_FN_F6 0x1d7 676 - #define KEY_FN_F7 0x1d8 677 - #define KEY_FN_F8 0x1d9 678 - #define KEY_FN_F9 0x1da 679 - #define KEY_FN_F10 0x1db 680 - #define KEY_FN_F11 0x1dc 681 - #define KEY_FN_F12 0x1dd 682 - #define KEY_FN_1 0x1de 683 - #define KEY_FN_2 0x1df 684 - #define KEY_FN_D 0x1e0 685 - #define KEY_FN_E 0x1e1 686 - #define KEY_FN_F 0x1e2 687 - #define KEY_FN_S 0x1e3 688 - #define KEY_FN_B 0x1e4 689 - 690 - #define KEY_BRL_DOT1 0x1f1 691 - #define KEY_BRL_DOT2 0x1f2 692 - #define KEY_BRL_DOT3 0x1f3 693 - #define KEY_BRL_DOT4 0x1f4 694 - #define KEY_BRL_DOT5 0x1f5 695 - #define KEY_BRL_DOT6 0x1f6 696 - #define KEY_BRL_DOT7 0x1f7 697 - #define KEY_BRL_DOT8 0x1f8 698 - #define KEY_BRL_DOT9 0x1f9 699 - #define KEY_BRL_DOT10 0x1fa 700 - 701 - #define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ 702 - #define KEY_NUMERIC_1 0x201 /* and other keypads */ 703 - #define KEY_NUMERIC_2 0x202 704 - #define KEY_NUMERIC_3 0x203 705 - #define KEY_NUMERIC_4 0x204 706 - #define KEY_NUMERIC_5 0x205 707 - #define KEY_NUMERIC_6 0x206 708 - #define KEY_NUMERIC_7 0x207 709 - #define KEY_NUMERIC_8 0x208 710 - #define KEY_NUMERIC_9 0x209 711 - #define KEY_NUMERIC_STAR 0x20a 712 - #define KEY_NUMERIC_POUND 0x20b 713 - #define KEY_NUMERIC_A 0x20c /* Phone key A - HUT Telephony 0xb9 */ 714 - #define KEY_NUMERIC_B 0x20d 715 - #define KEY_NUMERIC_C 0x20e 716 - #define KEY_NUMERIC_D 0x20f 717 - 718 - #define KEY_CAMERA_FOCUS 0x210 719 - #define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 720 - 721 - #define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */ 722 - #define KEY_TOUCHPAD_ON 0x213 723 - #define KEY_TOUCHPAD_OFF 0x214 724 - 725 - #define KEY_CAMERA_ZOOMIN 0x215 726 - #define KEY_CAMERA_ZOOMOUT 0x216 727 - #define KEY_CAMERA_UP 0x217 728 - #define KEY_CAMERA_DOWN 0x218 729 - #define KEY_CAMERA_LEFT 0x219 730 - #define KEY_CAMERA_RIGHT 0x21a 731 - 732 - #define KEY_ATTENDANT_ON 0x21b 733 - #define KEY_ATTENDANT_OFF 0x21c 734 - #define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ 735 - #define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ 736 - 737 - #define BTN_DPAD_UP 0x220 738 - #define BTN_DPAD_DOWN 0x221 739 - #define BTN_DPAD_LEFT 0x222 740 - #define BTN_DPAD_RIGHT 0x223 741 - 742 - #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ 743 - 744 - #define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ 745 - #define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ 746 - #define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */ 747 - #define KEY_CONTROLPANEL 0x243 /* AL Control Panel */ 748 - #define KEY_APPSELECT 0x244 /* AL Select Task/Application */ 749 - #define KEY_SCREENSAVER 0x245 /* AL Screen Saver */ 750 - #define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ 751 - 752 - #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ 753 - #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ 754 - 755 - #define KEY_KBDINPUTASSIST_PREV 0x260 756 - #define KEY_KBDINPUTASSIST_NEXT 0x261 757 - #define KEY_KBDINPUTASSIST_PREVGROUP 0x262 758 - #define KEY_KBDINPUTASSIST_NEXTGROUP 0x263 759 - #define KEY_KBDINPUTASSIST_ACCEPT 0x264 760 - #define KEY_KBDINPUTASSIST_CANCEL 0x265 761 - 762 - #define BTN_TRIGGER_HAPPY 0x2c0 763 - #define BTN_TRIGGER_HAPPY1 0x2c0 764 - #define BTN_TRIGGER_HAPPY2 0x2c1 765 - #define BTN_TRIGGER_HAPPY3 0x2c2 766 - #define BTN_TRIGGER_HAPPY4 0x2c3 767 - #define BTN_TRIGGER_HAPPY5 0x2c4 768 - #define BTN_TRIGGER_HAPPY6 0x2c5 769 - #define BTN_TRIGGER_HAPPY7 0x2c6 770 - #define BTN_TRIGGER_HAPPY8 0x2c7 771 - #define BTN_TRIGGER_HAPPY9 0x2c8 772 - #define BTN_TRIGGER_HAPPY10 0x2c9 773 - #define BTN_TRIGGER_HAPPY11 0x2ca 774 - #define BTN_TRIGGER_HAPPY12 0x2cb 775 - #define BTN_TRIGGER_HAPPY13 0x2cc 776 - #define BTN_TRIGGER_HAPPY14 0x2cd 777 - #define BTN_TRIGGER_HAPPY15 0x2ce 778 - #define BTN_TRIGGER_HAPPY16 0x2cf 779 - #define BTN_TRIGGER_HAPPY17 0x2d0 780 - #define BTN_TRIGGER_HAPPY18 0x2d1 781 - #define BTN_TRIGGER_HAPPY19 0x2d2 782 - #define BTN_TRIGGER_HAPPY20 0x2d3 783 - #define BTN_TRIGGER_HAPPY21 0x2d4 784 - #define BTN_TRIGGER_HAPPY22 0x2d5 785 - #define BTN_TRIGGER_HAPPY23 0x2d6 786 - #define BTN_TRIGGER_HAPPY24 0x2d7 787 - #define BTN_TRIGGER_HAPPY25 0x2d8 788 - #define BTN_TRIGGER_HAPPY26 0x2d9 789 - #define BTN_TRIGGER_HAPPY27 0x2da 790 - #define BTN_TRIGGER_HAPPY28 0x2db 791 - #define BTN_TRIGGER_HAPPY29 0x2dc 792 - #define BTN_TRIGGER_HAPPY30 0x2dd 793 - #define BTN_TRIGGER_HAPPY31 0x2de 794 - #define BTN_TRIGGER_HAPPY32 0x2df 795 - #define BTN_TRIGGER_HAPPY33 0x2e0 796 - #define BTN_TRIGGER_HAPPY34 0x2e1 797 - #define BTN_TRIGGER_HAPPY35 0x2e2 798 - #define BTN_TRIGGER_HAPPY36 0x2e3 799 - #define BTN_TRIGGER_HAPPY37 0x2e4 800 - #define BTN_TRIGGER_HAPPY38 0x2e5 801 - #define BTN_TRIGGER_HAPPY39 0x2e6 802 - #define BTN_TRIGGER_HAPPY40 0x2e7 803 - 804 - /* We avoid low common keys in module aliases so they don't get huge. */ 805 - #define KEY_MIN_INTERESTING KEY_MUTE 806 - #define KEY_MAX 0x2ff 807 - #define KEY_CNT (KEY_MAX+1) 808 - 809 - /* 810 - * Relative axes 188 + /** 189 + * EVIOCSMASK - Set event mask 190 + * 191 + * This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the 192 + * current event mask, this changes the client's event mask for a specific 193 + * type. See EVIOCGMASK for a description of event-masks and the 194 + * argument-type. 195 + * 196 + * This ioctl provides full forward compatibility. If the passed event type 197 + * is unknown to the kernel, or if the number of event codes specified in 198 + * the mask is bigger than what is known to the kernel, the ioctl is still 199 + * accepted and applied. However, any unknown codes are left untouched and 200 + * stay cleared. That means, the kernel always filters unknown codes 201 + * regardless of what the client requests. If the new mask doesn't cover 202 + * all known event-codes, all remaining codes are automatically cleared and 203 + * thus filtered. 204 + * 205 + * This ioctl may fail with ENODEV in case the file is revoked. EFAULT is 206 + * returned if the receive-buffer points to invalid memory. EINVAL is returned 207 + * if the kernel does not implement the ioctl. 811 208 */ 209 + #define EVIOCSMASK _IOW('E', 0x93, struct input_mask) /* Set event-masks */ 812 210 813 - #define REL_X 0x00 814 - #define REL_Y 0x01 815 - #define REL_Z 0x02 816 - #define REL_RX 0x03 817 - #define REL_RY 0x04 818 - #define REL_RZ 0x05 819 - #define REL_HWHEEL 0x06 820 - #define REL_DIAL 0x07 821 - #define REL_WHEEL 0x08 822 - #define REL_MISC 0x09 823 - #define REL_MAX 0x0f 824 - #define REL_CNT (REL_MAX+1) 825 - 826 - /* 827 - * Absolute axes 828 - */ 829 - 830 - #define ABS_X 0x00 831 - #define ABS_Y 0x01 832 - #define ABS_Z 0x02 833 - #define ABS_RX 0x03 834 - #define ABS_RY 0x04 835 - #define ABS_RZ 0x05 836 - #define ABS_THROTTLE 0x06 837 - #define ABS_RUDDER 0x07 838 - #define ABS_WHEEL 0x08 839 - #define ABS_GAS 0x09 840 - #define ABS_BRAKE 0x0a 841 - #define ABS_HAT0X 0x10 842 - #define ABS_HAT0Y 0x11 843 - #define ABS_HAT1X 0x12 844 - #define ABS_HAT1Y 0x13 845 - #define ABS_HAT2X 0x14 846 - #define ABS_HAT2Y 0x15 847 - #define ABS_HAT3X 0x16 848 - #define ABS_HAT3Y 0x17 849 - #define ABS_PRESSURE 0x18 850 - #define ABS_DISTANCE 0x19 851 - #define ABS_TILT_X 0x1a 852 - #define ABS_TILT_Y 0x1b 853 - #define ABS_TOOL_WIDTH 0x1c 854 - 855 - #define ABS_VOLUME 0x20 856 - 857 - #define ABS_MISC 0x28 858 - 859 - #define ABS_MT_SLOT 0x2f /* MT slot being modified */ 860 - #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ 861 - #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ 862 - #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ 863 - #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ 864 - #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ 865 - #define ABS_MT_POSITION_X 0x35 /* Center X touch position */ 866 - #define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ 867 - #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ 868 - #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 869 - #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 870 - #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 871 - #define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ 872 - #define ABS_MT_TOOL_X 0x3c /* Center X tool position */ 873 - #define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ 874 - 875 - 876 - #define ABS_MAX 0x3f 877 - #define ABS_CNT (ABS_MAX+1) 878 - 879 - /* 880 - * Switch events 881 - */ 882 - 883 - #define SW_LID 0x00 /* set = lid shut */ 884 - #define SW_TABLET_MODE 0x01 /* set = tablet mode */ 885 - #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ 886 - #define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" 887 - set = radio enabled */ 888 - #define SW_RADIO SW_RFKILL_ALL /* deprecated */ 889 - #define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ 890 - #define SW_DOCK 0x05 /* set = plugged into dock */ 891 - #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ 892 - #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ 893 - #define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ 894 - #define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */ 895 - #define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */ 896 - #define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ 897 - #define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ 898 - #define SW_LINEIN_INSERT 0x0d /* set = inserted */ 899 - #define SW_MUTE_DEVICE 0x0e /* set = device disabled */ 900 - #define SW_MAX 0x0f 901 - #define SW_CNT (SW_MAX+1) 902 - 903 - /* 904 - * Misc events 905 - */ 906 - 907 - #define MSC_SERIAL 0x00 908 - #define MSC_PULSELED 0x01 909 - #define MSC_GESTURE 0x02 910 - #define MSC_RAW 0x03 911 - #define MSC_SCAN 0x04 912 - #define MSC_TIMESTAMP 0x05 913 - #define MSC_MAX 0x07 914 - #define MSC_CNT (MSC_MAX+1) 915 - 916 - /* 917 - * LEDs 918 - */ 919 - 920 - #define LED_NUML 0x00 921 - #define LED_CAPSL 0x01 922 - #define LED_SCROLLL 0x02 923 - #define LED_COMPOSE 0x03 924 - #define LED_KANA 0x04 925 - #define LED_SLEEP 0x05 926 - #define LED_SUSPEND 0x06 927 - #define LED_MUTE 0x07 928 - #define LED_MISC 0x08 929 - #define LED_MAIL 0x09 930 - #define LED_CHARGING 0x0a 931 - #define LED_MAX 0x0f 932 - #define LED_CNT (LED_MAX+1) 933 - 934 - /* 935 - * Autorepeat values 936 - */ 937 - 938 - #define REP_DELAY 0x00 939 - #define REP_PERIOD 0x01 940 - #define REP_MAX 0x01 941 - #define REP_CNT (REP_MAX+1) 942 - 943 - /* 944 - * Sounds 945 - */ 946 - 947 - #define SND_CLICK 0x00 948 - #define SND_BELL 0x01 949 - #define SND_TONE 0x02 950 - #define SND_MAX 0x07 951 - #define SND_CNT (SND_MAX+1) 211 + #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ 952 212 953 213 /* 954 214 * IDs. ··· 473 1199 474 1200 #define FF_GAIN 0x60 475 1201 #define FF_AUTOCENTER 0x61 1202 + 1203 + /* 1204 + * ff->playback(effect_id = FF_GAIN) is the first effect_id to 1205 + * cause a collision with another ff method, in this case ff->set_gain(). 1206 + * Therefore the greatest safe value for effect_id is FF_GAIN - 1, 1207 + * and thus the total number of effects should never exceed FF_GAIN. 1208 + */ 1209 + #define FF_MAX_EFFECTS FF_GAIN 476 1210 477 1211 #define FF_MAX 0x7f 478 1212 #define FF_CNT (FF_MAX+1)
+44
include/uapi/linux/userio.h
··· 1 + /* 2 + * userio: virtual serio device support 3 + * Copyright (C) 2015 Red Hat 4 + * Copyright (C) 2015 Lyude (Stephen Chandler Paul) <cpaul@redhat.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU Lesser General Public License as published by the 8 + * Free Software Foundation; either version 2 of the License, or (at your 9 + * option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, but WITHOUT 12 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 + * details. 15 + * 16 + * This is the public header used for user-space communication with the userio 17 + * driver. __attribute__((__packed__)) is used for all structs to keep ABI 18 + * compatibility between all architectures. 19 + */ 20 + 21 + #ifndef _USERIO_H 22 + #define _USERIO_H 23 + 24 + #include <linux/types.h> 25 + 26 + enum userio_cmd_type { 27 + USERIO_CMD_REGISTER = 0, 28 + USERIO_CMD_SET_PORT_TYPE = 1, 29 + USERIO_CMD_SEND_INTERRUPT = 2 30 + }; 31 + 32 + /* 33 + * userio Commands 34 + * All commands sent to /dev/userio are encoded using this structure. The type 35 + * field should contain a USERIO_CMD* value that indicates what kind of command 36 + * is being sent to userio. The data field should contain the accompanying 37 + * argument for the command, if there is one. 38 + */ 39 + struct userio_cmd { 40 + __u8 type; 41 + __u8 data; 42 + } __attribute__((__packed__)); 43 + 44 + #endif /* !_USERIO_H */