2 * Copyright (c) 2007-2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 /************************************************************************/
21 /* FUNCTION DESCRIPTION zfLedCtrlType1 */
22 /* Traditional single-LED state */
25 /* dev : device pointer */
31 /* Stephen Chen Atheros Communications, INC. 2007.6 */
33 /************************************************************************/
34 // bit 15-12 : Toff for Scan state
35 // 11-8 : Ton for Scan state
38 //--------------------------------------
40 // 5-4 : Connect state
43 // 10 => Idle off, acitve on
44 // 11 => Idle on, active off
45 //--------------------------------------
52 //--------------------------------------
53 // 3 : Power save state
54 // 0 => always off in power save state
55 // 1 => works as connect state
59 void zfLedCtrlType1(zdev_t* dev)
62 u32_t ton, toff, tmp, period;
63 zmw_get_wlan_dev(dev);
65 for (i=0; i<ZM_MAX_LED_NUMBER; i++)
67 if (zfStaIsConnected(dev) != TRUE)
70 ton = ((wd->ledStruct.ledMode[i] & 0xf00) >> 8) * 5;
71 toff = ((wd->ledStruct.ledMode[i] & 0xf000) >> 12) * 5;
73 if ((ton + toff) != 0)
75 tmp = wd->ledStruct.counter / (ton+toff);
76 tmp = wd->ledStruct.counter - (tmp * (ton+toff));
79 zfHpLedCtrl(dev, i, 1);
83 zfHpLedCtrl(dev, i, 0);
89 if ((zfPowerSavingMgrIsSleeping(dev)) && ((wd->ledStruct.ledMode[i] & 0x8) == 0))
91 zfHpLedCtrl(dev, i, 0);
96 if ((wd->ledStruct.ledMode[i] & 0x40) == 0)
98 if ((wd->ledStruct.counter & 1) == 0)
100 zfHpLedCtrl(dev, i, (wd->ledStruct.ledMode[i] & 0x10) >> 4);
104 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
106 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
107 if ((wd->ledStruct.ledMode[i] & 0x20) != 0)
109 zfHpLedCtrl(dev, i, ((wd->ledStruct.ledMode[i] & 0x10) >> 4)^1);
113 }// if ((wd->ledStruct.ledMode[i] & 0x40) == 0)
116 period = 5 * (1 << ((wd->ledStruct.ledMode[i] & 0x30) >> 4));
117 tmp = wd->ledStruct.counter / (period*2);
118 tmp = wd->ledStruct.counter - (tmp * (period*2));
121 if ((wd->ledStruct.counter & 1) == 0)
123 zfHpLedCtrl(dev, i, 0);
127 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
129 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
130 zfHpLedCtrl(dev, i, 1);
136 if ((wd->ledStruct.counter & 1) == 0)
138 zfHpLedCtrl(dev, i, 1);
142 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
144 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
145 zfHpLedCtrl(dev, i, 0);
149 } //else, if ((wd->ledStruct.ledMode[i] & 0x40) == 0)
150 } //else, if (zfPowerSavingMgrIsSleeping(dev))
151 } //else : if (zfStaIsConnected(dev) != TRUE)
152 } //for (i=0; i<ZM_MAX_LED_NUMBER; i++)
155 /******************************************************************************/
157 /* FUNCTION DESCRIPTION zfLedCtrlType2 */
158 /* Customize for Netgear Dual-LED state ((bug#31292)) */
160 /* 1. Status: When dongle does not connect to 2.4G or 5G but in site */
161 /* survey/association */
162 /* LED status: Slow blinking, Amber then Blue per 500ms */
163 /* 2. Status: Connection at 2.4G in site survey/association */
164 /* LED status: Slow blinking, Amber/off per 500ms */
165 /* 3. Status: Connection at 5G in site survey/association */
166 /* LED status: Slow blinking, Blue/off per 500ms */
167 /* 4. Status: When transfer the packet */
168 /* LED status: Blink per packet, including TX and RX */
169 /* 5. Status: When linking is established but no traffic */
170 /* LED status: Always on */
171 /* 6. Status: When linking is dropped but no re-connection */
172 /* LED status: Always off */
173 /* 7. Status: From one connection(2.4G or 5G) to change to another band */
174 /* LED status: Amber/Blue =>Slow blinking, Amber then Blue per 500ms */
177 /* dev : device pointer */
183 /* Shang-Chun Liu Atheros Communications, INC. 2007.11 */
185 /******************************************************************************/
186 void zfLedCtrlType2_scan(zdev_t* dev);
188 void zfLedCtrlType2(zdev_t* dev)
191 zmw_get_wlan_dev(dev);
193 if (zfStaIsConnected(dev) != TRUE)
196 if(wd->ledStruct.counter % 4 != 0)
198 // Update LED each 400ms(4*100)
199 // Prevent this situation
201 // LED[0] ON | | | x |
202 // ------ OFF->+-+-+-+-+-+-+-+-+-+-+-+->>>...
208 if (((wd->state == ZM_WLAN_STATE_DISABLED) && (wd->sta.bChannelScan))
209 || ((wd->state != ZM_WLAN_STATE_DISABLED) && (wd->sta.bAutoReconnect)))
211 // Scan/AutoReconnect state
212 zfLedCtrlType2_scan(dev);
216 // Neither Connected nor Scan
217 zfHpLedCtrl(dev, 0, 0);
218 zfHpLedCtrl(dev, 1, 0);
223 if( wd->sta.bChannelScan )
226 if(wd->ledStruct.counter % 4 != 0)
228 zfLedCtrlType2_scan(dev);
232 if(wd->frequency < 3000)
234 OperateLED = 0; // LED[0]: work on 2.4G (b/g band)
235 zfHpLedCtrl(dev, 1, 0);
239 OperateLED = 1; // LED[1]: work on 5G (a band)
240 zfHpLedCtrl(dev, 0, 0);
243 if ((zfPowerSavingMgrIsSleeping(dev)) && ((wd->ledStruct.ledMode[OperateLED] & 0x8) == 0))
245 // If Sleeping, turn OFF
246 zfHpLedCtrl(dev, OperateLED, 0);
251 if ((wd->ledStruct.counter & 1) == 0) // even
253 // No traffic, always ON
254 zfHpLedCtrl(dev, OperateLED, 1);
258 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
260 // If have traffic, turn OFF
262 // LED[Operate] ON | | | | | | | |
263 // ------------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
265 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
266 zfHpLedCtrl(dev, OperateLED, 0);
273 void zfLedCtrlType2_scan(zdev_t* dev)
275 zmw_get_wlan_dev(dev);
277 // When doing scan, blink(Amber/Blue) and off per 500ms (about 400ms in our driver)
279 // LED[0] ON | | 8 12 | |
280 // ------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
281 // LED[1] ON 0 4 |_______| 0 3
284 switch(wd->ledStruct.counter % 16)
286 case 0: // case 0~3, LED[0] on
287 if(wd->supportMode & ZM_WIRELESS_MODE_24)
289 zfHpLedCtrl(dev, 0, 1);
290 zfHpLedCtrl(dev, 1, 0);
294 zfHpLedCtrl(dev, 1, 1);
295 zfHpLedCtrl(dev, 0, 0);
299 case 8: // case 8~11, LED[1] on
300 if(wd->supportMode & ZM_WIRELESS_MODE_5)
302 zfHpLedCtrl(dev, 1, 1);
303 zfHpLedCtrl(dev, 0, 0);
307 zfHpLedCtrl(dev, 0, 1);
308 zfHpLedCtrl(dev, 1, 0);
312 default: // others, all off
313 zfHpLedCtrl(dev, 0, 0);
314 zfHpLedCtrl(dev, 1, 0);
319 /**********************************************************************************/
321 /* FUNCTION DESCRIPTION zfLedCtrlType3 */
322 /* Customize for Netgear Single-LED state ((bug#32243)) */
324 /* ¡EOff: when the adapter is disabled or hasn't started to associate with AP */
326 /* ¡EOn: Once adpater associate with AP successfully */
327 /* ¡ESlow blinking: whenever adapters do site-survey or try to associate with AP */
328 /* - If there is a connection already, and adapters do site-survey or */
329 /* re-associate action, the LED should keep LED backgraoud as ON, thus */
330 /* the blinking behavior SHOULD be OFF (200ms) - ON (800ms) and continue this*/
332 /* - If there is no connection yet, and adapters start to do site-survey or */
333 /* associate action, the LED should keep LED background as OFF, thus the */
334 /* blinking behavior SHOULD be ON (200ms) - OFF (800ms) and continue this */
336 /* - For the case that associate fail, adpater should keep associating, and the*/
337 /* LED should also keep slow blinking. */
338 /* ¡EQuick blinking: to blink OFF-ON cycle for each time that traffic packet is */
339 /* received or is transmitted. */
342 /* dev : device pointer */
348 /* Shang-Chun Liu Atheros Communications, INC. 2008.01 */
350 /**********************************************************************************/
351 void zfLedCtrlType3_scan(zdev_t* dev, u16_t isConnect);
353 void zfLedCtrlType3(zdev_t* dev)
355 zmw_get_wlan_dev(dev);
357 if (zfStaIsConnected(dev) != TRUE)
360 if(wd->ledStruct.counter % 2 != 0)
362 // Update LED each 200ms(2*100)
363 // Prevent this situation
366 // ------ OFF->+-+-+-+-+-+-+->>>...
371 if (((wd->state == ZM_WLAN_STATE_DISABLED) && (wd->sta.bChannelScan))
372 || ((wd->state != ZM_WLAN_STATE_DISABLED) && (wd->sta.bAutoReconnect)))
374 // Scan/AutoReconnect state
375 zfLedCtrlType3_scan(dev, 0);
379 // Neither Connected nor Scan
380 zfHpLedCtrl(dev, 0, 0);
381 zfHpLedCtrl(dev, 1, 0);
386 if( wd->sta.bChannelScan )
389 if(wd->ledStruct.counter % 2 != 0)
391 zfLedCtrlType3_scan(dev, 1);
395 if ((zfPowerSavingMgrIsSleeping(dev)) && ((wd->ledStruct.ledMode[0] & 0x8) == 0))
397 // If Sleeping, turn OFF
398 zfHpLedCtrl(dev, 0, 0);
399 zfHpLedCtrl(dev, 1, 0);
404 if ((wd->ledStruct.counter & 1) == 0) // even
406 // No traffic, always ON
407 zfHpLedCtrl(dev, 0, 1);
408 zfHpLedCtrl(dev, 1, 1);
412 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
414 // If have traffic, turn OFF
416 // LED[Operate] ON | | | | | | | |
417 // ------------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
419 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
420 zfHpLedCtrl(dev, 0, 0);
421 zfHpLedCtrl(dev, 1, 0);
428 void zfLedCtrlType3_scan(zdev_t* dev, u16_t isConnect)
430 u32_t ton, toff, tmp;
431 zmw_get_wlan_dev(dev);
434 // 1. Disconnected: ON (200ms) - OFF (800ms) (200ms-600ms in our driver)
436 // LED[0] ON | | | | | |
437 // ------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
438 // 0 2 4 6 8 10 12 14 16
439 // 2. Connected: ON (800ms) - OFF (200ms) (600ms-200ms in our driver)
440 // ___________ ___________ ______
441 // LED[0] ON | | | | |
442 // ------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
443 // 0 2 4 6 8 10 12 14 16
451 if ((ton + toff) != 0)
453 tmp = wd->ledStruct.counter % (ton+toff);
456 zfHpLedCtrl(dev, 0, 1);
457 zfHpLedCtrl(dev, 1, 1);
461 zfHpLedCtrl(dev, 0, 0);
462 zfHpLedCtrl(dev, 1, 0);
467 /******************************************************************************/
469 /* FUNCTION DESCRIPTION zfLedCtrl_BlinkWhenScan_Alpha */
470 /* Customize for Alpha/DLink LED */
471 /* - Blink LED 12 times within 3 seconds when doing Active Scan */
472 /* ___ ___ ___ ___ */
473 /* LED[0] ON | | | | | | | | */
474 /* -------OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+--+-->>>... */
477 /* dev : device pointer */
483 /* Shang-Chun Liu Atheros Communications, INC. 2007.11 */
485 /******************************************************************************/
486 void zfLedCtrl_BlinkWhenScan_Alpha(zdev_t* dev)
488 static u32_t counter = 0;
489 zmw_get_wlan_dev(dev);
491 if(counter > 34) // counter for 3 sec
493 wd->ledStruct.LEDCtrlFlag &= ~(u8_t)ZM_LED_CTRL_FLAG_ALPHA;
497 if( (counter % 3) < 2)
498 zfHpLedCtrl(dev, 0, 1);
500 zfHpLedCtrl(dev, 0, 0);
506 /************************************************************************/
508 /* FUNCTION DESCRIPTION zfLed100msCtrl */
509 /* LED 100 milliseconds timer. */
512 /* dev : device pointer */
518 /* Stephen Chen Atheros Communications, INC. 2007.6 */
520 /************************************************************************/
521 void zfLed100msCtrl(zdev_t* dev)
523 zmw_get_wlan_dev(dev);
525 wd->ledStruct.counter++;
527 if(wd->ledStruct.LEDCtrlFlag)
529 switch(wd->ledStruct.LEDCtrlFlag) {
530 case ZM_LED_CTRL_FLAG_ALPHA:
531 zfLedCtrl_BlinkWhenScan_Alpha(dev);
537 switch(wd->ledStruct.LEDCtrlType) {
538 case 1: // Traditional 1 LED
542 case 2: // Dual-LEDs for Netgear
546 case 3: // Single-LED for Netgear (WN111v2)