From patchwork Thu Feb 2 11:11:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 649680 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 3180AC636D6 for ; Thu, 2 Feb 2023 11:14:43 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A843BE77; Thu, 2 Feb 2023 12:13:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A843BE77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1675336480; bh=vBHxm0ECjItpDsr4NygqyeYSNweCZZ0kvTU94VSrlDA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Y82jnQvlBvc//8SRImzQS2nzRAepG3czRgUSXocas/UR6nsDiQ8nKybt1o9u3Q7fh ZswSu7BTR6XmdyX6o1lQhrHkc/V56GkqL8B3djztB2WDaftqnZzgZgtHkW+CJiLKQv XaiXddz+HMU5qUrFnYO0UONHnnHaa5h1IeVg2IkY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1D111F804E2; Thu, 2 Feb 2023 12:12:38 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C972EF804E2; Thu, 2 Feb 2023 12:12:35 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 78324F80528 for ; Thu, 2 Feb 2023 12:11:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 78324F80528 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IXo56/hr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675336291; x=1706872291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vBHxm0ECjItpDsr4NygqyeYSNweCZZ0kvTU94VSrlDA=; b=IXo56/hrynK/VlFJSdYfJ1F2bsZqs+RQP/14OTSDEmcuZuAaXM4MjW/X SdeqXuHDzMsiTX/gn8eINYdxOxpXSMYstcLvd6NJxR3zgQ1YujrG8ucmX W52vbrsXUSgeHECgreUEzyCfW1XG/BC9swWfLlxPDf5LwYCwJc5RXgHja MgfMty29w8bAO5WMOBTP01WVmIymzq09qgRbPIhxi4jxBqfbbgBfhjf0L a2cyoXUfqRm6PRZfLIVbaXrcEjRvnTrPorj2FQHl5eVCDP2Xpy5FSj+dE ruvh2D+vWlxtPfPQtC0wGf70G4RAM8hV7yh/wpZUKIMaZU3a8f5sz3OfM w==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="414625187" X-IronPort-AV: E=Sophos;i="5.97,267,1669104000"; d="scan'208";a="414625187" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2023 03:11:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="695747687" X-IronPort-AV: E=Sophos;i="5.97,267,1669104000"; d="scan'208";a="695747687" Received: from jpdamery-mobl.ger.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.1.104]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2023 03:11:26 -0800 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz Subject: [PATCH v2 4/9] ASoC: SOF: ipc4-pcm: allocate time info for pcm delay feature Date: Thu, 2 Feb 2023 13:11:18 +0200 Message-Id: <20230202111123.25231-5-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202111123.25231-1-peter.ujfalusi@linux.intel.com> References: <20230202111123.25231-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, pierre-louis.bossart@linux.intel.com, rander.wang@intel.com, ranjani.sridharan@linux.intel.com, yung-chuan.liao@linux.intel.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Rander Wang Allocate time info when pcm is loaded by topology and free it when pcm is unloaded by topology. Signed-off-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc4-pcm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c index 521090d4498d..8071db487815 100644 --- a/sound/soc/sof/ipc4-pcm.c +++ b/sound/soc/sof/ipc4-pcm.c @@ -12,6 +12,7 @@ #include "sof-priv.h" #include "ipc4-priv.h" #include "ipc4-topology.h" +#include "ipc4-fw-reg.h" static int sof_ipc4_set_multi_pipeline_state(struct snd_sof_dev *sdev, u32 state, struct ipc4_pipeline_set_state_data *trigger_list) @@ -410,6 +411,8 @@ static void sof_ipc4_pcm_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm pipeline_list = &spcm->stream[stream].pipeline_list; kfree(pipeline_list->pipelines); pipeline_list->pipelines = NULL; + kfree(spcm->stream[stream].private); + spcm->stream[stream].private = NULL; } } @@ -417,8 +420,19 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm { struct snd_sof_pcm_stream_pipeline_list *pipeline_list; struct sof_ipc4_fw_data *ipc4_data = sdev->private; + struct sof_ipc4_timestamp_info *stream_info; + bool support_info = true; + u32 abi_version; + u32 abi_offset; int stream; + abi_offset = offsetof(struct sof_ipc4_fw_registers, abi_ver); + sof_mailbox_read(sdev, sdev->fw_info_box.offset + abi_offset, &abi_version, + sizeof(abi_version)); + + if (abi_version < SOF_IPC4_FW_REGS_ABI_VER) + support_info = false; + for_each_pcm_streams(stream) { pipeline_list = &spcm->stream[stream].pipeline_list; @@ -429,6 +443,17 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm sof_ipc4_pcm_free(sdev, spcm); return -ENOMEM; } + + if (!support_info) + continue; + + stream_info = kzalloc(sizeof(*stream_info), GFP_KERNEL); + if (!stream_info) { + sof_ipc4_pcm_free(sdev, spcm); + return -ENOMEM; + } + + spcm->stream[stream].private = stream_info; } return 0;