aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt4
-rw-r--r--sound/pci/hda/patch_analog.c327
2 files changed, 331 insertions, 0 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 9a56b9b273cd..bfc6d486ad99 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -912,6 +912,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
912 3stack 3-stack mode (default) 912 3stack 3-stack mode (default)
913 6stack 6-stack mode 913 6stack 6-stack mode
914 914
915 AD1884A / AD1883 / AD1984A / AD1984B
916 desktop 3-stack desktop (default)
917 laptop laptop with HP jack sensing
918
915 AD1884 919 AD1884
916 N/A 920 N/A
917 921
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 1f2102860fe8..b037fca1b44e 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -3411,6 +3411,329 @@ static int patch_ad1984(struct hda_codec *codec)
3411 3411
3412 3412
3413/* 3413/*
3414 * AD1883 / AD1884A / AD1984A / AD1984B
3415 *
3416 * port-B (0x14) - front mic-in
3417 * port-E (0x1c) - rear mic-in
3418 * port-F (0x16) - CD / ext out
3419 * port-C (0x15) - rear line-in
3420 * port-D (0x12) - rear line-out
3421 * port-A (0x11) - front hp-out
3422 *
3423 * AD1984A = AD1884A + digital-mic
3424 * AD1883 = equivalent with AD1984A
3425 * AD1984B = AD1984A + extra SPDIF-out
3426 *
3427 * FIXME:
3428 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3429 */
3430
3431static hda_nid_t ad1884a_dac_nids[1] = {
3432 0x03,
3433};
3434
3435#define ad1884a_adc_nids ad1884_adc_nids
3436#define ad1884a_capsrc_nids ad1884_capsrc_nids
3437
3438#define AD1884A_SPDIF_OUT 0x02
3439
3440static struct hda_input_mux ad1884a_capture_source = {
3441 .num_items = 5,
3442 .items = {
3443 { "Front Mic", 0x0 },
3444 { "Mic", 0x4 },
3445 { "Line", 0x1 },
3446 { "CD", 0x2 },
3447 { "Mix", 0x3 },
3448 },
3449};
3450
3451static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3452 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3453 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3455 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3456 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3457 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3458 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3459 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3460 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3461 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3462 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
3463 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
3464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3465 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3466 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3467 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3468 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3469 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3470 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3471 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3472 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3473 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3474 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3475 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3476 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3477 {
3478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3479 /* The multiple "Capture Source" controls confuse alsamixer
3480 * So call somewhat different..
3481 */
3482 /* .name = "Capture Source", */
3483 .name = "Input Source",
3484 .count = 2,
3485 .info = ad198x_mux_enum_info,
3486 .get = ad198x_mux_enum_get,
3487 .put = ad198x_mux_enum_put,
3488 },
3489 /* SPDIF controls */
3490 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3491 {
3492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3493 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3494 /* identical with ad1983 */
3495 .info = ad1983_spdif_route_info,
3496 .get = ad1983_spdif_route_get,
3497 .put = ad1983_spdif_route_put,
3498 },
3499 { } /* end */
3500};
3501
3502/*
3503 * initialization verbs
3504 */
3505static struct hda_verb ad1884a_init_verbs[] = {
3506 /* DACs; unmute as default */
3507 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3508 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3509 /* Port-A (HP) mixer - route only from analog mixer */
3510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3512 /* Port-A pin */
3513 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3514 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3515 /* Port-D (Line-out) mixer - route only from analog mixer */
3516 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3517 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3518 /* Port-D pin */
3519 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3520 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3521 /* Mono-out mixer - route only from analog mixer */
3522 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3523 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3524 /* Mono-out pin */
3525 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3526 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3527 /* Port-B (front mic) pin */
3528 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3530 /* Port-C (rear line-in) pin */
3531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3532 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3533 /* Port-E (rear mic) pin */
3534 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3535 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3536 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
3537 /* Port-F (CD) pin */
3538 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3540 /* Analog mixer; mute as default */
3541 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3542 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3543 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3544 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3545 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
3546 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3547 /* Analog Mix output amp */
3548 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3549 /* capture sources */
3550 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
3551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3552 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3554 /* SPDIF output amp */
3555 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3556 { } /* end */
3557};
3558
3559#ifdef CONFIG_SND_HDA_POWER_SAVE
3560static struct hda_amp_list ad1884a_loopbacks[] = {
3561 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3562 { 0x20, HDA_INPUT, 1 }, /* Mic */
3563 { 0x20, HDA_INPUT, 2 }, /* CD */
3564 { 0x20, HDA_INPUT, 4 }, /* Docking */
3565 { } /* end */
3566};
3567#endif
3568
3569/*
3570 * Laptop model
3571 *
3572 * Port A: Headphone jack
3573 * Port B: MIC jack
3574 * Port C: Internal MIC
3575 * Port D: Dock Line Out (if enabled)
3576 * Port E: Dock Line In (if enabled)
3577 * Port F: Internal speakers
3578 */
3579
3580static struct hda_input_mux ad1884a_laptop_capture_source = {
3581 .num_items = 4,
3582 .items = {
3583 { "Mic", 0x0 }, /* port-B */
3584 { "Internal Mic", 0x1 }, /* port-C */
3585 { "Dock Mic", 0x4 }, /* port-E */
3586 { "Mix", 0x3 },
3587 },
3588};
3589
3590static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3591 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3592 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3593 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3594 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3595 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3597 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3598 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3599 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3600 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3601 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3602 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3603 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3604 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3605 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3606 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3607 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3608 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3609 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3610 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3611 {
3612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3613 /* The multiple "Capture Source" controls confuse alsamixer
3614 * So call somewhat different..
3615 */
3616 /* .name = "Capture Source", */
3617 .name = "Input Source",
3618 .count = 2,
3619 .info = ad198x_mux_enum_info,
3620 .get = ad198x_mux_enum_get,
3621 .put = ad198x_mux_enum_put,
3622 },
3623 { } /* end */
3624};
3625
3626/* mute internal speaker if HP is plugged */
3627static void ad1884a_hp_automute(struct hda_codec *codec)
3628{
3629 unsigned int present;
3630
3631 present = snd_hda_codec_read(codec, 0x11, 0,
3632 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
3633 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
3634 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3635 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
3636 present ? 0x00 : 0x02);
3637}
3638
3639#define AD1884A_HP_EVENT 0x37
3640
3641/* unsolicited event for HP jack sensing */
3642static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3643{
3644 if ((res >> 26) != AD1884A_HP_EVENT)
3645 return;
3646 ad1884a_hp_automute(codec);
3647}
3648
3649/* initialize jack-sensing, too */
3650static int ad1884a_hp_init(struct hda_codec *codec)
3651{
3652 ad198x_init(codec);
3653 ad1884a_hp_automute(codec);
3654 return 0;
3655}
3656
3657/* additional verbs for laptop model */
3658static struct hda_verb ad1884a_laptop_verbs[] = {
3659 /* Port-A (HP) pin - always unmuted */
3660 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3661 /* Port-F (int speaker) mixer - route only from analog mixer */
3662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3664 /* Port-F pin */
3665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3667 /* analog mix */
3668 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3669 /* unsolicited event for pin-sense */
3670 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3671 { } /* end */
3672};
3673
3674/*
3675 */
3676
3677enum {
3678 AD1884A_DESKTOP,
3679 AD1884A_LAPTOP,
3680 AD1884A_MODELS
3681};
3682
3683static const char *ad1884a_models[AD1884A_MODELS] = {
3684 [AD1884A_DESKTOP] = "desktop",
3685 [AD1884A_LAPTOP] = "laptop",
3686};
3687
3688static int patch_ad1884a(struct hda_codec *codec)
3689{
3690 struct ad198x_spec *spec;
3691 int board_config;
3692
3693 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3694 if (spec == NULL)
3695 return -ENOMEM;
3696
3697 mutex_init(&spec->amp_mutex);
3698 codec->spec = spec;
3699
3700 spec->multiout.max_channels = 2;
3701 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
3702 spec->multiout.dac_nids = ad1884a_dac_nids;
3703 spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
3704 spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
3705 spec->adc_nids = ad1884a_adc_nids;
3706 spec->capsrc_nids = ad1884a_capsrc_nids;
3707 spec->input_mux = &ad1884a_capture_source;
3708 spec->num_mixers = 1;
3709 spec->mixers[0] = ad1884a_base_mixers;
3710 spec->num_init_verbs = 1;
3711 spec->init_verbs[0] = ad1884a_init_verbs;
3712 spec->spdif_route = 0;
3713#ifdef CONFIG_SND_HDA_POWER_SAVE
3714 spec->loopback.amplist = ad1884a_loopbacks;
3715#endif
3716 codec->patch_ops = ad198x_patch_ops;
3717
3718 /* override some parameters */
3719 board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
3720 ad1884a_models, NULL);
3721 switch (board_config) {
3722 case AD1884A_LAPTOP:
3723 spec->mixers[0] = ad1884a_laptop_mixers;
3724 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3725 spec->multiout.dig_out_nid = 0;
3726 spec->input_mux = &ad1884a_laptop_capture_source;
3727 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3728 codec->patch_ops.init = ad1884a_hp_init;
3729 break;
3730 }
3731
3732 return 0;
3733}
3734
3735
3736/*
3414 * AD1882 3737 * AD1882
3415 * 3738 *
3416 * port-A - front hp-out 3739 * port-A - front hp-out
@@ -3709,8 +4032,12 @@ static int patch_ad1882(struct hda_codec *codec)
3709 * patch entries 4032 * patch entries
3710 */ 4033 */
3711struct hda_codec_preset snd_hda_preset_analog[] = { 4034struct hda_codec_preset snd_hda_preset_analog[] = {
4035 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
3712 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, 4036 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
4037 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
3713 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, 4038 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
4039 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
4040 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
3714 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, 4041 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
3715 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, 4042 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3716 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 }, 4043 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },