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 subsystem updates from Dmitry Torokhov:
"Thanks to Samuel Thibault input device (keyboard) LEDs are no longer
hardwired within the input core but use LED subsystem and so allow use
of different triggers; Hans de Goede did a large update for the ALPS
touchpad driver; we have new TI drv2665 haptics driver and DA9063
OnKey driver, and host of other drivers got various fixes"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (55 commits)
Input: pixcir_i2c_ts - fix receive error
MAINTAINERS: remove non existent input mt git tree
Input: improve usage of gpiod API
tty/vt/keyboard: define LED triggers for VT keyboard lock states
tty/vt/keyboard: define LED triggers for VT LED states
Input: export LEDs as class devices in sysfs
Input: cyttsp4 - use swap() in cyttsp4_get_touch()
Input: goodix - do not explicitly set evbits in input device
Input: goodix - export id and version read from device
Input: goodix - fix variable length array warning
Input: goodix - fix alignment issues
Input: add OnKey driver for DA9063 MFD part
Input: elan_i2c - add product IDs FW names
Input: elan_i2c - add support for multi IC type and iap format
Input: focaltech - report finger width to userspace
tty: remove platform_sysrq_reset_seq
Input: synaptics_i2c - use proper boolean values
Input: psmouse - use true instead of 1 for boolean values
Input: cyapa - fix a few typos in comments
Input: stmpe-ts - enforce device tree only mode
...

+1278 -375
+1 -2
Documentation/devicetree/bindings/i2c/trivial-devices.txt
··· 19 19 adi,adt7476 +/-1C TDM Extended Temp Range I.C 20 20 adi,adt7490 +/-1C TDM Extended Temp Range I.C 21 21 adi,adxl345 Three-Axis Digital Accelerometer 22 - adi,adxl346 Three-Axis Digital Accelerometer 23 - adi,adxl34x Three-Axis Digital Accelerometer 22 + adi,adxl346 Three-Axis Digital Accelerometer (backward-compatibility value "adi,adxl345" must be listed too) 24 23 at,24c08 i2c serial eeprom (24cxx) 25 24 atmel,24c00 i2c serial eeprom (24cxx) 26 25 atmel,24c01 i2c serial eeprom (24cxx)
+17
Documentation/devicetree/bindings/input/ti,drv2665.txt
··· 1 + * Texas Instruments - drv2665 Haptics driver 2 + 3 + Required properties: 4 + - compatible - "ti,drv2665" - DRV2665 5 + - reg - I2C slave address 6 + - vbat-supply - Required supply regulator 7 + 8 + Example: 9 + 10 + haptics: haptics@59 { 11 + compatible = "ti,drv2665"; 12 + reg = <0x59>; 13 + vbat-supply = <&vbat>; 14 + }; 15 + 16 + For more product information please see the link below: 17 + http://www.ti.com/product/drv2665
-3
Documentation/leds/leds-class.txt
··· 2 2 LED handling under Linux 3 3 ======================== 4 4 5 - If you're reading this and thinking about keyboard leds, these are 6 - handled by the input subsystem and the led class is *not* needed. 7 - 8 5 In its simplest form, the LED class just allows control of LEDs from 9 6 userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the 10 7 LED is defined in max_brightness file. The brightness file will set the brightness
-1
MAINTAINERS
··· 5171 5171 INPUT MULTITOUCH (MT) PROTOCOL 5172 5172 M: Henrik Rydberg <rydberg@bitmath.org> 5173 5173 L: linux-input@vger.kernel.org 5174 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input-mt.git 5175 5174 S: Odd fixes 5176 5175 F: Documentation/input/multi-touch-protocol.txt 5177 5176 F: drivers/input/input-mt.c
+13
drivers/input/Kconfig
··· 25 25 26 26 if INPUT 27 27 28 + config INPUT_LEDS 29 + tristate "Export input device LEDs in sysfs" 30 + depends on LEDS_CLASS 31 + default INPUT 32 + help 33 + Say Y here if you would like to export LEDs on input devices 34 + as standard LED class devices in sysfs. 35 + 36 + If unsure, say Y. 37 + 38 + To compile this driver as a module, choose M here: the 39 + module will be called input-leds. 40 + 28 41 config INPUT_FF_MEMLESS 29 42 tristate "Support for memoryless force-feedback devices" 30 43 help
+1
drivers/input/Makefile
··· 12 12 obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o 13 13 obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o 14 14 15 + obj-$(CONFIG_INPUT_LEDS) += input-leds.o 15 16 obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o 16 17 obj-$(CONFIG_INPUT_JOYDEV) += joydev.o 17 18 obj-$(CONFIG_INPUT_EVDEV) += evdev.o
+1 -4
drivers/input/evdev.c
··· 422 422 423 423 evdev_detach_client(evdev, client); 424 424 425 - if (is_vmalloc_addr(client)) 426 - vfree(client); 427 - else 428 - kfree(client); 425 + kvfree(client); 429 426 430 427 evdev_close_device(evdev); 431 428
+2 -2
drivers/input/ff-core.c
··· 70 70 return -EINVAL; 71 71 72 72 /* 73 - * calculate manginude of sine wave as average of rumble's 73 + * calculate magnitude of sine wave as average of rumble's 74 74 * 2/3 of strong magnitude and 1/3 of weak magnitude 75 75 */ 76 76 magnitude = effect->u.rumble.strong_magnitude / 3 + ··· 213 213 /** 214 214 * input_ff_erase - erase a force-feedback effect from device 215 215 * @dev: input device to erase effect from 216 - * @effect_id: id of the ffect to be erased 216 + * @effect_id: id of the effect to be erased 217 217 * @file: purported owner of the request 218 218 * 219 219 * This function erases a force-feedback effect from specified device.
+212
drivers/input/input-leds.c
··· 1 + /* 2 + * LED support for the input layer 3 + * 4 + * Copyright 2010-2015 Samuel Thibault <samuel.thibault@ens-lyon.org> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + #include <linux/kernel.h> 12 + #include <linux/slab.h> 13 + #include <linux/module.h> 14 + #include <linux/init.h> 15 + #include <linux/leds.h> 16 + #include <linux/input.h> 17 + 18 + #if IS_ENABLED(CONFIG_VT) 19 + #define VT_TRIGGER(_name) .trigger = _name 20 + #else 21 + #define VT_TRIGGER(_name) .trigger = NULL 22 + #endif 23 + 24 + static const struct { 25 + const char *name; 26 + const char *trigger; 27 + } input_led_info[LED_CNT] = { 28 + [LED_NUML] = { "numlock", VT_TRIGGER("kbd-numlock") }, 29 + [LED_CAPSL] = { "capslock", VT_TRIGGER("kbd-capslock") }, 30 + [LED_SCROLLL] = { "scrolllock", VT_TRIGGER("kbd-scrolllock") }, 31 + [LED_COMPOSE] = { "compose" }, 32 + [LED_KANA] = { "kana", VT_TRIGGER("kbd-kanalock") }, 33 + [LED_SLEEP] = { "sleep" } , 34 + [LED_SUSPEND] = { "suspend" }, 35 + [LED_MUTE] = { "mute" }, 36 + [LED_MISC] = { "misc" }, 37 + [LED_MAIL] = { "mail" }, 38 + [LED_CHARGING] = { "charging" }, 39 + }; 40 + 41 + struct input_led { 42 + struct led_classdev cdev; 43 + struct input_handle *handle; 44 + unsigned int code; /* One of LED_* constants */ 45 + }; 46 + 47 + struct input_leds { 48 + struct input_handle handle; 49 + unsigned int num_leds; 50 + struct input_led leds[]; 51 + }; 52 + 53 + static enum led_brightness input_leds_brightness_get(struct led_classdev *cdev) 54 + { 55 + struct input_led *led = container_of(cdev, struct input_led, cdev); 56 + struct input_dev *input = led->handle->dev; 57 + 58 + return test_bit(led->code, input->led) ? cdev->max_brightness : 0; 59 + } 60 + 61 + static void input_leds_brightness_set(struct led_classdev *cdev, 62 + enum led_brightness brightness) 63 + { 64 + struct input_led *led = container_of(cdev, struct input_led, cdev); 65 + 66 + input_inject_event(led->handle, EV_LED, led->code, !!brightness); 67 + } 68 + 69 + static void input_leds_event(struct input_handle *handle, unsigned int type, 70 + unsigned int code, int value) 71 + { 72 + } 73 + 74 + static int input_leds_connect(struct input_handler *handler, 75 + struct input_dev *dev, 76 + const struct input_device_id *id) 77 + { 78 + struct input_leds *leds; 79 + unsigned int num_leds; 80 + unsigned int led_code; 81 + int led_no; 82 + int error; 83 + 84 + num_leds = bitmap_weight(dev->ledbit, LED_CNT); 85 + if (!num_leds) 86 + return -ENXIO; 87 + 88 + leds = kzalloc(sizeof(*leds) + num_leds * sizeof(*leds->leds), 89 + GFP_KERNEL); 90 + if (!leds) 91 + return -ENOMEM; 92 + 93 + leds->num_leds = num_leds; 94 + 95 + leds->handle.dev = dev; 96 + leds->handle.handler = handler; 97 + leds->handle.name = "leds"; 98 + leds->handle.private = leds; 99 + 100 + error = input_register_handle(&leds->handle); 101 + if (error) 102 + goto err_free_mem; 103 + 104 + error = input_open_device(&leds->handle); 105 + if (error) 106 + goto err_unregister_handle; 107 + 108 + led_no = 0; 109 + for_each_set_bit(led_code, dev->ledbit, LED_CNT) { 110 + struct input_led *led = &leds->leds[led_no]; 111 + 112 + led->handle = &leds->handle; 113 + led->code = led_code; 114 + 115 + if (WARN_ON(!input_led_info[led_code].name)) 116 + continue; 117 + 118 + led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s", 119 + dev_name(&dev->dev), 120 + input_led_info[led_code].name); 121 + if (!led->cdev.name) { 122 + error = -ENOMEM; 123 + goto err_unregister_leds; 124 + } 125 + 126 + led->cdev.max_brightness = 1; 127 + led->cdev.brightness_get = input_leds_brightness_get; 128 + led->cdev.brightness_set = input_leds_brightness_set; 129 + led->cdev.default_trigger = input_led_info[led_code].trigger; 130 + 131 + error = led_classdev_register(&dev->dev, &led->cdev); 132 + if (error) { 133 + dev_err(&dev->dev, "failed to register LED %s: %d\n", 134 + led->cdev.name, error); 135 + kfree(led->cdev.name); 136 + goto err_unregister_leds; 137 + } 138 + 139 + led_no++; 140 + } 141 + 142 + return 0; 143 + 144 + err_unregister_leds: 145 + while (--led_no >= 0) { 146 + struct input_led *led = &leds->leds[led_no]; 147 + 148 + led_classdev_unregister(&led->cdev); 149 + kfree(led->cdev.name); 150 + } 151 + 152 + input_close_device(&leds->handle); 153 + 154 + err_unregister_handle: 155 + input_unregister_handle(&leds->handle); 156 + 157 + err_free_mem: 158 + kfree(leds); 159 + return error; 160 + } 161 + 162 + static void input_leds_disconnect(struct input_handle *handle) 163 + { 164 + struct input_leds *leds = handle->private; 165 + int i; 166 + 167 + for (i = 0; i < leds->num_leds; i++) { 168 + struct input_led *led = &leds->leds[i]; 169 + 170 + led_classdev_unregister(&led->cdev); 171 + kfree(led->cdev.name); 172 + } 173 + 174 + input_close_device(handle); 175 + input_unregister_handle(handle); 176 + 177 + kfree(leds); 178 + } 179 + 180 + static const struct input_device_id input_leds_ids[] = { 181 + { 182 + .flags = INPUT_DEVICE_ID_MATCH_EVBIT, 183 + .evbit = { BIT_MASK(EV_LED) }, 184 + }, 185 + { }, 186 + }; 187 + MODULE_DEVICE_TABLE(input, input_leds_ids); 188 + 189 + static struct input_handler input_leds_handler = { 190 + .event = input_leds_event, 191 + .connect = input_leds_connect, 192 + .disconnect = input_leds_disconnect, 193 + .name = "leds", 194 + .id_table = input_leds_ids, 195 + }; 196 + 197 + static int __init input_leds_init(void) 198 + { 199 + return input_register_handler(&input_leds_handler); 200 + } 201 + module_init(input_leds_init); 202 + 203 + static void __exit input_leds_exit(void) 204 + { 205 + input_unregister_handler(&input_leds_handler); 206 + } 207 + module_exit(input_leds_exit); 208 + 209 + MODULE_AUTHOR("Samuel Thibault <samuel.thibault@ens-lyon.org>"); 210 + MODULE_AUTHOR("Dmitry Torokhov <dmitry.torokhov@gmail.com>"); 211 + MODULE_DESCRIPTION("Input -> LEDs Bridge"); 212 + MODULE_LICENSE("GPL v2");
+1 -1
drivers/input/input.c
··· 2262 2262 * 2263 2263 * Iterate over @bus's list of devices, and call @fn for each, passing 2264 2264 * it @data and stop when @fn returns a non-zero value. The function is 2265 - * using RCU to traverse the list and therefore may be usind in atonic 2265 + * using RCU to traverse the list and therefore may be using in atomic 2266 2266 * contexts. The @fn callback is invoked from RCU critical section and 2267 2267 * thus must not sleep. 2268 2268 */
+1
drivers/input/keyboard/Kconfig
··· 367 367 368 368 config KEYBOARD_MAX7359 369 369 tristate "Maxim MAX7359 Key Switch Controller" 370 + select INPUT_MATRIXKMAP 370 371 depends on I2C 371 372 help 372 373 If you say yes here you get support for the Maxim MAX7359 Key
+3 -3
drivers/input/keyboard/adp5589-keys.c
··· 180 180 #define LOGIC2_STAT (1 << 7) /* ADP5589 only */ 181 181 #define LOGIC1_STAT (1 << 6) 182 182 #define LOCK_STAT (1 << 5) /* ADP5589 only */ 183 - #define KEC 0xF 183 + #define KEC 0x1F 184 184 185 185 /* PIN_CONFIG_D Register */ 186 186 #define C4_EXTEND_CFG (1 << 6) /* RESET2 */ ··· 726 726 727 727 pull_mask |= val << (2 * (i & 0x3)); 728 728 729 - if (i == 3 || i == kpad->var->max_row_num) { 729 + if (i % 4 == 3 || i == kpad->var->max_row_num) { 730 730 ret |= adp5589_write(client, reg(ADP5585_RPULL_CONFIG_A) 731 731 + (i >> 2), pull_mask); 732 732 pull_mask = 0; ··· 746 746 747 747 pull_mask |= val << (2 * (i & 0x3)); 748 748 749 - if (i == 3 || i == kpad->var->max_col_num) { 749 + if (i % 4 == 3 || i == kpad->var->max_col_num) { 750 750 ret |= adp5589_write(client, 751 751 reg(ADP5585_RPULL_CONFIG_C) + 752 752 (i >> 2), pull_mask);
+1 -6
drivers/input/keyboard/clps711x-keypad.c
··· 120 120 for (i = 0; i < priv->row_count; i++) { 121 121 struct clps711x_gpio_data *data = &priv->gpio_data[i]; 122 122 123 - data->desc = devm_gpiod_get_index(dev, "row", i); 124 - if (!data->desc) 125 - return -EINVAL; 126 - 123 + data->desc = devm_gpiod_get_index(dev, "row", i, GPIOD_IN); 127 124 if (IS_ERR(data->desc)) 128 125 return PTR_ERR(data->desc); 129 - 130 - gpiod_direction_input(data->desc); 131 126 } 132 127 133 128 err = of_property_read_u32(np, "poll-interval", &poll_interval);
+9 -22
drivers/input/keyboard/max7359_keypad.c
··· 84 84 return ret; 85 85 } 86 86 87 - static void max7359_build_keycode(struct max7359_keypad *keypad, 88 - const struct matrix_keymap_data *keymap_data) 89 - { 90 - struct input_dev *input_dev = keypad->input_dev; 91 - int i; 92 - 93 - for (i = 0; i < keymap_data->keymap_size; i++) { 94 - unsigned int key = keymap_data->keymap[i]; 95 - unsigned int row = KEY_ROW(key); 96 - unsigned int col = KEY_COL(key); 97 - unsigned int scancode = MATRIX_SCAN_CODE(row, col, 98 - MAX7359_ROW_SHIFT); 99 - unsigned short keycode = KEY_VAL(key); 100 - 101 - keypad->keycodes[scancode] = keycode; 102 - __set_bit(keycode, input_dev->keybit); 103 - } 104 - __clear_bit(KEY_RESERVED, input_dev->keybit); 105 - } 106 - 107 87 /* runs in an IRQ thread -- can (and will!) sleep */ 108 88 static irqreturn_t max7359_interrupt(int irq, void *dev_id) 109 89 { ··· 146 166 static void max7359_initialize(struct i2c_client *client) 147 167 { 148 168 max7359_write_reg(client, MAX7359_REG_CONFIG, 149 - MAX7359_CFG_INTERRUPT | /* Irq clears after host read */ 150 169 MAX7359_CFG_KEY_RELEASE | /* Key release enable */ 151 170 MAX7359_CFG_WAKEUP); /* Key press wakeup enable */ 152 171 ··· 212 233 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 213 234 input_set_drvdata(input_dev, keypad); 214 235 215 - max7359_build_keycode(keypad, keymap_data); 236 + error = matrix_keypad_build_keymap(keymap_data, NULL, 237 + MAX7359_MAX_KEY_ROWS, 238 + MAX7359_MAX_KEY_COLS, 239 + keypad->keycodes, 240 + input_dev); 241 + if (error) { 242 + dev_err(&client->dev, "failed to build keymap\n"); 243 + return error; 244 + } 216 245 217 246 error = devm_request_threaded_irq(&client->dev, client->irq, NULL, 218 247 max7359_interrupt,
+1 -1
drivers/input/keyboard/samsung-keypad.c
··· 585 585 MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match); 586 586 #endif 587 587 588 - static struct platform_device_id samsung_keypad_driver_ids[] = { 588 + static const struct platform_device_id samsung_keypad_driver_ids[] = { 589 589 { 590 590 .name = "samsung-keypad", 591 591 .driver_data = KEYPAD_TYPE_SAMSUNG,
+1 -1
drivers/input/keyboard/spear-keyboard.c
··· 3 3 * Based on omap-keypad driver 4 4 * 5 5 * Copyright (C) 2010 ST Microelectronics 6 - * Rajeev Kumar<rajeev-dlh.kumar@st.com> 6 + * Rajeev Kumar <rajeevkumar.linux@gmail.com> 7 7 * 8 8 * This file is licensed under the terms of the GNU General Public 9 9 * License version 2. This program is licensed "as is" without any
+22 -1
drivers/input/misc/Kconfig
··· 610 610 To compile this driver as a module, choose M here: the module 611 611 will be called da9055_onkey. 612 612 613 + config INPUT_DA9063_ONKEY 614 + tristate "Dialog DA9063 OnKey" 615 + depends on MFD_DA9063 616 + help 617 + Support the ONKEY of Dialog DA9063 Power Management IC as an 618 + input device reporting power button statue. 619 + 620 + To compile this driver as a module, choose M here: the module 621 + will be called da9063_onkey. 622 + 613 623 config INPUT_DM355EVM 614 624 tristate "TI DaVinci DM355 EVM Keypad and IR Remote" 615 625 depends on MFD_DM355EVM_MSP ··· 785 775 To compile this driver as a module, choose M here: the 786 776 module will be called drv260x-haptics. 787 777 778 + config INPUT_DRV2665_HAPTICS 779 + tristate "TI DRV2665 haptics support" 780 + depends on INPUT && I2C 781 + select INPUT_FF_MEMLESS 782 + select REGMAP_I2C 783 + help 784 + Say Y to enable support for the TI DRV2665 haptics driver. 785 + 786 + To compile this driver as a module, choose M here: the 787 + module will be called drv2665-haptics. 788 + 788 789 config INPUT_DRV2667_HAPTICS 789 790 tristate "TI DRV2667 haptics support" 790 791 depends on INPUT && I2C ··· 805 784 Say Y to enable support for the TI DRV2667 haptics driver. 806 785 807 786 To compile this driver as a module, choose M here: the 808 - module will be called drv260x-haptics. 787 + module will be called drv2667-haptics. 809 788 810 789 endif
+2
drivers/input/misc/Makefile
··· 25 25 obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o 26 26 obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o 27 27 obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o 28 + obj-$(CONFIG_INPUT_DA9063_ONKEY) += da9063_onkey.o 28 29 obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o 29 30 obj-$(CONFIG_INPUT_E3X0_BUTTON) += e3x0-button.o 30 31 obj-$(CONFIG_INPUT_DRV260X_HAPTICS) += drv260x.o 32 + obj-$(CONFIG_INPUT_DRV2665_HAPTICS) += drv2665.o 31 33 obj-$(CONFIG_INPUT_DRV2667_HAPTICS) += drv2667.o 32 34 obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o 33 35 obj-$(CONFIG_INPUT_GPIO_BEEPER) += gpio-beeper.o
+21
drivers/input/misc/adxl34x-i2c.c
··· 10 10 #include <linux/input.h> /* BUS_I2C */ 11 11 #include <linux/i2c.h> 12 12 #include <linux/module.h> 13 + #include <linux/of.h> 13 14 #include <linux/types.h> 14 15 #include <linux/pm.h> 15 16 #include "adxl34x.h" ··· 136 135 137 136 MODULE_DEVICE_TABLE(i2c, adxl34x_id); 138 137 138 + #ifdef CONFIG_OF 139 + static const struct of_device_id adxl34x_of_id[] = { 140 + /* 141 + * The ADXL346 is backward-compatible with the ADXL345. Differences are 142 + * handled by runtime detection of the device model, there's thus no 143 + * need for listing the "adi,adxl346" compatible value explicitly. 144 + */ 145 + { .compatible = "adi,adxl345", }, 146 + /* 147 + * Deprecated, DT nodes should use one or more of the device-specific 148 + * compatible values "adi,adxl345" and "adi,adxl346". 149 + */ 150 + { .compatible = "adi,adxl34x", }, 151 + { } 152 + }; 153 + 154 + MODULE_DEVICE_TABLE(of, adxl34x_of_id); 155 + #endif 156 + 139 157 static struct i2c_driver adxl34x_driver = { 140 158 .driver = { 141 159 .name = "adxl34x", 142 160 .owner = THIS_MODULE, 143 161 .pm = &adxl34x_i2c_pm, 162 + .of_match_table = of_match_ptr(adxl34x_of_id), 144 163 }, 145 164 .probe = adxl34x_i2c_probe, 146 165 .remove = adxl34x_i2c_remove,
+226
drivers/input/misc/da9063_onkey.c
··· 1 + /* 2 + * OnKey device driver for DA9063 3 + * Copyright (C) 2015 Dialog Semiconductor Ltd. 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License 7 + * as published by the Free Software Foundation; either version 2 8 + * of the License, or (at your option) any later version. 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/module.h> 17 + #include <linux/errno.h> 18 + #include <linux/input.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/platform_device.h> 21 + #include <linux/workqueue.h> 22 + #include <linux/regmap.h> 23 + #include <linux/of.h> 24 + #include <linux/mfd/da9063/core.h> 25 + #include <linux/mfd/da9063/pdata.h> 26 + #include <linux/mfd/da9063/registers.h> 27 + 28 + struct da9063_onkey { 29 + struct da9063 *hw; 30 + struct delayed_work work; 31 + struct input_dev *input; 32 + struct device *dev; 33 + bool key_power; 34 + }; 35 + 36 + static void da9063_poll_on(struct work_struct *work) 37 + { 38 + struct da9063_onkey *onkey = container_of(work, struct da9063_onkey, 39 + work.work); 40 + unsigned int val; 41 + int fault_log = 0; 42 + bool poll = true; 43 + int error; 44 + 45 + /* Poll to see when the pin is released */ 46 + error = regmap_read(onkey->hw->regmap, DA9063_REG_STATUS_A, &val); 47 + if (error) { 48 + dev_err(onkey->dev, 49 + "Failed to read ON status: %d\n", error); 50 + goto err_poll; 51 + } 52 + 53 + if (!(val & DA9063_NONKEY)) { 54 + error = regmap_update_bits(onkey->hw->regmap, 55 + DA9063_REG_CONTROL_B, 56 + DA9063_NONKEY_LOCK, 0); 57 + if (error) { 58 + dev_err(onkey->dev, 59 + "Failed to reset the Key Delay %d\n", error); 60 + goto err_poll; 61 + } 62 + 63 + input_report_key(onkey->input, KEY_POWER, 0); 64 + input_sync(onkey->input); 65 + 66 + poll = false; 67 + } 68 + 69 + /* 70 + * If the fault log KEY_RESET is detected, then clear it 71 + * and shut down the system. 72 + */ 73 + error = regmap_read(onkey->hw->regmap, 74 + DA9063_REG_FAULT_LOG, &fault_log); 75 + if (error) { 76 + dev_warn(&onkey->input->dev, 77 + "Cannot read FAULT_LOG: %d\n", error); 78 + } else if (fault_log & DA9063_KEY_RESET) { 79 + error = regmap_write(onkey->hw->regmap, 80 + DA9063_REG_FAULT_LOG, 81 + DA9063_KEY_RESET); 82 + if (error) { 83 + dev_warn(&onkey->input->dev, 84 + "Cannot reset KEY_RESET fault log: %d\n", 85 + error); 86 + } else { 87 + /* at this point we do any S/W housekeeping 88 + * and then send shutdown command 89 + */ 90 + dev_dbg(&onkey->input->dev, 91 + "Sending SHUTDOWN to DA9063 ...\n"); 92 + error = regmap_write(onkey->hw->regmap, 93 + DA9063_REG_CONTROL_F, 94 + DA9063_SHUTDOWN); 95 + if (error) 96 + dev_err(&onkey->input->dev, 97 + "Cannot SHUTDOWN DA9063: %d\n", 98 + error); 99 + } 100 + } 101 + 102 + err_poll: 103 + if (poll) 104 + schedule_delayed_work(&onkey->work, msecs_to_jiffies(50)); 105 + } 106 + 107 + static irqreturn_t da9063_onkey_irq_handler(int irq, void *data) 108 + { 109 + struct da9063_onkey *onkey = data; 110 + unsigned int val; 111 + int error; 112 + 113 + error = regmap_read(onkey->hw->regmap, DA9063_REG_STATUS_A, &val); 114 + if (onkey->key_power && !error && (val & DA9063_NONKEY)) { 115 + input_report_key(onkey->input, KEY_POWER, 1); 116 + input_sync(onkey->input); 117 + schedule_delayed_work(&onkey->work, 0); 118 + dev_dbg(onkey->dev, "KEY_POWER pressed.\n"); 119 + } else { 120 + input_report_key(onkey->input, KEY_SLEEP, 1); 121 + input_sync(onkey->input); 122 + input_report_key(onkey->input, KEY_SLEEP, 0); 123 + input_sync(onkey->input); 124 + dev_dbg(onkey->dev, "KEY_SLEEP pressed.\n"); 125 + } 126 + 127 + return IRQ_HANDLED; 128 + } 129 + 130 + static void da9063_cancel_poll(void *data) 131 + { 132 + struct da9063_onkey *onkey = data; 133 + 134 + cancel_delayed_work_sync(&onkey->work); 135 + } 136 + 137 + static int da9063_onkey_probe(struct platform_device *pdev) 138 + { 139 + struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); 140 + struct da9063_pdata *pdata = dev_get_platdata(da9063->dev); 141 + struct da9063_onkey *onkey; 142 + int irq; 143 + int error; 144 + 145 + onkey = devm_kzalloc(&pdev->dev, sizeof(struct da9063_onkey), 146 + GFP_KERNEL); 147 + if (!onkey) { 148 + dev_err(&pdev->dev, "Failed to allocate memory.\n"); 149 + return -ENOMEM; 150 + } 151 + 152 + onkey->dev = &pdev->dev; 153 + onkey->hw = da9063; 154 + 155 + if (pdata) 156 + onkey->key_power = pdata->key_power; 157 + else 158 + onkey->key_power = 159 + !of_property_read_bool(pdev->dev.of_node, 160 + "dlg,disable-key-power"); 161 + 162 + onkey->input = devm_input_allocate_device(&pdev->dev); 163 + if (!onkey->input) { 164 + dev_err(&pdev->dev, "Failed to allocated input device.\n"); 165 + return -ENOMEM; 166 + } 167 + 168 + onkey->input->name = DA9063_DRVNAME_ONKEY; 169 + onkey->input->phys = DA9063_DRVNAME_ONKEY "/input0"; 170 + onkey->input->dev.parent = &pdev->dev; 171 + 172 + if (onkey->key_power) 173 + input_set_capability(onkey->input, EV_KEY, KEY_POWER); 174 + 175 + input_set_capability(onkey->input, EV_KEY, KEY_SLEEP); 176 + 177 + INIT_DELAYED_WORK(&onkey->work, da9063_poll_on); 178 + 179 + error = devm_add_action(&pdev->dev, da9063_cancel_poll, onkey); 180 + if (error) { 181 + dev_err(&pdev->dev, 182 + "Failed to add cancel poll action: %d\n", 183 + error); 184 + return error; 185 + } 186 + 187 + irq = platform_get_irq_byname(pdev, "ONKEY"); 188 + if (irq < 0) { 189 + error = irq; 190 + dev_err(&pdev->dev, "Failed to get platform IRQ: %d\n", error); 191 + return error; 192 + } 193 + 194 + error = devm_request_threaded_irq(&pdev->dev, irq, 195 + NULL, da9063_onkey_irq_handler, 196 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 197 + "ONKEY", onkey); 198 + if (error) { 199 + dev_err(&pdev->dev, 200 + "Failed to request IRQ %d: %d\n", irq, error); 201 + return error; 202 + } 203 + 204 + error = input_register_device(onkey->input); 205 + if (error) { 206 + dev_err(&pdev->dev, 207 + "Failed to register input device: %d\n", error); 208 + return error; 209 + } 210 + 211 + platform_set_drvdata(pdev, onkey); 212 + return 0; 213 + } 214 + 215 + static struct platform_driver da9063_onkey_driver = { 216 + .probe = da9063_onkey_probe, 217 + .driver = { 218 + .name = DA9063_DRVNAME_ONKEY, 219 + }, 220 + }; 221 + module_platform_driver(da9063_onkey_driver); 222 + 223 + MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>"); 224 + MODULE_DESCRIPTION("Onkey device driver for Dialog DA9063"); 225 + MODULE_LICENSE("GPL"); 226 + MODULE_ALIAS("platform:" DA9063_DRVNAME_ONKEY);
+4 -9
drivers/input/misc/drv260x.c
··· 580 580 return error; 581 581 } 582 582 583 - haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable"); 584 - if (IS_ERR(haptics->enable_gpio)) { 585 - error = PTR_ERR(haptics->enable_gpio); 586 - if (error != -ENOENT && error != -ENOSYS) 587 - return error; 588 - haptics->enable_gpio = NULL; 589 - } else { 590 - gpiod_direction_output(haptics->enable_gpio, 1); 591 - } 583 + haptics->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", 584 + GPIOD_OUT_HIGH); 585 + if (IS_ERR(haptics->enable_gpio)) 586 + return PTR_ERR(haptics->enable_gpio); 592 587 593 588 haptics->input_dev = devm_input_allocate_device(&client->dev); 594 589 if (!haptics->input_dev) {
+322
drivers/input/misc/drv2665.c
··· 1 + /* 2 + * DRV2665 haptics driver family 3 + * 4 + * Author: Dan Murphy <dmurphy@ti.com> 5 + * 6 + * Copyright: (C) 2015 Texas Instruments, Inc. 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, but 13 + * WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + */ 17 + 18 + #include <linux/i2c.h> 19 + #include <linux/input.h> 20 + #include <linux/module.h> 21 + #include <linux/regmap.h> 22 + #include <linux/slab.h> 23 + #include <linux/delay.h> 24 + #include <linux/regulator/consumer.h> 25 + 26 + /* Contol registers */ 27 + #define DRV2665_STATUS 0x00 28 + #define DRV2665_CTRL_1 0x01 29 + #define DRV2665_CTRL_2 0x02 30 + #define DRV2665_FIFO 0x0b 31 + 32 + /* Status Register */ 33 + #define DRV2665_FIFO_FULL BIT(0) 34 + #define DRV2665_FIFO_EMPTY BIT(1) 35 + 36 + /* Control 1 Register */ 37 + #define DRV2665_25_VPP_GAIN 0x00 38 + #define DRV2665_50_VPP_GAIN 0x01 39 + #define DRV2665_75_VPP_GAIN 0x02 40 + #define DRV2665_100_VPP_GAIN 0x03 41 + #define DRV2665_DIGITAL_IN 0xfc 42 + #define DRV2665_ANALOG_IN BIT(2) 43 + 44 + /* Control 2 Register */ 45 + #define DRV2665_BOOST_EN BIT(1) 46 + #define DRV2665_STANDBY BIT(6) 47 + #define DRV2665_DEV_RST BIT(7) 48 + #define DRV2665_5_MS_IDLE_TOUT 0x00 49 + #define DRV2665_10_MS_IDLE_TOUT 0x04 50 + #define DRV2665_15_MS_IDLE_TOUT 0x08 51 + #define DRV2665_20_MS_IDLE_TOUT 0x0c 52 + 53 + /** 54 + * struct drv2665_data - 55 + * @input_dev - Pointer to the input device 56 + * @client - Pointer to the I2C client 57 + * @regmap - Register map of the device 58 + * @work - Work item used to off load the enable/disable of the vibration 59 + * @regulator - Pointer to the regulator for the IC 60 + */ 61 + struct drv2665_data { 62 + struct input_dev *input_dev; 63 + struct i2c_client *client; 64 + struct regmap *regmap; 65 + struct work_struct work; 66 + struct regulator *regulator; 67 + }; 68 + 69 + /* 8kHz Sine wave to stream to the FIFO */ 70 + static const u8 drv2665_sine_wave_form[] = { 71 + 0x00, 0x10, 0x20, 0x2e, 0x3c, 0x48, 0x53, 0x5b, 0x61, 0x65, 0x66, 72 + 0x65, 0x61, 0x5b, 0x53, 0x48, 0x3c, 0x2e, 0x20, 0x10, 73 + 0x00, 0xf0, 0xe0, 0xd2, 0xc4, 0xb8, 0xad, 0xa5, 0x9f, 0x9b, 0x9a, 74 + 0x9b, 0x9f, 0xa5, 0xad, 0xb8, 0xc4, 0xd2, 0xe0, 0xf0, 0x00, 75 + }; 76 + 77 + static struct reg_default drv2665_reg_defs[] = { 78 + { DRV2665_STATUS, 0x02 }, 79 + { DRV2665_CTRL_1, 0x28 }, 80 + { DRV2665_CTRL_2, 0x40 }, 81 + { DRV2665_FIFO, 0x00 }, 82 + }; 83 + 84 + static void drv2665_worker(struct work_struct *work) 85 + { 86 + struct drv2665_data *haptics = 87 + container_of(work, struct drv2665_data, work); 88 + unsigned int read_buf; 89 + int error; 90 + 91 + error = regmap_read(haptics->regmap, DRV2665_STATUS, &read_buf); 92 + if (error) { 93 + dev_err(&haptics->client->dev, 94 + "Failed to read status: %d\n", error); 95 + return; 96 + } 97 + 98 + if (read_buf & DRV2665_FIFO_EMPTY) { 99 + error = regmap_bulk_write(haptics->regmap, 100 + DRV2665_FIFO, 101 + drv2665_sine_wave_form, 102 + ARRAY_SIZE(drv2665_sine_wave_form)); 103 + if (error) { 104 + dev_err(&haptics->client->dev, 105 + "Failed to write FIFO: %d\n", error); 106 + return; 107 + } 108 + } 109 + } 110 + 111 + static int drv2665_haptics_play(struct input_dev *input, void *data, 112 + struct ff_effect *effect) 113 + { 114 + struct drv2665_data *haptics = input_get_drvdata(input); 115 + 116 + schedule_work(&haptics->work); 117 + 118 + return 0; 119 + } 120 + 121 + static void drv2665_close(struct input_dev *input) 122 + { 123 + struct drv2665_data *haptics = input_get_drvdata(input); 124 + int error; 125 + 126 + cancel_work_sync(&haptics->work); 127 + 128 + error = regmap_update_bits(haptics->regmap, 129 + DRV2665_CTRL_2, DRV2665_STANDBY, 1); 130 + if (error) 131 + dev_err(&haptics->client->dev, 132 + "Failed to enter standby mode: %d\n", error); 133 + } 134 + 135 + static const struct reg_default drv2665_init_regs[] = { 136 + { DRV2665_CTRL_2, 0 | DRV2665_10_MS_IDLE_TOUT }, 137 + { DRV2665_CTRL_1, DRV2665_25_VPP_GAIN }, 138 + }; 139 + 140 + static int drv2665_init(struct drv2665_data *haptics) 141 + { 142 + int error; 143 + 144 + error = regmap_register_patch(haptics->regmap, 145 + drv2665_init_regs, 146 + ARRAY_SIZE(drv2665_init_regs)); 147 + if (error) { 148 + dev_err(&haptics->client->dev, 149 + "Failed to write init registers: %d\n", 150 + error); 151 + return error; 152 + } 153 + 154 + return 0; 155 + } 156 + 157 + static const struct regmap_config drv2665_regmap_config = { 158 + .reg_bits = 8, 159 + .val_bits = 8, 160 + 161 + .max_register = DRV2665_FIFO, 162 + .reg_defaults = drv2665_reg_defs, 163 + .num_reg_defaults = ARRAY_SIZE(drv2665_reg_defs), 164 + .cache_type = REGCACHE_NONE, 165 + }; 166 + 167 + static int drv2665_probe(struct i2c_client *client, 168 + const struct i2c_device_id *id) 169 + { 170 + struct drv2665_data *haptics; 171 + int error; 172 + 173 + haptics = devm_kzalloc(&client->dev, sizeof(*haptics), GFP_KERNEL); 174 + if (!haptics) 175 + return -ENOMEM; 176 + 177 + haptics->regulator = devm_regulator_get(&client->dev, "vbat"); 178 + if (IS_ERR(haptics->regulator)) { 179 + error = PTR_ERR(haptics->regulator); 180 + dev_err(&client->dev, 181 + "unable to get regulator, error: %d\n", error); 182 + return error; 183 + } 184 + 185 + haptics->input_dev = devm_input_allocate_device(&client->dev); 186 + if (!haptics->input_dev) { 187 + dev_err(&client->dev, "Failed to allocate input device\n"); 188 + return -ENOMEM; 189 + } 190 + 191 + haptics->input_dev->name = "drv2665:haptics"; 192 + haptics->input_dev->dev.parent = client->dev.parent; 193 + haptics->input_dev->close = drv2665_close; 194 + input_set_drvdata(haptics->input_dev, haptics); 195 + input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE); 196 + 197 + error = input_ff_create_memless(haptics->input_dev, NULL, 198 + drv2665_haptics_play); 199 + if (error) { 200 + dev_err(&client->dev, "input_ff_create() failed: %d\n", 201 + error); 202 + return error; 203 + } 204 + 205 + INIT_WORK(&haptics->work, drv2665_worker); 206 + 207 + haptics->client = client; 208 + i2c_set_clientdata(client, haptics); 209 + 210 + haptics->regmap = devm_regmap_init_i2c(client, &drv2665_regmap_config); 211 + if (IS_ERR(haptics->regmap)) { 212 + error = PTR_ERR(haptics->regmap); 213 + dev_err(&client->dev, "Failed to allocate register map: %d\n", 214 + error); 215 + return error; 216 + } 217 + 218 + error = drv2665_init(haptics); 219 + if (error) { 220 + dev_err(&client->dev, "Device init failed: %d\n", error); 221 + return error; 222 + } 223 + 224 + error = input_register_device(haptics->input_dev); 225 + if (error) { 226 + dev_err(&client->dev, "couldn't register input device: %d\n", 227 + error); 228 + return error; 229 + } 230 + 231 + return 0; 232 + } 233 + 234 + static int __maybe_unused drv2665_suspend(struct device *dev) 235 + { 236 + struct drv2665_data *haptics = dev_get_drvdata(dev); 237 + int ret = 0; 238 + 239 + mutex_lock(&haptics->input_dev->mutex); 240 + 241 + if (haptics->input_dev->users) { 242 + ret = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2, 243 + DRV2665_STANDBY, 1); 244 + if (ret) { 245 + dev_err(dev, "Failed to set standby mode\n"); 246 + regulator_disable(haptics->regulator); 247 + goto out; 248 + } 249 + 250 + ret = regulator_disable(haptics->regulator); 251 + if (ret) { 252 + dev_err(dev, "Failed to disable regulator\n"); 253 + regmap_update_bits(haptics->regmap, 254 + DRV2665_CTRL_2, 255 + DRV2665_STANDBY, 0); 256 + } 257 + } 258 + out: 259 + mutex_unlock(&haptics->input_dev->mutex); 260 + return ret; 261 + } 262 + 263 + static int __maybe_unused drv2665_resume(struct device *dev) 264 + { 265 + struct drv2665_data *haptics = dev_get_drvdata(dev); 266 + int ret = 0; 267 + 268 + mutex_lock(&haptics->input_dev->mutex); 269 + 270 + if (haptics->input_dev->users) { 271 + ret = regulator_enable(haptics->regulator); 272 + if (ret) { 273 + dev_err(dev, "Failed to enable regulator\n"); 274 + goto out; 275 + } 276 + 277 + ret = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2, 278 + DRV2665_STANDBY, 0); 279 + if (ret) { 280 + dev_err(dev, "Failed to unset standby mode\n"); 281 + regulator_disable(haptics->regulator); 282 + goto out; 283 + } 284 + 285 + } 286 + 287 + out: 288 + mutex_unlock(&haptics->input_dev->mutex); 289 + return ret; 290 + } 291 + 292 + static SIMPLE_DEV_PM_OPS(drv2665_pm_ops, drv2665_suspend, drv2665_resume); 293 + 294 + static const struct i2c_device_id drv2665_id[] = { 295 + { "drv2665", 0 }, 296 + { } 297 + }; 298 + MODULE_DEVICE_TABLE(i2c, drv2665_id); 299 + 300 + #ifdef CONFIG_OF 301 + static const struct of_device_id drv2665_of_match[] = { 302 + { .compatible = "ti,drv2665", }, 303 + { } 304 + }; 305 + MODULE_DEVICE_TABLE(of, drv2665_of_match); 306 + #endif 307 + 308 + static struct i2c_driver drv2665_driver = { 309 + .probe = drv2665_probe, 310 + .driver = { 311 + .name = "drv2665-haptics", 312 + .owner = THIS_MODULE, 313 + .of_match_table = of_match_ptr(drv2665_of_match), 314 + .pm = &drv2665_pm_ops, 315 + }, 316 + .id_table = drv2665_id, 317 + }; 318 + module_i2c_driver(drv2665_driver); 319 + 320 + MODULE_DESCRIPTION("TI DRV2665 haptics driver"); 321 + MODULE_LICENSE("GPL"); 322 + MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
+1 -6
drivers/input/misc/gpio-beeper.c
··· 66 66 { 67 67 struct gpio_beeper *beep; 68 68 struct input_dev *input; 69 - int err; 70 69 71 70 beep = devm_kzalloc(&pdev->dev, sizeof(*beep), GFP_KERNEL); 72 71 if (!beep) 73 72 return -ENOMEM; 74 73 75 - beep->desc = devm_gpiod_get(&pdev->dev, NULL); 74 + beep->desc = devm_gpiod_get(&pdev->dev, NULL, GPIOD_OUT_LOW); 76 75 if (IS_ERR(beep->desc)) 77 76 return PTR_ERR(beep->desc); 78 77 ··· 90 91 input->event = gpio_beeper_event; 91 92 92 93 input_set_capability(input, EV_SND, SND_BELL); 93 - 94 - err = gpiod_direction_output(beep->desc, 0); 95 - if (err) 96 - return err; 97 94 98 95 input_set_drvdata(input, beep); 99 96
+2 -1
drivers/input/misc/retu-pwrbutton.c
··· 63 63 input_set_drvdata(idev, rdev); 64 64 65 65 error = devm_request_threaded_irq(&pdev->dev, irq, 66 - NULL, retu_pwrbutton_irq, 0, 66 + NULL, retu_pwrbutton_irq, 67 + IRQF_ONESHOT, 67 68 "retu-pwrbutton", idev); 68 69 if (error) 69 70 return error;
-1
drivers/input/misc/soc_button_array.c
··· 18 18 #include <linux/gpio/consumer.h> 19 19 #include <linux/gpio_keys.h> 20 20 #include <linux/platform_device.h> 21 - #include <linux/acpi.h> 22 21 23 22 /* 24 23 * Definition of buttons on the tablet. The ACPI index of each button
+2 -1
drivers/input/misc/twl4030-pwrbutton.c
··· 71 71 pwr->dev.parent = &pdev->dev; 72 72 73 73 err = devm_request_threaded_irq(&pwr->dev, irq, NULL, powerbutton_irq, 74 - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 74 + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | 75 + IRQF_ONESHOT, 75 76 "twl4030_pwrbutton", pwr); 76 77 if (err < 0) { 77 78 dev_err(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
+2 -1
drivers/input/misc/twl6040-vibra.c
··· 308 308 mutex_init(&info->mutex); 309 309 310 310 error = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, 311 - twl6040_vib_irq_handler, 0, 311 + twl6040_vib_irq_handler, 312 + IRQF_ONESHOT, 312 313 "twl6040_irq_vib", info); 313 314 if (error) { 314 315 dev_err(info->dev, "VIB IRQ request failed: %d\n", error);
+2 -1
drivers/input/misc/wm831x-on.c
··· 99 99 wm831x_on->dev->dev.parent = &pdev->dev; 100 100 101 101 ret = request_threaded_irq(irq, NULL, wm831x_on_irq, 102 - IRQF_TRIGGER_RISING, "wm831x_on", 102 + IRQF_TRIGGER_RISING | IRQF_ONESHOT, 103 + "wm831x_on", 103 104 wm831x_on); 104 105 if (ret < 0) { 105 106 dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret);
+126 -118
drivers/input/mouse/alps.c
··· 159 159 160 160 static void alps_set_abs_params_st(struct alps_data *priv, 161 161 struct input_dev *dev1); 162 - static void alps_set_abs_params_mt(struct alps_data *priv, 163 - struct input_dev *dev1); 162 + static void alps_set_abs_params_semi_mt(struct alps_data *priv, 163 + struct input_dev *dev1); 164 164 static void alps_set_abs_params_v7(struct alps_data *priv, 165 165 struct input_dev *dev1); 166 166 static void alps_set_abs_params_ss4_v2(struct alps_data *priv, ··· 310 310 input_sync(dev); 311 311 } 312 312 313 - /* 314 - * Process bitmap data for V5 protocols. Return value is null. 315 - * 316 - * The bitmaps don't have enough data to track fingers, so this function 317 - * only generates points representing a bounding box of at most two contacts. 318 - * These two points are returned in fields->mt. 319 - */ 320 - static void alps_process_bitmap_dolphin(struct alps_data *priv, 321 - struct alps_fields *fields) 322 - { 323 - int box_middle_x, box_middle_y; 324 - unsigned int x_map, y_map; 325 - unsigned char start_bit, end_bit; 326 - unsigned char x_msb, x_lsb, y_msb, y_lsb; 327 - 328 - x_map = fields->x_map; 329 - y_map = fields->y_map; 330 - 331 - if (!x_map || !y_map) 332 - return; 333 - 334 - /* Get Most-significant and Least-significant bit */ 335 - x_msb = fls(x_map); 336 - x_lsb = ffs(x_map); 337 - y_msb = fls(y_map); 338 - y_lsb = ffs(y_map); 339 - 340 - /* Most-significant bit should never exceed max sensor line number */ 341 - if (x_msb > priv->x_bits || y_msb > priv->y_bits) 342 - return; 343 - 344 - if (fields->fingers > 1) { 345 - start_bit = priv->x_bits - x_msb; 346 - end_bit = priv->x_bits - x_lsb; 347 - box_middle_x = (priv->x_max * (start_bit + end_bit)) / 348 - (2 * (priv->x_bits - 1)); 349 - 350 - start_bit = y_lsb - 1; 351 - end_bit = y_msb - 1; 352 - box_middle_y = (priv->y_max * (start_bit + end_bit)) / 353 - (2 * (priv->y_bits - 1)); 354 - fields->mt[0] = fields->st; 355 - fields->mt[1].x = 2 * box_middle_x - fields->mt[0].x; 356 - fields->mt[1].y = 2 * box_middle_y - fields->mt[0].y; 357 - } 358 - } 359 - 360 313 static void alps_get_bitmap_points(unsigned int map, 361 314 struct alps_bitmap_point *low, 362 315 struct alps_bitmap_point *high, ··· 337 384 } 338 385 339 386 /* 340 - * Process bitmap data from v3 and v4 protocols. Returns the number of 387 + * Process bitmap data from semi-mt protocols. Returns the number of 341 388 * fingers detected. A return value of 0 means at least one of the 342 389 * bitmaps was empty. 343 390 * ··· 349 396 static int alps_process_bitmap(struct alps_data *priv, 350 397 struct alps_fields *fields) 351 398 { 352 - int i, fingers_x = 0, fingers_y = 0, fingers; 399 + int i, fingers_x = 0, fingers_y = 0, fingers, closest; 353 400 struct alps_bitmap_point x_low = {0,}, x_high = {0,}; 354 401 struct alps_bitmap_point y_low = {0,}, y_high = {0,}; 402 + struct input_mt_pos corner[4]; 355 403 356 404 if (!fields->x_map || !fields->y_map) 357 405 return 0; ··· 383 429 y_high.num_bits = max(i, 1); 384 430 } 385 431 386 - fields->mt[0].x = 432 + /* top-left corner */ 433 + corner[0].x = 387 434 (priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) / 388 435 (2 * (priv->x_bits - 1)); 389 - fields->mt[0].y = 436 + corner[0].y = 390 437 (priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) / 391 438 (2 * (priv->y_bits - 1)); 392 439 393 - fields->mt[1].x = 440 + /* top-right corner */ 441 + corner[1].x = 394 442 (priv->x_max * (2 * x_high.start_bit + x_high.num_bits - 1)) / 395 443 (2 * (priv->x_bits - 1)); 396 - fields->mt[1].y = 444 + corner[1].y = 445 + (priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) / 446 + (2 * (priv->y_bits - 1)); 447 + 448 + /* bottom-right corner */ 449 + corner[2].x = 450 + (priv->x_max * (2 * x_high.start_bit + x_high.num_bits - 1)) / 451 + (2 * (priv->x_bits - 1)); 452 + corner[2].y = 397 453 (priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) / 398 454 (2 * (priv->y_bits - 1)); 399 455 400 - /* y-bitmap order is reversed, except on rushmore */ 401 - if (priv->proto_version != ALPS_PROTO_V3_RUSHMORE) { 402 - fields->mt[0].y = priv->y_max - fields->mt[0].y; 403 - fields->mt[1].y = priv->y_max - fields->mt[1].y; 456 + /* bottom-left corner */ 457 + corner[3].x = 458 + (priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) / 459 + (2 * (priv->x_bits - 1)); 460 + corner[3].y = 461 + (priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) / 462 + (2 * (priv->y_bits - 1)); 463 + 464 + /* x-bitmap order is reversed on v5 touchpads */ 465 + if (priv->proto_version == ALPS_PROTO_V5) { 466 + for (i = 0; i < 4; i++) 467 + corner[i].x = priv->x_max - corner[i].x; 404 468 } 469 + 470 + /* y-bitmap order is reversed on v3 and v4 touchpads */ 471 + if (priv->proto_version == ALPS_PROTO_V3 || 472 + priv->proto_version == ALPS_PROTO_V4) { 473 + for (i = 0; i < 4; i++) 474 + corner[i].y = priv->y_max - corner[i].y; 475 + } 476 + 477 + /* 478 + * We only select a corner for the second touch once per 2 finger 479 + * touch sequence to avoid the chosen corner (and thus the coordinates) 480 + * jumping around when the first touch is in the middle. 481 + */ 482 + if (priv->second_touch == -1) { 483 + /* Find corner closest to our st coordinates */ 484 + closest = 0x7fffffff; 485 + for (i = 0; i < 4; i++) { 486 + int dx = fields->st.x - corner[i].x; 487 + int dy = fields->st.y - corner[i].y; 488 + int distance = dx * dx + dy * dy; 489 + 490 + if (distance < closest) { 491 + priv->second_touch = i; 492 + closest = distance; 493 + } 494 + } 495 + /* And select the opposite corner to use for the 2nd touch */ 496 + priv->second_touch = (priv->second_touch + 2) % 4; 497 + } 498 + 499 + fields->mt[0] = fields->st; 500 + fields->mt[1] = corner[priv->second_touch]; 405 501 406 502 return fingers; 407 503 } ··· 489 485 f->mt[0].x = f->st.x; 490 486 f->mt[0].y = f->st.y; 491 487 fingers = f->pressure > 0 ? 1 : 0; 488 + priv->second_touch = -1; 492 489 } 493 490 494 - alps_report_mt_data(psmouse, (fingers <= 2) ? fingers : 2); 491 + if (fingers >= 1) 492 + alps_set_slot(dev, 0, f->mt[0].x, f->mt[0].y); 493 + if (fingers >= 2) 494 + alps_set_slot(dev, 1, f->mt[1].x, f->mt[1].y); 495 + input_mt_sync_frame(dev); 495 496 496 497 input_mt_report_finger_count(dev, fingers); 497 498 ··· 593 584 f->first_mp = !!(p[4] & 0x40); 594 585 f->is_mp = !!(p[0] & 0x40); 595 586 596 - f->fingers = (p[5] & 0x3) + 1; 597 - f->x_map = ((p[4] & 0x7e) << 8) | 598 - ((p[1] & 0x7f) << 2) | 599 - ((p[0] & 0x30) >> 4); 600 - f->y_map = ((p[3] & 0x70) << 4) | 601 - ((p[2] & 0x7f) << 1) | 602 - (p[4] & 0x01); 587 + if (f->is_mp) { 588 + f->fingers = (p[5] & 0x3) + 1; 589 + f->x_map = ((p[4] & 0x7e) << 8) | 590 + ((p[1] & 0x7f) << 2) | 591 + ((p[0] & 0x30) >> 4); 592 + f->y_map = ((p[3] & 0x70) << 4) | 593 + ((p[2] & 0x7f) << 1) | 594 + (p[4] & 0x01); 595 + } else { 596 + f->st.x = ((p[1] & 0x7f) << 4) | ((p[4] & 0x30) >> 2) | 597 + ((p[0] & 0x30) >> 4); 598 + f->st.y = ((p[2] & 0x7f) << 4) | (p[4] & 0x0f); 599 + f->pressure = p[5] & 0x7f; 603 600 604 - f->st.x = ((p[1] & 0x7f) << 4) | ((p[4] & 0x30) >> 2) | 605 - ((p[0] & 0x30) >> 4); 606 - f->st.y = ((p[2] & 0x7f) << 4) | (p[4] & 0x0f); 607 - f->pressure = p[5] & 0x7f; 608 - 609 - alps_decode_buttons_v3(f, p); 601 + alps_decode_buttons_v3(f, p); 602 + } 610 603 611 604 return 0; 612 605 } ··· 616 605 static int alps_decode_rushmore(struct alps_fields *f, unsigned char *p, 617 606 struct psmouse *psmouse) 618 607 { 619 - alps_decode_pinnacle(f, p, psmouse); 620 - 621 - /* Rushmore's packet decode has a bit difference with Pinnacle's */ 608 + f->first_mp = !!(p[4] & 0x40); 622 609 f->is_mp = !!(p[5] & 0x40); 623 - f->fingers = max((p[5] & 0x3), ((p[5] >> 2) & 0x3)) + 1; 624 - f->x_map |= (p[5] & 0x10) << 11; 625 - f->y_map |= (p[5] & 0x20) << 6; 610 + 611 + if (f->is_mp) { 612 + f->fingers = max((p[5] & 0x3), ((p[5] >> 2) & 0x3)) + 1; 613 + f->x_map = ((p[5] & 0x10) << 11) | 614 + ((p[4] & 0x7e) << 8) | 615 + ((p[1] & 0x7f) << 2) | 616 + ((p[0] & 0x30) >> 4); 617 + f->y_map = ((p[5] & 0x20) << 6) | 618 + ((p[3] & 0x70) << 4) | 619 + ((p[2] & 0x7f) << 1) | 620 + (p[4] & 0x01); 621 + } else { 622 + f->st.x = ((p[1] & 0x7f) << 4) | ((p[4] & 0x30) >> 2) | 623 + ((p[0] & 0x30) >> 4); 624 + f->st.y = ((p[2] & 0x7f) << 4) | (p[4] & 0x0f); 625 + f->pressure = p[5] & 0x7f; 626 + 627 + alps_decode_buttons_v3(f, p); 628 + } 626 629 627 630 return 0; 628 631 } ··· 705 680 */ 706 681 if (f->is_mp) { 707 682 fingers = f->fingers; 708 - if (priv->proto_version == ALPS_PROTO_V3 || 709 - priv->proto_version == ALPS_PROTO_V3_RUSHMORE) { 710 - if (alps_process_bitmap(priv, f) == 0) 711 - fingers = 0; /* Use st data */ 712 - 713 - /* Now process position packet */ 714 - priv->decode_fields(f, priv->multi_data, 715 - psmouse); 716 - } else { 717 - /* 718 - * Because Dolphin uses position packet's 719 - * coordinate data as Pt1 and uses it to 720 - * calculate Pt2, so we need to do position 721 - * packet decode first. 722 - */ 723 - priv->decode_fields(f, priv->multi_data, 724 - psmouse); 725 - 726 - /* 727 - * Since Dolphin's finger number is reliable, 728 - * there is no need to compare with bmap_fn. 729 - */ 730 - alps_process_bitmap_dolphin(priv, f); 731 - } 683 + /* 684 + * Bitmap processing uses position packet's coordinate 685 + * data, so we need to do decode it first. 686 + */ 687 + priv->decode_fields(f, priv->multi_data, psmouse); 688 + if (alps_process_bitmap(priv, f) == 0) 689 + fingers = 0; /* Use st data */ 732 690 } else { 733 691 priv->multi_packet = 0; 734 692 } ··· 873 865 priv->multi_data[offset] = packet[6]; 874 866 priv->multi_data[offset + 1] = packet[7]; 875 867 868 + f->left = !!(packet[4] & 0x01); 869 + f->right = !!(packet[4] & 0x02); 870 + 871 + f->st.x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) | 872 + ((packet[0] & 0x30) >> 4); 873 + f->st.y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); 874 + f->pressure = packet[5] & 0x7f; 875 + 876 876 if (++priv->multi_packet > 2) { 877 877 priv->multi_packet = 0; 878 878 ··· 894 878 895 879 f->fingers = alps_process_bitmap(priv, f); 896 880 } 897 - 898 - f->left = !!(packet[4] & 0x01); 899 - f->right = !!(packet[4] & 0x02); 900 - 901 - f->st.x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) | 902 - ((packet[0] & 0x30) >> 4); 903 - f->st.y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); 904 - f->pressure = packet[5] & 0x7f; 905 881 906 882 alps_report_semi_mt_data(psmouse, f->fingers); 907 883 } ··· 2569 2561 case ALPS_PROTO_V3: 2570 2562 priv->hw_init = alps_hw_init_v3; 2571 2563 priv->process_packet = alps_process_packet_v3; 2572 - priv->set_abs_params = alps_set_abs_params_mt; 2564 + priv->set_abs_params = alps_set_abs_params_semi_mt; 2573 2565 priv->decode_fields = alps_decode_pinnacle; 2574 2566 priv->nibble_commands = alps_v3_nibble_commands; 2575 2567 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; ··· 2578 2570 case ALPS_PROTO_V3_RUSHMORE: 2579 2571 priv->hw_init = alps_hw_init_rushmore_v3; 2580 2572 priv->process_packet = alps_process_packet_v3; 2581 - priv->set_abs_params = alps_set_abs_params_mt; 2573 + priv->set_abs_params = alps_set_abs_params_semi_mt; 2582 2574 priv->decode_fields = alps_decode_rushmore; 2583 2575 priv->nibble_commands = alps_v3_nibble_commands; 2584 2576 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; ··· 2594 2586 case ALPS_PROTO_V4: 2595 2587 priv->hw_init = alps_hw_init_v4; 2596 2588 priv->process_packet = alps_process_packet_v4; 2597 - priv->set_abs_params = alps_set_abs_params_mt; 2589 + priv->set_abs_params = alps_set_abs_params_semi_mt; 2598 2590 priv->nibble_commands = alps_v4_nibble_commands; 2599 2591 priv->addr_command = PSMOUSE_CMD_DISABLE; 2600 2592 break; ··· 2603 2595 priv->hw_init = alps_hw_init_dolphin_v1; 2604 2596 priv->process_packet = alps_process_touchpad_packet_v3_v5; 2605 2597 priv->decode_fields = alps_decode_dolphin; 2606 - priv->set_abs_params = alps_set_abs_params_mt; 2598 + priv->set_abs_params = alps_set_abs_params_semi_mt; 2607 2599 priv->nibble_commands = alps_v3_nibble_commands; 2608 2600 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; 2609 2601 priv->x_bits = 23; ··· 2785 2777 set_bit(BTN_TOOL_QUADTAP, dev1->keybit); 2786 2778 } 2787 2779 2788 - static void alps_set_abs_params_mt(struct alps_data *priv, 2789 - struct input_dev *dev1) 2780 + static void alps_set_abs_params_semi_mt(struct alps_data *priv, 2781 + struct input_dev *dev1) 2790 2782 { 2791 2783 alps_set_abs_params_mt_common(priv, dev1); 2792 2784 input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); 2793 2785 2794 2786 input_mt_init_slots(dev1, MAX_TOUCHES, 2795 2787 INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED | 2796 - INPUT_MT_TRACK | INPUT_MT_SEMI_MT); 2788 + INPUT_MT_SEMI_MT); 2797 2789 } 2798 2790 2799 2791 static void alps_set_abs_params_v7(struct alps_data *priv,
+1
drivers/input/mouse/alps.h
··· 278 278 279 279 int prev_fin; 280 280 int multi_packet; 281 + int second_touch; 281 282 unsigned char multi_data[6]; 282 283 struct alps_fields f; 283 284 u8 quirks;
+1 -2
drivers/input/mouse/cyapa_gen3.c
··· 950 950 * Device power mode can only be set when device is in operational mode. 951 951 */ 952 952 static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode, 953 - u16 always_unused) 953 + u16 always_unused) 954 954 { 955 955 int ret; 956 956 u8 power; 957 957 int tries; 958 958 u16 sleep_time; 959 959 960 - always_unused = 0; 961 960 if (cyapa->state != CYAPA_STATE_OP) 962 961 return 0; 963 962
+9 -14
drivers/input/mouse/cyapa_gen5.c
··· 352 352 u8 parameter_data[0]; /* Parameter data variable based on cmd_code */ 353 353 } __packed; 354 354 355 - /* Applicaton get/set parameter command data structure */ 355 + /* Application get/set parameter command data structure */ 356 356 struct gen5_app_set_parameter_data { 357 357 u8 parameter_id; 358 358 u8 parameter_size; ··· 832 832 int ret; 833 833 834 834 /* 0x20 0x00 0xF7 is Gen5 Application HID Description Header; 835 - * 0x20 0x00 0xFF is Gen5 Booloader HID Description Header. 835 + * 0x20 0x00 0xFF is Gen5 Bootloader HID Description Header. 836 836 * 837 837 * Must read HID Description content through out, 838 838 * otherwise Gen5 trackpad cannot response next command ··· 1654 1654 * that trackpad unable to report signal to wake system up 1655 1655 * in the special situation that system is in suspending, and 1656 1656 * at the same time, user touch trackpad to wake system up. 1657 - * This function can avoid the data to be buffured when system 1658 - * is suspending which may cause interrput line unable to be 1657 + * This function can avoid the data to be buffered when system 1658 + * is suspending which may cause interrupt line unable to be 1659 1659 * asserted again. 1660 1660 */ 1661 1661 cyapa_empty_pip_output_data(cyapa, NULL, NULL, NULL); ··· 2546 2546 gen5_pip->resp_sort_func(cyapa, 2547 2547 gen5_pip->irq_cmd_buf, length))) { 2548 2548 /* 2549 - * Cover the Gen5 V1 firmware issue. 2550 - * The issue is there is no interrut will be 2551 - * asserted to notityf host to read a command 2552 - * data out when always has finger touch on 2553 - * trackpad during the command is issued to 2554 - * trackad device. 2555 - * This issue has the scenario is that, 2556 - * user always has his fingers touched on 2557 - * trackpad device when booting/rebooting 2558 - * their chrome book. 2549 + * Work around the Gen5 V1 firmware 2550 + * that does not assert interrupt signalling 2551 + * that command response is ready if user 2552 + * keeps touching the trackpad while command 2553 + * is sent to the device. 2559 2554 */ 2560 2555 length = 0; 2561 2556 if (gen5_pip->resp_len)
+4 -4
drivers/input/mouse/elan_i2c.h
··· 28 28 #define ETP_PRESSURE_OFFSET 25 29 29 30 30 /* IAP Firmware handling */ 31 - #define ETP_FW_NAME "elan_i2c.bin" 31 + #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0" 32 + #define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin" 32 33 #define ETP_IAP_START_ADDR 0x0083 33 34 #define ETP_FW_IAP_PAGE_ERR (1 << 5) 34 35 #define ETP_FW_IAP_INTF_ERR (1 << 4) 35 36 #define ETP_FW_PAGE_SIZE 64 36 - #define ETP_FW_VAILDPAGE_COUNT 768 37 37 #define ETP_FW_SIGNATURE_SIZE 6 38 - #define ETP_FW_SIGNATURE_ADDRESS 0xBFFA 39 38 40 39 struct i2c_client; 41 40 struct completion; ··· 57 58 bool max_baseliune, u8 *value); 58 59 59 60 int (*get_version)(struct i2c_client *client, bool iap, u8 *version); 60 - int (*get_sm_version)(struct i2c_client *client, u8 *version); 61 + int (*get_sm_version)(struct i2c_client *client, 62 + u8* ic_type, u8 *version); 61 63 int (*get_checksum)(struct i2c_client *client, bool iap, u16 *csum); 62 64 int (*get_product_id)(struct i2c_client *client, u8 *id); 63 65
+54 -9
drivers/input/mouse/elan_i2c_core.c
··· 4 4 * Copyright (c) 2013 ELAN Microelectronics Corp. 5 5 * 6 6 * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw> 7 - * Version: 1.5.7 7 + * Version: 1.5.9 8 8 * 9 9 * Based on cyapa driver: 10 10 * copyright (c) 2011-2012 Cypress Semiconductor, Inc. ··· 40 40 #include "elan_i2c.h" 41 41 42 42 #define DRIVER_NAME "elan_i2c" 43 - #define ELAN_DRIVER_VERSION "1.5.7" 43 + #define ELAN_DRIVER_VERSION "1.5.9" 44 44 #define ETP_MAX_PRESSURE 255 45 45 #define ETP_FWIDTH_REDUCE 90 46 46 #define ETP_FINGER_WIDTH 15 ··· 83 83 u16 fw_checksum; 84 84 int pressure_adjustment; 85 85 u8 mode; 86 + u8 ic_type; 87 + u16 fw_vaildpage_count; 88 + u16 fw_signature_address; 86 89 87 90 bool irq_wake; 88 91 ··· 93 90 u8 max_baseline; 94 91 bool baseline_ready; 95 92 }; 93 + 94 + static int elan_get_fwinfo(u8 ic_type, u16 *vaildpage_count, 95 + u16 *signature_address) 96 + { 97 + switch(ic_type) { 98 + case 0x09: 99 + *vaildpage_count = 768; 100 + break; 101 + case 0x0D: 102 + *vaildpage_count = 896; 103 + break; 104 + default: 105 + /* unknown ic type clear value */ 106 + *vaildpage_count = 0; 107 + *signature_address = 0; 108 + return -ENXIO; 109 + } 110 + 111 + *signature_address = 112 + (*vaildpage_count * ETP_FW_PAGE_SIZE) - ETP_FW_SIGNATURE_SIZE; 113 + 114 + return 0; 115 + } 96 116 97 117 static int elan_enable_power(struct elan_tp_data *data) 98 118 { ··· 247 221 if (error) 248 222 return error; 249 223 250 - error = data->ops->get_sm_version(data->client, &data->sm_version); 224 + error = data->ops->get_sm_version(data->client, &data->ic_type, 225 + &data->sm_version); 251 226 if (error) 252 227 return error; 253 228 ··· 260 233 &data->pressure_adjustment); 261 234 if (error) 262 235 return error; 236 + 237 + error = elan_get_fwinfo(data->ic_type, &data->fw_vaildpage_count, 238 + &data->fw_signature_address); 239 + if (error) { 240 + dev_err(&data->client->dev, 241 + "unknown ic type %d\n", data->ic_type); 242 + return error; 243 + } 263 244 264 245 return 0; 265 246 } ··· 353 318 iap_start_addr = get_unaligned_le16(&fw->data[ETP_IAP_START_ADDR * 2]); 354 319 355 320 boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE; 356 - for (i = boot_page_count; i < ETP_FW_VAILDPAGE_COUNT; i++) { 321 + for (i = boot_page_count; i < data->fw_vaildpage_count; i++) { 357 322 u16 checksum = 0; 358 323 const u8 *page = &fw->data[i * ETP_FW_PAGE_SIZE]; 359 324 ··· 438 403 struct i2c_client *client = to_i2c_client(dev); 439 404 struct elan_tp_data *data = i2c_get_clientdata(client); 440 405 441 - return sprintf(buf, "%d.0\n", data->product_id); 406 + return sprintf(buf, ETP_PRODUCT_ID_FORMAT_STRING "\n", 407 + data->product_id); 442 408 } 443 409 444 410 static ssize_t elan_sysfs_read_fw_ver(struct device *dev, ··· 478 442 { 479 443 struct elan_tp_data *data = dev_get_drvdata(dev); 480 444 const struct firmware *fw; 445 + char *fw_name; 481 446 int error; 482 447 const u8 *fw_signature; 483 448 static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF}; 484 449 485 - error = request_firmware(&fw, ETP_FW_NAME, dev); 450 + /* Look for a firmware with the product id appended. */ 451 + fw_name = kasprintf(GFP_KERNEL, ETP_FW_NAME, data->product_id); 452 + if (!fw_name) { 453 + dev_err(dev, "failed to allocate memory for firmware name\n"); 454 + return -ENOMEM; 455 + } 456 + 457 + dev_info(dev, "requesting fw '%s'\n", fw_name); 458 + error = request_firmware(&fw, fw_name, dev); 459 + kfree(fw_name); 486 460 if (error) { 487 - dev_err(dev, "cannot load firmware %s: %d\n", 488 - ETP_FW_NAME, error); 461 + dev_err(dev, "failed to request firmware: %d\n", error); 489 462 return error; 490 463 } 491 464 492 465 /* Firmware file must match signature data */ 493 - fw_signature = &fw->data[ETP_FW_SIGNATURE_ADDRESS]; 466 + fw_signature = &fw->data[data->fw_signature_address]; 494 467 if (memcmp(fw_signature, signature, sizeof(signature)) != 0) { 495 468 dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n", 496 469 (int)sizeof(signature), signature,
+3 -1
drivers/input/mouse/elan_i2c_i2c.c
··· 259 259 return 0; 260 260 } 261 261 262 - static int elan_i2c_get_sm_version(struct i2c_client *client, u8 *version) 262 + static int elan_i2c_get_sm_version(struct i2c_client *client, 263 + u8 *ic_type, u8 *version) 263 264 { 264 265 int error; 265 266 u8 val[3]; ··· 272 271 } 273 272 274 273 *version = val[0]; 274 + *ic_type = val[1]; 275 275 return 0; 276 276 } 277 277
+4 -2
drivers/input/mouse/elan_i2c_smbus.c
··· 165 165 return 0; 166 166 } 167 167 168 - static int elan_smbus_get_sm_version(struct i2c_client *client, u8 *version) 168 + static int elan_smbus_get_sm_version(struct i2c_client *client, 169 + u8 *ic_type, u8 *version) 169 170 { 170 171 int error; 171 172 u8 val[3]; ··· 178 177 return error; 179 178 } 180 179 181 - *version = val[0]; /* XXX Why 0 and not 2 as in IAP/FW versions? */ 180 + *version = val[0]; 181 + *ic_type = val[1]; 182 182 return 0; 183 183 } 184 184
+13
drivers/input/mouse/focaltech.c
··· 103 103 */ 104 104 struct focaltech_finger_state fingers[FOC_MAX_FINGERS]; 105 105 106 + /* 107 + * Finger width 0-7 and 15 for a very big contact area. 108 + * 15 value stays until the finger is released. 109 + * Width is reported only in absolute packets. 110 + * Since hardware reports width only for last touching finger, 111 + * there is no need to store width for every specific finger, 112 + * so we keep only last value reported. 113 + */ 114 + unsigned int width; 115 + 106 116 /* True if the clickpad has been pressed. */ 107 117 bool pressed; 108 118 }; ··· 147 137 input_report_abs(dev, ABS_MT_POSITION_X, clamped_x); 148 138 input_report_abs(dev, ABS_MT_POSITION_Y, 149 139 priv->y_max - clamped_y); 140 + input_report_abs(dev, ABS_TOOL_WIDTH, state->width); 150 141 } 151 142 } 152 143 input_mt_report_pointer_emulation(dev, true); ··· 198 187 199 188 state->fingers[finger].x = ((packet[1] & 0xf) << 8) | packet[2]; 200 189 state->fingers[finger].y = (packet[3] << 8) | packet[4]; 190 + state->width = packet[5] >> 4; 201 191 state->fingers[finger].valid = true; 202 192 } 203 193 ··· 343 331 __set_bit(EV_ABS, dev->evbit); 344 332 input_set_abs_params(dev, ABS_MT_POSITION_X, 0, priv->x_max, 0, 0); 345 333 input_set_abs_params(dev, ABS_MT_POSITION_Y, 0, priv->y_max, 0, 0); 334 + input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); 346 335 input_mt_init_slots(dev, 5, INPUT_MT_POINTER); 347 336 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 348 337 }
+1 -1
drivers/input/mouse/psmouse-base.c
··· 63 63 module_param_named(rate, psmouse_rate, uint, 0644); 64 64 MODULE_PARM_DESC(rate, "Report rate, in reports per second."); 65 65 66 - static bool psmouse_smartscroll = 1; 66 + static bool psmouse_smartscroll = true; 67 67 module_param_named(smartscroll, psmouse_smartscroll, bool, 0644); 68 68 MODULE_PARM_DESC(smartscroll, "Logitech Smartscroll autorepeat, 1 = enabled (default), 0 = disabled."); 69 69
+2 -2
drivers/input/mouse/sentelic.h
··· 123 123 extern int fsp_detect(struct psmouse *psmouse, bool set_properties); 124 124 extern int fsp_init(struct psmouse *psmouse); 125 125 #else 126 - inline int fsp_detect(struct psmouse *psmouse, bool set_properties) 126 + static inline int fsp_detect(struct psmouse *psmouse, bool set_properties) 127 127 { 128 128 return -ENOSYS; 129 129 } 130 - inline int fsp_init(struct psmouse *psmouse) 130 + static inline int fsp_init(struct psmouse *psmouse) 131 131 { 132 132 return -ENOSYS; 133 133 }
+3 -3
drivers/input/mouse/synaptics_i2c.c
··· 185 185 #define NO_DATA_SLEEP_MSECS (MSEC_PER_SEC / 4) 186 186 187 187 /* Control touchpad's No Deceleration option */ 188 - static bool no_decel = 1; 188 + static bool no_decel = true; 189 189 module_param(no_decel, bool, 0644); 190 190 MODULE_PARM_DESC(no_decel, "No Deceleration. Default = 1 (on)"); 191 191 ··· 340 340 s32 data; 341 341 s8 x_delta, y_delta; 342 342 343 - /* Deal with spontanious resets and errors */ 343 + /* Deal with spontaneous resets and errors */ 344 344 if (synaptics_i2c_check_error(touch->client)) 345 - return 0; 345 + return false; 346 346 347 347 /* Get Gesture Bit */ 348 348 data = synaptics_i2c_reg_get(touch->client, DATA_REG0);
+1
drivers/input/touchscreen/Kconfig
··· 958 958 config TOUCHSCREEN_STMPE 959 959 tristate "STMicroelectronics STMPE touchscreens" 960 960 depends on MFD_STMPE 961 + depends on (OF || COMPILE_TEST) 961 962 help 962 963 Say Y here if you want support for STMicroelectronics 963 964 STMPE touchscreen controllers.
+4 -4
drivers/input/touchscreen/atmel_mxt_ts.c
··· 726 726 { 727 727 struct input_dev *input = data->input_dev; 728 728 const struct mxt_platform_data *pdata = data->pdata; 729 - bool button; 730 729 int i; 731 730 732 - /* Active-low switch */ 733 731 for (i = 0; i < pdata->t19_num_keys; i++) { 734 732 if (pdata->t19_keymap[i] == KEY_RESERVED) 735 733 continue; 736 - button = !(message[1] & (1 << i)); 737 - input_report_key(input, pdata->t19_keymap[i], button); 734 + 735 + /* Active-low switch */ 736 + input_report_key(input, pdata->t19_keymap[i], 737 + !(message[1] & BIT(i))); 738 738 } 739 739 } 740 740
+1 -4
drivers/input/touchscreen/cyttsp4_core.c
··· 775 775 struct device *dev = &md->input->dev; 776 776 struct cyttsp4_sysinfo *si = md->si; 777 777 enum cyttsp4_tch_abs abs; 778 - int tmp; 779 778 bool flipped; 780 779 781 780 for (abs = CY_TCH_X; abs < CY_TCH_NUM_ABS; abs++) { ··· 789 790 } 790 791 791 792 if (md->pdata->flags & CY_FLAG_FLIP) { 792 - tmp = touch->abs[CY_TCH_X]; 793 - touch->abs[CY_TCH_X] = touch->abs[CY_TCH_Y]; 794 - touch->abs[CY_TCH_Y] = tmp; 793 + swap(touch->abs[CY_TCH_X], touch->abs[CY_TCH_Y]); 795 794 flipped = true; 796 795 } else 797 796 flipped = false;
+33 -25
drivers/input/touchscreen/goodix.c
··· 47 47 /* Register defines */ 48 48 #define GOODIX_READ_COOR_ADDR 0x814E 49 49 #define GOODIX_REG_CONFIG_DATA 0x8047 50 - #define GOODIX_REG_VERSION 0x8140 50 + #define GOODIX_REG_ID 0x8140 51 51 52 52 #define RESOLUTION_LOC 1 53 53 #define MAX_CONTACTS_LOC 5 ··· 69 69 * @len: length of the buffer to write 70 70 */ 71 71 static int goodix_i2c_read(struct i2c_client *client, 72 - u16 reg, u8 *buf, int len) 72 + u16 reg, u8 *buf, int len) 73 73 { 74 74 struct i2c_msg msgs[2]; 75 75 u16 wbuf = cpu_to_be16(reg); ··· 78 78 msgs[0].flags = 0; 79 79 msgs[0].addr = client->addr; 80 80 msgs[0].len = 2; 81 - msgs[0].buf = (u8 *) &wbuf; 81 + msgs[0].buf = (u8 *)&wbuf; 82 82 83 83 msgs[1].flags = I2C_M_RD; 84 84 msgs[1].addr = client->addr; ··· 100 100 dev_err(&ts->client->dev, "I2C transfer error: %d\n", error); 101 101 return error; 102 102 } 103 + 104 + if (!(data[0] & 0x80)) 105 + return -EAGAIN; 103 106 104 107 touch_num = data[0] & 0x0f; 105 108 if (touch_num > ts->max_touch_num) ··· 147 144 */ 148 145 static void goodix_process_events(struct goodix_ts_data *ts) 149 146 { 150 - u8 point_data[1 + GOODIX_CONTACT_SIZE * ts->max_touch_num]; 147 + u8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS]; 151 148 int touch_num; 152 149 int i; 153 150 ··· 199 196 int error; 200 197 201 198 error = goodix_i2c_read(ts->client, GOODIX_REG_CONFIG_DATA, 202 - config, 203 - GOODIX_CONFIG_MAX_LENGTH); 199 + config, 200 + GOODIX_CONFIG_MAX_LENGTH); 204 201 if (error) { 205 202 dev_warn(&ts->client->dev, 206 203 "Error reading config (%d), using defaults\n", ··· 230 227 * 231 228 * @client: the i2c client 232 229 * @version: output buffer containing the version on success 230 + * @id: output buffer containing the id on success 233 231 */ 234 - static int goodix_read_version(struct i2c_client *client, u16 *version) 232 + static int goodix_read_version(struct i2c_client *client, u16 *version, u16 *id) 235 233 { 236 234 int error; 237 235 u8 buf[6]; 236 + char id_str[5]; 238 237 239 - error = goodix_i2c_read(client, GOODIX_REG_VERSION, buf, sizeof(buf)); 238 + error = goodix_i2c_read(client, GOODIX_REG_ID, buf, sizeof(buf)); 240 239 if (error) { 241 240 dev_err(&client->dev, "read version failed: %d\n", error); 242 241 return error; 243 242 } 244 243 245 - if (version) 246 - *version = get_unaligned_le16(&buf[4]); 244 + memcpy(id_str, buf, 4); 245 + id_str[4] = 0; 246 + if (kstrtou16(id_str, 10, id)) 247 + *id = 0x1001; 247 248 248 - dev_info(&client->dev, "IC VERSION: %6ph\n", buf); 249 + *version = get_unaligned_le16(&buf[4]); 250 + 251 + dev_info(&client->dev, "ID %d, version: %04x\n", *id, *version); 249 252 250 253 return 0; 251 254 } ··· 285 276 * goodix_request_input_dev - Allocate, populate and register the input device 286 277 * 287 278 * @ts: our goodix_ts_data pointer 279 + * @version: device firmware version 280 + * @id: device ID 288 281 * 289 282 * Must be called during probe 290 283 */ 291 - static int goodix_request_input_dev(struct goodix_ts_data *ts) 284 + static int goodix_request_input_dev(struct goodix_ts_data *ts, u16 version, 285 + u16 id) 292 286 { 293 287 int error; 294 288 ··· 301 289 return -ENOMEM; 302 290 } 303 291 304 - ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | 305 - BIT_MASK(EV_KEY) | 306 - BIT_MASK(EV_ABS); 307 - 308 - input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, 309 - ts->abs_x_max, 0, 0); 310 - input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, 311 - ts->abs_y_max, 0, 0); 292 + input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 293 + 0, ts->abs_x_max, 0, 0); 294 + input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 295 + 0, ts->abs_y_max, 0, 0); 312 296 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); 313 297 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 314 298 ··· 315 307 ts->input_dev->phys = "input/ts"; 316 308 ts->input_dev->id.bustype = BUS_I2C; 317 309 ts->input_dev->id.vendor = 0x0416; 318 - ts->input_dev->id.product = 0x1001; 319 - ts->input_dev->id.version = 10427; 310 + ts->input_dev->id.product = id; 311 + ts->input_dev->id.version = version; 320 312 321 313 error = input_register_device(ts->input_dev); 322 314 if (error) { ··· 334 326 struct goodix_ts_data *ts; 335 327 unsigned long irq_flags; 336 328 int error; 337 - u16 version_info; 329 + u16 version_info, id_info; 338 330 339 331 dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr); 340 332 ··· 356 348 return error; 357 349 } 358 350 359 - error = goodix_read_version(client, &version_info); 351 + error = goodix_read_version(client, &version_info, &id_info); 360 352 if (error) { 361 353 dev_err(&client->dev, "Read version failed.\n"); 362 354 return error; ··· 364 356 365 357 goodix_read_config(ts); 366 358 367 - error = goodix_request_input_dev(ts); 359 + error = goodix_request_input_dev(ts, version_info, id_info); 368 360 if (error) 369 361 return error; 370 362
+1 -1
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 78 78 } 79 79 80 80 ret = i2c_master_recv(tsdata->client, rdbuf, readsize); 81 - if (ret != sizeof(rdbuf)) { 81 + if (ret != readsize) { 82 82 dev_err(&tsdata->client->dev, 83 83 "%s: i2c_master_recv failed(), ret=%d\n", 84 84 __func__, ret);
+1 -1
drivers/input/touchscreen/s3c2410_ts.c
··· 411 411 }; 412 412 #endif 413 413 414 - static struct platform_device_id s3cts_driver_ids[] = { 414 + static const struct platform_device_id s3cts_driver_ids[] = { 415 415 { "s3c2410-ts", 0 }, 416 416 { "s3c2440-ts", 0 }, 417 417 { "s3c64xx-ts", FEAT_PEN_IRQ },
+13 -24
drivers/input/touchscreen/stmpe-ts.c
··· 267 267 static void stmpe_ts_get_platform_info(struct platform_device *pdev, 268 268 struct stmpe_touch *ts) 269 269 { 270 - struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 271 270 struct device_node *np = pdev->dev.of_node; 272 - struct stmpe_ts_platform_data *ts_pdata = NULL; 271 + u32 val; 273 272 274 - ts->stmpe = stmpe; 275 - 276 - if (stmpe->pdata && stmpe->pdata->ts) { 277 - ts_pdata = stmpe->pdata->ts; 278 - 279 - ts->sample_time = ts_pdata->sample_time; 280 - ts->mod_12b = ts_pdata->mod_12b; 281 - ts->ref_sel = ts_pdata->ref_sel; 282 - ts->adc_freq = ts_pdata->adc_freq; 283 - ts->ave_ctrl = ts_pdata->ave_ctrl; 284 - ts->touch_det_delay = ts_pdata->touch_det_delay; 285 - ts->settling = ts_pdata->settling; 286 - ts->fraction_z = ts_pdata->fraction_z; 287 - ts->i_drive = ts_pdata->i_drive; 288 - } else if (np) { 289 - u32 val; 290 - 273 + if (np) { 291 274 if (!of_property_read_u32(np, "st,sample-time", &val)) 292 275 ts->sample_time = val; 293 276 if (!of_property_read_u32(np, "st,mod-12b", &val)) ··· 294 311 295 312 static int stmpe_input_probe(struct platform_device *pdev) 296 313 { 314 + struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 297 315 struct stmpe_touch *ts; 298 316 struct input_dev *idev; 299 317 int error; ··· 313 329 return -ENOMEM; 314 330 315 331 platform_set_drvdata(pdev, ts); 332 + ts->stmpe = stmpe; 316 333 ts->idev = idev; 317 334 ts->dev = &pdev->dev; 318 335 ··· 336 351 idev->name = STMPE_TS_NAME; 337 352 idev->phys = STMPE_TS_NAME"/input0"; 338 353 idev->id.bustype = BUS_I2C; 339 - idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 340 - idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 341 354 342 355 idev->open = stmpe_ts_open; 343 356 idev->close = stmpe_ts_close; 344 357 345 358 input_set_drvdata(idev, ts); 346 359 360 + input_set_capability(idev, EV_KEY, BTN_TOUCH); 347 361 input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0); 348 362 input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0); 349 363 input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0); ··· 367 383 368 384 static struct platform_driver stmpe_ts_driver = { 369 385 .driver = { 370 - .name = STMPE_TS_NAME, 371 - }, 386 + .name = STMPE_TS_NAME, 387 + }, 372 388 .probe = stmpe_input_probe, 373 389 .remove = stmpe_ts_remove, 374 390 }; 375 391 module_platform_driver(stmpe_ts_driver); 376 392 393 + static const struct of_device_id stmpe_ts_ids[] = { 394 + { .compatible = "st,stmpe-ts", }, 395 + { }, 396 + }; 397 + MODULE_DEVICE_TABLE(of, stmpe_ts_ids); 398 + 377 399 MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>"); 378 400 MODULE_DESCRIPTION("STMPEXXX touchscreen driver"); 379 401 MODULE_LICENSE("GPL"); 380 - MODULE_ALIAS("platform:" STMPE_TS_NAME);
-1
drivers/input/touchscreen/zforce_ts.c
··· 30 30 #include <linux/input/mt.h> 31 31 #include <linux/platform_data/zforce_ts.h> 32 32 #include <linux/regulator/consumer.h> 33 - #include <linux/delay.h> 34 33 #include <linux/of.h> 35 34 #include <linux/of_gpio.h> 36 35
-3
drivers/leds/Kconfig
··· 11 11 Say Y to enable Linux LED support. This allows control of supported 12 12 LEDs from both userspace and optionally, by kernel events (triggers). 13 13 14 - This is not related to standard keyboard LEDs which are controlled 15 - via the input system. 16 - 17 14 if NEW_LEDS 18 15 19 16 config LEDS_CLASS
+1 -18
drivers/tty/sysrq.c
··· 55 55 static int __read_mostly sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE; 56 56 static bool __read_mostly sysrq_always_enabled; 57 57 58 - unsigned short platform_sysrq_reset_seq[] __weak = { KEY_RESERVED }; 59 - int sysrq_reset_downtime_ms __weak; 60 - 61 58 static bool sysrq_on(void) 62 59 { 63 60 return sysrq_enabled || sysrq_always_enabled; ··· 566 569 EXPORT_SYMBOL(handle_sysrq); 567 570 568 571 #ifdef CONFIG_INPUT 572 + static int sysrq_reset_downtime_ms; 569 573 570 574 /* Simple translation table for the SysRq keys */ 571 575 static const unsigned char sysrq_xlate[KEY_CNT] = ··· 947 949 948 950 static inline void sysrq_register_handler(void) 949 951 { 950 - unsigned short key; 951 952 int error; 952 - int i; 953 953 954 - /* First check if a __weak interface was instantiated. */ 955 - for (i = 0; i < ARRAY_SIZE(sysrq_reset_seq); i++) { 956 - key = platform_sysrq_reset_seq[i]; 957 - if (key == KEY_RESERVED || key > KEY_MAX) 958 - break; 959 - 960 - sysrq_reset_seq[sysrq_reset_seq_len++] = key; 961 - } 962 - 963 - /* 964 - * DT configuration takes precedence over anything that would 965 - * have been defined via the __weak interface. 966 - */ 967 954 sysrq_of_get_keyreset_config(); 968 955 969 956 error = input_register_handler(&sysrq_handler);
+130 -26
drivers/tty/vt/keyboard.c
··· 33 33 #include <linux/string.h> 34 34 #include <linux/init.h> 35 35 #include <linux/slab.h> 36 + #include <linux/leds.h> 36 37 37 38 #include <linux/kbd_kern.h> 38 39 #include <linux/kbd_diacr.h> ··· 130 129 131 130 static int shift_state = 0; 132 131 133 - static unsigned char ledstate = 0xff; /* undefined */ 132 + static unsigned int ledstate = -1U; /* undefined */ 134 133 static unsigned char ledioctl; 135 134 136 135 /* ··· 962 961 } 963 962 } 964 963 964 + #if IS_ENABLED(CONFIG_INPUT_LEDS) && IS_ENABLED(CONFIG_LEDS_TRIGGERS) 965 + 966 + struct kbd_led_trigger { 967 + struct led_trigger trigger; 968 + unsigned int mask; 969 + }; 970 + 971 + static void kbd_led_trigger_activate(struct led_classdev *cdev) 972 + { 973 + struct kbd_led_trigger *trigger = 974 + container_of(cdev->trigger, struct kbd_led_trigger, trigger); 975 + 976 + tasklet_disable(&keyboard_tasklet); 977 + if (ledstate != -1U) 978 + led_trigger_event(&trigger->trigger, 979 + ledstate & trigger->mask ? 980 + LED_FULL : LED_OFF); 981 + tasklet_enable(&keyboard_tasklet); 982 + } 983 + 984 + #define KBD_LED_TRIGGER(_led_bit, _name) { \ 985 + .trigger = { \ 986 + .name = _name, \ 987 + .activate = kbd_led_trigger_activate, \ 988 + }, \ 989 + .mask = BIT(_led_bit), \ 990 + } 991 + 992 + #define KBD_LOCKSTATE_TRIGGER(_led_bit, _name) \ 993 + KBD_LED_TRIGGER((_led_bit) + 8, _name) 994 + 995 + static struct kbd_led_trigger kbd_led_triggers[] = { 996 + KBD_LED_TRIGGER(VC_SCROLLOCK, "kbd-scrollock"), 997 + KBD_LED_TRIGGER(VC_NUMLOCK, "kbd-numlock"), 998 + KBD_LED_TRIGGER(VC_CAPSLOCK, "kbd-capslock"), 999 + KBD_LED_TRIGGER(VC_KANALOCK, "kbd-kanalock"), 1000 + 1001 + KBD_LOCKSTATE_TRIGGER(VC_SHIFTLOCK, "kbd-shiftlock"), 1002 + KBD_LOCKSTATE_TRIGGER(VC_ALTGRLOCK, "kbd-altgrlock"), 1003 + KBD_LOCKSTATE_TRIGGER(VC_CTRLLOCK, "kbd-ctrllock"), 1004 + KBD_LOCKSTATE_TRIGGER(VC_ALTLOCK, "kbd-altlock"), 1005 + KBD_LOCKSTATE_TRIGGER(VC_SHIFTLLOCK, "kbd-shiftllock"), 1006 + KBD_LOCKSTATE_TRIGGER(VC_SHIFTRLOCK, "kbd-shiftrlock"), 1007 + KBD_LOCKSTATE_TRIGGER(VC_CTRLLLOCK, "kbd-ctrlllock"), 1008 + KBD_LOCKSTATE_TRIGGER(VC_CTRLRLOCK, "kbd-ctrlrlock"), 1009 + }; 1010 + 1011 + static void kbd_propagate_led_state(unsigned int old_state, 1012 + unsigned int new_state) 1013 + { 1014 + struct kbd_led_trigger *trigger; 1015 + unsigned int changed = old_state ^ new_state; 1016 + int i; 1017 + 1018 + for (i = 0; i < ARRAY_SIZE(kbd_led_triggers); i++) { 1019 + trigger = &kbd_led_triggers[i]; 1020 + 1021 + if (changed & trigger->mask) 1022 + led_trigger_event(&trigger->trigger, 1023 + new_state & trigger->mask ? 1024 + LED_FULL : LED_OFF); 1025 + } 1026 + } 1027 + 1028 + static int kbd_update_leds_helper(struct input_handle *handle, void *data) 1029 + { 1030 + unsigned int led_state = *(unsigned int *)data; 1031 + 1032 + if (test_bit(EV_LED, handle->dev->evbit)) 1033 + kbd_propagate_led_state(~led_state, led_state); 1034 + 1035 + return 0; 1036 + } 1037 + 1038 + static void kbd_init_leds(void) 1039 + { 1040 + int error; 1041 + int i; 1042 + 1043 + for (i = 0; i < ARRAY_SIZE(kbd_led_triggers); i++) { 1044 + error = led_trigger_register(&kbd_led_triggers[i].trigger); 1045 + if (error) 1046 + pr_err("error %d while registering trigger %s\n", 1047 + error, kbd_led_triggers[i].trigger.name); 1048 + } 1049 + } 1050 + 1051 + #else 1052 + 1053 + static int kbd_update_leds_helper(struct input_handle *handle, void *data) 1054 + { 1055 + unsigned int leds = *(unsigned int *)data; 1056 + 1057 + if (test_bit(EV_LED, handle->dev->evbit)) { 1058 + input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01)); 1059 + input_inject_event(handle, EV_LED, LED_NUML, !!(leds & 0x02)); 1060 + input_inject_event(handle, EV_LED, LED_CAPSL, !!(leds & 0x04)); 1061 + input_inject_event(handle, EV_SYN, SYN_REPORT, 0); 1062 + } 1063 + 1064 + return 0; 1065 + } 1066 + 1067 + static void kbd_propagate_led_state(unsigned int old_state, 1068 + unsigned int new_state) 1069 + { 1070 + input_handler_for_each_handle(&kbd_handler, &new_state, 1071 + kbd_update_leds_helper); 1072 + } 1073 + 1074 + static void kbd_init_leds(void) 1075 + { 1076 + } 1077 + 1078 + #endif 1079 + 965 1080 /* 966 1081 * The leds display either (i) the status of NumLock, CapsLock, ScrollLock, 967 1082 * or (ii) whatever pattern of lights people want to show using KDSETLED, ··· 1085 968 */ 1086 969 static unsigned char getledstate(void) 1087 970 { 1088 - return ledstate; 971 + return ledstate & 0xff; 1089 972 } 1090 973 1091 974 void setledstate(struct kbd_struct *kb, unsigned int led) ··· 1110 993 return ledioctl; 1111 994 1112 995 return kb->ledflagstate; 1113 - } 1114 - 1115 - static int kbd_update_leds_helper(struct input_handle *handle, void *data) 1116 - { 1117 - unsigned char leds = *(unsigned char *)data; 1118 - 1119 - if (test_bit(EV_LED, handle->dev->evbit)) { 1120 - input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01)); 1121 - input_inject_event(handle, EV_LED, LED_NUML, !!(leds & 0x02)); 1122 - input_inject_event(handle, EV_LED, LED_CAPSL, !!(leds & 0x04)); 1123 - input_inject_event(handle, EV_SYN, SYN_REPORT, 0); 1124 - } 1125 - 1126 - return 0; 1127 996 } 1128 997 1129 998 /** ··· 1188 1085 } 1189 1086 1190 1087 /* 1191 - * This is the tasklet that updates LED state on all keyboards 1192 - * attached to the box. The reason we use tasklet is that we 1193 - * need to handle the scenario when keyboard handler is not 1194 - * registered yet but we already getting updates from the VT to 1195 - * update led state. 1088 + * This is the tasklet that updates LED state of LEDs using standard 1089 + * keyboard triggers. The reason we use tasklet is that we need to 1090 + * handle the scenario when keyboard handler is not registered yet 1091 + * but we already getting updates from the VT to update led state. 1196 1092 */ 1197 1093 static void kbd_bh(unsigned long dummy) 1198 1094 { 1199 - unsigned char leds; 1095 + unsigned int leds; 1200 1096 unsigned long flags; 1201 - 1097 + 1202 1098 spin_lock_irqsave(&led_lock, flags); 1203 1099 leds = getleds(); 1100 + leds |= (unsigned int)kbd->lockstate << 8; 1204 1101 spin_unlock_irqrestore(&led_lock, flags); 1205 1102 1206 1103 if (leds != ledstate) { 1207 - input_handler_for_each_handle(&kbd_handler, &leds, 1208 - kbd_update_leds_helper); 1104 + kbd_propagate_led_state(ledstate, leds); 1209 1105 ledstate = leds; 1210 1106 } 1211 1107 } ··· 1552 1450 { 1553 1451 tasklet_disable(&keyboard_tasklet); 1554 1452 1555 - if (ledstate != 0xff) 1453 + if (ledstate != -1U) 1556 1454 kbd_update_leds_helper(handle, &ledstate); 1557 1455 1558 1456 tasklet_enable(&keyboard_tasklet); ··· 1598 1496 kbd_table[i].modeflags = KBD_DEFMODE; 1599 1497 kbd_table[i].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE; 1600 1498 } 1499 + 1500 + kbd_init_leds(); 1601 1501 1602 1502 error = input_register_handler(&kbd_handler); 1603 1503 if (error)
+1
include/linux/mfd/da9063/pdata.h
··· 103 103 struct da9063_pdata { 104 104 int (*init)(struct da9063 *da9063); 105 105 int irq_base; 106 + bool key_power; 106 107 unsigned flags; 107 108 struct da9063_regulators_pdata *regulators_pdata; 108 109 struct led_platform_data *leds_pdata;
-44
include/linux/mfd/stmpe.h
··· 118 118 #define STMPE_GPIO_NOREQ_811_TOUCH (0xf0) 119 119 120 120 /** 121 - * struct stmpe_ts_platform_data - stmpe811 touch screen controller platform 122 - * data 123 - * @sample_time: ADC converstion time in number of clock. 124 - * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks, 125 - * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks), 126 - * recommended is 4. 127 - * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC) 128 - * @ref_sel: ADC reference source 129 - * (0 -> internal reference, 1 -> external reference) 130 - * @adc_freq: ADC Clock speed 131 - * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz) 132 - * @ave_ctrl: Sample average control 133 - * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples) 134 - * @touch_det_delay: Touch detect interrupt delay 135 - * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us, 136 - * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) 137 - * recommended is 3 138 - * @settling: Panel driver settling time 139 - * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms, 140 - * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) 141 - * recommended is 2 142 - * @fraction_z: Length of the fractional part in z 143 - * (fraction_z ([0..7]) = Count of the fractional part) 144 - * recommended is 7 145 - * @i_drive: current limit value of the touchscreen drivers 146 - * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max) 147 - * 148 - * */ 149 - struct stmpe_ts_platform_data { 150 - u8 sample_time; 151 - u8 mod_12b; 152 - u8 ref_sel; 153 - u8 adc_freq; 154 - u8 ave_ctrl; 155 - u8 touch_det_delay; 156 - u8 settling; 157 - u8 fraction_z; 158 - u8 i_drive; 159 - }; 160 - 161 - /** 162 121 * struct stmpe_platform_data - STMPE platform data 163 122 * @id: device id to distinguish between multiple STMPEs on the same board 164 123 * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*) ··· 127 168 * @irq_over_gpio: true if gpio is used to get irq 128 169 * @irq_gpio: gpio number over which irq will be requested (significant only if 129 170 * irq_over_gpio is true) 130 - * @ts: touchscreen-specific platform data 131 171 */ 132 172 struct stmpe_platform_data { 133 173 int id; ··· 136 178 bool irq_over_gpio; 137 179 int irq_gpio; 138 180 int autosleep_timeout; 139 - 140 - struct stmpe_ts_platform_data *ts; 141 181 }; 142 182 143 183 #endif
+1 -1
include/linux/platform_data/keyboard-spear.h
··· 1 1 /* 2 2 * Copyright (C) 2010 ST Microelectronics 3 - * Rajeev Kumar<rajeev-dlh.kumar@st.com> 3 + * Rajeev Kumar <rajeevkumar.linux@gmail.com> 4 4 * 5 5 * This file is licensed under the terms of the GNU General Public 6 6 * License version 2. This program is licensed "as is" without any