From patchwork Wed Sep 21 12:02:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunxu Li X-Patchwork-Id: 12983632 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 75D5FECAAD8 for ; Wed, 21 Sep 2022 12:03:55 +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 0F616828; Wed, 21 Sep 2022 14:03:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0F616828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1663761833; bh=S9QiPNng7eSzJmXiN62sr2BtHMX+egiT7o3LhAj2ygY=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=kjS6UXY891UDTs0DThFhM0wY/8xBGX/J5y8121mCUKof7hH8wbqNwurPXAC6PWzGW sbNx9xmybLA8aj24NIEd+zXYqX2ktHduv7GCTMk9mky35UasySYJ42c1sRw7kjb3be 0iVklHIB/RqoR54NtpW3xf2edtZ6SEj/edG+rbhA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A4340F80169; Wed, 21 Sep 2022 14:03:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 056F5F80256; Wed, 21 Sep 2022 14:03:01 +0200 (CEST) Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 79C05F800C9; Wed, 21 Sep 2022 14:02:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 79C05F800C9 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ex6lN7Iq" X-UUID: 8976d09486ec49cbb20156b824bca0bb-20220921 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:Message-ID:Date:Subject:CC:To:From; bh=rnk6XT/XzFAqp50N45m5DaI+6+u2HgKxMgT5LBTZ044=; b=ex6lN7IqOklTdSG9WF+AOCVQBHETkp0vnp+ccEgXBOwjk/qNKA38S4tv0AWnp37lB9hL68L85imVTa8FQ7otOW3RJUSohvt6jLtRPGkp+1gadm361Hpw34G+ceX8gespqbVqZBsMPEYbUwoqzv5u1EpBUnq2bmSyg9YMI2bdVM4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11, REQID:a10e14ed-1b53-40a3-a149-30e93db36d89, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.11, REQID:a10e14ed-1b53-40a3-a149-30e93db36d89, IP:0, URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:39a5ff1, CLOUDID:b90e6c5e-5ed4-4e28-8b00-66ed9f042fbd, B ulkID:220921200244SK7U2YH9,BulkQuantity:0,Recheck:0,SF:28|17|19|48|823|824 ,TC:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil, COL:0 X-UUID: 8976d09486ec49cbb20156b824bca0bb-20220921 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 157263969; Wed, 21 Sep 2022 20:02:43 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Wed, 21 Sep 2022 20:02:42 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 21 Sep 2022 20:02:41 +0800 From: Chunxu Li To: , , , , , Subject: [PATCH] ASoC: SOF: mediatek: add pcm_pointer callback for mt8186 Date: Wed, 21 Sep 2022 20:02:39 +0800 Message-ID: <20220921120239.31934-1-chunxu.li@mediatek.com> X-Mailer: git-send-email 2.25.1 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 mt8186 to support read host position from DSP Signed-off-by: Chunxu Li Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/sof/mediatek/mt8186/mt8186.c | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 9ec89fc7fec0..181189e00e02 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -470,6 +470,38 @@ static int mt8186_pcm_hw_params(struct snd_sof_dev *sdev, return 0; } +static snd_pcm_uframes_t mt8186_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 struct snd_soc_dai_driver mt8186_dai[] = { { .name = "SOF_DL1", @@ -537,6 +569,7 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = { /* stream callbacks */ .pcm_open = sof_stream_pcm_open, .pcm_hw_params = mt8186_pcm_hw_params, + .pcm_pointer = mt8186_pcm_pointer, .pcm_close = sof_stream_pcm_close, /* firmware loading */