From nobody Sat Sep 21 15:31:16 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DF2DC32771 for ; Sat, 24 Sep 2022 03:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233210AbiIXDg1 (ORCPT ); Fri, 23 Sep 2022 23:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbiIXDgR (ORCPT ); Fri, 23 Sep 2022 23:36:17 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 395B513747A for ; Fri, 23 Sep 2022 20:36:12 -0700 (PDT) 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: , , , , , CC: , , , , , , , , Chunxu Li 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/mediate= k/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 *sd= ev, return 0; } =20 +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 =3D sdev->component; + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + + spcm =3D 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 =3D &spcm->stream[substream->stream]; + ret =3D 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 =3D spcm->stream[substream->stream].posn.host_posn; + pos =3D 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 =3D { /* stream callbacks */ .pcm_open =3D sof_stream_pcm_open, .pcm_hw_params =3D mt8195_pcm_hw_params, + .pcm_pointer =3D mt8195_pcm_pointer, .pcm_close =3D sof_stream_pcm_close, =20 /* firmware loading */ --=20 2.25.1