hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/******************************************************************************
 *
 * Copyright(c) 2015 - 2017 Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 *****************************************************************************/
#define _RTL8822BU_LED_C_
 
#include <drv_types.h>        /* PADAPTER */
#include <hal_data.h>        /* PHAL_DATA_TYPE */
#include <hal_com_led.h>    /* PLED_USB */
#include "../../hal_halmac.h" /* HALMAC API */
#ifdef CONFIG_RTW_SW_LED
 
/*
 * =============================================================================
 * LED object.
 * =============================================================================
 */
 
 
/*
 * =============================================================================
 * Prototype of protected function.
 * =============================================================================
 */
 
/*
 * =============================================================================
 * LED routines.
 * =============================================================================
 */
 
/*
 * Description:
 * Turn on LED according to LedPin specified.
 */
static void swledon(PADAPTER padapter, PLED_USB led)
{
   PHAL_DATA_TYPE hal = GET_HAL_DATA(padapter);
 
   if (RTW_CANNOT_RUN(padapter))
       return;
 
   switch (led->LedPin) {
   case LED_PIN_GPIO0:
       break;
   case LED_PIN_LED0:
   case LED_PIN_LED1:
   case LED_PIN_LED2:
   default:
       if (padapter->registrypriv.led_ctrl == 0) {
           rtw_halmac_led_switch(adapter_to_dvobj(padapter), 0);
       } else {
           rtw_halmac_led_switch(adapter_to_dvobj(padapter), 1);
       }
       break;
   }
 
   if (padapter->registrypriv.led_ctrl == 0) {
       led->bLedOn = _FALSE;
   } else {
       led->bLedOn = _TRUE;
   }
}
 
 
/*
 * Description:
 * Turn off LED according to LedPin specified.
 */
static void swledoff(PADAPTER padapter, PLED_USB led)
{
   PHAL_DATA_TYPE hal = GET_HAL_DATA(padapter);
 
   if (RTW_CANNOT_RUN(padapter))
       return;
 
   switch (led->LedPin) {
   case LED_PIN_GPIO0:
       break;
   case LED_PIN_LED0:
   case LED_PIN_LED1:
   case LED_PIN_LED2:
   default:
       if (padapter->registrypriv.led_ctrl <= 1) {
           rtw_halmac_led_switch(adapter_to_dvobj(padapter), 0);
       } else {
           rtw_halmac_led_switch(adapter_to_dvobj(padapter), 1);
       }
       break;
   }
 
   if (padapter->registrypriv.led_ctrl <= 1) {
       led->bLedOn = _FALSE;
   } else {
       led->bLedOn = _TRUE;
   }
}
 
/*
 * =============================================================================
 * Interface to manipulate LED objects.
 * =============================================================================
 */
 
/*
 * =============================================================================
 * Default LED behavior.
 * =============================================================================
 */
 
/*
 * Description:
 * Initialize all LED_871x objects.
 */
void rtl8822bu_initswleds(PADAPTER padapter)
{
   struct led_priv *ledpriv = adapter_to_led(padapter);
   u8 enable = 1;
   u8 mode = 3;
 
   ledpriv->LedControlHandler = LedControlUSB;
   ledpriv->SwLedOn = swledon;
   ledpriv->SwLedOff = swledoff;
 
   InitLed(padapter, &(ledpriv->SwLed0), LED_PIN_LED0);
   InitLed(padapter, &(ledpriv->SwLed1), LED_PIN_LED1);
   InitLed(padapter, &(ledpriv->SwLed2), LED_PIN_LED2);
}
 
/*
 * Description:
 * DeInitialize all LED_819xUsb objects.
 */
void rtl8822bu_deinitswleds(PADAPTER padapter)
{
   struct led_priv *ledpriv = adapter_to_led(padapter);
   u8 enable = 0;
   u8 mode = 3;
 
   DeInitLed(&(ledpriv->SwLed0));
   DeInitLed(&(ledpriv->SwLed1));
   DeInitLed(&(ledpriv->SwLed2));
}
#endif