GNU Linux-libre 4.14.254-gnu1
[releases.git] / drivers / staging / rtl8188eu / include / rtw_led.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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  ******************************************************************************/
16 #ifndef __RTW_LED_H_
17 #define __RTW_LED_H_
18
19 #include <osdep_service.h>
20 #include <drv_types.h>
21
22 #define LED_BLINK_NO_LINK_INTERVAL_ALPHA        1000
23 #define LED_BLINK_LINK_INTERVAL_ALPHA           500     /* 500 */
24 #define LED_BLINK_SCAN_INTERVAL_ALPHA           180     /* 150 */
25 #define LED_BLINK_FASTER_INTERVAL_ALPHA         50
26 #define LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA    5000
27
28 enum LED_CTL_MODE {
29         LED_CTL_POWER_ON,
30         LED_CTL_LINK,
31         LED_CTL_NO_LINK,
32         LED_CTL_TX,
33         LED_CTL_RX,
34         LED_CTL_SITE_SURVEY,
35         LED_CTL_POWER_OFF,
36         LED_CTL_START_TO_LINK,
37         LED_CTL_START_WPS,
38         LED_CTL_STOP_WPS,
39         LED_CTL_START_WPS_BOTTON,
40         LED_CTL_STOP_WPS_FAIL
41 };
42
43 enum LED_STATE_871x {
44         LED_UNKNOWN,
45         RTW_LED_ON,
46         RTW_LED_OFF,
47         LED_BLINK_NORMAL,
48         LED_BLINK_SLOWLY,
49         LED_BLINK_POWER_ON,
50         LED_BLINK_SCAN,
51         LED_BLINK_TXRX,
52         LED_BLINK_WPS,
53         LED_BLINK_WPS_STOP
54 };
55
56 struct LED_871x {
57         struct adapter *padapter;
58
59         enum LED_STATE_871x     CurrLedState; /*  Current LED state. */
60         enum LED_STATE_871x     BlinkingLedState; /*  Next state for blinking,
61                                    * either RTW_LED_ON or RTW_LED_OFF are. */
62
63         u8 bLedOn; /*  true if LED is ON, false if LED is OFF. */
64
65         u8 bLedBlinkInProgress; /*  true if it is blinking, false o.w.. */
66
67         u8 bLedWPSBlinkInProgress;
68
69         u32 BlinkTimes; /*  Number of times to toggle led state for blinking. */
70
71         struct timer_list BlinkTimer; /*  Timer object for led blinking. */
72
73         /*  ALPHA, added by chiyoko, 20090106 */
74         u8 bLedNoLinkBlinkInProgress;
75         u8 bLedLinkBlinkInProgress;
76         u8 bLedScanBlinkInProgress;
77         struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to
78                                            * manipulate H/W to blink LED. */
79 };
80
81 #define IS_LED_WPS_BLINKING(_LED_871x)                                  \
82         (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \
83         ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \
84         ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
85
86 void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE       LedAction);
87
88 struct led_priv {
89         /* add for led control */
90         struct LED_871x                 SwLed0;
91         /* add for led control */
92 };
93
94 void BlinkTimerCallback(unsigned long data);
95 void BlinkWorkItemCallback(struct work_struct *work);
96
97 void ResetLedStatus(struct LED_871x *pLed);
98
99 void InitLed871x(struct adapter *padapter, struct LED_871x *pLed);
100
101 void DeInitLed871x(struct LED_871x *pLed);
102
103 /* hal... */
104 void BlinkHandler(struct LED_871x *pLed);
105 void SwLedOn(struct adapter *padapter, struct LED_871x *pLed);
106 void SwLedOff(struct adapter *padapter, struct LED_871x *pLed);
107
108 #endif /* __RTW_LED_H_ */