hid-core.c revision e05eefb9be109e6cbbfd362b49ee83397130a7e4
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> 32dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 33dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/hid.h> 34dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#include <linux/hiddev.h> 35c080d89ad91e98fec0e8fc5f448a1ad899bd85c7Jiri Kosina#include <linux/hid-debug.h> 3686166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina#include <linux/hidraw.h> 37dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 385f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby#include "hid-ids.h" 395f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby 40dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 41dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Version Information 42dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 43dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 44531498013163c72cee8540e98e12c0c430c7fe87Jiri Kosina#define DRIVER_DESC "HID core driver" 45dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina#define DRIVER_LICENSE "GPL" 46dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 4758037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosinaint hid_debug = 0; 48377e10fbb4ef219f540d06796e9fb0d3ec35a58fAnssi Hannulamodule_param_named(debug, hid_debug, int, 0600); 49cd667ce24796700e1a0e6e7528efc61c96ff832eJiri KosinaMODULE_PARM_DESC(debug, "toggle HID debugging messages"); 5058037eb961f859607b161c50d9d4ecb374de1e8fJiri KosinaEXPORT_SYMBOL_GPL(hid_debug); 5158037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina 52dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 53dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Register a new report for a device. 54dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 55dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 5690a006abf8015c8cab893555244d8fc673b24839Michael Poolestruct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 57dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 58dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report_enum *report_enum = device->report_enum + type; 59dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report *report; 60dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 61dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report_enum->report_id_hash[id]) 62dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return report_enum->report_id_hash[id]; 63dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 64a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); 65a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!report) 66dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 67dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 68dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (id != 0) 69dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report_enum->numbered = 1; 70dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 71dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->id = id; 72dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->type = type; 73dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->size = 0; 74dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->device = device; 75dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report_enum->report_id_hash[id] = report; 76dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 77dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina list_add_tail(&report->list, &report_enum->report_list); 78dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 79dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return report; 80dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 8190a006abf8015c8cab893555244d8fc673b24839Michael PooleEXPORT_SYMBOL_GPL(hid_register_report); 82dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 83dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 84dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Register a new field for this report. 85dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 86dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 87dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 88dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 89dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_field *field; 90dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 91dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report->maxfield == HID_MAX_FIELDS) { 9258037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("too many fields in report\n"); 93dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 94dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 95dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 96a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches field = kzalloc((sizeof(struct hid_field) + 97a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches usages * sizeof(struct hid_usage) + 98a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches values * sizeof(unsigned)), GFP_KERNEL); 99a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!field) 100a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches return NULL; 101dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 102dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->index = report->maxfield++; 103dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->field[field->index] = field; 104dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->usage = (struct hid_usage *)(field + 1); 105282bfd4cbcc2bbeb1a2cad1f42debd378e0b5ac9Jiri Slaby field->value = (s32 *)(field->usage + usages); 106dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report = report; 107dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 108dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return field; 109dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 110dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 111dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 112dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Open a collection. The type/usage is pushed on the stack. 113dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 114dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 115dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int open_collection(struct hid_parser *parser, unsigned type) 116dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 117dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_collection *collection; 118dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned usage; 119dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 120dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina usage = parser->local.usage[0]; 121dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 122dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 12358037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("collection stack overflow\n"); 124dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 125dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 126dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 127dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->device->maxcollection == parser->device->collection_size) { 128dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection = kmalloc(sizeof(struct hid_collection) * 129dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size * 2, GFP_KERNEL); 130dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (collection == NULL) { 13158037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("failed to reallocate collection array\n"); 132dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 133dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 134dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memcpy(collection, parser->device->collection, 135dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina sizeof(struct hid_collection) * 136dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size); 137dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memset(collection + parser->device->collection_size, 0, 138dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina sizeof(struct hid_collection) * 139dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size); 140dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(parser->device->collection); 141dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection = collection; 142dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->collection_size *= 2; 143dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 144dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 145dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack[parser->collection_stack_ptr++] = 146dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->maxcollection; 147dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 148dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection = parser->device->collection + 149dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->maxcollection++; 150dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection->type = type; 151dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection->usage = usage; 152dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina collection->level = parser->collection_stack_ptr - 1; 153dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 154dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (type == HID_COLLECTION_APPLICATION) 155dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device->maxapplication++; 156dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 157dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 158dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 159dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 160dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 161dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Close a collection. 162dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 163dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 164dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int close_collection(struct hid_parser *parser) 165dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 166dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (!parser->collection_stack_ptr) { 16758037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("collection stack underflow\n"); 168dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 169dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 170dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack_ptr--; 171dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 172dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 173dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 174dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 175dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Climb up the stack, search for the specified collection type 176dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * and return the usage. 177dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 178dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 179dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 180dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 181504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches struct hid_collection *collection = parser->device->collection; 182dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int n; 183504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches 184504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { 185504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches unsigned index = parser->collection_stack[n]; 186504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches if (collection[index].type == type) 187504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches return collection[index].usage; 188504499f22c08a03e2e19dc88d31aa0ecd2ac815eJoe Perches } 189dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; /* we know nothing about this usage type */ 190dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 191dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 192dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 193dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Add a usage to the temporary parser table. 194dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 195dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 196dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_add_usage(struct hid_parser *parser, unsigned usage) 197dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 198dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->local.usage_index >= HID_MAX_USAGES) { 19958037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("usage index exceeded\n"); 200dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 201dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 202dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.usage[parser->local.usage_index] = usage; 203dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.collection_index[parser->local.usage_index] = 204dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack_ptr ? 205dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 206dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.usage_index++; 207dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 208dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 209dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 210dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 211dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Register a new field for this report. 212dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 213dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 214dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 215dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 216dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report *report; 217dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_field *field; 218dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int usages; 219dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned offset; 220dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int i; 221dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 222a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches report = hid_register_report(parser->device, report_type, parser->global.report_id); 223a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!report) { 22458037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("hid_register_report failed\n"); 225dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 226dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 227dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 228dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->global.logical_maximum < parser->global.logical_minimum) { 22958037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); 230dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 231dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 232dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 233dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina offset = report->size; 234dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report->size += parser->global.report_size * parser->global.report_count; 235dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 236dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (!parser->local.usage_index) /* Ignore padding fields */ 237dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 238dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 239dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina usages = max_t(int, parser->local.usage_index, parser->global.report_count); 240dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 241a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches field = hid_register_field(report, usages, parser->global.report_count); 242a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!field) 243dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 244dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 245dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 246dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 247dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 248dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 249dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (i = 0; i < usages; i++) { 250dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int j = i; 251dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina /* Duplicate the last usage we parsed if we have excess values */ 252dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (i >= parser->local.usage_index) 253dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina j = parser->local.usage_index - 1; 254dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->usage[i].hid = parser->local.usage[j]; 255dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->usage[i].collection_index = 256dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->local.collection_index[j]; 257dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 258dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 259dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->maxusage = usages; 260dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->flags = flags; 261dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_offset = offset; 262dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_type = report_type; 263dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_size = parser->global.report_size; 264dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->report_count = parser->global.report_count; 265dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->logical_minimum = parser->global.logical_minimum; 266dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->logical_maximum = parser->global.logical_maximum; 267dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->physical_minimum = parser->global.physical_minimum; 268dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->physical_maximum = parser->global.physical_maximum; 269dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->unit_exponent = parser->global.unit_exponent; 270dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->unit = parser->global.unit; 271dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 272dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 273dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 274dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 275dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 276dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Read data value from item. 277dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 278dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 279dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic u32 item_udata(struct hid_item *item) 280dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 281dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->size) { 282880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 1: return item->data.u8; 283880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 2: return item->data.u16; 284880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 4: return item->data.u32; 285dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 286dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 287dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 288dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 289dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic s32 item_sdata(struct hid_item *item) 290dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 291dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->size) { 292880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 1: return item->data.s8; 293880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 2: return item->data.s16; 294880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 4: return item->data.s32; 295dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 296dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 297dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 298dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 299dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 300dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a global item. 301dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 302dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 303dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 304dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 305dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->tag) { 306880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_PUSH: 307dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 308880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 309880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("global enviroment stack overflow\n"); 310880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 311880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 312dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 313880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby memcpy(parser->global_stack + parser->global_stack_ptr++, 314880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby &parser->global, sizeof(struct hid_global)); 315880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 316dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 317880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_POP: 318dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 319880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (!parser->global_stack_ptr) { 320880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("global enviroment stack underflow\n"); 321880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 322880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 323dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 324880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby memcpy(&parser->global, parser->global_stack + 325880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby --parser->global_stack_ptr, sizeof(struct hid_global)); 326880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 327dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 328880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 329880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.usage_page = item_udata(item); 330880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 331dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 332880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 333880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.logical_minimum = item_sdata(item); 334880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 335dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 336880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 337880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.logical_minimum < 0) 338880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.logical_maximum = item_sdata(item); 339880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby else 340880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.logical_maximum = item_udata(item); 341880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 342dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 343880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 344880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.physical_minimum = item_sdata(item); 345880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 346dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 347880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 348880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.physical_minimum < 0) 349880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.physical_maximum = item_sdata(item); 350880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby else 351880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.physical_maximum = item_udata(item); 352880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 353dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 354880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 355880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.unit_exponent = item_sdata(item); 356880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 357dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 358880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_UNIT: 359880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.unit = item_udata(item); 360880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 361dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 362880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 363880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_size = item_udata(item); 364880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.report_size > 32) { 365880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("invalid report_size %d\n", 366880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_size); 367880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 368880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 369880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 370dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 371880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 372880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_count = item_udata(item); 373880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.report_count > HID_MAX_USAGES) { 374880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("invalid report_count %d\n", 375880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_count); 376880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 377880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 378880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 379dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 380880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_GLOBAL_ITEM_TAG_REPORT_ID: 381880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->global.report_id = item_udata(item); 382880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->global.report_id == 0) { 383880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("report_id 0 is invalid\n"); 384dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 385880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 386880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 387880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 388880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby default: 389880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("unknown global tag 0x%x\n", item->tag); 390880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 391dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 392dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 393dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 394dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 395dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a local item. 396dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 397dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 398dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 399dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 400dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __u32 data; 401dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 402dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 403dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina data = item_udata(item); 404dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 405dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->tag) { 406880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_DELIMITER: 407880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 408880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (data) { 409880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby /* 410880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * We treat items before the first delimiter 411880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * as global to all usage sets (branch 0). 412880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * In the moment we process only these global 413880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby * items and the first delimiter set. 414880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby */ 415880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_depth != 0) { 416880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("nested delimiters\n"); 417880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 418dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 419880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.delimiter_depth++; 420880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.delimiter_branch++; 421880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } else { 422880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_depth < 1) { 423880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("bogus close delimiter\n"); 424880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 425dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 426880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.delimiter_depth--; 427880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 428880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 1; 429dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 430880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_USAGE: 431dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 432880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_branch > 1) { 433880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("alternative usage ignored\n"); 434880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 435880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 436dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 437880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (item->size <= 2) 438880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby data = (parser->global.usage_page << 16) + data; 439dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 440880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return hid_add_usage(parser, data); 441dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 442880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 443dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 444880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_branch > 1) { 445880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("alternative usage ignored\n"); 446dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 447880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 448dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 449880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (item->size <= 2) 450880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby data = (parser->global.usage_page << 16) + data; 451dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 452880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby parser->local.usage_minimum = data; 453880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 454dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 455880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 456dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 457880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (parser->local.delimiter_branch > 1) { 458880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("alternative usage ignored\n"); 459dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 460880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 461dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 462880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (item->size <= 2) 463880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby data = (parser->global.usage_page << 16) + data; 464dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 465880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby for (n = parser->local.usage_minimum; n <= data; n++) 466880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if (hid_add_usage(parser, n)) { 467880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("hid_add_usage failed\n"); 468880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return -1; 469880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby } 470880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 471880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 472880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby default: 473880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 474880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("unknown local item tag 0x%x\n", item->tag); 475880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return 0; 476dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 477dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 478dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 479dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 480dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 481dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a main item. 482dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 483dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 484dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 485dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 486dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __u32 data; 487dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina int ret; 488dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 489dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina data = item_udata(item); 490dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 491dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->tag) { 492880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 493880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = open_collection(parser, data & 0xff); 494880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 495880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_END_COLLECTION: 496880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = close_collection(parser); 497880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 498880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_INPUT: 499880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = hid_add_field(parser, HID_INPUT_REPORT, data); 500880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 501880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_OUTPUT: 502880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 503880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 504880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case HID_MAIN_ITEM_TAG_FEATURE: 505880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 506880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby break; 507880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby default: 508880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby dbg_hid("unknown main item tag 0x%x\n", item->tag); 509880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby ret = 0; 510dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 511dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 512dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 513dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 514dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return ret; 515dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 516dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 517dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 518dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Process a reserved item. 519dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 520dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 521dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 522dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 52358037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("reserved item type, tag 0x%x\n", item->tag); 524dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 525dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 526dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 527dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 528dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Free a report and all registered fields. The field->usage and 529dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * field->value table's are allocated behind the field, so we need 530dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * only to free(field) itself. 531dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 532dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 533dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic void hid_free_report(struct hid_report *report) 534dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 535dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 536dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 537dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < report->maxfield; n++) 538dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(report->field[n]); 539dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(report); 540dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 541dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 542dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 543dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Free a device structure, all reports, and all fields. 544dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 545dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 54685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic void hid_device_release(struct device *dev) 547dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 54885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *device = container_of(dev, struct hid_device, dev); 54985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned i, j; 550dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 551dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (i = 0; i < HID_REPORT_TYPES; i++) { 552dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report_enum *report_enum = device->report_enum + i; 553dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 554dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (j = 0; j < 256; j++) { 555dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_report *report = report_enum->report_id_hash[j]; 556dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report) 557dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_free_report(report); 558dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 559dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 560dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 561dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(device->rdesc); 562767fe7877c2928b5633992ee60a49ad4516dc2afJiri Kosina kfree(device->collection); 563dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(device); 564dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 565dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 566dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 567dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Fetch a report description item from the data stream. We support long 568dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * items, though they are not used yet. 569dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 570dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 571dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 572dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 573dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina u8 b; 574dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 575dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if ((end - start) <= 0) 576dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 577dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 578dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina b = *start++; 579dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 580dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->type = (b >> 2) & 3; 581dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->tag = (b >> 4) & 15; 582dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 583dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (item->tag == HID_ITEM_TAG_LONG) { 584dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 585dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->format = HID_ITEM_FORMAT_LONG; 586dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 587dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if ((end - start) < 2) 588dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 589dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 590dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->size = *start++; 591dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->tag = *start++; 592dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 593dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if ((end - start) < item->size) 594dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 595dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 596dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->data.longdata = start; 597dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina start += item->size; 598dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return start; 599dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 600dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 601dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->format = HID_ITEM_FORMAT_SHORT; 602dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina item->size = b & 3; 603dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 604dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (item->size) { 605880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 0: 606880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 607dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 608880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 1: 609880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if ((end - start) < 1) 610880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return NULL; 611880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->data.u8 = *start++; 612880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 613880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 614880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 2: 615880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if ((end - start) < 2) 616880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return NULL; 617880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->data.u16 = get_unaligned_le16(start); 618880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby start = (__u8 *)((__le16 *)start + 1); 619880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 620880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby 621880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 3: 622880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->size++; 623880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby if ((end - start) < 4) 624880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return NULL; 625880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby item->data.u32 = get_unaligned_le32(start); 626880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby start = (__u8 *)((__le32 *)start + 1); 627880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby return start; 628dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 629dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 630dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return NULL; 631dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 632dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 63385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 63485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_parse_report - parse device report 63585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 63685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @device: hid device 63785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @start: report start 63885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @size: report size 63985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 640dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Parse a report description into a hid_device structure. Reports are 641dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * enumerated, fields are attached to these reports. 64285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 0 returned on success, otherwise nonzero error value. 643dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 64485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint hid_parse_report(struct hid_device *device, __u8 *start, 64585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned size) 646dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 647dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_parser *parser; 648dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_item item; 649dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __u8 *end; 65085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 651dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina static int (*dispatch_type[])(struct hid_parser *parser, 652dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina struct hid_item *item) = { 653dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_main, 654dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_global, 655dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_local, 656dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_parser_reserved 657dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina }; 658dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 659c500c9714011edab021591340042787722db9cf0Jiri Slaby if (device->driver->report_fixup) 66073e4008ddddc84d5f2499c17012b340a0dae153eNikolai Kondrashov start = device->driver->report_fixup(device, start, &size); 661c500c9714011edab021591340042787722db9cf0Jiri Slaby 6621721a238ba5df9e870ed952464d38714261f5be9Julia Lawall device->rdesc = kmemdup(start, size, GFP_KERNEL); 66385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (device->rdesc == NULL) 66485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 665dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina device->rsize = size; 666dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 667fe2580204d8bbcd18540736a283ed0b784c6a024Joe Perches parser = vzalloc(sizeof(struct hid_parser)); 66885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!parser) { 66985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = -ENOMEM; 67085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 671dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 67285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 673dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina parser->device = device; 674dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 675dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina end = start + size; 67685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = -EINVAL; 677dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina while ((start = fetch_item(start, end, &item)) != NULL) { 678dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 679dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (item.format != HID_ITEM_FORMAT_SHORT) { 68058037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("unexpected long global item\n"); 68185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 682dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 683dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 684dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (dispatch_type[item.type](parser, &item)) { 68558037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("item %u %u %u %u parsing failed\n", 6864291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches item.format, (unsigned)item.size, 6874291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches (unsigned)item.type, (unsigned)item.tag); 68885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 689dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 690dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 691dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (start == end) { 692dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->collection_stack_ptr) { 69358037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("unbalanced collection at end of report description\n"); 69485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 695dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 696dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (parser->local.delimiter_depth) { 69758037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("unbalanced delimiter at end of report description\n"); 69885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 699dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 70047a80edb1d80ae644ea374a016c8e68d43d2671fJiri Kosina vfree(parser); 70185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 702dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 703dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 704dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 70558037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); 70685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr: 70747a80edb1d80ae644ea374a016c8e68d43d2671fJiri Kosina vfree(parser); 70885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 709dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 710229695e51efc4ed5e04ab471c82591d0f432909dJiri KosinaEXPORT_SYMBOL_GPL(hid_parse_report); 711dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 712dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 713dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Convert a signed n-bit integer to signed 32-bit integer. Common 714dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * cases are done through the compiler, the screwed things has to be 715dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * done by hand. 716dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 717dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 718dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic s32 snto32(__u32 value, unsigned n) 719dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 720dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina switch (n) { 721880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 8: return ((__s8)value); 722880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 16: return ((__s16)value); 723880d29f109428be1d027adf919a7457d8fe41fd3Jiri Slaby case 32: return ((__s32)value); 724dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 725dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return value & (1 << (n - 1)) ? value | (-1 << n) : value; 726dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 727dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 728dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 729dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Convert a signed 32-bit integer to a signed n-bit integer. 730dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 731dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 732dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinastatic u32 s32ton(__s32 value, unsigned n) 733dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 734dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina s32 a = value >> (n - 1); 735dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (a && a != -1) 736dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 737dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return value & ((1 << n) - 1); 738dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 739dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 740dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 741dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Extract/implement a data field from/to a little endian report (bit array). 742dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * 743dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Code sort-of follows HID spec: 744dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 745dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * 746dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * While the USB HID spec allows unlimited length bit fields in "report 747dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * descriptors", most devices never use more than 16 bits. 748dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * One model of UPS is claimed to report "LINEV" as a 32-bit field. 749dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 750dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 751dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 75216ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perchesstatic __u32 extract(const struct hid_device *hid, __u8 *report, 75316ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perches unsigned offset, unsigned n) 754dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 755dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina u64 x; 756dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 757c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina if (n > 32) 7584291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 7594291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches n, current->comm); 760dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 761dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report += offset >> 3; /* adjust byte index */ 762229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosina offset &= 7; /* now only need bit offset into one byte */ 763c105068f2b35343eecf2bf16ee29a362b6121fa3Harvey Harrison x = get_unaligned_le64(report); 764229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosina x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 765dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return (u32) x; 766dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 767dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 768dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 769dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * "implement" : set bits in a little endian bit stream. 770dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Same concepts as "extract" (see comments above). 771dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * The data mangled in the bit stream remains in little endian 772dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * order the whole time. It make more sense to talk about 773dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * endianness of register values by considering a register 774dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * a "cached" copy of the little endiad bit stream. 775dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 77616ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perchesstatic void implement(const struct hid_device *hid, __u8 *report, 77716ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perches unsigned offset, unsigned n, __u32 value) 778dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 7796f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison u64 x; 780dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina u64 m = (1ULL << n) - 1; 781dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 782c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina if (n > 32) 7834291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", 7844291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches __func__, n, current->comm); 785dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 786c4124c9b68bf8ecf1e8afedad3a22e18666cb6f3Jiri Kosina if (value > m) 7874291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_warn(hid, "%s() called with too large value %d! (%s)\n", 7884291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches __func__, value, current->comm); 789dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina WARN_ON(value > m); 790dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina value &= m; 791dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 792dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina report += offset >> 3; 793dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina offset &= 7; 794dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 7956f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison x = get_unaligned_le64(report); 7966f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison x &= ~(m << offset); 7976f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison x |= ((u64)value) << offset; 7986f0168d2dacd7972d887e1ca27943ef8af7512a5Harvey Harrison put_unaligned_le64(x, report); 799dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 800dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 801dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 802dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Search an array for a value. 803dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 804dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 80516ee4cc82b5dbb81a5dbfedcdb268b9467fe4605Joe Perchesstatic int search(__s32 *array, __s32 value, unsigned n) 806dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 807dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina while (n--) { 808dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (*array++ == value) 809dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 810dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 811dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 812dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 813dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 81485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 81585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_match_report - check if driver's raw_event should be called 81685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 81785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hid: hid device 81885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @report_type: type to match against 81985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 82085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * compare hid->driver->report_table->report_type to report->type 82185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 82285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_match_report(struct hid_device *hid, struct hid_report *report) 823dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 82485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const struct hid_report_id *id = hid->driver->report_table; 82585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 82685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!id) /* NULL means all */ 82785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 82885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 82985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (; id->report_type != HID_TERMINATOR; id++) 83085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (id->report_type == HID_ANY_ID || 83185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->report_type == report->type) 83285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 83385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 83485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 83585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 83685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 83785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_match_usage - check if driver's event should be called 83885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 83985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hid: hid device 84085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @usage: usage to match against 84185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 84285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * compare hid->driver->usage_table->usage_{type,code} to 84385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * usage->usage_{type,code} 84485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 84585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 84685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 84785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const struct hid_usage_id *id = hid->driver->usage_table; 84885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 84985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!id) /* NULL means all */ 85085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 85185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 85285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (; id->usage_type != HID_ANY_ID - 1; id++) 85385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if ((id->usage_hid == HID_ANY_ID || 85485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->usage_hid == usage->hid) && 85585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby (id->usage_type == HID_ANY_ID || 85685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->usage_type == usage->type) && 85785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby (id->usage_code == HID_ANY_ID || 85885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby id->usage_code == usage->code)) 85985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 86085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 86185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 86285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 86385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic void hid_process_event(struct hid_device *hid, struct hid_field *field, 86485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_usage *usage, __s32 value, int interrupt) 86585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 86685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = hid->driver; 86785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 86885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 869cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_dump_input(hid, usage, value); 87085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 87185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 87285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = hdrv->event(hid, field, usage, value); 87385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret != 0) { 87485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret < 0) 87585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("%s's event failed with %d\n", 87685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->name, ret); 87785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return; 87885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 87985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 88085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 881dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 882dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hidinput_hid_event(hid, field, usage, value); 883aa938f7974b82cfd9ee955031987344f332b7c77Jiri Kosina if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 884aa938f7974b82cfd9ee955031987344f332b7c77Jiri Kosina hid->hiddev_hid_event(hid, field, usage, value); 885dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 886dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 887dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 888dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Analyse a received field, and fetch the data from it. The field 889dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * content is stored for next report processing (we do differential 890dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * reporting to the layer). 891dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 892dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 893abdff0f7749a6696ba2a4238b675cbc55abcdb7aAdrian Bunkstatic void hid_input_field(struct hid_device *hid, struct hid_field *field, 894abdff0f7749a6696ba2a4238b675cbc55abcdb7aAdrian Bunk __u8 *data, int interrupt) 895dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 896dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 897dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned count = field->report_count; 898dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned offset = field->report_offset; 899dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned size = field->report_size; 900dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __s32 min = field->logical_minimum; 901dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __s32 max = field->logical_maximum; 902dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina __s32 *value; 903dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 904a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); 905a3789a1783d37f2772ba5046b26416c98dfe1bfaJoe Perches if (!value) 906dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return; 907dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 908dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < count; n++) { 909dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 9104291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches value[n] = min < 0 ? 9114291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches snto32(extract(hid, data, offset + n * size, size), 9124291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches size) : 9134291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches extract(hid, data, offset + n * size, size); 914dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 9154291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches /* Ignore report if ErrorRollOver */ 9164291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && 9174291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches value[n] >= min && value[n] <= max && 9184291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 9194291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches goto exit; 920dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 921dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 922dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < count; n++) { 923dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 924dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (HID_MAIN_ITEM_VARIABLE & field->flags) { 925dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 926dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina continue; 927dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 928dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 929dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (field->value[n] >= min && field->value[n] <= max 930dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && field->usage[field->value[n] - min].hid 931dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && search(value, field->value[n], count)) 932dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 933dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 934dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (value[n] >= min && value[n] <= max 935dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && field->usage[value[n] - min].hid 936dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina && search(field->value, value[n], count)) 937dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 938dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 939dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 940dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina memcpy(field->value, value, count * sizeof(__s32)); 941dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinaexit: 942dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina kfree(value); 943dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 944dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 945dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 946dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Output the field into the report. 947dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 948dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 9494291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perchesstatic void hid_output_field(const struct hid_device *hid, 9504291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches struct hid_field *field, __u8 *data) 951dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 952dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned count = field->report_count; 953dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned offset = field->report_offset; 954dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned size = field->report_size; 955dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 956dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 957dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < count; n++) { 958dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (field->logical_minimum < 0) /* signed values */ 9594291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches implement(hid, data, offset + n * size, size, 9604291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches s32ton(field->value[n], size)); 961dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina else /* unsigned values */ 9624291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches implement(hid, data, offset + n * size, size, 9634291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches field->value[n]); 964dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 965dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 966dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 967dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 968dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Create a report. 969dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 970dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 971229695e51efc4ed5e04ab471c82591d0f432909dJiri Kosinavoid hid_output_report(struct hid_report *report, __u8 *data) 972dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 973dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned n; 974dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 975dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (report->id > 0) 976dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina *data++ = report->id; 977dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 97875c28df87eb6d8e1389af67f26fbe2394e28385ePete Zaitcev memset(data, 0, ((report->size - 1) >> 3) + 1); 979dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina for (n = 0; n < report->maxfield; n++) 9804291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_output_field(report->device, report->field[n], data); 981dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 982229695e51efc4ed5e04ab471c82591d0f432909dJiri KosinaEXPORT_SYMBOL_GPL(hid_output_report); 983dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 984dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina/* 985dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * Set a field value. The report this field belongs to has to be 986dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * created and transferred to the device, to set this value in the 987dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina * device. 988dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina */ 989dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 990dde5845a529ff753364a6d1aea61180946270bfaJiri Kosinaint hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 991dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina{ 992dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina unsigned size = field->report_size; 993dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 994cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_dump_input(field->report->device, field->usage + offset, value); 995dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 996dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (offset >= field->report_count) { 99758037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); 998dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 999dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 1000dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (field->logical_minimum < 0) { 1001dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina if (value != snto32(s32ton(value, size), size)) { 100258037eb961f859607b161c50d9d4ecb374de1e8fJiri Kosina dbg_hid("value %d is out of range\n", value); 1003dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return -1; 1004dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 1005dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina } 1006dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina field->value[offset] = value; 1007dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina return 0; 1008dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina} 1009229695e51efc4ed5e04ab471c82591d0f432909dJiri KosinaEXPORT_SYMBOL_GPL(hid_set_field); 1010dde5845a529ff753364a6d1aea61180946270bfaJiri Kosina 101185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 101285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const u8 *data) 1013aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina{ 1014aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina struct hid_report *report; 101585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int n = 0; /* Normally report number is 0 */ 1016aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 101785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby /* Device uses numbered reports, data[0] is report number */ 101885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (report_enum->numbered) 101985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby n = *data; 1020aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 102185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby report = report_enum->report_id_hash[n]; 102285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (report == NULL) 102385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("undefined report_id %u received\n", n); 1024aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 102585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return report; 102685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 1027aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 102885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyvoid hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 102985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int interrupt) 103085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 103185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_report_enum *report_enum = hid->report_enum + type; 103285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_report *report; 103385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int a; 103485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int rsize, csize = size; 103585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby u8 *cdata = data; 1036aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 103785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby report = hid_get_report(report_enum, data); 103885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!report) 103985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return; 1040aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 104185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (report_enum->numbered) { 104285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby cdata++; 104385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby csize--; 1044aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina } 1045aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1046aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina rsize = ((report->size - 1) >> 3) + 1; 1047aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 104885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (csize < rsize) { 104985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("report %d is too short, (%d < %d)\n", report->id, 105085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby csize, rsize); 105185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby memset(cdata + csize, 0, rsize - csize); 1052aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina } 1053aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1054aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1055aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina hid->hiddev_report_event(hid, report); 10565a38f2c7c4dd53d5be097930902c108e362584a3Alan Ott if (hid->claimed & HID_CLAIMED_HIDRAW) 10575a38f2c7c4dd53d5be097930902c108e362584a3Alan Ott hidraw_report_event(hid, data, size); 1058aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 105985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (a = 0; a < report->maxfield; a++) 106085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hid_input_field(hid, report->field[a], cdata, interrupt); 1061aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1062aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 1063aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina hidinput_report_event(hid, report); 106485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 106585cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_report_raw_event); 106685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 106785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 106885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_input_report - report data from lower layer (usb, bt...) 106985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 107085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hid: hid device 107185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @type: HID report type (HID_*_REPORT) 107285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @data: report contents 107385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @size: size of data parameter 1074ff9b00a226ccea66e6ce70e9083c42f5b6001f73Jiri Kosina * @interrupt: distinguish between interrupt and control transfers 107585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 107685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * This is data entry for lower layers. 107785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 107885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 107985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 108076c317d6e5cb7f58541879006d39774596962715Julia Lawall struct hid_report_enum *report_enum; 108176c317d6e5cb7f58541879006d39774596962715Julia Lawall struct hid_driver *hdrv; 108285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_report *report; 1083cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina char *buf; 108485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int i; 108585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 108685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 108785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!hid || !hid->driver) 108885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENODEV; 108976c317d6e5cb7f58541879006d39774596962715Julia Lawall report_enum = hid->report_enum + type; 109076c317d6e5cb7f58541879006d39774596962715Julia Lawall hdrv = hid->driver; 109185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 109285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!size) { 109385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby dbg_hid("empty report\n"); 109485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -1; 109585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 109685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1097d1ff65226c5afe55f9af38a439058f41b71e114fJiri Kosina buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1098cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina 1099f77e347bd44e3640bdc56003b7402c63ddb1241dJiri Kosina if (!buf) 1100cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina goto nomem; 110185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 110285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby /* dump the report */ 1103cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 11041caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); 1105cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_debug_event(hid, buf); 11061caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina 1107cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina for (i = 0; i < size; i++) { 1108cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1109cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina " %02x", data[i]); 1110cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_debug_event(hid, buf); 1111cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina } 1112cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina hid_debug_event(hid, "\n"); 1113cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina kfree(buf); 111485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1115cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosinanomem: 11161caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina report = hid_get_report(report_enum, data); 11171caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina 1118f77e347bd44e3640bdc56003b7402c63ddb1241dJiri Kosina if (!report) 11191caea61eda5c4d446147aa0e712ba395bb6b81c3Jiri Kosina return -1; 112085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 112185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 112285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = hdrv->raw_event(hid, report, data, size); 112385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret != 0) 112485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret < 0 ? ret : 0; 112585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 112685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 112785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hid_report_raw_event(hid, type, data, size, interrupt); 1128aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 1129aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina return 0; 1130aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina} 1131aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri KosinaEXPORT_SYMBOL_GPL(hid_input_report); 1132aa8de2f038baec993f07ef66fb3e94481d1ec22bJiri Kosina 11330f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic bool hid_match_one_id(struct hid_device *hdev, 11340f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina const struct hid_device_id *id) 11350f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina{ 11360f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return id->bus == hdev->bus && 11370f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 11380f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina (id->product == HID_ANY_ID || id->product == hdev->product); 11390f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina} 11400f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11410f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic const struct hid_device_id *hid_match_id(struct hid_device *hdev, 11420f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina const struct hid_device_id *id) 11430f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina{ 11440f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina for (; id->bus; id++) 11450f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina if (hid_match_one_id(hdev, id)) 11460f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return id; 11470f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11480f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return NULL; 11490f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina} 11500f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11510f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic const struct hid_device_id hid_hiddev_list[] = { 1152c0bd6a429819f794f626f9e73be4564e18e132dbRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1153c0bd6a429819f794f626f9e73be4564e18e132dbRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 11540f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina { } 11550f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina}; 11560f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 11570f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosinastatic bool hid_hiddev(struct hid_device *hdev) 11580f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina{ 11590f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina return !!hid_match_id(hdev, hid_hiddev_list); 11600f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina} 11610f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina 116293c10132a7ac160df3175b53f7ee857625412165Jiri Slabyint hid_connect(struct hid_device *hdev, unsigned int connect_mask) 116393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby{ 116493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 116593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby "Joystick", "Gamepad", "Keyboard", "Keypad", 116693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby "Multi-Axis Controller" 116793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby }; 116893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby const char *type, *bus; 116993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby char buf[64]; 117093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby unsigned int i; 117193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby int len; 117293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 1173b5e5a37e36cd4d355b875665312d7aaae4e5833cBastien Nocera if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) 1174b5e5a37e36cd4d355b875665312d7aaae4e5833cBastien Nocera connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); 11753a343ee4509c982552b35fbc99d3213f3bb1acdeDaniel Mack if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) 11763a343ee4509c982552b35fbc99d3213f3bb1acdeDaniel Mack connect_mask |= HID_CONNECT_HIDINPUT_FORCE; 117793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->bus != BUS_USB) 117893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby connect_mask &= ~HID_CONNECT_HIDDEV; 11790f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina if (hid_hiddev(hdev)) 11800f37cd0306463ad35f958d8f74a2b00e5b190b4bJiri Kosina connect_mask |= HID_CONNECT_HIDDEV_FORCE; 118193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 118293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, 118393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby connect_mask & HID_CONNECT_HIDINPUT_FORCE)) 118493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->claimed |= HID_CLAIMED_INPUT; 118593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && 118693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby !hdev->hiddev_connect(hdev, 118793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby connect_mask & HID_CONNECT_HIDDEV_FORCE)) 118893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->claimed |= HID_CLAIMED_HIDDEV; 118993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) 119093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->claimed |= HID_CLAIMED_HIDRAW; 119193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 119293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (!hdev->claimed) { 11934291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); 119493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby return -ENODEV; 119593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 119693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 119793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if ((hdev->claimed & HID_CLAIMED_INPUT) && 119893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby (connect_mask & HID_CONNECT_FF) && hdev->ff_init) 119993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->ff_init(hdev); 120093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 120193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len = 0; 120293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->claimed & HID_CLAIMED_INPUT) 120393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len += sprintf(buf + len, "input"); 120493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->claimed & HID_CLAIMED_HIDDEV) 120593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len += sprintf(buf + len, "%shiddev%d", len ? "," : "", 120693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby hdev->minor); 120793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (hdev->claimed & HID_CLAIMED_HIDRAW) 120893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby len += sprintf(buf + len, "%shidraw%d", len ? "," : "", 120993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby ((struct hidraw *)hdev->hidraw)->minor); 121093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 121193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby type = "Device"; 121293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby for (i = 0; i < hdev->maxcollection; i++) { 121393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby struct hid_collection *col = &hdev->collection[i]; 121493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby if (col->type == HID_COLLECTION_APPLICATION && 121593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && 121693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby (col->usage & 0xffff) < ARRAY_SIZE(types)) { 121793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby type = types[col->usage & 0xffff]; 121893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby break; 121993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 122093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 122193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 122293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby switch (hdev->bus) { 122393c10132a7ac160df3175b53f7ee857625412165Jiri Slaby case BUS_USB: 122493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby bus = "USB"; 122593c10132a7ac160df3175b53f7ee857625412165Jiri Slaby break; 122693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby case BUS_BLUETOOTH: 122793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby bus = "BLUETOOTH"; 122893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby break; 122993c10132a7ac160df3175b53f7ee857625412165Jiri Slaby default: 123093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby bus = "<UNKNOWN>"; 123193c10132a7ac160df3175b53f7ee857625412165Jiri Slaby } 123293c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 12334291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 12344291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches buf, bus, hdev->version >> 8, hdev->version & 0xff, 12354291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches type, hdev->name, hdev->phys); 123693c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 123793c10132a7ac160df3175b53f7ee857625412165Jiri Slaby return 0; 123893c10132a7ac160df3175b53f7ee857625412165Jiri Slaby} 123993c10132a7ac160df3175b53f7ee857625412165Jiri SlabyEXPORT_SYMBOL_GPL(hid_connect); 124093c10132a7ac160df3175b53f7ee857625412165Jiri Slaby 1241c4c259bcc27c4242b012106afdba183622b1735fJiri Kosinavoid hid_disconnect(struct hid_device *hdev) 1242c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina{ 1243c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina if (hdev->claimed & HID_CLAIMED_INPUT) 1244c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina hidinput_disconnect(hdev); 1245c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDDEV) 1246c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina hdev->hiddev_disconnect(hdev); 1247c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDRAW) 1248c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina hidraw_disconnect(hdev); 1249c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina} 1250c4c259bcc27c4242b012106afdba183622b1735fJiri KosinaEXPORT_SYMBOL_GPL(hid_disconnect); 1251c4c259bcc27c4242b012106afdba183622b1735fJiri Kosina 1252bae7eb33b25387fdc7ccae08768bef1f9484a5b0Jiri Kosina/* a list of devices for which there is a specialized driver on HID bus */ 1253ce06b9d6d33fd2ed799b6e825d68fe95077da354Dmitry Torokhovstatic const struct hid_device_id hid_have_special_driver[] = { 1254b6353f4f36f03a12edaf3fa5365b475a28106035Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 12556dec143a50c01ca0cc0afcbf5ea4bb8e87981edfStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, 125614a21cd459f97e3b3cc4fcde48fc5bcdb81d097eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 125714a21cd459f97e3b3cc4fcde48fc5bcdb81d097eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1258b7e1b2039de3a028fba46fbaca58a45c23a417ecLech Perczak { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, 1259c0dbcc33c652a0646542560de29a1c3f1ab7169fSergei Kolzun#if defined(CONFIG_HID_ACRUX_FF) || defined(CONFIG_HID_ACRUX_FF_MODULE) 1260c0dbcc33c652a0646542560de29a1c3f1ab7169fSergei Kolzun { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, 1261c0dbcc33c652a0646542560de29a1c3f1ab7169fSergei Kolzun#endif 1262df9bcace7b1c29e9be1c13b034ff04f4f4c90edeJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 12638c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 12648c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1265128537cea464d919febeaea2000e256749f317ebMichael Poole { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, 1266a462230e16acc8664145216da3c928d03556691aChase Douglas { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, 12678c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 12688c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 12698c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 12708c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 12718c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 12728c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 12738c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 12748c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 12758c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 12768c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 12778c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1278fef3f571ecc2a82395c531d97b3f71a59e04e946Ryan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, 1279fef3f571ecc2a82395c531d97b3f71a59e04e946Ryan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, 1280fef3f571ecc2a82395c531d97b3f71a59e04e946Ryan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, 12818c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 12828c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 12838c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 12848c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 12858c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 12868c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1287ee8a1a0a1a5817accd03ced7e7ffde3a4430f485Jan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1288ee8a1a0a1a5817accd03ced7e7ffde3a4430f485Jan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1289ee8a1a0a1a5817accd03ced7e7ffde3a4430f485Jan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 12908c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 12918c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 12928c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 12938c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 12948c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 12958c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1296a96d6ef34751093797c3a6c6080733dd7af23d35Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1297a96d6ef34751093797c3a6c6080733dd7af23d35Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1298a96d6ef34751093797c3a6c6080733dd7af23d35Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 129999b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 130099b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 130199b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 130299b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 130399b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 130499b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 130523aeb61e7e1f02fb0f3b8f9e798e75537ca1731dChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 130623aeb61e7e1f02fb0f3b8f9e798e75537ca1731dChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 130723aeb61e7e1f02fb0f3b8f9e798e75537ca1731dChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 13088c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 13098c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1310eaca1386207a9e0314647d3a88967acb17cc30e3Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, 1311cec15a0ece19116b6c2c53fedf9696c20124d491Roland Baum { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 1312b5635b129b3ca3a9c879a36f58f5b8c4903d267aJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1313bf280628fca93c4c341587ec914863dcc395af72Wayne Thomas { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1314c3dc66de59531c921c4638b1285075ea1c831186Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 13155519cab477b61326963c8d523520db0342862b63Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 131636213e1e40fb863e2e8ef607b2958504b48f6b8eStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 1317bc5ab083a68bfec212780281f8e57d871d8882a0Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, 1318ba4d8abb31def963f49b7c239a8acce57fe1d1ccStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, 1319272036edb77e5967c175ac48b8c88e9b3358285fFrançois Jaouen { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 13203b239cd739a9499da08326356add3d9d992c7911Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 13211ce31b255cf8b06470dfbd469055b6fd8d2274bcRaphaël Doursenaud { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1322fcfacfd3594d5d2fa99fb5e7d33dee3904b1a156Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1323b9e4b1e0cd401e915e3ba97afc152946f78f9f0bDennis Kügler { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 13243a370ca1dcf8c80aff7a0a21d6b0f50ca2a151e9Don Prince { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 13250f2213208f8da51bcb665309e3468f000489c04fJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 13260f2213208f8da51bcb665309e3468f000489c04fJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1327e8d0eab4d9eda9f5e97852f780f020bfb134f9f0Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 13280f2213208f8da51bcb665309e3468f000489c04fJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1329a3b5e577d96bfccbc41ebf4df784e3a153072273Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, 13303f866fbd52d1863db5c07700e560aef22c4fdc01Richard Walmsley { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1331e05eefb9be109e6cbbfd362b49ee83397130a7e4Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 13320c3910c255d3f9caeef4ebad5d5a1156a2d33f69Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, 133383e4491818040ae6b2d9fc60434616304a101d39Chris Ball { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, 13344e93db23bf95cd763c9182b5d6187412fe6ce747Henrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, 133528906ad6d7c8a8090f720cf7c39461df0b1460f6Richard Nauber { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, 13364dd295a73e80b55c3fec25555bf0a5d253023740Andy Ross { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, 133764b386ea16112564e0b93473e2c347125effb6b2Richard Nauber { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 133804561c5aa243c98cae93cde27e05740df787e692Ignaz Forster { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, 13391f243e302cea1561ac881eb5d27041c5342beba4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 13405181e594512faeac7d7fd9620ce91105f45bf643Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1341578f3a35fecabff49bad808c5301313f785b5462Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 13425572da08a784621f2ab4fdc8dc65471261871795Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 13435181e594512faeac7d7fd9620ce91105f45bf643Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 134442859e0bd21daba9974757fcfe4a4dde265fe28dLukasz Lubojanski { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, 1345949f8fef77186c7361d22e1ea6f42c76ceda42b0Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 13461e093206734568e780c2717da1c89b97e9471954Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1347c2fd1a4ebf9127c280d227acb635eb1df213439cCory Maccarrone { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 13485519cab477b61326963c8d523520db0342862b63Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, 1349fdf93aa33268889e126aa677f2072238bd76adb0Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1350794227415f8f5f395a9ed4269a4ee7a3c34f66a5Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 1351b5635b129b3ca3a9c879a36f58f5b8c4903d267aJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 13525f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 13535f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 13545f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 13555f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 13565f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 13575f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 13585f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 13595f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 13605f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 13615f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 13625f22a7992349c5ca3842190be52d5e9a1dd7adf4Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 13632c6118e43040034d80894daeba41960bf0035b31Hendrik Iben { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, 1364606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, 1365606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, 1366606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1367fd30ea8c871552ddd6a5e1c0886de8fef4df53bcJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1368606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 136974f292ca8c7a2b9370f80d97a49e48174f4c7635Gary Stein { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, 1370606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1371606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 1372243b706d8a71364ad6080328d45b73516c8af5f3Christophe Borivant { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 137332c88cbc3080f43c429f6456aa9cd845e37f3778Simon Wood { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, 1374606bd0a8616a0e59021cb2997e942513f24f641dJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 137524985cf68612a5617d396b0b188cec807641cde1Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 137624985cf68612a5617d396b0b188cec807641cde1Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1377236db47c2b3b69464d50c695ab2ddd516cf64520Bruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1378236db47c2b3b69464d50c695ab2ddd516cf64520Bruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 137978a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 138078a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 138178a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 138278a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 138378a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 13843b8006e51038ef263a0404756d9e190c9a9f74d5Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 138594011f93f2cd7410401e22390cf7a14fe5495a22Rafi Rubin { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 13866e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 13876e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, 13886e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, 13896e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, 13906e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, 13916e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, 13926e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, 13936e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, 13946e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, 13956e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, 13966e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, 13976e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, 13986e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, 13996e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, 14006e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, 14016e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, 14026e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, 14036e32819e12ffbd507eced11a1871700a387d5407micki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, 1404cd9ec30da58bcd8ab154eba9eb54d16c67e7ef3bJohnathon Harris { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 14051e76253220dbe66e048e55680266dd1f4af0be85Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 140649e4739a0cf681cbfe08c72232c1dcc130b66ddeStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1407f54405db66fbec11679241daefd16fd8291a5762Alex Neblett { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 140814bf62cde79423a02a590e02664ed29a36facec1Stefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, 140947dbdbffe15b9582a41727766d43f1d4208e977eStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 1410cb7cf3da0daa9830e00640da8f7d2380f4b4de42Stefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 1411980a3da6acdd577ee3ae192e868dc52fe4b7f2e5Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1412b355850ba383232d4e0e357c1cda8cb7bfcc60bcDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1413bd28ce008bdc68ef5902f68d2d62cbb7fa78c415Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1414f9ce7c283c16538955d5d094101889792bcde109Bastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1415cc6e0bbb47f02fd36cd55b3189c0c79079096ab8Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1416d3fb5454a8474d5d22c8f8fe4d043b05732d91d5Stephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, 1417b6dc79929fa18a97bbc08400db72405ad835622fPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, 1418b6dc79929fa18a97bbc08400db72405ad835622fPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, 141990231e7eaf752856a2c13f786f36ec7f641bad28Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1420daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1421daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 14227a84b1336a145d683fb8cdfd6c2c67545a58b126Ruben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 14237a84b1336a145d683fb8cdfd6c2c67545a58b126Ruben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1424daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 14253ee8f0a2b1c81f0472b25d40aa5c1c7c6a0edc2aMarkus Rathgeb { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1426daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1427d65c3768afb47fb93c43fbfcafef53502edaaa85Simon Wood { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, 1428f14f526d02b14fd0b8c1ac4ec413e4577ad5f62eLev Babiev { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1429540010812179a16d3d00fb8363bb06ee83af25b8Kees Bakker { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 1430711a680e35059bc5c7c28d3c4bd0bebd3b7bb6eeBruno Premont { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1431c64f6f934c7490faff76faf96217066a1b3570a0Benjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 143241fa92302be7fa37c5c38e17e2097d3e5e9da13aNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, 1433f8a489cc5f7adafa9f1420279be793de0fba481cNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, 1434f8a489cc5f7adafa9f1420279be793de0fba481cNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, 1435f8a489cc5f7adafa9f1420279be793de0fba481cNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, 1436fac733f029251a393c42a8313432f2d9fe43bb83Jussi Kivilinna { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 1437ca2dcd40f54c8928b3994712a6cadd2078a087faBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 143872a46344867111c3e019b169ddfa9e1a1f55c759Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 143900e7f9649b3061281fe4b463263da26155dc9be4Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 144072a46344867111c3e019b169ddfa9e1a1f55c759Nikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 14418f1acc32bbdb1784bcb0be98fb02f4b20e6f328fNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1442daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1443daedb3d6a91f9626ab4c921378ac52e44de833d5Anssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1444a9885c8f7bf62e251fc178f838b9f0ee897c158aDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, 14458c19a51591d06f5226499972567f528cf6066bb7Jiri Slaby 144678a849a682a1d5ee7b7187b08abdc48656326a4eJiri Slaby { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 144785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby { } 144885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby}; 144985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 14503a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystruct hid_dynid { 14513a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct list_head list; 14523a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_device_id id; 14533a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby}; 14543a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14553a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby/** 14563a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * store_new_id - add a new HID device ID to this driver and re-probe devices 14573a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * @driver: target device driver 14583a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * @buf: buffer for scanning device ID data 14593a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * @count: input size 14603a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * 14613a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * Adds a new dynamic hid device ID to this driver, 14623a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby * and causes the driver to probe for all devices again. 14633a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby */ 14643a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic ssize_t store_new_id(struct device_driver *drv, const char *buf, 14653a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby size_t count) 14663a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby{ 14673a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 14683a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_dynid *dynid; 14693a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby __u32 bus, vendor, product; 14703a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby unsigned long driver_data = 0; 14713a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby int ret; 14723a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14733a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = sscanf(buf, "%x %x %x %lx", 14743a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby &bus, &vendor, &product, &driver_data); 14753a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (ret < 3) 14763a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return -EINVAL; 14773a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14783a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 14793a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (!dynid) 14803a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return -ENOMEM; 14813a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14823a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.bus = bus; 14833a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.vendor = vendor; 14843a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.product = product; 14853a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby dynid->id.driver_data = driver_data; 14863a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14873a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock(&hdrv->dyn_lock); 14883a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_add_tail(&dynid->list, &hdrv->dyn_list); 14893a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 14903a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14913a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = 0; 14923a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (get_driver(&hdrv->driver)) { 14933a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = driver_attach(&hdrv->driver); 14943a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby put_driver(&hdrv->driver); 14953a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 14963a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 14973a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return ret ? : count; 14983a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby} 14993a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 15003a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15013a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic void hid_free_dynids(struct hid_driver *hdrv) 15023a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby{ 15033a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_dynid *dynid, *n; 15043a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15053a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock(&hdrv->dyn_lock); 15063a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { 15073a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_del(&dynid->list); 15083a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby kfree(dynid); 15093a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 15103a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 15113a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby} 15123a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15133a6f82f7a22cf19687f556997c6978b31c109360Jiri Slabystatic const struct hid_device_id *hid_match_device(struct hid_device *hdev, 15143a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_driver *hdrv) 15153a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby{ 15163a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby struct hid_dynid *dynid; 15173a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15183a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock(&hdrv->dyn_lock); 15193a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby list_for_each_entry(dynid, &hdrv->dyn_list, list) { 15203a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (hid_match_one_id(hdev, &dynid->id)) { 15213a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 15223a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return &dynid->id; 15233a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 15243a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby } 15253a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_unlock(&hdrv->dyn_lock); 15263a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 15273a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return hid_match_id(hdev, hdrv->id_table); 15283a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby} 15293a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 153085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_bus_match(struct device *dev, struct device_driver *drv) 153185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 153285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 153385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 153485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 15353a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (!hid_match_device(hdev, hdrv)) 153685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 153785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1538ce06b9d6d33fd2ed799b6e825d68fe95077da354Dmitry Torokhov /* generic wants all that don't have specialized driver */ 153985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!strncmp(hdrv->name, "generic-", 8)) 1540ce06b9d6d33fd2ed799b6e825d68fe95077da354Dmitry Torokhov return !hid_match_id(hdev, hid_have_special_driver); 154185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 154285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 1; 154385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 154485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 154585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_device_probe(struct device *dev) 154685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 154785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = container_of(dev->driver, 154885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver, driver); 154985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 155085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const struct hid_device_id *id; 155185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret = 0; 155285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 155385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!hdev->driver) { 15543a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby id = hid_match_device(hdev, hdrv); 1555c500c9714011edab021591340042787722db9cf0Jiri Slaby if (id == NULL) 1556c500c9714011edab021591340042787722db9cf0Jiri Slaby return -ENODEV; 155785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1558c500c9714011edab021591340042787722db9cf0Jiri Slaby hdev->driver = hdrv; 1559c500c9714011edab021591340042787722db9cf0Jiri Slaby if (hdrv->probe) { 1560c500c9714011edab021591340042787722db9cf0Jiri Slaby ret = hdrv->probe(hdev, id); 1561c500c9714011edab021591340042787722db9cf0Jiri Slaby } else { /* default probe */ 1562c500c9714011edab021591340042787722db9cf0Jiri Slaby ret = hid_parse(hdev); 1563c500c9714011edab021591340042787722db9cf0Jiri Slaby if (!ret) 156493c10132a7ac160df3175b53f7ee857625412165Jiri Slaby ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 156585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 1566c500c9714011edab021591340042787722db9cf0Jiri Slaby if (ret) 1567c500c9714011edab021591340042787722db9cf0Jiri Slaby hdev->driver = NULL; 156885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 156985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 157085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 157185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 157285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_device_remove(struct device *dev) 157385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 157485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 157585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_driver *hdrv = hdev->driver; 157685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 157785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv) { 157885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdrv->remove) 157985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->remove(hdev); 1580c500c9714011edab021591340042787722db9cf0Jiri Slaby else /* default remove */ 1581c500c9714011edab021591340042787722db9cf0Jiri Slaby hid_hw_stop(hdev); 158285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->driver = NULL; 158385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 158485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 158585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 158685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 158785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 158885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 158985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 159085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 159185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 159285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 159385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->bus, hdev->vendor, hdev->product)) 159485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 159585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 159685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 159785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 159885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 159985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 160085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 160185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 160285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 160385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 160485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 160585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", 160685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->bus, hdev->vendor, hdev->product)) 160785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -ENOMEM; 160885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 160985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 161085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 161185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 161285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic struct bus_type hid_bus_type = { 161385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .name = "hid", 161485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .match = hid_bus_match, 161585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .probe = hid_device_probe, 161685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .remove = hid_device_remove, 161785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby .uevent = hid_uevent, 161885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby}; 161985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1620bae7eb33b25387fdc7ccae08768bef1f9484a5b0Jiri Kosina/* a list of devices that shouldn't be handled by HID core at all */ 1621d458a9dfc4de24870b8c747484b1988726534beeJiri Slabystatic const struct hid_device_id hid_ignore_list[] = { 1622d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1623d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1624d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1625d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1626d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1627d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1628d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1629d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1630d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1631d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1632d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1633d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 163477f720b71d88a3cbf574c113566a31c93099f97dStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, 163577f720b71d88a3cbf574c113566a31c93099f97dStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, 163662a56582e01b1c5139b235004548e233201df9aaAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1637d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1638d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1639d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1640d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1641d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1642d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 16435f6108cf9be4a77d6bee96750aa4fe18b6b97deeAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, 1644d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1645d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 164673bc7d315f56e260071bdb5f15e25b53bddc1402Melchior FRANZ { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, 1647d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 164870c66567d1e41d8b2186a2d198997a1c8d79c0c4Petr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1649df506f2c0023380ffa67a946fa36eee4150773a3Petr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1650d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1651d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, 1652d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1653d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1654d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1655d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1656d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1657d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1658d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1659d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1660d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1661d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1662d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1663d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1664d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1665d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1666d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1667d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1668d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1669d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1670d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1671d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1672d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1673d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1674d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1675d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1676d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1677d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1678d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1679d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1680d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1681d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1682d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1683d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1684d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1685d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1686d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1687d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1688d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1689d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1690d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1691d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1692d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1693d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1694d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 1695d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 1696d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 1697d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 1698d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 1699d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 1700d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 1701d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 1702d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 1703d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 1704d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 1705d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 1706d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 1707d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 1708d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 1709d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 1710d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 1711d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1712d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1713d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 17146bc235a2e24a5ef677daee3fd4f74f6cd643e23cTomoki Sekiyama { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_YUREX) }, 1715d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1716c91c21c5a6facddce936d82e5bc0c655d04288aaAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1717d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1718eb8141ccd32d422fa11c6e2108cae4c40456d811Lamarque Vieira Souza { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, 1719d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1720d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1721d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1722d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 1723d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 1724d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 1725d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, 1726d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 1727d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 1728d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 1729d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 1730d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 1731d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 1732d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 1733d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 1734d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 1735d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 1736d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 1737d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 1738d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 1739d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 1740d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 1741d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 1742d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 1743d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 1744d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 1745d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 1746d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 1747d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 1748d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 1749d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1750d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1751d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 17524cfae3e80431fd113f0f4a8e1d4fff84aafe045cHenning Glawe { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 175335cfd1d964f3c2420862f2167a0eb85ff1208999Michael Tokarev { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 1754d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1755d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1756d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1757d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 1758d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 1759d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 1760d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 1761d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1762d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1763d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1764d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby { } 1765d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby}; 1766d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 1767b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby/** 1768b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer 1769b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * 1770b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * There are composite devices for which we want to ignore only a certain 1771b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * interface. This is a list of devices for which only the mouse interface will 1772b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby * be ignored. This allows a dedicated driver to take care of the interface. 1773b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby */ 1774b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slabystatic const struct hid_device_id hid_mouse_ignore_list[] = { 1775b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby /* appletouch driver */ 1776b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1777b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1778b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1779b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1780b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1781b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1782b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1783b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1784b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1785b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1786b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1787b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1788b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1789b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1790b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1791b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1792b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1793b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1794b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1795b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1796ac26fca3e14c8882e382daa7e96ab73e0186cf03Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1797ac26fca3e14c8882e382daa7e96ab73e0186cf03Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1798ac26fca3e14c8882e382daa7e96ab73e0186cf03Jiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 179999b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 180099b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 180199b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 180299b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 180399b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 180499b9f758bbc904f22faffcf4d83205f4a5e7bc0cEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 1805b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1806b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1807b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby { } 1808b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby}; 1809b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby 1810d458a9dfc4de24870b8c747484b1988726534beeJiri Slabystatic bool hid_ignore(struct hid_device *hdev) 1811d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby{ 1812d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby switch (hdev->vendor) { 1813d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby case USB_VENDOR_ID_CODEMERCS: 1814d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby /* ignore all Code Mercenaries IOWarrior devices */ 1815d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 1816d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 1817d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return true; 1818d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby break; 1819d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby case USB_VENDOR_ID_LOGITECH: 1820d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 1821d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 1822d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return true; 1823d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby break; 182431f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson case USB_VENDOR_ID_SOUNDGRAPH: 182531f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && 182631f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) 182731f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson return true; 182831f7fd795d17b264c3c05e4a976f963012c17c68Jarod Wilson break; 1829bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei case USB_VENDOR_ID_HANWANG: 1830bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && 1831bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) 1832bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei return true; 1833bba5394ad3bd23fff6987fc8bc3aaf9d12433c63Xing Wei break; 1834d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby } 1835d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 1836b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby if (hdev->type == HID_TYPE_USBMOUSE && 1837b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby hid_match_id(hdev, hid_mouse_ignore_list)) 1838b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby return true; 1839b4d8e4736c94e78fd846dca0c95a3a0710582584Jiri Slaby 1840d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return !!hid_match_id(hdev, hid_ignore_list); 1841d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby} 1842d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 184385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint hid_add_device(struct hid_device *hdev) 184485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 184585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby static atomic_t id = ATOMIC_INIT(0); 184685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 184785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 184885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (WARN_ON(hdev->status & HID_STAT_ADDED)) 184985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return -EBUSY; 185085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1851d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby /* we need to kill them here, otherwise they will stay allocated to 1852d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby * wait for coming driver */ 1853e5a2a04c264e693eafcc78fec5add34c9e15e471Jindrich Makovicka if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 1854e5a2a04c264e693eafcc78fec5add34c9e15e471Jindrich Makovicka && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) 1855d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby return -ENODEV; 1856d458a9dfc4de24870b8c747484b1988726534beeJiri Slaby 18576bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers /* XXX hack, any other cleaner solution after the driver core 18586bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers * is converted to allow more than 20 bytes as the device name? */ 18596bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 18606bbe586fd4d94439f3960e200056ff057f7db5c6Kay Sievers hdev->vendor, hdev->product, atomic_inc_return(&id)); 186185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 18624da361b69102cdffe73006771eae7504d2cb8736Bruno Prémont hid_debug_register(hdev, dev_name(&hdev->dev)); 186385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = device_add(&hdev->dev); 186485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (!ret) 186585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->status |= HID_STAT_ADDED; 18664da361b69102cdffe73006771eae7504d2cb8736Bruno Prémont else 18674da361b69102cdffe73006771eae7504d2cb8736Bruno Prémont hid_debug_unregister(hdev); 1868a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina 186985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 187085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 187185cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_add_device); 187285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 187385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 187485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_allocate_device - allocate new hid device descriptor 187585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 187685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * Allocate and initialize hid device, so that hid_destroy_device might be 187785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * used to free it. 187885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 187985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 188085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * error value. 188185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 188285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystruct hid_device *hid_allocate_device(void) 188385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 188485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby struct hid_device *hdev; 188585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby unsigned int i; 188685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret = -ENOMEM; 188785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 188885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 188985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdev == NULL) 189085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ERR_PTR(ret); 189185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 189285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby device_initialize(&hdev->dev); 189385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->dev.release = hid_device_release; 189485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->dev.bus = &hid_bus_type; 189585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 189685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 189785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby sizeof(struct hid_collection), GFP_KERNEL); 189885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdev->collection == NULL) 189985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 190085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 190185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 190285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby for (i = 0; i < HID_REPORT_TYPES; i++) 190385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 190485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1905cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina init_waitqueue_head(&hdev->debug_wait); 1906cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina INIT_LIST_HEAD(&hdev->debug_list); 1907cd667ce24796700e1a0e6e7528efc61c96ff832eJiri Kosina 190885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return hdev; 190985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr: 191085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby put_device(&hdev->dev); 191185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ERR_PTR(ret); 191285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 191385cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_allocate_device); 191485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 191585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabystatic void hid_remove_device(struct hid_device *hdev) 191685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 191785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (hdev->status & HID_STAT_ADDED) { 191885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby device_del(&hdev->dev); 1919a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina hid_debug_unregister(hdev); 192085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdev->status &= ~HID_STAT_ADDED; 192185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 192285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 192385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 192485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby/** 192585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * hid_destroy_device - free previously allocated device 192685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 192785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * @hdev: hid device 192885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * 192985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * If you allocate hid_device through hid_allocate_device, you should ever 193085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby * free by this function. 193185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby */ 193285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyvoid hid_destroy_device(struct hid_device *hdev) 193385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 193485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hid_remove_device(hdev); 193585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby put_device(&hdev->dev); 193685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 193785cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_destroy_device); 193885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 193985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyint __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 194085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby const char *mod_name) 194185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 19423a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby int ret; 19433a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 194485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.name = hdrv->name; 194585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.bus = &hid_bus_type; 194685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.owner = owner; 194785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby hdrv->driver.mod_name = mod_name; 194885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 19493a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby INIT_LIST_HEAD(&hdrv->dyn_list); 19503a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby spin_lock_init(&hdrv->dyn_lock); 19513a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 19523a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = driver_register(&hdrv->driver); 19533a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (ret) 19543a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return ret; 19553a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 19563a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); 19573a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby if (ret) 19583a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby driver_unregister(&hdrv->driver); 19593a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby 19603a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby return ret; 196185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 196285cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(__hid_register_driver); 196385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 196485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyvoid hid_unregister_driver(struct hid_driver *hdrv) 196585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby{ 19663a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby driver_remove_file(&hdrv->driver, &driver_attr_new_id); 196785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby driver_unregister(&hdrv->driver); 19683a6f82f7a22cf19687f556997c6978b31c109360Jiri Slaby hid_free_dynids(hdrv); 196985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby} 197085cdaf524b7ddab627e7d15405693f2511ef7505Jiri SlabyEXPORT_SYMBOL_GPL(hid_unregister_driver); 197185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 19720361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukumint hid_check_keys_pressed(struct hid_device *hid) 19730361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum{ 19740361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum struct hid_input *hidinput; 19750361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum int i; 19760361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 1977e5288eb5ea89bd82d897cb687348bc608278f920Jiri Kosina if (!(hid->claimed & HID_CLAIMED_INPUT)) 1978e5288eb5ea89bd82d897cb687348bc608278f920Jiri Kosina return 0; 1979e5288eb5ea89bd82d897cb687348bc608278f920Jiri Kosina 19800361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum list_for_each_entry(hidinput, &hid->inputs, list) { 19810361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) 19820361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum if (hidinput->input->key[i]) 19830361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum return 1; 19840361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum } 19850361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 19860361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum return 0; 19870361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum} 19880361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 19890361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver NeukumEXPORT_SYMBOL_GPL(hid_check_keys_pressed); 19900361a28d3f9a4315a100c7b37ba0b55cfe15fe07Oliver Neukum 199186166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinastatic int __init hid_init(void) 199286166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina{ 199385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby int ret; 199485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 1995a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina if (hid_debug) 19964291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches pr_warn("hid_debug is now used solely for parser and driver debugging.\n" 19974291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches "debugfs is now used for inspecting the device (report descriptor, reports)\n"); 1998a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina 199985cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = bus_register(&hid_bus_type); 200085cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret) { 20014291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches pr_err("can't register hid bus\n"); 200285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err; 200385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby } 200485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 200585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby ret = hidraw_init(); 200685cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby if (ret) 200785cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby goto err_bus; 200885cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby 2009a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina hid_debug_init(); 2010a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina 201185cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return 0; 201285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr_bus: 201385cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby bus_unregister(&hid_bus_type); 201485cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slabyerr: 201585cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby return ret; 201686166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina} 201786166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina 201886166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinastatic void __exit hid_exit(void) 201986166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina{ 2020a635f9dd83f3382577f4544a96df12356e951a40Jiri Kosina hid_debug_exit(); 202186166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina hidraw_exit(); 202285cdaf524b7ddab627e7d15405693f2511ef7505Jiri Slaby bus_unregister(&hid_bus_type); 202386166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina} 202486166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina 202586166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinamodule_init(hid_init); 202686166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosinamodule_exit(hid_exit); 202786166b7bcda0bcb53525114fa1c87ac432be478eJiri Kosina 202888adb72bcf3b1cc6b440fda9fa97bc2151245fc5Jiri KosinaMODULE_AUTHOR("Andreas Gal"); 202988adb72bcf3b1cc6b440fda9fa97bc2151245fc5Jiri KosinaMODULE_AUTHOR("Vojtech Pavlik"); 203088adb72bcf3b1cc6b440fda9fa97bc2151245fc5Jiri KosinaMODULE_AUTHOR("Jiri Kosina"); 2031aa938f7974b82cfd9ee955031987344f332b7c77Jiri KosinaMODULE_LICENSE(DRIVER_LICENSE); 2032aa938f7974b82cfd9ee955031987344f332b7c77Jiri Kosina 2033