Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[pandora-kernel.git] / sound / pci / hda / patch_cmedia.c
index d38ce22..6c54793 100644 (file)
@@ -40,6 +40,7 @@ enum {
        CMI_FULL_DIG,   /* back 6-jack + front-panel 2-jack + digital I/O */
        CMI_ALLOUT,     /* back 5-jack + front-panel 2-jack + digital out */
        CMI_AUTO,       /* let driver guess it */
+       CMI_MODELS
 };
 
 struct cmi_spec {
@@ -49,7 +50,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 */
@@ -72,7 +73,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 */
 };
 
@@ -426,27 +426,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
  */
@@ -496,6 +475,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
  */
@@ -555,7 +545,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
        },
 };
 
@@ -603,14 +594,17 @@ static void cmi9880_free(struct hda_codec *codec)
 /*
  */
 
-static struct hda_board_config cmi9880_cfg_tbl[] = {
-       { .modelname = "minimal", .config = CMI_MINIMAL },
-       { .modelname = "min_fp", .config = CMI_MIN_FP },
-       { .modelname = "full", .config = CMI_FULL },
-       { .modelname = "full_dig", .config = CMI_FULL_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x813d, .config = CMI_FULL_DIG }, /* ASUS P5AD2 */
-       { .modelname = "allout", .config = CMI_ALLOUT },
-       { .modelname = "auto", .config = CMI_AUTO },
+static const char *cmi9880_models[CMI_MODELS] = {
+       [CMI_MINIMAL]   = "minimal",
+       [CMI_MIN_FP]    = "min_fp",
+       [CMI_FULL]      = "full",
+       [CMI_FULL_DIG]  = "full_dig",
+       [CMI_ALLOUT]    = "allout",
+       [CMI_AUTO]      = "auto",
+};
+
+static struct snd_pci_quirk cmi9880_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG),
        {} /* terminator */
 };
 
@@ -619,9 +613,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)
@@ -633,7 +624,9 @@ static int patch_cmi9880(struct hda_codec *codec)
                return -ENOMEM;
 
        codec->spec = spec;
-       spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl);
+       spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS,
+                                                       cmi9880_models,
+                                                       cmi9880_cfg_tbl);
        if (spec->board_config < 0) {
                snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n");
                spec->board_config = CMI_AUTO; /* try everything */