summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorCosmin-Gabriel Samoila <cosmin.samoila@nxp.com>2018-10-30 13:54:11 +0200
committerCosmin-Gabriel Samoila <cosmin.samoila@nxp.com>2018-10-31 09:34:19 +0200
commitd67a67e8b1fc5a1babc941dc3e38daea3611ac44 (patch)
treec659e28226029bc7ac60fb1c59f0824be61bde06 /sound
parentf4066de298feefa2bf884c154ada6d74e0cec61c (diff)
MLK-20102 sound: asoc: fix VAD channel select
The documentation specifies that VADCHSEL is used to select the channel number on which hwvad detector will work. However, we have used this field wrong (similar to the recording where you can enable, disable multiple channels at the time). This patch fixes hwvad and you can enable it by writing 0 to 7 in /sys/devices/platform/30080000.micfil/hwvad/enable or any other number to disable it. Signed-off-by: Cosmin-Gabriel Samoila <cosmin.samoila@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/fsl/fsl_micfil.c22
-rw-r--r--sound/soc/fsl/fsl_micfil.h2
2 files changed, 10 insertions, 14 deletions
diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c
index b2f8cdd69e6c..31d6aff59c8e 100644
--- a/sound/soc/fsl/fsl_micfil.c
+++ b/sound/soc/fsl/fsl_micfil.c
@@ -44,7 +44,7 @@ struct fsl_micfil {
struct clk *clk_src[MICFIL_CLK_SRC_NUM];
struct snd_dmaengine_dai_dma_data dma_params_rx;
struct kobject *hwvad_kobject;
- unsigned int channels;
+ unsigned int vad_channel;
unsigned int dataline;
char name[32];
int irq[MICFIL_IRQ_LINES];
@@ -1289,7 +1289,7 @@ static int __maybe_unused init_hwvad(struct device *dev)
/* configure source channel in VADCHSEL */
ret = regmap_update_bits(micfil->regmap, REG_MICFIL_VAD0_CTRL1,
MICFIL_VAD0_CTRL1_CHSEL_MASK,
- MICFIL_VAD0_CTRL1_CHSEL(micfil->channels));
+ MICFIL_VAD0_CTRL1_CHSEL(micfil->vad_channel));
if (ret) {
dev_err(dev, "Failed to set CHSEL in CTRL1_VAD0 [%d]\n", ret);
return ret;
@@ -1643,7 +1643,6 @@ static int fsl_micfil_hw_params(struct snd_pcm_substream *substream,
micfil->dma_params_rx.fifo_num = channels;
micfil->dma_params_rx.maxburst = channels * MICFIL_DMA_MAXBURST_RX;
- micfil->channels = channels;
return 0;
}
@@ -2142,27 +2141,24 @@ static ssize_t micfil_hwvad_handler(struct kobject *kobj,
struct kobject *nand_kobj = kobj->parent;
struct device *dev = container_of(nand_kobj, struct device, kobj);
struct fsl_micfil *micfil = dev_get_drvdata(dev);
- unsigned long enabled_channels;
+ unsigned long vad_channel;
int ret;
- ret = kstrtoul(buf, 16, &enabled_channels);
+ ret = kstrtoul(buf, 16, &vad_channel);
if (ret < 0)
return -EINVAL;
- if (enabled_channels > 0 && enabled_channels <= 8) {
+ if (vad_channel >= 0 && vad_channel <= 7) {
dev_info(dev,
"enabling hwvad with %lu channels at rate %d\n",
- enabled_channels,
+ vad_channel,
micfil_hwvad_rate_ints[micfil->vad_rate_index]);
- micfil->channels = enabled_channels;
+ micfil->vad_channel = vad_channel;
ret = enable_hwvad(dev);
- } else if (!enabled_channels) {
+ } else {
dev_info(dev, "disabling hwvad\n");
- micfil->channels = 0;
+ micfil->vad_channel = -1;
ret = disable_hwvad(dev);
- } else {
- dev_err(dev, "Unsupported number of channels. Try 0,1..8\n");
- ret = -EINVAL;
}
if (ret)
return ret;
diff --git a/sound/soc/fsl/fsl_micfil.h b/sound/soc/fsl/fsl_micfil.h
index 4b92f47b7a47..04156627456c 100644
--- a/sound/soc/fsl/fsl_micfil.h
+++ b/sound/soc/fsl/fsl_micfil.h
@@ -127,7 +127,7 @@
#define MICFIL_VAD0_CTRL1_CHSEL_WIDTH 3
#define MICFIL_VAD0_CTRL1_CHSEL_MASK ((BIT(MICFIL_VAD0_CTRL1_CHSEL_WIDTH) - 1) \
<< MICFIL_VAD0_CTRL1_CHSEL_SHIFT)
-#define MICFIL_VAD0_CTRL1_CHSEL(v) ((((1 << (v)) - 1) << MICFIL_VAD0_CTRL1_CHSEL_SHIFT) \
+#define MICFIL_VAD0_CTRL1_CHSEL(v) (((v) << MICFIL_VAD0_CTRL1_CHSEL_SHIFT) \
& MICFIL_VAD0_CTRL1_CHSEL_MASK)
#define MICFIL_VAD0_CTRL1_CICOSR_SHIFT 16
#define MICFIL_VAD0_CTRL1_CICOSR_WIDTH 4