ASoC: SOF: Intel: override mclk_id for ES8336 support
Subsystems (3)
v2 cover ASoC: SOF: Intel: override mclk_id for ES8336 support
This patchset solves a known issue with ES8336 platforms wrt MCLK selection. Most of the devices use the MCLK0 signal, but some devices do use the MCLK1 signal.
The MCLK is defined in the topology, it would be a nightmare to generate more topology files just for one MCLK difference. With a minor extension to the intel-nhlt library, the MCLK information can be found by parsing the NHLT table, and we can override the mclk_id at boot time.
The only known issues for this platform remain the detection of GPIO and microphone connections, currently only possible with manual quirks.
Thanks to Eugene J. Markow for testing this patchset.
v2: addressed comments from Takashi and Amadeusz Better error handling for the 1.5 case
Report error at the library level when 2 mclks are used
Pierre-Louis Bossart (4):
ASoC: SOF: Intel: hda: refine SSP count support
ASoC: SOF: add quirk to override topology mclk_id
ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask()
ASoC: SOF: Intel: hda: override mclk_id after parsing NHLT SSP blob
include/sound/intel-nhlt.h | 7 ++++ sound/hda/intel-nhlt.c | 79 +++++++++++++++++++++++++++++++++++ sound/soc/sof/intel/hda.c | 39 +++++++++++++++++ sound/soc/sof/intel/hda.h | 2 + sound/soc/sof/intel/mtl.c | 2 +- sound/soc/sof/intel/tgl.c | 8 ++-- sound/soc/sof/ipc3-topology.c | 7 ++++ sound/soc/sof/sof-priv.h | 4 ++ 8 files changed, 143 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 ASoC: SOF: Intel: hda: refine SSP count support
The SSP count is incorrect for TGL and MTL devices, the SSP count is limited to 3 (I2SPC parameter in the Integration HAS).
--- sound/soc/sof/intel/hda.h | 2 ++ sound/soc/sof/intel/mtl.c | 2 +- sound/soc/sof/intel/tgl.c | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-)
sound/soc/sof/intel/hda.h +2 -0
@@ -435,6 +435,8 @@#define APL_SSP_COUNT 6#define CNL_SSP_COUNT 3#define ICL_SSP_COUNT 6 +#define TGL_SSP_COUNT 3 +#define MTL_SSP_COUNT 3/* SSP Registers */ #define SSP_SSC1_OFFSET 0x4
sound/soc/sof/intel/mtl.c +1 -1
@@ -784,7 +784,7 @@ const struct sof_intel_dsp_desc mtl_chip_info = { .ipc_ctl = MTL_DSP_REG_HFIPCXCTL, .rom_status_reg = MTL_DSP_ROM_STS, .rom_init_timeout = 300, - .ssp_count = ICL_SSP_COUNT, + .ssp_count = MTL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, .sdw_shim_base = SDW_SHIM_BASE_ACE, .sdw_alh_base = SDW_ALH_BASE_ACE,
sound/soc/sof/intel/tgl.c +4 -4
@@ -123,7 +123,7 @@ const struct sof_intel_dsp_desc tgl_chip_info = { .ipc_ctl = CNL_DSP_REG_HIPCCTL, .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, .rom_init_timeout = 300, - .ssp_count = ICL_SSP_COUNT, + .ssp_count = TGL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, .sdw_shim_base = SDW_SHIM_BASE, .sdw_alh_base = SDW_ALH_BASE,
@@ -146,7 +146,7 @@ const struct sof_intel_dsp_desc tglh_chip_info = { .ipc_ctl = CNL_DSP_REG_HIPCCTL, .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, .rom_init_timeout = 300, - .ssp_count = ICL_SSP_COUNT, + .ssp_count = TGL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, .sdw_shim_base = SDW_SHIM_BASE, .sdw_alh_base = SDW_ALH_BASE,
@@ -169,7 +169,7 @@ const struct sof_intel_dsp_desc ehl_chip_info = { .ipc_ctl = CNL_DSP_REG_HIPCCTL, .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, .rom_init_timeout = 300, - .ssp_count = ICL_SSP_COUNT, + .ssp_count = TGL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, .sdw_shim_base = SDW_SHIM_BASE, .sdw_alh_base = SDW_ALH_BASE,
@@ -192,7 +192,7 @@ const struct sof_intel_dsp_desc adls_chip_info = { .ipc_ctl = CNL_DSP_REG_HIPCCTL, .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, .rom_init_timeout = 300, - .ssp_count = ICL_SSP_COUNT, + .ssp_count = TGL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, .sdw_shim_base = SDW_SHIM_BASE, .sdw_alh_base = SDW_ALH_BASE,
Signature · 1 line
2.34.1
PATCH v2 2/4 ASoC: SOF: add quirk to override topology mclk_id
In reply to Pierre-Louis BossartSome Intel-based platforms rely on a topology file that hard-codes the use of MCLK0. This is incorrect in 10% of the cases. Rather than generating yet another set of topology files, this patch adds a kernel module parameter to override the topology value.
In hindsight, we should never have allowed mclks to be specified in topology, this is a hardware-level information that should not have been visible in the topology.
Future patches will try to set this value automagically, e.g. by parsing the NHLT content.
--- sound/soc/sof/intel/hda.c | 11 +++++++++++ sound/soc/sof/ipc3-topology.c | 7 +++++++ sound/soc/sof/sof-priv.h | 4 ++++ 3 files changed, 22 insertions(+)
sound/soc/sof/intel/hda.c +11 -0
@@ -376,6 +376,10 @@ static int dmic_num_override = -1;module_param_named (dmic_num, dmic_num_override, int,0444 );MODULE_PARM_DESC (dmic_num,"SOF HDA DMIC number" ); +static int mclk_id_override =-1 ; +module_param_named (mclk_id, mclk_id_override, int,0444 ); +MODULE_PARM_DESC (mclk_id,"SOF SSP mclk_id" ); +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )static bool hda_codec_use_common_hdmi =IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI );module_param_named (use_common_hdmi, hda_codec_use_common_hdmi, bool,0444 );
@@ -1565,6 +1569,13 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) sof_pdata->tplg_filename = tplg_filename; } + +/* check if mclk_id should be modified from topology defaults */ +if (mclk_id_override >=0 ) { +dev_info (sdev->dev,"Overriding topology with MCLK %d from kernel_parameter\n" , mclk_id_override); + sdev->mclk_id_override = true; + sdev->mclk_id_quirk = mclk_id_override; + } }/*
sound/soc/sof/ipc3-topology.c +7 -0
@@ -1249,6 +1249,7 @@ static int sof_link_afe_load(struct snd_soc_component *scomp, struct snd_sof_daistatic int sof_link_ssp_load (struct snd_soc_component *scomp,struct snd_sof_dai_link *slink,struct sof_ipc_dai_config *config,struct snd_sof_dai *dai) { +struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;struct sof_dai_private_data *private = dai->private;u32 size =sizeof (*config);
@@ -1273,6 +1274,12 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, struct snd_sof_dai config[i].hdr.size = size; +if (sdev->mclk_id_override) { +dev_dbg (scomp->dev,"tplg: overriding topology mclk_id %d by quirk %d\n" , + config[i].ssp.mclk_id, sdev->mclk_id_quirk); + config[i].ssp.mclk_id = sdev->mclk_id_quirk; + } +/* copy differentiating hw configs to ipc structs */ config[i].ssp.mclk_rate =le32_to_cpu (hw_config[i].mclk_rate); config[i].ssp.bclk_rate =le32_to_cpu (hw_config[i].bclk_rate);
sound/soc/sof/sof-priv.h +4 -0
@@ -601,6 +601,10 @@ struct snd_sof_dev {/* to protect the ipc_rx_handler_list and dsp_state_handler_list list */ struct mutex client_event_handler_mutex; +/* quirks to override topology values */ +bool mclk_id_override; +u16 mclk_id_quirk;/* same size as in IPC3 definitions */ +void *private;/* core does not touch this */ };
Signature · 1 line
2.34.1
PATCH v2 3/4 ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask()
In reply to Pierre-Louis BossartSOF topologies hard-code the MCLK used for SSP connections. That was a bad idea in hindsight, this information should really come from BIOS and/or machine driver.
This patch introduces a helper to scan all SSP endpoints connected to a codec, and all formats to see what MCLK is used. When BIT(0) of the mdivc offset if set in the SSP blob, MCLK0 is used, and likewise when BIT(1) is set MCLK1 is used.
The case where both MCLKs are used is possible but has never been seen in practice so should be treated as an error by the caller.
--- include/sound/intel-nhlt.h | 7 ++++ sound/hda/intel-nhlt.c | 79 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+)
include/sound/intel-nhlt.h +7 -0
@@ -136,6 +136,8 @@ bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type);int intel_nhlt_ssp_endpoint_mask (struct nhlt_acpi_table *nhlt,u8 device_type); +int intel_nhlt_ssp_mclk_mask (struct nhlt_acpi_table *nhlt,int ssp_num); +struct nhlt_specific_cfg * intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, u32 bus_id, u8 link_type, u8 vbps, u8 bps,
@@ -169,6 +171,11 @@ static inline int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8return 0 ; } +static inline int intel_nhlt_ssp_mclk_mask (struct nhlt_acpi_table *nhlt,int ssp_num) +{ +return 0 ; +} +static inline struct nhlt_specific_cfg * intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, u32 bus_id, u8 link_type, u8 vbps, u8 bps,
sound/hda/intel-nhlt.c +79 -0
85 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 3/4] ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask()
Quoted 10 lines · Pierre-Louis Bossart
SOF topologies hard-code the MCLK used for SSP connections. That was a bad idea in hindsight, this information should really come from BIOS and/or machine driver.
This patch introduces a helper to scan all SSP endpoints connected to a codec, and all formats to see what MCLK is used. When BIT(0) of the mdivc offset if set in the SSP blob, MCLK0 is used, and likewise when BIT(1) is set MCLK1 is used.
Quoted 6 lines
The case where both MCLKs are used is possible but has never been seen in practice so should be treated as an error by the caller.
Signed-off-by Pierre-Louis Bossart <[email protected]>Reviewed-by Kai Vehmanen <[email protected]>Reviewed-by Bard Liao <[email protected]>
thanks,
Takashi
PATCH v2 4/4 ASoC: SOF: Intel: hda: override mclk_id after parsing NHLT SSP blob
In reply to Pierre-Louis BossartThe NHLT is already used to determine which SSP is connected to an audio codec, we can parse the SSP blob to get the mclk_id from NHLT.
--- sound/soc/sof/intel/hda.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
sound/soc/sof/intel/hda.c +28 -0
@@ -753,6 +753,18 @@ static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev)return ssp_mask; } +static int check_nhlt_ssp_mclk_mask (struct snd_sof_dev *sdev,int ssp_num) +{ +struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; +struct nhlt_acpi_table *nhlt; + + nhlt = hdev->nhlt; +if (!nhlt) +return 0 ; + +return intel_nhlt_ssp_mclk_mask (nhlt, ssp_num); +} +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) ||IS_ENABLED (CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE ) static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
@@ -1533,6 +1545,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) mach->mach_params.i2s_link_mask) {const struct sof_intel_dsp_desc *chip =get_chip_info (sdev->pdata);int ssp_num; +int mclk_mask;if (hweight_long (mach->mach_params.i2s_link_mask) >1 && !(mach->tplg_quirk_mask &SND_SOC_ACPI_TPLG_INTEL_SSP_MSB ))
@@ -1557,6 +1570,21 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) sof_pdata->tplg_filename = tplg_filename; add_extension = true; + + mclk_mask =check_nhlt_ssp_mclk_mask (sdev, ssp_num); + +if (mclk_mask <0 ) { +dev_err (sdev->dev,"Invalid MCLK configuration\n" ); +return NULL ; + } + +dev_dbg (sdev->dev,"MCLK mask %#x found in NHLT\n" , mclk_mask); + +if (mclk_mask) { +dev_info (sdev->dev,"Overriding topology with MCLK mask %#x from NHLT\n" , mclk_mask); + sdev->mclk_id_override = true; + sdev->mclk_id_quirk = (mclk_mask &BIT (0 )) ?0 :1 ; + } }if (tplg_fixup && add_extension) {
Signature · 1 line
2.34.1
Mark Brown
maintainerQuoted 11 lines · Pierre-Louis Bossart
This patchset solves a known issue with ES8336 platforms wrt MCLK selection. Most of the devices use the MCLK0 signal, but some devices do use the MCLK1 signal.
The MCLK is defined in the topology, it would be a nightmare to generate more topology files just for one MCLK difference. With a minor extension to the intel-nhlt library, the MCLK information can be found by parsing the NHLT table, and we can override the
mclk_idat boot time.[...]
Applied to
broonie/sound.git for-next
Thanks!
[1/4] ASoC: SOF: Intel: hda: refine SSP count support
commit: 9ccbc2e12e01b39b804774c3207d2474dd992d95
[2/4] ASoC: SOF: add quirk to override topology mclk_id
commit: d136949dd8e2e309dc2f186507486b71cbe9acdb
[3/4] ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask()
commit: 72176fccd5de1d9cf61e42771bb00567723f3353
[4/4] ASoC: SOF: Intel: hda: override mclk_id after parsing NHLT SSP blob
commit: d9252772cdc811beedabbcf21ef856d09b87d1ddAll 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