ALSA: hda - Add prefer_hp_amp flag to hda_gen_spec
authorTakashi Iwai <tiwai@suse.de>
Tue, 15 Jan 2013 17:45:53 +0000 (18:45 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 15 Jan 2013 17:45:53 +0000 (18:45 +0100)
Add a new flag to indicate whether HP amp is turned on as default for
speaker or line-outs, and enable this for ALC260 codec, as many
machines with this codec require the HP amp even for speakers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_generic.h
sound/pci/hda/patch_realtek.c

index 932e6a1..e878a9e 100644 (file)
@@ -1284,6 +1284,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
        struct hda_gen_spec *spec = codec->spec;
        struct auto_pin_cfg *cfg = &spec->autocfg;
        int i, err, badness;
        struct hda_gen_spec *spec = codec->spec;
        struct auto_pin_cfg *cfg = &spec->autocfg;
        int i, err, badness;
+       unsigned int val;
 
        /* set num_dacs once to full for look_for_dac() */
        spec->multiout.num_dacs = cfg->line_outs;
 
        /* set num_dacs once to full for look_for_dac() */
        spec->multiout.num_dacs = cfg->line_outs;
@@ -1421,13 +1422,18 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
                                   spec->speaker_paths);
 
        /* set initial pinctl targets */
                                   spec->speaker_paths);
 
        /* set initial pinctl targets */
-       set_pin_targets(codec, cfg->line_outs, cfg->line_out_pins,
-                       cfg->line_out_type == AUTO_PIN_HP_OUT ? PIN_HP : PIN_OUT);
+       if (spec->prefer_hp_amp || cfg->line_out_type == AUTO_PIN_HP_OUT)
+               val = PIN_HP;
+       else
+               val = PIN_OUT;
+       set_pin_targets(codec, cfg->line_outs, cfg->line_out_pins, val);
        if (cfg->line_out_type != AUTO_PIN_HP_OUT)
                set_pin_targets(codec, cfg->hp_outs, cfg->hp_pins, PIN_HP);
        if (cfg->line_out_type != AUTO_PIN_HP_OUT)
                set_pin_targets(codec, cfg->hp_outs, cfg->hp_pins, PIN_HP);
-       if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
+       if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
+               val = spec->prefer_hp_amp ? PIN_HP : PIN_OUT;
                set_pin_targets(codec, cfg->speaker_outs,
                set_pin_targets(codec, cfg->speaker_outs,
-                               cfg->speaker_pins, PIN_OUT);
+                               cfg->speaker_pins, val);
+       }
 
        return badness;
 }
 
        return badness;
 }
index 1ceaacd..6ba5805 100644 (file)
@@ -190,6 +190,7 @@ struct hda_gen_spec {
        unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */
        unsigned int indep_hp:1; /* independent HP supported */
        unsigned int indep_hp_enabled:1; /* independent HP enabled */
        unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */
        unsigned int indep_hp:1; /* independent HP supported */
        unsigned int indep_hp_enabled:1; /* independent HP enabled */
+       unsigned int prefer_hp_amp:1; /* enable HP amp for speaker if any */
        unsigned int add_stereo_mix_input:1; /* add aamix as a capture src */
        unsigned int add_out_jack_modes:1; /* add output jack mode enum ctls */
 
        unsigned int add_stereo_mix_input:1; /* add aamix as a capture src */
        unsigned int add_out_jack_modes:1; /* add output jack mode enum ctls */
 
index fab31d2..71a8894 100644 (file)
@@ -1506,8 +1506,6 @@ static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
 
        if (action == HDA_FIXUP_ACT_PRE_PROBE)
                spec->gen.add_out_jack_modes = 1;
 
        if (action == HDA_FIXUP_ACT_PRE_PROBE)
                spec->gen.add_out_jack_modes = 1;
-       else if (action == HDA_FIXUP_ACT_PROBE)
-               snd_hda_set_pin_ctl_cache(codec, 0x10, PIN_HP);
 }
 
 static const struct hda_fixup alc260_fixups[] = {
 }
 
 static const struct hda_fixup alc260_fixups[] = {
@@ -1597,6 +1595,11 @@ static int patch_alc260(struct hda_codec *codec)
                return err;
 
        spec = codec->spec;
                return err;
 
        spec = codec->spec;
+       /* as quite a few machines require HP amp for speaker outputs,
+        * it's easier to enable it unconditionally; even if it's unneeded,
+        * it's almost harmless.
+        */
+       spec->gen.prefer_hp_amp = 1;
 
        snd_hda_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
 
        snd_hda_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);