Re: [Patch V7 06/10] ASoC: qcom: Add LPASS platform driver

2015-03-05 Thread Mark Brown
On Tue, Mar 03, 2015 at 04:21:55PM -0800, Kenneth Westfield wrote:
> From: Kenneth Westfield 
> 
> Add platform driver for the Qualcomm Technologies
> low-power audio subsystem (LPASS) ports.

Applied, thanks.


signature.asc
Description: Digital signature


[Patch V7 06/10] ASoC: qcom: Add LPASS platform driver

2015-03-03 Thread Kenneth Westfield
From: Kenneth Westfield 

Add platform driver for the Qualcomm Technologies
low-power audio subsystem (LPASS) ports.

Signed-off-by: Kenneth Westfield 
Acked-by: Banajit Goswami 
---
 sound/soc/qcom/lpass-platform.c | 526 
 1 file changed, 526 insertions(+)
 create mode 100644 sound/soc/qcom/lpass-platform.c

diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
new file mode 100644
index 
..2fa6280dfb234b213904ad73dfad91c7f575538c
--- /dev/null
+++ b/sound/soc/qcom/lpass-platform.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * lpass-platform.c -- ALSA SoC platform driver for QTi LPASS
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "lpass-lpaif-ipq806x.h"
+#include "lpass.h"
+
+#define LPASS_PLATFORM_BUFFER_SIZE (16 * 1024)
+#define LPASS_PLATFORM_PERIODS 2
+
+static struct snd_pcm_hardware lpass_platform_pcm_hardware = {
+   .info   =   SNDRV_PCM_INFO_MMAP |
+   SNDRV_PCM_INFO_MMAP_VALID |
+   SNDRV_PCM_INFO_INTERLEAVED |
+   SNDRV_PCM_INFO_PAUSE |
+   SNDRV_PCM_INFO_RESUME,
+   .formats=   SNDRV_PCM_FMTBIT_S16 |
+   SNDRV_PCM_FMTBIT_S24 |
+   SNDRV_PCM_FMTBIT_S32,
+   .rates  =   SNDRV_PCM_RATE_8000_192000,
+   .rate_min   =   8000,
+   .rate_max   =   192000,
+   .channels_min   =   1,
+   .channels_max   =   8,
+   .buffer_bytes_max   =   LPASS_PLATFORM_BUFFER_SIZE,
+   .period_bytes_max   =   LPASS_PLATFORM_BUFFER_SIZE /
+   LPASS_PLATFORM_PERIODS,
+   .period_bytes_min   =   LPASS_PLATFORM_BUFFER_SIZE /
+   LPASS_PLATFORM_PERIODS,
+   .periods_min=   LPASS_PLATFORM_PERIODS,
+   .periods_max=   LPASS_PLATFORM_PERIODS,
+   .fifo_size  =   0,
+};
+
+static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream)
+{
+   struct snd_pcm_runtime *runtime = substream->runtime;
+   struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
+   int ret;
+
+   snd_soc_set_runtime_hwparams(substream, &lpass_platform_pcm_hardware);
+
+   runtime->dma_bytes = lpass_platform_pcm_hardware.buffer_bytes_max;
+
+   ret = snd_pcm_hw_constraint_integer(runtime,
+   SNDRV_PCM_HW_PARAM_PERIODS);
+   if (ret < 0) {
+   dev_err(soc_runtime->dev, "%s() setting constraints failed: 
%d\n",
+   __func__, ret);
+   return -EINVAL;
+   }
+
+   snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
+
+   return 0;
+}
+
+static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
+   struct lpass_data *drvdata =
+   snd_soc_platform_get_drvdata(soc_runtime->platform);
+   snd_pcm_format_t format = params_format(params);
+   unsigned int channels = params_channels(params);
+   unsigned int regval;
+   int bitwidth;
+   int ret;
+
+   bitwidth = snd_pcm_format_width(format);
+   if (bitwidth < 0) {
+   dev_err(soc_runtime->dev, "%s() invalid bit width given: %d\n",
+   __func__, bitwidth);
+   return bitwidth;
+   }
+
+   regval = LPAIF_RDMACTL_BURSTEN_INCR4 |
+   LPAIF_RDMACTL_AUDINTF_MI2S |
+   LPAIF_RDMACTL_FIFOWM_8;
+
+   switch (bitwidth) {
+   case 16:
+   switch (channels) {
+   case 1:
+   case 2:
+   regval |= LPAIF_RDMACTL_WPSCNT_ONE;
+   break;
+   case 4:
+   regval |= LPAIF_RDMACTL_WPSCNT_TWO;
+   break;
+   case 6:
+   regval |= LPAIF_RDMACTL