aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin P. Mattock <justinmattock@gmail.com>2009-12-07 18:07:46 -0500
committerTakashi Iwai <tiwai@suse.de>2009-12-08 06:31:44 -0500
commit4b7e180335d23296170a5fa8c1f074722f94b253 (patch)
tree833e1a4f5f8357fbb192bda47c2960c651260d68
parentac2c92e0cd06387ecee8115f5fa385fba6413c42 (diff)
ALSA: hda - iMac 9,1 sound patch.
This is an updated patch for the Apple iMac 9,1 model to add sound. Original patch posted here: http://article.gmane.org/gmane.linux.alsa.devel/61361/match= I have been using this patch for a while now and have to say it works vary well, except for a few minor things: With the iMac 24-inch 3.06GHz Intel Core 2 Duo everything seems to be working as it should, although I have not looked into the microphone (never really use one, nor have any apps to test, my guess is it doesn't work, or I never figured out how to get it to work). With the iMac 24-inch 2.66GHz Intel Core 2 Duo everything is the same as with the above machine except I'm hearing a light scratchy/distortion noise come out of the speakers when using headphones(above machine does not do this). Other than that the sound level is great(especially with good Dj headphones). Signed-off-by: Justin P. Mattock <justinmattock@gmail.com> Tested-by: Justin P. Mattock <justinmattock@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--Documentation/sound/alsa/HD-Audio-Models.txt1
-rw-r--r--sound/pci/hda/patch_realtek.c111
2 files changed, 112 insertions, 0 deletions
diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt
index 9000cd84d076..e93affff3af8 100644
--- a/Documentation/sound/alsa/HD-Audio-Models.txt
+++ b/Documentation/sound/alsa/HD-Audio-Models.txt
@@ -126,6 +126,7 @@ ALC882/883/885/888/889
126 mb5 Macbook 5,1 126 mb5 Macbook 5,1
127 mbp3 Macbook Pro rev3 127 mbp3 Macbook Pro rev3
128 imac24 iMac 24'' with jack detection 128 imac24 iMac 24'' with jack detection
129 imac91 iMac 9,1
129 w2jc ASUS W2JC 130 w2jc ASUS W2JC
130 3stack-2ch-dig 3-jack with SPDIF I/O (ALC883) 131 3stack-2ch-dig 3-jack with SPDIF I/O (ALC883)
131 alc883-6stack-dig 6-jack digital with SPDIF I/O (ALC883) 132 alc883-6stack-dig 6-jack digital with SPDIF I/O (ALC883)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d967836f36bb..d0d14ed7ce81 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -208,6 +208,7 @@ enum {
208 ALC885_MBP3, 208 ALC885_MBP3,
209 ALC885_MB5, 209 ALC885_MB5,
210 ALC885_IMAC24, 210 ALC885_IMAC24,
211 ALC885_IMAC91,
211 ALC883_3ST_2ch_DIG, 212 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG, 213 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch, 214 ALC883_3ST_6ch,
@@ -7050,6 +7051,20 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = {
7050 { } /* end */ 7051 { } /* end */
7051}; 7052};
7052 7053
7054static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7055 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7056 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7057 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7058 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7062 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7064 { } /* end */
7065};
7066
7067
7053static struct snd_kcontrol_new alc882_w2jc_mixer[] = { 7068static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7054 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7069 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7055 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7070 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -7505,6 +7520,66 @@ static struct hda_verb alc885_mbp3_init_verbs[] = {
7505 { } 7520 { }
7506}; 7521};
7507 7522
7523/* iMac 9,1 */
7524static struct hda_verb alc885_imac91_init_verbs[] = {
7525 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7529 /* Rear mixer */
7530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7532 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7533 /* HP Pin: output 0 (0x0c) */
7534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7535 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7536 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7537 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7538 /* Internal Speakers: output 0 (0x0d) */
7539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7541 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7542 /* Mic (rear) pin: input vref at 80% */
7543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7545 /* Front Mic pin: input vref at 80% */
7546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7548 /* Line In pin: use output 1 when in LineOut mode */
7549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7551 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7552
7553 /* FIXME: use matrix-type input source selection */
7554 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7555 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7560 /* Input mixer2 */
7561 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7565 /* Input mixer3 */
7566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7570 /* ADC1: mute amp left and right */
7571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7573 /* ADC2: mute amp left and right */
7574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7575 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7576 /* ADC3: mute amp left and right */
7577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7578 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7579
7580 { }
7581};
7582
7508/* iMac 24 mixer. */ 7583/* iMac 24 mixer. */
7509static struct snd_kcontrol_new alc885_imac24_mixer[] = { 7584static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7510 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 7585 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
@@ -7551,6 +7626,26 @@ static void alc885_mbp3_setup(struct hda_codec *codec)
7551 spec->autocfg.speaker_pins[0] = 0x14; 7626 spec->autocfg.speaker_pins[0] = 0x14;
7552} 7627}
7553 7628
7629static void alc885_imac91_automute(struct hda_codec *codec)
7630{
7631 unsigned int present;
7632
7633 present = snd_hda_codec_read(codec, 0x14, 0,
7634 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7635 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7636 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7637 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
7638 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7639
7640}
7641
7642static void alc885_imac91_unsol_event(struct hda_codec *codec,
7643 unsigned int res)
7644{
7645 /* Headphone insertion or removal. */
7646 if ((res >> 26) == ALC880_HP_EVENT)
7647 alc885_imac91_automute(codec);
7648}
7554 7649
7555static struct hda_verb alc882_targa_verbs[] = { 7650static struct hda_verb alc882_targa_verbs[] = {
7556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -8718,6 +8813,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
8718 [ALC885_MB5] = "mb5", 8813 [ALC885_MB5] = "mb5",
8719 [ALC885_MBP3] = "mbp3", 8814 [ALC885_MBP3] = "mbp3",
8720 [ALC885_IMAC24] = "imac24", 8815 [ALC885_IMAC24] = "imac24",
8816 [ALC885_IMAC91] = "imac91",
8721 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig", 8817 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
8722 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", 8818 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8723 [ALC883_3ST_6ch] = "3stack-6ch", 8819 [ALC883_3ST_6ch] = "3stack-6ch",
@@ -8891,6 +8987,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8891 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), 8987 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8892 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), 8988 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8893 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), 8989 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8990 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
8894 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), 8991 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8895 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2, 8992 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
8896 * so apparently no perfect solution yet 8993 * so apparently no perfect solution yet
@@ -9002,6 +9099,20 @@ static struct alc_config_preset alc882_presets[] = {
9002 .setup = alc885_imac24_setup, 9099 .setup = alc885_imac24_setup,
9003 .init_hook = alc885_imac24_init_hook, 9100 .init_hook = alc885_imac24_init_hook,
9004 }, 9101 },
9102 [ALC885_IMAC91] = {
9103 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9104 .init_verbs = { alc885_imac91_init_verbs,
9105 alc880_gpio1_init_verbs },
9106 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9107 .dac_nids = alc882_dac_nids,
9108 .channel_mode = alc885_mbp_4ch_modes,
9109 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9110 .input_mux = &alc882_capture_source,
9111 .dig_out_nid = ALC882_DIGOUT_NID,
9112 .dig_in_nid = ALC882_DIGIN_NID,
9113 .unsol_event = alc885_imac91_unsol_event,
9114 .init_hook = alc885_imac91_automute,
9115 },
9005 [ALC882_TARGA] = { 9116 [ALC882_TARGA] = {
9006 .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, 9117 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
9007 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, 9118 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,