diff mbox series

[1/6] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Tab 3 Pro YT3-X90 quirk

Message ID 20231021211534.114991-1-hdegoede@redhat.com (mailing list archive)
State Accepted
Commit 2cb54788393134d8174ee594002baae3ce52c61e
Headers show
Series [1/6] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Tab 3 Pro YT3-X90 quirk | expand

Commit Message

Hans de Goede Oct. 21, 2023, 9:15 p.m. UTC
The Lenovo Yoga Tab 3 Pro YT3-X90 x86 tablet, which ships with Android with
a custom kernel as factory OS, does not list the used WM5102 codec inside
its DSDT.

Workaround this with a new snd_soc_acpi_intel_baytrail_machines[] entry
which matches on the SST id instead of the codec id like nocodec does,
combined with using a machine_quirk callback which returns NULL on
other machines to skip the new entry on other machines.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../intel/common/soc-acpi-intel-cht-match.c   | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)

Comments

Pierre-Louis Bossart Oct. 23, 2023, 6:45 p.m. UTC | #1
On 10/21/23 16:15, Hans de Goede wrote:
> The Lenovo Yoga Tab 3 Pro YT3-X90 x86 tablet, which ships with Android with
> a custom kernel as factory OS, does not list the used WM5102 codec inside
> its DSDT.
> 
> Workaround this with a new snd_soc_acpi_intel_baytrail_machines[] entry
> which matches on the SST id instead of the codec id like nocodec does,
> combined with using a machine_quirk callback which returns NULL on
> other machines to skip the new entry on other machines.

The work-around sounds fine, but out of curiosity what causes the codec
driver to probe if there's no ACPI HID?

Really wondering how we avoid the -517 error code with the deferred
probe never completing because the codec driver never probed and
registered the needed components?
Hans de Goede Oct. 23, 2023, 7:23 p.m. UTC | #2
Hi,

On 10/23/23 20:45, Pierre-Louis Bossart wrote:
> 
> 
> On 10/21/23 16:15, Hans de Goede wrote:
>> The Lenovo Yoga Tab 3 Pro YT3-X90 x86 tablet, which ships with Android with
>> a custom kernel as factory OS, does not list the used WM5102 codec inside
>> its DSDT.
>>
>> Workaround this with a new snd_soc_acpi_intel_baytrail_machines[] entry
>> which matches on the SST id instead of the codec id like nocodec does,
>> combined with using a machine_quirk callback which returns NULL on
>> other machines to skip the new entry on other machines.
> 
> The work-around sounds fine, but out of curiosity what causes the codec
> driver to probe if there's no ACPI HID?
> 
> Really wondering how we avoid the -517 error code with the deferred
> probe never completing because the codec driver never probed and
> registered the needed components?


These x86 android tablets ship with pretty broken DSDTs with
A whole bunch of (usually i2c) devices missing like
e.g. the touchscreen and the accelerometer.

For the factory Android install this is not an issue because
it uses drivers which instantiate the i2c-clients itself using
hardcoded i2c-bus, i2c-address and irqs.

To make this work under Linux I've written a special helper
"driver" which loads only on these broken DSDT devices
based on DMI modalias and then identifies the exact
model (also by DMI) and instantiates the correct devices
from this "driver" (really more of an old fashioned
board file). This code also adds all the necessary
properties, etc. to make standard drivers work, so all
model specific knowledge missing from the DSDT is encoded
in this special x86-android-tablets driver.

I've also submitted a patch for that driver to instantiate
the codec SPI device using spi_device_id matching instead
of acpi_device_id matching:

https://lore.kernel.org/platform-driver-x86/20231014205314.59333-5-hdegoede@redhat.com/

So this is the other side of the puzzle, I hope this
helps explain how I actually got this working.

Regards,

Hans
Pierre-Louis Bossart Oct. 23, 2023, 7:37 p.m. UTC | #3
On 10/23/23 14:23, Hans de Goede wrote:
> Hi,
> 
> On 10/23/23 20:45, Pierre-Louis Bossart wrote:
>>
>>
>> On 10/21/23 16:15, Hans de Goede wrote:
>>> The Lenovo Yoga Tab 3 Pro YT3-X90 x86 tablet, which ships with Android with
>>> a custom kernel as factory OS, does not list the used WM5102 codec inside
>>> its DSDT.
>>>
>>> Workaround this with a new snd_soc_acpi_intel_baytrail_machines[] entry
>>> which matches on the SST id instead of the codec id like nocodec does,
>>> combined with using a machine_quirk callback which returns NULL on
>>> other machines to skip the new entry on other machines.
>>
>> The work-around sounds fine, but out of curiosity what causes the codec
>> driver to probe if there's no ACPI HID?
>>
>> Really wondering how we avoid the -517 error code with the deferred
>> probe never completing because the codec driver never probed and
>> registered the needed components?
> 
> 
> These x86 android tablets ship with pretty broken DSDTs with
> A whole bunch of (usually i2c) devices missing like
> e.g. the touchscreen and the accelerometer.
> 
> For the factory Android install this is not an issue because
> it uses drivers which instantiate the i2c-clients itself using
> hardcoded i2c-bus, i2c-address and irqs.
> 
> To make this work under Linux I've written a special helper
> "driver" which loads only on these broken DSDT devices
> based on DMI modalias and then identifies the exact
> model (also by DMI) and instantiates the correct devices
> from this "driver" (really more of an old fashioned
> board file). This code also adds all the necessary
> properties, etc. to make standard drivers work, so all
> model specific knowledge missing from the DSDT is encoded
> in this special x86-android-tablets driver.
> 
> I've also submitted a patch for that driver to instantiate
> the codec SPI device using spi_device_id matching instead
> of acpi_device_id matching:
> 
> https://lore.kernel.org/platform-driver-x86/20231014205314.59333-5-hdegoede@redhat.com/
> 
> So this is the other side of the puzzle, I hope this
> helps explain how I actually got this working.

Ah yes, thanks Hans for the information. The amount of work-arounds for
a broken DSDT and enumeration is just mind-boggling.... Oh well.

For the series

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mark Brown Oct. 24, 2023, 6:53 p.m. UTC | #4
On Sat, 21 Oct 2023 23:15:28 +0200, Hans de Goede wrote:
> The Lenovo Yoga Tab 3 Pro YT3-X90 x86 tablet, which ships with Android with
> a custom kernel as factory OS, does not list the used WM5102 codec inside
> its DSDT.
> 
> Workaround this with a new snd_soc_acpi_intel_baytrail_machines[] entry
> which matches on the SST id instead of the codec id like nocodec does,
> combined with using a machine_quirk callback which returns NULL on
> other machines to skip the new entry on other machines.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Tab 3 Pro YT3-X90 quirk
      commit: 2cb54788393134d8174ee594002baae3ce52c61e
[2/6] ASoC: Intel: bytcr_wm5102: Add support for Lenovo Yoga Tab 3 Pro YT3-X90
      commit: 109cb2160128211ca7b17bad79cb0441f1440bc9
[3/6] ASoC: Intel: bytcr_wm5102: Add BYT_WM5102_SSP2 quirk
      (no commit info)
[4/6] ASoC: Intel: bytcr_wm5102: Add BYT_WM5102_MCLK_19_2MHZ quirk
      (no commit info)
[5/6] ASoC: Intel: bytcr_wm5102: Add BYT_WM5102_OUT_MAP quirk
      (no commit info)
[6/6] ASoC: Intel: bytcr_wm5102: Add BYT_WM5102_IN_MAP quirk
      (no commit info)

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
index cdcbf04b8832..5e2ec60e2954 100644
--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
@@ -75,6 +75,39 @@  static struct snd_soc_acpi_mach *cht_ess8316_quirk(void *arg)
 	return arg;
 }
 
+/*
+ * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS has a buggy DSDT
+ * with the coded not being listed at all.
+ */
+static const struct dmi_system_id lenovo_yoga_tab3_x90[] = {
+	{
+		/* Lenovo Yoga Tab 3 Pro YT3-X90, codec missing from DSDT */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
+			DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
+		},
+	},
+	{ }
+};
+
+static struct snd_soc_acpi_mach cht_lenovo_yoga_tab3_x90_mach = {
+	.id = "10WM5102",
+	.drv_name = "bytcr_wm5102",
+	.fw_filename = "intel/fw_sst_22a8.bin",
+	.board = "bytcr_wm5102",
+	.sof_tplg_filename = "sof-cht-wm5102.tplg",
+};
+
+static struct snd_soc_acpi_mach *lenovo_yt3_x90_quirk(void *arg)
+{
+	if (dmi_check_system(lenovo_yoga_tab3_x90))
+		return &cht_lenovo_yoga_tab3_x90_mach;
+
+	/* Skip wildcard match snd_soc_acpi_intel_cherrytrail_machines[] entry */
+	return NULL;
+}
+
 static const struct snd_soc_acpi_codecs rt5640_comp_ids = {
 	.num_codecs = 2,
 	.codecs = { "10EC5640", "10EC3276" },
@@ -175,6 +208,16 @@  struct snd_soc_acpi_mach  snd_soc_acpi_intel_cherrytrail_machines[] = {
 		.drv_name = "sof_pcm512x",
 		.sof_tplg_filename = "sof-cht-src-50khz-pcm512x.tplg",
 	},
+	/*
+	 * Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 where the DSDT
+	 * misses the codec. Match on the SST id instead, lenovo_yt3_x90_quirk()
+	 * will return a YT3 specific mach or NULL when called on other hw,
+	 * skipping this entry.
+	 */
+	{
+		.id = "808622A8",
+		.machine_quirk = lenovo_yt3_x90_quirk,
+	},
 
 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
 	/*