From patchwork Thu Nov 15 18:13:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 10684817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E4A413BB for ; Thu, 15 Nov 2018 18:15:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E4612C92A for ; Thu, 15 Nov 2018 18:15:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01F572CE25; Thu, 15 Nov 2018 18:15:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B4BB2C92A for ; Thu, 15 Nov 2018 18:15:43 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D6C2A267B07; Thu, 15 Nov 2018 19:15:35 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0315F267B00; Thu, 15 Nov 2018 19:15:31 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by alsa0.perex.cz (Postfix) with ESMTP id 78E8F267B01 for ; Thu, 15 Nov 2018 19:15:30 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id b13so22217681wrx.6 for ; Thu, 15 Nov 2018 10:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q3gLC+nmyp2mq9QJP7D6LeLPOksVBsoxF3h1ogX1tDA=; b=PD2MiuqtbVX1pUtDQ5uG7knacHELfzxsm2rl4tC/L3ngPzrHoSpuX51Kj5XLtACe+8 TJyJoirK/chyhTCMDRGoAhgTM1HtEze10ObZ9eS24yWH3hRdYffonVmRxdc5UjMzb18n uEU3XUq52bRvcCBp+erqp9e6Ut6bP9aGmhXNI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q3gLC+nmyp2mq9QJP7D6LeLPOksVBsoxF3h1ogX1tDA=; b=BzPrse0qhaK6w5/TSBFPXGhu+mfJlM9eVeG7zM06elaMsfN+btw5x0LNA5D12JonPJ fLpGHJO95qRQeXUdwrU9FeDs/hhMqFbS9ou9JEGF9vdruAV8H3WjoRrhPxQd71R98pSt 0/9SL8tPdy6q60wSp9Q/jTiS7JSnqcCtKxDTmAiI3kw28rpy6xRnfb0rutqA2S449CuI CDab585ZUoKm/aRIm5GfnVAq//YZQByCbbFiZC8gl1J4N9K/cSqhqn88BHtHDUBtal0R OEoB62J+bJDmPzek/xTqdWrCB4kEsVmtH2ngwtlogXV50zWzqdXNJnaWDPtE15pRESWS wLHg== X-Gm-Message-State: AGRZ1gJj2YhhxfyXtjQXaBHcg2oC/FZdv9U3ZkBZtwRlYU04N8/ePBaj rL5NjVn6Tfbyg3C94wp0anNXqg== X-Google-Smtp-Source: AJdET5fnRA4SvEnBPKfr4dd6BpBU5UWc+RQGAc7NKwKUAJohxZFeZpXNhRGiZkqx4J4EJ0BkRRlI9g== X-Received: by 2002:adf:a78a:: with SMTP id j10-v6mr6975400wrc.286.1542305729876; Thu, 15 Nov 2018 10:15:29 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r76-v6sm20934737wmb.21.2018.11.15.10.15.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 10:15:29 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org, vkoul@kernel.org Date: Thu, 15 Nov 2018 18:13:20 +0000 Message-Id: <20181115181324.26784-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115181324.26784-1-srinivas.kandagatla@linaro.org> References: <20181115181324.26784-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, tiwai@suse.com, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, robh+dt@kernel.org, rohitkr@codeaurora.org, srini@kernel.org, Srinivas Kandagatla Subject: [alsa-devel] [PATCH v3 1/5] ALSA: soc-compress: add support to snd_compr_set_runtime_buffer() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Existing compress offload code allocates data buffers using simple kmalloc, however there are situations where these buffers have to be mapped in smmu. So provide a way to set the runtime buffer by the driver itself, simillar to what we do with pcm. This patch adds support to set runtime dma buffer on compressed stream. Signed-off-by: Srinivas Kandagatla --- include/sound/compress_driver.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index ea8c93bbb0e0..0cdc3999ecfa 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -23,6 +23,7 @@ struct snd_compr_ops; * struct snd_compr_runtime: runtime stream description * @state: stream state * @ops: pointer to DSP callbacks + * @dma_buffer_p: runtime dma buffer pointer * @buffer: pointer to kernel buffer, valid only when not in mmap mode or * DSP doesn't implement copy * @buffer_size: size of the above buffer @@ -37,6 +38,7 @@ struct snd_compr_ops; struct snd_compr_runtime { snd_pcm_state_t state; struct snd_compr_ops *ops; + struct snd_dma_buffer *dma_buffer_p; void *buffer; u64 buffer_size; u32 fragment_size; @@ -175,6 +177,23 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) wake_up(&stream->runtime->sleep); } +/** + * snd_compr_set_runtime_buffer - Set the Compress runtime buffer + * @substream: compress substream to set + * @bufp: the buffer information, NULL to clear + * + * Copy the buffer information to runtime buffer when @bufp is non-NULL. + * Otherwise it clears the current buffer information. + */ +static inline void snd_compr_set_runtime_buffer( + struct snd_compr_stream *substream, + struct snd_dma_buffer *bufp) +{ + struct snd_compr_runtime *runtime = substream->runtime; + + runtime->dma_buffer_p = bufp; +} + int snd_compr_stop_error(struct snd_compr_stream *stream, snd_pcm_state_t state);