Commit b42a362e authored by Linus Torvalds's avatar Linus Torvalds

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

Pull HID update from Jiri Kosina:

 - Wacom driver fixes/updates (device name generation improvements,
   touch ring status support) from Jason Gerecke

 - T100 touchpad support from Hans de Goede

 - support for batteries driven by HID input reports, from Dmitry
   Torokhov

 - Arnd pointed out that driver_lock semaphore is superfluous, as driver
   core already provides all the necessary concurency protection.
   Removal patch from Binoy Jayan

 - logical minimum numbering improvements in sensor-hub driver, from
   Srinivas Pandruvada

 - support for Microsoft Win8 Wireless Radio Controls extensions from
   João Paulo Rechi Vita

 - assorted small fixes and device ID additions

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (28 commits)
  HID: prodikeys: constify snd_rawmidi_ops structures
  HID: sensor: constify platform_device_id
  HID: input: throttle battery uevents
  HID: usbmouse: constify usb_device_id and fix space before '[' error
  HID: usbkbd: constify usb_device_id and fix space before '[' error.
  HID: hid-sensor-hub: Force logical minimum to 1 for power and report state
  HID: wacom: Do not completely map WACOM_HID_WD_TOUCHRINGSTATUS usage
  HID: asus: Add T100CHI bluetooth keyboard dock touchpad support
  HID: ntrig: constify attribute_group structures.
  HID: logitech-hidpp: constify attribute_group structures.
  HID: sensor: constify attribute_group structures.
  HID: multitouch: constify attribute_group structures.
  HID: multitouch: use proper symbolic constant for 0xff310076 application
  HID: multitouch: Support Asus T304UA media keys
  HID: multitouch: Support HID_GD_WIRELESS_RADIO_CTLS
  HID: input: optionally use device id in battery name
  HID: input: map digitizer battery usage
  HID: Remove the semaphore driver_lock
  HID: wacom: add USB_HID dependency
  HID: add ALWAYS_POLL quirk for Logitech 0xc077
  ...
parents 70b8e9eb de6c5070
...@@ -924,7 +924,7 @@ config HID_UDRAW_PS3 ...@@ -924,7 +924,7 @@ config HID_UDRAW_PS3
config HID_WACOM config HID_WACOM
tristate "Wacom Intuos/Graphire tablet support (USB)" tristate "Wacom Intuos/Graphire tablet support (USB)"
depends on HID depends on USB_HID
select POWER_SUPPLY select POWER_SUPPLY
select NEW_LEDS select NEW_LEDS
select LEDS_CLASS select LEDS_CLASS
......
This diff is collapsed.
...@@ -1982,6 +1982,7 @@ static const struct hid_device_id hid_have_special_driver[] = { ...@@ -1982,6 +1982,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD) },
{ HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) }, { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
{ HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) }, { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD) },
#endif #endif
#if IS_ENABLED(CONFIG_HID_AUREAL) #if IS_ENABLED(CONFIG_HID_AUREAL)
{ HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) }, { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) },
...@@ -2487,11 +2488,9 @@ static int hid_device_probe(struct device *dev) ...@@ -2487,11 +2488,9 @@ static int hid_device_probe(struct device *dev)
const struct hid_device_id *id; const struct hid_device_id *id;
int ret = 0; int ret = 0;
if (down_interruptible(&hdev->driver_lock))
return -EINTR;
if (down_interruptible(&hdev->driver_input_lock)) { if (down_interruptible(&hdev->driver_input_lock)) {
ret = -EINTR; ret = -EINTR;
goto unlock_driver_lock; goto end;
} }
hdev->io_started = false; hdev->io_started = false;
...@@ -2518,8 +2517,7 @@ static int hid_device_probe(struct device *dev) ...@@ -2518,8 +2517,7 @@ static int hid_device_probe(struct device *dev)
unlock: unlock:
if (!hdev->io_started) if (!hdev->io_started)
up(&hdev->driver_input_lock); up(&hdev->driver_input_lock);
unlock_driver_lock: end:
up(&hdev->driver_lock);
return ret; return ret;
} }
...@@ -2529,11 +2527,9 @@ static int hid_device_remove(struct device *dev) ...@@ -2529,11 +2527,9 @@ static int hid_device_remove(struct device *dev)
struct hid_driver *hdrv; struct hid_driver *hdrv;
int ret = 0; int ret = 0;
if (down_interruptible(&hdev->driver_lock))
return -EINTR;
if (down_interruptible(&hdev->driver_input_lock)) { if (down_interruptible(&hdev->driver_input_lock)) {
ret = -EINTR; ret = -EINTR;
goto unlock_driver_lock; goto end;
} }
hdev->io_started = false; hdev->io_started = false;
...@@ -2549,8 +2545,7 @@ static int hid_device_remove(struct device *dev) ...@@ -2549,8 +2545,7 @@ static int hid_device_remove(struct device *dev)
if (!hdev->io_started) if (!hdev->io_started)
up(&hdev->driver_input_lock); up(&hdev->driver_input_lock);
unlock_driver_lock: end:
up(&hdev->driver_lock);
return ret; return ret;
} }
...@@ -3008,7 +3003,6 @@ struct hid_device *hid_allocate_device(void) ...@@ -3008,7 +3003,6 @@ struct hid_device *hid_allocate_device(void)
init_waitqueue_head(&hdev->debug_wait); init_waitqueue_head(&hdev->debug_wait);
INIT_LIST_HEAD(&hdev->debug_list); INIT_LIST_HEAD(&hdev->debug_list);
spin_lock_init(&hdev->debug_list_lock); spin_lock_init(&hdev->debug_list_lock);
sema_init(&hdev->driver_lock, 1);
sema_init(&hdev->driver_input_lock, 1); sema_init(&hdev->driver_input_lock, 1);
mutex_init(&hdev->ll_open_lock); mutex_init(&hdev->ll_open_lock);
......
...@@ -176,6 +176,8 @@ ...@@ -176,6 +176,8 @@
#define USB_DEVICE_ID_ASUSTEK_LCM 0x1726 #define USB_DEVICE_ID_ASUSTEK_LCM 0x1726
#define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b #define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b
#define USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD 0x17e0 #define USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD 0x17e0
#define USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD 0x8502
#define USB_DEVICE_ID_ASUSTEK_T304_KEYBOARD 0x184a
#define USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD 0x8585 #define USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD 0x8585
#define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD 0x0101 #define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD 0x0101
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854
...@@ -666,7 +668,8 @@ ...@@ -666,7 +668,8 @@
#define USB_VENDOR_ID_LOGITECH 0x046d #define USB_VENDOR_ID_LOGITECH 0x046d
#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e #define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
#define USB_DEVICE_ID_LOGITECH_T651 0xb00c #define USB_DEVICE_ID_LOGITECH_T651 0xb00c
#define USB_DEVICE_ID_LOGITECH_C077 0xc007 #define USB_DEVICE_ID_LOGITECH_C007 0xc007
#define USB_DEVICE_ID_LOGITECH_C077 0xc077
#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
#define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
#define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
......
...@@ -340,13 +340,45 @@ static unsigned find_battery_quirk(struct hid_device *hdev) ...@@ -340,13 +340,45 @@ static unsigned find_battery_quirk(struct hid_device *hdev)
return quirks; return quirks;
} }
static int hidinput_scale_battery_capacity(struct hid_device *dev,
int value)
{
if (dev->battery_min < dev->battery_max &&
value >= dev->battery_min && value <= dev->battery_max)
value = ((value - dev->battery_min) * 100) /
(dev->battery_max - dev->battery_min);
return value;
}
static int hidinput_query_battery_capacity(struct hid_device *dev)
{
u8 *buf;
int ret;
buf = kmalloc(2, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2,
dev->battery_report_type, HID_REQ_GET_REPORT);
if (ret != 2) {
kfree(buf);
return -ENODATA;
}
ret = hidinput_scale_battery_capacity(dev, buf[1]);
kfree(buf);
return ret;
}
static int hidinput_get_battery_property(struct power_supply *psy, static int hidinput_get_battery_property(struct power_supply *psy,
enum power_supply_property prop, enum power_supply_property prop,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct hid_device *dev = power_supply_get_drvdata(psy); struct hid_device *dev = power_supply_get_drvdata(psy);
int value;
int ret = 0; int ret = 0;
__u8 *buf;
switch (prop) { switch (prop) {
case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_PRESENT:
...@@ -355,29 +387,15 @@ static int hidinput_get_battery_property(struct power_supply *psy, ...@@ -355,29 +387,15 @@ static int hidinput_get_battery_property(struct power_supply *psy,
break; break;
case POWER_SUPPLY_PROP_CAPACITY: case POWER_SUPPLY_PROP_CAPACITY:
if (dev->battery_report_type == HID_FEATURE_REPORT) {
buf = kmalloc(2 * sizeof(__u8), GFP_KERNEL); value = hidinput_query_battery_capacity(dev);
if (!buf) { if (value < 0)
ret = -ENOMEM; return value;
break; } else {
} value = dev->battery_capacity;
ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2,
dev->battery_report_type,
HID_REQ_GET_REPORT);
if (ret != 2) {
ret = -ENODATA;
kfree(buf);
break;
} }
ret = 0;
if (dev->battery_min < dev->battery_max && val->intval = value;
buf[1] >= dev->battery_min &&
buf[1] <= dev->battery_max)
val->intval = (100 * (buf[1] - dev->battery_min)) /
(dev->battery_max - dev->battery_min);
kfree(buf);
break; break;
case POWER_SUPPLY_PROP_MODEL_NAME: case POWER_SUPPLY_PROP_MODEL_NAME:
...@@ -385,7 +403,22 @@ static int hidinput_get_battery_property(struct power_supply *psy, ...@@ -385,7 +403,22 @@ static int hidinput_get_battery_property(struct power_supply *psy,
break; break;
case POWER_SUPPLY_PROP_STATUS: case POWER_SUPPLY_PROP_STATUS:
val->intval = POWER_SUPPLY_STATUS_DISCHARGING; if (!dev->battery_reported &&
dev->battery_report_type == HID_FEATURE_REPORT) {
value = hidinput_query_battery_capacity(dev);
if (value < 0)
return value;
dev->battery_capacity = value;
dev->battery_reported = true;
}
if (!dev->battery_reported)
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
else if (dev->battery_capacity == 100)
val->intval = POWER_SUPPLY_STATUS_FULL;
else
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
break; break;
case POWER_SUPPLY_PROP_SCOPE: case POWER_SUPPLY_PROP_SCOPE:
...@@ -400,18 +433,16 @@ static int hidinput_get_battery_property(struct power_supply *psy, ...@@ -400,18 +433,16 @@ static int hidinput_get_battery_property(struct power_supply *psy,
return ret; return ret;
} }
static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, struct hid_field *field) static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, struct hid_field *field)
{ {
struct power_supply_desc *psy_desc = NULL; struct power_supply_desc *psy_desc;
struct power_supply_config psy_cfg = { .drv_data = dev, }; struct power_supply_config psy_cfg = { .drv_data = dev, };
unsigned quirks; unsigned quirks;
s32 min, max; s32 min, max;
int error;
if (field->usage->hid != HID_DC_BATTERYSTRENGTH) if (dev->battery)
return false; /* no match */ return 0; /* already initialized? */
if (dev->battery != NULL)
goto out; /* already initialized? */
quirks = find_battery_quirk(dev); quirks = find_battery_quirk(dev);
...@@ -419,16 +450,18 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, ...@@ -419,16 +450,18 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
dev->bus, dev->vendor, dev->product, dev->version, quirks); dev->bus, dev->vendor, dev->product, dev->version, quirks);
if (quirks & HID_BATTERY_QUIRK_IGNORE) if (quirks & HID_BATTERY_QUIRK_IGNORE)
goto out; return 0;
psy_desc = kzalloc(sizeof(*psy_desc), GFP_KERNEL); psy_desc = kzalloc(sizeof(*psy_desc), GFP_KERNEL);
if (psy_desc == NULL) if (!psy_desc)
goto out; return -ENOMEM;
psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery", dev->uniq); psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery",
if (psy_desc->name == NULL) { strlen(dev->uniq) ?
kfree(psy_desc); dev->uniq : dev_name(&dev->dev));
goto out; if (!psy_desc->name) {
error = -ENOMEM;
goto err_free_mem;
} }
psy_desc->type = POWER_SUPPLY_TYPE_BATTERY; psy_desc->type = POWER_SUPPLY_TYPE_BATTERY;
...@@ -455,17 +488,20 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, ...@@ -455,17 +488,20 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg); dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg);
if (IS_ERR(dev->battery)) { if (IS_ERR(dev->battery)) {
hid_warn(dev, "can't register power supply: %ld\n", error = PTR_ERR(dev->battery);
PTR_ERR(dev->battery)); hid_warn(dev, "can't register power supply: %d\n", error);
kfree(psy_desc->name); goto err_free_name;
kfree(psy_desc);
dev->battery = NULL;
} else {
power_supply_powers(dev->battery, &dev->dev);
} }
out: power_supply_powers(dev->battery, &dev->dev);
return true; return 0;
err_free_name:
kfree(psy_desc->name);
err_free_mem:
kfree(psy_desc);
dev->battery = NULL;
return error;
} }
static void hidinput_cleanup_battery(struct hid_device *dev) static void hidinput_cleanup_battery(struct hid_device *dev)
...@@ -481,16 +517,39 @@ static void hidinput_cleanup_battery(struct hid_device *dev) ...@@ -481,16 +517,39 @@ static void hidinput_cleanup_battery(struct hid_device *dev)
kfree(psy_desc); kfree(psy_desc);
dev->battery = NULL; dev->battery = NULL;
} }
static void hidinput_update_battery(struct hid_device *dev, int value)
{
int capacity;
if (!dev->battery)
return;
if (value == 0 || value < dev->battery_min || value > dev->battery_max)
return;
capacity = hidinput_scale_battery_capacity(dev, value);
if (!dev->battery_reported || capacity != dev->battery_capacity) {
dev->battery_capacity = capacity;
dev->battery_reported = true;
power_supply_changed(dev->battery);
}
}
#else /* !CONFIG_HID_BATTERY_STRENGTH */ #else /* !CONFIG_HID_BATTERY_STRENGTH */
static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
struct hid_field *field) struct hid_field *field)
{ {
return false; return 0;
} }
static void hidinput_cleanup_battery(struct hid_device *dev) static void hidinput_cleanup_battery(struct hid_device *dev)
{ {
} }
static void hidinput_update_battery(struct hid_device *dev, int value)
{
}
#endif /* CONFIG_HID_BATTERY_STRENGTH */ #endif /* CONFIG_HID_BATTERY_STRENGTH */
static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
...@@ -710,6 +769,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -710,6 +769,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
} }
break; break;
case 0x3b: /* Battery Strength */
hidinput_setup_battery(device, HID_INPUT_REPORT, field);
usage->type = EV_PWR;
goto ignore;
case 0x3c: /* Invert */ case 0x3c: /* Invert */
map_key_clear(BTN_TOOL_RUBBER); map_key_clear(BTN_TOOL_RUBBER);
break; break;
...@@ -944,11 +1008,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -944,11 +1008,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break; break;
case HID_UP_GENDEVCTRLS: case HID_UP_GENDEVCTRLS:
if (hidinput_setup_battery(device, HID_INPUT_REPORT, field)) switch (usage->hid) {
case HID_DC_BATTERYSTRENGTH:
hidinput_setup_battery(device, HID_INPUT_REPORT, field);
usage->type = EV_PWR;
goto ignore; goto ignore;
else }
goto unknown; goto unknown;
break;
case HID_UP_HPVENDOR: /* Reported on a Dutch layout HP5308 */ case HID_UP_HPVENDOR: /* Reported on a Dutch layout HP5308 */
set_bit(EV_REP, input->evbit); set_bit(EV_REP, input->evbit);
...@@ -1031,7 +1097,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -1031,7 +1097,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
if (usage->code > max) if (usage->code > max)
goto ignore; goto ignore;
if (usage->type == EV_ABS) { if (usage->type == EV_ABS) {
int a = field->logical_minimum; int a = field->logical_minimum;
...@@ -1090,14 +1155,19 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct ...@@ -1090,14 +1155,19 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
struct input_dev *input; struct input_dev *input;
unsigned *quirks = &hid->quirks; unsigned *quirks = &hid->quirks;
if (!field->hidinput) if (!usage->type)
return; return;
input = field->hidinput->input; if (usage->type == EV_PWR) {
hidinput_update_battery(hid, value);
return;
}
if (!usage->type) if (!field->hidinput)
return; return;
input = field->hidinput->input;
if (usage->hat_min < usage->hat_max || usage->hat_dir) { if (usage->hat_min < usage->hat_max || usage->hat_dir) {
int hat_dir = usage->hat_dir; int hat_dir = usage->hat_dir;
if (!hat_dir) if (!hat_dir)
...@@ -1373,6 +1443,7 @@ static void report_features(struct hid_device *hid) ...@@ -1373,6 +1443,7 @@ static void report_features(struct hid_device *hid)
struct hid_driver *drv = hid->driver; struct hid_driver *drv = hid->driver;
struct hid_report_enum *rep_enum; struct hid_report_enum *rep_enum;
struct hid_report *rep; struct hid_report *rep;
struct hid_usage *usage;
int i, j; int i, j;
rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
...@@ -1383,12 +1454,15 @@ static void report_features(struct hid_device *hid) ...@@ -1383,12 +1454,15 @@ static void report_features(struct hid_device *hid)
continue; continue;
for (j = 0; j < rep->field[i]->maxusage; j++) { for (j = 0; j < rep->field[i]->maxusage; j++) {
usage = &rep->field[i]->usage[j];
/* Verify if Battery Strength feature is available */ /* Verify if Battery Strength feature is available */
hidinput_setup_battery(hid, HID_FEATURE_REPORT, rep->field[i]); if (usage->hid == HID_DC_BATTERYSTRENGTH)
hidinput_setup_battery(hid, HID_FEATURE_REPORT,
rep->field[i]);
if (drv->feature_mapping) if (drv->feature_mapping)
drv->feature_mapping(hid, rep->field[i], drv->feature_mapping(hid, rep->field[i], usage);
rep->field[i]->usage + j);
} }
} }
} }
......
...@@ -2926,7 +2926,7 @@ static struct attribute *sysfs_attrs[] = { ...@@ -2926,7 +2926,7 @@ static struct attribute *sysfs_attrs[] = {
NULL NULL
}; };
static struct attribute_group ps_attribute_group = { static const struct attribute_group ps_attribute_group = {
.attrs = sysfs_attrs .attrs = sysfs_attrs
}; };
......
...@@ -72,6 +72,7 @@ MODULE_LICENSE("GPL"); ...@@ -72,6 +72,7 @@ MODULE_LICENSE("GPL");
#define MT_QUIRK_FIX_CONST_CONTACT_ID BIT(14) #define MT_QUIRK_FIX_CONST_CONTACT_ID BIT(14)
#define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15) #define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15)
#define MT_QUIRK_STICKY_FINGERS BIT(16) #define MT_QUIRK_STICKY_FINGERS BIT(16)
#define MT_QUIRK_ASUS_CUSTOM_UP BIT(17)
#define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHSCREEN 0x02
#define MT_INPUTMODE_TOUCHPAD 0x03 #define MT_INPUTMODE_TOUCHPAD 0x03
...@@ -169,6 +170,7 @@ static void mt_post_parse(struct mt_device *td); ...@@ -169,6 +170,7 @@ static void mt_post_parse(struct mt_device *td);
#define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108
#define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109
#define MT_CLS_LG 0x010a #define MT_CLS_LG 0x010a
#define MT_CLS_ASUS 0x010b
#define MT_CLS_VTL 0x0110 #define MT_CLS_VTL 0x0110
#define MT_CLS_GOOGLE 0x0111 #define MT_CLS_GOOGLE 0x0111
...@@ -290,6 +292,10 @@ static struct mt_class mt_classes[] = { ...@@ -290,6 +292,10 @@ static struct mt_class mt_classes[] = {
MT_QUIRK_IGNORE_DUPLICATES | MT_QUIRK_IGNORE_DUPLICATES |
MT_QUIRK_HOVERING | MT_QUIRK_HOVERING |
MT_QUIRK_CONTACT_CNT_ACCURATE }, MT_QUIRK_CONTACT_CNT_ACCURATE },
{ .name = MT_CLS_ASUS,
.quirks = MT_QUIRK_ALWAYS_VALID |
MT_QUIRK_CONTACT_CNT_ACCURATE |
MT_QUIRK_ASUS_CUSTOM_UP },
{ .name = MT_CLS_VTL, { .name = MT_CLS_VTL,
.quirks = MT_QUIRK_ALWAYS_VALID | .quirks = MT_QUIRK_ALWAYS_VALID |
MT_QUIRK_CONTACT_CNT_ACCURATE | MT_QUIRK_CONTACT_CNT_ACCURATE |
...@@ -341,7 +347,7 @@ static struct attribute *sysfs_attrs[] = { ...@@ -341,7 +347,7 @@ static struct attribute *sysfs_attrs[] = {
NULL NULL
}; };
static struct attribute_group mt_attribute_group = { static const struct attribute_group mt_attribute_group = {
.attrs = sysfs_attrs .attrs = sysfs_attrs
}; };
...@@ -905,6 +911,8 @@ static int mt_touch_input_configured(struct hid_device *hdev, ...@@ -905,6 +911,8 @@ static int mt_touch_input_configured(struct hid_device *hdev,
return 0; return 0;
} }
#define mt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \
max, EV_KEY, (c))
static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage, struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max) unsigned long **bit, int *max)
...@@ -922,9 +930,35 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, ...@@ -922,9 +930,35 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
field->application != HID_DG_PEN && field->application != HID_DG_PEN &&
field->application != HID_DG_TOUCHPAD && field->application != HID_DG_TOUCHPAD &&
field->application != HID_GD_KEYBOARD && field->application != HID_GD_KEYBOARD &&
field->application != HID_CP_CONSUMER_CONTROL) field->application != HID_CP_CONSUMER_CONTROL &&
field->application != HID_GD_WIRELESS_RADIO_CTLS &&
!(field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS &&
td->mtclass.quirks & MT_QUIRK_ASUS_CUSTOM_UP))
return -1; return -1;
/*
* Some Asus keyboard+touchpad devices have the hotkeys defined in the
* touchpad report descriptor. We need to treat these as an array to
* map usages to input keys.
*/
if (field->application == HID_VD_ASUS_CUSTOM_MEDIA_KEYS &&
td->mtclass.quirks & MT_QUIRK_ASUS_CUSTOM_UP &&
(usage->hid & HID_USAGE_PAGE) == HID_UP_CUSTOM) {
set_bit(EV_REP, hi->input->evbit);
if (field->flags & HID_MAIN_ITEM_VARIABLE)
field->flags &= ~HID_MAIN_ITEM_VARIABLE;
switch (usage->hid & HID_USAGE) {
case 0x10: mt_map_key_clear(KEY_BRIGHTNESSDOWN); break;
case 0x20: mt_map_key_clear(KEY_BRIGHTNESSUP); break;
case 0x35: mt_map_key_clear(KEY_DISPLAY_OFF); break;
case 0x6b: mt_map_key_clear(KEY_F21); break;
case 0x6c: mt_map_key_clear(KEY_SLEEP); break;
default:
return -1;
}
return 1;
}
/* /*
* some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN"
* for the stylus. * for the stylus.
...@@ -1133,6 +1167,12 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) ...@@ -1133,6 +1167,12 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
case HID_CP_CONSUMER_CONTROL: case HID_CP_CONSUMER_CONTROL:
suffix = "Consumer Control"; suffix = "Consumer Control";
break; break;
case HID_GD_WIRELESS_RADIO_CTLS:
suffix = "Wireless Radio Control";
break;
case HID_VD_ASUS_CUSTOM_MEDIA_KEYS:
suffix = "Custom Media Keys";
break;
default: default:
suffix = "UNKNOWN"; suffix = "UNKNOWN";
break; break;
...@@ -1384,6 +1424,12 @@ static const struct hid_device_id mt_devices[] = { ...@@ -1384,6 +1424,12 @@ static const struct hid_device_id mt_devices[] = {
MT_USB_DEVICE(USB_VENDOR_ID_ANTON, MT_USB_DEVICE(USB_VENDOR_ID_ANTON,
USB_DEVICE_ID_ANTON_TOUCH_PAD) }, USB_DEVICE_ID_ANTON_TOUCH_PAD) },
/* Asus T304UA */
{ .driver_data = MT_CLS_ASUS,
HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8,
USB_VENDOR_ID_ASUSTEK,
USB_DEVICE_ID_ASUSTEK_T304_KEYBOARD) },
/* Atmel panels */ /* Atmel panels */
{ .driver_data = MT_CLS_SERIAL, { .driver_data = MT_CLS_SERIAL,
MT_USB_DEVICE(USB_VENDOR_ID_ATMEL, MT_USB_DEVICE(USB_VENDOR_ID_ATMEL,
......
...@@ -445,7 +445,7 @@ static struct attribute *sysfs_attrs[] = { ...@@ -445,7 +445,7 @@ static struct attribute *sysfs_attrs[] = {
NULL NULL
}; };
static struct attribute_group ntrig_attribute_group = { static const struct attribute_group ntrig_attribute_group = {
.attrs = sysfs_attrs .attrs = sysfs_attrs
}; };
......
...@@ -593,7 +593,7 @@ static void pcmidi_in_trigger(struct snd_rawmidi_substream *substream, int up) ...@@ -593,7 +593,7 @@ static void pcmidi_in_trigger(struct snd_rawmidi_substream *substream, int up)
pm->in_triggered = up; pm->in_triggered = up;
} }
static struct snd_rawmidi_ops pcmidi_in_ops = { static const struct snd_rawmidi_ops pcmidi_in_ops = {
.open = pcmidi_in_open, .open = pcmidi_in_open,
.close = pcmidi_in_close, .close = pcmidi_in_close,
.trigger = pcmidi_in_trigger .trigger = pcmidi_in_trigger
......
...@@ -276,7 +276,7 @@ static struct attribute *enable_sensor_attrs[] = { ...@@ -276,7 +276,7 @@ static struct attribute *enable_sensor_attrs[] = {
NULL, NULL,
}; };
static struct attribute_group enable_sensor_attr_group = { static const struct attribute_group enable_sensor_attr_group = {
.attrs = enable_sensor_attrs, .attrs = enable_sensor_attrs,
}; };
...@@ -823,7 +823,7 @@ static int hid_sensor_custom_remove(struct platform_device *pdev) ...@@ -823,7 +823,7 @@ static int hid_sensor_custom_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct platform_device_id hid_sensor_custom_ids[] = { static const struct platform_device_id hid_sensor_custom_ids[] = {
{ {
.name = "HID-SENSOR-2000e1", .name = "HID-SENSOR-2000e1",
}, },
......
...@@ -579,54 +579,6 @@ void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev) ...@@ -579,54 +579,6 @@ void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
} }
EXPORT_SYMBOL_GPL(sensor_hub_device_close); EXPORT_SYMBOL_GPL(sensor_hub_device_close);
static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
int index;
struct sensor_hub_data *sd = hid_get_drvdata(hdev);
unsigned char report_block[] = {
0x0a, 0x16, 0x03, 0x15, 0x00, 0x25, 0x05};
unsigned char power_block[] = {
0x0a, 0x19, 0x03, 0x15, 0x00, 0x25, 0x05};
if (!(sd->quirks & HID_SENSOR_HUB_ENUM_QUIRK)) {
hid_dbg(hdev, "No Enum quirks\n");
return rdesc;
}
/* Looks for power and report state usage id and force to 1 */
for (index = 0; index < *rsize; ++index) {
if (((*rsize - index) > sizeof(report_block)) &&
!memcmp(&rdesc[index], report_block,
sizeof(report_block))) {
rdesc[index + 4] = 0x01;
index += sizeof(report_block);
}
if (((*rsize - index) > sizeof(power_block)) &&
!memcmp(&rdesc[index], power_block,
sizeof(power_block))) {
rdesc[index + 4] = 0x01;
index += sizeof(power_block);
}
}
/* Checks if the report descriptor of Thinkpad Helix 2 has a logical
* minimum for magnetic flux axis greater than the maximum */
if (hdev->product == USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA &&
*rsize == 2558 && rdesc[913] == 0x17 && rdesc[914] == 0x40 &&
rdesc[915] == 0x81 && rdesc[916] == 0x08 &&
rdesc[917] == 0x00 && rdesc[918] == 0x27 &&
rdesc[921] == 0x07 && rdesc[922] == 0x00) {
/* Sets negative logical minimum for mag x, y and z */
rdesc[914] = rdesc[935] = rdesc[956] = 0xc0;
rdesc[915] = rdesc[936] = rdesc[957] = 0x7e;
rdesc[916] = rdesc[937] = rdesc[958] = 0xf7;
rdesc[917] = rdesc[938] = rdesc[959] = 0xff;
}
return rdesc;
}
static int sensor_hub_probe(struct hid_device *hdev, static int sensor_hub_probe(struct hid_device *hdev,
const struct hid_device_id *id) const struct hid_device_id *id)
{ {
...@@ -778,51 +730,6 @@ static void sensor_hub_remove(struct hid_device *hdev) ...@@ -778,51 +730,6 @@ static void sensor_hub_remove(struct hid_device *hdev)
} }
static const struct hid_device_id sensor_hub_devices[] = { static const struct hid_device_id sensor_hub_devices[] = {
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_0,
USB_DEVICE_ID_INTEL_HID_SENSOR_0),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
USB_DEVICE_ID_INTEL_HID_SENSOR_0),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
USB_DEVICE_ID_INTEL_HID_SENSOR_1),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
USB_DEVICE_ID_MS_SURFACE_PRO_2),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
USB_DEVICE_ID_MS_TOUCH_COVER_2),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
USB_DEVICE_ID_MS_TYPE_COVER_2),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
0x07bd), /* Microsoft Surface 3 */
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROCHIP,
0x0f01), /* MM7150 */
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_STM_0,
USB_DEVICE_ID_STM_HID_SENSOR),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_STM_0,
USB_DEVICE_ID_STM_HID_SENSOR_1),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_TEXAS_INSTRUMENTS,
USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
USB_DEVICE_ID_ITE_LENOVO_YOGA),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
USB_DEVICE_ID_ITE_LENOVO_YOGA2),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
USB_DEVICE_ID_ITE_LENOVO_YOGA900),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_0,
0x22D8),
.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID, { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
HID_ANY_ID) }, HID_ANY_ID) },
{ } { }
...@@ -835,7 +742,6 @@ static struct hid_driver sensor_hub_driver = { ...@@ -835,7 +742,6 @@ static struct hid_driver sensor_hub_driver = {
.probe = sensor_hub_probe, .probe = sensor_hub_probe,
.remove = sensor_hub_remove, .remove = sensor_hub_remove,
.raw_event = sensor_hub_raw_event, .raw_event = sensor_hub_raw_event,
.report_fixup = sensor_hub_report_fixup,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = sensor_hub_suspend, .suspend = sensor_hub_suspend,
.resume = sensor_hub_resume, .resume = sensor_hub_resume,
......
...@@ -780,7 +780,7 @@ static int i2c_hid_power(struct hid_device *hid, int lvl) ...@@ -780,7 +780,7 @@ static int i2c_hid_power(struct hid_device *hid, int lvl)
return 0; return 0;
} }
static struct hid_ll_driver i2c_hid_ll_driver = { struct hid_ll_driver i2c_hid_ll_driver = {
.parse = i2c_hid_parse, .parse = i2c_hid_parse,
.start = i2c_hid_start, .start = i2c_hid_start,
.stop = i2c_hid_stop, .stop = i2c_hid_stop,
...@@ -790,6 +790,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = { ...@@ -790,6 +790,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = {
.output_report = i2c_hid_output_report, .output_report = i2c_hid_output_report,
.raw_request = i2c_hid_raw_request, .raw_request = i2c_hid_raw_request,
}; };
EXPORT_SYMBOL_GPL(i2c_hid_ll_driver);
static int i2c_hid_init_irq(struct i2c_client *client) static int i2c_hid_init_irq(struct i2c_client *client)
{ {
......
...@@ -369,7 +369,7 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf, ...@@ -369,7 +369,7 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT); return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT);
} }
static struct hid_ll_driver uhid_hid_driver = { struct hid_ll_driver uhid_hid_driver = {
.start = uhid_hid_start, .start = uhid_hid_start,
.stop = uhid_hid_stop, .stop = uhid_hid_stop,
.open = uhid_hid_open, .open = uhid_hid_open,
...@@ -378,6 +378,7 @@ static struct hid_ll_driver uhid_hid_driver = { ...@@ -378,6 +378,7 @@ static struct hid_ll_driver uhid_hid_driver = {
.raw_request = uhid_hid_raw_request, .raw_request = uhid_hid_raw_request,
.output_report = uhid_hid_output_report, .output_report = uhid_hid_output_report,
}; };
EXPORT_SYMBOL_GPL(uhid_hid_driver);
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
......
...@@ -1265,7 +1265,7 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle, ...@@ -1265,7 +1265,7 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle,
return hid_set_idle(dev, ifnum, report, idle); return hid_set_idle(dev, ifnum, report, idle);
} }
static struct hid_ll_driver usb_hid_driver = { struct hid_ll_driver usb_hid_driver = {
.parse = usbhid_parse, .parse = usbhid_parse,
.start = usbhid_start, .start = usbhid_start,
.stop = usbhid_stop, .stop = usbhid_stop,
...@@ -1278,6 +1278,7 @@ static struct hid_ll_driver usb_hid_driver = { ...@@ -1278,6 +1278,7 @@ static struct hid_ll_driver usb_hid_driver = {
.output_report = usbhid_output_report, .output_report = usbhid_output_report,
.idle = usbhid_idle, .idle = usbhid_idle,
}; };
EXPORT_SYMBOL_GPL(usb_hid_driver);
static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
......
...@@ -99,6 +99,7 @@ static const struct hid_blacklist { ...@@ -99,6 +99,7 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C007, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C077, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C077, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KEYBOARD_G710_PLUS, HID_QUIRK_NOGET }, { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KEYBOARD_G710_PLUS, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C01A, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C01A, HID_QUIRK_ALWAYS_POLL },
......
...@@ -392,7 +392,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf) ...@@ -392,7 +392,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf)
} }
} }
static struct usb_device_id usb_kbd_id_table [] = { static const struct usb_device_id usb_kbd_id_table[] = {
{ USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID, USB_INTERFACE_SUBCLASS_BOOT, { USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID, USB_INTERFACE_SUBCLASS_BOOT,
USB_INTERFACE_PROTOCOL_KEYBOARD) }, USB_INTERFACE_PROTOCOL_KEYBOARD) },
{ } /* Terminating entry */ { } /* Terminating entry */
......
...@@ -226,7 +226,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf) ...@@ -226,7 +226,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf)
} }
} }
static struct usb_device_id usb_mouse_id_table [] = { static const struct usb_device_id usb_mouse_id_table[] = {
{ USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID, USB_INTERFACE_SUBCLASS_BOOT, { USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID, USB_INTERFACE_SUBCLASS_BOOT,
USB_INTERFACE_PROTOCOL_MOUSE) }, USB_INTERFACE_PROTOCOL_MOUSE) },
{ } /* Terminating entry */ { } /* Terminating entry */
......
...@@ -1671,10 +1671,7 @@ static ssize_t wacom_show_remote_mode(struct kobject *kobj, ...@@ -1671,10 +1671,7 @@ static ssize_t wacom_show_remote_mode(struct kobject *kobj,
u8 mode; u8 mode;
mode = wacom->led.groups[index].select; mode = wacom->led.groups[index].select;
if (mode >= 0 && mode < 3) return sprintf(buf, "%d\n", mode < 3 ? mode : -1);
return snprintf(buf, PAGE_SIZE, "%d\n", mode);
else
return snprintf(buf, PAGE_SIZE, "%d\n", -1);
} }
#define DEVICE_EKR_ATTR_GROUP(SET_ID) \ #define DEVICE_EKR_ATTR_GROUP(SET_ID) \
...@@ -2028,41 +2025,37 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix) ...@@ -2028,41 +2025,37 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
/* Generic devices name unspecified */ /* Generic devices name unspecified */
if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) { if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) {
if (strstr(wacom->hdev->name, "Wacom") || char *product_name = wacom->hdev->name;
strstr(wacom->hdev->name, "wacom") ||
strstr(wacom->hdev->name, "WACOM")) {
/* name is in HID descriptor, use it */
strlcpy(name, wacom->hdev->name, sizeof(name));
/* strip out excess whitespaces */
while (1) {
char *gap = strstr(name, " ");
if (gap == NULL)
break;
/* shift everything including the terminator */
memmove(gap, gap+1, strlen(gap));
}
/* strip off excessive prefixing */ if (hid_is_using_ll_driver(wacom->hdev, &usb_hid_driver)) {
if (strstr(name, "Wacom Co.,Ltd. Wacom ") == name) { struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent);
int n = strlen(name); struct usb_device *dev = interface_to_usbdev(intf);
int x = strlen("Wacom Co.,Ltd. "); product_name = dev->product;
memmove(name, name+x, n-x+1); }
}
if (strstr(name, "Wacom Co., Ltd. Wacom ") == name) {
int n = strlen(name);
int x = strlen("Wacom Co., Ltd. ");
memmove(name, name+x, n-x+1);
}
/* get rid of trailing whitespace */ if (wacom->hdev->bus == BUS_I2C) {
if (name[strlen(name)-1] == ' ') snprintf(name, sizeof(name), "%s %X",
name[strlen(name)-1] = '\0'; features->name, wacom->hdev->product);
} else if (strstr(product_name, "Wacom") ||
strstr(product_name, "wacom") ||
strstr(product_name, "WACOM")) {
strlcpy(name, product_name, sizeof(name));
} else { } else {
/* no meaningful name retrieved. use product ID */ snprintf(name, sizeof(name), "Wacom %s", product_name);
snprintf(name, sizeof(name),
"%s %X", features->name, wacom->hdev->product);
} }
/* strip out excess whitespaces */
while (1) {
char *gap = strstr(name, " ");
if (gap == NULL)
break;
/* shift everything including the terminator */
memmove(gap, gap+1, strlen(gap));
}
/* get rid of trailing whitespace */
if (name[strlen(name)-1] == ' ')
name[strlen(name)-1] = '\0';
} else { } else {
strlcpy(name, features->name, sizeof(name)); strlcpy(name, features->name, sizeof(name));
} }
......
...@@ -1846,7 +1846,13 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, ...@@ -1846,7 +1846,13 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
features->device_type |= WACOM_DEVICETYPE_PAD; features->device_type |= WACOM_DEVICETYPE_PAD;
break; break;
case WACOM_HID_WD_TOUCHRINGSTATUS: case WACOM_HID_WD_TOUCHRINGSTATUS:
wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); /*
* Only set up type/code association. Completely mapping
* this usage may overwrite the axis resolution and range.
*/
usage->type = EV_ABS;
usage->code = ABS_WHEEL;
set_bit(EV_ABS, input->evbit);
features->device_type |= WACOM_DEVICETYPE_PAD; features->device_type |= WACOM_DEVICETYPE_PAD;
break; break;
case WACOM_HID_WD_BUTTONCONFIG: case WACOM_HID_WD_BUTTONCONFIG:
......
...@@ -473,6 +473,9 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, ...@@ -473,6 +473,9 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
HID_USAGE_SENSOR_PROY_POWER_STATE, HID_USAGE_SENSOR_PROY_POWER_STATE,
&st->power_state); &st->power_state);
st->power_state.logical_minimum = 1;
st->report_state.logical_minimum = 1;
sensor_hub_input_get_attribute_info(hsdev, sensor_hub_input_get_attribute_info(hsdev,
HID_FEATURE_REPORT, usage_id, HID_FEATURE_REPORT, usage_id,
HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS, HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS,
......
...@@ -173,6 +173,7 @@ struct hid_item { ...@@ -173,6 +173,7 @@ struct hid_item {
#define HID_UP_LOGIVENDOR3 0xff430000 #define HID_UP_LOGIVENDOR3 0xff430000
#define HID_UP_LNVENDOR 0xffa00000 #define HID_UP_LNVENDOR 0xffa00000
#define HID_UP_SENSOR 0x00200000 #define HID_UP_SENSOR 0x00200000
#define HID_UP_ASUSVENDOR 0xff310000
#define HID_USAGE 0x0000ffff #define HID_USAGE 0x0000ffff
...@@ -292,6 +293,7 @@ struct hid_item { ...@@ -292,6 +293,7 @@ struct hid_item {
#define HID_DG_BARRELSWITCH2 0x000d005a #define HID_DG_BARRELSWITCH2 0x000d005a
#define HID_DG_TOOLSERIALNUMBER 0x000d005b #define HID_DG_TOOLSERIALNUMBER 0x000d005b
#define HID_VD_ASUS_CUSTOM_MEDIA_KEYS 0xff310076
/* /*
* HID report types --- Ouch! HID spec says 1 2 3! * HID report types --- Ouch! HID spec says 1 2 3!
*/ */
...@@ -532,7 +534,6 @@ struct hid_device { /* device report descriptor */ ...@@ -532,7 +534,6 @@ struct hid_device { /* device report descriptor */
struct hid_report_enum report_enum[HID_REPORT_TYPES]; struct hid_report_enum report_enum[HID_REPORT_TYPES];
struct work_struct led_work; /* delayed LED worker */ struct work_struct led_work; /* delayed LED worker */
struct semaphore driver_lock; /* protects the current driver, except during input */
struct semaphore driver_input_lock; /* protects the current driver */ struct semaphore driver_input_lock; /* protects the current driver */
struct device dev; /* device */ struct device dev; /* device */
struct hid_driver *driver; struct hid_driver *driver;
...@@ -548,16 +549,18 @@ struct hid_device { /* device report descriptor */ ...@@ -548,16 +549,18 @@ struct hid_device { /* device report descriptor */
* battery is non-NULL. * battery is non-NULL.
*/ */
struct power_supply *battery; struct power_supply *battery;
__s32 battery_capacity;
__s32 battery_min; __s32 battery_min;
__s32 battery_max; __s32 battery_max;
__s32 battery_report_type; __s32 battery_report_type;
__s32 battery_report_id; __s32 battery_report_id;
bool battery_reported;
#endif #endif
unsigned int status; /* see STAT flags above */ unsigned int status; /* see STAT flags above */
unsigned claimed; /* Claimed by hidinput, hiddev? */ unsigned claimed; /* Claimed by hidinput, hiddev? */
unsigned quirks; /* Various quirks the device can pull on us */ unsigned quirks; /* Various quirks the device can pull on us */
bool io_started; /* Protected by driver_lock. If IO has started */ bool io_started; /* If IO has started */
struct list_head inputs; /* The list of inputs */ struct list_head inputs; /* The list of inputs */
void *hiddev; /* The hiddev structure */ void *hiddev; /* The hiddev structure */
...@@ -783,6 +786,17 @@ struct hid_ll_driver { ...@@ -783,6 +786,17 @@ struct hid_ll_driver {
int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
}; };
extern struct hid_ll_driver i2c_hid_ll_driver;
extern struct hid_ll_driver hidp_hid_driver;
extern struct hid_ll_driver uhid_hid_driver;
extern struct hid_ll_driver usb_hid_driver;
static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
struct hid_ll_driver *driver)
{
return hdev->ll_driver == driver;
}
#define PM_HINT_FULLON 1<<5 #define PM_HINT_FULLON 1<<5
#define PM_HINT_NORMAL 1<<1 #define PM_HINT_NORMAL 1<<1
......
...@@ -734,7 +734,7 @@ static void hidp_stop(struct hid_device *hid) ...@@ -734,7 +734,7 @@ static void hidp_stop(struct hid_device *hid)
hid->claimed = 0; hid->claimed = 0;
} }
static struct hid_ll_driver hidp_hid_driver = { struct hid_ll_driver hidp_hid_driver = {
.parse = hidp_parse, .parse = hidp_parse,
.start = hidp_start, .start = hidp_start,
.stop = hidp_stop, .stop = hidp_stop,
...@@ -743,6 +743,7 @@ static struct hid_ll_driver hidp_hid_driver = { ...@@ -743,6 +743,7 @@ static struct hid_ll_driver hidp_hid_driver = {
.raw_request = hidp_raw_request, .raw_request = hidp_raw_request,
.output_report = hidp_output_report, .output_report = hidp_output_report,
}; };
EXPORT_SYMBOL_GPL(hidp_hid_driver);
/* This function sets up the hid device. It does not add it /* This function sets up the hid device. It does not add it
to the HID system. That is done in hidp_add_connection(). */ to the HID system. That is done in hidp_add_connection(). */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment