1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-09-19 20:50:41 +00:00

Reintroduce: Added LED control

This commit is cherry-pick + refactoring of:
ff04a94b00
and
313311c14b

I'm not sure how this got lost in the latest version on GitHub (I guess merging issues).
But all credits go to @gordboy, @kimocoder and all the other authors.
This commit is contained in:
int3l 2019-11-29 23:20:46 +02:00
parent 75a5725e0b
commit a8d0fec8e0
7 changed files with 83 additions and 32 deletions

View File

@ -186,31 +186,24 @@ $ sudo iw wlan0 set txpower fixed 3000
### LED control
#### 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 88XXau rtw_led_enable=0
options 88XXau rtw_led_ctrl=0
```
value can be 0 or 1
#### or dynamically by writing to /proc/net/rtl8812au/$(your interface name)/led_enable, for example:
#### or dynamically by writing to /proc/net/rtl8812au/$(your interface name)/led_ctrl, for example:
```sh
$ echo "0" > /proc/net/rtl8812au/$(your interface name)/led_enable
$ echo "0" > /proc/net/rtl8812au/$(your interface name)/led_ctrl
```
value can be 0 or 1
#### check current value:
```sh
$ cat /proc/net/rtl8812au/$(your interface name)/led_enable
$ cat /proc/net/rtl8812au/$(your interface name)/led_ctrl
```
### USB Mode Switch

View File

@ -7030,3 +7030,67 @@ inline void RTW_BUF_DUMP_SEL(uint _loglevel, void *sel, u8 *_titlestring,
}
#endif
#ifdef CONFIG_RTW_SW_LED
int proc_get_led_ctrl(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_ctrl);
return 0;
}
ssize_t proc_set_led_ctrl(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;
struct led_priv *ledpriv = adapter_to_led(padapter);
char tmp[32];
u32 mode;
if (buffer == NULL || pregpriv == NULL) {
RTW_INFO("input buffer is NULL!\n");
return -EFAULT;
}
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 (num != 1) {
RTW_INFO("Invalid format\n");
return count;
}
if (mode < 0 || mode > 2 || pregpriv->led_ctrl == mode) {
RTW_INFO("Invalid mode\n");
return count;
}
if (mode > 0) {
pregpriv->led_ctrl = (u8) mode;
LedControlUSB(padapter, LED_CTL_POWER_ON);
} else {
LedControlUSB(padapter, LED_CTL_POWER_OFF);
pregpriv->led_ctrl = (u8) mode;
}
RTW_INFO("led_ctrl=%d\n", pregpriv->led_ctrl);
}
return count;
}
#endif /* CONFIG_RTW_SW_LED */

View File

@ -1745,22 +1745,6 @@ void BlinkHandler(PLED_USB pLed)
return;
}
#ifdef CONFIG_SW_LED
// led_enable 1 is normal blinking so don't cause always on/off
if (padapter->registrypriv.led_ctrl != 1) {
if (padapter->registrypriv.led_ctrl == 0)
{
// Cause LED to be always off
pLed->BlinkingLedState = RTW_LED_OFF;
} else {
// Cause LED to be always on for led_ctrl 2 or greater
pLed->BlinkingLedState = RTW_LED_ON;
}
// Skip various switch cases where SwLedBlink*() called below
pLed->CurrLedState = LED_UNKNOWN;
}
#endif
switch (ledpriv->LedStrategy) {
#if CONFIG_RTW_SW_LED_TRX_DA_CLASSIFY
case SW_LED_MODE_UC_TRX_ONLY:
@ -4155,7 +4139,8 @@ LedControlUSB(
return;
}
if (ledpriv->bRegUseLed == _FALSE)
if (ledpriv->bRegUseLed == _FALSE ||
padapter->registrypriv.led_ctrl == 0)
return;
/* if(priv->bInHctTest) */

View File

@ -211,7 +211,7 @@ struct registry_priv {
#ifdef CONFIG_TX_EARLY_MODE
u8 early_mode;
#endif
#ifdef CONFIG_SW_LED
#ifdef CONFIG_RTW_SW_LED
u8 led_ctrl;
#endif
u8 acm_method;

View File

@ -563,6 +563,11 @@ ssize_t proc_set_mcc_sta_bw80_target_tp(struct file *file, const char __user *bu
int proc_get_mcc_policy_table(struct seq_file *m, void *v);
#endif /* CONFIG_MCC_MODE */
#ifdef CONFIG_RTW_SW_LED
int proc_get_led_ctrl(struct seq_file *m, void *v);
ssize_t proc_set_led_ctrl(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data);
#endif /* CONFIG_RTW_SW_LED */
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);

View File

@ -105,7 +105,7 @@ int rtw_check_fw_ps = 1;
int rtw_early_mode = 1;
#endif
#ifdef CONFIG_SW_LED
#ifdef CONFIG_RTW_SW_LED
int rtw_led_ctrl = 1; // default to normal blink
#endif
@ -465,7 +465,7 @@ module_param(rtw_pci_aspm_enable, int, 0644);
module_param(rtw_early_mode, int, 0644);
#endif
#ifdef CONFIG_SW_LED
#ifdef CONFIG_RTW_SW_LED
module_param(rtw_led_ctrl, int, 0644);
MODULE_PARM_DESC(rtw_led_ctrl,"Led Control: 0=Always off, 1=Normal blink, 2=Always on");
#endif
@ -1015,7 +1015,7 @@ uint loadparam(_adapter *padapter)
#ifdef CONFIG_TX_EARLY_MODE
registry_par->early_mode = (u8)rtw_early_mode;
#endif
#ifdef CONFIG_SW_LED
#ifdef CONFIG_RTW_SW_LED
registry_par->led_ctrl = (u8)rtw_led_ctrl;
#endif
registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit;

View File

@ -4120,6 +4120,10 @@ const struct rtw_proc_hdl adapter_proc_hdls[] = {
#endif
RTW_PROC_HDL_SSEQ("cur_beacon_keys", proc_get_cur_beacon_keys, NULL),
#ifdef CONFIG_RTW_SW_LED
RTW_PROC_HDL_SSEQ("led_ctrl", proc_get_led_ctrl, proc_set_led_ctrl),
#endif
};
const int adapter_proc_hdls_num = sizeof(adapter_proc_hdls) / sizeof(struct rtw_proc_hdl);