Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
Add LED control
Browse files Browse the repository at this point in the history
  • Loading branch information
gordboy committed Jan 18, 2018
1 parent c739c62 commit ff04a94
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ CONFIG_RTW_NAPI = y
CONFIG_RTW_GRO = y
CONFIG_RTW_IPCAM_APPLICATION = n
CONFIG_RTW_REPEATER_SON = n
CONFIG_LED_CONTROL = y
CONFIG_LED_ENABLE = y
########################## Debug ###########################
CONFIG_RTW_DEBUG = n
# default log level is _DRV_INFO_ = 4,
Expand Down Expand Up @@ -956,6 +958,13 @@ EXTRA_CFLAGS += -DCONFIG_WIFI_MONITOR
endif
endif

ifeq ($(CONFIG_LED_CONTROL), y)
EXTRA_CFLAGS += -DCONFIG_LED_CONTROL
ifeq ($(CONFIG_LED_ENABLE), y)
EXTRA_CFLAGS += -DCONFIG_LED_ENABLE
endif
endif

ifeq ($(CONFIG_MP_VHT_HW_TX_MODE), y)
EXTRA_CFLAGS += -DCONFIG_MP_VHT_HW_TX_MODE
ifeq ($(CONFIG_PLATFORM_I386_PC), y)
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Works fine with 4.13 kernel. Source now builds with no warnings or errors.
Added (cosmeticly edited) original Realtek_Changelog.txt, this README.md and dkms.conf.

Added device USB IDs, sorted by ID number.
Added LED control by Makefile, module parameter and dynamic /proc writing.

### Building

Expand Down Expand Up @@ -36,6 +37,37 @@ To use dkms uninstall and remove:
$ sudo dkms remove -m rtl8812au -v 5.2.20 --all
```

### LED control

Thanks to @dkadioglu and others for a start on this.

#### You can now control LED behaviour statically by Makefile, for example:

```sh
CONFIG_LED_ENABLE = n
```
value can be y or n

#### statically by module parameter in /etc/modprobe.d/8812au.conf or wherever, for example:

```sh
options 8812au rtw_led_enable=0
```
value can be 0 or 1

#### or dynamically by writing to /proc/net/rtl8812au/$(your interface name)/led_enable, for example:

```sh
$ echo "0" > /proc/net/rtl8812au/$(your interface name)/led_enable
```
value can be 0 or 1

#### check current value:

```sh
$ cat /proc/net/rtl8812au/$(your interface name)/led_enable
```

### NetworkManager

As others have noted, people using NetworkManager need to add this stanza to /etc/NetworkManager/NetworkManager.conf
Expand Down
51 changes: 51 additions & 0 deletions core/rtw_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -6121,4 +6121,55 @@ ssize_t proc_set_lck(struct file *file, const char __user *buffer, size_t count,
}
#endif /* CONFIG_DBG_RF_CAL */

#ifdef CONFIG_LED_CONTROL
int proc_get_led_enable(struct seq_file *m, void *v)
{
struct net_device *dev = m->private;
_adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
struct registry_priv *pregpriv = &padapter->registrypriv;

if (pregpriv)
RTW_PRINT_SEL(m, "%d\n", pregpriv->led_enable);

return 0;
}

ssize_t proc_set_led_enable(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
{
struct net_device *dev = data;
_adapter *padapter = (_adapter *)rtw_netdev_priv(dev);
struct registry_priv *pregpriv = &padapter->registrypriv;
char tmp[32];
u32 mode;

if (count < 1)
return -EFAULT;

if (count > sizeof(tmp)) {
rtw_warn_on(1);
return -EFAULT;
}

if (buffer && !copy_from_user(tmp, buffer, count)) {

int num = sscanf(tmp, "%d ", &mode);

if (pregpriv && mode < 2) {
pregpriv->led_enable = (u8) mode;

// FIXME need to initialize LEDS to current mode when turning on
// Otherwise need to wait for next mode change

if (mode == 1)
LedControlUSB(padapter, LED_CTL_POWER_ON);
else
LedControlUSB(padapter, LED_CTL_POWER_OFF);

RTW_INFO("led_enable=%d\n", pregpriv->led_enable);
}
}

return count;
}
#endif //CONFIG_LED_CONTROL
#endif /* CONFIG_PROC_DEBUG */
18 changes: 18 additions & 0 deletions hal/led/hal_usb_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
#include <hal_data.h>
#ifdef CONFIG_RTW_SW_LED

#ifdef CONFIG_LED_CONTROL
void
rtw_led_control(
_adapter *adapter,
LED_CTL_MODE LedAction
)
{
if (adapter->registrypriv.led_enable)
{
do
{
(adapter)->ledpriv.LedControlHandler((adapter), (LedAction));
}
while(0);
}
}
#endif //CONFIG_LED_CONTROL

/*
* Description:
* Implementation of LED blinking behavior.
Expand Down
4 changes: 4 additions & 0 deletions include/drv_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ struct registry_priv {
#ifdef CONFIG_FW_OFFLOAD_PARAM_INIT
u8 fw_param_init;
#endif

#ifdef CONFIG_LED_CONTROL
u8 led_enable;
#endif
};

/* For registry parameters */
Expand Down
4 changes: 4 additions & 0 deletions include/hal_com_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,15 @@ extern void BlinkHandler(PLED_DATA pLed);
#endif /* CONFIG_RTW_LED */

#if defined(CONFIG_RTW_LED) && defined(CONFIG_RTW_SW_LED)
#ifdef CONFIG_LED_CONTROL
void rtw_led_control(_adapter *adapter, LED_CTL_MODE LedAction);
#else
#define rtw_led_control(adapter, LedAction) \
do { \
if ((adapter)->ledpriv.LedControlHandler) \
(adapter)->ledpriv.LedControlHandler((adapter), (LedAction)); \
} while (0)
#endif //CONFIG_LED_CONTROL
#else
#define rtw_led_control(adapter, LedAction) do {} while (0)
#endif
Expand Down
5 changes: 5 additions & 0 deletions include/rtw_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ int proc_get_mcc_policy_table(struct seq_file *m, void *v);
ssize_t proc_set_mcc_policy_table(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data);
#endif /* CONFIG_MCC_MODE */

#ifdef CONFIG_LED_CONTROL
int proc_get_led_enable(struct seq_file *m, void *v);
ssize_t proc_set_led_enable(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data);
#endif //CONFIG_LED_CONTROL

int proc_get_ack_timeout(struct seq_file *m, void *v);
ssize_t proc_set_ack_timeout(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data);

Expand Down
15 changes: 15 additions & 0 deletions os_dep/linux/os_intfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,16 @@ uint rtw_wakeup_event = RTW_WAKEUP_EVENT;
module_param(rtw_wakeup_event, uint, 0644);
#endif

#ifdef CONFIG_LED_CONTROL
#ifdef CONFIG_LED_ENABLE
int rtw_led_enable = 1;
#else
int rtw_led_enable = 0;
#endif //CONFIG_LED_ENABLE
module_param(rtw_led_enable, int, 0644);
MODULE_PARM_DESC(rtw_led_enable,"Enable status LED");
#endif //CONFIG_LED_CONTROL

void rtw_regsty_load_target_tx_power(struct registry_priv *regsty)
{
int path, rs;
Expand Down Expand Up @@ -1125,6 +1135,11 @@ uint loadparam(_adapter *padapter)
#ifdef CONFIG_AP_MODE
registry_par->bmc_tx_rate = rtw_bmc_tx_rate;
#endif

#ifdef CONFIG_LED_CONTROL
registry_par->led_enable = (u8)rtw_led_enable;
#endif //CONFIG_LED_CONTROL

return status;
}

Expand Down
4 changes: 4 additions & 0 deletions os_dep/linux/rtw_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,10 @@ const struct rtw_proc_hdl adapter_proc_hdls[] = {
RTW_PROC_HDL_SSEQ("dynamic_agg_enable", proc_get_dynamic_agg_enable, proc_set_dynamic_agg_enable),
RTW_PROC_HDL_SSEQ("iqk_fw_offload", proc_get_iqk_fw_offload, proc_set_iqk_fw_offload),

#ifdef CONFIG_LED_CONTROL
RTW_PROC_HDL_SSEQ("led_enable", proc_get_led_enable, proc_set_led_enable),
#endif //CONFIG_LED_CONTROL

};

const int adapter_proc_hdls_num = sizeof(adapter_proc_hdls) / sizeof(struct rtw_proc_hdl);
Expand Down

0 comments on commit ff04a94

Please sign in to comment.