1 /****************************************************************************** 2 * 3 * Copyright(c) 2019 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 __HAL_CSI_BUFFER_H__ 16 #define __HAL_CSI_BUFFER_H__ 17 18 #define CSI_BUF_IDX_HW_MSK 0x7FF 19 20 #define CSI_BUF_SUB_IDX_80 0b0 21 #define CSI_BUF_SUB_IDX_40_U 0b100100 22 #define CSI_BUF_SUB_IDX_40_L 0b101000 23 #define CSI_BUF_SUB_IDX_20_UU 0b000100 24 #define CSI_BUF_SUB_IDX_20_UL 0b001000 25 #define CSI_BUF_SUB_IDX_20_LU 0b001100 26 #define CSI_BUF_SUB_IDX_20_LL 0b010000 27 #define CSI_BUF_SUB_IDX_NON 0b111111 28 29 #define CSI_BUF_STS_BUSY 1 30 #define CSI_BUF_STS_IDLE 0 31 32 #define IS_SUB20_BUSY(_csi, _idx) \ 33 (((_csi->sub_idx&BIT(_idx)) == BIT(_idx)) ? CSI_BUF_STS_BUSY : CSI_BUF_STS_IDLE) 34 35 #define SET_SUB20_BUSY(_csi, _idx) _csi->sub_idx |= BIT(_idx) 36 37 #define IS_40L_BUSY(_csi) \ 38 (((_csi->sub_idx & (BIT(0)|BIT(1)))==(BIT(0)|BIT(1))) ? CSI_BUF_STS_BUSY : CSI_BUF_STS_IDLE) 39 #define IS_40U_BUSY(_csi) \ 40 (((_csi->sub_idx & (BIT(2)|BIT(3)))==(BIT(2)|BIT(3))) ? CSI_BUF_STS_BUSY : CSI_BUF_STS_IDLE) 41 42 #define SET_40L_BUSY(_csi) _csi->sub_idx |= (BIT(0)|BIT(1)) 43 #define SET_40U_BUSY(_csi) _csi->sub_idx |= (BIT(2)|BIT(3)) 44 45 #define CLEAR_CSI_STS_BIT(_csi, _x) _csi->sub_idx &= ~(1 << _x) 46 47 enum hal_csi_buf_type { 48 HAL_CSI_BUF_TYPE_SU = 0, 49 HAL_CSI_BUF_TYPE_MU = 1 50 }; 51 52 enum hal_csi_buf_size { 53 HAL_CSI_BUF_SIZE_NONE = 0, 54 HAL_CSI_BUF_SIZE_20, 55 HAL_CSI_BUF_SIZE_40, 56 HAL_CSI_BUF_SIZE_80, 57 HAL_CSI_BUF_SIZE_160 58 }; 59 60 struct hal_csi_buf { 61 u16 sub_idx:6; 62 u16 idx:5; 63 u16 type:1; 64 u16 rsvd:4; 65 }; 66 67 struct hal_csi_obj { 68 u8 max_csi_buf_nr; 69 u8 max_csi_buf_nr_su; 70 u8 max_csi_buf_nr_mu; 71 struct hal_csi_buf *csi_buf; 72 _os_lock csi_lock; 73 }; 74 75 enum rtw_hal_status 76 hal_csi_init(struct hal_info_t *hal_info, u8 su_buf_nr, u8 mu_buf_nr); 77 78 void hal_csi_deinit(struct hal_info_t *hal_info); 79 80 enum rtw_hal_status hal_csi_query_idle_csi_buf( 81 struct hal_info_t *hal_info, u8 mu, enum channel_width bw, void *buf); 82 83 enum rtw_hal_status hal_csi_release_csi_buf( 84 struct hal_info_t *hal_info, 85 void *buf); 86 87 u8 hal_is_csi_buf_valid(struct hal_info_t *hal_info, void *buf); 88 89 enum channel_width 90 rtw_hal_get_csi_buf_bw(void *buf); 91 92 bool 93 rtw_hal_get_csi_buf_type(void *buf); 94 95 #endif 96