blob: e8a1b287b5bd3fcb4ea74dfeea556b17094059b8 [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Robbie Zhanged840022016-12-23 11:43:07 -08002#ifndef _SAR_H_
3#define _SAR_H_
4
5#include <stdint.h>
6
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +05307#define MAX_ANT_GAINS_REVISION 2
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +05308#define MAX_DSAR_SET_COUNT 3
9#define MAX_GEO_OFFSET_REVISION 3
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053010#define MAX_PROFILE_COUNT 3
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053011#define MAX_SAR_REVISION 2
12#define REVISION_SIZE 1
13#define SAR_REV0_CHAINS_COUNT 2
14#define SAR_REV0_SUBBANDS_COUNT 5
15#define SAR_FILE_REVISION 1
16#define SAR_STR_PREFIX "$SAR"
17#define SAR_STR_PREFIX_SIZE 4
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070018
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053019struct geo_profile {
20 uint8_t revision;
21 uint8_t chains_count;
22 uint8_t bands_count;
23 uint8_t wgds_table[0];
24} __packed;
25
26struct sar_profile {
27 uint8_t revision;
28 uint8_t dsar_set_count;
29 uint8_t chains_count;
30 uint8_t subbands_count;
31 uint8_t sar_table[0];
32} __packed;
33
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053034struct gain_profile {
35 uint8_t revision;
36 uint8_t mode;
37 uint8_t chains_count;
38 uint8_t bands_count;
39 uint8_t ppag_table[0];
40} __packed;
41
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053042struct sar_header {
43 char marker[SAR_STR_PREFIX_SIZE];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070044 uint8_t version;
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053045 uint16_t offsets[0];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070046} __packed;
Robbie Zhanged840022016-12-23 11:43:07 -080047
48/* Wifi SAR limit table structure */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053049union wifi_sar_limits {
50 struct {
51 struct sar_profile *sar;
52 struct geo_profile *wgds;
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053053 struct gain_profile *ppag;
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053054 };
55 void *profile[MAX_PROFILE_COUNT];
56};
Robbie Zhanged840022016-12-23 11:43:07 -080057
58/*
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053059 * Retrieve the wifi ACPI configuration data from CBFS and decode it
Robbie Zhanged840022016-12-23 11:43:07 -080060 * sar_limits: Pointer to wifi_sar_limits where the resulted data is stored
61 *
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053062 * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed)
Robbie Zhanged840022016-12-23 11:43:07 -080063 */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053064int get_wifi_sar_limits(union wifi_sar_limits *sar_limits);
Robbie Zhanged840022016-12-23 11:43:07 -080065
Furquan Shaikh7fe5d3d2021-03-13 22:54:16 -080066#define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex"
67
Justin TerAvestc650d6c2018-12-14 11:05:03 -070068const char *get_wifi_sar_cbfs_filename(void);
69
Robbie Zhanged840022016-12-23 11:43:07 -080070#endif /* _SAR_H_ */