ALSA: hda - Use auto model for HP laptops with ALC268 codec
[safe/jmp/linux-2.6] / sound / pci / hda / hda_proc.c
index 64b6a38..95f24e4 100644 (file)
@@ -91,31 +91,21 @@ static void print_amp_vals(struct snd_info_buffer *buffer,
 
 static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
 {
-       static unsigned int rates[] = {
-               8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
-               96000, 176400, 192000, 384000
-       };
-       int i;
+       char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
 
        pcm &= AC_SUPPCM_RATES;
        snd_iprintf(buffer, "    rates [0x%x]:", pcm);
-       for (i = 0; i < ARRAY_SIZE(rates); i++) 
-               if (pcm & (1 << i))
-                       snd_iprintf(buffer, " %d", rates[i]);
-       snd_iprintf(buffer, "\n");
+       snd_print_pcm_rates(pcm, buf, sizeof(buf));
+       snd_iprintf(buffer, "%s\n", buf);
 }
 
 static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
 {
-       static unsigned int bits[] = { 8, 16, 20, 24, 32 };
-       int i;
+       char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
 
-       pcm = (pcm >> 16) & 0xff;
-       snd_iprintf(buffer, "    bits [0x%x]:", pcm);
-       for (i = 0; i < ARRAY_SIZE(bits); i++)
-               if (pcm & (1 << i))
-                       snd_iprintf(buffer, " %d", bits[i]);
-       snd_iprintf(buffer, "\n");
+       snd_iprintf(buffer, "    bits [0x%x]:", (pcm >> 16) & 0xff);
+       snd_print_pcm_bits(pcm, buf, sizeof(buf));
+       snd_iprintf(buffer, "%s\n", buf);
 }
 
 static void print_pcm_formats(struct snd_info_buffer *buffer,
@@ -409,7 +399,10 @@ static void print_conn_list(struct snd_info_buffer *buffer,
 {
        int c, curr = -1;
 
-       if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
+       if (conn_len > 1 &&
+           wid_type != AC_WID_AUD_MIX &&
+           wid_type != AC_WID_VOL_KNB &&
+           wid_type != AC_WID_POWER)
                curr = snd_hda_codec_read(codec, nid, 0,
                                          AC_VERB_GET_CONNECT_SEL, 0);
        snd_iprintf(buffer, "  Connection: %d\n", conn_len);
@@ -424,17 +417,6 @@ static void print_conn_list(struct snd_info_buffer *buffer,
        }
 }
 
-static void print_realtek_coef(struct snd_info_buffer *buffer,
-                              struct hda_codec *codec, hda_nid_t nid)
-{
-       int coeff = snd_hda_codec_read(codec, nid, 0,
-                                      AC_VERB_GET_PROC_COEF, 0);
-       snd_iprintf(buffer, "  Processing Coefficient: 0x%02x\n", coeff);
-       coeff = snd_hda_codec_read(codec, nid, 0,
-                                  AC_VERB_GET_COEF_INDEX, 0);
-       snd_iprintf(buffer, "  Coefficient Index: 0x%02x\n", coeff);
-}
-
 static void print_gpio(struct snd_info_buffer *buffer,
                       struct hda_codec *codec, hda_nid_t nid)
 {
@@ -467,12 +449,13 @@ static void print_gpio(struct snd_info_buffer *buffer,
        for (i = 0; i < max; ++i)
                snd_iprintf(buffer,
                            "  IO[%d]: enable=%d, dir=%d, wake=%d, "
-                           "sticky=%d, data=%d\n", i,
+                           "sticky=%d, data=%d, unsol=%d\n", i,
                            (enable & (1<<i)) ? 1 : 0,
                            (direction & (1<<i)) ? 1 : 0,
                            (wake & (1<<i)) ? 1 : 0,
                            (sticky & (1<<i)) ? 1 : 0,
-                           (data & (1<<i)) ? 1 : 0);
+                           (data & (1<<i)) ? 1 : 0,
+                           (unsol & (1<<i)) ? 1 : 0);
        /* FIXME: add GPO and GPI pin information */
 }
 
@@ -483,11 +466,16 @@ static void print_codec_info(struct snd_info_entry *entry,
        hda_nid_t nid;
        int i, nodes;
 
-       snd_iprintf(buffer, "Codec: %s\n",
-                   codec->name ? codec->name : "Not Set");
+       snd_iprintf(buffer, "Codec: ");
+       if (codec->vendor_name && codec->chip_name)
+               snd_iprintf(buffer, "%s %s\n",
+                           codec->vendor_name, codec->chip_name);
+       else
+               snd_iprintf(buffer, "Not Set\n");
        snd_iprintf(buffer, "Address: %d\n", codec->addr);
-       snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
-       snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
+       snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id);
+       snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
+       snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
        snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
 
        if (codec->mfg)
@@ -513,22 +501,21 @@ static void print_codec_info(struct snd_info_entry *entry,
        }
 
        print_gpio(buffer, codec, codec->afg);
+       if (codec->proc_widget_hook)
+               codec->proc_widget_hook(buffer, codec, codec->afg);
 
        for (i = 0; i < nodes; i++, nid++) {
                unsigned int wid_caps =
                        snd_hda_param_read(codec, nid,
                                           AC_PAR_AUDIO_WIDGET_CAP);
-               unsigned int wid_type =
-                       (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
+               unsigned int wid_type = get_wcaps_type(wid_caps);
                hda_nid_t conn[HDA_MAX_CONNECTIONS];
                int conn_len = 0;
 
                snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
                            get_wid_type_name(wid_type), wid_caps);
                if (wid_caps & AC_WCAP_STEREO) {
-                       unsigned int chans;
-                       chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13;
-                       chans = ((chans << 1) | 1) + 1;
+                       unsigned int chans = get_wcaps_channels(wid_caps);
                        if (chans == 2)
                                snd_iprintf(buffer, " Stereo");
                        else
@@ -571,8 +558,14 @@ static void print_codec_info(struct snd_info_entry *entry,
                        snd_iprintf(buffer, "  Amp-Out caps: ");
                        print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
                        snd_iprintf(buffer, "  Amp-Out vals: ");
-                       print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
-                                      wid_caps & AC_WCAP_STEREO, 1);
+                       if (wid_type == AC_WID_PIN &&
+                           codec->pin_amp_workaround)
+                               print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
+                                              wid_caps & AC_WCAP_STEREO,
+                                              conn_len);
+                       else
+                               print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
+                                              wid_caps & AC_WCAP_STEREO, 1);
                }
 
                switch (wid_type) {
@@ -615,9 +608,8 @@ static void print_codec_info(struct snd_info_entry *entry,
                if (wid_caps & AC_WCAP_PROC_WID)
                        print_proc_caps(buffer, codec, nid);
 
-               /* NID 0x20 == Realtek Define Registers */
-               if (codec->vendor_id == 0x10ec && nid == 0x20)
-                       print_realtek_coef(buffer, codec, nid);
+               if (codec->proc_widget_hook)
+                       codec->proc_widget_hook(buffer, codec, nid);
        }
        snd_hda_power_down(codec);
 }