]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/hda/patch_realtek.c
ocfs2: Implementation of local and global quota file handling
[linux-2.6-omap-h63xx.git] / sound / pci / hda / patch_realtek.c
index 6ec56c62cb18421d653f33760faca45e5c0f5e80..0bd4e6bf354d42b7f74284b855d16ba41b78d3ef 100644 (file)
@@ -30,7 +30,6 @@
 #include <sound/core.h>
 #include "hda_codec.h"
 #include "hda_local.h"
-#include "hda_patch.h"
 
 #define ALC880_FRONT_EVENT             0x01
 #define ALC880_DCVOL_EVENT             0x02
@@ -230,6 +229,7 @@ enum {
        ALC883_MITAC,
        ALC883_CLEVO_M720,
        ALC883_FUJITSU_PI2515,
+       ALC888_FUJITSU_XA3530,
        ALC883_3ST_6ch_INTEL,
        ALC888_ASUS_M90V,
        ALC888_ASUS_EEE1601,
@@ -765,6 +765,27 @@ static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
        spec->init_verbs[spec->num_init_verbs++] = verb;
 }
 
+#ifdef CONFIG_PROC_FS
+/*
+ * hook for proc
+ */
+static void print_realtek_coef(struct snd_info_buffer *buffer,
+                              struct hda_codec *codec, hda_nid_t nid)
+{
+       int coeff;
+
+       if (nid != 0x20)
+               return;
+       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);
+}
+#else
+#define print_realtek_coef     NULL
+#endif
+
 /*
  * set up from the preset table
  */
@@ -1155,6 +1176,141 @@ static void alc_fix_pincfg(struct hda_codec *codec,
        }
 }
 
+/*
+ * ALC888
+ */
+
+/*
+ * 2ch mode
+ */
+static struct hda_verb alc888_4ST_ch2_intel_init[] = {
+/* Mic-in jack as mic in */
+       { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
+       { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
+/* Line-in jack as Line in */
+       { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
+       { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
+/* Line-Out as Front */
+       { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
+       { } /* end */
+};
+
+/*
+ * 4ch mode
+ */
+static struct hda_verb alc888_4ST_ch4_intel_init[] = {
+/* Mic-in jack as mic in */
+       { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
+       { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
+/* Line-in jack as Surround */
+       { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+/* Line-Out as Front */
+       { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
+       { } /* end */
+};
+
+/*
+ * 6ch mode
+ */
+static struct hda_verb alc888_4ST_ch6_intel_init[] = {
+/* Mic-in jack as CLFE */
+       { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+/* Line-in jack as Surround */
+       { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
+       { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
+       { } /* end */
+};
+
+/*
+ * 8ch mode
+ */
+static struct hda_verb alc888_4ST_ch8_intel_init[] = {
+/* Mic-in jack as CLFE */
+       { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+/* Line-in jack as Surround */
+       { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
+       { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
+/* Line-Out as Side */
+       { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
+       { } /* end */
+};
+
+static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
+       { 2, alc888_4ST_ch2_intel_init },
+       { 4, alc888_4ST_ch4_intel_init },
+       { 6, alc888_4ST_ch6_intel_init },
+       { 8, alc888_4ST_ch8_intel_init },
+};
+
+/*
+ * ALC888 Fujitsu Siemens Amillo xa3530
+ */
+
+static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
+/* Front Mic: set to PIN_IN (empty by default) */
+       {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+/* Connect Internal HP to Front */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
+/* Connect Bass HP to Front */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+/* Connect Line-Out side jack (SPDIF) to Side */
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
+/* Connect Mic jack to CLFE */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
+/* Connect Line-in jack to Surround */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
+/* Connect HP out jack to Front */
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+/* Enable unsolicited event for HP jack and Line-out jack */
+       {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+       {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+       {}
+};
+
+static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+       unsigned int bits;
+       /* Line out presence */
+       present = snd_hda_codec_read(codec, 0x17, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       /* HP out presence */
+       present = present || snd_hda_codec_read(codec, 0x1b, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       bits = present ? HDA_AMP_MUTE : 0;
+       /* Toggle internal speakers muting */
+       snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
+                                HDA_AMP_MUTE, bits);
+       /* Toggle internal bass muting */
+       snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
+                                HDA_AMP_MUTE, bits);
+}
+
+static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
+               unsigned int res)
+{
+       if (res >> 26 == ALC880_HP_EVENT)
+               alc888_fujitsu_xa3530_automute(codec);
+}
+
+
 /*
  * ALC888 Acer Aspire 4930G model
  */
@@ -1164,7 +1320,7 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
 /* Unselect Front Mic by default in input mixer 3 */
        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
-/* enable unsolicited event fpr HP jack */
+/* Enable unsolicited event for HP jack */
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
 /* Connect Internal HP to front */
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
@@ -1177,7 +1333,7 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
        { }
 };
 
-static struct hda_input_mux alc888_acer_aspire_4930g_capture_source[2] = {
+static struct hda_input_mux alc888_2_capture_sources[2] = {
        /* Front mic only available on one ADC */
        {
                .num_items = 4,
@@ -1198,7 +1354,7 @@ static struct hda_input_mux alc888_acer_aspire_4930g_capture_source[2] = {
        }
 };
 
-static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
+static struct snd_kcontrol_new alc888_base_mixer[] = {
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
@@ -1225,11 +1381,12 @@ static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
 {
        unsigned int present;
+       unsigned int bits;
        present = snd_hda_codec_read(codec, 0x15, 0,
                                     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
-       /* Toggle the internal HP PIN (regular muting doesn't work) */
-       snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
-                                       (present ? 0x0 : PIN_OUT));
+       bits = present ? HDA_AMP_MUTE : 0;
+       snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
+                                HDA_AMP_MUTE, bits);
 }
 
 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
@@ -4132,7 +4289,7 @@ static void set_capture_mixer(struct alc_spec *spec)
                alc_capture_mixer2,
                alc_capture_mixer3,
        };
-       if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
+       if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
                spec->cap_mixer = caps[spec->num_adc_nids - 1];
 }
 
@@ -4207,6 +4364,7 @@ static int patch_alc880(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc880_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -5732,6 +5890,7 @@ static int patch_alc260(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc260_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -6937,6 +7096,7 @@ static int patch_alc882(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc882_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -8286,6 +8446,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
        [ALC883_MITAC]          = "mitac",
        [ALC883_CLEVO_M720]     = "clevo-m720",
        [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
+       [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
        [ALC883_3ST_6ch_INTEL]  = "3stack-6ch-intel",
        [ALC1200_ASUS_P5Q]      = "asus-p5q",
        [ALC883_AUTO]           = "auto",
@@ -8335,6 +8496,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
        SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
        SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
        SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
@@ -8346,6 +8508,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
        SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
        SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
+       SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
+               ALC888_FUJITSU_XA3530),
        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
        SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
        SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
@@ -8472,7 +8636,7 @@ static struct alc_config_preset alc883_presets[] = {
                .init_hook = alc883_acer_aspire_automute,
        },
        [ALC888_ACER_ASPIRE_4930G] = {
-               .mixers = { alc888_acer_aspire_4930g_mixer,
+               .mixers = { alc888_base_mixer,
                                alc883_chmode_mixer },
                .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
                                alc888_acer_aspire_4930g_verbs },
@@ -8486,8 +8650,8 @@ static struct alc_config_preset alc883_presets[] = {
                .channel_mode = alc883_3ST_6ch_modes,
                .need_dac_fix = 1,
                .num_mux_defs =
-                       ARRAY_SIZE(alc888_acer_aspire_4930g_capture_source),
-               .input_mux = alc888_acer_aspire_4930g_capture_source,
+                       ARRAY_SIZE(alc888_2_capture_sources),
+               .input_mux = alc888_2_capture_sources,
                .unsol_event = alc888_acer_aspire_4930g_unsol_event,
                .init_hook = alc888_acer_aspire_4930g_automute,
        },
@@ -8634,6 +8798,24 @@ static struct alc_config_preset alc883_presets[] = {
                .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
                .init_hook = alc883_2ch_fujitsu_pi2515_automute,
        },
+       [ALC888_FUJITSU_XA3530] = {
+               .mixers = { alc888_base_mixer, alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs,
+                       alc888_fujitsu_xa3530_verbs },
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
+               .adc_nids = alc883_adc_nids_rev,
+               .capsrc_nids = alc883_capsrc_nids_rev,
+               .dig_out_nid = ALC883_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
+               .channel_mode = alc888_4ST_8ch_intel_modes,
+               .num_mux_defs =
+                       ARRAY_SIZE(alc888_2_capture_sources),
+               .input_mux = alc888_2_capture_sources,
+               .unsol_event = alc888_fujitsu_xa3530_unsol_event,
+               .init_hook = alc888_fujitsu_xa3530_automute,
+       },
        [ALC888_LENOVO_SKY] = {
                .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
                .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
@@ -8883,6 +9065,7 @@ static int patch_alc883(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc883_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -10375,6 +10558,8 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
        SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
        SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
        SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
+       SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
+                     ALC262_SONY_ASSAMD),
        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
                      ALC262_TOSHIBA_RX1),
        SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
@@ -10689,6 +10874,7 @@ static int patch_alc262(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc262_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -11754,6 +11940,8 @@ static int patch_alc268(struct hda_codec *codec)
        if (board_config == ALC268_AUTO)
                spec->init_hook = alc268_auto_init;
 
+       codec->proc_widget_hook = print_realtek_coef;
+
        return 0;
 }
 
@@ -12555,6 +12743,7 @@ static int patch_alc269(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc269_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -13643,6 +13832,7 @@ static int patch_alc861(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc861_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -14604,6 +14794,7 @@ static int patch_alc861vd(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc861vd_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -16413,6 +16604,7 @@ static int patch_alc662(struct hda_codec *codec)
        if (!spec->loopback.amplist)
                spec->loopback.amplist = alc662_loopbacks;
 #endif
+       codec->proc_widget_hook = print_realtek_coef;
 
        return 0;
 }
@@ -16420,7 +16612,7 @@ static int patch_alc662(struct hda_codec *codec)
 /*
  * patch entries
  */
-struct hda_codec_preset snd_hda_preset_realtek[] = {
+static struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
        { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
@@ -16452,3 +16644,26 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
        {} /* terminator */
 };
+
+MODULE_ALIAS("snd-hda-codec-id:10ec*");
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Realtek HD-audio codec");
+
+static struct hda_codec_preset_list realtek_list = {
+       .preset = snd_hda_preset_realtek,
+       .owner = THIS_MODULE,
+};
+
+static int __init patch_realtek_init(void)
+{
+       return snd_hda_add_codec_preset(&realtek_list);
+}
+
+static void __exit patch_realtek_exit(void)
+{
+       snd_hda_delete_codec_preset(&realtek_list);
+}
+
+module_init(patch_realtek_init)
+module_exit(patch_realtek_exit)