1 /* 2 * Copyright (c) 2011,2017-2021 The Linux Foundation. All rights reserved. 3 * 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #include <qdf_types.h> 21 #include "wlan_dfs_ioctl.h" 22 #include <spectral_ioctl.h> 23 24 #ifndef __KERNEL__ 25 #include <math.h> 26 #endif /* __KERNEL__ */ 27 28 #ifndef _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_ 29 #define _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_ 30 31 #ifndef AH_MAX_CHAINS 32 #define AH_MAX_CHAINS 3 33 #endif 34 35 #define MAX_NUM_CHANNELS 255 36 #define SPECTRAL_PHYERR_PARAM_NOVAL 65535 37 38 #ifdef SPECTRAL_USE_EMU_DEFAULTS 39 /* Use defaults from emulation */ 40 #define SPECTRAL_SCAN_ACTIVE_DEFAULT (0x0) 41 #define SPECTRAL_SCAN_ENABLE_DEFAULT (0x0) 42 #define SPECTRAL_SCAN_COUNT_DEFAULT (0x0) 43 #define SPECTRAL_SCAN_PERIOD_DEFAULT (250) 44 #define SPECTRAL_SCAN_PRIORITY_DEFAULT (0x1) 45 #define SPECTRAL_SCAN_FFT_SIZE_DEFAULT (0x7) 46 #define SPECTRAL_SCAN_GC_ENA_DEFAULT (0x1) 47 #define SPECTRAL_SCAN_RESTART_ENA_DEFAULT (0x0) 48 #define SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT (0xa0) 49 #define SPECTRAL_SCAN_INIT_DELAY_DEFAULT (0x50) 50 #define SPECTRAL_SCAN_NB_TONE_THR_DEFAULT (0xc) 51 #define SPECTRAL_SCAN_STR_BIN_THR_DEFAULT (0x7) 52 #define SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT (0x0) 53 #define SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT (0x1) 54 #define SPECTRAL_SCAN_RSSI_THR_DEFAULT (0xf) 55 #define SPECTRAL_SCAN_PWR_FORMAT_DEFAULT (0x1) 56 #define SPECTRAL_SCAN_RPT_MODE_DEFAULT (0x2) 57 #define SPECTRAL_SCAN_BIN_SCALE_DEFAULT (0x1) 58 #define SPECTRAL_SCAN_DBM_ADJ_DEFAULT (0x0) 59 #define SPECTRAL_SCAN_CHN_MASK_DEFAULT (0x1) 60 #else 61 /* 62 * Static default values for spectral state and configuration. 63 * These definitions should be treated as temporary. Ideally, 64 * we should get the defaults from firmware - this will be discussed. 65 * 66 * Use defaults from Spectral Hardware Micro-Architecture 67 * document (v1.0) 68 */ 69 #define SPECTRAL_SCAN_ACTIVE_DEFAULT (0) 70 #define SPECTRAL_SCAN_ENABLE_DEFAULT (0) 71 #define SPECTRAL_SCAN_COUNT_DEFAULT (0) 72 #define SPECTRAL_SCAN_PERIOD_GEN_I_DEFAULT (35) 73 #define SPECTRAL_SCAN_PERIOD_GEN_II_DEFAULT (35) 74 #define SPECTRAL_SCAN_PERIOD_GEN_III_DEFAULT (224) 75 #define SPECTRAL_SCAN_PRIORITY_DEFAULT (1) 76 #define SPECTRAL_SCAN_FFT_SIZE_DEFAULT (7) 77 #define SPECTRAL_SCAN_GC_ENA_DEFAULT (1) 78 #define SPECTRAL_SCAN_RESTART_ENA_DEFAULT (0) 79 #define SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT (-96) 80 #define SPECTRAL_SCAN_INIT_DELAY_DEFAULT (80) 81 #define SPECTRAL_SCAN_NB_TONE_THR_DEFAULT (12) 82 #define SPECTRAL_SCAN_STR_BIN_THR_DEFAULT (8) 83 #define SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT (0) 84 #define SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT (0) 85 #define SPECTRAL_SCAN_RSSI_THR_DEFAULT (0xf0) 86 #define SPECTRAL_SCAN_PWR_FORMAT_DEFAULT (0) 87 #define SPECTRAL_SCAN_RPT_MODE_DEFAULT (2) 88 #define SPECTRAL_SCAN_BIN_SCALE_DEFAULT (1) 89 #define SPECTRAL_SCAN_DBM_ADJ_DEFAULT (1) 90 #define SPECTRAL_SCAN_CHN_MASK_DEFAULT (1) 91 #define SPECTRAL_SCAN_FREQUENCY_DEFAULT (0) 92 #endif /* SPECTRAL_USE_EMU_DEFAULTS */ 93 94 /* The below two definitions apply only to pre-11ac chipsets */ 95 #define SPECTRAL_SCAN_SHORT_REPORT_DEFAULT (1) 96 #define SPECTRAL_SCAN_FFT_PERIOD_DEFAULT (1) 97 98 /* 99 * Definitions to help in scaling of gen3 linear format Spectral bins to values 100 * similar to those from gen2 chipsets. 101 */ 102 103 /* 104 * Max gain for QCA9984. Since this chipset is a prime representative of gen2 105 * chipsets, it is chosen for this value. 106 */ 107 #define SPECTRAL_QCA9984_MAX_GAIN (78) 108 109 /* Temporary section for hard-coded values. These need to come from FW. */ 110 111 /* Max gain for IPQ8074 */ 112 #define SPECTRAL_IPQ8074_DEFAULT_MAX_GAIN_HARDCODE (62) 113 114 /* 115 * Section for values needing tuning per customer platform. These too may need 116 * to come from FW. To be considered as hard-coded for now. 117 */ 118 119 /* 120 * If customers have a different gain line up than QCA reference designs for 121 * IPQ8074 and/or QCA9984, they may have to tune the low level threshold and 122 * the RSSI threshold. 123 */ 124 #define SPECTRAL_SCALING_LOW_LEVEL_OFFSET (7) 125 #define SPECTRAL_SCALING_RSSI_THRESH (5) 126 127 /* 128 * If customers set the AGC backoff differently, they may have to tune the high 129 * level threshold. 130 */ 131 #define SPECTRAL_SCALING_HIGH_LEVEL_OFFSET (5) 132 133 /* End of section for values needing fine tuning. */ 134 /* End of temporary section for hard-coded values */ 135 136 /** 137 * enum spectral_msg_buf_type - Spectral message buffer type 138 * @SPECTRAL_MSG_BUF_NEW: Allocate new buffer 139 * @SPECTRAL_MSG_BUF_SAVED: Reuse last buffer, used for secondary segment report 140 * in case of 160 MHz. 141 */ 142 enum spectral_msg_buf_type { 143 SPECTRAL_MSG_BUF_NEW, 144 SPECTRAL_MSG_BUF_SAVED, 145 SPECTRAL_MSG_BUF_TYPE_MAX, 146 }; 147 148 /** 149 * enum spectral_msg_type - Spectral SAMP message type 150 * @SPECTRAL_MSG_NORMAL_MODE: Normal mode Spectral SAMP message 151 * @SPECTRAL_MSG_AGILE_MODE: Agile mode Spectral SAMP message 152 * @SPECTRAL_MSG_INTERFERENCE_NOTIFICATION: Interference notification to 153 * external auto channel selection 154 * entity 155 * @SPECTRAL_MSG_TYPE_MAX: Spectral SAMP message type max 156 */ 157 enum spectral_msg_type { 158 SPECTRAL_MSG_NORMAL_MODE, 159 SPECTRAL_MSG_AGILE_MODE, 160 SPECTRAL_MSG_INTERFERENCE_NOTIFICATION, 161 SPECTRAL_MSG_TYPE_MAX, 162 }; 163 164 /** 165 * enum spectral_debug - Spectral debug level 166 * @DEBUG_SPECTRAL: Minimal SPECTRAL debug 167 * @DEBUG_SPECTRAL1: Normal SPECTRAL debug 168 * @DEBUG_SPECTRAL2: Maximal SPECTRAL debug 169 * @DEBUG_SPECTRAL3: Matched filterID display 170 * @DEBUG_SPECTRAL4: One time dump of FFT report 171 */ 172 enum spectral_debug { 173 DEBUG_SPECTRAL = 0x00000100, 174 DEBUG_SPECTRAL1 = 0x00000200, 175 DEBUG_SPECTRAL2 = 0x00000400, 176 DEBUG_SPECTRAL3 = 0x00000800, 177 DEBUG_SPECTRAL4 = 0x00001000, 178 }; 179 180 /** 181 * enum spectral_capability_type - Spectral capability type 182 * @SPECTRAL_CAP_PHYDIAG: Phydiag capability 183 * @SPECTRAL_CAP_RADAR: Radar detection capability 184 * @SPECTRAL_CAP_SPECTRAL_SCAN: Spectral capability 185 * @SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN: Advanced spectral capability 186 */ 187 enum spectral_capability_type { 188 SPECTRAL_CAP_PHYDIAG, 189 SPECTRAL_CAP_RADAR, 190 SPECTRAL_CAP_SPECTRAL_SCAN, 191 SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN, 192 }; 193 194 /** 195 * enum spectral_cp_error_code - Spectral control path response code 196 * @SPECTRAL_SCAN_RESP_ERR_INVALID: Invalid error identifier 197 * @SPECTRAL_SCAN_RESP_ERR_PARAM_UNSUPPORTED: parameter unsupported 198 * @SPECTRAL_SCAN_RESP_ERR_MODE_UNSUPPORTED: mode unsupported 199 * @SPECTRAL_SCAN_RESP_ERR_PARAM_INVALID_VALUE: invalid parameter value 200 * @SPECTRAL_SCAN_RESP_ERR_PARAM_NOT_INITIALIZED: parameter uninitialized 201 */ 202 enum spectral_cp_error_code { 203 SPECTRAL_SCAN_ERR_INVALID, 204 SPECTRAL_SCAN_ERR_PARAM_UNSUPPORTED, 205 SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED, 206 SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE, 207 SPECTRAL_SCAN_ERR_PARAM_NOT_INITIALIZED, 208 }; 209 210 /** 211 * enum spectral_dma_debug - Spectral DMA debug 212 * @SPECTRAL_DMA_RING_DEBUG: Spectral DMA ring debug 213 * @SPECTRAL_DMA_BUFFER_DEBUG: Spectral DMA buffer debug 214 */ 215 enum spectral_dma_debug { 216 SPECTRAL_DMA_RING_DEBUG, 217 SPECTRAL_DMA_BUFFER_DEBUG, 218 }; 219 220 struct wiphy; 221 struct wlan_objmgr_pdev; 222 struct wlan_objmgr_vdev; 223 /** 224 * struct spectral_cfg80211_vendor_cmd_handlers - Spectral vendor command 225 * handlers 226 * @wlan_cfg80211_spectral_scan_start: start scan handler 227 * @wlan_cfg80211_spectral_scan_stop: stop scan handler 228 * @wlan_cfg80211_spectral_scan_get_config: get config handler 229 * @wlan_cfg80211_spectral_scan_get_diag_stats: get diag stats handler 230 * @wlan_cfg80211_spectral_scan_get_cap: get capability handler 231 * @wlan_cfg80211_spectral_scan_get_status: get status handler 232 */ 233 struct spectral_cfg80211_vendor_cmd_handlers { 234 int (*wlan_cfg80211_spectral_scan_start)(struct wiphy *wiphy, 235 struct wlan_objmgr_pdev *pdev, 236 struct wlan_objmgr_vdev *vdev, 237 const void *data, 238 int data_len); 239 int (*wlan_cfg80211_spectral_scan_stop)(struct wiphy *wiphy, 240 struct wlan_objmgr_pdev *pdev, 241 struct wlan_objmgr_vdev *vdev, 242 const void *data, 243 int data_len); 244 int (*wlan_cfg80211_spectral_scan_get_config)( 245 struct wiphy *wiphy, 246 struct wlan_objmgr_pdev *pdev, 247 struct wlan_objmgr_vdev *vdev, 248 const void *data, 249 int data_len); 250 int (*wlan_cfg80211_spectral_scan_get_diag_stats)( 251 struct wiphy *wiphy, 252 struct wlan_objmgr_pdev *pdev, 253 struct wlan_objmgr_vdev *vdev, 254 const void *data, 255 int data_len); 256 int (*wlan_cfg80211_spectral_scan_get_cap)( 257 struct wiphy *wiphy, 258 struct wlan_objmgr_pdev *pdev, 259 struct wlan_objmgr_vdev *vdev, 260 const void *data, 261 int data_len); 262 int (*wlan_cfg80211_spectral_scan_get_status)( 263 struct wiphy *wiphy, 264 struct wlan_objmgr_pdev *pdev, 265 struct wlan_objmgr_vdev *vdev, 266 const void *data, 267 int data_len); 268 }; 269 270 /** 271 * struct spectral_cp_param - Spectral control path data structure which 272 * contains parameter and its value 273 * @id: Parameter ID 274 * @value: Single parameter value 275 * @freq: Spectral scan frequency 276 */ 277 struct spectral_cp_param { 278 uint32_t id; 279 union { 280 uint32_t value; 281 struct spectral_config_frequency freq; 282 }; 283 }; 284 285 /** 286 * struct spectral_chan_stats - channel status info 287 * @cycle_count: Cycle count 288 * @channel_load: Channel load 289 * @per: Period 290 * @noisefloor: Noise floor 291 * @comp_usablity: Computed usability 292 * @maxregpower: Maximum allowed regulatory power 293 * @comp_usablity_sec80: Computed usability of secondary 80 Mhz 294 * @maxregpower_sec80: Max regulatory power of secondary 80 Mhz 295 */ 296 struct spectral_chan_stats { 297 int cycle_count; 298 int channel_load; 299 int per; 300 int noisefloor; 301 uint16_t comp_usablity; 302 int8_t maxregpower; 303 uint16_t comp_usablity_sec80; 304 int8_t maxregpower_sec80; 305 }; 306 307 /** 308 * struct spectral_diag_stats - spectral diag stats 309 * @spectral_mismatch: Spectral TLV signature mismatches 310 * @spectral_sec80_sfft_insufflen: Insufficient length when parsing for 311 * Secondary 80 Search FFT report 312 * @spectral_no_sec80_sfft: Secondary 80 Search FFT report 313 * TLV not found 314 * @spectral_vhtseg1id_mismatch: VHT Operation Segment 1 ID 315 * mismatches in Search FFT report 316 * @spectral_vhtseg2id_mismatch: VHT Operation Segment 2 ID 317 * mismatches in Search FFT report 318 * @spectral_invalid_detector_id: Invalid detector id 319 */ 320 struct spectral_diag_stats { 321 uint64_t spectral_mismatch; 322 uint64_t spectral_sec80_sfft_insufflen; 323 uint64_t spectral_no_sec80_sfft; 324 uint64_t spectral_vhtseg1id_mismatch; 325 uint64_t spectral_vhtseg2id_mismatch; 326 uint64_t spectral_invalid_detector_id; 327 }; 328 329 /** 330 * struct spectral_scan_state - State of spectral scan 331 * @is_active: Is spectral scan active 332 * @is_enabled: Is spectral scan enabled 333 */ 334 struct spectral_scan_state { 335 uint8_t is_active; 336 uint8_t is_enabled; 337 }; 338 339 /* Forward declarations */ 340 struct wlan_objmgr_pdev; 341 342 /** 343 * struct spectral_nl_cb - Spectral Netlink callbacks 344 * @get_sbuff: Get the socket buffer to send the data to the application 345 * @send_nl_bcast: Send data to the application using netlink broadcast 346 * @send_nl_unicast: Send data to the application using netlink unicast 347 * @free_sbuff: Free the socket buffer for a particular message type 348 */ 349 struct spectral_nl_cb { 350 void *(*get_sbuff)(struct wlan_objmgr_pdev *pdev, 351 enum spectral_msg_type smsg_type, 352 enum spectral_msg_buf_type buf_type); 353 int (*send_nl_bcast)(struct wlan_objmgr_pdev *pdev, 354 enum spectral_msg_type smsg_type); 355 int (*send_nl_unicast)(struct wlan_objmgr_pdev *pdev, 356 enum spectral_msg_type smsg_type); 357 void (*free_sbuff)(struct wlan_objmgr_pdev *pdev, 358 enum spectral_msg_type smsg_type); 359 }; 360 361 /** 362 * struct spectral_scan_config_request - Config request 363 * @sscan_config: Spectral parameters 364 * @sscan_err_code: Spectral scan error code 365 */ 366 struct spectral_scan_config_request { 367 struct spectral_config sscan_config; 368 enum spectral_cp_error_code sscan_err_code; 369 }; 370 371 /** 372 * struct spectral_scan_action_request - Action request 373 * @sscan_err_code: Spectral scan error code 374 */ 375 struct spectral_scan_action_request { 376 enum spectral_cp_error_code sscan_err_code; 377 }; 378 379 /** 380 * struct spectral_scan_get_caps_request - Get caps request 381 * @sscan_caps: Spectral capabilities 382 * @sscan_err_code: Spectral scan error code 383 */ 384 struct spectral_scan_get_caps_request { 385 struct spectral_caps sscan_caps; 386 enum spectral_cp_error_code sscan_err_code; 387 }; 388 389 /** 390 * struct spectral_scan_get_diag_request - Get diag request 391 * @sscan_diag: Spectral diag stats 392 * @sscan_err_code: Spectral scan error code 393 */ 394 struct spectral_scan_get_diag_request { 395 struct spectral_diag_stats sscan_diag; 396 enum spectral_cp_error_code sscan_err_code; 397 }; 398 399 /** 400 * struct spectral_scan_get_chan_width_request - Get channel width request 401 * @chan_width: Channel width 402 * @sscan_err_code: Spectral scan error code 403 */ 404 struct spectral_scan_get_chan_width_request { 405 uint32_t chan_width; 406 enum spectral_cp_error_code sscan_err_code; 407 }; 408 409 /** 410 * struct spectral_scan_get_status_request - Get status request 411 * @is_active: is Spectral scan active 412 * @is_enabled: is Spectral scan enabled 413 * @sscan_err_code: Spectral scan error code 414 */ 415 struct spectral_scan_get_status_request { 416 bool is_active; 417 bool is_enabled; 418 enum spectral_cp_error_code sscan_err_code; 419 }; 420 421 /** 422 * struct spectral_scan_debug_request - Get/set debug level request 423 * @spectral_dbg_level: Spectral debug level 424 * @sscan_err_code: Spectral scan error code 425 */ 426 struct spectral_scan_debug_request { 427 uint32_t spectral_dbg_level; 428 enum spectral_cp_error_code sscan_err_code; 429 }; 430 431 /** 432 * struct spectral_scan_dma_debug_request - DMA debug request 433 * @dma_debug_enable: Enable/disable @dma_debug_type 434 * @dma_debug_type: Type of Spectral DMA debug i.e., ring or buffer debug 435 * @sscan_err_code: Spectral scan error code 436 */ 437 struct spectral_scan_dma_debug_request { 438 bool dma_debug_enable; 439 enum spectral_dma_debug dma_debug_type; 440 enum spectral_cp_error_code sscan_err_code; 441 }; 442 443 /** 444 * struct spectral_cp_request - Spectral control path request 445 * Creating request and extracting response has to 446 * be atomic. 447 * @ss_mode: Spectral scan mode 448 * @req_id: Request identifier 449 * @vdev_id: VDEV id 450 * @dma_debug_req: Spectral DMA debug request 451 */ 452 struct spectral_cp_request { 453 enum spectral_scan_mode ss_mode; 454 uint8_t req_id; 455 uint8_t vdev_id; 456 union { 457 struct spectral_scan_config_request config_req; 458 struct spectral_scan_action_request action_req; 459 struct spectral_scan_get_caps_request caps_req; 460 struct spectral_scan_get_diag_request diag_req; 461 struct spectral_scan_get_chan_width_request chan_width_req; 462 struct spectral_scan_get_status_request status_req; 463 struct spectral_scan_debug_request debug_req; 464 struct spectral_scan_dma_debug_request dma_debug_req; 465 }; 466 }; 467 468 #ifndef __KERNEL__ 469 470 static inline int16_t 471 spectral_pwfactor_max(int16_t pwfactor1, 472 int16_t pwfactor2) 473 { 474 return ((pwfactor1 > pwfactor2) ? pwfactor1 : pwfactor2); 475 } 476 477 /** 478 * get_spectral_scale_rssi_corr() - Compute RSSI correction factor for scaling 479 * @agc_total_gain_db: AGC total gain in dB steps 480 * @gen3_defmaxgain: Default max gain value of the gen III chipset 481 * @gen2_maxgain: Max gain value used by the reference gen II chipset 482 * @lowlevel_offset: Low level offset for scaling 483 * @inband_pwr: In band power in dB steps 484 * @rssi_thr: RSSI threshold for scaling 485 * 486 * Helper function to compute RSSI correction factor for Gen III linear format 487 * Spectral scaling. It is the responsibility of the caller to ensure that 488 * correct values are passed. 489 * 490 * Return: RSSI correction factor 491 */ 492 static inline int16_t 493 get_spectral_scale_rssi_corr(u_int8_t agc_total_gain_db, 494 u_int8_t gen3_defmaxgain, u_int8_t gen2_maxgain, 495 int16_t lowlevel_offset, int16_t inband_pwr, 496 int16_t rssi_thr) 497 { 498 return ((agc_total_gain_db < gen3_defmaxgain) ? 499 (gen2_maxgain - gen3_defmaxgain + lowlevel_offset) : 500 spectral_pwfactor_max((inband_pwr - rssi_thr), 0)); 501 } 502 503 /** 504 * spectral_scale_linear_to_gen2() - Scale linear bin value to gen II equivalent 505 * @gen3_binmag: Captured FFT bin value from the Spectral Search FFT report 506 * generated by the Gen III chipset 507 * @gen2_maxgain: Max gain value used by the reference gen II chipset 508 * @gen3_defmaxgain: Default max gain value of the gen III chipset 509 * @lowlevel_offset: Low level offset for scaling 510 * @inband_pwr: In band power in dB steps 511 * @rssi_thr: RSSI threshold for scaling 512 * @agc_total_gain_db: AGC total gain in dB steps 513 * @highlevel_offset: High level offset for scaling 514 * @gen2_bin_scale: Bin scale value used on reference gen II chipset 515 * @gen3_bin_scale: Bin scale value used on gen III chipset 516 * 517 * Helper function to scale a given gen III linear format bin value into an 518 * approximately equivalent gen II value. The scaled value can possibly be 519 * higher than 8 bits. If the caller is incapable of handling values larger 520 * than 8 bits, the caller can saturate the value at 255. This function does not 521 * carry out this saturation for the sake of flexibility so that callers 522 * interested in the larger values can avail of this. Also note it is the 523 * responsibility of the caller to ensure that correct values are passed. 524 * 525 * Return: Scaled bin value 526 */ 527 static inline u_int32_t 528 spectral_scale_linear_to_gen2(u_int8_t gen3_binmag, 529 u_int8_t gen2_maxgain, u_int8_t gen3_defmaxgain, 530 int16_t lowlevel_offset, int16_t inband_pwr, 531 int16_t rssi_thr, u_int8_t agc_total_gain_db, 532 int16_t highlevel_offset, u_int8_t gen2_bin_scale, 533 u_int8_t gen3_bin_scale) 534 { 535 return (gen3_binmag * 536 sqrt(pow(10, (((double)spectral_pwfactor_max(gen2_maxgain - 537 gen3_defmaxgain + lowlevel_offset - 538 get_spectral_scale_rssi_corr(agc_total_gain_db, 539 gen3_defmaxgain, 540 gen2_maxgain, 541 lowlevel_offset, 542 inband_pwr, 543 rssi_thr), 544 (agc_total_gain_db < gen3_defmaxgain) * 545 highlevel_offset)) / 10))) * 546 pow(2, (gen3_bin_scale - gen2_bin_scale))); 547 } 548 549 #endif /* __KERNEL__ */ 550 551 #endif /* _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_ */ 552