patch_realtek.c 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 PeiSen Hou <pshou@realtek.com.tw>
  7. * Takashi Iwai <tiwai@suse.de>
  8. *
  9. * This driver is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This driver is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <sound/driver.h>
  24. #include <linux/init.h>
  25. #include <linux/delay.h>
  26. #include <linux/slab.h>
  27. #include <linux/pci.h>
  28. #include <sound/core.h>
  29. #include "hda_codec.h"
  30. #include "hda_local.h"
  31. /* ALC880 board config type */
  32. enum {
  33. ALC880_MINIMAL,
  34. ALC880_3ST,
  35. ALC880_3ST_DIG,
  36. ALC880_5ST,
  37. ALC880_5ST_DIG,
  38. ALC880_W810,
  39. ALC880_Z71V,
  40. };
  41. struct alc_spec {
  42. /* codec parameterization */
  43. unsigned int front_panel: 1;
  44. snd_kcontrol_new_t* mixers[2];
  45. unsigned int num_mixers;
  46. struct hda_verb *init_verbs;
  47. char* stream_name_analog;
  48. struct hda_pcm_stream *stream_analog_playback;
  49. struct hda_pcm_stream *stream_analog_capture;
  50. char* stream_name_digital;
  51. struct hda_pcm_stream *stream_digital_playback;
  52. struct hda_pcm_stream *stream_digital_capture;
  53. /* playback */
  54. struct hda_multi_out multiout;
  55. /* capture */
  56. unsigned int num_adc_nids;
  57. hda_nid_t *adc_nids;
  58. hda_nid_t dig_in_nid;
  59. /* capture source */
  60. const struct hda_input_mux *input_mux;
  61. unsigned int cur_mux[3];
  62. /* channel model */
  63. const struct alc_channel_mode *channel_mode;
  64. int num_channel_mode;
  65. /* PCM information */
  66. struct hda_pcm pcm_rec[2];
  67. };
  68. /* DAC/ADC assignment */
  69. static hda_nid_t alc880_dac_nids[4] = {
  70. /* front, rear, clfe, rear_surr */
  71. 0x02, 0x05, 0x04, 0x03
  72. };
  73. static hda_nid_t alc880_w810_dac_nids[3] = {
  74. /* front, rear/surround, clfe */
  75. 0x02, 0x03, 0x04
  76. };
  77. static hda_nid_t alc880_z71v_dac_nids[1] = {
  78. /* front only? */
  79. 0x02
  80. };
  81. static hda_nid_t alc880_adc_nids[3] = {
  82. /* ADC0-2 */
  83. 0x07, 0x08, 0x09,
  84. };
  85. #define ALC880_DIGOUT_NID 0x06
  86. #define ALC880_DIGIN_NID 0x0a
  87. static hda_nid_t alc260_dac_nids[1] = {
  88. /* front */
  89. 0x02,
  90. };
  91. static hda_nid_t alc260_adc_nids[2] = {
  92. /* ADC0-1 */
  93. 0x04, 0x05,
  94. };
  95. #define ALC260_DIGOUT_NID 0x03
  96. #define ALC260_DIGIN_NID 0x06
  97. static struct hda_input_mux alc880_capture_source = {
  98. .num_items = 4,
  99. .items = {
  100. { "Mic", 0x0 },
  101. { "Front Mic", 0x3 },
  102. { "Line", 0x2 },
  103. { "CD", 0x4 },
  104. },
  105. };
  106. static struct hda_input_mux alc260_capture_source = {
  107. .num_items = 4,
  108. .items = {
  109. { "Mic", 0x0 },
  110. { "Front Mic", 0x1 },
  111. { "Line", 0x2 },
  112. { "CD", 0x4 },
  113. },
  114. };
  115. /*
  116. * input MUX handling
  117. */
  118. static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  119. {
  120. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  121. struct alc_spec *spec = codec->spec;
  122. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  123. }
  124. static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  125. {
  126. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  127. struct alc_spec *spec = codec->spec;
  128. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  129. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  130. return 0;
  131. }
  132. static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  133. {
  134. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  135. struct alc_spec *spec = codec->spec;
  136. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  137. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  138. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  139. }
  140. /*
  141. * channel mode setting
  142. */
  143. struct alc_channel_mode {
  144. int channels;
  145. const struct hda_verb *sequence;
  146. };
  147. /*
  148. * channel source setting (2/6 channel selection for 3-stack)
  149. */
  150. /*
  151. * set the path ways for 2 channel output
  152. * need to set the codec line out and mic 1 pin widgets to inputs
  153. */
  154. static struct hda_verb alc880_threestack_ch2_init[] = {
  155. /* set pin widget 1Ah (line in) for input */
  156. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  157. /* set pin widget 18h (mic1) for input, for mic also enable the vref */
  158. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  159. /* mute the output for Line In PW */
  160. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  161. /* mute for Mic1 PW */
  162. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  163. { } /* end */
  164. };
  165. /*
  166. * 6ch mode
  167. * need to set the codec line out and mic 1 pin widgets to outputs
  168. */
  169. static struct hda_verb alc880_threestack_ch6_init[] = {
  170. /* set pin widget 1Ah (line in) for output */
  171. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  172. /* set pin widget 18h (mic1) for output */
  173. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  174. /* unmute the output for Line In PW */
  175. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
  176. /* unmute for Mic1 PW */
  177. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
  178. /* for rear channel output using Line In 1
  179. * set select widget connection (nid = 0x12) - to summer node
  180. * for rear NID = 0x0f...offset 3 in connection list
  181. */
  182. { 0x12, AC_VERB_SET_CONNECT_SEL, 0x3 },
  183. /* for Mic1 - retask for center/lfe */
  184. /* set select widget connection (nid = 0x10) - to summer node for
  185. * front CLFE NID = 0x0e...offset 2 in connection list
  186. */
  187. { 0x10, AC_VERB_SET_CONNECT_SEL, 0x2 },
  188. { } /* end */
  189. };
  190. static struct alc_channel_mode alc880_threestack_modes[2] = {
  191. { 2, alc880_threestack_ch2_init },
  192. { 6, alc880_threestack_ch6_init },
  193. };
  194. /*
  195. * channel source setting (6/8 channel selection for 5-stack)
  196. */
  197. /* set the path ways for 6 channel output
  198. * need to set the codec line out and mic 1 pin widgets to inputs
  199. */
  200. static struct hda_verb alc880_fivestack_ch6_init[] = {
  201. /* set pin widget 1Ah (line in) for input */
  202. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  203. /* mute the output for Line In PW */
  204. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  205. { } /* end */
  206. };
  207. /* need to set the codec line out and mic 1 pin widgets to outputs */
  208. static struct hda_verb alc880_fivestack_ch8_init[] = {
  209. /* set pin widget 1Ah (line in) for output */
  210. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  211. /* unmute the output for Line In PW */
  212. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
  213. /* output for surround channel output using Line In 1 */
  214. /* set select widget connection (nid = 0x12) - to summer node
  215. * for surr_rear NID = 0x0d...offset 1 in connection list
  216. */
  217. { 0x12, AC_VERB_SET_CONNECT_SEL, 0x1 },
  218. { } /* end */
  219. };
  220. static struct alc_channel_mode alc880_fivestack_modes[2] = {
  221. { 6, alc880_fivestack_ch6_init },
  222. { 8, alc880_fivestack_ch8_init },
  223. };
  224. /*
  225. * channel source setting for W810 system
  226. *
  227. * W810 has rear IO for:
  228. * Front (DAC 02)
  229. * Surround (DAC 03)
  230. * Center/LFE (DAC 04)
  231. * Digital out (06)
  232. *
  233. * The system also has a pair of internal speakers, and a headphone jack.
  234. * These are both connected to Line2 on the codec, hence to DAC 02.
  235. *
  236. * There is a variable resistor to control the speaker or headphone
  237. * volume. This is a hardware-only device without a software API.
  238. *
  239. * Plugging headphones in will disable the internal speakers. This is
  240. * implemented in hardware, not via the driver using jack sense. In
  241. * a similar fashion, plugging into the rear socket marked "front" will
  242. * disable both the speakers and headphones.
  243. *
  244. * For input, there's a microphone jack, and an "audio in" jack.
  245. * These may not do anything useful with this driver yet, because I
  246. * haven't setup any initialization verbs for these yet...
  247. */
  248. static struct alc_channel_mode alc880_w810_modes[1] = {
  249. { 6, NULL }
  250. };
  251. static struct alc_channel_mode alc880_z71v_modes[1] = {
  252. { 2, NULL }
  253. };
  254. /*
  255. */
  256. static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  257. {
  258. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  259. struct alc_spec *spec = codec->spec;
  260. snd_assert(spec->channel_mode, return -ENXIO);
  261. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  262. uinfo->count = 1;
  263. uinfo->value.enumerated.items = 2;
  264. if (uinfo->value.enumerated.item >= 2)
  265. uinfo->value.enumerated.item = 1;
  266. sprintf(uinfo->value.enumerated.name, "%dch",
  267. spec->channel_mode[uinfo->value.enumerated.item].channels);
  268. return 0;
  269. }
  270. static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  271. {
  272. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  273. struct alc_spec *spec = codec->spec;
  274. snd_assert(spec->channel_mode, return -ENXIO);
  275. ucontrol->value.enumerated.item[0] =
  276. (spec->multiout.max_channels == spec->channel_mode[0].channels) ? 0 : 1;
  277. return 0;
  278. }
  279. static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  280. {
  281. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  282. struct alc_spec *spec = codec->spec;
  283. int mode;
  284. snd_assert(spec->channel_mode, return -ENXIO);
  285. mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
  286. if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
  287. ! codec->in_resume)
  288. return 0;
  289. /* change the current channel setting */
  290. spec->multiout.max_channels = spec->channel_mode[mode].channels;
  291. if (spec->channel_mode[mode].sequence)
  292. snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
  293. return 1;
  294. }
  295. /*
  296. */
  297. /* 3-stack mode
  298. * Pin assignment: Front=0x14, Line-In/Rear=0x1a, Mic/CLFE=0x18, F-Mic=0x1b
  299. * HP=0x19
  300. */
  301. static snd_kcontrol_new_t alc880_base_mixer[] = {
  302. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  303. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  304. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  305. HDA_CODEC_MUTE("Surround Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
  306. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  307. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  308. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x18, 1, 0x0, HDA_OUTPUT),
  309. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x18, 2, 0x0, HDA_OUTPUT),
  310. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  311. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  312. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  313. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  314. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  315. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  316. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  317. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  318. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  319. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  320. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  321. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  322. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  323. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  324. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  325. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  326. {
  327. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  328. /* The multiple "Capture Source" controls confuse alsamixer
  329. * So call somewhat different..
  330. * FIXME: the controls appear in the "playback" view!
  331. */
  332. /* .name = "Capture Source", */
  333. .name = "Input Source",
  334. .count = 2,
  335. .info = alc_mux_enum_info,
  336. .get = alc_mux_enum_get,
  337. .put = alc_mux_enum_put,
  338. },
  339. {
  340. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  341. .name = "Channel Mode",
  342. .info = alc880_ch_mode_info,
  343. .get = alc880_ch_mode_get,
  344. .put = alc880_ch_mode_put,
  345. },
  346. { } /* end */
  347. };
  348. /* 5-stack mode
  349. * Pin assignment: Front=0x14, Rear=0x17, CLFE=0x16
  350. * Line-In/Side=0x1a, Mic=0x18, F-Mic=0x1b, HP=0x19
  351. */
  352. static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
  353. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  354. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  355. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  356. HDA_CODEC_MUTE("Surround Playback Switch", 0x17, 0x0, HDA_OUTPUT),
  357. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  358. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  359. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  360. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  361. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  362. HDA_CODEC_MUTE("Side Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
  363. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  364. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  365. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  366. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  367. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  368. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  369. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  370. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  371. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  372. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  373. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  374. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  375. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  376. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  377. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  378. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  379. {
  380. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  381. /* The multiple "Capture Source" controls confuse alsamixer
  382. * So call somewhat different..
  383. * FIXME: the controls appear in the "playback" view!
  384. */
  385. /* .name = "Capture Source", */
  386. .name = "Input Source",
  387. .count = 2,
  388. .info = alc_mux_enum_info,
  389. .get = alc_mux_enum_get,
  390. .put = alc_mux_enum_put,
  391. },
  392. {
  393. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  394. .name = "Channel Mode",
  395. .info = alc880_ch_mode_info,
  396. .get = alc880_ch_mode_get,
  397. .put = alc880_ch_mode_put,
  398. },
  399. { } /* end */
  400. };
  401. static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
  402. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  403. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  404. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  405. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  406. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  407. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  408. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  409. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  410. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  411. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  412. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  413. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  414. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  415. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  416. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  417. {
  418. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  419. /* The multiple "Capture Source" controls confuse alsamixer
  420. * So call somewhat different..
  421. * FIXME: the controls appear in the "playback" view!
  422. */
  423. /* .name = "Capture Source", */
  424. .name = "Input Source",
  425. .count = 3,
  426. .info = alc_mux_enum_info,
  427. .get = alc_mux_enum_get,
  428. .put = alc_mux_enum_put,
  429. },
  430. { } /* end */
  431. };
  432. static snd_kcontrol_new_t alc880_z71v_mixer[] = {
  433. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  434. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  435. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  436. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  437. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  438. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  439. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  440. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  441. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  442. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  443. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  444. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  445. {
  446. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  447. /* The multiple "Capture Source" controls confuse alsamixer
  448. * So call somewhat different..
  449. * FIXME: the controls appear in the "playback" view!
  450. */
  451. /* .name = "Capture Source", */
  452. .name = "Input Source",
  453. .count = 2,
  454. .info = alc_mux_enum_info,
  455. .get = alc_mux_enum_get,
  456. .put = alc_mux_enum_put,
  457. },
  458. { } /* end */
  459. };
  460. /*
  461. */
  462. static int alc_build_controls(struct hda_codec *codec)
  463. {
  464. struct alc_spec *spec = codec->spec;
  465. int err;
  466. int i;
  467. for (i = 0; i < spec->num_mixers; i++) {
  468. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  469. if (err < 0)
  470. return err;
  471. }
  472. if (spec->multiout.dig_out_nid) {
  473. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  474. if (err < 0)
  475. return err;
  476. }
  477. if (spec->dig_in_nid) {
  478. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  479. if (err < 0)
  480. return err;
  481. }
  482. return 0;
  483. }
  484. /*
  485. * initialize the codec volumes, etc
  486. */
  487. static struct hda_verb alc880_init_verbs_three_stack[] = {
  488. /* Line In pin widget for input */
  489. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  490. /* CD pin widget for input */
  491. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  492. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  493. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  494. /* Mic2 (front panel) pin widget for input and vref at 80% */
  495. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  496. /* unmute amp left and right */
  497. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  498. /* set connection select to line in (default select for this ADC) */
  499. {0x07, AC_VERB_SET_CONNECT_SEL, 0x02},
  500. /* unmute front mixer amp left (volume = 0) */
  501. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  502. /* mute pin widget amp left and right (no gain on this amp) */
  503. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  504. /* unmute rear mixer amp left and right (volume = 0) */
  505. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  506. /* mute pin widget amp left and right (no gain on this amp) */
  507. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  508. /* unmute rear mixer amp left and right (volume = 0) */
  509. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  510. /* mute pin widget amp left and right (no gain on this amp) */
  511. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  512. /* using rear surround as the path for headphone output */
  513. /* unmute rear surround mixer amp left and right (volume = 0) */
  514. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  515. /* PASD 3 stack boards use the Mic 2 as the headphone output */
  516. /* need to program the selector associated with the Mic 2 pin widget to
  517. * surround path (index 0x01) for headphone output */
  518. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  519. /* mute pin widget amp left and right (no gain on this amp) */
  520. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  521. /* need to retask the Mic 2 pin widget to output */
  522. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  523. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer widget(nid=0x0B)
  524. * to support the input path of analog loopback
  525. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  526. * mic (mic 2)
  527. */
  528. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  529. /* unmute CD */
  530. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  531. /* unmute Line In */
  532. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  533. /* unmute Mic 1 */
  534. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  535. /* unmute Line In 2 (for PASD boards Mic 2) */
  536. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  537. /* Unmute input amps for the line out paths to support the output path of
  538. * analog loopback
  539. * the mixers on the output path has 2 inputs, one from the DAC and one
  540. * from the mixer
  541. */
  542. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  543. /* Unmute Front out path */
  544. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  545. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  546. /* Unmute Surround (used as HP) out path */
  547. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  548. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  549. /* Unmute C/LFE out path */
  550. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  551. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */
  552. /* Unmute rear Surround out path */
  553. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  554. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  555. { }
  556. };
  557. static struct hda_verb alc880_init_verbs_five_stack[] = {
  558. /* Line In pin widget for input */
  559. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  560. /* CD pin widget for input */
  561. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  562. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  563. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  564. /* Mic2 (front panel) pin widget for input and vref at 80% */
  565. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  566. /* unmute amp left and right */
  567. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  568. /* set connection select to line in (default select for this ADC) */
  569. {0x07, AC_VERB_SET_CONNECT_SEL, 0x02},
  570. /* unmute front mixer amp left and right (volume = 0) */
  571. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  572. /* mute pin widget amp left and right (no gain on this amp) */
  573. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  574. /* five rear and clfe */
  575. /* unmute rear mixer amp left and right (volume = 0) */
  576. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  577. /* mute pin widget amp left and right (no gain on this amp) */
  578. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  579. /* unmute clfe mixer amp left and right (volume = 0) */
  580. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  581. /* mute pin widget amp left and right (no gain on this amp) */
  582. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  583. /* using rear surround as the path for headphone output */
  584. /* unmute rear surround mixer amp left and right (volume = 0) */
  585. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  586. /* PASD 3 stack boards use the Mic 2 as the headphone output */
  587. /* need to program the selector associated with the Mic 2 pin widget to
  588. * surround path (index 0x01) for headphone output
  589. */
  590. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  591. /* mute pin widget amp left and right (no gain on this amp) */
  592. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  593. /* need to retask the Mic 2 pin widget to output */
  594. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  595. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer
  596. * widget(nid=0x0B) to support the input path of analog loopback
  597. */
  598. /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */
  599. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/
  600. /* unmute CD */
  601. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  602. /* unmute Line In */
  603. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  604. /* unmute Mic 1 */
  605. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  606. /* unmute Line In 2 (for PASD boards Mic 2) */
  607. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  608. /* Unmute input amps for the line out paths to support the output path of
  609. * analog loopback
  610. * the mixers on the output path has 2 inputs, one from the DAC and
  611. * one from the mixer
  612. */
  613. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  614. /* Unmute Front out path */
  615. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  616. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  617. /* Unmute Surround (used as HP) out path */
  618. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  619. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  620. /* Unmute C/LFE out path */
  621. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  622. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */
  623. /* Unmute rear Surround out path */
  624. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  625. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  626. { }
  627. };
  628. static struct hda_verb alc880_w810_init_verbs[] = {
  629. /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  630. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  631. /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  632. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  633. /* front channel selector/amp: output 0: unmuted, max volume */
  634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  635. /* front out pin: muted, (no volume selection) */
  636. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  637. /* front out pin: NOT headphone enable, out enable, vref disabled */
  638. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  639. /* surround channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  640. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  641. /* surround channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  642. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  643. /* surround channel selector/amp: output 0: unmuted, max volume */
  644. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  645. /* surround out pin: muted, (no volume selection) */
  646. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  647. /* surround out pin: NOT headphone enable, out enable, vref disabled */
  648. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  649. /* c/lfe channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  650. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  651. /* c/lfe channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  652. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  653. /* c/lfe channel selector/amp: output 0: unmuted, max volume */
  654. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  655. /* c/lfe out pin: muted, (no volume selection) */
  656. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  657. /* c/lfe out pin: NOT headphone enable, out enable, vref disabled */
  658. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  659. /* hphone/speaker input selector: front DAC */
  660. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  661. /* hphone/speaker out pin: muted, (no volume selection) */
  662. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  663. /* hphone/speaker out pin: NOT headphone enable, out enable, vref disabled */
  664. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  665. { }
  666. };
  667. static struct hda_verb alc880_z71v_init_verbs[] = {
  668. /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  669. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  670. /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  671. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  672. /* front channel selector/amp: output 0: unmuted, max volume */
  673. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  674. /* front out pin: muted, (no volume selection) */
  675. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  676. /* front out pin: NOT headphone enable, out enable, vref disabled */
  677. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  678. /* headphone channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  679. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  680. /* headphone channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  681. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  682. /* headphone channel selector/amp: output 0: unmuted, max volume */
  683. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  684. /* headphone out pin: muted, (no volume selection) */
  685. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  686. /* headpohne out pin: headphone enable, out enable, vref disabled */
  687. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  688. /* Line In pin widget for input */
  689. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  690. /* CD pin widget for input */
  691. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  692. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  693. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  694. /* Mic2 (front panel) pin widget for input and vref at 80% */
  695. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  696. /* unmute amp left and right */
  697. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  698. /* set connection select to line in (default select for this ADC) */
  699. {0x07, AC_VERB_SET_CONNECT_SEL, 0x02},
  700. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer
  701. * widget(nid=0x0B) to support the input path of analog loopback
  702. */
  703. /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */
  704. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/
  705. /* unmute CD */
  706. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  707. /* unmute Line In */
  708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  709. /* unmute Mic 1 */
  710. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  711. /* unmute Line In 2 (for PASD boards Mic 2) */
  712. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  713. { }
  714. };
  715. static int alc_init(struct hda_codec *codec)
  716. {
  717. struct alc_spec *spec = codec->spec;
  718. snd_hda_sequence_write(codec, spec->init_verbs);
  719. return 0;
  720. }
  721. #ifdef CONFIG_PM
  722. /*
  723. * resume
  724. */
  725. static int alc_resume(struct hda_codec *codec)
  726. {
  727. struct alc_spec *spec = codec->spec;
  728. int i;
  729. alc_init(codec);
  730. for (i = 0; i < spec->num_mixers; i++) {
  731. snd_hda_resume_ctls(codec, spec->mixers[i]);
  732. }
  733. if (spec->multiout.dig_out_nid)
  734. snd_hda_resume_spdif_out(codec);
  735. if (spec->dig_in_nid)
  736. snd_hda_resume_spdif_in(codec);
  737. return 0;
  738. }
  739. #endif
  740. /*
  741. * Analog playback callbacks
  742. */
  743. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  744. struct hda_codec *codec,
  745. snd_pcm_substream_t *substream)
  746. {
  747. struct alc_spec *spec = codec->spec;
  748. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  749. }
  750. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  751. struct hda_codec *codec,
  752. unsigned int stream_tag,
  753. unsigned int format,
  754. snd_pcm_substream_t *substream)
  755. {
  756. struct alc_spec *spec = codec->spec;
  757. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  758. format, substream);
  759. }
  760. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  761. struct hda_codec *codec,
  762. snd_pcm_substream_t *substream)
  763. {
  764. struct alc_spec *spec = codec->spec;
  765. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  766. }
  767. /*
  768. * Digital out
  769. */
  770. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  771. struct hda_codec *codec,
  772. snd_pcm_substream_t *substream)
  773. {
  774. struct alc_spec *spec = codec->spec;
  775. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  776. }
  777. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  778. struct hda_codec *codec,
  779. snd_pcm_substream_t *substream)
  780. {
  781. struct alc_spec *spec = codec->spec;
  782. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  783. }
  784. /*
  785. * Analog capture
  786. */
  787. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  788. struct hda_codec *codec,
  789. unsigned int stream_tag,
  790. unsigned int format,
  791. snd_pcm_substream_t *substream)
  792. {
  793. struct alc_spec *spec = codec->spec;
  794. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  795. stream_tag, 0, format);
  796. return 0;
  797. }
  798. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  799. struct hda_codec *codec,
  800. snd_pcm_substream_t *substream)
  801. {
  802. struct alc_spec *spec = codec->spec;
  803. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  804. return 0;
  805. }
  806. /*
  807. */
  808. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  809. .substreams = 1,
  810. .channels_min = 2,
  811. .channels_max = 8,
  812. .nid = 0x02, /* NID to query formats and rates */
  813. .ops = {
  814. .open = alc880_playback_pcm_open,
  815. .prepare = alc880_playback_pcm_prepare,
  816. .cleanup = alc880_playback_pcm_cleanup
  817. },
  818. };
  819. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  820. .substreams = 2,
  821. .channels_min = 2,
  822. .channels_max = 2,
  823. .nid = 0x07, /* NID to query formats and rates */
  824. .ops = {
  825. .prepare = alc880_capture_pcm_prepare,
  826. .cleanup = alc880_capture_pcm_cleanup
  827. },
  828. };
  829. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  830. .substreams = 1,
  831. .channels_min = 2,
  832. .channels_max = 2,
  833. /* NID is set in alc_build_pcms */
  834. .ops = {
  835. .open = alc880_dig_playback_pcm_open,
  836. .close = alc880_dig_playback_pcm_close
  837. },
  838. };
  839. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  840. .substreams = 1,
  841. .channels_min = 2,
  842. .channels_max = 2,
  843. /* NID is set in alc_build_pcms */
  844. };
  845. static int alc_build_pcms(struct hda_codec *codec)
  846. {
  847. struct alc_spec *spec = codec->spec;
  848. struct hda_pcm *info = spec->pcm_rec;
  849. int i;
  850. codec->num_pcms = 1;
  851. codec->pcm_info = info;
  852. info->name = spec->stream_name_analog;
  853. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  854. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  855. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  856. for (i = 0; i < spec->num_channel_mode; i++) {
  857. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  858. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  859. }
  860. }
  861. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  862. codec->num_pcms++;
  863. info++;
  864. info->name = spec->stream_name_digital;
  865. if (spec->multiout.dig_out_nid) {
  866. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  867. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  868. }
  869. if (spec->dig_in_nid) {
  870. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  871. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  872. }
  873. }
  874. return 0;
  875. }
  876. static void alc_free(struct hda_codec *codec)
  877. {
  878. kfree(codec->spec);
  879. }
  880. /*
  881. */
  882. static struct hda_codec_ops alc_patch_ops = {
  883. .build_controls = alc_build_controls,
  884. .build_pcms = alc_build_pcms,
  885. .init = alc_init,
  886. .free = alc_free,
  887. #ifdef CONFIG_PM
  888. .resume = alc_resume,
  889. #endif
  890. };
  891. /*
  892. */
  893. static struct hda_board_config alc880_cfg_tbl[] = {
  894. /* Back 3 jack, front 2 jack */
  895. { .modelname = "3stack", .config = ALC880_3ST },
  896. { .pci_vendor = 0x8086, .pci_device = 0xe200, .config = ALC880_3ST },
  897. { .pci_vendor = 0x8086, .pci_device = 0xe201, .config = ALC880_3ST },
  898. { .pci_vendor = 0x8086, .pci_device = 0xe202, .config = ALC880_3ST },
  899. { .pci_vendor = 0x8086, .pci_device = 0xe203, .config = ALC880_3ST },
  900. { .pci_vendor = 0x8086, .pci_device = 0xe204, .config = ALC880_3ST },
  901. { .pci_vendor = 0x8086, .pci_device = 0xe205, .config = ALC880_3ST },
  902. { .pci_vendor = 0x8086, .pci_device = 0xe206, .config = ALC880_3ST },
  903. { .pci_vendor = 0x8086, .pci_device = 0xe207, .config = ALC880_3ST },
  904. { .pci_vendor = 0x8086, .pci_device = 0xe208, .config = ALC880_3ST },
  905. { .pci_vendor = 0x8086, .pci_device = 0xe209, .config = ALC880_3ST },
  906. { .pci_vendor = 0x8086, .pci_device = 0xe20a, .config = ALC880_3ST },
  907. { .pci_vendor = 0x8086, .pci_device = 0xe20b, .config = ALC880_3ST },
  908. { .pci_vendor = 0x8086, .pci_device = 0xe20c, .config = ALC880_3ST },
  909. { .pci_vendor = 0x8086, .pci_device = 0xe20d, .config = ALC880_3ST },
  910. { .pci_vendor = 0x8086, .pci_device = 0xe20e, .config = ALC880_3ST },
  911. { .pci_vendor = 0x8086, .pci_device = 0xe20f, .config = ALC880_3ST },
  912. { .pci_vendor = 0x8086, .pci_device = 0xe210, .config = ALC880_3ST },
  913. { .pci_vendor = 0x8086, .pci_device = 0xe211, .config = ALC880_3ST },
  914. { .pci_vendor = 0x8086, .pci_device = 0xe214, .config = ALC880_3ST },
  915. { .pci_vendor = 0x8086, .pci_device = 0xe302, .config = ALC880_3ST },
  916. { .pci_vendor = 0x8086, .pci_device = 0xe303, .config = ALC880_3ST },
  917. { .pci_vendor = 0x8086, .pci_device = 0xe304, .config = ALC880_3ST },
  918. { .pci_vendor = 0x8086, .pci_device = 0xe306, .config = ALC880_3ST },
  919. { .pci_vendor = 0x8086, .pci_device = 0xe307, .config = ALC880_3ST },
  920. { .pci_vendor = 0x8086, .pci_device = 0xe404, .config = ALC880_3ST },
  921. { .pci_vendor = 0x8086, .pci_device = 0xa101, .config = ALC880_3ST },
  922. { .pci_vendor = 0x107b, .pci_device = 0x3031, .config = ALC880_3ST },
  923. { .pci_vendor = 0x107b, .pci_device = 0x4036, .config = ALC880_3ST },
  924. { .pci_vendor = 0x107b, .pci_device = 0x4037, .config = ALC880_3ST },
  925. { .pci_vendor = 0x107b, .pci_device = 0x4038, .config = ALC880_3ST },
  926. { .pci_vendor = 0x107b, .pci_device = 0x4040, .config = ALC880_3ST },
  927. { .pci_vendor = 0x107b, .pci_device = 0x4041, .config = ALC880_3ST },
  928. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  929. { .pci_vendor = 0x1025, .pci_device = 0xe310, .config = ALC880_3ST },
  930. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  931. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  932. { .pci_vendor = 0x8086, .pci_device = 0xe308, .config = ALC880_3ST_DIG },
  933. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  934. { .pci_vendor = 0x8086, .pci_device = 0xe305, .config = ALC880_3ST_DIG },
  935. { .pci_vendor = 0x8086, .pci_device = 0xd402, .config = ALC880_3ST_DIG },
  936. { .pci_vendor = 0x1025, .pci_device = 0xe309, .config = ALC880_3ST_DIG },
  937. /* Back 5 jack, front 2 jack */
  938. { .modelname = "5stack", .config = ALC880_5ST },
  939. { .pci_vendor = 0x107b, .pci_device = 0x3033, .config = ALC880_5ST },
  940. { .pci_vendor = 0x107b, .pci_device = 0x4039, .config = ALC880_5ST },
  941. { .pci_vendor = 0x107b, .pci_device = 0x3032, .config = ALC880_5ST },
  942. { .pci_vendor = 0x103c, .pci_device = 0x2a09, .config = ALC880_5ST },
  943. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  944. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  945. { .pci_vendor = 0x8086, .pci_device = 0xe224, .config = ALC880_5ST_DIG },
  946. { .pci_vendor = 0x8086, .pci_device = 0xe400, .config = ALC880_5ST_DIG },
  947. { .pci_vendor = 0x8086, .pci_device = 0xe401, .config = ALC880_5ST_DIG },
  948. { .pci_vendor = 0x8086, .pci_device = 0xe402, .config = ALC880_5ST_DIG },
  949. { .pci_vendor = 0x8086, .pci_device = 0xd400, .config = ALC880_5ST_DIG },
  950. { .pci_vendor = 0x8086, .pci_device = 0xd401, .config = ALC880_5ST_DIG },
  951. { .pci_vendor = 0x8086, .pci_device = 0xa100, .config = ALC880_5ST_DIG },
  952. { .pci_vendor = 0x1565, .pci_device = 0x8202, .config = ALC880_5ST_DIG },
  953. { .modelname = "w810", .config = ALC880_W810 },
  954. { .pci_vendor = 0x161f, .pci_device = 0x203d, .config = ALC880_W810 },
  955. { .modelname = "z71v", .config = ALC880_Z71V },
  956. { .pci_vendor = 0x1043, .pci_device = 0x1964, .config = ALC880_Z71V },
  957. {}
  958. };
  959. static int patch_alc880(struct hda_codec *codec)
  960. {
  961. struct alc_spec *spec;
  962. int board_config;
  963. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  964. if (spec == NULL)
  965. return -ENOMEM;
  966. codec->spec = spec;
  967. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  968. if (board_config < 0) {
  969. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC880\n");
  970. board_config = ALC880_MINIMAL;
  971. }
  972. switch (board_config) {
  973. case ALC880_W810:
  974. spec->mixers[spec->num_mixers] = alc880_w810_base_mixer;
  975. spec->num_mixers++;
  976. break;
  977. case ALC880_5ST:
  978. case ALC880_5ST_DIG:
  979. spec->mixers[spec->num_mixers] = alc880_five_stack_mixer;
  980. spec->num_mixers++;
  981. break;
  982. case ALC880_Z71V:
  983. spec->mixers[spec->num_mixers] = alc880_z71v_mixer;
  984. spec->num_mixers++;
  985. break;
  986. default:
  987. spec->mixers[spec->num_mixers] = alc880_base_mixer;
  988. spec->num_mixers++;
  989. break;
  990. }
  991. switch (board_config) {
  992. case ALC880_3ST_DIG:
  993. case ALC880_5ST_DIG:
  994. case ALC880_W810:
  995. case ALC880_Z71V:
  996. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  997. break;
  998. default:
  999. break;
  1000. }
  1001. switch (board_config) {
  1002. case ALC880_3ST:
  1003. case ALC880_3ST_DIG:
  1004. case ALC880_5ST:
  1005. case ALC880_5ST_DIG:
  1006. case ALC880_W810:
  1007. spec->front_panel = 1;
  1008. break;
  1009. default:
  1010. break;
  1011. }
  1012. switch (board_config) {
  1013. case ALC880_5ST:
  1014. case ALC880_5ST_DIG:
  1015. spec->init_verbs = alc880_init_verbs_five_stack;
  1016. spec->channel_mode = alc880_fivestack_modes;
  1017. spec->num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes);
  1018. break;
  1019. case ALC880_W810:
  1020. spec->init_verbs = alc880_w810_init_verbs;
  1021. spec->channel_mode = alc880_w810_modes;
  1022. spec->num_channel_mode = ARRAY_SIZE(alc880_w810_modes);
  1023. break;
  1024. case ALC880_Z71V:
  1025. spec->init_verbs = alc880_z71v_init_verbs;
  1026. spec->channel_mode = alc880_z71v_modes;
  1027. spec->num_channel_mode = ARRAY_SIZE(alc880_z71v_modes);
  1028. break;
  1029. default:
  1030. spec->init_verbs = alc880_init_verbs_three_stack;
  1031. spec->channel_mode = alc880_threestack_modes;
  1032. spec->num_channel_mode = ARRAY_SIZE(alc880_threestack_modes);
  1033. break;
  1034. }
  1035. spec->stream_name_analog = "ALC880 Analog";
  1036. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1037. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1038. spec->stream_name_digital = "ALC880 Digital";
  1039. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1040. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1041. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1042. switch (board_config) {
  1043. case ALC880_W810:
  1044. spec->multiout.num_dacs = ARRAY_SIZE(alc880_w810_dac_nids);
  1045. spec->multiout.dac_nids = alc880_w810_dac_nids;
  1046. // No dedicated headphone socket - it's shared with built-in speakers.
  1047. break;
  1048. case ALC880_Z71V:
  1049. spec->multiout.num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids);
  1050. spec->multiout.dac_nids = alc880_z71v_dac_nids;
  1051. spec->multiout.hp_nid = 0x03;
  1052. break;
  1053. default:
  1054. spec->multiout.num_dacs = ARRAY_SIZE(alc880_dac_nids);
  1055. spec->multiout.dac_nids = alc880_dac_nids;
  1056. spec->multiout.hp_nid = 0x03; /* rear-surround NID */
  1057. break;
  1058. }
  1059. spec->input_mux = &alc880_capture_source;
  1060. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  1061. spec->adc_nids = alc880_adc_nids;
  1062. codec->patch_ops = alc_patch_ops;
  1063. return 0;
  1064. }
  1065. /*
  1066. * ALC260 support
  1067. */
  1068. /*
  1069. * This is just place-holder, so there's something for alc_build_pcms to look
  1070. * at when it calculates the maximum number of channels. ALC260 has no mixer
  1071. * element which allows changing the channel mode, so the verb list is
  1072. * never used.
  1073. */
  1074. static struct alc_channel_mode alc260_modes[1] = {
  1075. { 2, NULL },
  1076. };
  1077. snd_kcontrol_new_t alc260_base_mixer[] = {
  1078. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1079. /* use LINE2 for the output */
  1080. /* HDA_CODEC_MUTE("Front Playback Switch", 0x0f, 0x0, HDA_OUTPUT), */
  1081. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  1082. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1083. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1084. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1085. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1087. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1088. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1089. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  1091. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  1093. HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  1094. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  1095. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  1096. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  1097. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  1098. {
  1099. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1100. .name = "Capture Source",
  1101. .info = alc_mux_enum_info,
  1102. .get = alc_mux_enum_get,
  1103. .put = alc_mux_enum_put,
  1104. },
  1105. { } /* end */
  1106. };
  1107. static struct hda_verb alc260_init_verbs[] = {
  1108. /* Line In pin widget for input */
  1109. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1110. /* CD pin widget for input */
  1111. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1112. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1113. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1114. /* Mic2 (front panel) pin widget for input and vref at 80% */
  1115. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1116. /* LINE-2 is used for line-out in rear */
  1117. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1118. /* select line-out */
  1119. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  1120. /* LINE-OUT pin */
  1121. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1122. /* enable HP */
  1123. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1124. /* enable Mono */
  1125. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1126. /* unmute amp left and right */
  1127. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1128. /* set connection select to line in (default select for this ADC) */
  1129. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  1130. /* unmute Line-Out mixer amp left and right (volume = 0) */
  1131. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1132. /* mute pin widget amp left and right (no gain on this amp) */
  1133. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1134. /* unmute HP mixer amp left and right (volume = 0) */
  1135. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1136. /* mute pin widget amp left and right (no gain on this amp) */
  1137. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1138. /* unmute Mono mixer amp left and right (volume = 0) */
  1139. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1140. /* mute pin widget amp left and right (no gain on this amp) */
  1141. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1142. /* mute LINE-2 out */
  1143. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1144. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  1145. /* unmute CD */
  1146. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  1147. /* unmute Line In */
  1148. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  1149. /* unmute Mic */
  1150. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1151. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  1152. /* Unmute Front out path */
  1153. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1154. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1155. /* Unmute Headphone out path */
  1156. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1157. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1158. /* Unmute Mono out path */
  1159. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1160. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1161. { }
  1162. };
  1163. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  1164. .substreams = 1,
  1165. .channels_min = 2,
  1166. .channels_max = 2,
  1167. .nid = 0x2,
  1168. };
  1169. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  1170. .substreams = 1,
  1171. .channels_min = 2,
  1172. .channels_max = 2,
  1173. .nid = 0x4,
  1174. };
  1175. static int patch_alc260(struct hda_codec *codec)
  1176. {
  1177. struct alc_spec *spec;
  1178. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1179. if (spec == NULL)
  1180. return -ENOMEM;
  1181. codec->spec = spec;
  1182. spec->mixers[spec->num_mixers] = alc260_base_mixer;
  1183. spec->num_mixers++;
  1184. spec->init_verbs = alc260_init_verbs;
  1185. spec->channel_mode = alc260_modes;
  1186. spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
  1187. spec->stream_name_analog = "ALC260 Analog";
  1188. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  1189. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  1190. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1191. spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
  1192. spec->multiout.dac_nids = alc260_dac_nids;
  1193. spec->input_mux = &alc260_capture_source;
  1194. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  1195. spec->adc_nids = alc260_adc_nids;
  1196. codec->patch_ops = alc_patch_ops;
  1197. return 0;
  1198. }
  1199. /*
  1200. * ALC882 support
  1201. *
  1202. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  1203. * configuration. Each pin widget can choose any input DACs and a mixer.
  1204. * Each ADC is connected from a mixer of all inputs. This makes possible
  1205. * 6-channel independent captures.
  1206. *
  1207. * In addition, an independent DAC for the multi-playback (not used in this
  1208. * driver yet).
  1209. */
  1210. static struct alc_channel_mode alc882_ch_modes[1] = {
  1211. { 8, NULL }
  1212. };
  1213. static hda_nid_t alc882_dac_nids[4] = {
  1214. /* front, rear, clfe, rear_surr */
  1215. 0x02, 0x03, 0x04, 0x05
  1216. };
  1217. static hda_nid_t alc882_adc_nids[3] = {
  1218. /* ADC0-2 */
  1219. 0x07, 0x08, 0x09,
  1220. };
  1221. /* input MUX */
  1222. /* FIXME: should be a matrix-type input source selection */
  1223. static struct hda_input_mux alc882_capture_source = {
  1224. .num_items = 4,
  1225. .items = {
  1226. { "Mic", 0x0 },
  1227. { "Front Mic", 0x1 },
  1228. { "Line", 0x2 },
  1229. { "CD", 0x4 },
  1230. },
  1231. };
  1232. #define alc882_mux_enum_info alc_mux_enum_info
  1233. #define alc882_mux_enum_get alc_mux_enum_get
  1234. static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1235. {
  1236. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1237. struct alc_spec *spec = codec->spec;
  1238. const struct hda_input_mux *imux = spec->input_mux;
  1239. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  1240. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  1241. hda_nid_t nid = capture_mixers[adc_idx];
  1242. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  1243. unsigned int i, idx;
  1244. idx = ucontrol->value.enumerated.item[0];
  1245. if (idx >= imux->num_items)
  1246. idx = imux->num_items - 1;
  1247. if (*cur_val == idx && ! codec->in_resume)
  1248. return 0;
  1249. for (i = 0; i < imux->num_items; i++) {
  1250. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  1251. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1252. v | (imux->items[i].index << 8));
  1253. }
  1254. *cur_val = idx;
  1255. return 1;
  1256. }
  1257. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  1258. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  1259. */
  1260. static snd_kcontrol_new_t alc882_base_mixer[] = {
  1261. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1262. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1263. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1264. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  1265. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1266. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1267. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  1268. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  1269. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1270. HDA_CODEC_MUTE("Side Playback Switch", 0x17, 0x0, HDA_OUTPUT),
  1271. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1272. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1273. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1274. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1275. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1276. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1277. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1278. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1279. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1280. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1281. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1282. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  1283. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  1284. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  1285. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  1286. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  1287. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  1288. {
  1289. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1290. /* .name = "Capture Source", */
  1291. .name = "Input Source",
  1292. .count = 3,
  1293. .info = alc882_mux_enum_info,
  1294. .get = alc882_mux_enum_get,
  1295. .put = alc882_mux_enum_put,
  1296. },
  1297. { } /* end */
  1298. };
  1299. static struct hda_verb alc882_init_verbs[] = {
  1300. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  1301. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1302. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1303. /* Rear mixer */
  1304. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1305. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1306. /* CLFE mixer */
  1307. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1308. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1309. /* Side mixer */
  1310. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1311. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1312. /* Front Pin: to output mode */
  1313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1314. /* Front Pin: mute amp left and right (no volume) */
  1315. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1316. /* select Front mixer (0x0c, index 0) */
  1317. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  1318. /* Rear Pin */
  1319. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1320. /* Rear Pin: mute amp left and right (no volume) */
  1321. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1322. /* select Rear mixer (0x0d, index 1) */
  1323. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  1324. /* CLFE Pin */
  1325. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1326. /* CLFE Pin: mute amp left and right (no volume) */
  1327. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1328. /* select CLFE mixer (0x0e, index 2) */
  1329. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  1330. /* Side Pin */
  1331. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1332. /* Side Pin: mute amp left and right (no volume) */
  1333. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1334. /* select Side mixer (0x0f, index 3) */
  1335. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  1336. /* Headphone Pin */
  1337. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1338. /* Headphone Pin: mute amp left and right (no volume) */
  1339. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1340. /* select Front mixer (0x0c, index 0) */
  1341. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1342. /* Mic (rear) pin widget for input and vref at 80% */
  1343. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1344. /* Front Mic pin widget for input and vref at 80% */
  1345. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1346. /* Line In pin widget for input */
  1347. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1348. /* CD pin widget for input */
  1349. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1350. /* FIXME: use matrix-type input source selection */
  1351. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  1352. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  1353. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1354. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  1355. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  1356. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  1357. /* Input mixer2 */
  1358. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1359. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  1360. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  1361. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  1362. /* Input mixer3 */
  1363. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1364. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  1365. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  1366. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  1367. /* ADC1: unmute amp left and right */
  1368. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1369. /* ADC2: unmute amp left and right */
  1370. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1371. /* ADC3: unmute amp left and right */
  1372. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1373. /* Unmute front loopback */
  1374. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1375. /* Unmute rear loopback */
  1376. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1377. /* Mute CLFE loopback */
  1378. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
  1379. /* Unmute side loopback */
  1380. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1381. { }
  1382. };
  1383. static int patch_alc882(struct hda_codec *codec)
  1384. {
  1385. struct alc_spec *spec;
  1386. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1387. if (spec == NULL)
  1388. return -ENOMEM;
  1389. codec->spec = spec;
  1390. spec->mixers[spec->num_mixers] = alc882_base_mixer;
  1391. spec->num_mixers++;
  1392. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1393. spec->dig_in_nid = ALC880_DIGIN_NID;
  1394. spec->front_panel = 1;
  1395. spec->init_verbs = alc882_init_verbs;
  1396. spec->channel_mode = alc882_ch_modes;
  1397. spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
  1398. spec->stream_name_analog = "ALC882 Analog";
  1399. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1400. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1401. spec->stream_name_digital = "ALC882 Digital";
  1402. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1403. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1404. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1405. spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
  1406. spec->multiout.dac_nids = alc882_dac_nids;
  1407. spec->input_mux = &alc882_capture_source;
  1408. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  1409. spec->adc_nids = alc882_adc_nids;
  1410. codec->patch_ops = alc_patch_ops;
  1411. return 0;
  1412. }
  1413. /*
  1414. * patch entries
  1415. */
  1416. struct hda_codec_preset snd_hda_preset_realtek[] = {
  1417. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  1418. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  1419. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  1420. {} /* terminator */
  1421. };