lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1347624358-25582-10-git-send-email-peter.ujfalusi@ti.com>
Date:	Fri, 14 Sep 2012 15:05:52 +0300
From:	Peter Ujfalusi <peter.ujfalusi@...com>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	Liam Girdwood <lrg@...com>, Tony Lindgren <tony@...mide.com>,
	Russell King <rmk+kernel@....linux.org.uk>,
	Vinod Koul <vinod.koul@...el.com>, Dan Williams <djbw@...com>,
	Jarkko Nikula <jarkko.nikula@...mer.com>
Cc:	alsa-devel@...a-project.org, linux-omap@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Janusz Krzysztofik <jkrzyszt@....icnet.pl>,
	Ricardo Neri <ricardo.neri@...com>,
	Lars-Peter Clausen <lars@...afoo.de>
Subject: [PATCH v3 09/15] ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties

Based on the format of the stream the omap-pcm can decide alone what data
type should be used with by the sDMA.
Keep the possibility for OMAP dai drivers to tell omap-pcm if they want to
use different data type. This is needed for the omap-hdmi for example which
needs 32bit data type even if the stream format is S16_LE.

The check if (dma_data->data_type) is safe at the moment since omap-pcm
does not support 8bit samples (OMAP_DMA_DATA_TYPE_S8 == 0x00).

The next step is to redefine the meaning of dma_data->data_type to unblock
this limitation.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@...com>
---
 sound/soc/omap/omap-pcm.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 02eeb2e..4c13a5f 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -149,6 +149,24 @@ static int omap_pcm_hw_free(struct snd_pcm_substream *substream)
 	return 0;
 }
 
+static int omap_pcm_get_dma_type(int num_bits)
+{
+	int data_type;
+
+	switch (num_bits) {
+	case 16:
+		data_type = OMAP_DMA_DATA_TYPE_S16;
+		break;
+	case 32:
+		data_type = OMAP_DMA_DATA_TYPE_S32;
+		break;
+	default:
+		data_type = -EINVAL;
+		break;
+	}
+	return data_type;
+}
+
 static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
@@ -163,7 +181,16 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 		return 0;
 
 	memset(&dma_params, 0, sizeof(dma_params));
-	dma_params.data_type			= dma_data->data_type;
+
+	if (dma_data->data_type)
+		dma_params.data_type = dma_data->data_type;
+	else
+		dma_params.data_type = omap_pcm_get_dma_type(
+				snd_pcm_format_physical_width(runtime->format));
+
+	if (dma_params.data_type < 0)
+		return dma_params.data_type;
+
 	dma_params.trigger			= dma_data->dma_req;
 
 	if (dma_data->packet_size)
@@ -195,7 +222,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 	 * still can get an interrupt at each period bounary
 	 */
 	bytes = snd_pcm_lib_period_bytes(substream);
-	dma_params.elem_count	= bytes >> dma_data->data_type;
+	dma_params.elem_count	= bytes >> dma_params.data_type;
 	dma_params.frame_count	= runtime->periods;
 	omap_set_dma_params(prtd->dma_ch, &dma_params);
 
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ