Merge master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6
[powerpc.git] / sound / pci / hda / patch_cmedia.c
index 6e0fd92..5b9d3a3 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 {
@@ -76,30 +77,17 @@ struct cmi_spec {
        struct hda_verb multi_init[9];  /* 2 verbs for each pin + terminator */
 };
 
-/* amp values */
-#define AMP_IN_MUTE(idx)       (0x7080 | ((idx)<<8))
-#define AMP_IN_UNMUTE(idx)     (0x7000 | ((idx)<<8))
-#define AMP_OUT_MUTE   0xb080
-#define AMP_OUT_UNMUTE 0xb000
-#define AMP_OUT_ZERO   0xb000
-/* pinctl values */
-#define PIN_IN         0x20
-#define PIN_VREF80     0x24
-#define PIN_VREF50     0x21
-#define PIN_OUT                0x40
-#define PIN_HP         0xc0
-
 /*
  * input MUX
  */
-static int cmi_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+static int cmi_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct cmi_spec *spec = codec->spec;
        return snd_hda_input_mux_info(spec->input_mux, uinfo);
 }
 
-static int cmi_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int cmi_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct cmi_spec *spec = codec->spec;
@@ -109,7 +97,7 @@ static int cmi_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon
        return 0;
 }
 
-static int cmi_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int cmi_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct cmi_spec *spec = codec->spec;
@@ -162,7 +150,7 @@ static struct hda_channel_mode cmi9880_channel_modes[3] = {
        { 8, cmi9880_ch8_init },
 };
 
-static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+static int cmi_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct cmi_spec *spec = codec->spec;
@@ -170,7 +158,7 @@ static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo
                                    spec->num_channel_modes);
 }
 
-static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int cmi_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct cmi_spec *spec = codec->spec;
@@ -178,7 +166,7 @@ static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont
                                   spec->num_channel_modes, spec->multiout.max_channels);
 }
 
-static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int cmi_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct cmi_spec *spec = codec->spec;
@@ -188,7 +176,7 @@ static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont
 
 /*
  */
-static snd_kcontrol_new_t cmi9880_basic_mixer[] = {
+static struct snd_kcontrol_new cmi9880_basic_mixer[] = {
        /* CMI9880 has no playback volumes! */
        HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), /* front */
        HDA_CODEC_MUTE("Surround Playback Switch", 0x04, 0x0, HDA_OUTPUT),
@@ -220,7 +208,7 @@ static snd_kcontrol_new_t cmi9880_basic_mixer[] = {
 /*
  * shared I/O pins
  */
-static snd_kcontrol_new_t cmi9880_ch_mode_mixer[] = {
+static struct snd_kcontrol_new cmi9880_ch_mode_mixer[] = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "Channel Mode",
@@ -465,7 +453,7 @@ static int cmi9880_resume(struct hda_codec *codec)
  */
 static int cmi9880_playback_pcm_open(struct hda_pcm_stream *hinfo,
                                     struct hda_codec *codec,
-                                    snd_pcm_substream_t *substream)
+                                    struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
@@ -475,7 +463,7 @@ static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
                                        struct hda_codec *codec,
                                        unsigned int stream_tag,
                                        unsigned int format,
-                                       snd_pcm_substream_t *substream)
+                                       struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
        return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
@@ -484,7 +472,7 @@ static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
 
 static int cmi9880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
                                       struct hda_codec *codec,
-                                      snd_pcm_substream_t *substream)
+                                      struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
        return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
@@ -495,7 +483,7 @@ static int cmi9880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  */
 static int cmi9880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
                                         struct hda_codec *codec,
-                                        snd_pcm_substream_t *substream)
+                                        struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
        return snd_hda_multi_out_dig_open(codec, &spec->multiout);
@@ -503,7 +491,7 @@ static int cmi9880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
 
 static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
                                          struct hda_codec *codec,
-                                         snd_pcm_substream_t *substream)
+                                         struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
        return snd_hda_multi_out_dig_close(codec, &spec->multiout);
@@ -516,7 +504,7 @@ static int cmi9880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
                                      struct hda_codec *codec,
                                      unsigned int stream_tag,
                                      unsigned int format,
-                                     snd_pcm_substream_t *substream)
+                                     struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
 
@@ -527,7 +515,7 @@ static int cmi9880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
 
 static int cmi9880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
                                      struct hda_codec *codec,
-                                     snd_pcm_substream_t *substream)
+                                     struct snd_pcm_substream *substream)
 {
        struct cmi_spec *spec = codec->spec;
 
@@ -616,14 +604,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 */
 };
 
@@ -646,7 +637,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 */
@@ -724,7 +717,7 @@ static int patch_cmi9880(struct hda_codec *codec)
                                spec->dig_in_nid = CMI_DIG_IN_NID;
                        spec->multiout.max_channels = 8;
                }
-               snd_hda_parse_pin_def_config(codec, &cfg);
+               snd_hda_parse_pin_def_config(codec, &cfg, NULL);
                if (cfg.line_outs) {
                        spec->multiout.max_channels = cfg.line_outs * 2;
                        cmi9880_fill_multi_dac_nids(codec, &cfg);