Lines Matching full:hid
6 * HID to Linux Input mapping
20 #include <linux/hid.h>
21 #include <linux/hid-debug.h>
23 #include "hid-ids.h"
52 __u32 usage; /* the HID usage associated */
62 * hid-input will convert this list into priorities:
67 * hid-input will then shift the priority by 8 bits to leave some space
73 * If drivers want to add fields before those, hid-input will
110 return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode; in match_scancode()
131 static struct hid_usage *hidinput_find_key(struct hid_device *hid, in hidinput_find_key() argument
141 list_for_each_entry(report, &hid->report_enum[k].report_list, list) { in hidinput_find_key()
160 static struct hid_usage *hidinput_locate_usage(struct hid_device *hid, in hidinput_locate_usage() argument
168 usage = hidinput_find_key(hid, match_index, ke->index, index); in hidinput_locate_usage()
170 usage = hidinput_find_key(hid, match_scancode, scancode, index); in hidinput_locate_usage()
180 struct hid_device *hid = input_get_drvdata(dev); in hidinput_getkeycode() local
184 usage = hidinput_locate_usage(hid, ke, &index); in hidinput_getkeycode()
189 scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE); in hidinput_getkeycode()
202 struct hid_device *hid = input_get_drvdata(dev); in hidinput_setkeycode() local
205 usage = hidinput_locate_usage(hid, ke, NULL); in hidinput_setkeycode()
214 dbg_hid("Assigned keycode %d to HID usage code %x\n", in hidinput_setkeycode()
215 usage->code, usage->hid); in hidinput_setkeycode()
221 if (hidinput_find_key(hid, match_keycode, *old_keycode, NULL)) in hidinput_setkeycode()
233 * @field: the HID report field to calculate resolution for
241 * as seen in the HID specification v1.11 6.2.2.7 Global Items.
261 * See HID specification v1.11 6.2.2.7 Global Items for unit decoding in hidinput_calc_abs_res()
389 * Elan I2C-HID touchscreens seem to all report a non present battery,
390 * set HID_BATTERY_QUIRK_IGNORE for all Elan I2C-HID devices.
524 psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery", in hidinput_setup_battery()
687 (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) { in hidinput_configure_usage()
693 if (usage->hid == hidinput_usages_priorities[i].usage) { in hidinput_configure_usage()
722 switch (usage->hid & HID_USAGE_PAGE) { in hidinput_configure_usage()
729 if ((usage->hid & HID_USAGE) < 256) { in hidinput_configure_usage()
730 if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore; in hidinput_configure_usage()
731 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]); in hidinput_configure_usage()
738 code = ((usage->hid - 1) & HID_USAGE); in hidinput_configure_usage()
780 switch (usage->hid & 0xffff) { in hidinput_configure_usage()
791 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ in hidinput_configure_usage()
792 switch (usage->hid & 0xf) { in hidinput_configure_usage()
813 if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/ in hidinput_configure_usage()
814 switch (usage->hid & 0xf) { in hidinput_configure_usage()
821 if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */ in hidinput_configure_usage()
822 switch (usage->hid & 0xf) { in hidinput_configure_usage()
830 if ((usage->hid & 0xf0) == 0xb0) { /* SC - Display */ in hidinput_configure_usage()
831 switch (usage->hid & 0xf) { in hidinput_configure_usage()
847 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */ in hidinput_configure_usage()
848 switch (usage->hid) { in hidinput_configure_usage()
863 switch (usage->hid) { in hidinput_configure_usage()
868 map_rel(usage->hid & 0xf); in hidinput_configure_usage()
870 map_abs_clear(usage->hid & 0xf); in hidinput_configure_usage()
878 map_abs(usage->hid & 0xf); in hidinput_configure_usage()
883 map_rel(usage->hid & 0xf); in hidinput_configure_usage()
885 map_abs(usage->hid & 0xf); in hidinput_configure_usage()
913 switch (usage->hid & 0xffff) { /* HID-Value: */ in hidinput_configure_usage()
936 switch (usage->hid & 0xff) { in hidinput_configure_usage()
1035 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
1058 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
1252 switch (usage->hid) { in hidinput_configure_usage()
1261 switch (usage->hid) { in hidinput_configure_usage()
1272 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
1284 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
1303 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
1326 switch (usage->hid & HID_USAGE) { in hidinput_configure_usage()
1369 * - HID aims at being generic so we should do our best to export in hidinput_configure_usage()
1371 * - HID describes what events are, so there is no reason for ABS_X in hidinput_configure_usage()
1373 * - HID is using *_MISC+N as a default value, but nothing prevents in hidinput_configure_usage()
1511 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, _… in hidinput_hid_event() argument
1515 unsigned *quirks = &hid->quirks; in hidinput_hid_event()
1521 bool handled = hidinput_set_battery_charge_status(hid, usage->hid, value); in hidinput_hid_event()
1524 hidinput_update_battery(hid, value); in hidinput_hid_event()
1545 * Ignore out-of-range values as per HID specification, in hidinput_hid_event()
1548 * driver as mentioned in "Required HID usages for digitizers": in hidinput_hid_event()
1568 switch (usage->hid) { in hidinput_hid_event()
1591 /* let hid-input set BTN_TOUCH */ in hidinput_hid_event()
1700 * RollOver implementations for localized keys (like BACKSLASH/PIPE; HID in hidinput_hid_event()
1704 * the input layer. If we filter the 'dead' keys on the HID level, we in hidinput_hid_event()
1717 input_event(input, EV_MSC, MSC_SCAN, usage->hid); in hidinput_hid_event()
1728 void hidinput_report_event(struct hid_device *hid, struct hid_report *report) in hidinput_report_event() argument
1732 if (hid->quirks & HID_QUIRK_NO_INPUT_SYNC) in hidinput_report_event()
1735 list_for_each_entry(hidinput, &hid->inputs, list) in hidinput_report_event()
1740 static int hidinput_find_field(struct hid_device *hid, unsigned int type, in hidinput_find_field() argument
1746 list_for_each_entry(report, &hid->report_enum[HID_OUTPUT_REPORT].report_list, list) { in hidinput_find_field()
1757 struct hid_field *hidinput_get_led_field(struct hid_device *hid) in hidinput_get_led_field() argument
1764 &hid->report_enum[HID_OUTPUT_REPORT].report_list, in hidinput_get_led_field()
1777 unsigned int hidinput_count_leds(struct hid_device *hid) in hidinput_count_leds() argument
1785 &hid->report_enum[HID_OUTPUT_REPORT].report_list, in hidinput_count_leds()
1801 struct hid_device *hid = container_of(work, struct hid_device, in hidinput_led_worker() local
1809 field = hidinput_get_led_field(hid); in hidinput_led_worker()
1814 * field->report is accessed unlocked regarding HID core. So there might in hidinput_led_worker()
1829 if (hid->ll_driver->request) in hidinput_led_worker()
1830 return hid->ll_driver->request(hid, report, HID_REQ_SET_REPORT); in hidinput_led_worker()
1840 ret = hid_hw_output_report(hid, buf, len); in hidinput_led_worker()
1842 hid_hw_raw_request(hid, report->id, buf, len, HID_OUTPUT_REPORT, in hidinput_led_worker()
1850 struct hid_device *hid = input_get_drvdata(dev); in hidinput_input_event() local
1860 if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) { in hidinput_input_event()
1867 schedule_work(&hid->led_work); in hidinput_input_event()
1873 struct hid_device *hid = input_get_drvdata(dev); in hidinput_open() local
1875 return hid_hw_open(hid); in hidinput_open()
1880 struct hid_device *hid = input_get_drvdata(dev); in hidinput_close() local
1882 hid_hw_close(hid); in hidinput_close()
1885 static bool __hidinput_change_resolution_multipliers(struct hid_device *hid, in __hidinput_change_resolution_multipliers() argument
1911 if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER) in __hidinput_change_resolution_multipliers()
1925 if (hid->quirks & HID_QUIRK_NO_INIT_REPORTS) in __hidinput_change_resolution_multipliers()
1928 hid_hw_request(hid, report, HID_REQ_GET_REPORT); in __hidinput_change_resolution_multipliers()
1929 hid_hw_wait(hid); in __hidinput_change_resolution_multipliers()
1941 static void hidinput_change_resolution_multipliers(struct hid_device *hid) in hidinput_change_resolution_multipliers() argument
1947 rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; in hidinput_change_resolution_multipliers()
1949 bool update_needed = __hidinput_change_resolution_multipliers(hid, in hidinput_change_resolution_multipliers()
1953 ret = __hid_request(hid, rep, HID_REQ_SET_REPORT); in hidinput_change_resolution_multipliers()
1955 __hidinput_change_resolution_multipliers(hid, in hidinput_change_resolution_multipliers()
1963 hid_setup_resolution_multiplier(hid); in hidinput_change_resolution_multipliers()
1966 static void report_features(struct hid_device *hid) in report_features() argument
1968 struct hid_driver *drv = hid->driver; in report_features()
1974 rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; in report_features()
1985 if (usage->hid == HID_DC_BATTERYSTRENGTH) in report_features()
1986 hidinput_setup_battery(hid, HID_FEATURE_REPORT, in report_features()
1990 drv->feature_mapping(hid, rep->field[i], usage); in report_features()
1995 static struct hid_input *hidinput_allocate(struct hid_device *hid, in hidinput_allocate() argument
2006 if ((hid->quirks & HID_QUIRK_INPUT_PER_APP) && in hidinput_allocate()
2007 hid->maxapplication > 1) { in hidinput_allocate()
2055 name_len = strlen(hid->name); in hidinput_allocate()
2058 strcmp(hid->name + name_len - suffix_len, suffix)) { in hidinput_allocate()
2060 hid->name, suffix); in hidinput_allocate()
2066 input_set_drvdata(input_dev, hid); in hidinput_allocate()
2073 input_dev->name = hidinput->name ? hidinput->name : hid->name; in hidinput_allocate()
2074 input_dev->phys = hid->phys; in hidinput_allocate()
2075 input_dev->uniq = hid->uniq; in hidinput_allocate()
2076 input_dev->id.bustype = hid->bus; in hidinput_allocate()
2077 input_dev->id.vendor = hid->vendor; in hidinput_allocate()
2078 input_dev->id.product = hid->product; in hidinput_allocate()
2079 input_dev->id.version = hid->version; in hidinput_allocate()
2080 input_dev->dev.parent = &hid->dev; in hidinput_allocate()
2084 list_add_tail(&hidinput->list, &hid->inputs); in hidinput_allocate()
2093 hid_err(hid, "Out of memory during hid input probe\n"); in hidinput_allocate()
2132 static void hidinput_cleanup_hidinput(struct hid_device *hid, in hidinput_cleanup_hidinput() argument
2144 hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) in hidinput_cleanup_hidinput()
2147 list_for_each_entry(report, &hid->report_enum[k].report_list, in hidinput_cleanup_hidinput()
2161 struct hid_device *hid = report->device; in hidinput_match() local
2164 list_for_each_entry(hidinput, &hid->inputs, list) { in hidinput_match()
2175 struct hid_device *hid = report->device; in hidinput_match_application() local
2178 list_for_each_entry(hidinput, &hid->inputs, list) { in hidinput_match_application()
2236 if (field->usage[j].hid == HID_DG_CONTACTID) { in hidinput_configure_usages()
2264 int hidinput_connect(struct hid_device *hid, unsigned int force) in hidinput_connect() argument
2266 struct hid_driver *drv = hid->driver; in hidinput_connect()
2272 INIT_LIST_HEAD(&hid->inputs); in hidinput_connect()
2273 INIT_WORK(&hid->led_work, hidinput_led_worker); in hidinput_connect()
2275 hid->status &= ~HID_STAT_DUP_DETECTED; in hidinput_connect()
2278 for (i = 0; i < hid->maxcollection; i++) { in hidinput_connect()
2279 struct hid_collection *col = &hid->collection[i]; in hidinput_connect()
2286 if (i == hid->maxcollection) in hidinput_connect()
2290 report_features(hid); in hidinput_connect()
2294 hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) in hidinput_connect()
2297 list_for_each_entry(report, &hid->report_enum[k].report_list, list) { in hidinput_connect()
2308 if (hid->quirks & HID_QUIRK_MULTI_INPUT) in hidinput_connect()
2310 else if (hid->maxapplication > 1 && in hidinput_connect()
2311 (hid->quirks & HID_QUIRK_INPUT_PER_APP)) in hidinput_connect()
2315 hidinput = hidinput_allocate(hid, application); in hidinput_connect()
2322 if (hid->quirks & HID_QUIRK_MULTI_INPUT) in hidinput_connect()
2330 hidinput_change_resolution_multipliers(hid); in hidinput_connect()
2332 list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { in hidinput_connect()
2334 drv->input_configured(hid, hidinput)) in hidinput_connect()
2339 hidinput_cleanup_hidinput(hid, hidinput); in hidinput_connect()
2348 if (list_empty(&hid->inputs)) { in hidinput_connect()
2349 hid_err(hid, "No inputs registered, leaving\n"); in hidinput_connect()
2353 if (hid->status & HID_STAT_DUP_DETECTED) in hidinput_connect()
2354 hid_dbg(hid, in hidinput_connect()
2361 hidinput_disconnect(hid); in hidinput_connect()
2367 void hidinput_disconnect(struct hid_device *hid) in hidinput_disconnect() argument
2371 hidinput_cleanup_battery(hid); in hidinput_disconnect()
2373 list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { in hidinput_disconnect()
2387 cancel_work_sync(&hid->led_work); in hidinput_disconnect()
2392 #include "hid-input-test.c"