ALSA: hda: slave digital out support
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / soc / codecs / wm9713.c
index 4863636e9d5634852869bc55d526ea69c79c04fb..38d1fe0971fc7faf328c6a19ca0f6f6516f42577 100644 (file)
@@ -453,7 +453,7 @@ SND_SOC_DAPM_INPUT("MIC2B"),
 SND_SOC_DAPM_VMID("VMID"),
 };
 
-static const char *audio_map[][3] = {
+static const struct snd_soc_dapm_route audio_map[] = {
        /* left HP mixer */
        {"Left HP Mixer", "PC Beep Playback Switch", "PCBEEP"},
        {"Left HP Mixer", "Voice Playback Switch",   "Voice DAC"},
@@ -604,21 +604,14 @@ static const char *audio_map[][3] = {
        {"Capture Mono Mux", "Stereo", "Capture Mixer"},
        {"Capture Mono Mux", "Left", "Left Capture Source"},
        {"Capture Mono Mux", "Right", "Right Capture Source"},
-
-       {NULL, NULL, NULL},
 };
 
 static int wm9713_add_widgets(struct snd_soc_codec *codec)
 {
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(wm9713_dapm_widgets); i++)
-               snd_soc_dapm_new_control(codec, &wm9713_dapm_widgets[i]);
+       snd_soc_dapm_new_controls(codec, wm9713_dapm_widgets,
+                                 ARRAY_SIZE(wm9713_dapm_widgets));
 
-       /* set up audio path audio_mapnects */
-       for (i = 0; audio_map[i][0] != NULL; i++)
-               snd_soc_dapm_connect_input(codec, audio_map[i][0],
-                       audio_map[i][1], audio_map[i][2]);
+       snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
        snd_soc_dapm_new_widgets(codec);
        return 0;
@@ -796,7 +789,7 @@ static int wm9713_set_pll(struct snd_soc_codec *codec,
        return 0;
 }
 
-static int wm9713_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
+static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai,
                int pll_id, unsigned int freq_in, unsigned int freq_out)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
@@ -807,7 +800,7 @@ static int wm9713_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
  * Tristate the PCM DAI lines, tristate can be disabled by calling
  * wm9713_set_dai_fmt()
  */
-static int wm9713_set_dai_tristate(struct snd_soc_codec_dai *codec_dai,
+static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai,
        int tristate)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
@@ -823,7 +816,7 @@ static int wm9713_set_dai_tristate(struct snd_soc_codec_dai *codec_dai,
  * Configure WM9713 clock dividers.
  * Voice DAC needs 256 FS
  */
-static int wm9713_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
+static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
                int div_id, int div)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
@@ -865,7 +858,7 @@ static int wm9713_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
        return 0;
 }
 
-static int wm9713_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
+static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai,
                unsigned int fmt)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
@@ -883,7 +876,7 @@ static int wm9713_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
                gpio |= 0x0018;
                break;
        case SND_SOC_DAIFMT_CBS_CFS:
-               reg |= 0x0200;
+               reg |= 0x2000;
                gpio |= 0x001a;
                break;
        case SND_SOC_DAIFMT_CBS_CFM:
@@ -1008,15 +1001,24 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream)
        return ac97_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate);
 }
 
-#define WM9713_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
-               SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
-               SNDRV_PCM_RATE_48000)
+#define WM9713_RATES (SNDRV_PCM_RATE_8000  |   \
+                     SNDRV_PCM_RATE_11025 |    \
+                     SNDRV_PCM_RATE_22050 |    \
+                     SNDRV_PCM_RATE_44100 |    \
+                     SNDRV_PCM_RATE_48000)
+
+#define WM9713_PCM_RATES (SNDRV_PCM_RATE_8000  |       \
+                         SNDRV_PCM_RATE_11025 |        \
+                         SNDRV_PCM_RATE_16000 |        \
+                         SNDRV_PCM_RATE_22050 |        \
+                         SNDRV_PCM_RATE_44100 |        \
+                         SNDRV_PCM_RATE_48000)
 
 #define WM9713_PCM_FORMATS \
        (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
         SNDRV_PCM_FORMAT_S24_LE)
 
-struct snd_soc_codec_dai wm9713_dai[] = {
+struct snd_soc_dai wm9713_dai[] = {
 {
        .name = "AC97 HiFi",
        .type = SND_SOC_DAI_AC97_BUS,
@@ -1058,13 +1060,13 @@ struct snd_soc_codec_dai wm9713_dai[] = {
                .stream_name = "Voice Playback",
                .channels_min = 1,
                .channels_max = 1,
-               .rates = WM9713_RATES,
+               .rates = WM9713_PCM_RATES,
                .formats = WM9713_PCM_FORMATS,},
        .capture = {
                .stream_name = "Voice Capture",
                .channels_min = 1,
                .channels_max = 2,
-               .rates = WM9713_RATES,
+               .rates = WM9713_PCM_RATES,
                .formats = WM9713_PCM_FORMATS,},
        .ops = {
                .hw_params = wm9713_pcm_hw_params,
@@ -1083,12 +1085,12 @@ int wm9713_reset(struct snd_soc_codec *codec, int try_warm)
 {
        if (try_warm && soc_ac97_ops.warm_reset) {
                soc_ac97_ops.warm_reset(codec->ac97);
-               if (!(ac97_read(codec, 0) & 0x8000))
+               if (ac97_read(codec, 0) == wm9713_reg[0])
                        return 1;
        }
 
        soc_ac97_ops.reset(codec->ac97);
-       if (ac97_read(codec, 0) & 0x8000)
+       if (ac97_read(codec, 0) != wm9713_reg[0])
                return -EIO;
        return 0;
 }