patch_realtek.c 194 KB

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