[ALSA] hda-intel - Fix PCM device number assignment
[cascardo/linux.git] / sound / pci / hda / patch_cmedia.c
index 5b9d3a3..99ce74b 100644 (file)
@@ -21,7 +21,6 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
@@ -50,7 +49,7 @@ struct cmi_spec {
 
        /* playback */
        struct hda_multi_out multiout;
-       hda_nid_t dac_nids[4];          /* NID for each DAC */
+       hda_nid_t dac_nids[AUTO_CFG_MAX_OUTS];  /* NID for each DAC */
        int num_dacs;
 
        /* capture */
@@ -73,7 +72,6 @@ struct cmi_spec {
        unsigned int pin_def_confs;
 
        /* multichannel pins */
-       hda_nid_t multich_pin[4];       /* max 8-channel */
        struct hda_verb multi_init[9];  /* 2 verbs for each pin + terminator */
 };
 
@@ -187,7 +185,6 @@ static struct snd_kcontrol_new cmi9880_basic_mixer[] = {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                /* The multiple "Capture Source" controls confuse alsamixer
                 * So call somewhat different..
-                * FIXME: the controls appear in the "playback" view!
                 */
                /* .name = "Capture Source", */
                .name = "Input Source",
@@ -427,27 +424,6 @@ static int cmi9880_init(struct hda_codec *codec)
        return 0;
 }
 
-#ifdef CONFIG_PM
-/*
- * resume
- */
-static int cmi9880_resume(struct hda_codec *codec)
-{
-       struct cmi_spec *spec = codec->spec;
-
-       cmi9880_init(codec);
-       snd_hda_resume_ctls(codec, cmi9880_basic_mixer);
-       if (spec->channel_modes)
-               snd_hda_resume_ctls(codec, cmi9880_ch_mode_mixer);
-       if (spec->multiout.dig_out_nid)
-               snd_hda_resume_spdif_out(codec);
-       if (spec->dig_in_nid)
-               snd_hda_resume_spdif_in(codec);
-
-       return 0;
-}
-#endif
-
 /*
  * Analog playback callbacks
  */
@@ -497,6 +473,17 @@ static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
        return snd_hda_multi_out_dig_close(codec, &spec->multiout);
 }
 
+static int cmi9880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
+                                           struct hda_codec *codec,
+                                           unsigned int stream_tag,
+                                           unsigned int format,
+                                           struct snd_pcm_substream *substream)
+{
+       struct cmi_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
+                                            format, substream);
+}
+
 /*
  * Analog capture
  */
@@ -556,7 +543,8 @@ static struct hda_pcm_stream cmi9880_pcm_digital_playback = {
        /* NID is set in cmi9880_build_pcms */
        .ops = {
                .open = cmi9880_dig_playback_pcm_open,
-               .close = cmi9880_dig_playback_pcm_close
+               .close = cmi9880_dig_playback_pcm_close,
+               .prepare = cmi9880_dig_playback_pcm_prepare
        },
 };
 
@@ -583,6 +571,7 @@ static int cmi9880_build_pcms(struct hda_codec *codec)
                codec->num_pcms++;
                info++;
                info->name = "CMI9880 Digital";
+               info->pcm_type = HDA_PCM_TYPE_SPDIF;
                if (spec->multiout.dig_out_nid) {
                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback;
                        info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -623,9 +612,6 @@ static struct hda_codec_ops cmi9880_patch_ops = {
        .build_pcms = cmi9880_build_pcms,
        .init = cmi9880_init,
        .free = cmi9880_free,
-#ifdef CONFIG_PM
-       .resume = cmi9880_resume,
-#endif
 };
 
 static int patch_cmi9880(struct hda_codec *codec)