patch_realtek.c 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659
  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_3ST,
  34. ALC880_3ST_DIG,
  35. ALC880_5ST,
  36. ALC880_5ST_DIG,
  37. ALC880_W810,
  38. ALC880_Z71V,
  39. ALC880_AUTO,
  40. ALC880_6ST,
  41. ALC880_6ST_DIG,
  42. ALC880_F1734,
  43. ALC880_ASUS,
  44. ALC880_ASUS_DIG,
  45. ALC880_ASUS_W1V,
  46. ALC880_UNIWILL_DIG,
  47. #ifdef CONFIG_SND_DEBUG
  48. ALC880_TEST,
  49. #endif
  50. ALC880_MODEL_LAST /* last tag */
  51. };
  52. /* ALC260 models */
  53. enum {
  54. ALC260_BASIC,
  55. ALC260_HP,
  56. ALC260_MODEL_LAST /* last tag */
  57. };
  58. /* amp values */
  59. #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
  60. #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
  61. #define AMP_OUT_MUTE 0xb080
  62. #define AMP_OUT_UNMUTE 0xb000
  63. #define AMP_OUT_ZERO 0xb000
  64. /* pinctl values */
  65. #define PIN_IN 0x20
  66. #define PIN_VREF80 0x24
  67. #define PIN_VREF50 0x21
  68. #define PIN_OUT 0x40
  69. #define PIN_HP 0xc0
  70. struct alc_spec {
  71. /* codec parameterization */
  72. snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
  73. unsigned int num_mixers;
  74. const struct hda_verb *init_verbs[3]; /* initialization verbs
  75. * don't forget NULL termination!
  76. */
  77. unsigned int num_init_verbs;
  78. char *stream_name_analog; /* analog PCM stream */
  79. struct hda_pcm_stream *stream_analog_playback;
  80. struct hda_pcm_stream *stream_analog_capture;
  81. char *stream_name_digital; /* digital PCM stream */
  82. struct hda_pcm_stream *stream_digital_playback;
  83. struct hda_pcm_stream *stream_digital_capture;
  84. /* playback */
  85. struct hda_multi_out multiout; /* playback set-up
  86. * max_channels, dacs must be set
  87. * dig_out_nid and hp_nid are optional
  88. */
  89. /* capture */
  90. unsigned int num_adc_nids;
  91. hda_nid_t *adc_nids;
  92. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  93. /* capture source */
  94. const struct hda_input_mux *input_mux;
  95. unsigned int cur_mux[3];
  96. /* channel model */
  97. const struct alc_channel_mode *channel_mode;
  98. int num_channel_mode;
  99. /* PCM information */
  100. struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
  101. struct semaphore bind_mutex; /* for bound controls */
  102. /* dynamic controls, init_verbs and input_mux */
  103. struct auto_pin_cfg autocfg;
  104. unsigned int num_kctl_alloc, num_kctl_used;
  105. snd_kcontrol_new_t *kctl_alloc;
  106. struct hda_input_mux private_imux;
  107. hda_nid_t private_dac_nids[4];
  108. };
  109. /*
  110. * input MUX handling
  111. */
  112. static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  113. {
  114. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  115. struct alc_spec *spec = codec->spec;
  116. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  117. }
  118. static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  119. {
  120. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  121. struct alc_spec *spec = codec->spec;
  122. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  123. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  124. return 0;
  125. }
  126. static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  127. {
  128. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  129. struct alc_spec *spec = codec->spec;
  130. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  131. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  132. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  133. }
  134. /*
  135. * channel mode setting
  136. */
  137. struct alc_channel_mode {
  138. int channels;
  139. const struct hda_verb *sequence;
  140. };
  141. static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  142. {
  143. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  144. struct alc_spec *spec = codec->spec;
  145. int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
  146. snd_assert(spec->channel_mode, return -ENXIO);
  147. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  148. uinfo->count = 1;
  149. uinfo->value.enumerated.items = items;
  150. if (uinfo->value.enumerated.item >= items)
  151. uinfo->value.enumerated.item = items - 1;
  152. sprintf(uinfo->value.enumerated.name, "%dch",
  153. spec->channel_mode[uinfo->value.enumerated.item].channels);
  154. return 0;
  155. }
  156. static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  157. {
  158. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  159. struct alc_spec *spec = codec->spec;
  160. int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
  161. int i;
  162. snd_assert(spec->channel_mode, return -ENXIO);
  163. for (i = 0; i < items; i++) {
  164. if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
  165. ucontrol->value.enumerated.item[0] = i;
  166. break;
  167. }
  168. }
  169. return 0;
  170. }
  171. static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  172. {
  173. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  174. struct alc_spec *spec = codec->spec;
  175. int mode;
  176. snd_assert(spec->channel_mode, return -ENXIO);
  177. mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
  178. if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
  179. ! codec->in_resume)
  180. return 0;
  181. /* change the current channel setting */
  182. spec->multiout.max_channels = spec->channel_mode[mode].channels;
  183. if (spec->channel_mode[mode].sequence)
  184. snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
  185. return 1;
  186. }
  187. /*
  188. * bound volume controls
  189. *
  190. * bind multiple volumes (# indices, from 0)
  191. */
  192. #define AMP_VAL_IDX_SHIFT 19
  193. #define AMP_VAL_IDX_MASK (0x0f<<19)
  194. static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  195. {
  196. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  197. struct alc_spec *spec = codec->spec;
  198. unsigned long pval;
  199. down(&spec->bind_mutex);
  200. pval = kcontrol->private_value;
  201. kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
  202. snd_hda_mixer_amp_switch_info(kcontrol, uinfo);
  203. kcontrol->private_value = pval;
  204. up(&spec->bind_mutex);
  205. return 0;
  206. }
  207. static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  208. {
  209. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  210. struct alc_spec *spec = codec->spec;
  211. unsigned long pval;
  212. down(&spec->bind_mutex);
  213. pval = kcontrol->private_value;
  214. kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
  215. snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
  216. kcontrol->private_value = pval;
  217. up(&spec->bind_mutex);
  218. return 0;
  219. }
  220. static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  221. {
  222. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  223. struct alc_spec *spec = codec->spec;
  224. unsigned long pval;
  225. int i, indices, change = 0;
  226. down(&spec->bind_mutex);
  227. pval = kcontrol->private_value;
  228. indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
  229. for (i = 0; i < indices; i++) {
  230. kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
  231. change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
  232. }
  233. kcontrol->private_value = pval;
  234. up(&spec->bind_mutex);
  235. return change;
  236. }
  237. #define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
  238. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  239. .info = alc_bind_switch_info, \
  240. .get = alc_bind_switch_get, \
  241. .put = alc_bind_switch_put, \
  242. .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
  243. #define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir)
  244. /*
  245. * ALC880 3-stack model
  246. *
  247. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  248. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
  249. * HP = 0x19
  250. */
  251. static hda_nid_t alc880_dac_nids[4] = {
  252. /* front, rear, clfe, rear_surr */
  253. 0x02, 0x05, 0x04, 0x03
  254. };
  255. static hda_nid_t alc880_adc_nids[3] = {
  256. /* ADC0-2 */
  257. 0x07, 0x08, 0x09,
  258. };
  259. /* The datasheet says the node 0x07 is connected from inputs,
  260. * but it shows zero connection in the real implementation on some devices.
  261. */
  262. static hda_nid_t alc880_adc_nids_alt[2] = {
  263. /* ADC1-2 */
  264. 0x08, 0x09,
  265. };
  266. #define ALC880_DIGOUT_NID 0x06
  267. #define ALC880_DIGIN_NID 0x0a
  268. static struct hda_input_mux alc880_capture_source = {
  269. .num_items = 4,
  270. .items = {
  271. { "Mic", 0x0 },
  272. { "Front Mic", 0x3 },
  273. { "Line", 0x2 },
  274. { "CD", 0x4 },
  275. },
  276. };
  277. /* channel source setting (2/6 channel selection for 3-stack) */
  278. /* 2ch mode */
  279. static struct hda_verb alc880_threestack_ch2_init[] = {
  280. /* set line-in to input, mute it */
  281. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  282. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  283. /* set mic-in to input vref 80%, mute it */
  284. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  285. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  286. { } /* end */
  287. };
  288. /* 6ch mode */
  289. static struct hda_verb alc880_threestack_ch6_init[] = {
  290. /* set line-in to output, unmute it */
  291. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  292. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  293. /* set mic-in to output, unmute it */
  294. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  295. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  296. { } /* end */
  297. };
  298. static struct alc_channel_mode alc880_threestack_modes[2] = {
  299. { 2, alc880_threestack_ch2_init },
  300. { 6, alc880_threestack_ch6_init },
  301. };
  302. static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
  303. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  304. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  305. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  306. ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  307. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  308. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  309. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  310. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  311. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  312. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  313. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  314. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  315. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  316. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  317. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  318. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  319. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  320. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  321. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  322. {
  323. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  324. .name = "Channel Mode",
  325. .info = alc880_ch_mode_info,
  326. .get = alc880_ch_mode_get,
  327. .put = alc880_ch_mode_put,
  328. },
  329. { } /* end */
  330. };
  331. /* capture mixer elements */
  332. static snd_kcontrol_new_t alc880_capture_mixer[] = {
  333. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  334. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  335. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  336. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  337. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  338. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  339. {
  340. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  341. /* The multiple "Capture Source" controls confuse alsamixer
  342. * So call somewhat different..
  343. * FIXME: the controls appear in the "playback" view!
  344. */
  345. /* .name = "Capture Source", */
  346. .name = "Input Source",
  347. .count = 3,
  348. .info = alc_mux_enum_info,
  349. .get = alc_mux_enum_get,
  350. .put = alc_mux_enum_put,
  351. },
  352. { } /* end */
  353. };
  354. /* capture mixer elements (in case NID 0x07 not available) */
  355. static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
  356. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  357. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  358. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  359. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  360. {
  361. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  362. /* The multiple "Capture Source" controls confuse alsamixer
  363. * So call somewhat different..
  364. * FIXME: the controls appear in the "playback" view!
  365. */
  366. /* .name = "Capture Source", */
  367. .name = "Input Source",
  368. .count = 2,
  369. .info = alc_mux_enum_info,
  370. .get = alc_mux_enum_get,
  371. .put = alc_mux_enum_put,
  372. },
  373. { } /* end */
  374. };
  375. /*
  376. * ALC880 5-stack model
  377. *
  378. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
  379. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  380. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  381. */
  382. /* additional mixers to alc880_three_stack_mixer */
  383. static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
  384. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  385. ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  386. { } /* end */
  387. };
  388. /* channel source setting (6/8 channel selection for 5-stack) */
  389. /* 6ch mode */
  390. static struct hda_verb alc880_fivestack_ch6_init[] = {
  391. /* set line-in to input, mute it */
  392. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  393. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  394. { } /* end */
  395. };
  396. /* 8ch mode */
  397. static struct hda_verb alc880_fivestack_ch8_init[] = {
  398. /* set line-in to output, unmute it */
  399. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  400. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  401. { } /* end */
  402. };
  403. static struct alc_channel_mode alc880_fivestack_modes[2] = {
  404. { 6, alc880_fivestack_ch6_init },
  405. { 8, alc880_fivestack_ch8_init },
  406. };
  407. /*
  408. * ALC880 6-stack model
  409. *
  410. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
  411. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  412. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  413. */
  414. static hda_nid_t alc880_6st_dac_nids[4] = {
  415. /* front, rear, clfe, rear_surr */
  416. 0x02, 0x03, 0x04, 0x05
  417. };
  418. static struct hda_input_mux alc880_6stack_capture_source = {
  419. .num_items = 4,
  420. .items = {
  421. { "Mic", 0x0 },
  422. { "Front Mic", 0x1 },
  423. { "Line", 0x2 },
  424. { "CD", 0x4 },
  425. },
  426. };
  427. /* fixed 8-channels */
  428. static struct alc_channel_mode alc880_sixstack_modes[1] = {
  429. { 8, NULL },
  430. };
  431. static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
  432. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  433. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  434. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  435. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  436. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  437. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  438. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  439. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  440. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  441. ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  442. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  443. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  444. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  445. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  446. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  447. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  448. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  449. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  450. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  451. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  452. {
  453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  454. .name = "Channel Mode",
  455. .info = alc880_ch_mode_info,
  456. .get = alc880_ch_mode_get,
  457. .put = alc880_ch_mode_put,
  458. },
  459. { } /* end */
  460. };
  461. /*
  462. * ALC880 W810 model
  463. *
  464. * W810 has rear IO for:
  465. * Front (DAC 02)
  466. * Surround (DAC 03)
  467. * Center/LFE (DAC 04)
  468. * Digital out (06)
  469. *
  470. * The system also has a pair of internal speakers, and a headphone jack.
  471. * These are both connected to Line2 on the codec, hence to DAC 02.
  472. *
  473. * There is a variable resistor to control the speaker or headphone
  474. * volume. This is a hardware-only device without a software API.
  475. *
  476. * Plugging headphones in will disable the internal speakers. This is
  477. * implemented in hardware, not via the driver using jack sense. In
  478. * a similar fashion, plugging into the rear socket marked "front" will
  479. * disable both the speakers and headphones.
  480. *
  481. * For input, there's a microphone jack, and an "audio in" jack.
  482. * These may not do anything useful with this driver yet, because I
  483. * haven't setup any initialization verbs for these yet...
  484. */
  485. static hda_nid_t alc880_w810_dac_nids[3] = {
  486. /* front, rear/surround, clfe */
  487. 0x02, 0x03, 0x04
  488. };
  489. /* fixed 6 channels */
  490. static struct alc_channel_mode alc880_w810_modes[1] = {
  491. { 6, NULL }
  492. };
  493. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  494. static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
  495. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  496. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  497. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  498. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  499. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  500. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  501. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  502. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  503. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  504. { } /* end */
  505. };
  506. /*
  507. * Z710V model
  508. *
  509. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  510. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
  511. */
  512. static hda_nid_t alc880_z71v_dac_nids[1] = {
  513. 0x02
  514. };
  515. #define ALC880_Z71V_HP_DAC 0x03
  516. /* fixed 2 channels */
  517. static struct alc_channel_mode alc880_2_jack_modes[1] = {
  518. { 2, NULL }
  519. };
  520. static snd_kcontrol_new_t alc880_z71v_mixer[] = {
  521. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  522. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  523. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  524. ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  525. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  526. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  527. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  528. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  529. { } /* end */
  530. };
  531. /* FIXME! */
  532. /*
  533. * ALC880 F1734 model
  534. *
  535. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  536. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  537. */
  538. static hda_nid_t alc880_f1734_dac_nids[1] = {
  539. 0x03
  540. };
  541. #define ALC880_F1734_HP_DAC 0x02
  542. static snd_kcontrol_new_t alc880_f1734_mixer[] = {
  543. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  544. ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  545. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  546. ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  547. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  548. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  549. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  550. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  551. { } /* end */
  552. };
  553. /* FIXME! */
  554. /*
  555. * ALC880 ASUS model
  556. *
  557. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  558. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  559. * Mic = 0x18, Line = 0x1a
  560. */
  561. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  562. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  563. static snd_kcontrol_new_t alc880_asus_mixer[] = {
  564. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  565. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  566. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  567. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  568. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  569. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  570. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  571. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  572. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  573. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  574. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  575. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  576. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  577. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  578. {
  579. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  580. .name = "Channel Mode",
  581. .info = alc880_ch_mode_info,
  582. .get = alc880_ch_mode_get,
  583. .put = alc880_ch_mode_put,
  584. },
  585. { } /* end */
  586. };
  587. /* FIXME! */
  588. /*
  589. * ALC880 ASUS W1V model
  590. *
  591. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  592. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  593. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  594. */
  595. /* additional mixers to alc880_asus_mixer */
  596. static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
  597. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  598. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  599. { } /* end */
  600. };
  601. /*
  602. * build control elements
  603. */
  604. static int alc_build_controls(struct hda_codec *codec)
  605. {
  606. struct alc_spec *spec = codec->spec;
  607. int err;
  608. int i;
  609. for (i = 0; i < spec->num_mixers; i++) {
  610. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  611. if (err < 0)
  612. return err;
  613. }
  614. if (spec->multiout.dig_out_nid) {
  615. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  616. if (err < 0)
  617. return err;
  618. }
  619. if (spec->dig_in_nid) {
  620. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  621. if (err < 0)
  622. return err;
  623. }
  624. return 0;
  625. }
  626. /*
  627. * initialize the codec volumes, etc
  628. */
  629. /*
  630. * generic initialization of ADC, input mixers and output mixers
  631. */
  632. static struct hda_verb alc880_volume_init_verbs[] = {
  633. /*
  634. * Unmute ADC0-2 and set the default input to mic-in
  635. */
  636. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  637. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  638. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  639. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  640. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  641. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  642. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  643. * mixer widget
  644. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  645. * mic (mic 2)
  646. */
  647. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  648. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  649. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  650. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  651. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  652. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  653. /*
  654. * Set up output mixers (0x0c - 0x0f)
  655. */
  656. /* set vol=0 to output mixers */
  657. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  658. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  659. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  660. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  661. /* set up input amps for analog loopback */
  662. /* Amp Indices: DAC = 0, mixer = 1 */
  663. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  664. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  665. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  666. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  667. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  668. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  669. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  670. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  671. { }
  672. };
  673. /*
  674. * 3-stack pin configuration:
  675. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  676. */
  677. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  678. /*
  679. * preset connection lists of input pins
  680. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  681. */
  682. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  683. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  684. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  685. /*
  686. * Set pin mode and muting
  687. */
  688. /* set front pin widgets 0x14 for output */
  689. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  690. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  691. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  692. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  693. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  694. /* Mic2 (as headphone out) for HP output */
  695. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  696. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  697. /* Line In pin widget for input */
  698. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  699. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  700. /* Line2 (as front mic) pin widget for input and vref at 80% */
  701. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  702. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  703. /* CD pin widget for input */
  704. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  705. { }
  706. };
  707. /*
  708. * 5-stack pin configuration:
  709. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  710. * line-in/side = 0x1a, f-mic = 0x1b
  711. */
  712. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  713. /*
  714. * preset connection lists of input pins
  715. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  716. */
  717. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  718. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  719. /*
  720. * Set pin mode and muting
  721. */
  722. /* set pin widgets 0x14-0x17 for output */
  723. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  724. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  725. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  726. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  727. /* unmute pins for output (no gain on this amp) */
  728. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  729. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  730. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  731. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  732. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  733. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  734. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  735. /* Mic2 (as headphone out) for HP output */
  736. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  737. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  738. /* Line In pin widget for input */
  739. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  740. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  741. /* Line2 (as front mic) pin widget for input and vref at 80% */
  742. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  743. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  744. /* CD pin widget for input */
  745. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  746. { }
  747. };
  748. /*
  749. * W810 pin configuration:
  750. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  751. */
  752. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  753. /* hphone/speaker input selector: front DAC */
  754. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  755. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  756. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  757. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  758. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  759. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  760. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  761. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  762. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  763. { }
  764. };
  765. /*
  766. * Z71V pin configuration:
  767. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  768. */
  769. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  770. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  771. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  772. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  773. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  774. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  775. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  776. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  777. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  778. { }
  779. };
  780. /*
  781. * 6-stack pin configuration:
  782. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
  783. * line = 0x1a, HP = 0x1b
  784. */
  785. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  786. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  787. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  788. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  789. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  790. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  791. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  792. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  793. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  794. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  795. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  796. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  797. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  798. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  799. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  800. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  801. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  802. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  803. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  804. { }
  805. };
  806. /* FIXME! */
  807. /*
  808. * F1734 pin configuration:
  809. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  810. */
  811. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  812. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  813. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  814. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  815. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  816. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  817. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  818. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  819. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  820. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  821. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  822. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  823. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  824. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  825. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  826. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  827. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  828. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  829. { }
  830. };
  831. /* FIXME! */
  832. /*
  833. * ASUS pin configuration:
  834. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  835. */
  836. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  837. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  838. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  839. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  840. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  841. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  842. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  843. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  844. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  845. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  846. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  847. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  848. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  849. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  850. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  851. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  852. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  853. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  854. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  855. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  856. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  857. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  858. { }
  859. };
  860. /* Enable GPIO mask and set output */
  861. static struct hda_verb alc880_gpio1_init_verbs[] = {
  862. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  863. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  864. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  865. };
  866. /* Enable GPIO mask and set output */
  867. static struct hda_verb alc880_gpio2_init_verbs[] = {
  868. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  869. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  870. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  871. };
  872. /*
  873. */
  874. static int alc_init(struct hda_codec *codec)
  875. {
  876. struct alc_spec *spec = codec->spec;
  877. unsigned int i;
  878. for (i = 0; i < spec->num_init_verbs; i++)
  879. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  880. return 0;
  881. }
  882. #ifdef CONFIG_PM
  883. /*
  884. * resume
  885. */
  886. static int alc_resume(struct hda_codec *codec)
  887. {
  888. struct alc_spec *spec = codec->spec;
  889. int i;
  890. alc_init(codec);
  891. for (i = 0; i < spec->num_mixers; i++)
  892. snd_hda_resume_ctls(codec, spec->mixers[i]);
  893. if (spec->multiout.dig_out_nid)
  894. snd_hda_resume_spdif_out(codec);
  895. if (spec->dig_in_nid)
  896. snd_hda_resume_spdif_in(codec);
  897. return 0;
  898. }
  899. #endif
  900. /*
  901. * Analog playback callbacks
  902. */
  903. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  904. struct hda_codec *codec,
  905. snd_pcm_substream_t *substream)
  906. {
  907. struct alc_spec *spec = codec->spec;
  908. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  909. }
  910. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  911. struct hda_codec *codec,
  912. unsigned int stream_tag,
  913. unsigned int format,
  914. snd_pcm_substream_t *substream)
  915. {
  916. struct alc_spec *spec = codec->spec;
  917. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  918. format, substream);
  919. }
  920. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  921. struct hda_codec *codec,
  922. snd_pcm_substream_t *substream)
  923. {
  924. struct alc_spec *spec = codec->spec;
  925. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  926. }
  927. /*
  928. * Digital out
  929. */
  930. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  931. struct hda_codec *codec,
  932. snd_pcm_substream_t *substream)
  933. {
  934. struct alc_spec *spec = codec->spec;
  935. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  936. }
  937. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  938. struct hda_codec *codec,
  939. snd_pcm_substream_t *substream)
  940. {
  941. struct alc_spec *spec = codec->spec;
  942. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  943. }
  944. /*
  945. * Analog capture
  946. */
  947. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  948. struct hda_codec *codec,
  949. unsigned int stream_tag,
  950. unsigned int format,
  951. snd_pcm_substream_t *substream)
  952. {
  953. struct alc_spec *spec = codec->spec;
  954. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  955. stream_tag, 0, format);
  956. return 0;
  957. }
  958. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  959. struct hda_codec *codec,
  960. snd_pcm_substream_t *substream)
  961. {
  962. struct alc_spec *spec = codec->spec;
  963. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  964. return 0;
  965. }
  966. /*
  967. */
  968. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  969. .substreams = 1,
  970. .channels_min = 2,
  971. .channels_max = 8,
  972. /* NID is set in alc_build_pcms */
  973. .ops = {
  974. .open = alc880_playback_pcm_open,
  975. .prepare = alc880_playback_pcm_prepare,
  976. .cleanup = alc880_playback_pcm_cleanup
  977. },
  978. };
  979. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  980. .substreams = 2,
  981. .channels_min = 2,
  982. .channels_max = 2,
  983. /* NID is set in alc_build_pcms */
  984. .ops = {
  985. .prepare = alc880_capture_pcm_prepare,
  986. .cleanup = alc880_capture_pcm_cleanup
  987. },
  988. };
  989. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  990. .substreams = 1,
  991. .channels_min = 2,
  992. .channels_max = 2,
  993. /* NID is set in alc_build_pcms */
  994. .ops = {
  995. .open = alc880_dig_playback_pcm_open,
  996. .close = alc880_dig_playback_pcm_close
  997. },
  998. };
  999. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1000. .substreams = 1,
  1001. .channels_min = 2,
  1002. .channels_max = 2,
  1003. /* NID is set in alc_build_pcms */
  1004. };
  1005. static int alc_build_pcms(struct hda_codec *codec)
  1006. {
  1007. struct alc_spec *spec = codec->spec;
  1008. struct hda_pcm *info = spec->pcm_rec;
  1009. int i;
  1010. codec->num_pcms = 1;
  1011. codec->pcm_info = info;
  1012. info->name = spec->stream_name_analog;
  1013. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1014. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1015. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1016. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1017. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1018. for (i = 0; i < spec->num_channel_mode; i++) {
  1019. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1020. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1021. }
  1022. }
  1023. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1024. codec->num_pcms++;
  1025. info++;
  1026. info->name = spec->stream_name_digital;
  1027. if (spec->multiout.dig_out_nid) {
  1028. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1029. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1030. }
  1031. if (spec->dig_in_nid) {
  1032. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1033. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1034. }
  1035. }
  1036. return 0;
  1037. }
  1038. static void alc_free(struct hda_codec *codec)
  1039. {
  1040. struct alc_spec *spec = codec->spec;
  1041. unsigned int i;
  1042. if (! spec)
  1043. return;
  1044. if (spec->kctl_alloc) {
  1045. for (i = 0; i < spec->num_kctl_used; i++)
  1046. kfree(spec->kctl_alloc[i].name);
  1047. kfree(spec->kctl_alloc);
  1048. }
  1049. kfree(spec);
  1050. }
  1051. /*
  1052. */
  1053. static struct hda_codec_ops alc_patch_ops = {
  1054. .build_controls = alc_build_controls,
  1055. .build_pcms = alc_build_pcms,
  1056. .init = alc_init,
  1057. .free = alc_free,
  1058. #ifdef CONFIG_PM
  1059. .resume = alc_resume,
  1060. #endif
  1061. };
  1062. /*
  1063. * Test configuration for debugging
  1064. *
  1065. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1066. * enum controls.
  1067. */
  1068. #ifdef CONFIG_SND_DEBUG
  1069. static hda_nid_t alc880_test_dac_nids[4] = {
  1070. 0x02, 0x03, 0x04, 0x05
  1071. };
  1072. static struct hda_input_mux alc880_test_capture_source = {
  1073. .num_items = 5,
  1074. .items = {
  1075. { "In-1", 0x0 },
  1076. { "In-2", 0x1 },
  1077. { "In-3", 0x2 },
  1078. { "In-4", 0x3 },
  1079. { "CD", 0x4 },
  1080. },
  1081. };
  1082. static struct alc_channel_mode alc880_test_modes[4] = {
  1083. { 2, NULL },
  1084. { 4, NULL },
  1085. { 6, NULL },
  1086. { 8, NULL },
  1087. };
  1088. static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1089. {
  1090. static char *texts[] = {
  1091. "N/A", "Line Out", "HP Out",
  1092. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1093. };
  1094. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1095. uinfo->count = 1;
  1096. uinfo->value.enumerated.items = 8;
  1097. if (uinfo->value.enumerated.item >= 8)
  1098. uinfo->value.enumerated.item = 7;
  1099. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1100. return 0;
  1101. }
  1102. static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1103. {
  1104. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1105. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1106. unsigned int pin_ctl, item = 0;
  1107. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1108. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1109. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1110. if (pin_ctl & AC_PINCTL_HP_EN)
  1111. item = 2;
  1112. else
  1113. item = 1;
  1114. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1115. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1116. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1117. case AC_PINCTL_VREF_50: item = 4; break;
  1118. case AC_PINCTL_VREF_GRD: item = 5; break;
  1119. case AC_PINCTL_VREF_80: item = 6; break;
  1120. case AC_PINCTL_VREF_100: item = 7; break;
  1121. }
  1122. }
  1123. ucontrol->value.enumerated.item[0] = item;
  1124. return 0;
  1125. }
  1126. static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1127. {
  1128. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1129. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1130. static unsigned int ctls[] = {
  1131. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1132. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1133. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1134. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1135. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1136. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1137. };
  1138. unsigned int old_ctl, new_ctl;
  1139. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1140. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1141. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1142. if (old_ctl != new_ctl) {
  1143. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1144. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1145. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1146. return 1;
  1147. }
  1148. return 0;
  1149. }
  1150. static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1151. {
  1152. static char *texts[] = {
  1153. "Front", "Surround", "CLFE", "Side"
  1154. };
  1155. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1156. uinfo->count = 1;
  1157. uinfo->value.enumerated.items = 4;
  1158. if (uinfo->value.enumerated.item >= 4)
  1159. uinfo->value.enumerated.item = 3;
  1160. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1161. return 0;
  1162. }
  1163. static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1164. {
  1165. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1166. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1167. unsigned int sel;
  1168. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1169. ucontrol->value.enumerated.item[0] = sel & 3;
  1170. return 0;
  1171. }
  1172. static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1173. {
  1174. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1175. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1176. unsigned int sel;
  1177. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1178. if (ucontrol->value.enumerated.item[0] != sel) {
  1179. sel = ucontrol->value.enumerated.item[0] & 3;
  1180. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1181. return 1;
  1182. }
  1183. return 0;
  1184. }
  1185. #define PIN_CTL_TEST(xname,nid) { \
  1186. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1187. .name = xname, \
  1188. .info = alc_test_pin_ctl_info, \
  1189. .get = alc_test_pin_ctl_get, \
  1190. .put = alc_test_pin_ctl_put, \
  1191. .private_value = nid \
  1192. }
  1193. #define PIN_SRC_TEST(xname,nid) { \
  1194. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1195. .name = xname, \
  1196. .info = alc_test_pin_src_info, \
  1197. .get = alc_test_pin_src_get, \
  1198. .put = alc_test_pin_src_put, \
  1199. .private_value = nid \
  1200. }
  1201. static snd_kcontrol_new_t alc880_test_mixer[] = {
  1202. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1203. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1204. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1205. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1206. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1207. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1208. ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT),
  1209. ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT),
  1210. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1211. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1212. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1213. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1214. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1215. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1216. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1217. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1218. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1219. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1220. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1221. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1222. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1223. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1224. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1225. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1226. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1227. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1228. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1229. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1230. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1231. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1232. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1233. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1234. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  1235. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  1236. {
  1237. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1238. .name = "Input Source",
  1239. .count = 2,
  1240. .info = alc_mux_enum_info,
  1241. .get = alc_mux_enum_get,
  1242. .put = alc_mux_enum_put,
  1243. },
  1244. {
  1245. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1246. .name = "Channel Mode",
  1247. .info = alc880_ch_mode_info,
  1248. .get = alc880_ch_mode_get,
  1249. .put = alc880_ch_mode_put,
  1250. },
  1251. { } /* end */
  1252. };
  1253. static struct hda_verb alc880_test_init_verbs[] = {
  1254. /* Unmute inputs of 0x0c - 0x0f */
  1255. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1256. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1257. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1258. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1259. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1260. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1261. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1262. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1263. /* Vol output for 0x0c-0x0f */
  1264. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1265. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1266. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1267. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1268. /* Set output pins 0x14-0x17 */
  1269. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1270. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1271. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1272. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1273. /* Unmute output pins 0x14-0x17 */
  1274. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1275. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1276. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1277. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1278. /* Set input pins 0x18-0x1c */
  1279. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1280. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1281. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1282. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1283. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1284. /* Mute input pins 0x18-0x1b */
  1285. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1286. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1287. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1288. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. /* ADC set up */
  1290. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1291. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1292. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1293. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1294. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1295. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1296. /* Analog input/passthru */
  1297. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1298. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1299. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1300. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1301. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1302. { }
  1303. };
  1304. #endif
  1305. /*
  1306. */
  1307. static struct hda_board_config alc880_cfg_tbl[] = {
  1308. /* Back 3 jack, front 2 jack */
  1309. { .modelname = "3stack", .config = ALC880_3ST },
  1310. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1311. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1312. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1313. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1314. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1315. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1316. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1317. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1318. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1319. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1320. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1321. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1322. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1323. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1324. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1325. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1326. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1327. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1328. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1329. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1330. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1331. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1332. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1333. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1334. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1335. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1336. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1337. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1338. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1339. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1340. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1341. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1342. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1343. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1344. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1345. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1346. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1347. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1348. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1349. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1350. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1351. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1352. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1353. /* Back 5 jack, front 2 jack */
  1354. { .modelname = "5stack", .config = ALC880_5ST },
  1355. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1356. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1357. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1358. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1359. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1360. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1361. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1362. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1363. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1364. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1365. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1366. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1367. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1368. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1369. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1370. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1371. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1372. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1373. /* note subvendor = 0 below */
  1374. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1375. { .modelname = "w810", .config = ALC880_W810 },
  1376. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1377. { .modelname = "z71v", .config = ALC880_Z71V },
  1378. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1379. { .modelname = "6stack", .config = ALC880_6ST },
  1380. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1381. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1382. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1383. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1384. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1385. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1386. { .modelname = "asus", .config = ALC880_ASUS },
  1387. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  1388. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  1389. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  1390. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  1391. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  1392. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  1393. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  1394. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  1395. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  1396. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  1397. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1398. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1399. { .modelname = "F1734", .config = ALC880_F1734 },
  1400. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1401. #ifdef CONFIG_SND_DEBUG
  1402. { .modelname = "test", .config = ALC880_TEST },
  1403. #endif
  1404. {}
  1405. };
  1406. /*
  1407. * configuration template - to be copied to the spec instance
  1408. */
  1409. struct alc_config_preset {
  1410. snd_kcontrol_new_t *mixers[4];
  1411. const struct hda_verb *init_verbs[4];
  1412. unsigned int num_dacs;
  1413. hda_nid_t *dac_nids;
  1414. hda_nid_t dig_out_nid; /* optional */
  1415. hda_nid_t hp_nid; /* optional */
  1416. unsigned int num_adc_nids;
  1417. hda_nid_t *adc_nids;
  1418. unsigned int num_channel_mode;
  1419. const struct alc_channel_mode *channel_mode;
  1420. const struct hda_input_mux *input_mux;
  1421. };
  1422. static struct alc_config_preset alc880_presets[] = {
  1423. [ALC880_3ST] = {
  1424. .mixers = { alc880_three_stack_mixer },
  1425. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1426. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1427. .dac_nids = alc880_dac_nids,
  1428. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1429. .channel_mode = alc880_threestack_modes,
  1430. .input_mux = &alc880_capture_source,
  1431. },
  1432. [ALC880_3ST_DIG] = {
  1433. .mixers = { alc880_three_stack_mixer },
  1434. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1435. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1436. .dac_nids = alc880_dac_nids,
  1437. .dig_out_nid = ALC880_DIGOUT_NID,
  1438. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1439. .channel_mode = alc880_threestack_modes,
  1440. .input_mux = &alc880_capture_source,
  1441. },
  1442. [ALC880_5ST] = {
  1443. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1444. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1445. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1446. .dac_nids = alc880_dac_nids,
  1447. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1448. .channel_mode = alc880_fivestack_modes,
  1449. .input_mux = &alc880_capture_source,
  1450. },
  1451. [ALC880_5ST_DIG] = {
  1452. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1453. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1454. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1455. .dac_nids = alc880_dac_nids,
  1456. .dig_out_nid = ALC880_DIGOUT_NID,
  1457. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1458. .channel_mode = alc880_fivestack_modes,
  1459. .input_mux = &alc880_capture_source,
  1460. },
  1461. [ALC880_6ST] = {
  1462. .mixers = { alc880_six_stack_mixer },
  1463. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1464. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1465. .dac_nids = alc880_6st_dac_nids,
  1466. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1467. .channel_mode = alc880_sixstack_modes,
  1468. .input_mux = &alc880_6stack_capture_source,
  1469. },
  1470. [ALC880_6ST_DIG] = {
  1471. .mixers = { alc880_six_stack_mixer },
  1472. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1473. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1474. .dac_nids = alc880_6st_dac_nids,
  1475. .dig_out_nid = ALC880_DIGOUT_NID,
  1476. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1477. .channel_mode = alc880_sixstack_modes,
  1478. .input_mux = &alc880_6stack_capture_source,
  1479. },
  1480. [ALC880_W810] = {
  1481. .mixers = { alc880_w810_base_mixer },
  1482. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  1483. alc880_gpio2_init_verbs },
  1484. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1485. .dac_nids = alc880_w810_dac_nids,
  1486. .dig_out_nid = ALC880_DIGOUT_NID,
  1487. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1488. .channel_mode = alc880_w810_modes,
  1489. .input_mux = &alc880_capture_source,
  1490. },
  1491. [ALC880_Z71V] = {
  1492. .mixers = { alc880_z71v_mixer },
  1493. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  1494. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1495. .dac_nids = alc880_z71v_dac_nids,
  1496. .dig_out_nid = ALC880_DIGOUT_NID,
  1497. .hp_nid = 0x03,
  1498. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1499. .channel_mode = alc880_2_jack_modes,
  1500. .input_mux = &alc880_capture_source,
  1501. },
  1502. [ALC880_F1734] = {
  1503. .mixers = { alc880_f1734_mixer },
  1504. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1505. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1506. .dac_nids = alc880_f1734_dac_nids,
  1507. .hp_nid = 0x02,
  1508. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1509. .channel_mode = alc880_2_jack_modes,
  1510. .input_mux = &alc880_capture_source,
  1511. },
  1512. [ALC880_ASUS] = {
  1513. .mixers = { alc880_asus_mixer },
  1514. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1515. alc880_gpio1_init_verbs },
  1516. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1517. .dac_nids = alc880_asus_dac_nids,
  1518. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1519. .channel_mode = alc880_asus_modes,
  1520. .input_mux = &alc880_capture_source,
  1521. },
  1522. [ALC880_ASUS_DIG] = {
  1523. .mixers = { alc880_asus_mixer },
  1524. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1525. alc880_gpio1_init_verbs },
  1526. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1527. .dac_nids = alc880_asus_dac_nids,
  1528. .dig_out_nid = ALC880_DIGOUT_NID,
  1529. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1530. .channel_mode = alc880_asus_modes,
  1531. .input_mux = &alc880_capture_source,
  1532. },
  1533. [ALC880_ASUS_W1V] = {
  1534. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1535. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1536. alc880_gpio1_init_verbs },
  1537. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1538. .dac_nids = alc880_asus_dac_nids,
  1539. .dig_out_nid = ALC880_DIGOUT_NID,
  1540. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1541. .channel_mode = alc880_asus_modes,
  1542. .input_mux = &alc880_capture_source,
  1543. },
  1544. [ALC880_UNIWILL_DIG] = {
  1545. .mixers = { alc880_asus_mixer },
  1546. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  1547. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1548. .dac_nids = alc880_asus_dac_nids,
  1549. .dig_out_nid = ALC880_DIGOUT_NID,
  1550. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1551. .channel_mode = alc880_asus_modes,
  1552. .input_mux = &alc880_capture_source,
  1553. },
  1554. #ifdef CONFIG_SND_DEBUG
  1555. [ALC880_TEST] = {
  1556. .mixers = { alc880_test_mixer },
  1557. .init_verbs = { alc880_test_init_verbs },
  1558. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  1559. .dac_nids = alc880_test_dac_nids,
  1560. .dig_out_nid = ALC880_DIGOUT_NID,
  1561. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  1562. .channel_mode = alc880_test_modes,
  1563. .input_mux = &alc880_test_capture_source,
  1564. },
  1565. #endif
  1566. };
  1567. /*
  1568. * Automatic parse of I/O pins from the BIOS configuration
  1569. */
  1570. #define NUM_CONTROL_ALLOC 32
  1571. #define NUM_VERB_ALLOC 32
  1572. enum {
  1573. ALC_CTL_WIDGET_VOL,
  1574. ALC_CTL_WIDGET_MUTE,
  1575. ALC_CTL_BIND_MUTE,
  1576. };
  1577. static snd_kcontrol_new_t alc880_control_templates[] = {
  1578. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  1579. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  1580. ALC_BIND_MUTE(NULL, 0, 0, 0),
  1581. };
  1582. /* add dynamic controls */
  1583. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  1584. {
  1585. snd_kcontrol_new_t *knew;
  1586. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  1587. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  1588. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  1589. if (! knew)
  1590. return -ENOMEM;
  1591. if (spec->kctl_alloc) {
  1592. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  1593. kfree(spec->kctl_alloc);
  1594. }
  1595. spec->kctl_alloc = knew;
  1596. spec->num_kctl_alloc = num;
  1597. }
  1598. knew = &spec->kctl_alloc[spec->num_kctl_used];
  1599. *knew = alc880_control_templates[type];
  1600. knew->name = kstrdup(name, GFP_KERNEL);
  1601. if (! knew->name)
  1602. return -ENOMEM;
  1603. knew->private_value = val;
  1604. spec->num_kctl_used++;
  1605. return 0;
  1606. }
  1607. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  1608. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  1609. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  1610. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  1611. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  1612. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  1613. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  1614. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  1615. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  1616. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  1617. #define ALC880_PIN_CD_NID 0x1c
  1618. /* fill in the dac_nids table from the parsed pin configuration */
  1619. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1620. {
  1621. hda_nid_t nid;
  1622. int assigned[4];
  1623. int i, j;
  1624. memset(assigned, 0, sizeof(assigned));
  1625. spec->multiout.dac_nids = spec->private_dac_nids;
  1626. /* check the pins hardwired to audio widget */
  1627. for (i = 0; i < cfg->line_outs; i++) {
  1628. nid = cfg->line_out_pins[i];
  1629. if (alc880_is_fixed_pin(nid)) {
  1630. int idx = alc880_fixed_pin_idx(nid);
  1631. spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
  1632. assigned[idx] = 1;
  1633. }
  1634. }
  1635. /* left pins can be connect to any audio widget */
  1636. for (i = 0; i < cfg->line_outs; i++) {
  1637. nid = cfg->line_out_pins[i];
  1638. if (alc880_is_fixed_pin(nid))
  1639. continue;
  1640. /* search for an empty channel */
  1641. for (j = 0; j < cfg->line_outs; j++) {
  1642. if (! assigned[j]) {
  1643. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  1644. assigned[j] = 1;
  1645. break;
  1646. }
  1647. }
  1648. }
  1649. spec->multiout.num_dacs = cfg->line_outs;
  1650. return 0;
  1651. }
  1652. /* add playback controls from the parsed DAC table */
  1653. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1654. {
  1655. char name[32];
  1656. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  1657. hda_nid_t nid;
  1658. int i, err;
  1659. for (i = 0; i < cfg->line_outs; i++) {
  1660. if (! spec->multiout.dac_nids[i])
  1661. continue;
  1662. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  1663. if (i == 2) {
  1664. /* Center/LFE */
  1665. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  1666. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  1667. return err;
  1668. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  1669. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  1670. return err;
  1671. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  1672. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  1673. return err;
  1674. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  1675. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  1676. return err;
  1677. } else {
  1678. sprintf(name, "%s Playback Volume", chname[i]);
  1679. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1680. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1681. return err;
  1682. sprintf(name, "%s Playback Switch", chname[i]);
  1683. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1684. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1685. return err;
  1686. }
  1687. }
  1688. return 0;
  1689. }
  1690. /* add playback controls for HP output */
  1691. static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  1692. {
  1693. hda_nid_t nid;
  1694. int err;
  1695. if (! pin)
  1696. return 0;
  1697. if (alc880_is_fixed_pin(pin)) {
  1698. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  1699. if (! spec->multiout.dac_nids[0]) {
  1700. /* use this as the primary output */
  1701. spec->multiout.dac_nids[0] = nid;
  1702. if (! spec->multiout.num_dacs)
  1703. spec->multiout.num_dacs = 1;
  1704. } else
  1705. /* specify the DAC as the extra HP output */
  1706. spec->multiout.hp_nid = nid;
  1707. /* control HP volume/switch on the output mixer amp */
  1708. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  1709. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  1710. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1711. return err;
  1712. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
  1713. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1714. return err;
  1715. } else if (alc880_is_multi_pin(pin)) {
  1716. /* set manual connection */
  1717. if (! spec->multiout.dac_nids[0]) {
  1718. /* use this as the primary output */
  1719. spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
  1720. if (! spec->multiout.num_dacs)
  1721. spec->multiout.num_dacs = 1;
  1722. }
  1723. /* we have only a switch on HP-out PIN */
  1724. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  1725. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  1726. return err;
  1727. }
  1728. return 0;
  1729. }
  1730. /* create input playback/capture controls for the given pin */
  1731. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
  1732. {
  1733. char name[32];
  1734. int err, idx;
  1735. sprintf(name, "%s Playback Volume", ctlname);
  1736. idx = alc880_input_pin_idx(pin);
  1737. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1738. HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
  1739. return err;
  1740. sprintf(name, "%s Playback Switch", ctlname);
  1741. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1742. HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
  1743. return err;
  1744. return 0;
  1745. }
  1746. /* create playback/capture controls for input pins */
  1747. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1748. {
  1749. static char *labels[AUTO_PIN_LAST] = {
  1750. "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
  1751. };
  1752. struct hda_input_mux *imux = &spec->private_imux;
  1753. int i, err;
  1754. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1755. if (alc880_is_input_pin(cfg->input_pins[i])) {
  1756. err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
  1757. if (err < 0)
  1758. return err;
  1759. imux->items[imux->num_items].label = labels[i];
  1760. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  1761. imux->num_items++;
  1762. }
  1763. }
  1764. return 0;
  1765. }
  1766. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
  1767. int dac_idx)
  1768. {
  1769. /* set as output */
  1770. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  1771. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  1772. /* need the manual connection? */
  1773. if (alc880_is_multi_pin(nid)) {
  1774. struct alc_spec *spec = codec->spec;
  1775. int idx = alc880_multi_pin_idx(nid);
  1776. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  1777. AC_VERB_SET_CONNECT_SEL,
  1778. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  1779. }
  1780. }
  1781. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  1782. {
  1783. struct alc_spec *spec = codec->spec;
  1784. int i;
  1785. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1786. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1787. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  1788. }
  1789. }
  1790. static void alc880_auto_init_hp_out(struct hda_codec *codec)
  1791. {
  1792. struct alc_spec *spec = codec->spec;
  1793. hda_nid_t pin;
  1794. pin = spec->autocfg.hp_pin;
  1795. if (pin) /* connect to front */
  1796. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  1797. }
  1798. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  1799. {
  1800. struct alc_spec *spec = codec->spec;
  1801. int i;
  1802. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1803. hda_nid_t nid = spec->autocfg.input_pins[i];
  1804. if (alc880_is_input_pin(nid)) {
  1805. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1806. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  1807. if (nid != ALC880_PIN_CD_NID)
  1808. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1809. AMP_OUT_MUTE);
  1810. }
  1811. }
  1812. }
  1813. /* parse the BIOS configuration and set up the alc_spec */
  1814. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  1815. static int alc880_parse_auto_config(struct hda_codec *codec)
  1816. {
  1817. struct alc_spec *spec = codec->spec;
  1818. int err;
  1819. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
  1820. return err;
  1821. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
  1822. return err;
  1823. if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
  1824. return 0; /* can't find valid BIOS pin config */
  1825. if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1826. (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  1827. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  1828. return err;
  1829. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1830. if (spec->autocfg.dig_out_pin)
  1831. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1832. if (spec->autocfg.dig_in_pin)
  1833. spec->dig_in_nid = ALC880_DIGIN_NID;
  1834. if (spec->kctl_alloc)
  1835. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1836. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  1837. spec->input_mux = &spec->private_imux;
  1838. return 1;
  1839. }
  1840. /* init callback for auto-configuration model -- overriding the default init */
  1841. static int alc880_auto_init(struct hda_codec *codec)
  1842. {
  1843. alc_init(codec);
  1844. alc880_auto_init_multi_out(codec);
  1845. alc880_auto_init_hp_out(codec);
  1846. alc880_auto_init_analog_input(codec);
  1847. return 0;
  1848. }
  1849. /*
  1850. * OK, here we have finally the patch for ALC880
  1851. */
  1852. static int patch_alc880(struct hda_codec *codec)
  1853. {
  1854. struct alc_spec *spec;
  1855. int board_config;
  1856. int i, err;
  1857. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1858. if (spec == NULL)
  1859. return -ENOMEM;
  1860. init_MUTEX(&spec->bind_mutex);
  1861. codec->spec = spec;
  1862. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  1863. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  1864. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  1865. board_config = ALC880_AUTO;
  1866. }
  1867. if (board_config == ALC880_AUTO) {
  1868. /* automatic parse from the BIOS config */
  1869. err = alc880_parse_auto_config(codec);
  1870. if (err < 0) {
  1871. alc_free(codec);
  1872. return err;
  1873. } else if (! err) {
  1874. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  1875. board_config = ALC880_3ST;
  1876. }
  1877. }
  1878. if (board_config != ALC880_AUTO) {
  1879. /* set up from the preset table */
  1880. const struct alc_config_preset *preset;
  1881. preset = &alc880_presets[board_config];
  1882. for (i = 0; preset->mixers[i]; i++) {
  1883. snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
  1884. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  1885. }
  1886. for (i = 0; preset->init_verbs[i]; i++) {
  1887. snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
  1888. spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
  1889. }
  1890. spec->channel_mode = preset->channel_mode;
  1891. spec->num_channel_mode = preset->num_channel_mode;
  1892. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1893. spec->multiout.num_dacs = preset->num_dacs;
  1894. spec->multiout.dac_nids = preset->dac_nids;
  1895. spec->multiout.dig_out_nid = preset->dig_out_nid;
  1896. spec->multiout.hp_nid = preset->hp_nid;
  1897. spec->input_mux = preset->input_mux;
  1898. spec->num_adc_nids = preset->num_adc_nids;
  1899. spec->adc_nids = preset->adc_nids;
  1900. }
  1901. spec->stream_name_analog = "ALC880 Analog";
  1902. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1903. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1904. spec->stream_name_digital = "ALC880 Digital";
  1905. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1906. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1907. if (! spec->adc_nids && spec->input_mux) {
  1908. /* check whether NID 0x07 is valid */
  1909. unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
  1910. AC_PAR_AUDIO_WIDGET_CAP);
  1911. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  1912. if (wcap != AC_WID_AUD_IN) {
  1913. spec->adc_nids = alc880_adc_nids_alt;
  1914. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  1915. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  1916. spec->num_mixers++;
  1917. } else {
  1918. spec->adc_nids = alc880_adc_nids;
  1919. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  1920. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  1921. spec->num_mixers++;
  1922. }
  1923. }
  1924. codec->patch_ops = alc_patch_ops;
  1925. if (board_config == ALC880_AUTO)
  1926. codec->patch_ops.init = alc880_auto_init;
  1927. return 0;
  1928. }
  1929. /*
  1930. * ALC260 support
  1931. */
  1932. static hda_nid_t alc260_dac_nids[1] = {
  1933. /* front */
  1934. 0x02,
  1935. };
  1936. static hda_nid_t alc260_adc_nids[1] = {
  1937. /* ADC0 */
  1938. 0x04,
  1939. };
  1940. static hda_nid_t alc260_hp_adc_nids[1] = {
  1941. /* ADC1 */
  1942. 0x05,
  1943. };
  1944. #define ALC260_DIGOUT_NID 0x03
  1945. #define ALC260_DIGIN_NID 0x06
  1946. static struct hda_input_mux alc260_capture_source = {
  1947. .num_items = 4,
  1948. .items = {
  1949. { "Mic", 0x0 },
  1950. { "Front Mic", 0x1 },
  1951. { "Line", 0x2 },
  1952. { "CD", 0x4 },
  1953. },
  1954. };
  1955. /*
  1956. * This is just place-holder, so there's something for alc_build_pcms to look
  1957. * at when it calculates the maximum number of channels. ALC260 has no mixer
  1958. * element which allows changing the channel mode, so the verb list is
  1959. * never used.
  1960. */
  1961. static struct alc_channel_mode alc260_modes[1] = {
  1962. { 2, NULL },
  1963. };
  1964. static snd_kcontrol_new_t alc260_base_mixer[] = {
  1965. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1966. ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  1967. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1968. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1969. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1970. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1971. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1972. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1973. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1974. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1975. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  1976. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  1977. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  1978. ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  1979. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  1980. ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
  1981. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  1982. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  1983. {
  1984. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1985. .name = "Capture Source",
  1986. .info = alc_mux_enum_info,
  1987. .get = alc_mux_enum_get,
  1988. .put = alc_mux_enum_put,
  1989. },
  1990. { } /* end */
  1991. };
  1992. static snd_kcontrol_new_t alc260_hp_mixer[] = {
  1993. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1994. ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  1995. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1996. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1997. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1998. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1999. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2000. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2001. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2002. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2003. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2004. ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2005. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2006. ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
  2007. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2008. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2009. {
  2010. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2011. .name = "Capture Source",
  2012. .info = alc_mux_enum_info,
  2013. .get = alc_mux_enum_get,
  2014. .put = alc_mux_enum_put,
  2015. },
  2016. { } /* end */
  2017. };
  2018. static struct hda_verb alc260_init_verbs[] = {
  2019. /* Line In pin widget for input */
  2020. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2021. /* CD pin widget for input */
  2022. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2023. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2024. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2025. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2026. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2027. /* LINE-2 is used for line-out in rear */
  2028. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2029. /* select line-out */
  2030. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  2031. /* LINE-OUT pin */
  2032. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2033. /* enable HP */
  2034. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2035. /* enable Mono */
  2036. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2037. /* mute capture amp left and right */
  2038. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2039. /* set connection select to line in (default select for this ADC) */
  2040. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2041. /* mute capture amp left and right */
  2042. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2043. /* set connection select to line in (default select for this ADC) */
  2044. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2045. /* set vol=0 Line-Out mixer amp left and right */
  2046. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2047. /* unmute pin widget amp left and right (no gain on this amp) */
  2048. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2049. /* set vol=0 HP mixer amp left and right */
  2050. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2051. /* unmute pin widget amp left and right (no gain on this amp) */
  2052. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2053. /* set vol=0 Mono mixer amp left and right */
  2054. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2055. /* unmute pin widget amp left and right (no gain on this amp) */
  2056. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2057. /* unmute LINE-2 out pin */
  2058. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2059. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2060. /* mute CD */
  2061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2062. /* mute Line In */
  2063. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2064. /* mute Mic */
  2065. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2066. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2067. /* mute Front out path */
  2068. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2069. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2070. /* mute Headphone out path */
  2071. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2072. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2073. /* mute Mono out path */
  2074. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2075. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2076. { }
  2077. };
  2078. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  2079. .substreams = 1,
  2080. .channels_min = 2,
  2081. .channels_max = 2,
  2082. };
  2083. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  2084. .substreams = 1,
  2085. .channels_min = 2,
  2086. .channels_max = 2,
  2087. };
  2088. static struct hda_board_config alc260_cfg_tbl[] = {
  2089. { .modelname = "hp", .config = ALC260_HP },
  2090. { .pci_subvendor = 0x103c, .config = ALC260_HP },
  2091. {}
  2092. };
  2093. static int patch_alc260(struct hda_codec *codec)
  2094. {
  2095. struct alc_spec *spec;
  2096. int board_config;
  2097. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  2098. if (spec == NULL)
  2099. return -ENOMEM;
  2100. init_MUTEX(&spec->bind_mutex);
  2101. codec->spec = spec;
  2102. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  2103. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  2104. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  2105. board_config = ALC260_BASIC;
  2106. }
  2107. switch (board_config) {
  2108. case ALC260_HP:
  2109. spec->mixers[spec->num_mixers] = alc260_hp_mixer;
  2110. spec->num_mixers++;
  2111. break;
  2112. default:
  2113. spec->mixers[spec->num_mixers] = alc260_base_mixer;
  2114. spec->num_mixers++;
  2115. break;
  2116. }
  2117. spec->init_verbs[0] = alc260_init_verbs;
  2118. spec->num_init_verbs = 1;
  2119. spec->channel_mode = alc260_modes;
  2120. spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
  2121. spec->stream_name_analog = "ALC260 Analog";
  2122. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  2123. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  2124. spec->multiout.max_channels = spec->channel_mode[0].channels;
  2125. spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
  2126. spec->multiout.dac_nids = alc260_dac_nids;
  2127. spec->input_mux = &alc260_capture_source;
  2128. switch (board_config) {
  2129. case ALC260_HP:
  2130. spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
  2131. spec->adc_nids = alc260_hp_adc_nids;
  2132. break;
  2133. default:
  2134. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  2135. spec->adc_nids = alc260_adc_nids;
  2136. break;
  2137. }
  2138. codec->patch_ops = alc_patch_ops;
  2139. return 0;
  2140. }
  2141. /*
  2142. * ALC882 support
  2143. *
  2144. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  2145. * configuration. Each pin widget can choose any input DACs and a mixer.
  2146. * Each ADC is connected from a mixer of all inputs. This makes possible
  2147. * 6-channel independent captures.
  2148. *
  2149. * In addition, an independent DAC for the multi-playback (not used in this
  2150. * driver yet).
  2151. */
  2152. static struct alc_channel_mode alc882_ch_modes[1] = {
  2153. { 8, NULL }
  2154. };
  2155. static hda_nid_t alc882_dac_nids[4] = {
  2156. /* front, rear, clfe, rear_surr */
  2157. 0x02, 0x03, 0x04, 0x05
  2158. };
  2159. static hda_nid_t alc882_adc_nids[3] = {
  2160. /* ADC0-2 */
  2161. 0x07, 0x08, 0x09,
  2162. };
  2163. /* input MUX */
  2164. /* FIXME: should be a matrix-type input source selection */
  2165. static struct hda_input_mux alc882_capture_source = {
  2166. .num_items = 4,
  2167. .items = {
  2168. { "Mic", 0x0 },
  2169. { "Front Mic", 0x1 },
  2170. { "Line", 0x2 },
  2171. { "CD", 0x4 },
  2172. },
  2173. };
  2174. #define alc882_mux_enum_info alc_mux_enum_info
  2175. #define alc882_mux_enum_get alc_mux_enum_get
  2176. static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  2177. {
  2178. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2179. struct alc_spec *spec = codec->spec;
  2180. const struct hda_input_mux *imux = spec->input_mux;
  2181. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  2182. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  2183. hda_nid_t nid = capture_mixers[adc_idx];
  2184. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  2185. unsigned int i, idx;
  2186. idx = ucontrol->value.enumerated.item[0];
  2187. if (idx >= imux->num_items)
  2188. idx = imux->num_items - 1;
  2189. if (*cur_val == idx && ! codec->in_resume)
  2190. return 0;
  2191. for (i = 0; i < imux->num_items; i++) {
  2192. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  2193. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2194. v | (imux->items[i].index << 8));
  2195. }
  2196. *cur_val = idx;
  2197. return 1;
  2198. }
  2199. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  2200. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  2201. */
  2202. static snd_kcontrol_new_t alc882_base_mixer[] = {
  2203. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2204. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2205. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2206. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2207. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  2208. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  2209. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  2210. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT),
  2211. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2212. ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2213. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  2214. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  2215. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  2216. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  2217. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  2218. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2219. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2220. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2221. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2222. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  2223. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  2224. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  2225. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  2226. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  2227. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  2228. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  2229. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  2230. {
  2231. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2232. /* .name = "Capture Source", */
  2233. .name = "Input Source",
  2234. .count = 3,
  2235. .info = alc882_mux_enum_info,
  2236. .get = alc882_mux_enum_get,
  2237. .put = alc882_mux_enum_put,
  2238. },
  2239. { } /* end */
  2240. };
  2241. static struct hda_verb alc882_init_verbs[] = {
  2242. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  2243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2245. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2246. /* Rear mixer */
  2247. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2248. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2249. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2250. /* CLFE mixer */
  2251. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2252. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2253. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2254. /* Side mixer */
  2255. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2256. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2257. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2258. /* Front Pin: output 0 (0x0c) */
  2259. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2260. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2261. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  2262. /* Rear Pin: output 1 (0x0d) */
  2263. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2264. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2265. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  2266. /* CLFE Pin: output 2 (0x0e) */
  2267. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2268. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2269. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  2270. /* Side Pin: output 3 (0x0f) */
  2271. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2272. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2273. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  2274. /* Mic (rear) pin: input vref at 80% */
  2275. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2276. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2277. /* Front Mic pin: input vref at 80% */
  2278. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2279. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2280. /* Line In pin: input */
  2281. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2282. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2283. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  2284. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2285. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2286. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  2287. /* CD pin widget for input */
  2288. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2289. /* FIXME: use matrix-type input source selection */
  2290. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  2291. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  2292. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2293. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2294. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2295. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2296. /* Input mixer2 */
  2297. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2299. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2300. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2301. /* Input mixer3 */
  2302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2303. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2304. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2305. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2306. /* ADC1: mute amp left and right */
  2307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2308. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2309. /* ADC2: mute amp left and right */
  2310. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2311. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2312. /* ADC3: mute amp left and right */
  2313. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2314. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2315. { }
  2316. };
  2317. static int patch_alc882(struct hda_codec *codec)
  2318. {
  2319. struct alc_spec *spec;
  2320. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  2321. if (spec == NULL)
  2322. return -ENOMEM;
  2323. init_MUTEX(&spec->bind_mutex);
  2324. codec->spec = spec;
  2325. spec->mixers[spec->num_mixers] = alc882_base_mixer;
  2326. spec->num_mixers++;
  2327. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2328. spec->dig_in_nid = ALC880_DIGIN_NID;
  2329. spec->init_verbs[0] = alc882_init_verbs;
  2330. spec->num_init_verbs = 1;
  2331. spec->channel_mode = alc882_ch_modes;
  2332. spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
  2333. spec->stream_name_analog = "ALC882 Analog";
  2334. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2335. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2336. spec->stream_name_digital = "ALC882 Digital";
  2337. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2338. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2339. spec->multiout.max_channels = spec->channel_mode[0].channels;
  2340. spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
  2341. spec->multiout.dac_nids = alc882_dac_nids;
  2342. spec->input_mux = &alc882_capture_source;
  2343. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  2344. spec->adc_nids = alc882_adc_nids;
  2345. codec->patch_ops = alc_patch_ops;
  2346. return 0;
  2347. }
  2348. /*
  2349. * patch entries
  2350. */
  2351. struct hda_codec_preset snd_hda_preset_realtek[] = {
  2352. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  2353. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  2354. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  2355. {} /* terminator */
  2356. };