From patchwork Fri Jun 9 14:53:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274070 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 94C2DC7EE29 for ; Fri, 9 Jun 2023 14:55:18 +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 CA72DA4D; Fri, 9 Jun 2023 16:54:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CA72DA4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322515; bh=rwkX+GrjqTA2Tm2gBMivuGVIrC0Zk5mpJ23KVX/5Mls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LRjkoMjbcaDqqSKbMILQ5xB+HY/thIGJmeX2JRzcWjrjxCiBL7dNpNt7fHVoL9pwf SP3yUihuNQwdVv/ZKJkG0LPAa/tgIgx8p5IRZD9E7M9YqbxbEm4IuWR4OgVtwfE0hQ 4ocEIK5RL//VFo7O63LlrPnz3gr8wmShi8jGMQ38= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8780CF80552; Fri, 9 Jun 2023 16:54:25 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id F2B09F80553; Fri, 9 Jun 2023 16:54:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5C1E8F80199; Fri, 9 Jun 2023 16:54:20 +0200 (CEST) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 27793F800C8 for ; Fri, 9 Jun 2023 16:54:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 27793F800C8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=pYx6AAYX Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f7fcdc7f7fso12652845e9.0 for ; Fri, 09 Jun 2023 07:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322456; x=1688914456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1ViS6qF8cS4iDl2a+diQ/4R9Vhl6rQuGyv9+232yC8g=; b=pYx6AAYX31qs1F2OdJbIgSLF5yMv3UfFa3oRnRll8KhhrmjwB3eEme0y1/+w3+P5bg idMNOEjcnlLemtdf/DSiN/3bybugS+OpaCxhTS/w7CXjZ9OwnE6bm/G89LRJQFiV4yzD hEJYKN0j72BaoMJuD/kUZbWg+yXlp1pUO+mmU40Y3H3kugF/792D1SskLtB9BFtflClQ fesCobyMVy3iaixO7aJFfh7MzgsF2nVbuPn9CHQ+ZIRGcj8+fGjAvTvCZJypMro1e9sS 6Umvo4fTd8nEamBKl8wWca8/pKDVdU3YlnN5Vo80gFlB5Av89qsqtjwaQGSVX1FhoYit mokw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322456; x=1688914456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1ViS6qF8cS4iDl2a+diQ/4R9Vhl6rQuGyv9+232yC8g=; b=ED7G6vNHSG7F7x7Uk699pV4xfc1K/FhpOdZoqNgODUD5Dx+L0gxD0+1sq5r9GVagX2 8tenTdHtcZQ8Q0AmodzUWw08nClh7Hs/WrouTqK82VKiU2cC67knWABKCMt3rakcAHXi JQoV0HyG5Qh1jWL/zwKVMd9W1oSys9cPBlZSMrjXVMTJDOZtIDXAUHTSYAKJNxjxlnWJ kHdkdIf8+8Av94wol6vIgd2Yaw0dGiLe5pr76Zt+kxCTRwPQA/CHUUmJLM7wqWkOnHa/ o42f6pGlyXKwGs7IpCFP0V8Ug7xmZH+s5AfkiLZX964rC6ISx1gWlnOpXsSKBxCJkhYR 95cQ== X-Gm-Message-State: AC+VfDwVlIBDGZ6s/bo4XPjp3nStWKBMWmK5aOFo6nF6D/P1VCSymduh HRTIfAA4il2N3nJmwcKF6WLSYA== X-Google-Smtp-Source: ACHHUZ6XJv+CElBwzddgkPF/3BDt6V+kN3w98q7v8ajDl+3UTsnaK0Y5g9kA2jnZsi6MOEamkqZNvQ== X-Received: by 2002:a05:600c:3b29:b0:3f7:ec1d:21b3 with SMTP id m41-20020a05600c3b2900b003f7ec1d21b3mr4169683wms.5.1686322455438; Fri, 09 Jun 2023 07:54:15 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:54:14 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Mohammad Rafi Shaik , Srinivas Kandagatla Subject: [PATCH v2 01/11] ASoC: qcom: SC7280: audioreach: Add sc7280 hardware param fixup callback Date: Fri, 9 Jun 2023 15:53:57 +0100 Message-Id: <20230609145407.18774-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: TXVSUXXUOW2AJAZDSHCXKGVCXXVDYGXE X-Message-ID-Hash: TXVSUXXUOW2AJAZDSHCXKGVCXXVDYGXE X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Mohammad Rafi Shaik Add support to set backend params such as sampling rate and number of channels using backend params fixup callback. Also add no pcm check for hardware params constraints setting. Signed-off-by: Mohammad Rafi Shaik Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sc7280.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/sc7280.c b/sound/soc/qcom/sc7280.c index da7469a6a267..787dd49e03f6 100644 --- a/sound/soc/qcom/sc7280.c +++ b/sound/soc/qcom/sc7280.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "../codecs/rt5682.h" #include "../codecs/rt5682s.h" @@ -196,8 +197,10 @@ static int sc7280_snd_hw_params(struct snd_pcm_substream *substream, struct sdw_stream_runtime *sruntime; int i; - snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); - snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, 48000, 48000); + if (!rtd->dai_link->no_pcm) { + snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); + snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, 48000, 48000); + } switch (cpu_dai->id) { case LPASS_CDC_DMA_TX3: @@ -358,6 +361,20 @@ static const struct snd_soc_dapm_widget sc7280_snd_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), }; +static int sc7280_snd_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE); + + return 0; +} + static int sc7280_snd_platform_probe(struct platform_device *pdev) { struct snd_soc_card *card; @@ -387,6 +404,8 @@ static int sc7280_snd_platform_probe(struct platform_device *pdev) for_each_card_prelinks(card, i, link) { link->init = sc7280_init; link->ops = &sc7280_ops; + if (link->no_pcm == 1) + link->be_hw_params_fixup = sc7280_snd_be_hw_params_fixup; } return devm_snd_soc_register_card(dev, card); From patchwork Fri Jun 9 14:53:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274071 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 55D70C7EE29 for ; Fri, 9 Jun 2023 14:55:37 +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 8545E6C0; Fri, 9 Jun 2023 16:54:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8545E6C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322535; bh=2KkWUHZ625w/PEVR+S3+jP7sIsSrnVNvwB2zLhROWGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=gbAgw+2XuihK6+gjeZccSbKRdcI7ii5+9jRzcnR7Z8svx7oVzrRLoylbKSyfPZ0+S HfmrFY5WbxLOV3/har6sa6OtAH2PBU9NCysM4JVBDF64W5sw27aozVzeL2bjSaIfbw nefNjMtpQAhVxVdf7Uo0HP/fuMM/B4iFIV8pTbuk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2ED7CF80558; Fri, 9 Jun 2023 16:54:34 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 941FFF80199; Fri, 9 Jun 2023 16:54:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 48D1CF80558; Fri, 9 Jun 2023 16:54:28 +0200 (CEST) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id EC46BF80549 for ; Fri, 9 Jun 2023 16:54:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EC46BF80549 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ONwJl09/ Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f736e0c9b1so19205865e9.3 for ; Fri, 09 Jun 2023 07:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322460; x=1688914460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RuQSolMY+GsunpVDUBYRLCP9uTfJjpPU4KcdicPOHq4=; b=ONwJl09/bsLQmdUzwtjnMWbC7fFCwIu40+1GGEzwNKYAYTImxjdf80WVJenHhV6SZE l4hyaIQb9uouf0Knk+bgqUpA18RhoQmWzHa7wGTm5DaL1kfmpeIfSfRyW1UzLp3TNe5M gND5CHZmr7t5WkwjRCPDvGuC0Edq6WoaG+VBGf4QjCiqRI+E3F9BC/91d2r+CdYGCS6i G17IodWT7T+WZtjs6mV8Dg2r0gO3rHNyRe2cAdPYHdyQ2n9s5t89eyCv0FdZ2gTN3MRX GqPUaqQnWTqHRyJZ/jEBAx1d8jxCsWZ7kSYgZXoGyrwXvIHOkOCROW+CL57a6XTPXRqX l03g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322460; x=1688914460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RuQSolMY+GsunpVDUBYRLCP9uTfJjpPU4KcdicPOHq4=; b=eWMWDRkLcldIPf0RaR+bu/ZUuMiD5HoG6m/w2/X+VM5bu26CaVwJsphvr+reFA8DjG M6e4lrK0J38s3HwZmUIZhnG3eyhiyxEtPzFPYYGgSyI8IG/xCz0vcBEpj1ILkqS84FdF gXnemwTS1KU9KE0EDbRFXI2c/acN0r9Gcn+be87ZRYprUObxYaeJ7a3ZCsVCpvcHMjnS ALnrxg8tuv80g/Im8zN46H+XouOXGAvWkAfYxDiusfGWFxbEg5m4mwFoGLEJIITC7hFl yAqj0RcLASNanGBwEQGRK9DY+J4ji7CZJ656teCMwWNn8DBpiWgXuf8gV3djX6+lo3JW D1uA== X-Gm-Message-State: AC+VfDxPBCiRqgctHrkh7lZDSgFfw7jhGfGV3x64IgF7dBloE92cLPsj jYqgtn8fmMET/IBU78QxtVVdzA== X-Google-Smtp-Source: ACHHUZ5jmIwMMsS6bJUifZ1z8l17raD0V7Vbgzz65Isey3BWjeSbT6ZHcqCta3q3QBlg09+h3SCrMw== X-Received: by 2002:a1c:6a18:0:b0:3f7:e536:8f06 with SMTP id f24-20020a1c6a18000000b003f7e5368f06mr1341409wmc.26.1686322460491; Fri, 09 Jun 2023 07:54:20 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:54:16 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Mohammad Rafi Shaik , Srinivas Kandagatla Subject: [PATCH v2 02/11] ASoC: q6dsp: q6apm: add end of stream events Date: Fri, 9 Jun 2023 15:53:58 +0100 Message-Id: <20230609145407.18774-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: PZDCOQ5ENJJPAN6V652RZHRRZ656YWS2 X-Message-ID-Hash: PZDCOQ5ENJJPAN6V652RZHRRZ656YWS2 X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Mohammad Rafi Shaik EOS event from dsp is currently not sent to the dai drivers, add the missing callback. Signed-off-by: Mohammad Rafi Shaik Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index a7a3f973eb6d..b07fee8ccac1 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -497,6 +497,9 @@ static int graph_callback(struct gpr_resp_pkt *data, void *priv, int op) } break; case DATA_CMD_WR_SH_MEM_EP_EOS_RENDERED: + client_event = APM_CLIENT_EVENT_CMD_EOS_DONE; + if (graph->cb) + graph->cb(client_event, hdr->token, data->payload, graph->priv); break; case GPR_BASIC_RSP_RESULT: switch (result->opcode) { From patchwork Fri Jun 9 14:53:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274082 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 E7D9DC7EE2F for ; Fri, 9 Jun 2023 14:56:09 +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 E8896E93; Fri, 9 Jun 2023 16:55:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E8896E93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322568; bh=swPdvsYTKlEmkM0HgKJRO4O3bGsqf+vXLPLn7l+pdUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=oEx6VQZ1BJBMqt96dYDdOmkqOIuSXgKor9GJs2H9InWud7gzacR9sdWeWNQjI4w/f 1wM9tlSTsvek20V4ANV6vCXk/DwjMWBvTBSZyLSITfcTI70QhmIKPPpuTvjRSdSnio MyZQ19E55C8LVw7G9f4W2C882OVMYUdfF0O/La90= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 52F47F80588; Fri, 9 Jun 2023 16:54:40 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CE09CF8057F; Fri, 9 Jun 2023 16:54:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C9C42F80290; Fri, 9 Jun 2023 16:54:31 +0200 (CEST) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5CA94F80551 for ; Fri, 9 Jun 2023 16:54:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5CA94F80551 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=TAMGIEEE Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f644dffd71so2421434e87.1 for ; Fri, 09 Jun 2023 07:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322464; x=1688914464; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9JFL8jNKRrHzDOE8BEGRQfXvBY019VxhOr2ufujXe1U=; b=TAMGIEEEJ9RK7aLUsa41oSkhZHSOgLJAFbWtA+9s51ls33ee6pMORTpWGF/vZdU2gS gX6ctJNYfSr84xx7f1gYCP+NUG0GaOJcKqEj5Rvw5ts48+CHxWDhqnIoouR/pGzWLzfh oseIe/J6D7bP/DLWGWniAZ/J4/BVAJ6md/8iTl5EIt8XgMMfcls6MnZI5N3lo2FaW18o IFphiRlsuDd1+A8ynDrSUVtFyFjX6Ca4c5sZL0Shih92VJPwyPpnxMtsAgE4SL6yw7IS KPe9MK+Bwl8P01Fpfl1j4qph41SFW9MJjKfX6D8uJpgLhMGNTaQsW8+5RyGxS3TgYbAm N+vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322464; x=1688914464; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9JFL8jNKRrHzDOE8BEGRQfXvBY019VxhOr2ufujXe1U=; b=jqV8Fh3qez1Cz1rn2rhtDiphqpvorYlMkXPTTTVvIOzuCLe/wojDo7tpA+qBjKBLV6 4hkgOPE0W2ybFW6evlOL73bxoACqJCvVVy+QzWjY115/F52/afFjIx0kkX4fToXAlg5Q AhSqrIjkQ0kBdeJ8MgHeEYqWVtrM3hfSYODz+n9D0H+PVhjpKm7MqoQBAUZE7+4+0omF lQjDgOdKsluZrYbn/01m9QUTylWiqfv7fhgmcfcqokDdrx7WJ+z1JXH/W6SpYOM+Jxn4 0xXjzPCN6EuTaU8wYgxu6Z73hPhgiaKRpFIvSccGzCGvJ24JH4H56s2PVsxVbyd+CQHs oonA== X-Gm-Message-State: AC+VfDxif7l5ax8ZEofFM8lF7ukkOsq/WFcZdTDsOqzg14lIJhPpe6rs HLDJzE9dQqE6dDrIM1Yl0tTVUQ== X-Google-Smtp-Source: ACHHUZ6ugyraOH0v8OYLxzLAY3Eq/p7st4i1LSwVEOuLuJ6w66qloZAfiplZ6C6zy8D5yeLp2D85Tw== X-Received: by 2002:a05:6512:521:b0:4f4:d41b:f421 with SMTP id o1-20020a056512052100b004f4d41bf421mr1328843lfc.33.1686322463902; Fri, 09 Jun 2023 07:54:23 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.54.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:54:21 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v2 03/11] ASoC: q6dsp: audioreach: add helper function to set u32 param Date: Fri, 9 Jun 2023 15:53:59 +0100 Message-Id: <20230609145407.18774-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: 6VFH2EP5TRFAW4IMWTQLRBL52XUT2AT5 X-Message-ID-Hash: 6VFH2EP5TRFAW4IMWTQLRBL52XUT2AT5 X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Some of the Audioreach commands take a u32 value, ex: PARAM_ID_MODULE_ENABLE. It makes more sense to provide a helper function so that other new commands can reuse this. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 100 +++++++----------------------- sound/soc/qcom/qdsp6/audioreach.h | 2 + 2 files changed, 26 insertions(+), 76 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 8d9410dcbd45..0acd4a75d5cd 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -732,33 +732,32 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph, return rc; } -static int audioreach_sal_limiter_enable(struct q6apm_graph *graph, - struct audioreach_module *module, bool enable) +int audioreach_send_u32_param(struct q6apm_graph *graph, struct audioreach_module *module, + uint32_t param_id, uint32_t param_val) { struct apm_module_param_data *param_data; - struct param_id_sal_limiter_enable *limiter_enable; - int payload_size; struct gpr_pkt *pkt; - int rc; + uint32_t *param; + int rc, payload_size; void *p; - payload_size = sizeof(*limiter_enable) + APM_MODULE_PARAM_DATA_SIZE; - - pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); - if (IS_ERR(pkt)) - return PTR_ERR(pkt); + payload_size = sizeof(uint32_t) + APM_MODULE_PARAM_DATA_SIZE; + p = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(p)) + return -ENOMEM; - p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + pkt = p; + p = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; param_data = p; param_data->module_instance_id = module->instance_id; param_data->error_code = 0; - param_data->param_id = PARAM_ID_SAL_LIMITER_ENABLE; - param_data->param_size = sizeof(*limiter_enable); - p = p + APM_MODULE_PARAM_DATA_SIZE; - limiter_enable = p; + param_data->param_id = param_id; + param_data->param_size = sizeof(uint32_t); - limiter_enable->enable_lim = enable; + p = p + APM_MODULE_PARAM_DATA_SIZE; + param = p; + *param = param_val; rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); @@ -766,77 +765,26 @@ static int audioreach_sal_limiter_enable(struct q6apm_graph *graph, return rc; } +EXPORT_SYMBOL_GPL(audioreach_send_u32_param); + +static int audioreach_sal_limiter_enable(struct q6apm_graph *graph, + struct audioreach_module *module, bool enable) +{ + return audioreach_send_u32_param(graph, module, PARAM_ID_SAL_LIMITER_ENABLE, enable); +} static int audioreach_sal_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) { - struct apm_module_param_data *param_data; - struct param_id_sal_output_config *media_format; - int payload_size; - struct gpr_pkt *pkt; - int rc; - void *p; - - payload_size = sizeof(*media_format) + APM_MODULE_PARAM_DATA_SIZE; - - pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); - if (IS_ERR(pkt)) - return PTR_ERR(pkt); - - p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; - - param_data = p; - param_data->module_instance_id = module->instance_id; - param_data->error_code = 0; - param_data->param_id = PARAM_ID_SAL_OUTPUT_CFG; - param_data->param_size = sizeof(*media_format); - p = p + APM_MODULE_PARAM_DATA_SIZE; - media_format = p; - - media_format->bits_per_sample = cfg->bit_width; - - rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); - - kfree(pkt); - - return rc; + return audioreach_send_u32_param(graph, module, PARAM_ID_SAL_OUTPUT_CFG, cfg->bit_width); } static int audioreach_module_enable(struct q6apm_graph *graph, struct audioreach_module *module, bool enable) { - struct apm_module_param_data *param_data; - struct param_id_module_enable *param; - int payload_size; - struct gpr_pkt *pkt; - int rc; - void *p; - - payload_size = sizeof(*param) + APM_MODULE_PARAM_DATA_SIZE; - - pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); - if (IS_ERR(pkt)) - return PTR_ERR(pkt); - - p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; - - param_data = p; - param_data->module_instance_id = module->instance_id; - param_data->error_code = 0; - param_data->param_id = PARAM_ID_MODULE_ENABLE; - param_data->param_size = sizeof(*param); - p = p + APM_MODULE_PARAM_DATA_SIZE; - param = p; - - param->enable = enable; - - rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); - - kfree(pkt); - - return rc; + return audioreach_send_u32_param(graph, module, PARAM_ID_MODULE_ENABLE, enable); } static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 3ebb81cd7cb0..18d8d243b06b 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -752,4 +752,6 @@ int audioreach_set_media_format(struct q6apm_graph *graph, int audioreach_shared_memory_send_eos(struct q6apm_graph *graph); int audioreach_gain_set_vol_ctrl(struct q6apm *apm, struct audioreach_module *module, int vol); +int audioreach_send_u32_param(struct q6apm_graph *graph, struct audioreach_module *module, + uint32_t param_id, uint32_t param_val); #endif /* __AUDIOREACH_H__ */ From patchwork Fri Jun 9 14:54:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274081 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 10080C7EE29 for ; Fri, 9 Jun 2023 14:56:08 +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 6B341E81; Fri, 9 Jun 2023 16:55:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6B341E81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322565; bh=Z4aZ7UoieQXmMmJvAM7v7QCJvzDxN0YKXHOpaKVcrXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=TUiVKT7xo411T1xZWN2s18Oc+9UvWCEBXu+05wG1Pu9WOr8h7InbmuSkU3Si6CgUY 5AiDldb6Z/2uQ1YbkLUg2nINoxUbLwXRnswQiF1kLNLxUY+EAOx/sbQrMr8VYgHzVT 0P/GR2kEjlOSJMX1g5RoSiPrgiLdNdWXT1WDeLhg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B7B7F8057E; Fri, 9 Jun 2023 16:54:36 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8F9E0F8056F; Fri, 9 Jun 2023 16:54:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 64A03F80494; Fri, 9 Jun 2023 16:54:31 +0200 (CEST) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CEAADF800ED for ; Fri, 9 Jun 2023 16:54:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CEAADF800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Vd0Vf8OB Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f7f4819256so14388085e9.1 for ; Fri, 09 Jun 2023 07:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322465; x=1688914465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xT6jIsaE6umxJp6LYKmlwleIfCNa53LIehUuB1/ryv8=; b=Vd0Vf8OBk3PGtxmzsgVG4KAb8TUnZ4cZkGdqyFQPd2LRpjIA1MektKV2tRCWG32Wpn ic7pvZymZ/UHYoGO6M1V2I7d3Grr2X8GSdTmwESak18rlmeaVKw2CuJXpW9nDQEEqFjN RuvQRXbG6FVfBxsJfrFVKniPlzeAnVkxHpX8t3lRyyuaixfVaLC2bojtgpuRrHiF2FU9 /AfQPO3ko7eQOLu7XYpwjzBjlDVOC/gjC4fqAhWEgpWaCVkXBm44IUO8nURx2TxI6Wvk AH7tqyelW+2h1zk7Kvnsd9fg5RduXVDPiEKVxNAacgYgSsGaYovXDo6BdvG9azXxMb+D JajA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322465; x=1688914465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xT6jIsaE6umxJp6LYKmlwleIfCNa53LIehUuB1/ryv8=; b=SEPCv4rYKRnO5ReDiZGE19uVD7GPTPah5ARlfRVIkTETRK5Fk6vwgYkNOiYYAhe3gA owD6rVjmFQ5mtCvRGWzcNymC98kxd0wubk+S6bkkoPaHvgkGT8G8/Q39dGZvcdxnEpPv vESXYXYzOK2Vl2h1VBLFibvYjfZn2BzX2bGi/XrxX9B8/dTFiFb6vVarjIXo2MkrXClX u1DJSwYdy8aMoQ7NP/MiFetYj4bm+9739DIVWzU1JUh97DNqYo1uBK7hBv3onkPo2NL+ utxLmoR9ChWbqNygzyhzpSAcQ7kZwgNx5joluUgAX4Ftk4kstdyA1XwH3QX6/y31E5Yp xqOg== X-Gm-Message-State: AC+VfDw6v4kmJA8CwjlZmz1dRJZW/4rWQvW9noYigPjZ/AjZKOcWzBKZ zo2iwz1LuOfvWLXtg9T0ITDtsvmODobP0BmmXdo= X-Google-Smtp-Source: ACHHUZ6NM+CuWRv9gxLexLQhJhCThjo5KuWFrA2fMwfi0ZS4s5lwkEQbk/XKpw8R0FsppMO3HSGbTQ== X-Received: by 2002:a1c:ed15:0:b0:3f7:f584:579d with SMTP id l21-20020a1ced15000000b003f7f584579dmr1058428wmh.0.1686322465617; Fri, 09 Jun 2023 07:54:25 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:54:24 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla , Mohammad Rafi Shaik Subject: [PATCH v2 04/11] ASoC: q6dsp: audioreach: Add placeholder decoder for compress playback Date: Fri, 9 Jun 2023 15:54:00 +0100 Message-Id: <20230609145407.18774-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: AV3MVXWXWYGT4247FDYY6MP3SHWFCBWX X-Message-ID-Hash: AV3MVXWXWYGT4247FDYY6MP3SHWFCBWX X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add placeholder decoder graph module for compressed playback feature. Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.h | 14 +++++++ sound/soc/qcom/qdsp6/q6apm.c | 65 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6apm.h | 4 ++ 3 files changed, 83 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 18d8d243b06b..c4e03a49ac82 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -15,6 +15,8 @@ struct q6apm_graph; #define MODULE_ID_PCM_CNV 0x07001003 #define MODULE_ID_PCM_ENC 0x07001004 #define MODULE_ID_PCM_DEC 0x07001005 +#define MODULE_ID_PLACEHOLDER_ENCODER 0x07001008 +#define MODULE_ID_PLACEHOLDER_DECODER 0x07001009 #define MODULE_ID_SAL 0x07001010 #define MODULE_ID_MFC 0x07001015 #define MODULE_ID_CODEC_DMA_SINK 0x07001023 @@ -22,6 +24,9 @@ struct q6apm_graph; #define MODULE_ID_I2S_SINK 0x0700100A #define MODULE_ID_I2S_SOURCE 0x0700100B #define MODULE_ID_DATA_LOGGING 0x0700101A +#define MODULE_ID_AAC_DEC 0x0700101F +#define MODULE_ID_FLAC_DEC 0x0700102F +#define MODULE_ID_MP3_DECODE 0x0700103B #define MODULE_ID_DISPLAY_PORT_SINK 0x07001069 #define APM_CMD_GET_SPF_STATE 0x01001021 @@ -608,6 +613,15 @@ struct param_id_vol_ctrl_master_gain { } __packed; +#define PARAM_ID_REMOVE_INITIAL_SILENCE 0x0800114B +#define PARAM_ID_REMOVE_TRAILING_SILENCE 0x0800115D + +#define PARAM_ID_REAL_MODULE_ID 0x0800100B + +struct param_id_placeholder_real_module_id { + uint32_t real_module_id; +} __packed; + /* Graph */ struct audioreach_connection { /* Connections */ diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index b07fee8ccac1..7bfac9492ab5 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -298,6 +298,71 @@ int q6apm_unmap_memory_regions(struct q6apm_graph *graph, unsigned int dir) } EXPORT_SYMBOL_GPL(q6apm_unmap_memory_regions); +int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples) +{ + struct audioreach_module *module; + + module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); + if (!module) + return -ENODEV; + + return audioreach_send_u32_param(graph, module, PARAM_ID_REMOVE_INITIAL_SILENCE, samples); +} +EXPORT_SYMBOL_GPL(q6apm_remove_initial_silence); + +int q6apm_remove_trailing_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples) +{ + struct audioreach_module *module; + + module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); + if (!module) + return -ENODEV; + + return audioreach_send_u32_param(graph, module, PARAM_ID_REMOVE_TRAILING_SILENCE, samples); +} +EXPORT_SYMBOL_GPL(q6apm_remove_trailing_silence); + +int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *graph, bool en) +{ + struct audioreach_module *module; + + module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); + if (!module) + return -ENODEV; + + return audioreach_send_u32_param(graph, module, PARAM_ID_MODULE_ENABLE, en); +} +EXPORT_SYMBOL_GPL(q6apm_enable_compress_module); + +int q6apm_set_real_module_id(struct device *dev, struct q6apm_graph *graph, + uint32_t codec_id) +{ + struct audioreach_module *module; + uint32_t module_id; + + module = q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); + if (!module) + return -ENODEV; + + switch (codec_id) { + case SND_AUDIOCODEC_MP3: + module_id = MODULE_ID_MP3_DECODE; + break; + case SND_AUDIOCODEC_AAC: + module_id = MODULE_ID_AAC_DEC; + break; + case SND_AUDIOCODEC_FLAC: + module_id = MODULE_ID_FLAC_DEC; + break; + default: + return -EINVAL; + } + + return audioreach_send_u32_param(graph, module, PARAM_ID_REAL_MODULE_ID, + module_id); +} +EXPORT_SYMBOL_GPL(q6apm_set_real_module_id); + int q6apm_graph_media_format_pcm(struct q6apm_graph *graph, struct audioreach_module_config *cfg) { struct audioreach_graph_info *info = graph->info; diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 7005be9b63e3..87d67faf5f1a 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -147,4 +147,8 @@ int q6apm_graph_get_rx_shmem_module_iid(struct q6apm_graph *graph); bool q6apm_is_adsp_ready(void); +int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *graph, bool en); +int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples); +int q6apm_remove_trailing_silence(struct device *dev, struct q6apm_graph *graph, uint32_t samples); +int q6apm_set_real_module_id(struct device *dev, struct q6apm_graph *graph, uint32_t codec_id); #endif /* __APM_GRAPH_ */ From patchwork Fri Jun 9 14:54:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274083 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 A8ACFC7EE29 for ; Fri, 9 Jun 2023 14:56:29 +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 BFE74E80; Fri, 9 Jun 2023 16:55:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BFE74E80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322587; bh=tqTDWASfrvgDbmEkW0f1FpCMUrobXpoIviF76PAgzZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EeZxHecM0tI4a0mDKbo2Ufvpl8hMxMXIhis4VcAYQ2FRBMOadDPlOGkIG3cqAfV2u Bi30Awmyzauo+aESqpINAlEXDkdUMRyFhkbAH02dqhbvWBv/jFu4FeHQYgXJjPe9vD mcWs+3S5HhLfLEFwJcruS1qA6QmMyUNeK7NXwhis= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7143F8058C; Fri, 9 Jun 2023 16:54:42 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 5374BF805B2; Fri, 9 Jun 2023 16:54:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 99F77F80290; Fri, 9 Jun 2023 16:54:32 +0200 (CEST) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D852EF80544 for ; Fri, 9 Jun 2023 16:54:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D852EF80544 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BwMDi6uc Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f644dffd71so2421590e87.1 for ; Fri, 09 Jun 2023 07:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322466; x=1688914466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1BtEBe2KiptIwTf8OQC3A599yqS9fPvPypfh6VxvoyE=; b=BwMDi6ucjw7EI9vmSDPSly0MyfJynfVsfquS5N/1+eXdBT9lxlub2WxQaChzZ6Zalf a4d1BHgOBD0LKxR8H5VAft8j18rvi8a7odq6I7ybEjANYsJgnD/A4eRN8Cra/3ho+YBa T4/VzDyM7t5exFA0fR5cXTArHIZJjocNUhneCyHy6bpWFBcX25d7NFLN7q06ky14vKGT f1cM5Z+4do+wlw826xymWNp1aiGGEeL7M2j1domlnxXwh61Vt5a2zyWRyigad6JwasN1 t3tE900VgWWIPLgd9pJKUF1qFiVGntyhPK1bR9NWxEXVHML7bZo3uKEOB5Q4hQF2YbGU sG6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322466; x=1688914466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1BtEBe2KiptIwTf8OQC3A599yqS9fPvPypfh6VxvoyE=; b=D8NUkYk6dEKnrw8Dx9ZEO3aLPB5PLX16UnhX++kdwvZ23LCCDozECi8qj67V/ByjvE L4gNJ/4T1PD3ddyHoNVyahwzKkkBiku1tVyIAXVVyv1MDNaYoRsg0O8j3m3DJFfXBhqb 8ygYIysNUaXMW5ZfwSqlvRuiXjaGCI1M4MYQHaCC+gIN/DVkGd9i7lzvSZVmAUOufQ/0 PasDsuEIP5EQgVWUZNs3tyd4xJtHgPCVdPcjRk5LNVCOZjaA7ajT8gUlXPk7QYI2quNQ AUVXlzG1Izg7Im4qGOxwPC6veHgo6NTiYQ9aukjxgfll9qilPRba+LOXvKDSEmSUCmtU uw1w== X-Gm-Message-State: AC+VfDzR5XNPf1NgCZej66Syv2QaoDMjuMkJlj9DOadI4AlAVuroP/GX jgKoFaM5tDJYhICYMCDbDTX+gw== X-Google-Smtp-Source: ACHHUZ5xAWwhl1lYGznngZ2YV3gAxOGrpQF8T5BCtHwbZZN+DOxnsvCsL1MRjJd9p4IQcYzOrAGr8A== X-Received: by 2002:a05:6512:328c:b0:4f2:53ab:8a2d with SMTP id p12-20020a056512328c00b004f253ab8a2dmr1157879lfe.4.1686322466679; Fri, 09 Jun 2023 07:54:26 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:54:26 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Mohammad Rafi Shaik , Srinivas Kandagatla Subject: [PATCH v2 05/11] ASoC: q6dsp: audioreach: Add support to set compress format params Date: Fri, 9 Jun 2023 15:54:01 +0100 Message-Id: <20230609145407.18774-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: FBIOUJB5U6BELZQ2XF7QGLW7FIB7HMFG X-Message-ID-Hash: FBIOUJB5U6BELZQ2XF7QGLW7FIB7HMFG X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Mohammad Rafi Shaik Add function for setting compress params. Signed-off-by: Mohammad Rafi Shaik Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 139 ++++++++++++++++++++++++++---- sound/soc/qcom/qdsp6/audioreach.h | 28 ++++++ sound/soc/qcom/qdsp6/q6apm-dai.c | 1 + 3 files changed, 149 insertions(+), 19 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 0acd4a75d5cd..6d0f4c8505f1 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -834,6 +834,99 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, return rc; } +static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr, + void *p, struct audioreach_module_config *mcfg) +{ + struct payload_media_fmt_aac_t *aac_cfg; + struct payload_media_fmt_pcm *mp3_cfg; + struct payload_media_fmt_flac_t *flac_cfg; + + switch (mcfg->fmt) { + case SND_AUDIOCODEC_MP3: + media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED; + media_fmt_hdr->fmt_id = MEDIA_FMT_ID_MP3; + media_fmt_hdr->payload_size = 0; + p = p + sizeof(*media_fmt_hdr); + mp3_cfg = p; + mp3_cfg->sample_rate = mcfg->sample_rate; + mp3_cfg->bit_width = mcfg->bit_width; + mp3_cfg->alignment = PCM_LSB_ALIGNED; + mp3_cfg->bits_per_sample = mcfg->bit_width; + mp3_cfg->q_factor = mcfg->bit_width - 1; + mp3_cfg->endianness = PCM_LITTLE_ENDIAN; + mp3_cfg->num_channels = mcfg->num_channels; + + if (mcfg->num_channels == 1) { + mp3_cfg->channel_mapping[0] = PCM_CHANNEL_L; + } else if (mcfg->num_channels == 2) { + mp3_cfg->channel_mapping[0] = PCM_CHANNEL_L; + mp3_cfg->channel_mapping[1] = PCM_CHANNEL_R; + } + break; + case SND_AUDIOCODEC_AAC: + media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED; + media_fmt_hdr->fmt_id = MEDIA_FMT_ID_AAC; + media_fmt_hdr->payload_size = sizeof(struct payload_media_fmt_aac_t); + p = p + sizeof(*media_fmt_hdr); + aac_cfg = p; + aac_cfg->aac_fmt_flag = 0; + aac_cfg->audio_obj_type = 5; + aac_cfg->num_channels = mcfg->num_channels; + aac_cfg->total_size_of_PCE_bits = 0; + aac_cfg->sample_rate = mcfg->sample_rate; + break; + case SND_AUDIOCODEC_FLAC: + media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED; + media_fmt_hdr->fmt_id = MEDIA_FMT_ID_FLAC; + media_fmt_hdr->payload_size = sizeof(struct payload_media_fmt_flac_t); + p = p + sizeof(*media_fmt_hdr); + flac_cfg = p; + flac_cfg->sample_size = mcfg->codec.options.flac_d.sample_size; + flac_cfg->num_channels = mcfg->num_channels; + flac_cfg->min_blk_size = mcfg->codec.options.flac_d.min_blk_size; + flac_cfg->max_blk_size = mcfg->codec.options.flac_d.max_blk_size; + flac_cfg->sample_rate = mcfg->sample_rate; + flac_cfg->min_frame_size = mcfg->codec.options.flac_d.min_frame_size; + flac_cfg->max_frame_size = mcfg->codec.options.flac_d.max_frame_size; + break; + default: + return -EINVAL; + } + + return 0; +} + +int audioreach_compr_set_param(struct q6apm_graph *graph, struct audioreach_module_config *mcfg) +{ + struct media_format *header; + struct gpr_pkt *pkt; + int iid, payload_size, rc; + void *p; + + payload_size = sizeof(struct apm_sh_module_media_fmt_cmd); + + iid = q6apm_graph_get_rx_shmem_module_iid(graph); + pkt = audioreach_alloc_cmd_pkt(payload_size, DATA_CMD_WR_SH_MEM_EP_MEDIA_FORMAT, + 0, graph->port->id, iid); + + if (IS_ERR(pkt)) + return -ENOMEM; + + p = (void *)pkt + GPR_HDR_SIZE; + header = p; + rc = audioreach_set_compr_media_format(header, p, mcfg); + if (rc) { + kfree(pkt); + return rc; + } + + rc = gpr_send_port_pkt(graph->port, pkt); + kfree(pkt); + + return rc; +} +EXPORT_SYMBOL_GPL(audioreach_compr_set_param); + static int audioreach_i2s_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -1037,25 +1130,33 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph, p = p + APM_MODULE_PARAM_DATA_SIZE; header = p; - header->data_format = DATA_FORMAT_FIXED_POINT; - header->fmt_id = MEDIA_FMT_ID_PCM; - header->payload_size = payload_size - sizeof(*header); - - p = p + sizeof(*header); - cfg = p; - cfg->sample_rate = mcfg->sample_rate; - cfg->bit_width = mcfg->bit_width; - cfg->alignment = PCM_LSB_ALIGNED; - cfg->bits_per_sample = mcfg->bit_width; - cfg->q_factor = mcfg->bit_width - 1; - cfg->endianness = PCM_LITTLE_ENDIAN; - cfg->num_channels = mcfg->num_channels; - - if (mcfg->num_channels == 1) { - cfg->channel_mapping[0] = PCM_CHANNEL_L; - } else if (num_channels == 2) { - cfg->channel_mapping[0] = PCM_CHANNEL_L; - cfg->channel_mapping[1] = PCM_CHANNEL_R; + if (mcfg->fmt == SND_AUDIOCODEC_PCM) { + header->data_format = DATA_FORMAT_FIXED_POINT; + header->fmt_id = MEDIA_FMT_ID_PCM; + header->payload_size = payload_size - sizeof(*header); + + p = p + sizeof(*header); + cfg = p; + cfg->sample_rate = mcfg->sample_rate; + cfg->bit_width = mcfg->bit_width; + cfg->alignment = PCM_LSB_ALIGNED; + cfg->bits_per_sample = mcfg->bit_width; + cfg->q_factor = mcfg->bit_width - 1; + cfg->endianness = PCM_LITTLE_ENDIAN; + cfg->num_channels = mcfg->num_channels; + + if (mcfg->num_channels == 1) + cfg->channel_mapping[0] = PCM_CHANNEL_L; + else if (num_channels == 2) { + cfg->channel_mapping[0] = PCM_CHANNEL_L; + cfg->channel_mapping[1] = PCM_CHANNEL_R; + } + } else { + rc = audioreach_set_compr_media_format(header, p, mcfg); + if (rc) { + kfree(pkt); + return rc; + } } rc = audioreach_graph_send_cmd_sync(graph, pkt, 0); diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index c4e03a49ac82..dc089879b501 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -148,12 +148,15 @@ struct param_id_enc_bitrate_param { } __packed; #define DATA_FORMAT_FIXED_POINT 1 +#define DATA_FORMAT_GENERIC_COMPRESSED 5 +#define DATA_FORMAT_RAW_COMPRESSED 6 #define PCM_LSB_ALIGNED 1 #define PCM_MSB_ALIGNED 2 #define PCM_LITTLE_ENDIAN 1 #define PCM_BIT_ENDIAN 2 #define MEDIA_FMT_ID_PCM 0x09001000 +#define MEDIA_FMT_ID_MP3 0x09001009 #define PCM_CHANNEL_L 1 #define PCM_CHANNEL_R 2 #define SAMPLE_RATE_48K 48000 @@ -231,6 +234,28 @@ struct apm_media_format { uint32_t payload_size; } __packed; +#define MEDIA_FMT_ID_FLAC 0x09001004 + +struct payload_media_fmt_flac_t { + uint16_t num_channels; + uint16_t sample_size; + uint16_t min_blk_size; + uint16_t max_blk_size; + uint32_t sample_rate; + uint32_t min_frame_size; + uint32_t max_frame_size; +} __packed; + +#define MEDIA_FMT_ID_AAC 0x09001001 + +struct payload_media_fmt_aac_t { + uint16_t aac_fmt_flag; + uint16_t audio_obj_type; + uint16_t num_channels; + uint16_t total_size_of_PCE_bits; + uint32_t sample_rate; +} __packed; + #define DATA_CMD_WR_SH_MEM_EP_EOS 0x04001002 #define WR_SH_MEM_EP_EOS_POLICY_LAST 1 #define WR_SH_MEM_EP_EOS_POLICY_EACH 2 @@ -730,6 +755,7 @@ struct audioreach_module_config { u32 channel_allocation; u32 sd_line_mask; int fmt; + struct snd_codec codec; u8 channel_map[AR_PCM_MAX_NUM_CHANNEL]; }; @@ -768,4 +794,6 @@ int audioreach_gain_set_vol_ctrl(struct q6apm *apm, struct audioreach_module *module, int vol); int audioreach_send_u32_param(struct q6apm_graph *graph, struct audioreach_module *module, uint32_t param_id, uint32_t param_val); +int audioreach_compr_set_param(struct q6apm_graph *graph, struct audioreach_module_config *mcfg); + #endif /* __AUDIOREACH_H__ */ diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index 7f02f5b2c33f..9fff41ee98eb 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -155,6 +155,7 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, cfg.sample_rate = runtime->rate; cfg.num_channels = runtime->channels; cfg.bit_width = prtd->bits_per_sample; + cfg.fmt = SND_AUDIOCODEC_PCM; if (prtd->state) { /* clear the previous setup if any */ From patchwork Fri Jun 9 14:54:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274084 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 EC0F5C7EE2F for ; Fri, 9 Jun 2023 14:56:49 +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 E88E7886; Fri, 9 Jun 2023 16:55:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E88E7886 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322608; bh=zwla3lViOteuIC3ju1PhOS7PaDD4OAdf1RLozBdw7x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EEitCA8pW0c0KowoNQVtmDj4lZW9KIkDyi+IRHhqJ+B+Laz5dr92PrS7pYQAa+yga ZKA0Xm61r/uJ5hKqEcPRVH/T+ZtmY97KedHidUW17jIStSKJqyR62wxHv/qkQ/jF5Y fNwFsjmpgAJ4xPpyjK0kcZ4v74nf7uJZNCluGLJg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CCBECF80527; Fri, 9 Jun 2023 16:55:50 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D7BA1F80520; Fri, 9 Jun 2023 16:55:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AF2B7F80254; Fri, 9 Jun 2023 16:55:45 +0200 (CEST) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7FFFAF800ED for ; Fri, 9 Jun 2023 16:55:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7FFFAF800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hECgauk1 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso18366365e9.2 for ; Fri, 09 Jun 2023 07:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322541; x=1688914541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hHdZfsXP57Mm/02dFH23BtlU4BZ6K+unFALB3eZT2XI=; b=hECgauk1lv9bUI/qzxcc7onysVmt8iROVx6nXi/YCoc83NhbFoD/4qrdkus6CWQeow 17XOJnERd4wS2pC9Jtj5Z0LvbO36dq8e7vFaP8wMVLS3ZksVs2+8vlHqAfHCdsM8IeYb kWxbAUioeWrEo98dX43/VwdaqSD/KMsyqBIJ1SVJ9PQSOP0qflDSJtl3ytD+0abDkaM8 dDW/IHhRlRiYvQ0fhPJA/JfbyB5nqsKeBHDju8yUK/ttUrUZ4XiCAAIad3mORYijf6Bw 4NUfuoHOHGUS5tN3dkeIk3q/SjCML4ET/V5bL3+tddwKzcaJaMDWjfdNwDA78wiPIFPT Z9dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322541; x=1688914541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hHdZfsXP57Mm/02dFH23BtlU4BZ6K+unFALB3eZT2XI=; b=FSX5Rv5HRaLY5hVxzw3RKe2LMxxjuF7oUg3gf7fMwowPhBgQ0InbPHM61n3wPppQMi +1hBU8yXm0Bn2k1WN9OnmOguMh68WHiiJ9hYvTF2MqCYzZHDPOYfP7NMUFo0jaVLg7nI wP/2QQ0voySR2ujwzx5Ill8HEQm562CsE9chDA84dPtmCmRQc91Kth91Fb8MQhUTU36c k6jqrKl+yN7tPqhMiVJpEi7xa4P9vm59pN6+ZAgz2iQ+ZCUNMy8BmpvnsUte+g0aDrSt pvJnZteiX3ApNSclRQqzzVnfOXF9+cIDwxhmLnH/OXyPx8y2EheFb8q5VFUy4QxMTvtS Xslw== X-Gm-Message-State: AC+VfDzxybFNi5Rd/OJoyh2UDYxTCVHiGxY+0YeW68MExOw2tqsEtTLw noZNn/tIKpiaDPeVRsksvd+Q8A== X-Google-Smtp-Source: ACHHUZ5DrewvI0+n2J+g2WI68Cm64oCnaD/7RuLUe7THX5lmRHb6ogXTyKEQqJRdaPOPKIZ/0Vk9Dg== X-Received: by 2002:a05:600c:2901:b0:3f7:39ed:c9a4 with SMTP id i1-20020a05600c290100b003f739edc9a4mr1475841wmd.30.1686322541228; Fri, 09 Jun 2023 07:55:41 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:54:27 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Mohammad Rafi Shaik , Srinivas Kandagatla Subject: [PATCH v2 06/11] ASoC: q6dsp: audioreach: Add gapless feature support Date: Fri, 9 Jun 2023 15:54:02 +0100 Message-Id: <20230609145407.18774-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: 4KNMKI4BCHNKEK222ZD47KELKXWR7EUG X-Message-ID-Hash: 4KNMKI4BCHNKEK222ZD47KELKXWR7EUG X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Mohammad Rafi Shaik Add support for setting EOS delay command and receive the EOS response from ADSP, for seamless compress offload playback feature. Signed-off-by: Srinivas Kandagatla Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/qdsp6/audioreach.c | 11 +++++++++++ sound/soc/qcom/qdsp6/audioreach.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 6d0f4c8505f1..fefab20aaf1c 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -787,6 +787,14 @@ static int audioreach_module_enable(struct q6apm_graph *graph, return audioreach_send_u32_param(graph, module, PARAM_ID_MODULE_ENABLE, enable); } +static int audioreach_gapless_set_media_format(struct q6apm_graph *graph, + struct audioreach_module *module, + struct audioreach_module_config *cfg) +{ + return audioreach_send_u32_param(graph, module, PARAM_ID_EARLY_EOS_DELAY, + EARLY_EOS_DELAY_MS); +} + static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -1268,6 +1276,9 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod case MODULE_ID_MFC: rc = audioreach_mfc_set_media_format(graph, module, cfg); break; + case MODULE_ID_GAPLESS: + rc = audioreach_gapless_set_media_format(graph, module, cfg); + break; default: rc = 0; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index dc089879b501..e38111ffd7b9 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -27,6 +27,7 @@ struct q6apm_graph; #define MODULE_ID_AAC_DEC 0x0700101F #define MODULE_ID_FLAC_DEC 0x0700102F #define MODULE_ID_MP3_DECODE 0x0700103B +#define MODULE_ID_GAPLESS 0x0700104D #define MODULE_ID_DISPLAY_PORT_SINK 0x07001069 #define APM_CMD_GET_SPF_STATE 0x01001021 @@ -552,6 +553,8 @@ struct param_id_sal_limiter_enable { } __packed; #define PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT 0x08001024 +#define PARAM_ID_EARLY_EOS_DELAY 0x0800114C +#define EARLY_EOS_DELAY_MS 150 struct param_id_mfc_media_format { uint32_t sample_rate; @@ -560,6 +563,10 @@ struct param_id_mfc_media_format { uint16_t channel_mapping[]; } __packed; +struct param_id_gapless_early_eos_delay_t { + uint32_t early_eos_delay_ms; +} __packed; + struct media_format { uint32_t data_format; uint32_t fmt_id; From patchwork Fri Jun 9 14:54:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274085 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 72C0AC7EE2E for ; Fri, 9 Jun 2023 14:57:00 +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 6D41AE91; Fri, 9 Jun 2023 16:56:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6D41AE91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322618; bh=gEPRkuSo6lFQCKYtKb2IP859s7T+V3C5clVEW+m2i38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Oquffpq0Hg4MsqiCbl1lbYEvL+Q2O7jnz5DUmmiuLWr8rjrdHwHXhx9VzsvzCSCMj ETxfGqF3DuLO1jr2SH7RxnG5Qk+omEQlFM4V/jMLLeQAbqi6Q07MUE2Jf8ITV0OA7q UkQNDkNJbWE8YcK1RnGlQZlUU/cMkAnPloDq0wv8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B69BBF80558; Fri, 9 Jun 2023 16:55:53 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id F10C7F80254; Fri, 9 Jun 2023 16:55:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 776ADF80199; Fri, 9 Jun 2023 16:55:46 +0200 (CEST) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 52F94F800C8 for ; Fri, 9 Jun 2023 16:55:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 52F94F800C8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=D3IZ+Fe4 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f6dfc4e01fso18454175e9.0 for ; Fri, 09 Jun 2023 07:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322542; x=1688914542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5oas5yfZUch+KwTs6sPoo3Z/Mjm/SkzsGldUfkoryZM=; b=D3IZ+Fe4GQ9c1/S5GhPhqwZWsWHCROvNIelKWbl7B6W+K3B83uRz9KpjGJ/nz7Sgy7 h3TSNUDTlut2ncpzSvtVP2EPV8V68Ap/q0b7Z0kiWDZXut1DYWWWLtLUSKtcDWRgnh8m ZCliVAH1s/Cu3HVOns0vrJQ7hJbnnVTZigFMH0iRA+tSU/0dsYPUArT/RIUx38iFHjmG gjLira3Tr8WALzgWQ00XFQDvfe7XYcWzG+NhS8Xng9d6RoLKHYrkdsb1oTNn/aComHlo YeZaMropnRmZs+QJzFunYs9ygx9f6hQ27z6otilxXEYY94WzNIVVj7t9mnRkyTiFhpyX 9OUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322542; x=1688914542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5oas5yfZUch+KwTs6sPoo3Z/Mjm/SkzsGldUfkoryZM=; b=B0lG1avOZTdUApeC4V1iLRbGDaLjdwwtKdCfOOrTJs+MYoVeaVCMk9lD/IAMW+gNNV 6D/pi3vAcaTYR2DwJeMl3dALWbEsClOk55FwkfXFW/muGUGO80ZI6hBUBIhbfHecOtc8 mLiCyyO67LRfhEMUl6b+eOkXHmfLg+vLccSODT0hTFtyxMuDNW9SPZWIDxN267tC3sFY 8531GSZGRPmq8s6R0pN5KLu9zSBSsrRyCF+Rggia734DfX8/evcb+65kw5UQEk9OJtZo CzKUL7gkX1H7jhguuOzde+apH/EL7YRXbI8hRsNtTnl5ocgK7ILvIo7PFBtHV4Uu67di Eutg== X-Gm-Message-State: AC+VfDxjTmC2YZha1IxBDIDMxKTIF59rE3/LgduJy5doDKKCBWVXMIlG 8w5Jd9a79F57ZQzLpTM7iPQh9Q== X-Google-Smtp-Source: ACHHUZ5VX5XFlF2Ps/n+HZ9WOvmRQVv13Bgxps4vrqIBIKOroweQSDzrmfUDOu38QCXMi4tv11j5tg== X-Received: by 2002:a05:600c:2245:b0:3f7:33cf:707f with SMTP id a5-20020a05600c224500b003f733cf707fmr1448347wmm.35.1686322542463; Fri, 09 Jun 2023 07:55:42 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:55:41 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla , Mohammad Rafi Shaik Subject: [PATCH v2 07/11] ASoC: q6dsp: q6apm-dai: Add open/free compress DAI callbacks Date: Fri, 9 Jun 2023 15:54:03 +0100 Message-Id: <20230609145407.18774-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: UUJOCZDKPOPLLQ5OFAVI5YTWZWBCISXG X-Message-ID-Hash: UUJOCZDKPOPLLQ5OFAVI5YTWZWBCISXG X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add q6apm open and free compress DAI callbacks to support compress offload playback. Include compress event handler callback also. Signed-off-by: Srinivas Kandagatla Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/qdsp6/q6apm-dai.c | 136 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6apm.h | 1 + 2 files changed, 137 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index 9fff41ee98eb..32df5db014d3 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -28,6 +28,8 @@ #define CAPTURE_MIN_PERIOD_SIZE 320 #define BUFFER_BYTES_MAX (PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE) #define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE) +#define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024) +#define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4) #define SID_MASK_DEFAULT 0xF enum stream_state { @@ -55,6 +57,7 @@ struct q6apm_dai_rtd { enum stream_state state; struct q6apm_graph *graph; spinlock_t lock; + bool notify_on_drain; }; struct q6apm_dai_data { @@ -132,6 +135,69 @@ static void event_handler(uint32_t opcode, uint32_t token, uint32_t *payload, vo } } +static void event_handler_compr(uint32_t opcode, uint32_t token, + uint32_t *payload, void *priv) +{ + struct q6apm_dai_rtd *prtd = priv; + struct snd_compr_stream *substream = prtd->cstream; + unsigned long flags; + uint32_t wflags = 0; + uint64_t avail; + uint32_t bytes_written, bytes_to_write; + bool is_last_buffer = false; + + switch (opcode) { + case APM_CLIENT_EVENT_CMD_EOS_DONE: + spin_lock_irqsave(&prtd->lock, flags); + if (prtd->notify_on_drain) { + snd_compr_drain_notify(prtd->cstream); + prtd->notify_on_drain = false; + } else { + prtd->state = Q6APM_STREAM_STOPPED; + } + spin_unlock_irqrestore(&prtd->lock, flags); + break; + case APM_CLIENT_EVENT_DATA_WRITE_DONE: + spin_lock_irqsave(&prtd->lock, flags); + bytes_written = token >> APM_WRITE_TOKEN_LEN_SHIFT; + prtd->copied_total += bytes_written; + snd_compr_fragment_elapsed(substream); + + if (prtd->state != Q6APM_STREAM_RUNNING) { + spin_unlock_irqrestore(&prtd->lock, flags); + break; + } + + avail = prtd->bytes_received - prtd->bytes_sent; + + if (avail > prtd->pcm_count) { + bytes_to_write = prtd->pcm_count; + } else { + if (substream->partial_drain || prtd->notify_on_drain) + is_last_buffer = true; + bytes_to_write = avail; + } + + if (bytes_to_write) { + if (substream->partial_drain && is_last_buffer) + wflags |= APM_LAST_BUFFER_FLAG; + + q6apm_write_async(prtd->graph, + bytes_to_write, 0, 0, wflags); + + prtd->bytes_sent += bytes_to_write; + + if (prtd->notify_on_drain && is_last_buffer) + audioreach_shared_memory_send_eos(prtd->graph); + } + + spin_unlock_irqrestore(&prtd->lock, flags); + break; + default: + break; + } +} + static int q6apm_dai_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -387,6 +453,75 @@ static int q6apm_dai_pcm_new(struct snd_soc_component *component, struct snd_soc return snd_pcm_set_fixed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, component->dev, size); } +static int q6apm_dai_compr_open(struct snd_soc_component *component, + struct snd_compr_stream *stream) +{ + struct snd_soc_pcm_runtime *rtd = stream->private_data; + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd; + struct q6apm_dai_data *pdata; + struct device *dev = component->dev; + int ret, size; + int graph_id; + + graph_id = cpu_dai->driver->id; + pdata = snd_soc_component_get_drvdata(component); + if (!pdata) + return -EINVAL; + + prtd = kzalloc(sizeof(*prtd), GFP_KERNEL); + if (prtd == NULL) + return -ENOMEM; + + prtd->cstream = stream; + prtd->graph = q6apm_graph_open(dev, (q6apm_cb)event_handler_compr, prtd, graph_id); + if (IS_ERR(prtd->graph)) { + ret = PTR_ERR(prtd->graph); + kfree(prtd); + return ret; + } + + runtime->private_data = prtd; + runtime->dma_bytes = BUFFER_BYTES_MAX; + size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE * COMPR_PLAYBACK_MAX_NUM_FRAGMENTS; + ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, &prtd->dma_buffer); + if (ret) + return ret; + + if (pdata->sid < 0) + prtd->phys = prtd->dma_buffer.addr; + else + prtd->phys = prtd->dma_buffer.addr | (pdata->sid << 32); + + snd_compr_set_runtime_buffer(stream, &prtd->dma_buffer); + spin_lock_init(&prtd->lock); + + q6apm_enable_compress_module(dev, prtd->graph, true); + return 0; +} + +static int q6apm_dai_compr_free(struct snd_soc_component *component, + struct snd_compr_stream *stream) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + + q6apm_graph_stop(prtd->graph); + q6apm_unmap_memory_regions(prtd->graph, SNDRV_PCM_STREAM_PLAYBACK); + q6apm_graph_close(prtd->graph); + snd_dma_free_pages(&prtd->dma_buffer); + prtd->graph = NULL; + kfree(prtd); + runtime->private_data = NULL; + + return 0; +} +static const struct snd_compress_ops q6apm_dai_compress_ops = { + .open = q6apm_dai_compr_open, + .free = q6apm_dai_compr_free, +}; + static const struct snd_soc_component_driver q6apm_fe_dai_component = { .name = DRV_NAME, .open = q6apm_dai_open, @@ -396,6 +531,7 @@ static const struct snd_soc_component_driver q6apm_fe_dai_component = { .hw_params = q6apm_dai_hw_params, .pointer = q6apm_dai_pointer, .trigger = q6apm_dai_trigger, + .compress_ops = &q6apm_dai_compress_ops, }; static int q6apm_dai_probe(struct platform_device *pdev) diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 87d67faf5f1a..d187d88c0a8c 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -45,6 +45,7 @@ #define APM_WRITE_TOKEN_LEN_SHIFT 16 #define APM_MAX_SESSIONS 8 +#define APM_LAST_BUFFER_FLAG BIT(30) struct q6apm { struct device *dev; From patchwork Fri Jun 9 14:54:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274086 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 52389C7EE2E for ; Fri, 9 Jun 2023 14:57:20 +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 82518A4C; Fri, 9 Jun 2023 16:56:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 82518A4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322638; bh=hi1AeZ0GCnk6o+EYVqxBTte1jHjOGOhIQob033Gi2Hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=b3n+3IPy+VjJk2AGpSjRxWNkh/uxNydIEu/9URbtvCyHrxX4y8cUlREY3VvkvRDKi GTS0RM9Zr/X5ygm7Nyvw0dYx9qZfqbCjSqYbzfsVY8yYQ505M6uO/TnevYvfE2v1ZZ DthgcQY+F8fn8ASpiWkpWKDZxlMDqMuvJsYO8r+0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 276C4F8059F; Fri, 9 Jun 2023 16:55:57 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9A071F8057D; Fri, 9 Jun 2023 16:55:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7FE31F80199; Fri, 9 Jun 2023 16:55:47 +0200 (CEST) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4425F800ED for ; Fri, 9 Jun 2023 16:55:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4425F800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=KnoVAq2J Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f6e4554453so14805575e9.3 for ; Fri, 09 Jun 2023 07:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322544; x=1688914544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WUxfLsYF7Nu3sb5ZtsLU4AYKkp6avkU3Rrr4hZloVjM=; b=KnoVAq2JS0/z/FdaxeliMNHC4v2r82hPnhb+Gc2gxUqkf5M9awco3trP/l+Rzv2MKg /FOM8Ac1YOMdHW2KzNz96/Ib6O1cYWzX5+bZ9a7kyP4UkouW13NLZTrws/bE6qHpSW8b oF39Xrc1KzCgTYViz7IMbsB7nX7fgSZuN2c8NlJiRaTYQNcABFKmCffiZfdme7b7wYWO ZFpBpLnLpgPfwdaihVZa2+53iTENjJhzigSmpNdmlfbeK6yhPawfkNzxmeS0xvmzs9QW lQswvR26gLD3nj5O9xDHEnq6j1y4uscbqnC9P4rjrSUcogb4pbEdp8g/unrWv0sO3nXW b/Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322544; x=1688914544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WUxfLsYF7Nu3sb5ZtsLU4AYKkp6avkU3Rrr4hZloVjM=; b=TiuEm2Kz4o3H8WhwffVW6SCK3+4aY9SDoPt1k1FkJb02dPjsDn7bYAElQGIdOtQmGi dJdh5z997Jm8niWPAcoGntQyfFQUwnbXedmHHfjR5c6Qt1z1kJSGat6576OgzabSOe96 2kxM6QiofvVSCNJwvgelSRO1s7jDqkQDLbE1lS2frA018vR5uVyN1shzFrmgqCseGbEG mq+GBfYryRLS33mtLv/aadWygazKGfQkIg0BL+IW0iry2F6+pmISUOGHCbDeD0YRif5t 5RWFQtXF/QzoZXzQFoe3kpm9CDEXPDd4kBiXjsVPsl2P9eDz5HfohXBflpakPhaWEyvV aumQ== X-Gm-Message-State: AC+VfDzCYL4sQRaJqkHs+E7cC3P3RyJZDRwzan/mMZ3AFeRG5lKcVvZR XBNj6ZqT7D9WIgIxx7xosjHRoA== X-Google-Smtp-Source: ACHHUZ6Dvm6xYWLAMBQdbRthwd09flGv8K/+0G+/L3BhiMdQPd+pyaItSJMcXsTdL+dfe/6wCAYDWg== X-Received: by 2002:a05:600c:2204:b0:3f6:be1:b8d9 with SMTP id z4-20020a05600c220400b003f60be1b8d9mr1376592wml.6.1686322543941; Fri, 09 Jun 2023 07:55:43 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:55:43 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla , Mohammad Rafi Shaik Subject: [PATCH v2 08/11] ASoC: q6dsp: q6apm-dai: Add compress DAI and codec caps get callbacks Date: Fri, 9 Jun 2023 15:54:04 +0100 Message-Id: <20230609145407.18774-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: B3SU6MXCRRXNYVGYRIZ2O4NVKA2UAN4D X-Message-ID-Hash: B3SU6MXCRRXNYVGYRIZ2O4NVKA2UAN4D X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add q6apm get compress DAI capabilities and codec capabilities callbacks to support compress offload playback. Signed-off-by: Srinivas Kandagatla Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/qdsp6/q6apm-dai.c | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index 32df5db014d3..d43705bf523a 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -30,8 +30,25 @@ #define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE) #define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024) #define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4) +#define COMPR_PLAYBACK_MIN_FRAGMENT_SIZE (8 * 1024) +#define COMPR_PLAYBACK_MIN_NUM_FRAGMENTS (4) #define SID_MASK_DEFAULT 0xF +static const struct snd_compr_codec_caps q6apm_compr_caps = { + .num_descriptors = 1, + .descriptor[0].max_ch = 2, + .descriptor[0].sample_rates = { 8000, 11025, 12000, 16000, 22050, + 24000, 32000, 44100, 48000, 88200, + 96000, 176400, 192000 }, + .descriptor[0].num_sample_rates = 13, + .descriptor[0].bit_rate[0] = 320, + .descriptor[0].bit_rate[1] = 128, + .descriptor[0].num_bitrates = 2, + .descriptor[0].profiles = 0, + .descriptor[0].modes = SND_AUDIOCHANMODE_MP3_STEREO, + .descriptor[0].formats = 0, +}; + enum stream_state { Q6APM_STREAM_IDLE = 0, Q6APM_STREAM_STOPPED, @@ -41,6 +58,7 @@ enum stream_state { struct q6apm_dai_rtd { struct snd_pcm_substream *substream; struct snd_compr_stream *cstream; + struct snd_codec codec; struct snd_compr_params codec_param; struct snd_dma_buffer dma_buffer; phys_addr_t phys; @@ -54,6 +72,7 @@ struct q6apm_dai_rtd { uint16_t bits_per_sample; uint16_t source; /* Encoding source bit mask */ uint16_t session_id; + bool next_track; enum stream_state state; struct q6apm_graph *graph; spinlock_t lock; @@ -517,9 +536,43 @@ static int q6apm_dai_compr_free(struct snd_soc_component *component, return 0; } + +static int q6apm_dai_compr_get_caps(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_compr_caps *caps) +{ + caps->direction = SND_COMPRESS_PLAYBACK; + caps->min_fragment_size = COMPR_PLAYBACK_MIN_FRAGMENT_SIZE; + caps->max_fragment_size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE; + caps->min_fragments = COMPR_PLAYBACK_MIN_NUM_FRAGMENTS; + caps->max_fragments = COMPR_PLAYBACK_MAX_NUM_FRAGMENTS; + caps->num_codecs = 3; + caps->codecs[0] = SND_AUDIOCODEC_MP3; + caps->codecs[1] = SND_AUDIOCODEC_AAC; + caps->codecs[2] = SND_AUDIOCODEC_FLAC; + + return 0; +} + +static int q6apm_dai_compr_get_codec_caps(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_compr_codec_caps *codec) +{ + switch (codec->codec) { + case SND_AUDIOCODEC_MP3: + *codec = q6apm_compr_caps; + break; + default: + break; + } + + return 0; +} static const struct snd_compress_ops q6apm_dai_compress_ops = { .open = q6apm_dai_compr_open, .free = q6apm_dai_compr_free, + .get_caps = q6apm_dai_compr_get_caps, + .get_codec_caps = q6apm_dai_compr_get_codec_caps, }; static const struct snd_soc_component_driver q6apm_fe_dai_component = { From patchwork Fri Jun 9 14:54:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274087 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 6324EC7EE29 for ; Fri, 9 Jun 2023 14:57:33 +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 6FAA3E96; Fri, 9 Jun 2023 16:56:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6FAA3E96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322651; bh=2rAbzoA8M0m1zSiadj/O8IO3HWaQMU2Et9W1rvgsAiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eL3118aFIrtQQiWbDb6egOP9YrnJYshxAM8gKDd9LHD87UHJ8TghHgAVbMlPK61+G jQziMQ5KdalAIxL3J4OW/vD3EIQeTtOFyITHk2nIw0wzdqbb1JFXtGKeESsW9mnoiQ npAlPpMOt9uzvz/KIA+EwRFCAkevIG247stFfA/E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2A9A3F805AE; Fri, 9 Jun 2023 16:55:59 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 75440F805AD; Fri, 9 Jun 2023 16:55:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BF913F80254; Fri, 9 Jun 2023 16:55:48 +0200 (CEST) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0CE59F800ED for ; Fri, 9 Jun 2023 16:55:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0CE59F800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=wGdDdU1W Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f6da07feb2so18480035e9.0 for ; Fri, 09 Jun 2023 07:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322545; x=1688914545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ceveTfOufM41Yk46cZA2HP7pP/eOM7y2Ye/vu65mbBg=; b=wGdDdU1WbBehr6YeSjJKJn2UicuWUB0ZAFeXWFhjulmN7L79cudbUKwhzTXhSnQlQT 5OtYwrDbnPzojxezVf7Nb+lDxIKdUzmoixPSzbd/BE55bL0rHwk0ibyDuDkvrK2+c5yZ ogHLqsEysKwz0f8Dw5JxGnyLcRHdHCb81BGP9H8WwEz/Rv/u+2PUMIG91z1HNx9JzjEq H3+T6KT7Roh0qPnWvFCrGkkFeyZK7LH0cDSTzbmCkrDLd9N8mPami5oHqSiooVvp1UUz 8PvZynmeITTUIV0GtWt17uKYjSZKFWT4c8iQxCUWtngcNNwih7RPKHqqTMxhG0KBtsqN 42jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322545; x=1688914545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ceveTfOufM41Yk46cZA2HP7pP/eOM7y2Ye/vu65mbBg=; b=h/seicz/J1dIKiPrvXcctibgcSd+brJuzOa4k2PcLCHfWsI5QdSIK0lMsM1Xo7TBgA w/OEDJC92ovCoTPXkWT5wDnpMYmetgNfdzEg0PU/504xvW4Te5FdDENwJXkqRuYMD48y ZmWL4oSD/JNTakrXy6duub8LQ+JIYFAkRT3hzlmmH0gXpxi4ln34pb6WoISu/jl4lxS+ NmfzmXobX67dFpQaBeWewV9/uZbP+rYAKGSiK5ZAGxrxv6qcZ+rTIl9fi611B9IUVq52 WxD5x6OJ9qAWCkTHMP62k5GAVJvsyckMm9jTbx6FDA3xOl3cLJp9i4f4TYCgFTFzeBGC gleA== X-Gm-Message-State: AC+VfDxSqbzXjn+2CjeHFS7lmq3wflhP8xoDMW6mMiVOq4cFSYpYovzo Fu20kvdgcRtHEVGTFlRyqSVRTPA6onEWGTnMFPo= X-Google-Smtp-Source: ACHHUZ4+xaJJt8ykggKW0Xc2YkxZCEXG9THMCFctHSJ1eSFC1V4U97xkSNUdkLqQXEYF4N2d4JWOPg== X-Received: by 2002:a05:600c:2901:b0:3f6:d2c:13f2 with SMTP id i1-20020a05600c290100b003f60d2c13f2mr1453507wmd.41.1686322545323; Fri, 09 Jun 2023 07:55:45 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:55:44 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla , Mohammad Rafi Shaik Subject: [PATCH v2 09/11] ASoC: q6dsp: q6apm-dai: Add trigger/pointer compress DAI callbacks Date: Fri, 9 Jun 2023 15:54:05 +0100 Message-Id: <20230609145407.18774-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: U3LBA3ZUNCHF7UIQDS4MJ4IQC3AKBCBZ X-Message-ID-Hash: U3LBA3ZUNCHF7UIQDS4MJ4IQC3AKBCBZ X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add q6apm trigger and pointer compress DAI callbacks to support compress offload playback. Signed-off-by: Srinivas Kandagatla Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/qdsp6/q6apm-dai.c | 67 ++++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6apm.h | 1 + 2 files changed, 68 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index d43705bf523a..9543b79ce83d 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -568,11 +568,78 @@ static int q6apm_dai_compr_get_codec_caps(struct snd_soc_component *component, return 0; } + +static int q6apm_dai_compr_pointer(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_compr_tstamp *tstamp) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + unsigned long flags; + + spin_lock_irqsave(&prtd->lock, flags); + tstamp->copied_total = prtd->copied_total; + tstamp->byte_offset = prtd->copied_total % prtd->pcm_size; + spin_unlock_irqrestore(&prtd->lock, flags); + + return 0; +} + +static int q6apm_dai_compr_trigger(struct snd_soc_component *component, + struct snd_compr_stream *stream, int cmd) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + int ret = 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + ret = q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTAMP); + break; + case SNDRV_PCM_TRIGGER_STOP: + break; + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + break; + case SND_COMPR_TRIGGER_NEXT_TRACK: + prtd->next_track = true; + break; + case SND_COMPR_TRIGGER_DRAIN: + case SND_COMPR_TRIGGER_PARTIAL_DRAIN: + prtd->notify_on_drain = true; + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int q6apm_dai_compr_ack(struct snd_soc_component *component, struct snd_compr_stream *stream, + size_t count) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + unsigned long flags; + + spin_lock_irqsave(&prtd->lock, flags); + prtd->bytes_received += count; + spin_unlock_irqrestore(&prtd->lock, flags); + + return count; +} + static const struct snd_compress_ops q6apm_dai_compress_ops = { .open = q6apm_dai_compr_open, .free = q6apm_dai_compr_free, .get_caps = q6apm_dai_compr_get_caps, .get_codec_caps = q6apm_dai_compr_get_codec_caps, + .pointer = q6apm_dai_compr_pointer, + .trigger = q6apm_dai_compr_trigger, + .ack = q6apm_dai_compr_ack, }; static const struct snd_soc_component_driver q6apm_fe_dai_component = { diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index d187d88c0a8c..8ee40732ce9e 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -46,6 +46,7 @@ #define APM_MAX_SESSIONS 8 #define APM_LAST_BUFFER_FLAG BIT(30) +#define NO_TIMESTAMP 0xFF00 struct q6apm { struct device *dev; From patchwork Fri Jun 9 14:54:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274088 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 4B009C7EE2E for ; Fri, 9 Jun 2023 14:57:51 +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 50AE2DE5; Fri, 9 Jun 2023 16:56:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 50AE2DE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322669; bh=ByPpk4/aj5+fn9NzrIvec6xI/PPQNeYjEwxEGICXnmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LCUm5Z0dQAro5H6JjH4LNJ4Z2fwq7H73IimA90YKOjt5Mg/KRULvRh9htIuqiIMwo BhJ/CqQOZToJoJZh/s6zMt1Cv6WFkCF9tDWQz+3PwwlhM2Get8iS+hmZ4KcGuRJrO7 EdeSKgq44Gz31tVjNzjpfc4kaFWm/vWBTsM1R3OI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 05339F805BE; Fri, 9 Jun 2023 16:56:01 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 748ABF805B3; Fri, 9 Jun 2023 16:56:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2199DF80552; Fri, 9 Jun 2023 16:55:52 +0200 (CEST) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9A69BF80254 for ; Fri, 9 Jun 2023 16:55:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A69BF80254 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aipY2JLl Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f735bfcbbbso14103865e9.2 for ; Fri, 09 Jun 2023 07:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322546; x=1688914546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kDTHAoTD8UW2CusT+8oVB9TCJ1eQ8kR6GrrvgY5ydt0=; b=aipY2JLl8aF3VEwqPW5eGQ7DZc1TockTkm3/IVxpaQoBzqgYHuYkPghfaVRvHlNkcQ 5PAClx7cGJ+wIxWnjs24kNPL0LxWp79O+jjB7O3eOCpE3uzYOwnwH1VO/8TgfeA8ypgY ve0PUnfSDnu1PcfZM4I64BeXjzC1xAZhOVOUOG0iwzqhRW52FqmS002ue8BJGpyntOj4 vG1L6YUx1SN4zWUua5kyuKEkPbSM42kw2udX06h/gt6QM6Q9M7pZO9hWcwG7oT+iUANY NpQyIv307wwMxqLo6fUUqglHtHVRlOW0tXcmr0CBFp7kl+X65XLeRfQNBmNXJZWF3Xjq tAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322546; x=1688914546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kDTHAoTD8UW2CusT+8oVB9TCJ1eQ8kR6GrrvgY5ydt0=; b=TmUgSdsfo3Agx1HclhUy+rKP8ySquaaerfT5nB00Eq0NqABZ5TENrtkHCtqNY7rVMs 0DQxwXMEEbZ9rmDBLoG8bcH9N/3SRRt580EuNKfjw6QHZjhRvlBXLXoVfck/vFQ2LFWv 1J0Dq5Tem04KZE33D6RPzQNTF4sR2CAVax+wqHLHaaByNuJdHRAnXg0AVRrzyKpOI61c ESsd1XrmXZEV+wKnXR22JiVnoK01d/XDy7pkTwvp8qNuMe5XVMCKgj9W9lbt2U3P5NBh MY9aB1w71sODBS1jTfdiaxSpmBbg3H8qFKrdwiP4v1LekiRzNZTth0He49+Qq2i6qork WT9A== X-Gm-Message-State: AC+VfDwPo2YGmOOCt35yfCy18t0Gkj9uW9IoxSw9wmeatlKkbt5VIsrB PeyEzY/KZUrGgbnNLeAJ9WUwEg== X-Google-Smtp-Source: ACHHUZ6ZtNL/tW7OcVMfj1SrOwMGTN210HRaFxEhXm8zNWcifVgfdkWsHwmdxU9y8d5IVMVTQqg61Q== X-Received: by 2002:a05:600c:219a:b0:3f1:9b85:e305 with SMTP id e26-20020a05600c219a00b003f19b85e305mr1145537wme.34.1686322546589; Fri, 09 Jun 2023 07:55:46 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:55:46 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla , Mohammad Rafi Shaik Subject: [PATCH v2 10/11] ASoC: q6dsp: q6apm-dai: Add compress set params and metadata DAI callbacks Date: Fri, 9 Jun 2023 15:54:06 +0100 Message-Id: <20230609145407.18774-11-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: 3MUPBFW7IRFI7RASZ5O66AEGYUJJSIOB X-Message-ID-Hash: 3MUPBFW7IRFI7RASZ5O66AEGYUJJSIOB X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add q6apm compress DAI callbacks for setting params and metadata to support compress offload playback. Signed-off-by: Srinivas Kandagatla Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/qdsp6/q6apm-dai.c | 107 +++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index 9543b79ce83d..c67147e5388b 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -76,6 +76,8 @@ struct q6apm_dai_rtd { enum stream_state state; struct q6apm_graph *graph; spinlock_t lock; + uint32_t initial_samples_drop; + uint32_t trailing_samples_drop; bool notify_on_drain; }; @@ -632,6 +634,109 @@ static int q6apm_dai_compr_ack(struct snd_soc_component *component, struct snd_c return count; } +static int q6apm_dai_compr_set_params(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_compr_params *params) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + struct q6apm_dai_data *pdata; + struct audioreach_module_config cfg; + struct snd_codec *codec = ¶ms->codec; + int dir = stream->direction; + int ret; + + pdata = snd_soc_component_get_drvdata(component); + if (!pdata) + return -EINVAL; + + prtd->periods = runtime->fragments; + prtd->pcm_count = runtime->fragment_size; + prtd->pcm_size = runtime->fragments * runtime->fragment_size; + prtd->bits_per_sample = 16; + + prtd->pos = 0; + + if (prtd->next_track != true) { + memcpy(&prtd->codec, codec, sizeof(*codec)); + + ret = q6apm_set_real_module_id(component->dev, prtd->graph, codec->id); + if (ret) + return ret; + + cfg.direction = dir; + cfg.sample_rate = codec->sample_rate; + cfg.num_channels = 2; + cfg.bit_width = prtd->bits_per_sample; + cfg.fmt = codec->id; + memcpy(&cfg.codec, codec, sizeof(*codec)); + + ret = q6apm_graph_media_format_shmem(prtd->graph, &cfg); + if (ret < 0) + return ret; + + ret = q6apm_graph_media_format_pcm(prtd->graph, &cfg); + if (ret) + return ret; + + ret = q6apm_map_memory_regions(prtd->graph, SNDRV_PCM_STREAM_PLAYBACK, + prtd->phys, (prtd->pcm_size / prtd->periods), + prtd->periods); + if (ret < 0) + return -ENOMEM; + + ret = q6apm_graph_prepare(prtd->graph); + if (ret) + return ret; + + ret = q6apm_graph_start(prtd->graph); + if (ret) + return ret; + + } else { + cfg.direction = dir; + cfg.sample_rate = codec->sample_rate; + cfg.num_channels = 2; + cfg.bit_width = prtd->bits_per_sample; + cfg.fmt = codec->id; + memcpy(&cfg.codec, codec, sizeof(*codec)); + + ret = audioreach_compr_set_param(prtd->graph, &cfg); + if (ret < 0) + return ret; + } + prtd->state = Q6APM_STREAM_RUNNING; + + return 0; +} + +static int q6apm_dai_compr_set_metadata(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_compr_metadata *metadata) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + int ret = 0; + + switch (metadata->key) { + case SNDRV_COMPRESS_ENCODER_PADDING: + prtd->trailing_samples_drop = metadata->value[0]; + q6apm_remove_trailing_silence(component->dev, prtd->graph, + prtd->trailing_samples_drop); + break; + case SNDRV_COMPRESS_ENCODER_DELAY: + prtd->initial_samples_drop = metadata->value[0]; + q6apm_remove_initial_silence(component->dev, prtd->graph, + prtd->initial_samples_drop); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + static const struct snd_compress_ops q6apm_dai_compress_ops = { .open = q6apm_dai_compr_open, .free = q6apm_dai_compr_free, @@ -640,6 +745,8 @@ static const struct snd_compress_ops q6apm_dai_compress_ops = { .pointer = q6apm_dai_compr_pointer, .trigger = q6apm_dai_compr_trigger, .ack = q6apm_dai_compr_ack, + .set_params = q6apm_dai_compr_set_params, + .set_metadata = q6apm_dai_compr_set_metadata, }; static const struct snd_soc_component_driver q6apm_fe_dai_component = { From patchwork Fri Jun 9 14:54:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 13274089 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 12DF6C7EE2E for ; Fri, 9 Jun 2023 14:58:11 +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 ED537EA3; Fri, 9 Jun 2023 16:57:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ED537EA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686322689; bh=dSP6YQRj1iv2UOEZECpY6YoBazSL29WNYwDXMZHwiDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=U14HJsMRh8Q8/N4YAq7bjerkNn8HRTeDqUqXgNQORszVwcr3pLT9bs5ip7uxxc8ma t4OHnLMyZna5vhZQGJRiMMVcTA46y1Dnv0WfJn+rhkFqSoW5Acz6PLxXn5EqQA+z+L VQqgNA1dDExyfdCW5A24/q1B2upEQekT3cGgE/aQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 43C13F8057E; Fri, 9 Jun 2023 16:56:05 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 29044F80567; Fri, 9 Jun 2023 16:56:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 885EAF80552; Fri, 9 Jun 2023 16:55:52 +0200 (CEST) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 421EAF80494 for ; Fri, 9 Jun 2023 16:55:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 421EAF80494 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=g3gqEel5 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f78a32266bso18340895e9.3 for ; Fri, 09 Jun 2023 07:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686322548; x=1688914548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ivatK82mIE79m2bjB3shZCKbThxgPNsfOJBEjwu6Sbk=; b=g3gqEel5hZ91PR/5WW666p6143wPgKRHct1WMme18BZDzpj1ossV6woI7s33X9jido Ajp+7zCIcWK7Vh5GmcEekrzFbIh1m9cpANsrA3cjcqJGDzXvs+GHN3IZR4VFeNdKslbf 3muw4ZeDeOb6EYekdgYBPdUWkzaPper537/n0PxFOzvAdZGuycHXokHOXDrXJq5pAOJy nbpT6TRUTWWKhabLVardlHjjd2xIbOQa0g7DfN7tkjEey/0tlC4HGFBCFCDFS1CfXDdJ 4sizJSD5w9eJKqODGMonOLTY/tGoQNnY/WX05cDC4HjxuyNHzFc3Rrk43ZQdoAZMfJcq V51A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686322548; x=1688914548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ivatK82mIE79m2bjB3shZCKbThxgPNsfOJBEjwu6Sbk=; b=XYzP1FcUzjkHhcFsuPD4i5dAOn0ddQTNom1YOmPL71aBbRglFyoyLsR9Z7RdFDYWdP SqS/+z/RFLb03B501MrE2VFzvjX+3/9PSIFDi9izC61IPspn8JPpzhH15n4lJ5u/u9fl XHlpDLCUpFMY/fUiNQLfH3rQNKVXBlBp7GGcwCwbC8mZdvzIEhV6hBH/YoLVcCHlVxRX D3psNuUsKXEfVR4xKeiWQYEbdF0CcSX+Geg2Lq8+MbgaInXSm+oZ+SKv3E2ae3+XRS3W gwcMGmAYjI8heuahYIFfRm40BRJ7sPfEhXfXlvrvvjBtb671RHKrIjEv9t769vxNCl/E 54Hg== X-Gm-Message-State: AC+VfDyUqZDC3vKceUxpqSRxlxPEMVjRfjETj4tYMoSJ047fqDZGtvE4 NaSirhbOWGE+kQV6z3HAHrDCvOb80d+lUJmYyGU= X-Google-Smtp-Source: ACHHUZ5dWz0dRCo8oE+uEbyqJqzKGnyMC9AFlnm0/AaLeKxls87+Rx6ZuPcuzqiz8ZR1mbhPI1g80Q== X-Received: by 2002:a05:600c:290:b0:3f7:f7d5:a07f with SMTP id 16-20020a05600c029000b003f7f7d5a07fmr1421885wmk.17.1686322548271; Fri, 09 Jun 2023 07:55:48 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm2946632wmr.2.2023.06.09.07.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 07:55:47 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, ckeepax@opensource.cirrus.com, kuninori.morimoto.gx@renesas.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Srinivas Kandagatla , Mohammad Rafi Shaik Subject: [PATCH v2 11/11] ASoC: q6dsp: q6apm-dai: Add mmap and copy compress DAI callbacks Date: Fri, 9 Jun 2023 15:54:07 +0100 Message-Id: <20230609145407.18774-12-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> References: <20230609145407.18774-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Message-ID-Hash: QOEVIW3Z5JDKC2CLH4EIJGJF5SSSEFQL X-Message-ID-Hash: QOEVIW3Z5JDKC2CLH4EIJGJF5SSSEFQL X-MailFrom: srinivas.kandagatla@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add q6apm mmap and copy compress DAI callbacks to support compress offload playback. Signed-off-by: Srinivas Kandagatla Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik --- sound/soc/qcom/qdsp6/q6apm-dai.c | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index c67147e5388b..5eb0b864c740 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -737,6 +737,85 @@ static int q6apm_dai_compr_set_metadata(struct snd_soc_component *component, return ret; } +static int q6apm_dai_compr_mmap(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct vm_area_struct *vma) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + struct device *dev = component->dev; + + return dma_mmap_coherent(dev, vma, prtd->dma_buffer.area, prtd->dma_buffer.addr, + prtd->dma_buffer.bytes); +} + +static int q6apm_compr_copy(struct snd_soc_component *component, + struct snd_compr_stream *stream, char __user *buf, + size_t count) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6apm_dai_rtd *prtd = runtime->private_data; + void *dstn; + unsigned long flags; + size_t copy; + u32 wflags = 0; + u32 app_pointer; + u32 bytes_received; + uint32_t bytes_to_write; + int avail, bytes_in_flight = 0; + + bytes_received = prtd->bytes_received; + + /** + * Make sure that next track data pointer is aligned at 32 bit boundary + * This is a Mandatory requirement from DSP data buffers alignment + */ + if (prtd->next_track) + bytes_received = ALIGN(prtd->bytes_received, prtd->pcm_count); + + app_pointer = bytes_received/prtd->pcm_size; + app_pointer = bytes_received - (app_pointer * prtd->pcm_size); + dstn = prtd->dma_buffer.area + app_pointer; + + if (count < prtd->pcm_size - app_pointer) { + if (copy_from_user(dstn, buf, count)) + return -EFAULT; + } else { + copy = prtd->pcm_size - app_pointer; + if (copy_from_user(dstn, buf, copy)) + return -EFAULT; + if (copy_from_user(prtd->dma_buffer.area, buf + copy, count - copy)) + return -EFAULT; + } + + spin_lock_irqsave(&prtd->lock, flags); + bytes_in_flight = prtd->bytes_received - prtd->copied_total; + + if (prtd->next_track) { + prtd->next_track = false; + prtd->copied_total = ALIGN(prtd->copied_total, prtd->pcm_count); + prtd->bytes_sent = ALIGN(prtd->bytes_sent, prtd->pcm_count); + } + + prtd->bytes_received = bytes_received + count; + + /* Kick off the data to dsp if its starving!! */ + if (prtd->state == Q6APM_STREAM_RUNNING && (bytes_in_flight == 0)) { + bytes_to_write = prtd->pcm_count; + avail = prtd->bytes_received - prtd->bytes_sent; + + if (avail < prtd->pcm_count) + bytes_to_write = avail; + + q6apm_write_async(prtd->graph, bytes_to_write, 0, 0, wflags); + prtd->bytes_sent += bytes_to_write; + } + + spin_unlock_irqrestore(&prtd->lock, flags); + + return count; +} + static const struct snd_compress_ops q6apm_dai_compress_ops = { .open = q6apm_dai_compr_open, .free = q6apm_dai_compr_free, @@ -747,6 +826,8 @@ static const struct snd_compress_ops q6apm_dai_compress_ops = { .ack = q6apm_dai_compr_ack, .set_params = q6apm_dai_compr_set_params, .set_metadata = q6apm_dai_compr_set_metadata, + .mmap = q6apm_dai_compr_mmap, + .copy = q6apm_compr_copy, }; static const struct snd_soc_component_driver q6apm_fe_dai_component = {