patch_realtek.c 189 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552
  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 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. /* ALC880 board config type */
  34. enum {
  35. ALC880_3ST,
  36. ALC880_3ST_DIG,
  37. ALC880_5ST,
  38. ALC880_5ST_DIG,
  39. ALC880_W810,
  40. ALC880_Z71V,
  41. ALC880_6ST,
  42. ALC880_6ST_DIG,
  43. ALC880_F1734,
  44. ALC880_ASUS,
  45. ALC880_ASUS_DIG,
  46. ALC880_ASUS_W1V,
  47. ALC880_ASUS_DIG2,
  48. ALC880_UNIWILL_DIG,
  49. ALC880_CLEVO,
  50. ALC880_TCL_S700,
  51. ALC880_LG,
  52. #ifdef CONFIG_SND_DEBUG
  53. ALC880_TEST,
  54. #endif
  55. ALC880_AUTO,
  56. ALC880_MODEL_LAST /* last tag */
  57. };
  58. /* ALC260 models */
  59. enum {
  60. ALC260_BASIC,
  61. ALC260_HP,
  62. ALC260_HP_3013,
  63. ALC260_FUJITSU_S702X,
  64. ALC260_ACER,
  65. #ifdef CONFIG_SND_DEBUG
  66. ALC260_TEST,
  67. #endif
  68. ALC260_AUTO,
  69. ALC260_MODEL_LAST /* last tag */
  70. };
  71. /* ALC262 models */
  72. enum {
  73. ALC262_BASIC,
  74. ALC262_FUJITSU,
  75. ALC262_AUTO,
  76. ALC262_MODEL_LAST /* last tag */
  77. };
  78. /* ALC861 models */
  79. enum {
  80. ALC861_3ST,
  81. ALC861_3ST_DIG,
  82. ALC861_6ST_DIG,
  83. ALC861_AUTO,
  84. ALC861_MODEL_LAST,
  85. };
  86. /* ALC882 models */
  87. enum {
  88. ALC882_3ST_DIG,
  89. ALC882_6ST_DIG,
  90. ALC882_AUTO,
  91. ALC882_MODEL_LAST,
  92. };
  93. /* for GPIO Poll */
  94. #define GPIO_MASK 0x03
  95. struct alc_spec {
  96. /* codec parameterization */
  97. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  98. unsigned int num_mixers;
  99. const struct hda_verb *init_verbs[5]; /* initialization verbs
  100. * don't forget NULL termination!
  101. */
  102. unsigned int num_init_verbs;
  103. char *stream_name_analog; /* analog PCM stream */
  104. struct hda_pcm_stream *stream_analog_playback;
  105. struct hda_pcm_stream *stream_analog_capture;
  106. char *stream_name_digital; /* digital PCM stream */
  107. struct hda_pcm_stream *stream_digital_playback;
  108. struct hda_pcm_stream *stream_digital_capture;
  109. /* playback */
  110. struct hda_multi_out multiout; /* playback set-up
  111. * max_channels, dacs must be set
  112. * dig_out_nid and hp_nid are optional
  113. */
  114. /* capture */
  115. unsigned int num_adc_nids;
  116. hda_nid_t *adc_nids;
  117. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  118. /* capture source */
  119. const struct hda_input_mux *input_mux;
  120. unsigned int cur_mux[3];
  121. /* channel model */
  122. const struct hda_channel_mode *channel_mode;
  123. int num_channel_mode;
  124. /* PCM information */
  125. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  126. /* dynamic controls, init_verbs and input_mux */
  127. struct auto_pin_cfg autocfg;
  128. unsigned int num_kctl_alloc, num_kctl_used;
  129. struct snd_kcontrol_new *kctl_alloc;
  130. struct hda_input_mux private_imux;
  131. hda_nid_t private_dac_nids[5];
  132. /* hooks */
  133. void (*init_hook)(struct hda_codec *codec);
  134. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  135. /* for pin sensing */
  136. unsigned int sense_updated: 1;
  137. unsigned int jack_present: 1;
  138. };
  139. /*
  140. * configuration template - to be copied to the spec instance
  141. */
  142. struct alc_config_preset {
  143. struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
  144. const struct hda_verb *init_verbs[5];
  145. unsigned int num_dacs;
  146. hda_nid_t *dac_nids;
  147. hda_nid_t dig_out_nid; /* optional */
  148. hda_nid_t hp_nid; /* optional */
  149. unsigned int num_adc_nids;
  150. hda_nid_t *adc_nids;
  151. hda_nid_t dig_in_nid;
  152. unsigned int num_channel_mode;
  153. const struct hda_channel_mode *channel_mode;
  154. const struct hda_input_mux *input_mux;
  155. void (*unsol_event)(struct hda_codec *, unsigned int);
  156. void (*init_hook)(struct hda_codec *);
  157. };
  158. /*
  159. * input MUX handling
  160. */
  161. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  162. {
  163. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  164. struct alc_spec *spec = codec->spec;
  165. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  166. }
  167. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  168. {
  169. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  170. struct alc_spec *spec = codec->spec;
  171. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  172. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  173. return 0;
  174. }
  175. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  176. {
  177. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  178. struct alc_spec *spec = codec->spec;
  179. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  180. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  181. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  182. }
  183. /*
  184. * channel mode setting
  185. */
  186. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  187. {
  188. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  189. struct alc_spec *spec = codec->spec;
  190. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  191. spec->num_channel_mode);
  192. }
  193. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  194. {
  195. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  196. struct alc_spec *spec = codec->spec;
  197. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  198. spec->num_channel_mode, spec->multiout.max_channels);
  199. }
  200. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  201. {
  202. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  203. struct alc_spec *spec = codec->spec;
  204. return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  205. spec->num_channel_mode, &spec->multiout.max_channels);
  206. }
  207. /*
  208. * Control the mode of pin widget settings via the mixer. "pc" is used
  209. * instead of "%" to avoid consequences of accidently treating the % as
  210. * being part of a format specifier. Maximum allowed length of a value is
  211. * 63 characters plus NULL terminator.
  212. *
  213. * Note: some retasking pin complexes seem to ignore requests for input
  214. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  215. * are requested. Therefore order this list so that this behaviour will not
  216. * cause problems when mixer clients move through the enum sequentially.
  217. * NIDs 0x0f and 0x10 have been observed to have this behaviour.
  218. */
  219. static char *alc_pin_mode_names[] = {
  220. "Mic 50pc bias", "Mic 80pc bias",
  221. "Line in", "Line out", "Headphone out",
  222. };
  223. static unsigned char alc_pin_mode_values[] = {
  224. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  225. };
  226. /* The control can present all 5 options, or it can limit the options based
  227. * in the pin being assumed to be exclusively an input or an output pin.
  228. */
  229. #define ALC_PIN_DIR_IN 0x00
  230. #define ALC_PIN_DIR_OUT 0x01
  231. #define ALC_PIN_DIR_INOUT 0x02
  232. /* Info about the pin modes supported by the three different pin directions.
  233. * For each direction the minimum and maximum values are given.
  234. */
  235. static signed char alc_pin_mode_dir_info[3][2] = {
  236. { 0, 2 }, /* ALC_PIN_DIR_IN */
  237. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  238. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  239. };
  240. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  241. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  242. #define alc_pin_mode_n_items(_dir) \
  243. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  244. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  245. {
  246. unsigned int item_num = uinfo->value.enumerated.item;
  247. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  248. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  249. uinfo->count = 1;
  250. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  251. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  252. item_num = alc_pin_mode_min(dir);
  253. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  254. return 0;
  255. }
  256. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  257. {
  258. unsigned int i;
  259. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  260. hda_nid_t nid = kcontrol->private_value & 0xffff;
  261. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  262. long *valp = ucontrol->value.integer.value;
  263. unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
  264. /* Find enumerated value for current pinctl setting */
  265. i = alc_pin_mode_min(dir);
  266. while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
  267. i++;
  268. *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
  269. return 0;
  270. }
  271. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  272. {
  273. signed int change;
  274. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  275. hda_nid_t nid = kcontrol->private_value & 0xffff;
  276. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  277. long val = *ucontrol->value.integer.value;
  278. unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
  279. if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
  280. val = alc_pin_mode_min(dir);
  281. change = pinctl != alc_pin_mode_values[val];
  282. if (change) {
  283. /* Set pin mode to that requested */
  284. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  285. alc_pin_mode_values[val]);
  286. /* Also enable the retasking pin's input/output as required
  287. * for the requested pin mode. Enum values of 2 or less are
  288. * input modes.
  289. *
  290. * Dynamically switching the input/output buffers probably
  291. * reduces noise slightly, particularly on input. However,
  292. * havingboth input and output buffers enabled
  293. * simultaneously doesn't seem to be problematic.
  294. */
  295. if (val <= 2) {
  296. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
  297. AMP_OUT_MUTE);
  298. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
  299. AMP_IN_UNMUTE(0));
  300. } else {
  301. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
  302. AMP_IN_MUTE(0));
  303. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
  304. AMP_OUT_UNMUTE);
  305. }
  306. }
  307. return change;
  308. }
  309. #define ALC_PIN_MODE(xname, nid, dir) \
  310. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  311. .info = alc_pin_mode_info, \
  312. .get = alc_pin_mode_get, \
  313. .put = alc_pin_mode_put, \
  314. .private_value = nid | (dir<<16) }
  315. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  316. * together using a mask with more than one bit set. This control is
  317. * currently used only by the ALC260 test model. At this stage they are not
  318. * needed for any "production" models.
  319. */
  320. #ifdef CONFIG_SND_DEBUG
  321. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  322. {
  323. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  324. uinfo->count = 1;
  325. uinfo->value.integer.min = 0;
  326. uinfo->value.integer.max = 1;
  327. return 0;
  328. }
  329. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  330. {
  331. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  332. hda_nid_t nid = kcontrol->private_value & 0xffff;
  333. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  334. long *valp = ucontrol->value.integer.value;
  335. unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
  336. *valp = (val & mask) != 0;
  337. return 0;
  338. }
  339. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  340. {
  341. signed int change;
  342. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  343. hda_nid_t nid = kcontrol->private_value & 0xffff;
  344. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  345. long val = *ucontrol->value.integer.value;
  346. unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
  347. /* Set/unset the masked GPIO bit(s) as needed */
  348. change = (val==0?0:mask) != (gpio_data & mask);
  349. if (val==0)
  350. gpio_data &= ~mask;
  351. else
  352. gpio_data |= mask;
  353. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
  354. return change;
  355. }
  356. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  357. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  358. .info = alc_gpio_data_info, \
  359. .get = alc_gpio_data_get, \
  360. .put = alc_gpio_data_put, \
  361. .private_value = nid | (mask<<16) }
  362. #endif /* CONFIG_SND_DEBUG */
  363. /* A switch control to allow the enabling of the digital IO pins on the
  364. * ALC260. This is incredibly simplistic; the intention of this control is
  365. * to provide something in the test model allowing digital outputs to be
  366. * identified if present. If models are found which can utilise these
  367. * outputs a more complete mixer control can be devised for those models if
  368. * necessary.
  369. */
  370. #ifdef CONFIG_SND_DEBUG
  371. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  372. {
  373. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  374. uinfo->count = 1;
  375. uinfo->value.integer.min = 0;
  376. uinfo->value.integer.max = 1;
  377. return 0;
  378. }
  379. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  380. {
  381. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  382. hda_nid_t nid = kcontrol->private_value & 0xffff;
  383. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  384. long *valp = ucontrol->value.integer.value;
  385. unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
  386. *valp = (val & mask) != 0;
  387. return 0;
  388. }
  389. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  390. {
  391. signed int change;
  392. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  393. hda_nid_t nid = kcontrol->private_value & 0xffff;
  394. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  395. long val = *ucontrol->value.integer.value;
  396. unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
  397. /* Set/unset the masked control bit(s) as needed */
  398. change = (val==0?0:mask) != (ctrl_data & mask);
  399. if (val==0)
  400. ctrl_data &= ~mask;
  401. else
  402. ctrl_data |= mask;
  403. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
  404. return change;
  405. }
  406. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  407. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  408. .info = alc_spdif_ctrl_info, \
  409. .get = alc_spdif_ctrl_get, \
  410. .put = alc_spdif_ctrl_put, \
  411. .private_value = nid | (mask<<16) }
  412. #endif /* CONFIG_SND_DEBUG */
  413. /*
  414. * set up from the preset table
  415. */
  416. static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
  417. {
  418. int i;
  419. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  420. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  421. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
  422. spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
  423. spec->channel_mode = preset->channel_mode;
  424. spec->num_channel_mode = preset->num_channel_mode;
  425. spec->multiout.max_channels = spec->channel_mode[0].channels;
  426. spec->multiout.num_dacs = preset->num_dacs;
  427. spec->multiout.dac_nids = preset->dac_nids;
  428. spec->multiout.dig_out_nid = preset->dig_out_nid;
  429. spec->multiout.hp_nid = preset->hp_nid;
  430. spec->input_mux = preset->input_mux;
  431. spec->num_adc_nids = preset->num_adc_nids;
  432. spec->adc_nids = preset->adc_nids;
  433. spec->dig_in_nid = preset->dig_in_nid;
  434. spec->unsol_event = preset->unsol_event;
  435. spec->init_hook = preset->init_hook;
  436. }
  437. /*
  438. * ALC880 3-stack model
  439. *
  440. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  441. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
  442. * HP = 0x19
  443. */
  444. static hda_nid_t alc880_dac_nids[4] = {
  445. /* front, rear, clfe, rear_surr */
  446. 0x02, 0x05, 0x04, 0x03
  447. };
  448. static hda_nid_t alc880_adc_nids[3] = {
  449. /* ADC0-2 */
  450. 0x07, 0x08, 0x09,
  451. };
  452. /* The datasheet says the node 0x07 is connected from inputs,
  453. * but it shows zero connection in the real implementation on some devices.
  454. * Note: this is a 915GAV bug, fixed on 915GLV
  455. */
  456. static hda_nid_t alc880_adc_nids_alt[2] = {
  457. /* ADC1-2 */
  458. 0x08, 0x09,
  459. };
  460. #define ALC880_DIGOUT_NID 0x06
  461. #define ALC880_DIGIN_NID 0x0a
  462. static struct hda_input_mux alc880_capture_source = {
  463. .num_items = 4,
  464. .items = {
  465. { "Mic", 0x0 },
  466. { "Front Mic", 0x3 },
  467. { "Line", 0x2 },
  468. { "CD", 0x4 },
  469. },
  470. };
  471. /* channel source setting (2/6 channel selection for 3-stack) */
  472. /* 2ch mode */
  473. static struct hda_verb alc880_threestack_ch2_init[] = {
  474. /* set line-in to input, mute it */
  475. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  476. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  477. /* set mic-in to input vref 80%, mute it */
  478. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  479. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  480. { } /* end */
  481. };
  482. /* 6ch mode */
  483. static struct hda_verb alc880_threestack_ch6_init[] = {
  484. /* set line-in to output, unmute it */
  485. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  486. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  487. /* set mic-in to output, unmute it */
  488. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  489. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  490. { } /* end */
  491. };
  492. static struct hda_channel_mode alc880_threestack_modes[2] = {
  493. { 2, alc880_threestack_ch2_init },
  494. { 6, alc880_threestack_ch6_init },
  495. };
  496. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  497. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  498. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  499. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  500. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  501. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  502. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  503. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  504. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  505. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  506. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  507. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  508. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  509. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  510. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  511. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  512. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  513. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  514. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  515. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  516. {
  517. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  518. .name = "Channel Mode",
  519. .info = alc_ch_mode_info,
  520. .get = alc_ch_mode_get,
  521. .put = alc_ch_mode_put,
  522. },
  523. { } /* end */
  524. };
  525. /* capture mixer elements */
  526. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  527. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  528. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  529. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  530. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  531. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  532. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  533. {
  534. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  535. /* The multiple "Capture Source" controls confuse alsamixer
  536. * So call somewhat different..
  537. * FIXME: the controls appear in the "playback" view!
  538. */
  539. /* .name = "Capture Source", */
  540. .name = "Input Source",
  541. .count = 3,
  542. .info = alc_mux_enum_info,
  543. .get = alc_mux_enum_get,
  544. .put = alc_mux_enum_put,
  545. },
  546. { } /* end */
  547. };
  548. /* capture mixer elements (in case NID 0x07 not available) */
  549. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  550. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  551. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  552. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  553. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  554. {
  555. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  556. /* The multiple "Capture Source" controls confuse alsamixer
  557. * So call somewhat different..
  558. * FIXME: the controls appear in the "playback" view!
  559. */
  560. /* .name = "Capture Source", */
  561. .name = "Input Source",
  562. .count = 2,
  563. .info = alc_mux_enum_info,
  564. .get = alc_mux_enum_get,
  565. .put = alc_mux_enum_put,
  566. },
  567. { } /* end */
  568. };
  569. /*
  570. * ALC880 5-stack model
  571. *
  572. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
  573. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  574. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  575. */
  576. /* additional mixers to alc880_three_stack_mixer */
  577. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  578. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  579. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  580. { } /* end */
  581. };
  582. /* channel source setting (6/8 channel selection for 5-stack) */
  583. /* 6ch mode */
  584. static struct hda_verb alc880_fivestack_ch6_init[] = {
  585. /* set line-in to input, mute it */
  586. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  587. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  588. { } /* end */
  589. };
  590. /* 8ch mode */
  591. static struct hda_verb alc880_fivestack_ch8_init[] = {
  592. /* set line-in to output, unmute it */
  593. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  594. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  595. { } /* end */
  596. };
  597. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  598. { 6, alc880_fivestack_ch6_init },
  599. { 8, alc880_fivestack_ch8_init },
  600. };
  601. /*
  602. * ALC880 6-stack model
  603. *
  604. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
  605. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  606. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  607. */
  608. static hda_nid_t alc880_6st_dac_nids[4] = {
  609. /* front, rear, clfe, rear_surr */
  610. 0x02, 0x03, 0x04, 0x05
  611. };
  612. static struct hda_input_mux alc880_6stack_capture_source = {
  613. .num_items = 4,
  614. .items = {
  615. { "Mic", 0x0 },
  616. { "Front Mic", 0x1 },
  617. { "Line", 0x2 },
  618. { "CD", 0x4 },
  619. },
  620. };
  621. /* fixed 8-channels */
  622. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  623. { 8, NULL },
  624. };
  625. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  626. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  627. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  628. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  629. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  630. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  631. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  632. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  633. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  634. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  635. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  636. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  637. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  638. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  639. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  640. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  641. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  642. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  643. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  644. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  645. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  646. {
  647. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  648. .name = "Channel Mode",
  649. .info = alc_ch_mode_info,
  650. .get = alc_ch_mode_get,
  651. .put = alc_ch_mode_put,
  652. },
  653. { } /* end */
  654. };
  655. /*
  656. * ALC880 W810 model
  657. *
  658. * W810 has rear IO for:
  659. * Front (DAC 02)
  660. * Surround (DAC 03)
  661. * Center/LFE (DAC 04)
  662. * Digital out (06)
  663. *
  664. * The system also has a pair of internal speakers, and a headphone jack.
  665. * These are both connected to Line2 on the codec, hence to DAC 02.
  666. *
  667. * There is a variable resistor to control the speaker or headphone
  668. * volume. This is a hardware-only device without a software API.
  669. *
  670. * Plugging headphones in will disable the internal speakers. This is
  671. * implemented in hardware, not via the driver using jack sense. In
  672. * a similar fashion, plugging into the rear socket marked "front" will
  673. * disable both the speakers and headphones.
  674. *
  675. * For input, there's a microphone jack, and an "audio in" jack.
  676. * These may not do anything useful with this driver yet, because I
  677. * haven't setup any initialization verbs for these yet...
  678. */
  679. static hda_nid_t alc880_w810_dac_nids[3] = {
  680. /* front, rear/surround, clfe */
  681. 0x02, 0x03, 0x04
  682. };
  683. /* fixed 6 channels */
  684. static struct hda_channel_mode alc880_w810_modes[1] = {
  685. { 6, NULL }
  686. };
  687. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  688. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  689. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  690. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  691. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  692. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  693. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  694. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  695. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  696. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  697. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  698. { } /* end */
  699. };
  700. /*
  701. * Z710V model
  702. *
  703. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  704. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
  705. */
  706. static hda_nid_t alc880_z71v_dac_nids[1] = {
  707. 0x02
  708. };
  709. #define ALC880_Z71V_HP_DAC 0x03
  710. /* fixed 2 channels */
  711. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  712. { 2, NULL }
  713. };
  714. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  715. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  716. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  717. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  718. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  719. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  720. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  722. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  723. { } /* end */
  724. };
  725. /* FIXME! */
  726. /*
  727. * ALC880 F1734 model
  728. *
  729. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  730. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  731. */
  732. static hda_nid_t alc880_f1734_dac_nids[1] = {
  733. 0x03
  734. };
  735. #define ALC880_F1734_HP_DAC 0x02
  736. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  737. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  738. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  739. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  740. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  741. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  742. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  743. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  744. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  745. { } /* end */
  746. };
  747. /* FIXME! */
  748. /*
  749. * ALC880 ASUS model
  750. *
  751. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  752. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  753. * Mic = 0x18, Line = 0x1a
  754. */
  755. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  756. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  757. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  758. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  759. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  760. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  761. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  762. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  763. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  764. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  765. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  766. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  767. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  768. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  769. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  770. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  771. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  772. {
  773. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  774. .name = "Channel Mode",
  775. .info = alc_ch_mode_info,
  776. .get = alc_ch_mode_get,
  777. .put = alc_ch_mode_put,
  778. },
  779. { } /* end */
  780. };
  781. /* FIXME! */
  782. /*
  783. * ALC880 ASUS W1V model
  784. *
  785. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  786. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  787. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  788. */
  789. /* additional mixers to alc880_asus_mixer */
  790. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  791. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  792. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  793. { } /* end */
  794. };
  795. /* additional mixers to alc880_asus_mixer */
  796. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  797. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  798. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  799. { } /* end */
  800. };
  801. /* TCL S700 */
  802. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  803. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  804. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  805. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  806. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  807. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  808. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  809. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  810. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  811. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  812. {
  813. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  814. /* The multiple "Capture Source" controls confuse alsamixer
  815. * So call somewhat different..
  816. * FIXME: the controls appear in the "playback" view!
  817. */
  818. /* .name = "Capture Source", */
  819. .name = "Input Source",
  820. .count = 1,
  821. .info = alc_mux_enum_info,
  822. .get = alc_mux_enum_get,
  823. .put = alc_mux_enum_put,
  824. },
  825. { } /* end */
  826. };
  827. /*
  828. * build control elements
  829. */
  830. static int alc_build_controls(struct hda_codec *codec)
  831. {
  832. struct alc_spec *spec = codec->spec;
  833. int err;
  834. int i;
  835. for (i = 0; i < spec->num_mixers; i++) {
  836. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  837. if (err < 0)
  838. return err;
  839. }
  840. if (spec->multiout.dig_out_nid) {
  841. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  842. if (err < 0)
  843. return err;
  844. }
  845. if (spec->dig_in_nid) {
  846. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  847. if (err < 0)
  848. return err;
  849. }
  850. return 0;
  851. }
  852. /*
  853. * initialize the codec volumes, etc
  854. */
  855. /*
  856. * generic initialization of ADC, input mixers and output mixers
  857. */
  858. static struct hda_verb alc880_volume_init_verbs[] = {
  859. /*
  860. * Unmute ADC0-2 and set the default input to mic-in
  861. */
  862. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  863. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  864. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  865. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  866. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  867. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  868. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  869. * mixer widget
  870. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  871. * mic (mic 2)
  872. */
  873. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  874. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  875. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  876. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  879. /*
  880. * Set up output mixers (0x0c - 0x0f)
  881. */
  882. /* set vol=0 to output mixers */
  883. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  884. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  885. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  886. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  887. /* set up input amps for analog loopback */
  888. /* Amp Indices: DAC = 0, mixer = 1 */
  889. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  890. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  891. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  892. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  893. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  894. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  895. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  896. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  897. { }
  898. };
  899. /*
  900. * 3-stack pin configuration:
  901. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  902. */
  903. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  904. /*
  905. * preset connection lists of input pins
  906. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  907. */
  908. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  909. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  910. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  911. /*
  912. * Set pin mode and muting
  913. */
  914. /* set front pin widgets 0x14 for output */
  915. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  916. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  917. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  918. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  919. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  920. /* Mic2 (as headphone out) for HP output */
  921. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  922. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  923. /* Line In pin widget for input */
  924. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  925. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  926. /* Line2 (as front mic) pin widget for input and vref at 80% */
  927. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  928. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  929. /* CD pin widget for input */
  930. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  931. { }
  932. };
  933. /*
  934. * 5-stack pin configuration:
  935. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  936. * line-in/side = 0x1a, f-mic = 0x1b
  937. */
  938. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  939. /*
  940. * preset connection lists of input pins
  941. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  942. */
  943. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  944. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  945. /*
  946. * Set pin mode and muting
  947. */
  948. /* set pin widgets 0x14-0x17 for output */
  949. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  950. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  951. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  952. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  953. /* unmute pins for output (no gain on this amp) */
  954. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  955. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  956. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  957. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  958. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  959. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  960. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  961. /* Mic2 (as headphone out) for HP output */
  962. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  963. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  964. /* Line In pin widget for input */
  965. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  966. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  967. /* Line2 (as front mic) pin widget for input and vref at 80% */
  968. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  969. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  970. /* CD pin widget for input */
  971. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  972. { }
  973. };
  974. /*
  975. * W810 pin configuration:
  976. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  977. */
  978. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  979. /* hphone/speaker input selector: front DAC */
  980. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  981. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  982. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  983. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  984. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  985. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  986. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  987. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  988. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  989. { }
  990. };
  991. /*
  992. * Z71V pin configuration:
  993. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  994. */
  995. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  996. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  997. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  998. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  999. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1000. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1001. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1002. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1003. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1004. { }
  1005. };
  1006. /*
  1007. * 6-stack pin configuration:
  1008. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
  1009. * line = 0x1a, HP = 0x1b
  1010. */
  1011. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1012. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1013. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1014. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1015. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1016. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1017. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1018. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1019. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1020. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1021. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1022. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1023. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1024. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1025. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1026. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1027. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1028. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1029. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1030. { }
  1031. };
  1032. /* FIXME! */
  1033. /*
  1034. * F1734 pin configuration:
  1035. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1036. */
  1037. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1038. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1039. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1040. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1041. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1042. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1043. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1044. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1045. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1046. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1047. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1048. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1049. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1050. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1051. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1052. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1053. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1054. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1055. { }
  1056. };
  1057. /* FIXME! */
  1058. /*
  1059. * ASUS pin configuration:
  1060. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1061. */
  1062. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1063. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1064. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1065. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1066. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1067. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1068. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1069. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1070. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1071. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1072. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1073. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1074. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1075. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1076. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1077. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1078. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1079. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1080. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1081. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1082. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1083. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1084. { }
  1085. };
  1086. /* Enable GPIO mask and set output */
  1087. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1088. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1089. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1090. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1091. { }
  1092. };
  1093. /* Enable GPIO mask and set output */
  1094. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1095. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1096. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1097. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1098. { }
  1099. };
  1100. /* Clevo m520g init */
  1101. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1102. /* headphone output */
  1103. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1104. /* line-out */
  1105. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1106. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1107. /* Line-in */
  1108. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1109. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1110. /* CD */
  1111. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1112. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1113. /* Mic1 (rear panel) */
  1114. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1115. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1116. /* Mic2 (front panel) */
  1117. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1118. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1119. /* headphone */
  1120. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1121. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1122. /* change to EAPD mode */
  1123. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1124. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1125. { }
  1126. };
  1127. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1128. /* Headphone output */
  1129. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1130. /* Front output*/
  1131. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1132. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1133. /* Line In pin widget for input */
  1134. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1135. /* CD pin widget for input */
  1136. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1137. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1138. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1139. /* change to EAPD mode */
  1140. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1141. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1142. { }
  1143. };
  1144. /*
  1145. * LG m1 express dual
  1146. *
  1147. * Pin assignment:
  1148. * Rear Line-In/Out (blue): 0x14
  1149. * Build-in Mic-In: 0x15
  1150. * Speaker-out: 0x17
  1151. * HP-Out (green): 0x1b
  1152. * Mic-In/Out (red): 0x19
  1153. * SPDIF-Out: 0x1e
  1154. */
  1155. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1156. static hda_nid_t alc880_lg_dac_nids[3] = {
  1157. 0x05, 0x02, 0x03
  1158. };
  1159. /* seems analog CD is not working */
  1160. static struct hda_input_mux alc880_lg_capture_source = {
  1161. .num_items = 3,
  1162. .items = {
  1163. { "Mic", 0x1 },
  1164. { "Line", 0x5 },
  1165. { "Internal Mic", 0x6 },
  1166. },
  1167. };
  1168. /* 2,4,6 channel modes */
  1169. static struct hda_verb alc880_lg_ch2_init[] = {
  1170. /* set line-in and mic-in to input */
  1171. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1172. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1173. { }
  1174. };
  1175. static struct hda_verb alc880_lg_ch4_init[] = {
  1176. /* set line-in to out and mic-in to input */
  1177. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1178. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1179. { }
  1180. };
  1181. static struct hda_verb alc880_lg_ch6_init[] = {
  1182. /* set line-in and mic-in to output */
  1183. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1184. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1185. { }
  1186. };
  1187. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1188. { 2, alc880_lg_ch2_init },
  1189. { 4, alc880_lg_ch4_init },
  1190. { 6, alc880_lg_ch6_init },
  1191. };
  1192. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1193. /* FIXME: it's not really "master" but front channels */
  1194. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1195. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1196. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1197. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1198. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1199. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1200. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1201. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1202. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1203. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1204. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1205. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1206. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1207. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1208. {
  1209. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1210. .name = "Channel Mode",
  1211. .info = alc_ch_mode_info,
  1212. .get = alc_ch_mode_get,
  1213. .put = alc_ch_mode_put,
  1214. },
  1215. { } /* end */
  1216. };
  1217. static struct hda_verb alc880_lg_init_verbs[] = {
  1218. /* set capture source to mic-in */
  1219. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1220. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1221. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1222. /* mute all amp mixer inputs */
  1223. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1224. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1225. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1226. /* line-in to input */
  1227. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1228. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1229. /* built-in mic */
  1230. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1231. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1232. /* speaker-out */
  1233. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1234. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1235. /* mic-in to input */
  1236. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1237. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1238. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1239. /* HP-out */
  1240. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1241. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1242. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1243. /* jack sense */
  1244. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1245. { }
  1246. };
  1247. /* toggle speaker-output according to the hp-jack state */
  1248. static void alc880_lg_automute(struct hda_codec *codec)
  1249. {
  1250. unsigned int present;
  1251. present = snd_hda_codec_read(codec, 0x1b, 0,
  1252. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1253. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1254. 0x80, present ? 0x80 : 0);
  1255. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1256. 0x80, present ? 0x80 : 0);
  1257. }
  1258. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1259. {
  1260. /* Looks like the unsol event is incompatible with the standard
  1261. * definition. 4bit tag is placed at 28 bit!
  1262. */
  1263. if ((res >> 28) == 0x01)
  1264. alc880_lg_automute(codec);
  1265. }
  1266. /*
  1267. * Common callbacks
  1268. */
  1269. static int alc_init(struct hda_codec *codec)
  1270. {
  1271. struct alc_spec *spec = codec->spec;
  1272. unsigned int i;
  1273. for (i = 0; i < spec->num_init_verbs; i++)
  1274. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1275. if (spec->init_hook)
  1276. spec->init_hook(codec);
  1277. return 0;
  1278. }
  1279. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1280. {
  1281. struct alc_spec *spec = codec->spec;
  1282. if (spec->unsol_event)
  1283. spec->unsol_event(codec, res);
  1284. }
  1285. #ifdef CONFIG_PM
  1286. /*
  1287. * resume
  1288. */
  1289. static int alc_resume(struct hda_codec *codec)
  1290. {
  1291. struct alc_spec *spec = codec->spec;
  1292. int i;
  1293. alc_init(codec);
  1294. for (i = 0; i < spec->num_mixers; i++)
  1295. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1296. if (spec->multiout.dig_out_nid)
  1297. snd_hda_resume_spdif_out(codec);
  1298. if (spec->dig_in_nid)
  1299. snd_hda_resume_spdif_in(codec);
  1300. return 0;
  1301. }
  1302. #endif
  1303. /*
  1304. * Analog playback callbacks
  1305. */
  1306. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1307. struct hda_codec *codec,
  1308. struct snd_pcm_substream *substream)
  1309. {
  1310. struct alc_spec *spec = codec->spec;
  1311. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1312. }
  1313. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1314. struct hda_codec *codec,
  1315. unsigned int stream_tag,
  1316. unsigned int format,
  1317. struct snd_pcm_substream *substream)
  1318. {
  1319. struct alc_spec *spec = codec->spec;
  1320. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  1321. format, substream);
  1322. }
  1323. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1324. struct hda_codec *codec,
  1325. struct snd_pcm_substream *substream)
  1326. {
  1327. struct alc_spec *spec = codec->spec;
  1328. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1329. }
  1330. /*
  1331. * Digital out
  1332. */
  1333. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1334. struct hda_codec *codec,
  1335. struct snd_pcm_substream *substream)
  1336. {
  1337. struct alc_spec *spec = codec->spec;
  1338. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1339. }
  1340. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1341. struct hda_codec *codec,
  1342. struct snd_pcm_substream *substream)
  1343. {
  1344. struct alc_spec *spec = codec->spec;
  1345. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1346. }
  1347. /*
  1348. * Analog capture
  1349. */
  1350. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1351. struct hda_codec *codec,
  1352. unsigned int stream_tag,
  1353. unsigned int format,
  1354. struct snd_pcm_substream *substream)
  1355. {
  1356. struct alc_spec *spec = codec->spec;
  1357. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1358. stream_tag, 0, format);
  1359. return 0;
  1360. }
  1361. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1362. struct hda_codec *codec,
  1363. struct snd_pcm_substream *substream)
  1364. {
  1365. struct alc_spec *spec = codec->spec;
  1366. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  1367. return 0;
  1368. }
  1369. /*
  1370. */
  1371. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1372. .substreams = 1,
  1373. .channels_min = 2,
  1374. .channels_max = 8,
  1375. /* NID is set in alc_build_pcms */
  1376. .ops = {
  1377. .open = alc880_playback_pcm_open,
  1378. .prepare = alc880_playback_pcm_prepare,
  1379. .cleanup = alc880_playback_pcm_cleanup
  1380. },
  1381. };
  1382. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1383. .substreams = 2,
  1384. .channels_min = 2,
  1385. .channels_max = 2,
  1386. /* NID is set in alc_build_pcms */
  1387. .ops = {
  1388. .prepare = alc880_capture_pcm_prepare,
  1389. .cleanup = alc880_capture_pcm_cleanup
  1390. },
  1391. };
  1392. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1393. .substreams = 1,
  1394. .channels_min = 2,
  1395. .channels_max = 2,
  1396. /* NID is set in alc_build_pcms */
  1397. .ops = {
  1398. .open = alc880_dig_playback_pcm_open,
  1399. .close = alc880_dig_playback_pcm_close
  1400. },
  1401. };
  1402. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1403. .substreams = 1,
  1404. .channels_min = 2,
  1405. .channels_max = 2,
  1406. /* NID is set in alc_build_pcms */
  1407. };
  1408. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1409. static struct hda_pcm_stream alc_pcm_null_playback = {
  1410. .substreams = 0,
  1411. .channels_min = 0,
  1412. .channels_max = 0,
  1413. };
  1414. static int alc_build_pcms(struct hda_codec *codec)
  1415. {
  1416. struct alc_spec *spec = codec->spec;
  1417. struct hda_pcm *info = spec->pcm_rec;
  1418. int i;
  1419. codec->num_pcms = 1;
  1420. codec->pcm_info = info;
  1421. info->name = spec->stream_name_analog;
  1422. if (spec->stream_analog_playback) {
  1423. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1424. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1425. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1426. }
  1427. if (spec->stream_analog_capture) {
  1428. snd_assert(spec->adc_nids, return -EINVAL);
  1429. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1430. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1431. }
  1432. if (spec->channel_mode) {
  1433. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1434. for (i = 0; i < spec->num_channel_mode; i++) {
  1435. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1436. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1437. }
  1438. }
  1439. }
  1440. /* If the use of more than one ADC is requested for the current
  1441. * model, configure a second analog capture-only PCM.
  1442. */
  1443. if (spec->num_adc_nids > 1) {
  1444. codec->num_pcms++;
  1445. info++;
  1446. info->name = spec->stream_name_analog;
  1447. /* No playback stream for second PCM */
  1448. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1449. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1450. if (spec->stream_analog_capture) {
  1451. snd_assert(spec->adc_nids, return -EINVAL);
  1452. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1453. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1454. }
  1455. }
  1456. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1457. codec->num_pcms++;
  1458. info++;
  1459. info->name = spec->stream_name_digital;
  1460. if (spec->multiout.dig_out_nid &&
  1461. spec->stream_digital_playback) {
  1462. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1463. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1464. }
  1465. if (spec->dig_in_nid &&
  1466. spec->stream_digital_capture) {
  1467. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1468. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1469. }
  1470. }
  1471. return 0;
  1472. }
  1473. static void alc_free(struct hda_codec *codec)
  1474. {
  1475. struct alc_spec *spec = codec->spec;
  1476. unsigned int i;
  1477. if (! spec)
  1478. return;
  1479. if (spec->kctl_alloc) {
  1480. for (i = 0; i < spec->num_kctl_used; i++)
  1481. kfree(spec->kctl_alloc[i].name);
  1482. kfree(spec->kctl_alloc);
  1483. }
  1484. kfree(spec);
  1485. }
  1486. /*
  1487. */
  1488. static struct hda_codec_ops alc_patch_ops = {
  1489. .build_controls = alc_build_controls,
  1490. .build_pcms = alc_build_pcms,
  1491. .init = alc_init,
  1492. .free = alc_free,
  1493. .unsol_event = alc_unsol_event,
  1494. #ifdef CONFIG_PM
  1495. .resume = alc_resume,
  1496. #endif
  1497. };
  1498. /*
  1499. * Test configuration for debugging
  1500. *
  1501. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1502. * enum controls.
  1503. */
  1504. #ifdef CONFIG_SND_DEBUG
  1505. static hda_nid_t alc880_test_dac_nids[4] = {
  1506. 0x02, 0x03, 0x04, 0x05
  1507. };
  1508. static struct hda_input_mux alc880_test_capture_source = {
  1509. .num_items = 7,
  1510. .items = {
  1511. { "In-1", 0x0 },
  1512. { "In-2", 0x1 },
  1513. { "In-3", 0x2 },
  1514. { "In-4", 0x3 },
  1515. { "CD", 0x4 },
  1516. { "Front", 0x5 },
  1517. { "Surround", 0x6 },
  1518. },
  1519. };
  1520. static struct hda_channel_mode alc880_test_modes[4] = {
  1521. { 2, NULL },
  1522. { 4, NULL },
  1523. { 6, NULL },
  1524. { 8, NULL },
  1525. };
  1526. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1527. {
  1528. static char *texts[] = {
  1529. "N/A", "Line Out", "HP Out",
  1530. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1531. };
  1532. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1533. uinfo->count = 1;
  1534. uinfo->value.enumerated.items = 8;
  1535. if (uinfo->value.enumerated.item >= 8)
  1536. uinfo->value.enumerated.item = 7;
  1537. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1538. return 0;
  1539. }
  1540. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1541. {
  1542. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1543. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1544. unsigned int pin_ctl, item = 0;
  1545. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1546. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1547. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1548. if (pin_ctl & AC_PINCTL_HP_EN)
  1549. item = 2;
  1550. else
  1551. item = 1;
  1552. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1553. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1554. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1555. case AC_PINCTL_VREF_50: item = 4; break;
  1556. case AC_PINCTL_VREF_GRD: item = 5; break;
  1557. case AC_PINCTL_VREF_80: item = 6; break;
  1558. case AC_PINCTL_VREF_100: item = 7; break;
  1559. }
  1560. }
  1561. ucontrol->value.enumerated.item[0] = item;
  1562. return 0;
  1563. }
  1564. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1565. {
  1566. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1567. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1568. static unsigned int ctls[] = {
  1569. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1570. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1571. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1572. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1573. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1574. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1575. };
  1576. unsigned int old_ctl, new_ctl;
  1577. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1578. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1579. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1580. if (old_ctl != new_ctl) {
  1581. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1582. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1583. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1584. return 1;
  1585. }
  1586. return 0;
  1587. }
  1588. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1589. {
  1590. static char *texts[] = {
  1591. "Front", "Surround", "CLFE", "Side"
  1592. };
  1593. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1594. uinfo->count = 1;
  1595. uinfo->value.enumerated.items = 4;
  1596. if (uinfo->value.enumerated.item >= 4)
  1597. uinfo->value.enumerated.item = 3;
  1598. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1599. return 0;
  1600. }
  1601. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1602. {
  1603. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1604. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1605. unsigned int sel;
  1606. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1607. ucontrol->value.enumerated.item[0] = sel & 3;
  1608. return 0;
  1609. }
  1610. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1611. {
  1612. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1613. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1614. unsigned int sel;
  1615. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1616. if (ucontrol->value.enumerated.item[0] != sel) {
  1617. sel = ucontrol->value.enumerated.item[0] & 3;
  1618. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1619. return 1;
  1620. }
  1621. return 0;
  1622. }
  1623. #define PIN_CTL_TEST(xname,nid) { \
  1624. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1625. .name = xname, \
  1626. .info = alc_test_pin_ctl_info, \
  1627. .get = alc_test_pin_ctl_get, \
  1628. .put = alc_test_pin_ctl_put, \
  1629. .private_value = nid \
  1630. }
  1631. #define PIN_SRC_TEST(xname,nid) { \
  1632. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1633. .name = xname, \
  1634. .info = alc_test_pin_src_info, \
  1635. .get = alc_test_pin_src_get, \
  1636. .put = alc_test_pin_src_put, \
  1637. .private_value = nid \
  1638. }
  1639. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1640. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1641. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1642. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1643. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1644. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1645. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1646. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1647. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1648. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1649. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1650. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1651. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1652. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1653. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1654. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1655. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1656. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1657. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1658. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1659. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1660. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1661. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1662. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1663. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1664. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1665. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1666. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1667. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1668. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1669. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1670. {
  1671. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1672. .name = "Channel Mode",
  1673. .info = alc_ch_mode_info,
  1674. .get = alc_ch_mode_get,
  1675. .put = alc_ch_mode_put,
  1676. },
  1677. { } /* end */
  1678. };
  1679. static struct hda_verb alc880_test_init_verbs[] = {
  1680. /* Unmute inputs of 0x0c - 0x0f */
  1681. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1683. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1684. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1685. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1686. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1687. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1688. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1689. /* Vol output for 0x0c-0x0f */
  1690. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1691. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1692. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1693. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1694. /* Set output pins 0x14-0x17 */
  1695. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1696. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1697. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1698. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1699. /* Unmute output pins 0x14-0x17 */
  1700. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1701. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1702. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1703. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1704. /* Set input pins 0x18-0x1c */
  1705. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1706. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1707. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1708. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1709. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1710. /* Mute input pins 0x18-0x1b */
  1711. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1712. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1713. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1714. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1715. /* ADC set up */
  1716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1717. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1718. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1719. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1720. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1721. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1722. /* Analog input/passthru */
  1723. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1724. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1725. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1726. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1727. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1728. { }
  1729. };
  1730. #endif
  1731. /*
  1732. */
  1733. static struct hda_board_config alc880_cfg_tbl[] = {
  1734. /* Back 3 jack, front 2 jack */
  1735. { .modelname = "3stack", .config = ALC880_3ST },
  1736. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1737. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1738. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1739. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1740. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1741. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1742. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1743. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1744. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1745. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1746. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1747. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1748. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1749. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1750. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1751. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1752. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1753. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1754. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1755. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1756. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1757. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1758. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1759. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1760. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1761. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1762. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1763. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1764. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1765. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1766. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1767. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1768. /* TCL S700 */
  1769. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  1770. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1771. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1772. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1773. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1774. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1775. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1776. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1777. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1778. /* Clevo m520G NB */
  1779. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
  1780. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1781. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1782. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1783. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1784. /* Back 5 jack, front 2 jack */
  1785. { .modelname = "5stack", .config = ALC880_5ST },
  1786. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1787. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1788. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1789. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1790. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1791. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1792. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1793. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1794. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1795. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1796. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1797. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1798. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1799. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1800. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1801. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1802. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1803. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1804. /* note subvendor = 0 below */
  1805. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1806. { .modelname = "w810", .config = ALC880_W810 },
  1807. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1808. { .modelname = "z71v", .config = ALC880_Z71V },
  1809. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1810. { .modelname = "6stack", .config = ALC880_6ST },
  1811. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  1812. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  1813. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1814. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  1815. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1816. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1817. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1818. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1819. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1820. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  1821. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  1822. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  1823. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  1824. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  1825. { .modelname = "asus", .config = ALC880_ASUS },
  1826. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  1827. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  1828. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  1829. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  1830. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  1831. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  1832. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  1833. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  1834. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  1835. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  1836. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  1837. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  1838. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1839. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1840. { .modelname = "F1734", .config = ALC880_F1734 },
  1841. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1842. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  1843. { .modelname = "lg", .config = ALC880_LG },
  1844. { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
  1845. #ifdef CONFIG_SND_DEBUG
  1846. { .modelname = "test", .config = ALC880_TEST },
  1847. #endif
  1848. { .modelname = "auto", .config = ALC880_AUTO },
  1849. {}
  1850. };
  1851. /*
  1852. * ALC880 codec presets
  1853. */
  1854. static struct alc_config_preset alc880_presets[] = {
  1855. [ALC880_3ST] = {
  1856. .mixers = { alc880_three_stack_mixer },
  1857. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1858. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1859. .dac_nids = alc880_dac_nids,
  1860. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1861. .channel_mode = alc880_threestack_modes,
  1862. .input_mux = &alc880_capture_source,
  1863. },
  1864. [ALC880_3ST_DIG] = {
  1865. .mixers = { alc880_three_stack_mixer },
  1866. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1867. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1868. .dac_nids = alc880_dac_nids,
  1869. .dig_out_nid = ALC880_DIGOUT_NID,
  1870. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1871. .channel_mode = alc880_threestack_modes,
  1872. .input_mux = &alc880_capture_source,
  1873. },
  1874. [ALC880_TCL_S700] = {
  1875. .mixers = { alc880_tcl_s700_mixer },
  1876. .init_verbs = { alc880_volume_init_verbs,
  1877. alc880_pin_tcl_S700_init_verbs,
  1878. alc880_gpio2_init_verbs },
  1879. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1880. .dac_nids = alc880_dac_nids,
  1881. .hp_nid = 0x03,
  1882. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1883. .channel_mode = alc880_2_jack_modes,
  1884. .input_mux = &alc880_capture_source,
  1885. },
  1886. [ALC880_5ST] = {
  1887. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1888. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1889. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1890. .dac_nids = alc880_dac_nids,
  1891. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1892. .channel_mode = alc880_fivestack_modes,
  1893. .input_mux = &alc880_capture_source,
  1894. },
  1895. [ALC880_5ST_DIG] = {
  1896. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1897. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1898. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1899. .dac_nids = alc880_dac_nids,
  1900. .dig_out_nid = ALC880_DIGOUT_NID,
  1901. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1902. .channel_mode = alc880_fivestack_modes,
  1903. .input_mux = &alc880_capture_source,
  1904. },
  1905. [ALC880_6ST] = {
  1906. .mixers = { alc880_six_stack_mixer },
  1907. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1908. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1909. .dac_nids = alc880_6st_dac_nids,
  1910. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1911. .channel_mode = alc880_sixstack_modes,
  1912. .input_mux = &alc880_6stack_capture_source,
  1913. },
  1914. [ALC880_6ST_DIG] = {
  1915. .mixers = { alc880_six_stack_mixer },
  1916. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1917. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1918. .dac_nids = alc880_6st_dac_nids,
  1919. .dig_out_nid = ALC880_DIGOUT_NID,
  1920. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1921. .channel_mode = alc880_sixstack_modes,
  1922. .input_mux = &alc880_6stack_capture_source,
  1923. },
  1924. [ALC880_W810] = {
  1925. .mixers = { alc880_w810_base_mixer },
  1926. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  1927. alc880_gpio2_init_verbs },
  1928. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1929. .dac_nids = alc880_w810_dac_nids,
  1930. .dig_out_nid = ALC880_DIGOUT_NID,
  1931. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1932. .channel_mode = alc880_w810_modes,
  1933. .input_mux = &alc880_capture_source,
  1934. },
  1935. [ALC880_Z71V] = {
  1936. .mixers = { alc880_z71v_mixer },
  1937. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  1938. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1939. .dac_nids = alc880_z71v_dac_nids,
  1940. .dig_out_nid = ALC880_DIGOUT_NID,
  1941. .hp_nid = 0x03,
  1942. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1943. .channel_mode = alc880_2_jack_modes,
  1944. .input_mux = &alc880_capture_source,
  1945. },
  1946. [ALC880_F1734] = {
  1947. .mixers = { alc880_f1734_mixer },
  1948. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1949. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1950. .dac_nids = alc880_f1734_dac_nids,
  1951. .hp_nid = 0x02,
  1952. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1953. .channel_mode = alc880_2_jack_modes,
  1954. .input_mux = &alc880_capture_source,
  1955. },
  1956. [ALC880_ASUS] = {
  1957. .mixers = { alc880_asus_mixer },
  1958. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1959. alc880_gpio1_init_verbs },
  1960. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1961. .dac_nids = alc880_asus_dac_nids,
  1962. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1963. .channel_mode = alc880_asus_modes,
  1964. .input_mux = &alc880_capture_source,
  1965. },
  1966. [ALC880_ASUS_DIG] = {
  1967. .mixers = { alc880_asus_mixer },
  1968. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1969. alc880_gpio1_init_verbs },
  1970. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1971. .dac_nids = alc880_asus_dac_nids,
  1972. .dig_out_nid = ALC880_DIGOUT_NID,
  1973. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1974. .channel_mode = alc880_asus_modes,
  1975. .input_mux = &alc880_capture_source,
  1976. },
  1977. [ALC880_ASUS_DIG2] = {
  1978. .mixers = { alc880_asus_mixer },
  1979. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1980. alc880_gpio2_init_verbs }, /* use GPIO2 */
  1981. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1982. .dac_nids = alc880_asus_dac_nids,
  1983. .dig_out_nid = ALC880_DIGOUT_NID,
  1984. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1985. .channel_mode = alc880_asus_modes,
  1986. .input_mux = &alc880_capture_source,
  1987. },
  1988. [ALC880_ASUS_W1V] = {
  1989. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1990. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1991. alc880_gpio1_init_verbs },
  1992. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1993. .dac_nids = alc880_asus_dac_nids,
  1994. .dig_out_nid = ALC880_DIGOUT_NID,
  1995. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1996. .channel_mode = alc880_asus_modes,
  1997. .input_mux = &alc880_capture_source,
  1998. },
  1999. [ALC880_UNIWILL_DIG] = {
  2000. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2001. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  2002. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2003. .dac_nids = alc880_asus_dac_nids,
  2004. .dig_out_nid = ALC880_DIGOUT_NID,
  2005. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2006. .channel_mode = alc880_asus_modes,
  2007. .input_mux = &alc880_capture_source,
  2008. },
  2009. [ALC880_CLEVO] = {
  2010. .mixers = { alc880_three_stack_mixer },
  2011. .init_verbs = { alc880_volume_init_verbs,
  2012. alc880_pin_clevo_init_verbs },
  2013. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2014. .dac_nids = alc880_dac_nids,
  2015. .hp_nid = 0x03,
  2016. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2017. .channel_mode = alc880_threestack_modes,
  2018. .input_mux = &alc880_capture_source,
  2019. },
  2020. [ALC880_LG] = {
  2021. .mixers = { alc880_lg_mixer },
  2022. .init_verbs = { alc880_volume_init_verbs,
  2023. alc880_lg_init_verbs },
  2024. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2025. .dac_nids = alc880_lg_dac_nids,
  2026. .dig_out_nid = ALC880_DIGOUT_NID,
  2027. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2028. .channel_mode = alc880_lg_ch_modes,
  2029. .input_mux = &alc880_lg_capture_source,
  2030. .unsol_event = alc880_lg_unsol_event,
  2031. .init_hook = alc880_lg_automute,
  2032. },
  2033. #ifdef CONFIG_SND_DEBUG
  2034. [ALC880_TEST] = {
  2035. .mixers = { alc880_test_mixer },
  2036. .init_verbs = { alc880_test_init_verbs },
  2037. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2038. .dac_nids = alc880_test_dac_nids,
  2039. .dig_out_nid = ALC880_DIGOUT_NID,
  2040. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2041. .channel_mode = alc880_test_modes,
  2042. .input_mux = &alc880_test_capture_source,
  2043. },
  2044. #endif
  2045. };
  2046. /*
  2047. * Automatic parse of I/O pins from the BIOS configuration
  2048. */
  2049. #define NUM_CONTROL_ALLOC 32
  2050. #define NUM_VERB_ALLOC 32
  2051. enum {
  2052. ALC_CTL_WIDGET_VOL,
  2053. ALC_CTL_WIDGET_MUTE,
  2054. ALC_CTL_BIND_MUTE,
  2055. };
  2056. static struct snd_kcontrol_new alc880_control_templates[] = {
  2057. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2058. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2059. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2060. };
  2061. /* add dynamic controls */
  2062. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2063. {
  2064. struct snd_kcontrol_new *knew;
  2065. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2066. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2067. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2068. if (! knew)
  2069. return -ENOMEM;
  2070. if (spec->kctl_alloc) {
  2071. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2072. kfree(spec->kctl_alloc);
  2073. }
  2074. spec->kctl_alloc = knew;
  2075. spec->num_kctl_alloc = num;
  2076. }
  2077. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2078. *knew = alc880_control_templates[type];
  2079. knew->name = kstrdup(name, GFP_KERNEL);
  2080. if (! knew->name)
  2081. return -ENOMEM;
  2082. knew->private_value = val;
  2083. spec->num_kctl_used++;
  2084. return 0;
  2085. }
  2086. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2087. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2088. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2089. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2090. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2091. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2092. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2093. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2094. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2095. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2096. #define ALC880_PIN_CD_NID 0x1c
  2097. /* fill in the dac_nids table from the parsed pin configuration */
  2098. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2099. {
  2100. hda_nid_t nid;
  2101. int assigned[4];
  2102. int i, j;
  2103. memset(assigned, 0, sizeof(assigned));
  2104. spec->multiout.dac_nids = spec->private_dac_nids;
  2105. /* check the pins hardwired to audio widget */
  2106. for (i = 0; i < cfg->line_outs; i++) {
  2107. nid = cfg->line_out_pins[i];
  2108. if (alc880_is_fixed_pin(nid)) {
  2109. int idx = alc880_fixed_pin_idx(nid);
  2110. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2111. assigned[idx] = 1;
  2112. }
  2113. }
  2114. /* left pins can be connect to any audio widget */
  2115. for (i = 0; i < cfg->line_outs; i++) {
  2116. nid = cfg->line_out_pins[i];
  2117. if (alc880_is_fixed_pin(nid))
  2118. continue;
  2119. /* search for an empty channel */
  2120. for (j = 0; j < cfg->line_outs; j++) {
  2121. if (! assigned[j]) {
  2122. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2123. assigned[j] = 1;
  2124. break;
  2125. }
  2126. }
  2127. }
  2128. spec->multiout.num_dacs = cfg->line_outs;
  2129. return 0;
  2130. }
  2131. /* add playback controls from the parsed DAC table */
  2132. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2133. const struct auto_pin_cfg *cfg)
  2134. {
  2135. char name[32];
  2136. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2137. hda_nid_t nid;
  2138. int i, err;
  2139. for (i = 0; i < cfg->line_outs; i++) {
  2140. if (! spec->multiout.dac_nids[i])
  2141. continue;
  2142. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2143. if (i == 2) {
  2144. /* Center/LFE */
  2145. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2146. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2147. return err;
  2148. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2149. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2150. return err;
  2151. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2152. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2153. return err;
  2154. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2155. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2156. return err;
  2157. } else {
  2158. sprintf(name, "%s Playback Volume", chname[i]);
  2159. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2160. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2161. return err;
  2162. sprintf(name, "%s Playback Switch", chname[i]);
  2163. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2164. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2165. return err;
  2166. }
  2167. }
  2168. return 0;
  2169. }
  2170. /* add playback controls for speaker and HP outputs */
  2171. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2172. const char *pfx)
  2173. {
  2174. hda_nid_t nid;
  2175. int err;
  2176. char name[32];
  2177. if (! pin)
  2178. return 0;
  2179. if (alc880_is_fixed_pin(pin)) {
  2180. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2181. if (! spec->multiout.dac_nids[0]) {
  2182. /* use this as the primary output */
  2183. spec->multiout.dac_nids[0] = nid;
  2184. if (! spec->multiout.num_dacs)
  2185. spec->multiout.num_dacs = 1;
  2186. } else
  2187. /* specify the DAC as the extra output */
  2188. spec->multiout.hp_nid = nid;
  2189. /* control HP volume/switch on the output mixer amp */
  2190. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2191. sprintf(name, "%s Playback Volume", pfx);
  2192. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2193. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2194. return err;
  2195. sprintf(name, "%s Playback Switch", pfx);
  2196. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2197. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2198. return err;
  2199. } else if (alc880_is_multi_pin(pin)) {
  2200. /* set manual connection */
  2201. if (! spec->multiout.dac_nids[0]) {
  2202. /* use this as the primary output */
  2203. spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
  2204. if (! spec->multiout.num_dacs)
  2205. spec->multiout.num_dacs = 1;
  2206. }
  2207. /* we have only a switch on HP-out PIN */
  2208. sprintf(name, "%s Playback Switch", pfx);
  2209. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2210. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2211. return err;
  2212. }
  2213. return 0;
  2214. }
  2215. /* create input playback/capture controls for the given pin */
  2216. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2217. int idx, hda_nid_t mix_nid)
  2218. {
  2219. char name[32];
  2220. int err;
  2221. sprintf(name, "%s Playback Volume", ctlname);
  2222. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2223. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2224. return err;
  2225. sprintf(name, "%s Playback Switch", ctlname);
  2226. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2227. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2228. return err;
  2229. return 0;
  2230. }
  2231. /* create playback/capture controls for input pins */
  2232. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2233. const struct auto_pin_cfg *cfg)
  2234. {
  2235. struct hda_input_mux *imux = &spec->private_imux;
  2236. int i, err, idx;
  2237. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2238. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2239. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2240. err = new_analog_input(spec, cfg->input_pins[i],
  2241. auto_pin_cfg_labels[i],
  2242. idx, 0x0b);
  2243. if (err < 0)
  2244. return err;
  2245. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2246. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2247. imux->num_items++;
  2248. }
  2249. }
  2250. return 0;
  2251. }
  2252. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2253. hda_nid_t nid, int pin_type,
  2254. int dac_idx)
  2255. {
  2256. /* set as output */
  2257. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2258. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2259. /* need the manual connection? */
  2260. if (alc880_is_multi_pin(nid)) {
  2261. struct alc_spec *spec = codec->spec;
  2262. int idx = alc880_multi_pin_idx(nid);
  2263. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2264. AC_VERB_SET_CONNECT_SEL,
  2265. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2266. }
  2267. }
  2268. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2269. {
  2270. struct alc_spec *spec = codec->spec;
  2271. int i;
  2272. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2273. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2274. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2275. }
  2276. }
  2277. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2278. {
  2279. struct alc_spec *spec = codec->spec;
  2280. hda_nid_t pin;
  2281. pin = spec->autocfg.speaker_pin;
  2282. if (pin) /* connect to front */
  2283. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2284. pin = spec->autocfg.hp_pin;
  2285. if (pin) /* connect to front */
  2286. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2287. }
  2288. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2289. {
  2290. struct alc_spec *spec = codec->spec;
  2291. int i;
  2292. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2293. hda_nid_t nid = spec->autocfg.input_pins[i];
  2294. if (alc880_is_input_pin(nid)) {
  2295. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2296. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2297. if (nid != ALC880_PIN_CD_NID)
  2298. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2299. AMP_OUT_MUTE);
  2300. }
  2301. }
  2302. }
  2303. /* parse the BIOS configuration and set up the alc_spec */
  2304. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2305. static int alc880_parse_auto_config(struct hda_codec *codec)
  2306. {
  2307. struct alc_spec *spec = codec->spec;
  2308. int err;
  2309. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2310. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2311. alc880_ignore)) < 0)
  2312. return err;
  2313. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  2314. ! spec->autocfg.hp_pin)
  2315. return 0; /* can't find valid BIOS pin config */
  2316. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2317. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2318. (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
  2319. "Speaker")) < 0 ||
  2320. (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
  2321. "Headphone")) < 0 ||
  2322. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2323. return err;
  2324. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2325. if (spec->autocfg.dig_out_pin)
  2326. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2327. if (spec->autocfg.dig_in_pin)
  2328. spec->dig_in_nid = ALC880_DIGIN_NID;
  2329. if (spec->kctl_alloc)
  2330. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2331. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2332. spec->input_mux = &spec->private_imux;
  2333. return 1;
  2334. }
  2335. /* additional initialization for auto-configuration model */
  2336. static void alc880_auto_init(struct hda_codec *codec)
  2337. {
  2338. alc880_auto_init_multi_out(codec);
  2339. alc880_auto_init_extra_out(codec);
  2340. alc880_auto_init_analog_input(codec);
  2341. }
  2342. /*
  2343. * OK, here we have finally the patch for ALC880
  2344. */
  2345. static int patch_alc880(struct hda_codec *codec)
  2346. {
  2347. struct alc_spec *spec;
  2348. int board_config;
  2349. int err;
  2350. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2351. if (spec == NULL)
  2352. return -ENOMEM;
  2353. codec->spec = spec;
  2354. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2355. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2356. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  2357. board_config = ALC880_AUTO;
  2358. }
  2359. if (board_config == ALC880_AUTO) {
  2360. /* automatic parse from the BIOS config */
  2361. err = alc880_parse_auto_config(codec);
  2362. if (err < 0) {
  2363. alc_free(codec);
  2364. return err;
  2365. } else if (! err) {
  2366. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  2367. board_config = ALC880_3ST;
  2368. }
  2369. }
  2370. if (board_config != ALC880_AUTO)
  2371. setup_preset(spec, &alc880_presets[board_config]);
  2372. spec->stream_name_analog = "ALC880 Analog";
  2373. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2374. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2375. spec->stream_name_digital = "ALC880 Digital";
  2376. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2377. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2378. if (! spec->adc_nids && spec->input_mux) {
  2379. /* check whether NID 0x07 is valid */
  2380. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2381. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2382. if (wcap != AC_WID_AUD_IN) {
  2383. spec->adc_nids = alc880_adc_nids_alt;
  2384. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2385. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2386. spec->num_mixers++;
  2387. } else {
  2388. spec->adc_nids = alc880_adc_nids;
  2389. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2390. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2391. spec->num_mixers++;
  2392. }
  2393. }
  2394. codec->patch_ops = alc_patch_ops;
  2395. if (board_config == ALC880_AUTO)
  2396. spec->init_hook = alc880_auto_init;
  2397. return 0;
  2398. }
  2399. /*
  2400. * ALC260 support
  2401. */
  2402. static hda_nid_t alc260_dac_nids[1] = {
  2403. /* front */
  2404. 0x02,
  2405. };
  2406. static hda_nid_t alc260_adc_nids[1] = {
  2407. /* ADC0 */
  2408. 0x04,
  2409. };
  2410. static hda_nid_t alc260_adc_nids_alt[1] = {
  2411. /* ADC1 */
  2412. 0x05,
  2413. };
  2414. static hda_nid_t alc260_hp_adc_nids[2] = {
  2415. /* ADC1, 0 */
  2416. 0x05, 0x04
  2417. };
  2418. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2419. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2420. */
  2421. static hda_nid_t alc260_dual_adc_nids[2] = {
  2422. /* ADC0, ADC1 */
  2423. 0x04, 0x05
  2424. };
  2425. #define ALC260_DIGOUT_NID 0x03
  2426. #define ALC260_DIGIN_NID 0x06
  2427. static struct hda_input_mux alc260_capture_source = {
  2428. .num_items = 4,
  2429. .items = {
  2430. { "Mic", 0x0 },
  2431. { "Front Mic", 0x1 },
  2432. { "Line", 0x2 },
  2433. { "CD", 0x4 },
  2434. },
  2435. };
  2436. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2437. * headphone jack and the internal CD lines.
  2438. */
  2439. static struct hda_input_mux alc260_fujitsu_capture_source = {
  2440. .num_items = 3,
  2441. .items = {
  2442. { "Mic/Line", 0x0 },
  2443. { "CD", 0x4 },
  2444. { "Headphone", 0x2 },
  2445. },
  2446. };
  2447. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
  2448. * the Fujitsu S702x, but jacks are marked differently. We won't allow
  2449. * retasking the Headphone jack, so it won't be available here.
  2450. */
  2451. static struct hda_input_mux alc260_acer_capture_source = {
  2452. .num_items = 3,
  2453. .items = {
  2454. { "Mic", 0x0 },
  2455. { "Line", 0x2 },
  2456. { "CD", 0x4 },
  2457. },
  2458. };
  2459. /*
  2460. * This is just place-holder, so there's something for alc_build_pcms to look
  2461. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2462. * element which allows changing the channel mode, so the verb list is
  2463. * never used.
  2464. */
  2465. static struct hda_channel_mode alc260_modes[1] = {
  2466. { 2, NULL },
  2467. };
  2468. /* Mixer combinations
  2469. *
  2470. * basic: base_output + input + pc_beep + capture
  2471. * HP: base_output + input + capture_alt
  2472. * HP_3013: hp_3013 + input + capture
  2473. * fujitsu: fujitsu + capture
  2474. * acer: acer + capture
  2475. */
  2476. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2477. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2478. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2479. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2480. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2481. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2482. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2483. { } /* end */
  2484. };
  2485. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2486. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2487. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2488. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2489. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2490. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2491. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2492. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2493. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2494. { } /* end */
  2495. };
  2496. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2497. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2498. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2499. { } /* end */
  2500. };
  2501. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2502. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2503. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2504. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2505. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2506. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2507. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2508. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2509. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2510. { } /* end */
  2511. };
  2512. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2513. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2514. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2515. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2516. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2517. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2518. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2519. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2520. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2521. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2522. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2523. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2524. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2525. { } /* end */
  2526. };
  2527. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2528. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2529. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2530. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2531. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2532. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2533. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2534. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2535. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2536. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2537. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2538. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2539. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2540. { } /* end */
  2541. };
  2542. /* capture mixer elements */
  2543. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2544. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2545. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2546. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2547. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2548. {
  2549. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2550. /* The multiple "Capture Source" controls confuse alsamixer
  2551. * So call somewhat different..
  2552. * FIXME: the controls appear in the "playback" view!
  2553. */
  2554. /* .name = "Capture Source", */
  2555. .name = "Input Source",
  2556. .count = 2,
  2557. .info = alc_mux_enum_info,
  2558. .get = alc_mux_enum_get,
  2559. .put = alc_mux_enum_put,
  2560. },
  2561. { } /* end */
  2562. };
  2563. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2564. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2565. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2566. {
  2567. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2568. /* The multiple "Capture Source" controls confuse alsamixer
  2569. * So call somewhat different..
  2570. * FIXME: the controls appear in the "playback" view!
  2571. */
  2572. /* .name = "Capture Source", */
  2573. .name = "Input Source",
  2574. .count = 1,
  2575. .info = alc_mux_enum_info,
  2576. .get = alc_mux_enum_get,
  2577. .put = alc_mux_enum_put,
  2578. },
  2579. { } /* end */
  2580. };
  2581. /*
  2582. * initialization verbs
  2583. */
  2584. static struct hda_verb alc260_init_verbs[] = {
  2585. /* Line In pin widget for input */
  2586. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2587. /* CD pin widget for input */
  2588. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2589. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2590. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2591. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2592. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2593. /* LINE-2 is used for line-out in rear */
  2594. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2595. /* select line-out */
  2596. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2597. /* LINE-OUT pin */
  2598. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2599. /* enable HP */
  2600. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2601. /* enable Mono */
  2602. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2603. /* mute capture amp left and right */
  2604. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2605. /* set connection select to line in (default select for this ADC) */
  2606. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2607. /* mute capture amp left and right */
  2608. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2609. /* set connection select to line in (default select for this ADC) */
  2610. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2611. /* set vol=0 Line-Out mixer amp left and right */
  2612. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2613. /* unmute pin widget amp left and right (no gain on this amp) */
  2614. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2615. /* set vol=0 HP mixer amp left and right */
  2616. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2617. /* unmute pin widget amp left and right (no gain on this amp) */
  2618. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2619. /* set vol=0 Mono mixer amp left and right */
  2620. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2621. /* unmute pin widget amp left and right (no gain on this amp) */
  2622. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2623. /* unmute LINE-2 out pin */
  2624. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2625. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2626. /* mute CD */
  2627. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2628. /* mute Line In */
  2629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2630. /* mute Mic */
  2631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2632. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2633. /* mute Front out path */
  2634. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2636. /* mute Headphone out path */
  2637. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2638. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2639. /* mute Mono out path */
  2640. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2641. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2642. { }
  2643. };
  2644. static struct hda_verb alc260_hp_init_verbs[] = {
  2645. /* Headphone and output */
  2646. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2647. /* mono output */
  2648. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2649. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2650. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2651. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2652. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2653. /* Line In pin widget for input */
  2654. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2655. /* Line-2 pin widget for output */
  2656. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2657. /* CD pin widget for input */
  2658. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2659. /* unmute amp left and right */
  2660. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2661. /* set connection select to line in (default select for this ADC) */
  2662. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2663. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2664. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2665. /* mute pin widget amp left and right (no gain on this amp) */
  2666. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2667. /* unmute HP mixer amp left and right (volume = 0) */
  2668. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2669. /* mute pin widget amp left and right (no gain on this amp) */
  2670. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2671. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2672. /* unmute CD */
  2673. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2674. /* unmute Line In */
  2675. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2676. /* unmute Mic */
  2677. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2678. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2679. /* Unmute Front out path */
  2680. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2681. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2682. /* Unmute Headphone out path */
  2683. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2684. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2685. /* Unmute Mono out path */
  2686. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2687. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2688. { }
  2689. };
  2690. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2691. /* Line out and output */
  2692. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2693. /* mono output */
  2694. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2695. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2696. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2697. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2698. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2699. /* Line In pin widget for input */
  2700. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2701. /* Headphone pin widget for output */
  2702. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2703. /* CD pin widget for input */
  2704. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2705. /* unmute amp left and right */
  2706. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2707. /* set connection select to line in (default select for this ADC) */
  2708. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2709. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2710. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2711. /* mute pin widget amp left and right (no gain on this amp) */
  2712. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2713. /* unmute HP mixer amp left and right (volume = 0) */
  2714. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2715. /* mute pin widget amp left and right (no gain on this amp) */
  2716. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2717. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2718. /* unmute CD */
  2719. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2720. /* unmute Line In */
  2721. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2722. /* unmute Mic */
  2723. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2724. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2725. /* Unmute Front out path */
  2726. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2727. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2728. /* Unmute Headphone out path */
  2729. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2730. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2731. /* Unmute Mono out path */
  2732. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2733. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2734. { }
  2735. };
  2736. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2737. * laptops.
  2738. */
  2739. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2740. /* Disable all GPIOs */
  2741. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2742. /* Internal speaker is connected to headphone pin */
  2743. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2744. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  2745. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2746. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  2747. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2748. /* Ensure all other unused pins are disabled and muted. */
  2749. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2750. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2751. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2752. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2753. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2754. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2755. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2756. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2757. /* Disable digital (SPDIF) pins */
  2758. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2759. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2760. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  2761. * when acting as an output.
  2762. */
  2763. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2764. /* Start with output sum widgets muted and their output gains at min */
  2765. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2766. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2767. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2768. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2769. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2770. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2771. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2772. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2773. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2774. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  2775. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2776. /* Unmute Line1 pin widget output buffer since it starts as an output.
  2777. * If the pin mode is changed by the user the pin mode control will
  2778. * take care of enabling the pin's input/output buffers as needed.
  2779. * Therefore there's no need to enable the input buffer at this
  2780. * stage.
  2781. */
  2782. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2783. /* Unmute input buffer of pin widget used for Line-in (no equiv
  2784. * mixer ctrl)
  2785. */
  2786. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2787. /* Mute capture amp left and right */
  2788. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2789. /* Set ADC connection select to match default mixer setting - line
  2790. * in (on mic1 pin)
  2791. */
  2792. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2793. /* Do the same for the second ADC: mute capture input amp and
  2794. * set ADC connection to line in (on mic1 pin)
  2795. */
  2796. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2797. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2798. /* Mute all inputs to mixer widget (even unconnected ones) */
  2799. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2800. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2801. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2802. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2803. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2804. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2805. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2806. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2807. { }
  2808. };
  2809. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  2810. * similar laptops (adapted from Fujitsu init verbs).
  2811. */
  2812. static struct hda_verb alc260_acer_init_verbs[] = {
  2813. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  2814. * the headphone jack. Turn this on and rely on the standard mute
  2815. * methods whenever the user wants to turn these outputs off.
  2816. */
  2817. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  2818. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  2819. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  2820. /* Internal speaker/Headphone jack is connected to Line-out pin */
  2821. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2822. /* Internal microphone/Mic jack is connected to Mic1 pin */
  2823. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  2824. /* Line In jack is connected to Line1 pin */
  2825. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2826. /* Ensure all other unused pins are disabled and muted. */
  2827. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2828. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2829. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2830. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2831. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2832. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2833. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2834. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2835. /* Disable digital (SPDIF) pins */
  2836. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2837. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2838. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  2839. * bus when acting as outputs.
  2840. */
  2841. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  2842. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2843. /* Start with output sum widgets muted and their output gains at min */
  2844. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2845. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2846. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2847. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2848. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2849. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2850. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2851. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2852. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2853. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  2854. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2855. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  2856. * inputs. If the pin mode is changed by the user the pin mode control
  2857. * will take care of enabling the pin's input/output buffers as needed.
  2858. * Therefore there's no need to enable the input buffer at this
  2859. * stage.
  2860. */
  2861. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2862. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2863. /* Mute capture amp left and right */
  2864. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2865. /* Set ADC connection select to match default mixer setting - mic
  2866. * (on mic1 pin)
  2867. */
  2868. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2869. /* Do similar with the second ADC: mute capture input amp and
  2870. * set ADC connection to line (on line1 pin)
  2871. */
  2872. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2873. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2874. /* Mute all inputs to mixer widget (even unconnected ones) */
  2875. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2876. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2877. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2878. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2879. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2880. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2881. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2882. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2883. { }
  2884. };
  2885. /* Test configuration for debugging, modelled after the ALC880 test
  2886. * configuration.
  2887. */
  2888. #ifdef CONFIG_SND_DEBUG
  2889. static hda_nid_t alc260_test_dac_nids[1] = {
  2890. 0x02,
  2891. };
  2892. static hda_nid_t alc260_test_adc_nids[2] = {
  2893. 0x04, 0x05,
  2894. };
  2895. /* This is a bit messy since the two input muxes in the ALC260 have slight
  2896. * variations in their signal assignments. The ideal way to deal with this
  2897. * is to extend alc_spec.input_mux to allow a different input MUX for each
  2898. * ADC. For the purposes of the test model it's sufficient to just list
  2899. * both options for affected signal indices. The separate input mux
  2900. * functionality only needs to be considered if a model comes along which
  2901. * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
  2902. * record.
  2903. */
  2904. static struct hda_input_mux alc260_test_capture_source = {
  2905. .num_items = 8,
  2906. .items = {
  2907. { "MIC1 pin", 0x0 },
  2908. { "MIC2 pin", 0x1 },
  2909. { "LINE1 pin", 0x2 },
  2910. { "LINE2 pin", 0x3 },
  2911. { "CD pin", 0x4 },
  2912. { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
  2913. { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
  2914. { "HP-OUT pin (cap2 only)", 0x7 },
  2915. },
  2916. };
  2917. static struct snd_kcontrol_new alc260_test_mixer[] = {
  2918. /* Output driver widgets */
  2919. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2920. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2921. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2922. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  2923. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2924. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  2925. /* Modes for retasking pin widgets */
  2926. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  2927. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  2928. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  2929. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  2930. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  2931. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  2932. /* Loopback mixer controls */
  2933. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  2934. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  2935. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  2936. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  2937. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  2938. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  2939. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  2940. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  2941. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2942. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2943. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2944. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2945. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  2946. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  2947. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  2948. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  2949. /* Controls for GPIO pins, assuming they are configured as outputs */
  2950. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  2951. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  2952. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  2953. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  2954. /* Switches to allow the digital IO pins to be enabled. The datasheet
  2955. * is ambigious as to which NID is which; testing on laptops which
  2956. * make this output available should provide clarification.
  2957. */
  2958. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  2959. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  2960. { } /* end */
  2961. };
  2962. static struct hda_verb alc260_test_init_verbs[] = {
  2963. /* Enable all GPIOs as outputs with an initial value of 0 */
  2964. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  2965. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  2966. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  2967. /* Enable retasking pins as output, initially without power amp */
  2968. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2969. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2970. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2971. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2972. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2973. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2974. /* Disable digital (SPDIF) pins initially, but users can enable
  2975. * them via a mixer switch. In the case of SPDIF-out, this initverb
  2976. * payload also sets the generation to 0, output to be in "consumer"
  2977. * PCM format, copyright asserted, no pre-emphasis and no validity
  2978. * control.
  2979. */
  2980. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2981. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2982. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  2983. * OUT1 sum bus when acting as an output.
  2984. */
  2985. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  2986. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  2987. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2988. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  2989. /* Start with output sum widgets muted and their output gains at min */
  2990. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2991. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2992. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2993. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2994. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2995. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2996. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2997. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2998. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2999. /* Unmute retasking pin widget output buffers since the default
  3000. * state appears to be output. As the pin mode is changed by the
  3001. * user the pin mode control will take care of enabling the pin's
  3002. * input/output buffers as needed.
  3003. */
  3004. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3005. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3006. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3007. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3008. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3009. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3010. /* Also unmute the mono-out pin widget */
  3011. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3012. /* Mute capture amp left and right */
  3013. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3014. /* Set ADC connection select to match default mixer setting (mic1
  3015. * pin)
  3016. */
  3017. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3018. /* Do the same for the second ADC: mute capture input amp and
  3019. * set ADC connection to mic1 pin
  3020. */
  3021. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3022. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3023. /* Mute all inputs to mixer widget (even unconnected ones) */
  3024. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3025. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3026. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3028. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3029. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3030. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3031. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3032. { }
  3033. };
  3034. #endif
  3035. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3036. .substreams = 1,
  3037. .channels_min = 2,
  3038. .channels_max = 2,
  3039. };
  3040. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3041. .substreams = 1,
  3042. .channels_min = 2,
  3043. .channels_max = 2,
  3044. };
  3045. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3046. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3047. /*
  3048. * for BIOS auto-configuration
  3049. */
  3050. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3051. const char *pfx)
  3052. {
  3053. hda_nid_t nid_vol;
  3054. unsigned long vol_val, sw_val;
  3055. char name[32];
  3056. int err;
  3057. if (nid >= 0x0f && nid < 0x11) {
  3058. nid_vol = nid - 0x7;
  3059. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3060. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3061. } else if (nid == 0x11) {
  3062. nid_vol = nid - 0x7;
  3063. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3064. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3065. } else if (nid >= 0x12 && nid <= 0x15) {
  3066. nid_vol = 0x08;
  3067. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3068. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3069. } else
  3070. return 0; /* N/A */
  3071. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3072. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3073. return err;
  3074. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3075. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3076. return err;
  3077. return 1;
  3078. }
  3079. /* add playback controls from the parsed DAC table */
  3080. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3081. const struct auto_pin_cfg *cfg)
  3082. {
  3083. hda_nid_t nid;
  3084. int err;
  3085. spec->multiout.num_dacs = 1;
  3086. spec->multiout.dac_nids = spec->private_dac_nids;
  3087. spec->multiout.dac_nids[0] = 0x02;
  3088. nid = cfg->line_out_pins[0];
  3089. if (nid) {
  3090. err = alc260_add_playback_controls(spec, nid, "Front");
  3091. if (err < 0)
  3092. return err;
  3093. }
  3094. nid = cfg->speaker_pin;
  3095. if (nid) {
  3096. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3097. if (err < 0)
  3098. return err;
  3099. }
  3100. nid = cfg->hp_pin;
  3101. if (nid) {
  3102. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3103. if (err < 0)
  3104. return err;
  3105. }
  3106. return 0;
  3107. }
  3108. /* create playback/capture controls for input pins */
  3109. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3110. const struct auto_pin_cfg *cfg)
  3111. {
  3112. struct hda_input_mux *imux = &spec->private_imux;
  3113. int i, err, idx;
  3114. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3115. if (cfg->input_pins[i] >= 0x12) {
  3116. idx = cfg->input_pins[i] - 0x12;
  3117. err = new_analog_input(spec, cfg->input_pins[i],
  3118. auto_pin_cfg_labels[i], idx, 0x07);
  3119. if (err < 0)
  3120. return err;
  3121. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3122. imux->items[imux->num_items].index = idx;
  3123. imux->num_items++;
  3124. }
  3125. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3126. idx = cfg->input_pins[i] - 0x09;
  3127. err = new_analog_input(spec, cfg->input_pins[i],
  3128. auto_pin_cfg_labels[i], idx, 0x07);
  3129. if (err < 0)
  3130. return err;
  3131. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3132. imux->items[imux->num_items].index = idx;
  3133. imux->num_items++;
  3134. }
  3135. }
  3136. return 0;
  3137. }
  3138. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3139. hda_nid_t nid, int pin_type,
  3140. int sel_idx)
  3141. {
  3142. /* set as output */
  3143. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3144. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3145. /* need the manual connection? */
  3146. if (nid >= 0x12) {
  3147. int idx = nid - 0x12;
  3148. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3149. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3150. }
  3151. }
  3152. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3153. {
  3154. struct alc_spec *spec = codec->spec;
  3155. hda_nid_t nid;
  3156. nid = spec->autocfg.line_out_pins[0];
  3157. if (nid)
  3158. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3159. nid = spec->autocfg.speaker_pin;
  3160. if (nid)
  3161. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3162. nid = spec->autocfg.hp_pin;
  3163. if (nid)
  3164. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3165. }
  3166. #define ALC260_PIN_CD_NID 0x16
  3167. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3168. {
  3169. struct alc_spec *spec = codec->spec;
  3170. int i;
  3171. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3172. hda_nid_t nid = spec->autocfg.input_pins[i];
  3173. if (nid >= 0x12) {
  3174. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3175. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3176. if (nid != ALC260_PIN_CD_NID)
  3177. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3178. AMP_OUT_MUTE);
  3179. }
  3180. }
  3181. }
  3182. /*
  3183. * generic initialization of ADC, input mixers and output mixers
  3184. */
  3185. static struct hda_verb alc260_volume_init_verbs[] = {
  3186. /*
  3187. * Unmute ADC0-1 and set the default input to mic-in
  3188. */
  3189. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3190. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3191. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3192. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3193. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3194. * mixer widget
  3195. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3196. * mic (mic 2)
  3197. */
  3198. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3199. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3200. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3201. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3202. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3203. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3204. /*
  3205. * Set up output mixers (0x08 - 0x0a)
  3206. */
  3207. /* set vol=0 to output mixers */
  3208. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3209. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3210. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3211. /* set up input amps for analog loopback */
  3212. /* Amp Indices: DAC = 0, mixer = 1 */
  3213. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3214. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3215. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3216. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3217. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3218. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3219. { }
  3220. };
  3221. static int alc260_parse_auto_config(struct hda_codec *codec)
  3222. {
  3223. struct alc_spec *spec = codec->spec;
  3224. unsigned int wcap;
  3225. int err;
  3226. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3227. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3228. alc260_ignore)) < 0)
  3229. return err;
  3230. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3231. return err;
  3232. if (! spec->kctl_alloc)
  3233. return 0; /* can't find valid BIOS pin config */
  3234. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3235. return err;
  3236. spec->multiout.max_channels = 2;
  3237. if (spec->autocfg.dig_out_pin)
  3238. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3239. if (spec->kctl_alloc)
  3240. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3241. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3242. spec->input_mux = &spec->private_imux;
  3243. /* check whether NID 0x04 is valid */
  3244. wcap = get_wcaps(codec, 0x04);
  3245. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3246. if (wcap != AC_WID_AUD_IN) {
  3247. spec->adc_nids = alc260_adc_nids_alt;
  3248. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3249. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3250. } else {
  3251. spec->adc_nids = alc260_adc_nids;
  3252. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3253. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3254. }
  3255. spec->num_mixers++;
  3256. return 1;
  3257. }
  3258. /* additional initialization for auto-configuration model */
  3259. static void alc260_auto_init(struct hda_codec *codec)
  3260. {
  3261. alc260_auto_init_multi_out(codec);
  3262. alc260_auto_init_analog_input(codec);
  3263. }
  3264. /*
  3265. * ALC260 configurations
  3266. */
  3267. static struct hda_board_config alc260_cfg_tbl[] = {
  3268. { .modelname = "basic", .config = ALC260_BASIC },
  3269. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3270. .config = ALC260_BASIC }, /* Sony VAIO */
  3271. { .modelname = "hp", .config = ALC260_HP },
  3272. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
  3273. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3274. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
  3275. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3276. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3277. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3278. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3279. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3280. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3281. { .modelname = "acer", .config = ALC260_ACER },
  3282. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3283. #ifdef CONFIG_SND_DEBUG
  3284. { .modelname = "test", .config = ALC260_TEST },
  3285. #endif
  3286. { .modelname = "auto", .config = ALC260_AUTO },
  3287. {}
  3288. };
  3289. static struct alc_config_preset alc260_presets[] = {
  3290. [ALC260_BASIC] = {
  3291. .mixers = { alc260_base_output_mixer,
  3292. alc260_input_mixer,
  3293. alc260_pc_beep_mixer,
  3294. alc260_capture_mixer },
  3295. .init_verbs = { alc260_init_verbs },
  3296. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3297. .dac_nids = alc260_dac_nids,
  3298. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3299. .adc_nids = alc260_adc_nids,
  3300. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3301. .channel_mode = alc260_modes,
  3302. .input_mux = &alc260_capture_source,
  3303. },
  3304. [ALC260_HP] = {
  3305. .mixers = { alc260_base_output_mixer,
  3306. alc260_input_mixer,
  3307. alc260_capture_alt_mixer },
  3308. .init_verbs = { alc260_hp_init_verbs },
  3309. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3310. .dac_nids = alc260_dac_nids,
  3311. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3312. .adc_nids = alc260_hp_adc_nids,
  3313. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3314. .channel_mode = alc260_modes,
  3315. .input_mux = &alc260_capture_source,
  3316. },
  3317. [ALC260_HP_3013] = {
  3318. .mixers = { alc260_hp_3013_mixer,
  3319. alc260_input_mixer,
  3320. alc260_capture_alt_mixer },
  3321. .init_verbs = { alc260_hp_3013_init_verbs },
  3322. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3323. .dac_nids = alc260_dac_nids,
  3324. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3325. .adc_nids = alc260_hp_adc_nids,
  3326. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3327. .channel_mode = alc260_modes,
  3328. .input_mux = &alc260_capture_source,
  3329. },
  3330. [ALC260_FUJITSU_S702X] = {
  3331. .mixers = { alc260_fujitsu_mixer,
  3332. alc260_capture_mixer },
  3333. .init_verbs = { alc260_fujitsu_init_verbs },
  3334. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3335. .dac_nids = alc260_dac_nids,
  3336. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3337. .adc_nids = alc260_dual_adc_nids,
  3338. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3339. .channel_mode = alc260_modes,
  3340. .input_mux = &alc260_fujitsu_capture_source,
  3341. },
  3342. [ALC260_ACER] = {
  3343. .mixers = { alc260_acer_mixer,
  3344. alc260_capture_mixer },
  3345. .init_verbs = { alc260_acer_init_verbs },
  3346. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3347. .dac_nids = alc260_dac_nids,
  3348. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3349. .adc_nids = alc260_dual_adc_nids,
  3350. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3351. .channel_mode = alc260_modes,
  3352. .input_mux = &alc260_acer_capture_source,
  3353. },
  3354. #ifdef CONFIG_SND_DEBUG
  3355. [ALC260_TEST] = {
  3356. .mixers = { alc260_test_mixer,
  3357. alc260_capture_mixer },
  3358. .init_verbs = { alc260_test_init_verbs },
  3359. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3360. .dac_nids = alc260_test_dac_nids,
  3361. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3362. .adc_nids = alc260_test_adc_nids,
  3363. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3364. .channel_mode = alc260_modes,
  3365. .input_mux = &alc260_test_capture_source,
  3366. },
  3367. #endif
  3368. };
  3369. static int patch_alc260(struct hda_codec *codec)
  3370. {
  3371. struct alc_spec *spec;
  3372. int err, board_config;
  3373. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3374. if (spec == NULL)
  3375. return -ENOMEM;
  3376. codec->spec = spec;
  3377. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3378. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3379. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  3380. board_config = ALC260_AUTO;
  3381. }
  3382. if (board_config == ALC260_AUTO) {
  3383. /* automatic parse from the BIOS config */
  3384. err = alc260_parse_auto_config(codec);
  3385. if (err < 0) {
  3386. alc_free(codec);
  3387. return err;
  3388. } else if (! err) {
  3389. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3390. board_config = ALC260_BASIC;
  3391. }
  3392. }
  3393. if (board_config != ALC260_AUTO)
  3394. setup_preset(spec, &alc260_presets[board_config]);
  3395. spec->stream_name_analog = "ALC260 Analog";
  3396. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3397. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3398. spec->stream_name_digital = "ALC260 Digital";
  3399. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3400. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3401. codec->patch_ops = alc_patch_ops;
  3402. if (board_config == ALC260_AUTO)
  3403. spec->init_hook = alc260_auto_init;
  3404. return 0;
  3405. }
  3406. /*
  3407. * ALC882 support
  3408. *
  3409. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3410. * configuration. Each pin widget can choose any input DACs and a mixer.
  3411. * Each ADC is connected from a mixer of all inputs. This makes possible
  3412. * 6-channel independent captures.
  3413. *
  3414. * In addition, an independent DAC for the multi-playback (not used in this
  3415. * driver yet).
  3416. */
  3417. #define ALC882_DIGOUT_NID 0x06
  3418. #define ALC882_DIGIN_NID 0x0a
  3419. static struct hda_channel_mode alc882_ch_modes[1] = {
  3420. { 8, NULL }
  3421. };
  3422. static hda_nid_t alc882_dac_nids[4] = {
  3423. /* front, rear, clfe, rear_surr */
  3424. 0x02, 0x03, 0x04, 0x05
  3425. };
  3426. /* identical with ALC880 */
  3427. #define alc882_adc_nids alc880_adc_nids
  3428. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3429. /* input MUX */
  3430. /* FIXME: should be a matrix-type input source selection */
  3431. static struct hda_input_mux alc882_capture_source = {
  3432. .num_items = 4,
  3433. .items = {
  3434. { "Mic", 0x0 },
  3435. { "Front Mic", 0x1 },
  3436. { "Line", 0x2 },
  3437. { "CD", 0x4 },
  3438. },
  3439. };
  3440. #define alc882_mux_enum_info alc_mux_enum_info
  3441. #define alc882_mux_enum_get alc_mux_enum_get
  3442. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3443. {
  3444. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3445. struct alc_spec *spec = codec->spec;
  3446. const struct hda_input_mux *imux = spec->input_mux;
  3447. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3448. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3449. hda_nid_t nid = capture_mixers[adc_idx];
  3450. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3451. unsigned int i, idx;
  3452. idx = ucontrol->value.enumerated.item[0];
  3453. if (idx >= imux->num_items)
  3454. idx = imux->num_items - 1;
  3455. if (*cur_val == idx && ! codec->in_resume)
  3456. return 0;
  3457. for (i = 0; i < imux->num_items; i++) {
  3458. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3459. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3460. v | (imux->items[i].index << 8));
  3461. }
  3462. *cur_val = idx;
  3463. return 1;
  3464. }
  3465. /*
  3466. * 6ch mode
  3467. */
  3468. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3469. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3470. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3471. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3472. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3473. { } /* end */
  3474. };
  3475. /*
  3476. * 8ch mode
  3477. */
  3478. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3479. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3480. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3481. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3482. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3483. { } /* end */
  3484. };
  3485. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3486. { 6, alc882_sixstack_ch6_init },
  3487. { 8, alc882_sixstack_ch8_init },
  3488. };
  3489. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3490. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3491. */
  3492. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3493. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3494. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3495. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3496. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3497. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3498. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3499. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3500. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3501. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3502. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3503. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3504. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3505. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3506. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3507. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3508. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3509. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3510. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3511. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3512. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3513. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3514. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3515. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3516. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3517. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3518. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3519. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3520. {
  3521. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3522. /* .name = "Capture Source", */
  3523. .name = "Input Source",
  3524. .count = 3,
  3525. .info = alc882_mux_enum_info,
  3526. .get = alc882_mux_enum_get,
  3527. .put = alc882_mux_enum_put,
  3528. },
  3529. { } /* end */
  3530. };
  3531. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3532. {
  3533. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3534. .name = "Channel Mode",
  3535. .info = alc_ch_mode_info,
  3536. .get = alc_ch_mode_get,
  3537. .put = alc_ch_mode_put,
  3538. },
  3539. { } /* end */
  3540. };
  3541. static struct hda_verb alc882_init_verbs[] = {
  3542. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3543. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3544. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3545. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3546. /* Rear mixer */
  3547. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3548. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3549. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3550. /* CLFE mixer */
  3551. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3552. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3553. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3554. /* Side mixer */
  3555. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3556. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3557. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3558. /* Front Pin: output 0 (0x0c) */
  3559. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3560. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3561. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3562. /* Rear Pin: output 1 (0x0d) */
  3563. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3564. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3565. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3566. /* CLFE Pin: output 2 (0x0e) */
  3567. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3568. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3569. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3570. /* Side Pin: output 3 (0x0f) */
  3571. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3572. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3573. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3574. /* Mic (rear) pin: input vref at 80% */
  3575. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3576. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3577. /* Front Mic pin: input vref at 80% */
  3578. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3579. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3580. /* Line In pin: input */
  3581. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3582. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3583. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3584. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3585. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3586. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3587. /* CD pin widget for input */
  3588. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3589. /* FIXME: use matrix-type input source selection */
  3590. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3591. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3592. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3593. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3594. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3595. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3596. /* Input mixer2 */
  3597. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3598. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3599. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3600. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3601. /* Input mixer3 */
  3602. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3603. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3604. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3605. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3606. /* ADC1: mute amp left and right */
  3607. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3609. /* ADC2: mute amp left and right */
  3610. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3611. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3612. /* ADC3: mute amp left and right */
  3613. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3614. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3615. { }
  3616. };
  3617. /*
  3618. * generic initialization of ADC, input mixers and output mixers
  3619. */
  3620. static struct hda_verb alc882_auto_init_verbs[] = {
  3621. /*
  3622. * Unmute ADC0-2 and set the default input to mic-in
  3623. */
  3624. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3625. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3626. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3627. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3628. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3629. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3630. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3631. * mixer widget
  3632. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3633. * mic (mic 2)
  3634. */
  3635. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3636. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3637. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3639. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3640. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3641. /*
  3642. * Set up output mixers (0x0c - 0x0f)
  3643. */
  3644. /* set vol=0 to output mixers */
  3645. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3646. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3647. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3648. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3649. /* set up input amps for analog loopback */
  3650. /* Amp Indices: DAC = 0, mixer = 1 */
  3651. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3652. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3653. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3654. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3655. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3656. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3657. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3658. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3659. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3660. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3661. /* FIXME: use matrix-type input source selection */
  3662. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3663. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3664. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3665. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3666. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3667. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3668. /* Input mixer2 */
  3669. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3670. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3671. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3672. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3673. /* Input mixer3 */
  3674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3675. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3676. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3677. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3678. { }
  3679. };
  3680. /* capture mixer elements */
  3681. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3682. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3683. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3684. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3685. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3686. {
  3687. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3688. /* The multiple "Capture Source" controls confuse alsamixer
  3689. * So call somewhat different..
  3690. * FIXME: the controls appear in the "playback" view!
  3691. */
  3692. /* .name = "Capture Source", */
  3693. .name = "Input Source",
  3694. .count = 2,
  3695. .info = alc882_mux_enum_info,
  3696. .get = alc882_mux_enum_get,
  3697. .put = alc882_mux_enum_put,
  3698. },
  3699. { } /* end */
  3700. };
  3701. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3702. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3703. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3704. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3705. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3706. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3707. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3708. {
  3709. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3710. /* The multiple "Capture Source" controls confuse alsamixer
  3711. * So call somewhat different..
  3712. * FIXME: the controls appear in the "playback" view!
  3713. */
  3714. /* .name = "Capture Source", */
  3715. .name = "Input Source",
  3716. .count = 3,
  3717. .info = alc882_mux_enum_info,
  3718. .get = alc882_mux_enum_get,
  3719. .put = alc882_mux_enum_put,
  3720. },
  3721. { } /* end */
  3722. };
  3723. /* pcm configuration: identiacal with ALC880 */
  3724. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  3725. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  3726. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  3727. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  3728. /*
  3729. * configuration and preset
  3730. */
  3731. static struct hda_board_config alc882_cfg_tbl[] = {
  3732. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  3733. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  3734. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
  3735. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
  3736. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
  3737. { .modelname = "auto", .config = ALC882_AUTO },
  3738. {}
  3739. };
  3740. static struct alc_config_preset alc882_presets[] = {
  3741. [ALC882_3ST_DIG] = {
  3742. .mixers = { alc882_base_mixer },
  3743. .init_verbs = { alc882_init_verbs },
  3744. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3745. .dac_nids = alc882_dac_nids,
  3746. .dig_out_nid = ALC882_DIGOUT_NID,
  3747. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3748. .adc_nids = alc882_adc_nids,
  3749. .dig_in_nid = ALC882_DIGIN_NID,
  3750. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  3751. .channel_mode = alc882_ch_modes,
  3752. .input_mux = &alc882_capture_source,
  3753. },
  3754. [ALC882_6ST_DIG] = {
  3755. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  3756. .init_verbs = { alc882_init_verbs },
  3757. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3758. .dac_nids = alc882_dac_nids,
  3759. .dig_out_nid = ALC882_DIGOUT_NID,
  3760. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3761. .adc_nids = alc882_adc_nids,
  3762. .dig_in_nid = ALC882_DIGIN_NID,
  3763. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  3764. .channel_mode = alc882_sixstack_modes,
  3765. .input_mux = &alc882_capture_source,
  3766. },
  3767. };
  3768. /*
  3769. * BIOS auto configuration
  3770. */
  3771. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  3772. hda_nid_t nid, int pin_type,
  3773. int dac_idx)
  3774. {
  3775. /* set as output */
  3776. struct alc_spec *spec = codec->spec;
  3777. int idx;
  3778. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  3779. idx = 4;
  3780. else
  3781. idx = spec->multiout.dac_nids[dac_idx] - 2;
  3782. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3783. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3784. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  3785. }
  3786. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  3787. {
  3788. struct alc_spec *spec = codec->spec;
  3789. int i;
  3790. for (i = 0; i <= HDA_SIDE; i++) {
  3791. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3792. if (nid)
  3793. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  3794. }
  3795. }
  3796. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  3797. {
  3798. struct alc_spec *spec = codec->spec;
  3799. hda_nid_t pin;
  3800. pin = spec->autocfg.hp_pin;
  3801. if (pin) /* connect to front */
  3802. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  3803. }
  3804. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  3805. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  3806. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  3807. {
  3808. struct alc_spec *spec = codec->spec;
  3809. int i;
  3810. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3811. hda_nid_t nid = spec->autocfg.input_pins[i];
  3812. if (alc882_is_input_pin(nid)) {
  3813. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3814. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3815. if (nid != ALC882_PIN_CD_NID)
  3816. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3817. AMP_OUT_MUTE);
  3818. }
  3819. }
  3820. }
  3821. /* almost identical with ALC880 parser... */
  3822. static int alc882_parse_auto_config(struct hda_codec *codec)
  3823. {
  3824. struct alc_spec *spec = codec->spec;
  3825. int err = alc880_parse_auto_config(codec);
  3826. if (err < 0)
  3827. return err;
  3828. else if (err > 0)
  3829. /* hack - override the init verbs */
  3830. spec->init_verbs[0] = alc882_auto_init_verbs;
  3831. return err;
  3832. }
  3833. /* additional initialization for auto-configuration model */
  3834. static void alc882_auto_init(struct hda_codec *codec)
  3835. {
  3836. alc882_auto_init_multi_out(codec);
  3837. alc882_auto_init_hp_out(codec);
  3838. alc882_auto_init_analog_input(codec);
  3839. }
  3840. /*
  3841. * ALC882 Headphone poll in 3.5.1a or 3.5.2
  3842. */
  3843. static int patch_alc882(struct hda_codec *codec)
  3844. {
  3845. struct alc_spec *spec;
  3846. int err, board_config;
  3847. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3848. if (spec == NULL)
  3849. return -ENOMEM;
  3850. codec->spec = spec;
  3851. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  3852. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  3853. printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
  3854. board_config = ALC882_AUTO;
  3855. }
  3856. if (board_config == ALC882_AUTO) {
  3857. /* automatic parse from the BIOS config */
  3858. err = alc882_parse_auto_config(codec);
  3859. if (err < 0) {
  3860. alc_free(codec);
  3861. return err;
  3862. } else if (! err) {
  3863. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3864. board_config = ALC882_3ST_DIG;
  3865. }
  3866. }
  3867. if (board_config != ALC882_AUTO)
  3868. setup_preset(spec, &alc882_presets[board_config]);
  3869. spec->stream_name_analog = "ALC882 Analog";
  3870. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  3871. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  3872. spec->stream_name_digital = "ALC882 Digital";
  3873. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  3874. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  3875. if (! spec->adc_nids && spec->input_mux) {
  3876. /* check whether NID 0x07 is valid */
  3877. unsigned int wcap = get_wcaps(codec, 0x07);
  3878. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3879. if (wcap != AC_WID_AUD_IN) {
  3880. spec->adc_nids = alc882_adc_nids_alt;
  3881. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  3882. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  3883. spec->num_mixers++;
  3884. } else {
  3885. spec->adc_nids = alc882_adc_nids;
  3886. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  3887. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  3888. spec->num_mixers++;
  3889. }
  3890. }
  3891. codec->patch_ops = alc_patch_ops;
  3892. if (board_config == ALC882_AUTO)
  3893. spec->init_hook = alc882_auto_init;
  3894. return 0;
  3895. }
  3896. /*
  3897. * ALC262 support
  3898. */
  3899. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  3900. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  3901. #define alc262_dac_nids alc260_dac_nids
  3902. #define alc262_adc_nids alc882_adc_nids
  3903. #define alc262_adc_nids_alt alc882_adc_nids_alt
  3904. #define alc262_modes alc260_modes
  3905. #define alc262_capture_source alc882_capture_source
  3906. static struct snd_kcontrol_new alc262_base_mixer[] = {
  3907. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3908. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  3909. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3910. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3911. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3912. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3913. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3914. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3915. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  3916. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  3917. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3918. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  3919. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  3920. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3921. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3922. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  3923. { } /* end */
  3924. };
  3925. #define alc262_capture_mixer alc882_capture_mixer
  3926. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  3927. /*
  3928. * generic initialization of ADC, input mixers and output mixers
  3929. */
  3930. static struct hda_verb alc262_init_verbs[] = {
  3931. /*
  3932. * Unmute ADC0-2 and set the default input to mic-in
  3933. */
  3934. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3935. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3936. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3937. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3938. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3939. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3940. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3941. * mixer widget
  3942. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3943. * mic (mic 2)
  3944. */
  3945. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3946. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3947. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3948. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3949. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3950. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3951. /*
  3952. * Set up output mixers (0x0c - 0x0e)
  3953. */
  3954. /* set vol=0 to output mixers */
  3955. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3956. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3957. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3958. /* set up input amps for analog loopback */
  3959. /* Amp Indices: DAC = 0, mixer = 1 */
  3960. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3961. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3962. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3963. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3964. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3965. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3966. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3967. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3968. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3969. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3970. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3971. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3972. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3973. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3974. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3975. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3976. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3977. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3978. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3979. /* FIXME: use matrix-type input source selection */
  3980. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3981. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3982. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3983. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3984. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3985. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3986. /* Input mixer2 */
  3987. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3988. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3989. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3990. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3991. /* Input mixer3 */
  3992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3993. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3994. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3995. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3996. { }
  3997. };
  3998. /*
  3999. * fujitsu model
  4000. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  4001. */
  4002. #define ALC_HP_EVENT 0x37
  4003. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  4004. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  4005. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4006. {}
  4007. };
  4008. static struct hda_input_mux alc262_fujitsu_capture_source = {
  4009. .num_items = 2,
  4010. .items = {
  4011. { "Mic", 0x0 },
  4012. { "CD", 0x4 },
  4013. },
  4014. };
  4015. /* mute/unmute internal speaker according to the hp jack and mute state */
  4016. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  4017. {
  4018. struct alc_spec *spec = codec->spec;
  4019. unsigned int mute;
  4020. if (force || ! spec->sense_updated) {
  4021. unsigned int present;
  4022. /* need to execute and sync at first */
  4023. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  4024. present = snd_hda_codec_read(codec, 0x14, 0,
  4025. AC_VERB_GET_PIN_SENSE, 0);
  4026. spec->jack_present = (present & 0x80000000) != 0;
  4027. spec->sense_updated = 1;
  4028. }
  4029. if (spec->jack_present) {
  4030. /* mute internal speaker */
  4031. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4032. 0x80, 0x80);
  4033. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4034. 0x80, 0x80);
  4035. } else {
  4036. /* unmute internal speaker if necessary */
  4037. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  4038. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4039. 0x80, mute & 0x80);
  4040. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  4041. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4042. 0x80, mute & 0x80);
  4043. }
  4044. }
  4045. /* unsolicited event for HP jack sensing */
  4046. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  4047. unsigned int res)
  4048. {
  4049. if ((res >> 26) != ALC_HP_EVENT)
  4050. return;
  4051. alc262_fujitsu_automute(codec, 1);
  4052. }
  4053. /* bind volumes of both NID 0x0c and 0x0d */
  4054. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  4055. struct snd_ctl_elem_value *ucontrol)
  4056. {
  4057. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4058. long *valp = ucontrol->value.integer.value;
  4059. int change;
  4060. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  4061. 0x7f, valp[0] & 0x7f);
  4062. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  4063. 0x7f, valp[1] & 0x7f);
  4064. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  4065. 0x7f, valp[0] & 0x7f);
  4066. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  4067. 0x7f, valp[1] & 0x7f);
  4068. return change;
  4069. }
  4070. /* bind hp and internal speaker mute (with plug check) */
  4071. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  4072. struct snd_ctl_elem_value *ucontrol)
  4073. {
  4074. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4075. long *valp = ucontrol->value.integer.value;
  4076. int change;
  4077. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  4078. 0x80, valp[0] ? 0 : 0x80);
  4079. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  4080. 0x80, valp[1] ? 0 : 0x80);
  4081. if (change || codec->in_resume)
  4082. alc262_fujitsu_automute(codec, codec->in_resume);
  4083. return change;
  4084. }
  4085. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  4086. {
  4087. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4088. .name = "Master Playback Volume",
  4089. .info = snd_hda_mixer_amp_volume_info,
  4090. .get = snd_hda_mixer_amp_volume_get,
  4091. .put = alc262_fujitsu_master_vol_put,
  4092. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  4093. },
  4094. {
  4095. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4096. .name = "Master Playback Switch",
  4097. .info = snd_hda_mixer_amp_switch_info,
  4098. .get = snd_hda_mixer_amp_switch_get,
  4099. .put = alc262_fujitsu_master_sw_put,
  4100. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  4101. },
  4102. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4103. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4104. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4105. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4106. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4107. { } /* end */
  4108. };
  4109. /* add playback controls from the parsed DAC table */
  4110. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4111. {
  4112. hda_nid_t nid;
  4113. int err;
  4114. spec->multiout.num_dacs = 1; /* only use one dac */
  4115. spec->multiout.dac_nids = spec->private_dac_nids;
  4116. spec->multiout.dac_nids[0] = 2;
  4117. nid = cfg->line_out_pins[0];
  4118. if (nid) {
  4119. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  4120. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  4121. return err;
  4122. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  4123. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4124. return err;
  4125. }
  4126. nid = cfg->speaker_pin;
  4127. if (nid) {
  4128. if (nid == 0x16) {
  4129. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  4130. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  4131. return err;
  4132. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  4133. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4134. return err;
  4135. } else {
  4136. if (! cfg->line_out_pins[0])
  4137. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  4138. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  4139. return err;
  4140. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  4141. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4142. return err;
  4143. }
  4144. }
  4145. nid = cfg->hp_pin;
  4146. if (nid) {
  4147. /* spec->multiout.hp_nid = 2; */
  4148. if (nid == 0x16) {
  4149. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  4150. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  4151. return err;
  4152. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4153. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4154. return err;
  4155. } else {
  4156. if (! cfg->line_out_pins[0])
  4157. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  4158. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  4159. return err;
  4160. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4161. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4162. return err;
  4163. }
  4164. }
  4165. return 0;
  4166. }
  4167. /* identical with ALC880 */
  4168. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  4169. /*
  4170. * generic initialization of ADC, input mixers and output mixers
  4171. */
  4172. static struct hda_verb alc262_volume_init_verbs[] = {
  4173. /*
  4174. * Unmute ADC0-2 and set the default input to mic-in
  4175. */
  4176. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4177. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4178. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4179. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4180. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4181. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4182. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4183. * mixer widget
  4184. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4185. * mic (mic 2)
  4186. */
  4187. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4188. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4189. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4190. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4191. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4192. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4193. /*
  4194. * Set up output mixers (0x0c - 0x0f)
  4195. */
  4196. /* set vol=0 to output mixers */
  4197. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4198. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4199. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4200. /* set up input amps for analog loopback */
  4201. /* Amp Indices: DAC = 0, mixer = 1 */
  4202. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4203. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4204. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4205. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4206. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4207. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4208. /* FIXME: use matrix-type input source selection */
  4209. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4210. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4211. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4212. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4213. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4214. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4215. /* Input mixer2 */
  4216. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4217. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4218. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4219. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4220. /* Input mixer3 */
  4221. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4222. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4223. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4224. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4225. { }
  4226. };
  4227. /* pcm configuration: identiacal with ALC880 */
  4228. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  4229. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  4230. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  4231. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  4232. /*
  4233. * BIOS auto configuration
  4234. */
  4235. static int alc262_parse_auto_config(struct hda_codec *codec)
  4236. {
  4237. struct alc_spec *spec = codec->spec;
  4238. int err;
  4239. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  4240. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4241. alc262_ignore)) < 0)
  4242. return err;
  4243. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  4244. ! spec->autocfg.hp_pin)
  4245. return 0; /* can't find valid BIOS pin config */
  4246. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4247. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4248. return err;
  4249. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4250. if (spec->autocfg.dig_out_pin)
  4251. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  4252. if (spec->autocfg.dig_in_pin)
  4253. spec->dig_in_nid = ALC262_DIGIN_NID;
  4254. if (spec->kctl_alloc)
  4255. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4256. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  4257. spec->input_mux = &spec->private_imux;
  4258. return 1;
  4259. }
  4260. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  4261. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  4262. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  4263. /* init callback for auto-configuration model -- overriding the default init */
  4264. static void alc262_auto_init(struct hda_codec *codec)
  4265. {
  4266. alc262_auto_init_multi_out(codec);
  4267. alc262_auto_init_hp_out(codec);
  4268. alc262_auto_init_analog_input(codec);
  4269. }
  4270. /*
  4271. * configuration and preset
  4272. */
  4273. static struct hda_board_config alc262_cfg_tbl[] = {
  4274. { .modelname = "basic", .config = ALC262_BASIC },
  4275. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  4276. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
  4277. { .modelname = "auto", .config = ALC262_AUTO },
  4278. {}
  4279. };
  4280. static struct alc_config_preset alc262_presets[] = {
  4281. [ALC262_BASIC] = {
  4282. .mixers = { alc262_base_mixer },
  4283. .init_verbs = { alc262_init_verbs },
  4284. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  4285. .dac_nids = alc262_dac_nids,
  4286. .hp_nid = 0x03,
  4287. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  4288. .channel_mode = alc262_modes,
  4289. .input_mux = &alc262_capture_source,
  4290. },
  4291. [ALC262_FUJITSU] = {
  4292. .mixers = { alc262_fujitsu_mixer },
  4293. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  4294. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  4295. .dac_nids = alc262_dac_nids,
  4296. .hp_nid = 0x03,
  4297. .dig_out_nid = ALC262_DIGOUT_NID,
  4298. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  4299. .channel_mode = alc262_modes,
  4300. .input_mux = &alc262_fujitsu_capture_source,
  4301. .unsol_event = alc262_fujitsu_unsol_event,
  4302. },
  4303. };
  4304. static int patch_alc262(struct hda_codec *codec)
  4305. {
  4306. struct alc_spec *spec;
  4307. int board_config;
  4308. int err;
  4309. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4310. if (spec == NULL)
  4311. return -ENOMEM;
  4312. codec->spec = spec;
  4313. #if 0
  4314. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  4315. {
  4316. int tmp;
  4317. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  4318. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  4319. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  4320. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  4321. }
  4322. #endif
  4323. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  4324. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  4325. printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
  4326. board_config = ALC262_AUTO;
  4327. }
  4328. if (board_config == ALC262_AUTO) {
  4329. /* automatic parse from the BIOS config */
  4330. err = alc262_parse_auto_config(codec);
  4331. if (err < 0) {
  4332. alc_free(codec);
  4333. return err;
  4334. } else if (! err) {
  4335. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4336. board_config = ALC262_BASIC;
  4337. }
  4338. }
  4339. if (board_config != ALC262_AUTO)
  4340. setup_preset(spec, &alc262_presets[board_config]);
  4341. spec->stream_name_analog = "ALC262 Analog";
  4342. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  4343. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  4344. spec->stream_name_digital = "ALC262 Digital";
  4345. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  4346. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  4347. if (! spec->adc_nids && spec->input_mux) {
  4348. /* check whether NID 0x07 is valid */
  4349. unsigned int wcap = get_wcaps(codec, 0x07);
  4350. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4351. if (wcap != AC_WID_AUD_IN) {
  4352. spec->adc_nids = alc262_adc_nids_alt;
  4353. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  4354. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  4355. spec->num_mixers++;
  4356. } else {
  4357. spec->adc_nids = alc262_adc_nids;
  4358. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  4359. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  4360. spec->num_mixers++;
  4361. }
  4362. }
  4363. codec->patch_ops = alc_patch_ops;
  4364. if (board_config == ALC262_AUTO)
  4365. spec->init_hook = alc262_auto_init;
  4366. return 0;
  4367. }
  4368. /*
  4369. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  4370. */
  4371. /*
  4372. * set the path ways for 2 channel output
  4373. * need to set the codec line out and mic 1 pin widgets to inputs
  4374. */
  4375. static struct hda_verb alc861_threestack_ch2_init[] = {
  4376. /* set pin widget 1Ah (line in) for input */
  4377. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4378. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  4379. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4380. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  4381. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
  4382. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
  4383. { } /* end */
  4384. };
  4385. /*
  4386. * 6ch mode
  4387. * need to set the codec line out and mic 1 pin widgets to outputs
  4388. */
  4389. static struct hda_verb alc861_threestack_ch6_init[] = {
  4390. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  4391. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4392. /* set pin widget 18h (mic1) for output (CLFE)*/
  4393. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4394. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4395. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4396. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  4397. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
  4398. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
  4399. { } /* end */
  4400. };
  4401. static struct hda_channel_mode alc861_threestack_modes[2] = {
  4402. { 2, alc861_threestack_ch2_init },
  4403. { 6, alc861_threestack_ch6_init },
  4404. };
  4405. /* patch-ALC861 */
  4406. static struct snd_kcontrol_new alc861_base_mixer[] = {
  4407. /* output mixer control */
  4408. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  4409. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  4410. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  4411. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  4412. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  4413. /*Input mixer control */
  4414. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  4415. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  4416. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  4417. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  4418. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  4419. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  4420. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  4421. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  4422. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  4423. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  4424. /* Capture mixer control */
  4425. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4426. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4427. {
  4428. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4429. .name = "Capture Source",
  4430. .count = 1,
  4431. .info = alc_mux_enum_info,
  4432. .get = alc_mux_enum_get,
  4433. .put = alc_mux_enum_put,
  4434. },
  4435. { } /* end */
  4436. };
  4437. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  4438. /* output mixer control */
  4439. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  4440. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  4441. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  4442. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  4443. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  4444. /* Input mixer control */
  4445. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  4446. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  4447. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  4448. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  4449. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  4450. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  4451. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  4452. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  4453. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  4454. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  4455. /* Capture mixer control */
  4456. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4457. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4458. {
  4459. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4460. .name = "Capture Source",
  4461. .count = 1,
  4462. .info = alc_mux_enum_info,
  4463. .get = alc_mux_enum_get,
  4464. .put = alc_mux_enum_put,
  4465. },
  4466. {
  4467. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4468. .name = "Channel Mode",
  4469. .info = alc_ch_mode_info,
  4470. .get = alc_ch_mode_get,
  4471. .put = alc_ch_mode_put,
  4472. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  4473. },
  4474. { } /* end */
  4475. };
  4476. /*
  4477. * generic initialization of ADC, input mixers and output mixers
  4478. */
  4479. static struct hda_verb alc861_base_init_verbs[] = {
  4480. /*
  4481. * Unmute ADC0 and set the default input to mic-in
  4482. */
  4483. /* port-A for surround (rear panel) */
  4484. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4485. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4486. /* port-B for mic-in (rear panel) with vref */
  4487. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4488. /* port-C for line-in (rear panel) */
  4489. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4490. /* port-D for Front */
  4491. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4492. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4493. /* port-E for HP out (front panel) */
  4494. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4495. /* route front PCM to HP */
  4496. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4497. /* port-F for mic-in (front panel) with vref */
  4498. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4499. /* port-G for CLFE (rear panel) */
  4500. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4501. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4502. /* port-H for side (rear panel) */
  4503. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4504. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4505. /* CD-in */
  4506. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4507. /* route front mic to ADC1*/
  4508. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4509. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4510. /* Unmute DAC0~3 & spdif out*/
  4511. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4512. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4513. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4514. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4515. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4516. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4517. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4518. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4519. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4520. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4521. /* Unmute Stereo Mixer 15 */
  4522. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4523. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4524. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4525. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4526. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4527. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4528. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4529. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4530. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4531. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4532. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4533. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4534. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4535. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4536. { }
  4537. };
  4538. static struct hda_verb alc861_threestack_init_verbs[] = {
  4539. /*
  4540. * Unmute ADC0 and set the default input to mic-in
  4541. */
  4542. /* port-A for surround (rear panel) */
  4543. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4544. /* port-B for mic-in (rear panel) with vref */
  4545. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4546. /* port-C for line-in (rear panel) */
  4547. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4548. /* port-D for Front */
  4549. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4550. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4551. /* port-E for HP out (front panel) */
  4552. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4553. /* route front PCM to HP */
  4554. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4555. /* port-F for mic-in (front panel) with vref */
  4556. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4557. /* port-G for CLFE (rear panel) */
  4558. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4559. /* port-H for side (rear panel) */
  4560. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4561. /* CD-in */
  4562. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4563. /* route front mic to ADC1*/
  4564. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4565. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4566. /* Unmute DAC0~3 & spdif out*/
  4567. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4568. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4569. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4570. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4571. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4572. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4573. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4574. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4575. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4576. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4577. /* Unmute Stereo Mixer 15 */
  4578. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4579. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4580. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4581. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4582. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4583. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4584. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4585. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4586. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4587. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4588. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4589. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4590. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4591. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4592. { }
  4593. };
  4594. /*
  4595. * generic initialization of ADC, input mixers and output mixers
  4596. */
  4597. static struct hda_verb alc861_auto_init_verbs[] = {
  4598. /*
  4599. * Unmute ADC0 and set the default input to mic-in
  4600. */
  4601. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4602. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4603. /* Unmute DAC0~3 & spdif out*/
  4604. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4605. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4606. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4607. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4608. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4609. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4610. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4611. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4612. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4613. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4614. /* Unmute Stereo Mixer 15 */
  4615. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4616. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4617. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4618. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  4619. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4620. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4621. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4622. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4623. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4624. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4625. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4626. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4627. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4628. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4629. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4630. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4631. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4632. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4633. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4634. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4635. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  4636. { }
  4637. };
  4638. /* pcm configuration: identiacal with ALC880 */
  4639. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  4640. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  4641. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  4642. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  4643. #define ALC861_DIGOUT_NID 0x07
  4644. static struct hda_channel_mode alc861_8ch_modes[1] = {
  4645. { 8, NULL }
  4646. };
  4647. static hda_nid_t alc861_dac_nids[4] = {
  4648. /* front, surround, clfe, side */
  4649. 0x03, 0x06, 0x05, 0x04
  4650. };
  4651. static hda_nid_t alc861_adc_nids[1] = {
  4652. /* ADC0-2 */
  4653. 0x08,
  4654. };
  4655. static struct hda_input_mux alc861_capture_source = {
  4656. .num_items = 5,
  4657. .items = {
  4658. { "Mic", 0x0 },
  4659. { "Front Mic", 0x3 },
  4660. { "Line", 0x1 },
  4661. { "CD", 0x4 },
  4662. { "Mixer", 0x5 },
  4663. },
  4664. };
  4665. /* fill in the dac_nids table from the parsed pin configuration */
  4666. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4667. {
  4668. int i;
  4669. hda_nid_t nid;
  4670. spec->multiout.dac_nids = spec->private_dac_nids;
  4671. for (i = 0; i < cfg->line_outs; i++) {
  4672. nid = cfg->line_out_pins[i];
  4673. if (nid) {
  4674. if (i >= ARRAY_SIZE(alc861_dac_nids))
  4675. continue;
  4676. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  4677. }
  4678. }
  4679. spec->multiout.num_dacs = cfg->line_outs;
  4680. return 0;
  4681. }
  4682. /* add playback controls from the parsed DAC table */
  4683. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  4684. const struct auto_pin_cfg *cfg)
  4685. {
  4686. char name[32];
  4687. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  4688. hda_nid_t nid;
  4689. int i, idx, err;
  4690. for (i = 0; i < cfg->line_outs; i++) {
  4691. nid = spec->multiout.dac_nids[i];
  4692. if (! nid)
  4693. continue;
  4694. if (nid == 0x05) {
  4695. /* Center/LFE */
  4696. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  4697. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  4698. return err;
  4699. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  4700. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4701. return err;
  4702. } else {
  4703. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  4704. if (nid == alc861_dac_nids[idx])
  4705. break;
  4706. sprintf(name, "%s Playback Switch", chname[idx]);
  4707. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  4708. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4709. return err;
  4710. }
  4711. }
  4712. return 0;
  4713. }
  4714. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  4715. {
  4716. int err;
  4717. hda_nid_t nid;
  4718. if (! pin)
  4719. return 0;
  4720. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  4721. nid = 0x03;
  4722. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4723. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4724. return err;
  4725. spec->multiout.hp_nid = nid;
  4726. }
  4727. return 0;
  4728. }
  4729. /* create playback/capture controls for input pins */
  4730. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4731. {
  4732. struct hda_input_mux *imux = &spec->private_imux;
  4733. int i, err, idx, idx1;
  4734. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4735. switch(cfg->input_pins[i]) {
  4736. case 0x0c:
  4737. idx1 = 1;
  4738. idx = 2; // Line In
  4739. break;
  4740. case 0x0f:
  4741. idx1 = 2;
  4742. idx = 2; // Line In
  4743. break;
  4744. case 0x0d:
  4745. idx1 = 0;
  4746. idx = 1; // Mic In
  4747. break;
  4748. case 0x10:
  4749. idx1 = 3;
  4750. idx = 1; // Mic In
  4751. break;
  4752. case 0x11:
  4753. idx1 = 4;
  4754. idx = 0; // CD
  4755. break;
  4756. default:
  4757. continue;
  4758. }
  4759. err = new_analog_input(spec, cfg->input_pins[i],
  4760. auto_pin_cfg_labels[i], idx, 0x15);
  4761. if (err < 0)
  4762. return err;
  4763. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  4764. imux->items[imux->num_items].index = idx1;
  4765. imux->num_items++;
  4766. }
  4767. return 0;
  4768. }
  4769. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  4770. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4771. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4772. {
  4773. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4774. /* The multiple "Capture Source" controls confuse alsamixer
  4775. * So call somewhat different..
  4776. *FIXME: the controls appear in the "playback" view!
  4777. */
  4778. /* .name = "Capture Source", */
  4779. .name = "Input Source",
  4780. .count = 1,
  4781. .info = alc_mux_enum_info,
  4782. .get = alc_mux_enum_get,
  4783. .put = alc_mux_enum_put,
  4784. },
  4785. { } /* end */
  4786. };
  4787. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  4788. int pin_type, int dac_idx)
  4789. {
  4790. /* set as output */
  4791. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4792. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4793. }
  4794. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  4795. {
  4796. struct alc_spec *spec = codec->spec;
  4797. int i;
  4798. for (i = 0; i < spec->autocfg.line_outs; i++) {
  4799. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4800. if (nid)
  4801. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  4802. }
  4803. }
  4804. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  4805. {
  4806. struct alc_spec *spec = codec->spec;
  4807. hda_nid_t pin;
  4808. pin = spec->autocfg.hp_pin;
  4809. if (pin) /* connect to front */
  4810. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  4811. }
  4812. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  4813. {
  4814. struct alc_spec *spec = codec->spec;
  4815. int i;
  4816. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4817. hda_nid_t nid = spec->autocfg.input_pins[i];
  4818. if ((nid>=0x0c) && (nid <=0x11)) {
  4819. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4820. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4821. }
  4822. }
  4823. }
  4824. /* parse the BIOS configuration and set up the alc_spec */
  4825. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  4826. static int alc861_parse_auto_config(struct hda_codec *codec)
  4827. {
  4828. struct alc_spec *spec = codec->spec;
  4829. int err;
  4830. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  4831. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4832. alc861_ignore)) < 0)
  4833. return err;
  4834. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  4835. ! spec->autocfg.hp_pin)
  4836. return 0; /* can't find valid BIOS pin config */
  4837. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  4838. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4839. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  4840. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4841. return err;
  4842. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4843. if (spec->autocfg.dig_out_pin)
  4844. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  4845. if (spec->kctl_alloc)
  4846. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4847. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  4848. spec->input_mux = &spec->private_imux;
  4849. spec->adc_nids = alc861_adc_nids;
  4850. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  4851. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  4852. spec->num_mixers++;
  4853. return 1;
  4854. }
  4855. /* additional initialization for auto-configuration model */
  4856. static void alc861_auto_init(struct hda_codec *codec)
  4857. {
  4858. alc861_auto_init_multi_out(codec);
  4859. alc861_auto_init_hp_out(codec);
  4860. alc861_auto_init_analog_input(codec);
  4861. }
  4862. /*
  4863. * configuration and preset
  4864. */
  4865. static struct hda_board_config alc861_cfg_tbl[] = {
  4866. { .modelname = "3stack", .config = ALC861_3ST },
  4867. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
  4868. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  4869. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  4870. { .modelname = "auto", .config = ALC861_AUTO },
  4871. {}
  4872. };
  4873. static struct alc_config_preset alc861_presets[] = {
  4874. [ALC861_3ST] = {
  4875. .mixers = { alc861_3ST_mixer },
  4876. .init_verbs = { alc861_threestack_init_verbs },
  4877. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4878. .dac_nids = alc861_dac_nids,
  4879. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4880. .channel_mode = alc861_threestack_modes,
  4881. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4882. .adc_nids = alc861_adc_nids,
  4883. .input_mux = &alc861_capture_source,
  4884. },
  4885. [ALC861_3ST_DIG] = {
  4886. .mixers = { alc861_base_mixer },
  4887. .init_verbs = { alc861_threestack_init_verbs },
  4888. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4889. .dac_nids = alc861_dac_nids,
  4890. .dig_out_nid = ALC861_DIGOUT_NID,
  4891. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4892. .channel_mode = alc861_threestack_modes,
  4893. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4894. .adc_nids = alc861_adc_nids,
  4895. .input_mux = &alc861_capture_source,
  4896. },
  4897. [ALC861_6ST_DIG] = {
  4898. .mixers = { alc861_base_mixer },
  4899. .init_verbs = { alc861_base_init_verbs },
  4900. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4901. .dac_nids = alc861_dac_nids,
  4902. .dig_out_nid = ALC861_DIGOUT_NID,
  4903. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  4904. .channel_mode = alc861_8ch_modes,
  4905. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4906. .adc_nids = alc861_adc_nids,
  4907. .input_mux = &alc861_capture_source,
  4908. },
  4909. };
  4910. static int patch_alc861(struct hda_codec *codec)
  4911. {
  4912. struct alc_spec *spec;
  4913. int board_config;
  4914. int err;
  4915. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4916. if (spec == NULL)
  4917. return -ENOMEM;
  4918. codec->spec = spec;
  4919. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  4920. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  4921. printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
  4922. board_config = ALC861_AUTO;
  4923. }
  4924. if (board_config == ALC861_AUTO) {
  4925. /* automatic parse from the BIOS config */
  4926. err = alc861_parse_auto_config(codec);
  4927. if (err < 0) {
  4928. alc_free(codec);
  4929. return err;
  4930. } else if (! err) {
  4931. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4932. board_config = ALC861_3ST_DIG;
  4933. }
  4934. }
  4935. if (board_config != ALC861_AUTO)
  4936. setup_preset(spec, &alc861_presets[board_config]);
  4937. spec->stream_name_analog = "ALC861 Analog";
  4938. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  4939. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  4940. spec->stream_name_digital = "ALC861 Digital";
  4941. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  4942. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  4943. codec->patch_ops = alc_patch_ops;
  4944. if (board_config == ALC861_AUTO)
  4945. spec->init_hook = alc861_auto_init;
  4946. return 0;
  4947. }
  4948. /*
  4949. * patch entries
  4950. */
  4951. struct hda_codec_preset snd_hda_preset_realtek[] = {
  4952. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  4953. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  4954. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  4955. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  4956. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
  4957. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  4958. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  4959. {} /* terminator */
  4960. };