Commit 105856b3 authored by Jiri Kosina's avatar Jiri Kosina
Browse files

Merge branch 'for-5.11/core' into for-linus

- increase of maximum HID report size to 16KB in order to support
  some of the modern devices, from Dean Camera

- control interface support for hidraw, from Dean Camera

- stylus battery reporting improvement, from Dmitry Torokhov
parents 90c5f464 f43d3870
Loading
Loading
Loading
Loading
+43 −2
Original line number Diff line number Diff line
@@ -123,8 +123,49 @@ HIDIOCGFEATURE(len):
This ioctl will request a feature report from the device using the control
endpoint.  The first byte of the supplied buffer should be set to the report
number of the requested report.  For devices which do not use numbered
reports, set the first byte to 0.  The report will be returned starting at
the first byte of the buffer (ie: the report number is not returned).
reports, set the first byte to 0.  The returned report buffer will contain the
report number in the first byte, followed by the report data read from the
device.  For devices which do not use numbered reports, the report data will
begin at the first byte of the returned buffer.

HIDIOCSINPUT(len):
	Send an Input Report

This ioctl will send an input report to the device, using the control endpoint.
In most cases, setting an input HID report on a device is meaningless and has
no effect, but some devices may choose to use this to set or reset an initial
state of a report.  The format of the buffer issued with this report is identical
to that of HIDIOCSFEATURE.

HIDIOCGINPUT(len):
	Get an Input Report

This ioctl will request an input report from the device using the control
endpoint.  This is slower on most devices where a dedicated In endpoint exists
for regular input reports, but allows the host to request the value of a
specific report number.  Typically, this is used to request the initial states of
an input report of a device, before an application listens for normal reports via
the regular device read() interface.  The format of the buffer issued with this report
is identical to that of HIDIOCGFEATURE.

HIDIOCSOUTPUT(len):
	Send an Output Report

This ioctl will send an output report to the device, using the control endpoint.
This is slower on most devices where a dedicated Out endpoint exists for regular
output reports, but is added for completeness.  Typically, this is used to set
the initial states of an output report of a device, before an application sends
updates via the regular device write() interface. The format of the buffer issued
with this report is identical to that of HIDIOCSFEATURE.

HIDIOCGOUTPUT(len):
	Get an Output Report

This ioctl will request an output report from the device using the control
endpoint.  Typically, this is used to retrive the initial state of
an output report of a device, before an application updates it as necessary either
via a HIDIOCSOUTPUT request, or the regular device write() interface.  The format
of the buffer issued with this report is identical to that of HIDIOCGFEATURE.

Example
-------
+5 −1
Original line number Diff line number Diff line
@@ -537,9 +537,12 @@ static void hidinput_update_battery(struct hid_device *dev, int value)
	capacity = hidinput_scale_battery_capacity(dev, value);

	if (dev->battery_status != HID_BATTERY_REPORTED ||
	    capacity != dev->battery_capacity) {
	    capacity != dev->battery_capacity ||
	    ktime_after(ktime_get_coarse(), dev->battery_ratelimit_time)) {
		dev->battery_capacity = capacity;
		dev->battery_status = HID_BATTERY_REPORTED;
		dev->battery_ratelimit_time =
			ktime_add_ms(ktime_get_coarse(), 30 * 1000);
		power_supply_changed(dev->battery);
	}
}
@@ -746,6 +749,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
				field->flags |= HID_MAIN_ITEM_RELATIVE;
				break;
			}
			goto unknown;

		default: goto unknown;
		}
+23 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
/*
 * This function performs a Get_Report transfer over the control endpoint
 * per section 7.2.1 of the HID specification, version 1.1.  The first byte
 * of buffer is the report number to request, or 0x0 if the defice does not
 * of buffer is the report number to request, or 0x0 if the device does not
 * use numbered reports. The report_type parameter can be HID_FEATURE_REPORT
 * or HID_INPUT_REPORT.
 */
@@ -428,6 +428,28 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
					break;
				}

				if (_IOC_NR(cmd) == _IOC_NR(HIDIOCSINPUT(0))) {
					int len = _IOC_SIZE(cmd);
					ret = hidraw_send_report(file, user_arg, len, HID_INPUT_REPORT);
					break;
				}
				if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGINPUT(0))) {
					int len = _IOC_SIZE(cmd);
					ret = hidraw_get_report(file, user_arg, len, HID_INPUT_REPORT);
					break;
				}

				if (_IOC_NR(cmd) == _IOC_NR(HIDIOCSOUTPUT(0))) {
					int len = _IOC_SIZE(cmd);
					ret = hidraw_send_report(file, user_arg, len, HID_OUTPUT_REPORT);
					break;
				}
				if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGOUTPUT(0))) {
					int len = _IOC_SIZE(cmd);
					ret = hidraw_get_report(file, user_arg, len, HID_OUTPUT_REPORT);
					break;
				}

				/* Begin Read-only ioctls. */
				if (_IOC_DIR(cmd) != _IOC_READ) {
					ret = -EINVAL;
+2 −0
Original line number Diff line number Diff line
@@ -438,6 +438,7 @@ static void hid_irq_out(struct urb *urb)
		break;
	case -ESHUTDOWN:	/* unplug */
		unplug = 1;
		break;
	case -EILSEQ:		/* protocol error or unplug */
	case -EPROTO:		/* protocol error or unplug */
	case -ECONNRESET:	/* unlink */
@@ -489,6 +490,7 @@ static void hid_ctrl(struct urb *urb)
		break;
	case -ESHUTDOWN:	/* unplug */
		unplug = 1;
		break;
	case -EILSEQ:		/* protocol error or unplug */
	case -EPROTO:		/* protocol error or unplug */
	case -ECONNRESET:	/* unlink */
+2 −1
Original line number Diff line number Diff line
@@ -494,7 +494,7 @@ struct hid_report_enum {
};

#define HID_MIN_BUFFER_SIZE	64		/* make sure there is at least a packet size of space */
#define HID_MAX_BUFFER_SIZE	8192		/* 8kb */
#define HID_MAX_BUFFER_SIZE	16384		/* 16kb */
#define HID_CONTROL_FIFO_SIZE	256		/* to init devices with >100 reports */
#define HID_OUTPUT_FIFO_SIZE	64

@@ -585,6 +585,7 @@ struct hid_device { /* device report descriptor */
	__s32 battery_report_id;
	enum hid_battery_status battery_status;
	bool battery_avoid_query;
	ktime_t battery_ratelimit_time;
#endif

	unsigned long status;						/* see STAT flags above */
Loading