Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6180090rwd; Mon, 19 Jun 2023 03:41:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ560OKTKXxwXEZXLasUxMrTqrR5jFzIFHawyunqVvfBUCOUq/vbMltZijtRNYgFLIB/lMwJ X-Received: by 2002:a05:6a00:1387:b0:668:71a1:2e86 with SMTP id t7-20020a056a00138700b0066871a12e86mr4999464pfg.7.1687171276473; Mon, 19 Jun 2023 03:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687171276; cv=none; d=google.com; s=arc-20160816; b=ZTP/E5MCvbqKvU4EsQyu4NTAQVNK9EH7an/s/IK31tG/kiBrxFLYeIHLDv2WImYTwV C3Wc0IZ8t/hq7j/JPEIBfQHJX5H0fKwqqHAtivKu9b493IkoF26ZfLCzaUUzJ6r+RiQp 8zpjj+/qmcAycZQf1WPkwmKrCTxANjUnNHg6mupOrvbYDyS2JCOmrFsygisGkYUprY4u 5bzmjRJS243BfRGrn/Loq+3+iAu7ReZm4NbPX8RdB6csbq2ZSqrzyh/rO5SzmWd2IzXN bVYH6XFN3eQPFfXn/xIGswczqcWhcw5hFk2WJnI7lFZIJFN8UQsXy4HGi2DOxYcdAggL +OYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8UTtnacXFhkaa2mZeZWdPy27iLwDS43g1aootOIyr7w=; b=iI3KXMDJnB6FUxe9SwYD3MgNs6RF4/J9fqHrEN8hM9CCtiRlw8y8clk+BWoORdo9Bz nds/sE+3O/apt6L6Z/5VS5XJ747h1ej519I2GDMDmOxV5fTaZ9VZlmC2AZJi3F76YlCH +ojGKvvgn04Qt4cIKkDZ4KY/Mzp7ICcY36ZYrDRiPYV7Dr6hFOZIFV/OnSrj3js/SIrO G89vTmv7OlGretYzlpW+o8GMnF8Z+WA5uLjBbO3yWR3uU5KV9LNt5oBFoPWRadHIrOyL 5AFwQimL+rEQ3MxYCNn2a4LCPavFWN6wOEykeCM+G0397Cf+4CCG/YKMJLqHA6WzZ7Vp gKfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K87vDtXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f62-20020a625141000000b0064f3917aedesi9082814pfb.176.2023.06.19.03.41.04; Mon, 19 Jun 2023 03:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K87vDtXv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjFSKRd (ORCPT + 99 others); Mon, 19 Jun 2023 06:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbjFSKRQ (ORCPT ); Mon, 19 Jun 2023 06:17:16 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2CFE6E for ; Mon, 19 Jun 2023 03:17:07 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-311183ef595so2978401f8f.0 for ; Mon, 19 Jun 2023 03:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687169826; x=1689761826; 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=8UTtnacXFhkaa2mZeZWdPy27iLwDS43g1aootOIyr7w=; b=K87vDtXv1eApSrwu3I7xQDm3u1Xqm2uvm5TTdetvU9fpgYbcAw18SzhP+k3w6A7ehq VsMgqHUtgycoZiBOnvgitT79/FSrmWKXF6GB3KbMfE8GSrBWQkCWEMOG/9hYBpPNMWSi yWU+XpXNexfvy+J6B9a/oSWUhj1SswnjnryJ2zaO1qhmoGwwsxCLpyALFRfDq/4jj+5z a3eEhXpa5/xfEUlLSRY001BzVVLTkkKLvNwSybF8nSzzIeGdxb16PSU9hW6fsbB7FtSb xasA+lzimf/4XUvvcPmnwpslGFGSPMKw7deCO/mpwH9mHySOlBe6S59tj9e+tbYRD3F+ WuAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687169826; x=1689761826; 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=8UTtnacXFhkaa2mZeZWdPy27iLwDS43g1aootOIyr7w=; b=DWmlf9fdJh6upMINGY5PUbtrbMGqUUR0wczJgJKTK+xx5Nb6slK/Nvp3WvVuqV3COk 3Bl0wU7Bap2Rnkzo5kn7E2x2joYxQtERLCF+ME++4ttoHubiEIWTvkLdUgBg36xSPoD4 NdJJ3NBjXtsqf8WV3kfgB1+YQ3pthKJBZfYF+pwwY8j9NPYE8kYFZlE2c1OIm9+QANB1 Q04gsCSFyURMNuRBh39wv03DqLHOqWbXLeAfOW2n4/EAlg0EpAOoLyjcehKZCdzvF7Cg 515vjXszgoTKguhof1ubIx7UWrw44l44yg/DnjJatyi0RT6yDoW7anvRcz0ddEDq9jEc ChnQ== X-Gm-Message-State: AC+VfDxPJKwPFYAglo27H9V4fub+JX4OjXJW0vBYsg5xUDa6dKVo6Cdu N9EnWJ8VG3Ajhvl647eHduaSnw== X-Received: by 2002:a5d:698f:0:b0:30a:d459:8f72 with SMTP id g15-20020a5d698f000000b0030ad4598f72mr7394877wru.60.1687169826500; Mon, 19 Jun 2023 03:17:06 -0700 (PDT) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id c2-20020a5d5282000000b002fae7408544sm31146922wrv.108.2023.06.19.03.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 03:17:05 -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 v3 09/11] ASoC: q6dsp: q6apm-dai: Add trigger/pointer compress DAI callbacks Date: Mon, 19 Jun 2023 11:16:51 +0100 Message-Id: <20230619101653.9750-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230619101653.9750-1-srinivas.kandagatla@linaro.org> References: <20230619101653.9750-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add q6apm trigger and pointer compress DAI callbacks to support compress offload playback. Co-developed-by: Mohammad Rafi Shaik Signed-off-by: Mohammad Rafi Shaik Signed-off-by: Srinivas Kandagatla --- 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; -- 2.21.0