]> err.no Git - linux-2.6/commitdiff
[ALSA] hda-codec - Add AD1884 / AD1984 codec support
authorTakashi Iwai <tiwai@suse.de>
Fri, 18 May 2007 16:21:41 +0000 (18:21 +0200)
committerJaroslav Kysela <perex@suse.cz>
Fri, 20 Jul 2007 09:11:18 +0000 (11:11 +0200)
Added the support of AD1884 and AD1984 codec chips.
Also experimental quirks for Thinkpad T61/X61 laptops with AD1984.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Documentation/sound/alsa/ALSA-Configuration.txt
sound/pci/hda/patch_analog.c

index 355ff0a2bb7c5a1cdc9862c4f827e9e49497c165..297ff0de7392542b3e7ac5265bef7fc4dafeee60 100644 (file)
@@ -864,12 +864,22 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          allout        5-jack in back, 2-jack in front, SPDIF out
          auto          auto-config reading BIOS (default)
 
+       AD1884
+         N/A
+
        AD1981
          basic         3-jack (default)
          hp            HP nx6320
          thinkpad      Lenovo Thinkpad T60/X60/Z60
          toshiba       Toshiba U205
 
+       AD1983
+         N/A
+
+       AD1984
+         basic         default configuration
+         thinkpad      Lenovo Thinkpad T61/X61
+
        AD1986A
          6stack        6-jack, separate surrounds (default)
          3stack        3-stack, shared surrounds
index 0e1a879663fa548b2ce8fde95f20c86ecb795262..30248cd562c5d1c94c15750df868c79247b93aed 100644 (file)
@@ -1,7 +1,8 @@
 /*
- * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988
+ * HD audio interface patch for AD1884, AD1981HD, AD1983, AD1984, AD1986A,
+ *   AD1988
  *
- * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
+ * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
  *
  *  This driver is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -61,7 +62,7 @@ struct ad198x_spec {
        int num_channel_mode;
 
        /* PCM information */
-       struct hda_pcm pcm_rec[2];      /* used in alc_build_pcms() */
+       struct hda_pcm pcm_rec[3];      /* used in alc_build_pcms() */
 
        struct mutex amp_mutex; /* PCM volume/mute control mutex */
        unsigned int spdif_route;
@@ -2774,12 +2775,350 @@ static int patch_ad1988(struct hda_codec *codec)
 }
 
 
+/*
+ * AD1884 / AD1984
+ *
+ * port-B - front line/mic-in
+ * port-E - aux in/out
+ * port-F - aux in/out
+ * port-C - rear line/mic-in
+ * port-D - rear line/hp-out
+ * port-A - front line/hp-out
+ *
+ * AD1984 = AD1884 + two digital mic-ins
+ *
+ * FIXME:
+ * For simplicity, we share the single DAC for both HP and line-outs
+ * right now.  The inidividual playbacks could be easily implemented,
+ * but no build-up framework is given, so far.
+ */
+
+static hda_nid_t ad1884_dac_nids[1] = {
+       0x04,
+};
+
+static hda_nid_t ad1884_adc_nids[2] = {
+       0x08, 0x09,
+};
+
+static hda_nid_t ad1884_capsrc_nids[2] = {
+       0x0c, 0x0d,
+};
+
+#define AD1884_SPDIF_OUT       0x02
+
+static struct hda_input_mux ad1884_capture_source = {
+       .num_items = 4,
+       .items = {
+               { "Front Mic", 0x0 },
+               { "Mic", 0x1 },
+               { "CD", 0x2 },
+               { "Mix", 0x3 },
+       },
+};
+
+static struct snd_kcontrol_new ad1884_base_mixers[] = {
+       HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
+       /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
+       /*
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
+       HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
+       */
+       HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
+       {
+               .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",
+               .count = 2,
+               .info = ad198x_mux_enum_info,
+               .get = ad198x_mux_enum_get,
+               .put = ad198x_mux_enum_put,
+       },
+       /* SPDIF controls */
+       HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
+               /* identical with ad1983 */
+               .info = ad1983_spdif_route_info,
+               .get = ad1983_spdif_route_get,
+               .put = ad1983_spdif_route_put,
+       },
+       { } /* end */
+};
+
+static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
+       HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
+                            HDA_OUTPUT),
+       HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
+                          HDA_OUTPUT),
+       { } /* end */
+};
+
+/*
+ * initialization verbs
+ */
+static struct hda_verb ad1884_init_verbs[] = {
+       /* DACs; mute as default */
+       {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Port-A (HP) mixer */
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       /* Port-A pin */
+       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* HP selector - select DAC2 */
+       {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
+       /* Port-D (Line-out) mixer */
+       {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       /* Port-D pin */
+       {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Mono-out mixer */
+       {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       /* Mono-out pin */
+       {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Mono selector */
+       {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
+       /* Port-B (front mic) pin */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Port-C (rear mic) pin */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Analog mixer; mute as default */
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       /* Analog Mix output amp */
+       {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
+       /* SPDIF output selector */
+       {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
+       { } /* end */
+};
+
+static int patch_ad1884(struct hda_codec *codec)
+{
+       struct ad198x_spec *spec;
+
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       mutex_init(&spec->amp_mutex);
+       codec->spec = spec;
+
+       spec->multiout.max_channels = 2;
+       spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
+       spec->multiout.dac_nids = ad1884_dac_nids;
+       spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
+       spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
+       spec->adc_nids = ad1884_adc_nids;
+       spec->capsrc_nids = ad1884_capsrc_nids;
+       spec->input_mux = &ad1884_capture_source;
+       spec->num_mixers = 1;
+       spec->mixers[0] = ad1884_base_mixers;
+       spec->num_init_verbs = 1;
+       spec->init_verbs[0] = ad1884_init_verbs;
+       spec->spdif_route = 0;
+
+       codec->patch_ops = ad198x_patch_ops;
+
+       return 0;
+}
+
+/*
+ * Lenovo Thinkpad T61/X61
+ */
+static struct hda_input_mux ad1984_thinkpad_capture_source = {
+       .num_items = 4,
+       .items = {
+               { "Mic", 0x0 },
+               { "Internal Mic", 0x1 },
+               { "Mix", 0x3 },
+       },
+};
+
+static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
+       HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
+       /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
+       HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
+       {
+               .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",
+               .count = 2,
+               .info = ad198x_mux_enum_info,
+               .get = ad198x_mux_enum_get,
+               .put = ad198x_mux_enum_put,
+       },
+       { } /* end */
+};
+
+/* additional verbs */
+static struct hda_verb ad1984_thinkpad_init_verbs[] = {
+       /* Port-E (docking station mic) pin */
+       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* docking mic boost */
+       {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Analog mixer - docking mic; mute as default */
+       {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       { } /* end */
+};
+
+/* Digial MIC ADC NID 0x05 + 0x06 */
+static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
+                                  struct hda_codec *codec,
+                                  unsigned int stream_tag,
+                                  unsigned int format,
+                                  struct snd_pcm_substream *substream)
+{
+       snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
+                                  stream_tag, 0, format);
+       return 0;
+}
+
+static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
+                                  struct hda_codec *codec,
+                                  struct snd_pcm_substream *substream)
+{
+       snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
+                                  0, 0, 0);
+       return 0;
+}
+
+static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
+       .substreams = 2,
+       .channels_min = 2,
+       .channels_max = 2,
+       .nid = 0x05,
+       .ops = {
+               .prepare = ad1984_pcm_dmic_prepare,
+               .cleanup = ad1984_pcm_dmic_cleanup
+       },
+};
+
+static int ad1984_build_pcms(struct hda_codec *codec)
+{
+       struct ad198x_spec *spec = codec->spec;
+       struct hda_pcm *info;
+       int err;
+
+       err = ad198x_build_pcms(codec);
+       if (err < 0)
+               return err;
+
+       info = spec->pcm_rec + codec->num_pcms;
+       codec->num_pcms++;
+       info->name = "AD1984 Digital Mic";
+       info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
+       return 0;
+}
+
+/* models */
+enum {
+       AD1984_BASIC,
+       AD1984_THINKPAD,
+       AD1984_MODELS
+};
+
+static const char *ad1984_models[AD1984_MODELS] = {
+       [AD1984_BASIC]          = "basic",
+       [AD1984_THINKPAD]       = "thinkpad",
+};
+
+static struct snd_pci_quirk ad1984_cfg_tbl[] = {
+       /* Lenovo Thinkpad T61/X61 */
+       SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
+       {}
+};
+
+static int patch_ad1984(struct hda_codec *codec)
+{
+       struct ad198x_spec *spec;
+       int board_config, err;
+
+       err = patch_ad1884(codec);
+       if (err < 0)
+               return err;
+       spec = codec->spec;
+       board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
+                                                 ad1984_models, ad1984_cfg_tbl);
+       switch (board_config) {
+       case AD1984_BASIC:
+               /* additional digital mics */
+               spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
+               codec->patch_ops.build_pcms = ad1984_build_pcms;
+               break;
+       case AD1984_THINKPAD:
+               spec->multiout.dig_out_nid = 0;
+               spec->input_mux = &ad1984_thinkpad_capture_source;
+               spec->mixers[0] = ad1984_thinkpad_mixers;
+               spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
+               break;
+       }
+       return 0;
+}
+
+
 /*
  * patch entries
  */
 struct hda_codec_preset snd_hda_preset_analog[] = {
+       { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
        { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
        { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
+       { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
        { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
        { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
        { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },