Skip to content

Commit

Permalink
ALSA: hda - Add multiple headphone support to ALC262 codec
Browse files Browse the repository at this point in the history
This patch changes the alc262 auto-parser to allow multiple pins
assigned for a single purpose (line-out, headphone or speaker).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Sep 8, 2010
1 parent bb35feb commit 033688a
Showing 1 changed file with 42 additions and 29 deletions.
71 changes: 42 additions & 29 deletions sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -11824,7 +11824,7 @@ static int alc262_check_volbit(hda_nid_t nid)
}

static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
const char *pfx, int *vbits)
const char *pfx, int *vbits, int idx)
{
unsigned long val;
int vbit;
Expand All @@ -11839,11 +11839,11 @@ static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
else
val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
}

static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
const char *pfx)
const char *pfx, int idx)
{
unsigned long val;

Expand All @@ -11853,7 +11853,7 @@ static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
else
val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
}

/* add playback controls from the parsed DAC table */
Expand All @@ -11862,7 +11862,7 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
{
const char *pfx;
int vbits;
int err;
int i, err;

spec->multiout.num_dacs = 1; /* only use one dac */
spec->multiout.dac_nids = spec->private_dac_nids;
Expand All @@ -11872,39 +11872,52 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
pfx = "Master";
else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
pfx = "Speaker";
else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
pfx = "Headphone";
else
pfx = "Front";
err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
if (err < 0)
return err;
err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
if (err < 0)
return err;
err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
if (err < 0)
return err;
for (i = 0; i < 2; i++) {
err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
if (err < 0)
return err;
if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
"Speaker", i);
if (err < 0)
return err;
}
if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
"Headphone", i);
if (err < 0)
return err;
}
}

vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
alc262_check_volbit(cfg->speaker_pins[0]) |
alc262_check_volbit(cfg->hp_pins[0]);
if (vbits == 1 || vbits == 2)
pfx = "Master"; /* only one mixer is used */
else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
pfx = "Speaker";
else
pfx = "Front";
vbits = 0;
err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
if (err < 0)
return err;
err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
&vbits);
if (err < 0)
return err;
err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
&vbits);
if (err < 0)
return err;
for (i = 0; i < 2; i++) {
err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
&vbits, i);
if (err < 0)
return err;
if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
"Speaker", &vbits, i);
if (err < 0)
return err;
}
if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
"Headphone", &vbits, i);
if (err < 0)
return err;
}
}
return 0;
}

Expand Down

0 comments on commit 033688a

Please sign in to comment.