1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef ATH11K_SPECTRAL_H
7 #define ATH11K_SPECTRAL_H
8 
9 #include "../spectral_common.h"
10 #include "dbring.h"
11 
12 /* enum ath11k_spectral_mode:
13  *
14  * @SPECTRAL_DISABLED: spectral mode is disabled
15  * @SPECTRAL_BACKGROUND: hardware sends samples when it is not busy with
16  *	something else.
17  * @SPECTRAL_MANUAL: spectral scan is enabled, triggering for samples
18  *	is performed manually.
19  */
20 enum ath11k_spectral_mode {
21 	ATH11K_SPECTRAL_DISABLED = 0,
22 	ATH11K_SPECTRAL_BACKGROUND,
23 	ATH11K_SPECTRAL_MANUAL,
24 };
25 
26 struct ath11k_spectral {
27 	struct ath11k_dbring rx_ring;
28 	/* Protects enabled */
29 	spinlock_t lock;
30 	struct rchan *rfs_scan;	/* relay(fs) channel for spectral scan */
31 	struct dentry *scan_ctl;
32 	struct dentry *scan_count;
33 	struct dentry *scan_bins;
34 	enum ath11k_spectral_mode mode;
35 	u16 count;
36 	u8 fft_size;
37 	bool enabled;
38 	bool is_primary;
39 };
40 
41 #ifdef CONFIG_ATH11K_SPECTRAL
42 
43 int ath11k_spectral_init(struct ath11k_base *ab);
44 void ath11k_spectral_deinit(struct ath11k_base *ab);
45 int ath11k_spectral_vif_stop(struct ath11k_vif *arvif);
46 void ath11k_spectral_reset_buffer(struct ath11k *ar);
47 enum ath11k_spectral_mode ath11k_spectral_get_mode(struct ath11k *ar);
48 struct ath11k_dbring *ath11k_spectral_get_dbring(struct ath11k *ar);
49 
50 #else
51 
52 static inline int ath11k_spectral_init(struct ath11k_base *ab)
53 {
54 	return 0;
55 }
56 
57 static inline void ath11k_spectral_deinit(struct ath11k_base *ab)
58 {
59 }
60 
61 static inline int ath11k_spectral_vif_stop(struct ath11k_vif *arvif)
62 {
63 	return 0;
64 }
65 
66 static inline void ath11k_spectral_reset_buffer(struct ath11k *ar)
67 {
68 }
69 
70 static inline
71 enum ath11k_spectral_mode ath11k_spectral_get_mode(struct ath11k *ar)
72 {
73 	return ATH11K_SPECTRAL_DISABLED;
74 }
75 
76 static inline
77 struct ath11k_dbring *ath11k_spectral_get_dbring(struct ath11k *ar)
78 {
79 	return NULL;
80 }
81 
82 #endif /* CONFIG_ATH11K_SPECTRAL */
83 #endif /* ATH11K_SPECTRAL_H */
84