From patchwork Mon Apr 30 11:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 10371483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C0296032A for ; Mon, 30 Apr 2018 11:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C83828A9A for ; Mon, 30 Apr 2018 11:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6167428AA0; Mon, 30 Apr 2018 11:27:28 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable 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 4BBBA28A9F for ; Mon, 30 Apr 2018 11:27:27 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D0B5D26762A; Mon, 30 Apr 2018 13:19:38 +0200 (CEST) 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 2B7FF2675DF; Mon, 30 Apr 2018 13:19:34 +0200 (CEST) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by alsa0.perex.cz (Postfix) with ESMTP id 7A2E42675D0 for ; Mon, 30 Apr 2018 13:19:30 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3UBJUWP010777; Mon, 30 Apr 2018 06:19:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1525087170; bh=JgbJuh1DGyRXy7sxWAXYdxX1brY/UMswATRbFbDdnjc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ocPkdHwe7hY+PWvfk6g0BwgkY7C2J2bfyIM5F99JUHs7+StyDGNBkV9lwVjuSF1Lz UapUqZj6YDTsZ67n9+EGGrZFJaqpVN+sh4+xkz7Rf8Ilnm/qhJba8c3WvHI8sNpRtB OfcVVvO29ng0B21wver/vX6kiLXIb0QRJWz6siEI= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3UBJTYM030124; Mon, 30 Apr 2018 06:19:29 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 30 Apr 2018 06:19:27 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 30 Apr 2018 06:19:27 -0500 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3UBJN3D019772; Mon, 30 Apr 2018 06:19:25 -0500 From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Date: Mon, 30 Apr 2018 14:19:52 +0300 Message-ID: <20180430111958.31289-2-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430111958.31289-1-peter.ujfalusi@ti.com> References: <20180430111958.31289-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, aaro.koskinen@iki.fi Subject: [alsa-devel] [PATCH v3 1/7] ASoC: omap: Introduce the generic_dmaengine_pcm based sdma-pcm 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 With the generic dmaengine_pcm support the omap-cpm can be replaced with a much smaller wrapper. CPU DAI drivers can use the: int sdma_pcm_platform_register(struct device *dev, char *txdmachan, char *rxdmachan); To register the platform driver, txdmachan/rxdmachan is only needed to be provided if the DMA channel names are not standard tx/rx, like in case of McPDM, or the DAI is only capable of one audio direction (DMIC, HDMI). This patch only introduces the source file and changes to the Kconfig/Makefile, but does not change any of the DAI drivers to use it. Signed-off-by: Peter Ujfalusi Acked-by: Jarkko Nikula --- sound/soc/omap/Kconfig | 6 ++++ sound/soc/omap/Makefile | 2 ++ sound/soc/omap/sdma-pcm.c | 68 +++++++++++++++++++++++++++++++++++++++ sound/soc/omap/sdma-pcm.h | 21 ++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 sound/soc/omap/sdma-pcm.c create mode 100644 sound/soc/omap/sdma-pcm.h diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 65864a60d0e2..22e216345a94 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -2,6 +2,12 @@ config SND_OMAP_SOC tristate "SoC Audio for Texas Instruments OMAP chips" depends on (ARCH_OMAP && DMA_OMAP) || (ARM && COMPILE_TEST) select SND_DMAENGINE_PCM + select SND_SDMA_SOC + +config SND_SDMA_SOC + tristate "SoC Audio for Texas Instruments chips using sDMA" + depends on DMA_OMAP + select SND_SOC_GENERIC_DMAENGINE_PCM config SND_OMAP_SOC_DMIC tristate "TI Digital Microphone Module (DMIC) support" diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index a6785dc4fc90..0619a5b3bd9f 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile @@ -1,12 +1,14 @@ # SPDX-License-Identifier: GPL-2.0 # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o +snd-soc-sdma-objs := sdma-pcm.o snd-soc-omap-dmic-objs := omap-dmic.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o mcbsp.o snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-audio-objs := omap-hdmi-audio.o obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o +obj-$(CONFIG_SND_SDMA_SOC) += snd-soc-sdma.o obj-$(CONFIG_SND_OMAP_SOC_DMIC) += snd-soc-omap-dmic.o obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o diff --git a/sound/soc/omap/sdma-pcm.c b/sound/soc/omap/sdma-pcm.c new file mode 100644 index 000000000000..f7b2b5b69d27 --- /dev/null +++ b/sound/soc/omap/sdma-pcm.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com + * Author: Peter Ujfalusi + */ + +#include +#include +#include +#include +#include +#include + +#include "sdma-pcm.h" + +static const struct snd_pcm_hardware sdma_pcm_hardware = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP | + SNDRV_PCM_INFO_INTERLEAVED, + .period_bytes_min = 32, + .period_bytes_max = 64 * 1024, + .buffer_bytes_max = 128 * 1024, + .periods_min = 2, + .periods_max = 255, +}; + +static const struct snd_dmaengine_pcm_config sdma_dmaengine_pcm_config = { + .pcm_hardware = &sdma_pcm_hardware, + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .compat_filter_fn = omap_dma_filter_fn, + .prealloc_buffer_size = 128 * 1024, +}; + +int sdma_pcm_platform_register(struct device *dev, + char *txdmachan, char *rxdmachan) +{ + struct snd_dmaengine_pcm_config *config; + unsigned int flags = SND_DMAENGINE_PCM_FLAG_COMPAT; + + /* Standard names for the directions: 'tx' and 'rx' */ + if (!txdmachan && !rxdmachan) + return devm_snd_dmaengine_pcm_register(dev, + &sdma_dmaengine_pcm_config, + flags); + + config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL); + if (!config) + return -ENOMEM; + + *config = sdma_dmaengine_pcm_config; + + if (!txdmachan || !rxdmachan) { + /* One direction only PCM */ + flags |= SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX; + if (!txdmachan) { + txdmachan = rxdmachan; + rxdmachan = NULL; + } + } + + config->chan_names[0] = txdmachan; + config->chan_names[1] = rxdmachan; + + return devm_snd_dmaengine_pcm_register(dev, config, flags); +} +EXPORT_SYMBOL_GPL(sdma_pcm_platform_register); diff --git a/sound/soc/omap/sdma-pcm.h b/sound/soc/omap/sdma-pcm.h new file mode 100644 index 000000000000..34a7f90b2587 --- /dev/null +++ b/sound/soc/omap/sdma-pcm.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com + * Author: Peter Ujfalusi + */ + +#ifndef __SDMA_PCM_H__ +#define __SDMA_PCM_H__ + +#if IS_ENABLED(CONFIG_SND_SDMA_SOC) +int sdma_pcm_platform_register(struct device *dev, + char *txdmachan, char *rxdmachan); +#else +static inline int sdma_pcm_platform_register(struct device *dev, + char *txdmachan, char *rxdmachan) +{ + return -ENODEV; +} +#endif /* CONFIG_SND_SDMA_SOC */ + +#endif /* __SDMA_PCM_H__ */