[PATCH 2/8] ASoC: aw88399: derive channel from I2C address on ACPI systems
From: Marco Giunta
Date: Fri Jul 17 2026 - 09:27:12 EST
Extend aw88399_parse_channel_dt to derive the audio channel from the
I2C address when the Device Tree property "awinic,audio-channel" is
absent.
The original code calls of_property_read_u32 without checking the
return value. On ACPI systems, the DT property is never present,
and channel_value is used uninitialized in the assignment to
aw_dev->channel.
Add a fallback that computes the channel as (i2c_addr - 0x34), where
0x34 is the AW88399's base I2C address per the datasheet (valid range
0x34-0x37). This channel assignment may be subsequently overridden by
the HDA side codec's property driver on systems that require it.
No change on Device Tree systems where the property is present.
Tested-by: Nadim Kobeissi <nadim@symbolic.software>
Tested-by: Xia Yun'an <imitoy@xxxxxxxxxx>
Tested-by: Munzir Taha <munzirtaha@xxxxxxxxx>
Co-developed-by: Yakov Till <yakov.till@xxxxxxxxx>
Signed-off-by: Yakov Till <yakov.till@xxxxxxxxx>
Signed-off-by: Marco Giunta <marco_giunta@xxxxxxxxxx>
---
sound/soc/codecs/aw88399-lib.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88399-lib.c b/sound/soc/codecs/aw88399-lib.c
index 258d6efbf590..b525695c96d1 100644
--- a/sound/soc/codecs/aw88399-lib.c
+++ b/sound/soc/codecs/aw88399-lib.c
@@ -1328,8 +1328,20 @@ static void aw88399_parse_channel_dt(struct aw_device *aw_dev)
{
struct device_node *np = aw_dev->dev->of_node;
u32 channel_value;
+ int ret;
- of_property_read_u32(np, "awinic,audio-channel", &channel_value);
+ ret = of_property_read_u32(np, "awinic,audio-channel", &channel_value);
+ if (ret) {
+ /*
+ * On ACPI systems, DT properties don't exist. Derive channel
+ * from I2C address: 0x34 -> channel 0 (left), 0x35 -> channel 1 (right)
+ */
+ aw_dev->channel = aw_dev->i2c->addr - 0x34;
+ dev_dbg(aw_dev->dev,
+ "DT channel property not found, using I2C address-based channel %d (addr 0x%02x)\n",
+ aw_dev->channel, aw_dev->i2c->addr);
+ return;
+ }
aw_dev->channel = channel_value;
}
--
2.55.0