summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Giunta <marco_giunta@outlook.it>2026-07-17 15:25:04 +0200
committerMark Brown <broonie@kernel.org>2026-07-21 19:16:05 +0100
commitdf5654d7306197087aef090377d196573bb4ee46 (patch)
tree1a81af79f17f2d9c25d6138a517fe240cdff7cbf
parent7fa44519a2a3a9da715669a7f359f08e49911e2f (diff)
ASoC: aw88399: derive channel from I2C address on ACPI systems
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@imitoy.top> Tested-by: Munzir Taha <munzirtaha@gmail.com> Co-developed-by: Yakov Till <yakov.till@gmail.com> Signed-off-by: Yakov Till <yakov.till@gmail.com> Signed-off-by: Marco Giunta <marco_giunta@outlook.it> Link: https://patch.msgid.link/DS7PR19MB772468BB9F4D6925DC4E8E3EFCC62@DS7PR19MB7724.namprd19.prod.outlook.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/aw88399-lib.c14
1 files changed, 13 insertions, 1 deletions
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;
}