patch_realtek.c 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011
  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. ALC880_TEST,
  41. };
  42. struct alc_spec {
  43. /* codec parameterization */
  44. unsigned int front_panel: 1;
  45. snd_kcontrol_new_t* mixers[2];
  46. unsigned int num_mixers;
  47. struct hda_verb *init_verbs;
  48. char* stream_name_analog;
  49. struct hda_pcm_stream *stream_analog_playback;
  50. struct hda_pcm_stream *stream_analog_capture;
  51. char* stream_name_digital;
  52. struct hda_pcm_stream *stream_digital_playback;
  53. struct hda_pcm_stream *stream_digital_capture;
  54. /* playback */
  55. struct hda_multi_out multiout;
  56. /* capture */
  57. unsigned int num_adc_nids;
  58. hda_nid_t *adc_nids;
  59. hda_nid_t dig_in_nid;
  60. /* capture source */
  61. const struct hda_input_mux *input_mux;
  62. unsigned int cur_mux[3];
  63. /* channel model */
  64. const struct alc_channel_mode *channel_mode;
  65. int num_channel_mode;
  66. /* PCM information */
  67. struct hda_pcm pcm_rec[2];
  68. struct semaphore bind_mutex;
  69. };
  70. /* DAC/ADC assignment */
  71. static hda_nid_t alc880_dac_nids[4] = {
  72. /* front, rear, clfe, rear_surr */
  73. 0x02, 0x05, 0x04, 0x03
  74. };
  75. static hda_nid_t alc880_w810_dac_nids[3] = {
  76. /* front, rear/surround, clfe */
  77. 0x02, 0x03, 0x04
  78. };
  79. static hda_nid_t alc880_z71v_dac_nids[1] = {
  80. /* front only? */
  81. 0x02
  82. };
  83. #if 0
  84. /* The datasheet says the node 0x07 is connected from inputs,
  85. * but it shows zero connection in the real implementation.
  86. */
  87. static hda_nid_t alc880_adc_nids[3] = {
  88. /* ADC0-2 */
  89. 0x07, 0x08, 0x09,
  90. };
  91. #else
  92. static hda_nid_t alc880_adc_nids[2] = {
  93. /* ADC1-2 */
  94. 0x08, 0x09,
  95. };
  96. #endif
  97. #define ALC880_DIGOUT_NID 0x06
  98. #define ALC880_DIGIN_NID 0x0a
  99. static hda_nid_t alc260_dac_nids[1] = {
  100. /* front */
  101. 0x02,
  102. };
  103. static hda_nid_t alc260_adc_nids[2] = {
  104. /* ADC0-1 */
  105. 0x04, 0x05,
  106. };
  107. #define ALC260_DIGOUT_NID 0x03
  108. #define ALC260_DIGIN_NID 0x06
  109. static struct hda_input_mux alc880_capture_source = {
  110. .num_items = 4,
  111. .items = {
  112. { "Mic", 0x0 },
  113. { "Front Mic", 0x3 },
  114. { "Line", 0x2 },
  115. { "CD", 0x4 },
  116. },
  117. };
  118. static struct hda_input_mux alc260_capture_source = {
  119. .num_items = 4,
  120. .items = {
  121. { "Mic", 0x0 },
  122. { "Front Mic", 0x1 },
  123. { "Line", 0x2 },
  124. { "CD", 0x4 },
  125. },
  126. };
  127. /*
  128. * input MUX handling
  129. */
  130. static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  131. {
  132. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  133. struct alc_spec *spec = codec->spec;
  134. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  135. }
  136. static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  137. {
  138. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  139. struct alc_spec *spec = codec->spec;
  140. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  141. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  142. return 0;
  143. }
  144. static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  145. {
  146. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  147. struct alc_spec *spec = codec->spec;
  148. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  149. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  150. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  151. }
  152. /*
  153. * channel mode setting
  154. */
  155. struct alc_channel_mode {
  156. int channels;
  157. const struct hda_verb *sequence;
  158. };
  159. /*
  160. * channel source setting (2/6 channel selection for 3-stack)
  161. */
  162. /*
  163. * set the path ways for 2 channel output
  164. * need to set the codec line out and mic 1 pin widgets to inputs
  165. */
  166. static struct hda_verb alc880_threestack_ch2_init[] = {
  167. /* set pin widget 1Ah (line in) for input */
  168. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  169. /* set pin widget 18h (mic1) for input, for mic also enable the vref */
  170. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  171. /* mute the output for Line In PW */
  172. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  173. /* mute for Mic1 PW */
  174. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  175. { } /* end */
  176. };
  177. /*
  178. * 6ch mode
  179. * need to set the codec line out and mic 1 pin widgets to outputs
  180. */
  181. static struct hda_verb alc880_threestack_ch6_init[] = {
  182. /* set pin widget 1Ah (line in) for output */
  183. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  184. /* set pin widget 18h (mic1) for output */
  185. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  186. /* unmute the output for Line In PW */
  187. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
  188. /* unmute for Mic1 PW */
  189. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
  190. /* for rear channel output using Line In 1
  191. * set select widget connection (nid = 0x12) - to summer node
  192. * for rear NID = 0x0f...offset 3 in connection list
  193. */
  194. { 0x12, AC_VERB_SET_CONNECT_SEL, 0x3 },
  195. /* for Mic1 - retask for center/lfe */
  196. /* set select widget connection (nid = 0x10) - to summer node for
  197. * front CLFE NID = 0x0e...offset 2 in connection list
  198. */
  199. { 0x10, AC_VERB_SET_CONNECT_SEL, 0x2 },
  200. { } /* end */
  201. };
  202. static struct alc_channel_mode alc880_threestack_modes[2] = {
  203. { 2, alc880_threestack_ch2_init },
  204. { 6, alc880_threestack_ch6_init },
  205. };
  206. /*
  207. * channel source setting (6/8 channel selection for 5-stack)
  208. */
  209. /* set the path ways for 6 channel output
  210. * need to set the codec line out and mic 1 pin widgets to inputs
  211. */
  212. static struct hda_verb alc880_fivestack_ch6_init[] = {
  213. /* set pin widget 1Ah (line in) for input */
  214. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  215. /* mute the output for Line In PW */
  216. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  217. { } /* end */
  218. };
  219. /* need to set the codec line out and mic 1 pin widgets to outputs */
  220. static struct hda_verb alc880_fivestack_ch8_init[] = {
  221. /* set pin widget 1Ah (line in) for output */
  222. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  223. /* unmute the output for Line In PW */
  224. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
  225. /* output for surround channel output using Line In 1 */
  226. /* set select widget connection (nid = 0x12) - to summer node
  227. * for surr_rear NID = 0x0d...offset 1 in connection list
  228. */
  229. { 0x12, AC_VERB_SET_CONNECT_SEL, 0x1 },
  230. { } /* end */
  231. };
  232. static struct alc_channel_mode alc880_fivestack_modes[2] = {
  233. { 6, alc880_fivestack_ch6_init },
  234. { 8, alc880_fivestack_ch8_init },
  235. };
  236. /*
  237. * channel source setting for W810 system
  238. *
  239. * W810 has rear IO for:
  240. * Front (DAC 02)
  241. * Surround (DAC 03)
  242. * Center/LFE (DAC 04)
  243. * Digital out (06)
  244. *
  245. * The system also has a pair of internal speakers, and a headphone jack.
  246. * These are both connected to Line2 on the codec, hence to DAC 02.
  247. *
  248. * There is a variable resistor to control the speaker or headphone
  249. * volume. This is a hardware-only device without a software API.
  250. *
  251. * Plugging headphones in will disable the internal speakers. This is
  252. * implemented in hardware, not via the driver using jack sense. In
  253. * a similar fashion, plugging into the rear socket marked "front" will
  254. * disable both the speakers and headphones.
  255. *
  256. * For input, there's a microphone jack, and an "audio in" jack.
  257. * These may not do anything useful with this driver yet, because I
  258. * haven't setup any initialization verbs for these yet...
  259. */
  260. static struct alc_channel_mode alc880_w810_modes[1] = {
  261. { 6, NULL }
  262. };
  263. static struct alc_channel_mode alc880_z71v_modes[1] = {
  264. { 2, NULL }
  265. };
  266. /*
  267. */
  268. static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
  273. snd_assert(spec->channel_mode, return -ENXIO);
  274. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  275. uinfo->count = 1;
  276. uinfo->value.enumerated.items = items;
  277. if (uinfo->value.enumerated.item >= items)
  278. uinfo->value.enumerated.item = items - 1;
  279. sprintf(uinfo->value.enumerated.name, "%dch",
  280. spec->channel_mode[uinfo->value.enumerated.item].channels);
  281. return 0;
  282. }
  283. static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  284. {
  285. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  286. struct alc_spec *spec = codec->spec;
  287. int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
  288. int i;
  289. snd_assert(spec->channel_mode, return -ENXIO);
  290. for (i = 0; i < items; i++) {
  291. if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
  292. ucontrol->value.enumerated.item[0] = i;
  293. break;
  294. }
  295. }
  296. return 0;
  297. }
  298. static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  299. {
  300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  301. struct alc_spec *spec = codec->spec;
  302. int mode;
  303. snd_assert(spec->channel_mode, return -ENXIO);
  304. mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
  305. if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
  306. ! codec->in_resume)
  307. return 0;
  308. /* change the current channel setting */
  309. spec->multiout.max_channels = spec->channel_mode[mode].channels;
  310. if (spec->channel_mode[mode].sequence)
  311. snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
  312. return 1;
  313. }
  314. /*
  315. * bound volume controls
  316. *
  317. * bind multiple volumes (# indices, from 0)
  318. */
  319. #define AMP_VAL_IDX_SHIFT 19
  320. #define AMP_VAL_IDX_MASK (0x0f<<19)
  321. static int alc_bind_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  322. {
  323. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  324. struct alc_spec *spec = codec->spec;
  325. unsigned long pval;
  326. down(&spec->bind_mutex);
  327. pval = kcontrol->private_value;
  328. kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
  329. snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
  330. kcontrol->private_value = pval;
  331. up(&spec->bind_mutex);
  332. return 0;
  333. }
  334. static int alc_bind_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  335. {
  336. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  337. struct alc_spec *spec = codec->spec;
  338. unsigned long pval;
  339. down(&spec->bind_mutex);
  340. pval = kcontrol->private_value;
  341. kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
  342. snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
  343. kcontrol->private_value = pval;
  344. up(&spec->bind_mutex);
  345. return 0;
  346. }
  347. static int alc_bind_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  348. {
  349. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  350. struct alc_spec *spec = codec->spec;
  351. unsigned long pval;
  352. int i, indices, change = 0;
  353. down(&spec->bind_mutex);
  354. pval = kcontrol->private_value;
  355. indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
  356. for (i = 0; i < indices; i++) {
  357. kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
  358. change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
  359. }
  360. kcontrol->private_value = pval;
  361. up(&spec->bind_mutex);
  362. return change;
  363. }
  364. #define ALC_BIND_VOL_MONO(xname, nid, channel, indices, direction) \
  365. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  366. .info = alc_bind_vol_info, \
  367. .get = alc_bind_vol_get, \
  368. .put = alc_bind_vol_put, \
  369. .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
  370. #define ALC_BIND_VOL(xname,nid,indices,dir) ALC_BIND_VOL_MONO(xname,nid,3,indices,dir)
  371. /*
  372. */
  373. /* 3-stack mode
  374. * Pin assignment: Front=0x14, Line-In/Rear=0x1a, Mic/CLFE=0x18, F-Mic=0x1b
  375. * HP=0x19
  376. */
  377. static snd_kcontrol_new_t alc880_base_mixer[] = {
  378. ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT),
  379. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  380. ALC_BIND_VOL("Surround Playback Volume", 0x0f, 2, HDA_OUTPUT),
  381. HDA_CODEC_MUTE("Surround Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
  382. ALC_BIND_VOL_MONO("Center Playback Volume", 0x0e, 1, 2, HDA_OUTPUT),
  383. ALC_BIND_VOL_MONO("LFE Playback Volume", 0x0e, 2, 2, HDA_OUTPUT),
  384. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x18, 1, 0x0, HDA_OUTPUT),
  385. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x18, 2, 0x0, HDA_OUTPUT),
  386. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  387. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  388. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  389. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  390. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  391. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  392. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  393. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  394. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  395. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  396. ALC_BIND_VOL("Headphone Playback Volume", 0x0d, 2, HDA_OUTPUT),
  397. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  398. /* We don't use NID 0x07 - see above */
  399. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  400. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  401. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  402. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  403. {
  404. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  405. /* The multiple "Capture Source" controls confuse alsamixer
  406. * So call somewhat different..
  407. * FIXME: the controls appear in the "playback" view!
  408. */
  409. /* .name = "Capture Source", */
  410. .name = "Input Source",
  411. .count = 2,
  412. .info = alc_mux_enum_info,
  413. .get = alc_mux_enum_get,
  414. .put = alc_mux_enum_put,
  415. },
  416. {
  417. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  418. .name = "Channel Mode",
  419. .info = alc880_ch_mode_info,
  420. .get = alc880_ch_mode_get,
  421. .put = alc880_ch_mode_put,
  422. },
  423. { } /* end */
  424. };
  425. /* 5-stack mode
  426. * Pin assignment: Front=0x14, Rear=0x17, CLFE=0x16
  427. * Line-In/Side=0x1a, Mic=0x18, F-Mic=0x1b, HP=0x19
  428. */
  429. static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
  430. ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT),
  431. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  432. ALC_BIND_VOL("Surround Playback Volume", 0x0f, 2, HDA_OUTPUT),
  433. HDA_CODEC_MUTE("Surround Playback Switch", 0x17, 0x0, HDA_OUTPUT),
  434. ALC_BIND_VOL_MONO("Center Playback Volume", 0x0e, 1, 2, HDA_OUTPUT),
  435. ALC_BIND_VOL_MONO("LFE Playback Volume", 0x0e, 2, 2, HDA_OUTPUT),
  436. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  437. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  438. ALC_BIND_VOL("Side Playback Volume", 0x0d, 2, HDA_OUTPUT),
  439. HDA_CODEC_MUTE("Side Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
  440. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  441. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  442. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  443. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  444. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  445. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  446. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  447. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  448. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  449. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  450. /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), */
  451. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  452. /* We don't use NID 0x07 - see above */
  453. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  454. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  455. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  456. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  457. {
  458. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  459. /* The multiple "Capture Source" controls confuse alsamixer
  460. * So call somewhat different..
  461. * FIXME: the controls appear in the "playback" view!
  462. */
  463. /* .name = "Capture Source", */
  464. .name = "Input Source",
  465. .count = 2,
  466. .info = alc_mux_enum_info,
  467. .get = alc_mux_enum_get,
  468. .put = alc_mux_enum_put,
  469. },
  470. {
  471. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  472. .name = "Channel Mode",
  473. .info = alc880_ch_mode_info,
  474. .get = alc880_ch_mode_get,
  475. .put = alc880_ch_mode_put,
  476. },
  477. { } /* end */
  478. };
  479. static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
  480. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  481. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  482. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  483. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  484. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  485. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  486. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  487. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  488. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  489. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  490. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  491. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  492. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  493. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  494. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  495. {
  496. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  497. /* The multiple "Capture Source" controls confuse alsamixer
  498. * So call somewhat different..
  499. * FIXME: the controls appear in the "playback" view!
  500. */
  501. /* .name = "Capture Source", */
  502. .name = "Input Source",
  503. .count = 3,
  504. .info = alc_mux_enum_info,
  505. .get = alc_mux_enum_get,
  506. .put = alc_mux_enum_put,
  507. },
  508. { } /* end */
  509. };
  510. static snd_kcontrol_new_t alc880_z71v_mixer[] = {
  511. ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT),
  512. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  513. ALC_BIND_VOL("Headphone Playback Volume", 0x0d, 2, HDA_OUTPUT),
  514. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  515. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  516. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  517. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  518. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  519. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  520. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  521. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  522. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  523. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  524. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  525. {
  526. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  527. /* The multiple "Capture Source" controls confuse alsamixer
  528. * So call somewhat different..
  529. * FIXME: the controls appear in the "playback" view!
  530. */
  531. /* .name = "Capture Source", */
  532. .name = "Input Source",
  533. .count = 3,
  534. .info = alc_mux_enum_info,
  535. .get = alc_mux_enum_get,
  536. .put = alc_mux_enum_put,
  537. },
  538. { } /* end */
  539. };
  540. /*
  541. */
  542. static int alc_build_controls(struct hda_codec *codec)
  543. {
  544. struct alc_spec *spec = codec->spec;
  545. int err;
  546. int i;
  547. for (i = 0; i < spec->num_mixers; i++) {
  548. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  549. if (err < 0)
  550. return err;
  551. }
  552. if (spec->multiout.dig_out_nid) {
  553. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  554. if (err < 0)
  555. return err;
  556. }
  557. if (spec->dig_in_nid) {
  558. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  559. if (err < 0)
  560. return err;
  561. }
  562. return 0;
  563. }
  564. /*
  565. * initialize the codec volumes, etc
  566. */
  567. static struct hda_verb alc880_init_verbs_three_stack[] = {
  568. /* Line In pin widget for input */
  569. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  570. /* CD pin widget for input */
  571. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  572. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  573. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  574. /* Mic2 (front panel) pin widget for input and vref at 80% */
  575. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  576. /* unmute amp left and right */
  577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  578. /* set connection select to mic in */
  579. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  580. /* unmute amp left and right */
  581. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  582. /* set connection select to mic in */
  583. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  584. /* unmute amp left and right */
  585. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  586. /* set connection select to mic in */
  587. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  588. /* unmute front mixer amp left (volume = 0) */
  589. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  590. /* mute pin widget amp left and right (no gain on this amp) */
  591. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  592. /* unmute rear mixer amp left and right (volume = 0) */
  593. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  594. /* mute pin widget amp left and right (no gain on this amp) */
  595. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  596. /* unmute rear mixer amp left and right (volume = 0) */
  597. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  598. /* mute pin widget amp left and right (no gain on this amp) */
  599. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  600. /* using rear surround as the path for headphone output */
  601. /* unmute rear surround mixer amp left and right (volume = 0) */
  602. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  603. /* PASD 3 stack boards use the Mic 2 as the headphone output */
  604. /* need to program the selector associated with the Mic 2 pin widget to
  605. * surround path (index 0x01) for headphone output */
  606. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  607. /* mute pin widget amp left and right (no gain on this amp) */
  608. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  609. /* need to retask the Mic 2 pin widget to output */
  610. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  611. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer widget(nid=0x0B)
  612. * to support the input path of analog loopback
  613. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  614. * mic (mic 2)
  615. */
  616. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  617. /* unmute CD */
  618. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  619. /* unmute Line In */
  620. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  621. /* unmute Mic 1 */
  622. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  623. /* unmute Line In 2 (for PASD boards Mic 2) */
  624. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  625. /* Unmute input amps for the line out paths to support the output path of
  626. * analog loopback
  627. * the mixers on the output path has 2 inputs, one from the DAC and one
  628. * from the mixer
  629. */
  630. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  631. /* Unmute Front out path */
  632. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  633. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  634. /* Unmute Surround (used as HP) out path */
  635. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  636. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  637. /* Unmute C/LFE out path */
  638. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  639. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */
  640. /* Unmute rear Surround out path */
  641. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  642. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  643. { }
  644. };
  645. static struct hda_verb alc880_init_verbs_five_stack[] = {
  646. /* Line In pin widget for input */
  647. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  648. /* CD pin widget for input */
  649. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  650. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  651. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  652. /* Mic2 (front panel) pin widget for input and vref at 80% */
  653. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  654. /* unmute amp left and right */
  655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  656. /* set connection select to mic in */
  657. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  658. /* unmute amp left and right */
  659. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  660. /* set connection select to mic in */
  661. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  662. /* unmute amp left and right */
  663. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  664. /* set connection select to mic in */
  665. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  666. /* unmute front mixer amp left and right (volume = 0) */
  667. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  668. /* mute pin widget amp left and right (no gain on this amp) */
  669. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  670. /* five rear and clfe */
  671. /* unmute rear mixer amp left and right (volume = 0) */
  672. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  673. /* mute pin widget amp left and right (no gain on this amp) */
  674. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  675. /* unmute clfe mixer amp left and right (volume = 0) */
  676. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  677. /* mute pin widget amp left and right (no gain on this amp) */
  678. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  679. /* using rear surround as the path for headphone output */
  680. /* unmute rear surround mixer amp left and right (volume = 0) */
  681. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  682. /* PASD 3 stack boards use the Mic 2 as the headphone output */
  683. /* need to program the selector associated with the Mic 2 pin widget to
  684. * surround path (index 0x01) for headphone output
  685. */
  686. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  687. /* mute pin widget amp left and right (no gain on this amp) */
  688. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  689. /* need to retask the Mic 2 pin widget to output */
  690. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  691. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer
  692. * widget(nid=0x0B) to support the input path of analog loopback
  693. */
  694. /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */
  695. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/
  696. /* unmute CD */
  697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  698. /* unmute Line In */
  699. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  700. /* unmute Mic 1 */
  701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  702. /* unmute Line In 2 (for PASD boards Mic 2) */
  703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  704. /* Unmute input amps for the line out paths to support the output path of
  705. * analog loopback
  706. * the mixers on the output path has 2 inputs, one from the DAC and
  707. * one from the mixer
  708. */
  709. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  710. /* Unmute Front out path */
  711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  712. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  713. /* Unmute Surround (used as HP) out path */
  714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  715. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  716. /* Unmute C/LFE out path */
  717. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  718. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */
  719. /* Unmute rear Surround out path */
  720. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  721. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  722. { }
  723. };
  724. static struct hda_verb alc880_w810_init_verbs[] = {
  725. /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  726. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  727. /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  728. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  729. /* front channel selector/amp: output 0: unmuted, max volume */
  730. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  731. /* front out pin: muted, (no volume selection) */
  732. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  733. /* front out pin: NOT headphone enable, out enable, vref disabled */
  734. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  735. /* surround channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  736. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  737. /* surround channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  738. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  739. /* surround channel selector/amp: output 0: unmuted, max volume */
  740. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  741. /* surround out pin: muted, (no volume selection) */
  742. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  743. /* surround out pin: NOT headphone enable, out enable, vref disabled */
  744. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  745. /* c/lfe channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  746. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  747. /* c/lfe channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  748. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  749. /* c/lfe channel selector/amp: output 0: unmuted, max volume */
  750. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  751. /* c/lfe out pin: muted, (no volume selection) */
  752. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  753. /* c/lfe out pin: NOT headphone enable, out enable, vref disabled */
  754. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  755. /* hphone/speaker input selector: front DAC */
  756. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  757. /* hphone/speaker out pin: muted, (no volume selection) */
  758. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  759. /* hphone/speaker out pin: NOT headphone enable, out enable, vref disabled */
  760. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  761. { }
  762. };
  763. static struct hda_verb alc880_z71v_init_verbs[] = {
  764. /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  765. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  766. /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  767. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  768. /* front channel selector/amp: output 0: unmuted, max volume */
  769. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  770. /* front out pin: muted, (no volume selection) */
  771. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  772. /* front out pin: NOT headphone enable, out enable, vref disabled */
  773. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  774. /* headphone channel selector/amp: input 0: DAC: unmuted, (no volume selection) */
  775. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  776. /* headphone channel selector/amp: input 1: capture mix: muted, (no volume selection) */
  777. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180},
  778. /* headphone channel selector/amp: output 0: unmuted, max volume */
  779. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  780. /* headphone out pin: muted, (no volume selection) */
  781. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  782. /* headpohne out pin: headphone enable, out enable, vref disabled */
  783. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  784. /* Line In pin widget for input */
  785. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  786. /* CD pin widget for input */
  787. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  788. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  789. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  790. /* Mic2 (front panel) pin widget for input and vref at 80% */
  791. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  792. /* unmute amp left and right */
  793. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  794. /* set connection select to mic in */
  795. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  796. /* unmute amp left and right */
  797. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  798. /* set connection select to mic in */
  799. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  800. /* unmute amp left and right */
  801. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  802. /* set connection select to mic in */
  803. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  804. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer
  805. * widget(nid=0x0B) to support the input path of analog loopback
  806. */
  807. /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */
  808. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/
  809. /* unmute CD */
  810. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  811. /* unmute Line In */
  812. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  813. /* unmute Mic 1 */
  814. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  815. /* unmute Line In 2 (for PASD boards Mic 2) */
  816. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  817. { }
  818. };
  819. static int alc_init(struct hda_codec *codec)
  820. {
  821. struct alc_spec *spec = codec->spec;
  822. snd_hda_sequence_write(codec, spec->init_verbs);
  823. return 0;
  824. }
  825. #ifdef CONFIG_PM
  826. /*
  827. * resume
  828. */
  829. static int alc_resume(struct hda_codec *codec)
  830. {
  831. struct alc_spec *spec = codec->spec;
  832. int i;
  833. alc_init(codec);
  834. for (i = 0; i < spec->num_mixers; i++) {
  835. snd_hda_resume_ctls(codec, spec->mixers[i]);
  836. }
  837. if (spec->multiout.dig_out_nid)
  838. snd_hda_resume_spdif_out(codec);
  839. if (spec->dig_in_nid)
  840. snd_hda_resume_spdif_in(codec);
  841. return 0;
  842. }
  843. #endif
  844. /*
  845. * Analog playback callbacks
  846. */
  847. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  848. struct hda_codec *codec,
  849. snd_pcm_substream_t *substream)
  850. {
  851. struct alc_spec *spec = codec->spec;
  852. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  853. }
  854. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  855. struct hda_codec *codec,
  856. unsigned int stream_tag,
  857. unsigned int format,
  858. snd_pcm_substream_t *substream)
  859. {
  860. struct alc_spec *spec = codec->spec;
  861. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  862. format, substream);
  863. }
  864. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  865. struct hda_codec *codec,
  866. snd_pcm_substream_t *substream)
  867. {
  868. struct alc_spec *spec = codec->spec;
  869. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  870. }
  871. /*
  872. * Digital out
  873. */
  874. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  875. struct hda_codec *codec,
  876. snd_pcm_substream_t *substream)
  877. {
  878. struct alc_spec *spec = codec->spec;
  879. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  880. }
  881. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  882. struct hda_codec *codec,
  883. snd_pcm_substream_t *substream)
  884. {
  885. struct alc_spec *spec = codec->spec;
  886. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  887. }
  888. /*
  889. * Analog capture
  890. */
  891. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  892. struct hda_codec *codec,
  893. unsigned int stream_tag,
  894. unsigned int format,
  895. snd_pcm_substream_t *substream)
  896. {
  897. struct alc_spec *spec = codec->spec;
  898. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  899. stream_tag, 0, format);
  900. return 0;
  901. }
  902. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  903. struct hda_codec *codec,
  904. snd_pcm_substream_t *substream)
  905. {
  906. struct alc_spec *spec = codec->spec;
  907. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  908. return 0;
  909. }
  910. /*
  911. */
  912. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  913. .substreams = 1,
  914. .channels_min = 2,
  915. .channels_max = 8,
  916. .nid = 0x02, /* NID to query formats and rates */
  917. .ops = {
  918. .open = alc880_playback_pcm_open,
  919. .prepare = alc880_playback_pcm_prepare,
  920. .cleanup = alc880_playback_pcm_cleanup
  921. },
  922. };
  923. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  924. .substreams = 2,
  925. .channels_min = 2,
  926. .channels_max = 2,
  927. .nid = 0x08, /* NID to query formats and rates
  928. * (0x07 might be broken on some devices)
  929. */
  930. .ops = {
  931. .prepare = alc880_capture_pcm_prepare,
  932. .cleanup = alc880_capture_pcm_cleanup
  933. },
  934. };
  935. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  936. .substreams = 1,
  937. .channels_min = 2,
  938. .channels_max = 2,
  939. /* NID is set in alc_build_pcms */
  940. .ops = {
  941. .open = alc880_dig_playback_pcm_open,
  942. .close = alc880_dig_playback_pcm_close
  943. },
  944. };
  945. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  946. .substreams = 1,
  947. .channels_min = 2,
  948. .channels_max = 2,
  949. /* NID is set in alc_build_pcms */
  950. };
  951. static int alc_build_pcms(struct hda_codec *codec)
  952. {
  953. struct alc_spec *spec = codec->spec;
  954. struct hda_pcm *info = spec->pcm_rec;
  955. int i;
  956. codec->num_pcms = 1;
  957. codec->pcm_info = info;
  958. info->name = spec->stream_name_analog;
  959. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  960. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  961. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  962. for (i = 0; i < spec->num_channel_mode; i++) {
  963. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  964. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  965. }
  966. }
  967. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  968. codec->num_pcms++;
  969. info++;
  970. info->name = spec->stream_name_digital;
  971. if (spec->multiout.dig_out_nid) {
  972. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  973. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  974. }
  975. if (spec->dig_in_nid) {
  976. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  977. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  978. }
  979. }
  980. return 0;
  981. }
  982. static void alc_free(struct hda_codec *codec)
  983. {
  984. kfree(codec->spec);
  985. }
  986. /*
  987. */
  988. static struct hda_codec_ops alc_patch_ops = {
  989. .build_controls = alc_build_controls,
  990. .build_pcms = alc_build_pcms,
  991. .init = alc_init,
  992. .free = alc_free,
  993. #ifdef CONFIG_PM
  994. .resume = alc_resume,
  995. #endif
  996. };
  997. /*
  998. * Test configuration for debugging
  999. *
  1000. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1001. * enum controls.
  1002. */
  1003. #ifdef CONFIG_SND_DEBUG
  1004. static hda_nid_t alc880_test_dac_nids[4] = {
  1005. 0x02, 0x03, 0x04, 0x05
  1006. };
  1007. static struct hda_input_mux alc880_test_capture_source = {
  1008. .num_items = 5,
  1009. .items = {
  1010. { "In-1", 0x0 },
  1011. { "In-2", 0x1 },
  1012. { "In-3", 0x2 },
  1013. { "In-4", 0x3 },
  1014. { "CD", 0x4 },
  1015. },
  1016. };
  1017. static struct alc_channel_mode alc880_test_modes[4] = {
  1018. { 2, NULL },
  1019. { 4, NULL },
  1020. { 6, NULL },
  1021. { 8, NULL },
  1022. };
  1023. static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1024. {
  1025. static char *texts[] = {
  1026. "N/A", "Line Out", "HP Out",
  1027. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1028. };
  1029. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1030. uinfo->count = 1;
  1031. uinfo->value.enumerated.items = 8;
  1032. if (uinfo->value.enumerated.item >= 8)
  1033. uinfo->value.enumerated.item = 7;
  1034. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1035. return 0;
  1036. }
  1037. static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1038. {
  1039. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1040. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1041. unsigned int pin_ctl, item = 0;
  1042. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1043. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1044. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1045. if (pin_ctl & AC_PINCTL_HP_EN)
  1046. item = 2;
  1047. else
  1048. item = 1;
  1049. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1050. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1051. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1052. case AC_PINCTL_VREF_50: item = 4; break;
  1053. case AC_PINCTL_VREF_GRD: item = 5; break;
  1054. case AC_PINCTL_VREF_80: item = 6; break;
  1055. case AC_PINCTL_VREF_100: item = 7; break;
  1056. }
  1057. }
  1058. ucontrol->value.enumerated.item[0] = item;
  1059. return 0;
  1060. }
  1061. static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1062. {
  1063. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1064. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1065. static unsigned int ctls[] = {
  1066. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1067. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1068. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1069. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1070. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1071. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1072. };
  1073. unsigned int old_ctl, new_ctl;
  1074. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1075. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1076. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1077. if (old_ctl != new_ctl) {
  1078. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1079. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1080. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1081. return 1;
  1082. }
  1083. return 0;
  1084. }
  1085. static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1086. {
  1087. static char *texts[] = {
  1088. "Front", "Surround", "CLFE", "Side"
  1089. };
  1090. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1091. uinfo->count = 1;
  1092. uinfo->value.enumerated.items = 4;
  1093. if (uinfo->value.enumerated.item >= 4)
  1094. uinfo->value.enumerated.item = 3;
  1095. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1096. return 0;
  1097. }
  1098. static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1099. {
  1100. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1101. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1102. unsigned int sel;
  1103. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1104. ucontrol->value.enumerated.item[0] = sel & 3;
  1105. return 0;
  1106. }
  1107. static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1108. {
  1109. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1110. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1111. unsigned int sel;
  1112. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1113. if (ucontrol->value.enumerated.item[0] != sel) {
  1114. sel = ucontrol->value.enumerated.item[0] & 3;
  1115. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1116. return 1;
  1117. }
  1118. return 0;
  1119. }
  1120. #define PIN_CTL_TEST(xname,nid) { \
  1121. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1122. .name = xname, \
  1123. .info = alc_test_pin_ctl_info, \
  1124. .get = alc_test_pin_ctl_get, \
  1125. .put = alc_test_pin_ctl_put, \
  1126. .private_value = nid \
  1127. }
  1128. #define PIN_SRC_TEST(xname,nid) { \
  1129. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1130. .name = xname, \
  1131. .info = alc_test_pin_src_info, \
  1132. .get = alc_test_pin_src_get, \
  1133. .put = alc_test_pin_src_put, \
  1134. .private_value = nid \
  1135. }
  1136. static snd_kcontrol_new_t alc880_test_mixer[] = {
  1137. ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT),
  1138. ALC_BIND_VOL("Surround Playback Volume", 0x0d, 2, HDA_OUTPUT),
  1139. ALC_BIND_VOL("CLFE Playback Volume", 0x0e, 2, HDA_OUTPUT),
  1140. ALC_BIND_VOL("Side Playback Volume", 0x0f, 2, HDA_OUTPUT),
  1141. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1142. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1143. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1144. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1145. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1146. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1147. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1148. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1149. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1150. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1151. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1152. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1153. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1154. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1155. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1156. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1157. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1158. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1159. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1160. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1161. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1162. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1163. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  1164. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  1165. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  1166. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  1167. {
  1168. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1169. .name = "Input Source",
  1170. .count = 2,
  1171. .info = alc_mux_enum_info,
  1172. .get = alc_mux_enum_get,
  1173. .put = alc_mux_enum_put,
  1174. },
  1175. {
  1176. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1177. .name = "Channel Mode",
  1178. .info = alc880_ch_mode_info,
  1179. .get = alc880_ch_mode_get,
  1180. .put = alc880_ch_mode_put,
  1181. .private_value = ARRAY_SIZE(alc880_test_modes),
  1182. },
  1183. { } /* end */
  1184. };
  1185. static struct hda_verb alc880_test_init_verbs[] = {
  1186. /* Unmute inputs of 0x0c - 0x0f */
  1187. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1188. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100},
  1189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1190. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100},
  1191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100},
  1193. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1194. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100},
  1195. /* Vol output for 0x0c-0x0f */
  1196. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1197. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1198. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1199. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1200. /* Set output pins 0x14-0x17 */
  1201. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1202. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1203. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1204. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1205. /* Unmute output pins 0x14-0x17 */
  1206. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1207. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1208. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1209. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1210. /* Set input pins 0x18-0x1c */
  1211. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, /* vref 80% */
  1212. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1213. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1214. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1215. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1216. /* Mute input pins 0x18-0x1b */
  1217. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1218. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1219. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1220. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1221. /* ADC set up */
  1222. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1223. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1224. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1225. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1226. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1227. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1228. { }
  1229. };
  1230. #endif
  1231. /*
  1232. */
  1233. static struct hda_board_config alc880_cfg_tbl[] = {
  1234. /* Back 3 jack, front 2 jack */
  1235. { .modelname = "3stack", .config = ALC880_3ST },
  1236. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1237. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1238. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1239. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1240. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1241. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1242. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1243. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1244. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1245. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1246. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1247. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1248. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1249. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1250. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1251. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1252. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1253. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1254. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1255. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1256. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1257. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1258. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1259. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1260. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1261. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1262. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1263. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1264. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1265. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1266. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1267. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1268. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1269. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1270. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1271. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1272. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1273. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1274. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1275. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1276. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1277. /* Back 5 jack, front 2 jack */
  1278. { .modelname = "5stack", .config = ALC880_5ST },
  1279. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1280. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1281. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1282. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1283. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1284. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1285. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1286. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1287. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1288. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1289. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1290. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1291. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1292. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1293. { .modelname = "w810", .config = ALC880_W810 },
  1294. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1295. { .modelname = "z71v", .config = ALC880_Z71V },
  1296. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1297. #ifdef CONFIG_SND_DEBUG
  1298. { .modelname = "test", .config = ALC880_TEST },
  1299. #endif
  1300. {}
  1301. };
  1302. static int patch_alc880(struct hda_codec *codec)
  1303. {
  1304. struct alc_spec *spec;
  1305. int board_config;
  1306. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1307. if (spec == NULL)
  1308. return -ENOMEM;
  1309. init_MUTEX(&spec->bind_mutex);
  1310. codec->spec = spec;
  1311. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  1312. if (board_config < 0) {
  1313. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC880\n");
  1314. board_config = ALC880_MINIMAL;
  1315. }
  1316. switch (board_config) {
  1317. case ALC880_W810:
  1318. spec->mixers[spec->num_mixers] = alc880_w810_base_mixer;
  1319. spec->num_mixers++;
  1320. break;
  1321. case ALC880_5ST:
  1322. case ALC880_5ST_DIG:
  1323. spec->mixers[spec->num_mixers] = alc880_five_stack_mixer;
  1324. spec->num_mixers++;
  1325. break;
  1326. case ALC880_Z71V:
  1327. spec->mixers[spec->num_mixers] = alc880_z71v_mixer;
  1328. spec->num_mixers++;
  1329. break;
  1330. #ifdef CONFIG_SND_DEBUG
  1331. case ALC880_TEST:
  1332. spec->mixers[spec->num_mixers] = alc880_test_mixer;
  1333. spec->num_mixers++;
  1334. break;
  1335. #endif
  1336. default:
  1337. spec->mixers[spec->num_mixers] = alc880_base_mixer;
  1338. spec->num_mixers++;
  1339. break;
  1340. }
  1341. switch (board_config) {
  1342. case ALC880_3ST_DIG:
  1343. case ALC880_5ST_DIG:
  1344. case ALC880_W810:
  1345. case ALC880_Z71V:
  1346. case ALC880_TEST:
  1347. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1348. break;
  1349. default:
  1350. break;
  1351. }
  1352. switch (board_config) {
  1353. case ALC880_3ST:
  1354. case ALC880_3ST_DIG:
  1355. case ALC880_5ST:
  1356. case ALC880_5ST_DIG:
  1357. case ALC880_W810:
  1358. spec->front_panel = 1;
  1359. break;
  1360. default:
  1361. break;
  1362. }
  1363. switch (board_config) {
  1364. case ALC880_5ST:
  1365. case ALC880_5ST_DIG:
  1366. spec->init_verbs = alc880_init_verbs_five_stack;
  1367. spec->channel_mode = alc880_fivestack_modes;
  1368. spec->num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes);
  1369. break;
  1370. case ALC880_W810:
  1371. spec->init_verbs = alc880_w810_init_verbs;
  1372. spec->channel_mode = alc880_w810_modes;
  1373. spec->num_channel_mode = ARRAY_SIZE(alc880_w810_modes);
  1374. break;
  1375. case ALC880_Z71V:
  1376. spec->init_verbs = alc880_z71v_init_verbs;
  1377. spec->channel_mode = alc880_z71v_modes;
  1378. spec->num_channel_mode = ARRAY_SIZE(alc880_z71v_modes);
  1379. break;
  1380. #ifdef CONFIG_SND_DEBUG
  1381. case ALC880_TEST:
  1382. spec->init_verbs = alc880_test_init_verbs;
  1383. spec->channel_mode = alc880_test_modes;
  1384. spec->num_channel_mode = ARRAY_SIZE(alc880_test_modes);
  1385. break;
  1386. #endif
  1387. default:
  1388. spec->init_verbs = alc880_init_verbs_three_stack;
  1389. spec->channel_mode = alc880_threestack_modes;
  1390. spec->num_channel_mode = ARRAY_SIZE(alc880_threestack_modes);
  1391. break;
  1392. }
  1393. spec->stream_name_analog = "ALC880 Analog";
  1394. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1395. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1396. spec->stream_name_digital = "ALC880 Digital";
  1397. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1398. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1399. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1400. switch (board_config) {
  1401. case ALC880_W810:
  1402. spec->multiout.num_dacs = ARRAY_SIZE(alc880_w810_dac_nids);
  1403. spec->multiout.dac_nids = alc880_w810_dac_nids;
  1404. // No dedicated headphone socket - it's shared with built-in speakers.
  1405. break;
  1406. case ALC880_Z71V:
  1407. spec->multiout.num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids);
  1408. spec->multiout.dac_nids = alc880_z71v_dac_nids;
  1409. spec->multiout.hp_nid = 0x03;
  1410. break;
  1411. #ifdef CONFIG_SND_DEBUG
  1412. case ALC880_TEST:
  1413. spec->multiout.num_dacs = ARRAY_SIZE(alc880_test_dac_nids);
  1414. spec->multiout.dac_nids = alc880_test_dac_nids;
  1415. spec->input_mux = &alc880_test_capture_source;
  1416. break;
  1417. #endif
  1418. default:
  1419. spec->multiout.num_dacs = ARRAY_SIZE(alc880_dac_nids);
  1420. spec->multiout.dac_nids = alc880_dac_nids;
  1421. spec->multiout.hp_nid = 0x03; /* rear-surround NID */
  1422. break;
  1423. }
  1424. if (! spec->input_mux)
  1425. spec->input_mux = &alc880_capture_source;
  1426. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  1427. spec->adc_nids = alc880_adc_nids;
  1428. codec->patch_ops = alc_patch_ops;
  1429. return 0;
  1430. }
  1431. /*
  1432. * ALC260 support
  1433. */
  1434. /*
  1435. * This is just place-holder, so there's something for alc_build_pcms to look
  1436. * at when it calculates the maximum number of channels. ALC260 has no mixer
  1437. * element which allows changing the channel mode, so the verb list is
  1438. * never used.
  1439. */
  1440. static struct alc_channel_mode alc260_modes[1] = {
  1441. { 2, NULL },
  1442. };
  1443. snd_kcontrol_new_t alc260_base_mixer[] = {
  1444. ALC_BIND_VOL("Front Playback Volume", 0x08, 2, HDA_OUTPUT),
  1445. /* use LINE2 for the output */
  1446. /* HDA_CODEC_MUTE("Front Playback Switch", 0x0f, 0x0, HDA_OUTPUT), */
  1447. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  1448. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1449. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1450. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1451. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1452. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1453. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1454. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1455. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1456. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  1457. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  1458. ALC_BIND_VOL("Headphone Playback Volume", 0x09, 2, HDA_OUTPUT),
  1459. HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  1460. ALC_BIND_VOL_MONO("Mono Playback Volume", 0x0a, 1, 2, HDA_OUTPUT),
  1461. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  1462. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  1463. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  1464. {
  1465. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1466. .name = "Capture Source",
  1467. .info = alc_mux_enum_info,
  1468. .get = alc_mux_enum_get,
  1469. .put = alc_mux_enum_put,
  1470. },
  1471. { } /* end */
  1472. };
  1473. static struct hda_verb alc260_init_verbs[] = {
  1474. /* Line In pin widget for input */
  1475. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1476. /* CD pin widget for input */
  1477. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1478. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1479. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1480. /* Mic2 (front panel) pin widget for input and vref at 80% */
  1481. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1482. /* LINE-2 is used for line-out in rear */
  1483. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1484. /* select line-out */
  1485. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  1486. /* LINE-OUT pin */
  1487. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1488. /* enable HP */
  1489. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1490. /* enable Mono */
  1491. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1492. /* unmute amp left and right */
  1493. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1494. /* set connection select to line in (default select for this ADC) */
  1495. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  1496. /* unmute Line-Out mixer amp left and right (volume = 0) */
  1497. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1498. /* mute pin widget amp left and right (no gain on this amp) */
  1499. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1500. /* unmute HP mixer amp left and right (volume = 0) */
  1501. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1502. /* mute pin widget amp left and right (no gain on this amp) */
  1503. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1504. /* unmute Mono mixer amp left and right (volume = 0) */
  1505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1506. /* mute pin widget amp left and right (no gain on this amp) */
  1507. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1508. /* mute LINE-2 out */
  1509. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  1510. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  1511. /* unmute CD */
  1512. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  1513. /* unmute Line In */
  1514. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  1515. /* unmute Mic */
  1516. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1517. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  1518. /* Unmute Front out path */
  1519. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1520. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1521. /* Unmute Headphone out path */
  1522. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1523. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1524. /* Unmute Mono out path */
  1525. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1526. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1527. { }
  1528. };
  1529. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  1530. .substreams = 1,
  1531. .channels_min = 2,
  1532. .channels_max = 2,
  1533. .nid = 0x2,
  1534. };
  1535. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  1536. .substreams = 1,
  1537. .channels_min = 2,
  1538. .channels_max = 2,
  1539. .nid = 0x4,
  1540. };
  1541. static int patch_alc260(struct hda_codec *codec)
  1542. {
  1543. struct alc_spec *spec;
  1544. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1545. if (spec == NULL)
  1546. return -ENOMEM;
  1547. init_MUTEX(&spec->bind_mutex);
  1548. codec->spec = spec;
  1549. spec->mixers[spec->num_mixers] = alc260_base_mixer;
  1550. spec->num_mixers++;
  1551. spec->init_verbs = alc260_init_verbs;
  1552. spec->channel_mode = alc260_modes;
  1553. spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
  1554. spec->stream_name_analog = "ALC260 Analog";
  1555. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  1556. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  1557. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1558. spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
  1559. spec->multiout.dac_nids = alc260_dac_nids;
  1560. spec->input_mux = &alc260_capture_source;
  1561. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  1562. spec->adc_nids = alc260_adc_nids;
  1563. codec->patch_ops = alc_patch_ops;
  1564. return 0;
  1565. }
  1566. /*
  1567. * ALC882 support
  1568. *
  1569. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  1570. * configuration. Each pin widget can choose any input DACs and a mixer.
  1571. * Each ADC is connected from a mixer of all inputs. This makes possible
  1572. * 6-channel independent captures.
  1573. *
  1574. * In addition, an independent DAC for the multi-playback (not used in this
  1575. * driver yet).
  1576. */
  1577. static struct alc_channel_mode alc882_ch_modes[1] = {
  1578. { 8, NULL }
  1579. };
  1580. static hda_nid_t alc882_dac_nids[4] = {
  1581. /* front, rear, clfe, rear_surr */
  1582. 0x02, 0x03, 0x04, 0x05
  1583. };
  1584. static hda_nid_t alc882_adc_nids[3] = {
  1585. /* ADC0-2 */
  1586. 0x07, 0x08, 0x09,
  1587. };
  1588. /* input MUX */
  1589. /* FIXME: should be a matrix-type input source selection */
  1590. static struct hda_input_mux alc882_capture_source = {
  1591. .num_items = 4,
  1592. .items = {
  1593. { "Mic", 0x0 },
  1594. { "Front Mic", 0x1 },
  1595. { "Line", 0x2 },
  1596. { "CD", 0x4 },
  1597. },
  1598. };
  1599. #define alc882_mux_enum_info alc_mux_enum_info
  1600. #define alc882_mux_enum_get alc_mux_enum_get
  1601. static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1602. {
  1603. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1604. struct alc_spec *spec = codec->spec;
  1605. const struct hda_input_mux *imux = spec->input_mux;
  1606. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  1607. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  1608. hda_nid_t nid = capture_mixers[adc_idx];
  1609. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  1610. unsigned int i, idx;
  1611. idx = ucontrol->value.enumerated.item[0];
  1612. if (idx >= imux->num_items)
  1613. idx = imux->num_items - 1;
  1614. if (*cur_val == idx && ! codec->in_resume)
  1615. return 0;
  1616. for (i = 0; i < imux->num_items; i++) {
  1617. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  1618. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1619. v | (imux->items[i].index << 8));
  1620. }
  1621. *cur_val = idx;
  1622. return 1;
  1623. }
  1624. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  1625. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  1626. */
  1627. static snd_kcontrol_new_t alc882_base_mixer[] = {
  1628. ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT),
  1629. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1630. ALC_BIND_VOL("Surround Playback Volume", 0x0d, 2, HDA_OUTPUT),
  1631. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  1632. ALC_BIND_VOL_MONO("Center Playback Volume", 0x0e, 1, 2, HDA_OUTPUT),
  1633. ALC_BIND_VOL_MONO("LFE Playback Volume", 0x0e, 2, 2, HDA_OUTPUT),
  1634. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  1635. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  1636. ALC_BIND_VOL("Side Playback Volume", 0x0f, 2, HDA_OUTPUT),
  1637. HDA_CODEC_MUTE("Side Playback Switch", 0x17, 0x0, HDA_OUTPUT),
  1638. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1639. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1640. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1641. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1642. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1643. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1644. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1645. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1646. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1647. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1648. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1649. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  1650. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  1651. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  1652. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  1653. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  1654. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  1655. {
  1656. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1657. /* .name = "Capture Source", */
  1658. .name = "Input Source",
  1659. .count = 3,
  1660. .info = alc882_mux_enum_info,
  1661. .get = alc882_mux_enum_get,
  1662. .put = alc882_mux_enum_put,
  1663. },
  1664. { } /* end */
  1665. };
  1666. static struct hda_verb alc882_init_verbs[] = {
  1667. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  1668. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1669. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1670. /* Rear mixer */
  1671. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1672. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1673. /* CLFE mixer */
  1674. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1675. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1676. /* Side mixer */
  1677. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  1678. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1679. /* Front Pin: to output mode */
  1680. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1681. /* Front Pin: mute amp left and right (no volume) */
  1682. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1683. /* select Front mixer (0x0c, index 0) */
  1684. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  1685. /* Rear Pin */
  1686. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1687. /* Rear Pin: mute amp left and right (no volume) */
  1688. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1689. /* select Rear mixer (0x0d, index 1) */
  1690. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  1691. /* CLFE Pin */
  1692. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1693. /* CLFE Pin: mute amp left and right (no volume) */
  1694. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1695. /* select CLFE mixer (0x0e, index 2) */
  1696. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  1697. /* Side Pin */
  1698. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1699. /* Side Pin: mute amp left and right (no volume) */
  1700. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1701. /* select Side mixer (0x0f, index 3) */
  1702. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  1703. /* Headphone Pin */
  1704. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  1705. /* Headphone Pin: mute amp left and right (no volume) */
  1706. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  1707. /* select Front mixer (0x0c, index 0) */
  1708. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1709. /* Mic (rear) pin widget for input and vref at 80% */
  1710. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1711. /* Front Mic pin widget for input and vref at 80% */
  1712. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  1713. /* Line In pin widget for input */
  1714. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1715. /* CD pin widget for input */
  1716. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  1717. /* FIXME: use matrix-type input source selection */
  1718. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  1719. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  1720. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1721. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  1722. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  1723. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  1724. /* Input mixer2 */
  1725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1726. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  1727. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  1728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  1729. /* Input mixer3 */
  1730. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1731. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  1732. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  1733. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  1734. /* ADC1: unmute amp left and right */
  1735. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1736. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1737. /* ADC2: unmute amp left and right */
  1738. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1739. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1740. /* ADC3: unmute amp left and right */
  1741. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  1742. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1743. /* Unmute front loopback */
  1744. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1745. /* Unmute rear loopback */
  1746. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1747. /* Mute CLFE loopback */
  1748. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
  1749. /* Unmute side loopback */
  1750. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1751. { }
  1752. };
  1753. static int patch_alc882(struct hda_codec *codec)
  1754. {
  1755. struct alc_spec *spec;
  1756. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1757. if (spec == NULL)
  1758. return -ENOMEM;
  1759. init_MUTEX(&spec->bind_mutex);
  1760. codec->spec = spec;
  1761. spec->mixers[spec->num_mixers] = alc882_base_mixer;
  1762. spec->num_mixers++;
  1763. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1764. spec->dig_in_nid = ALC880_DIGIN_NID;
  1765. spec->front_panel = 1;
  1766. spec->init_verbs = alc882_init_verbs;
  1767. spec->channel_mode = alc882_ch_modes;
  1768. spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
  1769. spec->stream_name_analog = "ALC882 Analog";
  1770. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1771. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1772. spec->stream_name_digital = "ALC882 Digital";
  1773. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1774. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1775. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1776. spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
  1777. spec->multiout.dac_nids = alc882_dac_nids;
  1778. spec->input_mux = &alc882_capture_source;
  1779. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  1780. spec->adc_nids = alc882_adc_nids;
  1781. codec->patch_ops = alc_patch_ops;
  1782. return 0;
  1783. }
  1784. /*
  1785. * patch entries
  1786. */
  1787. struct hda_codec_preset snd_hda_preset_realtek[] = {
  1788. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  1789. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  1790. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  1791. {} /* terminator */
  1792. };