[PATCH] ASoC: mediatek: mt8195: extract SOF common code

AngeloGioacchino Del Regno angelogioacchino.delregno at collabora.com
Fri Jul 15 01:30:05 PDT 2022


Il 15/07/22 05:42, Chunxu Li ha scritto:
> The functions related to SOF can be reused in different machine drivers,
> such as mt8195 or mt8186, so extract the common code to avoid duplication.
> 
> Set mtk_soc_card_data which include machine private data and SOF private
> data as card drvdata, then the difference between machine private can be
> ignored such as mt8195_mt6359_priv or mt8186_mt6366_priv, at the same
> time the SOF related code can be reused in different machine drivers.
> 
> Signed-off-by: Chunxu Li <chunxu.li at mediatek.com>
> ---
>   sound/soc/mediatek/common/Makefile            |   2 +-
>   .../soc/mediatek/common/mtk-dsp-sof-common.c  | 196 +++++++++++++++
>   .../soc/mediatek/common/mtk-dsp-sof-common.h  |  35 +++
>   sound/soc/mediatek/common/mtk-soc-card.h      |  17 ++
>   sound/soc/mediatek/mt8195/mt8195-mt6359.c     | 233 ++++--------------
>   5 files changed, 300 insertions(+), 183 deletions(-)
>   create mode 100644 sound/soc/mediatek/common/mtk-dsp-sof-common.c
>   create mode 100644 sound/soc/mediatek/common/mtk-dsp-sof-common.h
>   create mode 100644 sound/soc/mediatek/common/mtk-soc-card.h
> 
> diff --git a/sound/soc/mediatek/common/Makefile b/sound/soc/mediatek/common/Makefile
> index acbe01e9e928..576deb7f8cce 100644
> --- a/sound/soc/mediatek/common/Makefile
> +++ b/sound/soc/mediatek/common/Makefile
> @@ -1,6 +1,6 @@
>   # SPDX-License-Identifier: GPL-2.0
>   # platform driver
> -snd-soc-mtk-common-objs := mtk-afe-platform-driver.o mtk-afe-fe-dai.o
> +snd-soc-mtk-common-objs := mtk-afe-platform-driver.o mtk-afe-fe-dai.o mtk-dsp-sof-common.o
>   obj-$(CONFIG_SND_SOC_MEDIATEK) += snd-soc-mtk-common.o
>   
>   obj-$(CONFIG_SND_SOC_MTK_BTCVSD) += mtk-btcvsd.o
> diff --git a/sound/soc/mediatek/common/mtk-dsp-sof-common.c b/sound/soc/mediatek/common/mtk-dsp-sof-common.c
> new file mode 100644
> index 000000000000..1098694f4f36
> --- /dev/null
> +++ b/sound/soc/mediatek/common/mtk-dsp-sof-common.c
> @@ -0,0 +1,196 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * mtk-dsp-sof-common.c  --  MediaTek dsp sof common ctrl
> + *
> + * Copyright (c) 2022 MediaTek Inc.
> + * Author: Chunxu Li <chunxu.li at mediatek.com>
> + */
> +
> +#include <mtk-dsp-sof-common.h>
> +#include <mtk-soc-card.h>

Did you mean.....

#include "mtk-dsp-sof-common.h"
#include "mtk-soc-card.h"


> +
> +/* fixup the BE DAI link to match any values from topology */
> +int mtk_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
> +			   struct snd_pcm_hw_params *params)
> +{

..snip..

> diff --git a/sound/soc/mediatek/common/mtk-dsp-sof-common.h b/sound/soc/mediatek/common/mtk-dsp-sof-common.h
> new file mode 100644
> index 000000000000..f02ba2ce3718
> --- /dev/null
> +++ b/sound/soc/mediatek/common/mtk-dsp-sof-common.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * mtk-dsp-sof-common.h  --  MediaTek dsp sof common definition
> + *
> + * Copyright (c) 2022 MediaTek Inc.
> + * Author: Chunxu Li <chunxu.li at mediatek.com>
> + */
> +
> +#ifndef _MTK_DSP_SOF_COMMON_H_
> +#define _MTK_DSP_SOF_COMMON_H_
> +
> +#include <sound/soc.h>

Leave a blank line here.

> +struct sof_conn_stream {
> +	const char *normal_link;
> +	const char *sof_link;
> +	const char *sof_dma;
> +	int stream_dir;
> +};
> +

Thanks,
Angelo



More information about the Linux-mediatek mailing list