hid-core.c revision ad734bc1565364f9e4b70888d3ce5743b3c1030a
1dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 2229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosina * HID support for Linux 3dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * 4dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Copyright (c) 1999 Andreas Gal 5dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 77d39e849912f0c3c8c6fc94be7bf7d120b1ee0baJiri Kosina * Copyright (c) 2006-2010 Jiri Kosina 8dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 9dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 10dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 11dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * This program is free software; you can redistribute it and/or modify it 12dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * under the terms of the GNU General Public License as published by the Free 13dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Software Foundation; either version 2 of the License, or (at your option) 14dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * any later version. 15dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 16dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 174291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 184291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches 19dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/module.h> 20dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/slab.h> 21dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/init.h> 22dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/kernel.h> 23dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/list.h> 24dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/mm.h> 25dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/spinlock.h> 26dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <asm/unaligned.h> 27dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <asm/byteorder.h> 28dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/input.h> 29dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/wait.h> 3047a80edb1d80ae644ea374a016c8e68d43d2671fJiri Kosina#include <linux/vmalloc.h> 31c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina#include <linux/sched.h> 324ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann#include <linux/semaphore.h> 33dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 34dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/hid.h> 35dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/hiddev.h> 36c080d89ad91e98fec0e8fc5f448a1ad899bd85c7Jiri Kosina#include <linux/hid-debug.h> 3786166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina#include <linux/hidraw.h> 38dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 395f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby#include "hid-ids.h" 405f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby 41dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 42dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Version Information 43dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 44dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 45531498013163c72cee8540e98e12c0c430c7fe87Jiri Kosina#define DRIVER_DESC "HID core driver" 46dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#define DRIVER_LICENSE "GPL" 47dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 4858037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosinaint hid_debug = 0; 49377e10fbb4ef219f540d06796e9fb0d3ec35a58fAnssi Hannulamodule_param_named(debug, hid_debug, int, 0600); 50cd667ce24796700e1a0e6e7528efc61c96ff832eJiri KosinaMODULE_PARM_DESC(debug, "toggle HID debugging messages"); 5158037eb961f859607b161c50d9d4ecb374de1e8fJiri KosinaEXPORT_SYMBOL_GPL(hid_debug); 5258037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina 53dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 54dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Register a new report for a device. 55dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 56dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 5790a006abf8015c8cab893555244d8fc673b24839Michael Poolestruct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 58dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 59dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report_enum *report_enum = device->report_enum + type; 60dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report *report; 61dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 62dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report_enum->report_id_hash[id]) 63dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return report_enum->report_id_hash[id]; 64dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 65a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); 66a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!report) 67dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 68dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 69dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (id != 0) 70dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report_enum->numbered = 1; 71dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 72dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->id = id; 73dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->type = type; 74dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->size = 0; 75dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->device = device; 76dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report_enum->report_id_hash[id] = report; 77dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 78dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina list_add_tail(&report->list, &report_enum->report_list); 79dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 80dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return report; 81dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 8290a006abf8015c8cab893555244d8fc673b24839Michael PooleEXPORT_SYMBOL_GPL(hid_register_report); 83dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 84dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 85dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Register a new field for this report. 86dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 87dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 88dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 89dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 90dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_field *field; 91dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 92dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report->maxfield == HID_MAX_FIELDS) { 9358037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("too many fields in report\n"); 94dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 95dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 96dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 97a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches field = kzalloc((sizeof(struct hid_field) + 98a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches usages * sizeof(struct hid_usage) + 99a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches values * sizeof(unsigned)), GFP_KERNEL); 100a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!field) 101a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches return NULL; 102dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 103dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->index = report->maxfield++; 104dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->field[field->index] = field; 105dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->usage = (struct hid_usage *)(field + 1); 106282bfd4cbcc2bbeb1a2cad1f42debd378e0b5ac9Jiri Slaby field->value = (s32 *)(field->usage + usages); 107dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report = report; 108dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 109dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return field; 110dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 111dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 112dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 113dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Open a collection. The type/usage is pushed on the stack. 114dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 115dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 116dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int open_collection(struct hid_parser *parser, unsigned type) 117dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 118dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_collection *collection; 119dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned usage; 120dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 121dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina usage = parser->local.usage[0]; 122dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 123dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 12458037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("collection stack overflow\n"); 125dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 126dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 127dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 128dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->device->maxcollection == parser->device->collection_size) { 129dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection = kmalloc(sizeof(struct hid_collection) * 130dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size * 2, GFP_KERNEL); 131dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (collection == NULL) { 13258037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("failed to reallocate collection array\n"); 133dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 134dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 135dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memcpy(collection, parser->device->collection, 136dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina sizeof(struct hid_collection) * 137dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size); 138dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memset(collection + parser->device->collection_size, 0, 139dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina sizeof(struct hid_collection) * 140dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size); 141dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(parser->device->collection); 142dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection = collection; 143dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size *= 2; 144dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 145dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 146dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack[parser->collection_stack_ptr++] = 147dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->maxcollection; 148dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 149dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection = parser->device->collection + 150dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->maxcollection++; 151dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection->type = type; 152dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection->usage = usage; 153dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection->level = parser->collection_stack_ptr - 1; 154dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 155dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (type == HID_COLLECTION_APPLICATION) 156dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->maxapplication++; 157dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 158dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 159dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 160dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 161dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 162dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Close a collection. 163dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 164dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 165dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int close_collection(struct hid_parser *parser) 166dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 167dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (!parser->collection_stack_ptr) { 16858037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("collection stack underflow\n"); 169dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 170dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 171dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack_ptr--; 172dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 173dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 174dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 175dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 176dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Climb up the stack, search for the specified collection type 177dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * and return the usage. 178dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 179dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 180dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 181dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 182504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches struct hid_collection *collection = parser->device->collection; 183dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int n; 184504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches 185504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { 186504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches unsigned index = parser->collection_stack[n]; 187504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches if (collection[index].type == type) 188504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches return collection[index].usage; 189504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches } 190dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; /* we know nothing about this usage type */ 191dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 192dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 193dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 194dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Add a usage to the temporary parser table. 195dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 196dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 197dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_add_usage(struct hid_parser *parser, unsigned usage) 198dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 199dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->local.usage_index >= HID_MAX_USAGES) { 20058037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("usage index exceeded\n"); 201dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 202dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 203dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.usage[parser->local.usage_index] = usage; 204dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.collection_index[parser->local.usage_index] = 205dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack_ptr ? 206dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 207dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.usage_index++; 208dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 209dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 210dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 211dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 212dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Register a new field for this report. 213dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 214dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 215dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 216dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 217dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report *report; 218dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_field *field; 219dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int usages; 220dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned offset; 221dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int i; 222dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 223a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches report = hid_register_report(parser->device, report_type, parser->global.report_id); 224a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!report) { 22558037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("hid_register_report failed\n"); 226dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 227dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 228dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 229dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->global.logical_maximum < parser->global.logical_minimum) { 23058037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); 231dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 232dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 233dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 234dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina offset = report->size; 235dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->size += parser->global.report_size * parser->global.report_count; 236dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 237dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (!parser->local.usage_index) /* Ignore padding fields */ 238dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 239dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 240dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina usages = max_t(int, parser->local.usage_index, parser->global.report_count); 241dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 242a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches field = hid_register_field(report, usages, parser->global.report_count); 243a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!field) 244dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 245dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 246dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 247dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 248dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 249dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 250dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (i = 0; i < usages; i++) { 251dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int j = i; 252dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina /* Duplicate the last usage we parsed if we have excess values */ 253dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (i >= parser->local.usage_index) 254dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina j = parser->local.usage_index - 1; 255dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->usage[i].hid = parser->local.usage[j]; 256dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->usage[i].collection_index = 257dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.collection_index[j]; 258dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 259dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 260dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->maxusage = usages; 261dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->flags = flags; 262dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_offset = offset; 263dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_type = report_type; 264dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_size = parser->global.report_size; 265dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_count = parser->global.report_count; 266dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->logical_minimum = parser->global.logical_minimum; 267dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->logical_maximum = parser->global.logical_maximum; 268dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->physical_minimum = parser->global.physical_minimum; 269dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->physical_maximum = parser->global.physical_maximum; 270dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->unit_exponent = parser->global.unit_exponent; 271dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->unit = parser->global.unit; 272dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 273dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 274dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 275dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 276dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 277dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Read data value from item. 278dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 279dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 280dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic u32 item_udata(struct hid_item *item) 281dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 282dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->size) { 283880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 1: return item->data.u8; 284880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 2: return item->data.u16; 285880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 4: return item->data.u32; 286dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 287dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 288dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 289dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 290dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic s32 item_sdata(struct hid_item *item) 291dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 292dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->size) { 293880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 1: return item->data.s8; 294880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 2: return item->data.s16; 295880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 4: return item->data.s32; 296dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 297dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 298dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 299dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 300dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 301dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a global item. 302dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 303dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 304dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 305dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 306dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->tag) { 307880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_PUSH: 308dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 309880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 31025985edcedea6396277003854657b5f3cb31a628Lucas De Marchi dbg_hid("global environment stack overflow\n"); 311880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 312880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 313dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 314880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby memcpy(parser->global_stack + parser->global_stack_ptr++, 315880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby &parser->global, sizeof(struct hid_global)); 316880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 317dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 318880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_POP: 319dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 320880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (!parser->global_stack_ptr) { 32125985edcedea6396277003854657b5f3cb31a628Lucas De Marchi dbg_hid("global environment stack underflow\n"); 322880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 323880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 324dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 325880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby memcpy(&parser->global, parser->global_stack + 326880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby --parser->global_stack_ptr, sizeof(struct hid_global)); 327880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 328dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 329880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 330880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.usage_page = item_udata(item); 331880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 332dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 333880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 334880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.logical_minimum = item_sdata(item); 335880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 336dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 337880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 338880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.logical_minimum < 0) 339880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.logical_maximum = item_sdata(item); 340880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby else 341880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.logical_maximum = item_udata(item); 342880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 343dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 344880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 345880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.physical_minimum = item_sdata(item); 346880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 347dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 348880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 349880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.physical_minimum < 0) 350880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.physical_maximum = item_sdata(item); 351880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby else 352880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.physical_maximum = item_udata(item); 353880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 354dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 355880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 356880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.unit_exponent = item_sdata(item); 357880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 358dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 359880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_UNIT: 360880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.unit = item_udata(item); 361880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 362dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 363880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 364880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_size = item_udata(item); 365880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.report_size > 32) { 366880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("invalid report_size %d\n", 367880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_size); 368880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 369880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 370880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 371dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 372880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 373880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_count = item_udata(item); 374880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.report_count > HID_MAX_USAGES) { 375880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("invalid report_count %d\n", 376880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_count); 377880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 378880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 379880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 380dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 381880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_REPORT_ID: 382880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_id = item_udata(item); 383880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.report_id == 0) { 384880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("report_id 0 is invalid\n"); 385dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 386880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 387880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 388880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 389880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby default: 390880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("unknown global tag 0x%x\n", item->tag); 391880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 392dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 393dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 394dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 395dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 396dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a local item. 397dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 398dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 399dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 400dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 401dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __u32 data; 402dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 403dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 404dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina data = item_udata(item); 405dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 406dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->tag) { 407880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_DELIMITER: 408880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 409880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (data) { 410880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby /* 411880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * We treat items before the first delimiter 412880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * as global to all usage sets (branch 0). 413880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * In the moment we process only these global 414880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * items and the first delimiter set. 415880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby */ 416880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_depth != 0) { 417880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("nested delimiters\n"); 418880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 419dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 420880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.delimiter_depth++; 421880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.delimiter_branch++; 422880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } else { 423880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_depth < 1) { 424880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("bogus close delimiter\n"); 425880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 426dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 427880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.delimiter_depth--; 428880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 429880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 1; 430dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 431880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_USAGE: 432dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 433880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_branch > 1) { 434880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("alternative usage ignored\n"); 435880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 436880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 437dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 438880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (item->size <= 2) 439880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby data = (parser->global.usage_page << 16) + data; 440dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 441880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return hid_add_usage(parser, data); 442dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 443880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 444dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 445880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_branch > 1) { 446880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("alternative usage ignored\n"); 447dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 448880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 449dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 450880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (item->size <= 2) 451880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby data = (parser->global.usage_page << 16) + data; 452dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 453880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.usage_minimum = data; 454880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 455dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 456880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 457dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 458880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_branch > 1) { 459880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("alternative usage ignored\n"); 460dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 461880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 462dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 463880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (item->size <= 2) 464880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby data = (parser->global.usage_page << 16) + data; 465dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 466880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby for (n = parser->local.usage_minimum; n <= data; n++) 467880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (hid_add_usage(parser, n)) { 468880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("hid_add_usage failed\n"); 469880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 470880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 471880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 472880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 473880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby default: 474880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 475880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("unknown local item tag 0x%x\n", item->tag); 476880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 477dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 478dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 479dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 480dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 481dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 482dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a main item. 483dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 484dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 485dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 486dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 487dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __u32 data; 488dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int ret; 489dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 490dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina data = item_udata(item); 491dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 492dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->tag) { 493880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 494880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = open_collection(parser, data & 0xff); 495880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 496880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_END_COLLECTION: 497880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = close_collection(parser); 498880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 499880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_INPUT: 500880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = hid_add_field(parser, HID_INPUT_REPORT, data); 501880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 502880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_OUTPUT: 503880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 504880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 505880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_FEATURE: 506880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 507880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 508880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby default: 509880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("unknown main item tag 0x%x\n", item->tag); 510880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = 0; 511dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 512dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 513dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 514dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 515dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return ret; 516dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 517dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 518dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 519dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a reserved item. 520dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 521dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 522dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 523dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 52458037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("reserved item type, tag 0x%x\n", item->tag); 525dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 526dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 527dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 528dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 529dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Free a report and all registered fields. The field->usage and 530dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * field->value table's are allocated behind the field, so we need 531dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * only to free(field) itself. 532dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 533dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 534dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic void hid_free_report(struct hid_report *report) 535dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 536dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 537dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 538dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < report->maxfield; n++) 539dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(report->field[n]); 540dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(report); 541dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 542dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 543dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 544dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Free a device structure, all reports, and all fields. 545dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 546dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 54785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic void hid_device_release(struct device *dev) 548dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 54985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *device = container_of(dev, struct hid_device, dev); 55085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned i, j; 551dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 552dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (i = 0; i < HID_REPORT_TYPES; i++) { 553dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report_enum *report_enum = device->report_enum + i; 554dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 555dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (j = 0; j < 256; j++) { 556dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report *report = report_enum->report_id_hash[j]; 557dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report) 558dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_free_report(report); 559dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 560dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 561dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 562dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(device->rdesc); 563767fe7877c2928b5633992ee60a49ad4516dc2afJiri Kosina kfree(device->collection); 564dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(device); 565dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 566dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 567dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 568dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Fetch a report description item from the data stream. We support long 569dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * items, though they are not used yet. 570dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 571dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 572dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 573dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 574dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina u8 b; 575dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 576dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if ((end - start) <= 0) 577dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 578dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 579dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina b = *start++; 580dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 581dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->type = (b >> 2) & 3; 582dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->tag = (b >> 4) & 15; 583dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 584dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (item->tag == HID_ITEM_TAG_LONG) { 585dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 586dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->format = HID_ITEM_FORMAT_LONG; 587dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 588dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if ((end - start) < 2) 589dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 590dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 591dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->size = *start++; 592dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->tag = *start++; 593dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 594dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if ((end - start) < item->size) 595dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 596dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 597dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->data.longdata = start; 598dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina start += item->size; 599dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return start; 600dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 601dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 602dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->format = HID_ITEM_FORMAT_SHORT; 603dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->size = b & 3; 604dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 605dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->size) { 606880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 0: 607880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 608dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 609880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 1: 610880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if ((end - start) < 1) 611880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return NULL; 612880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->data.u8 = *start++; 613880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 614880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 615880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 2: 616880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if ((end - start) < 2) 617880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return NULL; 618880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->data.u16 = get_unaligned_le16(start); 619880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby start = (__u8 *)((__le16 *)start + 1); 620880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 621880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 622880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 3: 623880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->size++; 624880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if ((end - start) < 4) 625880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return NULL; 626880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->data.u32 = get_unaligned_le32(start); 627880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby start = (__u8 *)((__le32 *)start + 1); 628880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 629dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 630dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 631dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 632dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 633dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 63485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 63585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_parse_report - parse device report 63685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 63785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @device: hid device 63885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @start: report start 63985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @size: report size 64085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 641dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Parse a report description into a hid_device structure. Reports are 642dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * enumerated, fields are attached to these reports. 64385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 0 returned on success, otherwise nonzero error value. 644dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 64585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint hid_parse_report(struct hid_device *device, __u8 *start, 64685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned size) 647dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 648dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_parser *parser; 649dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_item item; 650dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __u8 *end; 65185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 652dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina static int (*dispatch_type[])(struct hid_parser *parser, 653dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_item *item) = { 654dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_main, 655dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_global, 656dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_local, 657dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_reserved 658dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina }; 659dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 660c500c9714011edab021591340042787722db9cf0Jiri Slaby if (device->driver->report_fixup) 66173e4008ddddc84d5f2499c17012b340a0dae153eNikolai Kondrashov start = device->driver->report_fixup(device, start, &size); 662c500c9714011edab021591340042787722db9cf0Jiri Slaby 6631721a238ba5df9e870ed952464d38714261f5be9Julia Lawall device->rdesc = kmemdup(start, size, GFP_KERNEL); 66485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (device->rdesc == NULL) 66585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 666dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina device->rsize = size; 667dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 668fe2580204d8bbcd18540736a283ed0b784c6a024Joe Perches parser = vzalloc(sizeof(struct hid_parser)); 66985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!parser) { 67085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = -ENOMEM; 67185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 672dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 67385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 674dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device = device; 675dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 676dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina end = start + size; 67785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = -EINVAL; 678dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina while ((start = fetch_item(start, end, &item)) != NULL) { 679dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 680dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (item.format != HID_ITEM_FORMAT_SHORT) { 68158037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("unexpected long global item\n"); 68285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 683dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 684dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 685dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (dispatch_type[item.type](parser, &item)) { 68658037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("item %u %u %u %u parsing failed\n", 6874291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches item.format, (unsigned)item.size, 6884291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches (unsigned)item.type, (unsigned)item.tag); 68985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 690dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 691dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 692dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (start == end) { 693dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->collection_stack_ptr) { 69458037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("unbalanced collection at end of report description\n"); 69585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 696dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 697dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->local.delimiter_depth) { 69858037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("unbalanced delimiter at end of report description\n"); 69985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 700dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 70147a80edb1d80ae644ea374a016c8e68d43d2671fJiri Kosina vfree(parser); 70285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 703dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 704dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 705dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 70658037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); 70785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr: 70847a80edb1d80ae644ea374a016c8e68d43d2671fJiri Kosina vfree(parser); 70985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 710dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 711229695e51efc4ed5e04ab471c82591d0f432909dJiri KosinaEXPORT_SYMBOL_GPL(hid_parse_report); 712dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 713dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 714dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Convert a signed n-bit integer to signed 32-bit integer. Common 715dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * cases are done through the compiler, the screwed things has to be 716dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * done by hand. 717dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 718dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 719dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic s32 snto32(__u32 value, unsigned n) 720dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 721dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (n) { 722880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 8: return ((__s8)value); 723880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 16: return ((__s16)value); 724880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 32: return ((__s32)value); 725dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 726dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return value & (1 << (n - 1)) ? value | (-1 << n) : value; 727dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 728dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 729dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 730dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Convert a signed 32-bit integer to a signed n-bit integer. 731dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 732dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 733dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic u32 s32ton(__s32 value, unsigned n) 734dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 735dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina s32 a = value >> (n - 1); 736dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (a && a != -1) 737dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 738dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return value & ((1 << n) - 1); 739dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 740dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 741dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 742dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Extract/implement a data field from/to a little endian report (bit array). 743dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * 744dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Code sort-of follows HID spec: 745dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 746dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * 747dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * While the USB HID spec allows unlimited length bit fields in "report 748dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * descriptors", most devices never use more than 16 bits. 749dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * One model of UPS is claimed to report "LINEV" as a 32-bit field. 750dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 751dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 752dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 75316ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perchesstatic __u32 extract(const struct hid_device *hid, __u8 *report, 75416ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perches unsigned offset, unsigned n) 755dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 756dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina u64 x; 757dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 758c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina if (n > 32) 7594291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 7604291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches n, current->comm); 761dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 762dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report += offset >> 3; /* adjust byte index */ 763229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosina offset &= 7; /* now only need bit offset into one byte */ 764c105068f2b35343eecf2bf16ee29a362b6121fa3Harvey Harrison x = get_unaligned_le64(report); 765229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosina x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 766dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return (u32) x; 767dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 768dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 769dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 770dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * "implement" : set bits in a little endian bit stream. 771dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Same concepts as "extract" (see comments above). 772dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * The data mangled in the bit stream remains in little endian 773dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * order the whole time. It make more sense to talk about 774dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * endianness of register values by considering a register 775dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * a "cached" copy of the little endiad bit stream. 776dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 77716ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perchesstatic void implement(const struct hid_device *hid, __u8 *report, 77816ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perches unsigned offset, unsigned n, __u32 value) 779dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 7806f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison u64 x; 781dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina u64 m = (1ULL << n) - 1; 782dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 783c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina if (n > 32) 7844291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", 7854291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches __func__, n, current->comm); 786dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 787c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina if (value > m) 7884291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_warn(hid, "%s() called with too large value %d! (%s)\n", 7894291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches __func__, value, current->comm); 790dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina WARN_ON(value > m); 791dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina value &= m; 792dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 793dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report += offset >> 3; 794dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina offset &= 7; 795dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 7966f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison x = get_unaligned_le64(report); 7976f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison x &= ~(m << offset); 7986f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison x |= ((u64)value) << offset; 7996f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison put_unaligned_le64(x, report); 800dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 801dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 802dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 803dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Search an array for a value. 804dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 805dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 80616ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perchesstatic int search(__s32 *array, __s32 value, unsigned n) 807dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 808dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina while (n--) { 809dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (*array++ == value) 810dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 811dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 812dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 813dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 814dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 81585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 81685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_match_report - check if driver's raw_event should be called 81785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 81885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hid: hid device 81985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @report_type: type to match against 82085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 82185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * compare hid->driver->report_table->report_type to report->type 82285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 82385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_match_report(struct hid_device *hid, struct hid_report *report) 824dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 82585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const struct hid_report_id *id = hid->driver->report_table; 82685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 82785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!id) /* NULL means all */ 82885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 82985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 83085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (; id->report_type != HID_TERMINATOR; id++) 83185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (id->report_type == HID_ANY_ID || 83285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->report_type == report->type) 83385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 83485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 83585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 83685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 83785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 83885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_match_usage - check if driver's event should be called 83985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 84085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hid: hid device 84185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @usage: usage to match against 84285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 84385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * compare hid->driver->usage_table->usage_{type,code} to 84485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * usage->usage_{type,code} 84585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 84685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 84785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 84885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const struct hid_usage_id *id = hid->driver->usage_table; 84985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 85085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!id) /* NULL means all */ 85185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 85285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 85385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (; id->usage_type != HID_ANY_ID - 1; id++) 85485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if ((id->usage_hid == HID_ANY_ID || 85585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->usage_hid == usage->hid) && 85685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby (id->usage_type == HID_ANY_ID || 85785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->usage_type == usage->type) && 85885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby (id->usage_code == HID_ANY_ID || 85985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->usage_code == usage->code)) 86085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 86185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 86285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 86385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 86485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic void hid_process_event(struct hid_device *hid, struct hid_field *field, 86585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_usage *usage, __s32 value, int interrupt) 86685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 86785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = hid->driver; 86885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 86985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 870cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_dump_input(hid, usage, value); 87185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 87285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 87385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = hdrv->event(hid, field, usage, value); 87485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret != 0) { 87585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret < 0) 87685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("%s's event failed with %d\n", 87785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->name, ret); 87885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return; 87985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 88085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 88185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 882dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 883dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hidinput_hid_event(hid, field, usage, value); 884aa938f7974b82cfd9ee955031987344f332b7c77Jiri Kosina if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 885aa938f7974b82cfd9ee955031987344f332b7c77Jiri Kosina hid->hiddev_hid_event(hid, field, usage, value); 886dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 887dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 888dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 889dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Analyse a received field, and fetch the data from it. The field 890dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * content is stored for next report processing (we do differential 891dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * reporting to the layer). 892dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 893dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 894abdff0f7749a6696ba2a4238b675cbc55abcdb7aAdrian Bunkstatic void hid_input_field(struct hid_device *hid, struct hid_field *field, 895abdff0f7749a6696ba2a4238b675cbc55abcdb7aAdrian Bunk __u8 *data, int interrupt) 896dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 897dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 898dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned count = field->report_count; 899dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned offset = field->report_offset; 900dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned size = field->report_size; 901dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __s32 min = field->logical_minimum; 902dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __s32 max = field->logical_maximum; 903dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __s32 *value; 904dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 905a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); 906a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!value) 907dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return; 908dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 909dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < count; n++) { 910dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 9114291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches value[n] = min < 0 ? 9124291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches snto32(extract(hid, data, offset + n * size, size), 9134291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches size) : 9144291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches extract(hid, data, offset + n * size, size); 915dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 9164291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches /* Ignore report if ErrorRollOver */ 9174291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && 9184291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches value[n] >= min && value[n] <= max && 9194291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 9204291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches goto exit; 921dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 922dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 923dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < count; n++) { 924dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 925dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (HID_MAIN_ITEM_VARIABLE & field->flags) { 926dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 927dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina continue; 928dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 929dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 930dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (field->value[n] >= min && field->value[n] <= max 931dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && field->usage[field->value[n] - min].hid 932dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && search(value, field->value[n], count)) 933dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 934dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 935dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (value[n] >= min && value[n] <= max 936dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && field->usage[value[n] - min].hid 937dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && search(field->value, value[n], count)) 938dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 939dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 940dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 941dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memcpy(field->value, value, count * sizeof(__s32)); 942dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinaexit: 943dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(value); 944dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 945dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 946dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 947dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Output the field into the report. 948dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 949dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 9504291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perchesstatic void hid_output_field(const struct hid_device *hid, 9514291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches struct hid_field *field, __u8 *data) 952dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 953dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned count = field->report_count; 954dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned offset = field->report_offset; 955dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned size = field->report_size; 956dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 957dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 958dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < count; n++) { 959dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (field->logical_minimum < 0) /* signed values */ 9604291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches implement(hid, data, offset + n * size, size, 9614291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches s32ton(field->value[n], size)); 962dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina else /* unsigned values */ 9634291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches implement(hid, data, offset + n * size, size, 9644291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches field->value[n]); 965dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 966dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 967dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 968dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 969dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Create a report. 970dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 971dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 972229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosinavoid hid_output_report(struct hid_report *report, __u8 *data) 973dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 974dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 975dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 976dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report->id > 0) 977dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina *data++ = report->id; 978dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 97975c28df87eb6d8e1389af67f26fbe2394e28385ePete Zaitcev memset(data, 0, ((report->size - 1) >> 3) + 1); 980dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < report->maxfield; n++) 9814291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_output_field(report->device, report->field[n], data); 982dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 983229695e51efc4ed5e04ab471c82591d0f432909dJiri KosinaEXPORT_SYMBOL_GPL(hid_output_report); 984dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 985dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 986dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Set a field value. The report this field belongs to has to be 987dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * created and transferred to the device, to set this value in the 988dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * device. 989dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 990dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 991dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinaint hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 992dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 993dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned size = field->report_size; 994dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 995cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_dump_input(field->report->device, field->usage + offset, value); 996dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 997dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (offset >= field->report_count) { 99858037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); 999dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 1000dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 1001dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (field->logical_minimum < 0) { 1002dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (value != snto32(s32ton(value, size), size)) { 100358037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("value %d is out of range\n", value); 1004dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 1005dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 1006dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 1007dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->value[offset] = value; 1008dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 1009dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 1010229695e51efc4ed5e04ab471c82591d0f432909dJiri KosinaEXPORT_SYMBOL_GPL(hid_set_field); 1011dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 101285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 101385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const u8 *data) 1014aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina{ 1015aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina struct hid_report *report; 101685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int n = 0; /* Normally report number is 0 */ 1017aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 101885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby /* Device uses numbered reports, data[0] is report number */ 101985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (report_enum->numbered) 102085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby n = *data; 1021aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 102285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby report = report_enum->report_id_hash[n]; 102385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (report == NULL) 102485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("undefined report_id %u received\n", n); 1025aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 102685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return report; 102785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 1028aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 102985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyvoid hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 103085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int interrupt) 103185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 103285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_report_enum *report_enum = hid->report_enum + type; 103385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_report *report; 103485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int a; 103585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int rsize, csize = size; 103685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby u8 *cdata = data; 1037aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 103885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby report = hid_get_report(report_enum, data); 103985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!report) 104085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return; 1041aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 104285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (report_enum->numbered) { 104385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby cdata++; 104485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby csize--; 1045aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina } 1046aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1047aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina rsize = ((report->size - 1) >> 3) + 1; 1048aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1049966922f26c7fb5eddbe3c506b66bb5659f57b76fArmando Visconti if (rsize > HID_MAX_BUFFER_SIZE) 1050966922f26c7fb5eddbe3c506b66bb5659f57b76fArmando Visconti rsize = HID_MAX_BUFFER_SIZE; 1051966922f26c7fb5eddbe3c506b66bb5659f57b76fArmando Visconti 105285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (csize < rsize) { 105385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("report %d is too short, (%d < %d)\n", report->id, 105485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby csize, rsize); 105585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby memset(cdata + csize, 0, rsize - csize); 1056aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina } 1057aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1058aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1059aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina hid->hiddev_report_event(hid, report); 10605a38f2c7c4dd53d5be097930902c108e362584a3Alan Ott if (hid->claimed & HID_CLAIMED_HIDRAW) 10615a38f2c7c4dd53d5be097930902c108e362584a3Alan Ott hidraw_report_event(hid, data, size); 1062aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 106385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (a = 0; a < report->maxfield; a++) 106485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hid_input_field(hid, report->field[a], cdata, interrupt); 1065aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1066aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 1067aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina hidinput_report_event(hid, report); 106885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 106985cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_report_raw_event); 107085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 107185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 107285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_input_report - report data from lower layer (usb, bt...) 107385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 107485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hid: hid device 107585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @type: HID report type (HID_*_REPORT) 107685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @data: report contents 107785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @size: size of data parameter 1078ff9b00a226ccea66e6ce70e9083c42f5b6001f73Jiri Kosina * @interrupt: distinguish between interrupt and control transfers 107985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 108085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * This is data entry for lower layers. 108185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 108285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 108385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 108476c317d6e5cb7f58541879006d39774596962715Julia Lawall struct hid_report_enum *report_enum; 108576c317d6e5cb7f58541879006d39774596962715Julia Lawall struct hid_driver *hdrv; 108685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_report *report; 1087cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina char *buf; 108885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int i; 108945dc1ac73d28b3adb5819818785e758b1f369b74Jiri Kosina int ret = 0; 109085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 10914ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (!hid) 109285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENODEV; 10934ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann 10944ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (down_trylock(&hid->driver_lock)) 10954ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann return -EBUSY; 10964ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann 10974ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (!hid->driver) { 10984ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann ret = -ENODEV; 10994ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann goto unlock; 11004ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann } 110176c317d6e5cb7f58541879006d39774596962715Julia Lawall report_enum = hid->report_enum + type; 110276c317d6e5cb7f58541879006d39774596962715Julia Lawall hdrv = hid->driver; 110385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 110485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!size) { 110585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("empty report\n"); 11064ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann ret = -1; 11074ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann goto unlock; 110885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 110985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1110d1ff65226c5afe55f9af38a439058f41b71e114fJiri Kosina buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1111cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina 1112f77e347bd44e3640bdc56003b7402c63ddb1241dJiri Kosina if (!buf) 1113cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina goto nomem; 111485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 111585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby /* dump the report */ 1116cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 11171caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); 1118cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_debug_event(hid, buf); 11191caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina 1120cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina for (i = 0; i < size; i++) { 1121cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1122cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina " %02x", data[i]); 1123cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_debug_event(hid, buf); 1124cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina } 1125cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_debug_event(hid, "\n"); 1126cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina kfree(buf); 112785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1128cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosinanomem: 11291caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina report = hid_get_report(report_enum, data); 11301caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina 11314ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (!report) { 11324ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann ret = -1; 11334ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann goto unlock; 11344ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann } 113585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 113685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 113785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = hdrv->raw_event(hid, report, data, size); 11384ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (ret != 0) { 11394ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann ret = ret < 0 ? ret : 0; 11404ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann goto unlock; 11414ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann } 114285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 114385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 114485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hid_report_raw_event(hid, type, data, size, interrupt); 1145aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 11464ea5454203d991ec85264f64f89ca8855fce69b0David Herrmannunlock: 11474ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann up(&hid->driver_lock); 114845dc1ac73d28b3adb5819818785e758b1f369b74Jiri Kosina return ret; 1149aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina} 1150aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri KosinaEXPORT_SYMBOL_GPL(hid_input_report); 1151aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 11520f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic bool hid_match_one_id(struct hid_device *hdev, 11530f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina const struct hid_device_id *id) 11540f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina{ 11550f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return id->bus == hdev->bus && 11560f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 11570f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina (id->product == HID_ANY_ID || id->product == hdev->product); 11580f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina} 11590f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11600f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic const struct hid_device_id *hid_match_id(struct hid_device *hdev, 11610f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina const struct hid_device_id *id) 11620f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina{ 11630f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina for (; id->bus; id++) 11640f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina if (hid_match_one_id(hdev, id)) 11650f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return id; 11660f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11670f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return NULL; 11680f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina} 11690f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11700f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic const struct hid_device_id hid_hiddev_list[] = { 1171c0bd6a429819f794f626f9e73be4564e18e132dbRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1172c0bd6a429819f794f626f9e73be4564e18e132dbRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 11730f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina { } 11740f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina}; 11750f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11760f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic bool hid_hiddev(struct hid_device *hdev) 11770f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina{ 11780f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return !!hid_match_id(hdev, hid_hiddev_list); 11790f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina} 11800f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11816d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 11826d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ottstatic ssize_t 11836d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ottread_report_descriptor(struct file *filp, struct kobject *kobj, 11846d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott struct bin_attribute *attr, 11856d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott char *buf, loff_t off, size_t count) 11866d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott{ 11876d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott struct device *dev = container_of(kobj, struct device, kobj); 11886d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott struct hid_device *hdev = container_of(dev, struct hid_device, dev); 11896d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 11906d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott if (off >= hdev->rsize) 11916d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott return 0; 11926d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 11936d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott if (off + count > hdev->rsize) 11946d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott count = hdev->rsize - off; 11956d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 11966d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott memcpy(buf, hdev->rdesc + off, count); 11976d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 11986d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott return count; 11996d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott} 12006d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 12016d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ottstatic struct bin_attribute dev_bin_attr_report_desc = { 12026d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott .attr = { .name = "report_descriptor", .mode = 0444 }, 12036d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott .read = read_report_descriptor, 12046d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott .size = HID_MAX_DESCRIPTOR_SIZE, 12056d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott}; 12066d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 120793c10132a7ac160df3175b53f7ee857625412165Jiri Slabyint hid_connect(struct hid_device *hdev, unsigned int connect_mask) 120893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby{ 120993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 121093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby "Joystick", "Gamepad", "Keyboard", "Keypad", 121193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby "Multi-Axis Controller" 121293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby }; 121393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby const char *type, *bus; 121493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby char buf[64]; 121593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby unsigned int i; 121693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby int len; 12176d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott int ret; 121893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 1219b5e5a37e36cd4d355b875665312d7aaae4e5833cBastien Nocera if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) 1220b5e5a37e36cd4d355b875665312d7aaae4e5833cBastien Nocera connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); 12213a343ee4509c982552b35fbc99d3213f3bb1acdeDaniel Mack if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) 12223a343ee4509c982552b35fbc99d3213f3bb1acdeDaniel Mack connect_mask |= HID_CONNECT_HIDINPUT_FORCE; 122393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->bus != BUS_USB) 122493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby connect_mask &= ~HID_CONNECT_HIDDEV; 12250f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina if (hid_hiddev(hdev)) 12260f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina connect_mask |= HID_CONNECT_HIDDEV_FORCE; 122793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 122893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, 122993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby connect_mask & HID_CONNECT_HIDINPUT_FORCE)) 123093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->claimed |= HID_CLAIMED_INPUT; 1231b77c3920e90e96103e4f41442999402925fe5f73Benjamin Tissoires if (hdev->quirks & HID_QUIRK_MULTITOUCH) { 1232b77c3920e90e96103e4f41442999402925fe5f73Benjamin Tissoires /* this device should be handled by hid-multitouch, skip it */ 1233b77c3920e90e96103e4f41442999402925fe5f73Benjamin Tissoires hdev->quirks &= ~HID_QUIRK_MULTITOUCH; 1234b77c3920e90e96103e4f41442999402925fe5f73Benjamin Tissoires return -ENODEV; 1235b77c3920e90e96103e4f41442999402925fe5f73Benjamin Tissoires } 1236b77c3920e90e96103e4f41442999402925fe5f73Benjamin Tissoires 123793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && 123893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby !hdev->hiddev_connect(hdev, 123993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby connect_mask & HID_CONNECT_HIDDEV_FORCE)) 124093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->claimed |= HID_CLAIMED_HIDDEV; 124193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) 124293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->claimed |= HID_CLAIMED_HIDRAW; 124393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 124493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (!hdev->claimed) { 12454291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); 124693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby return -ENODEV; 124793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 124893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 124993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((hdev->claimed & HID_CLAIMED_INPUT) && 125093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby (connect_mask & HID_CONNECT_FF) && hdev->ff_init) 125193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->ff_init(hdev); 125293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 125393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len = 0; 125493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->claimed & HID_CLAIMED_INPUT) 125593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len += sprintf(buf + len, "input"); 125693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->claimed & HID_CLAIMED_HIDDEV) 125793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len += sprintf(buf + len, "%shiddev%d", len ? "," : "", 125893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->minor); 125993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->claimed & HID_CLAIMED_HIDRAW) 126093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len += sprintf(buf + len, "%shidraw%d", len ? "," : "", 126193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby ((struct hidraw *)hdev->hidraw)->minor); 126293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 126393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby type = "Device"; 126493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby for (i = 0; i < hdev->maxcollection; i++) { 126593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby struct hid_collection *col = &hdev->collection[i]; 126693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (col->type == HID_COLLECTION_APPLICATION && 126793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && 126893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby (col->usage & 0xffff) < ARRAY_SIZE(types)) { 126993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby type = types[col->usage & 0xffff]; 127093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby break; 127193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 127293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 127393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 127493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby switch (hdev->bus) { 127593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby case BUS_USB: 127693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby bus = "USB"; 127793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby break; 127893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby case BUS_BLUETOOTH: 127993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby bus = "BLUETOOTH"; 128093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby break; 128193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby default: 128293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby bus = "<UNKNOWN>"; 128393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 128493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 12856d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 12866d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott if (ret) 12876d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott hid_warn(hdev, 12886d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott "can't create sysfs report descriptor attribute err: %d\n", ret); 12896d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott 12904291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 12914291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches buf, bus, hdev->version >> 8, hdev->version & 0xff, 12924291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches type, hdev->name, hdev->phys); 129393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 129493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby return 0; 129593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby} 129693c10132a7ac160df3175b53f7ee857625412165Jiri SlabyEXPORT_SYMBOL_GPL(hid_connect); 129793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 1298c4c259bcc27c4242b012106afdba183622b1735fJiri Kosinavoid hid_disconnect(struct hid_device *hdev) 1299c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina{ 13006d3bfb74341c2c1454fcf5ec9c4dd707011f78e5Alan Ott device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 1301c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina if (hdev->claimed & HID_CLAIMED_INPUT) 1302c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina hidinput_disconnect(hdev); 1303c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDDEV) 1304c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina hdev->hiddev_disconnect(hdev); 1305c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDRAW) 1306c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina hidraw_disconnect(hdev); 1307c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina} 1308c4c259bcc27c4242b012106afdba183622b1735fJiri KosinaEXPORT_SYMBOL_GPL(hid_disconnect); 1309c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina 1310bae7eb33b25387fdc7ccae08768bef1f9484a5b0Jiri Kosina/* a list of devices for which there is a specialized driver on HID bus */ 1311ce06b9d6d33fd2ed799b6e825d68fe95077da354Dmitry Torokhovstatic const struct hid_device_id hid_have_special_driver[] = { 1312b6353f4f36f03a12edaf3fa5365b475a28106035Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 13136dec143a50c01ca0cc0afcbf5ea4bb8e87981edfStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, 131414a21cd459f97e3b3cc4fcde48fc5bcdb81d097eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 131514a21cd459f97e3b3cc4fcde48fc5bcdb81d097eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1316b7e1b2039de3a028fba46fbaca58a45c23a417ecLech Perczak { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, 1317c0dbcc33c652a0646542560de29a1c3f1ab7169fSergei Kolzun { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, 1318e6aac3427ef03f61e7478514d0648b58359d05d1Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) }, 1319df9bcace7b1c29e9be1c13b034ff04f4f4c90edeJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 13208c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 13218c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1322128537cea464d919febeaea2000e256749f317ebMichael Poole { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, 1323a462230e16acc8664145216da3c928d03556691aChase Douglas { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, 13248c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 13258c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 13268c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 13278c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 13288c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 13298c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 13308c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 13318c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 13328c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 13338c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 13348c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1335fef3f571ecc2a82395c531d97b3f71a59e04e946Ryan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, 1336fef3f571ecc2a82395c531d97b3f71a59e04e946Ryan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, 1337fef3f571ecc2a82395c531d97b3f71a59e04e946Ryan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, 13388c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 13398c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 13408c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 13418c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 13428c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 13438c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1344ee8a1a0a1a5817accd03ced7e7ffde3a4430f485Jan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1345ee8a1a0a1a5817accd03ced7e7ffde3a4430f485Jan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1346ee8a1a0a1a5817accd03ced7e7ffde3a4430f485Jan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 13478c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 13488c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 13498c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 13508c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 13518c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 13528c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1353a96d6ef34751093797c3a6c6080733dd7af23d35Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1354a96d6ef34751093797c3a6c6080733dd7af23d35Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1355a96d6ef34751093797c3a6c6080733dd7af23d35Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 135699b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 135799b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 135899b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 135999b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 136099b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 136199b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 136247340bd9fefb571888836da942b5aee0e85e959cAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 136347340bd9fefb571888836da942b5aee0e85e959cAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 136447340bd9fefb571888836da942b5aee0e85e959cAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1365213f9da80533940560bef8fa43b10c590895459cGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1366213f9da80533940560bef8fa43b10c590895459cGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1367213f9da80533940560bef8fa43b10c590895459cGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 13684a4c879904aa0cc64629e14a49b64fb3d149bf1aDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) }, 13694a4c879904aa0cc64629e14a49b64fb3d149bf1aDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) }, 13704a4c879904aa0cc64629e14a49b64fb3d149bf1aDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) }, 1371f6f554f09c5b831efdaf67c449e18ca06ee648feJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 1372f6f554f09c5b831efdaf67c449e18ca06ee648feJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 1373f6f554f09c5b831efdaf67c449e18ca06ee648feJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 1374b3aec7b686329e6bb65aa08c7f9458f7fd512f06Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 1375b3aec7b686329e6bb65aa08c7f9458f7fd512f06Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 1376b3aec7b686329e6bb65aa08c7f9458f7fd512f06Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 137723aeb61e7e1f02fb0f3b8f9e798e75537ca1731dChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 137823aeb61e7e1f02fb0f3b8f9e798e75537ca1731dChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 137923aeb61e7e1f02fb0f3b8f9e798e75537ca1731dChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1380ad734bc1565364f9e4b70888d3ce5743b3c1030aAndreas Krist { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 13818c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 13828c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1383eaca1386207a9e0314647d3a88967acb17cc30e3Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, 1384cec15a0ece19116b6c2c53fedf9696c20124d491Roland Baum { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 1385b5635b129b3ca3a9c879a36f58f5b8c4903d267aJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1386bf280628fca93c4c341587ec914863dcc395af72Wayne Thomas { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1387c3dc66de59531c921c4638b1285075ea1c831186Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 13885519cab477b61326963c8d523520db0342862b63Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 138936213e1e40fb863e2e8ef607b2958504b48f6b8eStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 1390bc5ab083a68bfec212780281f8e57d871d8882a0Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, 1391ba4d8abb31def963f49b7c239a8acce57fe1d1ccStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, 1392272036edb77e5967c175ac48b8c88e9b3358285fFrançois Jaouen { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 13933b239cd739a9499da08326356add3d9d992c7911Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 13941ce31b255cf8b06470dfbd469055b6fd8d2274bcRaphaël Doursenaud { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1395fcfacfd3594d5d2fa99fb5e7d33dee3904b1a156Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1396b9e4b1e0cd401e915e3ba97afc152946f78f9f0bDennis Kügler { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 1397942fd4225f72826b31d893582b6ae7e172bb3202Austin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, 13983a370ca1dcf8c80aff7a0a21d6b0f50ca2a151e9Don Prince { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 139979603dc9a8223856cf3194dcabad32b9828c7be9Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, 14000f2213208f8da51bcb665309e3468f000489c04fJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 14010f2213208f8da51bcb665309e3468f000489c04fJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1402e8d0eab4d9eda9f5e97852f780f020bfb134f9f0Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 14030f2213208f8da51bcb665309e3468f000489c04fJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1404a3b5e577d96bfccbc41ebf4df784e3a153072273Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, 14053f866fbd52d1863db5c07700e560aef22c4fdc01Richard Walmsley { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1406e05eefb9be109e6cbbfd362b49ee83397130a7e4Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 14070c3910c255d3f9caeef4ebad5d5a1156a2d33f69Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, 140883e4491818040ae6b2d9fc60434616304a101d39Chris Ball { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, 14094e93db23bf95cd763c9182b5d6187412fe6ce747Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, 141028906ad6d7c8a8090f720cf7c39461df0b1460f6Richard Nauber { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, 14114dd295a73e80b55c3fec25555bf0a5d253023740Andy Ross { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, 141264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1413c04abeeff9d76a703cac1e6d312853b0fc8136f5Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) }, 141404561c5aa243c98cae93cde27e05740df787e692Ignaz Forster { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, 14151f243e302cea1561ac881eb5d27041c5342beba4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 14165181e594512faeac7d7fd9620ce91105f45bf643Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1417578f3a35fecabff49bad808c5301313f785b5462Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 14185572da08a784621f2ab4fdc8dc65471261871795Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 1419ee0fbd149182d91e3b9df7b306eb03cd1f1dd4a1Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) }, 14205181e594512faeac7d7fd9620ce91105f45bf643Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 142142859e0bd21daba9974757fcfe4a4dde265fe28dLukasz Lubojanski { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, 1422949f8fef77186c7361d22e1ea6f42c76ceda42b0Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 14231e093206734568e780c2717da1c89b97e9471954Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1424c2fd1a4ebf9127c280d227acb635eb1df213439cCory Maccarrone { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 14255519cab477b61326963c8d523520db0342862b63Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, 1426a062cc5a76fa1d12f0821e56e3746cad2dc2fc65Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) }, 1427d946e65e2ab885c05b8cacf292be65fa292d08f6Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, 14284e61f0d75aa86c9e59451f6bcffcdceb355b4fc4Austin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) }, 1429b2e7617e09a8e774d7819c629a0989cbddb5d1abBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, 1430fdf93aa33268889e126aa677f2072238bd76adb0Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1431177900e8c9ab28cdf097314fe7dd3877774df97dJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, 1432794227415f8f5f395a9ed4269a4ee7a3c34f66a5Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 1433b5635b129b3ca3a9c879a36f58f5b8c4903d267aJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 143475b07022462fc33d6be15669ad604118653210a9Chris Schlund { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, 1435c50bb1a4005630f47b5da26336f74a485033a515Jeff Brown { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) }, 14365f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 14375f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 14385f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 14395f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 14405f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 14415f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 14425f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 14435f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 14445f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 14455f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 14465f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 14472c6118e43040034d80894daeba41960bf0035b31Hendrik Iben { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, 1448606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, 1449606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, 1450606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1451fd30ea8c871552ddd6a5e1c0886de8fef4df53bcJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1452606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 145374f292ca8c7a2b9370f80d97a49e48174f4c7635Gary Stein { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, 1454606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1455606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 14565623a24a80814fe471e777f12b9dbbb0f77e002eJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) }, 1457e00ddc9b8f978ffbc6c212f780a2bb83aafe2fbdMichal Malý { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) }, 1458243b706d8a71364ad6080328d45b73516c8af5f3Christophe Borivant { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 1459fdc6807fcd09416c5537f479e1dcd624118e234cPeter Gundermann { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) }, 1460534a7b8e10ec55d9f521e68c20dbb3634c25b98aNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) }, 1461534a7b8e10ec55d9f521e68c20dbb3634c25b98aNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) }, 146232c88cbc3080f43c429f6456aa9cd845e37f3778Simon Wood { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, 1463606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 146424985cf68612a5617d396b0b188cec807641cde1Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 146524985cf68612a5617d396b0b188cec807641cde1Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1466df167c4a0d68a9dbde044a39a77f255ac666f93eBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, 1467c3ead6de4f6bd1c08a81f84e629e3dbf4a9078f0Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, 1468236db47c2b3b69464d50c695ab2ddd516cf64520Bruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1469236db47c2b3b69464d50c695ab2ddd516cf64520Bruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 1470b580169affd7ccc9347cbf4d5f4db1480ee7ee06Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, 147178a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 147278a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 147378a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 147478a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1475f3b83d71a1b1a1569dba774c3a4f6e2a3b9fef99Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 147678a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 14773b8006e51038ef263a0404756d9e190c9a9f74d5Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 147894011f93f2cd7410401e22390cf7a14fe5495a22Rafi Rubin { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 14796e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 14806e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, 14816e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, 14826e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, 14836e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, 14846e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, 14856e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, 14866e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, 14876e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, 14886e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, 14896e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, 14906e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, 14916e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, 14926e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, 14936e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, 14946e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, 14956e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, 14966e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, 1497270fdc0748bd3f7b625caff985f2fcf8e2185ec7Herton Ronaldo Krzesinski { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, 1498cd9ec30da58bcd8ab154eba9eb54d16c67e7ef3bJohnathon Harris { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 14996ab3a9a63fc16b04f7de48eb0190d516dd7574dfJohn Sung { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, 15001e76253220dbe66e048e55680266dd1f4af0be85Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1501f6a04605f303852963f3f357d19b967aa83c172fTerry Lambert { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, 150249e4739a0cf681cbfe08c72232c1dcc130b66ddeStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1503f54405db66fbec11679241daefd16fd8291a5762Alex Neblett { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 150414bf62cde79423a02a590e02664ed29a36facec1Stefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, 1505e68cc603b063416c85f3e408184219fb71d4a9ffStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, 150647dbdbffe15b9582a41727766d43f1d4208e977eStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 15070e70f97f257edcef4daa92ab9371a9aac0c851edStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, 1508cb7cf3da0daa9830e00640da8f7d2380f4b4de42Stefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 15093fce224608f38eac6d6b032b0619c1655acaf61dStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, 1510980a3da6acdd577ee3ae192e868dc52fe4b7f2e5Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1511b355850ba383232d4e0e357c1cda8cb7bfcc60bcDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1512d586dca06adddc6cee7177b013ee93eaffc9fe0eJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1513bd28ce008bdc68ef5902f68d2d62cbb7fa78c415Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 151435dca5b4a67a93bbb75c2753d6dc432dc8f82e5dJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1515f9ce7c283c16538955d5d094101889792bcde109Bastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1516cc6e0bbb47f02fd36cd55b3189c0c79079096ab8Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1517d3fb5454a8474d5d22c8f8fe4d043b05732d91d5Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, 1518b6dc79929fa18a97bbc08400db72405ad835622fPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, 1519b6dc79929fa18a97bbc08400db72405ad835622fPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, 152090231e7eaf752856a2c13f786f36ec7f641bad28Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1521daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1522daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 15237a84b1336a145d683fb8cdfd6c2c67545a58b126Ruben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 15247a84b1336a145d683fb8cdfd6c2c67545a58b126Ruben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1525daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 15263ee8f0a2b1c81f0472b25d40aa5c1c7c6a0edc2aMarkus Rathgeb { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1527daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1528d65c3768afb47fb93c43fbfcafef53502edaaa85Simon Wood { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, 1529f14f526d02b14fd0b8c1ac4ec413e4577ad5f62eLev Babiev { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1530540010812179a16d3d00fb8363bb06ee83af25b8Kees Bakker { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 15315e74e56da03f581482c104628951eeb1455848eaBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, 1532711a680e35059bc5c7c28d3c4bd0bebd3b7bb6eeBruno Premont { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1533c64f6f934c7490faff76faf96217066a1b3570a0Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 153441fa92302be7fa37c5c38e17e2097d3e5e9da13aNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, 1535f8a489cc5f7adafa9f1420279be793de0fba481cNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, 1536f8a489cc5f7adafa9f1420279be793de0fba481cNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, 1537f8a489cc5f7adafa9f1420279be793de0fba481cNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, 15386be914f11db8e88d11b08d6c496624dbbd642d80Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, 1539617b64f97708be26a061e6c8178ad46b4c49d031Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, 1540617b64f97708be26a061e6c8178ad46b4c49d031Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 1541fac733f029251a393c42a8313432f2d9fe43bb83Jussi Kivilinna { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 1542ad395ccadb6b2f0a4f9e004c9e6f2a8c22091ed0Sean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, 15431bcc20675a1ac1ba47eaa201e02a89b0508e17b2Sean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 15441bcc20675a1ac1ba47eaa201e02a89b0508e17b2Sean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 15451bcc20675a1ac1ba47eaa201e02a89b0508e17b2Sean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 1546ca2dcd40f54c8928b3994712a6cadd2078a087faBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 154772a46344867111c3e019b169ddfa9e1a1f55c759Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 154800e7f9649b3061281fe4b463263da26155dc9be4Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 154972a46344867111c3e019b169ddfa9e1a1f55c759Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 15508f1acc32bbdb1784bcb0be98fb02f4b20e6f328fNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1551bc8a2a9b4e5c418bebaa6bb812982b7ecd298821ice chien { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) }, 155274bc6953135ae1478acc18046321bfca05b0e823Stefan Kriwanek { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, 1553daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1554daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1555a9885c8f7bf62e251fc178f838b9f0ee897c158aDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, 15568c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby 155778a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 155802fb72a06ae1ed55b4373a4c678f25d70fd65902David Herrmann { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, 155985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby { } 156085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby}; 156185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 15623a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystruct hid_dynid { 15633a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct list_head list; 15643a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_device_id id; 15653a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby}; 15663a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15673a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby/** 15683a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * store_new_id - add a new HID device ID to this driver and re-probe devices 15693a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * @driver: target device driver 15703a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * @buf: buffer for scanning device ID data 15713a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * @count: input size 15723a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * 15733a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * Adds a new dynamic hid device ID to this driver, 15743a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * and causes the driver to probe for all devices again. 15753a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby */ 15763a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic ssize_t store_new_id(struct device_driver *drv, const char *buf, 15773a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby size_t count) 15783a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby{ 15793a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 15803a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_dynid *dynid; 15813a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby __u32 bus, vendor, product; 15823a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby unsigned long driver_data = 0; 15833a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby int ret; 15843a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15853a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = sscanf(buf, "%x %x %x %lx", 15863a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby &bus, &vendor, &product, &driver_data); 15873a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (ret < 3) 15883a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return -EINVAL; 15893a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15903a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 15913a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (!dynid) 15923a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return -ENOMEM; 15933a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15943a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.bus = bus; 15953a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.vendor = vendor; 15963a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.product = product; 15973a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.driver_data = driver_data; 15983a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15993a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock(&hdrv->dyn_lock); 16003a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_add_tail(&dynid->list, &hdrv->dyn_list); 16013a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 16023a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16033a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = 0; 16043a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (get_driver(&hdrv->driver)) { 16053a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = driver_attach(&hdrv->driver); 16063a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby put_driver(&hdrv->driver); 16073a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 16083a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16093a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return ret ? : count; 16103a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby} 16113a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 16123a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16133a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic void hid_free_dynids(struct hid_driver *hdrv) 16143a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby{ 16153a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_dynid *dynid, *n; 16163a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16173a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock(&hdrv->dyn_lock); 16183a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { 16193a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_del(&dynid->list); 16203a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby kfree(dynid); 16213a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 16223a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 16233a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby} 16243a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16253a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic const struct hid_device_id *hid_match_device(struct hid_device *hdev, 16263a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_driver *hdrv) 16273a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby{ 16283a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_dynid *dynid; 16293a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16303a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock(&hdrv->dyn_lock); 16313a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_for_each_entry(dynid, &hdrv->dyn_list, list) { 16323a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (hid_match_one_id(hdev, &dynid->id)) { 16333a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 16343a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return &dynid->id; 16353a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 16363a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 16373a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 16383a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 16393a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return hid_match_id(hdev, hdrv->id_table); 16403a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby} 16413a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 164285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_bus_match(struct device *dev, struct device_driver *drv) 164385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 164485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 164585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 164685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 16473a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (!hid_match_device(hdev, hdrv)) 164885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 164985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1650ce06b9d6d33fd2ed799b6e825d68fe95077da354Dmitry Torokhov /* generic wants all that don't have specialized driver */ 165185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!strncmp(hdrv->name, "generic-", 8)) 1652ce06b9d6d33fd2ed799b6e825d68fe95077da354Dmitry Torokhov return !hid_match_id(hdev, hid_have_special_driver); 165385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 165485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 165585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 165685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 165785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_device_probe(struct device *dev) 165885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 165985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = container_of(dev->driver, 166085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver, driver); 166185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 166285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const struct hid_device_id *id; 166385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret = 0; 166485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 16654ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (down_interruptible(&hdev->driver_lock)) 16664ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann return -EINTR; 16674ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann 166885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!hdev->driver) { 16693a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby id = hid_match_device(hdev, hdrv); 1670ba623a774f5b529f89b3d63e0837df52e16ffb3bDan Carpenter if (id == NULL) { 1671ba623a774f5b529f89b3d63e0837df52e16ffb3bDan Carpenter ret = -ENODEV; 1672ba623a774f5b529f89b3d63e0837df52e16ffb3bDan Carpenter goto unlock; 1673ba623a774f5b529f89b3d63e0837df52e16ffb3bDan Carpenter } 167485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1675c500c9714011edab021591340042787722db9cf0Jiri Slaby hdev->driver = hdrv; 1676c500c9714011edab021591340042787722db9cf0Jiri Slaby if (hdrv->probe) { 1677c500c9714011edab021591340042787722db9cf0Jiri Slaby ret = hdrv->probe(hdev, id); 1678c500c9714011edab021591340042787722db9cf0Jiri Slaby } else { /* default probe */ 1679c500c9714011edab021591340042787722db9cf0Jiri Slaby ret = hid_parse(hdev); 1680c500c9714011edab021591340042787722db9cf0Jiri Slaby if (!ret) 168193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 168285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 1683c500c9714011edab021591340042787722db9cf0Jiri Slaby if (ret) 1684c500c9714011edab021591340042787722db9cf0Jiri Slaby hdev->driver = NULL; 168585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 1686ba623a774f5b529f89b3d63e0837df52e16ffb3bDan Carpenterunlock: 16874ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann up(&hdev->driver_lock); 168885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 168985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 169085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 169185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_device_remove(struct device *dev) 169285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 169385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 16944ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann struct hid_driver *hdrv; 16954ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann 16964ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann if (down_interruptible(&hdev->driver_lock)) 16974ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann return -EINTR; 169885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 16994ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann hdrv = hdev->driver; 170085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv) { 170185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv->remove) 170285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->remove(hdev); 1703c500c9714011edab021591340042787722db9cf0Jiri Slaby else /* default remove */ 1704c500c9714011edab021591340042787722db9cf0Jiri Slaby hid_hw_stop(hdev); 170585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->driver = NULL; 170685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 170785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 17084ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann up(&hdev->driver_lock); 170985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 171085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 171185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 171285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 171385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 171485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 171585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 171685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 171785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->bus, hdev->vendor, hdev->product)) 171885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 171985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 172085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 172185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 172285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 172385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 172485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 172585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 172685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 172785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 172885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 172985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", 173085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->bus, hdev->vendor, hdev->product)) 173185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 173285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 173385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 173485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 173585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 173685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic struct bus_type hid_bus_type = { 173785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .name = "hid", 173885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .match = hid_bus_match, 173985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .probe = hid_device_probe, 174085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .remove = hid_device_remove, 174185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .uevent = hid_uevent, 174285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby}; 174385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1744bae7eb33b25387fdc7ccae08768bef1f9484a5b0Jiri Kosina/* a list of devices that shouldn't be handled by HID core at all */ 1745d458a9dfc4de24870b8c747484b1988726534beeJiri Slabystatic const struct hid_device_id hid_ignore_list[] = { 1746d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1747d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1748d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1749d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1750d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1751d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1752d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1753d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1754d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1755d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1756d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1757d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 175877f720b71d88a3cbf574c113566a31c93099f97dStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, 175977f720b71d88a3cbf574c113566a31c93099f97dStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, 176062a56582e01b1c5139b235004548e233201df9aaAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1761d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1762d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1763d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1764d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1765d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1766d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 17675f6108cf9be4a77d6bee96750aa4fe18b6b97deeAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, 1768d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1769d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 177073bc7d315f56e260071bdb5f15e25b53bddc1402Melchior FRANZ { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, 1771d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 177270c66567d1e41d8b2186a2d198997a1c8d79c0c4Petr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1773df506f2c0023380ffa67a946fa36eee4150773a3Petr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1774d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1775d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, 1776d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1777d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1778d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1779d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1780d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1781d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1782d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1783d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1784d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1785d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1786d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1787d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1788d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1789d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1790d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1791d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1792d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1793d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1794d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1795d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1796d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1797d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1798d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1799d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1800d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1801d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1802d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1803d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1804d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1805d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1806d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1807d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1808d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1809d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1810d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1811d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1812d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1813d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1814d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1815d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1816d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1817d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1818d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 1819d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 1820d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 1821d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 1822d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 1823d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 1824d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 1825d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 1826d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 1827d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 1828d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 1829d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 1830d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 1831d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 1832d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 1833d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 1834d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 1835d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1836d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1837d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1838d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1839c91c21c5a6facddce936d82e5bc0c655d04288aaAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1840d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1841eb8141ccd32d422fa11c6e2108cae4c40456d811Lamarque Vieira Souza { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, 1842d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1843ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, 1844d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1845ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, 1846d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1847ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, 1848ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, 1849ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, 1850ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 1851ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 1852ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 1853d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 1854d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 1855d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 1856ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, 1857ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, 1858ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, 1859d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 1860d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 1861ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, 1862d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 1863d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 1864d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 1865d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 1866d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 1867ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, 1868ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, 1869ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, 1870ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, 1871ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 1872ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 1873ce97cac813340eb8ecb1c5410041c9eade58f870Michael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 1874d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 1875d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 1876d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 1877d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 1878d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 1879d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 1880d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 1881d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 1882d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 1883d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 1884d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 1885d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 1886d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 1887d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 1888d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 1889d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 1890d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1891d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1892d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 18934cfae3e80431fd113f0f4a8e1d4fff84aafe045cHenning Glawe { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 189435cfd1d964f3c2420862f2167a0eb85ff1208999Michael Tokarev { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 1895d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1896d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1897d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1898d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 1899d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 1900d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 1901d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 1902d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1903d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1904d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1905d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { } 1906d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby}; 1907d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 1908b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby/** 1909b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer 1910b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * 1911b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * There are composite devices for which we want to ignore only a certain 1912b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * interface. This is a list of devices for which only the mouse interface will 1913b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * be ignored. This allows a dedicated driver to take care of the interface. 1914b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby */ 1915b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slabystatic const struct hid_device_id hid_mouse_ignore_list[] = { 1916b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby /* appletouch driver */ 1917b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1918b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1919b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1920b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1921b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1922b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1923b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1924b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1925b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1926b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1927b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1928b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1929b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1930b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1931b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1932b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1933b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1934b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1935b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1936b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1937ac26fca3e14c8882e382daa7e96ab73e0186cf03Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1938ac26fca3e14c8882e382daa7e96ab73e0186cf03Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1939ac26fca3e14c8882e382daa7e96ab73e0186cf03Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 194099b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 194199b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 194299b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 194399b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 194499b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 194599b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 194647340bd9fefb571888836da942b5aee0e85e959cAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 194747340bd9fefb571888836da942b5aee0e85e959cAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 194847340bd9fefb571888836da942b5aee0e85e959cAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1949213f9da80533940560bef8fa43b10c590895459cGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1950213f9da80533940560bef8fa43b10c590895459cGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1951213f9da80533940560bef8fa43b10c590895459cGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 19524b086910ad1b889ddf3ef5598caec03178cf2bb4Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 19534b086910ad1b889ddf3ef5598caec03178cf2bb4Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 19544b086910ad1b889ddf3ef5598caec03178cf2bb4Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 19554b086910ad1b889ddf3ef5598caec03178cf2bb4Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 19564b086910ad1b889ddf3ef5598caec03178cf2bb4Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 19574b086910ad1b889ddf3ef5598caec03178cf2bb4Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 1958b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1959b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1960b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { } 1961b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby}; 1962b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby 1963d458a9dfc4de24870b8c747484b1988726534beeJiri Slabystatic bool hid_ignore(struct hid_device *hdev) 1964d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby{ 1965d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby switch (hdev->vendor) { 1966d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby case USB_VENDOR_ID_CODEMERCS: 1967d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby /* ignore all Code Mercenaries IOWarrior devices */ 1968d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 1969d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 1970d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return true; 1971d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby break; 1972d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby case USB_VENDOR_ID_LOGITECH: 1973d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 1974d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 1975d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return true; 1976d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby break; 197731f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson case USB_VENDOR_ID_SOUNDGRAPH: 197831f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && 197931f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) 198031f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson return true; 198131f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson break; 1982bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei case USB_VENDOR_ID_HANWANG: 1983bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && 1984bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) 1985bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei return true; 1986bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei break; 19876dc1418e13144162e8bc4858789010d8f0e1e65cTomoki Sekiyama case USB_VENDOR_ID_JESS: 19886dc1418e13144162e8bc4858789010d8f0e1e65cTomoki Sekiyama if (hdev->product == USB_DEVICE_ID_JESS_YUREX && 19896dc1418e13144162e8bc4858789010d8f0e1e65cTomoki Sekiyama hdev->type == HID_TYPE_USBNONE) 19906dc1418e13144162e8bc4858789010d8f0e1e65cTomoki Sekiyama return true; 19916dc1418e13144162e8bc4858789010d8f0e1e65cTomoki Sekiyama break; 1992d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby } 1993d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 1994b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby if (hdev->type == HID_TYPE_USBMOUSE && 1995b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby hid_match_id(hdev, hid_mouse_ignore_list)) 1996b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby return true; 1997b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby 1998d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return !!hid_match_id(hdev, hid_ignore_list); 1999d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby} 2000d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 200185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint hid_add_device(struct hid_device *hdev) 200285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 200385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby static atomic_t id = ATOMIC_INIT(0); 200485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 200585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 200685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (WARN_ON(hdev->status & HID_STAT_ADDED)) 200785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -EBUSY; 200885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 2009d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby /* we need to kill them here, otherwise they will stay allocated to 2010d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby * wait for coming driver */ 2011e5a2a04c264e693eafcc78fec5add34c9e15e471Jindrich Makovicka if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 2012e5a2a04c264e693eafcc78fec5add34c9e15e471Jindrich Makovicka && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) 2013d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return -ENODEV; 2014d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 20156bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers /* XXX hack, any other cleaner solution after the driver core 20166bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers * is converted to allow more than 20 bytes as the device name? */ 20176bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 20186bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers hdev->vendor, hdev->product, atomic_inc_return(&id)); 201985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 20204da361b69102cdffe73006771eae7504d2cb8736Bruno Prémont hid_debug_register(hdev, dev_name(&hdev->dev)); 202185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = device_add(&hdev->dev); 202285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!ret) 202385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->status |= HID_STAT_ADDED; 20244da361b69102cdffe73006771eae7504d2cb8736Bruno Prémont else 20254da361b69102cdffe73006771eae7504d2cb8736Bruno Prémont hid_debug_unregister(hdev); 2026a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina 202785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 202885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 202985cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_add_device); 203085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 203185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 203285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_allocate_device - allocate new hid device descriptor 203385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 203485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * Allocate and initialize hid device, so that hid_destroy_device might be 203585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * used to free it. 203685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 203785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 203885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * error value. 203985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 204085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystruct hid_device *hid_allocate_device(void) 204185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 204285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev; 204385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int i; 204485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret = -ENOMEM; 204585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 204685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 204785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdev == NULL) 204885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ERR_PTR(ret); 204985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 205085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby device_initialize(&hdev->dev); 205185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->dev.release = hid_device_release; 205285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->dev.bus = &hid_bus_type; 205385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 205485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 205585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby sizeof(struct hid_collection), GFP_KERNEL); 205685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdev->collection == NULL) 205785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 205885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 205985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 206085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (i = 0; i < HID_REPORT_TYPES; i++) 206185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 206285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 2063cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina init_waitqueue_head(&hdev->debug_wait); 2064cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina INIT_LIST_HEAD(&hdev->debug_list); 20654ea5454203d991ec85264f64f89ca8855fce69b0David Herrmann sema_init(&hdev->driver_lock, 1); 2066cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina 206785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return hdev; 206885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr: 206985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby put_device(&hdev->dev); 207085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ERR_PTR(ret); 207185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 207285cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_allocate_device); 207385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 207485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic void hid_remove_device(struct hid_device *hdev) 207585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 207685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdev->status & HID_STAT_ADDED) { 207785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby device_del(&hdev->dev); 2078a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina hid_debug_unregister(hdev); 207985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->status &= ~HID_STAT_ADDED; 208085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 208185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 208285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 208385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 208485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_destroy_device - free previously allocated device 208585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 208685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hdev: hid device 208785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 208885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * If you allocate hid_device through hid_allocate_device, you should ever 208985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * free by this function. 209085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 209185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyvoid hid_destroy_device(struct hid_device *hdev) 209285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 209385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hid_remove_device(hdev); 209485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby put_device(&hdev->dev); 209585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 209685cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_destroy_device); 209785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 209885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 209985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const char *mod_name) 210085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 21013a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby int ret; 21023a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 210385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.name = hdrv->name; 210485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.bus = &hid_bus_type; 210585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.owner = owner; 210685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.mod_name = mod_name; 210785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 21083a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby INIT_LIST_HEAD(&hdrv->dyn_list); 21093a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock_init(&hdrv->dyn_lock); 21103a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 21113a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = driver_register(&hdrv->driver); 21123a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (ret) 21133a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return ret; 21143a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 21153a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); 21163a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (ret) 21173a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby driver_unregister(&hdrv->driver); 21183a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 21193a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return ret; 212085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 212185cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(__hid_register_driver); 212285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 212385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyvoid hid_unregister_driver(struct hid_driver *hdrv) 212485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 21253a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby driver_remove_file(&hdrv->driver, &driver_attr_new_id); 212685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby driver_unregister(&hdrv->driver); 21273a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby hid_free_dynids(hdrv); 212885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 212985cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_unregister_driver); 213085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 21310361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukumint hid_check_keys_pressed(struct hid_device *hid) 21320361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum{ 21330361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum struct hid_input *hidinput; 21340361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum int i; 21350361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 2136e5288eb5ea89bd82d897cb687348bc608278f920Jiri Kosina if (!(hid->claimed & HID_CLAIMED_INPUT)) 2137e5288eb5ea89bd82d897cb687348bc608278f920Jiri Kosina return 0; 2138e5288eb5ea89bd82d897cb687348bc608278f920Jiri Kosina 21390361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum list_for_each_entry(hidinput, &hid->inputs, list) { 21400361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) 21410361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum if (hidinput->input->key[i]) 21420361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum return 1; 21430361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum } 21440361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 21450361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum return 0; 21460361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum} 21470361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 21480361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver NeukumEXPORT_SYMBOL_GPL(hid_check_keys_pressed); 21490361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 215086166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinastatic int __init hid_init(void) 215186166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina{ 215285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 215385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 2154a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina if (hid_debug) 21554291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches pr_warn("hid_debug is now used solely for parser and driver debugging.\n" 21564291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches "debugfs is now used for inspecting the device (report descriptor, reports)\n"); 2157a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina 215885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = bus_register(&hid_bus_type); 215985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret) { 21604291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches pr_err("can't register hid bus\n"); 216185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 216285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 216385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 216485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = hidraw_init(); 216585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret) 216685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err_bus; 216785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 2168a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina hid_debug_init(); 2169a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina 217085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 217185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr_bus: 217285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby bus_unregister(&hid_bus_type); 217385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr: 217485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 217586166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina} 217686166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina 217786166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinastatic void __exit hid_exit(void) 217886166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina{ 2179a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina hid_debug_exit(); 218086166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina hidraw_exit(); 218185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby bus_unregister(&hid_bus_type); 218286166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina} 218386166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina 218486166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinamodule_init(hid_init); 218586166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinamodule_exit(hid_exit); 218686166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina 218788adb72bcf3b1cc6b440fda9fa97bc2151245fc5Jiri KosinaMODULE_AUTHOR("Andreas Gal"); 218888adb72bcf3b1cc6b440fda9fa97bc2151245fc5Jiri KosinaMODULE_AUTHOR("Vojtech Pavlik"); 218988adb72bcf3b1cc6b440fda9fa97bc2151245fc5Jiri KosinaMODULE_AUTHOR("Jiri Kosina"); 2190aa938f7974b82cfd9ee955031987344f332b7c77Jiri KosinaMODULE_LICENSE(DRIVER_LICENSE); 2191aa938f7974b82cfd9ee955031987344f332b7c77Jiri Kosina 2192