Linux wireless drivers development
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Arsenii Pashchenko <ulijg308@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH rtw-next v7 2/3] wifi: rtw88: rtw8822c: Convert DAC IQ calibration path to signed math
Date: Fri, 28 Aug 2026 08:29:58 +0000	[thread overview]
Message-ID: <d662dcab866042c08f050cfe035c7c70@realtek.com> (raw)
In-Reply-To: <86bde9882c56a1245a4c903b607e23d551dde1b9.1787895379.git.ulijg308@gmail.com>

Arsenii Pashchenko <ulijg308@gmail.com> wrote:
> Convert the temporary stack arrays 'iv' and 'qv' from u32 to s32.
> Update all internal function signatures to accept s32 pointers and
> handle signed values natively.
> 
> Use sign_extend32() combined with FIELD_GET_SIGNED() to properly interpret
> the 10-bit hardware values as signed integers. This allows flattening
> the complex nested unsigned boundary conditions in
> rtw8822c_dac_iq_check() into a simple amplitude boundary check. Ensure
> rtw8822c_dac_iq_offset() properly maps the signed average back to a
> 10-bit unsigned format expected by the hardware registers via GENMASK().
> 
> Signed-off-by: Arsenii Pashchenko <ulijg308@gmail.com>

[...]

> -static void rtw8822c_dac_iq_offset(struct rtw_dev *rtwdev, u32 *vec, u32 *val)
> +static u32 rtw8822c_dac_iq_offset(struct rtw_dev *rtwdev, s32 *vec)
>  {
> -       u32 p, m, t, i;
> +       s32 sum = 0;
> +       s32 avg;
> +       u32 i;
> 
> -       m = 0;
> -       p = 0;
> -       for (i = 10; i < DACK_SN_8822C - 10; i++) {
> -               if (vec[i] > 0x200)
> -                       m = (0x400 - vec[i]) + m;
> -               else
> -                       p = vec[i] + p;
> -       }
> +       for (i = 10; i < DACK_SN_8822C - 10; i++)
> +               sum += vec[i];
> 
> -       if (p > m) {
> -               t = p - m;
> -               t = t / (DACK_SN_8822C - 20);
> -       } else {
> -               t = m - p;
> -               t = t / (DACK_SN_8822C - 20);
> -               if (t != 0x0)
> -                       t = 0x400 - t;
> -       }
> +       avg = sum / (DACK_SN_8822C - 20);
> 
> -       *val = t;
> +       /* Map the signed average back to a 10-bit hardware format.
> +        * Example: avg = -1, returns 0x3FF (signed 10-bit value)
> +        */

The first line of comment block should be empty, like

/*
 * comment start here.
 * second.
 */

> +       return avg & GENMASK(9, 0);
>  }
> 
>  static u32 rtw8822c_get_path_write_addr(u8 path)



  reply	other threads:[~2026-08-28  8:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  5:40 [PATCH rtw-next v7 0/3] wifi: rtw88: rtw8822c: refactor DAC IQ calibration to s32 Arsenii Pashchenko
2026-08-28  5:40 ` [PATCH rtw-next v7 1/3] wifi: rtw88: rtw8822c: Use bitfield macros for DAC IQ sampling Arsenii Pashchenko
2026-08-28  8:23   ` Ping-Ke Shih
2026-08-28  5:40 ` [PATCH rtw-next v7 2/3] wifi: rtw88: rtw8822c: Convert DAC IQ calibration path to signed math Arsenii Pashchenko
2026-08-28  8:29   ` Ping-Ke Shih [this message]
2026-08-28  5:40 ` [PATCH rtw-next v7 3/3] wifi: rtw88: rtw8822c: Replace custom DAC IQ sorting with kernel sort Arsenii Pashchenko
2026-08-28  8:24   ` Ping-Ke Shih

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=d662dcab866042c08f050cfe035c7c70@realtek.com \
    --to=pkshih@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=ulijg308@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