From patchwork Sat Sep 24 03:35:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxu Li X-Patchwork-Id: 12987393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B5D33C32771 for ; Sat, 24 Sep 2022 03:38:07 +0000 (UTC) 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 C939A83D; Sat, 24 Sep 2022 05:37:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C939A83D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1663990685; bh=t7fqNH18/lrdWOv15vhXjV5In9HdTIqiRF+c+EJ/xLg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GkjdO12vctUszYrvs5JHSe2AEO6cNTEjxkkqPdPilU4DqhLVTGOQSUveuX6J9US2E ceyyGo8mFHXlEtCMLZ7+OgzhHkBv8dJ05RSaCGyQXTT1bHsxTarsSlwYc9Ic/dbOQi 3v10SX18uufSNhehnq2j/0DP14xfaUGX282+8GtM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 71494F80542; Sat, 24 Sep 2022 05:36:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0E407F80542; Sat, 24 Sep 2022 05:36:27 +0200 (CEST) Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4856F80154; Sat, 24 Sep 2022 05:36:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4856F80154 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="IyMe534N" X-UUID: c90b1d76824e4bdaa769bae01677227b-20220924 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=hIQ4mUx+Rp+E2H2Xc+2URnzvQPQLSU49LU5vAQg5gU4=; b=IyMe534NRYAo7OtW6kKXXYR6pe5h9g11Pg/frj2KJ0b3ho33YSjTFrxJMhJC31QSTKZNjMFMNn2fYqdIXJncLL7HSaW86aT2InUDQwbaBT97qZtWLYKgvpm67FxMgn3fZI0OAhzJiknVWvNf23Rj4yQRoEictdKglbw8sd6m6aA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11, REQID:8e917797-9935-40d1-8e0d-59d06e258870, IP:0, U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.11, REQID:8e917797-9935-40d1-8e0d-59d06e258870, IP:0, URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:39a5ff1, CLOUDID:dfd4d906-1cee-4c38-b21b-a45f9682fdc0, B ulkID:2209241136087SI94QT7,BulkQuantity:2,Recheck:0,SF:38|28|17|19|48|823| 824,TC:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:43,QS:nil,BEC:ni l,COL:0 X-UUID: c90b1d76824e4bdaa769bae01677227b-20220924 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 13614035; Sat, 24 Sep 2022 11:36:06 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Sat, 24 Sep 2022 11:36:05 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Sat, 24 Sep 2022 11:36:04 +0800 From: Chunxu Li To: , , , , , Subject: [PATCH 1/2] ASoC: SOF: mediatek: mt8195: Add pcm_hw_params callback Date: Sat, 24 Sep 2022 11:35:58 +0800 Message-ID: <20220924033559.26599-2-chunxu.li@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220924033559.26599-1-chunxu.li@mediatek.com> References: <20220924033559.26599-1-chunxu.li@mediatek.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Chunxu Li , linux-kernel@vger.kernel.org, project_global_chrome_upstream_group@mediatek.com, linux-mediatek@lists.infradead.org, yc.hung@mediatek.com, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, sound-open-firmware@alsa-project.org 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" Add pcm_hw_params callback for mt8195 to support continue update dma host position Signed-off-by: Chunxu Li Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/sof/mediatek/mt8195/mt8195.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index c12192c8a6f8..882fde741cf5 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -496,6 +496,16 @@ static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type) return type; } +static int mt8195_pcm_hw_params(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_sof_platform_stream_params *platform_params) +{ + platform_params->cont_update_posn = 1; + + return 0; +} + static void mt8195_adsp_dump(struct snd_sof_dev *sdev, u32 flags) { u32 dbg_pc, dbg_data, dbg_bus0, dbg_bus1, dbg_inst; @@ -588,6 +598,7 @@ static struct snd_sof_dsp_ops sof_mt8195_ops = { /* stream callbacks */ .pcm_open = sof_stream_pcm_open, + .pcm_hw_params = mt8195_pcm_hw_params, .pcm_close = sof_stream_pcm_close, /* firmware loading */ From patchwork Sat Sep 24 03:35:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxu Li X-Patchwork-Id: 12987392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1508FC07E9D for ; Sat, 24 Sep 2022 03:37:32 +0000 (UTC) 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 39F9120C; Sat, 24 Sep 2022 05:36:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 39F9120C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1663990650; bh=rncl63V1VJ9B5cC9lhUEIRwPlw+1apZBOXRXnPCnmW0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BtuJpZy59uvZrao+VfFxpdQfds+9tmC99D6CgBmXVY+TiGDJ4pQzvTnL4hCsvsYwj SN9zhEth6XZ5IJ1uTzt3cvs1AThD2XfSNms41hgoA4UWsL67aGMjGD6Njv8hXznpl5 Rug55mbnFtNO/kuQ3WlFBoQI/BGLHWia5RPsDb0w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 481AAF8028B; Sat, 24 Sep 2022 05:36:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F2940F8014E; Sat, 24 Sep 2022 05:36:24 +0200 (CEST) Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1BDECF8014B; Sat, 24 Sep 2022 05:36:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1BDECF8014B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="NHN6oEer" X-UUID: b5d7487008a745b68768876825525c61-20220924 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=HXyxt+QPcRzoxeoQ32yLL7lzO5+U9FmRkjwUiGGfG3c=; b=NHN6oEerxuuhRm01g1wjm61rOuoaxzCgfuxXV0KA9lyYB9hUQ1njhjaN5utQmdi1dD4UUU0oEcO99W7jitzugtS4xqE/Mawpo7h1dZnSCZUfUIgJMu27MhsKg8KPSI6gjD18ypoD9UI3BzBX246mJ/pYaBsnZYUnJp0YWrlXqUg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11, REQID:da877670-ed9b-412b-bd4d-4e9ca94bebe2, IP:0, U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.11, REQID:da877670-ed9b-412b-bd4d-4e9ca94bebe2, IP:0, URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:39a5ff1, CLOUDID:6b2b0ee4-87f9-4bb0-97b6-34957dc0fbbe, B ulkID:2209241136087SI94QT7,BulkQuantity:2,Recheck:0,SF:38|28|17|19|48|823| 824,TC:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:43,QS:nil,BEC:ni l,COL:0 X-UUID: b5d7487008a745b68768876825525c61-20220924 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1473645682; Sat, 24 Sep 2022 11:36:06 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Sat, 24 Sep 2022 11:36:05 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Sat, 24 Sep 2022 11:36:05 +0800 From: Chunxu Li To: , , , , , Subject: [PATCH 2/2] ASoC: SOF: mediatek: mt8195: Add pcm_pointer callback Date: Sat, 24 Sep 2022 11:35:59 +0800 Message-ID: <20220924033559.26599-3-chunxu.li@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220924033559.26599-1-chunxu.li@mediatek.com> References: <20220924033559.26599-1-chunxu.li@mediatek.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Chunxu Li , linux-kernel@vger.kernel.org, project_global_chrome_upstream_group@mediatek.com, linux-mediatek@lists.infradead.org, yc.hung@mediatek.com, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, sound-open-firmware@alsa-project.org 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" Add pcm_pointer callback for mt8195 to support read host position from DSP Signed-off-by: Chunxu Li Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/sof/mediatek/mt8195/mt8195.c | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 882fde741cf5..3c81e84fcecf 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -506,6 +506,38 @@ static int mt8195_pcm_hw_params(struct snd_sof_dev *sdev, return 0; } +static snd_pcm_uframes_t mt8195_pcm_pointer(struct snd_sof_dev *sdev, + struct snd_pcm_substream *substream) +{ + int ret; + snd_pcm_uframes_t pos; + struct snd_sof_pcm *spcm; + struct sof_ipc_stream_posn posn; + struct snd_sof_pcm_stream *stream; + struct snd_soc_component *scomp = sdev->component; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + + spcm = snd_sof_find_spcm_dai(scomp, rtd); + if (!spcm) { + dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n", + rtd->dai_link->id); + return 0; + } + + stream = &spcm->stream[substream->stream]; + ret = snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn)); + if (ret < 0) { + dev_warn(sdev->dev, "failed to read stream position: %d\n", ret); + return 0; + } + + memcpy(&stream->posn, &posn, sizeof(posn)); + pos = spcm->stream[substream->stream].posn.host_posn; + pos = bytes_to_frames(substream->runtime, pos); + + return pos; +} + static void mt8195_adsp_dump(struct snd_sof_dev *sdev, u32 flags) { u32 dbg_pc, dbg_data, dbg_bus0, dbg_bus1, dbg_inst; @@ -599,6 +631,7 @@ static struct snd_sof_dsp_ops sof_mt8195_ops = { /* stream callbacks */ .pcm_open = sof_stream_pcm_open, .pcm_hw_params = mt8195_pcm_hw_params, + .pcm_pointer = mt8195_pcm_pointer, .pcm_close = sof_stream_pcm_close, /* firmware loading */