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 _init_timer(&(pLed
->BlinkTimer
), nic
, BlinkTimerCallback
, pLed
);
101 _init_workitem(&(pLed
->BlinkWorkItem
), BlinkWorkItemCallback
, pLed
);
106 * DeInitialize an LED_871x object.
108 static void DeInitLed871x(struct LED_871x
*pLed
)
110 _cancel_timer_ex(&(pLed
->BlinkTimer
));
111 /* We should reset bLedBlinkInProgress if we cancel
112 * the LedControlTimer, */
113 pLed
->bLedBlinkInProgress
= false;
118 * Turn on LED according to LedPin specified.
120 static void SwLedOn(struct _adapter
*padapter
, struct LED_871x
*pLed
)
124 if ((padapter
->bSurpriseRemoved
== true) ||
125 (padapter
->bDriverStopped
== true))
127 LedCfg
= r8712_read8(padapter
, LEDCFG
);
128 switch (pLed
->LedPin
) {
132 /* SW control led0 on.*/
133 r8712_write8(padapter
, LEDCFG
, LedCfg
&0xf0);
136 /* SW control led1 on.*/
137 r8712_write8(padapter
, LEDCFG
, LedCfg
&0x0f);
147 * Turn off LED according to LedPin specified.
149 static void SwLedOff(struct _adapter
*padapter
, struct LED_871x
*pLed
)
153 if ((padapter
->bSurpriseRemoved
== true) ||
154 (padapter
->bDriverStopped
== true))
156 LedCfg
= r8712_read8(padapter
, LEDCFG
);
157 switch (pLed
->LedPin
) {
161 LedCfg
&= 0xf0; /* Set to software control.*/
162 r8712_write8(padapter
, LEDCFG
, (LedCfg
|BIT(3)));
165 LedCfg
&= 0x0f; /* Set to software control.*/
166 r8712_write8(padapter
, LEDCFG
, (LedCfg
|BIT(7)));
171 pLed
->bLedOn
= false;
174 /*===========================================================================
175 * Interface to manipulate LED objects.
176 *===========================================================================
179 * Initialize all LED_871x objects.
181 void r8712_InitSwLeds(struct _adapter
*padapter
)
183 struct led_priv
*pledpriv
= &(padapter
->ledpriv
);
185 pledpriv
->LedControlHandler
= LedControl871x
;
186 InitLed871x(padapter
, &(pledpriv
->SwLed0
), LED_PIN_LED0
);
187 InitLed871x(padapter
, &(pledpriv
->SwLed1
), LED_PIN_LED1
);
191 * DeInitialize all LED_819xUsb objects.
193 void r8712_DeInitSwLeds(struct _adapter
*padapter
)
195 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
197 DeInitLed871x(&(ledpriv
->SwLed0
));
198 DeInitLed871x(&(ledpriv
->SwLed1
));
202 * Implementation of LED blinking behavior.
203 * It toggle off LED and schedule corresponding timer if necessary.
205 static void SwLedBlink(struct LED_871x
*pLed
)
207 struct _adapter
*padapter
= pLed
->padapter
;
208 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
209 u8 bStopBlinking
= false;
211 /* Change LED according to BlinkingLedState specified. */
212 if (pLed
->BlinkingLedState
== LED_ON
)
213 SwLedOn(padapter
, pLed
);
215 SwLedOff(padapter
, pLed
);
216 /* Determine if we shall change LED state again. */
218 switch (pLed
->CurrLedState
) {
219 case LED_BLINK_NORMAL
:
220 if (pLed
->BlinkTimes
== 0)
221 bStopBlinking
= true;
223 case LED_BLINK_StartToBlink
:
224 if ((check_fwstate(pmlmepriv
, _FW_LINKED
) == true) &&
225 (pmlmepriv
->fw_state
& WIFI_STATION_STATE
))
226 bStopBlinking
= true;
227 if ((check_fwstate(pmlmepriv
, _FW_LINKED
) == true) &&
228 ((pmlmepriv
->fw_state
& WIFI_ADHOC_STATE
) ||
229 (pmlmepriv
->fw_state
& WIFI_ADHOC_MASTER_STATE
)))
230 bStopBlinking
= true;
231 else if (pLed
->BlinkTimes
== 0)
232 bStopBlinking
= true;
235 if (pLed
->BlinkTimes
== 0)
236 bStopBlinking
= true;
239 bStopBlinking
= true;
243 if ((check_fwstate(pmlmepriv
, _FW_LINKED
) == true) &&
244 (pLed
->bLedOn
== false))
245 SwLedOn(padapter
, pLed
);
246 else if ((check_fwstate(pmlmepriv
, _FW_LINKED
) ==
247 true) && pLed
->bLedOn
== true)
248 SwLedOff(padapter
, pLed
);
249 pLed
->BlinkTimes
= 0;
250 pLed
->bLedBlinkInProgress
= false;
252 /* Assign LED state to toggle. */
253 if (pLed
->BlinkingLedState
== LED_ON
)
254 pLed
->BlinkingLedState
= LED_OFF
;
256 pLed
->BlinkingLedState
= LED_ON
;
258 /* Schedule a timer to toggle LED state. */
259 switch (pLed
->CurrLedState
) {
260 case LED_BLINK_NORMAL
:
261 _set_timer(&(pLed
->BlinkTimer
),
262 LED_BLINK_NORMAL_INTERVAL
);
264 case LED_BLINK_SLOWLY
:
265 case LED_BLINK_StartToBlink
:
266 _set_timer(&(pLed
->BlinkTimer
),
267 LED_BLINK_SLOWLY_INTERVAL
);
270 _set_timer(&(pLed
->BlinkTimer
),
271 LED_BLINK_LONG_INTERVAL
);
274 _set_timer(&(pLed
->BlinkTimer
),
275 LED_BLINK_SLOWLY_INTERVAL
);
281 static void SwLedBlink1(struct LED_871x
*pLed
)
283 struct _adapter
*padapter
= pLed
->padapter
;
284 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
285 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
286 struct eeprom_priv
*peeprompriv
= &(padapter
->eeprompriv
);
287 struct LED_871x
*pLed1
= &(ledpriv
->SwLed1
);
288 u8 bStopBlinking
= false;
290 if (peeprompriv
->CustomerID
== RT_CID_819x_CAMEO
)
291 pLed
= &(ledpriv
->SwLed1
);
292 /* Change LED according to BlinkingLedState specified. */
293 if (pLed
->BlinkingLedState
== LED_ON
)
294 SwLedOn(padapter
, pLed
);
296 SwLedOff(padapter
, pLed
);
297 if (peeprompriv
->CustomerID
== RT_CID_DEFAULT
) {
298 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
299 if (!pLed1
->bSWLedCtrl
) {
300 SwLedOn(padapter
, pLed1
);
301 pLed1
->bSWLedCtrl
= true;
302 } else if (!pLed1
->bLedOn
)
303 SwLedOn(padapter
, pLed1
);
305 if (!pLed1
->bSWLedCtrl
) {
306 SwLedOff(padapter
, pLed1
);
307 pLed1
->bSWLedCtrl
= true;
308 } else if (pLed1
->bLedOn
)
309 SwLedOff(padapter
, pLed1
);
312 switch (pLed
->CurrLedState
) {
313 case LED_BLINK_SLOWLY
:
315 pLed
->BlinkingLedState
= LED_OFF
;
317 pLed
->BlinkingLedState
= LED_ON
;
318 _set_timer(&(pLed
->BlinkTimer
),
319 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
321 case LED_BLINK_NORMAL
:
323 pLed
->BlinkingLedState
= LED_OFF
;
325 pLed
->BlinkingLedState
= LED_ON
;
326 _set_timer(&(pLed
->BlinkTimer
),
327 LED_BLINK_LINK_INTERVAL_ALPHA
);
331 if (pLed
->BlinkTimes
== 0)
332 bStopBlinking
= true;
334 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
335 pLed
->bLedLinkBlinkInProgress
= true;
336 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
338 pLed
->BlinkingLedState
= LED_OFF
;
340 pLed
->BlinkingLedState
= LED_ON
;
341 _set_timer(&(pLed
->BlinkTimer
),
342 LED_BLINK_LINK_INTERVAL_ALPHA
);
343 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
344 pLed
->bLedNoLinkBlinkInProgress
= true;
345 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
347 pLed
->BlinkingLedState
= LED_OFF
;
349 pLed
->BlinkingLedState
= LED_ON
;
350 _set_timer(&(pLed
->BlinkTimer
),
351 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
353 pLed
->bLedScanBlinkInProgress
= false;
356 pLed
->BlinkingLedState
= LED_OFF
;
358 pLed
->BlinkingLedState
= LED_ON
;
359 _set_timer(&(pLed
->BlinkTimer
),
360 LED_BLINK_SCAN_INTERVAL_ALPHA
);
365 if (pLed
->BlinkTimes
== 0)
366 bStopBlinking
= true;
368 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
369 pLed
->bLedLinkBlinkInProgress
= true;
370 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
372 pLed
->BlinkingLedState
= LED_OFF
;
374 pLed
->BlinkingLedState
= LED_ON
;
375 _set_timer(&(pLed
->BlinkTimer
),
376 LED_BLINK_LINK_INTERVAL_ALPHA
);
377 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
378 pLed
->bLedNoLinkBlinkInProgress
= true;
379 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
381 pLed
->BlinkingLedState
= LED_OFF
;
383 pLed
->BlinkingLedState
= LED_ON
;
384 _set_timer(&(pLed
->BlinkTimer
),
385 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
387 pLed
->BlinkTimes
= 0;
388 pLed
->bLedBlinkInProgress
= false;
391 pLed
->BlinkingLedState
= LED_OFF
;
393 pLed
->BlinkingLedState
= LED_ON
;
394 _set_timer(&(pLed
->BlinkTimer
),
395 LED_BLINK_FASTER_INTERVAL_ALPHA
);
400 pLed
->BlinkingLedState
= LED_OFF
;
402 pLed
->BlinkingLedState
= LED_ON
;
403 _set_timer(&(pLed
->BlinkTimer
),
404 LED_BLINK_SCAN_INTERVAL_ALPHA
);
406 case LED_BLINK_WPS_STOP
: /* WPS success */
407 if (pLed
->BlinkingLedState
== LED_ON
) {
408 pLed
->BlinkingLedState
= LED_OFF
;
409 _set_timer(&(pLed
->BlinkTimer
),
410 LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
);
411 bStopBlinking
= false;
413 bStopBlinking
= true;
415 pLed
->bLedLinkBlinkInProgress
= true;
416 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
418 pLed
->BlinkingLedState
= LED_OFF
;
420 pLed
->BlinkingLedState
= LED_ON
;
421 _set_timer(&(pLed
->BlinkTimer
),
422 LED_BLINK_LINK_INTERVAL_ALPHA
);
424 pLed
->bLedWPSBlinkInProgress
= false;
431 static void SwLedBlink2(struct LED_871x
*pLed
)
433 struct _adapter
*padapter
= pLed
->padapter
;
434 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
435 u8 bStopBlinking
= false;
437 /* Change LED according to BlinkingLedState specified. */
438 if (pLed
->BlinkingLedState
== LED_ON
)
439 SwLedOn(padapter
, pLed
);
441 SwLedOff(padapter
, pLed
);
442 switch (pLed
->CurrLedState
) {
445 if (pLed
->BlinkTimes
== 0)
446 bStopBlinking
= true;
448 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
449 pLed
->CurrLedState
= LED_ON
;
450 pLed
->BlinkingLedState
= LED_ON
;
451 SwLedOn(padapter
, pLed
);
452 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
453 pLed
->CurrLedState
= LED_OFF
;
454 pLed
->BlinkingLedState
= LED_OFF
;
455 SwLedOff(padapter
, pLed
);
457 pLed
->bLedScanBlinkInProgress
= false;
460 pLed
->BlinkingLedState
= LED_OFF
;
462 pLed
->BlinkingLedState
= LED_ON
;
463 _set_timer(&(pLed
->BlinkTimer
),
464 LED_BLINK_SCAN_INTERVAL_ALPHA
);
469 if (pLed
->BlinkTimes
== 0)
470 bStopBlinking
= true;
472 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
473 pLed
->CurrLedState
= LED_ON
;
474 pLed
->BlinkingLedState
= LED_ON
;
475 SwLedOn(padapter
, pLed
);
476 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
477 pLed
->CurrLedState
= LED_OFF
;
478 pLed
->BlinkingLedState
= LED_OFF
;
479 SwLedOff(padapter
, pLed
);
481 pLed
->bLedBlinkInProgress
= false;
484 pLed
->BlinkingLedState
= LED_OFF
;
486 pLed
->BlinkingLedState
= LED_ON
;
487 _set_timer(&(pLed
->BlinkTimer
),
488 LED_BLINK_FASTER_INTERVAL_ALPHA
);
496 static void SwLedBlink3(struct LED_871x
*pLed
)
498 struct _adapter
*padapter
= pLed
->padapter
;
499 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
500 u8 bStopBlinking
= false;
502 /* Change LED according to BlinkingLedState specified. */
503 if (pLed
->BlinkingLedState
== LED_ON
)
504 SwLedOn(padapter
, pLed
);
506 if (pLed
->CurrLedState
!= LED_BLINK_WPS_STOP
)
507 SwLedOff(padapter
, pLed
);
508 switch (pLed
->CurrLedState
) {
511 if (pLed
->BlinkTimes
== 0)
512 bStopBlinking
= true;
514 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
515 pLed
->CurrLedState
= LED_ON
;
516 pLed
->BlinkingLedState
= LED_ON
;
518 SwLedOn(padapter
, pLed
);
519 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
520 pLed
->CurrLedState
= LED_OFF
;
521 pLed
->BlinkingLedState
= LED_OFF
;
523 SwLedOff(padapter
, pLed
);
525 pLed
->bLedScanBlinkInProgress
= false;
528 pLed
->BlinkingLedState
= LED_OFF
;
530 pLed
->BlinkingLedState
= LED_ON
;
531 _set_timer(&(pLed
->BlinkTimer
),
532 LED_BLINK_SCAN_INTERVAL_ALPHA
);
537 if (pLed
->BlinkTimes
== 0)
538 bStopBlinking
= true;
540 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
541 pLed
->CurrLedState
= LED_ON
;
542 pLed
->BlinkingLedState
= LED_ON
;
544 SwLedOn(padapter
, pLed
);
545 } else if (!check_fwstate(pmlmepriv
, _FW_LINKED
)) {
546 pLed
->CurrLedState
= LED_OFF
;
547 pLed
->BlinkingLedState
= LED_OFF
;
549 SwLedOff(padapter
, pLed
);
551 pLed
->bLedBlinkInProgress
= false;
554 pLed
->BlinkingLedState
= LED_OFF
;
556 pLed
->BlinkingLedState
= LED_ON
;
557 _set_timer(&(pLed
->BlinkTimer
),
558 LED_BLINK_FASTER_INTERVAL_ALPHA
);
563 pLed
->BlinkingLedState
= LED_OFF
;
565 pLed
->BlinkingLedState
= LED_ON
;
566 _set_timer(&(pLed
->BlinkTimer
),
567 LED_BLINK_SCAN_INTERVAL_ALPHA
);
569 case LED_BLINK_WPS_STOP
: /*WPS success*/
570 if (pLed
->BlinkingLedState
== LED_ON
) {
571 pLed
->BlinkingLedState
= LED_OFF
;
572 _set_timer(&(pLed
->BlinkTimer
),
573 LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
);
574 bStopBlinking
= false;
576 bStopBlinking
= true;
578 pLed
->CurrLedState
= LED_ON
;
579 pLed
->BlinkingLedState
= LED_ON
;
580 SwLedOn(padapter
, pLed
);
581 pLed
->bLedWPSBlinkInProgress
= false;
589 static void SwLedBlink4(struct LED_871x
*pLed
)
591 struct _adapter
*padapter
= pLed
->padapter
;
592 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
593 struct LED_871x
*pLed1
= &(ledpriv
->SwLed1
);
594 u8 bStopBlinking
= false;
596 /* Change LED according to BlinkingLedState specified. */
597 if (pLed
->BlinkingLedState
== LED_ON
)
598 SwLedOn(padapter
, pLed
);
600 SwLedOff(padapter
, pLed
);
601 if (!pLed1
->bLedWPSBlinkInProgress
&&
602 pLed1
->BlinkingLedState
== LED_UNKNOWN
) {
603 pLed1
->BlinkingLedState
= LED_OFF
;
604 pLed1
->CurrLedState
= LED_OFF
;
605 SwLedOff(padapter
, pLed1
);
607 switch (pLed
->CurrLedState
) {
608 case LED_BLINK_SLOWLY
:
610 pLed
->BlinkingLedState
= LED_OFF
;
612 pLed
->BlinkingLedState
= LED_ON
;
613 _set_timer(&(pLed
->BlinkTimer
),
614 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
616 case LED_BLINK_StartToBlink
:
618 pLed
->BlinkingLedState
= LED_OFF
;
619 _set_timer(&(pLed
->BlinkTimer
),
620 LED_BLINK_SLOWLY_INTERVAL
);
622 pLed
->BlinkingLedState
= LED_ON
;
623 _set_timer(&(pLed
->BlinkTimer
),
624 LED_BLINK_NORMAL_INTERVAL
);
629 if (pLed
->BlinkTimes
== 0)
630 bStopBlinking
= true;
632 pLed
->bLedNoLinkBlinkInProgress
= true;
633 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
635 pLed
->BlinkingLedState
= LED_OFF
;
637 pLed
->BlinkingLedState
= LED_ON
;
638 _set_timer(&(pLed
->BlinkTimer
),
639 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
640 pLed
->bLedScanBlinkInProgress
= false;
643 pLed
->BlinkingLedState
= LED_OFF
;
645 pLed
->BlinkingLedState
= LED_ON
;
646 _set_timer(&(pLed
->BlinkTimer
),
647 LED_BLINK_SCAN_INTERVAL_ALPHA
);
652 if (pLed
->BlinkTimes
== 0)
653 bStopBlinking
= true;
655 pLed
->bLedNoLinkBlinkInProgress
= true;
656 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
658 pLed
->BlinkingLedState
= LED_OFF
;
660 pLed
->BlinkingLedState
= LED_ON
;
661 _set_timer(&(pLed
->BlinkTimer
),
662 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
663 pLed
->bLedBlinkInProgress
= false;
666 pLed
->BlinkingLedState
= LED_OFF
;
668 pLed
->BlinkingLedState
= LED_ON
;
669 _set_timer(&(pLed
->BlinkTimer
),
670 LED_BLINK_FASTER_INTERVAL_ALPHA
);
675 pLed
->BlinkingLedState
= LED_OFF
;
676 _set_timer(&(pLed
->BlinkTimer
),
677 LED_BLINK_SLOWLY_INTERVAL
);
679 pLed
->BlinkingLedState
= LED_ON
;
680 _set_timer(&(pLed
->BlinkTimer
),
681 LED_BLINK_NORMAL_INTERVAL
);
684 case LED_BLINK_WPS_STOP
: /*WPS authentication fail*/
686 pLed
->BlinkingLedState
= LED_OFF
;
688 pLed
->BlinkingLedState
= LED_ON
;
689 _set_timer(&(pLed
->BlinkTimer
), LED_BLINK_NORMAL_INTERVAL
);
691 case LED_BLINK_WPS_STOP_OVERLAP
: /*WPS session overlap */
693 if (pLed
->BlinkTimes
== 0) {
695 pLed
->BlinkTimes
= 1;
697 bStopBlinking
= true;
700 pLed
->BlinkTimes
= 10;
701 pLed
->BlinkingLedState
= LED_ON
;
702 _set_timer(&(pLed
->BlinkTimer
),
703 LED_BLINK_LINK_INTERVAL_ALPHA
);
706 pLed
->BlinkingLedState
= LED_OFF
;
708 pLed
->BlinkingLedState
= LED_ON
;
709 _set_timer(&(pLed
->BlinkTimer
),
710 LED_BLINK_NORMAL_INTERVAL
);
718 static void SwLedBlink5(struct LED_871x
*pLed
)
720 struct _adapter
*padapter
= pLed
->padapter
;
721 u8 bStopBlinking
= false;
723 /* Change LED according to BlinkingLedState specified. */
724 if (pLed
->BlinkingLedState
== LED_ON
)
725 SwLedOn(padapter
, pLed
);
727 SwLedOff(padapter
, pLed
);
728 switch (pLed
->CurrLedState
) {
731 if (pLed
->BlinkTimes
== 0)
732 bStopBlinking
= true;
734 pLed
->CurrLedState
= LED_ON
;
735 pLed
->BlinkingLedState
= LED_ON
;
737 _set_timer(&(pLed
->BlinkTimer
),
738 LED_BLINK_FASTER_INTERVAL_ALPHA
);
739 pLed
->bLedScanBlinkInProgress
= false;
742 pLed
->BlinkingLedState
= LED_OFF
;
744 pLed
->BlinkingLedState
= LED_ON
;
745 _set_timer(&(pLed
->BlinkTimer
),
746 LED_BLINK_SCAN_INTERVAL_ALPHA
);
751 if (pLed
->BlinkTimes
== 0)
752 bStopBlinking
= true;
754 pLed
->CurrLedState
= LED_ON
;
755 pLed
->BlinkingLedState
= LED_ON
;
757 _set_timer(&(pLed
->BlinkTimer
),
758 LED_BLINK_FASTER_INTERVAL_ALPHA
);
759 pLed
->bLedBlinkInProgress
= false;
762 pLed
->BlinkingLedState
= LED_OFF
;
764 pLed
->BlinkingLedState
= LED_ON
;
765 _set_timer(&(pLed
->BlinkTimer
),
766 LED_BLINK_FASTER_INTERVAL_ALPHA
);
774 static void SwLedBlink6(struct LED_871x
*pLed
)
776 struct _adapter
*padapter
= pLed
->padapter
;
777 u8 bStopBlinking
= false;
779 /* Change LED according to BlinkingLedState specified. */
780 if (pLed
->BlinkingLedState
== LED_ON
)
781 SwLedOn(padapter
, pLed
);
783 SwLedOff(padapter
, pLed
);
784 switch (pLed
->CurrLedState
) {
787 if (pLed
->BlinkTimes
== 0)
788 bStopBlinking
= true;
790 pLed
->CurrLedState
= LED_ON
;
791 pLed
->BlinkingLedState
= LED_ON
;
793 SwLedOn(padapter
, pLed
);
794 pLed
->bLedBlinkInProgress
= false;
797 pLed
->BlinkingLedState
= LED_OFF
;
799 pLed
->BlinkingLedState
= LED_ON
;
800 _set_timer(&(pLed
->BlinkTimer
),
801 LED_BLINK_FASTER_INTERVAL_ALPHA
);
806 pLed
->BlinkingLedState
= LED_OFF
;
808 pLed
->BlinkingLedState
= LED_ON
;
809 _set_timer(&(pLed
->BlinkTimer
), LED_BLINK_SCAN_INTERVAL_ALPHA
);
818 * Callback function of LED BlinkTimer,
819 * it just schedules to corresponding BlinkWorkItem.
821 static void BlinkTimerCallback(unsigned long data
)
823 struct LED_871x
*pLed
= (struct LED_871x
*)data
;
825 /* This fixed the crash problem on Fedora 12 when trying to do the
826 * insmod;ifconfig up;rmmod commands. */
827 if ((pLed
->padapter
->bSurpriseRemoved
== true) ||
828 (pLed
->padapter
->bDriverStopped
== true))
830 _set_workitem(&(pLed
->BlinkWorkItem
));
834 * Callback function of LED BlinkWorkItem.
835 * We dispatch actual LED blink action according to LedStrategy.
837 static void BlinkWorkItemCallback(struct work_struct
*work
)
839 struct LED_871x
*pLed
= container_of(work
, struct LED_871x
,
841 struct led_priv
*ledpriv
= &(pLed
->padapter
->ledpriv
);
843 switch (ledpriv
->LedStrategy
) {
871 /*============================================================================
872 * Default LED behavior.
873 *============================================================================
876 * Implement each led action for SW_LED_MODE0.
877 * This is default strategy.
880 static void SwLedControlMode1(struct _adapter
*padapter
,
881 enum LED_CTL_MODE LedAction
)
883 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
884 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
885 struct mlme_priv
*pmlmepriv
= &(padapter
->mlmepriv
);
886 struct sitesurvey_ctrl
*psitesurveyctrl
= &(pmlmepriv
->sitesurveyctrl
);
888 if (padapter
->eeprompriv
.CustomerID
== RT_CID_819x_CAMEO
)
889 pLed
= &(ledpriv
->SwLed1
);
891 case LED_CTL_START_TO_LINK
:
892 case LED_CTL_NO_LINK
:
893 if (pLed
->bLedNoLinkBlinkInProgress
== false) {
894 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
895 IS_LED_WPS_BLINKING(pLed
))
897 if (pLed
->bLedLinkBlinkInProgress
== true) {
898 _cancel_timer_ex(&(pLed
->BlinkTimer
));
899 pLed
->bLedLinkBlinkInProgress
= false;
901 if (pLed
->bLedBlinkInProgress
== true) {
902 _cancel_timer_ex(&(pLed
->BlinkTimer
));
903 pLed
->bLedBlinkInProgress
= false;
905 pLed
->bLedNoLinkBlinkInProgress
= true;
906 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
908 pLed
->BlinkingLedState
= LED_OFF
;
910 pLed
->BlinkingLedState
= LED_ON
;
911 _set_timer(&(pLed
->BlinkTimer
),
912 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
916 if (pLed
->bLedLinkBlinkInProgress
== false) {
917 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
918 IS_LED_WPS_BLINKING(pLed
))
920 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
921 _cancel_timer_ex(&(pLed
->BlinkTimer
));
922 pLed
->bLedNoLinkBlinkInProgress
= false;
924 if (pLed
->bLedBlinkInProgress
== true) {
925 _cancel_timer_ex(&(pLed
->BlinkTimer
));
926 pLed
->bLedBlinkInProgress
= false;
928 pLed
->bLedLinkBlinkInProgress
= true;
929 pLed
->CurrLedState
= LED_BLINK_NORMAL
;
931 pLed
->BlinkingLedState
= LED_OFF
;
933 pLed
->BlinkingLedState
= LED_ON
;
934 _set_timer(&(pLed
->BlinkTimer
),
935 LED_BLINK_LINK_INTERVAL_ALPHA
);
938 case LED_CTL_SITE_SURVEY
:
939 if ((psitesurveyctrl
->traffic_busy
) &&
940 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true))
942 else if (pLed
->bLedScanBlinkInProgress
== false) {
943 if (IS_LED_WPS_BLINKING(pLed
))
945 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
946 _cancel_timer_ex(&(pLed
->BlinkTimer
));
947 pLed
->bLedNoLinkBlinkInProgress
= false;
949 if (pLed
->bLedLinkBlinkInProgress
== true) {
950 _cancel_timer_ex(&(pLed
->BlinkTimer
));
951 pLed
->bLedLinkBlinkInProgress
= false;
953 if (pLed
->bLedBlinkInProgress
== true) {
954 _cancel_timer_ex(&(pLed
->BlinkTimer
));
955 pLed
->bLedBlinkInProgress
= false;
957 pLed
->bLedScanBlinkInProgress
= true;
958 pLed
->CurrLedState
= LED_SCAN_BLINK
;
959 pLed
->BlinkTimes
= 24;
961 pLed
->BlinkingLedState
= LED_OFF
;
963 pLed
->BlinkingLedState
= LED_ON
;
964 _set_timer(&(pLed
->BlinkTimer
),
965 LED_BLINK_SCAN_INTERVAL_ALPHA
);
970 if (pLed
->bLedBlinkInProgress
== false) {
971 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
972 IS_LED_WPS_BLINKING(pLed
))
974 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
975 _cancel_timer_ex(&(pLed
->BlinkTimer
));
976 pLed
->bLedNoLinkBlinkInProgress
= false;
978 if (pLed
->bLedLinkBlinkInProgress
== true) {
979 _cancel_timer_ex(&(pLed
->BlinkTimer
));
980 pLed
->bLedLinkBlinkInProgress
= false;
982 pLed
->bLedBlinkInProgress
= true;
983 pLed
->CurrLedState
= LED_TXRX_BLINK
;
984 pLed
->BlinkTimes
= 2;
986 pLed
->BlinkingLedState
= LED_OFF
;
988 pLed
->BlinkingLedState
= LED_ON
;
989 _set_timer(&(pLed
->BlinkTimer
),
990 LED_BLINK_FASTER_INTERVAL_ALPHA
);
994 case LED_CTL_START_WPS
: /*wait until xinpin finish */
995 case LED_CTL_START_WPS_BOTTON
:
996 if (pLed
->bLedWPSBlinkInProgress
== false) {
997 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
998 _cancel_timer_ex(&(pLed
->BlinkTimer
));
999 pLed
->bLedNoLinkBlinkInProgress
= false;
1001 if (pLed
->bLedLinkBlinkInProgress
== true) {
1002 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1003 pLed
->bLedLinkBlinkInProgress
= false;
1005 if (pLed
->bLedBlinkInProgress
== true) {
1006 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1007 pLed
->bLedBlinkInProgress
= false;
1009 if (pLed
->bLedScanBlinkInProgress
== true) {
1010 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1011 pLed
->bLedScanBlinkInProgress
= false;
1013 pLed
->bLedWPSBlinkInProgress
= true;
1014 pLed
->CurrLedState
= LED_BLINK_WPS
;
1016 pLed
->BlinkingLedState
= LED_OFF
;
1018 pLed
->BlinkingLedState
= LED_ON
;
1019 _set_timer(&(pLed
->BlinkTimer
),
1020 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1023 case LED_CTL_STOP_WPS
:
1024 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1025 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1026 pLed
->bLedNoLinkBlinkInProgress
= false;
1028 if (pLed
->bLedLinkBlinkInProgress
== true) {
1029 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1030 pLed
->bLedLinkBlinkInProgress
= false;
1032 if (pLed
->bLedBlinkInProgress
== true) {
1033 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1034 pLed
->bLedBlinkInProgress
= false;
1036 if (pLed
->bLedScanBlinkInProgress
== true) {
1037 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1038 pLed
->bLedScanBlinkInProgress
= false;
1040 if (pLed
->bLedWPSBlinkInProgress
)
1041 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1043 pLed
->bLedWPSBlinkInProgress
= true;
1044 pLed
->CurrLedState
= LED_BLINK_WPS_STOP
;
1046 pLed
->BlinkingLedState
= LED_OFF
;
1047 _set_timer(&(pLed
->BlinkTimer
),
1048 LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
);
1050 pLed
->BlinkingLedState
= LED_ON
;
1051 _set_timer(&(pLed
->BlinkTimer
), 0);
1054 case LED_CTL_STOP_WPS_FAIL
:
1055 if (pLed
->bLedWPSBlinkInProgress
) {
1056 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1057 pLed
->bLedWPSBlinkInProgress
= false;
1059 pLed
->bLedNoLinkBlinkInProgress
= true;
1060 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1062 pLed
->BlinkingLedState
= LED_OFF
;
1064 pLed
->BlinkingLedState
= LED_ON
;
1065 _set_timer(&(pLed
->BlinkTimer
),
1066 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
1068 case LED_CTL_POWER_OFF
:
1069 pLed
->CurrLedState
= LED_OFF
;
1070 pLed
->BlinkingLedState
= LED_OFF
;
1071 if (pLed
->bLedNoLinkBlinkInProgress
) {
1072 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1073 pLed
->bLedNoLinkBlinkInProgress
= false;
1075 if (pLed
->bLedLinkBlinkInProgress
) {
1076 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1077 pLed
->bLedLinkBlinkInProgress
= false;
1079 if (pLed
->bLedBlinkInProgress
) {
1080 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1081 pLed
->bLedBlinkInProgress
= false;
1083 if (pLed
->bLedWPSBlinkInProgress
) {
1084 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1085 pLed
->bLedWPSBlinkInProgress
= false;
1087 if (pLed
->bLedScanBlinkInProgress
) {
1088 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1089 pLed
->bLedScanBlinkInProgress
= false;
1091 _set_timer(&(pLed
->BlinkTimer
), 0);
1098 static void SwLedControlMode2(struct _adapter
*padapter
,
1099 enum LED_CTL_MODE LedAction
)
1101 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1102 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1103 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1105 switch (LedAction
) {
1106 case LED_CTL_SITE_SURVEY
:
1107 if (pmlmepriv
->sitesurveyctrl
.traffic_busy
)
1108 ; /* dummy branch */
1109 else if (pLed
->bLedScanBlinkInProgress
== false) {
1110 if (IS_LED_WPS_BLINKING(pLed
))
1113 if (pLed
->bLedBlinkInProgress
== true) {
1114 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1115 pLed
->bLedBlinkInProgress
= false;
1117 pLed
->bLedScanBlinkInProgress
= true;
1118 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1119 pLed
->BlinkTimes
= 24;
1121 pLed
->BlinkingLedState
= LED_OFF
;
1123 pLed
->BlinkingLedState
= LED_ON
;
1124 _set_timer(&(pLed
->BlinkTimer
),
1125 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1131 if ((pLed
->bLedBlinkInProgress
== false) &&
1132 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true)) {
1133 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1134 IS_LED_WPS_BLINKING(pLed
))
1136 pLed
->bLedBlinkInProgress
= true;
1137 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1138 pLed
->BlinkTimes
= 2;
1140 pLed
->BlinkingLedState
= LED_OFF
;
1142 pLed
->BlinkingLedState
= LED_ON
;
1143 _set_timer(&(pLed
->BlinkTimer
),
1144 LED_BLINK_FASTER_INTERVAL_ALPHA
);
1149 pLed
->CurrLedState
= LED_ON
;
1150 pLed
->BlinkingLedState
= LED_ON
;
1151 if (pLed
->bLedBlinkInProgress
) {
1152 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1153 pLed
->bLedBlinkInProgress
= false;
1155 if (pLed
->bLedScanBlinkInProgress
) {
1156 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1157 pLed
->bLedScanBlinkInProgress
= false;
1160 _set_timer(&(pLed
->BlinkTimer
), 0);
1163 case LED_CTL_START_WPS
: /*wait until xinpin finish*/
1164 case LED_CTL_START_WPS_BOTTON
:
1165 if (pLed
->bLedWPSBlinkInProgress
== false) {
1166 if (pLed
->bLedBlinkInProgress
== true) {
1167 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1168 pLed
->bLedBlinkInProgress
= false;
1170 if (pLed
->bLedScanBlinkInProgress
== true) {
1171 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1172 pLed
->bLedScanBlinkInProgress
= false;
1174 pLed
->bLedWPSBlinkInProgress
= true;
1175 pLed
->CurrLedState
= LED_ON
;
1176 pLed
->BlinkingLedState
= LED_ON
;
1177 _set_timer(&(pLed
->BlinkTimer
), 0);
1181 case LED_CTL_STOP_WPS
:
1182 pLed
->bLedWPSBlinkInProgress
= false;
1183 pLed
->CurrLedState
= LED_ON
;
1184 pLed
->BlinkingLedState
= LED_ON
;
1185 _set_timer(&(pLed
->BlinkTimer
), 0);
1188 case LED_CTL_STOP_WPS_FAIL
:
1189 pLed
->bLedWPSBlinkInProgress
= false;
1190 pLed
->CurrLedState
= LED_OFF
;
1191 pLed
->BlinkingLedState
= LED_OFF
;
1192 _set_timer(&(pLed
->BlinkTimer
), 0);
1195 case LED_CTL_START_TO_LINK
:
1196 case LED_CTL_NO_LINK
:
1197 if (!IS_LED_BLINKING(pLed
)) {
1198 pLed
->CurrLedState
= LED_OFF
;
1199 pLed
->BlinkingLedState
= LED_OFF
;
1200 _set_timer(&(pLed
->BlinkTimer
), 0);
1203 case LED_CTL_POWER_OFF
:
1204 pLed
->CurrLedState
= LED_OFF
;
1205 pLed
->BlinkingLedState
= LED_OFF
;
1206 if (pLed
->bLedBlinkInProgress
) {
1207 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1208 pLed
->bLedBlinkInProgress
= false;
1210 if (pLed
->bLedScanBlinkInProgress
) {
1211 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1212 pLed
->bLedScanBlinkInProgress
= false;
1214 if (pLed
->bLedWPSBlinkInProgress
) {
1215 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1216 pLed
->bLedWPSBlinkInProgress
= false;
1218 _set_timer(&(pLed
->BlinkTimer
), 0);
1225 static void SwLedControlMode3(struct _adapter
*padapter
,
1226 enum LED_CTL_MODE LedAction
)
1228 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1229 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1230 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1232 switch (LedAction
) {
1233 case LED_CTL_SITE_SURVEY
:
1234 if (pmlmepriv
->sitesurveyctrl
.traffic_busy
)
1235 ; /* dummy branch */
1236 else if (pLed
->bLedScanBlinkInProgress
== false) {
1237 if (IS_LED_WPS_BLINKING(pLed
))
1239 if (pLed
->bLedBlinkInProgress
== true) {
1240 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1241 pLed
->bLedBlinkInProgress
= false;
1243 pLed
->bLedScanBlinkInProgress
= true;
1244 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1245 pLed
->BlinkTimes
= 24;
1247 pLed
->BlinkingLedState
= LED_OFF
;
1249 pLed
->BlinkingLedState
= LED_ON
;
1250 _set_timer(&(pLed
->BlinkTimer
),
1251 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1256 if ((pLed
->bLedBlinkInProgress
== false) &&
1257 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true)) {
1258 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1259 IS_LED_WPS_BLINKING(pLed
))
1261 pLed
->bLedBlinkInProgress
= true;
1262 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1263 pLed
->BlinkTimes
= 2;
1265 pLed
->BlinkingLedState
= LED_OFF
;
1267 pLed
->BlinkingLedState
= LED_ON
;
1268 _set_timer(&(pLed
->BlinkTimer
),
1269 LED_BLINK_FASTER_INTERVAL_ALPHA
);
1273 if (IS_LED_WPS_BLINKING(pLed
))
1275 pLed
->CurrLedState
= LED_ON
;
1276 pLed
->BlinkingLedState
= LED_ON
;
1277 if (pLed
->bLedBlinkInProgress
) {
1278 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1279 pLed
->bLedBlinkInProgress
= false;
1281 if (pLed
->bLedScanBlinkInProgress
) {
1282 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1283 pLed
->bLedScanBlinkInProgress
= false;
1285 _set_timer(&(pLed
->BlinkTimer
), 0);
1287 case LED_CTL_START_WPS
: /* wait until xinpin finish */
1288 case LED_CTL_START_WPS_BOTTON
:
1289 if (pLed
->bLedWPSBlinkInProgress
== false) {
1290 if (pLed
->bLedBlinkInProgress
== true) {
1291 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1292 pLed
->bLedBlinkInProgress
= false;
1294 if (pLed
->bLedScanBlinkInProgress
== true) {
1295 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1296 pLed
->bLedScanBlinkInProgress
= false;
1298 pLed
->bLedWPSBlinkInProgress
= true;
1299 pLed
->CurrLedState
= LED_BLINK_WPS
;
1301 pLed
->BlinkingLedState
= LED_OFF
;
1303 pLed
->BlinkingLedState
= LED_ON
;
1304 _set_timer(&(pLed
->BlinkTimer
),
1305 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1308 case LED_CTL_STOP_WPS
:
1309 if (pLed
->bLedWPSBlinkInProgress
) {
1310 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1311 pLed
->bLedWPSBlinkInProgress
= false;
1313 pLed
->bLedWPSBlinkInProgress
= true;
1314 pLed
->CurrLedState
= LED_BLINK_WPS_STOP
;
1316 pLed
->BlinkingLedState
= LED_OFF
;
1317 _set_timer(&(pLed
->BlinkTimer
),
1318 LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA
);
1320 pLed
->BlinkingLedState
= LED_ON
;
1321 _set_timer(&(pLed
->BlinkTimer
), 0);
1324 case LED_CTL_STOP_WPS_FAIL
:
1325 if (pLed
->bLedWPSBlinkInProgress
) {
1326 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1327 pLed
->bLedWPSBlinkInProgress
= false;
1329 pLed
->CurrLedState
= LED_OFF
;
1330 pLed
->BlinkingLedState
= LED_OFF
;
1331 _set_timer(&(pLed
->BlinkTimer
), 0);
1333 case LED_CTL_START_TO_LINK
:
1334 case LED_CTL_NO_LINK
:
1335 if (!IS_LED_BLINKING(pLed
)) {
1336 pLed
->CurrLedState
= LED_OFF
;
1337 pLed
->BlinkingLedState
= LED_OFF
;
1338 _set_timer(&(pLed
->BlinkTimer
), 0);
1341 case LED_CTL_POWER_OFF
:
1342 pLed
->CurrLedState
= LED_OFF
;
1343 pLed
->BlinkingLedState
= LED_OFF
;
1344 if (pLed
->bLedBlinkInProgress
) {
1345 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1346 pLed
->bLedBlinkInProgress
= false;
1348 if (pLed
->bLedScanBlinkInProgress
) {
1349 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1350 pLed
->bLedScanBlinkInProgress
= false;
1352 if (pLed
->bLedWPSBlinkInProgress
) {
1353 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1354 pLed
->bLedWPSBlinkInProgress
= false;
1356 _set_timer(&(pLed
->BlinkTimer
), 0);
1363 static void SwLedControlMode4(struct _adapter
*padapter
,
1364 enum LED_CTL_MODE LedAction
)
1366 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1367 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1368 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1369 struct LED_871x
*pLed1
= &(ledpriv
->SwLed1
);
1371 switch (LedAction
) {
1372 case LED_CTL_START_TO_LINK
:
1373 if (pLed1
->bLedWPSBlinkInProgress
) {
1374 pLed1
->bLedWPSBlinkInProgress
= false;
1375 _cancel_timer_ex(&(pLed1
->BlinkTimer
));
1376 pLed1
->BlinkingLedState
= LED_OFF
;
1377 pLed1
->CurrLedState
= LED_OFF
;
1379 _set_timer(&(pLed
->BlinkTimer
), 0);
1381 if (pLed
->bLedStartToLinkBlinkInProgress
== false) {
1382 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1383 IS_LED_WPS_BLINKING(pLed
))
1385 if (pLed
->bLedBlinkInProgress
== true) {
1386 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1387 pLed
->bLedBlinkInProgress
= false;
1389 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1390 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1391 pLed
->bLedNoLinkBlinkInProgress
= false;
1393 pLed
->bLedStartToLinkBlinkInProgress
= true;
1394 pLed
->CurrLedState
= LED_BLINK_StartToBlink
;
1396 pLed
->BlinkingLedState
= LED_OFF
;
1397 _set_timer(&(pLed
->BlinkTimer
),
1398 LED_BLINK_SLOWLY_INTERVAL
);
1400 pLed
->BlinkingLedState
= LED_ON
;
1401 _set_timer(&(pLed
->BlinkTimer
),
1402 LED_BLINK_NORMAL_INTERVAL
);
1407 case LED_CTL_NO_LINK
:
1409 if (LedAction
== LED_CTL_LINK
) {
1410 if (pLed1
->bLedWPSBlinkInProgress
) {
1411 pLed1
->bLedWPSBlinkInProgress
= false;
1412 _cancel_timer_ex(&(pLed1
->BlinkTimer
));
1413 pLed1
->BlinkingLedState
= LED_OFF
;
1414 pLed1
->CurrLedState
= LED_OFF
;
1416 _set_timer(&(pLed
->BlinkTimer
), 0);
1419 if (pLed
->bLedNoLinkBlinkInProgress
== false) {
1420 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1421 IS_LED_WPS_BLINKING(pLed
))
1423 if (pLed
->bLedBlinkInProgress
== true) {
1424 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1425 pLed
->bLedBlinkInProgress
= false;
1427 pLed
->bLedNoLinkBlinkInProgress
= true;
1428 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1430 pLed
->BlinkingLedState
= LED_OFF
;
1432 pLed
->BlinkingLedState
= LED_ON
;
1433 _set_timer(&(pLed
->BlinkTimer
),
1434 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
1437 case LED_CTL_SITE_SURVEY
:
1438 if ((pmlmepriv
->sitesurveyctrl
.traffic_busy
) &&
1439 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true))
1441 else if (pLed
->bLedScanBlinkInProgress
== false) {
1442 if (IS_LED_WPS_BLINKING(pLed
))
1444 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1445 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1446 pLed
->bLedNoLinkBlinkInProgress
= false;
1448 if (pLed
->bLedBlinkInProgress
== true) {
1449 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1450 pLed
->bLedBlinkInProgress
= false;
1452 pLed
->bLedScanBlinkInProgress
= true;
1453 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1454 pLed
->BlinkTimes
= 24;
1456 pLed
->BlinkingLedState
= LED_OFF
;
1458 pLed
->BlinkingLedState
= LED_ON
;
1459 _set_timer(&(pLed
->BlinkTimer
),
1460 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1465 if (pLed
->bLedBlinkInProgress
== false) {
1466 if (pLed
->CurrLedState
== LED_SCAN_BLINK
||
1467 IS_LED_WPS_BLINKING(pLed
))
1469 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1470 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1471 pLed
->bLedNoLinkBlinkInProgress
= false;
1473 pLed
->bLedBlinkInProgress
= true;
1474 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1475 pLed
->BlinkTimes
= 2;
1477 pLed
->BlinkingLedState
= LED_OFF
;
1479 pLed
->BlinkingLedState
= LED_ON
;
1480 _set_timer(&(pLed
->BlinkTimer
),
1481 LED_BLINK_FASTER_INTERVAL_ALPHA
);
1484 case LED_CTL_START_WPS
: /*wait until xinpin finish*/
1485 case LED_CTL_START_WPS_BOTTON
:
1486 if (pLed1
->bLedWPSBlinkInProgress
) {
1487 pLed1
->bLedWPSBlinkInProgress
= false;
1488 _cancel_timer_ex(&(pLed1
->BlinkTimer
));
1489 pLed1
->BlinkingLedState
= LED_OFF
;
1490 pLed1
->CurrLedState
= LED_OFF
;
1492 _set_timer(&(pLed
->BlinkTimer
), 0);
1494 if (pLed
->bLedWPSBlinkInProgress
== false) {
1495 if (pLed
->bLedNoLinkBlinkInProgress
== true) {
1496 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1497 pLed
->bLedNoLinkBlinkInProgress
= false;
1499 if (pLed
->bLedBlinkInProgress
== true) {
1500 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1501 pLed
->bLedBlinkInProgress
= false;
1503 if (pLed
->bLedScanBlinkInProgress
== true) {
1504 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1505 pLed
->bLedScanBlinkInProgress
= false;
1507 pLed
->bLedWPSBlinkInProgress
= true;
1508 pLed
->CurrLedState
= LED_BLINK_WPS
;
1510 pLed
->BlinkingLedState
= LED_OFF
;
1511 _set_timer(&(pLed
->BlinkTimer
),
1512 LED_BLINK_SLOWLY_INTERVAL
);
1514 pLed
->BlinkingLedState
= LED_ON
;
1515 _set_timer(&(pLed
->BlinkTimer
),
1516 LED_BLINK_NORMAL_INTERVAL
);
1520 case LED_CTL_STOP_WPS
: /*WPS connect success*/
1521 if (pLed
->bLedWPSBlinkInProgress
) {
1522 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1523 pLed
->bLedWPSBlinkInProgress
= false;
1525 pLed
->bLedNoLinkBlinkInProgress
= true;
1526 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1528 pLed
->BlinkingLedState
= LED_OFF
;
1530 pLed
->BlinkingLedState
= LED_ON
;
1531 _set_timer(&(pLed
->BlinkTimer
),
1532 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
1534 case LED_CTL_STOP_WPS_FAIL
: /*WPS authentication fail*/
1535 if (pLed
->bLedWPSBlinkInProgress
) {
1536 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1537 pLed
->bLedWPSBlinkInProgress
= false;
1539 pLed
->bLedNoLinkBlinkInProgress
= true;
1540 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1542 pLed
->BlinkingLedState
= LED_OFF
;
1544 pLed
->BlinkingLedState
= LED_ON
;
1545 _set_timer(&(pLed
->BlinkTimer
),
1546 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
1548 if (pLed1
->bLedWPSBlinkInProgress
)
1549 _cancel_timer_ex(&(pLed1
->BlinkTimer
));
1551 pLed1
->bLedWPSBlinkInProgress
= true;
1552 pLed1
->CurrLedState
= LED_BLINK_WPS_STOP
;
1554 pLed1
->BlinkingLedState
= LED_OFF
;
1556 pLed1
->BlinkingLedState
= LED_ON
;
1557 _set_timer(&(pLed
->BlinkTimer
), LED_BLINK_NORMAL_INTERVAL
);
1559 case LED_CTL_STOP_WPS_FAIL_OVERLAP
: /*WPS session overlap*/
1560 if (pLed
->bLedWPSBlinkInProgress
) {
1561 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1562 pLed
->bLedWPSBlinkInProgress
= false;
1564 pLed
->bLedNoLinkBlinkInProgress
= true;
1565 pLed
->CurrLedState
= LED_BLINK_SLOWLY
;
1567 pLed
->BlinkingLedState
= LED_OFF
;
1569 pLed
->BlinkingLedState
= LED_ON
;
1570 _set_timer(&(pLed
->BlinkTimer
),
1571 LED_BLINK_NO_LINK_INTERVAL_ALPHA
);
1573 if (pLed1
->bLedWPSBlinkInProgress
)
1574 _cancel_timer_ex(&(pLed1
->BlinkTimer
));
1576 pLed1
->bLedWPSBlinkInProgress
= true;
1577 pLed1
->CurrLedState
= LED_BLINK_WPS_STOP_OVERLAP
;
1578 pLed1
->BlinkTimes
= 10;
1580 pLed1
->BlinkingLedState
= LED_OFF
;
1582 pLed1
->BlinkingLedState
= LED_ON
;
1583 _set_timer(&(pLed
->BlinkTimer
), LED_BLINK_NORMAL_INTERVAL
);
1585 case LED_CTL_POWER_OFF
:
1586 pLed
->CurrLedState
= LED_OFF
;
1587 pLed
->BlinkingLedState
= LED_OFF
;
1588 if (pLed
->bLedNoLinkBlinkInProgress
) {
1589 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1590 pLed
->bLedNoLinkBlinkInProgress
= false;
1592 if (pLed
->bLedLinkBlinkInProgress
) {
1593 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1594 pLed
->bLedLinkBlinkInProgress
= false;
1596 if (pLed
->bLedBlinkInProgress
) {
1597 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1598 pLed
->bLedBlinkInProgress
= false;
1600 if (pLed
->bLedWPSBlinkInProgress
) {
1601 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1602 pLed
->bLedWPSBlinkInProgress
= false;
1604 if (pLed
->bLedScanBlinkInProgress
) {
1605 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1606 pLed
->bLedScanBlinkInProgress
= false;
1608 if (pLed
->bLedStartToLinkBlinkInProgress
) {
1609 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1610 pLed
->bLedStartToLinkBlinkInProgress
= false;
1612 if (pLed1
->bLedWPSBlinkInProgress
) {
1613 _cancel_timer_ex(&(pLed1
->BlinkTimer
));
1614 pLed1
->bLedWPSBlinkInProgress
= false;
1616 pLed1
->BlinkingLedState
= LED_UNKNOWN
;
1617 SwLedOff(padapter
, pLed
);
1618 SwLedOff(padapter
, pLed1
);
1625 static void SwLedControlMode5(struct _adapter
*padapter
,
1626 enum LED_CTL_MODE LedAction
)
1628 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1629 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1630 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1632 if (padapter
->eeprompriv
.CustomerID
== RT_CID_819x_CAMEO
)
1633 pLed
= &(ledpriv
->SwLed1
);
1635 switch (LedAction
) {
1636 case LED_CTL_POWER_ON
:
1637 case LED_CTL_NO_LINK
:
1638 case LED_CTL_LINK
: /* solid blue */
1639 if (pLed
->CurrLedState
== LED_SCAN_BLINK
)
1641 pLed
->CurrLedState
= LED_ON
;
1642 pLed
->BlinkingLedState
= LED_ON
;
1643 pLed
->bLedBlinkInProgress
= false;
1644 _set_timer(&(pLed
->BlinkTimer
), 0);
1646 case LED_CTL_SITE_SURVEY
:
1647 if ((pmlmepriv
->sitesurveyctrl
.traffic_busy
) &&
1648 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true))
1649 ; /* dummy branch */
1650 else if (pLed
->bLedScanBlinkInProgress
== false) {
1651 if (pLed
->bLedBlinkInProgress
== true) {
1652 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1653 pLed
->bLedBlinkInProgress
= false;
1655 pLed
->bLedScanBlinkInProgress
= true;
1656 pLed
->CurrLedState
= LED_SCAN_BLINK
;
1657 pLed
->BlinkTimes
= 24;
1659 pLed
->BlinkingLedState
= LED_OFF
;
1661 pLed
->BlinkingLedState
= LED_ON
;
1662 _set_timer(&(pLed
->BlinkTimer
),
1663 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1668 if (pLed
->bLedBlinkInProgress
== false) {
1669 if (pLed
->CurrLedState
== LED_SCAN_BLINK
)
1671 pLed
->bLedBlinkInProgress
= true;
1672 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1673 pLed
->BlinkTimes
= 2;
1675 pLed
->BlinkingLedState
= LED_OFF
;
1677 pLed
->BlinkingLedState
= LED_ON
;
1678 _set_timer(&(pLed
->BlinkTimer
),
1679 LED_BLINK_FASTER_INTERVAL_ALPHA
);
1682 case LED_CTL_POWER_OFF
:
1683 pLed
->CurrLedState
= LED_OFF
;
1684 pLed
->BlinkingLedState
= LED_OFF
;
1685 if (pLed
->bLedBlinkInProgress
) {
1686 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1687 pLed
->bLedBlinkInProgress
= false;
1689 SwLedOff(padapter
, pLed
);
1697 static void SwLedControlMode6(struct _adapter
*padapter
,
1698 enum LED_CTL_MODE LedAction
)
1700 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1701 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1702 struct LED_871x
*pLed
= &(ledpriv
->SwLed0
);
1704 switch (LedAction
) {
1705 case LED_CTL_POWER_ON
:
1706 case LED_CTL_NO_LINK
:
1707 case LED_CTL_LINK
: /*solid blue*/
1708 case LED_CTL_SITE_SURVEY
:
1709 if (IS_LED_WPS_BLINKING(pLed
))
1711 pLed
->CurrLedState
= LED_ON
;
1712 pLed
->BlinkingLedState
= LED_ON
;
1713 pLed
->bLedBlinkInProgress
= false;
1714 _set_timer(&(pLed
->BlinkTimer
), 0);
1718 if (pLed
->bLedBlinkInProgress
== false &&
1719 (check_fwstate(pmlmepriv
, _FW_LINKED
) == true)) {
1720 if (IS_LED_WPS_BLINKING(pLed
))
1722 pLed
->bLedBlinkInProgress
= true;
1723 pLed
->CurrLedState
= LED_TXRX_BLINK
;
1724 pLed
->BlinkTimes
= 2;
1726 pLed
->BlinkingLedState
= LED_OFF
;
1728 pLed
->BlinkingLedState
= LED_ON
;
1729 _set_timer(&(pLed
->BlinkTimer
),
1730 LED_BLINK_FASTER_INTERVAL_ALPHA
);
1733 case LED_CTL_START_WPS
: /*wait until xinpin finish*/
1734 case LED_CTL_START_WPS_BOTTON
:
1735 if (pLed
->bLedWPSBlinkInProgress
== false) {
1736 if (pLed
->bLedBlinkInProgress
== true) {
1737 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1738 pLed
->bLedBlinkInProgress
= false;
1740 pLed
->bLedWPSBlinkInProgress
= true;
1741 pLed
->CurrLedState
= LED_BLINK_WPS
;
1743 pLed
->BlinkingLedState
= LED_OFF
;
1745 pLed
->BlinkingLedState
= LED_ON
;
1746 _set_timer(&(pLed
->BlinkTimer
),
1747 LED_BLINK_SCAN_INTERVAL_ALPHA
);
1750 case LED_CTL_STOP_WPS_FAIL
:
1751 case LED_CTL_STOP_WPS
:
1752 if (pLed
->bLedWPSBlinkInProgress
) {
1753 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1754 pLed
->bLedWPSBlinkInProgress
= false;
1756 pLed
->CurrLedState
= LED_ON
;
1757 pLed
->BlinkingLedState
= LED_ON
;
1758 _set_timer(&(pLed
->BlinkTimer
), 0);
1760 case LED_CTL_POWER_OFF
:
1761 pLed
->CurrLedState
= LED_OFF
;
1762 pLed
->BlinkingLedState
= LED_OFF
;
1763 if (pLed
->bLedBlinkInProgress
) {
1764 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1765 pLed
->bLedBlinkInProgress
= false;
1767 if (pLed
->bLedWPSBlinkInProgress
) {
1768 _cancel_timer_ex(&(pLed
->BlinkTimer
));
1769 pLed
->bLedWPSBlinkInProgress
= false;
1771 SwLedOff(padapter
, pLed
);
1779 * Dispatch LED action according to pHalData->LedStrategy.
1781 void LedControl871x(struct _adapter
*padapter
, enum LED_CTL_MODE LedAction
)
1783 struct led_priv
*ledpriv
= &(padapter
->ledpriv
);
1785 if (ledpriv
->bRegUseLed
== false)
1787 switch (ledpriv
->LedStrategy
) {
1791 SwLedControlMode1(padapter
, LedAction
);
1794 SwLedControlMode2(padapter
, LedAction
);
1797 SwLedControlMode3(padapter
, LedAction
);
1800 SwLedControlMode4(padapter
, LedAction
);
1803 SwLedControlMode5(padapter
, LedAction
);
1806 SwLedControlMode6(padapter
, LedAction
);