xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8822bs/include/rtw_odm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2013 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __RTW_ODM_H__
16 #define __RTW_ODM_H__
17 
18 #include <drv_types.h>
19 #include "../hal/phydm/phydm_types.h"
20 /*
21 * This file provides utilities/wrappers for rtw driver to use ODM
22 */
23 typedef enum _HAL_PHYDM_OPS {
24 	HAL_PHYDM_DIS_ALL_FUNC,
25 	HAL_PHYDM_FUNC_SET,
26 	HAL_PHYDM_FUNC_CLR,
27 	HAL_PHYDM_ABILITY_BK,
28 	HAL_PHYDM_ABILITY_RESTORE,
29 	HAL_PHYDM_ABILITY_SET,
30 	HAL_PHYDM_ABILITY_GET,
31 } HAL_PHYDM_OPS;
32 
33 
34 #define DYNAMIC_FUNC_DISABLE		(0x0)
35 	u32 rtw_phydm_ability_ops(_adapter *adapter, HAL_PHYDM_OPS ops, u32 ability);
36 
37 #define rtw_phydm_func_disable_all(adapter)	\
38 		rtw_phydm_ability_ops(adapter, HAL_PHYDM_DIS_ALL_FUNC, 0)
39 
40 #ifdef CONFIG_RTW_ACS
41 #define rtw_phydm_func_for_offchannel(adapter) \
42 		do { \
43 			rtw_phydm_ability_ops(adapter, HAL_PHYDM_DIS_ALL_FUNC, 0); \
44 			if (rtw_odm_adaptivity_needed(adapter)) \
45 				rtw_phydm_ability_ops(adapter, HAL_PHYDM_FUNC_SET, ODM_BB_ADAPTIVITY); \
46 			if (IS_ACS_ENABLE(adapter))\
47 				rtw_phydm_ability_ops(adapter, HAL_PHYDM_FUNC_SET, ODM_BB_ENV_MONITOR); \
48 		} while (0)
49 #else
50 #define rtw_phydm_func_for_offchannel(adapter) \
51 		do { \
52 			rtw_phydm_ability_ops(adapter, HAL_PHYDM_DIS_ALL_FUNC, 0); \
53 			if (rtw_odm_adaptivity_needed(adapter)) \
54 				rtw_phydm_ability_ops(adapter, HAL_PHYDM_FUNC_SET, ODM_BB_ADAPTIVITY); \
55 		} while (0)
56 #endif
57 
58 #define rtw_phydm_func_clr(adapter, ability)	\
59 		rtw_phydm_ability_ops(adapter, HAL_PHYDM_FUNC_CLR, ability)
60 
61 #define rtw_phydm_ability_backup(adapter)	\
62 		rtw_phydm_ability_ops(adapter, HAL_PHYDM_ABILITY_BK, 0)
63 
64 #define rtw_phydm_ability_restore(adapter)	\
65 		rtw_phydm_ability_ops(adapter, HAL_PHYDM_ABILITY_RESTORE, 0)
66 
67 
rtw_phydm_ability_get(_adapter * adapter)68 static inline u32 rtw_phydm_ability_get(_adapter *adapter)
69 {
70 	return rtw_phydm_ability_ops(adapter, HAL_PHYDM_ABILITY_GET, 0);
71 }
72 
73 
74 void rtw_odm_init_ic_type(_adapter *adapter);
75 
76 void rtw_odm_adaptivity_config_msg(void *sel, _adapter *adapter);
77 
78 bool rtw_odm_adaptivity_needed(_adapter *adapter);
79 void rtw_odm_adaptivity_parm_msg(void *sel, _adapter *adapter);
80 void rtw_odm_adaptivity_parm_set(_adapter *adapter, s8 th_l2h_ini, s8 th_edcca_hl_diff);
81 void rtw_odm_get_perpkt_rssi(void *sel, _adapter *adapter);
82 void rtw_odm_acquirespinlock(_adapter *adapter,	enum rt_spinlock_type type);
83 void rtw_odm_releasespinlock(_adapter *adapter,	enum rt_spinlock_type type);
84 
85 #ifdef CONFIG_DFS_MASTER
86 void rtw_odm_radar_detect_reset(_adapter *adapter);
87 void rtw_odm_radar_detect_disable(_adapter *adapter);
88 void rtw_odm_radar_detect_enable(_adapter *adapter);
89 BOOLEAN rtw_odm_radar_detect(_adapter *adapter);
90 u8 rtw_odm_radar_detect_polling_int_ms(struct dvobj_priv *dvobj);
91 #endif /* CONFIG_DFS_MASTER */
92 
93 void rtw_odm_parse_rx_phy_status_chinfo(union recv_frame *rframe, u8 *phys);
94 
95 #if defined(CONFIG_RTL8822C) && defined(CONFIG_LPS_PG)
96 void odm_lps_pg_debug_8822c(void *dm_void);
97 #endif
98 
99 #endif /* __RTW_ODM_H__ */
100