* [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk()
@ 2026-11-19 16:30 Marco Giunta
2026-11-19 16:30 ` [PATCH 2/5] ASoC: aw88399: fix sign bit check in aw88399_dev_get_vcalk() Marco Giunta
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Marco Giunta @ 2026-11-19 16:30 UTC (permalink / raw)
To: Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, linux-sound,
linux-kernel, Marco Giunta
AW88261_EF_ISN_GESLP_SIGN_MASK and AW88261_EF_VSN_GESLP_SIGN_MASK are
defined with the usual Awinic inverted-mask convention, i.e. they both
equal ~BIT(9); therefore, their negations have to be used to test the
sign bit.
aw88261_dev_get_icalk() does this correctly:
if (reg_icalk & (~AW88261_EF_ISN_GESLP_SIGN_MASK))
while aw88261_dev_get_vcalk() does not:
if (reg_vcalk & AW88261_EF_VSN_GESLP_SIGN_MASK)
Add the missing negation to fix this. This ensures that the aw88261 driver
behaves like the vendor Android driver it was ported from (aw882xx), and
that it's consistent with the other upstream Awinic drivers that have
analogous functions, i.e. aw88166 and aw88395 (aw88399 has the same bug,
which is fixed in the next patch).
Fixes: 028a2ae25691 ("ASoC: codecs: Add aw88261 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
---
Hi everyone,
I'm currently working on an aw88399 patch series targeting some QOL fixes.
While working on this, I spotted some things needing fixes that I'm
sending separately now, as they are all relatively straightforward.
I checked whether the same bugs were present in other awinic drivers
and found a couple of matches, that are included in this series as
well.
Overall:
* patches 1 & 2 fix a missing bitmask inversion in aw88261 and aw88399;
* patches 3 & 4 fix an OR that should be an AND in aw88166 and aw88399;
* patch 5 fixes a forgotten rename from AW883XX to AW88399 in aw88399.
Best regards,
Marco
sound/soc/codecs/aw88261.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index e14df93e67f7..d4db919d8a2d 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -306,7 +306,7 @@ static int aw88261_dev_get_vcalk(struct aw_device *aw_dev, int16_t *vcalk)
reg_vcalk = (reg_vcalk >> AW88261_VCALK_SHIFT) & (reg_vcalkl >> AW88261_VCALKL_SHIFT);
- if (reg_vcalk & AW88261_EF_VSN_GESLP_SIGN_MASK)
+ if (reg_vcalk & (~AW88261_EF_VSN_GESLP_SIGN_MASK))
reg_vcalk = reg_vcalk | (~AW88261_EF_VSN_GESLP_NEG);
*vcalk = (int16_t)reg_vcalk;
base-commit: 20a21fd8ba1bb23c907ee5709f9232a9c84710a1
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] ASoC: aw88399: fix sign bit check in aw88399_dev_get_vcalk()
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
@ 2026-11-19 16:30 ` Marco Giunta
2026-11-19 16:30 ` [PATCH 3/5] ASoC: aw88166: fix clearing of SYSCTRL bits Marco Giunta
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marco Giunta @ 2026-11-19 16:30 UTC (permalink / raw)
To: Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, linux-sound,
linux-kernel, Marco Giunta
AW88399_EF_ISN_GESLP_SIGN_MASK and AW88399_EF_VSN_GESLP_SIGN_MASK are
defined with the usual Awinic inverted-mask convention, i.e. they both
equal ~BIT(9); therefore, their negations have to be used to test the
sign bit.
aw88399_dev_get_icalk() does this correctly:
if (icalk_val & (~AW88399_EF_ISN_GESLP_SIGN_MASK))
while aw88399_dev_get_vcalk() does not:
if (vcalk_val & AW88399_EF_VSN_GESLP_SIGN_MASK)
Add the missing negation to fix this. This ensures that the aw88399 driver
behaves like the vendor Android driver it was ported from (aw883xx), and
that it's consistent with the other upstream Awinic drivers that have
analogous functions, i.e. aw88166, aw88261, and aw88395.
Fixes: 8ade6cc7e261 ("ASoC: codecs: Add aw88399 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
---
sound/soc/codecs/aw88399-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88399-lib.c b/sound/soc/codecs/aw88399-lib.c
index f2e2c88f5ec0..39a752171aa1 100644
--- a/sound/soc/codecs/aw88399-lib.c
+++ b/sound/soc/codecs/aw88399-lib.c
@@ -296,7 +296,7 @@ static int aw88399_dev_get_vcalk(struct aw88399 *aw88399, int16_t *vcalk)
else
vcalk_val = vcalkh_val | vcalkl_val;
- if (vcalk_val & AW88399_EF_VSN_GESLP_SIGN_MASK)
+ if (vcalk_val & (~AW88399_EF_VSN_GESLP_SIGN_MASK))
vcalk_val = vcalk_val | AW88399_EF_VSN_GESLP_SIGN_NEG;
*vcalk = (int16_t)vcalk_val;
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] ASoC: aw88166: fix clearing of SYSCTRL bits
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
2026-11-19 16:30 ` [PATCH 2/5] ASoC: aw88399: fix sign bit check in aw88399_dev_get_vcalk() Marco Giunta
@ 2026-11-19 16:30 ` Marco Giunta
2026-11-19 16:30 ` [PATCH 4/5] ASoC: aw88399: " Marco Giunta
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marco Giunta @ 2026-11-19 16:30 UTC (permalink / raw)
To: Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, linux-sound,
linux-kernel, Marco Giunta
When applying the SYSCTRL value from the firmware,
aw_dev_update_reg_container() means to overwrite the HMUTE, PWDN and DSPBY
bits with fixed values, by clearing them and then taking the OR with the
intended values.
This is the same behavior as the Android driver aw88166 was ported from
(aw883xx), which does so field by field, and as the upstream aw88081
and aw88261 drivers, which manually compute a collective mask and
perform a single VAL &= MASK.
Currently, the aw88166 driver takes the latter approach, by computing MASK
as AW88166_HMUTE_MASK | AW88166_PWDN_MASK | AW88166_DSPBY_MASK.
As per the usual Awinic inverted-mask convention, these macros equal
~BIT(8), ~BIT(0) and ~BIT(2) respectively, so using OR on them yields all
ones and clears nothing.
Use AND instead, as commit b82fa9b0c26e ("ASoC: codecs: aw88261: Fix
erroneous bitmask logic in Awinic init") did for aw88261.
In practice this makes no difference, since the values ORed in right
afterwards equal BIT(8), BIT(0) and BIT(2): these bits end up set
regardless of whether or not they were previously cleared.
The fix here simply keeps the code correct regardless of the values used.
Fixes: 94e412c28e61 ("ASoC: codecs: Add aw88166 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
---
Alternatively, since the clear is redundant w.r.t. the OR with the *_VALUE
macros, I can add a comment explaining why no clearing is needed and
remove it, if that is preferred.
sound/soc/codecs/aw88166.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88166.c b/sound/soc/codecs/aw88166.c
index a520c9089425..226a36f041d9 100644
--- a/sound/soc/codecs/aw88166.c
+++ b/sound/soc/codecs/aw88166.c
@@ -961,7 +961,7 @@ static int aw_dev_update_reg_container(struct aw88166 *aw88166,
else
aw_dev->dsp_cfg = AW88166_DEV_DSP_WORK;
- reg_val &= (AW88166_HMUTE_MASK | AW88166_PWDN_MASK |
+ reg_val &= (AW88166_HMUTE_MASK & AW88166_PWDN_MASK &
AW88166_DSPBY_MASK);
reg_val |= (AW88166_HMUTE_ENABLE_VALUE | AW88166_PWDN_POWER_DOWN_VALUE |
AW88166_DSPBY_BYPASS_VALUE);
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] ASoC: aw88399: fix clearing of SYSCTRL bits
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
2026-11-19 16:30 ` [PATCH 2/5] ASoC: aw88399: fix sign bit check in aw88399_dev_get_vcalk() Marco Giunta
2026-11-19 16:30 ` [PATCH 3/5] ASoC: aw88166: fix clearing of SYSCTRL bits Marco Giunta
@ 2026-11-19 16:30 ` Marco Giunta
2026-11-19 16:30 ` [PATCH 5/5] ASoC: aw88399: rename AW883XX_* macros to AW88399_* Marco Giunta
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marco Giunta @ 2026-11-19 16:30 UTC (permalink / raw)
To: Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, linux-sound,
linux-kernel, Marco Giunta
When applying the SYSCTRL value from the firmware,
aw_dev_update_reg_container() means to overwrite the HMUTE, PWDN and DSPBY
bits with fixed values, by clearing them and then taking the OR with the
intended values.
This is the same behavior as the Android driver aw88399 was ported from
(aw883xx), which does so field by field, and as the upstream aw88081,
aw88166, and aw88261 drivers, which manually compute a collective mask and
perform a single VAL &= MASK.
Currently, the aw88399 driver takes the latter approach, by computing MASK
as AW88399_HMUTE_MASK | AW88399_PWDN_MASK | AW88399_DSPBY_MASK.
As per the usual Awinic inverted-mask convention, these macros equal
~BIT(8), ~BIT(0) and ~BIT(2) respectively, so using OR on them yields all
ones and clears nothing.
Use AND instead, as commit b82fa9b0c26e ("ASoC: codecs: aw88261: Fix
erroneous bitmask logic in Awinic init") did for aw88261.
In practice this makes no difference, since the values ORed in right
afterwards equal BIT(8), BIT(0) and BIT(2): these bits end up set
regardless of whether or not they were previously cleared.
The fix here simply keeps the code correct regardless of the values used.
Fixes: 8ade6cc7e261 ("ASoC: codecs: Add aw88399 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
---
Alternatively, since the clear is redundant w.r.t. the OR with the *_VALUE
macros, I can add a comment explaining why no clearing is needed and
remove it, if that is preferred.
sound/soc/codecs/aw88399-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88399-lib.c b/sound/soc/codecs/aw88399-lib.c
index 39a752171aa1..447ac5fb01a1 100644
--- a/sound/soc/codecs/aw88399-lib.c
+++ b/sound/soc/codecs/aw88399-lib.c
@@ -957,7 +957,7 @@ static int aw_dev_update_reg_container(struct aw88399 *aw88399,
else
aw_dev->dsp_cfg = AW88399_DEV_DSP_WORK;
- reg_val &= (AW88399_HMUTE_MASK | AW88399_PWDN_MASK |
+ reg_val &= (AW88399_HMUTE_MASK & AW88399_PWDN_MASK &
AW88399_DSPBY_MASK);
reg_val |= (AW88399_HMUTE_ENABLE_VALUE | AW88399_PWDN_POWER_DOWN_VALUE |
AW88399_DSPBY_BYPASS_VALUE);
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] ASoC: aw88399: rename AW883XX_* macros to AW88399_*
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
` (2 preceding siblings ...)
2026-11-19 16:30 ` [PATCH 4/5] ASoC: aw88399: " Marco Giunta
@ 2026-11-19 16:30 ` Marco Giunta
2026-11-19 16:40 ` [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Mark Brown
2026-11-22 22:06 ` Vladyslav Tymoshchuk
5 siblings, 0 replies; 7+ messages in thread
From: Marco Giunta @ 2026-11-19 16:30 UTC (permalink / raw)
To: Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, linux-sound,
linux-kernel, Marco Giunta
The aw88399 library header at include/sound/aw88399.h defines all its
macros as AW88399_*, apart from a few AW883XX_* ones.
These are likely an oversight from when the generic Android vendor driver,
aw883xx, was originally ported upstream in an aw88399-specialized version.
Rename these macros to AW88399_* to make them consistent with the rest of
the header.
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
---
include/sound/aw88399.h | 14 +++++++-------
sound/soc/codecs/aw88399.c | 6 +++---
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/sound/aw88399.h b/include/sound/aw88399.h
index d72c491ee866..fa43e8068093 100644
--- a/include/sound/aw88399.h
+++ b/include/sound/aw88399.h
@@ -469,13 +469,13 @@
#define AW88399_DSP_VOL_MASK \
(~(((1<<AW88399_DSP_VOL_BITS_LEN)-1) << AW88399_DSP_VOL_START_BIT))
-#define AW883XX_DSP_NG_EN_START (13)
-#define AW883XX_DSP_NG_EN_LEN (1)
-#define AW883XX_DSP_NG_EN_MASK \
- (~(((1 << AW883XX_DSP_NG_EN_LEN) - 1) << AW883XX_DSP_NG_EN_START))
-#define AW883XX_DSP_NG_EN_DISABLE (0)
-#define AW883XX_DSP_NG_EN_DISABLE_VALUE \
- (AW883XX_DSP_NG_EN_DISABLE << AW883XX_DSP_NG_EN_START)
+#define AW88399_DSP_NG_EN_START (13)
+#define AW88399_DSP_NG_EN_LEN (1)
+#define AW88399_DSP_NG_EN_MASK \
+ (~(((1 << AW88399_DSP_NG_EN_LEN) - 1) << AW88399_DSP_NG_EN_START))
+#define AW88399_DSP_NG_EN_DISABLE (0)
+#define AW88399_DSP_NG_EN_DISABLE_VALUE \
+ (AW88399_DSP_NG_EN_DISABLE << AW88399_DSP_NG_EN_START)
#define AW88399_VOLUME_STEP_DB (64)
#define AW88399_VOL_DEFAULT_VALUE (0)
diff --git a/sound/soc/codecs/aw88399.c b/sound/soc/codecs/aw88399.c
index 1275ac601bcb..28a9803a693f 100644
--- a/sound/soc/codecs/aw88399.c
+++ b/sound/soc/codecs/aw88399.c
@@ -106,7 +106,7 @@ static int aw_cali_svc_cali_en(struct aw_device *aw_dev, bool cali_en)
aw_dev_dsp_enable(aw_dev, false);
if (cali_en) {
regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG,
- ~AW883XX_DSP_NG_EN_MASK, AW883XX_DSP_NG_EN_DISABLE_VALUE);
+ ~AW88399_DSP_NG_EN_MASK, AW88399_DSP_NG_EN_DISABLE_VALUE);
aw_dev_dsp_write(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR,
AW88399_DSP_LOW_POWER_SWITCH_DISABLE, AW_DSP_16_DATA);
@@ -166,7 +166,7 @@ static void aw_cali_svc_backup_info(struct aw_device *aw_dev)
unsigned int reg_val, dsp_val;
regmap_read(aw_dev->regmap, AW88399_DBGCTRL_REG, ®_val);
- backup_desc->dsp_ng_cfg = reg_val & (~AW883XX_DSP_NG_EN_MASK);
+ backup_desc->dsp_ng_cfg = reg_val & (~AW88399_DSP_NG_EN_MASK);
aw_dev_dsp_read(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR, &dsp_val, AW_DSP_16_DATA);
@@ -178,7 +178,7 @@ static void aw_cali_svc_recover_info(struct aw_device *aw_dev)
struct aw_cali_backup_desc *backup_desc = &aw_dev->cali_desc.backup_info;
regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG,
- ~AW883XX_DSP_NG_EN_MASK, backup_desc->dsp_ng_cfg);
+ ~AW88399_DSP_NG_EN_MASK, backup_desc->dsp_ng_cfg);
aw_dev_dsp_write(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR,
backup_desc->dsp_lp_cfg, AW_DSP_16_DATA);
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk()
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
` (3 preceding siblings ...)
2026-11-19 16:30 ` [PATCH 5/5] ASoC: aw88399: rename AW883XX_* macros to AW88399_* Marco Giunta
@ 2026-11-19 16:40 ` Mark Brown
2026-11-22 22:06 ` Vladyslav Tymoshchuk
5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2026-11-19 16:40 UTC (permalink / raw)
To: Marco Giunta
Cc: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, linux-sound, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]
On Thu, Nov 19, 2026 at 05:30:12PM +0100, Marco Giunta wrote:
> ---
> Hi everyone,
> I'm currently working on an aw88399 patch series targeting some QOL fixes.
>
> While working on this, I spotted some things needing fixes that I'm
> sending separately now, as they are all relatively straightforward.
>
> I checked whether the same bugs were present in other awinic drivers
> and found a couple of matches, that are included in this series as
> well.
>
> Overall:
>
> * patches 1 & 2 fix a missing bitmask inversion in aw88261 and aw88399;
> * patches 3 & 4 fix an OR that should be an AND in aw88166 and aw88399;
> * patch 5 fixes a forgotten rename from AW883XX to AW88399 in aw88399.
As covered in submitting-patches.rst this stuff should be in a cover
letter, patch 0 for the series. No need to resend for just this.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk()
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
` (4 preceding siblings ...)
2026-11-19 16:40 ` [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Mark Brown
@ 2026-11-22 22:06 ` Vladyslav Tymoshchuk
5 siblings, 0 replies; 7+ messages in thread
From: Vladyslav Tymoshchuk @ 2026-11-22 22:06 UTC (permalink / raw)
To: Marco Giunta
Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
linux-sound, linux-kernel
On Thu, Nov 19, 2026 at 05:30:12PM +0100, Marco Giunta wrote:
> - if (reg_vcalk & AW88261_EF_VSN_GESLP_SIGN_MASK)
> + if (reg_vcalk & (~AW88261_EF_VSN_GESLP_SIGN_MASK))
I have been carrying the same one-line change in my tree for the
OnePlus Pad 3 (SM8750, two AW88261) since October, and the speakers
have been in daily use with it since then.
Reviewed-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
Tested-by: Vladyslav Tymoshchuk <tvlad744@gmail.com> # OnePlus Pad 3
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-22 22:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 16:30 [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Marco Giunta
2026-11-19 16:30 ` [PATCH 2/5] ASoC: aw88399: fix sign bit check in aw88399_dev_get_vcalk() Marco Giunta
2026-11-19 16:30 ` [PATCH 3/5] ASoC: aw88166: fix clearing of SYSCTRL bits Marco Giunta
2026-11-19 16:30 ` [PATCH 4/5] ASoC: aw88399: " Marco Giunta
2026-11-19 16:30 ` [PATCH 5/5] ASoC: aw88399: rename AW883XX_* macros to AW88399_* Marco Giunta
2026-11-19 16:40 ` [PATCH 1/5] ASoC: aw88261: fix sign bit check in aw88261_dev_get_vcalk() Mark Brown
2026-11-22 22:06 ` Vladyslav Tymoshchuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®