Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcc4c2f6 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 0b86c75d 66bc5ba5
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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

drivers/hid/hid-asus.c

0 → 100644
+52 −0
Original line number Diff line number Diff line
/*
 *  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");
+16 −18
Original line number Diff line number Diff line
@@ -1129,48 +1129,45 @@ 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;
	}

	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);
	} 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;
		}
	}

	__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) },
+8 −0
Original line number Diff line number Diff line
@@ -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
Loading