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)
190 u32_t ton, toff, tmp, period;
192 zmw_get_wlan_dev(dev);
194 if (zfStaIsConnected(dev) != TRUE)
197 if(wd->ledStruct.counter % 4 != 0)
199 // Update LED each 400ms(4*100)
200 // Prevent this situation
202 // LED[0] ON | | | x |
203 // ------ OFF->+-+-+-+-+-+-+-+-+-+-+-+->>>...
209 if (((wd->state == ZM_WLAN_STATE_DISABLED) && (wd->sta.bChannelScan))
210 || ((wd->state != ZM_WLAN_STATE_DISABLED) && (wd->sta.bAutoReconnect)))
212 // Scan/AutoReconnect state
213 zfLedCtrlType2_scan(dev);
217 // Neither Connected nor Scan
218 zfHpLedCtrl(dev, 0, 0);
219 zfHpLedCtrl(dev, 1, 0);
224 if( wd->sta.bChannelScan )
227 if(wd->ledStruct.counter % 4 != 0)
229 zfLedCtrlType2_scan(dev);
233 if(wd->frequency < 3000)
235 OperateLED = 0; // LED[0]: work on 2.4G (b/g band)
236 zfHpLedCtrl(dev, 1, 0);
240 OperateLED = 1; // LED[1]: work on 5G (a band)
241 zfHpLedCtrl(dev, 0, 0);
244 if ((zfPowerSavingMgrIsSleeping(dev)) && ((wd->ledStruct.ledMode[OperateLED] & 0x8) == 0))
246 // If Sleeping, turn OFF
247 zfHpLedCtrl(dev, OperateLED, 0);
252 if ((wd->ledStruct.counter & 1) == 0) // even
254 // No traffic, always ON
255 zfHpLedCtrl(dev, OperateLED, 1);
259 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
261 // If have traffic, turn OFF
263 // LED[Operate] ON | | | | | | | |
264 // ------------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
266 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
267 zfHpLedCtrl(dev, OperateLED, 0);
274 void zfLedCtrlType2_scan(zdev_t* dev)
276 zmw_get_wlan_dev(dev);
278 // When doing scan, blink(Amber/Blue) and off per 500ms (about 400ms in our driver)
280 // LED[0] ON | | 8 12 | |
281 // ------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
282 // LED[1] ON 0 4 |_______| 0 3
285 switch(wd->ledStruct.counter % 16)
287 case 0: // case 0~3, LED[0] on
288 if(wd->supportMode & ZM_WIRELESS_MODE_24)
290 zfHpLedCtrl(dev, 0, 1);
291 zfHpLedCtrl(dev, 1, 0);
295 zfHpLedCtrl(dev, 1, 1);
296 zfHpLedCtrl(dev, 0, 0);
300 case 8: // case 8~11, LED[1] on
301 if(wd->supportMode & ZM_WIRELESS_MODE_5)
303 zfHpLedCtrl(dev, 1, 1);
304 zfHpLedCtrl(dev, 0, 0);
308 zfHpLedCtrl(dev, 0, 1);
309 zfHpLedCtrl(dev, 1, 0);
313 default: // others, all off
314 zfHpLedCtrl(dev, 0, 0);
315 zfHpLedCtrl(dev, 1, 0);
320 /**********************************************************************************/
322 /* FUNCTION DESCRIPTION zfLedCtrlType3 */
323 /* Customize for Netgear Single-LED state ((bug#32243)) */
325 /* ¡EOff: when the adapter is disabled or hasn't started to associate with AP */
327 /* ¡EOn: Once adpater associate with AP successfully */
328 /* ¡ESlow blinking: whenever adapters do site-survey or try to associate with AP */
329 /* - If there is a connection already, and adapters do site-survey or */
330 /* re-associate action, the LED should keep LED backgraoud as ON, thus */
331 /* the blinking behavior SHOULD be OFF (200ms) - ON (800ms) and continue this*/
333 /* - If there is no connection yet, and adapters start to do site-survey or */
334 /* associate action, the LED should keep LED background as OFF, thus the */
335 /* blinking behavior SHOULD be ON (200ms) - OFF (800ms) and continue this */
337 /* - For the case that associate fail, adpater should keep associating, and the*/
338 /* LED should also keep slow blinking. */
339 /* ¡EQuick blinking: to blink OFF-ON cycle for each time that traffic packet is */
340 /* received or is transmitted. */
343 /* dev : device pointer */
349 /* Shang-Chun Liu Atheros Communications, INC. 2008.01 */
351 /**********************************************************************************/
352 void zfLedCtrlType3_scan(zdev_t* dev, u16_t isConnect);
354 void zfLedCtrlType3(zdev_t* dev)
356 zmw_get_wlan_dev(dev);
358 if (zfStaIsConnected(dev) != TRUE)
361 if(wd->ledStruct.counter % 2 != 0)
363 // Update LED each 200ms(2*100)
364 // Prevent this situation
367 // ------ OFF->+-+-+-+-+-+-+->>>...
372 if (((wd->state == ZM_WLAN_STATE_DISABLED) && (wd->sta.bChannelScan))
373 || ((wd->state != ZM_WLAN_STATE_DISABLED) && (wd->sta.bAutoReconnect)))
375 // Scan/AutoReconnect state
376 zfLedCtrlType3_scan(dev, 0);
380 // Neither Connected nor Scan
381 zfHpLedCtrl(dev, 0, 0);
382 zfHpLedCtrl(dev, 1, 0);
387 if( wd->sta.bChannelScan )
390 if(wd->ledStruct.counter % 2 != 0)
392 zfLedCtrlType3_scan(dev, 1);
396 if ((zfPowerSavingMgrIsSleeping(dev)) && ((wd->ledStruct.ledMode[0] & 0x8) == 0))
398 // If Sleeping, turn OFF
399 zfHpLedCtrl(dev, 0, 0);
400 zfHpLedCtrl(dev, 1, 0);
405 if ((wd->ledStruct.counter & 1) == 0) // even
407 // No traffic, always ON
408 zfHpLedCtrl(dev, 0, 1);
409 zfHpLedCtrl(dev, 1, 1);
413 if ((wd->ledStruct.txTraffic > 0) || (wd->ledStruct.rxTraffic > 0))
415 // If have traffic, turn OFF
417 // LED[Operate] ON | | | | | | | |
418 // ------------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
420 wd->ledStruct.txTraffic = wd->ledStruct.rxTraffic = 0;
421 zfHpLedCtrl(dev, 0, 0);
422 zfHpLedCtrl(dev, 1, 0);
429 void zfLedCtrlType3_scan(zdev_t* dev, u16_t isConnect)
431 u32_t ton, toff, tmp;
432 zmw_get_wlan_dev(dev);
435 // 1. Disconnected: ON (200ms) - OFF (800ms) (200ms-600ms in our driver)
437 // LED[0] ON | | | | | |
438 // ------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
439 // 0 2 4 6 8 10 12 14 16
440 // 2. Connected: ON (800ms) - OFF (200ms) (600ms-200ms in our driver)
441 // ___________ ___________ ______
442 // LED[0] ON | | | | |
443 // ------ OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+->>>...
444 // 0 2 4 6 8 10 12 14 16
452 if ((ton + toff) != 0)
454 tmp = wd->ledStruct.counter % (ton+toff);
457 zfHpLedCtrl(dev, 0, 1);
458 zfHpLedCtrl(dev, 1, 1);
462 zfHpLedCtrl(dev, 0, 0);
463 zfHpLedCtrl(dev, 1, 0);
468 /******************************************************************************/
470 /* FUNCTION DESCRIPTION zfLedCtrl_BlinkWhenScan_Alpha */
471 /* Customize for Alpha/DLink LED */
472 /* - Blink LED 12 times within 3 seconds when doing Active Scan */
473 /* ___ ___ ___ ___ */
474 /* LED[0] ON | | | | | | | | */
475 /* -------OFF->-+-+-+-+-+-+-+-+-+-+-+-+-+--+-->>>... */
478 /* dev : device pointer */
484 /* Shang-Chun Liu Atheros Communications, INC. 2007.11 */
486 /******************************************************************************/
487 void zfLedCtrl_BlinkWhenScan_Alpha(zdev_t* dev)
489 static u32_t counter = 0;
490 zmw_get_wlan_dev(dev);
492 if(counter > 34) // counter for 3 sec
494 wd->ledStruct.LEDCtrlFlag &= ~(u8_t)ZM_LED_CTRL_FLAG_ALPHA;
498 if( (counter % 3) < 2)
499 zfHpLedCtrl(dev, 0, 1);
501 zfHpLedCtrl(dev, 0, 0);
507 /************************************************************************/
509 /* FUNCTION DESCRIPTION zfLed100msCtrl */
510 /* LED 100 milliseconds timer. */
513 /* dev : device pointer */
519 /* Stephen Chen Atheros Communications, INC. 2007.6 */
521 /************************************************************************/
522 void zfLed100msCtrl(zdev_t* dev)
524 zmw_get_wlan_dev(dev);
526 wd->ledStruct.counter++;
528 if(wd->ledStruct.LEDCtrlFlag)
530 switch(wd->ledStruct.LEDCtrlFlag) {
531 case ZM_LED_CTRL_FLAG_ALPHA:
532 zfLedCtrl_BlinkWhenScan_Alpha(dev);
538 switch(wd->ledStruct.LEDCtrlType) {
539 case 1: // Traditional 1 LED
543 case 2: // Dual-LEDs for Netgear
547 case 3: // Single-LED for Netgear (WN111v2)