1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * HID report descriptors, structures and routines
4  * Copyright 2020 Advanced Micro Devices, Inc.
5  * Authors: Nehal Bakulchandra Shah <Nehal-bakulchandra.shah@amd.com>
6  *	    Sandeep Singh <Sandeep.singh@amd.com>
7  */
8 
9 #ifndef AMD_SFH_HID_DESCRIPTOR_H
10 #define AMD_SFH_HID_DESCRIPTOR_H
11 
12 enum desc_type {
13 	/* Report descriptor name */
14 	descr_size = 1,
15 	input_size,
16 	feature_size,
17 };
18 
19 struct common_feature_property {
20 	/* common properties */
21 	u8 report_id;
22 	u8 connection_type;
23 	u8 report_state;
24 	u8 power_state;
25 	u8 sensor_state;
26 	u32 report_interval;
27 } __packed;
28 
29 struct common_input_property {
30 	/* common properties */
31 	u8 report_id;
32 	u8 sensor_state;
33 	u8 event_type;
34 } __packed;
35 
36 struct accel3_feature_report {
37 	struct common_feature_property common_property;
38 	/* properties specific to this sensor */
39 	u16 accel_change_sesnitivity;
40 	s16 accel_sensitivity_max;
41 	s16 accel_sensitivity_min;
42 } __packed;
43 
44 struct accel3_input_report {
45 	struct	common_input_property common_property;
46 	/* values specific to this sensor */
47 	int in_accel_x_value;
48 	int in_accel_y_value;
49 	int in_accel_z_value;
50 	/* include if required to support the "shake" event */
51 	u8 in_accel_shake_detection;
52 } __packed;
53 
54 struct gyro_feature_report {
55 	struct common_feature_property common_property;
56 	/* properties specific to this sensor */
57 	u16 gyro_change_sesnitivity;
58 	s16 gyro_sensitivity_max;
59 	s16 gyro_sensitivity_min;
60 } __packed;
61 
62 struct gyro_input_report {
63 	struct	common_input_property common_property;
64 	/* values specific to this sensor */
65 	int in_angel_x_value;
66 	int in_angel_y_value;
67 	int in_angel_z_value;
68 } __packed;
69 
70 struct magno_feature_report {
71 	struct common_feature_property common_property;
72 	/*properties specific to this sensor */
73 	u16 magno_headingchange_sensitivity;
74 	s16 heading_min;
75 	s16 heading_max;
76 	u16 flux_change_sensitivity;
77 	s16 flux_min;
78 	s16 flux_max;
79 } __packed;
80 
81 struct magno_input_report {
82 	struct	common_input_property common_property;
83 	int in_magno_x;
84 	int in_magno_y;
85 	int in_magno_z;
86 	int in_magno_accuracy;
87 } __packed;
88 
89 struct als_feature_report {
90 	struct common_feature_property common_property;
91 	/* properties specific to this sensor */
92 	u16 als_change_sesnitivity;
93 	s16 als_sensitivity_max;
94 	s16 als_sensitivity_min;
95 } __packed;
96 
97 struct als_input_report {
98 	struct common_input_property common_property;
99 	/* values specific to this sensor */
100 	int illuminance_value;
101 } __packed;
102 
103 int get_report_descriptor(int sensor_idx, u8 rep_desc[]);
104 u32 get_descr_sz(int sensor_idx, int descriptor_name);
105 u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report);
106 u8 get_input_report(int sensor_idx, int report_id, u8 *input_report, u32 *sensor_virt_addr);
107 #endif
108