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