diff --git a/core/rtw_led.c b/core/rtw_led.c index 67cb696..5aafcfa 100644 --- a/core/rtw_led.c +++ b/core/rtw_led.c @@ -22,40 +22,38 @@ #include "rtw_led.h" /* */ -/* Description: */ -/* Callback function of LED BlinkTimer, */ -/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ +/* Description: */ +/* Callback function of LED BlinkTimer, */ +/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ /* */ void BlinkTimerCallback(void *data) { - struct LED_871x * pLed = (struct LED_871x *)data; - struct adapter *padapter = pLed->padapter; + struct LED_871x *pLed = (struct LED_871x *)data; + struct adapter *padapter = pLed->padapter; - if ( (padapter->bSurpriseRemoved == true) || ( padapter->bDriverStopped == true)) - { + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - } _set_workitem(&(pLed->BlinkWorkItem)); } /* */ -/* Description: */ -/* Callback function of LED BlinkWorkItem. */ -/* We dispatch acture LED blink action according to LedStrategy. */ +/* Description: */ +/* Callback function of LED BlinkWorkItem. */ +/* We dispatch acture LED blink action according to LedStrategy. */ /* */ void BlinkWorkItemCallback(struct work_struct *work) { - struct LED_871x * pLed = container_of(work, struct LED_871x, BlinkWorkItem); + struct LED_871x *pLed = container_of(work, struct LED_871x, BlinkWorkItem); BlinkHandler(pLed); } /* */ -/* Description: */ -/* Reset status of LED_871x object. */ +/* Description: */ +/* Reset status of LED_871x object. */ /* */ -void ResetLedStatus(struct LED_871x * pLed) { - +void ResetLedStatus(struct LED_871x *pLed) +{ pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ pLed->bLedOn = false; /* true if LED is ON, false if LED is OFF. */ @@ -71,14 +69,9 @@ void ResetLedStatus(struct LED_871x * pLed) { pLed->bLedScanBlinkInProgress = false; } -/* Description: */ -/* Initialize an LED_871x object. */ -void -InitLed871x( - struct adapter *padapter, - struct LED_871x *pLed, - enum LED_PIN_871x LedPin - ) +/*Description: */ +/* Initialize an LED_871x object. */ +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) { pLed->padapter = padapter; pLed->LedPin = LedPin; @@ -92,140 +85,96 @@ InitLed871x( /* */ -/* Description: */ -/* DeInitialize an LED_871x object. */ +/* Description: */ +/* DeInitialize an LED_871x object. */ /* */ -void -DeInitLed871x( - struct LED_871x * pLed - ) +void DeInitLed871x(struct LED_871x *pLed) { _cancel_workitem_sync(&(pLed->BlinkWorkItem)); _cancel_timer_ex(&(pLed->BlinkTimer)); ResetLedStatus(pLed); } - /* */ -/* Description: */ -/* Implementation of LED blinking behavior. */ -/* It toggle off LED and schedule corresponding timer if necessary. */ +/* Description: */ +/* Implementation of LED blinking behavior. */ +/* It toggle off LED and schedule corresponding timer if necessary. */ /* */ -void SwLedOn(struct adapter *padapter, struct LED_871x * pLed); -void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); - -static void -SwLedBlink( - struct LED_871x * pLed - ) +static void SwLedBlink(struct LED_871x *pLed) { - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,( "Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } /* Determine if we shall change LED state again. */ pLed->BlinkTimes--; - switch (pLed->CurrLedState) - { - + switch (pLed->CurrLedState) { case LED_BLINK_NORMAL: if (pLed->BlinkTimes == 0) - { bStopBlinking = true; - } break; - case LED_BLINK_StartToBlink: - if ( check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE) ) - { + if (check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE)) bStopBlinking = true; - } - if ( check_fwstate(pmlmepriv, _FW_LINKED) && - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) ) - { + if (check_fwstate(pmlmepriv, _FW_LINKED) && + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) bStopBlinking = true; - } else if (pLed->BlinkTimes == 0) - { bStopBlinking = true; - } break; - case LED_BLINK_WPS: - if ( pLed->BlinkTimes == 0 ) - { + if (pLed->BlinkTimes == 0) bStopBlinking = true; - } break; - - default: bStopBlinking = true; break; - } - if (bStopBlinking) - { - /* if ( padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ - if (0) - { + if (bStopBlinking) { + /* if (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ + if (0) { SwLedOff(padapter, pLed); - } - else if ( (check_fwstate(pmlmepriv, _FW_LINKED)== true) && (pLed->bLedOn == false)) - { + } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { SwLedOn(padapter, pLed); - } - else if ( (check_fwstate(pmlmepriv, _FW_LINKED)== true) && pLed->bLedOn == true) - { + } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) { SwLedOff(padapter, pLed); } - pLed->BlinkTimes = 0; pLed->bLedBlinkInProgress = false; - } - else - { + } else { /* Assign LED state to toggle. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) + if (pLed->BlinkingLedState == RTW_LED_ON) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; /* Schedule a timer to toggle LED state. */ - switch ( pLed->CurrLedState ) - { + switch (pLed->CurrLedState) { case LED_BLINK_NORMAL: _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); break; - case LED_BLINK_SLOWLY: case LED_BLINK_StartToBlink: _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); break; - case LED_BLINK_WPS: - { - if ( pLed->BlinkingLedState == RTW_LED_ON ) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); - else - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); - } + if (pLed->BlinkingLedState == RTW_LED_ON) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + else + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); break; - default: _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); break; @@ -233,1867 +182,1414 @@ SwLedBlink( } } -static void -SwLedBlink1( - struct LED_871x * pLed - ) +static void SwLedBlink1(struct LED_871x *pLed) { - struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct LED_871x * pLed1 = &(ledpriv->SwLed1); - u8 bStopBlinking = false; + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct LED_871x *pLed1 = &(ledpriv->SwLed1); + u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,( "Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff(padapter, pLed); ResetLedStatus(pLed); return; } - switch (pLed->CurrLedState) - { - case LED_BLINK_SLOWLY: - if ( pLed->bLedOn ) + switch (pLed->CurrLedState) { + case LED_BLINK_SLOWLY: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_NORMAL: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - break; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->BlinkTimes = 0; + pLed->bLedBlinkInProgress = false; + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) + bStopBlinking = false; + else + bStopBlinking = true; - case LED_BLINK_NORMAL: - if ( pLed->bLedOn ) + if (bStopBlinking) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - break; + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } + break; + default: + break; + } +} + +static void SwLedBlink2(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); + + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); } - - if (bStopBlinking) - { - if (check_fwstate(pmlmepriv, _FW_LINKED)== true) - { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== false) - { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } - else - { - if ( pLed->bLedOn ) + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); } - break; - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); } - if (bStopBlinking) - { - if (check_fwstate(pmlmepriv, _FW_LINKED)== true) - { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== false) - { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = false; - } - else - { - if ( pLed->bLedOn ) + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); } - break; - - case LED_BLINK_WPS: - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - break; - - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) - bStopBlinking = false; - else - bStopBlinking = true; - - if (bStopBlinking) - { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - - pLed->bLedWPSBlinkInProgress = false; - } - else - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } - break; - - default: - break; + } + break; + default: + break; } - } -static void -SwLedBlink2( - struct LED_871x * pLed - ) +static void SwLedBlink3(struct LED_871x *pLed) { - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - switch (pLed->CurrLedState) - { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; - } - - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== true) - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== false) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; - } - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== true) - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("stop CurrLedState %d\n", pLed->CurrLedState)); - - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== false) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("stop CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedBlinkInProgress = false; - } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - - default: - break; - } - -} - -static void -SwLedBlink3( - struct LED_871x * pLed - ) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) - { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { if (pLed->CurrLedState != LED_BLINK_WPS_STOP) SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } - switch (pLed->CurrLedState) - { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; - } - - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== true) - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if ( !pLed->bLedOn ) - SwLedOn(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== false) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if ( pLed->bLedOn ) - SwLedOff(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; - } - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== true) - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - - if ( !pLed->bLedOn ) - SwLedOn(padapter, pLed); - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED)== false) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if ( pLed->bLedOn ) - SwLedOff(padapter, pLed); - - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedBlinkInProgress = false; - } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - - case LED_BLINK_WPS: - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - break; - - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - bStopBlinking = false; - } - else - { - bStopBlinking = true; - } - - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on ) - { - SwLedOff(padapter, pLed); - } - else - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedWPSBlinkInProgress = false; + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } - break; + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; - - default: - break; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + bStopBlinking = false; + } else { + bStopBlinking = true; + } + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedWPSBlinkInProgress = false; + } + break; + default: + break; } - } - -static void -SwLedBlink4( - struct LED_871x * pLed - ) +static void SwLedBlink4(struct LED_871x *pLed) { - struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct LED_871x *pLed1 = &(ledpriv->SwLed1); - u8 bStopBlinking = false; + u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } - if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) - { + if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) { pLed1->BlinkingLedState = RTW_LED_OFF; pLed1->CurrLedState = RTW_LED_OFF; SwLedOff(padapter, pLed1); } - switch (pLed->CurrLedState) - { - case LED_BLINK_SLOWLY: - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - break; - - case LED_BLINK_StartToBlink: - if ( pLed->bLedOn ) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = false; - } - - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - SwLedOff(padapter, pLed); - } + switch (pLed->CurrLedState) { + case LED_BLINK_SLOWLY: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_StartToBlink: + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = false; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + pLed->bLedNoLinkBlinkInProgress = false; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; else - { - pLed->bLedNoLinkBlinkInProgress = false; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - pLed->bLedScanBlinkInProgress = false; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - SwLedOff(padapter, pLed); - } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); } - break; + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_BLINK_WPS_STOP: /* WPS authentication fail */ + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) { + if (pLed->bLedOn) + pLed->BlinkTimes = 1; + else bStopBlinking = true; - } - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - SwLedOff(padapter, pLed); - } - else - { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - pLed->bLedBlinkInProgress = false; - } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - SwLedOff(padapter, pLed); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; + } - case LED_BLINK_WPS: - if ( pLed->bLedOn ) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - - case LED_BLINK_WPS_STOP: /* WPS authentication fail */ - if ( pLed->bLedOn ) + if (bStopBlinking) { + pLed->BlinkTimes = 10; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + } else { + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - break; - - case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - { - if (pLed->bLedOn) - { - pLed->BlinkTimes = 1; - } - else - { - bStopBlinking = true; - } - } - - if (bStopBlinking) - { - pLed->BlinkTimes = 10; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - - - default: - break; + } + break; + default: + break; } - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); - - + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); } -static void -SwLedBlink5( - struct LED_871x * pLed - ) +static void SwLedBlink5(struct LED_871x *pLed) { - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) - { + if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } - switch (pLed->CurrLedState) - { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; - } + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } - else - { pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - - pLed->bLedScanBlinkInProgress = false; - } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) SwLedOff(padapter, pLed); - } - else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - - - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if ( pLed->BlinkTimes == 0 ) - { - bStopBlinking = true; - } - - if (bStopBlinking) - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } - else - { + } else { pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; if (!pLed->bLedOn) _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - - pLed->bLedBlinkInProgress = false; } - else - { - if ( padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) - { - SwLedOff(padapter, pLed); - } + + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; else - { - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } } - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); - - -} - -static void -SwLedBlink6( - struct LED_871x * pLed - ) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if ( pLed->BlinkingLedState == RTW_LED_ON ) - { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } - else - { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("<==== blink6\n")); -} - -static void -SwLedControlMode0( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed = &(ledpriv->SwLed1); - - /* Decide led state */ - switch (LedAction) - { - case LED_CTL_TX: - case LED_CTL_RX: - if ( pLed->bLedBlinkInProgress == false ) - { - pLed->bLedBlinkInProgress = true; - - pLed->CurrLedState = LED_BLINK_NORMAL; - pLed->BlinkTimes = 2; - - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - - case LED_CTL_START_TO_LINK: - if ( pLed->bLedBlinkInProgress == false ) - { - pLed->bLedBlinkInProgress = true; - - pLed->CurrLedState = LED_BLINK_StartToBlink; - pLed->BlinkTimes = 24; - - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } - else - { - pLed->CurrLedState = LED_BLINK_StartToBlink; - } - break; - - case LED_CTL_LINK: - pLed->CurrLedState = RTW_LED_ON; - if ( pLed->bLedBlinkInProgress == false ) - { - SwLedOn(padapter, pLed); - } - break; - - case LED_CTL_NO_LINK: - pLed->CurrLedState = RTW_LED_OFF; - if ( pLed->bLedBlinkInProgress == false ) - { - SwLedOff(padapter, pLed); - } - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; - } - SwLedOff(padapter, pLed); - break; - - case LED_CTL_START_WPS: - if ( pLed->bLedBlinkInProgress == false || pLed->CurrLedState == RTW_LED_ON) - { - pLed->bLedBlinkInProgress = true; - - pLed->CurrLedState = LED_BLINK_WPS; - pLed->BlinkTimes = 20; - - if ( pLed->bLedOn ) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); } } break; - case LED_CTL_STOP_WPS: - if (pLed->bLedBlinkInProgress) - { - pLed->CurrLedState = RTW_LED_OFF; - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - break; - - default: break; } - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Led %d\n", pLed->CurrLedState)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); +} +static void SwLedBlink6(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); +} + +static void SwLedControlMode0(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed = &(ledpriv->SwLed1); + + /* Decide led state */ + switch (LedAction) { + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + pLed->bLedBlinkInProgress = true; + + pLed->CurrLedState = LED_BLINK_NORMAL; + pLed->BlinkTimes = 2; + + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_CTL_START_TO_LINK: + if (!pLed->bLedBlinkInProgress) { + pLed->bLedBlinkInProgress = true; + + pLed->CurrLedState = LED_BLINK_StartToBlink; + pLed->BlinkTimes = 24; + + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->CurrLedState = LED_BLINK_StartToBlink; + } + break; + case LED_CTL_LINK: + pLed->CurrLedState = RTW_LED_ON; + if (!pLed->bLedBlinkInProgress) + SwLedOn(padapter, pLed); + break; + case LED_CTL_NO_LINK: + pLed->CurrLedState = RTW_LED_OFF; + if (!pLed->bLedBlinkInProgress) + SwLedOff(padapter, pLed); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + case LED_CTL_START_WPS: + if (!pLed->bLedBlinkInProgress || pLed->CurrLedState == RTW_LED_ON) { + pLed->bLedBlinkInProgress = true; + + pLed->CurrLedState = LED_BLINK_WPS; + pLed->BlinkTimes = 20; + + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + } + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedBlinkInProgress) { + pLed->CurrLedState = RTW_LED_OFF; + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + break; + default: + break; + } + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } /* ALPHA, added by chiyoko, 20090106 */ -static void -SwLedControlMode1( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) +static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x * pLed = &(ledpriv->SwLed0); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed = &(ledpriv->SwLed0); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if ( pLed->bLedNoLinkBlinkInProgress == false ) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - if ( pLed->bLedLinkBlinkInProgress == true ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + case LED_CTL_POWER_ON: + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!pLed->bLedNoLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; } - break; - - case LED_CTL_LINK: - if ( pLed->bLedLinkBlinkInProgress == false ) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; } - break; - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED)== true)) - ; - else if (pLed->bLedScanBlinkInProgress ==false) - { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if ( pLed->bLedLinkBlinkInProgress == true ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress ==false) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if ( pLed->bLedLinkBlinkInProgress == true ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress ==false) - { - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if ( pLed->bLedLinkBlinkInProgress == true ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - - case LED_CTL_STOP_WPS: - if (pLed->bLedNoLinkBlinkInProgress == true) - { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + if (!pLed->bLedLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } - if ( pLed->bLedLinkBlinkInProgress == true ) - { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + ; + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } - if (pLed->bLedBlinkInProgress ==true) - { + if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } - if (pLed->bLedScanBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - } - else - { - pLed->bLedWPSBlinkInProgress = true; - } - - pLed->CurrLedState = LED_BLINK_WPS_STOP; + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; if (pLed->bLedOn) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if ( pLed->bLedNoLinkBlinkInProgress) - { + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } - if ( pLed->bLedLinkBlinkInProgress) - { + if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } - if ( pLed->bLedBlinkInProgress) - { + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } - if ( pLed->bLedWPSBlinkInProgress ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - if ( pLed->bLedScanBlinkInProgress) - { + if (pLed->bLedScanBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedScanBlinkInProgress = false; } - - SwLedOff(padapter, pLed); - break; - - default: - break; - + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed->BlinkTimer)); + else + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS_FAIL: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + default: + break; } - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Led %d\n", pLed->CurrLedState)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ -static void -SwLedControlMode2( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) +static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct LED_871x *pLed = &(ledpriv->SwLed0); - switch (LedAction) - { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) - ; - else if (pLed->bLedScanBlinkInProgress ==false) - { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if ((pLed->bLedBlinkInProgress ==false) && (check_fwstate(pmlmepriv, _FW_LINKED)== true)) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - - case LED_CTL_LINK: - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if ( pLed->bLedBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if ( pLed->bLedScanBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - - _set_timer(&(pLed->BlinkTimer), 0); - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress ==false) - { - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - - case LED_CTL_STOP_WPS: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff(padapter, pLed); - } - else - { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - break; - - case LED_CTL_STOP_WPS_FAIL: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) - { - SwLedOff(padapter, pLed); - } - else - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); - } - break; - - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if ( pLed->bLedBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if ( pLed->bLedScanBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - if ( pLed->bLedWPSBlinkInProgress ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - - _set_timer(&(pLed->BlinkTimer), 0); - break; - - default: - break; - - } - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); -} - - /* COREGA, added by chiyoko, 20090316 */ - static void - SwLedControlMode3( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); - - switch (LedAction) - { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) - ; - else if (pLed->bLedScanBlinkInProgress ==false) - { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if ((pLed->bLedBlinkInProgress ==false) && (check_fwstate(pmlmepriv, _FW_LINKED)== true)) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - - case LED_CTL_LINK: + switch (LedAction) { + case LED_CTL_SITE_SURVEY: + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + } else if (!pLed->bLedScanBlinkInProgress) { if (IS_LED_WPS_BLINKING(pLed)) return; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; - if ( pLed->bLedBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if ( pLed->bLedScanBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - _set_timer(&(pLed->BlinkTimer), 0); - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress ==false) - { - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - case LED_CTL_STOP_WPS: - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - else - { - pLed->bLedWPSBlinkInProgress = true; - } - - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->bLedOn) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - } - - break; - - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - + } + break; + case LED_CTL_STOP_WPS: + pLed->bLedWPSBlinkInProgress = false; + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + break; + case LED_CTL_STOP_WPS_FAIL: + pLed->bLedWPSBlinkInProgress = false; + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; _set_timer(&(pLed->BlinkTimer), 0); - break; - - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) - { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - - case LED_CTL_POWER_OFF: + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + break; + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!IS_LED_BLINKING(pLed)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; - if ( pLed->bLedBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if ( pLed->bLedScanBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - if ( pLed->bLedWPSBlinkInProgress ) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - _set_timer(&(pLed->BlinkTimer), 0); - break; - - default: - break; + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + _set_timer(&(pLed->BlinkTimer), 0); + break; + default: + break; } - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("CurrLedState %d\n", pLed->CurrLedState)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } + /* COREGA, added by chiyoko, 20090316 */ + static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_SITE_SURVEY: + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + if (IS_LED_WPS_BLINKING(pLed)) + return; + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->bLedWPSBlinkInProgress = true; + } + + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS_FAIL: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!IS_LED_BLINKING(pLed)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + default: + break; + } + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, + ("CurrLedState %d\n", pLed->CurrLedState)); +} /* Edimax-Belkin, added by chiyoko, 20090413 */ -static void -SwLedControlMode4( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) +static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct LED_871x *pLed = &(ledpriv->SwLed0); struct LED_871x *pLed1 = &(ledpriv->SwLed1); - switch (LedAction) - { - case LED_CTL_START_TO_LINK: - if (pLed1->bLedWPSBlinkInProgress) - { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); + switch (LedAction) { + case LED_CTL_START_TO_LINK: + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; - if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); - } + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } - if ( pLed->bLedStartToLinkBlinkInProgress == false ) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedNoLinkBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - - pLed->bLedStartToLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_StartToBlink; - if ( pLed->bLedOn ) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - } - break; - - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - /* LED1 settings */ - if (LedAction == LED_CTL_LINK) - { - if (pLed1->bLedWPSBlinkInProgress) - { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); - } - } - - if ( pLed->bLedNoLinkBlinkInProgress == false ) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - break; - - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED)== true)) - ; - else if (pLed->bLedScanBlinkInProgress ==false) - { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress ==false) - { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - { - return; - } - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed1->bLedWPSBlinkInProgress) - { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); - } - - if (pLed->bLedWPSBlinkInProgress ==false) - { - if (pLed->bLedNoLinkBlinkInProgress == true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if ( pLed->bLedOn ) - { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } - else - { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - } - break; - - case LED_CTL_STOP_WPS: /* WPS connect success */ - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - break; - - case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed1->BlinkTimer)); - else - pLed1->bLedWPSBlinkInProgress = true; - - pLed1->CurrLedState = LED_BLINK_WPS_STOP; - if ( pLed1->bLedOn ) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - - break; - - case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ - if (pLed->bLedWPSBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed1->BlinkTimer)); - else - pLed1->bLedWPSBlinkInProgress = true; - - pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; - pLed1->BlinkTimes = 10; - if ( pLed1->bLedOn ) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if ( pLed->bLedNoLinkBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if ( pLed->bLedLinkBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if ( pLed->bLedBlinkInProgress) - { + if (!pLed->bLedStartToLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } - if ( pLed->bLedWPSBlinkInProgress ) - { + if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; + pLed->bLedNoLinkBlinkInProgress = false; } - if ( pLed->bLedScanBlinkInProgress) - { + + pLed->bLedStartToLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_StartToBlink; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + } + break; + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + /* LED1 settings */ + if (LedAction == LED_CTL_LINK) { + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + } + + if (!pLed->bLedNoLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedScanBlinkInProgress = false; } - if ( pLed->bLedStartToLinkBlinkInProgress) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedStartToLinkBlinkInProgress = false; + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); } + } + break; + case LED_CTL_STOP_WPS: /* WPS connect success */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } - if ( pLed1->bLedWPSBlinkInProgress ) - { - _cancel_timer_ex(&(pLed1->BlinkTimer)); - pLed1->bLedWPSBlinkInProgress = false; - } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - pLed1->BlinkingLedState = LED_UNKNOWN; - SwLedOff(padapter, pLed); - SwLedOff(padapter, pLed1); - break; + break; + case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - default: - break; + /* LED1 settings */ + if (pLed1->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed1->BlinkTimer)); + else + pLed1->bLedWPSBlinkInProgress = true; + pLed1->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed1->bLedOn) + pLed1->BlinkingLedState = RTW_LED_OFF; + else + pLed1->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + /* LED1 settings */ + if (pLed1->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed1->BlinkTimer)); + else + pLed1->bLedWPSBlinkInProgress = true; + pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; + pLed1->BlinkTimes = 10; + if (pLed1->bLedOn) + pLed1->BlinkingLedState = RTW_LED_OFF; + else + pLed1->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedStartToLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedStartToLinkBlinkInProgress = false; + } + if (pLed1->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed1->BlinkTimer)); + pLed1->bLedWPSBlinkInProgress = false; + } + pLed1->BlinkingLedState = LED_UNKNOWN; + SwLedOff(padapter, pLed); + SwLedOff(padapter, pLed1); + break; + default: + break; } - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Led %d\n", pLed->CurrLedState)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } @@ -2101,228 +1597,188 @@ SwLedControlMode4( /* Sercomm-Belkin, added by chiyoko, 20090415 */ static void SwLedControlMode5( - struct adapter *padapter, - enum LED_CTL_MODE LedAction + struct adapter *padapter, + enum LED_CTL_MODE LedAction ) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct LED_871x *pLed = &(ledpriv->SwLed0); switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_NO_LINK: - case LED_CTL_LINK: /* solid blue */ - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; + case LED_CTL_POWER_ON: + case LED_CTL_NO_LINK: + case LED_CTL_LINK: /* solid blue */ + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - break; - - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED)== true)) - ; - else if (pLed->bLedScanBlinkInProgress ==false) - { - if (pLed->bLedBlinkInProgress ==true) - { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress ==false) - { - if (pLed->CurrLedState == LED_BLINK_SCAN) - { - return; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if ( pLed->bLedOn ) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if ( pLed->bLedBlinkInProgress) - { + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - break; - - default: - break; - + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + default: + break; } - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("Led %d\n", pLed->CurrLedState)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } /* WNC-Corega, added by chiyoko, 20090902 */ static void SwLedControlMode6( - struct adapter *padapter, - enum LED_CTL_MODE LedAction + struct adapter *padapter, + enum LED_CTL_MODE LedAction ) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x * pLed0 = &(ledpriv->SwLed0); + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed0 = &(ledpriv->SwLed0); - switch (LedAction) - { - case LED_CTL_POWER_ON: - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - _cancel_timer_ex(&(pLed0->BlinkTimer)); - pLed0->CurrLedState = RTW_LED_ON; - pLed0->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed0->BlinkTimer), 0); - break; - - case LED_CTL_POWER_OFF: - SwLedOff(padapter, pLed0); - break; - - default: - break; + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + _cancel_timer_ex(&(pLed0->BlinkTimer)); + pLed0->CurrLedState = RTW_LED_ON; + pLed0->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed0->BlinkTimer), 0); + break; + case LED_CTL_POWER_OFF: + SwLedOff(padapter, pLed0); + break; + default: + break; } - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); } /* */ -/* Description: */ -/* Handler function of LED Blinking. */ -/* We dispatch acture LED blink action according to LedStrategy. */ +/* Description: */ +/* Handler function of LED Blinking. */ +/* We dispatch acture LED blink action according to LedStrategy. */ /* */ -void BlinkHandler(struct LED_871x * pLed) +void BlinkHandler(struct LED_871x *pLed) { - struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); - if ( (padapter->bSurpriseRemoved == true) || ( padapter->bDriverStopped == true)) + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - switch (ledpriv->LedStrategy) - { - case SW_LED_MODE0: - SwLedBlink(pLed); - break; - - case SW_LED_MODE1: - SwLedBlink1(pLed); - break; - - case SW_LED_MODE2: - SwLedBlink2(pLed); - break; - - case SW_LED_MODE3: - SwLedBlink3(pLed); - break; - - case SW_LED_MODE4: - SwLedBlink4(pLed); - break; - - case SW_LED_MODE5: - SwLedBlink5(pLed); - break; - - case SW_LED_MODE6: - SwLedBlink6(pLed); - break; - - default: - break; + switch (ledpriv->LedStrategy) { + case SW_LED_MODE0: + SwLedBlink(pLed); + break; + case SW_LED_MODE1: + SwLedBlink1(pLed); + break; + case SW_LED_MODE2: + SwLedBlink2(pLed); + break; + case SW_LED_MODE3: + SwLedBlink3(pLed); + break; + case SW_LED_MODE4: + SwLedBlink4(pLed); + break; + case SW_LED_MODE5: + SwLedBlink5(pLed); + break; + case SW_LED_MODE6: + SwLedBlink6(pLed); + break; + default: + break; } } -void -LedControl871x( - struct adapter *padapter, - enum LED_CTL_MODE LedAction - ) +void LedControl871x(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &(padapter->ledpriv); - if ( (padapter->bSurpriseRemoved == true) || ( padapter->bDriverStopped == true) - ||(padapter->hw_init_completed == false) ) - { - return; - } - - - if ( ledpriv->bRegUseLed == false) + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || + (!padapter->hw_init_completed)) return; - - - if ( (padapter->pwrctrlpriv.rf_pwrstate != rf_on && - padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) && - (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || - LedAction == LED_CTL_SITE_SURVEY || - LedAction == LED_CTL_LINK || - LedAction == LED_CTL_NO_LINK || - LedAction == LED_CTL_POWER_ON) ) - { + if (!ledpriv->bRegUseLed) return; + + if ((padapter->pwrctrlpriv.rf_pwrstate != rf_on && + padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) && + (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || + LedAction == LED_CTL_SITE_SURVEY || + LedAction == LED_CTL_LINK || + LedAction == LED_CTL_NO_LINK || + LedAction == LED_CTL_POWER_ON)) + return; + + switch (ledpriv->LedStrategy) { + case SW_LED_MODE0: + break; + case SW_LED_MODE1: + SwLedControlMode1(padapter, LedAction); + break; + case SW_LED_MODE2: + SwLedControlMode2(padapter, LedAction); + break; + case SW_LED_MODE3: + SwLedControlMode3(padapter, LedAction); + break; + case SW_LED_MODE4: + SwLedControlMode4(padapter, LedAction); + break; + case SW_LED_MODE5: + SwLedControlMode5(padapter, LedAction); + break; + case SW_LED_MODE6: + SwLedControlMode6(padapter, LedAction); + break; + default: + break; } - switch (ledpriv->LedStrategy) - { - case SW_LED_MODE0: - break; - - case SW_LED_MODE1: - SwLedControlMode1(padapter, LedAction); - break; - case SW_LED_MODE2: - SwLedControlMode2(padapter, LedAction); - break; - - case SW_LED_MODE3: - SwLedControlMode3(padapter, LedAction); - break; - - case SW_LED_MODE4: - SwLedControlMode4(padapter, LedAction); - break; - - case SW_LED_MODE5: - SwLedControlMode5(padapter, LedAction); - break; - - case SW_LED_MODE6: - SwLedControlMode6(padapter, LedAction); - break; - - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_,_drv_info_,("LedStrategy:%d, LedAction %d\n", ledpriv->LedStrategy,LedAction)); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, + ("LedStrategy:%d, LedAction %d\n", + ledpriv->LedStrategy, LedAction)); } diff --git a/include/rtw_led.h b/include/rtw_led.h index 1319cc4..76850c5 100644 --- a/include/rtw_led.h +++ b/include/rtw_led.h @@ -185,12 +185,11 @@ InitLed871x( enum LED_PIN_871x LedPin ); -void -DeInitLed871x( - struct LED_871x * pLed - ); +void DeInitLed871x(struct LED_871x *pLed); //hal... -extern void BlinkHandler(struct LED_871x * pLed); +void BlinkHandler(struct LED_871x * pLed); +void SwLedOn(struct adapter *padapter, struct LED_871x * pLed); +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); #endif //__RTW_LED_H_