Skip to content

Commit d48696b

Browse files
jwrdegoedebroonie
authored andcommitted
ASoC: Intel: bytcr_rt5640: Add support for non ACPI instantiated codec
On some x86 Bay Trail tablets which shipped with Android as factory OS, the DSDT is so broken that the codec needs to be manually instantatiated by the special x86-android-tablets.ko "fixup" driver for cases like this. This means that the codec-dev cannot be retrieved through its ACPI fwnode, add support to the bytcr_rt5640 machine driver for such manually instantiated rt5640 i2c_clients. An example of a tablet which needs this is the Vexia EDU ATLA 10 tablet, which has been distributed to schools in the Spanish Andalucía region. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://patch.msgid.link/20241024211615.79518-1-hdegoede@redhat.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 032532f commit d48696b

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

sound/soc/intel/boards/bytcr_rt5640.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/acpi.h>
1818
#include <linux/clk.h>
1919
#include <linux/device.h>
20+
#include <linux/device/bus.h>
2021
#include <linux/dmi.h>
2122
#include <linux/gpio/consumer.h>
2223
#include <linux/gpio/machine.h>
@@ -32,6 +33,8 @@
3233
#include "../atom/sst-atom-controls.h"
3334
#include "../common/soc-intel-quirks.h"
3435

36+
#define BYT_RT5640_FALLBACK_CODEC_DEV_NAME "i2c-rt5640"
37+
3538
enum {
3639
BYT_RT5640_DMIC1_MAP,
3740
BYT_RT5640_DMIC2_MAP,
@@ -1698,9 +1701,33 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
16981701

16991702
codec_dev = acpi_get_first_physical_node(adev);
17001703
acpi_dev_put(adev);
1701-
if (!codec_dev)
1702-
return -EPROBE_DEFER;
1703-
priv->codec_dev = get_device(codec_dev);
1704+
1705+
if (codec_dev) {
1706+
priv->codec_dev = get_device(codec_dev);
1707+
} else {
1708+
/*
1709+
* Special case for Android tablets where the codec i2c_client
1710+
* has been manually instantiated by x86_android_tablets.ko due
1711+
* to a broken DSDT.
1712+
*/
1713+
codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
1714+
BYT_RT5640_FALLBACK_CODEC_DEV_NAME);
1715+
if (!codec_dev)
1716+
return -EPROBE_DEFER;
1717+
1718+
if (!i2c_verify_client(codec_dev)) {
1719+
dev_err(dev, "Error '%s' is not an i2c_client\n",
1720+
BYT_RT5640_FALLBACK_CODEC_DEV_NAME);
1721+
put_device(codec_dev);
1722+
}
1723+
1724+
/* fixup codec name */
1725+
strscpy(byt_rt5640_codec_name, BYT_RT5640_FALLBACK_CODEC_DEV_NAME,
1726+
sizeof(byt_rt5640_codec_name));
1727+
1728+
/* bus_find_device() returns a reference no need to get() */
1729+
priv->codec_dev = codec_dev;
1730+
}
17041731

17051732
/*
17061733
* swap SSP0 if bytcr is detected

0 commit comments

Comments
 (0)