1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __RTW_LED_H_
21#define __RTW_LED_H_
22
23#include <osdep_service.h>
24#include <drv_types.h>
25
26#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
27
28#define LED_BLINK_NORMAL_INTERVAL 100
29#define LED_BLINK_SLOWLY_INTERVAL 200
30#define LED_BLINK_LONG_INTERVAL 400
31
32#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000
33#define LED_BLINK_LINK_INTERVAL_ALPHA 500
34#define LED_BLINK_SCAN_INTERVAL_ALPHA 180
35#define LED_BLINK_FASTER_INTERVAL_ALPHA 50
36#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000
37
38#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100
39#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000
40
41#define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000
42#define LED_BLINK_NORMAL_INTERVAL_PORNET 100
43
44#define LED_BLINK_FAST_INTERVAL_BITLAND 30
45
46
47#define LED_CM2_BLINK_ON_INTERVAL 250
48#define LED_CM2_BLINK_OFF_INTERVAL 4750
49
50#define LED_CM8_BLINK_INTERVAL 500
51#define LED_CM8_BLINK_OFF_INTERVAL 3750
52
53
54#define LED_RunTop_BLINK_INTERVAL 300
55
56
57#define LED_CM3_BLINK_INTERVAL 1500
58
59enum LED_CTL_MODE {
60 LED_CTL_POWER_ON = 1,
61 LED_CTL_LINK = 2,
62 LED_CTL_NO_LINK = 3,
63 LED_CTL_TX = 4,
64 LED_CTL_RX = 5,
65 LED_CTL_SITE_SURVEY = 6,
66 LED_CTL_POWER_OFF = 7,
67 LED_CTL_START_TO_LINK = 8,
68 LED_CTL_START_WPS = 9,
69 LED_CTL_STOP_WPS = 10,
70 LED_CTL_START_WPS_BOTTON = 11,
71 LED_CTL_STOP_WPS_FAIL = 12,
72 LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
73 LED_CTL_CONNECTION_NO_TRANSFER = 14,
74};
75
76enum LED_STATE_871x {
77 LED_UNKNOWN = 0,
78 RTW_LED_ON = 1,
79 RTW_LED_OFF = 2,
80 LED_BLINK_NORMAL = 3,
81 LED_BLINK_SLOWLY = 4,
82 LED_BLINK_POWER_ON = 5,
83 LED_BLINK_SCAN = 6,
84
85
86 LED_BLINK_NO_LINK = 7,
87 LED_BLINK_StartToBlink = 8,
88
89 LED_BLINK_TXRX = 9,
90 LED_BLINK_WPS = 10,
91 LED_BLINK_WPS_STOP = 11,
92 LED_BLINK_WPS_STOP_OVERLAP = 12,
93 LED_BLINK_RUNTOP = 13,
94 LED_BLINK_CAMEO = 14,
95 LED_BLINK_XAVI = 15,
96 LED_BLINK_ALWAYS_ON = 16,
97};
98
99enum LED_PIN_871x {
100 LED_PIN_NULL = 0,
101 LED_PIN_LED0 = 1,
102 LED_PIN_LED1 = 2,
103 LED_PIN_LED2 = 3,
104 LED_PIN_GPIO0 = 4,
105};
106
107struct LED_871x {
108 struct adapter *padapter;
109
110 enum LED_PIN_871x LedPin;
111
112 enum LED_STATE_871x CurrLedState;
113 enum LED_STATE_871x BlinkingLedState;
114
115
116 u8 bLedOn;
117
118 u8 bLedBlinkInProgress;
119
120 u8 bLedWPSBlinkInProgress;
121
122 u32 BlinkTimes;
123
124 struct timer_list BlinkTimer;
125
126 u8 bSWLedCtrl;
127
128
129 u8 bLedNoLinkBlinkInProgress;
130 u8 bLedLinkBlinkInProgress;
131 u8 bLedStartToLinkBlinkInProgress;
132 u8 bLedScanBlinkInProgress;
133 struct work_struct BlinkWorkItem;
134
135};
136
137#define IS_LED_WPS_BLINKING(_LED_871x) \
138 (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \
139 ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \
140 ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
141
142#define IS_LED_BLINKING(_LED_871x) \
143 (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \
144 ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
145
146
147
148enum LED_STRATEGY_871x {
149 SW_LED_MODE0 = 0,
150 SW_LED_MODE1 = 1,
151 SW_LED_MODE2 = 2,
152
153 SW_LED_MODE3 = 3,
154
155 SW_LED_MODE4 = 4,
156 SW_LED_MODE5 = 5,
157 SW_LED_MODE6 = 6,
158 HW_LED = 50,
159
160 LED_ST_NONE = 99,
161};
162
163void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction);
164
165struct led_priv{
166
167 struct LED_871x SwLed0;
168 struct LED_871x SwLed1;
169 enum LED_STRATEGY_871x LedStrategy;
170 u8 bRegUseLed;
171 void (*LedControlHandler)(struct adapter *padapter,
172 enum LED_CTL_MODE LedAction);
173
174};
175
176#define rtw_led_control(adapt, action) \
177 do { \
178 if ((adapt)->ledpriv.LedControlHandler) \
179 (adapt)->ledpriv.LedControlHandler((adapt), (action)); \
180 } while (0)
181
182void BlinkTimerCallback(void *data);
183void BlinkWorkItemCallback(struct work_struct *work);
184
185void ResetLedStatus(struct LED_871x *pLed);
186
187void InitLed871x(struct adapter *padapter, struct LED_871x *pLed,
188 enum LED_PIN_871x LedPin);
189
190void DeInitLed871x(struct LED_871x *pLed);
191
192
193void BlinkHandler(struct LED_871x *pLed);
194void SwLedOn(struct adapter *padapter, struct LED_871x *pLed);
195void SwLedOff(struct adapter *padapter, struct LED_871x *pLed);
196
197#endif
198