]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
MLK-10001: ASoC: fsl_sai: no sound for mono wav in master mode
authorShengjiu Wang <shengjiu.wang@freescale.com>
Tue, 16 Dec 2014 02:09:50 +0000 (10:09 +0800)
committerNitin Garg <nitin.garg@freescale.com>
Fri, 16 Jan 2015 03:18:49 +0000 (21:18 -0600)
The bclk caculation should according to the slot num, not the channels.
Because sometime we have two slots, but only one slot is enabled for mono
channel.
As when the codec wm8962 works on mono mode, it needs two slots I2S signal.
So here set the default slots of sai to 2, and add function set_tdm_slots for
future usage.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 991a1f269ce4e4d0daa2cf5615169891acca0607)

sound/soc/fsl/fsl_sai.c
sound/soc/fsl/fsl_sai.h

index c6a08486766b7cf36fab47bd50b50a2d089bbcb8..e29e07899cf7c15d57d1d42ffca55281bd1808c7 100644 (file)
@@ -115,6 +115,17 @@ out:
                return IRQ_HANDLED;
 }
 
+static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
+                               u32 rx_mask, int slots, int slot_width)
+{
+       struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
+
+       sai->slots = slots;
+       sai->slot_width = slot_width;
+
+       return 0;
+}
+
 static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
                int clk_id, unsigned int freq, int fsl_dir)
 {
@@ -361,7 +372,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
        int ret;
 
        if (!sai->is_slave_mode) {
-               ret = fsl_sai_set_bclk(cpu_dai, tx, 2 * word_width * params_rate(params));
+               ret = fsl_sai_set_bclk(cpu_dai, tx, sai->slots * word_width * params_rate(params));
                if (ret)
                        return ret;
 
@@ -387,7 +398,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
        else
                val_cr5 |= FSL_SAI_CR5_FBT(word_width - 1);
 
-       val_cr4 |= FSL_SAI_CR4_FRSZ(channels);
+       val_cr4 |= FSL_SAI_CR4_FRSZ(sai->slots);
 
        regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx),
                           FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK,
@@ -530,6 +541,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
 static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
        .set_sysclk     = fsl_sai_set_dai_sysclk,
        .set_fmt        = fsl_sai_set_dai_fmt,
+       .set_tdm_slot   = fsl_sai_set_dai_tdm_slot,
        .hw_params      = fsl_sai_hw_params,
        .hw_free        = fsl_sai_hw_free,
        .trigger        = fsl_sai_trigger,
@@ -717,6 +729,8 @@ static int fsl_sai_probe(struct platform_device *pdev)
                }
        }
 
+       sai->slots = 2;
+
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
index 078ceb2ec8991ba4c4e26d27382b79d1af9671f1..bbcc7b6b6ff6912a5b4334ada2d9a585e5f6868f 100644 (file)
@@ -143,6 +143,8 @@ struct fsl_sai {
 
        unsigned int mclk_id;
        unsigned int mclk_streams;
+       unsigned int slots;
+       unsigned int slot_width;
 
        struct snd_dmaengine_dai_dma_data dma_params_rx;
        struct snd_dmaengine_dai_dma_data dma_params_tx;