Debian Codegraph @

src/include/sar.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _SAR_H_
3 #define _SAR_H_
4
5 #include <fw_config.h>
6 #include <stdint.h>
7
8 #define MAX_ANT_GAINS_REVISION 2
9 #define MAX_DENYLIST_ENTRY 16
10 #define MAX_DSAR_SET_COUNT 3
11 #define MAX_GEO_OFFSET_REVISION 3
12 #define MAX_PROFILE_COUNT 16
13 #define MAX_SAR_REVISION 2
14 #define MAX_BSAR_REVISION 2
15 #define WBEM_REVISION 0
16 #define BPAG_REVISION 2
17 #define BBFB_REVISION 1
18 #define BDCM_REVISION 1
19 #define BBSM_REVISION 1
20 #define BUCS_REVISION 1
21 #define BDMM_REVISION 1
22 #define EBRD_REVISION 1
23 #define WPFC_REVISION 0
24 #define DSBR_REVISION 1
25 #define REVISION_SIZE 1
26 #define SAR_REV0_CHAINS_COUNT 2
27 #define SAR_REV0_SUBBANDS_COUNT 5
28 #define SAR_FILE_REVISION 1
29 #define SAR_STR_PREFIX "$SAR"
30 #define SAR_STR_PREFIX_SIZE 4
31
32 struct geo_profile {
33 uint8_t revision;
34 uint8_t chains_count;
35 uint8_t bands_count;
36 uint8_t wgds_table[];
37 } __packed;
38
39 struct sar_profile {
40 uint8_t revision;
41 uint8_t dsar_set_count;
42 uint8_t chains_count;
43 uint8_t subbands_count;
44 uint8_t sar_table[];
45 } __packed;
46
47 struct gain_profile {
48 uint8_t revision;
49 uint8_t mode;
50 uint8_t chains_count;
51 uint8_t bands_count;
52 uint8_t ppag_table[];
53 } __packed;
54
55 struct avg_profile {
56 uint8_t revision;
57 uint8_t tas_selection;
58 uint8_t tas_list_size;
59 uint16_t deny_list_entry[MAX_DENYLIST_ENTRY];
60 } __packed;
61
62 struct dsm_profile {
63 uint32_t supported_functions;
64 uint32_t disable_active_sdr_channels;
65 uint32_t support_indonesia_5g_band;
66 uint32_t support_ultra_high_band;
67 uint32_t regulatory_configurations;
68 uint32_t uart_configurations;
69 uint32_t enablement_11ax;
70 uint32_t unii_4;
71 uint32_t enablement_11be;
72 uint32_t energy_detection_threshold;
73 uint32_t rfi_mitigation;
74 };
75
76 struct sar_power_table {
77 uint8_t restriction_for_2g4;
78 uint8_t restriction_for_5g2;
79 uint8_t restriction_for_5g8_5g9;
80 uint8_t restriction_for_6g1;
81 uint8_t restriction_for_6g3;
82 } __packed;
83
84 struct bsar_profile {
85 uint8_t revision;
86 uint8_t increased_power_mode_limitation;
87 union {
88 struct rev1 {
89 uint8_t sar_lb_power_restriction;
90 uint8_t br_modulation;
91 uint8_t edr2_modulation;
92 uint8_t edr3_modulation;
93 uint8_t le_modulation;
94 uint8_t le2_mhz_modulation;
95 uint8_t le_lr_modulation;
96 } rev1;
97 struct rev2 {
98 struct sar_power_table set_1_chain_a;
99 struct sar_power_table set_1_chain_b;
100 } rev2;
101 } revs;
102 } __packed;
103
104 struct wbem_profile {
105 uint8_t revision;
106 uint32_t bandwidth_320mhz_country_enablement;
107 } __packed;
108
109 struct bpag_profile {
110 uint8_t revision;
111 uint32_t antenna_gain_country_enablement;
112 } __packed;
113
114 struct bbfb_profile {
115 uint8_t revision;
116 uint8_t enable_quad_filter_bypass;
117 } __packed;
118
119 struct bdcm_profile {
120 uint8_t revision;
121 uint32_t dual_chain_mode;
122 } __packed;
123
124 struct bbsm_profile {
125 uint8_t revision;
126 uint32_t bands_selection;
127 } __packed;
128
129 struct bucs_profile {
130 uint8_t revision;
131 uint32_t uhb_country_selection;
132 } __packed;
133
134 struct bdmm_profile {
135 uint8_t revision;
136 uint8_t dual_mac_enable;
137 } __packed;
138
139 struct ebrd_profile {
140 uint8_t revision;
141 uint32_t dynamic_sar_enable;
142 uint32_t number_of_optional_sar;
143 struct {
144 struct sar_power_table chain_a;
145 struct sar_power_table chain_b;
146 } sar_table_sets[3];
147 } __packed;
148
149 struct wpfc_profile {
150 uint8_t revision;
151 uint8_t filter_cfg_chain_a;
152 uint8_t filter_cfg_chain_b;
153 uint8_t filter_cfg_chain_c;
154 uint8_t filter_cfg_chain_d;
155 } __packed;
156
157 struct dsbr_profile {
158 uint8_t revision;
159 uint32_t bri_resistor_value;
160 } __packed;
161
162 struct sar_header {
163 char marker[SAR_STR_PREFIX_SIZE];
164 uint8_t version;
165 uint16_t offsets[];
166 } __packed;
167
168 /* Wifi SAR limit table structure */
169 union wifi_sar_limits {
170 struct {
171 struct sar_profile *sar;
172 struct geo_profile *wgds;
173 struct gain_profile *ppag;
174 struct avg_profile *wtas;
175 struct dsm_profile *dsm;
176 struct bsar_profile *bsar;
177 struct wbem_profile *wbem;
178 struct bpag_profile *bpag;
179 struct bbfb_profile *bbfb;
180 struct bdcm_profile *bdcm;
181 struct bbsm_profile *bbsm;
182 struct bucs_profile *bucs;
183 struct bdmm_profile *bdmm;
184 struct ebrd_profile *ebrd;
185 struct wpfc_profile *wpfc;
186 struct dsbr_profile *dsbr;
187 };
188 void *profile[MAX_PROFILE_COUNT];
189 };
190
191 /*
192 * Retrieve the wifi ACPI configuration data from CBFS and decode it
193 * sar_limits: Pointer to wifi_sar_limits where the resulted data is stored
194 *
195 * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed)
196 */
197 int get_wifi_sar_limits(union wifi_sar_limits *sar_limits);
198
199 #define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex"
200
201 const char *get_wifi_sar_cbfs_filename(void);
202
203 char *get_wifi_sar_fw_config_filename(const struct fw_config_field *field);
204
205 #endif /* _SAR_H_ */