diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-10-02 03:20:00 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-10-02 03:24:14 -0400 |
commit | 0afe5f891501609f31146798fb41784f4adad27c (patch) | |
tree | 55d80e26e3e5eadec543b49448c8bd57485da652 /sound/pci/hda/patch_realtek.c | |
parent | 081a8c450290401ffc75558c65a188d7b72db07d (diff) |
ALSA: hda - Clean up name string creation in patch_realtek.c
Use a common helper to create playback controls.
This gives less chance of typos.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 137 |
1 files changed, 57 insertions, 80 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 7810d3dcad83..a751858811e1 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -4309,6 +4309,20 @@ static int add_control(struct alc_spec *spec, int type, const char *name, | |||
4309 | return 0; | 4309 | return 0; |
4310 | } | 4310 | } |
4311 | 4311 | ||
4312 | static int add_control_with_pfx(struct alc_spec *spec, int type, | ||
4313 | const char *pfx, const char *dir, | ||
4314 | const char *sfx, unsigned long val) | ||
4315 | { | ||
4316 | char name[32]; | ||
4317 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); | ||
4318 | return add_control(spec, type, name, val); | ||
4319 | } | ||
4320 | |||
4321 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ | ||
4322 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val) | ||
4323 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ | ||
4324 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val) | ||
4325 | |||
4312 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | 4326 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) |
4313 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | 4327 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
4314 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | 4328 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
@@ -4362,7 +4376,6 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, | |||
4362 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | 4376 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
4363 | const struct auto_pin_cfg *cfg) | 4377 | const struct auto_pin_cfg *cfg) |
4364 | { | 4378 | { |
4365 | char name[32]; | ||
4366 | static const char *chname[4] = { | 4379 | static const char *chname[4] = { |
4367 | "Front", "Surround", NULL /*CLFE*/, "Side" | 4380 | "Front", "Surround", NULL /*CLFE*/, "Side" |
4368 | }; | 4381 | }; |
@@ -4375,26 +4388,26 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4375 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | 4388 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); |
4376 | if (i == 2) { | 4389 | if (i == 2) { |
4377 | /* Center/LFE */ | 4390 | /* Center/LFE */ |
4378 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 4391 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
4379 | "Center Playback Volume", | 4392 | "Center", |
4380 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | 4393 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
4381 | HDA_OUTPUT)); | 4394 | HDA_OUTPUT)); |
4382 | if (err < 0) | 4395 | if (err < 0) |
4383 | return err; | 4396 | return err; |
4384 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 4397 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
4385 | "LFE Playback Volume", | 4398 | "LFE", |
4386 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | 4399 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
4387 | HDA_OUTPUT)); | 4400 | HDA_OUTPUT)); |
4388 | if (err < 0) | 4401 | if (err < 0) |
4389 | return err; | 4402 | return err; |
4390 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 4403 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
4391 | "Center Playback Switch", | 4404 | "Center", |
4392 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | 4405 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
4393 | HDA_INPUT)); | 4406 | HDA_INPUT)); |
4394 | if (err < 0) | 4407 | if (err < 0) |
4395 | return err; | 4408 | return err; |
4396 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 4409 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
4397 | "LFE Playback Switch", | 4410 | "LFE", |
4398 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | 4411 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
4399 | HDA_INPUT)); | 4412 | HDA_INPUT)); |
4400 | if (err < 0) | 4413 | if (err < 0) |
@@ -4406,14 +4419,12 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4406 | pfx = "Speaker"; | 4419 | pfx = "Speaker"; |
4407 | else | 4420 | else |
4408 | pfx = chname[i]; | 4421 | pfx = chname[i]; |
4409 | sprintf(name, "%s Playback Volume", pfx); | 4422 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
4410 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4411 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 4423 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
4412 | HDA_OUTPUT)); | 4424 | HDA_OUTPUT)); |
4413 | if (err < 0) | 4425 | if (err < 0) |
4414 | return err; | 4426 | return err; |
4415 | sprintf(name, "%s Playback Switch", pfx); | 4427 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
4416 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
4417 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | 4428 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
4418 | HDA_INPUT)); | 4429 | HDA_INPUT)); |
4419 | if (err < 0) | 4430 | if (err < 0) |
@@ -4429,7 +4440,6 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
4429 | { | 4440 | { |
4430 | hda_nid_t nid; | 4441 | hda_nid_t nid; |
4431 | int err; | 4442 | int err; |
4432 | char name[32]; | ||
4433 | 4443 | ||
4434 | if (!pin) | 4444 | if (!pin) |
4435 | return 0; | 4445 | return 0; |
@@ -4443,21 +4453,18 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
4443 | spec->multiout.extra_out_nid[0] = nid; | 4453 | spec->multiout.extra_out_nid[0] = nid; |
4444 | /* control HP volume/switch on the output mixer amp */ | 4454 | /* control HP volume/switch on the output mixer amp */ |
4445 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | 4455 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); |
4446 | sprintf(name, "%s Playback Volume", pfx); | 4456 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
4447 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4448 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 4457 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
4449 | if (err < 0) | 4458 | if (err < 0) |
4450 | return err; | 4459 | return err; |
4451 | sprintf(name, "%s Playback Switch", pfx); | 4460 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
4452 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
4453 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | 4461 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); |
4454 | if (err < 0) | 4462 | if (err < 0) |
4455 | return err; | 4463 | return err; |
4456 | } else if (alc880_is_multi_pin(pin)) { | 4464 | } else if (alc880_is_multi_pin(pin)) { |
4457 | /* set manual connection */ | 4465 | /* set manual connection */ |
4458 | /* we have only a switch on HP-out PIN */ | 4466 | /* we have only a switch on HP-out PIN */ |
4459 | sprintf(name, "%s Playback Switch", pfx); | 4467 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
4460 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
4461 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 4468 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
4462 | if (err < 0) | 4469 | if (err < 0) |
4463 | return err; | 4470 | return err; |
@@ -4470,16 +4477,13 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, | |||
4470 | const char *ctlname, | 4477 | const char *ctlname, |
4471 | int idx, hda_nid_t mix_nid) | 4478 | int idx, hda_nid_t mix_nid) |
4472 | { | 4479 | { |
4473 | char name[32]; | ||
4474 | int err; | 4480 | int err; |
4475 | 4481 | ||
4476 | sprintf(name, "%s Playback Volume", ctlname); | 4482 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, |
4477 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
4478 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 4483 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
4479 | if (err < 0) | 4484 | if (err < 0) |
4480 | return err; | 4485 | return err; |
4481 | sprintf(name, "%s Playback Switch", ctlname); | 4486 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
4482 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
4483 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | 4487 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
4484 | if (err < 0) | 4488 | if (err < 0) |
4485 | return err; | 4489 | return err; |
@@ -5972,7 +5976,6 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, | |||
5972 | { | 5976 | { |
5973 | hda_nid_t nid_vol; | 5977 | hda_nid_t nid_vol; |
5974 | unsigned long vol_val, sw_val; | 5978 | unsigned long vol_val, sw_val; |
5975 | char name[32]; | ||
5976 | int err; | 5979 | int err; |
5977 | 5980 | ||
5978 | if (nid >= 0x0f && nid < 0x11) { | 5981 | if (nid >= 0x0f && nid < 0x11) { |
@@ -5992,14 +5995,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, | |||
5992 | 5995 | ||
5993 | if (!(*vol_bits & (1 << nid_vol))) { | 5996 | if (!(*vol_bits & (1 << nid_vol))) { |
5994 | /* first control for the volume widget */ | 5997 | /* first control for the volume widget */ |
5995 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | 5998 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val); |
5996 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | ||
5997 | if (err < 0) | 5999 | if (err < 0) |
5998 | return err; | 6000 | return err; |
5999 | *vol_bits |= (1 << nid_vol); | 6001 | *vol_bits |= (1 << nid_vol); |
6000 | } | 6002 | } |
6001 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | 6003 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val); |
6002 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); | ||
6003 | if (err < 0) | 6004 | if (err < 0) |
6004 | return err; | 6005 | return err; |
6005 | return 1; | 6006 | return 1; |
@@ -10936,7 +10937,6 @@ static int alc262_check_volbit(hda_nid_t nid) | |||
10936 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | 10937 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, |
10937 | const char *pfx, int *vbits) | 10938 | const char *pfx, int *vbits) |
10938 | { | 10939 | { |
10939 | char name[32]; | ||
10940 | unsigned long val; | 10940 | unsigned long val; |
10941 | int vbit; | 10941 | int vbit; |
10942 | 10942 | ||
@@ -10946,28 +10946,25 @@ static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | |||
10946 | if (*vbits & vbit) /* a volume control for this mixer already there */ | 10946 | if (*vbits & vbit) /* a volume control for this mixer already there */ |
10947 | return 0; | 10947 | return 0; |
10948 | *vbits |= vbit; | 10948 | *vbits |= vbit; |
10949 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | ||
10950 | if (vbit == 2) | 10949 | if (vbit == 2) |
10951 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | 10950 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); |
10952 | else | 10951 | else |
10953 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | 10952 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); |
10954 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, val); | 10953 | return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val); |
10955 | } | 10954 | } |
10956 | 10955 | ||
10957 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | 10956 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, |
10958 | const char *pfx) | 10957 | const char *pfx) |
10959 | { | 10958 | { |
10960 | char name[32]; | ||
10961 | unsigned long val; | 10959 | unsigned long val; |
10962 | 10960 | ||
10963 | if (!nid) | 10961 | if (!nid) |
10964 | return 0; | 10962 | return 0; |
10965 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
10966 | if (nid == 0x16) | 10963 | if (nid == 0x16) |
10967 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | 10964 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); |
10968 | else | 10965 | else |
10969 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | 10966 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
10970 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val); | 10967 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val); |
10971 | } | 10968 | } |
10972 | 10969 | ||
10973 | /* add playback controls from the parsed DAC table */ | 10970 | /* add playback controls from the parsed DAC table */ |
@@ -12305,11 +12302,9 @@ static struct snd_kcontrol_new alc268_test_mixer[] = { | |||
12305 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | 12302 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, |
12306 | const char *ctlname, int idx) | 12303 | const char *ctlname, int idx) |
12307 | { | 12304 | { |
12308 | char name[32]; | ||
12309 | hda_nid_t dac; | 12305 | hda_nid_t dac; |
12310 | int err; | 12306 | int err; |
12311 | 12307 | ||
12312 | sprintf(name, "%s Playback Volume", ctlname); | ||
12313 | switch (nid) { | 12308 | switch (nid) { |
12314 | case 0x14: | 12309 | case 0x14: |
12315 | case 0x16: | 12310 | case 0x16: |
@@ -12323,7 +12318,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12323 | } | 12318 | } |
12324 | if (spec->multiout.dac_nids[0] != dac && | 12319 | if (spec->multiout.dac_nids[0] != dac && |
12325 | spec->multiout.dac_nids[1] != dac) { | 12320 | spec->multiout.dac_nids[1] != dac) { |
12326 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12321 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, |
12327 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, | 12322 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, |
12328 | HDA_OUTPUT)); | 12323 | HDA_OUTPUT)); |
12329 | if (err < 0) | 12324 | if (err < 0) |
@@ -12331,12 +12326,11 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12331 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; | 12326 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
12332 | } | 12327 | } |
12333 | 12328 | ||
12334 | sprintf(name, "%s Playback Switch", ctlname); | ||
12335 | if (nid != 0x16) | 12329 | if (nid != 0x16) |
12336 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12330 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
12337 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | 12331 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); |
12338 | else /* mono */ | 12332 | else /* mono */ |
12339 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12333 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, |
12340 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); | 12334 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); |
12341 | if (err < 0) | 12335 | if (err < 0) |
12342 | return err; | 12336 | return err; |
@@ -12366,8 +12360,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12366 | 12360 | ||
12367 | nid = cfg->speaker_pins[0]; | 12361 | nid = cfg->speaker_pins[0]; |
12368 | if (nid == 0x1d) { | 12362 | if (nid == 0x1d) { |
12369 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 12363 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker", |
12370 | "Speaker Playback Volume", | ||
12371 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | 12364 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
12372 | if (err < 0) | 12365 | if (err < 0) |
12373 | return err; | 12366 | return err; |
@@ -12385,8 +12378,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12385 | 12378 | ||
12386 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | 12379 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; |
12387 | if (nid == 0x16) { | 12380 | if (nid == 0x16) { |
12388 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 12381 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono", |
12389 | "Mono Playback Switch", | ||
12390 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); | 12382 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); |
12391 | if (err < 0) | 12383 | if (err < 0) |
12392 | return err; | 12384 | return err; |
@@ -14235,9 +14227,7 @@ static int alc861_auto_fill_dac_nids(struct hda_codec *codec, | |||
14235 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, | 14227 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, |
14236 | hda_nid_t nid, unsigned int chs) | 14228 | hda_nid_t nid, unsigned int chs) |
14237 | { | 14229 | { |
14238 | char name[32]; | 14230 | return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, |
14239 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
14240 | return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name, | ||
14241 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 14231 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
14242 | } | 14232 | } |
14243 | 14233 | ||
@@ -15360,7 +15350,6 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |||
15360 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | 15350 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, |
15361 | const struct auto_pin_cfg *cfg) | 15351 | const struct auto_pin_cfg *cfg) |
15362 | { | 15352 | { |
15363 | char name[32]; | ||
15364 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | 15353 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; |
15365 | hda_nid_t nid_v, nid_s; | 15354 | hda_nid_t nid_v, nid_s; |
15366 | int i, err; | 15355 | int i, err; |
@@ -15377,26 +15366,26 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15377 | 15366 | ||
15378 | if (i == 2) { | 15367 | if (i == 2) { |
15379 | /* Center/LFE */ | 15368 | /* Center/LFE */ |
15380 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 15369 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
15381 | "Center Playback Volume", | 15370 | "Center", |
15382 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | 15371 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, |
15383 | HDA_OUTPUT)); | 15372 | HDA_OUTPUT)); |
15384 | if (err < 0) | 15373 | if (err < 0) |
15385 | return err; | 15374 | return err; |
15386 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 15375 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, |
15387 | "LFE Playback Volume", | 15376 | "LFE", |
15388 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | 15377 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, |
15389 | HDA_OUTPUT)); | 15378 | HDA_OUTPUT)); |
15390 | if (err < 0) | 15379 | if (err < 0) |
15391 | return err; | 15380 | return err; |
15392 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 15381 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
15393 | "Center Playback Switch", | 15382 | "Center", |
15394 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | 15383 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, |
15395 | HDA_INPUT)); | 15384 | HDA_INPUT)); |
15396 | if (err < 0) | 15385 | if (err < 0) |
15397 | return err; | 15386 | return err; |
15398 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 15387 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, |
15399 | "LFE Playback Switch", | 15388 | "LFE", |
15400 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | 15389 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, |
15401 | HDA_INPUT)); | 15390 | HDA_INPUT)); |
15402 | if (err < 0) | 15391 | if (err < 0) |
@@ -15411,8 +15400,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15411 | pfx = "PCM"; | 15400 | pfx = "PCM"; |
15412 | } else | 15401 | } else |
15413 | pfx = chname[i]; | 15402 | pfx = chname[i]; |
15414 | sprintf(name, "%s Playback Volume", pfx); | 15403 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
15415 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
15416 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | 15404 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, |
15417 | HDA_OUTPUT)); | 15405 | HDA_OUTPUT)); |
15418 | if (err < 0) | 15406 | if (err < 0) |
@@ -15420,8 +15408,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15420 | if (cfg->line_outs == 1 && | 15408 | if (cfg->line_outs == 1 && |
15421 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | 15409 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
15422 | pfx = "Speaker"; | 15410 | pfx = "Speaker"; |
15423 | sprintf(name, "%s Playback Switch", pfx); | 15411 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
15424 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
15425 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, | 15412 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
15426 | HDA_INPUT)); | 15413 | HDA_INPUT)); |
15427 | if (err < 0) | 15414 | if (err < 0) |
@@ -15439,7 +15426,6 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |||
15439 | { | 15426 | { |
15440 | hda_nid_t nid_v, nid_s; | 15427 | hda_nid_t nid_v, nid_s; |
15441 | int err; | 15428 | int err; |
15442 | char name[32]; | ||
15443 | 15429 | ||
15444 | if (!pin) | 15430 | if (!pin) |
15445 | return 0; | 15431 | return 0; |
@@ -15457,21 +15443,18 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |||
15457 | nid_s = alc861vd_idx_to_mixer_switch( | 15443 | nid_s = alc861vd_idx_to_mixer_switch( |
15458 | alc880_fixed_pin_idx(pin)); | 15444 | alc880_fixed_pin_idx(pin)); |
15459 | 15445 | ||
15460 | sprintf(name, "%s Playback Volume", pfx); | 15446 | err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
15461 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
15462 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | 15447 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); |
15463 | if (err < 0) | 15448 | if (err < 0) |
15464 | return err; | 15449 | return err; |
15465 | sprintf(name, "%s Playback Switch", pfx); | 15450 | err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx, |
15466 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
15467 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | 15451 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); |
15468 | if (err < 0) | 15452 | if (err < 0) |
15469 | return err; | 15453 | return err; |
15470 | } else if (alc880_is_multi_pin(pin)) { | 15454 | } else if (alc880_is_multi_pin(pin)) { |
15471 | /* set manual connection */ | 15455 | /* set manual connection */ |
15472 | /* we have only a switch on HP-out PIN */ | 15456 | /* we have only a switch on HP-out PIN */ |
15473 | sprintf(name, "%s Playback Switch", pfx); | 15457 | err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
15474 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
15475 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 15458 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
15476 | if (err < 0) | 15459 | if (err < 0) |
15477 | return err; | 15460 | return err; |
@@ -17213,21 +17196,17 @@ static int alc662_auto_fill_dac_nids(struct hda_codec *codec, | |||
17213 | return 0; | 17196 | return 0; |
17214 | } | 17197 | } |
17215 | 17198 | ||
17216 | static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, | 17199 | static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx, |
17217 | hda_nid_t nid, unsigned int chs) | 17200 | hda_nid_t nid, unsigned int chs) |
17218 | { | 17201 | { |
17219 | char name[32]; | 17202 | return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, |
17220 | sprintf(name, "%s Playback Volume", pfx); | ||
17221 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
17222 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 17203 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
17223 | } | 17204 | } |
17224 | 17205 | ||
17225 | static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, | 17206 | static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx, |
17226 | hda_nid_t nid, unsigned int chs) | 17207 | hda_nid_t nid, unsigned int chs) |
17227 | { | 17208 | { |
17228 | char name[32]; | 17209 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
17229 | sprintf(name, "%s Playback Switch", pfx); | ||
17230 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
17231 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); | 17210 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT)); |
17232 | } | 17211 | } |
17233 | 17212 | ||
@@ -17305,13 +17284,11 @@ static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, | |||
17305 | return 0; | 17284 | return 0; |
17306 | nid = alc662_look_for_dac(codec, pin); | 17285 | nid = alc662_look_for_dac(codec, pin); |
17307 | if (!nid) { | 17286 | if (!nid) { |
17308 | char name[32]; | ||
17309 | /* the corresponding DAC is already occupied */ | 17287 | /* the corresponding DAC is already occupied */ |
17310 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) | 17288 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
17311 | return 0; /* no way */ | 17289 | return 0; /* no way */ |
17312 | /* create a switch only */ | 17290 | /* create a switch only */ |
17313 | sprintf(name, "%s Playback Switch", pfx); | 17291 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
17314 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
17315 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | 17292 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
17316 | } | 17293 | } |
17317 | 17294 | ||