From cd4dc0821bc97947f25c8483a4aa0711bff8619a Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Wed, 22 Jan 2014 13:49:41 -0500 Subject: HID: Add transport-driver callbacks to the hid_ll_driver struct Add raw_request and output_report callbacks to the hid_ll_driver struct. Signed-off-by: Frank Praznik Acked-by: David Herrmann Signed-off-by: Jiri Kosina --- include/linux/hid.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 31b9d299ef6c..003cc8e89831 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -700,8 +700,14 @@ struct hid_ll_driver { struct hid_report *report, int reqtype); int (*wait)(struct hid_device *hdev); - int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); + int (*raw_request) (struct hid_device *hdev, unsigned char reportnum, + __u8 *buf, size_t len, unsigned char rtype, + int reqtype); + + int (*output_report) (struct hid_device *hdev, __u8 *buf, size_t len); + + int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); }; #define PM_HINT_FULLON 1<<5 -- cgit v1.2.3 From b69d6536794c93dda362ab79c9f559382e3465be Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 5 Feb 2014 16:33:16 -0500 Subject: HID: add inliners for ll_driver transport-layer callbacks Those callbacks are not mandatory, so it's better to add inliners to use them safely. Reviewed-by: David Herrmann Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 003cc8e89831..dddcad07c2d9 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -680,6 +680,8 @@ struct hid_driver { * shouldn't allocate anything to not leak memory * @request: send report request to device (e.g. feature report) * @wait: wait for buffered io to complete (send/recv reports) + * @raw_request: send raw report request to device (e.g. feature report) + * @output_report: send output report to device * @idle: send idle request to device */ struct hid_ll_driver { @@ -973,6 +975,49 @@ static inline void hid_hw_request(struct hid_device *hdev, hdev->ll_driver->request(hdev, report, reqtype); } +/** + * hid_hw_raw_request - send report request to device + * + * @hdev: hid device + * @reportnum: report ID + * @buf: in/out data to transfer + * @len: length of buf + * @rtype: HID report type + * @reqtype: HID_REQ_GET_REPORT or HID_REQ_SET_REPORT + * + * @return: count of data transfered, negative if error + * + * Same behavior as hid_hw_request, but with raw buffers instead. + */ +static inline int hid_hw_raw_request(struct hid_device *hdev, + unsigned char reportnum, __u8 *buf, + size_t len, unsigned char rtype, int reqtype) +{ + if (hdev->ll_driver->raw_request) + return hdev->ll_driver->raw_request(hdev, reportnum, buf, len, + rtype, reqtype); + + return -ENOSYS; +} + +/** + * hid_hw_output_report - send output report to device + * + * @hdev: hid device + * @buf: raw data to transfer + * @len: length of buf + * + * @return: count of data transfered, negative if error + */ +static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, + size_t len) +{ + if (hdev->ll_driver->output_report) + return hdev->ll_driver->output_report(hdev, buf, len); + + return -ENOSYS; +} + /** * hid_hw_idle - send idle request to device * -- cgit v1.2.3 From b40272e4d0e6d07a0bf9409e5f95d622422cd73d Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 5 Feb 2014 16:33:19 -0500 Subject: HID: remove hidinput_input_event handler All the different transport drivers use now the generic event handling in hid-input. We can remove the handler definitively now. Reviewed-by: David Herrmann Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index dddcad07c2d9..38c307b8138a 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -675,7 +675,6 @@ struct hid_driver { * @stop: called on remove * @open: called by input layer on open * @close: called by input layer on close - * @hidinput_input_event: event input event (e.g. ff or leds) * @parse: this method is called only once to parse the device data, * shouldn't allocate anything to not leak memory * @request: send report request to device (e.g. feature report) @@ -693,9 +692,6 @@ struct hid_ll_driver { int (*power)(struct hid_device *hdev, int level); - int (*hidinput_input_event) (struct input_dev *idev, unsigned int type, - unsigned int code, int value); - int (*parse)(struct hid_device *hdev); void (*request)(struct hid_device *hdev, -- cgit v1.2.3 From cafebc058bf86e63fff5354864781d3de11e41d3 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 5 Feb 2014 16:33:22 -0500 Subject: HID: remove hid_get_raw_report in struct hid_device dev->hid_get_raw_report(X) and hid_hw_raw_request(X, HID_REQ_GET_REPORT) are strictly equivalent. Switch the hid subsystem to the hid_hw notation and remove the field .hid_get_raw_report in struct hid_device. Reviewed-by: David Herrmann Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 38c307b8138a..c56681a66b0b 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -508,9 +508,6 @@ struct hid_device { /* device report descriptor */ struct hid_usage *, __s32); void (*hiddev_report_event) (struct hid_device *, struct hid_report *); - /* handler for raw input (Get_Report) data, used by hidraw */ - int (*hid_get_raw_report) (struct hid_device *, unsigned char, __u8 *, size_t, unsigned char); - /* handler for raw output data, used by hidraw */ int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char); -- cgit v1.2.3 From 7e845d46b13e7730a3720e978c28117ce422edf9 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 5 Feb 2014 16:33:23 -0500 Subject: HID: introduce helper to access hid_output_raw_report() Add a helper to access hdev->hid_output_raw_report(). To convert the drivers, use the following snippets: for i in drivers/hid/*.c do sed -i.bak "s/[^ \t]*->hid_output_raw_report(/hid_output_raw_report(/g" $i done Then manually fix for checkpatch.pl Reviewed-by: David Herrmann Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index c56681a66b0b..a837ede65ec6 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1011,6 +1011,22 @@ static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, return -ENOSYS; } +/** + * hid_output_raw_report - send an output or a feature report to the device + * + * @hdev: hid device + * @buf: raw data to transfer + * @len: length of buf + * @report_type: HID_FEATURE_REPORT or HID_OUTPUT_REPORT + * + * @return: count of data transfered, negative if error + */ +static inline int hid_output_raw_report(struct hid_device *hdev, __u8 *buf, + size_t len, unsigned char report_type) +{ + return hdev->hid_output_raw_report(hdev, buf, len, report_type); +} + /** * hid_hw_idle - send idle request to device * -- cgit v1.2.3 From 4fa5a7f76cc7b6ac87f57741edd2b124851d119f Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 10 Feb 2014 12:58:48 -0500 Subject: HID: core: implement generic .request() .request() can be emulated through .raw_request() we can implement this emulation in hid-core, and make .request not mandatory for transport layer drivers. Signed-off-by: Benjamin Tissoires Reviewed-by: David Herrmann Signed-off-by: Jiri Kosina --- include/linux/hid.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index a837ede65ec6..09fbbd7fb784 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -753,6 +753,7 @@ struct hid_field *hidinput_get_led_field(struct hid_device *hid); unsigned int hidinput_count_leds(struct hid_device *hid); __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code); void hid_output_report(struct hid_report *report, __u8 *data); +void __hid_request(struct hid_device *hid, struct hid_report *rep, int reqtype); u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags); struct hid_device *hid_allocate_device(void); struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id); @@ -965,7 +966,9 @@ static inline void hid_hw_request(struct hid_device *hdev, struct hid_report *report, int reqtype) { if (hdev->ll_driver->request) - hdev->ll_driver->request(hdev, report, reqtype); + return hdev->ll_driver->request(hdev, report, reqtype); + + __hid_request(hdev, report, reqtype); } /** -- cgit v1.2.3 From 5318251744b2c8a288f91f4e53ed69f2a01d6412 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 10 Feb 2014 12:58:59 -0500 Subject: HID: core: check parameters when sending/receiving data from the device It is better to check them soon enough before triggering any kernel panic. Signed-off-by: Benjamin Tissoires Reviewed-by: David Herrmann Signed-off-by: Jiri Kosina --- include/linux/hid.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 09fbbd7fb784..60f3ff762376 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -989,6 +989,9 @@ static inline int hid_hw_raw_request(struct hid_device *hdev, unsigned char reportnum, __u8 *buf, size_t len, unsigned char rtype, int reqtype) { + if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf) + return -EINVAL; + if (hdev->ll_driver->raw_request) return hdev->ll_driver->raw_request(hdev, reportnum, buf, len, rtype, reqtype); @@ -1008,6 +1011,9 @@ static inline int hid_hw_raw_request(struct hid_device *hdev, static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len) { + if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf) + return -EINVAL; + if (hdev->ll_driver->output_report) return hdev->ll_driver->output_report(hdev, buf, len); -- cgit v1.2.3 From e02cee4819ae51f26333471c8eed50678b08572a Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 23 Jan 2014 18:50:21 -0800 Subject: HID: hid-sensor-hub: Add selector api In some report descriptors, they leave holes in the selectors. In this case if we use hardcoded selector values, this will result in invalid values. For example, if there is selectors defined for Power State from OFF to D0 to D3. We can't use indexes of these states if some states are not implemented or not present in the report decriptors. In this case, we need to get the indexes from report descriptors. One API is added to get the index of a selector. This API will search for usage id in the field usage list and return the index. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/hid-sensor-hub.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index b914ca3f57ba..205eba0326af 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@ -218,4 +218,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st, int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, int *val1, int *val2); +int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev, + u32 report_id, int field_index, u32 usage_id); + #endif -- cgit v1.2.3 From 1a214ae5d1a66ead18c5e8c3a8d03b969b0ee647 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 23 Jan 2014 18:50:22 -0800 Subject: iio: hid-sensor-hub: Remove hard coded indexes Remove the hard coded indexes, instead search for usage id and use the index to set the power and report state. This will fix issue, where the report descriptor doesn't contain the full list of possible selector for power and report state. Signed-off-by: Srinivas Pandruvada Acked-by: Jonathan Cameron Signed-off-by: Jiri Kosina --- include/linux/hid-sensor-ids.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index beaf965621c1..f8607605a31c 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -130,15 +130,15 @@ #define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS 0x1000 /* Power state enumerations */ -#define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x00 -#define HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM 0x01 -#define HID_USAGE_SENSOR_PROP_POWER_STATE_D1_LOW_POWER_ENUM 0x02 -#define HID_USAGE_SENSOR_PROP_POWER_STATE_D2_STANDBY_WITH_WAKE_ENUM 0x03 -#define HID_USAGE_SENSOR_PROP_POWER_STATE_D3_SLEEP_WITH_WAKE_ENUM 0x04 -#define HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM 0x05 +#define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x200850 +#define HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM 0x200851 +#define HID_USAGE_SENSOR_PROP_POWER_STATE_D1_LOW_POWER_ENUM 0x200852 +#define HID_USAGE_SENSOR_PROP_POWER_STATE_D2_STANDBY_WITH_WAKE_ENUM 0x200853 +#define HID_USAGE_SENSOR_PROP_POWER_STATE_D3_SLEEP_WITH_WAKE_ENUM 0x200854 +#define HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM 0x200855 /* Report State enumerations */ -#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM 0x00 -#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x01 +#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM 0x200840 +#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x200841 #endif -- cgit v1.2.3 From ca2ed12f163bf430a425ec725ef76df5254b9f45 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 31 Jan 2014 12:04:10 -0800 Subject: HID: hid-sensor-hub: Processing for duplicate physical ids In HID sensor hub, HID physical ids are used to represent different sensors. For example physical id of 0x73 in usage page = 0x20, represents an accelerometer. The HID sensor hub driver uses this physical ids to create platform devices using MFD. There is 1:1 correspondence between an phy id and a client driver. But in some cases these physical ids are reused. There is a phy id 0xe1, which specifies a custom sensor, which can exist multiple times to represent various custom sensors. In this case there can be multiple instances of client MFD drivers, processing specific custom sensor. In this case when client driver looks for report id or a field index, it should still get the report id specific to its own type. This is also true for reports, they should be directed towards correct instance. This change introduce a way to parse and tie physical devices to their correct instance. Summary of changes: - To get physical ids, use collections. If a collection of type=physical exist then use usage id as in the name of platform device name - As part of the platform data, we assign a hdsev instance, which has start and end of collection indexes. Using these indexes attributes can be tied to correct MFD client instances - When a report is received, call callback with correct hsdev instance. In this way using its private data stored as part of its registry, it can distinguish different sensors even when they have same physical and logical ids. This patch is co-authored with Archana Patni . Reported-by: Archana Patni Signed-off-by: Srinivas Pandruvada Signed-off-by: Archana Patni Signed-off-by: Jiri Kosina --- include/linux/hid-sensor-hub.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index 205eba0326af..b70cfd7ff29c 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@ -51,13 +51,15 @@ struct hid_sensor_hub_attribute_info { * @hdev: Stores the hid instance. * @vendor_id: Vendor id of hub device. * @product_id: Product id of hub device. - * @ref_cnt: Number of MFD clients have opened this device + * @start_collection_index: Starting index for a phy type collection + * @end_collection_index: Last index for a phy type collection */ struct hid_sensor_hub_device { struct hid_device *hdev; u32 vendor_id; u32 product_id; - int ref_cnt; + int start_collection_index; + int end_collection_index; }; /** -- cgit v1.2.3 From 3c86726cfe38952f0366f86acfbbb025813ec1c2 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 20 Feb 2014 15:24:49 -0500 Subject: HID: make .raw_request mandatory SET_REPORT and GET_REPORT are mandatory in the HID specification. Make the corresponding API in hid-core mandatory too, which removes the need to test against it in some various places. Signed-off-by: Benjamin Tissoires Reviewed-by: David Herrmann Signed-off-by: Jiri Kosina --- include/linux/hid.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 60f3ff762376..5eb282e0dff7 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -992,11 +992,8 @@ static inline int hid_hw_raw_request(struct hid_device *hdev, if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf) return -EINVAL; - if (hdev->ll_driver->raw_request) - return hdev->ll_driver->raw_request(hdev, reportnum, buf, len, + return hdev->ll_driver->raw_request(hdev, reportnum, buf, len, rtype, reqtype); - - return -ENOSYS; } /** -- cgit v1.2.3 From 6aef704e38293524067505eeafec9c811b18d66a Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 28 Feb 2014 11:41:25 -0500 Subject: HID: multitouch: add support of other generic collections in hid-mt The ANTON Touch Pad is a device which can switch from a multitouch touchpad to a mouse. It thus presents several generic collections which are currently ignored by hid-multitouch. Enable them by not ignoring them in mt_input_mapping. Adding also a suffix for them depending on their application. Reported-by: Edel Maks Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 5eb282e0dff7..e224516cc565 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -201,6 +201,7 @@ struct hid_item { #define HID_GD_VBRZ 0x00010045 #define HID_GD_VNO 0x00010046 #define HID_GD_FEATURE 0x00010047 +#define HID_GD_SYSTEM_CONTROL 0x00010080 #define HID_GD_UP 0x00010090 #define HID_GD_DOWN 0x00010091 #define HID_GD_RIGHT 0x00010092 @@ -208,6 +209,8 @@ struct hid_item { #define HID_DC_BATTERYSTRENGTH 0x00060020 +#define HID_CP_CONSUMER_CONTROL 0x000c0001 + #define HID_DG_DIGITIZER 0x000d0001 #define HID_DG_PEN 0x000d0002 #define HID_DG_LIGHTPEN 0x000d0003 -- cgit v1.2.3 From e534a9352237e84263cecedff283387b144b3ed8 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Sat, 8 Mar 2014 22:52:42 -0500 Subject: HID: sony: do not rely on hid_output_raw_report hid_out_raw_report is going to be obsoleted as it is not part of the unified HID low level transport documentation (Documentation/hid/hid-transport.txt) To do so, we need to introduce two new quirks: * HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP: this quirks prevents the transport driver to use the interrupt channel to send output report (and thus force to use HID_REQ_SET_REPORT command) * HID_QUIRK_SKIP_OUTPUT_REPORT_ID: this one forces usbhid to not include the report ID in the buffer it sends to the device through HID_REQ_SET_REPORT in case of an output report This also fixes a regression introduced in commit 3a75b24949a8 (HID: hidraw: replace hid_output_raw_report() calls by appropriates ones). The hidraw API was not able to communicate with the PS3 SixAxis controllers in USB mode. Reviewed-by: David Herrmann Signed-off-by: Benjamin Tissoires Tested-by: Antonio Ospite Signed-off-by: Jiri Kosina --- include/linux/hid.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 5eb282e0dff7..3fe444f4a36f 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -287,6 +287,8 @@ struct hid_item { #define HID_QUIRK_NO_EMPTY_INPUT 0x00000100 #define HID_QUIRK_NO_INIT_INPUT_REPORTS 0x00000200 #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 +#define HID_QUIRK_SKIP_OUTPUT_REPORT_ID 0x00020000 +#define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP 0x00040000 #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 #define HID_QUIRK_NO_INIT_REPORTS 0x20000000 #define HID_QUIRK_NO_IGNORE 0x40000000 -- cgit v1.2.3 From 6fd182028c43baf1c7d017d52b0134ecadbdc447 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Sat, 8 Mar 2014 22:52:43 -0500 Subject: HID: remove hid_output_raw_report transport implementations Nobody calls hid_output_raw_report anymore, and nobody should. We can now remove the various implementation in the different transport drivers and the declarations. Reviewed-by: David Herrmann Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 3fe444f4a36f..01a90b8d53bb 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -510,9 +510,6 @@ struct hid_device { /* device report descriptor */ struct hid_usage *, __s32); void (*hiddev_report_event) (struct hid_device *, struct hid_report *); - /* handler for raw output data, used by hidraw */ - int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char); - /* debugging support via debugfs */ unsigned short debug; struct dentry *debug_dir; @@ -1019,22 +1016,6 @@ static inline int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, return -ENOSYS; } -/** - * hid_output_raw_report - send an output or a feature report to the device - * - * @hdev: hid device - * @buf: raw data to transfer - * @len: length of buf - * @report_type: HID_FEATURE_REPORT or HID_OUTPUT_REPORT - * - * @return: count of data transfered, negative if error - */ -static inline int hid_output_raw_report(struct hid_device *hdev, __u8 *buf, - size_t len, unsigned char report_type) -{ - return hdev->hid_output_raw_report(hdev, buf, len, report_type); -} - /** * hid_hw_idle - send idle request to device * -- cgit v1.2.3 From 4522643aa9630be17238edf1b4c0b690c5dd7f5d Mon Sep 17 00:00:00 2001 From: Petri Gynther Date: Mon, 24 Mar 2014 13:50:01 -0700 Subject: HID: uhid: Add UHID_CREATE2 + UHID_INPUT2 UHID_CREATE2: HID report descriptor data (rd_data) is an array in struct uhid_create2_req, instead of a pointer. Enables use from languages that don't support pointers, e.g. Python. UHID_INPUT2: Data array is the last field of struct uhid_input2_req. Enables userspace to write only the required bytes to kernel (ev.type + ev.u.input2.size + the part of the data array that matters), instead of the entire struct uhid_input2_req. Note: UHID_CREATE2 increases the total size of struct uhid_event slightly, thus increasing the size of messages that are queued for userspace. However, this won't affect the userspace processing of these events. [Jiri Kosina : adjust to hid_get_raw_report() and hid_output_raw_report() API changes] Signed-off-by: Petri Gynther Reviewed-by: David Herrmann Signed-off-by: Jiri Kosina --- include/uapi/linux/uhid.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/uapi/linux/uhid.h b/include/uapi/linux/uhid.h index 414b74be4da1..1e3b09c191cd 100644 --- a/include/uapi/linux/uhid.h +++ b/include/uapi/linux/uhid.h @@ -21,6 +21,7 @@ #include #include +#include enum uhid_event_type { UHID_CREATE, @@ -34,6 +35,8 @@ enum uhid_event_type { UHID_INPUT, UHID_FEATURE, UHID_FEATURE_ANSWER, + UHID_CREATE2, + UHID_INPUT2, }; struct uhid_create_req { @@ -50,6 +53,19 @@ struct uhid_create_req { __u32 country; } __attribute__((__packed__)); +struct uhid_create2_req { + __u8 name[128]; + __u8 phys[64]; + __u8 uniq[64]; + __u16 rd_size; + __u16 bus; + __u32 vendor; + __u32 product; + __u32 version; + __u32 country; + __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE]; +} __attribute__((__packed__)); + #define UHID_DATA_MAX 4096 enum uhid_report_type { @@ -63,6 +79,11 @@ struct uhid_input_req { __u16 size; } __attribute__((__packed__)); +struct uhid_input2_req { + __u16 size; + __u8 data[UHID_DATA_MAX]; +} __attribute__((__packed__)); + struct uhid_output_req { __u8 data[UHID_DATA_MAX]; __u16 size; @@ -100,6 +121,8 @@ struct uhid_event { struct uhid_output_ev_req output_ev; struct uhid_feature_req feature; struct uhid_feature_answer_req feature_answer; + struct uhid_create2_req create2; + struct uhid_input2_req input2; } u; } __attribute__((__packed__)); -- cgit v1.2.3