ALSA: hda - Add the pin fixup for HP Envy TS bass speaker
[firefly-linux-kernel-4.4.55.git] / sound / pci / hda / patch_sigmatel.c
index 7f40a150899ca3e12f656acad0f3d1ab1cbbc3e9..946ae4094aa3175996b45bbd6d50855debb00469 100644 (file)
@@ -103,6 +103,7 @@ enum {
        STAC_92HD83XXX_HP,
        STAC_HP_ENVY_BASS,
        STAC_HP_BNB13_EQ,
+       STAC_HP_ENVY_TS_BASS,
        STAC_92HD83XXX_MODELS
 };
 
@@ -121,6 +122,12 @@ enum {
        STAC_92HD71BXX_MODELS
 };
 
+enum {
+       STAC_92HD95_HP_LED,
+       STAC_92HD95_HP_BASS,
+       STAC_92HD95_MODELS
+};
+
 enum {
        STAC_925x_REF,
        STAC_M1,
@@ -1011,7 +1018,7 @@ static int stac_create_spdif_mux_ctls(struct hda_codec *codec)
        for (i = 0; i < num_cons; i++) {
                if (snd_BUG_ON(!labels[i]))
                        return -EINVAL;
-               snd_hda_add_imux_item(&spec->spdif_mux, labels[i], i, NULL);
+               snd_hda_add_imux_item(codec, &spec->spdif_mux, labels[i], i, NULL);
        }
 
        kctl = snd_hda_gen_add_kctl(&spec->gen, NULL, &stac_smux_mixer);
@@ -2662,6 +2669,13 @@ static const struct hda_fixup stac92hd83xxx_fixups[] = {
                .chained = true,
                .chain_id = STAC_92HD83XXX_HP_MIC_LED,
        },
+       [STAC_HP_ENVY_TS_BASS] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x10, 0x92170111 },
+                       {}
+               },
+       },
 };
 
 static const struct hda_model_fixup stac92hd83xxx_models[] = {
@@ -2678,6 +2692,7 @@ static const struct hda_model_fixup stac92hd83xxx_models[] = {
        { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" },
        { .id = STAC_HP_ENVY_BASS, .name = "hp-envy-bass" },
        { .id = STAC_HP_BNB13_EQ, .name = "hp-bnb13-eq" },
+       { .id = STAC_HP_ENVY_TS_BASS, .name = "hp-envy-ts-bass" },
        {}
 };
 
@@ -2733,6 +2748,8 @@ static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
                          "HP bNB13", STAC_HP_BNB13_EQ),
        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x190A,
                          "HP bNB13", STAC_HP_BNB13_EQ),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x190e,
+                         "HP ENVY TS", STAC_HP_ENVY_TS_BASS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1940,
                          "HP bNB13", STAC_HP_BNB13_EQ),
        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1941,
@@ -4128,6 +4145,48 @@ static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
        {} /* terminator */
 };
 
+static void stac92hd95_fixup_hp_led(struct hda_codec *codec,
+                                   const struct hda_fixup *fix, int action)
+{
+       struct sigmatel_spec *spec = codec->spec;
+
+       if (action != HDA_FIXUP_ACT_PRE_PROBE)
+               return;
+
+       if (find_mute_led_cfg(codec, spec->default_polarity))
+               codec_dbg(codec, "mute LED gpio %d polarity %d\n",
+                               spec->gpio_led,
+                               spec->gpio_led_polarity);
+}
+
+static const struct hda_fixup stac92hd95_fixups[] = {
+       [STAC_92HD95_HP_LED] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = stac92hd95_fixup_hp_led,
+       },
+       [STAC_92HD95_HP_BASS] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       {0x1a, 0x795, 0x00}, /* HPF to 100Hz */
+                       {}
+               },
+               .chained = true,
+               .chain_id = STAC_92HD95_HP_LED,
+       },
+};
+
+static const struct snd_pci_quirk stac92hd95_fixup_tbl[] = {
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1911, "HP Spectre 13", STAC_92HD95_HP_BASS),
+       {} /* terminator */
+};
+
+static const struct hda_model_fixup stac92hd95_models[] = {
+       { .id = STAC_92HD95_HP_LED, .name = "hp-led" },
+       { .id = STAC_92HD95_HP_BASS, .name = "hp-bass" },
+       {}
+};
+
+
 static int stac_parse_auto_config(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec = codec->spec;
@@ -4580,10 +4639,16 @@ static int patch_stac92hd95(struct hda_codec *codec)
        spec->gen.beep_nid = 0x19; /* digital beep */
        spec->pwr_nids = stac92hd95_pwr_nids;
        spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids);
-       spec->default_polarity = -1; /* no default cfg */
+       spec->default_polarity = 0;
 
        codec->patch_ops = stac_patch_ops;
 
+       snd_hda_pick_fixup(codec, stac92hd95_models, stac92hd95_fixup_tbl,
+                          stac92hd95_fixups);
+       snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
+
+       stac_setup_gpio(codec);
+
        err = stac_parse_auto_config(codec);
        if (err < 0) {
                stac_free(codec);
@@ -4592,6 +4657,8 @@ static int patch_stac92hd95(struct hda_codec *codec)
 
        codec->proc_widget_hook = stac92hd_proc_hook;
 
+       snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
+
        return 0;
 }