OSDN Git Service

Merge remote-tracking branches 'asoc/topic/wm8523' and 'asoc/topic/wm8741' into asoc...
[uclinux-h8/linux.git] / sound / soc / codecs / wm8523.c
index b1cc94f..43ea8ae 100644 (file)
@@ -113,6 +113,15 @@ static struct {
        { 7, 1152 },
 };
 
+static struct {
+       int value;
+       int ratio;
+} bclk_ratios[WM8523_NUM_RATES] = {
+       { 2, 32 },
+       { 3, 64 },
+       { 4, 128 },
+};
+
 static int wm8523_startup(struct snd_pcm_substream *substream,
                          struct snd_soc_dai *dai)
 {
@@ -162,6 +171,23 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
        aifctrl2 &= ~WM8523_SR_MASK;
        aifctrl2 |= lrclk_ratios[i].value;
 
+       if (aifctrl1 & WM8523_AIF_MSTR) {
+               /* Find a fs->bclk ratio */
+               for (i = 0; i < ARRAY_SIZE(bclk_ratios); i++)
+                       if (params_width(params) * 2 <= bclk_ratios[i].ratio)
+                               break;
+
+               if (i == ARRAY_SIZE(bclk_ratios)) {
+                       dev_err(codec->dev,
+                               "No matching BCLK/fs ratio for word length %d\n",
+                               params_width(params));
+                       return -EINVAL;
+               }
+
+               aifctrl2 &= ~WM8523_BCLKDIV_MASK;
+               aifctrl2 |= bclk_ratios[i].value << WM8523_BCLKDIV_SHIFT;
+       }
+
        aifctrl1 &= ~WM8523_WL_MASK;
        switch (params_width(params)) {
        case 16:
@@ -308,7 +334,7 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
                break;
 
        case SND_SOC_BIAS_STANDBY:
-               if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
+               if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
                        ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
                                                    wm8523->supplies);
                        if (ret != 0) {
@@ -344,7 +370,6 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
                                       wm8523->supplies);
                break;
        }
-       codec->dapm.bias_level = level;
        return 0;
 }