123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
#ifndef _HID_OVER_SPI_H_
#define _HID_OVER_SPI_H_
#include <linux/bits.h>
#include <linux/types.h>
enum input_report_type {
INVALID_INPUT_REPORT_TYPE_0 = 0,
DATA = 1,
INVALID_TYPE_2 = 2,
RESET_RESPONSE = 3,
COMMAND_RESPONSE = 4,
GET_FEATURE_RESPONSE = 5,
INVALID_TYPE_6 = 6,
DEVICE_DESCRIPTOR_RESPONSE = 7,
REPORT_DESCRIPTOR_RESPONSE = 8,
SET_FEATURE_RESPONSE = 9,
OUTPUT_REPORT_RESPONSE = 10,
GET_INPUT_REPORT_RESPONSE = 11,
INVALID_INPUT_REPORT_TYPE = 0xF,
};
enum output_report_type {
INVALID_OUTPUT_REPORT_TYPE_0 = 0,
DEVICE_DESCRIPTOR = 1,
REPORT_DESCRIPTOR = 2,
SET_FEATURE = 3,
GET_FEATURE = 4,
OUTPUT_REPORT = 5,
GET_INPUT_REPORT = 6,
COMMAND_CONTENT = 7,
};
#define HIDSPI_SET_POWER_CMD_ID 1
enum hidspi_power_state {
HIDSPI_ON = 1,
HIDSPI_SLEEP = 2,
HIDSPI_OFF = 3,
};
#define HIDSPI_INPUT_HEADER_SIZE sizeof(u32)
#define HIDSPI_INPUT_HEADER_VER GENMASK(3, 0)
#define HIDSPI_INPUT_HEADER_REPORT_LEN GENMASK(21, 8)
#define HIDSPI_INPUT_HEADER_LAST_FLAG BIT(22)
#define HIDSPI_INPUT_HEADER_SYNC GENMASK(31, 24)
struct input_report_body_header {
u8 input_report_type;
__le16 content_len;
u8 content_id;
} __packed;
#define HIDSPI_INPUT_BODY_HEADER_SIZE sizeof(struct input_report_body_header)
struct input_report_body {
struct input_report_body_header body_hdr;
u8 content[];
} __packed;
#define HIDSPI_INPUT_BODY_SIZE(content_len) ((content_len) + HIDSPI_INPUT_BODY_HEADER_SIZE)
struct output_report_header {
u8 report_type;
__le16 content_len;
u8 content_id;
} __packed;
#define HIDSPI_OUTPUT_REPORT_HEADER_SIZE sizeof(struct output_report_header)
struct output_report {
struct output_report_header output_hdr;
u8 content[];
} __packed;
#define HIDSPI_OUTPUT_REPORT_SIZE(content_len) ((content_len) + HIDSPI_OUTPUT_REPORT_HEADER_SIZE)
struct hidspi_dev_descriptor {
__le16 dev_desc_len;
__le16 bcd_ver;
__le16 rep_desc_len;
__le16 max_input_len;
__le16 max_output_len;
__le16 max_frag_len;
__le16 vendor_id;
__le16 product_id;
__le16 version_id;
__le16 flags;
__le32 reserved;
};
#define HIDSPI_DEVICE_DESCRIPTOR_SIZE sizeof(struct hidspi_dev_descriptor)
#define HIDSPI_INPUT_DEVICE_DESCRIPTOR_SIZE \
(HIDSPI_INPUT_BODY_HEADER_SIZE + HIDSPI_DEVICE_DESCRIPTOR_SIZE)
#endif /* _HID_OVER_SPI_H_ */