Add ASoC machine driver for Lenovo YB1 tablets
Subsystems (3)
cover Add ASoC machine driver for Lenovo YB1 tablets
This is the first iteration of my submission for sound support for Lenovo Yoga Book YB1-X90/X91 tablets.
These are Cherry Trail-based platforms that use the RT5677 codec and TS3A227E jack detection IC.
The YB1-X90 is an Android-designated device and has incorrect ACPI entries for many onboard peripherals, including sound devices. The YB1-X91 has a DSDT node for the codec, and the same node is shared with the TS3A227E jack detection IC (see below).
Matching with ACPI entries is somewhat tricky; see the corresponding commit. Jack detection IC info is defined in the x86-android-tablets driver for both platforms to simplify the code.
The machine driver is called 'cht_yogabook' because it has some hardcoded device-specific elements and it seems this is the only known Cherry Trail platform using the RT5677 codec. This naming is open to discussion: a more generic name like 'cht_rt5677' or 'cht_bsw_rt5677' may be better (requiring reworking of the driver to make it more generic with device-specific quirks).
The driver requires support for the RT5677 definition as an ACPI node or i2c_board_info, submitted earlier in [1].
1. https://lore.kernel.org/linux-sound/[email protected]/
For reference, there is an ACPI node for sound configuration from YB1-X91 DSDT below:
HID: 10EC5677_CRS resources:
I2C devices:
0: rt5677 codec
1: ts3a227e jack detection IC
GPIOs:
0: rt5677 codec reset
1: rt5677 codec pow-ldo2
2: speaker enable
INTs:
0: rt5677 codec
1: ts3a227e jack detection IC
SPI device:
0: rt5677 codec SPI connection
ACPI decompiled dump fragment:
Device (RTEK)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "10EC5677") // _HID: Hardware ID
Name (_CID, "10EC5677") // _CID: Compatible ID
Name (_DDN, "Realtek IIS Audio Codec") // _DDN: DOS Device Name
Name (_SUB, "17AA7005") // _SUB: Subsystem ID
Name (_UID, One) // _UID: Unique ID
Name (_PR0, Package (0x01) // _PR0: Power Resources for D0
{
CLK3
})
Name (CHAN, Package (0x02)
{
One,
0x0124F800
})
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
I2cSerialBusV2 (0x002C, ControllerInitiated, 0x000186A0,
AddressingMode7Bit, "\\_SB.PCI0.I2C1",
0x00, ResourceConsumer, , Exclusive,
)
I2cSerialBusV2 (0x003B, ControllerInitiated, 0x000186A0,
AddressingMode7Bit, "\\_SB.PCI0.I2C1",
0x00, ResourceConsumer, , Exclusive,
)
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO3", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0019
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO3", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0012
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO3", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0030
}
GpioInt (Edge, ActiveLow, Exclusive, PullNone, 0x0000,
"\\_SB.GPO0", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x005B
}
GpioInt (Edge, ActiveLow, Exclusive, PullNone, 0x0000,
"\\_SB.GPO0", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x004D
}
SpiSerialBusV2 (0x0001, PolarityLow, FourWireMode, 0x08,
ControllerInitiated, 0x003D0900, ClockPolarityHigh,
ClockPhaseSecond, "\\_SB.PCI0.SPI1",
0x00, ResourceConsumer, , Exclusive,
)
})
Return (SBUF) /* \_SB_.PCI0.I2C1.RTEK._CRS.SBUF */
}
}Yauhen Kharuzhy (2):
ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets
ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries
sound/soc/intel/boards/Kconfig | 15 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/cht_yogabook.c | 602 ++++++++++++++++++ .../intel/common/soc-acpi-intel-cht-match.c | 144 +++-- 4 files changed, 713 insertions(+), 50 deletions(-) create mode 100644 sound/soc/intel/boards/cht_yogabook.c
base-commit: 635c467cc14ebdffab3f77610217c1dacaf88e8c
message-id: [email protected]
Signature · 1 line
2.51.0
PATCH 1/2 ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets
Add a new ASoC machine driver for Lenovo Yoga Book Intel Cherry Trail-based tablets (YB1-X90F/L, YB1-X91F/L models).
This platform uses a Realtek ALC5677 codec accompanied by a TS3A227E jack configuration detection IC.
The driver is based on the cht_bsw_rt5672.c mainline driver and the driver from the vendor's Android kernel [1].
There are no other known Cherry Trail platforms using an RT5677 codec, so the driver is named 'cht_yogabook', and some device-specific tricks are hardcoded, such as jack events and additional GPIOs controlling the speaker amplifier.
--- sound/soc/intel/boards/Kconfig | 15 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/cht_yogabook.c | 602 ++++++++++++++++++++++++++ 3 files changed, 619 insertions(+) create mode 100644 sound/soc/intel/boards/cht_yogabook.c
sound/soc/intel/boards/Kconfig +15 -0
@@ -237,6 +237,21 @@ config SND_SOC_INTEL_BYT_CHT_ES8316_MACH Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_CHT_YOGABOOK_MACH + tristate "Cherrytrail-based Lenovo Yoga Book tablet" + depends on I2C && ACPI + depends on X86_INTEL_LPSS || COMPILE_TEST + depends on GPIOLIB || COMPILE_TEST + select SND_SOC_ACPI + select SND_SOC_RT5677 + select SND_SOC_TS3A227E + help + This adds support for ASoC machine driver for the Lenovo Yoga Book + tablets based on CherryTrail platform with RT5677 audio codec, models + YB1-X90F, YB1-X90L, YB1-X91F, YB1-X91L. + Say Y or m if you have such a device. This is a recommended option. + If unsure select "N". + endif ## SND_SST_ATOM_HIFI2_PLATFORM || SND_SOC_SOF_BAYTRAIL if SND_SST_ATOM_HIFI2_PLATFORM
sound/soc/intel/boards/Makefile +2 -0
@@ -15,6 +15,7 @@ snd-soc-sst-cht-bsw-nau8824-y := cht_bsw_nau8824.o snd-soc-sst-byt-cht-cx2072x-y := bytcht_cx2072x.o snd-soc-sst-byt-cht-da7213-y := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-y := bytcht_es8316.o +snd-soc-sst-cht-yogabook-objs := cht_yogabook.o snd-soc-sst-byt-cht-nocodec-y := bytcht_nocodec.o snd-soc-sof_rt5682-y := sof_rt5682.o snd-soc-sof_cs42l42-y := sof_cs42l42.o
@@ -47,6 +48,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH) += snd-soc-sst-cht-bsw-nau8824. obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_CX2072X_MACH) += snd-soc-sst-byt-cht-cx2072x.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o +obj-$(CONFIG_SND_SOC_INTEL_CHT_YOGABOOK_MACH) += snd-soc-sst-cht-yogabook.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o obj-$(CONFIG_SND_SOC_INTEL_EHL_RT5660_MACH) += snd-soc-ehl-rt5660.o
sound/soc/intel/boards/cht_yogabook.c new file +602 -0
602 lines not on this page · raw message
Signature · 1 line
2.51.0
Pierre-Louis Bossart
reviewerRe: [PATCH v1 1/2] ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets
Thanks for the patch, looks mostly good to me, see below a couple of comments.
Quoted 6 lines
sound/soc/intel/boards/cht_yogabook.c new file +6
-0+static int cht_yb_hp_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_card *card =snd_soc_dapm_to_card (w->dapm); +struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); +
sound/soc/intel/boards/cht_yogabook.c line 121
Quoted 10 lines
sound/soc/intel/boards/cht_yogabook.c new file +10
-0+dev_dbg (card->dev,"HP event: %s\n" , +SND_SOC_DAPM_EVENT_ON (event) ?"ON" :"OFF" ); + +if (SND_SOC_DAPM_EVENT_ON (event)) { +msleep (20 ); +gpiod_set_value_cansleep (ctx->gpio_hp_en,1 ); +msleep (50 ); + }else { +gpiod_set_value_cansleep (ctx->gpio_hp_en,0 ); + }
It'd be worth having a comment on why you need the 2 separate msleep. IIRC for Broadwell we only had a common 70ms sleep for both enable and disable.
Quoted 18 lines
sound/soc/intel/boards/cht_yogabook.c new file +18
-0+ +return 0 ; +} + +static int cht_yb_spk_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_card *card =snd_soc_dapm_to_card (w->dapm); +struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); + +dev_dbg (card->dev,"SPK event: %s\n" , +SND_SOC_DAPM_EVENT_ON (event) ?"ON" :"OFF" ); + +/* Black magic from the Lenovo's Android kernel +* FIXME: Check if it is needed, an original comment: +* "use gpio GPIO_SPK_EN to enable/disable ext boost pa +* use mode 3" +*/
sound/soc/intel/boards/cht_yogabook.c line 149
Quoted 10 lines
sound/soc/intel/boards/cht_yogabook.c new file +10
-0+if (SND_SOC_DAPM_EVENT_ON (event)) { +gpiod_set_value_cansleep (ctx->gpio_spk_en1,1 ); +udelay (2 ); +gpiod_set_value_cansleep (ctx->gpio_spk_en1,0 ); +udelay (2 ); +gpiod_set_value_cansleep (ctx->gpio_spk_en1,1 ); +udelay (2 ); +gpiod_set_value_cansleep (ctx->gpio_spk_en1,0 ); +udelay (2 ); + }
That seems weird indeed, never seen this before. What happens if that block is removed?
Quoted 17 lines
sound/soc/intel/boards/cht_yogabook.c new file +16
-0+gpiod_set_value_cansleep (ctx->gpio_spk_en1, +SND_SOC_DAPM_EVENT_ON (event)); +gpiod_set_value_cansleep (ctx->gpio_spk_en2, +SND_SOC_DAPM_EVENT_ON (event)); +msleep (50 ); + +return 0 ; +} + +static int cht_yb_codec_fixup (struct snd_soc_pcm_runtime *rtd, +struct snd_pcm_hw_params *params) +{ +struct snd_interval *rate =hw_param_interval (params, +SNDRV_PCM_HW_PARAM_RATE ); +struct snd_interval *channels =hw_param_interval (params, +SNDRV_PCM_HW_PARAM_CHANNELS );
sound/soc/intel/boards/cht_yogabook.c line 350
Quoted 10 lines
sound/soc/intel/boards/cht_yogabook.c new file +10
-0+ +/* The DSP will convert the FE rate to 48k, stereo, 24bits */ + rate->min = rate->max =48000 ; + channels->min = channels->max =2 ; + +/* +* set SSP2 to 24-bit +* Looks like strange black magic because ssp2-port supports S16LE +* format only, taken from Intel's code +*/
No, SSP2 supports 24 bits in TDM mode. only SSP0 has firmware restrictions to S16LE.
Quoted 16 lines
sound/soc/intel/boards/cht_yogabook.c new file +16
-0+params_set_format (params,SNDRV_PCM_FORMAT_S24_LE ); + +return 0 ; +} + +static struct snd_soc_jack_pin cht_yb_jack_pins[] = { + { + .pin ="Headphone" , + .mask =SND_JACK_HEADPHONE , + }, + { + .pin ="Headset Mic" , + .mask =SND_JACK_MICROPHONE , + }, +}; +
Re: [PATCH v1 1/2] ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets
Quoted 13 lines · Pierre-Louis Bossart
Thanks for the patch, looks mostly good to me, see below a couple of comments.
Quoted 11 lines
sound/soc/intel/boards/cht_yogabook.c new file +11
-0+static int cht_yb_hp_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_card *card =snd_soc_dapm_to_card (w->dapm); +struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); + +dev_dbg (card->dev,"HP event: %s\n" , +SND_SOC_DAPM_EVENT_ON (event) ?"ON" :"OFF" ); + +if (SND_SOC_DAPM_EVENT_ON (event)) { +msleep (20 );
Quoted 8 lines
sound/soc/intel/boards/cht_yogabook.c line 121
Quoted 5 lines
sound/soc/intel/boards/cht_yogabook.c new file +5
-0+gpiod_set_value_cansleep (ctx->gpio_hp_en,1 ); +msleep (50 ); + }else { +gpiod_set_value_cansleep (ctx->gpio_hp_en,0 ); + }It'd be worth having a comment on why you need the 2 separate msleep. IIRC for Broadwell we only had a common 70ms sleep for both enable and disable.
Actually I don't know, it just a copy-paste from the Lenovo Android kernel code, and I didn't check what happens if this sleeps are removed, AFAIR, if there are any sound artifacts or something else.
Will check.
Quoted 23 lines
Quoted 23 lines
sound/soc/intel/boards/cht_yogabook.c new file +22
-0+ +return 0 ; +} + +static int cht_yb_spk_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *k,int event) +{ +struct snd_soc_card *card =snd_soc_dapm_to_card (w->dapm); +struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); + +dev_dbg (card->dev,"SPK event: %s\n" , +SND_SOC_DAPM_EVENT_ON (event) ?"ON" :"OFF" ); + +/* Black magic from the Lenovo's Android kernel +* FIXME: Check if it is needed, an original comment: +* "use gpio GPIO_SPK_EN to enable/disable ext boost pa +* use mode 3" +*/ +if (SND_SOC_DAPM_EVENT_ON (event)) { +gpiod_set_value_cansleep (ctx->gpio_spk_en1,1 ); +udelay (2 ); +gpiod_set_value_cansleep (ctx->gpio_spk_en1,0 );
Quoted 8 lines
sound/soc/intel/boards/cht_yogabook.c line 149
Quoted 6 lines
sound/soc/intel/boards/cht_yogabook.c new file +6
-0+udelay (2 ); +gpiod_set_value_cansleep (ctx->gpio_spk_en1,1 ); +udelay (2 ); +gpiod_set_value_cansleep (ctx->gpio_spk_en1,0 ); +udelay (2 ); + }That seems weird indeed, never seen this before. What happens if that block is removed?
Sure. Will check, I cannot remember if I checked this during initial porting...
Quoted 22 lines
Quoted 22 lines
sound/soc/intel/boards/cht_yogabook.c new file +20
-0+gpiod_set_value_cansleep (ctx->gpio_spk_en1, +SND_SOC_DAPM_EVENT_ON (event)); +gpiod_set_value_cansleep (ctx->gpio_spk_en2, +SND_SOC_DAPM_EVENT_ON (event)); +msleep (50 ); + +return 0 ; +} + +static int cht_yb_codec_fixup (struct snd_soc_pcm_runtime *rtd, +struct snd_pcm_hw_params *params) +{ +struct snd_interval *rate =hw_param_interval (params, +SNDRV_PCM_HW_PARAM_RATE ); +struct snd_interval *channels =hw_param_interval (params, +SNDRV_PCM_HW_PARAM_CHANNELS ); + +/* The DSP will convert the FE rate to 48k, stereo, 24bits */ + rate->min = rate->max =48000 ; + channels->min = channels->max =2 ;
Quoted 8 lines
sound/soc/intel/boards/cht_yogabook.c line 350
Quoted 6 lines
sound/soc/intel/boards/cht_yogabook.c new file +6
-0+ +/* +* set SSP2 to 24-bit +* Looks like strange black magic because ssp2-port supports S16LE +* format only, taken from Intel's code +*/ No, SSP2 supports 24 bits in TDM mode. only SSP0 has firmware restrictions to S16LE.
Thanks, I even don't remember why I added this comment. To be removed.
Quoted 17 lines
Quoted 17 lines
sound/soc/intel/boards/cht_yogabook.c new file +16
-0+params_set_format (params,SNDRV_PCM_FORMAT_S24_LE ); + +return 0 ; +} + +static struct snd_soc_jack_pin cht_yb_jack_pins[] = { + { + .pin ="Headphone" , + .mask =SND_JACK_HEADPHONE , + }, + { + .pin ="Headset Mic" , + .mask =SND_JACK_MICROPHONE , + }, +}; +
Signature · 1 line
Yauhen Kharuzhy
PATCH 2/2 ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries
In reply to Yauhen KharuzhyLenovo Yoga Book YB1-X91 device uses a Cherry Trail SoC and has a valid ACPI DSDT entry for the RT5677 codec. This entry has some non-standard resource definitions, such as jack detection chip information, and hardware has some additional GPIO controls so use 'cht-yogabook' for the driver name instead of some default (like 'cht-bsw-rt5677').
Lenovo Yoga Book YB1-X90 device (Android version of the tablet) has the same hardware configuration but lacks a valid ACPI DSDT entry for the codec. To match this device, extend the existing quirk designated for the Lenovo Yoga Tab 3 Pro YT3-X90 and make it more generic: select a matched machine using the dmi_check_system() quirk mechanism.
--- .../intel/common/soc-acpi-intel-cht-match.c | 144 ++++++++++++------ 1 file changed, 94 insertions(+), 50 deletions(-)
sound/soc/intel/common/soc-acpi-intel-cht-match.c +94 -50
@@ -9,13 +9,47 @@#include <sound/soc-acpi.h> #include <sound/soc-acpi-intel-match.h> -static unsigned long cht_machine_id; +static struct snd_soc_acpi_mach *cht_quirk_mach; -#define CHT_SURFACE_MACH 1 +static struct snd_soc_acpi_mach cht_surface_mach = { + .id ="10EC5640" , + .drv_name ="cht-bsw-rt5645" , + .fw_filename ="intel/fw_sst_22a8.bin" , + .board ="cht-bsw" , + .sof_tplg_filename ="sof-cht-rt5645.tplg" , +}; + +static struct snd_soc_acpi_mach cht_yogabook_mach = { + .id ="10EC5677" , + .drv_name ="cht-yogabook" , + .fw_filename ="intel/fw_sst_22a8.bin" , + .board ="cht-yogabook" , + .sof_tplg_filename ="sof-cht-rt5677.tplg" , +}; + +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 int cht_surface_quirk_cb (const struct dmi_system_id *id) { - cht_machine_id =CHT_SURFACE_MACH ; + cht_quirk_mach = &cht_surface_mach; +return 1 ; +} + +static int cht_yogabook_quirk_cb (const struct dmi_system_id *id) +{ + cht_quirk_mach = &cht_yogabook_mach; +return 1 ; +} + +static int cht_yt3_quirk_cb (const struct dmi_system_id *id) +{ + cht_quirk_mach = &cht_lenovo_yoga_tab3_x90_mach;return 1 ; }
@@ -27,29 +61,57 @@ static const struct dmi_system_id cht_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), }, }, + { + .callback = cht_yogabook_quirk_cb, + .ident = "Lenovo Yoga Book YB1-X91", + /* YB1-X91L/F */ + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"), + } + }, + { + .callback = cht_yogabook_quirk_cb, + .ident = "Lenovo Yoga Book YB1-X90", + /* YB1-X90L/F, codec is not listed in DSDT */ + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), + } + }, + { + /* + * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS + * has a buggy DSDT with the codec not being listed at all. + */ + .callback = cht_yt3_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"), + }, + }, { } }; -static struct snd_soc_acpi_mach cht_surface_mach = { - .id ="10EC5640" , - .drv_name ="cht-bsw-rt5645" , - .fw_filename ="intel/fw_sst_22a8.bin" , - .board ="cht-bsw" , - .sof_tplg_filename ="sof-cht-rt5645.tplg" , -}; - static struct snd_soc_acpi_mach *cht_quirk(void *arg) { struct snd_soc_acpi_mach *mach = arg; dmi_check_system(cht_table); -if (cht_machine_id ==CHT_SURFACE_MACH ) -return &cht_surface_mach; + if (cht_quirk_mach) + return cht_quirk_mach; else return mach; } +static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg) +{ + struct snd_soc_acpi_mach *mach = cht_quirk(arg); + + return mach == arg ? NULL : mach; +} + /* * Some tablets with Android factory OS have buggy DSDTs with an ESSX8316 device * in the ACPI tables. While they are not using an ESS8316 codec. These DSDTs
@@ -75,38 +137,6 @@ 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_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" },
@@ -137,6 +167,20 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .board = "cht-bsw", .sof_tplg_filename = "sof-cht-rt5670.tplg", }, +/* +* The only known Cherry Trail device with RT5677 codec and 10EC677 +* DSTD entry is the Lenovo Yoga Book YB1-X91. It has a device-specific +* driver, so check DMI and use a machine quirk to override the default +* (non-existent) machine driver. +*/ + { + .id = "10EC5677", + .drv_name = "cht-bsw-rt5677", + .fw_filename = "intel/fw_sst_22a8.bin", + .board = "cht-bsw", + .machine_quirk = cht_quirk, + .sof_tplg_filename = "sof-cht-rt5677.tplg", + }, { .comp_ids = &rt5645_comp_ids, .drv_name = "cht-bsw-rt5645",
@@ -208,14 +252,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .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. +* Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 and Lenovo +* Yoga Book YB1-X90 where the DSDT misses the codec. Match on the +* SST id instead, cht_quirk_nocodec() will return a machine-specific +* mach or NULL when called on other hw, skipping this entry. */ { .id = "808622A8", - .machine_quirk = lenovo_yt3_x90_quirk, + .machine_quirk = cht_quirk_nocodec, },#if IS_ENABLED (CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH )
Signature · 1 line
2.51.0
Pierre-Louis Bossart
reviewerRe: [PATCH v1 2/2] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries
Quoted 6 lines · Yauhen Kharuzhy
Lenovo Yoga Book YB1-X91 device uses a Cherry Trail SoC and has a valid ACPI DSDT entry for the RT5677 codec. This entry has some non-standard resource definitions, such as jack detection chip information, and hardware has some additional GPIO controls so use 'cht-yogabook' for the driver name instead of some default (like 'cht-bsw-rt5677').
Quoted 7 lines
Lenovo Yoga Book YB1-X90 device (Android version of the tablet) has the same hardware configuration but lacks a valid ACPI DSDT entry for the codec. To match this device, extend the existing quirk designated for the Lenovo Yoga Tab 3 Pro YT3-X90 and make it more generic: select a matched machine using the
dmi_check_system()quirk mechanism.Signed-off-by Yauhen Kharuzhy <[email protected]>
Looks ok to me, but since this is touching 10-yr old stuff maybe it's worth having a patch that only merged the existing quirks together. Then you can add a new set of entries. Easier to review/test/bisect.
Quoted 207 lines
--- .../intel/common/soc-acpi-intel-cht-match.c | 144 ++++++++++++------ 1 file changed, 94 insertions(+), 50 deletions(-)sound/soc/intel/common/soc-acpi-intel-cht-match.c +94
-50@@ -9,13 +9,47 @@#include <sound/soc-acpi.h> #include <sound/soc-acpi-intel-match.h> -static unsigned long cht_machine_id; +static struct snd_soc_acpi_mach *cht_quirk_mach; -#define CHT_SURFACE_MACH 1 +static struct snd_soc_acpi_mach cht_surface_mach = { + .id ="10EC5640" , + .drv_name ="cht-bsw-rt5645" , + .fw_filename ="intel/fw_sst_22a8.bin" , + .board ="cht-bsw" , + .sof_tplg_filename ="sof-cht-rt5645.tplg" , +}; + +static struct snd_soc_acpi_mach cht_yogabook_mach = { + .id ="10EC5677" , + .drv_name ="cht-yogabook" , + .fw_filename ="intel/fw_sst_22a8.bin" , + .board ="cht-yogabook" , + .sof_tplg_filename ="sof-cht-rt5677.tplg" , +}; + +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 int cht_surface_quirk_cb (const struct dmi_system_id *id) { - cht_machine_id =CHT_SURFACE_MACH ; + cht_quirk_mach = &cht_surface_mach; +return 1 ; +} + +static int cht_yogabook_quirk_cb (const struct dmi_system_id *id) +{ + cht_quirk_mach = &cht_yogabook_mach; +return 1 ; +} + +static int cht_yt3_quirk_cb (const struct dmi_system_id *id) +{ + cht_quirk_mach = &cht_lenovo_yoga_tab3_x90_mach;return 1 ; }@@ -27,29 +61,57 @@ static const struct dmi_system_id cht_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), }, }, + { + .callback = cht_yogabook_quirk_cb, + .ident = "Lenovo Yoga Book YB1-X91", + /* YB1-X91L/F */ + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"), + } + }, + { + .callback = cht_yogabook_quirk_cb, + .ident = "Lenovo Yoga Book YB1-X90", + /* YB1-X90L/F, codec is not listed in DSDT */ + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), + } + }, + { + /* + * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS + * has a buggy DSDT with the codec not being listed at all. + */ + .callback = cht_yt3_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"), + }, + }, { } }; -static struct snd_soc_acpi_mach cht_surface_mach = { - .id ="10EC5640" , - .drv_name ="cht-bsw-rt5645" , - .fw_filename ="intel/fw_sst_22a8.bin" , - .board ="cht-bsw" , - .sof_tplg_filename ="sof-cht-rt5645.tplg" , -}; - static struct snd_soc_acpi_mach *cht_quirk(void *arg) { struct snd_soc_acpi_mach *mach = arg; dmi_check_system(cht_table); -if (cht_machine_id ==CHT_SURFACE_MACH ) -return &cht_surface_mach; + if (cht_quirk_mach) + return cht_quirk_mach; else return mach; } +static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg) +{ + struct snd_soc_acpi_mach *mach = cht_quirk(arg); + + return mach == arg ? NULL : mach; +} + /* * Some tablets with Android factory OS have buggy DSDTs with an ESSX8316 device * in the ACPI tables. While they are not using an ESS8316 codec. These DSDTs@@ -75,38 +137,6 @@ 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_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" },@@ -137,6 +167,20 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .board = "cht-bsw", .sof_tplg_filename = "sof-cht-rt5670.tplg", }, +/* +* The only known Cherry Trail device with RT5677 codec and 10EC677 +* DSTD entry is the Lenovo Yoga Book YB1-X91. It has a device-specific +* driver, so check DMI and use a machine quirk to override the default +* (non-existent) machine driver. +*/ + { + .id = "10EC5677", + .drv_name = "cht-bsw-rt5677", + .fw_filename = "intel/fw_sst_22a8.bin", + .board = "cht-bsw", + .machine_quirk = cht_quirk, + .sof_tplg_filename = "sof-cht-rt5677.tplg", + }, { .comp_ids = &rt5645_comp_ids, .drv_name = "cht-bsw-rt5645",@@ -208,14 +252,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .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. +* Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 and Lenovo +* Yoga Book YB1-X90 where the DSDT misses the codec. Match on the +* SST id instead, cht_quirk_nocodec() will return a machine-specific +* mach or NULL when called on other hw, skipping this entry. */ { .id = "808622A8", - .machine_quirk = lenovo_yt3_x90_quirk, + .machine_quirk = cht_quirk_nocodec, },#if IS_ENABLED (CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH )
Re: [PATCH v1 2/2] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries
Quoted 13 lines · Pierre-Louis Bossart
Quoted 12 lines · Yauhen Kharuzhy
Lenovo Yoga Book YB1-X91 device uses a Cherry Trail SoC and has a valid ACPI DSDT entry for the RT5677 codec. This entry has some non-standard resource definitions, such as jack detection chip information, and hardware has some additional GPIO controls so use 'cht-yogabook' for the driver name instead of some default (like 'cht-bsw-rt5677').
Lenovo Yoga Book YB1-X90 device (Android version of the tablet) has the same hardware configuration but lacks a valid ACPI DSDT entry for the codec. To match this device, extend the existing quirk designated for the Lenovo Yoga Tab 3 Pro YT3-X90 and make it more generic: select a matched machine using the
dmi_check_system()quirk mechanism.
Quoted 4 lines
Quoted 1 line
Signed-off-by Yauhen Kharuzhy <[email protected]>Looks ok to me, but since this is touching 10-yr old stuff maybe it's worth having a patch that only merged the existing quirks together. Then you can add a new set of entries. Easier to review/test/bisect.
Agree, that sounds reasonable.
What about the driver naming? In this patch, I used 'cht-bsw-rt5677' as the default driver name, but this driver doesn't exist (and I doubt it ever will in the future). Should we use this 'template' approach, or add a 'cht-yogabook' driver entry only, or rename 'cht-yogabook' to the generic 'cht-bsw-rt5677'?
Signature · 1 line
Yauhen Kharuzhy