From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8879C7EE2E for ; Fri, 9 Jun 2023 14:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241631AbjFIOy3 (ORCPT ); Fri, 9 Jun 2023 10:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241616AbjFIOyX (ORCPT ); Fri, 9 Jun 2023 10:54:23 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C2B73A84 for ; Fri, 9 Jun 2023 07:54:18 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f6d38a140bso14621065e9.1 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=fD5gPrw+cza/e+zSOTGaRQva0KjSbOILzaIEDkp+ECEl9PvyLXOUhKbi6Hvu/2wKVh c4fg2zzSAGgl5xUkUkp94bXbSV5GDUOet+6BxuMZWVn3Gl+pVpbBIn9XfKuAUiyWHXm0 5Lm9Ndk97jqtPd82gRP2EHkLCVVWtKzSvEwFthe5NqJ6KcwutxoW3QKrMQRVJQkRAxMv tN0AzmQh8J0Ube2Gl2540RfOPe4WDZ/gDXoqJIn/idHBxWH4Sh8l2OlMJZLji5dBrnaA 3SU3cIuhKqA/ZyPogqgkMsmwWHNcXP3Sj5l/oWNYR1WB2X7VV6EtifaLNJL5oVlMwJ3P ks6A== X-Gm-Message-State: AC+VfDyPxNZoR89Lx/yC+sMm/85hn6vTro7qEd1ytqP1KIvkzzC1WVpF 0dq4169jHFsOfzvtSCwIv+bUAA== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 #include "../codecs/rt5682.h" #include "../codecs/rt5682s.h" @@ -196,8 +197,10 @@ static int sc7280_snd_hw_params(struct snd_pcm_substre= am *substream, struct sdw_stream_runtime *sruntime; int i; =20 - 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, 480= 00); + 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, 48= 000); + } =20 switch (cpu_dai->id) { case LPASS_CDC_DMA_TX3: @@ -358,6 +361,20 @@ static const struct snd_soc_dapm_widget sc7280_snd_wid= gets[] =3D { SND_SOC_DAPM_MIC("Headset Mic", NULL), }; =20 +static int sc7280_snd_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate =3D hw_param_interval(params, SNDRV_PCM_HW_PARA= M_RATE); + struct snd_interval *channels =3D hw_param_interval(params, SNDRV_PCM_HW_= PARAM_CHANNELS); + struct snd_mask *fmt =3D hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + rate->min =3D rate->max =3D 48000; + channels->min =3D channels->max =3D 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_de= vice *pdev) for_each_card_prelinks(card, i, link) { link->init =3D sc7280_init; link->ops =3D &sc7280_ops; + if (link->no_pcm =3D=3D 1) + link->be_hw_params_fixup =3D sc7280_snd_be_hw_params_fixup; } =20 return devm_snd_soc_register_card(dev, card); --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02148C7EE29 for ; Fri, 9 Jun 2023 14:54:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241636AbjFIOyj (ORCPT ); Fri, 9 Jun 2023 10:54:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241624AbjFIOyb (ORCPT ); Fri, 9 Jun 2023 10:54:31 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2420D30F1 for ; Fri, 9 Jun 2023 07:54:22 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f7a8089709so19235525e9.1 for ; Fri, 09 Jun 2023 07:54:21 -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=f2u59xMfTKVLfyMcwbPATBvMZ4cBYeY6P9jmuI1XnyixGGZGEqMMXD+NYcyWxlNezq 1eemcVnP828RYzQYImwnIDyQugqBWP4A6Xa+VDd69Ct/WUjJPuw8MX5CEuFGfmoxC99m MlyxW+qlHrAk+vr3b23xtFpNed4iWOt8F0tTn1Oe0XbEuOqlmnTT3A/vQmfTKV5rRdOW BMzyELewYFJzb8WFwwJ6zbhLAG0Q56XLE1aGEFimdHel8wN6d808Y5oLwTMInuU+SLtO K/UoOgb3fxVMwtzNMy+w8aDf8SO6OVNi0cdMpUngzfl7Pd6HSIqolkUMaP5mgPxFN3dy qcmA== X-Gm-Message-State: AC+VfDzYCXhFo+h/PH7++a5FST0OPGRGjnnkaEb5hqIW8rYpJkcw9BHI Gs3aazs6L64OzJbCe0FFCyw6jQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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, vo= id *priv, int op) } break; case DATA_CMD_WR_SH_MEM_EP_EOS_RENDERED: + client_event =3D 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) { --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03F9BC7EE2E for ; Fri, 9 Jun 2023 14:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241653AbjFIOyl (ORCPT ); Fri, 9 Jun 2023 10:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241628AbjFIOyg (ORCPT ); Fri, 9 Jun 2023 10:54:36 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A11F93A8F for ; Fri, 9 Jun 2023 07:54:25 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4effb818c37so2414370e87.3 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=lq19o8MI6lO7cHMNNCYjxF56lVxbKOGJ79sghmGRP62VLCxAl8EJBYJn1matvouTCq JKoemDT54oiC+nvDPEpEcNN04vN9uIiBPFsHArNm1n3uM/6Op8J+UIhXkmPGgUpRXL8U H1g5uYI8f+O7gKcsTSmsZ1DQyZ3NmMKyq54LQoDzrHv90IsgZ5CB1xa533UG2V/MJ8RK kjlkszjwJiw4MUAtiCoKmHSIa89u469OD28DWH6vC+5UbEvWaZCCdYRcdE+gEU9QBffA 7Hql1RjXqJjBHM+4PILUXIy8p66CH/6fYpQLxg0zYp5bOAPPO00OXRzeUq80WBaugnMD rBSg== X-Gm-Message-State: AC+VfDxOMAbXV6ijMrCEvF2hmngLg5RNbWeUlkSmpp+1bU6SIljjqe0A 2e4RUuBsrYedEkqKwGLT427Rsw== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/audio= reach.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(stru= ct q6apm_graph *graph, return rc; } =20 -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; =20 - payload_size =3D sizeof(*limiter_enable) + APM_MODULE_PARAM_DATA_SIZE; - - pkt =3D audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); - if (IS_ERR(pkt)) - return PTR_ERR(pkt); + payload_size =3D sizeof(uint32_t) + APM_MODULE_PARAM_DATA_SIZE; + p =3D audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(p)) + return -ENOMEM; =20 - p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + pkt =3D p; + p =3D p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; =20 param_data =3D p; param_data->module_instance_id =3D module->instance_id; param_data->error_code =3D 0; - param_data->param_id =3D PARAM_ID_SAL_LIMITER_ENABLE; - param_data->param_size =3D sizeof(*limiter_enable); - p =3D p + APM_MODULE_PARAM_DATA_SIZE; - limiter_enable =3D p; + param_data->param_id =3D param_id; + param_data->param_size =3D sizeof(uint32_t); =20 - limiter_enable->enable_lim =3D enable; + p =3D p + APM_MODULE_PARAM_DATA_SIZE; + param =3D p; + *param =3D param_val; =20 rc =3D q6apm_send_cmd_sync(graph->apm, pkt, 0); =20 @@ -766,77 +765,26 @@ static int audioreach_sal_limiter_enable(struct q6apm= _graph *graph, =20 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_ENAB= LE, enable); +} =20 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 =3D sizeof(*media_format) + APM_MODULE_PARAM_DATA_SIZE; - - pkt =3D audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); - if (IS_ERR(pkt)) - return PTR_ERR(pkt); - - p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; - - param_data =3D p; - param_data->module_instance_id =3D module->instance_id; - param_data->error_code =3D 0; - param_data->param_id =3D PARAM_ID_SAL_OUTPUT_CFG; - param_data->param_size =3D sizeof(*media_format); - p =3D p + APM_MODULE_PARAM_DATA_SIZE; - media_format =3D p; - - media_format->bits_per_sample =3D cfg->bit_width; - - rc =3D 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); } =20 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 =3D sizeof(*param) + APM_MODULE_PARAM_DATA_SIZE; - - pkt =3D audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); - if (IS_ERR(pkt)) - return PTR_ERR(pkt); - - p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; - - param_data =3D p; - param_data->module_instance_id =3D module->instance_id; - param_data->error_code =3D 0; - param_data->param_id =3D PARAM_ID_MODULE_ENABLE; - param_data->param_size =3D sizeof(*param); - p =3D p + APM_MODULE_PARAM_DATA_SIZE; - param =3D p; - - param->enable =3D enable; - - rc =3D q6apm_send_cmd_sync(graph->apm, pkt, 0); - - kfree(pkt); - - return rc; + return audioreach_send_u32_param(graph, module, PARAM_ID_MODULE_ENABLE, e= nable); } =20 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/audio= reach.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 *gra= ph, 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__ */ --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A52E2C7EE29 for ; Fri, 9 Jun 2023 14:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241666AbjFIOyn (ORCPT ); Fri, 9 Jun 2023 10:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241614AbjFIOyg (ORCPT ); Fri, 9 Jun 2023 10:54:36 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2080E3A91 for ; Fri, 9 Jun 2023 07:54:27 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f7f4819256so14388095e9.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=AsasI/qoEZgLXgt6oRHsZ6+U2Aoy4y0+41jcW12M+tABZQimbuRev7SIvHb5N7zPPQ i6NYjgkeh1j1o1viNG7sIUGrhq6+zpJsOaaB3q3WbMs4WG/I846VCyXNPsYP9Pfi9cx+ G/aCEfxXSQY4yTvGm/1d11nUKCto+NrF03FGAR/3j9r4hLFnv82CIZQIbNF4DJ0qhe5Y Ocvyw3NqRmM/b+nY3eEgazljxlp9pBjrEsUDl3gzm6nmn4mt4QuYZOu7D/Ln0rEAVLUw 9Qcb34VGLizaisNndrbVvUmiaKqDUjEsbZiJXDZx89BBKhx4/KTgOUSZejakJT/DEERi ImtQ== X-Gm-Message-State: AC+VfDx7UkdW8RSpgfT+8/Xt+SHsQOe0SLQmnW2jX1t1twLZoJOQGc5q i/y/nYAP12VJ/2MxgtSL1elIIg== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 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/audio= reach.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 =20 #define APM_CMD_GET_SPF_STATE 0x01001021 @@ -608,6 +613,15 @@ struct param_id_vol_ctrl_master_gain { } __packed; =20 =20 +#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 *gra= ph, unsigned int dir) } EXPORT_SYMBOL_GPL(q6apm_unmap_memory_regions); =20 +int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *g= raph, uint32_t samples) +{ + struct audioreach_module *module; + + module =3D 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_S= ILENCE, 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 =3D 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 *g= raph, bool en) +{ + struct audioreach_module *module; + + module =3D 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, e= n); +} +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 =3D q6apm_find_module_by_mid(graph, MODULE_ID_PLACEHOLDER_DECODER); + if (!module) + return -ENODEV; + + switch (codec_id) { + case SND_AUDIOCODEC_MP3: + module_id =3D MODULE_ID_MP3_DECODE; + break; + case SND_AUDIOCODEC_AAC: + module_id =3D MODULE_ID_AAC_DEC; + break; + case SND_AUDIOCODEC_FLAC: + module_id =3D 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 audiore= ach_module_config *cfg) { struct audioreach_graph_info *info =3D 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_gr= aph *graph); =20 bool q6apm_is_adsp_ready(void); =20 +int q6apm_enable_compress_module(struct device *dev, struct q6apm_graph *g= raph, bool en); +int q6apm_remove_initial_silence(struct device *dev, struct q6apm_graph *g= raph, 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_ */ --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA5BC7EE29 for ; Fri, 9 Jun 2023 14:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241699AbjFIOyr (ORCPT ); Fri, 9 Jun 2023 10:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238846AbjFIOyg (ORCPT ); Fri, 9 Jun 2023 10:54:36 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569FA3A80 for ; Fri, 9 Jun 2023 07:54:28 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f6255ad8aeso2414997e87.2 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=lojO5qTS8BKZux6BuESAxPKXd8eiMwuSt83S5fpWzjswNq6XWXs9odDvINfN5cC5Mc nPihYwb0QA+vCglDFFYgLuOtL/ERqzLGQJun9O71c2ei/H6ghSgzKRFhE2hSk6yii/I8 J+JJC1wxOQ/jGuhfQHoyIpd4/inCc8XIkEWT4CUkBJUU1tYgKKVw/O5YTGyByInF8Aa5 ZKo+Yew4vy70McXV7WWcB3bjAVcal9PLPyb4pSkb6fN/OPTMRLoFxyaxNTL/QW4rEWV7 4tw7Q+5ntuCXB5LJdaEagaQ9BUsh5EfiMDDLtsZr3BngIg+2LwXXIhd3vO4B3dL1Qj4e VfAQ== X-Gm-Message-State: AC+VfDyKIGIB2iV5NHfjP16bEytX8NC8JwZSeJ6+VDSw7mOXglj1fAXO 9jj0f2Gw5ofusI/xEWfhpSidMw== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/audio= reach.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 q6ap= m_graph *graph, return rc; } =20 +static int audioreach_set_compr_media_format(struct media_format *media_fm= t_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 =3D DATA_FORMAT_RAW_COMPRESSED; + media_fmt_hdr->fmt_id =3D MEDIA_FMT_ID_MP3; + media_fmt_hdr->payload_size =3D 0; + p =3D p + sizeof(*media_fmt_hdr); + mp3_cfg =3D p; + mp3_cfg->sample_rate =3D mcfg->sample_rate; + mp3_cfg->bit_width =3D mcfg->bit_width; + mp3_cfg->alignment =3D PCM_LSB_ALIGNED; + mp3_cfg->bits_per_sample =3D mcfg->bit_width; + mp3_cfg->q_factor =3D mcfg->bit_width - 1; + mp3_cfg->endianness =3D PCM_LITTLE_ENDIAN; + mp3_cfg->num_channels =3D mcfg->num_channels; + + if (mcfg->num_channels =3D=3D 1) { + mp3_cfg->channel_mapping[0] =3D PCM_CHANNEL_L; + } else if (mcfg->num_channels =3D=3D 2) { + mp3_cfg->channel_mapping[0] =3D PCM_CHANNEL_L; + mp3_cfg->channel_mapping[1] =3D PCM_CHANNEL_R; + } + break; + case SND_AUDIOCODEC_AAC: + media_fmt_hdr->data_format =3D DATA_FORMAT_RAW_COMPRESSED; + media_fmt_hdr->fmt_id =3D MEDIA_FMT_ID_AAC; + media_fmt_hdr->payload_size =3D sizeof(struct payload_media_fmt_aac_t); + p =3D p + sizeof(*media_fmt_hdr); + aac_cfg =3D p; + aac_cfg->aac_fmt_flag =3D 0; + aac_cfg->audio_obj_type =3D 5; + aac_cfg->num_channels =3D mcfg->num_channels; + aac_cfg->total_size_of_PCE_bits =3D 0; + aac_cfg->sample_rate =3D mcfg->sample_rate; + break; + case SND_AUDIOCODEC_FLAC: + media_fmt_hdr->data_format =3D DATA_FORMAT_RAW_COMPRESSED; + media_fmt_hdr->fmt_id =3D MEDIA_FMT_ID_FLAC; + media_fmt_hdr->payload_size =3D sizeof(struct payload_media_fmt_flac_t); + p =3D p + sizeof(*media_fmt_hdr); + flac_cfg =3D p; + flac_cfg->sample_size =3D mcfg->codec.options.flac_d.sample_size; + flac_cfg->num_channels =3D mcfg->num_channels; + flac_cfg->min_blk_size =3D mcfg->codec.options.flac_d.min_blk_size; + flac_cfg->max_blk_size =3D mcfg->codec.options.flac_d.max_blk_size; + flac_cfg->sample_rate =3D mcfg->sample_rate; + flac_cfg->min_frame_size =3D mcfg->codec.options.flac_d.min_frame_size; + flac_cfg->max_frame_size =3D mcfg->codec.options.flac_d.max_frame_size; + break; + default: + return -EINVAL; + } + + return 0; +} + +int audioreach_compr_set_param(struct q6apm_graph *graph, struct audioreac= h_module_config *mcfg) +{ + struct media_format *header; + struct gpr_pkt *pkt; + int iid, payload_size, rc; + void *p; + + payload_size =3D sizeof(struct apm_sh_module_media_fmt_cmd); + + iid =3D q6apm_graph_get_rx_shmem_module_iid(graph); + pkt =3D audioreach_alloc_cmd_pkt(payload_size, DATA_CMD_WR_SH_MEM_EP_MEDI= A_FORMAT, + 0, graph->port->id, iid); + + if (IS_ERR(pkt)) + return -ENOMEM; + + p =3D (void *)pkt + GPR_HDR_SIZE; + header =3D p; + rc =3D audioreach_set_compr_media_format(header, p, mcfg); + if (rc) { + kfree(pkt); + return rc; + } + + rc =3D 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 =3D p + APM_MODULE_PARAM_DATA_SIZE; =20 header =3D p; - header->data_format =3D DATA_FORMAT_FIXED_POINT; - header->fmt_id =3D MEDIA_FMT_ID_PCM; - header->payload_size =3D payload_size - sizeof(*header); - - p =3D p + sizeof(*header); - cfg =3D p; - cfg->sample_rate =3D mcfg->sample_rate; - cfg->bit_width =3D mcfg->bit_width; - cfg->alignment =3D PCM_LSB_ALIGNED; - cfg->bits_per_sample =3D mcfg->bit_width; - cfg->q_factor =3D mcfg->bit_width - 1; - cfg->endianness =3D PCM_LITTLE_ENDIAN; - cfg->num_channels =3D mcfg->num_channels; - - if (mcfg->num_channels =3D=3D 1) { - cfg->channel_mapping[0] =3D PCM_CHANNEL_L; - } else if (num_channels =3D=3D 2) { - cfg->channel_mapping[0] =3D PCM_CHANNEL_L; - cfg->channel_mapping[1] =3D PCM_CHANNEL_R; + if (mcfg->fmt =3D=3D SND_AUDIOCODEC_PCM) { + header->data_format =3D DATA_FORMAT_FIXED_POINT; + header->fmt_id =3D MEDIA_FMT_ID_PCM; + header->payload_size =3D payload_size - sizeof(*header); + + p =3D p + sizeof(*header); + cfg =3D p; + cfg->sample_rate =3D mcfg->sample_rate; + cfg->bit_width =3D mcfg->bit_width; + cfg->alignment =3D PCM_LSB_ALIGNED; + cfg->bits_per_sample =3D mcfg->bit_width; + cfg->q_factor =3D mcfg->bit_width - 1; + cfg->endianness =3D PCM_LITTLE_ENDIAN; + cfg->num_channels =3D mcfg->num_channels; + + if (mcfg->num_channels =3D=3D 1) + cfg->channel_mapping[0] =3D PCM_CHANNEL_L; + else if (num_channels =3D=3D 2) { + cfg->channel_mapping[0] =3D PCM_CHANNEL_L; + cfg->channel_mapping[1] =3D PCM_CHANNEL_R; + } + } else { + rc =3D audioreach_set_compr_media_format(header, p, mcfg); + if (rc) { + kfree(pkt); + return rc; + } } =20 rc =3D audioreach_graph_send_cmd_sync(graph, pkt, 0); diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audio= reach.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; =20 #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 =20 #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; =20 +#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]; }; =20 @@ -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 audioreac= h_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 =3D runtime->rate; cfg.num_channels =3D runtime->channels; cfg.bit_width =3D prtd->bits_per_sample; + cfg.fmt =3D SND_AUDIOCODEC_PCM; =20 if (prtd->state) { /* clear the previous setup if any */ --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65135C7EE29 for ; Fri, 9 Jun 2023 14:56:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231966AbjFIO4e (ORCPT ); Fri, 9 Jun 2023 10:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240274AbjFIO40 (ORCPT ); Fri, 9 Jun 2023 10:56:26 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 942E535A7 for ; Fri, 9 Jun 2023 07:55:58 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f735259fa0so18463205e9.1 for ; Fri, 09 Jun 2023 07:55:58 -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=kNwfNFBPYugOWJGt76SLs+8NjwfHnwpN3VyamoCL8LevNyoaqvh9k9DaU5lBLBlKLz aHbZcqejkt7NUCNuhZ4TKrUV+ifPSg0Wa4jITBlkoUO3SAqXuQ5oxYZ6gR9cnuERYq7G fhFlmtVvZJ8y1d4zFZVC4tiyFWx1/pazP9UYJIuECwUsjSNjpaw3i3x2oYEdSdWwZJ9L Bu1pgQgpwZAa1ne93XWlwACPS6cXkxU1iCAP92CEmSfOhxXJN1uhPgqfgHWVpI0HaEIz P6HtQKTsl+MjFW67wCI7jVA0GvMGKHYPLYOcyy559WbpgEVI4OKSKj6ys5+rI69RPgLY BwAA== X-Gm-Message-State: AC+VfDyNvMBf3KtMbeAIA/aaaDWZTlXcm8WZwgTuUneFajxYgvoYifAX GrzSALxPw/LIVVIfMoarUnKIuQ== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/audio= reach.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, e= nable); } =20 +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 *g= raph, struct audioreach_mod case MODULE_ID_MFC: rc =3D audioreach_mfc_set_media_format(graph, module, cfg); break; + case MODULE_ID_GAPLESS: + rc =3D audioreach_gapless_set_media_format(graph, module, cfg); + break; default: rc =3D 0; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audio= reach.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 =20 #define APM_CMD_GET_SPF_STATE 0x01001021 @@ -552,6 +553,8 @@ struct param_id_sal_limiter_enable { } __packed; =20 #define PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT 0x08001024 +#define PARAM_ID_EARLY_EOS_DELAY 0x0800114C +#define EARLY_EOS_DELAY_MS 150 =20 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; =20 +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; --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92707C7EE2E for ; Fri, 9 Jun 2023 14:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241524AbjFIO4f (ORCPT ); Fri, 9 Jun 2023 10:56:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241670AbjFIO40 (ORCPT ); Fri, 9 Jun 2023 10:56:26 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6FA330C5 for ; Fri, 9 Jun 2023 07:55:59 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso18366685e9.2 for ; Fri, 09 Jun 2023 07:55:59 -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=h7CTKvSWJuUoG+YnZPcQXtBoYKyfx4nHYrxjwPQRbt6YJNQMLLT8wzlqtOaoHlST8c 0J1lnmabrdzqFpwEdem0dpNTT34wQBMYBW4NrADkrHPna2lT9m+vzGblAPsFKoQv+kuk Gn9+hSvqpKGg23OC5BthaaoTObOuyOFnSnQu+TsHsP5ICuZ1ygFRO1ktRTy3TnuactzI Jx5qGt3aE9/lhjKHz2xeUY5Io1dpvdGcbvEjLWlrikZ7/IoNYrW/XNTtH+egeGj3ozIp L9gAUKZfRYYNpi3FGbbBF51loFdyflOPK79pHHkTXgd4W0p1LBXYhprg+Z3GeRAQBJg4 yYAg== X-Gm-Message-State: AC+VfDzIOwNjSf0ERMqOuzDSTU+zq0KdH24D6X2wNs/qSYW7x3f8tClH YPWt7OD5qymP4sYd6p9fVhiELw== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 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_S= IZE) #define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_S= IZE) +#define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024) +#define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4) #define SID_MASK_DEFAULT 0xF =20 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; }; =20 struct q6apm_dai_data { @@ -132,6 +135,69 @@ static void event_handler(uint32_t opcode, uint32_t to= ken, uint32_t *payload, vo } } =20 +static void event_handler_compr(uint32_t opcode, uint32_t token, + uint32_t *payload, void *priv) +{ + struct q6apm_dai_rtd *prtd =3D priv; + struct snd_compr_stream *substream =3D prtd->cstream; + unsigned long flags; + uint32_t wflags =3D 0; + uint64_t avail; + uint32_t bytes_written, bytes_to_write; + bool is_last_buffer =3D 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 =3D false; + } else { + prtd->state =3D 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 =3D token >> APM_WRITE_TOKEN_LEN_SHIFT; + prtd->copied_total +=3D bytes_written; + snd_compr_fragment_elapsed(substream); + + if (prtd->state !=3D Q6APM_STREAM_RUNNING) { + spin_unlock_irqrestore(&prtd->lock, flags); + break; + } + + avail =3D prtd->bytes_received - prtd->bytes_sent; + + if (avail > prtd->pcm_count) { + bytes_to_write =3D prtd->pcm_count; + } else { + if (substream->partial_drain || prtd->notify_on_drain) + is_last_buffer =3D true; + bytes_to_write =3D avail; + } + + if (bytes_to_write) { + if (substream->partial_drain && is_last_buffer) + wflags |=3D APM_LAST_BUFFER_FLAG; + + q6apm_write_async(prtd->graph, + bytes_to_write, 0, 0, wflags); + + prtd->bytes_sent +=3D 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, compone= nt->dev, size); } =20 +static int q6apm_dai_compr_open(struct snd_soc_component *component, + struct snd_compr_stream *stream) +{ + struct snd_soc_pcm_runtime *rtd =3D stream->private_data; + struct snd_soc_dai *cpu_dai =3D asoc_rtd_to_cpu(rtd, 0); + struct snd_compr_runtime *runtime =3D stream->runtime; + struct q6apm_dai_rtd *prtd; + struct q6apm_dai_data *pdata; + struct device *dev =3D component->dev; + int ret, size; + int graph_id; + + graph_id =3D cpu_dai->driver->id; + pdata =3D snd_soc_component_get_drvdata(component); + if (!pdata) + return -EINVAL; + + prtd =3D kzalloc(sizeof(*prtd), GFP_KERNEL); + if (prtd =3D=3D NULL) + return -ENOMEM; + + prtd->cstream =3D stream; + prtd->graph =3D q6apm_graph_open(dev, (q6apm_cb)event_handler_compr, prtd= , graph_id); + if (IS_ERR(prtd->graph)) { + ret =3D PTR_ERR(prtd->graph); + kfree(prtd); + return ret; + } + + runtime->private_data =3D prtd; + runtime->dma_bytes =3D BUFFER_BYTES_MAX; + size =3D COMPR_PLAYBACK_MAX_FRAGMENT_SIZE * COMPR_PLAYBACK_MAX_NUM_FRAGME= NTS; + ret =3D snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, &prtd->dma_buf= fer); + if (ret) + return ret; + + if (pdata->sid < 0) + prtd->phys =3D prtd->dma_buffer.addr; + else + prtd->phys =3D 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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D 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 =3D NULL; + kfree(prtd); + runtime->private_data =3D NULL; + + return 0; +} +static const struct snd_compress_ops q6apm_dai_compress_ops =3D { + .open =3D q6apm_dai_compr_open, + .free =3D q6apm_dai_compr_free, +}; + static const struct snd_soc_component_driver q6apm_fe_dai_component =3D { .name =3D DRV_NAME, .open =3D q6apm_dai_open, @@ -396,6 +531,7 @@ static const struct snd_soc_component_driver q6apm_fe_d= ai_component =3D { .hw_params =3D q6apm_dai_hw_params, .pointer =3D q6apm_dai_pointer, .trigger =3D q6apm_dai_trigger, + .compress_ops =3D &q6apm_dai_compress_ops, }; =20 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 =20 #define APM_MAX_SESSIONS 8 +#define APM_LAST_BUFFER_FLAG BIT(30) =20 struct q6apm { struct device *dev; --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFB2BC7EE29 for ; Fri, 9 Jun 2023 14:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241727AbjFIO4o (ORCPT ); Fri, 9 Jun 2023 10:56:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241675AbjFIO41 (ORCPT ); Fri, 9 Jun 2023 10:56:27 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E743A82 for ; Fri, 9 Jun 2023 07:56:00 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f6e4554453so14805565e9.3 for ; Fri, 09 Jun 2023 07:56:00 -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=bL3y/Kunde+uP5+i++0m2q0i+11kNB9B8t6eTq94kSOfW2F+YYnIWOPAD8pKFRjhj/ tvZwvbm5Dk8c+JKJ4cLPYvBTD8vBnvOBLDOEUDbs7n/VxQDa14NHsEE+aM1fGitgOAtN pb3iuGBhXE+L3ZrWBIeOTuXLINE0aYeI9ThqOblVXtmjT0eDLIrFkTS3mYPb/PyvfhYg 88dcteEEyRvhU5WqVMwpiQFZ/IY1xRf52MCrApoVz2HapBVNzBZ+bCvHtp4sOSd78I6v 7eklBw/anRNMNyKLkLlpba7HsF35eiUJ9JwBiqxNA0Lpw9AWBAv/9p3qVlX1wsVTgKIJ cXtQ== X-Gm-Message-State: AC+VfDxgLl52UPiL7d2B6XvVAd6xyeXBHlqjT70+XGINie4i888GwDIU r9GZmPYM2ehwlBV8A1F5pa85dw== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 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_S= IZE) #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 =20 +static const struct snd_compr_codec_caps q6apm_compr_caps =3D { + .num_descriptors =3D 1, + .descriptor[0].max_ch =3D 2, + .descriptor[0].sample_rates =3D { 8000, 11025, 12000, 16000, 22050, + 24000, 32000, 44100, 48000, 88200, + 96000, 176400, 192000 }, + .descriptor[0].num_sample_rates =3D 13, + .descriptor[0].bit_rate[0] =3D 320, + .descriptor[0].bit_rate[1] =3D 128, + .descriptor[0].num_bitrates =3D 2, + .descriptor[0].profiles =3D 0, + .descriptor[0].modes =3D SND_AUDIOCHANMODE_MP3_STEREO, + .descriptor[0].formats =3D 0, +}; + enum stream_state { Q6APM_STREAM_IDLE =3D 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_compone= nt *component, =20 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 =3D SND_COMPRESS_PLAYBACK; + caps->min_fragment_size =3D COMPR_PLAYBACK_MIN_FRAGMENT_SIZE; + caps->max_fragment_size =3D COMPR_PLAYBACK_MAX_FRAGMENT_SIZE; + caps->min_fragments =3D COMPR_PLAYBACK_MIN_NUM_FRAGMENTS; + caps->max_fragments =3D COMPR_PLAYBACK_MAX_NUM_FRAGMENTS; + caps->num_codecs =3D 3; + caps->codecs[0] =3D SND_AUDIOCODEC_MP3; + caps->codecs[1] =3D SND_AUDIOCODEC_AAC; + caps->codecs[2] =3D SND_AUDIOCODEC_FLAC; + + return 0; +} + +static int q6apm_dai_compr_get_codec_caps(struct snd_soc_component *compon= ent, + struct snd_compr_stream *stream, + struct snd_compr_codec_caps *codec) +{ + switch (codec->codec) { + case SND_AUDIOCODEC_MP3: + *codec =3D q6apm_compr_caps; + break; + default: + break; + } + + return 0; +} static const struct snd_compress_ops q6apm_dai_compress_ops =3D { .open =3D q6apm_dai_compr_open, .free =3D q6apm_dai_compr_free, + .get_caps =3D q6apm_dai_compr_get_caps, + .get_codec_caps =3D q6apm_dai_compr_get_codec_caps, }; =20 static const struct snd_soc_component_driver q6apm_fe_dai_component =3D { --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F369C7EE2E for ; Fri, 9 Jun 2023 14:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241688AbjFIO4j (ORCPT ); Fri, 9 Jun 2023 10:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241673AbjFIO41 (ORCPT ); Fri, 9 Jun 2023 10:56:27 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821193A84 for ; Fri, 9 Jun 2023 07:56:00 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f7f6341bf9so18355205e9.1 for ; Fri, 09 Jun 2023 07:56:00 -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=iEj6BbmSSUJ817Dqs252WPy/U6Ys5OB8MHAJyyxTmWcEUqFVpLZ0RXD710tV2KmMFY ZHJp0J0uF171fRnZmVMenpNqoOU0wjqjqIT+f2PDBczuyLCj9za77QkcPXOWPfbKF0CM QI1zrUjp5AR55W783VpEtFFFRFQVBnmoVggZRdaEds6X0SzpNOOeR01iz7jAHbwtCLnw HyA1LS85zI3hBfQHwxwnhe2sr4EFEDdOkZbUV7uAl9xh9riLmyVzUJopHPIZkuLaGJ4y 5hR0emF0BTl23ZXTDirSphCK2NVL85dT9/5Po2db4U4c8o6b3NsNhGFCiRLTMH4UYtWr 0Ryw== X-Gm-Message-State: AC+VfDzSc0V+WDCkJ64LgU9E9hbELgUCsaKWv8mJHA4cIg0Z8XRliQQV 3fRuyulwlPvZdRIQDCt5lyT/VA== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 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, =20 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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + unsigned long flags; + + spin_lock_irqsave(&prtd->lock, flags); + tstamp->copied_total =3D prtd->copied_total; + tstamp->byte_offset =3D 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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + int ret =3D 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + ret =3D q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTA= MP); + 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 =3D true; + break; + case SND_COMPR_TRIGGER_DRAIN: + case SND_COMPR_TRIGGER_PARTIAL_DRAIN: + prtd->notify_on_drain =3D true; + break; + default: + ret =3D -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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + unsigned long flags; + + spin_lock_irqsave(&prtd->lock, flags); + prtd->bytes_received +=3D count; + spin_unlock_irqrestore(&prtd->lock, flags); + + return count; +} + static const struct snd_compress_ops q6apm_dai_compress_ops =3D { .open =3D q6apm_dai_compr_open, .free =3D q6apm_dai_compr_free, .get_caps =3D q6apm_dai_compr_get_caps, .get_codec_caps =3D q6apm_dai_compr_get_codec_caps, + .pointer =3D q6apm_dai_compr_pointer, + .trigger =3D q6apm_dai_compr_trigger, + .ack =3D q6apm_dai_compr_ack, }; =20 static const struct snd_soc_component_driver q6apm_fe_dai_component =3D { 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 @@ =20 #define APM_MAX_SESSIONS 8 #define APM_LAST_BUFFER_FLAG BIT(30) +#define NO_TIMESTAMP 0xFF00 =20 struct q6apm { struct device *dev; --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4279C7EE29 for ; Fri, 9 Jun 2023 14:56:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241702AbjFIO4q (ORCPT ); Fri, 9 Jun 2023 10:56:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241679AbjFIO41 (ORCPT ); Fri, 9 Jun 2023 10:56:27 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF453A86 for ; Fri, 9 Jun 2023 07:56:00 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f7378a75c0so14125075e9.3 for ; Fri, 09 Jun 2023 07:56:00 -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=LHL7jIOLK4mRmta1X5w5MEge4BvFcdfXDabQpAnfiKVLdQT8UW94Q9Z6FAkTNiEvwn Xaz8JrosYNPj8asc2GTZUBKkqWSAxrqkik9YR97zkVegHzOiC8KY8Rb648nqpo5g/wAg YfgCrv/2F0RLRjCexm5I5f1TFg80E4uHw6Qfox/a0opRf6qeX551ImeHBYd9fg8O7m/3 zQAoJEG1OIMX4iol2bhb/i9Pg7nZVQhNB9FtN5t13quL85LUcnY3zibqOMNQ/d2NbO8p 8d7oG0DB6vyDadHSRHIvo2KdPKyrHYrxtExWrIu+25GpCBQF+Ywm7Pk6lowEwlSDNLWi TCMA== X-Gm-Message-State: AC+VfDw2b4S619eBrAw2CAWO4rh9jfZZUQNussN6a/EJ4PFh8lxnVIxl a4/jakrO+zCVGf1JESEotO++PtH/hvVjcqkf4RA= 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 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; }; =20 @@ -632,6 +634,109 @@ static int q6apm_dai_compr_ack(struct snd_soc_compone= nt *component, struct snd_c return count; } =20 +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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + struct q6apm_dai_data *pdata; + struct audioreach_module_config cfg; + struct snd_codec *codec =3D ¶ms->codec; + int dir =3D stream->direction; + int ret; + + pdata =3D snd_soc_component_get_drvdata(component); + if (!pdata) + return -EINVAL; + + prtd->periods =3D runtime->fragments; + prtd->pcm_count =3D runtime->fragment_size; + prtd->pcm_size =3D runtime->fragments * runtime->fragment_size; + prtd->bits_per_sample =3D 16; + + prtd->pos =3D 0; + + if (prtd->next_track !=3D true) { + memcpy(&prtd->codec, codec, sizeof(*codec)); + + ret =3D q6apm_set_real_module_id(component->dev, prtd->graph, codec->id); + if (ret) + return ret; + + cfg.direction =3D dir; + cfg.sample_rate =3D codec->sample_rate; + cfg.num_channels =3D 2; + cfg.bit_width =3D prtd->bits_per_sample; + cfg.fmt =3D codec->id; + memcpy(&cfg.codec, codec, sizeof(*codec)); + + ret =3D q6apm_graph_media_format_shmem(prtd->graph, &cfg); + if (ret < 0) + return ret; + + ret =3D q6apm_graph_media_format_pcm(prtd->graph, &cfg); + if (ret) + return ret; + + ret =3D 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 =3D q6apm_graph_prepare(prtd->graph); + if (ret) + return ret; + + ret =3D q6apm_graph_start(prtd->graph); + if (ret) + return ret; + + } else { + cfg.direction =3D dir; + cfg.sample_rate =3D codec->sample_rate; + cfg.num_channels =3D 2; + cfg.bit_width =3D prtd->bits_per_sample; + cfg.fmt =3D codec->id; + memcpy(&cfg.codec, codec, sizeof(*codec)); + + ret =3D audioreach_compr_set_param(prtd->graph, &cfg); + if (ret < 0) + return ret; + } + prtd->state =3D Q6APM_STREAM_RUNNING; + + return 0; +} + +static int q6apm_dai_compr_set_metadata(struct snd_soc_component *componen= t, + struct snd_compr_stream *stream, + struct snd_compr_metadata *metadata) +{ + struct snd_compr_runtime *runtime =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + int ret =3D 0; + + switch (metadata->key) { + case SNDRV_COMPRESS_ENCODER_PADDING: + prtd->trailing_samples_drop =3D 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 =3D metadata->value[0]; + q6apm_remove_initial_silence(component->dev, prtd->graph, + prtd->initial_samples_drop); + break; + default: + ret =3D -EINVAL; + break; + } + + return ret; +} + static const struct snd_compress_ops q6apm_dai_compress_ops =3D { .open =3D q6apm_dai_compr_open, .free =3D q6apm_dai_compr_free, @@ -640,6 +745,8 @@ static const struct snd_compress_ops q6apm_dai_compress= _ops =3D { .pointer =3D q6apm_dai_compr_pointer, .trigger =3D q6apm_dai_compr_trigger, .ack =3D q6apm_dai_compr_ack, + .set_params =3D q6apm_dai_compr_set_params, + .set_metadata =3D q6apm_dai_compr_set_metadata, }; =20 static const struct snd_soc_component_driver q6apm_fe_dai_component =3D { --=20 2.21.0 From nobody Mon Feb 9 01:31:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E91AC7EE2E for ; Fri, 9 Jun 2023 14:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241754AbjFIO4t (ORCPT ); Fri, 9 Jun 2023 10:56:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241682AbjFIO42 (ORCPT ); Fri, 9 Jun 2023 10:56:28 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B623A87 for ; Fri, 9 Jun 2023 07:56:01 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso18368645e9.2 for ; Fri, 09 Jun 2023 07:56:01 -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=ZtOnEH0/lxWW+QnujKGR4+VGfegs8U/bfaWf97XdVVdICvKNt2c95zA9mbHuOnov+j FF7FpAAgcptA1CkBgz/QCE1C8FCZbAiSDlTYqlEB6CQfD4SfxDSh7TFjhZ6dexCTp9HY TWF5Qauhe0521rPISvkRw38dMcVZn17+7b+7y+GmuXXYZ4oWHXccnx0tjmasmqv+6cEN 5hPWRJOsrI/e8TSBXU5vS6uHl/ZQTGmNJNmJ5hmI2MxJpVFIoGgb3ZK/XIaoD7LvQh0Y thELPx4iJDSQ4TGmy0TjEfDhhtzLVmVv2lVC5tUBoVrS6aAgHpWxbKOobIVMms6rKg3p sZUg== X-Gm-Message-State: AC+VfDyIA0sH1HUgiNkNJIh+Bh70t3dS/25obqJkyOW9oDavlvHEzlfE 6bq7ADDwdcezd1UM+TEe3l6i/A== 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add 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; } =20 +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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + struct device *dev =3D component->dev; + + return dma_mmap_coherent(dev, vma, prtd->dma_buffer.area, prtd->dma_buffe= r.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 =3D stream->runtime; + struct q6apm_dai_rtd *prtd =3D runtime->private_data; + void *dstn; + unsigned long flags; + size_t copy; + u32 wflags =3D 0; + u32 app_pointer; + u32 bytes_received; + uint32_t bytes_to_write; + int avail, bytes_in_flight =3D 0; + + bytes_received =3D 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 =3D ALIGN(prtd->bytes_received, prtd->pcm_count); + + app_pointer =3D bytes_received/prtd->pcm_size; + app_pointer =3D bytes_received - (app_pointer * prtd->pcm_size); + dstn =3D prtd->dma_buffer.area + app_pointer; + + if (count < prtd->pcm_size - app_pointer) { + if (copy_from_user(dstn, buf, count)) + return -EFAULT; + } else { + copy =3D 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 =3D prtd->bytes_received - prtd->copied_total; + + if (prtd->next_track) { + prtd->next_track =3D false; + prtd->copied_total =3D ALIGN(prtd->copied_total, prtd->pcm_count); + prtd->bytes_sent =3D ALIGN(prtd->bytes_sent, prtd->pcm_count); + } + + prtd->bytes_received =3D bytes_received + count; + + /* Kick off the data to dsp if its starving!! */ + if (prtd->state =3D=3D Q6APM_STREAM_RUNNING && (bytes_in_flight =3D=3D 0)= ) { + bytes_to_write =3D prtd->pcm_count; + avail =3D prtd->bytes_received - prtd->bytes_sent; + + if (avail < prtd->pcm_count) + bytes_to_write =3D avail; + + q6apm_write_async(prtd->graph, bytes_to_write, 0, 0, wflags); + prtd->bytes_sent +=3D bytes_to_write; + } + + spin_unlock_irqrestore(&prtd->lock, flags); + + return count; +} + static const struct snd_compress_ops q6apm_dai_compress_ops =3D { .open =3D q6apm_dai_compr_open, .free =3D q6apm_dai_compr_free, @@ -747,6 +826,8 @@ static const struct snd_compress_ops q6apm_dai_compress= _ops =3D { .ack =3D q6apm_dai_compr_ack, .set_params =3D q6apm_dai_compr_set_params, .set_metadata =3D q6apm_dai_compr_set_metadata, + .mmap =3D q6apm_dai_compr_mmap, + .copy =3D q6apm_compr_copy, }; =20 static const struct snd_soc_component_driver q6apm_fe_dai_component =3D { --=20 2.21.0