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>
This commit is contained in:
Marco Giunta 2026-07-17 15:25:04 +02:00 committed by Mark Brown
parent 7fa44519a2
commit df5654d730
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -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;
}