]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/soc/codecs/wm9713.c
ALSA: ASoC: Advertise 16000Hz rate for WM9713 PCM interface
[linux-2.6-omap-h63xx.git] / sound / soc / codecs / wm9713.c
index e3174c4d980d6d8d2d6852433ea301fc04796881..a4806189044d3305cc9bad3f1de6a04a1f1e9a68 100644 (file)
@@ -10,9 +10,6 @@
  *  Free Software Foundation;  either version 2 of the  License, or (at your
  *  option) any later version.
  *
- *  Revision history
- *    4th Feb 2006   Initial version.
- *
  *  Features:-
  *
  *   o Support for AC97 Codec, Voice DAC and Aux DAC
@@ -456,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"},
@@ -607,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;
@@ -886,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:
@@ -1011,9 +1001,18 @@ 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 | \
@@ -1061,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,
@@ -1086,44 +1085,44 @@ 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;
 }
 EXPORT_SYMBOL_GPL(wm9713_reset);
 
-static int wm9713_dapm_event(struct snd_soc_codec *codec, int event)
+static int wm9713_set_bias_level(struct snd_soc_codec *codec,
+                                enum snd_soc_bias_level level)
 {
        u16 reg;
 
-       switch (event) {
-       case SNDRV_CTL_POWER_D0: /* full On */
+       switch (level) {
+       case SND_SOC_BIAS_ON:
                /* enable thermal shutdown */
                reg = ac97_read(codec, AC97_EXTENDED_MID) & 0x1bff;
                ac97_write(codec, AC97_EXTENDED_MID, reg);
                break;
-       case SNDRV_CTL_POWER_D1: /* partial On */
-       case SNDRV_CTL_POWER_D2: /* partial On */
+       case SND_SOC_BIAS_PREPARE:
                break;
-       case SNDRV_CTL_POWER_D3hot: /* Off, with power */
+       case SND_SOC_BIAS_STANDBY:
                /* enable master bias and vmid */
                reg = ac97_read(codec, AC97_EXTENDED_MID) & 0x3bff;
                ac97_write(codec, AC97_EXTENDED_MID, reg);
                ac97_write(codec, AC97_POWERDOWN, 0x0000);
                break;
-       case SNDRV_CTL_POWER_D3cold: /* Off, without power */
+       case SND_SOC_BIAS_OFF:
                /* disable everything including AC link */
                ac97_write(codec, AC97_EXTENDED_MID, 0xffff);
                ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
                ac97_write(codec, AC97_POWERDOWN, 0xffff);
                break;
        }
-       codec->dapm_state = event;
+       codec->bias_level = level;
        return 0;
 }
 
@@ -1132,8 +1131,17 @@ static int wm9713_soc_suspend(struct platform_device *pdev,
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
        struct snd_soc_codec *codec = socdev->codec;
+       u16 reg;
+
+       /* Disable everything except touchpanel - that will be handled
+        * by the touch driver and left disabled if touch is not in
+        * use. */
+       reg = ac97_read(codec, AC97_EXTENDED_MID);
+       ac97_write(codec, AC97_EXTENDED_MID, reg | 0x7fff);
+       ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
+       ac97_write(codec, AC97_POWERDOWN, 0x6f00);
+       ac97_write(codec, AC97_POWERDOWN, 0xffff);
 
-       wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
        return 0;
 }
 
@@ -1151,7 +1159,7 @@ static int wm9713_soc_resume(struct platform_device *pdev)
                return ret;
        }
 
-       wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+       wm9713_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
        /* do we need to re-start the PLL ? */
        if (wm9713->pll_out)
@@ -1167,8 +1175,8 @@ static int wm9713_soc_resume(struct platform_device *pdev)
                }
        }
 
-       if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0)
-               wm9713_dapm_event(codec, SNDRV_CTL_POWER_D0);
+       if (codec->suspend_bias_level == SND_SOC_BIAS_ON)
+               wm9713_set_bias_level(codec, SND_SOC_BIAS_ON);
 
        return ret;
 }
@@ -1207,7 +1215,7 @@ static int wm9713_soc_probe(struct platform_device *pdev)
        codec->num_dai = ARRAY_SIZE(wm9713_dai);
        codec->write = ac97_write;
        codec->read = ac97_read;
-       codec->dapm_event = wm9713_dapm_event;
+       codec->set_bias_level = wm9713_set_bias_level;
        INIT_LIST_HEAD(&codec->dapm_widgets);
        INIT_LIST_HEAD(&codec->dapm_paths);
 
@@ -1229,7 +1237,7 @@ static int wm9713_soc_probe(struct platform_device *pdev)
                goto reset_err;
        }
 
-       wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
+       wm9713_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
        /* unmute the adc - move to kcontrol */
        reg = ac97_read(codec, AC97_CD) & 0x7fff;