Lines Matching full:hid

2  * HID over I2C protocol implementation
8 * This code is partly based on "USB HID support for Linux":
36 #include <linux/hid.h>
40 #include "../hid-ids.h"
41 #include "i2c-hid.h"
100 struct hid_device *hid; /* pointer to corresponding HID dev */ member
101 struct i2c_hid_desc hdesc; /* the HID Descriptor */
103 * register of the HID
150 * i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device
313 * @ihid: the i2c hid device
318 * @do_set: true: use SET_REPORT HID command, false: send plain OUTPUT report
418 * The HID over I2C specification states that if a DEVICE needs time in i2c_hid_set_power()
559 hid_input_report(ihid->hid, HID_INPUT_REPORT, in i2c_hid_get_input()
588 static void i2c_hid_find_max_report(struct hid_device *hid, unsigned int type, in i2c_hid_find_max_report() argument
596 list_for_each_entry(report, &hid->report_enum[type].report_list, list) { in i2c_hid_find_max_report()
643 static int i2c_hid_get_raw_report(struct hid_device *hid, in i2c_hid_get_raw_report() argument
647 struct i2c_client *client = hid->driver_data; in i2c_hid_get_raw_report()
675 static int i2c_hid_output_raw_report(struct hid_device *hid, u8 report_type, in i2c_hid_output_raw_report() argument
678 struct i2c_client *client = hid->driver_data; in i2c_hid_output_raw_report()
707 static int i2c_hid_output_report(struct hid_device *hid, u8 *buf, size_t count) in i2c_hid_output_report() argument
709 return i2c_hid_output_raw_report(hid, HID_OUTPUT_REPORT, buf, count, in i2c_hid_output_report()
713 static int i2c_hid_raw_request(struct hid_device *hid, unsigned char reportnum, in i2c_hid_raw_request() argument
719 return i2c_hid_get_raw_report(hid, rtype, reportnum, buf, len); in i2c_hid_raw_request()
723 return i2c_hid_output_raw_report(hid, rtype, buf, len, true); in i2c_hid_raw_request()
729 static int i2c_hid_parse(struct hid_device *hid) in i2c_hid_parse() argument
731 struct i2c_client *client = hid->driver_data; in i2c_hid_parse()
762 i2c_hid_dbg(ihid, "Using a HID report descriptor override\n"); in i2c_hid_parse()
771 i2c_hid_dbg(ihid, "asking HID report descriptor\n"); in i2c_hid_parse()
777 hid_err(hid, "reading report descriptor failed\n"); in i2c_hid_parse()
785 ret = hid_parse_report(hid, rdesc, rsize); in i2c_hid_parse()
797 static int i2c_hid_start(struct hid_device *hid) in i2c_hid_start() argument
799 struct i2c_client *client = hid->driver_data; in i2c_hid_start()
804 i2c_hid_find_max_report(hid, HID_INPUT_REPORT, &bufsize); in i2c_hid_start()
805 i2c_hid_find_max_report(hid, HID_OUTPUT_REPORT, &bufsize); in i2c_hid_start()
806 i2c_hid_find_max_report(hid, HID_FEATURE_REPORT, &bufsize); in i2c_hid_start()
822 static void i2c_hid_stop(struct hid_device *hid) in i2c_hid_stop() argument
824 hid->claimed = 0; in i2c_hid_stop()
827 static int i2c_hid_open(struct hid_device *hid) in i2c_hid_open() argument
829 struct i2c_client *client = hid->driver_data; in i2c_hid_open()
836 static void i2c_hid_close(struct hid_device *hid) in i2c_hid_close() argument
838 struct i2c_client *client = hid->driver_data; in i2c_hid_close()
887 /* i2c hid fetch using a fixed descriptor size (30 bytes) */ in i2c_hid_fetch_hid_descriptor()
889 i2c_hid_dbg(ihid, "Using a HID descriptor override\n"); in i2c_hid_fetch_hid_descriptor()
893 i2c_hid_dbg(ihid, "Fetching the HID descriptor\n"); in i2c_hid_fetch_hid_descriptor()
900 "failed to fetch HID descriptor: %d\n", in i2c_hid_fetch_hid_descriptor()
906 /* Validate the length of HID descriptor, the 4 first bytes: in i2c_hid_fetch_hid_descriptor()
912 "unexpected HID descriptor bcdVersion (0x%04hx)\n", in i2c_hid_fetch_hid_descriptor()
921 "weird size of HID descriptor (%u)\n", dsize); in i2c_hid_fetch_hid_descriptor()
924 i2c_hid_dbg(ihid, "HID Descriptor: %*ph\n", dsize, &ihid->hdesc); in i2c_hid_fetch_hid_descriptor()
957 struct hid_device *hid; in i2c_hid_core_probe() local
959 dbg_hid("HID probe called for i2c 0x%02x\n", client->addr); in i2c_hid_core_probe()
963 "HID over i2c has not been provided an Int IRQ\n"); in i2c_hid_core_probe()
970 "HID over i2c doesn't have a valid IRQ\n"); in i2c_hid_core_probe()
1013 "Failed to fetch the HID Descriptor\n"); in i2c_hid_core_probe()
1021 hid = hid_allocate_device(); in i2c_hid_core_probe()
1022 if (IS_ERR(hid)) { in i2c_hid_core_probe()
1023 ret = PTR_ERR(hid); in i2c_hid_core_probe()
1027 ihid->hid = hid; in i2c_hid_core_probe()
1029 hid->driver_data = client; in i2c_hid_core_probe()
1030 hid->ll_driver = &i2c_hid_ll_driver; in i2c_hid_core_probe()
1031 hid->dev.parent = &client->dev; in i2c_hid_core_probe()
1032 hid->bus = BUS_I2C; in i2c_hid_core_probe()
1033 hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); in i2c_hid_core_probe()
1034 hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); in i2c_hid_core_probe()
1035 hid->product = le16_to_cpu(ihid->hdesc.wProductID); in i2c_hid_core_probe()
1037 snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", in i2c_hid_core_probe()
1038 client->name, (u16)hid->vendor, (u16)hid->product); in i2c_hid_core_probe()
1039 strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); in i2c_hid_core_probe()
1041 ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); in i2c_hid_core_probe()
1043 ret = hid_add_device(hid); in i2c_hid_core_probe()
1046 hid_err(client, "can't add hid device: %d\n", ret); in i2c_hid_core_probe()
1050 hid->quirks |= quirks; in i2c_hid_core_probe()
1055 hid_destroy_device(hid); in i2c_hid_core_probe()
1070 struct hid_device *hid; in i2c_hid_core_remove() local
1072 hid = ihid->hid; in i2c_hid_core_remove()
1073 hid_destroy_device(hid); in i2c_hid_core_remove()
1100 struct hid_device *hid = ihid->hid; in i2c_hid_core_suspend() local
1104 ret = hid_driver_suspend(hid, PMSG_SUSPEND); in i2c_hid_core_suspend()
1118 hid_warn(hid, "Failed to enable irq wake: %d\n", in i2c_hid_core_suspend()
1132 struct hid_device *hid = ihid->hid; in i2c_hid_core_resume() local
1142 hid_warn(hid, "Failed to disable irq wake: %d\n", in i2c_hid_core_resume()
1164 return hid_driver_reset_resume(hid); in i2c_hid_core_resume()
1173 MODULE_DESCRIPTION("HID over I2C core driver");