From patchwork Wed Apr 22 04:48:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11502907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50581913 for ; Wed, 22 Apr 2020 04:49:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC43B20747 for ; Wed, 22 Apr 2020 04:49:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="TlWlbUnA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC43B20747 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3104B16C6; Wed, 22 Apr 2020 06:48:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3104B16C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1587530945; bh=xvdk3kElL62WA2NuEBH0ReWmEPJKeBuVpBGrhG6D6o0=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TlWlbUnAqmupcHnnHFPKRpiOCVeF9CuRQqaA8uvaTHaVBHHTtrpjFj3BxKcshZuF3 97xKWbprXRZltI6EZpol5CEq1HQWdQfJRRtH0txjneeLHsYx767maaIr/QMYIGqL+A gA0G4QzwEtFLGx4qYdV89p/+yiyWzW8+ExtwdO4c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9480CF8021C; Wed, 22 Apr 2020 06:48:17 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id B5E56F8023F; Wed, 22 Apr 2020 06:48:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id A9789F800FF for ; Wed, 22 Apr 2020 06:48:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A9789F800FF Date: 22 Apr 2020 13:48:06 +0900 X-IronPort-AV: E=Sophos;i="5.72,412,1580742000"; d="scan'208";a="45169016" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 22 Apr 2020 13:48:06 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id F3EEA41C1DAA; Wed, 22 Apr 2020 13:48:05 +0900 (JST) Message-ID: <87blnkunw9.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/4] ASoC: mediatek: don't use snd_soc_rtdcom_lookup() User-Agent: Wanderlust/2.15.9 Emacs/25.2 Mule/6.0 To: Mark Brown In-Reply-To: <87d080unyx.wl-kuninori.morimoto.gx@renesas.com> References: <87d080unyx.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Kate Stewart , Cezary Rojewski , Jie Yang , alsa-devel@alsa-project.org, Liam Girdwood , Richard Fontana , Shunli Wang , YueHaibing , Pierre-Louis Bossart , Jiaxin Yu , linux-arm-kernel@lists.infradead.org, Vijendar Mukunda , Stephen Boyd , linux-mediatek@lists.infradead.org, Eason Yen , Matthias Brugger , Thomas Gleixner , Allison Randal , Takashi Iwai , Ravulapati Vishnu vardhan rao , Colin Ian King X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto We shouldn't use snd_soc_rtdcom_lookup() as much as possible. It works today, but, will not work in the future if we support multi CPU/Codec/Platform, because 1 rtd might have multiple same driver named component. mediatek drivers are using snd_soc_rtdcom_lookup() at afe->memif_fs and/or afe->irq_fs to get component. But, caller knows it via dai->component. We don't need to use snd_soc_rtdcom_lookup(). This patch fixup it. Signed-off-by: Kuninori Morimoto --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 12 +++++------- sound/soc/mediatek/common/mtk-afe-fe-dai.h | 3 ++- sound/soc/mediatek/common/mtk-base-afe.h | 6 ++++-- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 6 ++++-- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 11 ++++------- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 7 ++++--- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 11 ++++------- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index 375e3b492922..8ee7206aa63d 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -162,7 +162,7 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, } /* set rate */ - ret = mtk_memif_set_rate_substream(substream, id, rate); + ret = mtk_memif_set_rate_substream(dai->component, substream, id, rate); if (ret) { dev_err(afe->dev, "%s(), error, id %d, set rate %d, ret %d\n", __func__, id, rate, ret); @@ -225,7 +225,7 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, irq_data->irq_cnt_shift); /* set irq fs */ - fs = afe->irq_fs(substream, runtime->rate); + fs = afe->irq_fs(dai->component, substream, runtime->rate); if (fs < 0) return -EINVAL; @@ -502,12 +502,10 @@ int mtk_memif_set_rate(struct mtk_base_afe *afe, } EXPORT_SYMBOL_GPL(mtk_memif_set_rate); -int mtk_memif_set_rate_substream(struct snd_pcm_substream *substream, +int mtk_memif_set_rate_substream(struct snd_soc_component *component, + struct snd_pcm_substream *substream, int id, unsigned int rate) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int fs = 0; @@ -518,7 +516,7 @@ int mtk_memif_set_rate_substream(struct snd_pcm_substream *substream, return -EINVAL; } - fs = afe->memif_fs(substream, rate); + fs = afe->memif_fs(component, substream, rate); if (fs < 0) return -EINVAL; diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.h b/sound/soc/mediatek/common/mtk-afe-fe-dai.h index 8cec90671827..d8fab806dbd0 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.h +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.h @@ -44,7 +44,8 @@ int mtk_memif_set_channel(struct mtk_base_afe *afe, int id, unsigned int channel); int mtk_memif_set_rate(struct mtk_base_afe *afe, int id, unsigned int rate); -int mtk_memif_set_rate_substream(struct snd_pcm_substream *substream, +int mtk_memif_set_rate_substream(struct snd_soc_component *component, + struct snd_pcm_substream *substream, int id, unsigned int rate); int mtk_memif_set_format(struct mtk_base_afe *afe, int id, snd_pcm_format_t format); diff --git a/sound/soc/mediatek/common/mtk-base-afe.h b/sound/soc/mediatek/common/mtk-base-afe.h index a8cf44d98244..c5e3c680332d 100644 --- a/sound/soc/mediatek/common/mtk-base-afe.h +++ b/sound/soc/mediatek/common/mtk-base-afe.h @@ -97,9 +97,11 @@ struct mtk_base_afe { unsigned int num_dai_drivers; const struct snd_pcm_hardware *mtk_afe_hardware; - int (*memif_fs)(struct snd_pcm_substream *substream, + int (*memif_fs)(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate); - int (*irq_fs)(struct snd_pcm_substream *substream, + int (*irq_fs)(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate); int (*get_dai_fs)(struct mtk_base_afe *afe, int dai_id, unsigned int rate); diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index f0250b0dd734..456f3a0b98f9 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -491,7 +491,8 @@ static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream, } } -static int mt2701_memif_fs(struct snd_pcm_substream *substream, +static int mt2701_memif_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -505,7 +506,8 @@ static int mt2701_memif_fs(struct snd_pcm_substream *substream, return fs; } -static int mt2701_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) +static int mt2701_irq_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { return mt2701_afe_i2s_fs(rate); } diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c index 7f930556d961..7a0bbaaad677 100644 --- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c @@ -136,23 +136,20 @@ static const struct snd_pcm_hardware mt6797_afe_hardware = { .fifo_size = 0, }; -static int mt6797_memif_fs(struct snd_pcm_substream *substream, +static int mt6797_memif_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int id = asoc_rtd_to_cpu(rtd, 0)->id; return mt6797_rate_transform(afe->dev, rate, id); } -static int mt6797_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) +static int mt6797_irq_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); return mt6797_general_rate_transform(afe->dev, rate); diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index 1e3f2d786066..6262e2c69107 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -479,11 +479,11 @@ static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd, } } -static int mt8173_memif_fs(struct snd_pcm_substream *substream, +static int mt8173_memif_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id]; int fs; @@ -509,7 +509,8 @@ static int mt8173_memif_fs(struct snd_pcm_substream *substream, return fs; } -static int mt8173_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) +static int mt8173_irq_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { return mt8173_afe_i2s_fs(rate); } diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c index c8ded53bde1d..5071f38fba29 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -139,23 +139,20 @@ static const struct snd_pcm_hardware mt8183_afe_hardware = { .fifo_size = 0, }; -static int mt8183_memif_fs(struct snd_pcm_substream *substream, +static int mt8183_memif_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int id = asoc_rtd_to_cpu(rtd, 0)->id; return mt8183_rate_transform(afe->dev, rate, id); } -static int mt8183_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) +static int mt8183_irq_fs(struct snd_soc_component *component, + struct snd_pcm_substream *substream, unsigned int rate) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); return mt8183_general_rate_transform(afe->dev, rate);