diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-17 17:34:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-17 17:34:33 -0700 |
commit | dcc4c2f61cdc7e0ab61b25b8d28205302497a8c4 (patch) | |
tree | 240ec9f0352d35e78936eb95b61399a71440b68b /drivers | |
parent | 0b86c75db6e7f68c22ac5d0dae0f551c4897cdf5 (diff) | |
parent | 66bc5ba5236519297d4ba2b52cdb6fc003a897d3 (diff) | |
download | linux-dcc4c2f61cdc7e0ab61b25b8d28205302497a8c4.tar.bz2 |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID updates from Jiri Kosina:
"No biggies this time:
- micro-optimization of implement() in HID core parses, from Dmitry
Torokhov
- thingm driver cleanups from Heiner Kallweit
- fine-graining detection of distance and tilt axes in wacom driver
from Jason Gerecke
- New hid-asus driver, currently supporting X205TA and VivoBook
E200HA, from Yusuke Fujimaki"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid:
HID: wacom: Add fuzz factor to distance and tilt axes
HID: usbhid: quirks for Corsair RGB keyboard & mice (K70R, K95RGB, M65RGB, K70RGB, K65RGB)
HID: thingm: remove not needed error message
HID: thingm: set new flag LED_HW_PLUGGABLE
HID: thingm: factor out duplicated code to thingm_init_led
HID: simplify implement() a bit
HID: asus: add support for VivoBook E200HA
HID: hidraw: silence an uninitialized variable warning
HID: roccat: silence an uninitialized variable warning
HID: Asus X205TA keyboard driver
HID: hidraw: switch to using memdup_user
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/Kconfig | 10 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/hid-asus.c | 52 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 34 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 8 | ||||
-rw-r--r-- | drivers/hid/hid-roccat.c | 5 | ||||
-rw-r--r-- | drivers/hid/hid-thingm.c | 49 | ||||
-rw-r--r-- | drivers/hid/hidraw.c | 18 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-quirks.c | 5 | ||||
-rw-r--r-- | drivers/hid/wacom_sys.c | 3 | ||||
-rw-r--r-- | drivers/hid/wacom_wac.c | 13 | ||||
-rw-r--r-- | drivers/hid/wacom_wac.h | 1 |
12 files changed, 126 insertions, 73 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 411722570035..5646ca4b95de 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -134,6 +134,16 @@ config HID_APPLEIR Say Y here if you want support for Apple infrared remote control. +config HID_ASUS + tristate "Asus" + depends on I2C_HID + ---help--- + Support for Asus notebook built-in keyboard via i2c. + + Supported devices: + - EeeBook X205TA + - VivoBook E200HA + config HID_AUREAL tristate "Aureal" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index be56ab6f75a8..a2fb562de748 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o +obj-$(CONFIG_HID_ASUS) += hid-asus.o obj-$(CONFIG_HID_AUREAL) += hid-aureal.o obj-$(CONFIG_HID_BELKIN) += hid-belkin.o obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c new file mode 100644 index 000000000000..7a811ec4f2e1 --- /dev/null +++ b/drivers/hid/hid-asus.c @@ -0,0 +1,52 @@ +/* + * HID driver for Asus notebook built-in keyboard. + * Fixes small logical maximum to match usage maximum. + * + * Currently supported devices are: + * EeeBook X205TA + * VivoBook E200HA + * + * Copyright (c) 2016 Yusuke Fujimaki <usk.fujimaki@gmail.com> + * + * This module based on hid-ortek by + * Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com> + * Copyright (c) 2011 Jiri Kosina + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <linux/device.h> +#include <linux/hid.h> +#include <linux/module.h> + +#include "hid-ids.h" + +static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x65) { + hid_info(hdev, "Fixing up Asus notebook report descriptor\n"); + rdesc[55] = 0xdd; + } + return rdesc; +} + +static const struct hid_device_id asus_devices[] = { + { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) }, + { } +}; +MODULE_DEVICE_TABLE(hid, asus_devices); + +static struct hid_driver asus_driver = { + .name = "asus", + .id_table = asus_devices, + .report_fixup = asus_report_fixup +}; +module_hid_driver(asus_driver); + +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 4f9c5c6deaed..8ea3a26360e9 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1129,49 +1129,46 @@ EXPORT_SYMBOL_GPL(hid_field_extract); static void __implement(u8 *report, unsigned offset, int n, u32 value) { unsigned int idx = offset / 8; - unsigned int size = offset + n; unsigned int bit_shift = offset % 8; int bits_to_set = 8 - bit_shift; - u8 bit_mask = 0xff << bit_shift; while (n - bits_to_set >= 0) { - report[idx] &= ~bit_mask; + report[idx] &= ~(0xff << bit_shift); report[idx] |= value << bit_shift; value >>= bits_to_set; n -= bits_to_set; bits_to_set = 8; - bit_mask = 0xff; bit_shift = 0; idx++; } /* last nibble */ if (n) { - if (size % 8) - bit_mask &= (1U << (size % 8)) - 1; - report[idx] &= ~bit_mask; - report[idx] |= (value << bit_shift) & bit_mask; + u8 bit_mask = ((1U << n) - 1); + report[idx] &= ~(bit_mask << bit_shift); + report[idx] |= value << bit_shift; } } static void implement(const struct hid_device *hid, u8 *report, unsigned offset, unsigned n, u32 value) { - u64 m; - - if (n > 32) { + if (unlikely(n > 32)) { hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", __func__, n, current->comm); n = 32; + } else if (n < 32) { + u32 m = (1U << n) - 1; + + if (unlikely(value > m)) { + hid_warn(hid, + "%s() called with too large value %d (n: %d)! (%s)\n", + __func__, value, n, current->comm); + WARN_ON(1); + value &= m; + } } - m = (1ULL << n) - 1; - if (value > m) - hid_warn(hid, "%s() called with too large value %d! (%s)\n", - __func__, value, current->comm); - WARN_ON(value > m); - value &= m; - __implement(report, offset, n, value); } @@ -1856,6 +1853,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, + { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) }, { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) }, { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, { HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185BFM, 0x2208) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 0238f0169e48..3eec09a134cb 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -163,6 +163,7 @@ #define USB_VENDOR_ID_ASUSTEK 0x0b05 #define USB_DEVICE_ID_ASUSTEK_LCM 0x1726 #define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b +#define USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD 0x8585 #define USB_VENDOR_ID_ATEN 0x0557 #define USB_DEVICE_ID_ATEN_UC100KM 0x2004 @@ -258,6 +259,13 @@ #define USB_VENDOR_ID_CORSAIR 0x1b1c #define USB_DEVICE_ID_CORSAIR_K90 0x1b02 +#define USB_VENDOR_ID_CORSAIR 0x1b1c +#define USB_DEVICE_ID_CORSAIR_K70R 0x1b09 +#define USB_DEVICE_ID_CORSAIR_K95RGB 0x1b11 +#define USB_DEVICE_ID_CORSAIR_M65RGB 0x1b12 +#define USB_DEVICE_ID_CORSAIR_K70RGB 0x1b13 +#define USB_DEVICE_ID_CORSAIR_K65RGB 0x1b17 + #define USB_VENDOR_ID_CREATIVELABS 0x041e #define USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51 0x322c #define USB_DEVICE_ID_PRODIKEYS_PCMIDI 0x2801 diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c index 65c4ccfcbd29..76d06cf87b2a 100644 --- a/drivers/hid/hid-roccat.c +++ b/drivers/hid/hid-roccat.c @@ -421,14 +421,13 @@ static int __init roccat_init(void) retval = alloc_chrdev_region(&dev_id, ROCCAT_FIRST_MINOR, ROCCAT_MAX_DEVICES, "roccat"); - - roccat_major = MAJOR(dev_id); - if (retval < 0) { pr_warn("can't get major number\n"); goto error; } + roccat_major = MAJOR(dev_id); + cdev_init(&roccat_cdev, &roccat_ops); retval = cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c index 847a497cd472..9ad9c6ec5bba 100644 --- a/drivers/hid/hid-thingm.c +++ b/drivers/hid/hid-thingm.c @@ -148,13 +148,21 @@ static int thingm_led_set(struct led_classdev *ldev, enum led_brightness brightness) { struct thingm_led *led = container_of(ldev, struct thingm_led, ldev); - int ret; - ret = thingm_write_color(led->rgb); - if (ret) - hid_err(led->rgb->tdev->hdev, "failed to write color\n"); + return thingm_write_color(led->rgb); +} - return ret; +static int thingm_init_led(struct thingm_led *led, const char *color_name, + struct thingm_rgb *rgb, int minor) +{ + snprintf(led->name, sizeof(led->name), "thingm%d:%s:led%d", + minor, color_name, rgb->num); + led->ldev.name = led->name; + led->ldev.max_brightness = 255; + led->ldev.brightness_set_blocking = thingm_led_set; + led->ldev.flags = LED_HW_PLUGGABLE; + led->rgb = rgb; + return devm_led_classdev_register(&rgb->tdev->hdev->dev, &led->ldev); } static int thingm_init_rgb(struct thingm_rgb *rgb) @@ -163,42 +171,17 @@ static int thingm_init_rgb(struct thingm_rgb *rgb) int err; /* Register the red diode */ - snprintf(rgb->red.name, sizeof(rgb->red.name), - "thingm%d:red:led%d", minor, rgb->num); - rgb->red.ldev.name = rgb->red.name; - rgb->red.ldev.max_brightness = 255; - rgb->red.ldev.brightness_set_blocking = thingm_led_set; - rgb->red.rgb = rgb; - - err = devm_led_classdev_register(&rgb->tdev->hdev->dev, - &rgb->red.ldev); + err = thingm_init_led(&rgb->red, "red", rgb, minor); if (err) return err; /* Register the green diode */ - snprintf(rgb->green.name, sizeof(rgb->green.name), - "thingm%d:green:led%d", minor, rgb->num); - rgb->green.ldev.name = rgb->green.name; - rgb->green.ldev.max_brightness = 255; - rgb->green.ldev.brightness_set_blocking = thingm_led_set; - rgb->green.rgb = rgb; - - err = devm_led_classdev_register(&rgb->tdev->hdev->dev, - &rgb->green.ldev); + err = thingm_init_led(&rgb->green, "green", rgb, minor); if (err) return err; /* Register the blue diode */ - snprintf(rgb->blue.name, sizeof(rgb->blue.name), - "thingm%d:blue:led%d", minor, rgb->num); - rgb->blue.ldev.name = rgb->blue.name; - rgb->blue.ldev.max_brightness = 255; - rgb->blue.ldev.brightness_set_blocking = thingm_led_set; - rgb->blue.rgb = rgb; - - err = devm_led_classdev_register(&rgb->tdev->hdev->dev, - &rgb->blue.ldev); - return err; + return thingm_init_led(&rgb->blue, "blue", rgb, minor); } static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id) diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 9c2d7c23f296..f0e2757cb909 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -34,6 +34,7 @@ #include <linux/hid.h> #include <linux/mutex.h> #include <linux/sched.h> +#include <linux/string.h> #include <linux/hidraw.h> @@ -123,7 +124,6 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, dev = hidraw_table[minor]->hid; - if (count > HID_MAX_BUFFER_SIZE) { hid_warn(dev, "pid %d passed too large report\n", task_pid_nr(current)); @@ -138,17 +138,12 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, goto out; } - buf = kmalloc(count * sizeof(__u8), GFP_KERNEL); - if (!buf) { - ret = -ENOMEM; + buf = memdup_user(buffer, count); + if (IS_ERR(buf)) { + ret = PTR_ERR(buf); goto out; } - if (copy_from_user(buf, buffer, count)) { - ret = -EFAULT; - goto out_free; - } - if ((report_type == HID_OUTPUT_REPORT) && !(dev->quirks & HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP)) { ret = hid_hw_output_report(dev, buf, count); @@ -587,14 +582,13 @@ int __init hidraw_init(void) result = alloc_chrdev_region(&dev_id, HIDRAW_FIRST_MINOR, HIDRAW_MAX_DEVICES, "hidraw"); - - hidraw_major = MAJOR(dev_id); - if (result < 0) { pr_warn("can't get major number\n"); goto out; } + hidraw_major = MAJOR(dev_id); + hidraw_class = class_create(THIS_MODULE, "hidraw"); if (IS_ERR(hidraw_class)) { result = PTR_ERR(hidraw_class); diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 53fc856d6867..b4b8c6abb03e 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c @@ -71,6 +71,11 @@ static const struct hid_blacklist { { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, + { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70R, HID_QUIRK_NO_INIT_REPORTS }, + { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_M65RGB, HID_QUIRK_NO_INIT_REPORTS }, + { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K95RGB, HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL }, + { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB, HID_QUIRK_NO_INIT_REPORTS }, + { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT }, diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index ccf1883318c3..499cc8213cfe 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -493,7 +493,8 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev, features->x_fuzz = 4; features->y_fuzz = 4; features->pressure_fuzz = 0; - features->distance_fuzz = 0; + features->distance_fuzz = 1; + features->tilt_fuzz = 1; /* * The wireless device HID is basic and layout conflicts with diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index cf2ba43453fd..1eae13cdc502 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2344,12 +2344,13 @@ static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac) __set_bit(BTN_STYLUS2, input_dev->keybit); input_set_abs_params(input_dev, ABS_DISTANCE, - 0, wacom_wac->features.distance_max, 0, 0); + 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0); } static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) { struct input_dev *input_dev = wacom_wac->pen_input; + struct wacom_features *features = &wacom_wac->features; wacom_setup_basic_pro_pen(wacom_wac); @@ -2359,9 +2360,9 @@ static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); - input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0); + input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0); input_abs_set_res(input_dev, ABS_TILT_X, 57); - input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, 0, 0); + input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0); input_abs_set_res(input_dev, ABS_TILT_Y, 57); } @@ -2507,7 +2508,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, case WACOM_G4: input_set_abs_params(input_dev, ABS_DISTANCE, 0, features->distance_max, - 0, 0); + features->distance_fuzz, 0); /* fall through */ case GRAPHIRE: @@ -2569,7 +2570,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, input_set_abs_params(input_dev, ABS_DISTANCE, 0, features->distance_max, - 0, 0); + features->distance_fuzz, 0); input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); input_abs_set_res(input_dev, ABS_Z, 287); @@ -2628,7 +2629,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, __set_bit(BTN_STYLUS2, input_dev->keybit); input_set_abs_params(input_dev, ABS_DISTANCE, 0, features->distance_max, - 0, 0); + features->distance_fuzz, 0); } break; case BAMBOO_PAD: diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index e2084d914c14..53d16537fd2a 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -177,6 +177,7 @@ struct wacom_features { int y_fuzz; int pressure_fuzz; int distance_fuzz; + int tilt_fuzz; unsigned quirks; unsigned touch_max; int oVid; |