[alsa-devel] [RESEND PATCH] ASoC: intel: Add Broadwell rt5650 machine driver

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Wed Dec 4 02:23:34 CET 2019



On 12/3/19 7:11 PM, Curtis Malainey wrote:
> From: Ben Zhang <benzh at chromium.org>
> 
> Add machine driver for Broadwell + rt5650.

Curtis, you may want to take a look at the comments posted on July 22. I 
quickly re-added the obvious ones below.

We can improve this a bit and make it SOF-ready - or at least avoid 
build conflicts.

> 
> Signed-off-by: Bard Liao <bardliao at realtek.com>
> Signed-off-by: Ben Zhang <benzh at chromium.org>
> Signed-off-by: Mac Chiang <mac.chiang at intel.com>
> Signed-off-by: Jon Flatley <jflat at chromium.org>
> Signed-off-by: Curtis Malainey <cujomalainey at chromium.org>
> ---
>   sound/soc/intel/boards/Kconfig                |  11 +
>   sound/soc/intel/boards/Makefile               |   2 +
>   sound/soc/intel/boards/bdw-rt5650.c           | 310 ++++++++++++++++++
>   .../common/soc-acpi-intel-hsw-bdw-match.c     |   5 +
>   4 files changed, 328 insertions(+)
>   create mode 100644 sound/soc/intel/boards/bdw-rt5650.c
> 
> diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
> index 6c9fd9ad566ed..5f31fadd2e1a1 100644
> --- a/sound/soc/intel/boards/Kconfig
> +++ b/sound/soc/intel/boards/Kconfig
> @@ -31,6 +31,17 @@ endif ## SND_SOC_INTEL_HASWELL
>   
>   if SND_SOC_INTEL_HASWELL || SND_SOC_SOF_BROADWELL
>   
> +config SND_SOC_INTEL_BDW_RT5650_MACH
> +	tristate "Broadwell with RT5650 codec"
> +	depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC

Intel sst is not needed

Also need to aligned with other machine drivers.

> +	select SND_COMPRESS_OFFLOAD

not needed?

> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/delay.h>
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/soc.h>
> +#include <sound/pcm_params.h>
> +#include <sound/jack.h>

sound/soc-acpi.h

> +
> +#include "../common/sst-dsp.h"
> +#include "../haswell/sst-haswell-ipc.h"
> +

> +static struct snd_soc_ops bdw_rt5650_ops = {
> +	.hw_params = bdw_rt5650_hw_params,
> +};
> +
> +static int bdw_rt5650_rtd_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct snd_soc_component *component =
> +		snd_soc_rtdcom_lookup(rtd, DRV_NAME);
> +	struct sst_pdata *pdata = dev_get_platdata(component->dev);
> +	struct sst_hsw *broadwell = pdata->dsp;
> +	int ret;
> +
> +	/* Set ADSP SSP port settings
> +	 * clock_divider = 4 means BCLK = MCLK/5 = 24MHz/5 = 4.8MHz
> +	 */
> +	ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0,
> +		SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
> +		SST_HSW_DEVICE_TDM_CLOCK_MASTER, 4);
> +	if (ret < 0) {
> +		dev_err(rtd->dev, "error: failed to set device config\n");
> +		return ret;
> +	}

add ifdef for SOF

> +
> +	return 0;
> +}
> +
> +static int bdw_rt5650_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct bdw_rt5650_priv *bdw_rt5650 =
> +		snd_soc_card_get_drvdata(rtd->card);
> +	struct snd_soc_component *component = rtd->codec_dai->component;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	int ret;
> +
> +	/* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1.
> +	 * The ASRC clock source is clk_i2s1_asrc.
> +	 */
> +	rt5645_sel_asrc_clk_src(component,
> +				RT5645_DA_STEREO_FILTER |
> +				RT5645_DA_MONO_L_FILTER |
> +				RT5645_DA_MONO_R_FILTER |
> +				RT5645_AD_STEREO_FILTER |
> +				RT5645_AD_MONO_L_FILTER |
> +				RT5645_AD_MONO_R_FILTER,
> +				RT5645_CLK_SEL_I2S1_ASRC);
> +
> +	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
> +	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0xF, 4, 24);
> +
> +	if (ret < 0) {
> +		dev_err(rtd->dev, "can't set codec TDM slot %d\n", ret);
> +		return ret;
> +	}

move to use format defined by topology for SOF?

> +/* ASoC machine driver for Broadwell DSP + RT5650 */
> +static struct snd_soc_card bdw_rt5650_card = {
> +	.name = "bdw-rt5650",
> +	.owner = THIS_MODULE,

is this needed?

> +	.dai_link = bdw_rt5650_dais,
> +	.num_links = ARRAY_SIZE(bdw_rt5650_dais),
> +	.dapm_widgets = bdw_rt5650_widgets,
> +	.num_dapm_widgets = ARRAY_SIZE(bdw_rt5650_widgets),
> +	.dapm_routes = bdw_rt5650_map,
> +	.num_dapm_routes = ARRAY_SIZE(bdw_rt5650_map),
> +	.controls = bdw_rt5650_controls,
> +	.num_controls = ARRAY_SIZE(bdw_rt5650_controls),
> +	.fully_routed = true,
> +};
> +
> +static int bdw_rt5650_probe(struct platform_device *pdev)
> +{
> +	struct bdw_rt5650_priv *bdw_rt5650;
> +
> +	bdw_rt5650_card.dev = &pdev->dev;
> +
> +	/* Allocate driver private struct */
> +	bdw_rt5650 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5650_priv),
> +		GFP_KERNEL);
> +	if (!bdw_rt5650)
> +		return -ENOMEM;

platform override stuff needed.

> +	snd_soc_card_set_drvdata(&bdw_rt5650_card, bdw_rt5650);
> +
> +	return snd_soc_register_card(&bdw_rt5650_card);
> +}
> +
> +static int bdw_rt5650_remove(struct platform_device *pdev)
> +{
> +	snd_soc_unregister_card(&bdw_rt5650_card);
> +	return 0;
> +}
> +
> +static struct platform_driver bdw_rt5650_audio = {
> +	.probe = bdw_rt5650_probe,
> +	.remove = bdw_rt5650_remove,
> +	.driver = {
> +		.name = "bdw-rt5650",
> +		.owner = THIS_MODULE,

is this needed?

> +	},
> +};
> +
> +module_platform_driver(bdw_rt5650_audio)
> +
> +/* Module information */
> +MODULE_AUTHOR("Ben Zhang <benzh at chromium.org>");
> +MODULE_DESCRIPTION("Intel Broadwell RT5650 machine driver");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:bdw-rt5650");
> diff --git a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c
> index 34eb0baaa9517..cae1e559ec79b 100644
> --- a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c
> +++ b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c
> @@ -29,6 +29,11 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_broadwell_machines[] = {
>   		.sof_fw_filename = "sof-bdw.ri",
>   		.sof_tplg_filename = "sof-bdw-rt286.tplg",
>   	},
> +	{
> +		.id = "10EC5650",
> +		.drv_name = "bdw-rt5650",
> +		.fw_filename = "intel/IntcSST2.bin",

add SOF files?

> +	},
>   	{
>   		.id = "RT5677CE",
>   		.drv_name = "bdw-rt5677",
> 


More information about the Alsa-devel mailing list