Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ALSA] hda-intel: support for iMac 24'' released on 09/2006

Basic audio support for the iMac 24'' model released on 09/2006,
including
headphone jack detection with automatic speaker muting.
This iMac uses the Realtek ALC885 codec, not a Sigmatel one as in
other models.
Functionality has been tested for internal speakers, headphone and
microphone.

Signed-off-by: Nicola Fagnani <nicfagn@iol.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>

authored by

Nicola Fagnani and committed by
Jaroslav Kysela
c54728d8 c5d9f1cd

+74 -1
+1
Documentation/sound/alsa/ALSA-Configuration.txt
··· 843 843 6stack-dig 6-jack digital with SPDIF I/O 844 844 arima Arima W820Di1 845 845 macpro MacPro support 846 + imac24 iMac 24'' with jack detection 846 847 w2jc ASUS W2JC 847 848 auto auto-config reading BIOS (default) 848 849
+73 -1
sound/pci/hda/patch_realtek.c
··· 153 153 ALC882_TARGA, 154 154 ALC882_ASUS_A7J, 155 155 ALC885_MACPRO, 156 + ALC885_IMAC24, 156 157 ALC882_AUTO, 157 158 ALC882_MODEL_LAST, 158 159 }; ··· 5119 5118 { } 5120 5119 }; 5121 5120 5121 + /* iMac 24 mixer. */ 5122 + static struct snd_kcontrol_new alc885_imac24_mixer[] = { 5123 + HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 5124 + HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), 5125 + { } /* end */ 5126 + }; 5127 + 5128 + /* iMac 24 init verbs. */ 5129 + static struct hda_verb alc885_imac24_init_verbs[] = { 5130 + /* Internal speakers: output 0 (0x0c) */ 5131 + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5132 + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5133 + {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, 5134 + /* Internal speakers: output 0 (0x0c) */ 5135 + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 5136 + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5137 + {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 5138 + /* Headphone: output 0 (0x0c) */ 5139 + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5140 + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 5141 + {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 5142 + {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5143 + /* Front Mic: input vref at 80% */ 5144 + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 5145 + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 5146 + { } 5147 + }; 5148 + 5149 + /* Toggle speaker-output according to the hp-jack state */ 5150 + static void alc885_imac24_automute(struct hda_codec *codec) 5151 + { 5152 + unsigned int present; 5153 + 5154 + present = snd_hda_codec_read(codec, 0x14, 0, 5155 + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5156 + snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0, 5157 + 0x80, present ? 0x80 : 0); 5158 + snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0, 5159 + 0x80, present ? 0x80 : 0); 5160 + snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0, 5161 + 0x80, present ? 0x80 : 0); 5162 + snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0, 5163 + 0x80, present ? 0x80 : 0); 5164 + } 5165 + 5166 + /* Processes unsolicited events. */ 5167 + static void alc885_imac24_unsol_event(struct hda_codec *codec, 5168 + unsigned int res) 5169 + { 5170 + /* Headphone insertion or removal. */ 5171 + if ((res >> 26) == ALC880_HP_EVENT) 5172 + alc885_imac24_automute(codec); 5173 + } 5174 + 5122 5175 static struct hda_verb alc882_targa_verbs[] = { 5123 5176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5124 5177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, ··· 5393 5338 [ALC882_ARIMA] = "arima", 5394 5339 [ALC882_W2JC] = "w2jc", 5395 5340 [ALC885_MACPRO] = "macpro", 5341 + [ALC885_IMAC24] = "imac24", 5396 5342 [ALC882_AUTO] = "auto", 5397 5343 }; 5398 5344 ··· 5465 5409 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 5466 5410 .channel_mode = alc882_ch_modes, 5467 5411 .input_mux = &alc882_capture_source, 5412 + }, 5413 + [ALC885_IMAC24] = { 5414 + .mixers = { alc885_imac24_mixer }, 5415 + .init_verbs = { alc885_imac24_init_verbs }, 5416 + .num_dacs = ARRAY_SIZE(alc882_dac_nids), 5417 + .dac_nids = alc882_dac_nids, 5418 + .dig_out_nid = ALC882_DIGOUT_NID, 5419 + .dig_in_nid = ALC882_DIGIN_NID, 5420 + .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 5421 + .channel_mode = alc882_ch_modes, 5422 + .input_mux = &alc882_capture_source, 5423 + .unsol_event = alc885_imac24_unsol_event, 5424 + .init_hook = alc885_imac24_automute, 5468 5425 }, 5469 5426 [ALC882_TARGA] = { 5470 5427 .mixers = { alc882_targa_mixer, alc882_chmode_mixer, ··· 5651 5582 case 0x106b0c00: /* Mac Pro */ 5652 5583 board_config = ALC885_MACPRO; 5653 5584 break; 5585 + case 0x106b1000: /* iMac 24 */ 5586 + board_config = ALC885_IMAC24; 5587 + break; 5654 5588 default: 5655 5589 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 5656 5590 "trying auto-probe from BIOS...\n"); ··· 5680 5608 if (board_config != ALC882_AUTO) 5681 5609 setup_preset(spec, &alc882_presets[board_config]); 5682 5610 5683 - if (board_config == ALC885_MACPRO) { 5611 + if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) { 5684 5612 alc882_gpio_mute(codec, 0, 0); 5685 5613 alc882_gpio_mute(codec, 1, 0); 5686 5614 }