Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284162
b: refs/heads/master
c: 24de183
h: refs/heads/master
v: v3
  • Loading branch information
Takashi Iwai committed Nov 8, 2011
1 parent 3770e2f commit 4f08e65
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 82e14a4754599952f5504c1f696bbc77bdfd6009
refs/heads/master: 24de183ed0369d73af89e6752fcc1ecbde59053d
65 changes: 64 additions & 1 deletion trunk/sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ struct alc_spec {
unsigned int single_input_src:1;
unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */

/* auto-mute control */
int automute_mode;
Expand Down Expand Up @@ -277,6 +278,8 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
return false;
}

static void call_update_outputs(struct hda_codec *codec);

/* select the given imux item; either unmute exclusively or select the route */
static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
unsigned int idx, bool force)
Expand All @@ -298,6 +301,19 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
return 0;
spec->cur_mux[adc_idx] = idx;

/* for shared I/O, change the pin-control accordingly */
if (spec->shared_mic_hp) {
/* NOTE: this assumes that there are only two inputs, the
* first is the real internal mic and the second is HP jack.
*/
snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL,
spec->cur_mux[adc_idx] ?
PIN_VREF80 : PIN_HP);
spec->automute_speaker = !spec->cur_mux[adc_idx];
call_update_outputs(codec);
}

if (spec->dyn_adc_switch) {
alc_dyn_adc_pcm_resetup(codec, idx);
adc_idx = spec->dyn_adc_idx[idx];
Expand Down Expand Up @@ -547,7 +563,8 @@ static void update_outputs(struct hda_codec *codec)
* in general, HP pins/amps control should be enabled in all cases,
* but currently set only for master_mute, just to be safe
*/
do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */
do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
spec->autocfg.hp_pins, spec->master_mute, true);

if (!spec->automute_speaker)
Expand Down Expand Up @@ -1115,6 +1132,9 @@ static void alc_init_auto_mic(struct hda_codec *codec)
hda_nid_t fixed, ext, dock;
int i;

if (spec->shared_mic_hp)
return; /* no auto-mic for the shared I/O */

spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;

fixed = ext = dock = 0;
Expand Down Expand Up @@ -2667,6 +2687,9 @@ static int alc_auto_fill_adc_caps(struct hda_codec *codec)
int max_nums = ARRAY_SIZE(spec->private_adc_nids);
int i, nums = 0;

if (spec->shared_mic_hp)
max_nums = 1; /* no multi streams with the shared HP/mic */

nid = codec->start_nid;
for (i = 0; i < codec->num_nodes; i++, nid++) {
hda_nid_t src;
Expand Down Expand Up @@ -2729,6 +2752,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
continue;

label = hda_get_autocfg_input_label(codec, cfg, i);
if (spec->shared_mic_hp && !strcmp(label, "Misc"))
label = "Headphone Mic";
if (prev_label && !strcmp(label, prev_label))
type_idx++;
else
Expand Down Expand Up @@ -2764,6 +2789,39 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
return 0;
}

/* create a shared input with the headphone out */
static int alc_auto_create_shared_input(struct hda_codec *codec)
{
struct alc_spec *spec = codec->spec;
struct auto_pin_cfg *cfg = &spec->autocfg;
unsigned int defcfg;
hda_nid_t nid;

/* only one internal input pin? */
if (cfg->num_inputs != 1)
return 0;
defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin);
if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
return 0;

if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */
else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT)
nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */
else
return 0; /* both not available */

if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
return 0; /* no input */

cfg->inputs[1].pin = nid;
cfg->inputs[1].type = AUTO_PIN_MIC;
cfg->num_inputs = 2;
spec->shared_mic_hp = 1;
snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid);
return 0;
}

static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
unsigned int pin_type)
{
Expand Down Expand Up @@ -3654,6 +3712,8 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
char boost_label[32];

label = hda_get_autocfg_input_label(codec, cfg, i);
if (spec->shared_mic_hp && !strcmp(label, "Misc"))
label = "Headphone Mic";
if (prev_label && !strcmp(label, prev_label))
type_idx++;
else
Expand Down Expand Up @@ -3857,6 +3917,9 @@ static int alc_parse_auto_config(struct hda_codec *codec,
if (err < 0)
return err;
err = alc_auto_create_speaker_out(codec);
if (err < 0)
return err;
err = alc_auto_create_shared_input(codec);
if (err < 0)
return err;
err = alc_auto_create_input_ctls(codec);
Expand Down

0 comments on commit 4f08e65

Please sign in to comment.