Commit e149af9c authored by Even Xu's avatar Even Xu Committed by Jiri Kosina
Browse files

HID: Intel-thc-hid: Intel-quicki2c: Support writing output report format



There are two output formats requested in the HID-over-I2C specification:
- Command format (set feature/set report): encoded command written to
  command register, followed by data written to data register
- Output report format: all data written directly to output register

Current quicki2c_init_write_buf() implementation only supports the
command format.

Extend quicki2c_init_write_buf() to automatically detect the output
format based on the presence of command parameters and prepare the
appropriate output buffer accordingly.

Tested-by: default avatarRui Zhang <rui1.zhang@intel.com>
Signed-off-by: default avatarEven Xu <even.xu@intel.com>
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 678cbaa2
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ static ssize_t quicki2c_init_write_buf(struct quicki2c_device *qcdev, u32 cmd, s
	if (buf_len > write_buf_len)
		return -EINVAL;

	if (cmd_len) {
		memcpy(write_buf, &qcdev->dev_desc.cmd_reg, HIDI2C_REG_LEN);
		offset += HIDI2C_REG_LEN;
		memcpy(write_buf + offset, &cmd, cmd_len);
@@ -39,6 +40,10 @@ static ssize_t quicki2c_init_write_buf(struct quicki2c_device *qcdev, u32 cmd, s
			memcpy(write_buf + offset, &qcdev->dev_desc.data_reg, HIDI2C_REG_LEN);
			offset += HIDI2C_REG_LEN;
		}
	} else {
		memcpy(write_buf, &qcdev->dev_desc.output_reg, HIDI2C_REG_LEN);
		offset += HIDI2C_REG_LEN;
	}

	if (data && data_len) {
		put_unaligned_le16(data_len + HIDI2C_LENGTH_LEN, write_buf + offset);