public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: Zenm Chen <zenmchen@gmail.com>, Jes.Sorensen@gmail.com
Cc: kvalo@kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, pkshih@realtek.com
Subject: Re: [PATCH] wifi: rtl8xxxu: fix LED control code of RTL8192FU
Date: Mon, 11 Sep 2023 15:41:21 +0300	[thread overview]
Message-ID: <2984eff5-528e-4a27-bfa0-502210d84b79@gmail.com> (raw)
In-Reply-To: <20230910002038.56362-1-zenmchen@gmail.com>

On 10/09/2023 03:20, Zenm Chen wrote:
> ASUS USB-N13 C1 is a wifi adapter based on a RTL8192FU chip and its LED
> doesn't blink with the rtl8xxxu driver. This patch fix this via writing
> the correct value to the register "REG_LEDCFG0".
> 
> This was tested with these two wifi adapters:
> ASUS USB-N13 C1	(vid=0x0b05, pid=0x18f1, rfe_type=0x1)
> MERCURY MW310UH	(vid=0x0bda, pid=0xf192, rfe_type=0x5)
> 
> Signed-off-by: Zenm Chen <zenmchen@gmail.com>
> ---
>  .../realtek/rtl8xxxu/rtl8xxxu_8192f.c         | 24 ++++++++-----------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c
> index 28e93835e05a..ab6d4e4e228e 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c
> @@ -2014,26 +2014,22 @@ static int rtl8192fu_led_brightness_set(struct led_classdev *led_cdev,
>  	struct rtl8xxxu_priv *priv = container_of(led_cdev,
>  						  struct rtl8xxxu_priv,
>  						  led_cdev);
> -	u16 ledcfg;
> +	u32 ledcfg;
>  
>  	/* Values obtained by observing the USB traffic from the Windows driver. */
>  	rtl8xxxu_write32(priv, REG_SW_GPIO_SHARE_CTRL_0, 0x20080);
>  	rtl8xxxu_write32(priv, REG_SW_GPIO_SHARE_CTRL_1, 0x1b0000);
>  
> -	ledcfg = rtl8xxxu_read16(priv, REG_LEDCFG0);
> -
> -	if (brightness == LED_OFF) {
> -		/* Value obtained like above. */
> -		ledcfg = BIT(1) | BIT(7);
> -	} else if (brightness == LED_ON) {
> -		/* Value obtained like above. */
> -		ledcfg = BIT(1) | BIT(7) | BIT(11);
> -	} else if (brightness == RTL8XXXU_HW_LED_CONTROL) {
> -		/* Value obtained by brute force. */
> -		ledcfg = BIT(8) | BIT(9);
> -	}
> +	/* Enable LED0 GPIO and turn LED0/LED1 off. */
> +	ledcfg = (rtl8xxxu_read32(priv, REG_LEDCFG0) | BIT(21)) & ~0xffff;
> +
> +	/* Values obtained by brute force. */
> +	if (brightness == LED_ON)
> +		ledcfg |= BIT(3) | BIT(11);

Can you explain in the commit message why you changed the
LED_ON and LED_OFF branches? It's not obvious to me and they
don't have anything to do with the hardware-controlled blinking.

> +	else if (brightness == RTL8XXXU_HW_LED_CONTROL)
> +		ledcfg |= BIT(0) | BIT(1) | BIT(8) | BIT(9);
>  
> -	rtl8xxxu_write16(priv, REG_LEDCFG0, ledcfg);
> +	rtl8xxxu_write32(priv, REG_LEDCFG0, ledcfg);
>  
>  	return 0;
>  }

My Comfast CF-826F still works fine with this patch.

  parent reply	other threads:[~2023-09-11 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-10  0:20 [PATCH] wifi: rtl8xxxu: fix LED control code of RTL8192FU Zenm Chen
2023-09-11  3:45 ` Ping-Ke Shih
2023-09-11 12:41 ` Bitterblue Smith [this message]
2023-09-11 14:41 ` xx777
2023-09-12  4:54 ` Zenm Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2984eff5-528e-4a27-bfa0-502210d84b79@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=Jes.Sorensen@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=zenmchen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox