qcacmn: Add definitions for Spectral linear bin scaling
Add definitions for Spectral linear bin scaling, including conversion functions, RF parameter definitions, and hardware generation specifiers. CRs-Fixed: 2294176 Change-Id: I6e1eb2ce3ec19d8734facb88c6329fe0026ecce0
Esse commit está contido em:
@@ -85,13 +85,26 @@ struct spectral_ioctl_params {
|
||||
uint16_t spectral_pri;
|
||||
};
|
||||
|
||||
/**
|
||||
* spectral_cap_hw_gen: Definitions for the Spectral hardware generation.
|
||||
* This corresponds to definitions in qca_wlan_vendor_spectral_scan_cap_hw_gen.
|
||||
* @SPECTRAL_CAP_HW_GEN_1: Generation 1
|
||||
* @SPECTRAL_CAP_HW_GEN_2: Generation 2
|
||||
* @SPECTRAL_CAP_HW_GEN_3: Generation 3
|
||||
*/
|
||||
enum spectral_cap_hw_gen {
|
||||
SPECTRAL_CAP_HW_GEN_1 = 0,
|
||||
SPECTRAL_CAP_HW_GEN_2 = 1,
|
||||
SPECTRAL_CAP_HW_GEN_3 = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct spectral_caps - Spectral capabilities structure
|
||||
* @phydiag_cap: Phydiag capability
|
||||
* @radar_cap: Radar detection capability
|
||||
* @spectral_cap: Spectral capability
|
||||
* @advncd_spectral_cap: Advanced spectral capability
|
||||
* @hw_gen: Spectral hw generation
|
||||
* @hw_gen: Spectral hw generation as defined in spectral_cap_hw_gen
|
||||
*/
|
||||
struct spectral_caps {
|
||||
uint8_t phydiag_cap;
|
||||
|
@@ -21,6 +21,10 @@
|
||||
#include "wlan_dfs_ioctl.h"
|
||||
#include <spectral_ioctl.h>
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <math.h>
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#ifndef _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_
|
||||
#define _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_
|
||||
|
||||
@@ -103,6 +107,44 @@
|
||||
#define SPECTRAL_SCAN_SHORT_REPORT_DEFAULT (1)
|
||||
#define SPECTRAL_SCAN_FFT_PERIOD_DEFAULT (1)
|
||||
|
||||
/*
|
||||
* Definitions to help in scaling of gen3 linear format Spectral bins to values
|
||||
* similar to those from gen2 chipsets.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Max gain for QCA9984. Since this chipset is a prime representative of gen2
|
||||
* chipsets, it is chosen for this value.
|
||||
*/
|
||||
#define SPECTRAL_QCA9984_MAX_GAIN (78)
|
||||
|
||||
/* Temporary section for hard-coded values. These need to come from FW. */
|
||||
|
||||
/* Max gain for IPQ8074 */
|
||||
#define SPECTRAL_IPQ8074_DEFAULT_MAX_GAIN_HARDCODE (62)
|
||||
|
||||
/*
|
||||
* Section for values needing tuning per customer platform. These too may need
|
||||
* to come from FW. To be considered as hard-coded for now.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If customers have a different gain line up than QCA reference designs for
|
||||
* IPQ8074 and/or QCA9984, they may have to tune the low level threshold and
|
||||
* the RSSI threshold.
|
||||
*/
|
||||
#define SPECTRAL_SCALING_LOW_LEVEL_OFFSET (7)
|
||||
#define SPECTRAL_SCALING_RSSI_THRESH (5)
|
||||
|
||||
/*
|
||||
* If customers set the AGC backoff differently, they may have to tune the high
|
||||
* level threshold.
|
||||
*/
|
||||
#define SPECTRAL_SCALING_HIGH_LEVEL_OFFSET (5)
|
||||
|
||||
/* End of section for values needing fine tuning. */
|
||||
/* End of temporary section for hard-coded values */
|
||||
|
||||
/**
|
||||
* enum wlan_cfg80211_spectral_vendorcmd_handler_idx - Indices to cfg80211
|
||||
* spectral vendor command handlers
|
||||
@@ -484,6 +526,90 @@ struct spectral_nl_cb {
|
||||
int (*send_nl_bcast)(struct wlan_objmgr_pdev *pdev);
|
||||
int (*send_nl_unicast)(struct wlan_objmgr_pdev *pdev);
|
||||
};
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
static inline int16_t
|
||||
spectral_pwfactor_max(int16_t pwfactor1,
|
||||
int16_t pwfactor2)
|
||||
{
|
||||
return ((pwfactor1 > pwfactor2) ? pwfactor1 : pwfactor2);
|
||||
}
|
||||
|
||||
/**
|
||||
* get_spectral_scale_rssi_corr() - Compute RSSI correction factor for scaling
|
||||
* @agc_total_gain_db: AGC total gain in dB steps
|
||||
* @gen3_defmaxgain: Default max gain value of the gen III chipset
|
||||
* @gen2_maxgain: Max gain value used by the reference gen II chipset
|
||||
* @lowlevel_offset: Low level offset for scaling
|
||||
* @inband_pwr: In band power in dB steps
|
||||
* @rssi_thr: RSSI threshold for scaling
|
||||
*
|
||||
* Helper function to compute RSSI correction factor for Gen III linear format
|
||||
* Spectral scaling. It is the responsibility of the caller to ensure that
|
||||
* correct values are passed.
|
||||
*
|
||||
* Return: RSSI correction factor
|
||||
*/
|
||||
static inline int16_t
|
||||
get_spectral_scale_rssi_corr(u_int8_t agc_total_gain_db,
|
||||
u_int8_t gen3_defmaxgain, u_int8_t gen2_maxgain,
|
||||
int16_t lowlevel_offset, int16_t inband_pwr,
|
||||
int16_t rssi_thr)
|
||||
{
|
||||
return ((agc_total_gain_db < gen3_defmaxgain) ?
|
||||
(gen2_maxgain - gen3_defmaxgain + lowlevel_offset) :
|
||||
spectral_pwfactor_max((inband_pwr - rssi_thr), 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* spectral_scale_linear_to_gen2() - Scale linear bin value to gen II equivalent
|
||||
* @gen3_binmag: Captured FFT bin value from the Spectral Search FFT report
|
||||
* generated by the Gen III chipset
|
||||
* @gen2_maxgain: Max gain value used by the reference gen II chipset
|
||||
* @gen3_defmaxgain: Default max gain value of the gen III chipset
|
||||
* @lowlevel_offset: Low level offset for scaling
|
||||
* @inband_pwr: In band power in dB steps
|
||||
* @rssi_thr: RSSI threshold for scaling
|
||||
* @agc_total_gain_db: AGC total gain in dB steps
|
||||
* @highlevel_offset: High level offset for scaling
|
||||
* @gen2_bin_scale: Bin scale value used on reference gen II chipset
|
||||
* @gen3_bin_scale: Bin scale value used on gen III chipset
|
||||
*
|
||||
* Helper function to scale a given gen III linear format bin value into an
|
||||
* approximately equivalent gen II value. The scaled value can possibly be
|
||||
* higher than 8 bits. If the caller is incapable of handling values larger
|
||||
* than 8 bits, the caller can saturate the value at 255. This function does not
|
||||
* carry out this saturation for the sake of flexibility so that callers
|
||||
* interested in the larger values can avail of this. Also note it is the
|
||||
* responsibility of the caller to ensure that correct values are passed.
|
||||
*
|
||||
* Return: Scaled bin value
|
||||
*/
|
||||
static inline u_int32_t
|
||||
spectral_scale_linear_to_gen2(u_int8_t gen3_binmag,
|
||||
u_int8_t gen2_maxgain, u_int8_t gen3_defmaxgain,
|
||||
int16_t lowlevel_offset, int16_t inband_pwr,
|
||||
int16_t rssi_thr, u_int8_t agc_total_gain_db,
|
||||
int16_t highlevel_offset, u_int8_t gen2_bin_scale,
|
||||
u_int8_t gen3_bin_scale)
|
||||
{
|
||||
return (gen3_binmag *
|
||||
sqrt(pow(10, (((double)spectral_pwfactor_max(gen2_maxgain -
|
||||
gen3_defmaxgain + lowlevel_offset -
|
||||
get_spectral_scale_rssi_corr(agc_total_gain_db,
|
||||
gen3_defmaxgain,
|
||||
gen2_maxgain,
|
||||
lowlevel_offset,
|
||||
inband_pwr,
|
||||
rssi_thr),
|
||||
(agc_total_gain_db < gen3_defmaxgain) *
|
||||
highlevel_offset)) / 10))) *
|
||||
pow(2, (gen3_bin_scale - gen2_bin_scale)));
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma pack(pop, spectral)
|
||||
#endif
|
||||
|
Referência em uma nova issue
Block a user