sm8150.c 211 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/clk.h>
  5. #include <linux/delay.h>
  6. #include <linux/gpio.h>
  7. #include <linux/of_gpio.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/slab.h>
  10. #include <linux/io.h>
  11. #include <linux/module.h>
  12. #include <linux/input.h>
  13. #include <linux/of_device.h>
  14. #include <linux/pm_qos.h>
  15. #include <linux/soc/qcom/fsa4480-i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/soc-dapm.h>
  19. #include <sound/pcm.h>
  20. #include <sound/pcm_params.h>
  21. #include <sound/info.h>
  22. #include <dsp/audio_notifier.h>
  23. #include <dsp/q6afe-v2.h>
  24. #include <dsp/q6core.h>
  25. #include "device_event.h"
  26. #include "msm-pcm-routing-v2.h"
  27. #include "codecs/msm-cdc-pinctrl.h"
  28. #include "codecs/wcd934x/wcd934x.h"
  29. #include "codecs/wcd934x/wcd934x-mbhc.h"
  30. #include "codecs/wcd9360/wcd9360.h"
  31. #include "codecs/wsa881x.h"
  32. #include "codecs/wcd-mbhc-v2.h"
  33. #define DRV_NAME "sm8150-asoc-snd"
  34. #define __CHIPSET__ "SM8150 "
  35. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  36. #define DEV_NAME_STR_LEN 32
  37. #define SAMPLING_RATE_8KHZ 8000
  38. #define SAMPLING_RATE_11P025KHZ 11025
  39. #define SAMPLING_RATE_16KHZ 16000
  40. #define SAMPLING_RATE_22P05KHZ 22050
  41. #define SAMPLING_RATE_32KHZ 32000
  42. #define SAMPLING_RATE_44P1KHZ 44100
  43. #define SAMPLING_RATE_48KHZ 48000
  44. #define SAMPLING_RATE_88P2KHZ 88200
  45. #define SAMPLING_RATE_96KHZ 96000
  46. #define SAMPLING_RATE_176P4KHZ 176400
  47. #define SAMPLING_RATE_192KHZ 192000
  48. #define SAMPLING_RATE_352P8KHZ 352800
  49. #define SAMPLING_RATE_384KHZ 384000
  50. #define WCD9XXX_MBHC_DEF_RLOADS 5
  51. #define WSA8810_NAME_1 "wsa881x.20170211"
  52. #define WSA8810_NAME_2 "wsa881x.20170212"
  53. #define WCN_CDC_SLIM_RX_CH_MAX 2
  54. #define WCN_CDC_SLIM_TX_CH_MAX 3
  55. #define TDM_CHANNEL_MAX 8
  56. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  57. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  58. #define MSM_HIFI_ON 1
  59. enum {
  60. SLIM_RX_0 = 0,
  61. SLIM_RX_1,
  62. SLIM_RX_2,
  63. SLIM_RX_3,
  64. SLIM_RX_4,
  65. SLIM_RX_5,
  66. SLIM_RX_6,
  67. SLIM_RX_7,
  68. SLIM_RX_MAX,
  69. };
  70. enum {
  71. SLIM_TX_0 = 0,
  72. SLIM_TX_1,
  73. SLIM_TX_2,
  74. SLIM_TX_3,
  75. SLIM_TX_4,
  76. SLIM_TX_5,
  77. SLIM_TX_6,
  78. SLIM_TX_7,
  79. SLIM_TX_8,
  80. SLIM_TX_MAX,
  81. };
  82. enum {
  83. PRIM_MI2S = 0,
  84. SEC_MI2S,
  85. TERT_MI2S,
  86. QUAT_MI2S,
  87. QUIN_MI2S,
  88. MI2S_MAX,
  89. };
  90. enum {
  91. PRIM_AUX_PCM = 0,
  92. SEC_AUX_PCM,
  93. TERT_AUX_PCM,
  94. QUAT_AUX_PCM,
  95. QUIN_AUX_PCM,
  96. AUX_PCM_MAX,
  97. };
  98. struct mi2s_conf {
  99. struct mutex lock;
  100. u32 ref_cnt;
  101. u32 msm_is_mi2s_master;
  102. };
  103. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  104. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  105. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  106. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  107. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT,
  108. Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT
  109. };
  110. struct dev_config {
  111. u32 sample_rate;
  112. u32 bit_format;
  113. u32 channels;
  114. };
  115. enum {
  116. DP_RX_IDX = 0,
  117. EXT_DISP_RX_IDX_MAX,
  118. };
  119. struct msm_wsa881x_dev_info {
  120. struct device_node *of_node;
  121. u32 index;
  122. };
  123. enum pinctrl_pin_state {
  124. STATE_DISABLE = 0, /* All pins are in sleep state */
  125. STATE_MI2S_ACTIVE, /* IS2 = active, TDM = sleep */
  126. STATE_TDM_ACTIVE, /* IS2 = sleep, TDM = active */
  127. };
  128. struct msm_pinctrl_info {
  129. struct pinctrl *pinctrl;
  130. struct pinctrl_state *mi2s_disable;
  131. struct pinctrl_state *tdm_disable;
  132. struct pinctrl_state *mi2s_active;
  133. struct pinctrl_state *tdm_active;
  134. enum pinctrl_pin_state curr_state;
  135. };
  136. struct msm_asoc_mach_data {
  137. struct snd_info_entry *codec_root;
  138. struct msm_pinctrl_info pinctrl_info;
  139. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  140. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  141. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  142. struct device_node *fsa_handle;
  143. struct snd_soc_codec *codec;
  144. struct work_struct adsp_power_up_work;
  145. };
  146. struct msm_asoc_wcd93xx_codec {
  147. void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
  148. enum afe_config_type config_type);
  149. };
  150. static const char *const pin_states[] = {"sleep", "i2s-active",
  151. "tdm-active"};
  152. enum {
  153. TDM_0 = 0,
  154. TDM_1,
  155. TDM_2,
  156. TDM_3,
  157. TDM_4,
  158. TDM_5,
  159. TDM_6,
  160. TDM_7,
  161. TDM_PORT_MAX,
  162. };
  163. enum {
  164. TDM_PRI = 0,
  165. TDM_SEC,
  166. TDM_TERT,
  167. TDM_QUAT,
  168. TDM_QUIN,
  169. TDM_INTERFACE_MAX,
  170. };
  171. struct tdm_port {
  172. u32 mode;
  173. u32 channel;
  174. };
  175. /* TDM default config */
  176. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  177. { /* PRI TDM */
  178. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  179. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  180. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  181. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  182. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  183. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  184. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  185. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  186. },
  187. { /* SEC TDM */
  188. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  189. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  190. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  191. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  192. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  193. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  194. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  195. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  196. },
  197. { /* TERT TDM */
  198. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  199. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  200. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  201. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  202. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  203. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  204. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  205. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  206. },
  207. { /* QUAT TDM */
  208. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  209. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  210. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  211. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  212. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  213. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  216. },
  217. { /* QUIN TDM */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  220. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  221. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  222. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  223. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  226. }
  227. };
  228. /* TDM default config */
  229. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  230. { /* PRI TDM */
  231. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  232. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  233. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  239. },
  240. { /* SEC TDM */
  241. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  242. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  243. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  249. },
  250. { /* TERT TDM */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  252. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  253. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  254. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  255. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  256. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  259. },
  260. { /* QUAT TDM */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  262. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  263. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  264. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  265. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  266. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  269. },
  270. { /* QUIN TDM */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  272. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  273. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  274. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  275. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  276. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  277. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  278. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  279. }
  280. };
  281. /* Default configuration of slimbus channels */
  282. static struct dev_config slim_rx_cfg[] = {
  283. [SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  284. [SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  285. [SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  286. [SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  287. [SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  288. [SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  289. [SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  290. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  291. };
  292. static struct dev_config slim_tx_cfg[] = {
  293. [SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  294. [SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  295. [SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  296. [SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  297. [SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  298. [SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  299. [SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  300. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  301. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  302. };
  303. /* Default configuration of external display BE */
  304. static struct dev_config ext_disp_rx_cfg[] = {
  305. [DP_RX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  306. };
  307. static struct dev_config usb_rx_cfg = {
  308. .sample_rate = SAMPLING_RATE_48KHZ,
  309. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  310. .channels = 2,
  311. };
  312. static struct dev_config usb_tx_cfg = {
  313. .sample_rate = SAMPLING_RATE_48KHZ,
  314. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  315. .channels = 1,
  316. };
  317. static struct dev_config proxy_rx_cfg = {
  318. .sample_rate = SAMPLING_RATE_48KHZ,
  319. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  320. .channels = 2,
  321. };
  322. /* Default configuration of MI2S channels */
  323. static struct dev_config mi2s_rx_cfg[] = {
  324. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  325. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  326. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  327. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  328. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  329. };
  330. static struct dev_config mi2s_tx_cfg[] = {
  331. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  332. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  333. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  334. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  335. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  336. };
  337. static struct dev_config aux_pcm_rx_cfg[] = {
  338. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  339. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  340. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  341. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  342. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  343. };
  344. static struct dev_config aux_pcm_tx_cfg[] = {
  345. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  346. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  347. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  348. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  349. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  350. };
  351. static int msm_vi_feed_tx_ch = 2;
  352. static const char *const slim_rx_ch_text[] = {"One", "Two"};
  353. static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
  354. "Five", "Six", "Seven",
  355. "Eight"};
  356. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  357. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  358. "S32_LE"};
  359. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  360. "S24_3LE"};
  361. static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  362. "KHZ_32", "KHZ_44P1", "KHZ_48",
  363. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  364. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  365. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  366. "KHZ_44P1", "KHZ_48",
  367. "KHZ_88P2", "KHZ_96"};
  368. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  369. "KHZ_44P1", "KHZ_48",
  370. "KHZ_88P2", "KHZ_96"};
  371. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  372. "KHZ_44P1", "KHZ_48",
  373. "KHZ_88P2", "KHZ_96"};
  374. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  375. "Five", "Six", "Seven",
  376. "Eight"};
  377. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  378. "Six", "Seven", "Eight"};
  379. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  380. "KHZ_16", "KHZ_22P05",
  381. "KHZ_32", "KHZ_44P1", "KHZ_48",
  382. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  383. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  384. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  385. "KHZ_192", "KHZ_32", "KHZ_44P1",
  386. "KHZ_88P2", "KHZ_176P4" };
  387. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  388. "Five", "Six", "Seven", "Eight"};
  389. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  390. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  391. "KHZ_48", "KHZ_176P4",
  392. "KHZ_352P8"};
  393. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  394. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  395. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  396. "KHZ_48", "KHZ_96", "KHZ_192"};
  397. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  398. "Five", "Six", "Seven",
  399. "Eight"};
  400. static const char *const hifi_text[] = {"Off", "On"};
  401. static const char *const qos_text[] = {"Disable", "Enable"};
  402. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
  403. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
  404. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
  405. static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
  406. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
  407. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
  408. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  409. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  410. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  411. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  412. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  413. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
  414. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
  415. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
  416. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
  417. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  418. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  419. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  420. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
  421. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
  422. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
  423. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
  424. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
  425. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  426. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  427. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  428. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  429. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  430. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  431. ext_disp_sample_rate_text);
  432. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  433. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  434. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  435. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  436. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  437. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  438. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  439. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  440. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  441. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  442. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  443. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  444. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  445. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  446. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  447. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  448. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  449. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  450. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  451. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  452. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  453. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  454. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  455. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  456. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  457. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  458. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  459. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  460. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  461. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  462. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  463. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  464. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  465. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  466. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  467. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  468. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  469. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  470. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  471. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  472. static SOC_ENUM_SINGLE_EXT_DECL(hifi_function, hifi_text);
  473. static struct platform_device *spdev;
  474. static int msm_hifi_control;
  475. static bool is_initial_boot;
  476. static bool codec_reg_done;
  477. static struct snd_soc_aux_dev *msm_aux_dev;
  478. static struct snd_soc_codec_conf *msm_codec_conf;
  479. static struct msm_asoc_wcd93xx_codec msm_codec_fn;
  480. static void *def_wcd_mbhc_cal(void);
  481. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
  482. int enable, bool dapm);
  483. static int msm_wsa881x_init(struct snd_soc_component *component);
  484. /*
  485. * Need to report LINEIN
  486. * if R/L channel impedance is larger than 5K ohm
  487. */
  488. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  489. .read_fw_bin = false,
  490. .calibration = NULL,
  491. .detect_extn_cable = true,
  492. .mono_stero_detection = false,
  493. .swap_gnd_mic = NULL,
  494. .hs_ext_micbias = true,
  495. .key_code[0] = KEY_MEDIA,
  496. .key_code[1] = KEY_VOICECOMMAND,
  497. .key_code[2] = KEY_VOLUMEUP,
  498. .key_code[3] = KEY_VOLUMEDOWN,
  499. .key_code[4] = 0,
  500. .key_code[5] = 0,
  501. .key_code[6] = 0,
  502. .key_code[7] = 0,
  503. .linein_th = 5000,
  504. .moisture_en = true,
  505. .mbhc_micbias = MIC_BIAS_2,
  506. .anc_micbias = MIC_BIAS_2,
  507. .enable_anc_mic_detect = false,
  508. };
  509. static struct snd_soc_dapm_route wcd_audio_paths[] = {
  510. {"MIC BIAS1", NULL, "MCLK TX"},
  511. {"MIC BIAS3", NULL, "MCLK TX"},
  512. {"MIC BIAS4", NULL, "MCLK TX"},
  513. };
  514. static struct snd_soc_dapm_route wcd_audio_paths_tavil[] = {
  515. {"MIC BIAS1", NULL, "MCLK TX"},
  516. {"MIC BIAS2", NULL, "MCLK TX"},
  517. {"MIC BIAS3", NULL, "MCLK TX"},
  518. {"MIC BIAS4", NULL, "MCLK TX"},
  519. };
  520. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  521. {
  522. AFE_API_VERSION_I2S_CONFIG,
  523. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  524. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  525. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  526. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  527. 0,
  528. },
  529. {
  530. AFE_API_VERSION_I2S_CONFIG,
  531. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  532. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  533. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  534. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  535. 0,
  536. },
  537. {
  538. AFE_API_VERSION_I2S_CONFIG,
  539. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  540. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  541. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  542. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  543. 0,
  544. },
  545. {
  546. AFE_API_VERSION_I2S_CONFIG,
  547. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  548. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  549. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  550. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  551. 0,
  552. },
  553. {
  554. AFE_API_VERSION_I2S_CONFIG,
  555. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  556. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  557. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  558. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  559. 0,
  560. }
  561. };
  562. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  563. static int slim_get_sample_rate_val(int sample_rate)
  564. {
  565. int sample_rate_val = 0;
  566. switch (sample_rate) {
  567. case SAMPLING_RATE_8KHZ:
  568. sample_rate_val = 0;
  569. break;
  570. case SAMPLING_RATE_16KHZ:
  571. sample_rate_val = 1;
  572. break;
  573. case SAMPLING_RATE_32KHZ:
  574. sample_rate_val = 2;
  575. break;
  576. case SAMPLING_RATE_44P1KHZ:
  577. sample_rate_val = 3;
  578. break;
  579. case SAMPLING_RATE_48KHZ:
  580. sample_rate_val = 4;
  581. break;
  582. case SAMPLING_RATE_88P2KHZ:
  583. sample_rate_val = 5;
  584. break;
  585. case SAMPLING_RATE_96KHZ:
  586. sample_rate_val = 6;
  587. break;
  588. case SAMPLING_RATE_176P4KHZ:
  589. sample_rate_val = 7;
  590. break;
  591. case SAMPLING_RATE_192KHZ:
  592. sample_rate_val = 8;
  593. break;
  594. case SAMPLING_RATE_352P8KHZ:
  595. sample_rate_val = 9;
  596. break;
  597. case SAMPLING_RATE_384KHZ:
  598. sample_rate_val = 10;
  599. break;
  600. default:
  601. sample_rate_val = 4;
  602. break;
  603. }
  604. return sample_rate_val;
  605. }
  606. static int slim_get_sample_rate(int value)
  607. {
  608. int sample_rate = 0;
  609. switch (value) {
  610. case 0:
  611. sample_rate = SAMPLING_RATE_8KHZ;
  612. break;
  613. case 1:
  614. sample_rate = SAMPLING_RATE_16KHZ;
  615. break;
  616. case 2:
  617. sample_rate = SAMPLING_RATE_32KHZ;
  618. break;
  619. case 3:
  620. sample_rate = SAMPLING_RATE_44P1KHZ;
  621. break;
  622. case 4:
  623. sample_rate = SAMPLING_RATE_48KHZ;
  624. break;
  625. case 5:
  626. sample_rate = SAMPLING_RATE_88P2KHZ;
  627. break;
  628. case 6:
  629. sample_rate = SAMPLING_RATE_96KHZ;
  630. break;
  631. case 7:
  632. sample_rate = SAMPLING_RATE_176P4KHZ;
  633. break;
  634. case 8:
  635. sample_rate = SAMPLING_RATE_192KHZ;
  636. break;
  637. case 9:
  638. sample_rate = SAMPLING_RATE_352P8KHZ;
  639. break;
  640. case 10:
  641. sample_rate = SAMPLING_RATE_384KHZ;
  642. break;
  643. default:
  644. sample_rate = SAMPLING_RATE_48KHZ;
  645. break;
  646. }
  647. return sample_rate;
  648. }
  649. static int slim_get_bit_format_val(int bit_format)
  650. {
  651. int val = 0;
  652. switch (bit_format) {
  653. case SNDRV_PCM_FORMAT_S32_LE:
  654. val = 3;
  655. break;
  656. case SNDRV_PCM_FORMAT_S24_3LE:
  657. val = 2;
  658. break;
  659. case SNDRV_PCM_FORMAT_S24_LE:
  660. val = 1;
  661. break;
  662. case SNDRV_PCM_FORMAT_S16_LE:
  663. default:
  664. val = 0;
  665. break;
  666. }
  667. return val;
  668. }
  669. static int slim_get_bit_format(int val)
  670. {
  671. int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  672. switch (val) {
  673. case 0:
  674. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  675. break;
  676. case 1:
  677. bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
  678. break;
  679. case 2:
  680. bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
  681. break;
  682. case 3:
  683. bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
  684. break;
  685. default:
  686. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  687. break;
  688. }
  689. return bit_fmt;
  690. }
  691. static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
  692. {
  693. int port_id = 0;
  694. if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX"))) {
  695. port_id = SLIM_RX_0;
  696. } else if (strnstr(kcontrol->id.name,
  697. "SLIM_2_RX", sizeof("SLIM_2_RX"))) {
  698. port_id = SLIM_RX_2;
  699. } else if (strnstr(kcontrol->id.name,
  700. "SLIM_5_RX", sizeof("SLIM_5_RX"))) {
  701. port_id = SLIM_RX_5;
  702. } else if (strnstr(kcontrol->id.name,
  703. "SLIM_6_RX", sizeof("SLIM_6_RX"))) {
  704. port_id = SLIM_RX_6;
  705. } else if (strnstr(kcontrol->id.name,
  706. "SLIM_0_TX", sizeof("SLIM_0_TX"))) {
  707. port_id = SLIM_TX_0;
  708. } else if (strnstr(kcontrol->id.name,
  709. "SLIM_1_TX", sizeof("SLIM_1_TX"))) {
  710. port_id = SLIM_TX_1;
  711. } else {
  712. pr_err("%s: unsupported channel: %s",
  713. __func__, kcontrol->id.name);
  714. return -EINVAL;
  715. }
  716. return port_id;
  717. }
  718. static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  719. struct snd_ctl_elem_value *ucontrol)
  720. {
  721. int ch_num = slim_get_port_idx(kcontrol);
  722. if (ch_num < 0)
  723. return ch_num;
  724. ucontrol->value.enumerated.item[0] =
  725. slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
  726. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  727. ch_num, slim_rx_cfg[ch_num].sample_rate,
  728. ucontrol->value.enumerated.item[0]);
  729. return 0;
  730. }
  731. static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  732. struct snd_ctl_elem_value *ucontrol)
  733. {
  734. int ch_num = slim_get_port_idx(kcontrol);
  735. if (ch_num < 0)
  736. return ch_num;
  737. slim_rx_cfg[ch_num].sample_rate =
  738. slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  739. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  740. ch_num, slim_rx_cfg[ch_num].sample_rate,
  741. ucontrol->value.enumerated.item[0]);
  742. return 0;
  743. }
  744. static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  745. struct snd_ctl_elem_value *ucontrol)
  746. {
  747. int ch_num = slim_get_port_idx(kcontrol);
  748. if (ch_num < 0)
  749. return ch_num;
  750. ucontrol->value.enumerated.item[0] =
  751. slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
  752. pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  753. ch_num, slim_tx_cfg[ch_num].sample_rate,
  754. ucontrol->value.enumerated.item[0]);
  755. return 0;
  756. }
  757. static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  758. struct snd_ctl_elem_value *ucontrol)
  759. {
  760. int sample_rate = 0;
  761. int ch_num = slim_get_port_idx(kcontrol);
  762. if (ch_num < 0)
  763. return ch_num;
  764. sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  765. if (sample_rate == SAMPLING_RATE_44P1KHZ) {
  766. pr_err("%s: Unsupported sample rate %d: for Tx path\n",
  767. __func__, sample_rate);
  768. return -EINVAL;
  769. }
  770. slim_tx_cfg[ch_num].sample_rate = sample_rate;
  771. pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
  772. ch_num, slim_tx_cfg[ch_num].sample_rate,
  773. ucontrol->value.enumerated.item[0]);
  774. return 0;
  775. }
  776. static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  777. struct snd_ctl_elem_value *ucontrol)
  778. {
  779. int ch_num = slim_get_port_idx(kcontrol);
  780. if (ch_num < 0)
  781. return ch_num;
  782. ucontrol->value.enumerated.item[0] =
  783. slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
  784. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  785. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  786. ucontrol->value.enumerated.item[0]);
  787. return 0;
  788. }
  789. static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  790. struct snd_ctl_elem_value *ucontrol)
  791. {
  792. int ch_num = slim_get_port_idx(kcontrol);
  793. if (ch_num < 0)
  794. return ch_num;
  795. slim_rx_cfg[ch_num].bit_format =
  796. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  797. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  798. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  799. ucontrol->value.enumerated.item[0]);
  800. return 0;
  801. }
  802. static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
  803. struct snd_ctl_elem_value *ucontrol)
  804. {
  805. int ch_num = slim_get_port_idx(kcontrol);
  806. if (ch_num < 0)
  807. return ch_num;
  808. ucontrol->value.enumerated.item[0] =
  809. slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
  810. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  811. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  812. ucontrol->value.enumerated.item[0]);
  813. return 0;
  814. }
  815. static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
  816. struct snd_ctl_elem_value *ucontrol)
  817. {
  818. int ch_num = slim_get_port_idx(kcontrol);
  819. if (ch_num < 0)
  820. return ch_num;
  821. slim_tx_cfg[ch_num].bit_format =
  822. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  823. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  824. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  825. ucontrol->value.enumerated.item[0]);
  826. return 0;
  827. }
  828. static int slim_rx_ch_get(struct snd_kcontrol *kcontrol,
  829. struct snd_ctl_elem_value *ucontrol)
  830. {
  831. int ch_num = slim_get_port_idx(kcontrol);
  832. if (ch_num < 0)
  833. return ch_num;
  834. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  835. ch_num, slim_rx_cfg[ch_num].channels);
  836. ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
  837. return 0;
  838. }
  839. static int slim_rx_ch_put(struct snd_kcontrol *kcontrol,
  840. struct snd_ctl_elem_value *ucontrol)
  841. {
  842. int ch_num = slim_get_port_idx(kcontrol);
  843. if (ch_num < 0)
  844. return ch_num;
  845. slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  846. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  847. ch_num, slim_rx_cfg[ch_num].channels);
  848. return 1;
  849. }
  850. static int slim_tx_ch_get(struct snd_kcontrol *kcontrol,
  851. struct snd_ctl_elem_value *ucontrol)
  852. {
  853. int ch_num = slim_get_port_idx(kcontrol);
  854. if (ch_num < 0)
  855. return ch_num;
  856. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  857. ch_num, slim_tx_cfg[ch_num].channels);
  858. ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
  859. return 0;
  860. }
  861. static int slim_tx_ch_put(struct snd_kcontrol *kcontrol,
  862. struct snd_ctl_elem_value *ucontrol)
  863. {
  864. int ch_num = slim_get_port_idx(kcontrol);
  865. if (ch_num < 0)
  866. return ch_num;
  867. slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  868. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  869. ch_num, slim_tx_cfg[ch_num].channels);
  870. return 1;
  871. }
  872. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  873. struct snd_ctl_elem_value *ucontrol)
  874. {
  875. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  876. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  877. ucontrol->value.integer.value[0]);
  878. return 0;
  879. }
  880. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  881. struct snd_ctl_elem_value *ucontrol)
  882. {
  883. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  884. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  885. return 1;
  886. }
  887. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  888. struct snd_ctl_elem_value *ucontrol)
  889. {
  890. /*
  891. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  892. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  893. * value.
  894. */
  895. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  896. case SAMPLING_RATE_96KHZ:
  897. ucontrol->value.integer.value[0] = 5;
  898. break;
  899. case SAMPLING_RATE_88P2KHZ:
  900. ucontrol->value.integer.value[0] = 4;
  901. break;
  902. case SAMPLING_RATE_48KHZ:
  903. ucontrol->value.integer.value[0] = 3;
  904. break;
  905. case SAMPLING_RATE_44P1KHZ:
  906. ucontrol->value.integer.value[0] = 2;
  907. break;
  908. case SAMPLING_RATE_16KHZ:
  909. ucontrol->value.integer.value[0] = 1;
  910. break;
  911. case SAMPLING_RATE_8KHZ:
  912. default:
  913. ucontrol->value.integer.value[0] = 0;
  914. break;
  915. }
  916. pr_debug("%s: sample rate = %d", __func__,
  917. slim_rx_cfg[SLIM_RX_7].sample_rate);
  918. return 0;
  919. }
  920. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  921. struct snd_ctl_elem_value *ucontrol)
  922. {
  923. switch (ucontrol->value.integer.value[0]) {
  924. case 1:
  925. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  926. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  927. break;
  928. case 2:
  929. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  930. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  931. break;
  932. case 3:
  933. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  934. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  935. break;
  936. case 4:
  937. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  938. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  939. break;
  940. case 5:
  941. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  942. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  943. break;
  944. case 0:
  945. default:
  946. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  947. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  948. break;
  949. }
  950. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  951. __func__,
  952. slim_rx_cfg[SLIM_RX_7].sample_rate,
  953. slim_tx_cfg[SLIM_TX_7].sample_rate,
  954. ucontrol->value.enumerated.item[0]);
  955. return 0;
  956. }
  957. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  958. struct snd_ctl_elem_value *ucontrol)
  959. {
  960. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  961. case SAMPLING_RATE_96KHZ:
  962. ucontrol->value.integer.value[0] = 5;
  963. break;
  964. case SAMPLING_RATE_88P2KHZ:
  965. ucontrol->value.integer.value[0] = 4;
  966. break;
  967. case SAMPLING_RATE_48KHZ:
  968. ucontrol->value.integer.value[0] = 3;
  969. break;
  970. case SAMPLING_RATE_44P1KHZ:
  971. ucontrol->value.integer.value[0] = 2;
  972. break;
  973. case SAMPLING_RATE_16KHZ:
  974. ucontrol->value.integer.value[0] = 1;
  975. break;
  976. case SAMPLING_RATE_8KHZ:
  977. default:
  978. ucontrol->value.integer.value[0] = 0;
  979. break;
  980. }
  981. pr_debug("%s: sample rate rx = %d", __func__,
  982. slim_rx_cfg[SLIM_RX_7].sample_rate);
  983. return 0;
  984. }
  985. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  986. struct snd_ctl_elem_value *ucontrol)
  987. {
  988. switch (ucontrol->value.integer.value[0]) {
  989. case 1:
  990. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  991. break;
  992. case 2:
  993. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  994. break;
  995. case 3:
  996. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  997. break;
  998. case 4:
  999. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1000. break;
  1001. case 5:
  1002. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1003. break;
  1004. case 0:
  1005. default:
  1006. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1007. break;
  1008. }
  1009. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  1010. __func__,
  1011. slim_rx_cfg[SLIM_RX_7].sample_rate,
  1012. ucontrol->value.enumerated.item[0]);
  1013. return 0;
  1014. }
  1015. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  1016. struct snd_ctl_elem_value *ucontrol)
  1017. {
  1018. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  1019. case SAMPLING_RATE_96KHZ:
  1020. ucontrol->value.integer.value[0] = 5;
  1021. break;
  1022. case SAMPLING_RATE_88P2KHZ:
  1023. ucontrol->value.integer.value[0] = 4;
  1024. break;
  1025. case SAMPLING_RATE_48KHZ:
  1026. ucontrol->value.integer.value[0] = 3;
  1027. break;
  1028. case SAMPLING_RATE_44P1KHZ:
  1029. ucontrol->value.integer.value[0] = 2;
  1030. break;
  1031. case SAMPLING_RATE_16KHZ:
  1032. ucontrol->value.integer.value[0] = 1;
  1033. break;
  1034. case SAMPLING_RATE_8KHZ:
  1035. default:
  1036. ucontrol->value.integer.value[0] = 0;
  1037. break;
  1038. }
  1039. pr_debug("%s: sample rate tx = %d", __func__,
  1040. slim_tx_cfg[SLIM_TX_7].sample_rate);
  1041. return 0;
  1042. }
  1043. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  1044. struct snd_ctl_elem_value *ucontrol)
  1045. {
  1046. switch (ucontrol->value.integer.value[0]) {
  1047. case 1:
  1048. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1049. break;
  1050. case 2:
  1051. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1052. break;
  1053. case 3:
  1054. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1055. break;
  1056. case 4:
  1057. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1058. break;
  1059. case 5:
  1060. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1061. break;
  1062. case 0:
  1063. default:
  1064. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1065. break;
  1066. }
  1067. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  1068. __func__,
  1069. slim_tx_cfg[SLIM_TX_7].sample_rate,
  1070. ucontrol->value.enumerated.item[0]);
  1071. return 0;
  1072. }
  1073. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1074. struct snd_ctl_elem_value *ucontrol)
  1075. {
  1076. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1077. usb_rx_cfg.channels);
  1078. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1079. return 0;
  1080. }
  1081. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1082. struct snd_ctl_elem_value *ucontrol)
  1083. {
  1084. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1085. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1086. return 1;
  1087. }
  1088. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1089. struct snd_ctl_elem_value *ucontrol)
  1090. {
  1091. int sample_rate_val;
  1092. switch (usb_rx_cfg.sample_rate) {
  1093. case SAMPLING_RATE_384KHZ:
  1094. sample_rate_val = 12;
  1095. break;
  1096. case SAMPLING_RATE_352P8KHZ:
  1097. sample_rate_val = 11;
  1098. break;
  1099. case SAMPLING_RATE_192KHZ:
  1100. sample_rate_val = 10;
  1101. break;
  1102. case SAMPLING_RATE_176P4KHZ:
  1103. sample_rate_val = 9;
  1104. break;
  1105. case SAMPLING_RATE_96KHZ:
  1106. sample_rate_val = 8;
  1107. break;
  1108. case SAMPLING_RATE_88P2KHZ:
  1109. sample_rate_val = 7;
  1110. break;
  1111. case SAMPLING_RATE_48KHZ:
  1112. sample_rate_val = 6;
  1113. break;
  1114. case SAMPLING_RATE_44P1KHZ:
  1115. sample_rate_val = 5;
  1116. break;
  1117. case SAMPLING_RATE_32KHZ:
  1118. sample_rate_val = 4;
  1119. break;
  1120. case SAMPLING_RATE_22P05KHZ:
  1121. sample_rate_val = 3;
  1122. break;
  1123. case SAMPLING_RATE_16KHZ:
  1124. sample_rate_val = 2;
  1125. break;
  1126. case SAMPLING_RATE_11P025KHZ:
  1127. sample_rate_val = 1;
  1128. break;
  1129. case SAMPLING_RATE_8KHZ:
  1130. default:
  1131. sample_rate_val = 0;
  1132. break;
  1133. }
  1134. ucontrol->value.integer.value[0] = sample_rate_val;
  1135. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  1136. usb_rx_cfg.sample_rate);
  1137. return 0;
  1138. }
  1139. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1140. struct snd_ctl_elem_value *ucontrol)
  1141. {
  1142. switch (ucontrol->value.integer.value[0]) {
  1143. case 12:
  1144. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1145. break;
  1146. case 11:
  1147. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1148. break;
  1149. case 10:
  1150. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1151. break;
  1152. case 9:
  1153. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1154. break;
  1155. case 8:
  1156. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1157. break;
  1158. case 7:
  1159. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1160. break;
  1161. case 6:
  1162. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1163. break;
  1164. case 5:
  1165. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1166. break;
  1167. case 4:
  1168. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1169. break;
  1170. case 3:
  1171. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1172. break;
  1173. case 2:
  1174. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1175. break;
  1176. case 1:
  1177. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1178. break;
  1179. case 0:
  1180. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1181. break;
  1182. default:
  1183. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1184. break;
  1185. }
  1186. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  1187. __func__, ucontrol->value.integer.value[0],
  1188. usb_rx_cfg.sample_rate);
  1189. return 0;
  1190. }
  1191. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1192. struct snd_ctl_elem_value *ucontrol)
  1193. {
  1194. switch (usb_rx_cfg.bit_format) {
  1195. case SNDRV_PCM_FORMAT_S32_LE:
  1196. ucontrol->value.integer.value[0] = 3;
  1197. break;
  1198. case SNDRV_PCM_FORMAT_S24_3LE:
  1199. ucontrol->value.integer.value[0] = 2;
  1200. break;
  1201. case SNDRV_PCM_FORMAT_S24_LE:
  1202. ucontrol->value.integer.value[0] = 1;
  1203. break;
  1204. case SNDRV_PCM_FORMAT_S16_LE:
  1205. default:
  1206. ucontrol->value.integer.value[0] = 0;
  1207. break;
  1208. }
  1209. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1210. __func__, usb_rx_cfg.bit_format,
  1211. ucontrol->value.integer.value[0]);
  1212. return 0;
  1213. }
  1214. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1215. struct snd_ctl_elem_value *ucontrol)
  1216. {
  1217. int rc = 0;
  1218. switch (ucontrol->value.integer.value[0]) {
  1219. case 3:
  1220. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1221. break;
  1222. case 2:
  1223. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1224. break;
  1225. case 1:
  1226. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1227. break;
  1228. case 0:
  1229. default:
  1230. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1231. break;
  1232. }
  1233. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1234. __func__, usb_rx_cfg.bit_format,
  1235. ucontrol->value.integer.value[0]);
  1236. return rc;
  1237. }
  1238. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1239. struct snd_ctl_elem_value *ucontrol)
  1240. {
  1241. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1242. usb_tx_cfg.channels);
  1243. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1244. return 0;
  1245. }
  1246. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1247. struct snd_ctl_elem_value *ucontrol)
  1248. {
  1249. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1250. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1251. return 1;
  1252. }
  1253. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1254. struct snd_ctl_elem_value *ucontrol)
  1255. {
  1256. int sample_rate_val;
  1257. switch (usb_tx_cfg.sample_rate) {
  1258. case SAMPLING_RATE_384KHZ:
  1259. sample_rate_val = 12;
  1260. break;
  1261. case SAMPLING_RATE_352P8KHZ:
  1262. sample_rate_val = 11;
  1263. break;
  1264. case SAMPLING_RATE_192KHZ:
  1265. sample_rate_val = 10;
  1266. break;
  1267. case SAMPLING_RATE_176P4KHZ:
  1268. sample_rate_val = 9;
  1269. break;
  1270. case SAMPLING_RATE_96KHZ:
  1271. sample_rate_val = 8;
  1272. break;
  1273. case SAMPLING_RATE_88P2KHZ:
  1274. sample_rate_val = 7;
  1275. break;
  1276. case SAMPLING_RATE_48KHZ:
  1277. sample_rate_val = 6;
  1278. break;
  1279. case SAMPLING_RATE_44P1KHZ:
  1280. sample_rate_val = 5;
  1281. break;
  1282. case SAMPLING_RATE_32KHZ:
  1283. sample_rate_val = 4;
  1284. break;
  1285. case SAMPLING_RATE_22P05KHZ:
  1286. sample_rate_val = 3;
  1287. break;
  1288. case SAMPLING_RATE_16KHZ:
  1289. sample_rate_val = 2;
  1290. break;
  1291. case SAMPLING_RATE_11P025KHZ:
  1292. sample_rate_val = 1;
  1293. break;
  1294. case SAMPLING_RATE_8KHZ:
  1295. sample_rate_val = 0;
  1296. break;
  1297. default:
  1298. sample_rate_val = 6;
  1299. break;
  1300. }
  1301. ucontrol->value.integer.value[0] = sample_rate_val;
  1302. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1303. usb_tx_cfg.sample_rate);
  1304. return 0;
  1305. }
  1306. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1307. struct snd_ctl_elem_value *ucontrol)
  1308. {
  1309. switch (ucontrol->value.integer.value[0]) {
  1310. case 12:
  1311. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1312. break;
  1313. case 11:
  1314. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1315. break;
  1316. case 10:
  1317. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1318. break;
  1319. case 9:
  1320. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1321. break;
  1322. case 8:
  1323. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1324. break;
  1325. case 7:
  1326. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1327. break;
  1328. case 6:
  1329. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1330. break;
  1331. case 5:
  1332. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1333. break;
  1334. case 4:
  1335. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1336. break;
  1337. case 3:
  1338. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1339. break;
  1340. case 2:
  1341. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1342. break;
  1343. case 1:
  1344. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1345. break;
  1346. case 0:
  1347. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1348. break;
  1349. default:
  1350. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1351. break;
  1352. }
  1353. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1354. __func__, ucontrol->value.integer.value[0],
  1355. usb_tx_cfg.sample_rate);
  1356. return 0;
  1357. }
  1358. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1359. struct snd_ctl_elem_value *ucontrol)
  1360. {
  1361. switch (usb_tx_cfg.bit_format) {
  1362. case SNDRV_PCM_FORMAT_S32_LE:
  1363. ucontrol->value.integer.value[0] = 3;
  1364. break;
  1365. case SNDRV_PCM_FORMAT_S24_3LE:
  1366. ucontrol->value.integer.value[0] = 2;
  1367. break;
  1368. case SNDRV_PCM_FORMAT_S24_LE:
  1369. ucontrol->value.integer.value[0] = 1;
  1370. break;
  1371. case SNDRV_PCM_FORMAT_S16_LE:
  1372. default:
  1373. ucontrol->value.integer.value[0] = 0;
  1374. break;
  1375. }
  1376. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1377. __func__, usb_tx_cfg.bit_format,
  1378. ucontrol->value.integer.value[0]);
  1379. return 0;
  1380. }
  1381. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1382. struct snd_ctl_elem_value *ucontrol)
  1383. {
  1384. int rc = 0;
  1385. switch (ucontrol->value.integer.value[0]) {
  1386. case 3:
  1387. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1388. break;
  1389. case 2:
  1390. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1391. break;
  1392. case 1:
  1393. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1394. break;
  1395. case 0:
  1396. default:
  1397. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1398. break;
  1399. }
  1400. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1401. __func__, usb_tx_cfg.bit_format,
  1402. ucontrol->value.integer.value[0]);
  1403. return rc;
  1404. }
  1405. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  1406. {
  1407. int idx;
  1408. if (strnstr(kcontrol->id.name, "Display Port RX",
  1409. sizeof("Display Port RX"))) {
  1410. idx = DP_RX_IDX;
  1411. } else {
  1412. pr_err("%s: unsupported BE: %s",
  1413. __func__, kcontrol->id.name);
  1414. idx = -EINVAL;
  1415. }
  1416. return idx;
  1417. }
  1418. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  1419. struct snd_ctl_elem_value *ucontrol)
  1420. {
  1421. int idx = ext_disp_get_port_idx(kcontrol);
  1422. if (idx < 0)
  1423. return idx;
  1424. switch (ext_disp_rx_cfg[idx].bit_format) {
  1425. case SNDRV_PCM_FORMAT_S24_3LE:
  1426. ucontrol->value.integer.value[0] = 2;
  1427. break;
  1428. case SNDRV_PCM_FORMAT_S24_LE:
  1429. ucontrol->value.integer.value[0] = 1;
  1430. break;
  1431. case SNDRV_PCM_FORMAT_S16_LE:
  1432. default:
  1433. ucontrol->value.integer.value[0] = 0;
  1434. break;
  1435. }
  1436. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1437. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1438. ucontrol->value.integer.value[0]);
  1439. return 0;
  1440. }
  1441. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  1442. struct snd_ctl_elem_value *ucontrol)
  1443. {
  1444. int idx = ext_disp_get_port_idx(kcontrol);
  1445. if (idx < 0)
  1446. return idx;
  1447. switch (ucontrol->value.integer.value[0]) {
  1448. case 2:
  1449. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1450. break;
  1451. case 1:
  1452. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1453. break;
  1454. case 0:
  1455. default:
  1456. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1457. break;
  1458. }
  1459. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1460. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1461. ucontrol->value.integer.value[0]);
  1462. return 0;
  1463. }
  1464. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  1465. struct snd_ctl_elem_value *ucontrol)
  1466. {
  1467. int idx = ext_disp_get_port_idx(kcontrol);
  1468. if (idx < 0)
  1469. return idx;
  1470. ucontrol->value.integer.value[0] =
  1471. ext_disp_rx_cfg[idx].channels - 2;
  1472. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1473. idx, ext_disp_rx_cfg[idx].channels);
  1474. return 0;
  1475. }
  1476. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  1477. struct snd_ctl_elem_value *ucontrol)
  1478. {
  1479. int idx = ext_disp_get_port_idx(kcontrol);
  1480. if (idx < 0)
  1481. return idx;
  1482. ext_disp_rx_cfg[idx].channels =
  1483. ucontrol->value.integer.value[0] + 2;
  1484. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1485. idx, ext_disp_rx_cfg[idx].channels);
  1486. return 1;
  1487. }
  1488. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1489. struct snd_ctl_elem_value *ucontrol)
  1490. {
  1491. int sample_rate_val;
  1492. int idx = ext_disp_get_port_idx(kcontrol);
  1493. if (idx < 0)
  1494. return idx;
  1495. switch (ext_disp_rx_cfg[idx].sample_rate) {
  1496. case SAMPLING_RATE_176P4KHZ:
  1497. sample_rate_val = 6;
  1498. break;
  1499. case SAMPLING_RATE_88P2KHZ:
  1500. sample_rate_val = 5;
  1501. break;
  1502. case SAMPLING_RATE_44P1KHZ:
  1503. sample_rate_val = 4;
  1504. break;
  1505. case SAMPLING_RATE_32KHZ:
  1506. sample_rate_val = 3;
  1507. break;
  1508. case SAMPLING_RATE_192KHZ:
  1509. sample_rate_val = 2;
  1510. break;
  1511. case SAMPLING_RATE_96KHZ:
  1512. sample_rate_val = 1;
  1513. break;
  1514. case SAMPLING_RATE_48KHZ:
  1515. default:
  1516. sample_rate_val = 0;
  1517. break;
  1518. }
  1519. ucontrol->value.integer.value[0] = sample_rate_val;
  1520. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  1521. idx, ext_disp_rx_cfg[idx].sample_rate);
  1522. return 0;
  1523. }
  1524. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1525. struct snd_ctl_elem_value *ucontrol)
  1526. {
  1527. int idx = ext_disp_get_port_idx(kcontrol);
  1528. if (idx < 0)
  1529. return idx;
  1530. switch (ucontrol->value.integer.value[0]) {
  1531. case 6:
  1532. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  1533. break;
  1534. case 5:
  1535. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  1536. break;
  1537. case 4:
  1538. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  1539. break;
  1540. case 3:
  1541. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  1542. break;
  1543. case 2:
  1544. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  1545. break;
  1546. case 1:
  1547. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  1548. break;
  1549. case 0:
  1550. default:
  1551. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  1552. break;
  1553. }
  1554. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  1555. __func__, ucontrol->value.integer.value[0], idx,
  1556. ext_disp_rx_cfg[idx].sample_rate);
  1557. return 0;
  1558. }
  1559. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1560. struct snd_ctl_elem_value *ucontrol)
  1561. {
  1562. pr_debug("%s: proxy_rx channels = %d\n",
  1563. __func__, proxy_rx_cfg.channels);
  1564. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1565. return 0;
  1566. }
  1567. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1568. struct snd_ctl_elem_value *ucontrol)
  1569. {
  1570. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1571. pr_debug("%s: proxy_rx channels = %d\n",
  1572. __func__, proxy_rx_cfg.channels);
  1573. return 1;
  1574. }
  1575. static int tdm_get_sample_rate(int value)
  1576. {
  1577. int sample_rate = 0;
  1578. switch (value) {
  1579. case 0:
  1580. sample_rate = SAMPLING_RATE_8KHZ;
  1581. break;
  1582. case 1:
  1583. sample_rate = SAMPLING_RATE_16KHZ;
  1584. break;
  1585. case 2:
  1586. sample_rate = SAMPLING_RATE_32KHZ;
  1587. break;
  1588. case 3:
  1589. sample_rate = SAMPLING_RATE_48KHZ;
  1590. break;
  1591. case 4:
  1592. sample_rate = SAMPLING_RATE_176P4KHZ;
  1593. break;
  1594. case 5:
  1595. sample_rate = SAMPLING_RATE_352P8KHZ;
  1596. break;
  1597. default:
  1598. sample_rate = SAMPLING_RATE_48KHZ;
  1599. break;
  1600. }
  1601. return sample_rate;
  1602. }
  1603. static int aux_pcm_get_sample_rate(int value)
  1604. {
  1605. int sample_rate;
  1606. switch (value) {
  1607. case 1:
  1608. sample_rate = SAMPLING_RATE_16KHZ;
  1609. break;
  1610. case 0:
  1611. default:
  1612. sample_rate = SAMPLING_RATE_8KHZ;
  1613. break;
  1614. }
  1615. return sample_rate;
  1616. }
  1617. static int tdm_get_sample_rate_val(int sample_rate)
  1618. {
  1619. int sample_rate_val = 0;
  1620. switch (sample_rate) {
  1621. case SAMPLING_RATE_8KHZ:
  1622. sample_rate_val = 0;
  1623. break;
  1624. case SAMPLING_RATE_16KHZ:
  1625. sample_rate_val = 1;
  1626. break;
  1627. case SAMPLING_RATE_32KHZ:
  1628. sample_rate_val = 2;
  1629. break;
  1630. case SAMPLING_RATE_48KHZ:
  1631. sample_rate_val = 3;
  1632. break;
  1633. case SAMPLING_RATE_176P4KHZ:
  1634. sample_rate_val = 4;
  1635. break;
  1636. case SAMPLING_RATE_352P8KHZ:
  1637. sample_rate_val = 5;
  1638. break;
  1639. default:
  1640. sample_rate_val = 3;
  1641. break;
  1642. }
  1643. return sample_rate_val;
  1644. }
  1645. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1646. {
  1647. int sample_rate_val;
  1648. switch (sample_rate) {
  1649. case SAMPLING_RATE_16KHZ:
  1650. sample_rate_val = 1;
  1651. break;
  1652. case SAMPLING_RATE_8KHZ:
  1653. default:
  1654. sample_rate_val = 0;
  1655. break;
  1656. }
  1657. return sample_rate_val;
  1658. }
  1659. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1660. struct tdm_port *port)
  1661. {
  1662. if (port) {
  1663. if (strnstr(kcontrol->id.name, "PRI",
  1664. sizeof(kcontrol->id.name))) {
  1665. port->mode = TDM_PRI;
  1666. } else if (strnstr(kcontrol->id.name, "SEC",
  1667. sizeof(kcontrol->id.name))) {
  1668. port->mode = TDM_SEC;
  1669. } else if (strnstr(kcontrol->id.name, "TERT",
  1670. sizeof(kcontrol->id.name))) {
  1671. port->mode = TDM_TERT;
  1672. } else if (strnstr(kcontrol->id.name, "QUAT",
  1673. sizeof(kcontrol->id.name))) {
  1674. port->mode = TDM_QUAT;
  1675. } else if (strnstr(kcontrol->id.name, "QUIN",
  1676. sizeof(kcontrol->id.name))) {
  1677. port->mode = TDM_QUIN;
  1678. } else {
  1679. pr_err("%s: unsupported mode in: %s",
  1680. __func__, kcontrol->id.name);
  1681. return -EINVAL;
  1682. }
  1683. if (strnstr(kcontrol->id.name, "RX_0",
  1684. sizeof(kcontrol->id.name)) ||
  1685. strnstr(kcontrol->id.name, "TX_0",
  1686. sizeof(kcontrol->id.name))) {
  1687. port->channel = TDM_0;
  1688. } else if (strnstr(kcontrol->id.name, "RX_1",
  1689. sizeof(kcontrol->id.name)) ||
  1690. strnstr(kcontrol->id.name, "TX_1",
  1691. sizeof(kcontrol->id.name))) {
  1692. port->channel = TDM_1;
  1693. } else if (strnstr(kcontrol->id.name, "RX_2",
  1694. sizeof(kcontrol->id.name)) ||
  1695. strnstr(kcontrol->id.name, "TX_2",
  1696. sizeof(kcontrol->id.name))) {
  1697. port->channel = TDM_2;
  1698. } else if (strnstr(kcontrol->id.name, "RX_3",
  1699. sizeof(kcontrol->id.name)) ||
  1700. strnstr(kcontrol->id.name, "TX_3",
  1701. sizeof(kcontrol->id.name))) {
  1702. port->channel = TDM_3;
  1703. } else if (strnstr(kcontrol->id.name, "RX_4",
  1704. sizeof(kcontrol->id.name)) ||
  1705. strnstr(kcontrol->id.name, "TX_4",
  1706. sizeof(kcontrol->id.name))) {
  1707. port->channel = TDM_4;
  1708. } else if (strnstr(kcontrol->id.name, "RX_5",
  1709. sizeof(kcontrol->id.name)) ||
  1710. strnstr(kcontrol->id.name, "TX_5",
  1711. sizeof(kcontrol->id.name))) {
  1712. port->channel = TDM_5;
  1713. } else if (strnstr(kcontrol->id.name, "RX_6",
  1714. sizeof(kcontrol->id.name)) ||
  1715. strnstr(kcontrol->id.name, "TX_6",
  1716. sizeof(kcontrol->id.name))) {
  1717. port->channel = TDM_6;
  1718. } else if (strnstr(kcontrol->id.name, "RX_7",
  1719. sizeof(kcontrol->id.name)) ||
  1720. strnstr(kcontrol->id.name, "TX_7",
  1721. sizeof(kcontrol->id.name))) {
  1722. port->channel = TDM_7;
  1723. } else {
  1724. pr_err("%s: unsupported channel in: %s",
  1725. __func__, kcontrol->id.name);
  1726. return -EINVAL;
  1727. }
  1728. } else
  1729. return -EINVAL;
  1730. return 0;
  1731. }
  1732. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1733. struct snd_ctl_elem_value *ucontrol)
  1734. {
  1735. struct tdm_port port;
  1736. int ret = tdm_get_port_idx(kcontrol, &port);
  1737. if (ret) {
  1738. pr_err("%s: unsupported control: %s",
  1739. __func__, kcontrol->id.name);
  1740. } else {
  1741. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1742. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1743. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1744. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1745. ucontrol->value.enumerated.item[0]);
  1746. }
  1747. return ret;
  1748. }
  1749. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1750. struct snd_ctl_elem_value *ucontrol)
  1751. {
  1752. struct tdm_port port;
  1753. int ret = tdm_get_port_idx(kcontrol, &port);
  1754. if (ret) {
  1755. pr_err("%s: unsupported control: %s",
  1756. __func__, kcontrol->id.name);
  1757. } else {
  1758. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1759. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1760. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1761. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1762. ucontrol->value.enumerated.item[0]);
  1763. }
  1764. return ret;
  1765. }
  1766. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1767. struct snd_ctl_elem_value *ucontrol)
  1768. {
  1769. struct tdm_port port;
  1770. int ret = tdm_get_port_idx(kcontrol, &port);
  1771. if (ret) {
  1772. pr_err("%s: unsupported control: %s",
  1773. __func__, kcontrol->id.name);
  1774. } else {
  1775. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1776. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1777. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1778. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1779. ucontrol->value.enumerated.item[0]);
  1780. }
  1781. return ret;
  1782. }
  1783. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1784. struct snd_ctl_elem_value *ucontrol)
  1785. {
  1786. struct tdm_port port;
  1787. int ret = tdm_get_port_idx(kcontrol, &port);
  1788. if (ret) {
  1789. pr_err("%s: unsupported control: %s",
  1790. __func__, kcontrol->id.name);
  1791. } else {
  1792. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1793. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1794. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1795. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1796. ucontrol->value.enumerated.item[0]);
  1797. }
  1798. return ret;
  1799. }
  1800. static int tdm_get_format(int value)
  1801. {
  1802. int format = 0;
  1803. switch (value) {
  1804. case 0:
  1805. format = SNDRV_PCM_FORMAT_S16_LE;
  1806. break;
  1807. case 1:
  1808. format = SNDRV_PCM_FORMAT_S24_LE;
  1809. break;
  1810. case 2:
  1811. format = SNDRV_PCM_FORMAT_S32_LE;
  1812. break;
  1813. default:
  1814. format = SNDRV_PCM_FORMAT_S16_LE;
  1815. break;
  1816. }
  1817. return format;
  1818. }
  1819. static int tdm_get_format_val(int format)
  1820. {
  1821. int value = 0;
  1822. switch (format) {
  1823. case SNDRV_PCM_FORMAT_S16_LE:
  1824. value = 0;
  1825. break;
  1826. case SNDRV_PCM_FORMAT_S24_LE:
  1827. value = 1;
  1828. break;
  1829. case SNDRV_PCM_FORMAT_S32_LE:
  1830. value = 2;
  1831. break;
  1832. default:
  1833. value = 0;
  1834. break;
  1835. }
  1836. return value;
  1837. }
  1838. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1839. struct snd_ctl_elem_value *ucontrol)
  1840. {
  1841. struct tdm_port port;
  1842. int ret = tdm_get_port_idx(kcontrol, &port);
  1843. if (ret) {
  1844. pr_err("%s: unsupported control: %s",
  1845. __func__, kcontrol->id.name);
  1846. } else {
  1847. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1848. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1849. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1850. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1851. ucontrol->value.enumerated.item[0]);
  1852. }
  1853. return ret;
  1854. }
  1855. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1856. struct snd_ctl_elem_value *ucontrol)
  1857. {
  1858. struct tdm_port port;
  1859. int ret = tdm_get_port_idx(kcontrol, &port);
  1860. if (ret) {
  1861. pr_err("%s: unsupported control: %s",
  1862. __func__, kcontrol->id.name);
  1863. } else {
  1864. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1865. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1866. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1867. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1868. ucontrol->value.enumerated.item[0]);
  1869. }
  1870. return ret;
  1871. }
  1872. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1873. struct snd_ctl_elem_value *ucontrol)
  1874. {
  1875. struct tdm_port port;
  1876. int ret = tdm_get_port_idx(kcontrol, &port);
  1877. if (ret) {
  1878. pr_err("%s: unsupported control: %s",
  1879. __func__, kcontrol->id.name);
  1880. } else {
  1881. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1882. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1883. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1884. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1885. ucontrol->value.enumerated.item[0]);
  1886. }
  1887. return ret;
  1888. }
  1889. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1890. struct snd_ctl_elem_value *ucontrol)
  1891. {
  1892. struct tdm_port port;
  1893. int ret = tdm_get_port_idx(kcontrol, &port);
  1894. if (ret) {
  1895. pr_err("%s: unsupported control: %s",
  1896. __func__, kcontrol->id.name);
  1897. } else {
  1898. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1899. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1900. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1901. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1902. ucontrol->value.enumerated.item[0]);
  1903. }
  1904. return ret;
  1905. }
  1906. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1907. struct snd_ctl_elem_value *ucontrol)
  1908. {
  1909. struct tdm_port port;
  1910. int ret = tdm_get_port_idx(kcontrol, &port);
  1911. if (ret) {
  1912. pr_err("%s: unsupported control: %s",
  1913. __func__, kcontrol->id.name);
  1914. } else {
  1915. ucontrol->value.enumerated.item[0] =
  1916. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1917. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1918. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1919. ucontrol->value.enumerated.item[0]);
  1920. }
  1921. return ret;
  1922. }
  1923. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1924. struct snd_ctl_elem_value *ucontrol)
  1925. {
  1926. struct tdm_port port;
  1927. int ret = tdm_get_port_idx(kcontrol, &port);
  1928. if (ret) {
  1929. pr_err("%s: unsupported control: %s",
  1930. __func__, kcontrol->id.name);
  1931. } else {
  1932. tdm_rx_cfg[port.mode][port.channel].channels =
  1933. ucontrol->value.enumerated.item[0] + 1;
  1934. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1935. tdm_rx_cfg[port.mode][port.channel].channels,
  1936. ucontrol->value.enumerated.item[0] + 1);
  1937. }
  1938. return ret;
  1939. }
  1940. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1941. struct snd_ctl_elem_value *ucontrol)
  1942. {
  1943. struct tdm_port port;
  1944. int ret = tdm_get_port_idx(kcontrol, &port);
  1945. if (ret) {
  1946. pr_err("%s: unsupported control: %s",
  1947. __func__, kcontrol->id.name);
  1948. } else {
  1949. ucontrol->value.enumerated.item[0] =
  1950. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1951. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1952. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1953. ucontrol->value.enumerated.item[0]);
  1954. }
  1955. return ret;
  1956. }
  1957. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1958. struct snd_ctl_elem_value *ucontrol)
  1959. {
  1960. struct tdm_port port;
  1961. int ret = tdm_get_port_idx(kcontrol, &port);
  1962. if (ret) {
  1963. pr_err("%s: unsupported control: %s",
  1964. __func__, kcontrol->id.name);
  1965. } else {
  1966. tdm_tx_cfg[port.mode][port.channel].channels =
  1967. ucontrol->value.enumerated.item[0] + 1;
  1968. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1969. tdm_tx_cfg[port.mode][port.channel].channels,
  1970. ucontrol->value.enumerated.item[0] + 1);
  1971. }
  1972. return ret;
  1973. }
  1974. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1975. {
  1976. int idx;
  1977. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1978. sizeof("PRIM_AUX_PCM")))
  1979. idx = PRIM_AUX_PCM;
  1980. else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1981. sizeof("SEC_AUX_PCM")))
  1982. idx = SEC_AUX_PCM;
  1983. else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1984. sizeof("TERT_AUX_PCM")))
  1985. idx = TERT_AUX_PCM;
  1986. else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  1987. sizeof("QUAT_AUX_PCM")))
  1988. idx = QUAT_AUX_PCM;
  1989. else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  1990. sizeof("QUIN_AUX_PCM")))
  1991. idx = QUIN_AUX_PCM;
  1992. else {
  1993. pr_err("%s: unsupported port: %s",
  1994. __func__, kcontrol->id.name);
  1995. idx = -EINVAL;
  1996. }
  1997. return idx;
  1998. }
  1999. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2000. struct snd_ctl_elem_value *ucontrol)
  2001. {
  2002. int idx = aux_pcm_get_port_idx(kcontrol);
  2003. if (idx < 0)
  2004. return idx;
  2005. aux_pcm_rx_cfg[idx].sample_rate =
  2006. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2007. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2008. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2009. ucontrol->value.enumerated.item[0]);
  2010. return 0;
  2011. }
  2012. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2013. struct snd_ctl_elem_value *ucontrol)
  2014. {
  2015. int idx = aux_pcm_get_port_idx(kcontrol);
  2016. if (idx < 0)
  2017. return idx;
  2018. ucontrol->value.enumerated.item[0] =
  2019. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  2020. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2021. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2022. ucontrol->value.enumerated.item[0]);
  2023. return 0;
  2024. }
  2025. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2026. struct snd_ctl_elem_value *ucontrol)
  2027. {
  2028. int idx = aux_pcm_get_port_idx(kcontrol);
  2029. if (idx < 0)
  2030. return idx;
  2031. aux_pcm_tx_cfg[idx].sample_rate =
  2032. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2033. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2034. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2035. ucontrol->value.enumerated.item[0]);
  2036. return 0;
  2037. }
  2038. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2039. struct snd_ctl_elem_value *ucontrol)
  2040. {
  2041. int idx = aux_pcm_get_port_idx(kcontrol);
  2042. if (idx < 0)
  2043. return idx;
  2044. ucontrol->value.enumerated.item[0] =
  2045. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  2046. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2047. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2048. ucontrol->value.enumerated.item[0]);
  2049. return 0;
  2050. }
  2051. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2052. {
  2053. int idx;
  2054. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2055. sizeof("PRIM_MI2S_RX")))
  2056. idx = PRIM_MI2S;
  2057. else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2058. sizeof("SEC_MI2S_RX")))
  2059. idx = SEC_MI2S;
  2060. else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2061. sizeof("TERT_MI2S_RX")))
  2062. idx = TERT_MI2S;
  2063. else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2064. sizeof("QUAT_MI2S_RX")))
  2065. idx = QUAT_MI2S;
  2066. else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2067. sizeof("QUIN_MI2S_RX")))
  2068. idx = QUIN_MI2S;
  2069. else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2070. sizeof("PRIM_MI2S_TX")))
  2071. idx = PRIM_MI2S;
  2072. else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2073. sizeof("SEC_MI2S_TX")))
  2074. idx = SEC_MI2S;
  2075. else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2076. sizeof("TERT_MI2S_TX")))
  2077. idx = TERT_MI2S;
  2078. else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2079. sizeof("QUAT_MI2S_TX")))
  2080. idx = QUAT_MI2S;
  2081. else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2082. sizeof("QUIN_MI2S_TX")))
  2083. idx = QUIN_MI2S;
  2084. else {
  2085. pr_err("%s: unsupported channel: %s",
  2086. __func__, kcontrol->id.name);
  2087. idx = -EINVAL;
  2088. }
  2089. return idx;
  2090. }
  2091. static int mi2s_get_sample_rate_val(int sample_rate)
  2092. {
  2093. int sample_rate_val;
  2094. switch (sample_rate) {
  2095. case SAMPLING_RATE_8KHZ:
  2096. sample_rate_val = 0;
  2097. break;
  2098. case SAMPLING_RATE_11P025KHZ:
  2099. sample_rate_val = 1;
  2100. break;
  2101. case SAMPLING_RATE_16KHZ:
  2102. sample_rate_val = 2;
  2103. break;
  2104. case SAMPLING_RATE_22P05KHZ:
  2105. sample_rate_val = 3;
  2106. break;
  2107. case SAMPLING_RATE_32KHZ:
  2108. sample_rate_val = 4;
  2109. break;
  2110. case SAMPLING_RATE_44P1KHZ:
  2111. sample_rate_val = 5;
  2112. break;
  2113. case SAMPLING_RATE_48KHZ:
  2114. sample_rate_val = 6;
  2115. break;
  2116. case SAMPLING_RATE_96KHZ:
  2117. sample_rate_val = 7;
  2118. break;
  2119. case SAMPLING_RATE_192KHZ:
  2120. sample_rate_val = 8;
  2121. break;
  2122. default:
  2123. sample_rate_val = 6;
  2124. break;
  2125. }
  2126. return sample_rate_val;
  2127. }
  2128. static int mi2s_get_sample_rate(int value)
  2129. {
  2130. int sample_rate;
  2131. switch (value) {
  2132. case 0:
  2133. sample_rate = SAMPLING_RATE_8KHZ;
  2134. break;
  2135. case 1:
  2136. sample_rate = SAMPLING_RATE_11P025KHZ;
  2137. break;
  2138. case 2:
  2139. sample_rate = SAMPLING_RATE_16KHZ;
  2140. break;
  2141. case 3:
  2142. sample_rate = SAMPLING_RATE_22P05KHZ;
  2143. break;
  2144. case 4:
  2145. sample_rate = SAMPLING_RATE_32KHZ;
  2146. break;
  2147. case 5:
  2148. sample_rate = SAMPLING_RATE_44P1KHZ;
  2149. break;
  2150. case 6:
  2151. sample_rate = SAMPLING_RATE_48KHZ;
  2152. break;
  2153. case 7:
  2154. sample_rate = SAMPLING_RATE_96KHZ;
  2155. break;
  2156. case 8:
  2157. sample_rate = SAMPLING_RATE_192KHZ;
  2158. break;
  2159. default:
  2160. sample_rate = SAMPLING_RATE_48KHZ;
  2161. break;
  2162. }
  2163. return sample_rate;
  2164. }
  2165. static int mi2s_auxpcm_get_format(int value)
  2166. {
  2167. int format;
  2168. switch (value) {
  2169. case 0:
  2170. format = SNDRV_PCM_FORMAT_S16_LE;
  2171. break;
  2172. case 1:
  2173. format = SNDRV_PCM_FORMAT_S24_LE;
  2174. break;
  2175. case 2:
  2176. format = SNDRV_PCM_FORMAT_S24_3LE;
  2177. break;
  2178. case 3:
  2179. format = SNDRV_PCM_FORMAT_S32_LE;
  2180. break;
  2181. default:
  2182. format = SNDRV_PCM_FORMAT_S16_LE;
  2183. break;
  2184. }
  2185. return format;
  2186. }
  2187. static int mi2s_auxpcm_get_format_value(int format)
  2188. {
  2189. int value;
  2190. switch (format) {
  2191. case SNDRV_PCM_FORMAT_S16_LE:
  2192. value = 0;
  2193. break;
  2194. case SNDRV_PCM_FORMAT_S24_LE:
  2195. value = 1;
  2196. break;
  2197. case SNDRV_PCM_FORMAT_S24_3LE:
  2198. value = 2;
  2199. break;
  2200. case SNDRV_PCM_FORMAT_S32_LE:
  2201. value = 3;
  2202. break;
  2203. default:
  2204. value = 0;
  2205. break;
  2206. }
  2207. return value;
  2208. }
  2209. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2210. struct snd_ctl_elem_value *ucontrol)
  2211. {
  2212. int idx = mi2s_get_port_idx(kcontrol);
  2213. if (idx < 0)
  2214. return idx;
  2215. mi2s_rx_cfg[idx].sample_rate =
  2216. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2217. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2218. idx, mi2s_rx_cfg[idx].sample_rate,
  2219. ucontrol->value.enumerated.item[0]);
  2220. return 0;
  2221. }
  2222. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2223. struct snd_ctl_elem_value *ucontrol)
  2224. {
  2225. int idx = mi2s_get_port_idx(kcontrol);
  2226. if (idx < 0)
  2227. return idx;
  2228. ucontrol->value.enumerated.item[0] =
  2229. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2230. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2231. idx, mi2s_rx_cfg[idx].sample_rate,
  2232. ucontrol->value.enumerated.item[0]);
  2233. return 0;
  2234. }
  2235. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2236. struct snd_ctl_elem_value *ucontrol)
  2237. {
  2238. int idx = mi2s_get_port_idx(kcontrol);
  2239. if (idx < 0)
  2240. return idx;
  2241. mi2s_tx_cfg[idx].sample_rate =
  2242. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2243. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2244. idx, mi2s_tx_cfg[idx].sample_rate,
  2245. ucontrol->value.enumerated.item[0]);
  2246. return 0;
  2247. }
  2248. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2249. struct snd_ctl_elem_value *ucontrol)
  2250. {
  2251. int idx = mi2s_get_port_idx(kcontrol);
  2252. if (idx < 0)
  2253. return idx;
  2254. ucontrol->value.enumerated.item[0] =
  2255. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2256. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2257. idx, mi2s_tx_cfg[idx].sample_rate,
  2258. ucontrol->value.enumerated.item[0]);
  2259. return 0;
  2260. }
  2261. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2262. struct snd_ctl_elem_value *ucontrol)
  2263. {
  2264. int idx = mi2s_get_port_idx(kcontrol);
  2265. if (idx < 0)
  2266. return idx;
  2267. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2268. idx, mi2s_rx_cfg[idx].channels);
  2269. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2270. return 0;
  2271. }
  2272. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2273. struct snd_ctl_elem_value *ucontrol)
  2274. {
  2275. int idx = mi2s_get_port_idx(kcontrol);
  2276. if (idx < 0)
  2277. return idx;
  2278. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2279. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2280. idx, mi2s_rx_cfg[idx].channels);
  2281. return 1;
  2282. }
  2283. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2284. struct snd_ctl_elem_value *ucontrol)
  2285. {
  2286. int idx = mi2s_get_port_idx(kcontrol);
  2287. if (idx < 0)
  2288. return idx;
  2289. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2290. idx, mi2s_tx_cfg[idx].channels);
  2291. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2292. return 0;
  2293. }
  2294. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2295. struct snd_ctl_elem_value *ucontrol)
  2296. {
  2297. int idx = mi2s_get_port_idx(kcontrol);
  2298. if (idx < 0)
  2299. return idx;
  2300. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2301. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2302. idx, mi2s_tx_cfg[idx].channels);
  2303. return 1;
  2304. }
  2305. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2306. struct snd_ctl_elem_value *ucontrol)
  2307. {
  2308. int idx = mi2s_get_port_idx(kcontrol);
  2309. if (idx < 0)
  2310. return idx;
  2311. ucontrol->value.enumerated.item[0] =
  2312. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2313. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2314. idx, mi2s_rx_cfg[idx].bit_format,
  2315. ucontrol->value.enumerated.item[0]);
  2316. return 0;
  2317. }
  2318. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2319. struct snd_ctl_elem_value *ucontrol)
  2320. {
  2321. int idx = mi2s_get_port_idx(kcontrol);
  2322. if (idx < 0)
  2323. return idx;
  2324. mi2s_rx_cfg[idx].bit_format =
  2325. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2326. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2327. idx, mi2s_rx_cfg[idx].bit_format,
  2328. ucontrol->value.enumerated.item[0]);
  2329. return 0;
  2330. }
  2331. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2332. struct snd_ctl_elem_value *ucontrol)
  2333. {
  2334. int idx = mi2s_get_port_idx(kcontrol);
  2335. if (idx < 0)
  2336. return idx;
  2337. ucontrol->value.enumerated.item[0] =
  2338. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2339. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2340. idx, mi2s_tx_cfg[idx].bit_format,
  2341. ucontrol->value.enumerated.item[0]);
  2342. return 0;
  2343. }
  2344. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2345. struct snd_ctl_elem_value *ucontrol)
  2346. {
  2347. int idx = mi2s_get_port_idx(kcontrol);
  2348. if (idx < 0)
  2349. return idx;
  2350. mi2s_tx_cfg[idx].bit_format =
  2351. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2352. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2353. idx, mi2s_tx_cfg[idx].bit_format,
  2354. ucontrol->value.enumerated.item[0]);
  2355. return 0;
  2356. }
  2357. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  2358. struct snd_ctl_elem_value *ucontrol)
  2359. {
  2360. int idx = aux_pcm_get_port_idx(kcontrol);
  2361. if (idx < 0)
  2362. return idx;
  2363. ucontrol->value.enumerated.item[0] =
  2364. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  2365. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2366. idx, aux_pcm_rx_cfg[idx].bit_format,
  2367. ucontrol->value.enumerated.item[0]);
  2368. return 0;
  2369. }
  2370. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  2371. struct snd_ctl_elem_value *ucontrol)
  2372. {
  2373. int idx = aux_pcm_get_port_idx(kcontrol);
  2374. if (idx < 0)
  2375. return idx;
  2376. aux_pcm_rx_cfg[idx].bit_format =
  2377. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2378. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2379. idx, aux_pcm_rx_cfg[idx].bit_format,
  2380. ucontrol->value.enumerated.item[0]);
  2381. return 0;
  2382. }
  2383. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  2384. struct snd_ctl_elem_value *ucontrol)
  2385. {
  2386. int idx = aux_pcm_get_port_idx(kcontrol);
  2387. if (idx < 0)
  2388. return idx;
  2389. ucontrol->value.enumerated.item[0] =
  2390. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  2391. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2392. idx, aux_pcm_tx_cfg[idx].bit_format,
  2393. ucontrol->value.enumerated.item[0]);
  2394. return 0;
  2395. }
  2396. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  2397. struct snd_ctl_elem_value *ucontrol)
  2398. {
  2399. int idx = aux_pcm_get_port_idx(kcontrol);
  2400. if (idx < 0)
  2401. return idx;
  2402. aux_pcm_tx_cfg[idx].bit_format =
  2403. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2404. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2405. idx, aux_pcm_tx_cfg[idx].bit_format,
  2406. ucontrol->value.enumerated.item[0]);
  2407. return 0;
  2408. }
  2409. static int msm_hifi_ctrl(struct snd_soc_codec *codec)
  2410. {
  2411. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  2412. struct snd_soc_card *card = codec->component.card;
  2413. struct msm_asoc_mach_data *pdata =
  2414. snd_soc_card_get_drvdata(card);
  2415. dev_dbg(codec->dev, "%s: msm_hifi_control = %d\n", __func__,
  2416. msm_hifi_control);
  2417. if (!pdata || !pdata->hph_en1_gpio_p) {
  2418. dev_err(codec->dev, "%s: hph_en1_gpio is invalid\n", __func__);
  2419. return -EINVAL;
  2420. }
  2421. if (msm_hifi_control == MSM_HIFI_ON) {
  2422. msm_cdc_pinctrl_select_active_state(pdata->hph_en1_gpio_p);
  2423. /* 5msec delay needed as per HW requirement */
  2424. usleep_range(5000, 5010);
  2425. } else {
  2426. msm_cdc_pinctrl_select_sleep_state(pdata->hph_en1_gpio_p);
  2427. }
  2428. snd_soc_dapm_sync(dapm);
  2429. return 0;
  2430. }
  2431. static int msm_hifi_get(struct snd_kcontrol *kcontrol,
  2432. struct snd_ctl_elem_value *ucontrol)
  2433. {
  2434. pr_debug("%s: msm_hifi_control = %d\n",
  2435. __func__, msm_hifi_control);
  2436. ucontrol->value.integer.value[0] = msm_hifi_control;
  2437. return 0;
  2438. }
  2439. static int msm_hifi_put(struct snd_kcontrol *kcontrol,
  2440. struct snd_ctl_elem_value *ucontrol)
  2441. {
  2442. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  2443. dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  2444. __func__, ucontrol->value.integer.value[0]);
  2445. msm_hifi_control = ucontrol->value.integer.value[0];
  2446. msm_hifi_ctrl(codec);
  2447. return 0;
  2448. }
  2449. static const struct snd_kcontrol_new msm_snd_controls[] = {
  2450. SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
  2451. slim_rx_ch_get, slim_rx_ch_put),
  2452. SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
  2453. slim_rx_ch_get, slim_rx_ch_put),
  2454. SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
  2455. slim_tx_ch_get, slim_tx_ch_put),
  2456. SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
  2457. slim_tx_ch_get, slim_tx_ch_put),
  2458. SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
  2459. slim_rx_ch_get, slim_rx_ch_put),
  2460. SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
  2461. slim_rx_ch_get, slim_rx_ch_put),
  2462. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  2463. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  2464. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  2465. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  2466. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  2467. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  2468. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  2469. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  2470. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  2471. proxy_rx_ch_get, proxy_rx_ch_put),
  2472. SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
  2473. slim_rx_bit_format_get, slim_rx_bit_format_put),
  2474. SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
  2475. slim_rx_bit_format_get, slim_rx_bit_format_put),
  2476. SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
  2477. slim_rx_bit_format_get, slim_rx_bit_format_put),
  2478. SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
  2479. slim_tx_bit_format_get, slim_tx_bit_format_put),
  2480. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  2481. usb_audio_rx_format_get, usb_audio_rx_format_put),
  2482. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  2483. usb_audio_tx_format_get, usb_audio_tx_format_put),
  2484. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  2485. ext_disp_rx_format_get, ext_disp_rx_format_put),
  2486. SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
  2487. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  2488. SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
  2489. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  2490. SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
  2491. slim_tx_sample_rate_get, slim_tx_sample_rate_put),
  2492. SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
  2493. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  2494. SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
  2495. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  2496. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  2497. msm_bt_sample_rate_get,
  2498. msm_bt_sample_rate_put),
  2499. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  2500. msm_bt_sample_rate_rx_get,
  2501. msm_bt_sample_rate_rx_put),
  2502. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  2503. msm_bt_sample_rate_tx_get,
  2504. msm_bt_sample_rate_tx_put),
  2505. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  2506. usb_audio_rx_sample_rate_get,
  2507. usb_audio_rx_sample_rate_put),
  2508. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  2509. usb_audio_tx_sample_rate_get,
  2510. usb_audio_tx_sample_rate_put),
  2511. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  2512. ext_disp_rx_sample_rate_get,
  2513. ext_disp_rx_sample_rate_put),
  2514. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2515. tdm_rx_sample_rate_get,
  2516. tdm_rx_sample_rate_put),
  2517. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2518. tdm_tx_sample_rate_get,
  2519. tdm_tx_sample_rate_put),
  2520. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  2521. tdm_rx_format_get,
  2522. tdm_rx_format_put),
  2523. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  2524. tdm_tx_format_get,
  2525. tdm_tx_format_put),
  2526. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  2527. tdm_rx_ch_get,
  2528. tdm_rx_ch_put),
  2529. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  2530. tdm_tx_ch_get,
  2531. tdm_tx_ch_put),
  2532. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2533. tdm_rx_sample_rate_get,
  2534. tdm_rx_sample_rate_put),
  2535. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2536. tdm_tx_sample_rate_get,
  2537. tdm_tx_sample_rate_put),
  2538. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  2539. tdm_rx_format_get,
  2540. tdm_rx_format_put),
  2541. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  2542. tdm_tx_format_get,
  2543. tdm_tx_format_put),
  2544. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  2545. tdm_rx_ch_get,
  2546. tdm_rx_ch_put),
  2547. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  2548. tdm_tx_ch_get,
  2549. tdm_tx_ch_put),
  2550. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2551. tdm_rx_sample_rate_get,
  2552. tdm_rx_sample_rate_put),
  2553. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2554. tdm_tx_sample_rate_get,
  2555. tdm_tx_sample_rate_put),
  2556. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  2557. tdm_rx_format_get,
  2558. tdm_rx_format_put),
  2559. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  2560. tdm_tx_format_get,
  2561. tdm_tx_format_put),
  2562. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  2563. tdm_rx_ch_get,
  2564. tdm_rx_ch_put),
  2565. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  2566. tdm_tx_ch_get,
  2567. tdm_tx_ch_put),
  2568. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2569. tdm_rx_sample_rate_get,
  2570. tdm_rx_sample_rate_put),
  2571. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2572. tdm_tx_sample_rate_get,
  2573. tdm_tx_sample_rate_put),
  2574. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  2575. tdm_rx_format_get,
  2576. tdm_rx_format_put),
  2577. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  2578. tdm_tx_format_get,
  2579. tdm_tx_format_put),
  2580. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  2581. tdm_rx_ch_get,
  2582. tdm_rx_ch_put),
  2583. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  2584. tdm_tx_ch_get,
  2585. tdm_tx_ch_put),
  2586. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2587. tdm_rx_sample_rate_get,
  2588. tdm_rx_sample_rate_put),
  2589. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2590. tdm_tx_sample_rate_get,
  2591. tdm_tx_sample_rate_put),
  2592. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  2593. tdm_rx_format_get,
  2594. tdm_rx_format_put),
  2595. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  2596. tdm_tx_format_get,
  2597. tdm_tx_format_put),
  2598. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  2599. tdm_rx_ch_get,
  2600. tdm_rx_ch_put),
  2601. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  2602. tdm_tx_ch_get,
  2603. tdm_tx_ch_put),
  2604. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2605. aux_pcm_rx_sample_rate_get,
  2606. aux_pcm_rx_sample_rate_put),
  2607. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  2608. aux_pcm_rx_sample_rate_get,
  2609. aux_pcm_rx_sample_rate_put),
  2610. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  2611. aux_pcm_rx_sample_rate_get,
  2612. aux_pcm_rx_sample_rate_put),
  2613. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  2614. aux_pcm_rx_sample_rate_get,
  2615. aux_pcm_rx_sample_rate_put),
  2616. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  2617. aux_pcm_rx_sample_rate_get,
  2618. aux_pcm_rx_sample_rate_put),
  2619. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2620. aux_pcm_tx_sample_rate_get,
  2621. aux_pcm_tx_sample_rate_put),
  2622. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  2623. aux_pcm_tx_sample_rate_get,
  2624. aux_pcm_tx_sample_rate_put),
  2625. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  2626. aux_pcm_tx_sample_rate_get,
  2627. aux_pcm_tx_sample_rate_put),
  2628. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  2629. aux_pcm_tx_sample_rate_get,
  2630. aux_pcm_tx_sample_rate_put),
  2631. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  2632. aux_pcm_tx_sample_rate_get,
  2633. aux_pcm_tx_sample_rate_put),
  2634. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  2635. mi2s_rx_sample_rate_get,
  2636. mi2s_rx_sample_rate_put),
  2637. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  2638. mi2s_rx_sample_rate_get,
  2639. mi2s_rx_sample_rate_put),
  2640. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  2641. mi2s_rx_sample_rate_get,
  2642. mi2s_rx_sample_rate_put),
  2643. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  2644. mi2s_rx_sample_rate_get,
  2645. mi2s_rx_sample_rate_put),
  2646. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  2647. mi2s_rx_sample_rate_get,
  2648. mi2s_rx_sample_rate_put),
  2649. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  2650. mi2s_tx_sample_rate_get,
  2651. mi2s_tx_sample_rate_put),
  2652. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  2653. mi2s_tx_sample_rate_get,
  2654. mi2s_tx_sample_rate_put),
  2655. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  2656. mi2s_tx_sample_rate_get,
  2657. mi2s_tx_sample_rate_put),
  2658. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  2659. mi2s_tx_sample_rate_get,
  2660. mi2s_tx_sample_rate_put),
  2661. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  2662. mi2s_tx_sample_rate_get,
  2663. mi2s_tx_sample_rate_put),
  2664. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  2665. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2666. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  2667. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2668. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  2669. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2670. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  2671. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2672. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  2673. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2674. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  2675. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2676. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  2677. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2678. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  2679. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2680. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  2681. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2682. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  2683. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2684. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  2685. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2686. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  2687. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2688. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  2689. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2690. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  2691. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2692. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  2693. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2694. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  2695. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2696. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  2697. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2698. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  2699. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2700. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  2701. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2702. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  2703. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2704. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2705. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2706. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2707. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2708. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  2709. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2710. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  2711. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2712. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  2713. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2714. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  2715. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2716. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  2717. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2718. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  2719. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2720. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  2721. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2722. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  2723. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2724. SOC_ENUM_EXT("HiFi Function", hifi_function, msm_hifi_get,
  2725. msm_hifi_put),
  2726. };
  2727. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
  2728. int enable, bool dapm)
  2729. {
  2730. int ret = 0;
  2731. if (!strcmp(dev_name(codec->dev), "pahu_codec")) {
  2732. ret = pahu_cdc_mclk_enable(codec, enable);
  2733. } else if (!strcmp(dev_name(codec->dev), "tavil_codec")) {
  2734. ret = tavil_cdc_mclk_enable(codec, enable);
  2735. } else {
  2736. dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
  2737. __func__);
  2738. ret = -EINVAL;
  2739. }
  2740. return ret;
  2741. }
  2742. static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_codec *codec,
  2743. int enable, bool dapm)
  2744. {
  2745. int ret = 0;
  2746. if (!strcmp(dev_name(codec->dev), "pahu_codec")) {
  2747. ret = pahu_cdc_mclk_tx_enable(codec, enable);
  2748. } else if (!strcmp(dev_name(codec->dev), "tavil_codec")) {
  2749. ret = tavil_cdc_mclk_tx_enable(codec, enable);
  2750. } else {
  2751. dev_err(codec->dev, "%s: unknown codec to enable TX ext clk\n",
  2752. __func__);
  2753. ret = -EINVAL;
  2754. }
  2755. return ret;
  2756. }
  2757. static int msm_mclk_tx_event(struct snd_soc_dapm_widget *w,
  2758. struct snd_kcontrol *kcontrol, int event)
  2759. {
  2760. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2761. pr_debug("%s: event = %d\n", __func__, event);
  2762. switch (event) {
  2763. case SND_SOC_DAPM_PRE_PMU:
  2764. return msm_snd_enable_codec_ext_tx_clk(codec, 1, true);
  2765. case SND_SOC_DAPM_POST_PMD:
  2766. return msm_snd_enable_codec_ext_tx_clk(codec, 0, true);
  2767. }
  2768. return 0;
  2769. }
  2770. static int msm_mclk_event(struct snd_soc_dapm_widget *w,
  2771. struct snd_kcontrol *kcontrol, int event)
  2772. {
  2773. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2774. pr_debug("%s: event = %d\n", __func__, event);
  2775. switch (event) {
  2776. case SND_SOC_DAPM_PRE_PMU:
  2777. return msm_snd_enable_codec_ext_clk(codec, 1, true);
  2778. case SND_SOC_DAPM_POST_PMD:
  2779. return msm_snd_enable_codec_ext_clk(codec, 0, true);
  2780. }
  2781. return 0;
  2782. }
  2783. static int msm_hifi_ctrl_event(struct snd_soc_dapm_widget *w,
  2784. struct snd_kcontrol *k, int event)
  2785. {
  2786. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  2787. struct snd_soc_card *card = codec->component.card;
  2788. struct msm_asoc_mach_data *pdata =
  2789. snd_soc_card_get_drvdata(card);
  2790. dev_dbg(codec->dev, "%s: msm_hifi_control = %d\n",
  2791. __func__, msm_hifi_control);
  2792. if (!pdata || !pdata->hph_en0_gpio_p) {
  2793. dev_err(codec->dev, "%s: hph_en0_gpio is invalid\n", __func__);
  2794. return -EINVAL;
  2795. }
  2796. if (msm_hifi_control != MSM_HIFI_ON) {
  2797. dev_dbg(codec->dev, "%s: HiFi mixer control is not set\n",
  2798. __func__);
  2799. return 0;
  2800. }
  2801. switch (event) {
  2802. case SND_SOC_DAPM_POST_PMU:
  2803. msm_cdc_pinctrl_select_active_state(pdata->hph_en0_gpio_p);
  2804. break;
  2805. case SND_SOC_DAPM_PRE_PMD:
  2806. msm_cdc_pinctrl_select_sleep_state(pdata->hph_en0_gpio_p);
  2807. break;
  2808. }
  2809. return 0;
  2810. }
  2811. static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
  2812. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  2813. msm_mclk_event,
  2814. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  2815. SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
  2816. msm_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  2817. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  2818. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  2819. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  2820. SND_SOC_DAPM_MIC("Digital Mic0", NULL),
  2821. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  2822. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  2823. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  2824. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  2825. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  2826. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  2827. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  2828. };
  2829. static const struct snd_soc_dapm_widget msm_dapm_widgets_tavil[] = {
  2830. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  2831. msm_mclk_event,
  2832. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  2833. SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
  2834. msm_mclk_tx_event,
  2835. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  2836. SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
  2837. SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
  2838. SND_SOC_DAPM_SPK("hifi amp", msm_hifi_ctrl_event),
  2839. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  2840. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  2841. SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
  2842. SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
  2843. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  2844. SND_SOC_DAPM_MIC("Digital Mic0", NULL),
  2845. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  2846. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  2847. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  2848. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  2849. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  2850. };
  2851. static inline int param_is_mask(int p)
  2852. {
  2853. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  2854. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  2855. }
  2856. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  2857. int n)
  2858. {
  2859. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  2860. }
  2861. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  2862. unsigned int bit)
  2863. {
  2864. if (bit >= SNDRV_MASK_MAX)
  2865. return;
  2866. if (param_is_mask(n)) {
  2867. struct snd_mask *m = param_to_mask(p, n);
  2868. m->bits[0] = 0;
  2869. m->bits[1] = 0;
  2870. m->bits[bit >> 5] |= (1 << (bit & 31));
  2871. }
  2872. }
  2873. static int msm_slim_get_ch_from_beid(int32_t be_id)
  2874. {
  2875. int ch_id = 0;
  2876. switch (be_id) {
  2877. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  2878. ch_id = SLIM_RX_0;
  2879. break;
  2880. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  2881. ch_id = SLIM_RX_1;
  2882. break;
  2883. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  2884. ch_id = SLIM_RX_2;
  2885. break;
  2886. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  2887. ch_id = SLIM_RX_3;
  2888. break;
  2889. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  2890. ch_id = SLIM_RX_4;
  2891. break;
  2892. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  2893. ch_id = SLIM_RX_6;
  2894. break;
  2895. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  2896. ch_id = SLIM_TX_0;
  2897. break;
  2898. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  2899. ch_id = SLIM_TX_3;
  2900. break;
  2901. default:
  2902. ch_id = SLIM_RX_0;
  2903. break;
  2904. }
  2905. return ch_id;
  2906. }
  2907. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  2908. {
  2909. int idx;
  2910. switch (be_id) {
  2911. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2912. idx = DP_RX_IDX;
  2913. break;
  2914. default:
  2915. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  2916. idx = -EINVAL;
  2917. break;
  2918. }
  2919. return idx;
  2920. }
  2921. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  2922. struct snd_pcm_hw_params *params)
  2923. {
  2924. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  2925. struct snd_interval *rate = hw_param_interval(params,
  2926. SNDRV_PCM_HW_PARAM_RATE);
  2927. struct snd_interval *channels = hw_param_interval(params,
  2928. SNDRV_PCM_HW_PARAM_CHANNELS);
  2929. int rc = 0;
  2930. int idx;
  2931. void *config = NULL;
  2932. struct snd_soc_codec *codec = NULL;
  2933. pr_debug("%s: format = %d, rate = %d\n",
  2934. __func__, params_format(params), params_rate(params));
  2935. switch (dai_link->id) {
  2936. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  2937. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  2938. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  2939. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  2940. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  2941. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  2942. idx = msm_slim_get_ch_from_beid(dai_link->id);
  2943. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2944. slim_rx_cfg[idx].bit_format);
  2945. rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
  2946. channels->min = channels->max = slim_rx_cfg[idx].channels;
  2947. break;
  2948. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  2949. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  2950. idx = msm_slim_get_ch_from_beid(dai_link->id);
  2951. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2952. slim_tx_cfg[idx].bit_format);
  2953. rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
  2954. channels->min = channels->max = slim_tx_cfg[idx].channels;
  2955. break;
  2956. case MSM_BACKEND_DAI_SLIMBUS_1_TX:
  2957. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2958. slim_tx_cfg[1].bit_format);
  2959. rate->min = rate->max = slim_tx_cfg[1].sample_rate;
  2960. channels->min = channels->max = slim_tx_cfg[1].channels;
  2961. break;
  2962. case MSM_BACKEND_DAI_SLIMBUS_4_TX:
  2963. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2964. SNDRV_PCM_FORMAT_S32_LE);
  2965. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  2966. channels->min = channels->max = msm_vi_feed_tx_ch;
  2967. break;
  2968. case MSM_BACKEND_DAI_SLIMBUS_5_RX:
  2969. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2970. slim_rx_cfg[5].bit_format);
  2971. rate->min = rate->max = slim_rx_cfg[5].sample_rate;
  2972. channels->min = channels->max = slim_rx_cfg[5].channels;
  2973. break;
  2974. case MSM_BACKEND_DAI_SLIMBUS_5_TX:
  2975. codec = rtd->codec;
  2976. rate->min = rate->max = SAMPLING_RATE_16KHZ;
  2977. channels->min = channels->max = 1;
  2978. config = msm_codec_fn.get_afe_config_fn(codec,
  2979. AFE_SLIMBUS_SLAVE_PORT_CONFIG);
  2980. if (config) {
  2981. rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
  2982. config, SLIMBUS_5_TX);
  2983. if (rc)
  2984. pr_err("%s: Failed to set slimbus slave port config %d\n",
  2985. __func__, rc);
  2986. }
  2987. break;
  2988. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  2989. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2990. slim_rx_cfg[SLIM_RX_7].bit_format);
  2991. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  2992. channels->min = channels->max =
  2993. slim_rx_cfg[SLIM_RX_7].channels;
  2994. break;
  2995. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  2996. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  2997. channels->min = channels->max =
  2998. slim_tx_cfg[SLIM_TX_7].channels;
  2999. break;
  3000. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  3001. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  3002. channels->min = channels->max =
  3003. slim_tx_cfg[SLIM_TX_8].channels;
  3004. break;
  3005. case MSM_BACKEND_DAI_USB_RX:
  3006. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3007. usb_rx_cfg.bit_format);
  3008. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3009. channels->min = channels->max = usb_rx_cfg.channels;
  3010. break;
  3011. case MSM_BACKEND_DAI_USB_TX:
  3012. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3013. usb_tx_cfg.bit_format);
  3014. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3015. channels->min = channels->max = usb_tx_cfg.channels;
  3016. break;
  3017. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3018. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3019. if (idx < 0) {
  3020. pr_err("%s: Incorrect ext disp idx %d\n",
  3021. __func__, idx);
  3022. rc = idx;
  3023. goto done;
  3024. }
  3025. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3026. ext_disp_rx_cfg[idx].bit_format);
  3027. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3028. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3029. break;
  3030. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3031. channels->min = channels->max = proxy_rx_cfg.channels;
  3032. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3033. break;
  3034. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3035. channels->min = channels->max =
  3036. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3037. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3038. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3039. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3040. break;
  3041. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3042. channels->min = channels->max =
  3043. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3044. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3045. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3046. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3047. break;
  3048. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3049. channels->min = channels->max =
  3050. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3051. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3052. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3053. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3054. break;
  3055. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3056. channels->min = channels->max =
  3057. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3058. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3059. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3060. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3061. break;
  3062. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3063. channels->min = channels->max =
  3064. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3065. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3066. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3067. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3068. break;
  3069. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3070. channels->min = channels->max =
  3071. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3072. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3073. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3074. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3075. break;
  3076. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3077. channels->min = channels->max =
  3078. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3079. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3080. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3081. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3082. break;
  3083. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3084. channels->min = channels->max =
  3085. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3086. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3087. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3088. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3089. break;
  3090. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3091. channels->min = channels->max =
  3092. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3093. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3094. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3095. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3096. break;
  3097. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3098. channels->min = channels->max =
  3099. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3100. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3101. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3102. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3103. break;
  3104. case MSM_BACKEND_DAI_AUXPCM_RX:
  3105. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3106. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3107. rate->min = rate->max =
  3108. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3109. channels->min = channels->max =
  3110. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3111. break;
  3112. case MSM_BACKEND_DAI_AUXPCM_TX:
  3113. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3114. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3115. rate->min = rate->max =
  3116. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3117. channels->min = channels->max =
  3118. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3119. break;
  3120. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3121. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3122. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3123. rate->min = rate->max =
  3124. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3125. channels->min = channels->max =
  3126. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3127. break;
  3128. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3129. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3130. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3131. rate->min = rate->max =
  3132. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3133. channels->min = channels->max =
  3134. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3135. break;
  3136. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3137. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3138. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3139. rate->min = rate->max =
  3140. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3141. channels->min = channels->max =
  3142. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3143. break;
  3144. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3145. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3146. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3147. rate->min = rate->max =
  3148. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  3149. channels->min = channels->max =
  3150. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  3151. break;
  3152. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  3153. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3154. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  3155. rate->min = rate->max =
  3156. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  3157. channels->min = channels->max =
  3158. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  3159. break;
  3160. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  3161. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3162. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  3163. rate->min = rate->max =
  3164. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  3165. channels->min = channels->max =
  3166. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  3167. break;
  3168. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  3169. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3170. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  3171. rate->min = rate->max =
  3172. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  3173. channels->min = channels->max =
  3174. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  3175. break;
  3176. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  3177. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3178. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  3179. rate->min = rate->max =
  3180. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  3181. channels->min = channels->max =
  3182. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  3183. break;
  3184. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  3185. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3186. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  3187. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  3188. channels->min = channels->max =
  3189. mi2s_rx_cfg[PRIM_MI2S].channels;
  3190. break;
  3191. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  3192. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3193. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  3194. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  3195. channels->min = channels->max =
  3196. mi2s_tx_cfg[PRIM_MI2S].channels;
  3197. break;
  3198. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  3199. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3200. mi2s_rx_cfg[SEC_MI2S].bit_format);
  3201. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  3202. channels->min = channels->max =
  3203. mi2s_rx_cfg[SEC_MI2S].channels;
  3204. break;
  3205. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  3206. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3207. mi2s_tx_cfg[SEC_MI2S].bit_format);
  3208. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  3209. channels->min = channels->max =
  3210. mi2s_tx_cfg[SEC_MI2S].channels;
  3211. break;
  3212. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  3213. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3214. mi2s_rx_cfg[TERT_MI2S].bit_format);
  3215. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  3216. channels->min = channels->max =
  3217. mi2s_rx_cfg[TERT_MI2S].channels;
  3218. break;
  3219. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  3220. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3221. mi2s_tx_cfg[TERT_MI2S].bit_format);
  3222. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  3223. channels->min = channels->max =
  3224. mi2s_tx_cfg[TERT_MI2S].channels;
  3225. break;
  3226. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  3227. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3228. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  3229. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  3230. channels->min = channels->max =
  3231. mi2s_rx_cfg[QUAT_MI2S].channels;
  3232. break;
  3233. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  3234. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3235. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  3236. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  3237. channels->min = channels->max =
  3238. mi2s_tx_cfg[QUAT_MI2S].channels;
  3239. break;
  3240. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  3241. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3242. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  3243. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  3244. channels->min = channels->max =
  3245. mi2s_rx_cfg[QUIN_MI2S].channels;
  3246. break;
  3247. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  3248. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3249. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  3250. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  3251. channels->min = channels->max =
  3252. mi2s_tx_cfg[QUIN_MI2S].channels;
  3253. break;
  3254. default:
  3255. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3256. break;
  3257. }
  3258. done:
  3259. return rc;
  3260. }
  3261. static bool msm_usbc_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
  3262. {
  3263. struct snd_soc_card *card = codec->component.card;
  3264. struct msm_asoc_mach_data *pdata =
  3265. snd_soc_card_get_drvdata(card);
  3266. if (!pdata->fsa_handle)
  3267. return false;
  3268. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  3269. }
  3270. static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
  3271. {
  3272. int value = 0;
  3273. bool ret = false;
  3274. struct snd_soc_card *card;
  3275. struct msm_asoc_mach_data *pdata;
  3276. if (!codec) {
  3277. pr_err("%s codec is NULL\n", __func__);
  3278. return false;
  3279. }
  3280. card = codec->component.card;
  3281. pdata = snd_soc_card_get_drvdata(card);
  3282. if (!pdata)
  3283. return false;
  3284. if (wcd_mbhc_cfg.enable_usbc_analog)
  3285. return msm_usbc_swap_gnd_mic(codec, active);
  3286. /* if usbc is not defined, swap using us_euro_gpio_p */
  3287. if (pdata->us_euro_gpio_p) {
  3288. value = msm_cdc_pinctrl_get_state(
  3289. pdata->us_euro_gpio_p);
  3290. if (value)
  3291. msm_cdc_pinctrl_select_sleep_state(
  3292. pdata->us_euro_gpio_p);
  3293. else
  3294. msm_cdc_pinctrl_select_active_state(
  3295. pdata->us_euro_gpio_p);
  3296. dev_dbg(codec->dev, "%s: swap select switch %d to %d\n",
  3297. __func__, value, !value);
  3298. ret = true;
  3299. }
  3300. return ret;
  3301. }
  3302. static int msm_afe_set_config(struct snd_soc_codec *codec)
  3303. {
  3304. int ret = 0;
  3305. void *config_data = NULL;
  3306. if (!msm_codec_fn.get_afe_config_fn) {
  3307. dev_err(codec->dev, "%s: codec get afe config not init'ed\n",
  3308. __func__);
  3309. return -EINVAL;
  3310. }
  3311. config_data = msm_codec_fn.get_afe_config_fn(codec,
  3312. AFE_CDC_REGISTERS_CONFIG);
  3313. if (config_data) {
  3314. ret = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  3315. if (ret) {
  3316. dev_err(codec->dev,
  3317. "%s: Failed to set codec registers config %d\n",
  3318. __func__, ret);
  3319. return ret;
  3320. }
  3321. }
  3322. config_data = msm_codec_fn.get_afe_config_fn(codec,
  3323. AFE_CDC_REGISTER_PAGE_CONFIG);
  3324. if (config_data) {
  3325. ret = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
  3326. 0);
  3327. if (ret)
  3328. dev_err(codec->dev,
  3329. "%s: Failed to set cdc register page config\n",
  3330. __func__);
  3331. }
  3332. config_data = msm_codec_fn.get_afe_config_fn(codec,
  3333. AFE_SLIMBUS_SLAVE_CONFIG);
  3334. if (config_data) {
  3335. ret = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  3336. if (ret) {
  3337. dev_err(codec->dev,
  3338. "%s: Failed to set slimbus slave config %d\n",
  3339. __func__, ret);
  3340. return ret;
  3341. }
  3342. }
  3343. return 0;
  3344. }
  3345. static void msm_afe_clear_config(void)
  3346. {
  3347. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  3348. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  3349. }
  3350. static int msm_adsp_power_up_config(struct snd_soc_codec *codec,
  3351. struct snd_card *card)
  3352. {
  3353. int ret = 0;
  3354. unsigned long timeout;
  3355. int adsp_ready = 0;
  3356. bool snd_card_online = 0;
  3357. timeout = jiffies +
  3358. msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
  3359. do {
  3360. if (!snd_card_online) {
  3361. snd_card_online = snd_card_is_online_state(card);
  3362. pr_debug("%s: Sound card is %s\n", __func__,
  3363. snd_card_online ? "Online" : "Offline");
  3364. }
  3365. if (!adsp_ready) {
  3366. adsp_ready = q6core_is_adsp_ready();
  3367. pr_debug("%s: ADSP Audio is %s\n", __func__,
  3368. adsp_ready ? "ready" : "not ready");
  3369. }
  3370. if (snd_card_online && adsp_ready)
  3371. break;
  3372. /*
  3373. * Sound card/ADSP will be coming up after subsystem restart and
  3374. * it might not be fully up when the control reaches
  3375. * here. So, wait for 50msec before checking ADSP state
  3376. */
  3377. msleep(50);
  3378. } while (time_after(timeout, jiffies));
  3379. if (!snd_card_online || !adsp_ready) {
  3380. pr_err("%s: Timeout. Sound card is %s, ADSP Audio is %s\n",
  3381. __func__,
  3382. snd_card_online ? "Online" : "Offline",
  3383. adsp_ready ? "ready" : "not ready");
  3384. ret = -ETIMEDOUT;
  3385. goto err;
  3386. }
  3387. ret = msm_afe_set_config(codec);
  3388. if (ret)
  3389. pr_err("%s: Failed to set AFE config. err %d\n",
  3390. __func__, ret);
  3391. return 0;
  3392. err:
  3393. return ret;
  3394. }
  3395. static void msm_adsp_power_up_config_work(struct work_struct *work)
  3396. {
  3397. struct msm_asoc_mach_data *pdata;
  3398. struct snd_soc_codec *codec;
  3399. struct snd_card *card;
  3400. pdata = container_of(work, struct msm_asoc_mach_data,
  3401. adsp_power_up_work);
  3402. codec = pdata->codec;
  3403. card = codec->component.card->snd_card;
  3404. msm_adsp_power_up_config(codec, card);
  3405. }
  3406. static int sm8150_notifier_service_cb(struct notifier_block *this,
  3407. unsigned long opcode, void *ptr)
  3408. {
  3409. int ret;
  3410. struct snd_soc_card *card = NULL;
  3411. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  3412. struct snd_soc_pcm_runtime *rtd;
  3413. struct snd_soc_codec *codec;
  3414. struct msm_asoc_mach_data *pdata;
  3415. pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
  3416. switch (opcode) {
  3417. case AUDIO_NOTIFIER_SERVICE_DOWN:
  3418. /*
  3419. * Use flag to ignore initial boot notifications
  3420. * On initial boot msm_adsp_power_up_config is
  3421. * called on init. There is no need to clear
  3422. * and set the config again on initial boot.
  3423. */
  3424. if (is_initial_boot)
  3425. break;
  3426. msm_afe_clear_config();
  3427. break;
  3428. case AUDIO_NOTIFIER_SERVICE_UP:
  3429. if (is_initial_boot) {
  3430. is_initial_boot = false;
  3431. break;
  3432. }
  3433. if (!spdev)
  3434. return -EINVAL;
  3435. card = platform_get_drvdata(spdev);
  3436. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  3437. if (!rtd) {
  3438. dev_err(card->dev,
  3439. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  3440. __func__, be_dl_name);
  3441. ret = -EINVAL;
  3442. goto err;
  3443. }
  3444. codec = rtd->codec;
  3445. pdata = snd_soc_card_get_drvdata(card);
  3446. pdata->codec = codec;
  3447. schedule_work(&pdata->adsp_power_up_work);
  3448. break;
  3449. default:
  3450. break;
  3451. }
  3452. err:
  3453. return NOTIFY_OK;
  3454. }
  3455. static struct notifier_block service_nb = {
  3456. .notifier_call = sm8150_notifier_service_cb,
  3457. .priority = -INT_MAX,
  3458. };
  3459. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  3460. {
  3461. int ret = 0;
  3462. void *config_data;
  3463. struct snd_soc_codec *codec = rtd->codec;
  3464. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  3465. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3466. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3467. struct snd_soc_component *aux_comp;
  3468. struct snd_card *card;
  3469. struct snd_info_entry *entry;
  3470. struct msm_asoc_mach_data *pdata =
  3471. snd_soc_card_get_drvdata(rtd->card);
  3472. /*
  3473. * Codec SLIMBUS configuration
  3474. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
  3475. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  3476. * TX14, TX15, TX16
  3477. */
  3478. unsigned int rx_ch[WCD9360_RX_MAX] = {144, 145, 146, 147, 148, 149,
  3479. 150, 151};
  3480. unsigned int tx_ch[WCD9360_TX_MAX] = {128, 129, 130, 131, 132, 133,
  3481. 134, 135, 136, 137, 138, 139,
  3482. 140, 141, 142, 143};
  3483. pr_debug("%s: dev_name:%s\n", __func__, dev_name(cpu_dai->dev));
  3484. rtd->pmdown_time = 0;
  3485. ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
  3486. ARRAY_SIZE(msm_snd_controls));
  3487. if (ret < 0) {
  3488. pr_err("%s: add_codec_controls failed, err %d\n",
  3489. __func__, ret);
  3490. return ret;
  3491. }
  3492. if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
  3493. snd_soc_dapm_new_controls(dapm, msm_dapm_widgets_tavil,
  3494. ARRAY_SIZE(msm_dapm_widgets_tavil));
  3495. snd_soc_dapm_add_routes(dapm, wcd_audio_paths_tavil,
  3496. ARRAY_SIZE(wcd_audio_paths_tavil));
  3497. } else {
  3498. snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
  3499. ARRAY_SIZE(msm_dapm_widgets));
  3500. snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
  3501. ARRAY_SIZE(wcd_audio_paths));
  3502. }
  3503. snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
  3504. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  3505. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  3506. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  3507. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  3508. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  3509. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  3510. snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
  3511. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
  3512. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT1");
  3513. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT2");
  3514. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  3515. snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
  3516. snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
  3517. snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
  3518. snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
  3519. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
  3520. if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
  3521. snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
  3522. snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
  3523. snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
  3524. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  3525. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
  3526. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
  3527. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  3528. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  3529. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
  3530. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
  3531. } else {
  3532. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  3533. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  3534. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  3535. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  3536. }
  3537. snd_soc_dapm_sync(dapm);
  3538. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3539. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3540. if (!strcmp(dev_name(codec_dai->dev), "tavil_codec"))
  3541. msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
  3542. else
  3543. msm_codec_fn.get_afe_config_fn = pahu_get_afe_config;
  3544. ret = msm_adsp_power_up_config(codec, rtd->card->snd_card);
  3545. if (ret) {
  3546. pr_err("%s: Failed to set AFE config %d\n", __func__, ret);
  3547. goto err;
  3548. }
  3549. config_data = msm_codec_fn.get_afe_config_fn(codec,
  3550. AFE_AANC_VERSION);
  3551. if (config_data) {
  3552. ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  3553. if (ret) {
  3554. pr_err("%s: Failed to set aanc version %d\n",
  3555. __func__, ret);
  3556. goto err;
  3557. }
  3558. }
  3559. /*
  3560. * Send speaker configuration only for WSA8810.
  3561. * Default configuration is for WSA8815.
  3562. */
  3563. pr_debug("%s: Number of aux devices: %d\n",
  3564. __func__, rtd->card->num_aux_devs);
  3565. if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
  3566. if (rtd->card->num_aux_devs &&
  3567. !list_empty(&rtd->card->component_dev_list)) {
  3568. aux_comp = list_first_entry(
  3569. &rtd->card->component_dev_list,
  3570. struct snd_soc_component,
  3571. card_aux_list);
  3572. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  3573. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  3574. tavil_set_spkr_mode(rtd->codec,
  3575. WCD934X_SPKR_MODE_1);
  3576. tavil_set_spkr_gain_offset(rtd->codec,
  3577. WCD934X_RX_GAIN_OFFSET_M1P5_DB);
  3578. }
  3579. }
  3580. card = rtd->card->snd_card;
  3581. entry = snd_info_create_subdir(card->module, "codecs",
  3582. card->proc_root);
  3583. if (!entry) {
  3584. pr_debug("%s: Cannot create codecs module entry\n",
  3585. __func__);
  3586. pdata->codec_root = NULL;
  3587. goto done;
  3588. }
  3589. pdata->codec_root = entry;
  3590. tavil_codec_info_create_codec_entry(pdata->codec_root, codec);
  3591. } else {
  3592. if (rtd->card->num_aux_devs &&
  3593. !list_empty(&rtd->card->component_dev_list)) {
  3594. aux_comp = list_first_entry(&rtd->card->component_dev_list,
  3595. struct snd_soc_component, card_aux_list);
  3596. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  3597. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  3598. pahu_set_spkr_mode(rtd->codec, WCD9360_SPKR_MODE_1);
  3599. pahu_set_spkr_gain_offset(rtd->codec,
  3600. WCD9360_RX_GAIN_OFFSET_M1P5_DB);
  3601. }
  3602. }
  3603. card = rtd->card->snd_card;
  3604. entry = snd_info_create_subdir(card->module, "codecs",
  3605. card->proc_root);
  3606. if (!entry) {
  3607. pr_debug("%s: Cannot create codecs module entry\n",
  3608. __func__);
  3609. pdata->codec_root = NULL;
  3610. goto done;
  3611. }
  3612. pdata->codec_root = entry;
  3613. pahu_codec_info_create_codec_entry(pdata->codec_root, codec);
  3614. }
  3615. done:
  3616. codec_reg_done = true;
  3617. return 0;
  3618. err:
  3619. return ret;
  3620. }
  3621. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  3622. {
  3623. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  3624. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161};
  3625. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3626. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3627. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3628. }
  3629. static void *def_wcd_mbhc_cal(void)
  3630. {
  3631. void *wcd_mbhc_cal;
  3632. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  3633. u16 *btn_high;
  3634. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  3635. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  3636. if (!wcd_mbhc_cal)
  3637. return NULL;
  3638. #define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->X) = (Y))
  3639. S(v_hs_max, 1600);
  3640. #undef S
  3641. #define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->X) = (Y))
  3642. S(num_btn, WCD_MBHC_DEF_BUTTONS);
  3643. #undef S
  3644. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  3645. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  3646. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  3647. btn_high[0] = 75;
  3648. btn_high[1] = 150;
  3649. btn_high[2] = 237;
  3650. btn_high[3] = 500;
  3651. btn_high[4] = 500;
  3652. btn_high[5] = 500;
  3653. btn_high[6] = 500;
  3654. btn_high[7] = 500;
  3655. return wcd_mbhc_cal;
  3656. }
  3657. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  3658. struct snd_pcm_hw_params *params)
  3659. {
  3660. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3661. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3662. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3663. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3664. int ret = 0;
  3665. u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  3666. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3667. u32 user_set_tx_ch = 0;
  3668. u32 rx_ch_count;
  3669. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3670. ret = snd_soc_dai_get_channel_map(codec_dai,
  3671. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3672. if (ret < 0) {
  3673. pr_err("%s: failed to get codec chan map, err:%d\n",
  3674. __func__, ret);
  3675. goto err;
  3676. }
  3677. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
  3678. pr_debug("%s: rx_5_ch=%d\n", __func__,
  3679. slim_rx_cfg[5].channels);
  3680. rx_ch_count = slim_rx_cfg[5].channels;
  3681. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
  3682. pr_debug("%s: rx_2_ch=%d\n", __func__,
  3683. slim_rx_cfg[2].channels);
  3684. rx_ch_count = slim_rx_cfg[2].channels;
  3685. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
  3686. pr_debug("%s: rx_6_ch=%d\n", __func__,
  3687. slim_rx_cfg[6].channels);
  3688. rx_ch_count = slim_rx_cfg[6].channels;
  3689. } else {
  3690. pr_debug("%s: rx_0_ch=%d\n", __func__,
  3691. slim_rx_cfg[0].channels);
  3692. rx_ch_count = slim_rx_cfg[0].channels;
  3693. }
  3694. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  3695. rx_ch_count, rx_ch);
  3696. if (ret < 0) {
  3697. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3698. __func__, ret);
  3699. goto err;
  3700. }
  3701. } else {
  3702. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  3703. codec_dai->name, codec_dai->id, user_set_tx_ch);
  3704. ret = snd_soc_dai_get_channel_map(codec_dai,
  3705. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3706. if (ret < 0) {
  3707. pr_err("%s: failed to get tx codec chan map, err:%d\n",
  3708. __func__, ret);
  3709. goto err;
  3710. }
  3711. /* For <codec>_tx1 case */
  3712. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
  3713. user_set_tx_ch = slim_tx_cfg[0].channels;
  3714. /* For <codec>_tx3 case */
  3715. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
  3716. user_set_tx_ch = slim_tx_cfg[1].channels;
  3717. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
  3718. user_set_tx_ch = msm_vi_feed_tx_ch;
  3719. else
  3720. user_set_tx_ch = tx_ch_cnt;
  3721. pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
  3722. __func__, slim_tx_cfg[0].channels, user_set_tx_ch,
  3723. tx_ch_cnt, dai_link->id);
  3724. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3725. user_set_tx_ch, tx_ch, 0, 0);
  3726. if (ret < 0)
  3727. pr_err("%s: failed to set tx cpu chan map, err:%d\n",
  3728. __func__, ret);
  3729. }
  3730. err:
  3731. return ret;
  3732. }
  3733. static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream,
  3734. struct snd_pcm_hw_params *params)
  3735. {
  3736. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3737. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3738. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3739. unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  3740. unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
  3741. unsigned int num_tx_ch = 0;
  3742. unsigned int num_rx_ch = 0;
  3743. int ret = 0;
  3744. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3745. num_rx_ch = params_channels(params);
  3746. pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
  3747. codec_dai->name, codec_dai->id, num_rx_ch);
  3748. ret = snd_soc_dai_get_channel_map(codec_dai,
  3749. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3750. if (ret < 0) {
  3751. pr_err("%s: failed to get codec chan map, err:%d\n",
  3752. __func__, ret);
  3753. goto err;
  3754. }
  3755. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  3756. num_rx_ch, rx_ch);
  3757. if (ret < 0) {
  3758. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3759. __func__, ret);
  3760. goto err;
  3761. }
  3762. } else {
  3763. num_tx_ch = params_channels(params);
  3764. pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
  3765. codec_dai->name, codec_dai->id, num_tx_ch);
  3766. ret = snd_soc_dai_get_channel_map(codec_dai,
  3767. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3768. if (ret < 0) {
  3769. pr_err("%s: failed to get tx codec chan map, err:%d\n",
  3770. __func__, ret);
  3771. goto err;
  3772. }
  3773. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3774. num_tx_ch, tx_ch, 0, 0);
  3775. if (ret < 0) {
  3776. pr_err("%s: failed to set tx cpu chan map, err:%d\n",
  3777. __func__, ret);
  3778. goto err;
  3779. }
  3780. }
  3781. err:
  3782. return ret;
  3783. }
  3784. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  3785. struct snd_pcm_hw_params *params)
  3786. {
  3787. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3788. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3789. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3790. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3791. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  3792. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3793. int ret;
  3794. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  3795. codec_dai->name, codec_dai->id);
  3796. ret = snd_soc_dai_get_channel_map(codec_dai,
  3797. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3798. if (ret) {
  3799. dev_err(rtd->dev,
  3800. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  3801. __func__, ret);
  3802. goto err;
  3803. }
  3804. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  3805. __func__, tx_ch_cnt, dai_link->id);
  3806. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3807. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  3808. if (ret)
  3809. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  3810. __func__, ret);
  3811. err:
  3812. return ret;
  3813. }
  3814. static int msm_get_port_id(int be_id)
  3815. {
  3816. int afe_port_id;
  3817. switch (be_id) {
  3818. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  3819. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  3820. break;
  3821. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  3822. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  3823. break;
  3824. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  3825. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  3826. break;
  3827. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  3828. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  3829. break;
  3830. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  3831. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  3832. break;
  3833. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  3834. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  3835. break;
  3836. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  3837. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  3838. break;
  3839. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  3840. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  3841. break;
  3842. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  3843. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  3844. break;
  3845. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  3846. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  3847. break;
  3848. default:
  3849. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  3850. afe_port_id = -EINVAL;
  3851. }
  3852. return afe_port_id;
  3853. }
  3854. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  3855. {
  3856. u32 bit_per_sample;
  3857. switch (bit_format) {
  3858. case SNDRV_PCM_FORMAT_S32_LE:
  3859. case SNDRV_PCM_FORMAT_S24_3LE:
  3860. case SNDRV_PCM_FORMAT_S24_LE:
  3861. bit_per_sample = 32;
  3862. break;
  3863. case SNDRV_PCM_FORMAT_S16_LE:
  3864. default:
  3865. bit_per_sample = 16;
  3866. break;
  3867. }
  3868. return bit_per_sample;
  3869. }
  3870. static void update_mi2s_clk_val(int dai_id, int stream)
  3871. {
  3872. u32 bit_per_sample;
  3873. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3874. bit_per_sample =
  3875. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  3876. mi2s_clk[dai_id].clk_freq_in_hz =
  3877. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  3878. } else {
  3879. bit_per_sample =
  3880. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  3881. mi2s_clk[dai_id].clk_freq_in_hz =
  3882. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  3883. }
  3884. }
  3885. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  3886. {
  3887. int ret = 0;
  3888. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3889. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3890. int port_id = 0;
  3891. int index = cpu_dai->id;
  3892. port_id = msm_get_port_id(rtd->dai_link->id);
  3893. if (port_id < 0) {
  3894. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  3895. ret = port_id;
  3896. goto err;
  3897. }
  3898. if (enable) {
  3899. update_mi2s_clk_val(index, substream->stream);
  3900. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  3901. mi2s_clk[index].clk_freq_in_hz);
  3902. }
  3903. mi2s_clk[index].enable = enable;
  3904. ret = afe_set_lpass_clock_v2(port_id,
  3905. &mi2s_clk[index]);
  3906. if (ret < 0) {
  3907. dev_err(rtd->card->dev,
  3908. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  3909. __func__, port_id, ret);
  3910. goto err;
  3911. }
  3912. err:
  3913. return ret;
  3914. }
  3915. static int msm_set_pinctrl(struct msm_pinctrl_info *pinctrl_info,
  3916. enum pinctrl_pin_state new_state)
  3917. {
  3918. int ret = 0;
  3919. int curr_state = 0;
  3920. if (pinctrl_info == NULL) {
  3921. pr_err("%s: pinctrl_info is NULL\n", __func__);
  3922. ret = -EINVAL;
  3923. goto err;
  3924. }
  3925. if (pinctrl_info->pinctrl == NULL) {
  3926. pr_err("%s: pinctrl_info->pinctrl is NULL\n", __func__);
  3927. ret = -EINVAL;
  3928. goto err;
  3929. }
  3930. curr_state = pinctrl_info->curr_state;
  3931. pinctrl_info->curr_state = new_state;
  3932. pr_debug("%s: curr_state = %s new_state = %s\n", __func__,
  3933. pin_states[curr_state], pin_states[pinctrl_info->curr_state]);
  3934. if (curr_state == pinctrl_info->curr_state) {
  3935. pr_debug("%s: Already in same state\n", __func__);
  3936. goto err;
  3937. }
  3938. if (curr_state != STATE_DISABLE &&
  3939. pinctrl_info->curr_state != STATE_DISABLE) {
  3940. pr_debug("%s: state already active cannot switch\n", __func__);
  3941. ret = -EIO;
  3942. goto err;
  3943. }
  3944. switch (pinctrl_info->curr_state) {
  3945. case STATE_MI2S_ACTIVE:
  3946. ret = pinctrl_select_state(pinctrl_info->pinctrl,
  3947. pinctrl_info->mi2s_active);
  3948. if (ret) {
  3949. pr_err("%s: MI2S state select failed with %d\n",
  3950. __func__, ret);
  3951. ret = -EIO;
  3952. goto err;
  3953. }
  3954. break;
  3955. case STATE_TDM_ACTIVE:
  3956. ret = pinctrl_select_state(pinctrl_info->pinctrl,
  3957. pinctrl_info->tdm_active);
  3958. if (ret) {
  3959. pr_err("%s: TDM state select failed with %d\n",
  3960. __func__, ret);
  3961. ret = -EIO;
  3962. goto err;
  3963. }
  3964. break;
  3965. case STATE_DISABLE:
  3966. if (curr_state == STATE_MI2S_ACTIVE) {
  3967. ret = pinctrl_select_state(pinctrl_info->pinctrl,
  3968. pinctrl_info->mi2s_disable);
  3969. } else {
  3970. ret = pinctrl_select_state(pinctrl_info->pinctrl,
  3971. pinctrl_info->tdm_disable);
  3972. }
  3973. if (ret) {
  3974. pr_err("%s: state disable failed with %d\n",
  3975. __func__, ret);
  3976. ret = -EIO;
  3977. goto err;
  3978. }
  3979. break;
  3980. default:
  3981. pr_err("%s: TLMM pin state is invalid\n", __func__);
  3982. return -EINVAL;
  3983. }
  3984. err:
  3985. return ret;
  3986. }
  3987. static void msm_release_pinctrl(struct platform_device *pdev)
  3988. {
  3989. struct snd_soc_card *card = platform_get_drvdata(pdev);
  3990. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3991. struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
  3992. if (pinctrl_info->pinctrl) {
  3993. devm_pinctrl_put(pinctrl_info->pinctrl);
  3994. pinctrl_info->pinctrl = NULL;
  3995. }
  3996. }
  3997. static int msm_get_pinctrl(struct platform_device *pdev)
  3998. {
  3999. struct snd_soc_card *card = platform_get_drvdata(pdev);
  4000. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4001. struct msm_pinctrl_info *pinctrl_info = NULL;
  4002. struct pinctrl *pinctrl;
  4003. int ret;
  4004. pinctrl_info = &pdata->pinctrl_info;
  4005. if (pinctrl_info == NULL) {
  4006. pr_err("%s: pinctrl_info is NULL\n", __func__);
  4007. return -EINVAL;
  4008. }
  4009. pinctrl = devm_pinctrl_get(&pdev->dev);
  4010. if (IS_ERR_OR_NULL(pinctrl)) {
  4011. pr_err("%s: Unable to get pinctrl handle\n", __func__);
  4012. return -EINVAL;
  4013. }
  4014. pinctrl_info->pinctrl = pinctrl;
  4015. /* get all the states handles from Device Tree */
  4016. pinctrl_info->mi2s_disable = pinctrl_lookup_state(pinctrl,
  4017. "quat_mi2s_disable");
  4018. if (IS_ERR(pinctrl_info->mi2s_disable)) {
  4019. pr_err("%s: could not get mi2s_disable pinstate\n", __func__);
  4020. goto err;
  4021. }
  4022. pinctrl_info->mi2s_active = pinctrl_lookup_state(pinctrl,
  4023. "quat_mi2s_enable");
  4024. if (IS_ERR(pinctrl_info->mi2s_active)) {
  4025. pr_err("%s: could not get mi2s_active pinstate\n", __func__);
  4026. goto err;
  4027. }
  4028. pinctrl_info->tdm_disable = pinctrl_lookup_state(pinctrl,
  4029. "quat_tdm_disable");
  4030. if (IS_ERR(pinctrl_info->tdm_disable)) {
  4031. pr_err("%s: could not get tdm_disable pinstate\n", __func__);
  4032. goto err;
  4033. }
  4034. pinctrl_info->tdm_active = pinctrl_lookup_state(pinctrl,
  4035. "quat_tdm_enable");
  4036. if (IS_ERR(pinctrl_info->tdm_active)) {
  4037. pr_err("%s: could not get tdm_active pinstate\n",
  4038. __func__);
  4039. goto err;
  4040. }
  4041. /* Reset the TLMM pins to a default state */
  4042. ret = pinctrl_select_state(pinctrl_info->pinctrl,
  4043. pinctrl_info->mi2s_disable);
  4044. if (ret != 0) {
  4045. pr_err("%s: Disable TLMM pins failed with %d\n",
  4046. __func__, ret);
  4047. ret = -EIO;
  4048. goto err;
  4049. }
  4050. pinctrl_info->curr_state = STATE_DISABLE;
  4051. return 0;
  4052. err:
  4053. devm_pinctrl_put(pinctrl);
  4054. pinctrl_info->pinctrl = NULL;
  4055. return -EINVAL;
  4056. }
  4057. static int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  4058. struct snd_pcm_hw_params *params)
  4059. {
  4060. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4061. struct snd_interval *rate = hw_param_interval(params,
  4062. SNDRV_PCM_HW_PARAM_RATE);
  4063. struct snd_interval *channels = hw_param_interval(params,
  4064. SNDRV_PCM_HW_PARAM_CHANNELS);
  4065. if (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) {
  4066. channels->min = channels->max =
  4067. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  4068. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4069. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  4070. rate->min = rate->max =
  4071. tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  4072. } else if (cpu_dai->id == AFE_PORT_ID_SECONDARY_TDM_RX) {
  4073. channels->min = channels->max =
  4074. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  4075. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4076. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  4077. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  4078. } else if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_RX) {
  4079. channels->min = channels->max =
  4080. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  4081. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4082. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  4083. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  4084. } else {
  4085. pr_err("%s: dai id 0x%x not supported\n",
  4086. __func__, cpu_dai->id);
  4087. return -EINVAL;
  4088. }
  4089. pr_debug("%s: dai id = 0x%x channels = %d rate = %d format = 0x%x\n",
  4090. __func__, cpu_dai->id, channels->max, rate->max,
  4091. params_format(params));
  4092. return 0;
  4093. }
  4094. static int sm8150_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  4095. struct snd_pcm_hw_params *params)
  4096. {
  4097. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4098. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4099. int ret = 0;
  4100. int slot_width = 32;
  4101. int channels, slots;
  4102. unsigned int slot_mask, rate, clk_freq;
  4103. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  4104. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  4105. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  4106. switch (cpu_dai->id) {
  4107. case AFE_PORT_ID_PRIMARY_TDM_RX:
  4108. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  4109. break;
  4110. case AFE_PORT_ID_SECONDARY_TDM_RX:
  4111. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  4112. break;
  4113. case AFE_PORT_ID_TERTIARY_TDM_RX:
  4114. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  4115. break;
  4116. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  4117. slots = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  4118. break;
  4119. case AFE_PORT_ID_QUINARY_TDM_RX:
  4120. slots = tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  4121. break;
  4122. case AFE_PORT_ID_PRIMARY_TDM_TX:
  4123. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  4124. break;
  4125. case AFE_PORT_ID_SECONDARY_TDM_TX:
  4126. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  4127. break;
  4128. case AFE_PORT_ID_TERTIARY_TDM_TX:
  4129. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  4130. break;
  4131. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  4132. slots = tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  4133. break;
  4134. case AFE_PORT_ID_QUINARY_TDM_TX:
  4135. slots = tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  4136. break;
  4137. default:
  4138. pr_err("%s: dai id 0x%x not supported\n",
  4139. __func__, cpu_dai->id);
  4140. return -EINVAL;
  4141. }
  4142. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4143. /*2 slot config - bits 0 and 1 set for the first two slots */
  4144. slot_mask = 0x0000FFFF >> (16-slots);
  4145. channels = slots;
  4146. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  4147. __func__, slot_width, slots);
  4148. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  4149. slots, slot_width);
  4150. if (ret < 0) {
  4151. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  4152. __func__, ret);
  4153. goto end;
  4154. }
  4155. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4156. 0, NULL, channels, slot_offset);
  4157. if (ret < 0) {
  4158. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  4159. __func__, ret);
  4160. goto end;
  4161. }
  4162. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4163. /*2 slot config - bits 0 and 1 set for the first two slots */
  4164. slot_mask = 0x0000FFFF >> (16-slots);
  4165. channels = slots;
  4166. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  4167. __func__, slot_width, slots);
  4168. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  4169. slots, slot_width);
  4170. if (ret < 0) {
  4171. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  4172. __func__, ret);
  4173. goto end;
  4174. }
  4175. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4176. channels, slot_offset, 0, NULL);
  4177. if (ret < 0) {
  4178. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  4179. __func__, ret);
  4180. goto end;
  4181. }
  4182. } else {
  4183. ret = -EINVAL;
  4184. pr_err("%s: invalid use case, err:%d\n",
  4185. __func__, ret);
  4186. goto end;
  4187. }
  4188. rate = params_rate(params);
  4189. clk_freq = rate * slot_width * slots;
  4190. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  4191. if (ret < 0)
  4192. pr_err("%s: failed to set tdm clk, err:%d\n",
  4193. __func__, ret);
  4194. end:
  4195. return ret;
  4196. }
  4197. static int sm8150_tdm_snd_startup(struct snd_pcm_substream *substream)
  4198. {
  4199. int ret = 0;
  4200. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4201. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4202. struct snd_soc_card *card = rtd->card;
  4203. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4204. struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
  4205. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  4206. if ((cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) ||
  4207. (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_TX)) {
  4208. ret = msm_set_pinctrl(pinctrl_info, STATE_TDM_ACTIVE);
  4209. if (ret)
  4210. pr_err("%s: TDM TLMM pinctrl set failed with %d\n",
  4211. __func__, ret);
  4212. }
  4213. return ret;
  4214. }
  4215. static void sm8150_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  4216. {
  4217. int ret = 0;
  4218. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4219. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4220. struct snd_soc_card *card = rtd->card;
  4221. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4222. struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
  4223. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  4224. if ((cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) ||
  4225. (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_TX)) {
  4226. ret = msm_set_pinctrl(pinctrl_info, STATE_DISABLE);
  4227. if (ret)
  4228. pr_err("%s: TDM TLMM pinctrl set failed with %d\n",
  4229. __func__, ret);
  4230. }
  4231. }
  4232. static struct snd_soc_ops sm8150_tdm_be_ops = {
  4233. .hw_params = sm8150_tdm_snd_hw_params,
  4234. .startup = sm8150_tdm_snd_startup,
  4235. .shutdown = sm8150_tdm_snd_shutdown
  4236. };
  4237. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4238. {
  4239. cpumask_t mask;
  4240. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  4241. pm_qos_remove_request(&substream->latency_pm_qos_req);
  4242. cpumask_clear(&mask);
  4243. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  4244. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  4245. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  4246. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  4247. pm_qos_add_request(&substream->latency_pm_qos_req,
  4248. PM_QOS_CPU_DMA_LATENCY,
  4249. MSM_LL_QOS_VALUE);
  4250. return 0;
  4251. }
  4252. static struct snd_soc_ops msm_fe_qos_ops = {
  4253. .prepare = msm_fe_qos_prepare,
  4254. };
  4255. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4256. {
  4257. int ret = 0;
  4258. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4259. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4260. int index = cpu_dai->id;
  4261. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4262. struct snd_soc_card *card = rtd->card;
  4263. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4264. struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
  4265. int ret_pinctrl = 0;
  4266. dev_dbg(rtd->card->dev,
  4267. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4268. __func__, substream->name, substream->stream,
  4269. cpu_dai->name, cpu_dai->id);
  4270. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4271. ret = -EINVAL;
  4272. dev_err(rtd->card->dev,
  4273. "%s: CPU DAI id (%d) out of range\n",
  4274. __func__, cpu_dai->id);
  4275. goto err;
  4276. }
  4277. /*
  4278. * Mutex protection in case the same MI2S
  4279. * interface using for both TX and RX so
  4280. * that the same clock won't be enable twice.
  4281. */
  4282. mutex_lock(&mi2s_intf_conf[index].lock);
  4283. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4284. /* Check if msm needs to provide the clock to the interface */
  4285. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4286. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4287. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4288. }
  4289. ret = msm_mi2s_set_sclk(substream, true);
  4290. if (ret < 0) {
  4291. dev_err(rtd->card->dev,
  4292. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4293. __func__, ret);
  4294. goto clean_up;
  4295. }
  4296. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4297. if (ret < 0) {
  4298. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4299. __func__, index, ret);
  4300. goto clk_off;
  4301. }
  4302. if (index == QUAT_MI2S) {
  4303. ret_pinctrl = msm_set_pinctrl(pinctrl_info,
  4304. STATE_MI2S_ACTIVE);
  4305. if (ret_pinctrl)
  4306. pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
  4307. __func__, ret_pinctrl);
  4308. }
  4309. }
  4310. clk_off:
  4311. if (ret < 0)
  4312. msm_mi2s_set_sclk(substream, false);
  4313. clean_up:
  4314. if (ret < 0)
  4315. mi2s_intf_conf[index].ref_cnt--;
  4316. mutex_unlock(&mi2s_intf_conf[index].lock);
  4317. err:
  4318. return ret;
  4319. }
  4320. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4321. {
  4322. int ret;
  4323. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4324. int index = rtd->cpu_dai->id;
  4325. struct snd_soc_card *card = rtd->card;
  4326. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4327. struct msm_pinctrl_info *pinctrl_info = &pdata->pinctrl_info;
  4328. int ret_pinctrl = 0;
  4329. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4330. substream->name, substream->stream);
  4331. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4332. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4333. return;
  4334. }
  4335. mutex_lock(&mi2s_intf_conf[index].lock);
  4336. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4337. ret = msm_mi2s_set_sclk(substream, false);
  4338. if (ret < 0)
  4339. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4340. __func__, index, ret);
  4341. if (index == QUAT_MI2S) {
  4342. ret_pinctrl = msm_set_pinctrl(pinctrl_info,
  4343. STATE_DISABLE);
  4344. if (ret_pinctrl)
  4345. pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
  4346. __func__, ret_pinctrl);
  4347. }
  4348. }
  4349. mutex_unlock(&mi2s_intf_conf[index].lock);
  4350. }
  4351. static struct snd_soc_ops msm_mi2s_be_ops = {
  4352. .startup = msm_mi2s_snd_startup,
  4353. .shutdown = msm_mi2s_snd_shutdown,
  4354. };
  4355. static struct snd_soc_ops msm_be_ops = {
  4356. .hw_params = msm_snd_hw_params,
  4357. };
  4358. static struct snd_soc_ops msm_slimbus_2_be_ops = {
  4359. .hw_params = msm_slimbus_2_hw_params,
  4360. };
  4361. static struct snd_soc_ops msm_wcn_ops = {
  4362. .hw_params = msm_wcn_hw_params,
  4363. };
  4364. /* Digital audio interface glue - connects codec <---> CPU */
  4365. static struct snd_soc_dai_link msm_common_dai_links[] = {
  4366. /* FrontEnd DAI Links */
  4367. {
  4368. .name = MSM_DAILINK_NAME(Media1),
  4369. .stream_name = "MultiMedia1",
  4370. .cpu_dai_name = "MultiMedia1",
  4371. .platform_name = "msm-pcm-dsp.0",
  4372. .dynamic = 1,
  4373. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4374. .dpcm_playback = 1,
  4375. .dpcm_capture = 1,
  4376. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4377. SND_SOC_DPCM_TRIGGER_POST},
  4378. .codec_dai_name = "snd-soc-dummy-dai",
  4379. .codec_name = "snd-soc-dummy",
  4380. .ignore_suspend = 1,
  4381. /* this dainlink has playback support */
  4382. .ignore_pmdown_time = 1,
  4383. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  4384. },
  4385. {
  4386. .name = MSM_DAILINK_NAME(Media2),
  4387. .stream_name = "MultiMedia2",
  4388. .cpu_dai_name = "MultiMedia2",
  4389. .platform_name = "msm-pcm-dsp.0",
  4390. .dynamic = 1,
  4391. .dpcm_playback = 1,
  4392. .dpcm_capture = 1,
  4393. .codec_dai_name = "snd-soc-dummy-dai",
  4394. .codec_name = "snd-soc-dummy",
  4395. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4396. SND_SOC_DPCM_TRIGGER_POST},
  4397. .ignore_suspend = 1,
  4398. /* this dainlink has playback support */
  4399. .ignore_pmdown_time = 1,
  4400. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  4401. },
  4402. {
  4403. .name = "VoiceMMode1",
  4404. .stream_name = "VoiceMMode1",
  4405. .cpu_dai_name = "VoiceMMode1",
  4406. .platform_name = "msm-pcm-voice",
  4407. .dynamic = 1,
  4408. .dpcm_playback = 1,
  4409. .dpcm_capture = 1,
  4410. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4411. SND_SOC_DPCM_TRIGGER_POST},
  4412. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4413. .ignore_suspend = 1,
  4414. .ignore_pmdown_time = 1,
  4415. .codec_dai_name = "snd-soc-dummy-dai",
  4416. .codec_name = "snd-soc-dummy",
  4417. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  4418. },
  4419. {
  4420. .name = "MSM VoIP",
  4421. .stream_name = "VoIP",
  4422. .cpu_dai_name = "VoIP",
  4423. .platform_name = "msm-voip-dsp",
  4424. .dynamic = 1,
  4425. .dpcm_playback = 1,
  4426. .dpcm_capture = 1,
  4427. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4428. SND_SOC_DPCM_TRIGGER_POST},
  4429. .codec_dai_name = "snd-soc-dummy-dai",
  4430. .codec_name = "snd-soc-dummy",
  4431. .ignore_suspend = 1,
  4432. /* this dainlink has playback support */
  4433. .ignore_pmdown_time = 1,
  4434. .id = MSM_FRONTEND_DAI_VOIP,
  4435. },
  4436. {
  4437. .name = MSM_DAILINK_NAME(ULL),
  4438. .stream_name = "MultiMedia3",
  4439. .cpu_dai_name = "MultiMedia3",
  4440. .platform_name = "msm-pcm-dsp.2",
  4441. .dynamic = 1,
  4442. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4443. .dpcm_playback = 1,
  4444. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4445. SND_SOC_DPCM_TRIGGER_POST},
  4446. .codec_dai_name = "snd-soc-dummy-dai",
  4447. .codec_name = "snd-soc-dummy",
  4448. .ignore_suspend = 1,
  4449. /* this dainlink has playback support */
  4450. .ignore_pmdown_time = 1,
  4451. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  4452. },
  4453. /* Hostless PCM purpose */
  4454. {
  4455. .name = "SLIMBUS_0 Hostless",
  4456. .stream_name = "SLIMBUS_0 Hostless",
  4457. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  4458. .platform_name = "msm-pcm-hostless",
  4459. .dynamic = 1,
  4460. .dpcm_playback = 1,
  4461. .dpcm_capture = 1,
  4462. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4463. SND_SOC_DPCM_TRIGGER_POST},
  4464. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4465. .ignore_suspend = 1,
  4466. /* this dailink has playback support */
  4467. .ignore_pmdown_time = 1,
  4468. .codec_dai_name = "snd-soc-dummy-dai",
  4469. .codec_name = "snd-soc-dummy",
  4470. },
  4471. {
  4472. .name = "MSM AFE-PCM RX",
  4473. .stream_name = "AFE-PROXY RX",
  4474. .cpu_dai_name = "msm-dai-q6-dev.241",
  4475. .codec_name = "msm-stub-codec.1",
  4476. .codec_dai_name = "msm-stub-rx",
  4477. .platform_name = "msm-pcm-afe",
  4478. .dpcm_playback = 1,
  4479. .ignore_suspend = 1,
  4480. /* this dainlink has playback support */
  4481. .ignore_pmdown_time = 1,
  4482. },
  4483. {
  4484. .name = "MSM AFE-PCM TX",
  4485. .stream_name = "AFE-PROXY TX",
  4486. .cpu_dai_name = "msm-dai-q6-dev.240",
  4487. .codec_name = "msm-stub-codec.1",
  4488. .codec_dai_name = "msm-stub-tx",
  4489. .platform_name = "msm-pcm-afe",
  4490. .dpcm_capture = 1,
  4491. .ignore_suspend = 1,
  4492. },
  4493. {
  4494. .name = MSM_DAILINK_NAME(Compress1),
  4495. .stream_name = "Compress1",
  4496. .cpu_dai_name = "MultiMedia4",
  4497. .platform_name = "msm-compress-dsp",
  4498. .dynamic = 1,
  4499. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  4500. .dpcm_playback = 1,
  4501. .dpcm_capture = 1,
  4502. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4503. SND_SOC_DPCM_TRIGGER_POST},
  4504. .codec_dai_name = "snd-soc-dummy-dai",
  4505. .codec_name = "snd-soc-dummy",
  4506. .ignore_suspend = 1,
  4507. .ignore_pmdown_time = 1,
  4508. /* this dainlink has playback support */
  4509. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  4510. },
  4511. {
  4512. .name = "AUXPCM Hostless",
  4513. .stream_name = "AUXPCM Hostless",
  4514. .cpu_dai_name = "AUXPCM_HOSTLESS",
  4515. .platform_name = "msm-pcm-hostless",
  4516. .dynamic = 1,
  4517. .dpcm_playback = 1,
  4518. .dpcm_capture = 1,
  4519. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4520. SND_SOC_DPCM_TRIGGER_POST},
  4521. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4522. .ignore_suspend = 1,
  4523. /* this dainlink has playback support */
  4524. .ignore_pmdown_time = 1,
  4525. .codec_dai_name = "snd-soc-dummy-dai",
  4526. .codec_name = "snd-soc-dummy",
  4527. },
  4528. {
  4529. .name = "SLIMBUS_1 Hostless",
  4530. .stream_name = "SLIMBUS_1 Hostless",
  4531. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  4532. .platform_name = "msm-pcm-hostless",
  4533. .dynamic = 1,
  4534. .dpcm_playback = 1,
  4535. .dpcm_capture = 1,
  4536. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4537. SND_SOC_DPCM_TRIGGER_POST},
  4538. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4539. .ignore_suspend = 1,
  4540. /* this dailink has playback support */
  4541. .ignore_pmdown_time = 1,
  4542. .codec_dai_name = "snd-soc-dummy-dai",
  4543. .codec_name = "snd-soc-dummy",
  4544. },
  4545. {
  4546. .name = "SLIMBUS_3 Hostless",
  4547. .stream_name = "SLIMBUS_3 Hostless",
  4548. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  4549. .platform_name = "msm-pcm-hostless",
  4550. .dynamic = 1,
  4551. .dpcm_playback = 1,
  4552. .dpcm_capture = 1,
  4553. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4554. SND_SOC_DPCM_TRIGGER_POST},
  4555. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4556. .ignore_suspend = 1,
  4557. /* this dailink has playback support */
  4558. .ignore_pmdown_time = 1,
  4559. .codec_dai_name = "snd-soc-dummy-dai",
  4560. .codec_name = "snd-soc-dummy",
  4561. },
  4562. {
  4563. .name = "SLIMBUS_4 Hostless",
  4564. .stream_name = "SLIMBUS_4 Hostless",
  4565. .cpu_dai_name = "SLIMBUS4_HOSTLESS",
  4566. .platform_name = "msm-pcm-hostless",
  4567. .dynamic = 1,
  4568. .dpcm_playback = 1,
  4569. .dpcm_capture = 1,
  4570. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4571. SND_SOC_DPCM_TRIGGER_POST},
  4572. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4573. .ignore_suspend = 1,
  4574. /* this dailink has playback support */
  4575. .ignore_pmdown_time = 1,
  4576. .codec_dai_name = "snd-soc-dummy-dai",
  4577. .codec_name = "snd-soc-dummy",
  4578. },
  4579. {
  4580. .name = MSM_DAILINK_NAME(LowLatency),
  4581. .stream_name = "MultiMedia5",
  4582. .cpu_dai_name = "MultiMedia5",
  4583. .platform_name = "msm-pcm-dsp.1",
  4584. .dynamic = 1,
  4585. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4586. .dpcm_playback = 1,
  4587. .dpcm_capture = 1,
  4588. .codec_dai_name = "snd-soc-dummy-dai",
  4589. .codec_name = "snd-soc-dummy",
  4590. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4591. SND_SOC_DPCM_TRIGGER_POST},
  4592. .ignore_suspend = 1,
  4593. /* this dainlink has playback support */
  4594. .ignore_pmdown_time = 1,
  4595. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  4596. .ops = &msm_fe_qos_ops,
  4597. },
  4598. {
  4599. .name = "Listen 1 Audio Service",
  4600. .stream_name = "Listen 1 Audio Service",
  4601. .cpu_dai_name = "LSM1",
  4602. .platform_name = "msm-lsm-client",
  4603. .dynamic = 1,
  4604. .dpcm_capture = 1,
  4605. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4606. SND_SOC_DPCM_TRIGGER_POST },
  4607. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4608. .ignore_suspend = 1,
  4609. .codec_dai_name = "snd-soc-dummy-dai",
  4610. .codec_name = "snd-soc-dummy",
  4611. .id = MSM_FRONTEND_DAI_LSM1,
  4612. },
  4613. /* Multiple Tunnel instances */
  4614. {
  4615. .name = MSM_DAILINK_NAME(Compress2),
  4616. .stream_name = "Compress2",
  4617. .cpu_dai_name = "MultiMedia7",
  4618. .platform_name = "msm-compress-dsp",
  4619. .dynamic = 1,
  4620. .dpcm_playback = 1,
  4621. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4622. SND_SOC_DPCM_TRIGGER_POST},
  4623. .codec_dai_name = "snd-soc-dummy-dai",
  4624. .codec_name = "snd-soc-dummy",
  4625. .ignore_suspend = 1,
  4626. .ignore_pmdown_time = 1,
  4627. /* this dainlink has playback support */
  4628. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  4629. },
  4630. {
  4631. .name = MSM_DAILINK_NAME(MultiMedia10),
  4632. .stream_name = "MultiMedia10",
  4633. .cpu_dai_name = "MultiMedia10",
  4634. .platform_name = "msm-pcm-dsp.1",
  4635. .dynamic = 1,
  4636. .dpcm_playback = 1,
  4637. .dpcm_capture = 1,
  4638. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4639. SND_SOC_DPCM_TRIGGER_POST},
  4640. .codec_dai_name = "snd-soc-dummy-dai",
  4641. .codec_name = "snd-soc-dummy",
  4642. .ignore_suspend = 1,
  4643. .ignore_pmdown_time = 1,
  4644. /* this dainlink has playback support */
  4645. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  4646. },
  4647. {
  4648. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  4649. .stream_name = "MM_NOIRQ",
  4650. .cpu_dai_name = "MultiMedia8",
  4651. .platform_name = "msm-pcm-dsp-noirq",
  4652. .dynamic = 1,
  4653. .dpcm_playback = 1,
  4654. .dpcm_capture = 1,
  4655. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4656. SND_SOC_DPCM_TRIGGER_POST},
  4657. .codec_dai_name = "snd-soc-dummy-dai",
  4658. .codec_name = "snd-soc-dummy",
  4659. .ignore_suspend = 1,
  4660. .ignore_pmdown_time = 1,
  4661. /* this dainlink has playback support */
  4662. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  4663. .ops = &msm_fe_qos_ops,
  4664. },
  4665. /* HDMI Hostless */
  4666. {
  4667. .name = "HDMI_RX_HOSTLESS",
  4668. .stream_name = "HDMI_RX_HOSTLESS",
  4669. .cpu_dai_name = "HDMI_HOSTLESS",
  4670. .platform_name = "msm-pcm-hostless",
  4671. .dynamic = 1,
  4672. .dpcm_playback = 1,
  4673. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4674. SND_SOC_DPCM_TRIGGER_POST},
  4675. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4676. .ignore_suspend = 1,
  4677. .ignore_pmdown_time = 1,
  4678. .codec_dai_name = "snd-soc-dummy-dai",
  4679. .codec_name = "snd-soc-dummy",
  4680. },
  4681. {
  4682. .name = "VoiceMMode2",
  4683. .stream_name = "VoiceMMode2",
  4684. .cpu_dai_name = "VoiceMMode2",
  4685. .platform_name = "msm-pcm-voice",
  4686. .dynamic = 1,
  4687. .dpcm_playback = 1,
  4688. .dpcm_capture = 1,
  4689. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4690. SND_SOC_DPCM_TRIGGER_POST},
  4691. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4692. .ignore_suspend = 1,
  4693. .ignore_pmdown_time = 1,
  4694. .codec_dai_name = "snd-soc-dummy-dai",
  4695. .codec_name = "snd-soc-dummy",
  4696. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  4697. },
  4698. /* LSM FE */
  4699. {
  4700. .name = "Listen 2 Audio Service",
  4701. .stream_name = "Listen 2 Audio Service",
  4702. .cpu_dai_name = "LSM2",
  4703. .platform_name = "msm-lsm-client",
  4704. .dynamic = 1,
  4705. .dpcm_capture = 1,
  4706. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4707. SND_SOC_DPCM_TRIGGER_POST },
  4708. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4709. .ignore_suspend = 1,
  4710. .codec_dai_name = "snd-soc-dummy-dai",
  4711. .codec_name = "snd-soc-dummy",
  4712. .id = MSM_FRONTEND_DAI_LSM2,
  4713. },
  4714. {
  4715. .name = "Listen 3 Audio Service",
  4716. .stream_name = "Listen 3 Audio Service",
  4717. .cpu_dai_name = "LSM3",
  4718. .platform_name = "msm-lsm-client",
  4719. .dynamic = 1,
  4720. .dpcm_capture = 1,
  4721. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4722. SND_SOC_DPCM_TRIGGER_POST },
  4723. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4724. .ignore_suspend = 1,
  4725. .codec_dai_name = "snd-soc-dummy-dai",
  4726. .codec_name = "snd-soc-dummy",
  4727. .id = MSM_FRONTEND_DAI_LSM3,
  4728. },
  4729. {
  4730. .name = "Listen 4 Audio Service",
  4731. .stream_name = "Listen 4 Audio Service",
  4732. .cpu_dai_name = "LSM4",
  4733. .platform_name = "msm-lsm-client",
  4734. .dynamic = 1,
  4735. .dpcm_capture = 1,
  4736. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4737. SND_SOC_DPCM_TRIGGER_POST },
  4738. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4739. .ignore_suspend = 1,
  4740. .codec_dai_name = "snd-soc-dummy-dai",
  4741. .codec_name = "snd-soc-dummy",
  4742. .id = MSM_FRONTEND_DAI_LSM4,
  4743. },
  4744. {
  4745. .name = "Listen 5 Audio Service",
  4746. .stream_name = "Listen 5 Audio Service",
  4747. .cpu_dai_name = "LSM5",
  4748. .platform_name = "msm-lsm-client",
  4749. .dynamic = 1,
  4750. .dpcm_capture = 1,
  4751. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4752. SND_SOC_DPCM_TRIGGER_POST },
  4753. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4754. .ignore_suspend = 1,
  4755. .codec_dai_name = "snd-soc-dummy-dai",
  4756. .codec_name = "snd-soc-dummy",
  4757. .id = MSM_FRONTEND_DAI_LSM5,
  4758. },
  4759. {
  4760. .name = "Listen 6 Audio Service",
  4761. .stream_name = "Listen 6 Audio Service",
  4762. .cpu_dai_name = "LSM6",
  4763. .platform_name = "msm-lsm-client",
  4764. .dynamic = 1,
  4765. .dpcm_capture = 1,
  4766. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4767. SND_SOC_DPCM_TRIGGER_POST },
  4768. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4769. .ignore_suspend = 1,
  4770. .codec_dai_name = "snd-soc-dummy-dai",
  4771. .codec_name = "snd-soc-dummy",
  4772. .id = MSM_FRONTEND_DAI_LSM6,
  4773. },
  4774. {
  4775. .name = "Listen 7 Audio Service",
  4776. .stream_name = "Listen 7 Audio Service",
  4777. .cpu_dai_name = "LSM7",
  4778. .platform_name = "msm-lsm-client",
  4779. .dynamic = 1,
  4780. .dpcm_capture = 1,
  4781. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4782. SND_SOC_DPCM_TRIGGER_POST },
  4783. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4784. .ignore_suspend = 1,
  4785. .codec_dai_name = "snd-soc-dummy-dai",
  4786. .codec_name = "snd-soc-dummy",
  4787. .id = MSM_FRONTEND_DAI_LSM7,
  4788. },
  4789. {
  4790. .name = "Listen 8 Audio Service",
  4791. .stream_name = "Listen 8 Audio Service",
  4792. .cpu_dai_name = "LSM8",
  4793. .platform_name = "msm-lsm-client",
  4794. .dynamic = 1,
  4795. .dpcm_capture = 1,
  4796. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4797. SND_SOC_DPCM_TRIGGER_POST },
  4798. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4799. .ignore_suspend = 1,
  4800. .codec_dai_name = "snd-soc-dummy-dai",
  4801. .codec_name = "snd-soc-dummy",
  4802. .id = MSM_FRONTEND_DAI_LSM8,
  4803. },
  4804. {
  4805. .name = MSM_DAILINK_NAME(Media9),
  4806. .stream_name = "MultiMedia9",
  4807. .cpu_dai_name = "MultiMedia9",
  4808. .platform_name = "msm-pcm-dsp.0",
  4809. .dynamic = 1,
  4810. .dpcm_playback = 1,
  4811. .dpcm_capture = 1,
  4812. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4813. SND_SOC_DPCM_TRIGGER_POST},
  4814. .codec_dai_name = "snd-soc-dummy-dai",
  4815. .codec_name = "snd-soc-dummy",
  4816. .ignore_suspend = 1,
  4817. /* this dainlink has playback support */
  4818. .ignore_pmdown_time = 1,
  4819. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  4820. },
  4821. {
  4822. .name = MSM_DAILINK_NAME(Compress4),
  4823. .stream_name = "Compress4",
  4824. .cpu_dai_name = "MultiMedia11",
  4825. .platform_name = "msm-compress-dsp",
  4826. .dynamic = 1,
  4827. .dpcm_playback = 1,
  4828. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4829. SND_SOC_DPCM_TRIGGER_POST},
  4830. .codec_dai_name = "snd-soc-dummy-dai",
  4831. .codec_name = "snd-soc-dummy",
  4832. .ignore_suspend = 1,
  4833. .ignore_pmdown_time = 1,
  4834. /* this dainlink has playback support */
  4835. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  4836. },
  4837. {
  4838. .name = MSM_DAILINK_NAME(Compress5),
  4839. .stream_name = "Compress5",
  4840. .cpu_dai_name = "MultiMedia12",
  4841. .platform_name = "msm-compress-dsp",
  4842. .dynamic = 1,
  4843. .dpcm_playback = 1,
  4844. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4845. SND_SOC_DPCM_TRIGGER_POST},
  4846. .codec_dai_name = "snd-soc-dummy-dai",
  4847. .codec_name = "snd-soc-dummy",
  4848. .ignore_suspend = 1,
  4849. .ignore_pmdown_time = 1,
  4850. /* this dainlink has playback support */
  4851. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  4852. },
  4853. {
  4854. .name = MSM_DAILINK_NAME(Compress6),
  4855. .stream_name = "Compress6",
  4856. .cpu_dai_name = "MultiMedia13",
  4857. .platform_name = "msm-compress-dsp",
  4858. .dynamic = 1,
  4859. .dpcm_playback = 1,
  4860. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4861. SND_SOC_DPCM_TRIGGER_POST},
  4862. .codec_dai_name = "snd-soc-dummy-dai",
  4863. .codec_name = "snd-soc-dummy",
  4864. .ignore_suspend = 1,
  4865. .ignore_pmdown_time = 1,
  4866. /* this dainlink has playback support */
  4867. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  4868. },
  4869. {
  4870. .name = MSM_DAILINK_NAME(Compress7),
  4871. .stream_name = "Compress7",
  4872. .cpu_dai_name = "MultiMedia14",
  4873. .platform_name = "msm-compress-dsp",
  4874. .dynamic = 1,
  4875. .dpcm_playback = 1,
  4876. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4877. SND_SOC_DPCM_TRIGGER_POST},
  4878. .codec_dai_name = "snd-soc-dummy-dai",
  4879. .codec_name = "snd-soc-dummy",
  4880. .ignore_suspend = 1,
  4881. .ignore_pmdown_time = 1,
  4882. /* this dainlink has playback support */
  4883. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  4884. },
  4885. {
  4886. .name = MSM_DAILINK_NAME(Compress8),
  4887. .stream_name = "Compress8",
  4888. .cpu_dai_name = "MultiMedia15",
  4889. .platform_name = "msm-compress-dsp",
  4890. .dynamic = 1,
  4891. .dpcm_playback = 1,
  4892. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4893. SND_SOC_DPCM_TRIGGER_POST},
  4894. .codec_dai_name = "snd-soc-dummy-dai",
  4895. .codec_name = "snd-soc-dummy",
  4896. .ignore_suspend = 1,
  4897. .ignore_pmdown_time = 1,
  4898. /* this dainlink has playback support */
  4899. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  4900. },
  4901. {
  4902. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  4903. .stream_name = "MM_NOIRQ_2",
  4904. .cpu_dai_name = "MultiMedia16",
  4905. .platform_name = "msm-pcm-dsp-noirq",
  4906. .dynamic = 1,
  4907. .dpcm_playback = 1,
  4908. .dpcm_capture = 1,
  4909. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4910. SND_SOC_DPCM_TRIGGER_POST},
  4911. .codec_dai_name = "snd-soc-dummy-dai",
  4912. .codec_name = "snd-soc-dummy",
  4913. .ignore_suspend = 1,
  4914. .ignore_pmdown_time = 1,
  4915. /* this dainlink has playback support */
  4916. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  4917. },
  4918. {
  4919. .name = "SLIMBUS_8 Hostless",
  4920. .stream_name = "SLIMBUS8_HOSTLESS Capture",
  4921. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  4922. .platform_name = "msm-pcm-hostless",
  4923. .dynamic = 1,
  4924. .dpcm_capture = 1,
  4925. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4926. SND_SOC_DPCM_TRIGGER_POST},
  4927. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4928. .ignore_suspend = 1,
  4929. .codec_dai_name = "snd-soc-dummy-dai",
  4930. .codec_name = "snd-soc-dummy",
  4931. },
  4932. };
  4933. static struct snd_soc_dai_link msm_pahu_fe_dai_links[] = {
  4934. {
  4935. .name = LPASS_BE_SLIMBUS_4_TX,
  4936. .stream_name = "Slimbus4 Capture",
  4937. .cpu_dai_name = "msm-dai-q6-dev.16393",
  4938. .platform_name = "msm-pcm-hostless",
  4939. .codec_name = "pahu_codec",
  4940. .codec_dai_name = "pahu_vifeedback",
  4941. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  4942. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4943. .ops = &msm_be_ops,
  4944. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4945. .ignore_suspend = 1,
  4946. },
  4947. /* Ultrasound RX DAI Link */
  4948. {
  4949. .name = "SLIMBUS_2 Hostless Playback",
  4950. .stream_name = "SLIMBUS_2 Hostless Playback",
  4951. .cpu_dai_name = "msm-dai-q6-dev.16388",
  4952. .platform_name = "msm-pcm-hostless",
  4953. .codec_name = "pahu_codec",
  4954. .codec_dai_name = "pahu_rx2",
  4955. .ignore_suspend = 1,
  4956. .ignore_pmdown_time = 1,
  4957. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4958. .ops = &msm_slimbus_2_be_ops,
  4959. },
  4960. /* Ultrasound TX DAI Link */
  4961. {
  4962. .name = "SLIMBUS_2 Hostless Capture",
  4963. .stream_name = "SLIMBUS_2 Hostless Capture",
  4964. .cpu_dai_name = "msm-dai-q6-dev.16389",
  4965. .platform_name = "msm-pcm-hostless",
  4966. .codec_name = "pahu_codec",
  4967. .codec_dai_name = "pahu_tx2",
  4968. .ignore_suspend = 1,
  4969. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4970. .ops = &msm_slimbus_2_be_ops,
  4971. },
  4972. };
  4973. static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = {
  4974. {
  4975. .name = LPASS_BE_SLIMBUS_4_TX,
  4976. .stream_name = "Slimbus4 Capture",
  4977. .cpu_dai_name = "msm-dai-q6-dev.16393",
  4978. .platform_name = "msm-pcm-hostless",
  4979. .codec_name = "tavil_codec",
  4980. .codec_dai_name = "tavil_vifeedback",
  4981. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  4982. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4983. .ops = &msm_be_ops,
  4984. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4985. .ignore_suspend = 1,
  4986. },
  4987. /* Ultrasound RX DAI Link */
  4988. {
  4989. .name = "SLIMBUS_2 Hostless Playback",
  4990. .stream_name = "SLIMBUS_2 Hostless Playback",
  4991. .cpu_dai_name = "msm-dai-q6-dev.16388",
  4992. .platform_name = "msm-pcm-hostless",
  4993. .codec_name = "tavil_codec",
  4994. .codec_dai_name = "tavil_rx2",
  4995. .ignore_suspend = 1,
  4996. .ignore_pmdown_time = 1,
  4997. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4998. .ops = &msm_slimbus_2_be_ops,
  4999. },
  5000. /* Ultrasound TX DAI Link */
  5001. {
  5002. .name = "SLIMBUS_2 Hostless Capture",
  5003. .stream_name = "SLIMBUS_2 Hostless Capture",
  5004. .cpu_dai_name = "msm-dai-q6-dev.16389",
  5005. .platform_name = "msm-pcm-hostless",
  5006. .codec_name = "tavil_codec",
  5007. .codec_dai_name = "tavil_tx2",
  5008. .ignore_suspend = 1,
  5009. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5010. .ops = &msm_slimbus_2_be_ops,
  5011. },
  5012. };
  5013. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5014. {
  5015. .name = MSM_DAILINK_NAME(ASM Loopback),
  5016. .stream_name = "MultiMedia6",
  5017. .cpu_dai_name = "MultiMedia6",
  5018. .platform_name = "msm-pcm-loopback",
  5019. .dynamic = 1,
  5020. .dpcm_playback = 1,
  5021. .dpcm_capture = 1,
  5022. .codec_dai_name = "snd-soc-dummy-dai",
  5023. .codec_name = "snd-soc-dummy",
  5024. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5025. SND_SOC_DPCM_TRIGGER_POST},
  5026. .ignore_suspend = 1,
  5027. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5028. .ignore_pmdown_time = 1,
  5029. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5030. },
  5031. {
  5032. .name = "USB Audio Hostless",
  5033. .stream_name = "USB Audio Hostless",
  5034. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  5035. .platform_name = "msm-pcm-hostless",
  5036. .dynamic = 1,
  5037. .dpcm_playback = 1,
  5038. .dpcm_capture = 1,
  5039. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5040. SND_SOC_DPCM_TRIGGER_POST},
  5041. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5042. .ignore_suspend = 1,
  5043. .ignore_pmdown_time = 1,
  5044. .codec_dai_name = "snd-soc-dummy-dai",
  5045. .codec_name = "snd-soc-dummy",
  5046. },
  5047. {
  5048. .name = "SLIMBUS_7 Hostless",
  5049. .stream_name = "SLIMBUS_7 Hostless",
  5050. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  5051. .platform_name = "msm-pcm-hostless",
  5052. .dynamic = 1,
  5053. .dpcm_capture = 1,
  5054. .dpcm_playback = 1,
  5055. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5056. SND_SOC_DPCM_TRIGGER_POST},
  5057. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5058. .ignore_suspend = 1,
  5059. .ignore_pmdown_time = 1,
  5060. .codec_dai_name = "snd-soc-dummy-dai",
  5061. .codec_name = "snd-soc-dummy",
  5062. },
  5063. {
  5064. .name = "Compress Capture",
  5065. .stream_name = "Compress9",
  5066. .cpu_dai_name = "MultiMedia17",
  5067. .platform_name = "msm-compress-dsp",
  5068. .dynamic = 1,
  5069. .dpcm_capture = 1,
  5070. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5071. SND_SOC_DPCM_TRIGGER_POST},
  5072. .codec_dai_name = "snd-soc-dummy-dai",
  5073. .codec_name = "snd-soc-dummy",
  5074. .ignore_suspend = 1,
  5075. .ignore_pmdown_time = 1,
  5076. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5077. },
  5078. };
  5079. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5080. /* Backend AFE DAI Links */
  5081. {
  5082. .name = LPASS_BE_AFE_PCM_RX,
  5083. .stream_name = "AFE Playback",
  5084. .cpu_dai_name = "msm-dai-q6-dev.224",
  5085. .platform_name = "msm-pcm-routing",
  5086. .codec_name = "msm-stub-codec.1",
  5087. .codec_dai_name = "msm-stub-rx",
  5088. .no_pcm = 1,
  5089. .dpcm_playback = 1,
  5090. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5091. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5092. /* this dainlink has playback support */
  5093. .ignore_pmdown_time = 1,
  5094. .ignore_suspend = 1,
  5095. },
  5096. {
  5097. .name = LPASS_BE_AFE_PCM_TX,
  5098. .stream_name = "AFE Capture",
  5099. .cpu_dai_name = "msm-dai-q6-dev.225",
  5100. .platform_name = "msm-pcm-routing",
  5101. .codec_name = "msm-stub-codec.1",
  5102. .codec_dai_name = "msm-stub-tx",
  5103. .no_pcm = 1,
  5104. .dpcm_capture = 1,
  5105. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5106. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5107. .ignore_suspend = 1,
  5108. },
  5109. /* Incall Record Uplink BACK END DAI Link */
  5110. {
  5111. .name = LPASS_BE_INCALL_RECORD_TX,
  5112. .stream_name = "Voice Uplink Capture",
  5113. .cpu_dai_name = "msm-dai-q6-dev.32772",
  5114. .platform_name = "msm-pcm-routing",
  5115. .codec_name = "msm-stub-codec.1",
  5116. .codec_dai_name = "msm-stub-tx",
  5117. .no_pcm = 1,
  5118. .dpcm_capture = 1,
  5119. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5120. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5121. .ignore_suspend = 1,
  5122. },
  5123. /* Incall Record Downlink BACK END DAI Link */
  5124. {
  5125. .name = LPASS_BE_INCALL_RECORD_RX,
  5126. .stream_name = "Voice Downlink Capture",
  5127. .cpu_dai_name = "msm-dai-q6-dev.32771",
  5128. .platform_name = "msm-pcm-routing",
  5129. .codec_name = "msm-stub-codec.1",
  5130. .codec_dai_name = "msm-stub-tx",
  5131. .no_pcm = 1,
  5132. .dpcm_capture = 1,
  5133. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5134. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5135. .ignore_suspend = 1,
  5136. },
  5137. /* Incall Music BACK END DAI Link */
  5138. {
  5139. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5140. .stream_name = "Voice Farend Playback",
  5141. .cpu_dai_name = "msm-dai-q6-dev.32773",
  5142. .platform_name = "msm-pcm-routing",
  5143. .codec_name = "msm-stub-codec.1",
  5144. .codec_dai_name = "msm-stub-rx",
  5145. .no_pcm = 1,
  5146. .dpcm_playback = 1,
  5147. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5148. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5149. .ignore_suspend = 1,
  5150. .ignore_pmdown_time = 1,
  5151. },
  5152. /* Incall Music 2 BACK END DAI Link */
  5153. {
  5154. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5155. .stream_name = "Voice2 Farend Playback",
  5156. .cpu_dai_name = "msm-dai-q6-dev.32770",
  5157. .platform_name = "msm-pcm-routing",
  5158. .codec_name = "msm-stub-codec.1",
  5159. .codec_dai_name = "msm-stub-rx",
  5160. .no_pcm = 1,
  5161. .dpcm_playback = 1,
  5162. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5163. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5164. .ignore_suspend = 1,
  5165. .ignore_pmdown_time = 1,
  5166. },
  5167. {
  5168. .name = LPASS_BE_USB_AUDIO_RX,
  5169. .stream_name = "USB Audio Playback",
  5170. .cpu_dai_name = "msm-dai-q6-dev.28672",
  5171. .platform_name = "msm-pcm-routing",
  5172. .codec_name = "msm-stub-codec.1",
  5173. .codec_dai_name = "msm-stub-rx",
  5174. .no_pcm = 1,
  5175. .dpcm_playback = 1,
  5176. .id = MSM_BACKEND_DAI_USB_RX,
  5177. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5178. .ignore_pmdown_time = 1,
  5179. .ignore_suspend = 1,
  5180. },
  5181. {
  5182. .name = LPASS_BE_USB_AUDIO_TX,
  5183. .stream_name = "USB Audio Capture",
  5184. .cpu_dai_name = "msm-dai-q6-dev.28673",
  5185. .platform_name = "msm-pcm-routing",
  5186. .codec_name = "msm-stub-codec.1",
  5187. .codec_dai_name = "msm-stub-tx",
  5188. .no_pcm = 1,
  5189. .dpcm_capture = 1,
  5190. .id = MSM_BACKEND_DAI_USB_TX,
  5191. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5192. .ignore_suspend = 1,
  5193. },
  5194. {
  5195. .name = LPASS_BE_PRI_TDM_RX_0,
  5196. .stream_name = "Primary TDM0 Playback",
  5197. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  5198. .platform_name = "msm-pcm-routing",
  5199. .codec_name = "msm-stub-codec.1",
  5200. .codec_dai_name = "msm-stub-rx",
  5201. .no_pcm = 1,
  5202. .dpcm_playback = 1,
  5203. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5204. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5205. .ops = &sm8150_tdm_be_ops,
  5206. .ignore_suspend = 1,
  5207. .ignore_pmdown_time = 1,
  5208. },
  5209. {
  5210. .name = LPASS_BE_PRI_TDM_TX_0,
  5211. .stream_name = "Primary TDM0 Capture",
  5212. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  5213. .platform_name = "msm-pcm-routing",
  5214. .codec_name = "msm-stub-codec.1",
  5215. .codec_dai_name = "msm-stub-tx",
  5216. .no_pcm = 1,
  5217. .dpcm_capture = 1,
  5218. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5219. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5220. .ops = &sm8150_tdm_be_ops,
  5221. .ignore_suspend = 1,
  5222. },
  5223. {
  5224. .name = LPASS_BE_SEC_TDM_RX_0,
  5225. .stream_name = "Secondary TDM0 Playback",
  5226. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  5227. .platform_name = "msm-pcm-routing",
  5228. .codec_name = "msm-stub-codec.1",
  5229. .codec_dai_name = "msm-stub-rx",
  5230. .no_pcm = 1,
  5231. .dpcm_playback = 1,
  5232. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5233. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5234. .ops = &sm8150_tdm_be_ops,
  5235. .ignore_suspend = 1,
  5236. .ignore_pmdown_time = 1,
  5237. },
  5238. {
  5239. .name = LPASS_BE_SEC_TDM_TX_0,
  5240. .stream_name = "Secondary TDM0 Capture",
  5241. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  5242. .platform_name = "msm-pcm-routing",
  5243. .codec_name = "msm-stub-codec.1",
  5244. .codec_dai_name = "msm-stub-tx",
  5245. .no_pcm = 1,
  5246. .dpcm_capture = 1,
  5247. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5248. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5249. .ops = &sm8150_tdm_be_ops,
  5250. .ignore_suspend = 1,
  5251. },
  5252. {
  5253. .name = LPASS_BE_TERT_TDM_RX_0,
  5254. .stream_name = "Tertiary TDM0 Playback",
  5255. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  5256. .platform_name = "msm-pcm-routing",
  5257. .codec_name = "msm-stub-codec.1",
  5258. .codec_dai_name = "msm-stub-rx",
  5259. .no_pcm = 1,
  5260. .dpcm_playback = 1,
  5261. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5262. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5263. .ops = &sm8150_tdm_be_ops,
  5264. .ignore_suspend = 1,
  5265. .ignore_pmdown_time = 1,
  5266. },
  5267. {
  5268. .name = LPASS_BE_TERT_TDM_TX_0,
  5269. .stream_name = "Tertiary TDM0 Capture",
  5270. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  5271. .platform_name = "msm-pcm-routing",
  5272. .codec_name = "msm-stub-codec.1",
  5273. .codec_dai_name = "msm-stub-tx",
  5274. .no_pcm = 1,
  5275. .dpcm_capture = 1,
  5276. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5277. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5278. .ops = &sm8150_tdm_be_ops,
  5279. .ignore_suspend = 1,
  5280. },
  5281. {
  5282. .name = LPASS_BE_QUAT_TDM_RX_0,
  5283. .stream_name = "Quaternary TDM0 Playback",
  5284. .cpu_dai_name = "msm-dai-q6-tdm.36912",
  5285. .platform_name = "msm-pcm-routing",
  5286. .codec_name = "msm-stub-codec.1",
  5287. .codec_dai_name = "msm-stub-rx",
  5288. .no_pcm = 1,
  5289. .dpcm_playback = 1,
  5290. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5291. .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
  5292. .ops = &sm8150_tdm_be_ops,
  5293. .ignore_suspend = 1,
  5294. .ignore_pmdown_time = 1,
  5295. },
  5296. {
  5297. .name = LPASS_BE_QUAT_TDM_TX_0,
  5298. .stream_name = "Quaternary TDM0 Capture",
  5299. .cpu_dai_name = "msm-dai-q6-tdm.36913",
  5300. .platform_name = "msm-pcm-routing",
  5301. .codec_name = "msm-stub-codec.1",
  5302. .codec_dai_name = "msm-stub-tx",
  5303. .no_pcm = 1,
  5304. .dpcm_capture = 1,
  5305. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5306. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5307. .ops = &sm8150_tdm_be_ops,
  5308. .ignore_suspend = 1,
  5309. },
  5310. };
  5311. static struct snd_soc_dai_link msm_pahu_be_dai_links[] = {
  5312. {
  5313. .name = LPASS_BE_SLIMBUS_0_RX,
  5314. .stream_name = "Slimbus Playback",
  5315. .cpu_dai_name = "msm-dai-q6-dev.16384",
  5316. .platform_name = "msm-pcm-routing",
  5317. .codec_name = "pahu_codec",
  5318. .codec_dai_name = "pahu_rx1",
  5319. .no_pcm = 1,
  5320. .dpcm_playback = 1,
  5321. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  5322. .init = &msm_audrx_init,
  5323. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5324. /* this dainlink has playback support */
  5325. .ignore_pmdown_time = 1,
  5326. .ignore_suspend = 1,
  5327. .ops = &msm_be_ops,
  5328. },
  5329. {
  5330. .name = LPASS_BE_SLIMBUS_0_TX,
  5331. .stream_name = "Slimbus Capture",
  5332. .cpu_dai_name = "msm-dai-q6-dev.16385",
  5333. .platform_name = "msm-pcm-routing",
  5334. .codec_name = "pahu_codec",
  5335. .codec_dai_name = "pahu_tx1",
  5336. .no_pcm = 1,
  5337. .dpcm_capture = 1,
  5338. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  5339. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5340. .ignore_suspend = 1,
  5341. .ops = &msm_be_ops,
  5342. },
  5343. {
  5344. .name = LPASS_BE_SLIMBUS_1_RX,
  5345. .stream_name = "Slimbus1 Playback",
  5346. .cpu_dai_name = "msm-dai-q6-dev.16386",
  5347. .platform_name = "msm-pcm-routing",
  5348. .codec_name = "pahu_codec",
  5349. .codec_dai_name = "pahu_rx1",
  5350. .no_pcm = 1,
  5351. .dpcm_playback = 1,
  5352. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  5353. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5354. .ops = &msm_be_ops,
  5355. /* dai link has playback support */
  5356. .ignore_pmdown_time = 1,
  5357. .ignore_suspend = 1,
  5358. },
  5359. {
  5360. .name = LPASS_BE_SLIMBUS_1_TX,
  5361. .stream_name = "Slimbus1 Capture",
  5362. .cpu_dai_name = "msm-dai-q6-dev.16387",
  5363. .platform_name = "msm-pcm-routing",
  5364. .codec_name = "pahu_codec",
  5365. .codec_dai_name = "pahu_tx3",
  5366. .no_pcm = 1,
  5367. .dpcm_capture = 1,
  5368. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  5369. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5370. .ops = &msm_be_ops,
  5371. .ignore_suspend = 1,
  5372. },
  5373. {
  5374. .name = LPASS_BE_SLIMBUS_2_RX,
  5375. .stream_name = "Slimbus2 Playback",
  5376. .cpu_dai_name = "msm-dai-q6-dev.16388",
  5377. .platform_name = "msm-pcm-routing",
  5378. .codec_name = "pahu_codec",
  5379. .codec_dai_name = "pahu_rx2",
  5380. .no_pcm = 1,
  5381. .dpcm_playback = 1,
  5382. .id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
  5383. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5384. .ops = &msm_be_ops,
  5385. .ignore_pmdown_time = 1,
  5386. .ignore_suspend = 1,
  5387. },
  5388. {
  5389. .name = LPASS_BE_SLIMBUS_3_RX,
  5390. .stream_name = "Slimbus3 Playback",
  5391. .cpu_dai_name = "msm-dai-q6-dev.16390",
  5392. .platform_name = "msm-pcm-routing",
  5393. .codec_name = "pahu_codec",
  5394. .codec_dai_name = "pahu_rx1",
  5395. .no_pcm = 1,
  5396. .dpcm_playback = 1,
  5397. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  5398. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5399. .ops = &msm_be_ops,
  5400. /* dai link has playback support */
  5401. .ignore_pmdown_time = 1,
  5402. .ignore_suspend = 1,
  5403. },
  5404. {
  5405. .name = LPASS_BE_SLIMBUS_3_TX,
  5406. .stream_name = "Slimbus3 Capture",
  5407. .cpu_dai_name = "msm-dai-q6-dev.16391",
  5408. .platform_name = "msm-pcm-routing",
  5409. .codec_name = "pahu_codec",
  5410. .codec_dai_name = "pahu_tx1",
  5411. .no_pcm = 1,
  5412. .dpcm_capture = 1,
  5413. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  5414. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5415. .ops = &msm_be_ops,
  5416. .ignore_suspend = 1,
  5417. },
  5418. {
  5419. .name = LPASS_BE_SLIMBUS_4_RX,
  5420. .stream_name = "Slimbus4 Playback",
  5421. .cpu_dai_name = "msm-dai-q6-dev.16392",
  5422. .platform_name = "msm-pcm-routing",
  5423. .codec_name = "pahu_codec",
  5424. .codec_dai_name = "pahu_rx1",
  5425. .no_pcm = 1,
  5426. .dpcm_playback = 1,
  5427. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  5428. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5429. .ops = &msm_be_ops,
  5430. /* dai link has playback support */
  5431. .ignore_pmdown_time = 1,
  5432. .ignore_suspend = 1,
  5433. },
  5434. {
  5435. .name = LPASS_BE_SLIMBUS_5_RX,
  5436. .stream_name = "Slimbus5 Playback",
  5437. .cpu_dai_name = "msm-dai-q6-dev.16394",
  5438. .platform_name = "msm-pcm-routing",
  5439. .codec_name = "pahu_codec",
  5440. .codec_dai_name = "pahu_rx3",
  5441. .no_pcm = 1,
  5442. .dpcm_playback = 1,
  5443. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  5444. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5445. .ops = &msm_be_ops,
  5446. /* dai link has playback support */
  5447. .ignore_pmdown_time = 1,
  5448. .ignore_suspend = 1,
  5449. },
  5450. /* MAD BE */
  5451. {
  5452. .name = LPASS_BE_SLIMBUS_5_TX,
  5453. .stream_name = "Slimbus5 Capture",
  5454. .cpu_dai_name = "msm-dai-q6-dev.16395",
  5455. .platform_name = "msm-pcm-routing",
  5456. .codec_name = "pahu_codec",
  5457. .codec_dai_name = "pahu_mad1",
  5458. .no_pcm = 1,
  5459. .dpcm_capture = 1,
  5460. .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  5461. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5462. .ops = &msm_be_ops,
  5463. .ignore_suspend = 1,
  5464. },
  5465. {
  5466. .name = LPASS_BE_SLIMBUS_6_RX,
  5467. .stream_name = "Slimbus6 Playback",
  5468. .cpu_dai_name = "msm-dai-q6-dev.16396",
  5469. .platform_name = "msm-pcm-routing",
  5470. .codec_name = "pahu_codec",
  5471. .codec_dai_name = "pahu_rx4",
  5472. .no_pcm = 1,
  5473. .dpcm_playback = 1,
  5474. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  5475. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5476. .ops = &msm_be_ops,
  5477. /* dai link has playback support */
  5478. .ignore_pmdown_time = 1,
  5479. .ignore_suspend = 1,
  5480. },
  5481. /* Slimbus VI Recording */
  5482. {
  5483. .name = LPASS_BE_SLIMBUS_TX_VI,
  5484. .stream_name = "Slimbus4 Capture",
  5485. .cpu_dai_name = "msm-dai-q6-dev.16393",
  5486. .platform_name = "msm-pcm-routing",
  5487. .codec_name = "pahu_codec",
  5488. .codec_dai_name = "pahu_vifeedback",
  5489. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  5490. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5491. .ops = &msm_be_ops,
  5492. .ignore_suspend = 1,
  5493. .no_pcm = 1,
  5494. .dpcm_capture = 1,
  5495. },
  5496. };
  5497. static struct snd_soc_dai_link msm_tavil_be_dai_links[] = {
  5498. {
  5499. .name = LPASS_BE_SLIMBUS_0_RX,
  5500. .stream_name = "Slimbus Playback",
  5501. .cpu_dai_name = "msm-dai-q6-dev.16384",
  5502. .platform_name = "msm-pcm-routing",
  5503. .codec_name = "tavil_codec",
  5504. .codec_dai_name = "tavil_rx1",
  5505. .no_pcm = 1,
  5506. .dpcm_playback = 1,
  5507. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  5508. .init = &msm_audrx_init,
  5509. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5510. /* this dainlink has playback support */
  5511. .ignore_pmdown_time = 1,
  5512. .ignore_suspend = 1,
  5513. .ops = &msm_be_ops,
  5514. },
  5515. {
  5516. .name = LPASS_BE_SLIMBUS_0_TX,
  5517. .stream_name = "Slimbus Capture",
  5518. .cpu_dai_name = "msm-dai-q6-dev.16385",
  5519. .platform_name = "msm-pcm-routing",
  5520. .codec_name = "tavil_codec",
  5521. .codec_dai_name = "tavil_tx1",
  5522. .no_pcm = 1,
  5523. .dpcm_capture = 1,
  5524. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  5525. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5526. .ignore_suspend = 1,
  5527. .ops = &msm_be_ops,
  5528. },
  5529. {
  5530. .name = LPASS_BE_SLIMBUS_1_RX,
  5531. .stream_name = "Slimbus1 Playback",
  5532. .cpu_dai_name = "msm-dai-q6-dev.16386",
  5533. .platform_name = "msm-pcm-routing",
  5534. .codec_name = "tavil_codec",
  5535. .codec_dai_name = "tavil_rx1",
  5536. .no_pcm = 1,
  5537. .dpcm_playback = 1,
  5538. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  5539. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5540. .ops = &msm_be_ops,
  5541. /* dai link has playback support */
  5542. .ignore_pmdown_time = 1,
  5543. .ignore_suspend = 1,
  5544. },
  5545. {
  5546. .name = LPASS_BE_SLIMBUS_1_TX,
  5547. .stream_name = "Slimbus1 Capture",
  5548. .cpu_dai_name = "msm-dai-q6-dev.16387",
  5549. .platform_name = "msm-pcm-routing",
  5550. .codec_name = "tavil_codec",
  5551. .codec_dai_name = "tavil_tx3",
  5552. .no_pcm = 1,
  5553. .dpcm_capture = 1,
  5554. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  5555. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5556. .ops = &msm_be_ops,
  5557. .ignore_suspend = 1,
  5558. },
  5559. {
  5560. .name = LPASS_BE_SLIMBUS_2_RX,
  5561. .stream_name = "Slimbus2 Playback",
  5562. .cpu_dai_name = "msm-dai-q6-dev.16388",
  5563. .platform_name = "msm-pcm-routing",
  5564. .codec_name = "tavil_codec",
  5565. .codec_dai_name = "tavil_rx2",
  5566. .no_pcm = 1,
  5567. .dpcm_playback = 1,
  5568. .id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
  5569. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5570. .ops = &msm_be_ops,
  5571. .ignore_pmdown_time = 1,
  5572. .ignore_suspend = 1,
  5573. },
  5574. {
  5575. .name = LPASS_BE_SLIMBUS_3_RX,
  5576. .stream_name = "Slimbus3 Playback",
  5577. .cpu_dai_name = "msm-dai-q6-dev.16390",
  5578. .platform_name = "msm-pcm-routing",
  5579. .codec_name = "tavil_codec",
  5580. .codec_dai_name = "tavil_rx1",
  5581. .no_pcm = 1,
  5582. .dpcm_playback = 1,
  5583. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  5584. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5585. .ops = &msm_be_ops,
  5586. /* dai link has playback support */
  5587. .ignore_pmdown_time = 1,
  5588. .ignore_suspend = 1,
  5589. },
  5590. {
  5591. .name = LPASS_BE_SLIMBUS_3_TX,
  5592. .stream_name = "Slimbus3 Capture",
  5593. .cpu_dai_name = "msm-dai-q6-dev.16391",
  5594. .platform_name = "msm-pcm-routing",
  5595. .codec_name = "tavil_codec",
  5596. .codec_dai_name = "tavil_tx1",
  5597. .no_pcm = 1,
  5598. .dpcm_capture = 1,
  5599. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  5600. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5601. .ops = &msm_be_ops,
  5602. .ignore_suspend = 1,
  5603. },
  5604. {
  5605. .name = LPASS_BE_SLIMBUS_4_RX,
  5606. .stream_name = "Slimbus4 Playback",
  5607. .cpu_dai_name = "msm-dai-q6-dev.16392",
  5608. .platform_name = "msm-pcm-routing",
  5609. .codec_name = "tavil_codec",
  5610. .codec_dai_name = "tavil_rx1",
  5611. .no_pcm = 1,
  5612. .dpcm_playback = 1,
  5613. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  5614. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5615. .ops = &msm_be_ops,
  5616. /* dai link has playback support */
  5617. .ignore_pmdown_time = 1,
  5618. .ignore_suspend = 1,
  5619. },
  5620. {
  5621. .name = LPASS_BE_SLIMBUS_5_RX,
  5622. .stream_name = "Slimbus5 Playback",
  5623. .cpu_dai_name = "msm-dai-q6-dev.16394",
  5624. .platform_name = "msm-pcm-routing",
  5625. .codec_name = "tavil_codec",
  5626. .codec_dai_name = "tavil_rx3",
  5627. .no_pcm = 1,
  5628. .dpcm_playback = 1,
  5629. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  5630. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5631. .ops = &msm_be_ops,
  5632. /* dai link has playback support */
  5633. .ignore_pmdown_time = 1,
  5634. .ignore_suspend = 1,
  5635. },
  5636. /* MAD BE */
  5637. {
  5638. .name = LPASS_BE_SLIMBUS_5_TX,
  5639. .stream_name = "Slimbus5 Capture",
  5640. .cpu_dai_name = "msm-dai-q6-dev.16395",
  5641. .platform_name = "msm-pcm-routing",
  5642. .codec_name = "tavil_codec",
  5643. .codec_dai_name = "tavil_mad1",
  5644. .no_pcm = 1,
  5645. .dpcm_capture = 1,
  5646. .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  5647. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5648. .ops = &msm_be_ops,
  5649. .ignore_suspend = 1,
  5650. },
  5651. {
  5652. .name = LPASS_BE_SLIMBUS_6_RX,
  5653. .stream_name = "Slimbus6 Playback",
  5654. .cpu_dai_name = "msm-dai-q6-dev.16396",
  5655. .platform_name = "msm-pcm-routing",
  5656. .codec_name = "tavil_codec",
  5657. .codec_dai_name = "tavil_rx4",
  5658. .no_pcm = 1,
  5659. .dpcm_playback = 1,
  5660. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  5661. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5662. .ops = &msm_be_ops,
  5663. /* dai link has playback support */
  5664. .ignore_pmdown_time = 1,
  5665. .ignore_suspend = 1,
  5666. },
  5667. /* Slimbus VI Recording */
  5668. {
  5669. .name = LPASS_BE_SLIMBUS_TX_VI,
  5670. .stream_name = "Slimbus4 Capture",
  5671. .cpu_dai_name = "msm-dai-q6-dev.16393",
  5672. .platform_name = "msm-pcm-routing",
  5673. .codec_name = "tavil_codec",
  5674. .codec_dai_name = "tavil_vifeedback",
  5675. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  5676. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5677. .ops = &msm_be_ops,
  5678. .ignore_suspend = 1,
  5679. .no_pcm = 1,
  5680. .dpcm_capture = 1,
  5681. },
  5682. };
  5683. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5684. {
  5685. .name = LPASS_BE_SLIMBUS_7_RX,
  5686. .stream_name = "Slimbus7 Playback",
  5687. .cpu_dai_name = "msm-dai-q6-dev.16398",
  5688. .platform_name = "msm-pcm-routing",
  5689. .codec_name = "btfmslim_slave",
  5690. /* BT codec driver determines capabilities based on
  5691. * dai name, bt codecdai name should always contains
  5692. * supported usecase information
  5693. */
  5694. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  5695. .no_pcm = 1,
  5696. .dpcm_playback = 1,
  5697. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5698. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5699. .ops = &msm_wcn_ops,
  5700. /* dai link has playback support */
  5701. .ignore_pmdown_time = 1,
  5702. .ignore_suspend = 1,
  5703. },
  5704. {
  5705. .name = LPASS_BE_SLIMBUS_7_TX,
  5706. .stream_name = "Slimbus7 Capture",
  5707. .cpu_dai_name = "msm-dai-q6-dev.16399",
  5708. .platform_name = "msm-pcm-routing",
  5709. .codec_name = "btfmslim_slave",
  5710. .codec_dai_name = "btfm_bt_sco_slim_tx",
  5711. .no_pcm = 1,
  5712. .dpcm_capture = 1,
  5713. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5714. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5715. .ops = &msm_wcn_ops,
  5716. .ignore_suspend = 1,
  5717. },
  5718. {
  5719. .name = LPASS_BE_SLIMBUS_8_TX,
  5720. .stream_name = "Slimbus8 Capture",
  5721. .cpu_dai_name = "msm-dai-q6-dev.16401",
  5722. .platform_name = "msm-pcm-routing",
  5723. .codec_name = "btfmslim_slave",
  5724. .codec_dai_name = "btfm_fm_slim_tx",
  5725. .no_pcm = 1,
  5726. .dpcm_capture = 1,
  5727. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  5728. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5729. .init = &msm_wcn_init,
  5730. .ops = &msm_wcn_ops,
  5731. .ignore_suspend = 1,
  5732. },
  5733. };
  5734. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  5735. /* DISP PORT BACK END DAI Link */
  5736. {
  5737. .name = LPASS_BE_DISPLAY_PORT,
  5738. .stream_name = "Display Port Playback",
  5739. .cpu_dai_name = "msm-dai-q6-dp.24608",
  5740. .platform_name = "msm-pcm-routing",
  5741. .codec_name = "msm-ext-disp-audio-codec-rx",
  5742. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  5743. .no_pcm = 1,
  5744. .dpcm_playback = 1,
  5745. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  5746. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5747. .ignore_pmdown_time = 1,
  5748. .ignore_suspend = 1,
  5749. },
  5750. /* DISP PORT 1 BACK END DAI Link */
  5751. {
  5752. .name = LPASS_BE_DISPLAY_PORT1,
  5753. .stream_name = "Display Port1 Playback",
  5754. .cpu_dai_name = "msm-dai-q6-dp.24608",
  5755. .platform_name = "msm-pcm-routing",
  5756. .codec_name = "msm-ext-disp-audio-codec-rx",
  5757. .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
  5758. .no_pcm = 1,
  5759. .dpcm_playback = 1,
  5760. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  5761. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5762. .ignore_pmdown_time = 1,
  5763. .ignore_suspend = 1,
  5764. },
  5765. };
  5766. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  5767. {
  5768. .name = LPASS_BE_PRI_MI2S_RX,
  5769. .stream_name = "Primary MI2S Playback",
  5770. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  5771. .platform_name = "msm-pcm-routing",
  5772. .codec_name = "msm-stub-codec.1",
  5773. .codec_dai_name = "msm-stub-rx",
  5774. .no_pcm = 1,
  5775. .dpcm_playback = 1,
  5776. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  5777. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5778. .ops = &msm_mi2s_be_ops,
  5779. .ignore_suspend = 1,
  5780. .ignore_pmdown_time = 1,
  5781. },
  5782. {
  5783. .name = LPASS_BE_PRI_MI2S_TX,
  5784. .stream_name = "Primary MI2S Capture",
  5785. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  5786. .platform_name = "msm-pcm-routing",
  5787. .codec_name = "msm-stub-codec.1",
  5788. .codec_dai_name = "msm-stub-tx",
  5789. .no_pcm = 1,
  5790. .dpcm_capture = 1,
  5791. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  5792. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5793. .ops = &msm_mi2s_be_ops,
  5794. .ignore_suspend = 1,
  5795. },
  5796. {
  5797. .name = LPASS_BE_SEC_MI2S_RX,
  5798. .stream_name = "Secondary MI2S Playback",
  5799. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  5800. .platform_name = "msm-pcm-routing",
  5801. .codec_name = "msm-stub-codec.1",
  5802. .codec_dai_name = "msm-stub-rx",
  5803. .no_pcm = 1,
  5804. .dpcm_playback = 1,
  5805. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  5806. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5807. .ops = &msm_mi2s_be_ops,
  5808. .ignore_suspend = 1,
  5809. .ignore_pmdown_time = 1,
  5810. },
  5811. {
  5812. .name = LPASS_BE_SEC_MI2S_TX,
  5813. .stream_name = "Secondary MI2S Capture",
  5814. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  5815. .platform_name = "msm-pcm-routing",
  5816. .codec_name = "msm-stub-codec.1",
  5817. .codec_dai_name = "msm-stub-tx",
  5818. .no_pcm = 1,
  5819. .dpcm_capture = 1,
  5820. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  5821. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5822. .ops = &msm_mi2s_be_ops,
  5823. .ignore_suspend = 1,
  5824. },
  5825. {
  5826. .name = LPASS_BE_TERT_MI2S_RX,
  5827. .stream_name = "Tertiary MI2S Playback",
  5828. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  5829. .platform_name = "msm-pcm-routing",
  5830. .codec_name = "msm-stub-codec.1",
  5831. .codec_dai_name = "msm-stub-rx",
  5832. .no_pcm = 1,
  5833. .dpcm_playback = 1,
  5834. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  5835. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5836. .ops = &msm_mi2s_be_ops,
  5837. .ignore_suspend = 1,
  5838. .ignore_pmdown_time = 1,
  5839. },
  5840. {
  5841. .name = LPASS_BE_TERT_MI2S_TX,
  5842. .stream_name = "Tertiary MI2S Capture",
  5843. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  5844. .platform_name = "msm-pcm-routing",
  5845. .codec_name = "msm-stub-codec.1",
  5846. .codec_dai_name = "msm-stub-tx",
  5847. .no_pcm = 1,
  5848. .dpcm_capture = 1,
  5849. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  5850. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5851. .ops = &msm_mi2s_be_ops,
  5852. .ignore_suspend = 1,
  5853. },
  5854. {
  5855. .name = LPASS_BE_QUAT_MI2S_RX,
  5856. .stream_name = "Quaternary MI2S Playback",
  5857. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  5858. .platform_name = "msm-pcm-routing",
  5859. .codec_name = "msm-stub-codec.1",
  5860. .codec_dai_name = "msm-stub-rx",
  5861. .no_pcm = 1,
  5862. .dpcm_playback = 1,
  5863. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  5864. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5865. .ops = &msm_mi2s_be_ops,
  5866. .ignore_suspend = 1,
  5867. .ignore_pmdown_time = 1,
  5868. },
  5869. {
  5870. .name = LPASS_BE_QUAT_MI2S_TX,
  5871. .stream_name = "Quaternary MI2S Capture",
  5872. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  5873. .platform_name = "msm-pcm-routing",
  5874. .codec_name = "msm-stub-codec.1",
  5875. .codec_dai_name = "msm-stub-tx",
  5876. .no_pcm = 1,
  5877. .dpcm_capture = 1,
  5878. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  5879. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5880. .ops = &msm_mi2s_be_ops,
  5881. .ignore_suspend = 1,
  5882. },
  5883. {
  5884. .name = LPASS_BE_QUIN_MI2S_RX,
  5885. .stream_name = "Quinary MI2S Playback",
  5886. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  5887. .platform_name = "msm-pcm-routing",
  5888. .codec_name = "msm-stub-codec.1",
  5889. .codec_dai_name = "msm-stub-rx",
  5890. .no_pcm = 1,
  5891. .dpcm_playback = 1,
  5892. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  5893. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5894. .ops = &msm_mi2s_be_ops,
  5895. .ignore_suspend = 1,
  5896. .ignore_pmdown_time = 1,
  5897. },
  5898. {
  5899. .name = LPASS_BE_QUIN_MI2S_TX,
  5900. .stream_name = "Quinary MI2S Capture",
  5901. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  5902. .platform_name = "msm-pcm-routing",
  5903. .codec_name = "msm-stub-codec.1",
  5904. .codec_dai_name = "msm-stub-tx",
  5905. .no_pcm = 1,
  5906. .dpcm_capture = 1,
  5907. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  5908. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5909. .ops = &msm_mi2s_be_ops,
  5910. .ignore_suspend = 1,
  5911. },
  5912. };
  5913. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  5914. /* Primary AUX PCM Backend DAI Links */
  5915. {
  5916. .name = LPASS_BE_AUXPCM_RX,
  5917. .stream_name = "AUX PCM Playback",
  5918. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  5919. .platform_name = "msm-pcm-routing",
  5920. .codec_name = "msm-stub-codec.1",
  5921. .codec_dai_name = "msm-stub-rx",
  5922. .no_pcm = 1,
  5923. .dpcm_playback = 1,
  5924. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  5925. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5926. .ignore_pmdown_time = 1,
  5927. .ignore_suspend = 1,
  5928. },
  5929. {
  5930. .name = LPASS_BE_AUXPCM_TX,
  5931. .stream_name = "AUX PCM Capture",
  5932. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  5933. .platform_name = "msm-pcm-routing",
  5934. .codec_name = "msm-stub-codec.1",
  5935. .codec_dai_name = "msm-stub-tx",
  5936. .no_pcm = 1,
  5937. .dpcm_capture = 1,
  5938. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  5939. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5940. .ignore_suspend = 1,
  5941. },
  5942. /* Secondary AUX PCM Backend DAI Links */
  5943. {
  5944. .name = LPASS_BE_SEC_AUXPCM_RX,
  5945. .stream_name = "Sec AUX PCM Playback",
  5946. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  5947. .platform_name = "msm-pcm-routing",
  5948. .codec_name = "msm-stub-codec.1",
  5949. .codec_dai_name = "msm-stub-rx",
  5950. .no_pcm = 1,
  5951. .dpcm_playback = 1,
  5952. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  5953. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5954. .ignore_pmdown_time = 1,
  5955. .ignore_suspend = 1,
  5956. },
  5957. {
  5958. .name = LPASS_BE_SEC_AUXPCM_TX,
  5959. .stream_name = "Sec AUX PCM Capture",
  5960. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  5961. .platform_name = "msm-pcm-routing",
  5962. .codec_name = "msm-stub-codec.1",
  5963. .codec_dai_name = "msm-stub-tx",
  5964. .no_pcm = 1,
  5965. .dpcm_capture = 1,
  5966. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  5967. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5968. .ignore_suspend = 1,
  5969. },
  5970. /* Tertiary AUX PCM Backend DAI Links */
  5971. {
  5972. .name = LPASS_BE_TERT_AUXPCM_RX,
  5973. .stream_name = "Tert AUX PCM Playback",
  5974. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  5975. .platform_name = "msm-pcm-routing",
  5976. .codec_name = "msm-stub-codec.1",
  5977. .codec_dai_name = "msm-stub-rx",
  5978. .no_pcm = 1,
  5979. .dpcm_playback = 1,
  5980. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  5981. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5982. .ignore_suspend = 1,
  5983. },
  5984. {
  5985. .name = LPASS_BE_TERT_AUXPCM_TX,
  5986. .stream_name = "Tert AUX PCM Capture",
  5987. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  5988. .platform_name = "msm-pcm-routing",
  5989. .codec_name = "msm-stub-codec.1",
  5990. .codec_dai_name = "msm-stub-tx",
  5991. .no_pcm = 1,
  5992. .dpcm_capture = 1,
  5993. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  5994. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5995. .ignore_suspend = 1,
  5996. },
  5997. /* Quaternary AUX PCM Backend DAI Links */
  5998. {
  5999. .name = LPASS_BE_QUAT_AUXPCM_RX,
  6000. .stream_name = "Quat AUX PCM Playback",
  6001. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  6002. .platform_name = "msm-pcm-routing",
  6003. .codec_name = "msm-stub-codec.1",
  6004. .codec_dai_name = "msm-stub-rx",
  6005. .no_pcm = 1,
  6006. .dpcm_playback = 1,
  6007. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  6008. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6009. .ignore_pmdown_time = 1,
  6010. .ignore_suspend = 1,
  6011. },
  6012. {
  6013. .name = LPASS_BE_QUAT_AUXPCM_TX,
  6014. .stream_name = "Quat AUX PCM Capture",
  6015. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  6016. .platform_name = "msm-pcm-routing",
  6017. .codec_name = "msm-stub-codec.1",
  6018. .codec_dai_name = "msm-stub-tx",
  6019. .no_pcm = 1,
  6020. .dpcm_capture = 1,
  6021. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  6022. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6023. .ignore_suspend = 1,
  6024. },
  6025. /* Quinary AUX PCM Backend DAI Links */
  6026. {
  6027. .name = LPASS_BE_QUIN_AUXPCM_RX,
  6028. .stream_name = "Quin AUX PCM Playback",
  6029. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  6030. .platform_name = "msm-pcm-routing",
  6031. .codec_name = "msm-stub-codec.1",
  6032. .codec_dai_name = "msm-stub-rx",
  6033. .no_pcm = 1,
  6034. .dpcm_playback = 1,
  6035. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  6036. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6037. .ignore_pmdown_time = 1,
  6038. .ignore_suspend = 1,
  6039. },
  6040. {
  6041. .name = LPASS_BE_QUIN_AUXPCM_TX,
  6042. .stream_name = "Quin AUX PCM Capture",
  6043. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  6044. .platform_name = "msm-pcm-routing",
  6045. .codec_name = "msm-stub-codec.1",
  6046. .codec_dai_name = "msm-stub-tx",
  6047. .no_pcm = 1,
  6048. .dpcm_capture = 1,
  6049. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  6050. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6051. .ignore_suspend = 1,
  6052. },
  6053. };
  6054. static struct snd_soc_dai_link msm_pahu_snd_card_dai_links[
  6055. ARRAY_SIZE(msm_common_dai_links) +
  6056. ARRAY_SIZE(msm_pahu_fe_dai_links) +
  6057. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6058. ARRAY_SIZE(msm_common_be_dai_links) +
  6059. ARRAY_SIZE(msm_pahu_be_dai_links) +
  6060. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6061. ARRAY_SIZE(ext_disp_be_dai_link) +
  6062. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6063. ARRAY_SIZE(msm_auxpcm_be_dai_links)];
  6064. static struct snd_soc_dai_link msm_tavil_dai_links[
  6065. ARRAY_SIZE(msm_common_dai_links) +
  6066. ARRAY_SIZE(msm_tavil_fe_dai_links) +
  6067. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6068. ARRAY_SIZE(msm_common_be_dai_links) +
  6069. ARRAY_SIZE(msm_tavil_be_dai_links) +
  6070. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6071. ARRAY_SIZE(ext_disp_be_dai_link) +
  6072. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6073. ARRAY_SIZE(msm_auxpcm_be_dai_links)];
  6074. static int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
  6075. {
  6076. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  6077. struct snd_soc_pcm_runtime *rtd;
  6078. int ret = 0;
  6079. void *mbhc_calibration;
  6080. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  6081. if (!rtd) {
  6082. dev_err(card->dev,
  6083. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  6084. __func__, be_dl_name);
  6085. ret = -EINVAL;
  6086. goto err_pcm_runtime;
  6087. }
  6088. mbhc_calibration = def_wcd_mbhc_cal();
  6089. if (!mbhc_calibration) {
  6090. ret = -ENOMEM;
  6091. goto err_mbhc_cal;
  6092. }
  6093. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6094. ret = tavil_mbhc_hs_detect(rtd->codec, &wcd_mbhc_cfg);
  6095. if (ret) {
  6096. dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
  6097. __func__, ret);
  6098. goto err_hs_detect;
  6099. }
  6100. return 0;
  6101. err_hs_detect:
  6102. kfree(mbhc_calibration);
  6103. err_mbhc_cal:
  6104. err_pcm_runtime:
  6105. return ret;
  6106. }
  6107. struct snd_soc_card snd_soc_card_pahu_msm = {
  6108. .name = "sm8150-pahu-snd-card",
  6109. };
  6110. struct snd_soc_card snd_soc_card_tavil_msm = {
  6111. .name = "sm8150-tavil-snd-card",
  6112. .late_probe = msm_snd_card_tavil_late_probe,
  6113. };
  6114. static int msm_populate_dai_link_component_of_node(
  6115. struct snd_soc_card *card)
  6116. {
  6117. int i, index, ret = 0;
  6118. struct device *cdev = card->dev;
  6119. struct snd_soc_dai_link *dai_link = card->dai_link;
  6120. struct device_node *np;
  6121. if (!cdev) {
  6122. pr_err("%s: Sound card device memory NULL\n", __func__);
  6123. return -ENODEV;
  6124. }
  6125. for (i = 0; i < card->num_links; i++) {
  6126. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  6127. continue;
  6128. /* populate platform_of_node for snd card dai links */
  6129. if (dai_link[i].platform_name &&
  6130. !dai_link[i].platform_of_node) {
  6131. index = of_property_match_string(cdev->of_node,
  6132. "asoc-platform-names",
  6133. dai_link[i].platform_name);
  6134. if (index < 0) {
  6135. pr_err("%s: No match found for platform name: %s\n",
  6136. __func__, dai_link[i].platform_name);
  6137. ret = index;
  6138. goto err;
  6139. }
  6140. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6141. index);
  6142. if (!np) {
  6143. pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
  6144. __func__, dai_link[i].platform_name,
  6145. index);
  6146. ret = -ENODEV;
  6147. goto err;
  6148. }
  6149. dai_link[i].platform_of_node = np;
  6150. dai_link[i].platform_name = NULL;
  6151. }
  6152. /* populate cpu_of_node for snd card dai links */
  6153. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  6154. index = of_property_match_string(cdev->of_node,
  6155. "asoc-cpu-names",
  6156. dai_link[i].cpu_dai_name);
  6157. if (index >= 0) {
  6158. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6159. index);
  6160. if (!np) {
  6161. pr_err("%s: retrieving phandle for cpu dai %s failed\n",
  6162. __func__,
  6163. dai_link[i].cpu_dai_name);
  6164. ret = -ENODEV;
  6165. goto err;
  6166. }
  6167. dai_link[i].cpu_of_node = np;
  6168. dai_link[i].cpu_dai_name = NULL;
  6169. }
  6170. }
  6171. /* populate codec_of_node for snd card dai links */
  6172. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  6173. index = of_property_match_string(cdev->of_node,
  6174. "asoc-codec-names",
  6175. dai_link[i].codec_name);
  6176. if (index < 0)
  6177. continue;
  6178. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  6179. index);
  6180. if (!np) {
  6181. pr_err("%s: retrieving phandle for codec %s failed\n",
  6182. __func__, dai_link[i].codec_name);
  6183. ret = -ENODEV;
  6184. goto err;
  6185. }
  6186. dai_link[i].codec_of_node = np;
  6187. dai_link[i].codec_name = NULL;
  6188. }
  6189. }
  6190. err:
  6191. return ret;
  6192. }
  6193. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6194. {
  6195. int ret = 0;
  6196. struct snd_soc_codec *codec = rtd->codec;
  6197. ret = snd_soc_add_codec_controls(codec, msm_snd_controls,
  6198. ARRAY_SIZE(msm_snd_controls));
  6199. if (ret < 0) {
  6200. dev_err(codec->dev,
  6201. "%s: add_codec_controls failed, err = %d\n",
  6202. __func__, ret);
  6203. return ret;
  6204. }
  6205. return 0;
  6206. }
  6207. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6208. struct snd_pcm_hw_params *params)
  6209. {
  6210. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  6211. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  6212. int ret = 0;
  6213. unsigned int rx_ch[] = {144, 145, 146, 147, 148, 149, 150,
  6214. 151};
  6215. unsigned int tx_ch[] = {128, 129, 130, 131, 132, 133,
  6216. 134, 135, 136, 137, 138, 139,
  6217. 140, 141, 142, 143};
  6218. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  6219. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  6220. slim_rx_cfg[SLIM_RX_0].channels,
  6221. rx_ch);
  6222. if (ret < 0)
  6223. pr_err("%s: RX failed to set cpu chan map error %d\n",
  6224. __func__, ret);
  6225. } else {
  6226. ret = snd_soc_dai_set_channel_map(cpu_dai,
  6227. slim_tx_cfg[SLIM_TX_0].channels,
  6228. tx_ch, 0, 0);
  6229. if (ret < 0)
  6230. pr_err("%s: TX failed to set cpu chan map error %d\n",
  6231. __func__, ret);
  6232. }
  6233. return ret;
  6234. }
  6235. static struct snd_soc_ops msm_stub_be_ops = {
  6236. .hw_params = msm_snd_stub_hw_params,
  6237. };
  6238. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6239. /* FrontEnd DAI Links */
  6240. {
  6241. .name = "MSMSTUB Media1",
  6242. .stream_name = "MultiMedia1",
  6243. .cpu_dai_name = "MultiMedia1",
  6244. .platform_name = "msm-pcm-dsp.0",
  6245. .dynamic = 1,
  6246. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6247. .dpcm_playback = 1,
  6248. .dpcm_capture = 1,
  6249. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6250. SND_SOC_DPCM_TRIGGER_POST},
  6251. .codec_dai_name = "snd-soc-dummy-dai",
  6252. .codec_name = "snd-soc-dummy",
  6253. .ignore_suspend = 1,
  6254. /* this dainlink has playback support */
  6255. .ignore_pmdown_time = 1,
  6256. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  6257. },
  6258. };
  6259. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6260. /* Backend DAI Links */
  6261. {
  6262. .name = LPASS_BE_SLIMBUS_0_RX,
  6263. .stream_name = "Slimbus Playback",
  6264. .cpu_dai_name = "msm-dai-q6-dev.16384",
  6265. .platform_name = "msm-pcm-routing",
  6266. .codec_name = "msm-stub-codec.1",
  6267. .codec_dai_name = "msm-stub-rx",
  6268. .no_pcm = 1,
  6269. .dpcm_playback = 1,
  6270. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  6271. .init = &msm_audrx_stub_init,
  6272. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6273. .ignore_pmdown_time = 1, /* dai link has playback support */
  6274. .ignore_suspend = 1,
  6275. .ops = &msm_stub_be_ops,
  6276. },
  6277. {
  6278. .name = LPASS_BE_SLIMBUS_0_TX,
  6279. .stream_name = "Slimbus Capture",
  6280. .cpu_dai_name = "msm-dai-q6-dev.16385",
  6281. .platform_name = "msm-pcm-routing",
  6282. .codec_name = "msm-stub-codec.1",
  6283. .codec_dai_name = "msm-stub-tx",
  6284. .no_pcm = 1,
  6285. .dpcm_capture = 1,
  6286. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  6287. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6288. .ignore_suspend = 1,
  6289. .ops = &msm_stub_be_ops,
  6290. },
  6291. };
  6292. static struct snd_soc_dai_link msm_stub_dai_links[
  6293. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6294. ARRAY_SIZE(msm_stub_be_dai_links)];
  6295. struct snd_soc_card snd_soc_card_stub_msm = {
  6296. .name = "sm8150-stub-snd-card",
  6297. };
  6298. static const struct of_device_id sm8150_asoc_machine_of_match[] = {
  6299. { .compatible = "qcom,sm8150-asoc-snd-pahu",
  6300. .data = "pahu_codec"},
  6301. { .compatible = "qcom,sm8150-asoc-snd-tavil",
  6302. .data = "tavil_codec"},
  6303. { .compatible = "qcom,sm8150-asoc-snd-stub",
  6304. .data = "stub_codec"},
  6305. {},
  6306. };
  6307. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6308. {
  6309. struct snd_soc_card *card = NULL;
  6310. struct snd_soc_dai_link *dailink;
  6311. int len_1, len_2, len_3, len_4;
  6312. int total_links;
  6313. const struct of_device_id *match;
  6314. int ret = 0;
  6315. u32 val = 0;
  6316. match = of_match_node(sm8150_asoc_machine_of_match, dev->of_node);
  6317. if (!match) {
  6318. dev_err(dev, "%s: No DT match found for sound card\n",
  6319. __func__);
  6320. return NULL;
  6321. }
  6322. if (!strcmp(match->data, "pahu_codec")) {
  6323. card = &snd_soc_card_pahu_msm;
  6324. len_1 = ARRAY_SIZE(msm_common_dai_links);
  6325. len_2 = len_1 + ARRAY_SIZE(msm_pahu_fe_dai_links);
  6326. len_3 = len_2 + ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6327. len_4 = len_3 + ARRAY_SIZE(msm_common_be_dai_links);
  6328. total_links = len_4 + ARRAY_SIZE(msm_pahu_be_dai_links);
  6329. memcpy(msm_pahu_snd_card_dai_links,
  6330. msm_common_dai_links,
  6331. sizeof(msm_common_dai_links));
  6332. memcpy(msm_pahu_snd_card_dai_links + len_1,
  6333. msm_pahu_fe_dai_links,
  6334. sizeof(msm_pahu_fe_dai_links));
  6335. memcpy(msm_pahu_snd_card_dai_links + len_2,
  6336. msm_common_misc_fe_dai_links,
  6337. sizeof(msm_common_misc_fe_dai_links));
  6338. memcpy(msm_pahu_snd_card_dai_links + len_3,
  6339. msm_common_be_dai_links,
  6340. sizeof(msm_common_be_dai_links));
  6341. memcpy(msm_pahu_snd_card_dai_links + len_4,
  6342. msm_pahu_be_dai_links,
  6343. sizeof(msm_pahu_be_dai_links));
  6344. ret = of_property_read_u32(dev->of_node, "qcom,wcn-btfm", &val);
  6345. if (!ret && val) {
  6346. dev_dbg(dev, "%s(): WCN BTFM support present\n",
  6347. __func__);
  6348. memcpy(msm_pahu_snd_card_dai_links + total_links,
  6349. msm_wcn_be_dai_links,
  6350. sizeof(msm_wcn_be_dai_links));
  6351. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6352. }
  6353. ret = of_property_read_u32(dev->of_node,
  6354. "qcom,ext-disp-audio-rx", &val);
  6355. if (!ret && val) {
  6356. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6357. __func__);
  6358. memcpy(msm_pahu_snd_card_dai_links + total_links,
  6359. ext_disp_be_dai_link,
  6360. sizeof(ext_disp_be_dai_link));
  6361. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6362. }
  6363. ret = of_property_read_u32(dev->of_node,
  6364. "qcom,mi2s-audio-intf", &val);
  6365. if (!ret && val) {
  6366. memcpy(msm_pahu_snd_card_dai_links + total_links,
  6367. msm_mi2s_be_dai_links,
  6368. sizeof(msm_mi2s_be_dai_links));
  6369. total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
  6370. }
  6371. ret = of_property_read_u32(dev->of_node,
  6372. "qcom,auxpcm-audio-intf", &val);
  6373. if (!ret && val) {
  6374. memcpy(msm_pahu_snd_card_dai_links + total_links,
  6375. msm_auxpcm_be_dai_links,
  6376. sizeof(msm_auxpcm_be_dai_links));
  6377. total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6378. }
  6379. dailink = msm_pahu_snd_card_dai_links;
  6380. } else if (!strcmp(match->data, "tavil_codec")) {
  6381. card = &snd_soc_card_tavil_msm;
  6382. len_1 = ARRAY_SIZE(msm_common_dai_links);
  6383. len_2 = len_1 + ARRAY_SIZE(msm_tavil_fe_dai_links);
  6384. len_3 = len_2 + ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6385. len_4 = len_3 + ARRAY_SIZE(msm_common_be_dai_links);
  6386. total_links = len_4 + ARRAY_SIZE(msm_tavil_be_dai_links);
  6387. memcpy(msm_tavil_dai_links,
  6388. msm_common_dai_links,
  6389. sizeof(msm_common_dai_links));
  6390. memcpy(msm_tavil_dai_links + len_1,
  6391. msm_tavil_fe_dai_links,
  6392. sizeof(msm_tavil_fe_dai_links));
  6393. memcpy(msm_tavil_dai_links + len_2,
  6394. msm_common_misc_fe_dai_links,
  6395. sizeof(msm_common_misc_fe_dai_links));
  6396. memcpy(msm_tavil_dai_links + len_3,
  6397. msm_common_be_dai_links,
  6398. sizeof(msm_common_be_dai_links));
  6399. memcpy(msm_tavil_dai_links + len_4,
  6400. msm_tavil_be_dai_links,
  6401. sizeof(msm_tavil_be_dai_links));
  6402. ret = of_property_read_u32(dev->of_node, "qcom,wcn-btfm", &val);
  6403. if (!ret && val) {
  6404. dev_dbg(dev, "%s(): WCN BTFM support present\n",
  6405. __func__);
  6406. memcpy(msm_tavil_dai_links + total_links,
  6407. msm_wcn_be_dai_links,
  6408. sizeof(msm_wcn_be_dai_links));
  6409. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6410. }
  6411. ret = of_property_read_u32(dev->of_node,
  6412. "qcom,ext-disp-audio-rx", &val);
  6413. if (!ret && val) {
  6414. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6415. __func__);
  6416. memcpy(msm_tavil_dai_links + total_links,
  6417. ext_disp_be_dai_link,
  6418. sizeof(ext_disp_be_dai_link));
  6419. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6420. }
  6421. ret = of_property_read_u32(dev->of_node,
  6422. "qcom,mi2s-audio-intf", &val);
  6423. if (!ret && val) {
  6424. memcpy(msm_tavil_dai_links + total_links,
  6425. msm_mi2s_be_dai_links,
  6426. sizeof(msm_mi2s_be_dai_links));
  6427. total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
  6428. }
  6429. ret = of_property_read_u32(dev->of_node,
  6430. "qcom,auxpcm-audio-intf", &val);
  6431. if (!ret && val) {
  6432. memcpy(msm_tavil_dai_links + total_links,
  6433. msm_auxpcm_be_dai_links,
  6434. sizeof(msm_auxpcm_be_dai_links));
  6435. total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6436. }
  6437. dailink = msm_tavil_dai_links;
  6438. } else if (!strcmp(match->data, "stub_codec")) {
  6439. card = &snd_soc_card_stub_msm;
  6440. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6441. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6442. memcpy(msm_stub_dai_links,
  6443. msm_stub_fe_dai_links,
  6444. sizeof(msm_stub_fe_dai_links));
  6445. memcpy(msm_stub_dai_links + len_1,
  6446. msm_stub_be_dai_links,
  6447. sizeof(msm_stub_be_dai_links));
  6448. dailink = msm_stub_dai_links;
  6449. total_links = len_2;
  6450. }
  6451. if (card) {
  6452. card->dai_link = dailink;
  6453. card->num_links = total_links;
  6454. }
  6455. return card;
  6456. }
  6457. static int msm_wsa881x_init(struct snd_soc_component *component)
  6458. {
  6459. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
  6460. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
  6461. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  6462. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6463. struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
  6464. struct msm_asoc_mach_data *pdata;
  6465. struct snd_soc_dapm_context *dapm;
  6466. int ret = 0;
  6467. if (!codec) {
  6468. pr_err("%s codec is NULL\n", __func__);
  6469. return -EINVAL;
  6470. }
  6471. dapm = snd_soc_codec_get_dapm(codec);
  6472. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  6473. dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
  6474. __func__, codec->component.name);
  6475. wsa881x_set_channel_map(codec, &spkleft_ports[0],
  6476. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  6477. &ch_rate[0], NULL);
  6478. if (dapm->component) {
  6479. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  6480. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  6481. }
  6482. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  6483. dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
  6484. __func__, codec->component.name);
  6485. wsa881x_set_channel_map(codec, &spkright_ports[0],
  6486. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  6487. &ch_rate[0], NULL);
  6488. if (dapm->component) {
  6489. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  6490. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  6491. }
  6492. } else {
  6493. dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
  6494. codec->component.name);
  6495. ret = -EINVAL;
  6496. goto err;
  6497. }
  6498. pdata = snd_soc_card_get_drvdata(component->card);
  6499. if (pdata && pdata->codec_root)
  6500. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  6501. codec);
  6502. err:
  6503. return ret;
  6504. }
  6505. static int msm_init_wsa_dev(struct platform_device *pdev,
  6506. struct snd_soc_card *card)
  6507. {
  6508. struct device_node *wsa_of_node;
  6509. u32 wsa_max_devs;
  6510. u32 wsa_dev_cnt;
  6511. int i;
  6512. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  6513. const char *wsa_auxdev_name_prefix[1];
  6514. char *dev_name_str = NULL;
  6515. int found = 0;
  6516. int ret = 0;
  6517. /* Get maximum WSA device count for this platform */
  6518. ret = of_property_read_u32(pdev->dev.of_node,
  6519. "qcom,wsa-max-devs", &wsa_max_devs);
  6520. if (ret) {
  6521. dev_info(&pdev->dev,
  6522. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6523. __func__, pdev->dev.of_node->full_name, ret);
  6524. card->num_aux_devs = 0;
  6525. return 0;
  6526. }
  6527. if (wsa_max_devs == 0) {
  6528. dev_warn(&pdev->dev,
  6529. "%s: Max WSA devices is 0 for this target?\n",
  6530. __func__);
  6531. card->num_aux_devs = 0;
  6532. return 0;
  6533. }
  6534. /* Get count of WSA device phandles for this platform */
  6535. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  6536. "qcom,wsa-devs", NULL);
  6537. if (wsa_dev_cnt == -ENOENT) {
  6538. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  6539. __func__);
  6540. goto err;
  6541. } else if (wsa_dev_cnt <= 0) {
  6542. dev_err(&pdev->dev,
  6543. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  6544. __func__, wsa_dev_cnt);
  6545. ret = -EINVAL;
  6546. goto err;
  6547. }
  6548. /*
  6549. * Expect total phandles count to be NOT less than maximum possible
  6550. * WSA count. However, if it is less, then assign same value to
  6551. * max count as well.
  6552. */
  6553. if (wsa_dev_cnt < wsa_max_devs) {
  6554. dev_dbg(&pdev->dev,
  6555. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  6556. __func__, wsa_max_devs, wsa_dev_cnt);
  6557. wsa_max_devs = wsa_dev_cnt;
  6558. }
  6559. /* Make sure prefix string passed for each WSA device */
  6560. ret = of_property_count_strings(pdev->dev.of_node,
  6561. "qcom,wsa-aux-dev-prefix");
  6562. if (ret != wsa_dev_cnt) {
  6563. dev_err(&pdev->dev,
  6564. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  6565. __func__, wsa_dev_cnt, ret);
  6566. ret = -EINVAL;
  6567. goto err;
  6568. }
  6569. /*
  6570. * Alloc mem to store phandle and index info of WSA device, if already
  6571. * registered with ALSA core
  6572. */
  6573. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  6574. sizeof(struct msm_wsa881x_dev_info),
  6575. GFP_KERNEL);
  6576. if (!wsa881x_dev_info) {
  6577. ret = -ENOMEM;
  6578. goto err;
  6579. }
  6580. /*
  6581. * search and check whether all WSA devices are already
  6582. * registered with ALSA core or not. If found a node, store
  6583. * the node and the index in a local array of struct for later
  6584. * use.
  6585. */
  6586. for (i = 0; i < wsa_dev_cnt; i++) {
  6587. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  6588. "qcom,wsa-devs", i);
  6589. if (unlikely(!wsa_of_node)) {
  6590. /* we should not be here */
  6591. dev_err(&pdev->dev,
  6592. "%s: wsa dev node is not present\n",
  6593. __func__);
  6594. ret = -EINVAL;
  6595. goto err_free_dev_info;
  6596. }
  6597. if (soc_find_component_locked(wsa_of_node, NULL)) {
  6598. /* WSA device registered with ALSA core */
  6599. wsa881x_dev_info[found].of_node = wsa_of_node;
  6600. wsa881x_dev_info[found].index = i;
  6601. found++;
  6602. if (found == wsa_max_devs)
  6603. break;
  6604. }
  6605. }
  6606. if (found < wsa_max_devs) {
  6607. dev_dbg(&pdev->dev,
  6608. "%s: failed to find %d components. Found only %d\n",
  6609. __func__, wsa_max_devs, found);
  6610. return -EPROBE_DEFER;
  6611. }
  6612. dev_info(&pdev->dev,
  6613. "%s: found %d wsa881x devices registered with ALSA core\n",
  6614. __func__, found);
  6615. card->num_aux_devs = wsa_max_devs;
  6616. card->num_configs = wsa_max_devs;
  6617. /* Alloc array of AUX devs struct */
  6618. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  6619. sizeof(struct snd_soc_aux_dev),
  6620. GFP_KERNEL);
  6621. if (!msm_aux_dev) {
  6622. ret = -ENOMEM;
  6623. goto err_free_dev_info;
  6624. }
  6625. /* Alloc array of codec conf struct */
  6626. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  6627. sizeof(struct snd_soc_codec_conf),
  6628. GFP_KERNEL);
  6629. if (!msm_codec_conf) {
  6630. ret = -ENOMEM;
  6631. goto err_free_aux_dev;
  6632. }
  6633. for (i = 0; i < card->num_aux_devs; i++) {
  6634. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  6635. GFP_KERNEL);
  6636. if (!dev_name_str) {
  6637. ret = -ENOMEM;
  6638. goto err_free_cdc_conf;
  6639. }
  6640. ret = of_property_read_string_index(pdev->dev.of_node,
  6641. "qcom,wsa-aux-dev-prefix",
  6642. wsa881x_dev_info[i].index,
  6643. wsa_auxdev_name_prefix);
  6644. if (ret) {
  6645. dev_err(&pdev->dev,
  6646. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  6647. __func__, ret);
  6648. ret = -EINVAL;
  6649. goto err_free_dev_name_str;
  6650. }
  6651. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  6652. msm_aux_dev[i].name = dev_name_str;
  6653. msm_aux_dev[i].codec_name = NULL;
  6654. msm_aux_dev[i].codec_of_node =
  6655. wsa881x_dev_info[i].of_node;
  6656. msm_aux_dev[i].init = msm_wsa881x_init;
  6657. msm_codec_conf[i].dev_name = NULL;
  6658. msm_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
  6659. msm_codec_conf[i].of_node =
  6660. wsa881x_dev_info[i].of_node;
  6661. }
  6662. card->codec_conf = msm_codec_conf;
  6663. card->aux_dev = msm_aux_dev;
  6664. return 0;
  6665. err_free_dev_name_str:
  6666. devm_kfree(&pdev->dev, dev_name_str);
  6667. err_free_cdc_conf:
  6668. devm_kfree(&pdev->dev, msm_codec_conf);
  6669. err_free_aux_dev:
  6670. devm_kfree(&pdev->dev, msm_aux_dev);
  6671. err_free_dev_info:
  6672. devm_kfree(&pdev->dev, wsa881x_dev_info);
  6673. err:
  6674. return ret;
  6675. }
  6676. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  6677. {
  6678. int count;
  6679. u32 mi2s_master_slave[MI2S_MAX];
  6680. int ret;
  6681. for (count = 0; count < MI2S_MAX; count++) {
  6682. mutex_init(&mi2s_intf_conf[count].lock);
  6683. mi2s_intf_conf[count].ref_cnt = 0;
  6684. }
  6685. ret = of_property_read_u32_array(pdev->dev.of_node,
  6686. "qcom,msm-mi2s-master",
  6687. mi2s_master_slave, MI2S_MAX);
  6688. if (ret) {
  6689. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  6690. __func__);
  6691. } else {
  6692. for (count = 0; count < MI2S_MAX; count++) {
  6693. mi2s_intf_conf[count].msm_is_mi2s_master =
  6694. mi2s_master_slave[count];
  6695. }
  6696. }
  6697. }
  6698. static void msm_i2s_auxpcm_deinit(void)
  6699. {
  6700. int count;
  6701. for (count = 0; count < MI2S_MAX; count++) {
  6702. mutex_destroy(&mi2s_intf_conf[count].lock);
  6703. mi2s_intf_conf[count].ref_cnt = 0;
  6704. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  6705. }
  6706. }
  6707. static int msm_asoc_machine_probe(struct platform_device *pdev)
  6708. {
  6709. struct snd_soc_card *card;
  6710. struct msm_asoc_mach_data *pdata;
  6711. const char *mbhc_audio_jack_type = NULL;
  6712. int ret;
  6713. if (!pdev->dev.of_node) {
  6714. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  6715. return -EINVAL;
  6716. }
  6717. pdata = devm_kzalloc(&pdev->dev,
  6718. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  6719. if (!pdata)
  6720. return -ENOMEM;
  6721. card = populate_snd_card_dailinks(&pdev->dev);
  6722. if (!card) {
  6723. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  6724. ret = -EINVAL;
  6725. goto err;
  6726. }
  6727. card->dev = &pdev->dev;
  6728. platform_set_drvdata(pdev, card);
  6729. snd_soc_card_set_drvdata(card, pdata);
  6730. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  6731. if (ret) {
  6732. dev_err(&pdev->dev, "parse card name failed, err:%d\n",
  6733. ret);
  6734. goto err;
  6735. }
  6736. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  6737. if (ret) {
  6738. dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
  6739. ret);
  6740. goto err;
  6741. }
  6742. ret = msm_populate_dai_link_component_of_node(card);
  6743. if (ret) {
  6744. ret = -EPROBE_DEFER;
  6745. goto err;
  6746. }
  6747. ret = msm_init_wsa_dev(pdev, card);
  6748. if (ret)
  6749. goto err;
  6750. ret = devm_snd_soc_register_card(&pdev->dev, card);
  6751. if (ret == -EPROBE_DEFER) {
  6752. if (codec_reg_done)
  6753. ret = -EINVAL;
  6754. goto err;
  6755. } else if (ret) {
  6756. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  6757. ret);
  6758. goto err;
  6759. }
  6760. dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
  6761. spdev = pdev;
  6762. INIT_WORK(&pdata->adsp_power_up_work, msm_adsp_power_up_config_work);
  6763. ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6764. if (ret) {
  6765. dev_dbg(&pdev->dev, "%s: failed to add child nodes, ret=%d\n",
  6766. __func__, ret);
  6767. } else {
  6768. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6769. "qcom,hph-en1-gpio", 0);
  6770. if (!pdata->hph_en1_gpio_p) {
  6771. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  6772. "qcom,hph-en1-gpio",
  6773. pdev->dev.of_node->full_name);
  6774. }
  6775. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6776. "qcom,hph-en0-gpio", 0);
  6777. if (!pdata->hph_en0_gpio_p) {
  6778. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  6779. "qcom,hph-en0-gpio",
  6780. pdev->dev.of_node->full_name);
  6781. }
  6782. }
  6783. ret = of_property_read_string(pdev->dev.of_node,
  6784. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  6785. if (ret) {
  6786. dev_dbg(&pdev->dev, "Looking up %s property in node %s failed\n",
  6787. "qcom,mbhc-audio-jack-type",
  6788. pdev->dev.of_node->full_name);
  6789. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  6790. } else {
  6791. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  6792. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  6793. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  6794. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  6795. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  6796. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  6797. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  6798. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  6799. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  6800. } else {
  6801. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  6802. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  6803. }
  6804. }
  6805. /*
  6806. * Parse US-Euro gpio info from DT. Report no error if us-euro
  6807. * entry is not found in DT file as some targets do not support
  6808. * US-Euro detection
  6809. */
  6810. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6811. "qcom,us-euro-gpios", 0);
  6812. if (!pdata->us_euro_gpio_p) {
  6813. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  6814. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  6815. } else {
  6816. dev_dbg(&pdev->dev, "%s detected\n",
  6817. "qcom,us-euro-gpios");
  6818. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  6819. }
  6820. if (wcd_mbhc_cfg.enable_usbc_analog)
  6821. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  6822. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  6823. "fsa4480-i2c-handle", 0);
  6824. if (!pdata->fsa_handle)
  6825. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  6826. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  6827. /* Parse pinctrl info from devicetree */
  6828. ret = msm_get_pinctrl(pdev);
  6829. if (!ret) {
  6830. pr_debug("%s: pinctrl parsing successful\n", __func__);
  6831. } else {
  6832. dev_dbg(&pdev->dev,
  6833. "%s: Parsing pinctrl failed with %d. Cannot use Ports\n",
  6834. __func__, ret);
  6835. ret = 0;
  6836. }
  6837. msm_i2s_auxpcm_init(pdev);
  6838. is_initial_boot = true;
  6839. ret = audio_notifier_register("sm8150", AUDIO_NOTIFIER_ADSP_DOMAIN,
  6840. &service_nb);
  6841. if (ret < 0)
  6842. pr_err("%s: Audio notifier register failed ret = %d\n",
  6843. __func__, ret);
  6844. return 0;
  6845. err:
  6846. msm_release_pinctrl(pdev);
  6847. devm_kfree(&pdev->dev, pdata);
  6848. return ret;
  6849. }
  6850. static int msm_asoc_machine_remove(struct platform_device *pdev)
  6851. {
  6852. audio_notifier_deregister("sm8150");
  6853. msm_i2s_auxpcm_deinit();
  6854. msm_release_pinctrl(pdev);
  6855. return 0;
  6856. }
  6857. static struct platform_driver sm8150_asoc_machine_driver = {
  6858. .driver = {
  6859. .name = DRV_NAME,
  6860. .owner = THIS_MODULE,
  6861. .pm = &snd_soc_pm_ops,
  6862. .of_match_table = sm8150_asoc_machine_of_match,
  6863. },
  6864. .probe = msm_asoc_machine_probe,
  6865. .remove = msm_asoc_machine_remove,
  6866. };
  6867. int __init sm8150_init(void)
  6868. {
  6869. pr_debug("%s\n", __func__);
  6870. return platform_driver_register(&sm8150_asoc_machine_driver);
  6871. }
  6872. void sm8150_exit(void)
  6873. {
  6874. pr_debug("%s\n", __func__);
  6875. platform_driver_unregister(&sm8150_asoc_machine_driver);
  6876. }
  6877. MODULE_DESCRIPTION("ALSA SoC msm");
  6878. MODULE_LICENSE("GPL v2");
  6879. MODULE_ALIAS("platform:" DRV_NAME);
  6880. MODULE_DEVICE_TABLE(of, sm8150_asoc_machine_of_match);