From patchwork Mon Feb 26 11:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 129623 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp83388lja; Mon, 26 Feb 2018 03:17:19 -0800 (PST) X-Google-Smtp-Source: AG47ELsENk8VRX+s0r98u1zVDcHltHohWLL9OvZ59Os03K6jWWfHNhvFaWpkX68nKmQEjp1IeTlS X-Received: by 10.223.171.6 with SMTP id q6mr6832027wrc.267.1519643839780; Mon, 26 Feb 2018 03:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519643839; cv=none; d=google.com; s=arc-20160816; b=DGks+0PkDxT/R7JcpyttXW50rGzLe047Gv8PsWmiRmBrm4YVIaqB/Wno069nDtiosG kcNftB6QvUiZNHwP+hSfIaytnUnDaWej7oJOvhOAY1cH3HXsE6u4zikm5L0tMDztRT9I Bc2D23qwz7ZJdMXFG0E+MpJQcDFFhXfbnTO6qn7f7VLClnLR6Q5cissCLlYG8wvCMZOO HIUtIixp9DQDB55GoIrUS3lleHagY+oetZU8j9QqnXYh105sm9Pj44IAOhRWsJg3E+nq PnS9FzP4Ze97G1QnxmOV4MV29jVEuTt8NN4NSiOFA/9Y60aFf3UTnxJpwEo93LMmYLls tYxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=IZ03xPCZWyyc9cJYDPhNhlGm+hr9+myKxe9XvWEAua0=; b=ajKh5UjAuJ9Zn12AsyzAyeCGEKbmuACrBtJ8VYQo4U8e/UGhfrvzOhHUjpbJOr/b5i bXbbPmnbxYVp3o9AqNCbuqA1K+wRE+aFiW86ymxJCyG7GVgPd1TFn4p25WJL+BQCgdnR elGxAt1Uxx0MdfOEpSmRqrZ6oNzP4ez15EXkuPDe6BcE8uVb2j0GT1WfgOznUZkWpQVM 4XqJhSzwUUoqu36UWXI2ZfrFwLViD8R6+BkmOpC2Ddd/xOHTWusJrRFlBj14PLzZhbyn OYwjgr+KGAZBLSrsLn4ps+VzB1Jo8+rkbCgbocJ3iIEQJ6MJTw4MLnIsxqybEe+mvtJe h6Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=OxOmDLV3; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id x2si4941742wmx.43.2018.02.26.03.17.19; Mon, 26 Feb 2018 03:17:19 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=OxOmDLV3; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5032A267A35; Mon, 26 Feb 2018 12:17:18 +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 00350267A35; Mon, 26 Feb 2018 12:17:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id D8D72267990 for ; Mon, 26 Feb 2018 12:17:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=UnGkI7+IHYWULOLB0s0mg9y80Bi4HeK+wcBGsZ/PHOw=; b=OxOmDLV3TnnZ 1m/4tDovhMKqQR4LlokNaTwgQrJH0v602UldlZK9GjZFtqined9z1gLiMDCftAXpc4MHw7CJY5h8U lXxIcK88Ilc6dlV05OosSDEdurT0Pndxr/ZksijZObV8yM91IZJ3l6enDiC34BGQb8BwLHSpNKYKi eUrVA=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eqGmN-0007v2-Bi; Mon, 26 Feb 2018 11:17:11 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1eqGmM-0005Om-NT; Mon, 26 Feb 2018 11:17:10 +0000 From: Mark Brown To: Olivier Moysan In-Reply-To: Message-Id: Date: Mon, 26 Feb 2018 11:17:10 +0000 Cc: alsa-devel@alsa-project.org, Mark Brown Subject: [alsa-devel] Applied "ASoC: dmaengine_pcm: add processing support" to the asoc tree 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: dmaengine_pcm: add processing support has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 78648092ef46255e6dc6685202164199c86cf930 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Mon, 19 Feb 2018 16:00:36 +0100 Subject: [PATCH] ASoC: dmaengine_pcm: add processing support Allow dmaengine client to optionally register a processing callback. This callback is intended to apply processing on samples in buffer copied from/to user space, before/after DMA transfer. Signed-off-by: Olivier Moysan Signed-off-by: Mark Brown --- include/sound/dmaengine_pcm.h | 3 ++ sound/soc/soc-generic-dmaengine-pcm.c | 62 +++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) -- 2.16.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 8a5a8404966e..47ef486852ed 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -140,6 +140,9 @@ struct snd_dmaengine_pcm_config { struct dma_chan *(*compat_request_channel)( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream); + int (*process)(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes); dma_filter_fn compat_filter_fn; struct device *dma_dev; const char *chan_names[SNDRV_PCM_STREAM_LAST + 1]; diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 785f25ede3e5..567fbdfd1ca9 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -341,6 +341,41 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( return snd_dmaengine_pcm_pointer(substream); } +static int dmaengine_copy_user(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct snd_pcm_runtime *runtime = substream->runtime; + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); + int (*process)(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes) = pcm->config->process; + bool is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; + void *dma_ptr = runtime->dma_area + hwoff + + channel * (runtime->dma_bytes / runtime->channels); + int ret; + + if (is_playback) + if (copy_from_user(dma_ptr, (void __user *)buf, bytes)) + return -EFAULT; + + if (process) { + ret = process(substream, channel, hwoff, + (void __user *)buf, bytes); + if (ret < 0) + return ret; + } + + if (!is_playback) + if (copy_to_user((void __user *)buf, dma_ptr, bytes)) + return -EFAULT; + + return 0; +} + static const struct snd_pcm_ops dmaengine_pcm_ops = { .open = dmaengine_pcm_open, .close = snd_dmaengine_pcm_close, @@ -351,6 +386,17 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = { .pointer = dmaengine_pcm_pointer, }; +static const struct snd_pcm_ops dmaengine_pcm_process_ops = { + .open = dmaengine_pcm_open, + .close = snd_dmaengine_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = dmaengine_pcm_hw_params, + .hw_free = snd_pcm_lib_free_pages, + .trigger = snd_dmaengine_pcm_trigger, + .pointer = dmaengine_pcm_pointer, + .copy_user = dmaengine_copy_user, +}; + static const struct snd_soc_component_driver dmaengine_pcm_component = { .name = SND_DMAENGINE_PCM_DRV_NAME, .probe_order = SND_SOC_COMP_ORDER_LATE, @@ -358,6 +404,13 @@ static const struct snd_soc_component_driver dmaengine_pcm_component = { .pcm_new = dmaengine_pcm_new, }; +static const struct snd_soc_component_driver dmaengine_pcm_component_process = { + .name = SND_DMAENGINE_PCM_DRV_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, + .ops = &dmaengine_pcm_process_ops, + .pcm_new = dmaengine_pcm_new, +}; + static const char * const dmaengine_pcm_dma_channel_names[] = { [SNDRV_PCM_STREAM_PLAYBACK] = "tx", [SNDRV_PCM_STREAM_CAPTURE] = "rx", @@ -453,8 +506,13 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_pcm; - ret = snd_soc_add_component(dev, &pcm->component, - &dmaengine_pcm_component, NULL, 0); + if (config && config->process) + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component_process, + NULL, 0); + else + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component, NULL, 0); if (ret) goto err_free_dma;