1 /******************************************************************************
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5 * Linux device driver for RTL8192SU
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 * Modifications for inclusion into the Linux staging tree are
21 * Copyright(c) 2010 Larry Finger. All rights reserved.
23 * Contact information:
24 * WLAN FAE <wlanfae@realtek.com>
25 * Larry Finger <Larry.Finger@lwfinger.net>
27 ******************************************************************************/
29 #include "drv_types.h"
31 /*===========================================================================
33 *===========================================================================
36 * Default LED behavior.
38 #define LED_BLINK_NORMAL_INTERVAL 100
39 #define LED_BLINK_SLOWLY_INTERVAL 200
40 #define LED_BLINK_LONG_INTERVAL 400
42 #define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000
43 #define LED_BLINK_LINK_INTERVAL_ALPHA 500
44 #define LED_BLINK_SCAN_INTERVAL_ALPHA 180
45 #define LED_BLINK_FASTER_INTERVAL_ALPHA 50
46 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000
48 /*===========================================================================
50 *===========================================================================
52 enum _LED_STATE_871x
{
58 LED_POWER_ON_BLINK
= 5,
59 LED_SCAN_BLINK
= 6, /* LED is blinking during scanning period,
60 * the # of times to blink is depend on time
62 LED_NO_LINK_BLINK
= 7, /* LED is blinking during no link state. */
63 LED_BLINK_StartToBlink
= 8,/* Customized for Sercomm Printer
65 LED_BLINK_WPS
= 9, /* LED is blinkg during WPS communication */
67 LED_BLINK_WPS_STOP
= 11, /*for ALPHA */
68 LED_BLINK_WPS_STOP_OVERLAP
= 12, /*for BELKIN */
71 /*===========================================================================
72 * Prototype of protected function.
73 *===========================================================================
75 static void BlinkTimerCallback(unsigned long data
);
77 static void BlinkWorkItemCallback(struct work_struct
*work
);
78 /*===========================================================================
79 * LED_819xUsb routines.
80 *===========================================================================
85 * Initialize an LED_871x object.
87 static void InitLed871x(struct _adapter
*padapter
, struct LED_871x
*pLed
,
88 enum LED_PIN_871x LedPin
)
90 struct net_device
*nic
;
92 nic
= padapter
->pnetdev
;
93 pLed
->padapter
= padapter
;
94 pLed
->LedPin
= LedPin
;
95 pLed
->CurrLedState
= LED_OFF
;
97 pLed
->bLedBlinkInProgress
= false;
99 pLed
->BlinkingLedState
= LED_UNKNOWN
;
100 setup_timer(&pLed
->BlinkTimer
, BlinkTimerCallback
,
101 (unsigned long)pLed
);
102 INIT_WORK(&pLed
->BlinkWorkItem
, BlinkWorkItemCallback
);
107 * DeInitialize an LED_871x object.
109 static void DeInitLed871x(struct LED_871x
*pLed
)
111 del_timer_sync(&pLed
->BlinkTimer
);
112 /* We should reset bLedBlinkInProgress if we cancel
113 * the LedControlTimer, */
114 pLed
->bLedBlinkInProgress
= false;
119 * Turn on LED according to LedPin specified.
121 static void SwLedOn(struct _adapter
*padapter
, struct LED_871x
*pLed
)
125 if ((padapter
->bSurpriseRemoved
== true) ||
126 (padapter
->bDriverStopped
== true))
128 LedCfg
= r8712_read8(padapter
, LEDCFG
);
129 switch (pLed
->LedPin
) {
133 /* SW control led0 on.*/
134 r8712_write8(padapter
, LEDCFG
, LedCfg
&0xf0);
137 /* SW control led1 on.*/
138 r8712_write8(padapter
, LEDCFG
, LedCfg
&0x0f);
148 * Turn off LED according to LedPin specified.
150 static void SwLedOff(struct _adapter
*padapter
, struct LED_871x
*pLed
)
154 if ((padapter
->bSurpriseRemoved
== true) ||
155 (padapter
->bDriverStopped
== true))
157 LedCfg
= r8712_read8(padapter
, LEDCFG
);
158 switch (pLed
->LedPin
) {
162 LedCfg
&= 0xf0; /* Set to software control.*/
163 r8712_write8(padapter
, LEDCFG
, (LedCfg
|BIT(3)));
166 LedCfg
&= 0x0f; /* Set to software control.*/
167 r8712_write8(padapter
, LEDCFG
, (LedCfg
|BIT(7)));
172 pLed
->bLedOn
= false;
175 /*===========================================================================
176 * Interface to manipulate LED objects.
177 *===========================================================================
180 * Initialize all LED_871x objects.
182 void r8712_InitSwLeds(struct _adapter
*padapter
)
184 struct led_priv
*pledpriv
= &(padapter
->ledpriv
);
186 pledpriv
->LedControlHandler
= LedControl871x
;
187 InitLed871x(padapter
, &(pledpriv
->SwLed0
), LED_PIN_LED0
);
188 InitLed871x(padapter
, &(pledpriv
->SwLed1
), LED_PIN_LED1
);
192 * DeInitialize all LED_819xUsb objects.
194 void r8712_DeInitSwLeds(struct _adapter
*padapter
)
196 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
198 DeInitLed871x(&(ledpriv
->SwLed0
));
199 DeInitLed871x(&(ledpriv
->SwLed1
));
203 * Implementation of LED blinking behavior.
204 * It toggle off LED and schedule corresponding timer if necessary.
206 static void SwLedBlink(struct LED_871x
*pLed
)
208 struct _adapter
*padapter
= pLed
->padapter
;
209 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
210 u8 bStopBlinking
= false;
212 /* Change LED according to BlinkingLedState specified. */
213 if (pLed
->BlinkingLedState
== LED_ON
)
214 SwLedOn(padapter
, pLed
);
216 SwLedOff(padapter
, pLed
);
217 /* Determine if we shall change LED state again. */
219 switch (pLed
->CurrLedState
) {
220 case LED_BLINK_NORMAL
:
221 if (pLed
->BlinkTimes
== 0)
222 bStopBlinking
= true;
224 case LED_BLINK_StartToBlink
:
225 if ((check_fwstate(pmlmepriv
, _FW_LINKED
) == true) &&
226 (pmlmepriv
->fw_state
& WIFI_STATION_STATE
))
227 bStopBlinking
= true;
228 if ((check_fwstate(pmlmepriv
, _FW_LINKED
) == true) &&
229 ((pmlmepriv
->fw_state
& WIFI_ADHOC_STATE
) ||
230 (pmlmepriv
->fw_state
& WIFI_ADHOC_MASTER_STATE
)))
231 bStopBlinking
= true;
232 else if (pLed
->BlinkTimes
== 0)
233 bStopBlinking
= true;
236 if (pLed
->BlinkTimes
== 0)
237 bStopBlinking
= true;
240 bStopBlinking
= true;
244 if ((check_fwstate(pmlmepriv
, _FW_LINKED
) == true) &&
245 (pLed
->bLedOn
== false))
246 SwLedOn(padapter
, pLed
);
247 else if ((check_fwstate(pmlmepriv
, _FW_LINKED
) ==
248 true) && pLed
->bLedOn
== true)
249 SwLedOff(padapter
, pLed
);
250 pLed
->BlinkTimes
= 0;
251 pLed
->bLedBlinkInProgress
= false;
253 /* Assign LED state to toggle. */
254 if (pLed
->BlinkingLedState
== LED_ON
)
255 pLed
->BlinkingLedState
= LED_OFF
;
257 pLed
->BlinkingLedState
= LED_ON
;
259 /* Schedule a timer to toggle LED state. */
260 switch (pLed
->CurrLedState
) {
261 case LED_BLINK_NORMAL
:
262 mod_timer(&pLed
->BlinkTimer
, jiffies
+
263 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
265 case LED_BLINK_SLOWLY
:
266 case LED_BLINK_StartToBlink
:
267 mod_timer(&pLed
->BlinkTimer
, jiffies
+
268 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL
));
271 mod_timer(&pLed
->BlinkTimer
, jiffies
+
272 msecs_to_jiffies(LED_BLINK_LONG_INTERVAL
));
275 mod_timer(&pLed
->BlinkTimer
, jiffies
+
276 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL
));
282 static void SwLedBlink1(struct LED_871x
*pLed
)
284 struct _adapter
*padapter
= pLed
->padapter
;
285 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
286 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
287 struct eeprom_priv
*peeprompriv
= &(padapter
->eeprompriv
);
288 struct LED_871x
*pLed1
= &(ledpriv
->SwLed1
);
289 u8 bStopBlinking
= false;
291 if (peeprompriv
->CustomerID
== RT_CID_819x_CAMEO
)
292 pLed
= &(ledpriv
->SwLed1
);
293 /* Change LED according to BlinkingLedState specified. */
294 if (pLed
->BlinkingLedState
== LED_ON
)
295 SwLedOn(padapter
, pLed
);
297 SwLedOff(padapter
, pLed
);
298 if (peeprompriv
->CustomerID
== RT_CID_DEFAULT
) {
299 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
300 if (!pLed1
->bSWLedCtrl
) {
301 SwLedOn(padapter
, pLed1
);
302 pLed1
->bSWLedCtrl
= true;
303 } else if (!pLed1
->bLedOn
)
304 SwLedOn(padapter
, pLed1
);
306 if (!pLed1
->bSWLedCtrl
) {
307 SwLedOff(padapter
, pLed1
);
308 pLed1
->bSWLedCtrl
= true;
309 } else if (pLed1
->bLedOn
)
310 SwLedOff(padapter
, pLed1
);
313 switch (pLed
->CurrLedState
) {
314 case LED_BLINK_SLOWLY
:
316 pLed
->BlinkingLedState
= LED_OFF
;
318 pLed
->BlinkingLedState
= LED_ON
;
319 mod_timer(&pLed
->BlinkTimer
, jiffies
+
320 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
322 case LED_BLINK_NORMAL
:
324 pLed
->BlinkingLedState
= LED_OFF
;
326 pLed
->BlinkingLedState
= LED_ON
;
327 mod_timer(&pLed
->BlinkTimer
, jiffies
+
328 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA
));
332 if (pLed
->BlinkTimes
== 0)
333 bStopBlinking
= true;
335 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
336 pLed
->bLedLinkBlinkInProgress
= true;
337 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
339 pLed
->BlinkingLedState
= LED_OFF
;
341 pLed
->BlinkingLedState
= LED_ON
;
342 mod_timer(&pLed
->BlinkTimer
, jiffies
+
343 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA
));
344 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
345 pLed
->bLedNoLinkBlinkInProgress
= true;
346 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
348 pLed
->BlinkingLedState
= LED_OFF
;
350 pLed
->BlinkingLedState
= LED_ON
;
351 mod_timer(&pLed
->BlinkTimer
, jiffies
+
352 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
354 pLed
->bLedScanBlinkInProgress
= false;
357 pLed
->BlinkingLedState
= LED_OFF
;
359 pLed
->BlinkingLedState
= LED_ON
;
360 mod_timer(&pLed
->BlinkTimer
, jiffies
+
361 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
366 if (pLed
->BlinkTimes
== 0)
367 bStopBlinking
= true;
369 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
370 pLed
->bLedLinkBlinkInProgress
= true;
371 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
373 pLed
->BlinkingLedState
= LED_OFF
;
375 pLed
->BlinkingLedState
= LED_ON
;
376 mod_timer(&pLed
->BlinkTimer
, jiffies
+
377 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA
));
378 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
379 pLed
->bLedNoLinkBlinkInProgress
= true;
380 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
382 pLed
->BlinkingLedState
= LED_OFF
;
384 pLed
->BlinkingLedState
= LED_ON
;
385 mod_timer(&pLed
->BlinkTimer
, jiffies
+
386 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
388 pLed
->BlinkTimes
= 0;
389 pLed
->bLedBlinkInProgress
= false;
392 pLed
->BlinkingLedState
= LED_OFF
;
394 pLed
->BlinkingLedState
= LED_ON
;
395 mod_timer(&pLed
->BlinkTimer
, jiffies
+
396 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
401 pLed
->BlinkingLedState
= LED_OFF
;
403 pLed
->BlinkingLedState
= LED_ON
;
404 mod_timer(&pLed
->BlinkTimer
, jiffies
+
405 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
407 case LED_BLINK_WPS_STOP
: /* WPS success */
408 if (pLed
->BlinkingLedState
== LED_ON
) {
409 pLed
->BlinkingLedState
= LED_OFF
;
410 mod_timer(&pLed
->BlinkTimer
, jiffies
+
411 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
));
412 bStopBlinking
= false;
414 bStopBlinking
= true;
416 pLed
->bLedLinkBlinkInProgress
= true;
417 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
419 pLed
->BlinkingLedState
= LED_OFF
;
421 pLed
->BlinkingLedState
= LED_ON
;
422 mod_timer(&pLed
->BlinkTimer
, jiffies
+
423 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA
));
425 pLed
->bLedWPSBlinkInProgress
= false;
432 static void SwLedBlink2(struct LED_871x
*pLed
)
434 struct _adapter
*padapter
= pLed
->padapter
;
435 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
436 u8 bStopBlinking
= false;
438 /* Change LED according to BlinkingLedState specified. */
439 if (pLed
->BlinkingLedState
== LED_ON
)
440 SwLedOn(padapter
, pLed
);
442 SwLedOff(padapter
, pLed
);
443 switch (pLed
->CurrLedState
) {
446 if (pLed
->BlinkTimes
== 0)
447 bStopBlinking
= true;
449 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
450 pLed
->CurrLedState
= LED_ON
;
451 pLed
->BlinkingLedState
= LED_ON
;
452 SwLedOn(padapter
, pLed
);
453 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
454 pLed
->CurrLedState
= LED_OFF
;
455 pLed
->BlinkingLedState
= LED_OFF
;
456 SwLedOff(padapter
, pLed
);
458 pLed
->bLedScanBlinkInProgress
= false;
461 pLed
->BlinkingLedState
= LED_OFF
;
463 pLed
->BlinkingLedState
= LED_ON
;
464 mod_timer(&pLed
->BlinkTimer
, jiffies
+
465 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
470 if (pLed
->BlinkTimes
== 0)
471 bStopBlinking
= true;
473 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
474 pLed
->CurrLedState
= LED_ON
;
475 pLed
->BlinkingLedState
= LED_ON
;
476 SwLedOn(padapter
, pLed
);
477 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
478 pLed
->CurrLedState
= LED_OFF
;
479 pLed
->BlinkingLedState
= LED_OFF
;
480 SwLedOff(padapter
, pLed
);
482 pLed
->bLedBlinkInProgress
= false;
485 pLed
->BlinkingLedState
= LED_OFF
;
487 pLed
->BlinkingLedState
= LED_ON
;
488 mod_timer(&pLed
->BlinkTimer
, jiffies
+
489 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
497 static void SwLedBlink3(struct LED_871x
*pLed
)
499 struct _adapter
*padapter
= pLed
->padapter
;
500 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
501 u8 bStopBlinking
= false;
503 /* Change LED according to BlinkingLedState specified. */
504 if (pLed
->BlinkingLedState
== LED_ON
)
505 SwLedOn(padapter
, pLed
);
507 if (pLed
->CurrLedState
!= LED_BLINK_WPS_STOP
)
508 SwLedOff(padapter
, pLed
);
509 switch (pLed
->CurrLedState
) {
512 if (pLed
->BlinkTimes
== 0)
513 bStopBlinking
= true;
515 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
516 pLed
->CurrLedState
= LED_ON
;
517 pLed
->BlinkingLedState
= LED_ON
;
519 SwLedOn(padapter
, pLed
);
520 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
521 pLed
->CurrLedState
= LED_OFF
;
522 pLed
->BlinkingLedState
= LED_OFF
;
524 SwLedOff(padapter
, pLed
);
526 pLed
->bLedScanBlinkInProgress
= false;
529 pLed
->BlinkingLedState
= LED_OFF
;
531 pLed
->BlinkingLedState
= LED_ON
;
532 mod_timer(&pLed
->BlinkTimer
, jiffies
+
533 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
538 if (pLed
->BlinkTimes
== 0)
539 bStopBlinking
= true;
541 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
542 pLed
->CurrLedState
= LED_ON
;
543 pLed
->BlinkingLedState
= LED_ON
;
545 SwLedOn(padapter
, pLed
);
546 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
547 pLed
->CurrLedState
= LED_OFF
;
548 pLed
->BlinkingLedState
= LED_OFF
;
550 SwLedOff(padapter
, pLed
);
552 pLed
->bLedBlinkInProgress
= false;
555 pLed
->BlinkingLedState
= LED_OFF
;
557 pLed
->BlinkingLedState
= LED_ON
;
558 mod_timer(&pLed
->BlinkTimer
, jiffies
+
559 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
564 pLed
->BlinkingLedState
= LED_OFF
;
566 pLed
->BlinkingLedState
= LED_ON
;
567 mod_timer(&pLed
->BlinkTimer
, jiffies
+
568 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
570 case LED_BLINK_WPS_STOP
: /*WPS success*/
571 if (pLed
->BlinkingLedState
== LED_ON
) {
572 pLed
->BlinkingLedState
= LED_OFF
;
573 mod_timer(&pLed
->BlinkTimer
, jiffies
+
574 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
));
575 bStopBlinking
= false;
577 bStopBlinking
= true;
579 pLed
->CurrLedState
= LED_ON
;
580 pLed
->BlinkingLedState
= LED_ON
;
581 SwLedOn(padapter
, pLed
);
582 pLed
->bLedWPSBlinkInProgress
= false;
590 static void SwLedBlink4(struct LED_871x
*pLed
)
592 struct _adapter
*padapter
= pLed
->padapter
;
593 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
594 struct LED_871x
*pLed1
= &(ledpriv
->SwLed1
);
595 u8 bStopBlinking
= false;
597 /* Change LED according to BlinkingLedState specified. */
598 if (pLed
->BlinkingLedState
== LED_ON
)
599 SwLedOn(padapter
, pLed
);
601 SwLedOff(padapter
, pLed
);
602 if (!pLed1
->bLedWPSBlinkInProgress
&&
603 pLed1
->BlinkingLedState
== LED_UNKNOWN
) {
604 pLed1
->BlinkingLedState
= LED_OFF
;
605 pLed1
->CurrLedState
= LED_OFF
;
606 SwLedOff(padapter
, pLed1
);
608 switch (pLed
->CurrLedState
) {
609 case LED_BLINK_SLOWLY
:
611 pLed
->BlinkingLedState
= LED_OFF
;
613 pLed
->BlinkingLedState
= LED_ON
;
614 mod_timer(&pLed
->BlinkTimer
, jiffies
+
615 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
617 case LED_BLINK_StartToBlink
:
619 pLed
->BlinkingLedState
= LED_OFF
;
620 mod_timer(&pLed
->BlinkTimer
, jiffies
+
621 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL
));
623 pLed
->BlinkingLedState
= LED_ON
;
624 mod_timer(&pLed
->BlinkTimer
, jiffies
+
625 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
630 if (pLed
->BlinkTimes
== 0)
631 bStopBlinking
= true;
633 pLed
->bLedNoLinkBlinkInProgress
= true;
634 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
636 pLed
->BlinkingLedState
= LED_OFF
;
638 pLed
->BlinkingLedState
= LED_ON
;
639 mod_timer(&pLed
->BlinkTimer
, jiffies
+
640 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
641 pLed
->bLedScanBlinkInProgress
= false;
644 pLed
->BlinkingLedState
= LED_OFF
;
646 pLed
->BlinkingLedState
= LED_ON
;
647 mod_timer(&pLed
->BlinkTimer
, jiffies
+
648 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
653 if (pLed
->BlinkTimes
== 0)
654 bStopBlinking
= true;
656 pLed
->bLedNoLinkBlinkInProgress
= true;
657 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
659 pLed
->BlinkingLedState
= LED_OFF
;
661 pLed
->BlinkingLedState
= LED_ON
;
662 mod_timer(&pLed
->BlinkTimer
, jiffies
+
663 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
664 pLed
->bLedBlinkInProgress
= false;
667 pLed
->BlinkingLedState
= LED_OFF
;
669 pLed
->BlinkingLedState
= LED_ON
;
670 mod_timer(&pLed
->BlinkTimer
, jiffies
+
671 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
676 pLed
->BlinkingLedState
= LED_OFF
;
677 mod_timer(&pLed
->BlinkTimer
, jiffies
+
678 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL
));
680 pLed
->BlinkingLedState
= LED_ON
;
681 mod_timer(&pLed
->BlinkTimer
, jiffies
+
682 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
685 case LED_BLINK_WPS_STOP
: /*WPS authentication fail*/
687 pLed
->BlinkingLedState
= LED_OFF
;
689 pLed
->BlinkingLedState
= LED_ON
;
690 mod_timer(&pLed
->BlinkTimer
, jiffies
+
691 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
693 case LED_BLINK_WPS_STOP_OVERLAP
: /*WPS session overlap */
695 if (pLed
->BlinkTimes
== 0) {
697 pLed
->BlinkTimes
= 1;
699 bStopBlinking
= true;
702 pLed
->BlinkTimes
= 10;
703 pLed
->BlinkingLedState
= LED_ON
;
704 mod_timer(&pLed
->BlinkTimer
, jiffies
+
705 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA
));
708 pLed
->BlinkingLedState
= LED_OFF
;
710 pLed
->BlinkingLedState
= LED_ON
;
711 mod_timer(&pLed
->BlinkTimer
, jiffies
+
712 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
720 static void SwLedBlink5(struct LED_871x
*pLed
)
722 struct _adapter
*padapter
= pLed
->padapter
;
723 u8 bStopBlinking
= false;
725 /* Change LED according to BlinkingLedState specified. */
726 if (pLed
->BlinkingLedState
== LED_ON
)
727 SwLedOn(padapter
, pLed
);
729 SwLedOff(padapter
, pLed
);
730 switch (pLed
->CurrLedState
) {
733 if (pLed
->BlinkTimes
== 0)
734 bStopBlinking
= true;
736 pLed
->CurrLedState
= LED_ON
;
737 pLed
->BlinkingLedState
= LED_ON
;
739 mod_timer(&pLed
->BlinkTimer
, jiffies
+
740 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
741 pLed
->bLedScanBlinkInProgress
= false;
744 pLed
->BlinkingLedState
= LED_OFF
;
746 pLed
->BlinkingLedState
= LED_ON
;
747 mod_timer(&pLed
->BlinkTimer
, jiffies
+
748 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
753 if (pLed
->BlinkTimes
== 0)
754 bStopBlinking
= true;
756 pLed
->CurrLedState
= LED_ON
;
757 pLed
->BlinkingLedState
= LED_ON
;
759 mod_timer(&pLed
->BlinkTimer
, jiffies
+
760 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
761 pLed
->bLedBlinkInProgress
= false;
764 pLed
->BlinkingLedState
= LED_OFF
;
766 pLed
->BlinkingLedState
= LED_ON
;
767 mod_timer(&pLed
->BlinkTimer
, jiffies
+
768 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
776 static void SwLedBlink6(struct LED_871x
*pLed
)
778 struct _adapter
*padapter
= pLed
->padapter
;
779 u8 bStopBlinking
= false;
781 /* Change LED according to BlinkingLedState specified. */
782 if (pLed
->BlinkingLedState
== LED_ON
)
783 SwLedOn(padapter
, pLed
);
785 SwLedOff(padapter
, pLed
);
786 switch (pLed
->CurrLedState
) {
789 if (pLed
->BlinkTimes
== 0)
790 bStopBlinking
= true;
792 pLed
->CurrLedState
= LED_ON
;
793 pLed
->BlinkingLedState
= LED_ON
;
795 SwLedOn(padapter
, pLed
);
796 pLed
->bLedBlinkInProgress
= false;
799 pLed
->BlinkingLedState
= LED_OFF
;
801 pLed
->BlinkingLedState
= LED_ON
;
802 mod_timer(&pLed
->BlinkTimer
, jiffies
+
803 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
808 pLed
->BlinkingLedState
= LED_OFF
;
810 pLed
->BlinkingLedState
= LED_ON
;
811 mod_timer(&pLed
->BlinkTimer
, jiffies
+
812 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
821 * Callback function of LED BlinkTimer,
822 * it just schedules to corresponding BlinkWorkItem.
824 static void BlinkTimerCallback(unsigned long data
)
826 struct LED_871x
*pLed
= (struct LED_871x
*)data
;
828 /* This fixed the crash problem on Fedora 12 when trying to do the
829 * insmod;ifconfig up;rmmod commands. */
830 if ((pLed
->padapter
->bSurpriseRemoved
== true) ||
831 (pLed
->padapter
->bDriverStopped
== true))
833 schedule_work(&pLed
->BlinkWorkItem
);
837 * Callback function of LED BlinkWorkItem.
838 * We dispatch actual LED blink action according to LedStrategy.
840 static void BlinkWorkItemCallback(struct work_struct
*work
)
842 struct LED_871x
*pLed
= container_of(work
, struct LED_871x
,
844 struct led_priv
*ledpriv
= &(pLed
->padapter
->ledpriv
);
846 switch (ledpriv
->LedStrategy
) {
874 /*============================================================================
875 * Default LED behavior.
876 *============================================================================
879 * Implement each led action for SW_LED_MODE0.
880 * This is default strategy.
883 static void SwLedControlMode1(struct _adapter
*padapter
,
884 enum LED_CTL_MODE LedAction
)
886 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
887 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
888 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
889 struct sitesurvey_ctrl
*psitesurveyctrl
= &(pmlmepriv
->sitesurveyctrl
);
891 if (padapter
->eeprompriv
.CustomerID
== RT_CID_819x_CAMEO
)
892 pLed
= &(ledpriv
->SwLed1
);
894 case LED_CTL_START_TO_LINK
:
895 case LED_CTL_NO_LINK
:
896 if (pLed
->bLedNoLinkBlinkInProgress
== false) {
897 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
898 IS_LED_WPS_BLINKING(pLed
))
900 if (pLed
->bLedLinkBlinkInProgress
== true) {
901 del_timer_sync(&pLed
->BlinkTimer
);
902 pLed
->bLedLinkBlinkInProgress
= false;
904 if (pLed
->bLedBlinkInProgress
== true) {
905 del_timer_sync(&pLed
->BlinkTimer
);
906 pLed
->bLedBlinkInProgress
= false;
908 pLed
->bLedNoLinkBlinkInProgress
= true;
909 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
911 pLed
->BlinkingLedState
= LED_OFF
;
913 pLed
->BlinkingLedState
= LED_ON
;
914 mod_timer(&pLed
->BlinkTimer
, jiffies
+
915 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
919 if (pLed
->bLedLinkBlinkInProgress
== false) {
920 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
921 IS_LED_WPS_BLINKING(pLed
))
923 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
924 del_timer_sync(&pLed
->BlinkTimer
);
925 pLed
->bLedNoLinkBlinkInProgress
= false;
927 if (pLed
->bLedBlinkInProgress
== true) {
928 del_timer_sync(&pLed
->BlinkTimer
);
929 pLed
->bLedBlinkInProgress
= false;
931 pLed
->bLedLinkBlinkInProgress
= true;
932 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
934 pLed
->BlinkingLedState
= LED_OFF
;
936 pLed
->BlinkingLedState
= LED_ON
;
937 mod_timer(&pLed
->BlinkTimer
, jiffies
+
938 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA
));
941 case LED_CTL_SITE_SURVEY
:
942 if ((psitesurveyctrl
->traffic_busy
) &&
943 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true))
945 else if (pLed
->bLedScanBlinkInProgress
== false) {
946 if (IS_LED_WPS_BLINKING(pLed
))
948 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
949 del_timer_sync(&pLed
->BlinkTimer
);
950 pLed
->bLedNoLinkBlinkInProgress
= false;
952 if (pLed
->bLedLinkBlinkInProgress
== true) {
953 del_timer_sync(&pLed
->BlinkTimer
);
954 pLed
->bLedLinkBlinkInProgress
= false;
956 if (pLed
->bLedBlinkInProgress
== true) {
957 del_timer_sync(&pLed
->BlinkTimer
);
958 pLed
->bLedBlinkInProgress
= false;
960 pLed
->bLedScanBlinkInProgress
= true;
961 pLed
->CurrLedState
= LED_SCAN_BLINK
;
962 pLed
->BlinkTimes
= 24;
964 pLed
->BlinkingLedState
= LED_OFF
;
966 pLed
->BlinkingLedState
= LED_ON
;
967 mod_timer(&pLed
->BlinkTimer
, jiffies
+
968 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
973 if (pLed
->bLedBlinkInProgress
== false) {
974 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
975 IS_LED_WPS_BLINKING(pLed
))
977 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
978 del_timer_sync(&pLed
->BlinkTimer
);
979 pLed
->bLedNoLinkBlinkInProgress
= false;
981 if (pLed
->bLedLinkBlinkInProgress
== true) {
982 del_timer_sync(&pLed
->BlinkTimer
);
983 pLed
->bLedLinkBlinkInProgress
= false;
985 pLed
->bLedBlinkInProgress
= true;
986 pLed
->CurrLedState
= LED_TXRX_BLINK
;
987 pLed
->BlinkTimes
= 2;
989 pLed
->BlinkingLedState
= LED_OFF
;
991 pLed
->BlinkingLedState
= LED_ON
;
992 mod_timer(&pLed
->BlinkTimer
, jiffies
+
993 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
997 case LED_CTL_START_WPS
: /*wait until xinpin finish */
998 case LED_CTL_START_WPS_BOTTON
:
999 if (pLed
->bLedWPSBlinkInProgress
== false) {
1000 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1001 del_timer_sync(&pLed
->BlinkTimer
);
1002 pLed
->bLedNoLinkBlinkInProgress
= false;
1004 if (pLed
->bLedLinkBlinkInProgress
== true) {
1005 del_timer_sync(&pLed
->BlinkTimer
);
1006 pLed
->bLedLinkBlinkInProgress
= false;
1008 if (pLed
->bLedBlinkInProgress
== true) {
1009 del_timer_sync(&pLed
->BlinkTimer
);
1010 pLed
->bLedBlinkInProgress
= false;
1012 if (pLed
->bLedScanBlinkInProgress
== true) {
1013 del_timer_sync(&pLed
->BlinkTimer
);
1014 pLed
->bLedScanBlinkInProgress
= false;
1016 pLed
->bLedWPSBlinkInProgress
= true;
1017 pLed
->CurrLedState
= LED_BLINK_WPS
;
1019 pLed
->BlinkingLedState
= LED_OFF
;
1021 pLed
->BlinkingLedState
= LED_ON
;
1022 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1023 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1026 case LED_CTL_STOP_WPS
:
1027 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1028 del_timer_sync(&pLed
->BlinkTimer
);
1029 pLed
->bLedNoLinkBlinkInProgress
= false;
1031 if (pLed
->bLedLinkBlinkInProgress
== true) {
1032 del_timer_sync(&pLed
->BlinkTimer
);
1033 pLed
->bLedLinkBlinkInProgress
= false;
1035 if (pLed
->bLedBlinkInProgress
== true) {
1036 del_timer_sync(&pLed
->BlinkTimer
);
1037 pLed
->bLedBlinkInProgress
= false;
1039 if (pLed
->bLedScanBlinkInProgress
== true) {
1040 del_timer_sync(&pLed
->BlinkTimer
);
1041 pLed
->bLedScanBlinkInProgress
= false;
1043 if (pLed
->bLedWPSBlinkInProgress
)
1044 del_timer_sync(&pLed
->BlinkTimer
);
1046 pLed
->bLedWPSBlinkInProgress
= true;
1047 pLed
->CurrLedState
= LED_BLINK_WPS_STOP
;
1049 pLed
->BlinkingLedState
= LED_OFF
;
1050 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1051 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
));
1053 pLed
->BlinkingLedState
= LED_ON
;
1054 mod_timer(&pLed
->BlinkTimer
,
1055 jiffies
+ msecs_to_jiffies(0));
1058 case LED_CTL_STOP_WPS_FAIL
:
1059 if (pLed
->bLedWPSBlinkInProgress
) {
1060 del_timer_sync(&pLed
->BlinkTimer
);
1061 pLed
->bLedWPSBlinkInProgress
= false;
1063 pLed
->bLedNoLinkBlinkInProgress
= true;
1064 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1066 pLed
->BlinkingLedState
= LED_OFF
;
1068 pLed
->BlinkingLedState
= LED_ON
;
1069 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1070 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
1072 case LED_CTL_POWER_OFF
:
1073 pLed
->CurrLedState
= LED_OFF
;
1074 pLed
->BlinkingLedState
= LED_OFF
;
1075 if (pLed
->bLedNoLinkBlinkInProgress
) {
1076 del_timer_sync(&pLed
->BlinkTimer
);
1077 pLed
->bLedNoLinkBlinkInProgress
= false;
1079 if (pLed
->bLedLinkBlinkInProgress
) {
1080 del_timer_sync(&pLed
->BlinkTimer
);
1081 pLed
->bLedLinkBlinkInProgress
= false;
1083 if (pLed
->bLedBlinkInProgress
) {
1084 del_timer_sync(&pLed
->BlinkTimer
);
1085 pLed
->bLedBlinkInProgress
= false;
1087 if (pLed
->bLedWPSBlinkInProgress
) {
1088 del_timer_sync(&pLed
->BlinkTimer
);
1089 pLed
->bLedWPSBlinkInProgress
= false;
1091 if (pLed
->bLedScanBlinkInProgress
) {
1092 del_timer_sync(&pLed
->BlinkTimer
);
1093 pLed
->bLedScanBlinkInProgress
= false;
1095 mod_timer(&pLed
->BlinkTimer
,
1096 jiffies
+ msecs_to_jiffies(0));
1103 static void SwLedControlMode2(struct _adapter
*padapter
,
1104 enum LED_CTL_MODE LedAction
)
1106 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1107 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1108 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1110 switch (LedAction
) {
1111 case LED_CTL_SITE_SURVEY
:
1112 if (pmlmepriv
->sitesurveyctrl
.traffic_busy
)
1113 ; /* dummy branch */
1114 else if (pLed
->bLedScanBlinkInProgress
== false) {
1115 if (IS_LED_WPS_BLINKING(pLed
))
1118 if (pLed
->bLedBlinkInProgress
== true) {
1119 del_timer_sync(&pLed
->BlinkTimer
);
1120 pLed
->bLedBlinkInProgress
= false;
1122 pLed
->bLedScanBlinkInProgress
= true;
1123 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1124 pLed
->BlinkTimes
= 24;
1126 pLed
->BlinkingLedState
= LED_OFF
;
1128 pLed
->BlinkingLedState
= LED_ON
;
1129 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1130 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1136 if ((pLed
->bLedBlinkInProgress
== false) &&
1137 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true)) {
1138 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1139 IS_LED_WPS_BLINKING(pLed
))
1141 pLed
->bLedBlinkInProgress
= true;
1142 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1143 pLed
->BlinkTimes
= 2;
1145 pLed
->BlinkingLedState
= LED_OFF
;
1147 pLed
->BlinkingLedState
= LED_ON
;
1148 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1149 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
1154 pLed
->CurrLedState
= LED_ON
;
1155 pLed
->BlinkingLedState
= LED_ON
;
1156 if (pLed
->bLedBlinkInProgress
) {
1157 del_timer_sync(&pLed
->BlinkTimer
);
1158 pLed
->bLedBlinkInProgress
= false;
1160 if (pLed
->bLedScanBlinkInProgress
) {
1161 del_timer_sync(&pLed
->BlinkTimer
);
1162 pLed
->bLedScanBlinkInProgress
= false;
1165 mod_timer(&pLed
->BlinkTimer
,
1166 jiffies
+ msecs_to_jiffies(0));
1169 case LED_CTL_START_WPS
: /*wait until xinpin finish*/
1170 case LED_CTL_START_WPS_BOTTON
:
1171 if (pLed
->bLedWPSBlinkInProgress
== false) {
1172 if (pLed
->bLedBlinkInProgress
== true) {
1173 del_timer_sync(&pLed
->BlinkTimer
);
1174 pLed
->bLedBlinkInProgress
= false;
1176 if (pLed
->bLedScanBlinkInProgress
== true) {
1177 del_timer_sync(&pLed
->BlinkTimer
);
1178 pLed
->bLedScanBlinkInProgress
= false;
1180 pLed
->bLedWPSBlinkInProgress
= true;
1181 pLed
->CurrLedState
= LED_ON
;
1182 pLed
->BlinkingLedState
= LED_ON
;
1183 mod_timer(&pLed
->BlinkTimer
,
1184 jiffies
+ msecs_to_jiffies(0));
1188 case LED_CTL_STOP_WPS
:
1189 pLed
->bLedWPSBlinkInProgress
= false;
1190 pLed
->CurrLedState
= LED_ON
;
1191 pLed
->BlinkingLedState
= LED_ON
;
1192 mod_timer(&pLed
->BlinkTimer
,
1193 jiffies
+ msecs_to_jiffies(0));
1196 case LED_CTL_STOP_WPS_FAIL
:
1197 pLed
->bLedWPSBlinkInProgress
= false;
1198 pLed
->CurrLedState
= LED_OFF
;
1199 pLed
->BlinkingLedState
= LED_OFF
;
1200 mod_timer(&pLed
->BlinkTimer
,
1201 jiffies
+ msecs_to_jiffies(0));
1204 case LED_CTL_START_TO_LINK
:
1205 case LED_CTL_NO_LINK
:
1206 if (!IS_LED_BLINKING(pLed
)) {
1207 pLed
->CurrLedState
= LED_OFF
;
1208 pLed
->BlinkingLedState
= LED_OFF
;
1209 mod_timer(&pLed
->BlinkTimer
,
1210 jiffies
+ msecs_to_jiffies(0));
1213 case LED_CTL_POWER_OFF
:
1214 pLed
->CurrLedState
= LED_OFF
;
1215 pLed
->BlinkingLedState
= LED_OFF
;
1216 if (pLed
->bLedBlinkInProgress
) {
1217 del_timer_sync(&pLed
->BlinkTimer
);
1218 pLed
->bLedBlinkInProgress
= false;
1220 if (pLed
->bLedScanBlinkInProgress
) {
1221 del_timer_sync(&pLed
->BlinkTimer
);
1222 pLed
->bLedScanBlinkInProgress
= false;
1224 if (pLed
->bLedWPSBlinkInProgress
) {
1225 del_timer_sync(&pLed
->BlinkTimer
);
1226 pLed
->bLedWPSBlinkInProgress
= false;
1228 mod_timer(&pLed
->BlinkTimer
,
1229 jiffies
+ msecs_to_jiffies(0));
1236 static void SwLedControlMode3(struct _adapter
*padapter
,
1237 enum LED_CTL_MODE LedAction
)
1239 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1240 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1241 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1243 switch (LedAction
) {
1244 case LED_CTL_SITE_SURVEY
:
1245 if (pmlmepriv
->sitesurveyctrl
.traffic_busy
)
1246 ; /* dummy branch */
1247 else if (pLed
->bLedScanBlinkInProgress
== false) {
1248 if (IS_LED_WPS_BLINKING(pLed
))
1250 if (pLed
->bLedBlinkInProgress
== true) {
1251 del_timer_sync(&pLed
->BlinkTimer
);
1252 pLed
->bLedBlinkInProgress
= false;
1254 pLed
->bLedScanBlinkInProgress
= true;
1255 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1256 pLed
->BlinkTimes
= 24;
1258 pLed
->BlinkingLedState
= LED_OFF
;
1260 pLed
->BlinkingLedState
= LED_ON
;
1261 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1262 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1267 if ((pLed
->bLedBlinkInProgress
== false) &&
1268 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true)) {
1269 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1270 IS_LED_WPS_BLINKING(pLed
))
1272 pLed
->bLedBlinkInProgress
= true;
1273 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1274 pLed
->BlinkTimes
= 2;
1276 pLed
->BlinkingLedState
= LED_OFF
;
1278 pLed
->BlinkingLedState
= LED_ON
;
1279 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1280 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
1284 if (IS_LED_WPS_BLINKING(pLed
))
1286 pLed
->CurrLedState
= LED_ON
;
1287 pLed
->BlinkingLedState
= LED_ON
;
1288 if (pLed
->bLedBlinkInProgress
) {
1289 del_timer_sync(&pLed
->BlinkTimer
);
1290 pLed
->bLedBlinkInProgress
= false;
1292 if (pLed
->bLedScanBlinkInProgress
) {
1293 del_timer_sync(&pLed
->BlinkTimer
);
1294 pLed
->bLedScanBlinkInProgress
= false;
1296 mod_timer(&pLed
->BlinkTimer
,
1297 jiffies
+ msecs_to_jiffies(0));
1299 case LED_CTL_START_WPS
: /* wait until xinpin finish */
1300 case LED_CTL_START_WPS_BOTTON
:
1301 if (pLed
->bLedWPSBlinkInProgress
== false) {
1302 if (pLed
->bLedBlinkInProgress
== true) {
1303 del_timer_sync(&pLed
->BlinkTimer
);
1304 pLed
->bLedBlinkInProgress
= false;
1306 if (pLed
->bLedScanBlinkInProgress
== true) {
1307 del_timer_sync(&pLed
->BlinkTimer
);
1308 pLed
->bLedScanBlinkInProgress
= false;
1310 pLed
->bLedWPSBlinkInProgress
= true;
1311 pLed
->CurrLedState
= LED_BLINK_WPS
;
1313 pLed
->BlinkingLedState
= LED_OFF
;
1315 pLed
->BlinkingLedState
= LED_ON
;
1316 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1317 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1320 case LED_CTL_STOP_WPS
:
1321 if (pLed
->bLedWPSBlinkInProgress
) {
1322 del_timer_sync(&(pLed
->BlinkTimer
));
1323 pLed
->bLedWPSBlinkInProgress
= false;
1325 pLed
->bLedWPSBlinkInProgress
= true;
1326 pLed
->CurrLedState
= LED_BLINK_WPS_STOP
;
1328 pLed
->BlinkingLedState
= LED_OFF
;
1329 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1330 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
));
1332 pLed
->BlinkingLedState
= LED_ON
;
1333 mod_timer(&pLed
->BlinkTimer
,
1334 jiffies
+ msecs_to_jiffies(0));
1337 case LED_CTL_STOP_WPS_FAIL
:
1338 if (pLed
->bLedWPSBlinkInProgress
) {
1339 del_timer_sync(&pLed
->BlinkTimer
);
1340 pLed
->bLedWPSBlinkInProgress
= false;
1342 pLed
->CurrLedState
= LED_OFF
;
1343 pLed
->BlinkingLedState
= LED_OFF
;
1344 mod_timer(&pLed
->BlinkTimer
,
1345 jiffies
+ msecs_to_jiffies(0));
1347 case LED_CTL_START_TO_LINK
:
1348 case LED_CTL_NO_LINK
:
1349 if (!IS_LED_BLINKING(pLed
)) {
1350 pLed
->CurrLedState
= LED_OFF
;
1351 pLed
->BlinkingLedState
= LED_OFF
;
1352 mod_timer(&pLed
->BlinkTimer
,
1353 jiffies
+ msecs_to_jiffies(0));
1356 case LED_CTL_POWER_OFF
:
1357 pLed
->CurrLedState
= LED_OFF
;
1358 pLed
->BlinkingLedState
= LED_OFF
;
1359 if (pLed
->bLedBlinkInProgress
) {
1360 del_timer_sync(&pLed
->BlinkTimer
);
1361 pLed
->bLedBlinkInProgress
= false;
1363 if (pLed
->bLedScanBlinkInProgress
) {
1364 del_timer_sync(&pLed
->BlinkTimer
);
1365 pLed
->bLedScanBlinkInProgress
= false;
1367 if (pLed
->bLedWPSBlinkInProgress
) {
1368 del_timer_sync(&pLed
->BlinkTimer
);
1369 pLed
->bLedWPSBlinkInProgress
= false;
1371 mod_timer(&pLed
->BlinkTimer
,
1372 jiffies
+ msecs_to_jiffies(0));
1379 static void SwLedControlMode4(struct _adapter
*padapter
,
1380 enum LED_CTL_MODE LedAction
)
1382 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1383 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1384 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1385 struct LED_871x
*pLed1
= &(ledpriv
->SwLed1
);
1387 switch (LedAction
) {
1388 case LED_CTL_START_TO_LINK
:
1389 if (pLed1
->bLedWPSBlinkInProgress
) {
1390 pLed1
->bLedWPSBlinkInProgress
= false;
1391 del_timer_sync(&pLed1
->BlinkTimer
);
1392 pLed1
->BlinkingLedState
= LED_OFF
;
1393 pLed1
->CurrLedState
= LED_OFF
;
1395 mod_timer(&pLed
->BlinkTimer
,
1396 jiffies
+ msecs_to_jiffies(0));
1398 if (pLed
->bLedStartToLinkBlinkInProgress
== false) {
1399 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1400 IS_LED_WPS_BLINKING(pLed
))
1402 if (pLed
->bLedBlinkInProgress
== true) {
1403 del_timer_sync(&pLed
->BlinkTimer
);
1404 pLed
->bLedBlinkInProgress
= false;
1406 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1407 del_timer_sync(&pLed
->BlinkTimer
);
1408 pLed
->bLedNoLinkBlinkInProgress
= false;
1410 pLed
->bLedStartToLinkBlinkInProgress
= true;
1411 pLed
->CurrLedState
= LED_BLINK_StartToBlink
;
1413 pLed
->BlinkingLedState
= LED_OFF
;
1414 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1415 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL
));
1417 pLed
->BlinkingLedState
= LED_ON
;
1418 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1419 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
1424 case LED_CTL_NO_LINK
:
1426 if (LedAction
== LED_CTL_LINK
) {
1427 if (pLed1
->bLedWPSBlinkInProgress
) {
1428 pLed1
->bLedWPSBlinkInProgress
= false;
1429 del_timer_sync(&pLed1
->BlinkTimer
);
1430 pLed1
->BlinkingLedState
= LED_OFF
;
1431 pLed1
->CurrLedState
= LED_OFF
;
1433 mod_timer(&pLed
->BlinkTimer
,
1434 jiffies
+ msecs_to_jiffies(0));
1437 if (pLed
->bLedNoLinkBlinkInProgress
== false) {
1438 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1439 IS_LED_WPS_BLINKING(pLed
))
1441 if (pLed
->bLedBlinkInProgress
== true) {
1442 del_timer_sync(&pLed
->BlinkTimer
);
1443 pLed
->bLedBlinkInProgress
= false;
1445 pLed
->bLedNoLinkBlinkInProgress
= true;
1446 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1448 pLed
->BlinkingLedState
= LED_OFF
;
1450 pLed
->BlinkingLedState
= LED_ON
;
1451 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1452 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
1455 case LED_CTL_SITE_SURVEY
:
1456 if ((pmlmepriv
->sitesurveyctrl
.traffic_busy
) &&
1457 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true))
1459 else if (pLed
->bLedScanBlinkInProgress
== false) {
1460 if (IS_LED_WPS_BLINKING(pLed
))
1462 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1463 del_timer_sync(&pLed
->BlinkTimer
);
1464 pLed
->bLedNoLinkBlinkInProgress
= false;
1466 if (pLed
->bLedBlinkInProgress
== true) {
1467 del_timer_sync(&pLed
->BlinkTimer
);
1468 pLed
->bLedBlinkInProgress
= false;
1470 pLed
->bLedScanBlinkInProgress
= true;
1471 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1472 pLed
->BlinkTimes
= 24;
1474 pLed
->BlinkingLedState
= LED_OFF
;
1476 pLed
->BlinkingLedState
= LED_ON
;
1477 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1478 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1483 if (pLed
->bLedBlinkInProgress
== false) {
1484 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1485 IS_LED_WPS_BLINKING(pLed
))
1487 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1488 del_timer_sync(&pLed
->BlinkTimer
);
1489 pLed
->bLedNoLinkBlinkInProgress
= false;
1491 pLed
->bLedBlinkInProgress
= true;
1492 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1493 pLed
->BlinkTimes
= 2;
1495 pLed
->BlinkingLedState
= LED_OFF
;
1497 pLed
->BlinkingLedState
= LED_ON
;
1498 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1499 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
1502 case LED_CTL_START_WPS
: /*wait until xinpin finish*/
1503 case LED_CTL_START_WPS_BOTTON
:
1504 if (pLed1
->bLedWPSBlinkInProgress
) {
1505 pLed1
->bLedWPSBlinkInProgress
= false;
1506 del_timer_sync(&(pLed1
->BlinkTimer
));
1507 pLed1
->BlinkingLedState
= LED_OFF
;
1508 pLed1
->CurrLedState
= LED_OFF
;
1510 mod_timer(&pLed
->BlinkTimer
,
1511 jiffies
+ msecs_to_jiffies(0));
1513 if (pLed
->bLedWPSBlinkInProgress
== false) {
1514 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1515 del_timer_sync(&pLed
->BlinkTimer
);
1516 pLed
->bLedNoLinkBlinkInProgress
= false;
1518 if (pLed
->bLedBlinkInProgress
== true) {
1519 del_timer_sync(&pLed
->BlinkTimer
);
1520 pLed
->bLedBlinkInProgress
= false;
1522 if (pLed
->bLedScanBlinkInProgress
== true) {
1523 del_timer_sync(&pLed
->BlinkTimer
);
1524 pLed
->bLedScanBlinkInProgress
= false;
1526 pLed
->bLedWPSBlinkInProgress
= true;
1527 pLed
->CurrLedState
= LED_BLINK_WPS
;
1529 pLed
->BlinkingLedState
= LED_OFF
;
1530 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1531 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL
));
1533 pLed
->BlinkingLedState
= LED_ON
;
1534 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1535 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
1539 case LED_CTL_STOP_WPS
: /*WPS connect success*/
1540 if (pLed
->bLedWPSBlinkInProgress
) {
1541 del_timer_sync(&pLed
->BlinkTimer
);
1542 pLed
->bLedWPSBlinkInProgress
= false;
1544 pLed
->bLedNoLinkBlinkInProgress
= true;
1545 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1547 pLed
->BlinkingLedState
= LED_OFF
;
1549 pLed
->BlinkingLedState
= LED_ON
;
1550 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1551 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
1553 case LED_CTL_STOP_WPS_FAIL
: /*WPS authentication fail*/
1554 if (pLed
->bLedWPSBlinkInProgress
) {
1555 del_timer_sync(&pLed
->BlinkTimer
);
1556 pLed
->bLedWPSBlinkInProgress
= false;
1558 pLed
->bLedNoLinkBlinkInProgress
= true;
1559 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1561 pLed
->BlinkingLedState
= LED_OFF
;
1563 pLed
->BlinkingLedState
= LED_ON
;
1564 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1565 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
1567 if (pLed1
->bLedWPSBlinkInProgress
)
1568 del_timer_sync(&pLed1
->BlinkTimer
);
1570 pLed1
->bLedWPSBlinkInProgress
= true;
1571 pLed1
->CurrLedState
= LED_BLINK_WPS_STOP
;
1573 pLed1
->BlinkingLedState
= LED_OFF
;
1575 pLed1
->BlinkingLedState
= LED_ON
;
1576 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1577 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
1579 case LED_CTL_STOP_WPS_FAIL_OVERLAP
: /*WPS session overlap*/
1580 if (pLed
->bLedWPSBlinkInProgress
) {
1581 del_timer_sync(&pLed
->BlinkTimer
);
1582 pLed
->bLedWPSBlinkInProgress
= false;
1584 pLed
->bLedNoLinkBlinkInProgress
= true;
1585 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1587 pLed
->BlinkingLedState
= LED_OFF
;
1589 pLed
->BlinkingLedState
= LED_ON
;
1590 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1591 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA
));
1593 if (pLed1
->bLedWPSBlinkInProgress
)
1594 del_timer_sync(&pLed1
->BlinkTimer
);
1596 pLed1
->bLedWPSBlinkInProgress
= true;
1597 pLed1
->CurrLedState
= LED_BLINK_WPS_STOP_OVERLAP
;
1598 pLed1
->BlinkTimes
= 10;
1600 pLed1
->BlinkingLedState
= LED_OFF
;
1602 pLed1
->BlinkingLedState
= LED_ON
;
1603 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1604 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL
));
1606 case LED_CTL_POWER_OFF
:
1607 pLed
->CurrLedState
= LED_OFF
;
1608 pLed
->BlinkingLedState
= LED_OFF
;
1609 if (pLed
->bLedNoLinkBlinkInProgress
) {
1610 del_timer_sync(&pLed
->BlinkTimer
);
1611 pLed
->bLedNoLinkBlinkInProgress
= false;
1613 if (pLed
->bLedLinkBlinkInProgress
) {
1614 del_timer_sync(&pLed
->BlinkTimer
);
1615 pLed
->bLedLinkBlinkInProgress
= false;
1617 if (pLed
->bLedBlinkInProgress
) {
1618 del_timer_sync(&pLed
->BlinkTimer
);
1619 pLed
->bLedBlinkInProgress
= false;
1621 if (pLed
->bLedWPSBlinkInProgress
) {
1622 del_timer_sync(&pLed
->BlinkTimer
);
1623 pLed
->bLedWPSBlinkInProgress
= false;
1625 if (pLed
->bLedScanBlinkInProgress
) {
1626 del_timer_sync(&pLed
->BlinkTimer
);
1627 pLed
->bLedScanBlinkInProgress
= false;
1629 if (pLed
->bLedStartToLinkBlinkInProgress
) {
1630 del_timer_sync(&pLed
->BlinkTimer
);
1631 pLed
->bLedStartToLinkBlinkInProgress
= false;
1633 if (pLed1
->bLedWPSBlinkInProgress
) {
1634 del_timer_sync(&pLed1
->BlinkTimer
);
1635 pLed1
->bLedWPSBlinkInProgress
= false;
1637 pLed1
->BlinkingLedState
= LED_UNKNOWN
;
1638 SwLedOff(padapter
, pLed
);
1639 SwLedOff(padapter
, pLed1
);
1646 static void SwLedControlMode5(struct _adapter
*padapter
,
1647 enum LED_CTL_MODE LedAction
)
1649 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1650 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1651 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1653 if (padapter
->eeprompriv
.CustomerID
== RT_CID_819x_CAMEO
)
1654 pLed
= &(ledpriv
->SwLed1
);
1656 switch (LedAction
) {
1657 case LED_CTL_POWER_ON
:
1658 case LED_CTL_NO_LINK
:
1659 case LED_CTL_LINK
: /* solid blue */
1660 if (pLed
->CurrLedState
== LED_SCAN_BLINK
)
1662 pLed
->CurrLedState
= LED_ON
;
1663 pLed
->BlinkingLedState
= LED_ON
;
1664 pLed
->bLedBlinkInProgress
= false;
1665 mod_timer(&pLed
->BlinkTimer
,
1666 jiffies
+ msecs_to_jiffies(0));
1668 case LED_CTL_SITE_SURVEY
:
1669 if ((pmlmepriv
->sitesurveyctrl
.traffic_busy
) &&
1670 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true))
1671 ; /* dummy branch */
1672 else if (pLed
->bLedScanBlinkInProgress
== false) {
1673 if (pLed
->bLedBlinkInProgress
== true) {
1674 del_timer_sync(&pLed
->BlinkTimer
);
1675 pLed
->bLedBlinkInProgress
= false;
1677 pLed
->bLedScanBlinkInProgress
= true;
1678 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1679 pLed
->BlinkTimes
= 24;
1681 pLed
->BlinkingLedState
= LED_OFF
;
1683 pLed
->BlinkingLedState
= LED_ON
;
1684 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1685 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1690 if (pLed
->bLedBlinkInProgress
== false) {
1691 if (pLed
->CurrLedState
== LED_SCAN_BLINK
)
1693 pLed
->bLedBlinkInProgress
= true;
1694 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1695 pLed
->BlinkTimes
= 2;
1697 pLed
->BlinkingLedState
= LED_OFF
;
1699 pLed
->BlinkingLedState
= LED_ON
;
1700 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1701 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
1704 case LED_CTL_POWER_OFF
:
1705 pLed
->CurrLedState
= LED_OFF
;
1706 pLed
->BlinkingLedState
= LED_OFF
;
1707 if (pLed
->bLedBlinkInProgress
) {
1708 del_timer_sync(&pLed
->BlinkTimer
);
1709 pLed
->bLedBlinkInProgress
= false;
1711 SwLedOff(padapter
, pLed
);
1719 static void SwLedControlMode6(struct _adapter
*padapter
,
1720 enum LED_CTL_MODE LedAction
)
1722 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1723 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1724 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1726 switch (LedAction
) {
1727 case LED_CTL_POWER_ON
:
1728 case LED_CTL_NO_LINK
:
1729 case LED_CTL_LINK
: /*solid blue*/
1730 case LED_CTL_SITE_SURVEY
:
1731 if (IS_LED_WPS_BLINKING(pLed
))
1733 pLed
->CurrLedState
= LED_ON
;
1734 pLed
->BlinkingLedState
= LED_ON
;
1735 pLed
->bLedBlinkInProgress
= false;
1736 mod_timer(&(pLed
->BlinkTimer
), jiffies
+ msecs_to_jiffies(0));
1740 if (pLed
->bLedBlinkInProgress
== false &&
1741 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true)) {
1742 if (IS_LED_WPS_BLINKING(pLed
))
1744 pLed
->bLedBlinkInProgress
= true;
1745 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1746 pLed
->BlinkTimes
= 2;
1748 pLed
->BlinkingLedState
= LED_OFF
;
1750 pLed
->BlinkingLedState
= LED_ON
;
1751 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1752 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA
));
1755 case LED_CTL_START_WPS
: /*wait until xinpin finish*/
1756 case LED_CTL_START_WPS_BOTTON
:
1757 if (pLed
->bLedWPSBlinkInProgress
== false) {
1758 if (pLed
->bLedBlinkInProgress
== true) {
1759 del_timer_sync(&pLed
->BlinkTimer
);
1760 pLed
->bLedBlinkInProgress
= false;
1762 pLed
->bLedWPSBlinkInProgress
= true;
1763 pLed
->CurrLedState
= LED_BLINK_WPS
;
1765 pLed
->BlinkingLedState
= LED_OFF
;
1767 pLed
->BlinkingLedState
= LED_ON
;
1768 mod_timer(&pLed
->BlinkTimer
, jiffies
+
1769 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA
));
1772 case LED_CTL_STOP_WPS_FAIL
:
1773 case LED_CTL_STOP_WPS
:
1774 if (pLed
->bLedWPSBlinkInProgress
) {
1775 del_timer_sync(&pLed
->BlinkTimer
);
1776 pLed
->bLedWPSBlinkInProgress
= false;
1778 pLed
->CurrLedState
= LED_ON
;
1779 pLed
->BlinkingLedState
= LED_ON
;
1780 mod_timer(&pLed
->BlinkTimer
,
1781 jiffies
+ msecs_to_jiffies(0));
1783 case LED_CTL_POWER_OFF
:
1784 pLed
->CurrLedState
= LED_OFF
;
1785 pLed
->BlinkingLedState
= LED_OFF
;
1786 if (pLed
->bLedBlinkInProgress
) {
1787 del_timer_sync(&pLed
->BlinkTimer
);
1788 pLed
->bLedBlinkInProgress
= false;
1790 if (pLed
->bLedWPSBlinkInProgress
) {
1791 del_timer_sync(&pLed
->BlinkTimer
);
1792 pLed
->bLedWPSBlinkInProgress
= false;
1794 SwLedOff(padapter
, pLed
);
1802 * Dispatch LED action according to pHalData->LedStrategy.
1804 void LedControl871x(struct _adapter
*padapter
, enum LED_CTL_MODE LedAction
)
1806 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1808 if (ledpriv
->bRegUseLed
== false)
1810 switch (ledpriv
->LedStrategy
) {
1814 SwLedControlMode1(padapter
, LedAction
);
1817 SwLedControlMode2(padapter
, LedAction
);
1820 SwLedControlMode3(padapter
, LedAction
);
1823 SwLedControlMode4(padapter
, LedAction
);
1826 SwLedControlMode5(padapter
, LedAction
);
1829 SwLedControlMode6(padapter
, LedAction
);