patch_realtek.c 195 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726
  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. { .modelname = "lg-lw", .config = ALC880_LG_LW },
  1940. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
  1941. #ifdef CONFIG_SND_DEBUG
  1942. { .modelname = "test", .config = ALC880_TEST },
  1943. #endif
  1944. { .modelname = "auto", .config = ALC880_AUTO },
  1945. {}
  1946. };
  1947. /*
  1948. * ALC880 codec presets
  1949. */
  1950. static struct alc_config_preset alc880_presets[] = {
  1951. [ALC880_3ST] = {
  1952. .mixers = { alc880_three_stack_mixer },
  1953. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1954. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1955. .dac_nids = alc880_dac_nids,
  1956. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1957. .channel_mode = alc880_threestack_modes,
  1958. .input_mux = &alc880_capture_source,
  1959. },
  1960. [ALC880_3ST_DIG] = {
  1961. .mixers = { alc880_three_stack_mixer },
  1962. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1963. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1964. .dac_nids = alc880_dac_nids,
  1965. .dig_out_nid = ALC880_DIGOUT_NID,
  1966. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1967. .channel_mode = alc880_threestack_modes,
  1968. .input_mux = &alc880_capture_source,
  1969. },
  1970. [ALC880_TCL_S700] = {
  1971. .mixers = { alc880_tcl_s700_mixer },
  1972. .init_verbs = { alc880_volume_init_verbs,
  1973. alc880_pin_tcl_S700_init_verbs,
  1974. alc880_gpio2_init_verbs },
  1975. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1976. .dac_nids = alc880_dac_nids,
  1977. .hp_nid = 0x03,
  1978. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1979. .channel_mode = alc880_2_jack_modes,
  1980. .input_mux = &alc880_capture_source,
  1981. },
  1982. [ALC880_5ST] = {
  1983. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1984. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1985. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1986. .dac_nids = alc880_dac_nids,
  1987. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1988. .channel_mode = alc880_fivestack_modes,
  1989. .input_mux = &alc880_capture_source,
  1990. },
  1991. [ALC880_5ST_DIG] = {
  1992. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1993. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1994. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1995. .dac_nids = alc880_dac_nids,
  1996. .dig_out_nid = ALC880_DIGOUT_NID,
  1997. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1998. .channel_mode = alc880_fivestack_modes,
  1999. .input_mux = &alc880_capture_source,
  2000. },
  2001. [ALC880_6ST] = {
  2002. .mixers = { alc880_six_stack_mixer },
  2003. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2004. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2005. .dac_nids = alc880_6st_dac_nids,
  2006. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2007. .channel_mode = alc880_sixstack_modes,
  2008. .input_mux = &alc880_6stack_capture_source,
  2009. },
  2010. [ALC880_6ST_DIG] = {
  2011. .mixers = { alc880_six_stack_mixer },
  2012. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2013. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2014. .dac_nids = alc880_6st_dac_nids,
  2015. .dig_out_nid = ALC880_DIGOUT_NID,
  2016. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2017. .channel_mode = alc880_sixstack_modes,
  2018. .input_mux = &alc880_6stack_capture_source,
  2019. },
  2020. [ALC880_W810] = {
  2021. .mixers = { alc880_w810_base_mixer },
  2022. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2023. alc880_gpio2_init_verbs },
  2024. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2025. .dac_nids = alc880_w810_dac_nids,
  2026. .dig_out_nid = ALC880_DIGOUT_NID,
  2027. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2028. .channel_mode = alc880_w810_modes,
  2029. .input_mux = &alc880_capture_source,
  2030. },
  2031. [ALC880_Z71V] = {
  2032. .mixers = { alc880_z71v_mixer },
  2033. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2034. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2035. .dac_nids = alc880_z71v_dac_nids,
  2036. .dig_out_nid = ALC880_DIGOUT_NID,
  2037. .hp_nid = 0x03,
  2038. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2039. .channel_mode = alc880_2_jack_modes,
  2040. .input_mux = &alc880_capture_source,
  2041. },
  2042. [ALC880_F1734] = {
  2043. .mixers = { alc880_f1734_mixer },
  2044. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2045. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2046. .dac_nids = alc880_f1734_dac_nids,
  2047. .hp_nid = 0x02,
  2048. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2049. .channel_mode = alc880_2_jack_modes,
  2050. .input_mux = &alc880_capture_source,
  2051. },
  2052. [ALC880_ASUS] = {
  2053. .mixers = { alc880_asus_mixer },
  2054. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2055. alc880_gpio1_init_verbs },
  2056. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2057. .dac_nids = alc880_asus_dac_nids,
  2058. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2059. .channel_mode = alc880_asus_modes,
  2060. .input_mux = &alc880_capture_source,
  2061. },
  2062. [ALC880_ASUS_DIG] = {
  2063. .mixers = { alc880_asus_mixer },
  2064. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2065. alc880_gpio1_init_verbs },
  2066. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2067. .dac_nids = alc880_asus_dac_nids,
  2068. .dig_out_nid = ALC880_DIGOUT_NID,
  2069. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2070. .channel_mode = alc880_asus_modes,
  2071. .input_mux = &alc880_capture_source,
  2072. },
  2073. [ALC880_ASUS_DIG2] = {
  2074. .mixers = { alc880_asus_mixer },
  2075. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2076. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2077. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2078. .dac_nids = alc880_asus_dac_nids,
  2079. .dig_out_nid = ALC880_DIGOUT_NID,
  2080. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2081. .channel_mode = alc880_asus_modes,
  2082. .input_mux = &alc880_capture_source,
  2083. },
  2084. [ALC880_ASUS_W1V] = {
  2085. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2086. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2087. alc880_gpio1_init_verbs },
  2088. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2089. .dac_nids = alc880_asus_dac_nids,
  2090. .dig_out_nid = ALC880_DIGOUT_NID,
  2091. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2092. .channel_mode = alc880_asus_modes,
  2093. .input_mux = &alc880_capture_source,
  2094. },
  2095. [ALC880_UNIWILL_DIG] = {
  2096. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2097. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  2098. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2099. .dac_nids = alc880_asus_dac_nids,
  2100. .dig_out_nid = ALC880_DIGOUT_NID,
  2101. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2102. .channel_mode = alc880_asus_modes,
  2103. .input_mux = &alc880_capture_source,
  2104. },
  2105. [ALC880_CLEVO] = {
  2106. .mixers = { alc880_three_stack_mixer },
  2107. .init_verbs = { alc880_volume_init_verbs,
  2108. alc880_pin_clevo_init_verbs },
  2109. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2110. .dac_nids = alc880_dac_nids,
  2111. .hp_nid = 0x03,
  2112. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2113. .channel_mode = alc880_threestack_modes,
  2114. .input_mux = &alc880_capture_source,
  2115. },
  2116. [ALC880_LG] = {
  2117. .mixers = { alc880_lg_mixer },
  2118. .init_verbs = { alc880_volume_init_verbs,
  2119. alc880_lg_init_verbs },
  2120. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2121. .dac_nids = alc880_lg_dac_nids,
  2122. .dig_out_nid = ALC880_DIGOUT_NID,
  2123. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2124. .channel_mode = alc880_lg_ch_modes,
  2125. .input_mux = &alc880_lg_capture_source,
  2126. .unsol_event = alc880_lg_unsol_event,
  2127. .init_hook = alc880_lg_automute,
  2128. },
  2129. [ALC880_LG_LW] = {
  2130. .mixers = { alc880_lg_lw_mixer },
  2131. .init_verbs = { alc880_volume_init_verbs,
  2132. alc880_lg_lw_init_verbs },
  2133. .num_dacs = 1,
  2134. .dac_nids = alc880_dac_nids,
  2135. .dig_out_nid = ALC880_DIGOUT_NID,
  2136. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2137. .channel_mode = alc880_2_jack_modes,
  2138. .input_mux = &alc880_lg_lw_capture_source,
  2139. .unsol_event = alc880_lg_lw_unsol_event,
  2140. .init_hook = alc880_lg_lw_automute,
  2141. },
  2142. #ifdef CONFIG_SND_DEBUG
  2143. [ALC880_TEST] = {
  2144. .mixers = { alc880_test_mixer },
  2145. .init_verbs = { alc880_test_init_verbs },
  2146. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2147. .dac_nids = alc880_test_dac_nids,
  2148. .dig_out_nid = ALC880_DIGOUT_NID,
  2149. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2150. .channel_mode = alc880_test_modes,
  2151. .input_mux = &alc880_test_capture_source,
  2152. },
  2153. #endif
  2154. };
  2155. /*
  2156. * Automatic parse of I/O pins from the BIOS configuration
  2157. */
  2158. #define NUM_CONTROL_ALLOC 32
  2159. #define NUM_VERB_ALLOC 32
  2160. enum {
  2161. ALC_CTL_WIDGET_VOL,
  2162. ALC_CTL_WIDGET_MUTE,
  2163. ALC_CTL_BIND_MUTE,
  2164. };
  2165. static struct snd_kcontrol_new alc880_control_templates[] = {
  2166. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2167. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2168. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2169. };
  2170. /* add dynamic controls */
  2171. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2172. {
  2173. struct snd_kcontrol_new *knew;
  2174. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2175. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2176. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2177. if (! knew)
  2178. return -ENOMEM;
  2179. if (spec->kctl_alloc) {
  2180. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2181. kfree(spec->kctl_alloc);
  2182. }
  2183. spec->kctl_alloc = knew;
  2184. spec->num_kctl_alloc = num;
  2185. }
  2186. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2187. *knew = alc880_control_templates[type];
  2188. knew->name = kstrdup(name, GFP_KERNEL);
  2189. if (! knew->name)
  2190. return -ENOMEM;
  2191. knew->private_value = val;
  2192. spec->num_kctl_used++;
  2193. return 0;
  2194. }
  2195. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2196. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2197. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2198. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2199. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2200. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2201. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2202. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2203. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2204. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2205. #define ALC880_PIN_CD_NID 0x1c
  2206. /* fill in the dac_nids table from the parsed pin configuration */
  2207. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2208. {
  2209. hda_nid_t nid;
  2210. int assigned[4];
  2211. int i, j;
  2212. memset(assigned, 0, sizeof(assigned));
  2213. spec->multiout.dac_nids = spec->private_dac_nids;
  2214. /* check the pins hardwired to audio widget */
  2215. for (i = 0; i < cfg->line_outs; i++) {
  2216. nid = cfg->line_out_pins[i];
  2217. if (alc880_is_fixed_pin(nid)) {
  2218. int idx = alc880_fixed_pin_idx(nid);
  2219. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2220. assigned[idx] = 1;
  2221. }
  2222. }
  2223. /* left pins can be connect to any audio widget */
  2224. for (i = 0; i < cfg->line_outs; i++) {
  2225. nid = cfg->line_out_pins[i];
  2226. if (alc880_is_fixed_pin(nid))
  2227. continue;
  2228. /* search for an empty channel */
  2229. for (j = 0; j < cfg->line_outs; j++) {
  2230. if (! assigned[j]) {
  2231. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2232. assigned[j] = 1;
  2233. break;
  2234. }
  2235. }
  2236. }
  2237. spec->multiout.num_dacs = cfg->line_outs;
  2238. return 0;
  2239. }
  2240. /* add playback controls from the parsed DAC table */
  2241. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2242. const struct auto_pin_cfg *cfg)
  2243. {
  2244. char name[32];
  2245. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2246. hda_nid_t nid;
  2247. int i, err;
  2248. for (i = 0; i < cfg->line_outs; i++) {
  2249. if (! spec->multiout.dac_nids[i])
  2250. continue;
  2251. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2252. if (i == 2) {
  2253. /* Center/LFE */
  2254. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2255. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2256. return err;
  2257. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2258. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2259. return err;
  2260. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2261. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2262. return err;
  2263. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2264. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2265. return err;
  2266. } else {
  2267. sprintf(name, "%s Playback Volume", chname[i]);
  2268. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2269. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2270. return err;
  2271. sprintf(name, "%s Playback Switch", chname[i]);
  2272. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2273. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2274. return err;
  2275. }
  2276. }
  2277. return 0;
  2278. }
  2279. /* add playback controls for speaker and HP outputs */
  2280. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2281. const char *pfx)
  2282. {
  2283. hda_nid_t nid;
  2284. int err;
  2285. char name[32];
  2286. if (! pin)
  2287. return 0;
  2288. if (alc880_is_fixed_pin(pin)) {
  2289. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2290. /* specify the DAC as the extra output */
  2291. if (! spec->multiout.hp_nid)
  2292. spec->multiout.hp_nid = nid;
  2293. else
  2294. spec->multiout.extra_out_nid[0] = nid;
  2295. /* control HP volume/switch on the output mixer amp */
  2296. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2297. sprintf(name, "%s Playback Volume", pfx);
  2298. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2299. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2300. return err;
  2301. sprintf(name, "%s Playback Switch", pfx);
  2302. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2303. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2304. return err;
  2305. } else if (alc880_is_multi_pin(pin)) {
  2306. /* set manual connection */
  2307. /* we have only a switch on HP-out PIN */
  2308. sprintf(name, "%s Playback Switch", pfx);
  2309. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2310. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2311. return err;
  2312. }
  2313. return 0;
  2314. }
  2315. /* create input playback/capture controls for the given pin */
  2316. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2317. int idx, hda_nid_t mix_nid)
  2318. {
  2319. char name[32];
  2320. int err;
  2321. sprintf(name, "%s Playback Volume", ctlname);
  2322. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2323. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2324. return err;
  2325. sprintf(name, "%s Playback Switch", ctlname);
  2326. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2327. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2328. return err;
  2329. return 0;
  2330. }
  2331. /* create playback/capture controls for input pins */
  2332. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2333. const struct auto_pin_cfg *cfg)
  2334. {
  2335. struct hda_input_mux *imux = &spec->private_imux;
  2336. int i, err, idx;
  2337. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2338. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2339. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2340. err = new_analog_input(spec, cfg->input_pins[i],
  2341. auto_pin_cfg_labels[i],
  2342. idx, 0x0b);
  2343. if (err < 0)
  2344. return err;
  2345. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2346. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2347. imux->num_items++;
  2348. }
  2349. }
  2350. return 0;
  2351. }
  2352. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2353. hda_nid_t nid, int pin_type,
  2354. int dac_idx)
  2355. {
  2356. /* set as output */
  2357. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2358. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2359. /* need the manual connection? */
  2360. if (alc880_is_multi_pin(nid)) {
  2361. struct alc_spec *spec = codec->spec;
  2362. int idx = alc880_multi_pin_idx(nid);
  2363. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2364. AC_VERB_SET_CONNECT_SEL,
  2365. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2366. }
  2367. }
  2368. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2369. {
  2370. struct alc_spec *spec = codec->spec;
  2371. int i;
  2372. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2373. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2374. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2375. }
  2376. }
  2377. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2378. {
  2379. struct alc_spec *spec = codec->spec;
  2380. hda_nid_t pin;
  2381. pin = spec->autocfg.speaker_pins[0];
  2382. if (pin) /* connect to front */
  2383. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2384. pin = spec->autocfg.hp_pin;
  2385. if (pin) /* connect to front */
  2386. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2387. }
  2388. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2389. {
  2390. struct alc_spec *spec = codec->spec;
  2391. int i;
  2392. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2393. hda_nid_t nid = spec->autocfg.input_pins[i];
  2394. if (alc880_is_input_pin(nid)) {
  2395. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2396. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2397. if (nid != ALC880_PIN_CD_NID)
  2398. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2399. AMP_OUT_MUTE);
  2400. }
  2401. }
  2402. }
  2403. /* parse the BIOS configuration and set up the alc_spec */
  2404. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2405. static int alc880_parse_auto_config(struct hda_codec *codec)
  2406. {
  2407. struct alc_spec *spec = codec->spec;
  2408. int err;
  2409. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2410. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2411. alc880_ignore)) < 0)
  2412. return err;
  2413. if (! spec->autocfg.line_outs)
  2414. return 0; /* can't find valid BIOS pin config */
  2415. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2416. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2417. (err = alc880_auto_create_extra_out(spec,
  2418. spec->autocfg.speaker_pins[0],
  2419. "Speaker")) < 0 ||
  2420. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
  2421. "Headphone")) < 0 ||
  2422. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2423. return err;
  2424. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2425. if (spec->autocfg.dig_out_pin)
  2426. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2427. if (spec->autocfg.dig_in_pin)
  2428. spec->dig_in_nid = ALC880_DIGIN_NID;
  2429. if (spec->kctl_alloc)
  2430. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2431. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2432. spec->num_mux_defs = 1;
  2433. spec->input_mux = &spec->private_imux;
  2434. return 1;
  2435. }
  2436. /* additional initialization for auto-configuration model */
  2437. static void alc880_auto_init(struct hda_codec *codec)
  2438. {
  2439. alc880_auto_init_multi_out(codec);
  2440. alc880_auto_init_extra_out(codec);
  2441. alc880_auto_init_analog_input(codec);
  2442. }
  2443. /*
  2444. * OK, here we have finally the patch for ALC880
  2445. */
  2446. static int patch_alc880(struct hda_codec *codec)
  2447. {
  2448. struct alc_spec *spec;
  2449. int board_config;
  2450. int err;
  2451. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2452. if (spec == NULL)
  2453. return -ENOMEM;
  2454. codec->spec = spec;
  2455. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2456. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2457. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  2458. board_config = ALC880_AUTO;
  2459. }
  2460. if (board_config == ALC880_AUTO) {
  2461. /* automatic parse from the BIOS config */
  2462. err = alc880_parse_auto_config(codec);
  2463. if (err < 0) {
  2464. alc_free(codec);
  2465. return err;
  2466. } else if (! err) {
  2467. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  2468. board_config = ALC880_3ST;
  2469. }
  2470. }
  2471. if (board_config != ALC880_AUTO)
  2472. setup_preset(spec, &alc880_presets[board_config]);
  2473. spec->stream_name_analog = "ALC880 Analog";
  2474. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2475. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2476. spec->stream_name_digital = "ALC880 Digital";
  2477. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2478. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2479. if (! spec->adc_nids && spec->input_mux) {
  2480. /* check whether NID 0x07 is valid */
  2481. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2482. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2483. if (wcap != AC_WID_AUD_IN) {
  2484. spec->adc_nids = alc880_adc_nids_alt;
  2485. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2486. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2487. spec->num_mixers++;
  2488. } else {
  2489. spec->adc_nids = alc880_adc_nids;
  2490. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2491. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2492. spec->num_mixers++;
  2493. }
  2494. }
  2495. codec->patch_ops = alc_patch_ops;
  2496. if (board_config == ALC880_AUTO)
  2497. spec->init_hook = alc880_auto_init;
  2498. return 0;
  2499. }
  2500. /*
  2501. * ALC260 support
  2502. */
  2503. static hda_nid_t alc260_dac_nids[1] = {
  2504. /* front */
  2505. 0x02,
  2506. };
  2507. static hda_nid_t alc260_adc_nids[1] = {
  2508. /* ADC0 */
  2509. 0x04,
  2510. };
  2511. static hda_nid_t alc260_adc_nids_alt[1] = {
  2512. /* ADC1 */
  2513. 0x05,
  2514. };
  2515. static hda_nid_t alc260_hp_adc_nids[2] = {
  2516. /* ADC1, 0 */
  2517. 0x05, 0x04
  2518. };
  2519. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2520. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2521. */
  2522. static hda_nid_t alc260_dual_adc_nids[2] = {
  2523. /* ADC0, ADC1 */
  2524. 0x04, 0x05
  2525. };
  2526. #define ALC260_DIGOUT_NID 0x03
  2527. #define ALC260_DIGIN_NID 0x06
  2528. static struct hda_input_mux alc260_capture_source = {
  2529. .num_items = 4,
  2530. .items = {
  2531. { "Mic", 0x0 },
  2532. { "Front Mic", 0x1 },
  2533. { "Line", 0x2 },
  2534. { "CD", 0x4 },
  2535. },
  2536. };
  2537. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2538. * headphone jack and the internal CD lines since these are the only pins at
  2539. * which audio can appear. For flexibility, also allow the option of
  2540. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2541. * connection to the mixer output).
  2542. */
  2543. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2544. {
  2545. .num_items = 3,
  2546. .items = {
  2547. { "Mic/Line", 0x0 },
  2548. { "CD", 0x4 },
  2549. { "Headphone", 0x2 },
  2550. },
  2551. },
  2552. {
  2553. .num_items = 4,
  2554. .items = {
  2555. { "Mic/Line", 0x0 },
  2556. { "CD", 0x4 },
  2557. { "Headphone", 0x2 },
  2558. { "Mixer", 0x5 },
  2559. },
  2560. },
  2561. };
  2562. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2563. * the Fujitsu S702x, but jacks are marked differently.
  2564. */
  2565. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2566. {
  2567. .num_items = 4,
  2568. .items = {
  2569. { "Mic", 0x0 },
  2570. { "Line", 0x2 },
  2571. { "CD", 0x4 },
  2572. { "Headphone", 0x5 },
  2573. },
  2574. },
  2575. {
  2576. .num_items = 5,
  2577. .items = {
  2578. { "Mic", 0x0 },
  2579. { "Line", 0x2 },
  2580. { "CD", 0x4 },
  2581. { "Headphone", 0x6 },
  2582. { "Mixer", 0x5 },
  2583. },
  2584. },
  2585. };
  2586. /*
  2587. * This is just place-holder, so there's something for alc_build_pcms to look
  2588. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2589. * element which allows changing the channel mode, so the verb list is
  2590. * never used.
  2591. */
  2592. static struct hda_channel_mode alc260_modes[1] = {
  2593. { 2, NULL },
  2594. };
  2595. /* Mixer combinations
  2596. *
  2597. * basic: base_output + input + pc_beep + capture
  2598. * HP: base_output + input + capture_alt
  2599. * HP_3013: hp_3013 + input + capture
  2600. * fujitsu: fujitsu + capture
  2601. * acer: acer + capture
  2602. */
  2603. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2604. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2605. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2606. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2607. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2608. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2609. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2610. { } /* end */
  2611. };
  2612. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2613. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2614. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2615. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2616. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2617. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2618. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2619. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2620. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2621. { } /* end */
  2622. };
  2623. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2624. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2625. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2626. { } /* end */
  2627. };
  2628. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2629. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2630. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2631. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2632. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2633. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2634. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2635. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2636. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2637. { } /* end */
  2638. };
  2639. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2640. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2641. */
  2642. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2643. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2644. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2645. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2646. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2647. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2648. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2649. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2650. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2651. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2652. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2653. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2654. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2655. { } /* end */
  2656. };
  2657. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2658. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2659. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2660. * datasheet doesn't mention this restriction. At this stage it's not clear
  2661. * whether this behaviour is intentional or is a hardware bug in chip
  2662. * revisions available in early 2006. Therefore for now allow the
  2663. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2664. * that the lack of mic bias for this NID is intentional we could change the
  2665. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2666. *
  2667. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2668. * don't appear to make the mic bias available from the "line" jack, even
  2669. * though the NID used for this jack (0x14) can supply it. The theory is
  2670. * that perhaps Acer have included blocking capacitors between the ALC260
  2671. * and the output jack. If this turns out to be the case for all such
  2672. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2673. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2674. */
  2675. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2676. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2677. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2678. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2679. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2680. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2681. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2682. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2683. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2684. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2685. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2686. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2687. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2688. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2689. { } /* end */
  2690. };
  2691. /* capture mixer elements */
  2692. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2693. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2694. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2695. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2696. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2697. {
  2698. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2699. /* The multiple "Capture Source" controls confuse alsamixer
  2700. * So call somewhat different..
  2701. * FIXME: the controls appear in the "playback" view!
  2702. */
  2703. /* .name = "Capture Source", */
  2704. .name = "Input Source",
  2705. .count = 2,
  2706. .info = alc_mux_enum_info,
  2707. .get = alc_mux_enum_get,
  2708. .put = alc_mux_enum_put,
  2709. },
  2710. { } /* end */
  2711. };
  2712. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2713. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2714. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2715. {
  2716. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2717. /* The multiple "Capture Source" controls confuse alsamixer
  2718. * So call somewhat different..
  2719. * FIXME: the controls appear in the "playback" view!
  2720. */
  2721. /* .name = "Capture Source", */
  2722. .name = "Input Source",
  2723. .count = 1,
  2724. .info = alc_mux_enum_info,
  2725. .get = alc_mux_enum_get,
  2726. .put = alc_mux_enum_put,
  2727. },
  2728. { } /* end */
  2729. };
  2730. /*
  2731. * initialization verbs
  2732. */
  2733. static struct hda_verb alc260_init_verbs[] = {
  2734. /* Line In pin widget for input */
  2735. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2736. /* CD pin widget for input */
  2737. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2738. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2739. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2740. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2741. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2742. /* LINE-2 is used for line-out in rear */
  2743. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2744. /* select line-out */
  2745. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2746. /* LINE-OUT pin */
  2747. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2748. /* enable HP */
  2749. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2750. /* enable Mono */
  2751. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2752. /* mute capture amp left and right */
  2753. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2754. /* set connection select to line in (default select for this ADC) */
  2755. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2756. /* mute capture amp left and right */
  2757. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2758. /* set connection select to line in (default select for this ADC) */
  2759. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2760. /* set vol=0 Line-Out mixer amp left and right */
  2761. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2762. /* unmute pin widget amp left and right (no gain on this amp) */
  2763. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2764. /* set vol=0 HP mixer amp left and right */
  2765. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2766. /* unmute pin widget amp left and right (no gain on this amp) */
  2767. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2768. /* set vol=0 Mono mixer amp left and right */
  2769. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2770. /* unmute pin widget amp left and right (no gain on this amp) */
  2771. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2772. /* unmute LINE-2 out pin */
  2773. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2774. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2775. /* mute CD */
  2776. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2777. /* mute Line In */
  2778. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2779. /* mute Mic */
  2780. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2781. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2782. /* mute Front out path */
  2783. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2784. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2785. /* mute Headphone out path */
  2786. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2787. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2788. /* mute Mono out path */
  2789. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2790. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2791. { }
  2792. };
  2793. static struct hda_verb alc260_hp_init_verbs[] = {
  2794. /* Headphone and output */
  2795. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2796. /* mono output */
  2797. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2798. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2799. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2800. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2801. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2802. /* Line In pin widget for input */
  2803. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2804. /* Line-2 pin widget for output */
  2805. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2806. /* CD pin widget for input */
  2807. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2808. /* unmute amp left and right */
  2809. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2810. /* set connection select to line in (default select for this ADC) */
  2811. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2812. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2813. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2814. /* mute pin widget amp left and right (no gain on this amp) */
  2815. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2816. /* unmute HP mixer amp left and right (volume = 0) */
  2817. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2818. /* mute pin widget amp left and right (no gain on this amp) */
  2819. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2820. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2821. /* unmute CD */
  2822. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2823. /* unmute Line In */
  2824. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2825. /* unmute Mic */
  2826. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2827. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2828. /* Unmute Front out path */
  2829. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2830. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2831. /* Unmute Headphone out path */
  2832. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2834. /* Unmute Mono out path */
  2835. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2836. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2837. { }
  2838. };
  2839. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2840. /* Line out and output */
  2841. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2842. /* mono output */
  2843. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2844. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2845. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2846. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2847. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2848. /* Line In pin widget for input */
  2849. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2850. /* Headphone pin widget for output */
  2851. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2852. /* CD pin widget for input */
  2853. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2854. /* unmute amp left and right */
  2855. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2856. /* set connection select to line in (default select for this ADC) */
  2857. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2858. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2859. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2860. /* mute pin widget amp left and right (no gain on this amp) */
  2861. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2862. /* unmute HP mixer amp left and right (volume = 0) */
  2863. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2864. /* mute pin widget amp left and right (no gain on this amp) */
  2865. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2866. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2867. /* unmute CD */
  2868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2869. /* unmute Line In */
  2870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2871. /* unmute Mic */
  2872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2873. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2874. /* Unmute Front out path */
  2875. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2876. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2877. /* Unmute Headphone out path */
  2878. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2879. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2880. /* Unmute Mono out path */
  2881. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2882. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2883. { }
  2884. };
  2885. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2886. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  2887. * audio = 0x16, internal speaker = 0x10.
  2888. */
  2889. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2890. /* Disable all GPIOs */
  2891. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2892. /* Internal speaker is connected to headphone pin */
  2893. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2894. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  2895. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2896. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  2897. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2898. /* Ensure all other unused pins are disabled and muted. */
  2899. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2900. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2901. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2902. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2903. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2904. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2905. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2906. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2907. /* Disable digital (SPDIF) pins */
  2908. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2909. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2910. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  2911. * when acting as an output.
  2912. */
  2913. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2914. /* Start with output sum widgets muted and their output gains at min */
  2915. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2916. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2917. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2918. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2919. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2920. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2921. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2922. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2923. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2924. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  2925. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2926. /* Unmute Line1 pin widget output buffer since it starts as an output.
  2927. * If the pin mode is changed by the user the pin mode control will
  2928. * take care of enabling the pin's input/output buffers as needed.
  2929. * Therefore there's no need to enable the input buffer at this
  2930. * stage.
  2931. */
  2932. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2933. /* Unmute input buffer of pin widget used for Line-in (no equiv
  2934. * mixer ctrl)
  2935. */
  2936. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2937. /* Mute capture amp left and right */
  2938. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2939. /* Set ADC connection select to match default mixer setting - line
  2940. * in (on mic1 pin)
  2941. */
  2942. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2943. /* Do the same for the second ADC: mute capture input amp and
  2944. * set ADC connection to line in (on mic1 pin)
  2945. */
  2946. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2947. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2948. /* Mute all inputs to mixer widget (even unconnected ones) */
  2949. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2950. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2951. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2952. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2953. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2954. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2955. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2956. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2957. { }
  2958. };
  2959. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  2960. * similar laptops (adapted from Fujitsu init verbs).
  2961. */
  2962. static struct hda_verb alc260_acer_init_verbs[] = {
  2963. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  2964. * the headphone jack. Turn this on and rely on the standard mute
  2965. * methods whenever the user wants to turn these outputs off.
  2966. */
  2967. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  2968. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  2969. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  2970. /* Internal speaker/Headphone jack is connected to Line-out pin */
  2971. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2972. /* Internal microphone/Mic jack is connected to Mic1 pin */
  2973. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  2974. /* Line In jack is connected to Line1 pin */
  2975. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2976. /* Ensure all other unused pins are disabled and muted. */
  2977. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2978. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2979. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2980. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2981. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2982. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2983. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2984. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2985. /* Disable digital (SPDIF) pins */
  2986. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2987. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2988. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  2989. * bus when acting as outputs.
  2990. */
  2991. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  2992. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2993. /* Start with output sum widgets muted and their output gains at min */
  2994. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2995. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2996. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2997. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2998. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2999. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3000. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3001. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3002. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3003. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3004. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3005. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3006. * inputs. If the pin mode is changed by the user the pin mode control
  3007. * will take care of enabling the pin's input/output buffers as needed.
  3008. * Therefore there's no need to enable the input buffer at this
  3009. * stage.
  3010. */
  3011. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3012. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3013. /* Mute capture amp left and right */
  3014. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3015. /* Set ADC connection select to match default mixer setting - mic
  3016. * (on mic1 pin)
  3017. */
  3018. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3019. /* Do similar with the second ADC: mute capture input amp and
  3020. * set ADC connection to mic to match ALSA's default state.
  3021. */
  3022. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3023. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3024. /* Mute all inputs to mixer widget (even unconnected ones) */
  3025. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3026. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3028. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3029. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3030. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3031. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3032. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3033. { }
  3034. };
  3035. /* Test configuration for debugging, modelled after the ALC880 test
  3036. * configuration.
  3037. */
  3038. #ifdef CONFIG_SND_DEBUG
  3039. static hda_nid_t alc260_test_dac_nids[1] = {
  3040. 0x02,
  3041. };
  3042. static hda_nid_t alc260_test_adc_nids[2] = {
  3043. 0x04, 0x05,
  3044. };
  3045. /* For testing the ALC260, each input MUX needs its own definition since
  3046. * the signal assignments are different. This assumes that the first ADC
  3047. * is NID 0x04.
  3048. */
  3049. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3050. {
  3051. .num_items = 7,
  3052. .items = {
  3053. { "MIC1 pin", 0x0 },
  3054. { "MIC2 pin", 0x1 },
  3055. { "LINE1 pin", 0x2 },
  3056. { "LINE2 pin", 0x3 },
  3057. { "CD pin", 0x4 },
  3058. { "LINE-OUT pin", 0x5 },
  3059. { "HP-OUT pin", 0x6 },
  3060. },
  3061. },
  3062. {
  3063. .num_items = 8,
  3064. .items = {
  3065. { "MIC1 pin", 0x0 },
  3066. { "MIC2 pin", 0x1 },
  3067. { "LINE1 pin", 0x2 },
  3068. { "LINE2 pin", 0x3 },
  3069. { "CD pin", 0x4 },
  3070. { "Mixer", 0x5 },
  3071. { "LINE-OUT pin", 0x6 },
  3072. { "HP-OUT pin", 0x7 },
  3073. },
  3074. },
  3075. };
  3076. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3077. /* Output driver widgets */
  3078. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3079. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3080. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3081. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3082. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3083. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3084. /* Modes for retasking pin widgets
  3085. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3086. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3087. * mention this restriction. At this stage it's not clear whether
  3088. * this behaviour is intentional or is a hardware bug in chip
  3089. * revisions available at least up until early 2006. Therefore for
  3090. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3091. * choices, but if it turns out that the lack of mic bias for these
  3092. * NIDs is intentional we could change their modes from
  3093. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3094. */
  3095. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3096. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3097. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3098. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3099. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3100. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3101. /* Loopback mixer controls */
  3102. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3103. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3104. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3105. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3106. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3107. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3108. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3109. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3110. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3111. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3112. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3113. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3114. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3115. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3116. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3117. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3118. /* Controls for GPIO pins, assuming they are configured as outputs */
  3119. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3120. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3121. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3122. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3123. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3124. * is ambigious as to which NID is which; testing on laptops which
  3125. * make this output available should provide clarification.
  3126. */
  3127. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3128. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3129. { } /* end */
  3130. };
  3131. static struct hda_verb alc260_test_init_verbs[] = {
  3132. /* Enable all GPIOs as outputs with an initial value of 0 */
  3133. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3134. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3135. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3136. /* Enable retasking pins as output, initially without power amp */
  3137. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3138. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3139. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3140. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3141. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3142. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3143. /* Disable digital (SPDIF) pins initially, but users can enable
  3144. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3145. * payload also sets the generation to 0, output to be in "consumer"
  3146. * PCM format, copyright asserted, no pre-emphasis and no validity
  3147. * control.
  3148. */
  3149. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3150. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3151. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3152. * OUT1 sum bus when acting as an output.
  3153. */
  3154. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3155. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3156. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3157. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3158. /* Start with output sum widgets muted and their output gains at min */
  3159. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3160. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3161. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3162. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3163. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3164. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3165. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3166. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3167. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3168. /* Unmute retasking pin widget output buffers since the default
  3169. * state appears to be output. As the pin mode is changed by the
  3170. * user the pin mode control will take care of enabling the pin's
  3171. * input/output buffers as needed.
  3172. */
  3173. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3174. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3175. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3176. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3177. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3178. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3179. /* Also unmute the mono-out pin widget */
  3180. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3181. /* Mute capture amp left and right */
  3182. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3183. /* Set ADC connection select to match default mixer setting (mic1
  3184. * pin)
  3185. */
  3186. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3187. /* Do the same for the second ADC: mute capture input amp and
  3188. * set ADC connection to mic1 pin
  3189. */
  3190. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3191. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3192. /* Mute all inputs to mixer widget (even unconnected ones) */
  3193. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3194. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3195. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3197. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3199. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3200. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3201. { }
  3202. };
  3203. #endif
  3204. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3205. .substreams = 1,
  3206. .channels_min = 2,
  3207. .channels_max = 2,
  3208. };
  3209. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3210. .substreams = 1,
  3211. .channels_min = 2,
  3212. .channels_max = 2,
  3213. };
  3214. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3215. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3216. /*
  3217. * for BIOS auto-configuration
  3218. */
  3219. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3220. const char *pfx)
  3221. {
  3222. hda_nid_t nid_vol;
  3223. unsigned long vol_val, sw_val;
  3224. char name[32];
  3225. int err;
  3226. if (nid >= 0x0f && nid < 0x11) {
  3227. nid_vol = nid - 0x7;
  3228. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3229. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3230. } else if (nid == 0x11) {
  3231. nid_vol = nid - 0x7;
  3232. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3233. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3234. } else if (nid >= 0x12 && nid <= 0x15) {
  3235. nid_vol = 0x08;
  3236. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3237. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3238. } else
  3239. return 0; /* N/A */
  3240. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3241. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3242. return err;
  3243. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3244. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3245. return err;
  3246. return 1;
  3247. }
  3248. /* add playback controls from the parsed DAC table */
  3249. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3250. const struct auto_pin_cfg *cfg)
  3251. {
  3252. hda_nid_t nid;
  3253. int err;
  3254. spec->multiout.num_dacs = 1;
  3255. spec->multiout.dac_nids = spec->private_dac_nids;
  3256. spec->multiout.dac_nids[0] = 0x02;
  3257. nid = cfg->line_out_pins[0];
  3258. if (nid) {
  3259. err = alc260_add_playback_controls(spec, nid, "Front");
  3260. if (err < 0)
  3261. return err;
  3262. }
  3263. nid = cfg->speaker_pins[0];
  3264. if (nid) {
  3265. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3266. if (err < 0)
  3267. return err;
  3268. }
  3269. nid = cfg->hp_pin;
  3270. if (nid) {
  3271. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3272. if (err < 0)
  3273. return err;
  3274. }
  3275. return 0;
  3276. }
  3277. /* create playback/capture controls for input pins */
  3278. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3279. const struct auto_pin_cfg *cfg)
  3280. {
  3281. struct hda_input_mux *imux = &spec->private_imux;
  3282. int i, err, idx;
  3283. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3284. if (cfg->input_pins[i] >= 0x12) {
  3285. idx = cfg->input_pins[i] - 0x12;
  3286. err = new_analog_input(spec, cfg->input_pins[i],
  3287. auto_pin_cfg_labels[i], idx, 0x07);
  3288. if (err < 0)
  3289. return err;
  3290. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3291. imux->items[imux->num_items].index = idx;
  3292. imux->num_items++;
  3293. }
  3294. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3295. idx = cfg->input_pins[i] - 0x09;
  3296. err = new_analog_input(spec, cfg->input_pins[i],
  3297. auto_pin_cfg_labels[i], idx, 0x07);
  3298. if (err < 0)
  3299. return err;
  3300. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3301. imux->items[imux->num_items].index = idx;
  3302. imux->num_items++;
  3303. }
  3304. }
  3305. return 0;
  3306. }
  3307. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3308. hda_nid_t nid, int pin_type,
  3309. int sel_idx)
  3310. {
  3311. /* set as output */
  3312. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3313. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3314. /* need the manual connection? */
  3315. if (nid >= 0x12) {
  3316. int idx = nid - 0x12;
  3317. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3318. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3319. }
  3320. }
  3321. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3322. {
  3323. struct alc_spec *spec = codec->spec;
  3324. hda_nid_t nid;
  3325. nid = spec->autocfg.line_out_pins[0];
  3326. if (nid)
  3327. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3328. nid = spec->autocfg.speaker_pins[0];
  3329. if (nid)
  3330. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3331. nid = spec->autocfg.hp_pin;
  3332. if (nid)
  3333. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3334. }
  3335. #define ALC260_PIN_CD_NID 0x16
  3336. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3337. {
  3338. struct alc_spec *spec = codec->spec;
  3339. int i;
  3340. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3341. hda_nid_t nid = spec->autocfg.input_pins[i];
  3342. if (nid >= 0x12) {
  3343. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3344. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3345. if (nid != ALC260_PIN_CD_NID)
  3346. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3347. AMP_OUT_MUTE);
  3348. }
  3349. }
  3350. }
  3351. /*
  3352. * generic initialization of ADC, input mixers and output mixers
  3353. */
  3354. static struct hda_verb alc260_volume_init_verbs[] = {
  3355. /*
  3356. * Unmute ADC0-1 and set the default input to mic-in
  3357. */
  3358. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3359. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3360. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3361. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3362. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3363. * mixer widget
  3364. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3365. * mic (mic 2)
  3366. */
  3367. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3368. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3369. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3370. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3371. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3372. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3373. /*
  3374. * Set up output mixers (0x08 - 0x0a)
  3375. */
  3376. /* set vol=0 to output mixers */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3378. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3379. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3380. /* set up input amps for analog loopback */
  3381. /* Amp Indices: DAC = 0, mixer = 1 */
  3382. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3383. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3384. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3385. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3386. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3387. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3388. { }
  3389. };
  3390. static int alc260_parse_auto_config(struct hda_codec *codec)
  3391. {
  3392. struct alc_spec *spec = codec->spec;
  3393. unsigned int wcap;
  3394. int err;
  3395. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3396. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3397. alc260_ignore)) < 0)
  3398. return err;
  3399. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3400. return err;
  3401. if (! spec->kctl_alloc)
  3402. return 0; /* can't find valid BIOS pin config */
  3403. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3404. return err;
  3405. spec->multiout.max_channels = 2;
  3406. if (spec->autocfg.dig_out_pin)
  3407. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3408. if (spec->kctl_alloc)
  3409. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3410. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3411. spec->num_mux_defs = 1;
  3412. spec->input_mux = &spec->private_imux;
  3413. /* check whether NID 0x04 is valid */
  3414. wcap = get_wcaps(codec, 0x04);
  3415. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3416. if (wcap != AC_WID_AUD_IN) {
  3417. spec->adc_nids = alc260_adc_nids_alt;
  3418. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3419. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3420. } else {
  3421. spec->adc_nids = alc260_adc_nids;
  3422. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3423. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3424. }
  3425. spec->num_mixers++;
  3426. return 1;
  3427. }
  3428. /* additional initialization for auto-configuration model */
  3429. static void alc260_auto_init(struct hda_codec *codec)
  3430. {
  3431. alc260_auto_init_multi_out(codec);
  3432. alc260_auto_init_analog_input(codec);
  3433. }
  3434. /*
  3435. * ALC260 configurations
  3436. */
  3437. static struct hda_board_config alc260_cfg_tbl[] = {
  3438. { .modelname = "basic", .config = ALC260_BASIC },
  3439. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3440. .config = ALC260_BASIC }, /* Sony VAIO */
  3441. { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
  3442. .config = ALC260_BASIC }, /* CTL Travel Master U553W */
  3443. { .modelname = "hp", .config = ALC260_HP },
  3444. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
  3445. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3446. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
  3447. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3448. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3449. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3450. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3451. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3452. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3453. { .modelname = "acer", .config = ALC260_ACER },
  3454. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3455. #ifdef CONFIG_SND_DEBUG
  3456. { .modelname = "test", .config = ALC260_TEST },
  3457. #endif
  3458. { .modelname = "auto", .config = ALC260_AUTO },
  3459. {}
  3460. };
  3461. static struct alc_config_preset alc260_presets[] = {
  3462. [ALC260_BASIC] = {
  3463. .mixers = { alc260_base_output_mixer,
  3464. alc260_input_mixer,
  3465. alc260_pc_beep_mixer,
  3466. alc260_capture_mixer },
  3467. .init_verbs = { alc260_init_verbs },
  3468. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3469. .dac_nids = alc260_dac_nids,
  3470. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3471. .adc_nids = alc260_adc_nids,
  3472. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3473. .channel_mode = alc260_modes,
  3474. .input_mux = &alc260_capture_source,
  3475. },
  3476. [ALC260_HP] = {
  3477. .mixers = { alc260_base_output_mixer,
  3478. alc260_input_mixer,
  3479. alc260_capture_alt_mixer },
  3480. .init_verbs = { alc260_hp_init_verbs },
  3481. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3482. .dac_nids = alc260_dac_nids,
  3483. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3484. .adc_nids = alc260_hp_adc_nids,
  3485. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3486. .channel_mode = alc260_modes,
  3487. .input_mux = &alc260_capture_source,
  3488. },
  3489. [ALC260_HP_3013] = {
  3490. .mixers = { alc260_hp_3013_mixer,
  3491. alc260_input_mixer,
  3492. alc260_capture_alt_mixer },
  3493. .init_verbs = { alc260_hp_3013_init_verbs },
  3494. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3495. .dac_nids = alc260_dac_nids,
  3496. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3497. .adc_nids = alc260_hp_adc_nids,
  3498. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3499. .channel_mode = alc260_modes,
  3500. .input_mux = &alc260_capture_source,
  3501. },
  3502. [ALC260_FUJITSU_S702X] = {
  3503. .mixers = { alc260_fujitsu_mixer,
  3504. alc260_capture_mixer },
  3505. .init_verbs = { alc260_fujitsu_init_verbs },
  3506. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3507. .dac_nids = alc260_dac_nids,
  3508. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3509. .adc_nids = alc260_dual_adc_nids,
  3510. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3511. .channel_mode = alc260_modes,
  3512. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3513. .input_mux = alc260_fujitsu_capture_sources,
  3514. },
  3515. [ALC260_ACER] = {
  3516. .mixers = { alc260_acer_mixer,
  3517. alc260_capture_mixer },
  3518. .init_verbs = { alc260_acer_init_verbs },
  3519. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3520. .dac_nids = alc260_dac_nids,
  3521. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3522. .adc_nids = alc260_dual_adc_nids,
  3523. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3524. .channel_mode = alc260_modes,
  3525. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3526. .input_mux = alc260_acer_capture_sources,
  3527. },
  3528. #ifdef CONFIG_SND_DEBUG
  3529. [ALC260_TEST] = {
  3530. .mixers = { alc260_test_mixer,
  3531. alc260_capture_mixer },
  3532. .init_verbs = { alc260_test_init_verbs },
  3533. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3534. .dac_nids = alc260_test_dac_nids,
  3535. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3536. .adc_nids = alc260_test_adc_nids,
  3537. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3538. .channel_mode = alc260_modes,
  3539. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3540. .input_mux = alc260_test_capture_sources,
  3541. },
  3542. #endif
  3543. };
  3544. static int patch_alc260(struct hda_codec *codec)
  3545. {
  3546. struct alc_spec *spec;
  3547. int err, board_config;
  3548. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3549. if (spec == NULL)
  3550. return -ENOMEM;
  3551. codec->spec = spec;
  3552. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3553. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3554. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  3555. board_config = ALC260_AUTO;
  3556. }
  3557. if (board_config == ALC260_AUTO) {
  3558. /* automatic parse from the BIOS config */
  3559. err = alc260_parse_auto_config(codec);
  3560. if (err < 0) {
  3561. alc_free(codec);
  3562. return err;
  3563. } else if (! err) {
  3564. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3565. board_config = ALC260_BASIC;
  3566. }
  3567. }
  3568. if (board_config != ALC260_AUTO)
  3569. setup_preset(spec, &alc260_presets[board_config]);
  3570. spec->stream_name_analog = "ALC260 Analog";
  3571. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3572. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3573. spec->stream_name_digital = "ALC260 Digital";
  3574. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3575. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3576. codec->patch_ops = alc_patch_ops;
  3577. if (board_config == ALC260_AUTO)
  3578. spec->init_hook = alc260_auto_init;
  3579. return 0;
  3580. }
  3581. /*
  3582. * ALC882 support
  3583. *
  3584. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3585. * configuration. Each pin widget can choose any input DACs and a mixer.
  3586. * Each ADC is connected from a mixer of all inputs. This makes possible
  3587. * 6-channel independent captures.
  3588. *
  3589. * In addition, an independent DAC for the multi-playback (not used in this
  3590. * driver yet).
  3591. */
  3592. #define ALC882_DIGOUT_NID 0x06
  3593. #define ALC882_DIGIN_NID 0x0a
  3594. static struct hda_channel_mode alc882_ch_modes[1] = {
  3595. { 8, NULL }
  3596. };
  3597. static hda_nid_t alc882_dac_nids[4] = {
  3598. /* front, rear, clfe, rear_surr */
  3599. 0x02, 0x03, 0x04, 0x05
  3600. };
  3601. /* identical with ALC880 */
  3602. #define alc882_adc_nids alc880_adc_nids
  3603. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3604. /* input MUX */
  3605. /* FIXME: should be a matrix-type input source selection */
  3606. static struct hda_input_mux alc882_capture_source = {
  3607. .num_items = 4,
  3608. .items = {
  3609. { "Mic", 0x0 },
  3610. { "Front Mic", 0x1 },
  3611. { "Line", 0x2 },
  3612. { "CD", 0x4 },
  3613. },
  3614. };
  3615. #define alc882_mux_enum_info alc_mux_enum_info
  3616. #define alc882_mux_enum_get alc_mux_enum_get
  3617. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3618. {
  3619. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3620. struct alc_spec *spec = codec->spec;
  3621. const struct hda_input_mux *imux = spec->input_mux;
  3622. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3623. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3624. hda_nid_t nid = capture_mixers[adc_idx];
  3625. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3626. unsigned int i, idx;
  3627. idx = ucontrol->value.enumerated.item[0];
  3628. if (idx >= imux->num_items)
  3629. idx = imux->num_items - 1;
  3630. if (*cur_val == idx && ! codec->in_resume)
  3631. return 0;
  3632. for (i = 0; i < imux->num_items; i++) {
  3633. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3634. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3635. v | (imux->items[i].index << 8));
  3636. }
  3637. *cur_val = idx;
  3638. return 1;
  3639. }
  3640. /*
  3641. * 6ch mode
  3642. */
  3643. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3644. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3645. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3646. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3647. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3648. { } /* end */
  3649. };
  3650. /*
  3651. * 8ch mode
  3652. */
  3653. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3654. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3655. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3656. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3657. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3658. { } /* end */
  3659. };
  3660. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3661. { 6, alc882_sixstack_ch6_init },
  3662. { 8, alc882_sixstack_ch8_init },
  3663. };
  3664. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3665. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3666. */
  3667. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3668. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3669. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3670. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3671. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3672. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3673. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3674. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3675. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3676. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3677. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3678. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3679. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3680. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3681. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3682. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3683. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3684. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3685. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3686. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3687. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3688. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3689. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3690. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3691. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3692. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3693. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3694. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3695. {
  3696. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3697. /* .name = "Capture Source", */
  3698. .name = "Input Source",
  3699. .count = 3,
  3700. .info = alc882_mux_enum_info,
  3701. .get = alc882_mux_enum_get,
  3702. .put = alc882_mux_enum_put,
  3703. },
  3704. { } /* end */
  3705. };
  3706. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3707. {
  3708. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3709. .name = "Channel Mode",
  3710. .info = alc_ch_mode_info,
  3711. .get = alc_ch_mode_get,
  3712. .put = alc_ch_mode_put,
  3713. },
  3714. { } /* end */
  3715. };
  3716. static struct hda_verb alc882_init_verbs[] = {
  3717. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3718. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3719. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3720. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3721. /* Rear mixer */
  3722. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3723. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3724. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3725. /* CLFE mixer */
  3726. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3727. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3728. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3729. /* Side mixer */
  3730. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3731. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3732. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3733. /* Front Pin: output 0 (0x0c) */
  3734. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3735. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3736. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3737. /* Rear Pin: output 1 (0x0d) */
  3738. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3739. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3740. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3741. /* CLFE Pin: output 2 (0x0e) */
  3742. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3743. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3744. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3745. /* Side Pin: output 3 (0x0f) */
  3746. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3747. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3748. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3749. /* Mic (rear) pin: input vref at 80% */
  3750. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3751. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3752. /* Front Mic pin: input vref at 80% */
  3753. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3754. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3755. /* Line In pin: input */
  3756. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3757. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3758. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3759. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3760. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3761. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3762. /* CD pin widget for input */
  3763. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3764. /* FIXME: use matrix-type input source selection */
  3765. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3766. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3767. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3768. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3769. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3770. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3771. /* Input mixer2 */
  3772. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3773. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3774. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3775. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3776. /* Input mixer3 */
  3777. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3778. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3779. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3780. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3781. /* ADC1: mute amp left and right */
  3782. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3783. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3784. /* ADC2: mute amp left and right */
  3785. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3786. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3787. /* ADC3: mute amp left and right */
  3788. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3789. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3790. { }
  3791. };
  3792. /*
  3793. * generic initialization of ADC, input mixers and output mixers
  3794. */
  3795. static struct hda_verb alc882_auto_init_verbs[] = {
  3796. /*
  3797. * Unmute ADC0-2 and set the default input to mic-in
  3798. */
  3799. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3800. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3801. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3802. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3803. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3804. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3805. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3806. * mixer widget
  3807. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3808. * mic (mic 2)
  3809. */
  3810. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3811. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3812. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3813. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3814. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3815. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3816. /*
  3817. * Set up output mixers (0x0c - 0x0f)
  3818. */
  3819. /* set vol=0 to output mixers */
  3820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3821. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3822. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3823. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3824. /* set up input amps for analog loopback */
  3825. /* Amp Indices: DAC = 0, mixer = 1 */
  3826. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3827. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3828. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3829. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3830. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3831. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3832. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3833. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3834. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3835. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3836. /* FIXME: use matrix-type input source selection */
  3837. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3838. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3839. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3840. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3841. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3842. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3843. /* Input mixer2 */
  3844. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3845. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3846. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3847. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3848. /* Input mixer3 */
  3849. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3850. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3851. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3852. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3853. { }
  3854. };
  3855. /* capture mixer elements */
  3856. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3857. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3858. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3859. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3860. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3861. {
  3862. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3863. /* The multiple "Capture Source" controls confuse alsamixer
  3864. * So call somewhat different..
  3865. * FIXME: the controls appear in the "playback" view!
  3866. */
  3867. /* .name = "Capture Source", */
  3868. .name = "Input Source",
  3869. .count = 2,
  3870. .info = alc882_mux_enum_info,
  3871. .get = alc882_mux_enum_get,
  3872. .put = alc882_mux_enum_put,
  3873. },
  3874. { } /* end */
  3875. };
  3876. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3877. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3878. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3879. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3880. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3881. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3882. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3883. {
  3884. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3885. /* The multiple "Capture Source" controls confuse alsamixer
  3886. * So call somewhat different..
  3887. * FIXME: the controls appear in the "playback" view!
  3888. */
  3889. /* .name = "Capture Source", */
  3890. .name = "Input Source",
  3891. .count = 3,
  3892. .info = alc882_mux_enum_info,
  3893. .get = alc882_mux_enum_get,
  3894. .put = alc882_mux_enum_put,
  3895. },
  3896. { } /* end */
  3897. };
  3898. /* pcm configuration: identiacal with ALC880 */
  3899. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  3900. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  3901. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  3902. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  3903. /*
  3904. * configuration and preset
  3905. */
  3906. static struct hda_board_config alc882_cfg_tbl[] = {
  3907. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  3908. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  3909. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
  3910. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
  3911. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
  3912. { .modelname = "auto", .config = ALC882_AUTO },
  3913. {}
  3914. };
  3915. static struct alc_config_preset alc882_presets[] = {
  3916. [ALC882_3ST_DIG] = {
  3917. .mixers = { alc882_base_mixer },
  3918. .init_verbs = { alc882_init_verbs },
  3919. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3920. .dac_nids = alc882_dac_nids,
  3921. .dig_out_nid = ALC882_DIGOUT_NID,
  3922. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3923. .adc_nids = alc882_adc_nids,
  3924. .dig_in_nid = ALC882_DIGIN_NID,
  3925. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  3926. .channel_mode = alc882_ch_modes,
  3927. .input_mux = &alc882_capture_source,
  3928. },
  3929. [ALC882_6ST_DIG] = {
  3930. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  3931. .init_verbs = { alc882_init_verbs },
  3932. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3933. .dac_nids = alc882_dac_nids,
  3934. .dig_out_nid = ALC882_DIGOUT_NID,
  3935. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3936. .adc_nids = alc882_adc_nids,
  3937. .dig_in_nid = ALC882_DIGIN_NID,
  3938. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  3939. .channel_mode = alc882_sixstack_modes,
  3940. .input_mux = &alc882_capture_source,
  3941. },
  3942. };
  3943. /*
  3944. * BIOS auto configuration
  3945. */
  3946. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  3947. hda_nid_t nid, int pin_type,
  3948. int dac_idx)
  3949. {
  3950. /* set as output */
  3951. struct alc_spec *spec = codec->spec;
  3952. int idx;
  3953. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  3954. idx = 4;
  3955. else
  3956. idx = spec->multiout.dac_nids[dac_idx] - 2;
  3957. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3958. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3959. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  3960. }
  3961. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  3962. {
  3963. struct alc_spec *spec = codec->spec;
  3964. int i;
  3965. for (i = 0; i <= HDA_SIDE; i++) {
  3966. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3967. if (nid)
  3968. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  3969. }
  3970. }
  3971. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  3972. {
  3973. struct alc_spec *spec = codec->spec;
  3974. hda_nid_t pin;
  3975. pin = spec->autocfg.hp_pin;
  3976. if (pin) /* connect to front */
  3977. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  3978. }
  3979. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  3980. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  3981. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  3982. {
  3983. struct alc_spec *spec = codec->spec;
  3984. int i;
  3985. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3986. hda_nid_t nid = spec->autocfg.input_pins[i];
  3987. if (alc882_is_input_pin(nid)) {
  3988. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3989. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3990. if (nid != ALC882_PIN_CD_NID)
  3991. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3992. AMP_OUT_MUTE);
  3993. }
  3994. }
  3995. }
  3996. /* almost identical with ALC880 parser... */
  3997. static int alc882_parse_auto_config(struct hda_codec *codec)
  3998. {
  3999. struct alc_spec *spec = codec->spec;
  4000. int err = alc880_parse_auto_config(codec);
  4001. if (err < 0)
  4002. return err;
  4003. else if (err > 0)
  4004. /* hack - override the init verbs */
  4005. spec->init_verbs[0] = alc882_auto_init_verbs;
  4006. return err;
  4007. }
  4008. /* additional initialization for auto-configuration model */
  4009. static void alc882_auto_init(struct hda_codec *codec)
  4010. {
  4011. alc882_auto_init_multi_out(codec);
  4012. alc882_auto_init_hp_out(codec);
  4013. alc882_auto_init_analog_input(codec);
  4014. }
  4015. /*
  4016. * ALC882 Headphone poll in 3.5.1a or 3.5.2
  4017. */
  4018. static int patch_alc882(struct hda_codec *codec)
  4019. {
  4020. struct alc_spec *spec;
  4021. int err, board_config;
  4022. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4023. if (spec == NULL)
  4024. return -ENOMEM;
  4025. codec->spec = spec;
  4026. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  4027. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4028. printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
  4029. board_config = ALC882_AUTO;
  4030. }
  4031. if (board_config == ALC882_AUTO) {
  4032. /* automatic parse from the BIOS config */
  4033. err = alc882_parse_auto_config(codec);
  4034. if (err < 0) {
  4035. alc_free(codec);
  4036. return err;
  4037. } else if (! err) {
  4038. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4039. board_config = ALC882_3ST_DIG;
  4040. }
  4041. }
  4042. if (board_config != ALC882_AUTO)
  4043. setup_preset(spec, &alc882_presets[board_config]);
  4044. spec->stream_name_analog = "ALC882 Analog";
  4045. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4046. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4047. spec->stream_name_digital = "ALC882 Digital";
  4048. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4049. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4050. if (! spec->adc_nids && spec->input_mux) {
  4051. /* check whether NID 0x07 is valid */
  4052. unsigned int wcap = get_wcaps(codec, 0x07);
  4053. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4054. if (wcap != AC_WID_AUD_IN) {
  4055. spec->adc_nids = alc882_adc_nids_alt;
  4056. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4057. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4058. spec->num_mixers++;
  4059. } else {
  4060. spec->adc_nids = alc882_adc_nids;
  4061. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4062. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4063. spec->num_mixers++;
  4064. }
  4065. }
  4066. codec->patch_ops = alc_patch_ops;
  4067. if (board_config == ALC882_AUTO)
  4068. spec->init_hook = alc882_auto_init;
  4069. return 0;
  4070. }
  4071. /*
  4072. * ALC262 support
  4073. */
  4074. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  4075. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  4076. #define alc262_dac_nids alc260_dac_nids
  4077. #define alc262_adc_nids alc882_adc_nids
  4078. #define alc262_adc_nids_alt alc882_adc_nids_alt
  4079. #define alc262_modes alc260_modes
  4080. #define alc262_capture_source alc882_capture_source
  4081. static struct snd_kcontrol_new alc262_base_mixer[] = {
  4082. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4083. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4084. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4085. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4086. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4087. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4088. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4089. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4090. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4091. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4092. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4093. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  4094. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  4095. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4096. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4097. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4098. { } /* end */
  4099. };
  4100. #define alc262_capture_mixer alc882_capture_mixer
  4101. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  4102. /*
  4103. * generic initialization of ADC, input mixers and output mixers
  4104. */
  4105. static struct hda_verb alc262_init_verbs[] = {
  4106. /*
  4107. * Unmute ADC0-2 and set the default input to mic-in
  4108. */
  4109. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4110. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4111. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4112. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4113. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4114. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4115. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4116. * mixer widget
  4117. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4118. * mic (mic 2)
  4119. */
  4120. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4121. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4122. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4123. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4124. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4125. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4126. /*
  4127. * Set up output mixers (0x0c - 0x0e)
  4128. */
  4129. /* set vol=0 to output mixers */
  4130. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4131. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4132. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4133. /* set up input amps for analog loopback */
  4134. /* Amp Indices: DAC = 0, mixer = 1 */
  4135. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4136. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4137. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4138. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4139. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4140. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4141. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4142. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  4143. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  4144. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  4145. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4146. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  4147. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4148. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4149. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4150. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4151. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  4152. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4153. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4154. /* FIXME: use matrix-type input source selection */
  4155. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4156. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4157. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4158. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4159. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4160. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4161. /* Input mixer2 */
  4162. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4163. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4164. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4165. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4166. /* Input mixer3 */
  4167. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4168. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4169. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4170. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4171. { }
  4172. };
  4173. /*
  4174. * fujitsu model
  4175. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  4176. */
  4177. #define ALC_HP_EVENT 0x37
  4178. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  4179. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  4180. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4181. {}
  4182. };
  4183. static struct hda_input_mux alc262_fujitsu_capture_source = {
  4184. .num_items = 2,
  4185. .items = {
  4186. { "Mic", 0x0 },
  4187. { "CD", 0x4 },
  4188. },
  4189. };
  4190. /* mute/unmute internal speaker according to the hp jack and mute state */
  4191. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  4192. {
  4193. struct alc_spec *spec = codec->spec;
  4194. unsigned int mute;
  4195. if (force || ! spec->sense_updated) {
  4196. unsigned int present;
  4197. /* need to execute and sync at first */
  4198. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  4199. present = snd_hda_codec_read(codec, 0x14, 0,
  4200. AC_VERB_GET_PIN_SENSE, 0);
  4201. spec->jack_present = (present & 0x80000000) != 0;
  4202. spec->sense_updated = 1;
  4203. }
  4204. if (spec->jack_present) {
  4205. /* mute internal speaker */
  4206. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4207. 0x80, 0x80);
  4208. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4209. 0x80, 0x80);
  4210. } else {
  4211. /* unmute internal speaker if necessary */
  4212. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  4213. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4214. 0x80, mute & 0x80);
  4215. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  4216. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4217. 0x80, mute & 0x80);
  4218. }
  4219. }
  4220. /* unsolicited event for HP jack sensing */
  4221. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  4222. unsigned int res)
  4223. {
  4224. if ((res >> 26) != ALC_HP_EVENT)
  4225. return;
  4226. alc262_fujitsu_automute(codec, 1);
  4227. }
  4228. /* bind volumes of both NID 0x0c and 0x0d */
  4229. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  4230. struct snd_ctl_elem_value *ucontrol)
  4231. {
  4232. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4233. long *valp = ucontrol->value.integer.value;
  4234. int change;
  4235. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  4236. 0x7f, valp[0] & 0x7f);
  4237. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  4238. 0x7f, valp[1] & 0x7f);
  4239. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  4240. 0x7f, valp[0] & 0x7f);
  4241. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  4242. 0x7f, valp[1] & 0x7f);
  4243. return change;
  4244. }
  4245. /* bind hp and internal speaker mute (with plug check) */
  4246. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  4247. struct snd_ctl_elem_value *ucontrol)
  4248. {
  4249. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4250. long *valp = ucontrol->value.integer.value;
  4251. int change;
  4252. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  4253. 0x80, valp[0] ? 0 : 0x80);
  4254. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  4255. 0x80, valp[1] ? 0 : 0x80);
  4256. if (change || codec->in_resume)
  4257. alc262_fujitsu_automute(codec, codec->in_resume);
  4258. return change;
  4259. }
  4260. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  4261. {
  4262. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4263. .name = "Master Playback Volume",
  4264. .info = snd_hda_mixer_amp_volume_info,
  4265. .get = snd_hda_mixer_amp_volume_get,
  4266. .put = alc262_fujitsu_master_vol_put,
  4267. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  4268. },
  4269. {
  4270. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4271. .name = "Master Playback Switch",
  4272. .info = snd_hda_mixer_amp_switch_info,
  4273. .get = snd_hda_mixer_amp_switch_get,
  4274. .put = alc262_fujitsu_master_sw_put,
  4275. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  4276. },
  4277. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4278. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4279. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4280. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4281. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4282. { } /* end */
  4283. };
  4284. /* add playback controls from the parsed DAC table */
  4285. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4286. {
  4287. hda_nid_t nid;
  4288. int err;
  4289. spec->multiout.num_dacs = 1; /* only use one dac */
  4290. spec->multiout.dac_nids = spec->private_dac_nids;
  4291. spec->multiout.dac_nids[0] = 2;
  4292. nid = cfg->line_out_pins[0];
  4293. if (nid) {
  4294. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  4295. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  4296. return err;
  4297. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  4298. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4299. return err;
  4300. }
  4301. nid = cfg->speaker_pins[0];
  4302. if (nid) {
  4303. if (nid == 0x16) {
  4304. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  4305. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  4306. return err;
  4307. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  4308. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4309. return err;
  4310. } else {
  4311. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  4312. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4313. return err;
  4314. }
  4315. }
  4316. nid = cfg->hp_pin;
  4317. if (nid) {
  4318. /* spec->multiout.hp_nid = 2; */
  4319. if (nid == 0x16) {
  4320. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  4321. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  4322. return err;
  4323. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4324. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4325. return err;
  4326. } else {
  4327. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4328. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4329. return err;
  4330. }
  4331. }
  4332. return 0;
  4333. }
  4334. /* identical with ALC880 */
  4335. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  4336. /*
  4337. * generic initialization of ADC, input mixers and output mixers
  4338. */
  4339. static struct hda_verb alc262_volume_init_verbs[] = {
  4340. /*
  4341. * Unmute ADC0-2 and set the default input to mic-in
  4342. */
  4343. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4344. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4345. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4346. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4347. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4348. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4349. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4350. * mixer widget
  4351. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4352. * mic (mic 2)
  4353. */
  4354. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4355. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4356. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4357. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4358. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4359. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4360. /*
  4361. * Set up output mixers (0x0c - 0x0f)
  4362. */
  4363. /* set vol=0 to output mixers */
  4364. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4365. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4366. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4367. /* set up input amps for analog loopback */
  4368. /* Amp Indices: DAC = 0, mixer = 1 */
  4369. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4370. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4371. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4372. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4373. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4374. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4375. /* FIXME: use matrix-type input source selection */
  4376. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4377. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4378. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4379. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4380. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4381. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4382. /* Input mixer2 */
  4383. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4384. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4385. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4386. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4387. /* Input mixer3 */
  4388. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4389. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4390. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4391. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4392. { }
  4393. };
  4394. /* pcm configuration: identiacal with ALC880 */
  4395. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  4396. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  4397. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  4398. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  4399. /*
  4400. * BIOS auto configuration
  4401. */
  4402. static int alc262_parse_auto_config(struct hda_codec *codec)
  4403. {
  4404. struct alc_spec *spec = codec->spec;
  4405. int err;
  4406. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  4407. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4408. alc262_ignore)) < 0)
  4409. return err;
  4410. if (! spec->autocfg.line_outs)
  4411. return 0; /* can't find valid BIOS pin config */
  4412. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4413. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4414. return err;
  4415. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4416. if (spec->autocfg.dig_out_pin)
  4417. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  4418. if (spec->autocfg.dig_in_pin)
  4419. spec->dig_in_nid = ALC262_DIGIN_NID;
  4420. if (spec->kctl_alloc)
  4421. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4422. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  4423. spec->num_mux_defs = 1;
  4424. spec->input_mux = &spec->private_imux;
  4425. return 1;
  4426. }
  4427. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  4428. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  4429. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  4430. /* init callback for auto-configuration model -- overriding the default init */
  4431. static void alc262_auto_init(struct hda_codec *codec)
  4432. {
  4433. alc262_auto_init_multi_out(codec);
  4434. alc262_auto_init_hp_out(codec);
  4435. alc262_auto_init_analog_input(codec);
  4436. }
  4437. /*
  4438. * configuration and preset
  4439. */
  4440. static struct hda_board_config alc262_cfg_tbl[] = {
  4441. { .modelname = "basic", .config = ALC262_BASIC },
  4442. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  4443. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
  4444. { .modelname = "auto", .config = ALC262_AUTO },
  4445. {}
  4446. };
  4447. static struct alc_config_preset alc262_presets[] = {
  4448. [ALC262_BASIC] = {
  4449. .mixers = { alc262_base_mixer },
  4450. .init_verbs = { alc262_init_verbs },
  4451. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  4452. .dac_nids = alc262_dac_nids,
  4453. .hp_nid = 0x03,
  4454. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  4455. .channel_mode = alc262_modes,
  4456. .input_mux = &alc262_capture_source,
  4457. },
  4458. [ALC262_FUJITSU] = {
  4459. .mixers = { alc262_fujitsu_mixer },
  4460. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  4461. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  4462. .dac_nids = alc262_dac_nids,
  4463. .hp_nid = 0x03,
  4464. .dig_out_nid = ALC262_DIGOUT_NID,
  4465. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  4466. .channel_mode = alc262_modes,
  4467. .input_mux = &alc262_fujitsu_capture_source,
  4468. .unsol_event = alc262_fujitsu_unsol_event,
  4469. },
  4470. };
  4471. static int patch_alc262(struct hda_codec *codec)
  4472. {
  4473. struct alc_spec *spec;
  4474. int board_config;
  4475. int err;
  4476. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4477. if (spec == NULL)
  4478. return -ENOMEM;
  4479. codec->spec = spec;
  4480. #if 0
  4481. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  4482. {
  4483. int tmp;
  4484. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  4485. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  4486. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  4487. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  4488. }
  4489. #endif
  4490. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  4491. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  4492. printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
  4493. board_config = ALC262_AUTO;
  4494. }
  4495. if (board_config == ALC262_AUTO) {
  4496. /* automatic parse from the BIOS config */
  4497. err = alc262_parse_auto_config(codec);
  4498. if (err < 0) {
  4499. alc_free(codec);
  4500. return err;
  4501. } else if (! err) {
  4502. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4503. board_config = ALC262_BASIC;
  4504. }
  4505. }
  4506. if (board_config != ALC262_AUTO)
  4507. setup_preset(spec, &alc262_presets[board_config]);
  4508. spec->stream_name_analog = "ALC262 Analog";
  4509. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  4510. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  4511. spec->stream_name_digital = "ALC262 Digital";
  4512. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  4513. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  4514. if (! spec->adc_nids && spec->input_mux) {
  4515. /* check whether NID 0x07 is valid */
  4516. unsigned int wcap = get_wcaps(codec, 0x07);
  4517. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4518. if (wcap != AC_WID_AUD_IN) {
  4519. spec->adc_nids = alc262_adc_nids_alt;
  4520. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  4521. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  4522. spec->num_mixers++;
  4523. } else {
  4524. spec->adc_nids = alc262_adc_nids;
  4525. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  4526. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  4527. spec->num_mixers++;
  4528. }
  4529. }
  4530. codec->patch_ops = alc_patch_ops;
  4531. if (board_config == ALC262_AUTO)
  4532. spec->init_hook = alc262_auto_init;
  4533. return 0;
  4534. }
  4535. /*
  4536. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  4537. */
  4538. /*
  4539. * set the path ways for 2 channel output
  4540. * need to set the codec line out and mic 1 pin widgets to inputs
  4541. */
  4542. static struct hda_verb alc861_threestack_ch2_init[] = {
  4543. /* set pin widget 1Ah (line in) for input */
  4544. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4545. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  4546. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4547. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  4548. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
  4549. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
  4550. { } /* end */
  4551. };
  4552. /*
  4553. * 6ch mode
  4554. * need to set the codec line out and mic 1 pin widgets to outputs
  4555. */
  4556. static struct hda_verb alc861_threestack_ch6_init[] = {
  4557. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  4558. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4559. /* set pin widget 18h (mic1) for output (CLFE)*/
  4560. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4561. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4562. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4563. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  4564. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
  4565. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
  4566. { } /* end */
  4567. };
  4568. static struct hda_channel_mode alc861_threestack_modes[2] = {
  4569. { 2, alc861_threestack_ch2_init },
  4570. { 6, alc861_threestack_ch6_init },
  4571. };
  4572. /* patch-ALC861 */
  4573. static struct snd_kcontrol_new alc861_base_mixer[] = {
  4574. /* output mixer control */
  4575. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  4576. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  4577. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  4578. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  4579. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  4580. /*Input mixer control */
  4581. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  4582. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  4583. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  4584. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  4585. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  4586. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  4587. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  4588. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  4589. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  4590. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  4591. /* Capture mixer control */
  4592. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4593. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4594. {
  4595. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4596. .name = "Capture Source",
  4597. .count = 1,
  4598. .info = alc_mux_enum_info,
  4599. .get = alc_mux_enum_get,
  4600. .put = alc_mux_enum_put,
  4601. },
  4602. { } /* end */
  4603. };
  4604. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  4605. /* output mixer control */
  4606. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  4607. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  4608. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  4609. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  4610. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  4611. /* Input mixer control */
  4612. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  4613. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  4614. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  4615. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  4616. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  4617. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  4618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  4619. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  4620. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  4621. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  4622. /* Capture mixer control */
  4623. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4624. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4625. {
  4626. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4627. .name = "Capture Source",
  4628. .count = 1,
  4629. .info = alc_mux_enum_info,
  4630. .get = alc_mux_enum_get,
  4631. .put = alc_mux_enum_put,
  4632. },
  4633. {
  4634. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4635. .name = "Channel Mode",
  4636. .info = alc_ch_mode_info,
  4637. .get = alc_ch_mode_get,
  4638. .put = alc_ch_mode_put,
  4639. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  4640. },
  4641. { } /* end */
  4642. };
  4643. /*
  4644. * generic initialization of ADC, input mixers and output mixers
  4645. */
  4646. static struct hda_verb alc861_base_init_verbs[] = {
  4647. /*
  4648. * Unmute ADC0 and set the default input to mic-in
  4649. */
  4650. /* port-A for surround (rear panel) */
  4651. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4652. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4653. /* port-B for mic-in (rear panel) with vref */
  4654. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4655. /* port-C for line-in (rear panel) */
  4656. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4657. /* port-D for Front */
  4658. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4659. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4660. /* port-E for HP out (front panel) */
  4661. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4662. /* route front PCM to HP */
  4663. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4664. /* port-F for mic-in (front panel) with vref */
  4665. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4666. /* port-G for CLFE (rear panel) */
  4667. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4668. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4669. /* port-H for side (rear panel) */
  4670. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4671. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4672. /* CD-in */
  4673. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4674. /* route front mic to ADC1*/
  4675. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4677. /* Unmute DAC0~3 & spdif out*/
  4678. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4679. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4680. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4681. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4682. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4683. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4684. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4685. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4686. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4687. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4688. /* Unmute Stereo Mixer 15 */
  4689. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4690. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4691. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4692. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4693. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4694. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4695. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4696. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4697. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4698. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4699. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4700. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4701. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4702. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4703. { }
  4704. };
  4705. static struct hda_verb alc861_threestack_init_verbs[] = {
  4706. /*
  4707. * Unmute ADC0 and set the default input to mic-in
  4708. */
  4709. /* port-A for surround (rear panel) */
  4710. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4711. /* port-B for mic-in (rear panel) with vref */
  4712. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4713. /* port-C for line-in (rear panel) */
  4714. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4715. /* port-D for Front */
  4716. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4717. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4718. /* port-E for HP out (front panel) */
  4719. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4720. /* route front PCM to HP */
  4721. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4722. /* port-F for mic-in (front panel) with vref */
  4723. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4724. /* port-G for CLFE (rear panel) */
  4725. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4726. /* port-H for side (rear panel) */
  4727. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4728. /* CD-in */
  4729. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4730. /* route front mic to ADC1*/
  4731. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4732. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4733. /* Unmute DAC0~3 & spdif out*/
  4734. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4735. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4736. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4737. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4738. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4739. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4740. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4741. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4742. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4743. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4744. /* Unmute Stereo Mixer 15 */
  4745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4748. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4750. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4751. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4752. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4753. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4754. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4755. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4756. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4757. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4758. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4759. { }
  4760. };
  4761. /*
  4762. * generic initialization of ADC, input mixers and output mixers
  4763. */
  4764. static struct hda_verb alc861_auto_init_verbs[] = {
  4765. /*
  4766. * Unmute ADC0 and set the default input to mic-in
  4767. */
  4768. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4769. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4770. /* Unmute DAC0~3 & spdif out*/
  4771. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4772. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4773. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4774. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4775. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4776. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4777. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4778. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4779. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4780. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4781. /* Unmute Stereo Mixer 15 */
  4782. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4783. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4784. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4785. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  4786. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4787. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4788. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4789. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4790. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4791. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4792. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4793. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4794. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4795. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4796. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4797. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4798. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4799. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4800. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4801. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4802. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  4803. { }
  4804. };
  4805. /* pcm configuration: identiacal with ALC880 */
  4806. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  4807. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  4808. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  4809. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  4810. #define ALC861_DIGOUT_NID 0x07
  4811. static struct hda_channel_mode alc861_8ch_modes[1] = {
  4812. { 8, NULL }
  4813. };
  4814. static hda_nid_t alc861_dac_nids[4] = {
  4815. /* front, surround, clfe, side */
  4816. 0x03, 0x06, 0x05, 0x04
  4817. };
  4818. static hda_nid_t alc861_adc_nids[1] = {
  4819. /* ADC0-2 */
  4820. 0x08,
  4821. };
  4822. static struct hda_input_mux alc861_capture_source = {
  4823. .num_items = 5,
  4824. .items = {
  4825. { "Mic", 0x0 },
  4826. { "Front Mic", 0x3 },
  4827. { "Line", 0x1 },
  4828. { "CD", 0x4 },
  4829. { "Mixer", 0x5 },
  4830. },
  4831. };
  4832. /* fill in the dac_nids table from the parsed pin configuration */
  4833. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4834. {
  4835. int i;
  4836. hda_nid_t nid;
  4837. spec->multiout.dac_nids = spec->private_dac_nids;
  4838. for (i = 0; i < cfg->line_outs; i++) {
  4839. nid = cfg->line_out_pins[i];
  4840. if (nid) {
  4841. if (i >= ARRAY_SIZE(alc861_dac_nids))
  4842. continue;
  4843. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  4844. }
  4845. }
  4846. spec->multiout.num_dacs = cfg->line_outs;
  4847. return 0;
  4848. }
  4849. /* add playback controls from the parsed DAC table */
  4850. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  4851. const struct auto_pin_cfg *cfg)
  4852. {
  4853. char name[32];
  4854. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  4855. hda_nid_t nid;
  4856. int i, idx, err;
  4857. for (i = 0; i < cfg->line_outs; i++) {
  4858. nid = spec->multiout.dac_nids[i];
  4859. if (! nid)
  4860. continue;
  4861. if (nid == 0x05) {
  4862. /* Center/LFE */
  4863. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  4864. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  4865. return err;
  4866. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  4867. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4868. return err;
  4869. } else {
  4870. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  4871. if (nid == alc861_dac_nids[idx])
  4872. break;
  4873. sprintf(name, "%s Playback Switch", chname[idx]);
  4874. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  4875. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4876. return err;
  4877. }
  4878. }
  4879. return 0;
  4880. }
  4881. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  4882. {
  4883. int err;
  4884. hda_nid_t nid;
  4885. if (! pin)
  4886. return 0;
  4887. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  4888. nid = 0x03;
  4889. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4890. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4891. return err;
  4892. spec->multiout.hp_nid = nid;
  4893. }
  4894. return 0;
  4895. }
  4896. /* create playback/capture controls for input pins */
  4897. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4898. {
  4899. struct hda_input_mux *imux = &spec->private_imux;
  4900. int i, err, idx, idx1;
  4901. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4902. switch(cfg->input_pins[i]) {
  4903. case 0x0c:
  4904. idx1 = 1;
  4905. idx = 2; // Line In
  4906. break;
  4907. case 0x0f:
  4908. idx1 = 2;
  4909. idx = 2; // Line In
  4910. break;
  4911. case 0x0d:
  4912. idx1 = 0;
  4913. idx = 1; // Mic In
  4914. break;
  4915. case 0x10:
  4916. idx1 = 3;
  4917. idx = 1; // Mic In
  4918. break;
  4919. case 0x11:
  4920. idx1 = 4;
  4921. idx = 0; // CD
  4922. break;
  4923. default:
  4924. continue;
  4925. }
  4926. err = new_analog_input(spec, cfg->input_pins[i],
  4927. auto_pin_cfg_labels[i], idx, 0x15);
  4928. if (err < 0)
  4929. return err;
  4930. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  4931. imux->items[imux->num_items].index = idx1;
  4932. imux->num_items++;
  4933. }
  4934. return 0;
  4935. }
  4936. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  4937. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4938. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4939. {
  4940. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4941. /* The multiple "Capture Source" controls confuse alsamixer
  4942. * So call somewhat different..
  4943. *FIXME: the controls appear in the "playback" view!
  4944. */
  4945. /* .name = "Capture Source", */
  4946. .name = "Input Source",
  4947. .count = 1,
  4948. .info = alc_mux_enum_info,
  4949. .get = alc_mux_enum_get,
  4950. .put = alc_mux_enum_put,
  4951. },
  4952. { } /* end */
  4953. };
  4954. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  4955. int pin_type, int dac_idx)
  4956. {
  4957. /* set as output */
  4958. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4959. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4960. }
  4961. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  4962. {
  4963. struct alc_spec *spec = codec->spec;
  4964. int i;
  4965. for (i = 0; i < spec->autocfg.line_outs; i++) {
  4966. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4967. if (nid)
  4968. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  4969. }
  4970. }
  4971. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  4972. {
  4973. struct alc_spec *spec = codec->spec;
  4974. hda_nid_t pin;
  4975. pin = spec->autocfg.hp_pin;
  4976. if (pin) /* connect to front */
  4977. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  4978. }
  4979. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  4980. {
  4981. struct alc_spec *spec = codec->spec;
  4982. int i;
  4983. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4984. hda_nid_t nid = spec->autocfg.input_pins[i];
  4985. if ((nid>=0x0c) && (nid <=0x11)) {
  4986. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4987. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4988. }
  4989. }
  4990. }
  4991. /* parse the BIOS configuration and set up the alc_spec */
  4992. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  4993. static int alc861_parse_auto_config(struct hda_codec *codec)
  4994. {
  4995. struct alc_spec *spec = codec->spec;
  4996. int err;
  4997. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  4998. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4999. alc861_ignore)) < 0)
  5000. return err;
  5001. if (! spec->autocfg.line_outs)
  5002. return 0; /* can't find valid BIOS pin config */
  5003. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  5004. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5005. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  5006. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5007. return err;
  5008. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5009. if (spec->autocfg.dig_out_pin)
  5010. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  5011. if (spec->kctl_alloc)
  5012. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5013. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  5014. spec->num_mux_defs = 1;
  5015. spec->input_mux = &spec->private_imux;
  5016. spec->adc_nids = alc861_adc_nids;
  5017. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  5018. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  5019. spec->num_mixers++;
  5020. return 1;
  5021. }
  5022. /* additional initialization for auto-configuration model */
  5023. static void alc861_auto_init(struct hda_codec *codec)
  5024. {
  5025. alc861_auto_init_multi_out(codec);
  5026. alc861_auto_init_hp_out(codec);
  5027. alc861_auto_init_analog_input(codec);
  5028. }
  5029. /*
  5030. * configuration and preset
  5031. */
  5032. static struct hda_board_config alc861_cfg_tbl[] = {
  5033. { .modelname = "3stack", .config = ALC861_3ST },
  5034. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
  5035. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  5036. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  5037. { .modelname = "auto", .config = ALC861_AUTO },
  5038. {}
  5039. };
  5040. static struct alc_config_preset alc861_presets[] = {
  5041. [ALC861_3ST] = {
  5042. .mixers = { alc861_3ST_mixer },
  5043. .init_verbs = { alc861_threestack_init_verbs },
  5044. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  5045. .dac_nids = alc861_dac_nids,
  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_3ST_DIG] = {
  5053. .mixers = { alc861_base_mixer },
  5054. .init_verbs = { alc861_threestack_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_threestack_modes),
  5059. .channel_mode = alc861_threestack_modes,
  5060. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  5061. .adc_nids = alc861_adc_nids,
  5062. .input_mux = &alc861_capture_source,
  5063. },
  5064. [ALC861_6ST_DIG] = {
  5065. .mixers = { alc861_base_mixer },
  5066. .init_verbs = { alc861_base_init_verbs },
  5067. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  5068. .dac_nids = alc861_dac_nids,
  5069. .dig_out_nid = ALC861_DIGOUT_NID,
  5070. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  5071. .channel_mode = alc861_8ch_modes,
  5072. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  5073. .adc_nids = alc861_adc_nids,
  5074. .input_mux = &alc861_capture_source,
  5075. },
  5076. };
  5077. static int patch_alc861(struct hda_codec *codec)
  5078. {
  5079. struct alc_spec *spec;
  5080. int board_config;
  5081. int err;
  5082. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  5083. if (spec == NULL)
  5084. return -ENOMEM;
  5085. codec->spec = spec;
  5086. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  5087. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  5088. printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
  5089. board_config = ALC861_AUTO;
  5090. }
  5091. if (board_config == ALC861_AUTO) {
  5092. /* automatic parse from the BIOS config */
  5093. err = alc861_parse_auto_config(codec);
  5094. if (err < 0) {
  5095. alc_free(codec);
  5096. return err;
  5097. } else if (! err) {
  5098. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  5099. board_config = ALC861_3ST_DIG;
  5100. }
  5101. }
  5102. if (board_config != ALC861_AUTO)
  5103. setup_preset(spec, &alc861_presets[board_config]);
  5104. spec->stream_name_analog = "ALC861 Analog";
  5105. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  5106. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  5107. spec->stream_name_digital = "ALC861 Digital";
  5108. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  5109. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  5110. codec->patch_ops = alc_patch_ops;
  5111. if (board_config == ALC861_AUTO)
  5112. spec->init_hook = alc861_auto_init;
  5113. return 0;
  5114. }
  5115. /*
  5116. * patch entries
  5117. */
  5118. struct hda_codec_preset snd_hda_preset_realtek[] = {
  5119. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  5120. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  5121. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  5122. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  5123. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
  5124. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  5125. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  5126. {} /* terminator */
  5127. };