ASoC: S3C: Remove <plat/audio.h>
[safe/jmp/linux-2.6] / sound / soc / s3c24xx / s3c-i2s-v2.c
index 11d8717..28b0ab2 100644 (file)
 
 #include <plat/regs-s3c2412-iis.h>
 
-#include <plat/audio.h>
 #include <mach/dma.h>
 
 #include "s3c-i2s-v2.h"
+#include "s3c24xx-pcm.h"
 
 #undef S3C_IIS_V2_SUPPORTED
 
@@ -229,6 +229,8 @@ static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on)
        pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic);
 }
 
+#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
+
 /*
  * Wait for the LR signal to allow synchronisation to the L/R clock
  * from the codec. May only be needed for slave mode.
@@ -236,19 +238,21 @@ static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on)
 static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s)
 {
        u32 iiscon;
-       unsigned long timeout = jiffies + msecs_to_jiffies(5);
+       unsigned long loops = msecs_to_loops(5);
 
        pr_debug("Entered %s\n", __func__);
 
-       while (1) {
+       while (--loops) {
                iiscon = readl(i2s->regs + S3C2412_IISCON);
                if (iiscon & S3C2412_IISCON_LRINDEX)
                        break;
 
-               if (timeout < jiffies) {
-                       printk(KERN_ERR "%s: timeout\n", __func__);
-                       return -ETIMEDOUT;
-               }
+               cpu_relax();
+       }
+
+       if (!loops) {
+               printk(KERN_ERR "%s: timeout\n", __func__);
+               return -ETIMEDOUT;
        }
 
        return 0;
@@ -307,12 +311,15 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
 
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
        case SND_SOC_DAIFMT_RIGHT_J:
+               iismod |= S3C2412_IISMOD_LR_RLOW;
                iismod |= S3C2412_IISMOD_SDF_MSB;
                break;
        case SND_SOC_DAIFMT_LEFT_J:
+               iismod |= S3C2412_IISMOD_LR_RLOW;
                iismod |= S3C2412_IISMOD_SDF_LSB;
                break;
        case SND_SOC_DAIFMT_I2S:
+               iismod &= ~S3C2412_IISMOD_LR_RLOW;
                iismod |= S3C2412_IISMOD_SDF_IIS;
                break;
        default:
@@ -462,6 +469,31 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
 
        switch (div_id) {
        case S3C_I2SV2_DIV_BCLK:
+               if (div > 3) {
+                       /* convert value to bit field */
+
+                       switch (div) {
+                       case 16:
+                               div = S3C2412_IISMOD_BCLK_16FS;
+                               break;
+
+                       case 32:
+                               div = S3C2412_IISMOD_BCLK_32FS;
+                               break;
+
+                       case 24:
+                               div = S3C2412_IISMOD_BCLK_24FS;
+                               break;
+
+                       case 48:
+                               div = S3C2412_IISMOD_BCLK_48FS;
+                               break;
+
+                       default:
+                               return -EINVAL;
+                       }
+               }
+
                reg = readl(i2s->regs + S3C2412_IISMOD);
                reg &= ~S3C2412_IISMOD_BCLK_MASK;
                writel(reg | div, i2s->regs + S3C2412_IISMOD);
@@ -621,7 +653,7 @@ int s3c_i2sv2_probe(struct platform_device *pdev,
        }
 
        i2s->iis_pclk = clk_get(dev, "iis");
-       if (i2s->iis_pclk == NULL) {
+       if (IS_ERR(i2s->iis_pclk)) {
                dev_err(dev, "failed to get iis_clock\n");
                iounmap(i2s->regs);
                return -ENOENT;