patch_realtek.c 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655
  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. /* additional mixers to alc880_asus_mixer */
  602. static snd_kcontrol_new_t alc880_pcbeep_mixer[] = {
  603. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  604. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  605. { } /* end */
  606. };
  607. /*
  608. * build control elements
  609. */
  610. static int alc_build_controls(struct hda_codec *codec)
  611. {
  612. struct alc_spec *spec = codec->spec;
  613. int err;
  614. int i;
  615. for (i = 0; i < spec->num_mixers; i++) {
  616. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  617. if (err < 0)
  618. return err;
  619. }
  620. if (spec->multiout.dig_out_nid) {
  621. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  622. if (err < 0)
  623. return err;
  624. }
  625. if (spec->dig_in_nid) {
  626. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  627. if (err < 0)
  628. return err;
  629. }
  630. return 0;
  631. }
  632. /*
  633. * initialize the codec volumes, etc
  634. */
  635. /*
  636. * generic initialization of ADC, input mixers and output mixers
  637. */
  638. static struct hda_verb alc880_volume_init_verbs[] = {
  639. /*
  640. * Unmute ADC0-2 and set the default input to mic-in
  641. */
  642. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  643. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  644. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  645. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  646. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  647. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  648. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  649. * mixer widget
  650. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  651. * mic (mic 2)
  652. */
  653. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  654. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  658. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  659. /*
  660. * Set up output mixers (0x0c - 0x0f)
  661. */
  662. /* set vol=0 to output mixers */
  663. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  664. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  665. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  666. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  667. /* set up input amps for analog loopback */
  668. /* Amp Indices: DAC = 0, mixer = 1 */
  669. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  670. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  671. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  672. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  673. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  674. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  675. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  676. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  677. { }
  678. };
  679. /*
  680. * 3-stack pin configuration:
  681. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  682. */
  683. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  684. /*
  685. * preset connection lists of input pins
  686. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  687. */
  688. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  689. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  690. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  691. /*
  692. * Set pin mode and muting
  693. */
  694. /* set front pin widgets 0x14 for output */
  695. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  696. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  697. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  698. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  699. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  700. /* Mic2 (as headphone out) for HP output */
  701. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  702. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  703. /* Line In pin widget for input */
  704. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  705. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  706. /* Line2 (as front mic) pin widget for input and vref at 80% */
  707. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  708. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  709. /* CD pin widget for input */
  710. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  711. { }
  712. };
  713. /*
  714. * 5-stack pin configuration:
  715. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  716. * line-in/side = 0x1a, f-mic = 0x1b
  717. */
  718. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  719. /*
  720. * preset connection lists of input pins
  721. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  722. */
  723. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  724. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  725. /*
  726. * Set pin mode and muting
  727. */
  728. /* set pin widgets 0x14-0x17 for output */
  729. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  730. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  731. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  732. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  733. /* unmute pins for output (no gain on this amp) */
  734. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  735. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  736. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  737. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  738. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  739. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  740. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  741. /* Mic2 (as headphone out) for HP output */
  742. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  743. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  744. /* Line In pin widget for input */
  745. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  746. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  747. /* Line2 (as front mic) pin widget for input and vref at 80% */
  748. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  749. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  750. /* CD pin widget for input */
  751. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  752. { }
  753. };
  754. /*
  755. * W810 pin configuration:
  756. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  757. */
  758. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  759. /* hphone/speaker input selector: front DAC */
  760. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  761. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  762. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  763. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  764. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  765. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  766. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  767. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  768. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  769. { }
  770. };
  771. /*
  772. * Z71V pin configuration:
  773. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  774. */
  775. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  776. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  777. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  778. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  779. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  780. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  781. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  782. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  783. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  784. { }
  785. };
  786. /*
  787. * 6-stack pin configuration:
  788. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
  789. * line = 0x1a, HP = 0x1b
  790. */
  791. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  792. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  793. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  794. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  795. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  796. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  797. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  798. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  799. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  800. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  801. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  802. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  803. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  804. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  805. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  806. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  807. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  808. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  809. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  810. { }
  811. };
  812. /* FIXME! */
  813. /*
  814. * F1734 pin configuration:
  815. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  816. */
  817. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  818. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  819. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  820. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  821. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  822. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  823. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  824. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  825. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  826. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  827. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  828. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  829. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  830. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  831. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  832. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  833. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  834. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  835. { }
  836. };
  837. /* FIXME! */
  838. /*
  839. * ASUS pin configuration:
  840. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  841. */
  842. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  843. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  844. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  845. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  846. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  847. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  848. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  849. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  850. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  851. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  852. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  853. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  854. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  855. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  856. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  857. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  858. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  859. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  860. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  861. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  862. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  863. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  864. { }
  865. };
  866. /* Enable GPIO mask and set output */
  867. static struct hda_verb alc880_gpio1_init_verbs[] = {
  868. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  869. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  870. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  871. };
  872. /* Enable GPIO mask and set output */
  873. static struct hda_verb alc880_gpio2_init_verbs[] = {
  874. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  875. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  876. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  877. };
  878. /*
  879. */
  880. static int alc_init(struct hda_codec *codec)
  881. {
  882. struct alc_spec *spec = codec->spec;
  883. unsigned int i;
  884. for (i = 0; i < spec->num_init_verbs; i++)
  885. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  886. return 0;
  887. }
  888. #ifdef CONFIG_PM
  889. /*
  890. * resume
  891. */
  892. static int alc_resume(struct hda_codec *codec)
  893. {
  894. struct alc_spec *spec = codec->spec;
  895. int i;
  896. alc_init(codec);
  897. for (i = 0; i < spec->num_mixers; i++)
  898. snd_hda_resume_ctls(codec, spec->mixers[i]);
  899. if (spec->multiout.dig_out_nid)
  900. snd_hda_resume_spdif_out(codec);
  901. if (spec->dig_in_nid)
  902. snd_hda_resume_spdif_in(codec);
  903. return 0;
  904. }
  905. #endif
  906. /*
  907. * Analog playback callbacks
  908. */
  909. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  910. struct hda_codec *codec,
  911. snd_pcm_substream_t *substream)
  912. {
  913. struct alc_spec *spec = codec->spec;
  914. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  915. }
  916. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  917. struct hda_codec *codec,
  918. unsigned int stream_tag,
  919. unsigned int format,
  920. snd_pcm_substream_t *substream)
  921. {
  922. struct alc_spec *spec = codec->spec;
  923. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  924. format, substream);
  925. }
  926. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  927. struct hda_codec *codec,
  928. snd_pcm_substream_t *substream)
  929. {
  930. struct alc_spec *spec = codec->spec;
  931. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  932. }
  933. /*
  934. * Digital out
  935. */
  936. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  937. struct hda_codec *codec,
  938. snd_pcm_substream_t *substream)
  939. {
  940. struct alc_spec *spec = codec->spec;
  941. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  942. }
  943. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  944. struct hda_codec *codec,
  945. snd_pcm_substream_t *substream)
  946. {
  947. struct alc_spec *spec = codec->spec;
  948. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  949. }
  950. /*
  951. * Analog capture
  952. */
  953. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  954. struct hda_codec *codec,
  955. unsigned int stream_tag,
  956. unsigned int format,
  957. snd_pcm_substream_t *substream)
  958. {
  959. struct alc_spec *spec = codec->spec;
  960. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  961. stream_tag, 0, format);
  962. return 0;
  963. }
  964. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  965. struct hda_codec *codec,
  966. snd_pcm_substream_t *substream)
  967. {
  968. struct alc_spec *spec = codec->spec;
  969. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  970. return 0;
  971. }
  972. /*
  973. */
  974. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  975. .substreams = 1,
  976. .channels_min = 2,
  977. .channels_max = 8,
  978. /* NID is set in alc_build_pcms */
  979. .ops = {
  980. .open = alc880_playback_pcm_open,
  981. .prepare = alc880_playback_pcm_prepare,
  982. .cleanup = alc880_playback_pcm_cleanup
  983. },
  984. };
  985. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  986. .substreams = 2,
  987. .channels_min = 2,
  988. .channels_max = 2,
  989. /* NID is set in alc_build_pcms */
  990. .ops = {
  991. .prepare = alc880_capture_pcm_prepare,
  992. .cleanup = alc880_capture_pcm_cleanup
  993. },
  994. };
  995. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  996. .substreams = 1,
  997. .channels_min = 2,
  998. .channels_max = 2,
  999. /* NID is set in alc_build_pcms */
  1000. .ops = {
  1001. .open = alc880_dig_playback_pcm_open,
  1002. .close = alc880_dig_playback_pcm_close
  1003. },
  1004. };
  1005. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1006. .substreams = 1,
  1007. .channels_min = 2,
  1008. .channels_max = 2,
  1009. /* NID is set in alc_build_pcms */
  1010. };
  1011. static int alc_build_pcms(struct hda_codec *codec)
  1012. {
  1013. struct alc_spec *spec = codec->spec;
  1014. struct hda_pcm *info = spec->pcm_rec;
  1015. int i;
  1016. codec->num_pcms = 1;
  1017. codec->pcm_info = info;
  1018. info->name = spec->stream_name_analog;
  1019. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1020. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1021. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1022. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1023. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1024. for (i = 0; i < spec->num_channel_mode; i++) {
  1025. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1026. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1027. }
  1028. }
  1029. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1030. codec->num_pcms++;
  1031. info++;
  1032. info->name = spec->stream_name_digital;
  1033. if (spec->multiout.dig_out_nid) {
  1034. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1035. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1036. }
  1037. if (spec->dig_in_nid) {
  1038. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1039. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1040. }
  1041. }
  1042. return 0;
  1043. }
  1044. static void alc_free(struct hda_codec *codec)
  1045. {
  1046. struct alc_spec *spec = codec->spec;
  1047. unsigned int i;
  1048. if (! spec)
  1049. return;
  1050. if (spec->kctl_alloc) {
  1051. for (i = 0; i < spec->num_kctl_used; i++)
  1052. kfree(spec->kctl_alloc[i].name);
  1053. kfree(spec->kctl_alloc);
  1054. }
  1055. kfree(spec);
  1056. }
  1057. /*
  1058. */
  1059. static struct hda_codec_ops alc_patch_ops = {
  1060. .build_controls = alc_build_controls,
  1061. .build_pcms = alc_build_pcms,
  1062. .init = alc_init,
  1063. .free = alc_free,
  1064. #ifdef CONFIG_PM
  1065. .resume = alc_resume,
  1066. #endif
  1067. };
  1068. /*
  1069. * Test configuration for debugging
  1070. *
  1071. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1072. * enum controls.
  1073. */
  1074. #ifdef CONFIG_SND_DEBUG
  1075. static hda_nid_t alc880_test_dac_nids[4] = {
  1076. 0x02, 0x03, 0x04, 0x05
  1077. };
  1078. static struct hda_input_mux alc880_test_capture_source = {
  1079. .num_items = 5,
  1080. .items = {
  1081. { "In-1", 0x0 },
  1082. { "In-2", 0x1 },
  1083. { "In-3", 0x2 },
  1084. { "In-4", 0x3 },
  1085. { "CD", 0x4 },
  1086. },
  1087. };
  1088. static struct alc_channel_mode alc880_test_modes[4] = {
  1089. { 2, NULL },
  1090. { 4, NULL },
  1091. { 6, NULL },
  1092. { 8, NULL },
  1093. };
  1094. static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1095. {
  1096. static char *texts[] = {
  1097. "N/A", "Line Out", "HP Out",
  1098. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1099. };
  1100. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1101. uinfo->count = 1;
  1102. uinfo->value.enumerated.items = 8;
  1103. if (uinfo->value.enumerated.item >= 8)
  1104. uinfo->value.enumerated.item = 7;
  1105. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1106. return 0;
  1107. }
  1108. static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1109. {
  1110. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1111. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1112. unsigned int pin_ctl, item = 0;
  1113. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1114. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1115. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1116. if (pin_ctl & AC_PINCTL_HP_EN)
  1117. item = 2;
  1118. else
  1119. item = 1;
  1120. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1121. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1122. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1123. case AC_PINCTL_VREF_50: item = 4; break;
  1124. case AC_PINCTL_VREF_GRD: item = 5; break;
  1125. case AC_PINCTL_VREF_80: item = 6; break;
  1126. case AC_PINCTL_VREF_100: item = 7; break;
  1127. }
  1128. }
  1129. ucontrol->value.enumerated.item[0] = item;
  1130. return 0;
  1131. }
  1132. static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1133. {
  1134. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1135. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1136. static unsigned int ctls[] = {
  1137. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1138. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1139. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1140. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1141. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1142. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1143. };
  1144. unsigned int old_ctl, new_ctl;
  1145. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1146. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1147. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1148. if (old_ctl != new_ctl) {
  1149. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1150. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1151. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1152. return 1;
  1153. }
  1154. return 0;
  1155. }
  1156. static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1157. {
  1158. static char *texts[] = {
  1159. "Front", "Surround", "CLFE", "Side"
  1160. };
  1161. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1162. uinfo->count = 1;
  1163. uinfo->value.enumerated.items = 4;
  1164. if (uinfo->value.enumerated.item >= 4)
  1165. uinfo->value.enumerated.item = 3;
  1166. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1167. return 0;
  1168. }
  1169. static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1170. {
  1171. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1172. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1173. unsigned int sel;
  1174. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1175. ucontrol->value.enumerated.item[0] = sel & 3;
  1176. return 0;
  1177. }
  1178. static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1179. {
  1180. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1181. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1182. unsigned int sel;
  1183. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1184. if (ucontrol->value.enumerated.item[0] != sel) {
  1185. sel = ucontrol->value.enumerated.item[0] & 3;
  1186. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1187. return 1;
  1188. }
  1189. return 0;
  1190. }
  1191. #define PIN_CTL_TEST(xname,nid) { \
  1192. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1193. .name = xname, \
  1194. .info = alc_test_pin_ctl_info, \
  1195. .get = alc_test_pin_ctl_get, \
  1196. .put = alc_test_pin_ctl_put, \
  1197. .private_value = nid \
  1198. }
  1199. #define PIN_SRC_TEST(xname,nid) { \
  1200. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1201. .name = xname, \
  1202. .info = alc_test_pin_src_info, \
  1203. .get = alc_test_pin_src_get, \
  1204. .put = alc_test_pin_src_put, \
  1205. .private_value = nid \
  1206. }
  1207. static snd_kcontrol_new_t alc880_test_mixer[] = {
  1208. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1209. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1210. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1211. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1212. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1213. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1214. ALC_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1215. ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1216. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1217. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1218. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1219. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1220. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1221. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1222. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1223. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1224. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1225. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1226. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1227. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1228. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1229. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1230. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1231. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1232. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1233. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1234. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1235. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1236. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1237. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1238. {
  1239. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1240. .name = "Channel Mode",
  1241. .info = alc880_ch_mode_info,
  1242. .get = alc880_ch_mode_get,
  1243. .put = alc880_ch_mode_put,
  1244. },
  1245. { } /* end */
  1246. };
  1247. static struct hda_verb alc880_test_init_verbs[] = {
  1248. /* Unmute inputs of 0x0c - 0x0f */
  1249. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1250. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1251. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1252. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1253. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1254. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1255. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1256. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1257. /* Vol output for 0x0c-0x0f */
  1258. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1259. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1260. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1261. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1262. /* Set output pins 0x14-0x17 */
  1263. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1264. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1265. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1266. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1267. /* Unmute output pins 0x14-0x17 */
  1268. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1270. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1271. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1272. /* Set input pins 0x18-0x1c */
  1273. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1274. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1275. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1276. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1277. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1278. /* Mute input pins 0x18-0x1b */
  1279. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1280. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1281. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1282. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1283. /* ADC set up */
  1284. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1285. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1286. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1287. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1288. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1289. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1290. /* Analog input/passthru */
  1291. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1292. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1293. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1294. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1295. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1296. { }
  1297. };
  1298. #endif
  1299. /*
  1300. */
  1301. static struct hda_board_config alc880_cfg_tbl[] = {
  1302. /* Back 3 jack, front 2 jack */
  1303. { .modelname = "3stack", .config = ALC880_3ST },
  1304. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1305. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1306. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1307. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1308. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1309. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1310. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1311. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1312. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1313. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1314. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1315. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1316. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1317. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1318. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1319. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1320. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1321. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1322. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1323. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1324. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1325. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1326. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1327. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1328. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1329. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1330. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1331. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1332. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1333. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1334. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1335. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1336. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1337. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1338. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1339. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1340. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1341. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1342. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1343. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1344. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1345. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1346. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1347. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1348. /* Back 5 jack, front 2 jack */
  1349. { .modelname = "5stack", .config = ALC880_5ST },
  1350. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1351. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1352. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1353. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1354. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1355. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1356. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1357. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1358. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1359. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1360. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1361. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1362. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1363. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1364. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1365. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1366. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1367. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1368. /* note subvendor = 0 below */
  1369. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1370. { .modelname = "w810", .config = ALC880_W810 },
  1371. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1372. { .modelname = "z71v", .config = ALC880_Z71V },
  1373. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1374. { .modelname = "6stack", .config = ALC880_6ST },
  1375. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1376. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1377. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1378. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1379. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1380. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1381. { .modelname = "asus", .config = ALC880_ASUS },
  1382. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  1383. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  1384. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  1385. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  1386. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  1387. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  1388. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  1389. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  1390. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  1391. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  1392. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  1393. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1394. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1395. { .modelname = "F1734", .config = ALC880_F1734 },
  1396. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1397. #ifdef CONFIG_SND_DEBUG
  1398. { .modelname = "test", .config = ALC880_TEST },
  1399. #endif
  1400. {}
  1401. };
  1402. /*
  1403. * configuration template - to be copied to the spec instance
  1404. */
  1405. struct alc_config_preset {
  1406. snd_kcontrol_new_t *mixers[4];
  1407. const struct hda_verb *init_verbs[4];
  1408. unsigned int num_dacs;
  1409. hda_nid_t *dac_nids;
  1410. hda_nid_t dig_out_nid; /* optional */
  1411. hda_nid_t hp_nid; /* optional */
  1412. unsigned int num_adc_nids;
  1413. hda_nid_t *adc_nids;
  1414. unsigned int num_channel_mode;
  1415. const struct alc_channel_mode *channel_mode;
  1416. const struct hda_input_mux *input_mux;
  1417. };
  1418. static struct alc_config_preset alc880_presets[] = {
  1419. [ALC880_3ST] = {
  1420. .mixers = { alc880_three_stack_mixer },
  1421. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1422. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1423. .dac_nids = alc880_dac_nids,
  1424. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1425. .channel_mode = alc880_threestack_modes,
  1426. .input_mux = &alc880_capture_source,
  1427. },
  1428. [ALC880_3ST_DIG] = {
  1429. .mixers = { alc880_three_stack_mixer },
  1430. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1431. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1432. .dac_nids = alc880_dac_nids,
  1433. .dig_out_nid = ALC880_DIGOUT_NID,
  1434. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1435. .channel_mode = alc880_threestack_modes,
  1436. .input_mux = &alc880_capture_source,
  1437. },
  1438. [ALC880_5ST] = {
  1439. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1440. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1441. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1442. .dac_nids = alc880_dac_nids,
  1443. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1444. .channel_mode = alc880_fivestack_modes,
  1445. .input_mux = &alc880_capture_source,
  1446. },
  1447. [ALC880_5ST_DIG] = {
  1448. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1449. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1450. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1451. .dac_nids = alc880_dac_nids,
  1452. .dig_out_nid = ALC880_DIGOUT_NID,
  1453. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1454. .channel_mode = alc880_fivestack_modes,
  1455. .input_mux = &alc880_capture_source,
  1456. },
  1457. [ALC880_6ST] = {
  1458. .mixers = { alc880_six_stack_mixer },
  1459. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1460. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1461. .dac_nids = alc880_6st_dac_nids,
  1462. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1463. .channel_mode = alc880_sixstack_modes,
  1464. .input_mux = &alc880_6stack_capture_source,
  1465. },
  1466. [ALC880_6ST_DIG] = {
  1467. .mixers = { alc880_six_stack_mixer },
  1468. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1469. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1470. .dac_nids = alc880_6st_dac_nids,
  1471. .dig_out_nid = ALC880_DIGOUT_NID,
  1472. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1473. .channel_mode = alc880_sixstack_modes,
  1474. .input_mux = &alc880_6stack_capture_source,
  1475. },
  1476. [ALC880_W810] = {
  1477. .mixers = { alc880_w810_base_mixer },
  1478. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  1479. alc880_gpio2_init_verbs },
  1480. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1481. .dac_nids = alc880_w810_dac_nids,
  1482. .dig_out_nid = ALC880_DIGOUT_NID,
  1483. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1484. .channel_mode = alc880_w810_modes,
  1485. .input_mux = &alc880_capture_source,
  1486. },
  1487. [ALC880_Z71V] = {
  1488. .mixers = { alc880_z71v_mixer },
  1489. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  1490. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1491. .dac_nids = alc880_z71v_dac_nids,
  1492. .dig_out_nid = ALC880_DIGOUT_NID,
  1493. .hp_nid = 0x03,
  1494. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1495. .channel_mode = alc880_2_jack_modes,
  1496. .input_mux = &alc880_capture_source,
  1497. },
  1498. [ALC880_F1734] = {
  1499. .mixers = { alc880_f1734_mixer },
  1500. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1501. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1502. .dac_nids = alc880_f1734_dac_nids,
  1503. .hp_nid = 0x02,
  1504. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1505. .channel_mode = alc880_2_jack_modes,
  1506. .input_mux = &alc880_capture_source,
  1507. },
  1508. [ALC880_ASUS] = {
  1509. .mixers = { alc880_asus_mixer },
  1510. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1511. alc880_gpio1_init_verbs },
  1512. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1513. .dac_nids = alc880_asus_dac_nids,
  1514. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1515. .channel_mode = alc880_asus_modes,
  1516. .input_mux = &alc880_capture_source,
  1517. },
  1518. [ALC880_ASUS_DIG] = {
  1519. .mixers = { alc880_asus_mixer },
  1520. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1521. alc880_gpio1_init_verbs },
  1522. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1523. .dac_nids = alc880_asus_dac_nids,
  1524. .dig_out_nid = ALC880_DIGOUT_NID,
  1525. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1526. .channel_mode = alc880_asus_modes,
  1527. .input_mux = &alc880_capture_source,
  1528. },
  1529. [ALC880_ASUS_W1V] = {
  1530. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1531. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1532. alc880_gpio1_init_verbs },
  1533. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1534. .dac_nids = alc880_asus_dac_nids,
  1535. .dig_out_nid = ALC880_DIGOUT_NID,
  1536. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1537. .channel_mode = alc880_asus_modes,
  1538. .input_mux = &alc880_capture_source,
  1539. },
  1540. [ALC880_UNIWILL_DIG] = {
  1541. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  1542. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  1543. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1544. .dac_nids = alc880_asus_dac_nids,
  1545. .dig_out_nid = ALC880_DIGOUT_NID,
  1546. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1547. .channel_mode = alc880_asus_modes,
  1548. .input_mux = &alc880_capture_source,
  1549. },
  1550. #ifdef CONFIG_SND_DEBUG
  1551. [ALC880_TEST] = {
  1552. .mixers = { alc880_test_mixer },
  1553. .init_verbs = { alc880_test_init_verbs },
  1554. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  1555. .dac_nids = alc880_test_dac_nids,
  1556. .dig_out_nid = ALC880_DIGOUT_NID,
  1557. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  1558. .channel_mode = alc880_test_modes,
  1559. .input_mux = &alc880_test_capture_source,
  1560. },
  1561. #endif
  1562. };
  1563. /*
  1564. * Automatic parse of I/O pins from the BIOS configuration
  1565. */
  1566. #define NUM_CONTROL_ALLOC 32
  1567. #define NUM_VERB_ALLOC 32
  1568. enum {
  1569. ALC_CTL_WIDGET_VOL,
  1570. ALC_CTL_WIDGET_MUTE,
  1571. ALC_CTL_BIND_MUTE,
  1572. };
  1573. static snd_kcontrol_new_t alc880_control_templates[] = {
  1574. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  1575. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  1576. ALC_BIND_MUTE(NULL, 0, 0, 0),
  1577. };
  1578. /* add dynamic controls */
  1579. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  1580. {
  1581. snd_kcontrol_new_t *knew;
  1582. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  1583. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  1584. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  1585. if (! knew)
  1586. return -ENOMEM;
  1587. if (spec->kctl_alloc) {
  1588. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  1589. kfree(spec->kctl_alloc);
  1590. }
  1591. spec->kctl_alloc = knew;
  1592. spec->num_kctl_alloc = num;
  1593. }
  1594. knew = &spec->kctl_alloc[spec->num_kctl_used];
  1595. *knew = alc880_control_templates[type];
  1596. knew->name = kstrdup(name, GFP_KERNEL);
  1597. if (! knew->name)
  1598. return -ENOMEM;
  1599. knew->private_value = val;
  1600. spec->num_kctl_used++;
  1601. return 0;
  1602. }
  1603. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  1604. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  1605. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  1606. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  1607. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  1608. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  1609. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  1610. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  1611. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  1612. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  1613. #define ALC880_PIN_CD_NID 0x1c
  1614. /* fill in the dac_nids table from the parsed pin configuration */
  1615. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1616. {
  1617. hda_nid_t nid;
  1618. int assigned[4];
  1619. int i, j;
  1620. memset(assigned, 0, sizeof(assigned));
  1621. spec->multiout.dac_nids = spec->private_dac_nids;
  1622. /* check the pins hardwired to audio widget */
  1623. for (i = 0; i < cfg->line_outs; i++) {
  1624. nid = cfg->line_out_pins[i];
  1625. if (alc880_is_fixed_pin(nid)) {
  1626. int idx = alc880_fixed_pin_idx(nid);
  1627. spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
  1628. assigned[idx] = 1;
  1629. }
  1630. }
  1631. /* left pins can be connect to any audio widget */
  1632. for (i = 0; i < cfg->line_outs; i++) {
  1633. nid = cfg->line_out_pins[i];
  1634. if (alc880_is_fixed_pin(nid))
  1635. continue;
  1636. /* search for an empty channel */
  1637. for (j = 0; j < cfg->line_outs; j++) {
  1638. if (! assigned[j]) {
  1639. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  1640. assigned[j] = 1;
  1641. break;
  1642. }
  1643. }
  1644. }
  1645. spec->multiout.num_dacs = cfg->line_outs;
  1646. return 0;
  1647. }
  1648. /* add playback controls from the parsed DAC table */
  1649. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1650. {
  1651. char name[32];
  1652. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  1653. hda_nid_t nid;
  1654. int i, err;
  1655. for (i = 0; i < cfg->line_outs; i++) {
  1656. if (! spec->multiout.dac_nids[i])
  1657. continue;
  1658. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  1659. if (i == 2) {
  1660. /* Center/LFE */
  1661. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  1662. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  1663. return err;
  1664. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  1665. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  1666. return err;
  1667. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  1668. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  1669. return err;
  1670. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  1671. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  1672. return err;
  1673. } else {
  1674. sprintf(name, "%s Playback Volume", chname[i]);
  1675. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1676. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1677. return err;
  1678. sprintf(name, "%s Playback Switch", chname[i]);
  1679. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1680. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1681. return err;
  1682. }
  1683. }
  1684. return 0;
  1685. }
  1686. /* add playback controls for HP output */
  1687. static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  1688. {
  1689. hda_nid_t nid;
  1690. int err;
  1691. if (! pin)
  1692. return 0;
  1693. if (alc880_is_fixed_pin(pin)) {
  1694. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  1695. if (! spec->multiout.dac_nids[0]) {
  1696. /* use this as the primary output */
  1697. spec->multiout.dac_nids[0] = nid;
  1698. if (! spec->multiout.num_dacs)
  1699. spec->multiout.num_dacs = 1;
  1700. } else
  1701. /* specify the DAC as the extra HP output */
  1702. spec->multiout.hp_nid = nid;
  1703. /* control HP volume/switch on the output mixer amp */
  1704. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  1705. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  1706. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1707. return err;
  1708. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
  1709. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1710. return err;
  1711. } else if (alc880_is_multi_pin(pin)) {
  1712. /* set manual connection */
  1713. if (! spec->multiout.dac_nids[0]) {
  1714. /* use this as the primary output */
  1715. spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
  1716. if (! spec->multiout.num_dacs)
  1717. spec->multiout.num_dacs = 1;
  1718. }
  1719. /* we have only a switch on HP-out PIN */
  1720. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  1721. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  1722. return err;
  1723. }
  1724. return 0;
  1725. }
  1726. /* create input playback/capture controls for the given pin */
  1727. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
  1728. {
  1729. char name[32];
  1730. int err, idx;
  1731. sprintf(name, "%s Playback Volume", ctlname);
  1732. idx = alc880_input_pin_idx(pin);
  1733. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1734. HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
  1735. return err;
  1736. sprintf(name, "%s Playback Switch", ctlname);
  1737. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1738. HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
  1739. return err;
  1740. return 0;
  1741. }
  1742. /* create playback/capture controls for input pins */
  1743. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1744. {
  1745. static char *labels[AUTO_PIN_LAST] = {
  1746. "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
  1747. };
  1748. struct hda_input_mux *imux = &spec->private_imux;
  1749. int i, err;
  1750. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1751. if (alc880_is_input_pin(cfg->input_pins[i])) {
  1752. err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
  1753. if (err < 0)
  1754. return err;
  1755. imux->items[imux->num_items].label = labels[i];
  1756. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  1757. imux->num_items++;
  1758. }
  1759. }
  1760. return 0;
  1761. }
  1762. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
  1763. int dac_idx)
  1764. {
  1765. /* set as output */
  1766. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  1767. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  1768. /* need the manual connection? */
  1769. if (alc880_is_multi_pin(nid)) {
  1770. struct alc_spec *spec = codec->spec;
  1771. int idx = alc880_multi_pin_idx(nid);
  1772. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  1773. AC_VERB_SET_CONNECT_SEL,
  1774. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  1775. }
  1776. }
  1777. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  1778. {
  1779. struct alc_spec *spec = codec->spec;
  1780. int i;
  1781. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1782. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1783. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  1784. }
  1785. }
  1786. static void alc880_auto_init_hp_out(struct hda_codec *codec)
  1787. {
  1788. struct alc_spec *spec = codec->spec;
  1789. hda_nid_t pin;
  1790. pin = spec->autocfg.hp_pin;
  1791. if (pin) /* connect to front */
  1792. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  1793. }
  1794. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  1795. {
  1796. struct alc_spec *spec = codec->spec;
  1797. int i;
  1798. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1799. hda_nid_t nid = spec->autocfg.input_pins[i];
  1800. if (alc880_is_input_pin(nid)) {
  1801. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1802. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  1803. if (nid != ALC880_PIN_CD_NID)
  1804. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1805. AMP_OUT_MUTE);
  1806. }
  1807. }
  1808. }
  1809. /* parse the BIOS configuration and set up the alc_spec */
  1810. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  1811. static int alc880_parse_auto_config(struct hda_codec *codec)
  1812. {
  1813. struct alc_spec *spec = codec->spec;
  1814. int err;
  1815. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
  1816. return err;
  1817. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
  1818. return err;
  1819. if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
  1820. return 0; /* can't find valid BIOS pin config */
  1821. if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1822. (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  1823. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  1824. return err;
  1825. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1826. if (spec->autocfg.dig_out_pin)
  1827. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1828. if (spec->autocfg.dig_in_pin)
  1829. spec->dig_in_nid = ALC880_DIGIN_NID;
  1830. if (spec->kctl_alloc)
  1831. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1832. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  1833. spec->input_mux = &spec->private_imux;
  1834. return 1;
  1835. }
  1836. /* init callback for auto-configuration model -- overriding the default init */
  1837. static int alc880_auto_init(struct hda_codec *codec)
  1838. {
  1839. alc_init(codec);
  1840. alc880_auto_init_multi_out(codec);
  1841. alc880_auto_init_hp_out(codec);
  1842. alc880_auto_init_analog_input(codec);
  1843. return 0;
  1844. }
  1845. /*
  1846. * OK, here we have finally the patch for ALC880
  1847. */
  1848. static int patch_alc880(struct hda_codec *codec)
  1849. {
  1850. struct alc_spec *spec;
  1851. int board_config;
  1852. int i, err;
  1853. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1854. if (spec == NULL)
  1855. return -ENOMEM;
  1856. init_MUTEX(&spec->bind_mutex);
  1857. codec->spec = spec;
  1858. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  1859. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  1860. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  1861. board_config = ALC880_AUTO;
  1862. }
  1863. if (board_config == ALC880_AUTO) {
  1864. /* automatic parse from the BIOS config */
  1865. err = alc880_parse_auto_config(codec);
  1866. if (err < 0) {
  1867. alc_free(codec);
  1868. return err;
  1869. } else if (! err) {
  1870. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  1871. board_config = ALC880_3ST;
  1872. }
  1873. }
  1874. if (board_config != ALC880_AUTO) {
  1875. /* set up from the preset table */
  1876. const struct alc_config_preset *preset;
  1877. preset = &alc880_presets[board_config];
  1878. for (i = 0; preset->mixers[i]; i++) {
  1879. snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
  1880. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  1881. }
  1882. for (i = 0; preset->init_verbs[i]; i++) {
  1883. snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
  1884. spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
  1885. }
  1886. spec->channel_mode = preset->channel_mode;
  1887. spec->num_channel_mode = preset->num_channel_mode;
  1888. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1889. spec->multiout.num_dacs = preset->num_dacs;
  1890. spec->multiout.dac_nids = preset->dac_nids;
  1891. spec->multiout.dig_out_nid = preset->dig_out_nid;
  1892. spec->multiout.hp_nid = preset->hp_nid;
  1893. spec->input_mux = preset->input_mux;
  1894. spec->num_adc_nids = preset->num_adc_nids;
  1895. spec->adc_nids = preset->adc_nids;
  1896. }
  1897. spec->stream_name_analog = "ALC880 Analog";
  1898. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1899. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1900. spec->stream_name_digital = "ALC880 Digital";
  1901. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1902. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1903. if (! spec->adc_nids && spec->input_mux) {
  1904. /* check whether NID 0x07 is valid */
  1905. unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
  1906. AC_PAR_AUDIO_WIDGET_CAP);
  1907. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  1908. if (wcap != AC_WID_AUD_IN) {
  1909. spec->adc_nids = alc880_adc_nids_alt;
  1910. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  1911. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  1912. spec->num_mixers++;
  1913. } else {
  1914. spec->adc_nids = alc880_adc_nids;
  1915. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  1916. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  1917. spec->num_mixers++;
  1918. }
  1919. }
  1920. codec->patch_ops = alc_patch_ops;
  1921. if (board_config == ALC880_AUTO)
  1922. codec->patch_ops.init = alc880_auto_init;
  1923. return 0;
  1924. }
  1925. /*
  1926. * ALC260 support
  1927. */
  1928. static hda_nid_t alc260_dac_nids[1] = {
  1929. /* front */
  1930. 0x02,
  1931. };
  1932. static hda_nid_t alc260_adc_nids[1] = {
  1933. /* ADC0 */
  1934. 0x04,
  1935. };
  1936. static hda_nid_t alc260_hp_adc_nids[1] = {
  1937. /* ADC1 */
  1938. 0x05,
  1939. };
  1940. #define ALC260_DIGOUT_NID 0x03
  1941. #define ALC260_DIGIN_NID 0x06
  1942. static struct hda_input_mux alc260_capture_source = {
  1943. .num_items = 4,
  1944. .items = {
  1945. { "Mic", 0x0 },
  1946. { "Front Mic", 0x1 },
  1947. { "Line", 0x2 },
  1948. { "CD", 0x4 },
  1949. },
  1950. };
  1951. /*
  1952. * This is just place-holder, so there's something for alc_build_pcms to look
  1953. * at when it calculates the maximum number of channels. ALC260 has no mixer
  1954. * element which allows changing the channel mode, so the verb list is
  1955. * never used.
  1956. */
  1957. static struct alc_channel_mode alc260_modes[1] = {
  1958. { 2, NULL },
  1959. };
  1960. static snd_kcontrol_new_t alc260_base_mixer[] = {
  1961. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1962. ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  1963. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1964. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1965. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1966. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1968. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1969. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1970. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1971. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  1972. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  1973. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  1974. ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  1975. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  1976. ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  1977. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  1978. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  1979. {
  1980. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1981. .name = "Capture Source",
  1982. .info = alc_mux_enum_info,
  1983. .get = alc_mux_enum_get,
  1984. .put = alc_mux_enum_put,
  1985. },
  1986. { } /* end */
  1987. };
  1988. static snd_kcontrol_new_t alc260_hp_mixer[] = {
  1989. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1990. ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  1991. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1992. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1993. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1994. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1995. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1996. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1997. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1998. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1999. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2000. ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2001. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2002. ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2003. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2004. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2005. {
  2006. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2007. .name = "Capture Source",
  2008. .info = alc_mux_enum_info,
  2009. .get = alc_mux_enum_get,
  2010. .put = alc_mux_enum_put,
  2011. },
  2012. { } /* end */
  2013. };
  2014. static struct hda_verb alc260_init_verbs[] = {
  2015. /* Line In pin widget for input */
  2016. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2017. /* CD pin widget for input */
  2018. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2019. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2020. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2021. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2022. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2023. /* LINE-2 is used for line-out in rear */
  2024. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2025. /* select line-out */
  2026. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  2027. /* LINE-OUT pin */
  2028. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2029. /* enable HP */
  2030. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2031. /* enable Mono */
  2032. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2033. /* mute capture amp left and right */
  2034. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2035. /* set connection select to line in (default select for this ADC) */
  2036. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2037. /* mute capture amp left and right */
  2038. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2039. /* set connection select to line in (default select for this ADC) */
  2040. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2041. /* set vol=0 Line-Out mixer amp left and right */
  2042. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2043. /* unmute pin widget amp left and right (no gain on this amp) */
  2044. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2045. /* set vol=0 HP mixer amp left and right */
  2046. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2047. /* unmute pin widget amp left and right (no gain on this amp) */
  2048. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2049. /* set vol=0 Mono mixer amp left and right */
  2050. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2051. /* unmute pin widget amp left and right (no gain on this amp) */
  2052. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2053. /* unmute LINE-2 out pin */
  2054. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2055. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2056. /* mute CD */
  2057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2058. /* mute Line In */
  2059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2060. /* mute Mic */
  2061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2062. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2063. /* mute Front out path */
  2064. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2065. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2066. /* mute Headphone out path */
  2067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2069. /* mute Mono out path */
  2070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2071. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2072. { }
  2073. };
  2074. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  2075. .substreams = 1,
  2076. .channels_min = 2,
  2077. .channels_max = 2,
  2078. };
  2079. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  2080. .substreams = 1,
  2081. .channels_min = 2,
  2082. .channels_max = 2,
  2083. };
  2084. static struct hda_board_config alc260_cfg_tbl[] = {
  2085. { .modelname = "hp", .config = ALC260_HP },
  2086. { .pci_subvendor = 0x103c, .config = ALC260_HP },
  2087. {}
  2088. };
  2089. static int patch_alc260(struct hda_codec *codec)
  2090. {
  2091. struct alc_spec *spec;
  2092. int board_config;
  2093. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2094. if (spec == NULL)
  2095. return -ENOMEM;
  2096. init_MUTEX(&spec->bind_mutex);
  2097. codec->spec = spec;
  2098. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  2099. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  2100. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  2101. board_config = ALC260_BASIC;
  2102. }
  2103. switch (board_config) {
  2104. case ALC260_HP:
  2105. spec->mixers[spec->num_mixers] = alc260_hp_mixer;
  2106. spec->num_mixers++;
  2107. break;
  2108. default:
  2109. spec->mixers[spec->num_mixers] = alc260_base_mixer;
  2110. spec->num_mixers++;
  2111. break;
  2112. }
  2113. spec->init_verbs[0] = alc260_init_verbs;
  2114. spec->num_init_verbs = 1;
  2115. spec->channel_mode = alc260_modes;
  2116. spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
  2117. spec->stream_name_analog = "ALC260 Analog";
  2118. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  2119. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  2120. spec->multiout.max_channels = spec->channel_mode[0].channels;
  2121. spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
  2122. spec->multiout.dac_nids = alc260_dac_nids;
  2123. spec->input_mux = &alc260_capture_source;
  2124. switch (board_config) {
  2125. case ALC260_HP:
  2126. spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
  2127. spec->adc_nids = alc260_hp_adc_nids;
  2128. break;
  2129. default:
  2130. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  2131. spec->adc_nids = alc260_adc_nids;
  2132. break;
  2133. }
  2134. codec->patch_ops = alc_patch_ops;
  2135. return 0;
  2136. }
  2137. /*
  2138. * ALC882 support
  2139. *
  2140. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  2141. * configuration. Each pin widget can choose any input DACs and a mixer.
  2142. * Each ADC is connected from a mixer of all inputs. This makes possible
  2143. * 6-channel independent captures.
  2144. *
  2145. * In addition, an independent DAC for the multi-playback (not used in this
  2146. * driver yet).
  2147. */
  2148. static struct alc_channel_mode alc882_ch_modes[1] = {
  2149. { 8, NULL }
  2150. };
  2151. static hda_nid_t alc882_dac_nids[4] = {
  2152. /* front, rear, clfe, rear_surr */
  2153. 0x02, 0x03, 0x04, 0x05
  2154. };
  2155. static hda_nid_t alc882_adc_nids[3] = {
  2156. /* ADC0-2 */
  2157. 0x07, 0x08, 0x09,
  2158. };
  2159. /* input MUX */
  2160. /* FIXME: should be a matrix-type input source selection */
  2161. static struct hda_input_mux alc882_capture_source = {
  2162. .num_items = 4,
  2163. .items = {
  2164. { "Mic", 0x0 },
  2165. { "Front Mic", 0x1 },
  2166. { "Line", 0x2 },
  2167. { "CD", 0x4 },
  2168. },
  2169. };
  2170. #define alc882_mux_enum_info alc_mux_enum_info
  2171. #define alc882_mux_enum_get alc_mux_enum_get
  2172. static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  2173. {
  2174. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2175. struct alc_spec *spec = codec->spec;
  2176. const struct hda_input_mux *imux = spec->input_mux;
  2177. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  2178. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  2179. hda_nid_t nid = capture_mixers[adc_idx];
  2180. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  2181. unsigned int i, idx;
  2182. idx = ucontrol->value.enumerated.item[0];
  2183. if (idx >= imux->num_items)
  2184. idx = imux->num_items - 1;
  2185. if (*cur_val == idx && ! codec->in_resume)
  2186. return 0;
  2187. for (i = 0; i < imux->num_items; i++) {
  2188. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  2189. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2190. v | (imux->items[i].index << 8));
  2191. }
  2192. *cur_val = idx;
  2193. return 1;
  2194. }
  2195. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  2196. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  2197. */
  2198. static snd_kcontrol_new_t alc882_base_mixer[] = {
  2199. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2200. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2201. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2202. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2203. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  2204. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  2205. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  2206. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  2207. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2208. ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2209. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  2210. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  2211. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  2212. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  2213. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  2214. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2215. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2216. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2217. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2218. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  2219. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  2220. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  2221. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  2222. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  2223. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  2224. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  2225. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  2226. {
  2227. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2228. /* .name = "Capture Source", */
  2229. .name = "Input Source",
  2230. .count = 3,
  2231. .info = alc882_mux_enum_info,
  2232. .get = alc882_mux_enum_get,
  2233. .put = alc882_mux_enum_put,
  2234. },
  2235. { } /* end */
  2236. };
  2237. static struct hda_verb alc882_init_verbs[] = {
  2238. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  2239. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2242. /* Rear mixer */
  2243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2245. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2246. /* CLFE mixer */
  2247. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2248. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2249. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2250. /* Side mixer */
  2251. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2252. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2253. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2254. /* Front Pin: output 0 (0x0c) */
  2255. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2256. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2257. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  2258. /* Rear Pin: output 1 (0x0d) */
  2259. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2260. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2261. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  2262. /* CLFE Pin: output 2 (0x0e) */
  2263. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2264. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2265. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  2266. /* Side Pin: output 3 (0x0f) */
  2267. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2268. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2269. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  2270. /* Mic (rear) pin: input vref at 80% */
  2271. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2272. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2273. /* Front Mic pin: input vref at 80% */
  2274. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2275. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2276. /* Line In pin: input */
  2277. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2278. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2279. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  2280. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2281. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2282. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  2283. /* CD pin widget for input */
  2284. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2285. /* FIXME: use matrix-type input source selection */
  2286. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  2287. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  2288. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2289. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2290. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2291. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2292. /* Input mixer2 */
  2293. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2294. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2295. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2296. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2297. /* Input mixer3 */
  2298. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2299. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2300. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2301. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2302. /* ADC1: mute amp left and right */
  2303. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2304. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2305. /* ADC2: mute amp left and right */
  2306. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2307. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2308. /* ADC3: mute amp left and right */
  2309. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2310. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2311. { }
  2312. };
  2313. static int patch_alc882(struct hda_codec *codec)
  2314. {
  2315. struct alc_spec *spec;
  2316. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2317. if (spec == NULL)
  2318. return -ENOMEM;
  2319. init_MUTEX(&spec->bind_mutex);
  2320. codec->spec = spec;
  2321. spec->mixers[spec->num_mixers] = alc882_base_mixer;
  2322. spec->num_mixers++;
  2323. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2324. spec->dig_in_nid = ALC880_DIGIN_NID;
  2325. spec->init_verbs[0] = alc882_init_verbs;
  2326. spec->num_init_verbs = 1;
  2327. spec->channel_mode = alc882_ch_modes;
  2328. spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
  2329. spec->stream_name_analog = "ALC882 Analog";
  2330. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2331. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2332. spec->stream_name_digital = "ALC882 Digital";
  2333. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2334. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2335. spec->multiout.max_channels = spec->channel_mode[0].channels;
  2336. spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
  2337. spec->multiout.dac_nids = alc882_dac_nids;
  2338. spec->input_mux = &alc882_capture_source;
  2339. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  2340. spec->adc_nids = alc882_adc_nids;
  2341. codec->patch_ops = alc_patch_ops;
  2342. return 0;
  2343. }
  2344. /*
  2345. * patch entries
  2346. */
  2347. struct hda_codec_preset snd_hda_preset_realtek[] = {
  2348. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  2349. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  2350. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  2351. {} /* terminator */
  2352. };