File Index
Files and directories
Sign in
FILE

hid-over-i2c.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/hid-over-i2c.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Copyright 2024 Intel Corporation */
  3
  4#include <linux/bits.h>
  5
  6#ifndef _HID_OVER_I2C_H_
  7#define _HID_OVER_I2C_H_
  8
  9#define HIDI2C_REG_LEN		sizeof(__le16)
 10
 11/* Input report type definition in HIDI2C protocol */
 12enum hidi2c_report_type {
 13	HIDI2C_RESERVED = 0,
 14	HIDI2C_INPUT,
 15	HIDI2C_OUTPUT,
 16	HIDI2C_FEATURE,
 17};
 18
 19/* Power state type definition in HIDI2C protocol */
 20enum hidi2c_power_state {
 21	HIDI2C_ON,
 22	HIDI2C_SLEEP,
 23};
 24
 25/* Opcode type definition in HIDI2C protocol */
 26enum hidi2c_opcode {
 27	HIDI2C_RESET = 1,
 28	HIDI2C_GET_REPORT,
 29	HIDI2C_SET_REPORT,
 30	HIDI2C_GET_IDLE,
 31	HIDI2C_SET_IDLE,
 32	HIDI2C_GET_PROTOCOL,
 33	HIDI2C_SET_PROTOCOL,
 34	HIDI2C_SET_POWER,
 35};
 36
 37/**
 38 * struct hidi2c_report_packet - Report packet definition in HIDI2C protocol
 39 * @len: data field length
 40 * @data: HIDI2C report packet data
 41 */
 42struct hidi2c_report_packet {
 43	__le16 len;
 44	u8 data[];
 45} __packed;
 46
 47#define HIDI2C_LENGTH_LEN	sizeof(__le16)
 48
 49#define HIDI2C_PACKET_LEN(data_len)	((data_len) + HIDI2C_LENGTH_LEN)
 50#define HIDI2C_DATA_LEN(pkt_len)	((pkt_len) - HIDI2C_LENGTH_LEN)
 51
 52#define HIDI2C_CMD_MAX_RI	0x0F
 53
 54/**
 55 * HIDI2C command data packet - Command packet definition in HIDI2C protocol
 56 * @report_id:		[0:3] report id (<15) for features or output reports
 57 * @report_type:	[4:5] indicate report type, reference to hidi2c_report_type
 58 * @reserved0:		[6:7] reserved bits
 59 * @opcode:		[8:11] command operation code, reference to hidi2c_opcode
 60 * @reserved1:		[12:15] reserved bits
 61 * @report_id_optional: [23:16] appended 3rd byte.
 62 *                      If the report_id in the low byte is set to the
 63 *                      sentinel value (HIDI2C_CMD_MAX_RI), then this
 64 *                      optional third byte represents the report id (>=15)
 65 *                      Otherwise, not this 3rd byte.
 66 */
 67
 68#define HIDI2C_CMD_LEN			sizeof(__le16)
 69#define HIDI2C_CMD_LEN_OPT		(sizeof(__le16) + 1)
 70#define HIDI2C_CMD_REPORT_ID		GENMASK(3, 0)
 71#define HIDI2C_CMD_REPORT_TYPE		GENMASK(5, 4)
 72#define HIDI2C_CMD_OPCODE		GENMASK(11, 8)
 73#define HIDI2C_CMD_OPCODE		GENMASK(11, 8)
 74#define HIDI2C_CMD_3RD_BYTE		GENMASK(23, 16)
 75
 76#define HIDI2C_HID_DESC_BCDVERSION	0x100
 77
 78/**
 79 * struct hidi2c_dev_descriptor - HIDI2C device descriptor definition
 80 * @dev_desc_len: The length of the complete device descriptor, fixed to 0x1E (30).
 81 * @bcd_ver: The version number of the HIDI2C protocol supported.
 82 *           In binary coded decimal (BCD) format.
 83 * @report_desc_len: The length of the report descriptor
 84 * @report_desc_reg: The register address to retrieve report descriptor
 85 * @input_reg: the register address to retrieve input report
 86 * @max_input_len: The length of the largest possible HID input (or feature) report
 87 * @output_reg: the register address to send output report
 88 * @max_output_len: The length of the largest output (or feature) report
 89 * @cmd_reg: the register address to send command
 90 * @data_reg: the register address to send command data
 91 * @vendor_id: Device manufacturers vendor ID
 92 * @product_id: Device unique model/product ID
 93 * @version_id: Device’s unique version
 94 * @reserved0: Reserved and should be 0
 95 * @reserved1: Reserved and should be 0
 96 */
 97struct hidi2c_dev_descriptor {
 98	__le16 dev_desc_len;
 99	__le16 bcd_ver;
100	__le16 report_desc_len;
101	__le16 report_desc_reg;
102	__le16 input_reg;
103	__le16 max_input_len;
104	__le16 output_reg;
105	__le16 max_output_len;
106	__le16 cmd_reg;
107	__le16 data_reg;
108	__le16 vendor_id;
109	__le16 product_id;
110	__le16 version_id;
111	__le16 reserved0;
112	__le16 reserved1;
113} __packed;
114
115#define HIDI2C_DEV_DESC_LEN		sizeof(struct hidi2c_dev_descriptor)
116
117#endif /* _HID_OVER_I2C_H_ */
~/ Read-only file preview.