ASoC: OMAP: Update contact addresses
[pandora-kernel.git] / sound / soc / omap / omap-mcbsp.c
index ec5e18a..9126142 100644 (file)
@@ -3,7 +3,8 @@
  *
  * Copyright (C) 2008 Nokia Corporation
  *
- * Contact: Jarkko Nikula <jarkko.nikula@nokia.com>
+ * Contact: Jarkko Nikula <jhnikula@gmail.com>
+ *          Peter Ujfalusi <peter.ujfalusi@nokia.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -146,6 +147,17 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
        struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
        int err = 0;
 
+       if (cpu_is_omap343x() && mcbsp_data->bus_id == 1) {
+               /*
+                * McBSP2 in OMAP3 has 1024 * 32-bit internal audio buffer.
+                * Set constraint for minimum buffer size to the same than FIFO
+                * size in order to avoid underruns in playback startup because
+                * HW is keeping the DMA request active until FIFO is filled.
+                */
+               snd_pcm_hw_constraint_minmax(substream->runtime,
+                       SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 4096, UINT_MAX);
+       }
+
        if (!cpu_dai->active)
                err = omap_mcbsp_request(mcbsp_data->bus_id);
 
@@ -272,7 +284,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
                break;
        case SND_SOC_DAIFMT_DSP_B:
                regs->srgr2     |= FPER(wlen * channels - 1);
-               regs->srgr1     |= FWID(wlen * channels - 2);
+               regs->srgr1     |= FWID(0);
                break;
        }
 
@@ -291,6 +303,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 {
        struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
        struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
+       unsigned int temp_fmt = fmt;
 
        if (mcbsp_data->configured)
                return 0;
@@ -302,6 +315,10 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
        regs->spcr1     |= RINTM(3);
        regs->rcr2      |= RFIG;
        regs->xcr2      |= XFIG;
+       if (cpu_is_omap2430() || cpu_is_omap34xx()) {
+               regs->xccr = DXENDLY(1) | XDMAEN;
+               regs->rccr = RFULL_CYCLE | RDMAEN;
+       }
 
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
        case SND_SOC_DAIFMT_I2S:
@@ -313,6 +330,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
                /* 0-bit data delay */
                regs->rcr2      |= RDATDLY(0);
                regs->xcr2      |= XDATDLY(0);
+               /* Invert FS polarity configuration */
+               temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
                break;
        default:
                /* Unsupported data format */
@@ -336,7 +355,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
        }
 
        /* Set bit clock (CLKX/CLKR) and FS polarities */
-       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       switch (temp_fmt & SND_SOC_DAIFMT_INV_MASK) {
        case SND_SOC_DAIFMT_NB_NF:
                /*
                 * Normal BCLK + FS.
@@ -457,6 +476,16 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
        return err;
 }
 
+static struct snd_soc_dai_ops omap_mcbsp_dai_ops = {
+       .startup        = omap_mcbsp_dai_startup,
+       .shutdown       = omap_mcbsp_dai_shutdown,
+       .trigger        = omap_mcbsp_dai_trigger,
+       .hw_params      = omap_mcbsp_dai_hw_params,
+       .set_fmt        = omap_mcbsp_dai_set_dai_fmt,
+       .set_clkdiv     = omap_mcbsp_dai_set_clkdiv,
+       .set_sysclk     = omap_mcbsp_dai_set_dai_sysclk,
+};
+
 #define OMAP_MCBSP_DAI_BUILDER(link_id)                                \
 {                                                              \
        .name = "omap-mcbsp-dai-"#link_id,                      \
@@ -473,15 +502,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
                .rates = OMAP_MCBSP_RATES,                      \
                .formats = SNDRV_PCM_FMTBIT_S16_LE,             \
        },                                                      \
-       .ops = {                                                \
-               .startup = omap_mcbsp_dai_startup,              \
-               .shutdown = omap_mcbsp_dai_shutdown,            \
-               .trigger = omap_mcbsp_dai_trigger,              \
-               .hw_params = omap_mcbsp_dai_hw_params,          \
-               .set_fmt = omap_mcbsp_dai_set_dai_fmt,          \
-               .set_clkdiv = omap_mcbsp_dai_set_clkdiv,        \
-               .set_sysclk = omap_mcbsp_dai_set_dai_sysclk,    \
-       },                                                      \
+       .ops = &omap_mcbsp_dai_ops,                             \
        .private_data = &mcbsp_data[(link_id)].bus_id,          \
 }
 
@@ -512,6 +533,6 @@ static void __exit snd_omap_mcbsp_exit(void)
 }
 module_exit(snd_omap_mcbsp_exit);
 
-MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@nokia.com>");
+MODULE_AUTHOR("Jarkko Nikula <jhnikula@gmail.com>");
 MODULE_DESCRIPTION("OMAP I2S SoC Interface");
 MODULE_LICENSE("GPL");