qcs405.c 267 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2018-2019, 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/i2c.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/pm_qos.h>
  16. #include <linux/regulator/consumer.h>
  17. #include <sound/core.h>
  18. #include <sound/soc.h>
  19. #include <sound/soc-dapm.h>
  20. #include <sound/pcm.h>
  21. #include <sound/pcm_params.h>
  22. #include <sound/info.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <dsp/q6afe-v2.h>
  25. #include <dsp/q6core.h>
  26. #include <dsp/msm_mdf.h>
  27. #include "device_event.h"
  28. #include "msm-pcm-routing-v2.h"
  29. #include <asoc/msm-cdc-pinctrl.h>
  30. #include "codecs/wcd9335.h"
  31. #include "codecs/wsa881x.h"
  32. #include "codecs/csra66x0/csra66x0.h"
  33. #include <dt-bindings/sound/audio-codec-port-types.h>
  34. #include "codecs/bolero/bolero-cdc.h"
  35. #include "codecs/bolero/wsa-macro.h"
  36. #define DRV_NAME "qcs405-asoc-snd"
  37. #define __CHIPSET__ "QCS405 "
  38. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  39. #define DEV_NAME_STR_LEN 32
  40. #define SAMPLING_RATE_8KHZ 8000
  41. #define SAMPLING_RATE_11P025KHZ 11025
  42. #define SAMPLING_RATE_16KHZ 16000
  43. #define SAMPLING_RATE_22P05KHZ 22050
  44. #define SAMPLING_RATE_32KHZ 32000
  45. #define SAMPLING_RATE_44P1KHZ 44100
  46. #define SAMPLING_RATE_48KHZ 48000
  47. #define SAMPLING_RATE_88P2KHZ 88200
  48. #define SAMPLING_RATE_96KHZ 96000
  49. #define SAMPLING_RATE_176P4KHZ 176400
  50. #define SAMPLING_RATE_192KHZ 192000
  51. #define SAMPLING_RATE_352P8KHZ 352800
  52. #define SAMPLING_RATE_384KHZ 384000
  53. #define SPDIF_TX_CORE_CLK_163_P84_MHZ 163840000
  54. #define TLMM_EAST_SPARE 0x07BA0000
  55. #define TLMM_SPDIF_HDMI_ARC_CTL 0x07BA2000
  56. #define WSA8810_NAME_1 "wsa881x.20170211"
  57. #define WSA8810_NAME_2 "wsa881x.20170212"
  58. #define WCN_CDC_SLIM_RX_CH_MAX 2
  59. #define WCN_CDC_SLIM_TX_CH_MAX 4
  60. #define TDM_CHANNEL_MAX 8
  61. #define BT_SLIM_TX SLIM_TX_9
  62. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  63. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  64. enum {
  65. SLIM_RX_0 = 0,
  66. SLIM_RX_1,
  67. SLIM_RX_2,
  68. SLIM_RX_3,
  69. SLIM_RX_4,
  70. SLIM_RX_5,
  71. SLIM_RX_6,
  72. SLIM_RX_7,
  73. SLIM_RX_MAX,
  74. };
  75. enum {
  76. SLIM_TX_0 = 0,
  77. SLIM_TX_1,
  78. SLIM_TX_2,
  79. SLIM_TX_3,
  80. SLIM_TX_4,
  81. SLIM_TX_5,
  82. SLIM_TX_6,
  83. SLIM_TX_7,
  84. SLIM_TX_8,
  85. SLIM_TX_9,
  86. SLIM_TX_MAX,
  87. };
  88. enum {
  89. PRIM_MI2S = 0,
  90. SEC_MI2S,
  91. TERT_MI2S,
  92. QUAT_MI2S,
  93. QUIN_MI2S,
  94. SEN_MI2S,
  95. MI2S_MAX,
  96. };
  97. enum {
  98. PRIM_META_MI2S = 0,
  99. SEC_META_MI2S,
  100. META_MI2S_MAX,
  101. };
  102. enum {
  103. PRIM_AUX_PCM = 0,
  104. SEC_AUX_PCM,
  105. TERT_AUX_PCM,
  106. QUAT_AUX_PCM,
  107. QUIN_AUX_PCM,
  108. SEN_AUX_PCM,
  109. AUX_PCM_MAX,
  110. };
  111. enum {
  112. WSA_CDC_DMA_RX_0 = 0,
  113. WSA_CDC_DMA_RX_1,
  114. CDC_DMA_RX_MAX,
  115. };
  116. enum {
  117. WSA_CDC_DMA_TX_0 = 0,
  118. WSA_CDC_DMA_TX_1,
  119. WSA_CDC_DMA_TX_2,
  120. VA_CDC_DMA_TX_0,
  121. VA_CDC_DMA_TX_1,
  122. CDC_DMA_TX_MAX,
  123. };
  124. enum {
  125. PRIM_SPDIF_RX = 0,
  126. SEC_SPDIF_RX,
  127. SPDIF_RX_MAX,
  128. };
  129. enum {
  130. PRIM_SPDIF_TX = 0,
  131. SEC_SPDIF_TX,
  132. SPDIF_TX_MAX,
  133. };
  134. struct mi2s_conf {
  135. struct mutex lock;
  136. u32 ref_cnt;
  137. u32 msm_is_mi2s_master;
  138. };
  139. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  140. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  141. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  142. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  143. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT,
  144. Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT,
  145. Q6AFE_LPASS_CLK_ID_SEN_MI2S_EBIT
  146. };
  147. struct meta_mi2s_conf {
  148. u32 num_member_ports;
  149. u32 member_port[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  150. bool clk_enable[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  151. };
  152. struct dev_config {
  153. u32 sample_rate;
  154. u32 bit_format;
  155. u32 channels;
  156. };
  157. struct msm_wsa881x_dev_info {
  158. struct device_node *of_node;
  159. u32 index;
  160. };
  161. struct msm_csra66x0_dev_info {
  162. struct device_node *of_node;
  163. u32 index;
  164. };
  165. struct msm_asoc_mach_data {
  166. struct snd_info_entry *codec_root;
  167. struct device_node *dmic_01_gpio_p; /* used by pinctrl API */
  168. struct device_node *dmic_23_gpio_p; /* used by pinctrl API */
  169. struct device_node *dmic_45_gpio_p; /* used by pinctrl API */
  170. struct device_node *dmic_67_gpio_p; /* used by pinctrl API */
  171. struct device_node *lineout_booster_gpio_p; /* used by pinctrl API */
  172. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  173. int dmic_01_gpio_cnt;
  174. int dmic_23_gpio_cnt;
  175. int dmic_45_gpio_cnt;
  176. int dmic_67_gpio_cnt;
  177. struct regulator *tdm_micb_supply;
  178. u32 tdm_micb_voltage;
  179. u32 tdm_micb_current;
  180. bool codec_is_csra;
  181. };
  182. struct msm_asoc_wcd93xx_codec {
  183. void* (*get_afe_config_fn)(struct snd_soc_component *component,
  184. enum afe_config_type config_type);
  185. };
  186. static const char *const pin_states[] = {"sleep", "i2s-active",
  187. "tdm-active"};
  188. enum {
  189. TDM_0 = 0,
  190. TDM_1,
  191. TDM_2,
  192. TDM_3,
  193. TDM_4,
  194. TDM_5,
  195. TDM_6,
  196. TDM_7,
  197. TDM_PORT_MAX,
  198. };
  199. enum {
  200. TDM_PRI = 0,
  201. TDM_SEC,
  202. TDM_TERT,
  203. TDM_QUAT,
  204. TDM_QUIN,
  205. TDM_INTERFACE_MAX,
  206. };
  207. struct tdm_port {
  208. u32 mode;
  209. u32 channel;
  210. };
  211. /* TDM default config */
  212. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  213. { /* PRI TDM */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  216. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  217. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  220. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  221. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  222. },
  223. { /* SEC TDM */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  226. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  227. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  228. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  229. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  230. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  231. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  232. },
  233. { /* TERT TDM */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  239. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  240. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  241. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  242. },
  243. { /* QUAT TDM */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  249. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  250. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  252. },
  253. { /* QUIN TDM */
  254. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  255. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  256. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  259. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  260. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  262. }
  263. };
  264. /* TDM default config */
  265. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  266. { /* PRI TDM */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  272. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  273. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  274. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  275. },
  276. { /* SEC TDM */
  277. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  278. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  279. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  280. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  281. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  282. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  283. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  284. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  285. },
  286. { /* TERT TDM */
  287. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  288. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  295. },
  296. { /* QUAT TDM */
  297. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  298. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  301. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  302. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  305. },
  306. { /* QUIN TDM */
  307. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  308. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  309. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  310. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  311. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  312. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  313. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  314. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  315. }
  316. };
  317. /* Default configuration of slimbus channels */
  318. static struct dev_config slim_rx_cfg[] = {
  319. [SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  320. [SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  321. [SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  322. [SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  323. [SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  324. [SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  325. [SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  326. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  327. };
  328. static struct dev_config slim_tx_cfg[] = {
  329. [SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  330. [SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  331. [SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  332. [SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  333. [SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  334. [SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  335. [SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  336. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  337. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  338. [SLIM_TX_9] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  339. };
  340. /* Default configuration of Codec DMA Interface Tx */
  341. static struct dev_config cdc_dma_rx_cfg[] = {
  342. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  343. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  344. };
  345. /* Default configuration of Codec DMA Interface Rx */
  346. static struct dev_config cdc_dma_tx_cfg[] = {
  347. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  348. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  349. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  350. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  351. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  352. };
  353. static struct dev_config usb_rx_cfg = {
  354. .sample_rate = SAMPLING_RATE_48KHZ,
  355. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  356. .channels = 2,
  357. };
  358. static struct dev_config usb_tx_cfg = {
  359. .sample_rate = SAMPLING_RATE_48KHZ,
  360. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  361. .channels = 1,
  362. };
  363. static struct dev_config proxy_rx_cfg = {
  364. .sample_rate = SAMPLING_RATE_48KHZ,
  365. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  366. .channels = 2,
  367. };
  368. /* Default configuration of MI2S channels */
  369. static struct dev_config mi2s_rx_cfg[] = {
  370. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  371. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  372. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  373. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  374. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  375. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  376. };
  377. static struct dev_config meta_mi2s_rx_cfg[] = {
  378. [PRIM_META_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  379. [SEC_META_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  380. };
  381. /* Default configuration of SPDIF channels */
  382. static struct dev_config spdif_rx_cfg[] = {
  383. [PRIM_SPDIF_RX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  384. [SEC_SPDIF_RX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  385. };
  386. static struct dev_config spdif_tx_cfg[] = {
  387. [PRIM_SPDIF_TX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  388. [SEC_SPDIF_TX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  389. };
  390. static struct dev_config mi2s_tx_cfg[] = {
  391. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  392. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  393. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  394. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  395. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  396. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  397. };
  398. static struct dev_config aux_pcm_rx_cfg[] = {
  399. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  400. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  401. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  402. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  403. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  404. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  405. };
  406. static struct dev_config aux_pcm_tx_cfg[] = {
  407. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  408. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  409. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  410. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  411. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  412. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  413. };
  414. static struct dev_config afe_lb_tx_cfg = {
  415. .sample_rate = SAMPLING_RATE_48KHZ,
  416. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  417. .channels = 2,
  418. };
  419. static int msm_vi_feed_tx_ch = 2;
  420. static const char *const slim_rx_ch_text[] = {"One", "Two"};
  421. static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
  422. "Five", "Six", "Seven",
  423. "Eight"};
  424. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  425. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  426. "S32_LE"};
  427. static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  428. "KHZ_32", "KHZ_44P1", "KHZ_48",
  429. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  430. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  431. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  432. "KHZ_44P1", "KHZ_48",
  433. "KHZ_88P2", "KHZ_96"};
  434. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  435. "Five", "Six", "Seven",
  436. "Eight"};
  437. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  438. "Six", "Seven", "Eight"};
  439. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  440. "KHZ_16", "KHZ_22P05",
  441. "KHZ_32", "KHZ_44P1", "KHZ_48",
  442. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  443. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  444. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  445. "Five", "Six", "Seven", "Eight"};
  446. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  447. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  448. "KHZ_48", "KHZ_176P4",
  449. "KHZ_352P8"};
  450. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  451. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  452. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  453. "KHZ_48", "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  454. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  455. static const char *const mi2s_ch_text[] = {
  456. "One", "Two", "Three", "Four", "Five", "Six", "Seven",
  457. "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
  458. "Fourteen", "Fifteen", "Sixteen"
  459. };
  460. static const char *const meta_mi2s_ch_text[] = {
  461. "One", "Two", "Three", "Four", "Five", "Six", "Seven",
  462. "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
  463. "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
  464. "Nineteen", "Twenty", "TwentyOne", "TwentyTwo", "TwentyThree",
  465. "TwentyFour", "TwentyFive", "TwentySix", "TwentySeven",
  466. "TwentyEight", "TwentyNine", "Thirty", "ThirtyOne", "ThirtyTwo"
  467. };
  468. static const char *const qos_text[] = {"Disable", "Enable"};
  469. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  470. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  471. "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
  472. "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen"};
  473. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  474. "KHZ_16", "KHZ_22P05",
  475. "KHZ_32", "KHZ_44P1", "KHZ_48",
  476. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  477. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  478. static const char *spdif_rate_text[] = {"KHZ_32", "KHZ_44P1", "KHZ_48",
  479. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  480. "KHZ_192"};
  481. static const char *spdif_ch_text[] = {"One", "Two"};
  482. static const char *spdif_bit_format_text[] = {"S16_LE", "S24_LE"};
  483. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
  484. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
  485. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
  486. static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
  487. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
  488. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
  489. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  490. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  491. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  492. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  493. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
  494. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
  495. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
  496. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
  497. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  498. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  499. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
  500. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
  501. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
  502. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
  503. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
  504. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  505. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_sink, bt_sample_rate_text);
  506. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  507. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  508. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  509. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  510. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  511. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  512. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  513. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  514. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  515. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  516. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  517. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  518. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  519. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  520. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  521. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  522. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  523. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  524. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  525. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  526. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  527. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  528. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  529. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  530. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  531. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_sample_rate, mi2s_rate_text);
  532. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  533. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  534. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  535. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  536. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  537. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_sample_rate, mi2s_rate_text);
  538. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  539. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  540. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  541. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  542. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  543. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  544. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  545. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  546. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  547. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  548. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_chs, mi2s_ch_text);
  549. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_chs, mi2s_ch_text);
  550. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  551. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  552. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  553. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  554. static SOC_ENUM_SINGLE_EXT_DECL(prim_meta_mi2s_rx_sample_rate, mi2s_rate_text);
  555. static SOC_ENUM_SINGLE_EXT_DECL(sec_meta_mi2s_rx_sample_rate, mi2s_rate_text);
  556. static SOC_ENUM_SINGLE_EXT_DECL(prim_meta_mi2s_rx_chs, meta_mi2s_ch_text);
  557. static SOC_ENUM_SINGLE_EXT_DECL(sec_meta_mi2s_rx_chs, meta_mi2s_ch_text);
  558. static SOC_ENUM_SINGLE_EXT_DECL(prim_meta_mi2s_rx_format, bit_format_text);
  559. static SOC_ENUM_SINGLE_EXT_DECL(sec_meta_mi2s_rx_format, bit_format_text);
  560. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  561. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  562. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  563. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  564. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  565. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  566. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  567. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  568. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  569. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  570. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  571. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  572. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  573. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  574. cdc_dma_sample_rate_text);
  575. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  576. cdc_dma_sample_rate_text);
  577. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  578. cdc_dma_sample_rate_text);
  579. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  580. cdc_dma_sample_rate_text);
  581. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  582. cdc_dma_sample_rate_text);
  583. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  584. cdc_dma_sample_rate_text);
  585. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  586. cdc_dma_sample_rate_text);
  587. static SOC_ENUM_SINGLE_EXT_DECL(spdif_rx_sample_rate, spdif_rate_text);
  588. static SOC_ENUM_SINGLE_EXT_DECL(spdif_tx_sample_rate, spdif_rate_text);
  589. static SOC_ENUM_SINGLE_EXT_DECL(spdif_rx_chs, spdif_ch_text);
  590. static SOC_ENUM_SINGLE_EXT_DECL(spdif_tx_chs, spdif_ch_text);
  591. static SOC_ENUM_SINGLE_EXT_DECL(spdif_rx_format, spdif_bit_format_text);
  592. static SOC_ENUM_SINGLE_EXT_DECL(spdif_tx_format, spdif_bit_format_text);
  593. static SOC_ENUM_SINGLE_EXT_DECL(afe_lb_tx_chs, cdc_dma_tx_ch_text);
  594. static SOC_ENUM_SINGLE_EXT_DECL(afe_lb_tx_format, bit_format_text);
  595. static SOC_ENUM_SINGLE_EXT_DECL(afe_lb_tx_sample_rate,
  596. cdc_dma_sample_rate_text);
  597. static struct platform_device *spdev;
  598. static bool is_initial_boot;
  599. static bool codec_reg_done;
  600. static struct snd_soc_aux_dev *msm_aux_dev;
  601. static struct snd_soc_codec_conf *msm_codec_conf;
  602. static struct msm_asoc_wcd93xx_codec msm_codec_fn;
  603. static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component,
  604. int enable, bool dapm);
  605. static int msm_wsa881x_init(struct snd_soc_component *component);
  606. static int msm_snd_vad_cfg_put(struct snd_kcontrol *kcontrol,
  607. struct snd_ctl_elem_value *ucontrol);
  608. static struct snd_soc_dapm_route wcd_audio_paths[] = {
  609. {"MIC BIAS1", NULL, "MCLK TX"},
  610. {"MIC BIAS2", NULL, "MCLK TX"},
  611. {"MIC BIAS3", NULL, "MCLK TX"},
  612. {"MIC BIAS4", NULL, "MCLK TX"},
  613. };
  614. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  615. {
  616. AFE_API_VERSION_I2S_CONFIG,
  617. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  618. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  619. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  620. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  621. 0,
  622. },
  623. {
  624. AFE_API_VERSION_I2S_CONFIG,
  625. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  626. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  627. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  628. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  629. 0,
  630. },
  631. {
  632. AFE_API_VERSION_I2S_CONFIG,
  633. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  634. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  635. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  636. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  637. 0,
  638. },
  639. {
  640. AFE_API_VERSION_I2S_CONFIG,
  641. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  642. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  643. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  644. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  645. 0,
  646. },
  647. {
  648. AFE_API_VERSION_I2S_CONFIG,
  649. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  650. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  651. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  652. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  653. 0,
  654. },
  655. {
  656. AFE_API_VERSION_I2S_CONFIG,
  657. Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
  658. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  659. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  660. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  661. 0,
  662. }
  663. };
  664. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  665. static struct meta_mi2s_conf meta_mi2s_intf_conf[META_MI2S_MAX];
  666. static int msm_island_vad_get_portid_from_beid(int32_t be_id, int *port_id)
  667. {
  668. *port_id = 0xFFFF;
  669. switch (be_id) {
  670. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  671. *port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_0;
  672. break;
  673. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  674. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  675. break;
  676. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  677. *port_id = AFE_PORT_ID_QUINARY_TDM_TX;
  678. break;
  679. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  680. *port_id = AFE_PORT_ID_QUINARY_PCM_TX;
  681. break;
  682. default:
  683. return -EINVAL;
  684. }
  685. return 0;
  686. }
  687. static int qcs405_send_island_vad_config(int32_t be_id)
  688. {
  689. int rc = 0;
  690. int port_id = 0xFFFF;
  691. rc = msm_island_vad_get_portid_from_beid(be_id, &port_id);
  692. if (rc) {
  693. pr_debug("%s: Invalid island interface\n", __func__);
  694. } else {
  695. /*
  696. * send island mode config
  697. * This should be the first configuration
  698. */
  699. rc = afe_send_port_island_mode(port_id);
  700. if (rc) {
  701. pr_err("%s: afe send island mode failed %d\n",
  702. __func__, rc);
  703. return rc;
  704. }
  705. rc = afe_send_port_vad_cfg_params(port_id);
  706. if (rc) {
  707. pr_err("%s: afe send vad config failed %d\n",
  708. __func__, rc);
  709. return rc;
  710. }
  711. }
  712. return 0;
  713. }
  714. static int slim_get_sample_rate_val(int sample_rate)
  715. {
  716. int sample_rate_val = 0;
  717. switch (sample_rate) {
  718. case SAMPLING_RATE_8KHZ:
  719. sample_rate_val = 0;
  720. break;
  721. case SAMPLING_RATE_16KHZ:
  722. sample_rate_val = 1;
  723. break;
  724. case SAMPLING_RATE_32KHZ:
  725. sample_rate_val = 2;
  726. break;
  727. case SAMPLING_RATE_44P1KHZ:
  728. sample_rate_val = 3;
  729. break;
  730. case SAMPLING_RATE_48KHZ:
  731. sample_rate_val = 4;
  732. break;
  733. case SAMPLING_RATE_88P2KHZ:
  734. sample_rate_val = 5;
  735. break;
  736. case SAMPLING_RATE_96KHZ:
  737. sample_rate_val = 6;
  738. break;
  739. case SAMPLING_RATE_176P4KHZ:
  740. sample_rate_val = 7;
  741. break;
  742. case SAMPLING_RATE_192KHZ:
  743. sample_rate_val = 8;
  744. break;
  745. case SAMPLING_RATE_352P8KHZ:
  746. sample_rate_val = 9;
  747. break;
  748. case SAMPLING_RATE_384KHZ:
  749. sample_rate_val = 10;
  750. break;
  751. default:
  752. sample_rate_val = 4;
  753. break;
  754. }
  755. return sample_rate_val;
  756. }
  757. static int slim_get_sample_rate(int value)
  758. {
  759. int sample_rate = 0;
  760. switch (value) {
  761. case 0:
  762. sample_rate = SAMPLING_RATE_8KHZ;
  763. break;
  764. case 1:
  765. sample_rate = SAMPLING_RATE_16KHZ;
  766. break;
  767. case 2:
  768. sample_rate = SAMPLING_RATE_32KHZ;
  769. break;
  770. case 3:
  771. sample_rate = SAMPLING_RATE_44P1KHZ;
  772. break;
  773. case 4:
  774. sample_rate = SAMPLING_RATE_48KHZ;
  775. break;
  776. case 5:
  777. sample_rate = SAMPLING_RATE_88P2KHZ;
  778. break;
  779. case 6:
  780. sample_rate = SAMPLING_RATE_96KHZ;
  781. break;
  782. case 7:
  783. sample_rate = SAMPLING_RATE_176P4KHZ;
  784. break;
  785. case 8:
  786. sample_rate = SAMPLING_RATE_192KHZ;
  787. break;
  788. case 9:
  789. sample_rate = SAMPLING_RATE_352P8KHZ;
  790. break;
  791. case 10:
  792. sample_rate = SAMPLING_RATE_384KHZ;
  793. break;
  794. default:
  795. sample_rate = SAMPLING_RATE_48KHZ;
  796. break;
  797. }
  798. return sample_rate;
  799. }
  800. static int slim_get_bit_format_val(int bit_format)
  801. {
  802. int val = 0;
  803. switch (bit_format) {
  804. case SNDRV_PCM_FORMAT_S32_LE:
  805. val = 3;
  806. break;
  807. case SNDRV_PCM_FORMAT_S24_3LE:
  808. val = 2;
  809. break;
  810. case SNDRV_PCM_FORMAT_S24_LE:
  811. val = 1;
  812. break;
  813. case SNDRV_PCM_FORMAT_S16_LE:
  814. default:
  815. val = 0;
  816. break;
  817. }
  818. return val;
  819. }
  820. static int slim_get_bit_format(int val)
  821. {
  822. int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  823. switch (val) {
  824. case 0:
  825. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  826. break;
  827. case 1:
  828. bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
  829. break;
  830. case 2:
  831. bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
  832. break;
  833. case 3:
  834. bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
  835. break;
  836. default:
  837. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  838. break;
  839. }
  840. return bit_fmt;
  841. }
  842. static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
  843. {
  844. int port_id = 0;
  845. if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX"))) {
  846. port_id = SLIM_RX_0;
  847. } else if (strnstr(kcontrol->id.name,
  848. "SLIM_2_RX", sizeof("SLIM_2_RX"))) {
  849. port_id = SLIM_RX_2;
  850. } else if (strnstr(kcontrol->id.name,
  851. "SLIM_5_RX", sizeof("SLIM_5_RX"))) {
  852. port_id = SLIM_RX_5;
  853. } else if (strnstr(kcontrol->id.name,
  854. "SLIM_6_RX", sizeof("SLIM_6_RX"))) {
  855. port_id = SLIM_RX_6;
  856. } else if (strnstr(kcontrol->id.name,
  857. "SLIM_0_TX", sizeof("SLIM_0_TX"))) {
  858. port_id = SLIM_TX_0;
  859. } else if (strnstr(kcontrol->id.name,
  860. "SLIM_1_TX", sizeof("SLIM_1_TX"))) {
  861. port_id = SLIM_TX_1;
  862. } else {
  863. pr_err("%s: unsupported channel: %s",
  864. __func__, kcontrol->id.name);
  865. return -EINVAL;
  866. }
  867. return port_id;
  868. }
  869. static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  870. struct snd_ctl_elem_value *ucontrol)
  871. {
  872. int ch_num = slim_get_port_idx(kcontrol);
  873. if (ch_num < 0)
  874. return ch_num;
  875. ucontrol->value.enumerated.item[0] =
  876. slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
  877. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  878. ch_num, slim_rx_cfg[ch_num].sample_rate,
  879. ucontrol->value.enumerated.item[0]);
  880. return 0;
  881. }
  882. static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  883. struct snd_ctl_elem_value *ucontrol)
  884. {
  885. int ch_num = slim_get_port_idx(kcontrol);
  886. if (ch_num < 0)
  887. return ch_num;
  888. slim_rx_cfg[ch_num].sample_rate =
  889. slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  890. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  891. ch_num, slim_rx_cfg[ch_num].sample_rate,
  892. ucontrol->value.enumerated.item[0]);
  893. return 0;
  894. }
  895. static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  896. struct snd_ctl_elem_value *ucontrol)
  897. {
  898. int ch_num = slim_get_port_idx(kcontrol);
  899. if (ch_num < 0)
  900. return ch_num;
  901. ucontrol->value.enumerated.item[0] =
  902. slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
  903. pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  904. ch_num, slim_tx_cfg[ch_num].sample_rate,
  905. ucontrol->value.enumerated.item[0]);
  906. return 0;
  907. }
  908. static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value *ucontrol)
  910. {
  911. int sample_rate = 0;
  912. int ch_num = slim_get_port_idx(kcontrol);
  913. if (ch_num < 0)
  914. return ch_num;
  915. sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  916. if (sample_rate == SAMPLING_RATE_44P1KHZ) {
  917. pr_err("%s: Unsupported sample rate %d: for Tx path\n",
  918. __func__, sample_rate);
  919. return -EINVAL;
  920. }
  921. slim_tx_cfg[ch_num].sample_rate = sample_rate;
  922. pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
  923. ch_num, slim_tx_cfg[ch_num].sample_rate,
  924. ucontrol->value.enumerated.item[0]);
  925. return 0;
  926. }
  927. static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  928. struct snd_ctl_elem_value *ucontrol)
  929. {
  930. int ch_num = slim_get_port_idx(kcontrol);
  931. if (ch_num < 0)
  932. return ch_num;
  933. ucontrol->value.enumerated.item[0] =
  934. slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
  935. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  936. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  937. ucontrol->value.enumerated.item[0]);
  938. return 0;
  939. }
  940. static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  941. struct snd_ctl_elem_value *ucontrol)
  942. {
  943. int ch_num = slim_get_port_idx(kcontrol);
  944. if (ch_num < 0)
  945. return ch_num;
  946. slim_rx_cfg[ch_num].bit_format =
  947. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  948. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  949. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  950. ucontrol->value.enumerated.item[0]);
  951. return 0;
  952. }
  953. static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
  954. struct snd_ctl_elem_value *ucontrol)
  955. {
  956. int ch_num = slim_get_port_idx(kcontrol);
  957. if (ch_num < 0)
  958. return ch_num;
  959. ucontrol->value.enumerated.item[0] =
  960. slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
  961. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  962. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  963. ucontrol->value.enumerated.item[0]);
  964. return 0;
  965. }
  966. static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
  967. struct snd_ctl_elem_value *ucontrol)
  968. {
  969. int ch_num = slim_get_port_idx(kcontrol);
  970. if (ch_num < 0)
  971. return ch_num;
  972. slim_tx_cfg[ch_num].bit_format =
  973. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  974. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  975. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  976. ucontrol->value.enumerated.item[0]);
  977. return 0;
  978. }
  979. static int slim_rx_ch_get(struct snd_kcontrol *kcontrol,
  980. struct snd_ctl_elem_value *ucontrol)
  981. {
  982. int ch_num = slim_get_port_idx(kcontrol);
  983. if (ch_num < 0)
  984. return ch_num;
  985. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  986. ch_num, slim_rx_cfg[ch_num].channels);
  987. ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
  988. return 0;
  989. }
  990. static int slim_rx_ch_put(struct snd_kcontrol *kcontrol,
  991. struct snd_ctl_elem_value *ucontrol)
  992. {
  993. int ch_num = slim_get_port_idx(kcontrol);
  994. if (ch_num < 0)
  995. return ch_num;
  996. slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  997. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  998. ch_num, slim_rx_cfg[ch_num].channels);
  999. return 1;
  1000. }
  1001. static int slim_tx_ch_get(struct snd_kcontrol *kcontrol,
  1002. struct snd_ctl_elem_value *ucontrol)
  1003. {
  1004. int ch_num = slim_get_port_idx(kcontrol);
  1005. if (ch_num < 0)
  1006. return ch_num;
  1007. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  1008. ch_num, slim_tx_cfg[ch_num].channels);
  1009. ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
  1010. return 0;
  1011. }
  1012. static int slim_tx_ch_put(struct snd_kcontrol *kcontrol,
  1013. struct snd_ctl_elem_value *ucontrol)
  1014. {
  1015. int ch_num = slim_get_port_idx(kcontrol);
  1016. if (ch_num < 0)
  1017. return ch_num;
  1018. slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  1019. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  1020. ch_num, slim_tx_cfg[ch_num].channels);
  1021. return 1;
  1022. }
  1023. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1024. struct snd_ctl_elem_value *ucontrol)
  1025. {
  1026. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1027. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1028. ucontrol->value.integer.value[0]);
  1029. return 0;
  1030. }
  1031. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1032. struct snd_ctl_elem_value *ucontrol)
  1033. {
  1034. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1035. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1036. return 1;
  1037. }
  1038. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  1039. struct snd_ctl_elem_value *ucontrol)
  1040. {
  1041. /*
  1042. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  1043. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  1044. * value.
  1045. */
  1046. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  1047. case SAMPLING_RATE_96KHZ:
  1048. ucontrol->value.integer.value[0] = 5;
  1049. break;
  1050. case SAMPLING_RATE_88P2KHZ:
  1051. ucontrol->value.integer.value[0] = 4;
  1052. break;
  1053. case SAMPLING_RATE_48KHZ:
  1054. ucontrol->value.integer.value[0] = 3;
  1055. break;
  1056. case SAMPLING_RATE_44P1KHZ:
  1057. ucontrol->value.integer.value[0] = 2;
  1058. break;
  1059. case SAMPLING_RATE_16KHZ:
  1060. ucontrol->value.integer.value[0] = 1;
  1061. break;
  1062. case SAMPLING_RATE_8KHZ:
  1063. default:
  1064. ucontrol->value.integer.value[0] = 0;
  1065. break;
  1066. }
  1067. pr_debug("%s: sample rate = %d", __func__,
  1068. slim_rx_cfg[SLIM_RX_7].sample_rate);
  1069. return 0;
  1070. }
  1071. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  1072. struct snd_ctl_elem_value *ucontrol)
  1073. {
  1074. switch (ucontrol->value.integer.value[0]) {
  1075. case 1:
  1076. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1077. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1078. break;
  1079. case 2:
  1080. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1081. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1082. break;
  1083. case 3:
  1084. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1085. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1086. break;
  1087. case 4:
  1088. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1089. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1090. break;
  1091. case 5:
  1092. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1093. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1094. break;
  1095. case 0:
  1096. default:
  1097. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1098. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1099. break;
  1100. }
  1101. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  1102. __func__,
  1103. slim_rx_cfg[SLIM_RX_7].sample_rate,
  1104. slim_tx_cfg[SLIM_TX_7].sample_rate,
  1105. ucontrol->value.enumerated.item[0]);
  1106. return 0;
  1107. }
  1108. static int msm_bt_sample_rate_sink_get(struct snd_kcontrol *kcontrol,
  1109. struct snd_ctl_elem_value *ucontrol)
  1110. {
  1111. switch (slim_tx_cfg[BT_SLIM_TX].sample_rate) {
  1112. case SAMPLING_RATE_96KHZ:
  1113. ucontrol->value.integer.value[0] = 5;
  1114. break;
  1115. case SAMPLING_RATE_88P2KHZ:
  1116. ucontrol->value.integer.value[0] = 4;
  1117. break;
  1118. case SAMPLING_RATE_48KHZ:
  1119. ucontrol->value.integer.value[0] = 3;
  1120. break;
  1121. case SAMPLING_RATE_44P1KHZ:
  1122. ucontrol->value.integer.value[0] = 2;
  1123. break;
  1124. case SAMPLING_RATE_16KHZ:
  1125. ucontrol->value.integer.value[0] = 1;
  1126. break;
  1127. case SAMPLING_RATE_8KHZ:
  1128. default:
  1129. ucontrol->value.integer.value[0] = 0;
  1130. break;
  1131. }
  1132. pr_debug("%s: sample rate = %d", __func__,
  1133. slim_tx_cfg[BT_SLIM_TX].sample_rate);
  1134. return 0;
  1135. }
  1136. static int msm_bt_sample_rate_sink_put(struct snd_kcontrol *kcontrol,
  1137. struct snd_ctl_elem_value *ucontrol)
  1138. {
  1139. switch (ucontrol->value.integer.value[0]) {
  1140. case 1:
  1141. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_16KHZ;
  1142. break;
  1143. case 2:
  1144. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_44P1KHZ;
  1145. break;
  1146. case 3:
  1147. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_48KHZ;
  1148. break;
  1149. case 4:
  1150. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_88P2KHZ;
  1151. break;
  1152. case 5:
  1153. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_96KHZ;
  1154. break;
  1155. case 0:
  1156. default:
  1157. slim_tx_cfg[BT_SLIM_TX].sample_rate = SAMPLING_RATE_8KHZ;
  1158. break;
  1159. }
  1160. pr_debug("%s: sample rate = %d, value = %d\n",
  1161. __func__,
  1162. slim_tx_cfg[BT_SLIM_TX].sample_rate,
  1163. ucontrol->value.enumerated.item[0]);
  1164. return 0;
  1165. }
  1166. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1167. {
  1168. int idx = 0;
  1169. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1170. sizeof("WSA_CDC_DMA_RX_0")))
  1171. idx = WSA_CDC_DMA_RX_0;
  1172. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  1173. sizeof("WSA_CDC_DMA_RX_0")))
  1174. idx = WSA_CDC_DMA_RX_1;
  1175. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  1176. sizeof("WSA_CDC_DMA_TX_0")))
  1177. idx = WSA_CDC_DMA_TX_0;
  1178. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  1179. sizeof("WSA_CDC_DMA_TX_1")))
  1180. idx = WSA_CDC_DMA_TX_1;
  1181. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  1182. sizeof("WSA_CDC_DMA_TX_2")))
  1183. idx = WSA_CDC_DMA_TX_2;
  1184. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  1185. sizeof("VA_CDC_DMA_TX_0")))
  1186. idx = VA_CDC_DMA_TX_0;
  1187. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  1188. sizeof("VA_CDC_DMA_TX_1")))
  1189. idx = VA_CDC_DMA_TX_1;
  1190. else {
  1191. pr_err("%s: unsupported port: %s\n",
  1192. __func__, kcontrol->id.name);
  1193. return -EINVAL;
  1194. }
  1195. return idx;
  1196. }
  1197. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  1198. struct snd_ctl_elem_value *ucontrol)
  1199. {
  1200. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1201. if (ch_num < 0)
  1202. return ch_num;
  1203. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1204. cdc_dma_rx_cfg[ch_num].channels - 1);
  1205. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  1206. return 0;
  1207. }
  1208. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  1209. struct snd_ctl_elem_value *ucontrol)
  1210. {
  1211. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1212. if (ch_num < 0)
  1213. return ch_num;
  1214. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1215. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1216. cdc_dma_rx_cfg[ch_num].channels);
  1217. return 1;
  1218. }
  1219. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  1220. struct snd_ctl_elem_value *ucontrol)
  1221. {
  1222. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1223. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  1224. case SNDRV_PCM_FORMAT_S32_LE:
  1225. ucontrol->value.integer.value[0] = 3;
  1226. break;
  1227. case SNDRV_PCM_FORMAT_S24_3LE:
  1228. ucontrol->value.integer.value[0] = 2;
  1229. break;
  1230. case SNDRV_PCM_FORMAT_S24_LE:
  1231. ucontrol->value.integer.value[0] = 1;
  1232. break;
  1233. case SNDRV_PCM_FORMAT_S16_LE:
  1234. default:
  1235. ucontrol->value.integer.value[0] = 0;
  1236. break;
  1237. }
  1238. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  1239. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  1240. ucontrol->value.integer.value[0]);
  1241. return 0;
  1242. }
  1243. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  1244. struct snd_ctl_elem_value *ucontrol)
  1245. {
  1246. int rc = 0;
  1247. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1248. switch (ucontrol->value.integer.value[0]) {
  1249. case 3:
  1250. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1251. break;
  1252. case 2:
  1253. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1254. break;
  1255. case 1:
  1256. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1257. break;
  1258. case 0:
  1259. default:
  1260. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1261. break;
  1262. }
  1263. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  1264. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  1265. ucontrol->value.integer.value[0]);
  1266. return rc;
  1267. }
  1268. static int cdc_dma_get_sample_rate_val(int sample_rate)
  1269. {
  1270. int sample_rate_val = 0;
  1271. switch (sample_rate) {
  1272. case SAMPLING_RATE_8KHZ:
  1273. sample_rate_val = 0;
  1274. break;
  1275. case SAMPLING_RATE_11P025KHZ:
  1276. sample_rate_val = 1;
  1277. break;
  1278. case SAMPLING_RATE_16KHZ:
  1279. sample_rate_val = 2;
  1280. break;
  1281. case SAMPLING_RATE_22P05KHZ:
  1282. sample_rate_val = 3;
  1283. break;
  1284. case SAMPLING_RATE_32KHZ:
  1285. sample_rate_val = 4;
  1286. break;
  1287. case SAMPLING_RATE_44P1KHZ:
  1288. sample_rate_val = 5;
  1289. break;
  1290. case SAMPLING_RATE_48KHZ:
  1291. sample_rate_val = 6;
  1292. break;
  1293. case SAMPLING_RATE_88P2KHZ:
  1294. sample_rate_val = 7;
  1295. break;
  1296. case SAMPLING_RATE_96KHZ:
  1297. sample_rate_val = 8;
  1298. break;
  1299. case SAMPLING_RATE_176P4KHZ:
  1300. sample_rate_val = 9;
  1301. break;
  1302. case SAMPLING_RATE_192KHZ:
  1303. sample_rate_val = 10;
  1304. break;
  1305. case SAMPLING_RATE_352P8KHZ:
  1306. sample_rate_val = 11;
  1307. break;
  1308. case SAMPLING_RATE_384KHZ:
  1309. sample_rate_val = 12;
  1310. break;
  1311. default:
  1312. sample_rate_val = 6;
  1313. break;
  1314. }
  1315. return sample_rate_val;
  1316. }
  1317. static int cdc_dma_get_sample_rate(int value)
  1318. {
  1319. int sample_rate = 0;
  1320. switch (value) {
  1321. case 0:
  1322. sample_rate = SAMPLING_RATE_8KHZ;
  1323. break;
  1324. case 1:
  1325. sample_rate = SAMPLING_RATE_11P025KHZ;
  1326. break;
  1327. case 2:
  1328. sample_rate = SAMPLING_RATE_16KHZ;
  1329. break;
  1330. case 3:
  1331. sample_rate = SAMPLING_RATE_22P05KHZ;
  1332. break;
  1333. case 4:
  1334. sample_rate = SAMPLING_RATE_32KHZ;
  1335. break;
  1336. case 5:
  1337. sample_rate = SAMPLING_RATE_44P1KHZ;
  1338. break;
  1339. case 6:
  1340. sample_rate = SAMPLING_RATE_48KHZ;
  1341. break;
  1342. case 7:
  1343. sample_rate = SAMPLING_RATE_88P2KHZ;
  1344. break;
  1345. case 8:
  1346. sample_rate = SAMPLING_RATE_96KHZ;
  1347. break;
  1348. case 9:
  1349. sample_rate = SAMPLING_RATE_176P4KHZ;
  1350. break;
  1351. case 10:
  1352. sample_rate = SAMPLING_RATE_192KHZ;
  1353. break;
  1354. case 11:
  1355. sample_rate = SAMPLING_RATE_352P8KHZ;
  1356. break;
  1357. case 12:
  1358. sample_rate = SAMPLING_RATE_384KHZ;
  1359. break;
  1360. default:
  1361. sample_rate = SAMPLING_RATE_48KHZ;
  1362. break;
  1363. }
  1364. return sample_rate;
  1365. }
  1366. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1367. struct snd_ctl_elem_value *ucontrol)
  1368. {
  1369. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1370. if (ch_num < 0)
  1371. return ch_num;
  1372. ucontrol->value.enumerated.item[0] =
  1373. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  1374. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  1375. cdc_dma_rx_cfg[ch_num].sample_rate);
  1376. return 0;
  1377. }
  1378. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1379. struct snd_ctl_elem_value *ucontrol)
  1380. {
  1381. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1382. if (ch_num < 0)
  1383. return ch_num;
  1384. cdc_dma_rx_cfg[ch_num].sample_rate =
  1385. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1386. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  1387. __func__, ucontrol->value.enumerated.item[0],
  1388. cdc_dma_rx_cfg[ch_num].sample_rate);
  1389. return 0;
  1390. }
  1391. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  1392. struct snd_ctl_elem_value *ucontrol)
  1393. {
  1394. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1395. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  1396. cdc_dma_tx_cfg[ch_num].channels);
  1397. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  1398. return 0;
  1399. }
  1400. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  1401. struct snd_ctl_elem_value *ucontrol)
  1402. {
  1403. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1404. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1405. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  1406. cdc_dma_tx_cfg[ch_num].channels);
  1407. return 1;
  1408. }
  1409. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1410. struct snd_ctl_elem_value *ucontrol)
  1411. {
  1412. int sample_rate_val;
  1413. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1414. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  1415. case SAMPLING_RATE_384KHZ:
  1416. sample_rate_val = 12;
  1417. break;
  1418. case SAMPLING_RATE_352P8KHZ:
  1419. sample_rate_val = 11;
  1420. break;
  1421. case SAMPLING_RATE_192KHZ:
  1422. sample_rate_val = 10;
  1423. break;
  1424. case SAMPLING_RATE_176P4KHZ:
  1425. sample_rate_val = 9;
  1426. break;
  1427. case SAMPLING_RATE_96KHZ:
  1428. sample_rate_val = 8;
  1429. break;
  1430. case SAMPLING_RATE_88P2KHZ:
  1431. sample_rate_val = 7;
  1432. break;
  1433. case SAMPLING_RATE_48KHZ:
  1434. sample_rate_val = 6;
  1435. break;
  1436. case SAMPLING_RATE_44P1KHZ:
  1437. sample_rate_val = 5;
  1438. break;
  1439. case SAMPLING_RATE_32KHZ:
  1440. sample_rate_val = 4;
  1441. break;
  1442. case SAMPLING_RATE_22P05KHZ:
  1443. sample_rate_val = 3;
  1444. break;
  1445. case SAMPLING_RATE_16KHZ:
  1446. sample_rate_val = 2;
  1447. break;
  1448. case SAMPLING_RATE_11P025KHZ:
  1449. sample_rate_val = 1;
  1450. break;
  1451. case SAMPLING_RATE_8KHZ:
  1452. sample_rate_val = 0;
  1453. break;
  1454. default:
  1455. sample_rate_val = 6;
  1456. break;
  1457. }
  1458. ucontrol->value.integer.value[0] = sample_rate_val;
  1459. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  1460. cdc_dma_tx_cfg[ch_num].sample_rate);
  1461. return 0;
  1462. }
  1463. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1464. struct snd_ctl_elem_value *ucontrol)
  1465. {
  1466. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1467. switch (ucontrol->value.integer.value[0]) {
  1468. case 12:
  1469. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  1470. break;
  1471. case 11:
  1472. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  1473. break;
  1474. case 10:
  1475. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  1476. break;
  1477. case 9:
  1478. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  1479. break;
  1480. case 8:
  1481. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  1482. break;
  1483. case 7:
  1484. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  1485. break;
  1486. case 6:
  1487. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  1488. break;
  1489. case 5:
  1490. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  1491. break;
  1492. case 4:
  1493. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  1494. break;
  1495. case 3:
  1496. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  1497. break;
  1498. case 2:
  1499. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  1500. break;
  1501. case 1:
  1502. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  1503. break;
  1504. case 0:
  1505. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  1506. break;
  1507. default:
  1508. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  1509. break;
  1510. }
  1511. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  1512. __func__, ucontrol->value.integer.value[0],
  1513. cdc_dma_tx_cfg[ch_num].sample_rate);
  1514. return 0;
  1515. }
  1516. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  1517. struct snd_ctl_elem_value *ucontrol)
  1518. {
  1519. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1520. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  1521. case SNDRV_PCM_FORMAT_S32_LE:
  1522. ucontrol->value.integer.value[0] = 3;
  1523. break;
  1524. case SNDRV_PCM_FORMAT_S24_3LE:
  1525. ucontrol->value.integer.value[0] = 2;
  1526. break;
  1527. case SNDRV_PCM_FORMAT_S24_LE:
  1528. ucontrol->value.integer.value[0] = 1;
  1529. break;
  1530. case SNDRV_PCM_FORMAT_S16_LE:
  1531. default:
  1532. ucontrol->value.integer.value[0] = 0;
  1533. break;
  1534. }
  1535. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  1536. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  1537. ucontrol->value.integer.value[0]);
  1538. return 0;
  1539. }
  1540. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  1541. struct snd_ctl_elem_value *ucontrol)
  1542. {
  1543. int rc = 0;
  1544. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1545. switch (ucontrol->value.integer.value[0]) {
  1546. case 3:
  1547. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1548. break;
  1549. case 2:
  1550. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1551. break;
  1552. case 1:
  1553. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1554. break;
  1555. case 0:
  1556. default:
  1557. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1558. break;
  1559. }
  1560. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  1561. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  1562. ucontrol->value.integer.value[0]);
  1563. return rc;
  1564. }
  1565. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1566. struct snd_ctl_elem_value *ucontrol)
  1567. {
  1568. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1569. usb_rx_cfg.channels);
  1570. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1571. return 0;
  1572. }
  1573. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1574. struct snd_ctl_elem_value *ucontrol)
  1575. {
  1576. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1577. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1578. return 1;
  1579. }
  1580. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1581. struct snd_ctl_elem_value *ucontrol)
  1582. {
  1583. int sample_rate_val;
  1584. switch (usb_rx_cfg.sample_rate) {
  1585. case SAMPLING_RATE_384KHZ:
  1586. sample_rate_val = 12;
  1587. break;
  1588. case SAMPLING_RATE_352P8KHZ:
  1589. sample_rate_val = 11;
  1590. break;
  1591. case SAMPLING_RATE_192KHZ:
  1592. sample_rate_val = 10;
  1593. break;
  1594. case SAMPLING_RATE_176P4KHZ:
  1595. sample_rate_val = 9;
  1596. break;
  1597. case SAMPLING_RATE_96KHZ:
  1598. sample_rate_val = 8;
  1599. break;
  1600. case SAMPLING_RATE_88P2KHZ:
  1601. sample_rate_val = 7;
  1602. break;
  1603. case SAMPLING_RATE_48KHZ:
  1604. sample_rate_val = 6;
  1605. break;
  1606. case SAMPLING_RATE_44P1KHZ:
  1607. sample_rate_val = 5;
  1608. break;
  1609. case SAMPLING_RATE_32KHZ:
  1610. sample_rate_val = 4;
  1611. break;
  1612. case SAMPLING_RATE_22P05KHZ:
  1613. sample_rate_val = 3;
  1614. break;
  1615. case SAMPLING_RATE_16KHZ:
  1616. sample_rate_val = 2;
  1617. break;
  1618. case SAMPLING_RATE_11P025KHZ:
  1619. sample_rate_val = 1;
  1620. break;
  1621. case SAMPLING_RATE_8KHZ:
  1622. default:
  1623. sample_rate_val = 0;
  1624. break;
  1625. }
  1626. ucontrol->value.integer.value[0] = sample_rate_val;
  1627. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  1628. usb_rx_cfg.sample_rate);
  1629. return 0;
  1630. }
  1631. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1632. struct snd_ctl_elem_value *ucontrol)
  1633. {
  1634. switch (ucontrol->value.integer.value[0]) {
  1635. case 12:
  1636. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1637. break;
  1638. case 11:
  1639. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1640. break;
  1641. case 10:
  1642. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1643. break;
  1644. case 9:
  1645. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1646. break;
  1647. case 8:
  1648. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1649. break;
  1650. case 7:
  1651. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1652. break;
  1653. case 6:
  1654. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1655. break;
  1656. case 5:
  1657. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1658. break;
  1659. case 4:
  1660. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1661. break;
  1662. case 3:
  1663. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1664. break;
  1665. case 2:
  1666. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1667. break;
  1668. case 1:
  1669. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1670. break;
  1671. case 0:
  1672. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1673. break;
  1674. default:
  1675. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1676. break;
  1677. }
  1678. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  1679. __func__, ucontrol->value.integer.value[0],
  1680. usb_rx_cfg.sample_rate);
  1681. return 0;
  1682. }
  1683. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1684. struct snd_ctl_elem_value *ucontrol)
  1685. {
  1686. switch (usb_rx_cfg.bit_format) {
  1687. case SNDRV_PCM_FORMAT_S32_LE:
  1688. ucontrol->value.integer.value[0] = 3;
  1689. break;
  1690. case SNDRV_PCM_FORMAT_S24_3LE:
  1691. ucontrol->value.integer.value[0] = 2;
  1692. break;
  1693. case SNDRV_PCM_FORMAT_S24_LE:
  1694. ucontrol->value.integer.value[0] = 1;
  1695. break;
  1696. case SNDRV_PCM_FORMAT_S16_LE:
  1697. default:
  1698. ucontrol->value.integer.value[0] = 0;
  1699. break;
  1700. }
  1701. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1702. __func__, usb_rx_cfg.bit_format,
  1703. ucontrol->value.integer.value[0]);
  1704. return 0;
  1705. }
  1706. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1707. struct snd_ctl_elem_value *ucontrol)
  1708. {
  1709. int rc = 0;
  1710. switch (ucontrol->value.integer.value[0]) {
  1711. case 3:
  1712. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1713. break;
  1714. case 2:
  1715. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1716. break;
  1717. case 1:
  1718. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1719. break;
  1720. case 0:
  1721. default:
  1722. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1723. break;
  1724. }
  1725. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1726. __func__, usb_rx_cfg.bit_format,
  1727. ucontrol->value.integer.value[0]);
  1728. return rc;
  1729. }
  1730. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1731. struct snd_ctl_elem_value *ucontrol)
  1732. {
  1733. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1734. usb_tx_cfg.channels);
  1735. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1736. return 0;
  1737. }
  1738. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1739. struct snd_ctl_elem_value *ucontrol)
  1740. {
  1741. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1742. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1743. return 1;
  1744. }
  1745. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1746. struct snd_ctl_elem_value *ucontrol)
  1747. {
  1748. int sample_rate_val;
  1749. switch (usb_tx_cfg.sample_rate) {
  1750. case SAMPLING_RATE_384KHZ:
  1751. sample_rate_val = 12;
  1752. break;
  1753. case SAMPLING_RATE_352P8KHZ:
  1754. sample_rate_val = 11;
  1755. break;
  1756. case SAMPLING_RATE_192KHZ:
  1757. sample_rate_val = 10;
  1758. break;
  1759. case SAMPLING_RATE_176P4KHZ:
  1760. sample_rate_val = 9;
  1761. break;
  1762. case SAMPLING_RATE_96KHZ:
  1763. sample_rate_val = 8;
  1764. break;
  1765. case SAMPLING_RATE_88P2KHZ:
  1766. sample_rate_val = 7;
  1767. break;
  1768. case SAMPLING_RATE_48KHZ:
  1769. sample_rate_val = 6;
  1770. break;
  1771. case SAMPLING_RATE_44P1KHZ:
  1772. sample_rate_val = 5;
  1773. break;
  1774. case SAMPLING_RATE_32KHZ:
  1775. sample_rate_val = 4;
  1776. break;
  1777. case SAMPLING_RATE_22P05KHZ:
  1778. sample_rate_val = 3;
  1779. break;
  1780. case SAMPLING_RATE_16KHZ:
  1781. sample_rate_val = 2;
  1782. break;
  1783. case SAMPLING_RATE_11P025KHZ:
  1784. sample_rate_val = 1;
  1785. break;
  1786. case SAMPLING_RATE_8KHZ:
  1787. sample_rate_val = 0;
  1788. break;
  1789. default:
  1790. sample_rate_val = 6;
  1791. break;
  1792. }
  1793. ucontrol->value.integer.value[0] = sample_rate_val;
  1794. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1795. usb_tx_cfg.sample_rate);
  1796. return 0;
  1797. }
  1798. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1799. struct snd_ctl_elem_value *ucontrol)
  1800. {
  1801. switch (ucontrol->value.integer.value[0]) {
  1802. case 12:
  1803. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1804. break;
  1805. case 11:
  1806. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1807. break;
  1808. case 10:
  1809. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1810. break;
  1811. case 9:
  1812. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1813. break;
  1814. case 8:
  1815. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1816. break;
  1817. case 7:
  1818. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1819. break;
  1820. case 6:
  1821. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1822. break;
  1823. case 5:
  1824. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1825. break;
  1826. case 4:
  1827. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1828. break;
  1829. case 3:
  1830. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1831. break;
  1832. case 2:
  1833. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1834. break;
  1835. case 1:
  1836. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1837. break;
  1838. case 0:
  1839. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1840. break;
  1841. default:
  1842. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1843. break;
  1844. }
  1845. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1846. __func__, ucontrol->value.integer.value[0],
  1847. usb_tx_cfg.sample_rate);
  1848. return 0;
  1849. }
  1850. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1851. struct snd_ctl_elem_value *ucontrol)
  1852. {
  1853. switch (usb_tx_cfg.bit_format) {
  1854. case SNDRV_PCM_FORMAT_S32_LE:
  1855. ucontrol->value.integer.value[0] = 3;
  1856. break;
  1857. case SNDRV_PCM_FORMAT_S24_3LE:
  1858. ucontrol->value.integer.value[0] = 2;
  1859. break;
  1860. case SNDRV_PCM_FORMAT_S24_LE:
  1861. ucontrol->value.integer.value[0] = 1;
  1862. break;
  1863. case SNDRV_PCM_FORMAT_S16_LE:
  1864. default:
  1865. ucontrol->value.integer.value[0] = 0;
  1866. break;
  1867. }
  1868. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1869. __func__, usb_tx_cfg.bit_format,
  1870. ucontrol->value.integer.value[0]);
  1871. return 0;
  1872. }
  1873. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1874. struct snd_ctl_elem_value *ucontrol)
  1875. {
  1876. int rc = 0;
  1877. switch (ucontrol->value.integer.value[0]) {
  1878. case 3:
  1879. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1880. break;
  1881. case 2:
  1882. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1883. break;
  1884. case 1:
  1885. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1886. break;
  1887. case 0:
  1888. default:
  1889. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1890. break;
  1891. }
  1892. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1893. __func__, usb_tx_cfg.bit_format,
  1894. ucontrol->value.integer.value[0]);
  1895. return rc;
  1896. }
  1897. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1898. struct snd_ctl_elem_value *ucontrol)
  1899. {
  1900. pr_debug("%s: proxy_rx channels = %d\n",
  1901. __func__, proxy_rx_cfg.channels);
  1902. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1903. return 0;
  1904. }
  1905. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1906. struct snd_ctl_elem_value *ucontrol)
  1907. {
  1908. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1909. pr_debug("%s: proxy_rx channels = %d\n",
  1910. __func__, proxy_rx_cfg.channels);
  1911. return 1;
  1912. }
  1913. static int tdm_get_sample_rate(int value)
  1914. {
  1915. int sample_rate = 0;
  1916. switch (value) {
  1917. case 0:
  1918. sample_rate = SAMPLING_RATE_8KHZ;
  1919. break;
  1920. case 1:
  1921. sample_rate = SAMPLING_RATE_16KHZ;
  1922. break;
  1923. case 2:
  1924. sample_rate = SAMPLING_RATE_32KHZ;
  1925. break;
  1926. case 3:
  1927. sample_rate = SAMPLING_RATE_48KHZ;
  1928. break;
  1929. case 4:
  1930. sample_rate = SAMPLING_RATE_176P4KHZ;
  1931. break;
  1932. case 5:
  1933. sample_rate = SAMPLING_RATE_352P8KHZ;
  1934. break;
  1935. default:
  1936. sample_rate = SAMPLING_RATE_48KHZ;
  1937. break;
  1938. }
  1939. return sample_rate;
  1940. }
  1941. static int aux_pcm_get_sample_rate(int value)
  1942. {
  1943. int sample_rate;
  1944. switch (value) {
  1945. case 1:
  1946. sample_rate = SAMPLING_RATE_16KHZ;
  1947. break;
  1948. case 0:
  1949. default:
  1950. sample_rate = SAMPLING_RATE_8KHZ;
  1951. break;
  1952. }
  1953. return sample_rate;
  1954. }
  1955. static int tdm_get_sample_rate_val(int sample_rate)
  1956. {
  1957. int sample_rate_val = 0;
  1958. switch (sample_rate) {
  1959. case SAMPLING_RATE_8KHZ:
  1960. sample_rate_val = 0;
  1961. break;
  1962. case SAMPLING_RATE_16KHZ:
  1963. sample_rate_val = 1;
  1964. break;
  1965. case SAMPLING_RATE_32KHZ:
  1966. sample_rate_val = 2;
  1967. break;
  1968. case SAMPLING_RATE_48KHZ:
  1969. sample_rate_val = 3;
  1970. break;
  1971. case SAMPLING_RATE_176P4KHZ:
  1972. sample_rate_val = 4;
  1973. break;
  1974. case SAMPLING_RATE_352P8KHZ:
  1975. sample_rate_val = 5;
  1976. break;
  1977. default:
  1978. sample_rate_val = 3;
  1979. break;
  1980. }
  1981. return sample_rate_val;
  1982. }
  1983. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1984. {
  1985. int sample_rate_val;
  1986. switch (sample_rate) {
  1987. case SAMPLING_RATE_16KHZ:
  1988. sample_rate_val = 1;
  1989. break;
  1990. case SAMPLING_RATE_8KHZ:
  1991. default:
  1992. sample_rate_val = 0;
  1993. break;
  1994. }
  1995. return sample_rate_val;
  1996. }
  1997. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1998. struct tdm_port *port)
  1999. {
  2000. if (port) {
  2001. if (strnstr(kcontrol->id.name, "PRI",
  2002. sizeof(kcontrol->id.name))) {
  2003. port->mode = TDM_PRI;
  2004. } else if (strnstr(kcontrol->id.name, "SEC",
  2005. sizeof(kcontrol->id.name))) {
  2006. port->mode = TDM_SEC;
  2007. } else if (strnstr(kcontrol->id.name, "TERT",
  2008. sizeof(kcontrol->id.name))) {
  2009. port->mode = TDM_TERT;
  2010. } else if (strnstr(kcontrol->id.name, "QUAT",
  2011. sizeof(kcontrol->id.name))) {
  2012. port->mode = TDM_QUAT;
  2013. } else if (strnstr(kcontrol->id.name, "QUIN",
  2014. sizeof(kcontrol->id.name))) {
  2015. port->mode = TDM_QUIN;
  2016. } else {
  2017. pr_err("%s: unsupported mode in: %s",
  2018. __func__, kcontrol->id.name);
  2019. return -EINVAL;
  2020. }
  2021. if (strnstr(kcontrol->id.name, "RX_0",
  2022. sizeof(kcontrol->id.name)) ||
  2023. strnstr(kcontrol->id.name, "TX_0",
  2024. sizeof(kcontrol->id.name))) {
  2025. port->channel = TDM_0;
  2026. } else if (strnstr(kcontrol->id.name, "RX_1",
  2027. sizeof(kcontrol->id.name)) ||
  2028. strnstr(kcontrol->id.name, "TX_1",
  2029. sizeof(kcontrol->id.name))) {
  2030. port->channel = TDM_1;
  2031. } else if (strnstr(kcontrol->id.name, "RX_2",
  2032. sizeof(kcontrol->id.name)) ||
  2033. strnstr(kcontrol->id.name, "TX_2",
  2034. sizeof(kcontrol->id.name))) {
  2035. port->channel = TDM_2;
  2036. } else if (strnstr(kcontrol->id.name, "RX_3",
  2037. sizeof(kcontrol->id.name)) ||
  2038. strnstr(kcontrol->id.name, "TX_3",
  2039. sizeof(kcontrol->id.name))) {
  2040. port->channel = TDM_3;
  2041. } else if (strnstr(kcontrol->id.name, "RX_4",
  2042. sizeof(kcontrol->id.name)) ||
  2043. strnstr(kcontrol->id.name, "TX_4",
  2044. sizeof(kcontrol->id.name))) {
  2045. port->channel = TDM_4;
  2046. } else if (strnstr(kcontrol->id.name, "RX_5",
  2047. sizeof(kcontrol->id.name)) ||
  2048. strnstr(kcontrol->id.name, "TX_5",
  2049. sizeof(kcontrol->id.name))) {
  2050. port->channel = TDM_5;
  2051. } else if (strnstr(kcontrol->id.name, "RX_6",
  2052. sizeof(kcontrol->id.name)) ||
  2053. strnstr(kcontrol->id.name, "TX_6",
  2054. sizeof(kcontrol->id.name))) {
  2055. port->channel = TDM_6;
  2056. } else if (strnstr(kcontrol->id.name, "RX_7",
  2057. sizeof(kcontrol->id.name)) ||
  2058. strnstr(kcontrol->id.name, "TX_7",
  2059. sizeof(kcontrol->id.name))) {
  2060. port->channel = TDM_7;
  2061. } else {
  2062. pr_err("%s: unsupported channel in: %s",
  2063. __func__, kcontrol->id.name);
  2064. return -EINVAL;
  2065. }
  2066. } else
  2067. return -EINVAL;
  2068. return 0;
  2069. }
  2070. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2071. struct snd_ctl_elem_value *ucontrol)
  2072. {
  2073. struct tdm_port port;
  2074. int ret = tdm_get_port_idx(kcontrol, &port);
  2075. if (ret) {
  2076. pr_err("%s: unsupported control: %s",
  2077. __func__, kcontrol->id.name);
  2078. } else {
  2079. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  2080. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  2081. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  2082. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  2083. ucontrol->value.enumerated.item[0]);
  2084. }
  2085. return ret;
  2086. }
  2087. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2088. struct snd_ctl_elem_value *ucontrol)
  2089. {
  2090. struct tdm_port port;
  2091. int ret = tdm_get_port_idx(kcontrol, &port);
  2092. if (ret) {
  2093. pr_err("%s: unsupported control: %s",
  2094. __func__, kcontrol->id.name);
  2095. } else {
  2096. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  2097. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2098. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  2099. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  2100. ucontrol->value.enumerated.item[0]);
  2101. }
  2102. return ret;
  2103. }
  2104. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2105. struct snd_ctl_elem_value *ucontrol)
  2106. {
  2107. struct tdm_port port;
  2108. int ret = tdm_get_port_idx(kcontrol, &port);
  2109. if (ret) {
  2110. pr_err("%s: unsupported control: %s",
  2111. __func__, kcontrol->id.name);
  2112. } else {
  2113. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  2114. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  2115. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  2116. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  2117. ucontrol->value.enumerated.item[0]);
  2118. }
  2119. return ret;
  2120. }
  2121. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2122. struct snd_ctl_elem_value *ucontrol)
  2123. {
  2124. struct tdm_port port;
  2125. int ret = tdm_get_port_idx(kcontrol, &port);
  2126. if (ret) {
  2127. pr_err("%s: unsupported control: %s",
  2128. __func__, kcontrol->id.name);
  2129. } else {
  2130. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  2131. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2132. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  2133. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  2134. ucontrol->value.enumerated.item[0]);
  2135. }
  2136. return ret;
  2137. }
  2138. static int tdm_get_format(int value)
  2139. {
  2140. int format = 0;
  2141. switch (value) {
  2142. case 0:
  2143. format = SNDRV_PCM_FORMAT_S16_LE;
  2144. break;
  2145. case 1:
  2146. format = SNDRV_PCM_FORMAT_S24_LE;
  2147. break;
  2148. case 2:
  2149. format = SNDRV_PCM_FORMAT_S32_LE;
  2150. break;
  2151. default:
  2152. format = SNDRV_PCM_FORMAT_S16_LE;
  2153. break;
  2154. }
  2155. return format;
  2156. }
  2157. static int tdm_get_format_val(int format)
  2158. {
  2159. int value = 0;
  2160. switch (format) {
  2161. case SNDRV_PCM_FORMAT_S16_LE:
  2162. value = 0;
  2163. break;
  2164. case SNDRV_PCM_FORMAT_S24_LE:
  2165. value = 1;
  2166. break;
  2167. case SNDRV_PCM_FORMAT_S32_LE:
  2168. value = 2;
  2169. break;
  2170. default:
  2171. value = 0;
  2172. break;
  2173. }
  2174. return value;
  2175. }
  2176. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  2177. struct snd_ctl_elem_value *ucontrol)
  2178. {
  2179. struct tdm_port port;
  2180. int ret = tdm_get_port_idx(kcontrol, &port);
  2181. if (ret) {
  2182. pr_err("%s: unsupported control: %s",
  2183. __func__, kcontrol->id.name);
  2184. } else {
  2185. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  2186. tdm_rx_cfg[port.mode][port.channel].bit_format);
  2187. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  2188. tdm_rx_cfg[port.mode][port.channel].bit_format,
  2189. ucontrol->value.enumerated.item[0]);
  2190. }
  2191. return ret;
  2192. }
  2193. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  2194. struct snd_ctl_elem_value *ucontrol)
  2195. {
  2196. struct tdm_port port;
  2197. int ret = tdm_get_port_idx(kcontrol, &port);
  2198. if (ret) {
  2199. pr_err("%s: unsupported control: %s",
  2200. __func__, kcontrol->id.name);
  2201. } else {
  2202. tdm_rx_cfg[port.mode][port.channel].bit_format =
  2203. tdm_get_format(ucontrol->value.enumerated.item[0]);
  2204. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  2205. tdm_rx_cfg[port.mode][port.channel].bit_format,
  2206. ucontrol->value.enumerated.item[0]);
  2207. }
  2208. return ret;
  2209. }
  2210. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  2211. struct snd_ctl_elem_value *ucontrol)
  2212. {
  2213. struct tdm_port port;
  2214. int ret = tdm_get_port_idx(kcontrol, &port);
  2215. if (ret) {
  2216. pr_err("%s: unsupported control: %s",
  2217. __func__, kcontrol->id.name);
  2218. } else {
  2219. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  2220. tdm_tx_cfg[port.mode][port.channel].bit_format);
  2221. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  2222. tdm_tx_cfg[port.mode][port.channel].bit_format,
  2223. ucontrol->value.enumerated.item[0]);
  2224. }
  2225. return ret;
  2226. }
  2227. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  2228. struct snd_ctl_elem_value *ucontrol)
  2229. {
  2230. struct tdm_port port;
  2231. int ret = tdm_get_port_idx(kcontrol, &port);
  2232. if (ret) {
  2233. pr_err("%s: unsupported control: %s",
  2234. __func__, kcontrol->id.name);
  2235. } else {
  2236. tdm_tx_cfg[port.mode][port.channel].bit_format =
  2237. tdm_get_format(ucontrol->value.enumerated.item[0]);
  2238. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  2239. tdm_tx_cfg[port.mode][port.channel].bit_format,
  2240. ucontrol->value.enumerated.item[0]);
  2241. }
  2242. return ret;
  2243. }
  2244. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  2245. struct snd_ctl_elem_value *ucontrol)
  2246. {
  2247. struct tdm_port port;
  2248. int ret = tdm_get_port_idx(kcontrol, &port);
  2249. if (ret) {
  2250. pr_err("%s: unsupported control: %s",
  2251. __func__, kcontrol->id.name);
  2252. } else {
  2253. ucontrol->value.enumerated.item[0] =
  2254. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  2255. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  2256. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  2257. ucontrol->value.enumerated.item[0]);
  2258. }
  2259. return ret;
  2260. }
  2261. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  2262. struct snd_ctl_elem_value *ucontrol)
  2263. {
  2264. struct tdm_port port;
  2265. int ret = tdm_get_port_idx(kcontrol, &port);
  2266. if (ret) {
  2267. pr_err("%s: unsupported control: %s",
  2268. __func__, kcontrol->id.name);
  2269. } else {
  2270. tdm_rx_cfg[port.mode][port.channel].channels =
  2271. ucontrol->value.enumerated.item[0] + 1;
  2272. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  2273. tdm_rx_cfg[port.mode][port.channel].channels,
  2274. ucontrol->value.enumerated.item[0] + 1);
  2275. }
  2276. return ret;
  2277. }
  2278. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  2279. struct snd_ctl_elem_value *ucontrol)
  2280. {
  2281. struct tdm_port port;
  2282. int ret = tdm_get_port_idx(kcontrol, &port);
  2283. if (ret) {
  2284. pr_err("%s: unsupported control: %s",
  2285. __func__, kcontrol->id.name);
  2286. } else {
  2287. ucontrol->value.enumerated.item[0] =
  2288. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  2289. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  2290. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  2291. ucontrol->value.enumerated.item[0]);
  2292. }
  2293. return ret;
  2294. }
  2295. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  2296. struct snd_ctl_elem_value *ucontrol)
  2297. {
  2298. struct tdm_port port;
  2299. int ret = tdm_get_port_idx(kcontrol, &port);
  2300. if (ret) {
  2301. pr_err("%s: unsupported control: %s",
  2302. __func__, kcontrol->id.name);
  2303. } else {
  2304. tdm_tx_cfg[port.mode][port.channel].channels =
  2305. ucontrol->value.enumerated.item[0] + 1;
  2306. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  2307. tdm_tx_cfg[port.mode][port.channel].channels,
  2308. ucontrol->value.enumerated.item[0] + 1);
  2309. }
  2310. return ret;
  2311. }
  2312. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  2313. {
  2314. int idx;
  2315. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  2316. sizeof("PRIM_AUX_PCM")))
  2317. idx = PRIM_AUX_PCM;
  2318. else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  2319. sizeof("SEC_AUX_PCM")))
  2320. idx = SEC_AUX_PCM;
  2321. else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  2322. sizeof("TERT_AUX_PCM")))
  2323. idx = TERT_AUX_PCM;
  2324. else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  2325. sizeof("QUAT_AUX_PCM")))
  2326. idx = QUAT_AUX_PCM;
  2327. else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  2328. sizeof("QUIN_AUX_PCM")))
  2329. idx = QUIN_AUX_PCM;
  2330. else if (strnstr(kcontrol->id.name, "SEN_AUX_PCM",
  2331. sizeof("SENN_AUX_PCM")))
  2332. idx = SEN_AUX_PCM;
  2333. else {
  2334. pr_err("%s: unsupported port: %s",
  2335. __func__, kcontrol->id.name);
  2336. idx = -EINVAL;
  2337. }
  2338. return idx;
  2339. }
  2340. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2341. struct snd_ctl_elem_value *ucontrol)
  2342. {
  2343. int idx = aux_pcm_get_port_idx(kcontrol);
  2344. if (idx < 0)
  2345. return idx;
  2346. aux_pcm_rx_cfg[idx].sample_rate =
  2347. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2348. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2349. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2350. ucontrol->value.enumerated.item[0]);
  2351. return 0;
  2352. }
  2353. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2354. struct snd_ctl_elem_value *ucontrol)
  2355. {
  2356. int idx = aux_pcm_get_port_idx(kcontrol);
  2357. if (idx < 0)
  2358. return idx;
  2359. ucontrol->value.enumerated.item[0] =
  2360. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  2361. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2362. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2363. ucontrol->value.enumerated.item[0]);
  2364. return 0;
  2365. }
  2366. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2367. struct snd_ctl_elem_value *ucontrol)
  2368. {
  2369. int idx = aux_pcm_get_port_idx(kcontrol);
  2370. if (idx < 0)
  2371. return idx;
  2372. aux_pcm_tx_cfg[idx].sample_rate =
  2373. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2374. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2375. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2376. ucontrol->value.enumerated.item[0]);
  2377. return 0;
  2378. }
  2379. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2380. struct snd_ctl_elem_value *ucontrol)
  2381. {
  2382. int idx = aux_pcm_get_port_idx(kcontrol);
  2383. if (idx < 0)
  2384. return idx;
  2385. ucontrol->value.enumerated.item[0] =
  2386. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  2387. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2388. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2389. ucontrol->value.enumerated.item[0]);
  2390. return 0;
  2391. }
  2392. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2393. {
  2394. int idx;
  2395. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2396. sizeof("PRIM_MI2S_RX")))
  2397. idx = PRIM_MI2S;
  2398. else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2399. sizeof("SEC_MI2S_RX")))
  2400. idx = SEC_MI2S;
  2401. else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2402. sizeof("TERT_MI2S_RX")))
  2403. idx = TERT_MI2S;
  2404. else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2405. sizeof("QUAT_MI2S_RX")))
  2406. idx = QUAT_MI2S;
  2407. else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2408. sizeof("QUIN_MI2S_RX")))
  2409. idx = QUIN_MI2S;
  2410. else if (strnstr(kcontrol->id.name, "SEN_MI2S_RX",
  2411. sizeof("SEN_MI2S_RX")))
  2412. idx = SEN_MI2S;
  2413. else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2414. sizeof("PRIM_MI2S_TX")))
  2415. idx = PRIM_MI2S;
  2416. else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2417. sizeof("SEC_MI2S_TX")))
  2418. idx = SEC_MI2S;
  2419. else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2420. sizeof("TERT_MI2S_TX")))
  2421. idx = TERT_MI2S;
  2422. else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2423. sizeof("QUAT_MI2S_TX")))
  2424. idx = QUAT_MI2S;
  2425. else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2426. sizeof("QUIN_MI2S_TX")))
  2427. idx = QUIN_MI2S;
  2428. else if (strnstr(kcontrol->id.name, "SEN_MI2S_TX",
  2429. sizeof("SEN_MI2S_TX")))
  2430. idx = SEN_MI2S;
  2431. else {
  2432. pr_err("%s: unsupported channel: %s",
  2433. __func__, kcontrol->id.name);
  2434. idx = -EINVAL;
  2435. }
  2436. return idx;
  2437. }
  2438. static int mi2s_get_sample_rate_val(int sample_rate)
  2439. {
  2440. int sample_rate_val;
  2441. switch (sample_rate) {
  2442. case SAMPLING_RATE_8KHZ:
  2443. sample_rate_val = 0;
  2444. break;
  2445. case SAMPLING_RATE_11P025KHZ:
  2446. sample_rate_val = 1;
  2447. break;
  2448. case SAMPLING_RATE_16KHZ:
  2449. sample_rate_val = 2;
  2450. break;
  2451. case SAMPLING_RATE_22P05KHZ:
  2452. sample_rate_val = 3;
  2453. break;
  2454. case SAMPLING_RATE_32KHZ:
  2455. sample_rate_val = 4;
  2456. break;
  2457. case SAMPLING_RATE_44P1KHZ:
  2458. sample_rate_val = 5;
  2459. break;
  2460. case SAMPLING_RATE_48KHZ:
  2461. sample_rate_val = 6;
  2462. break;
  2463. case SAMPLING_RATE_88P2KHZ:
  2464. sample_rate_val = 7;
  2465. break;
  2466. case SAMPLING_RATE_96KHZ:
  2467. sample_rate_val = 8;
  2468. break;
  2469. case SAMPLING_RATE_176P4KHZ:
  2470. sample_rate_val = 9;
  2471. break;
  2472. case SAMPLING_RATE_192KHZ:
  2473. sample_rate_val = 10;
  2474. break;
  2475. case SAMPLING_RATE_352P8KHZ:
  2476. sample_rate_val = 11;
  2477. break;
  2478. case SAMPLING_RATE_384KHZ:
  2479. sample_rate_val = 12;
  2480. break;
  2481. default:
  2482. sample_rate_val = 6;
  2483. break;
  2484. }
  2485. return sample_rate_val;
  2486. }
  2487. static int mi2s_get_sample_rate(int value)
  2488. {
  2489. int sample_rate;
  2490. switch (value) {
  2491. case 0:
  2492. sample_rate = SAMPLING_RATE_8KHZ;
  2493. break;
  2494. case 1:
  2495. sample_rate = SAMPLING_RATE_11P025KHZ;
  2496. break;
  2497. case 2:
  2498. sample_rate = SAMPLING_RATE_16KHZ;
  2499. break;
  2500. case 3:
  2501. sample_rate = SAMPLING_RATE_22P05KHZ;
  2502. break;
  2503. case 4:
  2504. sample_rate = SAMPLING_RATE_32KHZ;
  2505. break;
  2506. case 5:
  2507. sample_rate = SAMPLING_RATE_44P1KHZ;
  2508. break;
  2509. case 6:
  2510. sample_rate = SAMPLING_RATE_48KHZ;
  2511. break;
  2512. case 7:
  2513. sample_rate = SAMPLING_RATE_88P2KHZ;
  2514. break;
  2515. case 8:
  2516. sample_rate = SAMPLING_RATE_96KHZ;
  2517. break;
  2518. case 9:
  2519. sample_rate = SAMPLING_RATE_176P4KHZ;
  2520. break;
  2521. case 10:
  2522. sample_rate = SAMPLING_RATE_192KHZ;
  2523. break;
  2524. case 11:
  2525. sample_rate = SAMPLING_RATE_352P8KHZ;
  2526. break;
  2527. case 12:
  2528. sample_rate = SAMPLING_RATE_384KHZ;
  2529. break;
  2530. default:
  2531. sample_rate = SAMPLING_RATE_48KHZ;
  2532. break;
  2533. }
  2534. return sample_rate;
  2535. }
  2536. static int mi2s_auxpcm_get_format(int value)
  2537. {
  2538. int format;
  2539. switch (value) {
  2540. case 0:
  2541. format = SNDRV_PCM_FORMAT_S16_LE;
  2542. break;
  2543. case 1:
  2544. format = SNDRV_PCM_FORMAT_S24_LE;
  2545. break;
  2546. case 2:
  2547. format = SNDRV_PCM_FORMAT_S24_3LE;
  2548. break;
  2549. case 3:
  2550. format = SNDRV_PCM_FORMAT_S32_LE;
  2551. break;
  2552. default:
  2553. format = SNDRV_PCM_FORMAT_S16_LE;
  2554. break;
  2555. }
  2556. return format;
  2557. }
  2558. static int mi2s_auxpcm_get_format_value(int format)
  2559. {
  2560. int value;
  2561. switch (format) {
  2562. case SNDRV_PCM_FORMAT_S16_LE:
  2563. value = 0;
  2564. break;
  2565. case SNDRV_PCM_FORMAT_S24_LE:
  2566. value = 1;
  2567. break;
  2568. case SNDRV_PCM_FORMAT_S24_3LE:
  2569. value = 2;
  2570. break;
  2571. case SNDRV_PCM_FORMAT_S32_LE:
  2572. value = 3;
  2573. break;
  2574. default:
  2575. value = 0;
  2576. break;
  2577. }
  2578. return value;
  2579. }
  2580. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2581. struct snd_ctl_elem_value *ucontrol)
  2582. {
  2583. int idx = mi2s_get_port_idx(kcontrol);
  2584. if (idx < 0)
  2585. return idx;
  2586. mi2s_rx_cfg[idx].sample_rate =
  2587. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2588. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2589. idx, mi2s_rx_cfg[idx].sample_rate,
  2590. ucontrol->value.enumerated.item[0]);
  2591. return 0;
  2592. }
  2593. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2594. struct snd_ctl_elem_value *ucontrol)
  2595. {
  2596. int idx = mi2s_get_port_idx(kcontrol);
  2597. if (idx < 0)
  2598. return idx;
  2599. ucontrol->value.enumerated.item[0] =
  2600. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2601. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2602. idx, mi2s_rx_cfg[idx].sample_rate,
  2603. ucontrol->value.enumerated.item[0]);
  2604. return 0;
  2605. }
  2606. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2607. struct snd_ctl_elem_value *ucontrol)
  2608. {
  2609. int idx = mi2s_get_port_idx(kcontrol);
  2610. if (idx < 0)
  2611. return idx;
  2612. mi2s_tx_cfg[idx].sample_rate =
  2613. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2614. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2615. idx, mi2s_tx_cfg[idx].sample_rate,
  2616. ucontrol->value.enumerated.item[0]);
  2617. return 0;
  2618. }
  2619. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2620. struct snd_ctl_elem_value *ucontrol)
  2621. {
  2622. int idx = mi2s_get_port_idx(kcontrol);
  2623. if (idx < 0)
  2624. return idx;
  2625. ucontrol->value.enumerated.item[0] =
  2626. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2627. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2628. idx, mi2s_tx_cfg[idx].sample_rate,
  2629. ucontrol->value.enumerated.item[0]);
  2630. return 0;
  2631. }
  2632. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2633. struct snd_ctl_elem_value *ucontrol)
  2634. {
  2635. int idx = mi2s_get_port_idx(kcontrol);
  2636. if (idx < 0)
  2637. return idx;
  2638. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2639. idx, mi2s_rx_cfg[idx].channels);
  2640. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2641. return 0;
  2642. }
  2643. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2644. struct snd_ctl_elem_value *ucontrol)
  2645. {
  2646. int idx = mi2s_get_port_idx(kcontrol);
  2647. if (idx < 0)
  2648. return idx;
  2649. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2650. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2651. idx, mi2s_rx_cfg[idx].channels);
  2652. return 1;
  2653. }
  2654. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2655. struct snd_ctl_elem_value *ucontrol)
  2656. {
  2657. int idx = mi2s_get_port_idx(kcontrol);
  2658. if (idx < 0)
  2659. return idx;
  2660. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2661. idx, mi2s_tx_cfg[idx].channels);
  2662. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2663. return 0;
  2664. }
  2665. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2666. struct snd_ctl_elem_value *ucontrol)
  2667. {
  2668. int idx = mi2s_get_port_idx(kcontrol);
  2669. if (idx < 0)
  2670. return idx;
  2671. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2672. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2673. idx, mi2s_tx_cfg[idx].channels);
  2674. return 1;
  2675. }
  2676. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2677. struct snd_ctl_elem_value *ucontrol)
  2678. {
  2679. int idx = mi2s_get_port_idx(kcontrol);
  2680. if (idx < 0)
  2681. return idx;
  2682. ucontrol->value.enumerated.item[0] =
  2683. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2684. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2685. idx, mi2s_rx_cfg[idx].bit_format,
  2686. ucontrol->value.enumerated.item[0]);
  2687. return 0;
  2688. }
  2689. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2690. struct snd_ctl_elem_value *ucontrol)
  2691. {
  2692. struct msm_asoc_mach_data *pdata = NULL;
  2693. struct snd_soc_component *component = NULL;
  2694. struct snd_soc_card *card = NULL;
  2695. int idx = mi2s_get_port_idx(kcontrol);
  2696. component = snd_soc_kcontrol_component(kcontrol);
  2697. card = kcontrol->private_data;
  2698. pdata = snd_soc_card_get_drvdata(card);
  2699. if (idx < 0)
  2700. return idx;
  2701. /* check for PRIM_MI2S and CSRAx config to allow 24bit BE config only */
  2702. if ((PRIM_MI2S == idx) && (true==pdata->codec_is_csra))
  2703. {
  2704. mi2s_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2705. pr_debug("%s: Keeping default format idx[%d]_rx_format = %d, item = %d\n",
  2706. __func__, idx, mi2s_rx_cfg[idx].bit_format,
  2707. ucontrol->value.enumerated.item[0]);
  2708. } else {
  2709. mi2s_rx_cfg[idx].bit_format =
  2710. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2711. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2712. idx, mi2s_rx_cfg[idx].bit_format,
  2713. ucontrol->value.enumerated.item[0]);
  2714. }
  2715. return 0;
  2716. }
  2717. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2718. struct snd_ctl_elem_value *ucontrol)
  2719. {
  2720. int idx = mi2s_get_port_idx(kcontrol);
  2721. if (idx < 0)
  2722. return idx;
  2723. ucontrol->value.enumerated.item[0] =
  2724. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2725. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2726. idx, mi2s_tx_cfg[idx].bit_format,
  2727. ucontrol->value.enumerated.item[0]);
  2728. return 0;
  2729. }
  2730. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2731. struct snd_ctl_elem_value *ucontrol)
  2732. {
  2733. int idx = mi2s_get_port_idx(kcontrol);
  2734. if (idx < 0)
  2735. return idx;
  2736. mi2s_tx_cfg[idx].bit_format =
  2737. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2738. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2739. idx, mi2s_tx_cfg[idx].bit_format,
  2740. ucontrol->value.enumerated.item[0]);
  2741. return 0;
  2742. }
  2743. static int msm_meta_mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2744. {
  2745. int idx = 0;
  2746. if (strnstr(kcontrol->id.name, "PRIM_META_MI2S_RX",
  2747. sizeof("PRIM_META_MI2S_RX"))) {
  2748. idx = PRIM_META_MI2S;
  2749. } else if (strnstr(kcontrol->id.name, "SEC_META_MI2S_RX",
  2750. sizeof("SEC_META_MI2S_RX"))) {
  2751. idx = SEC_META_MI2S;
  2752. } else {
  2753. pr_err("%s: unsupported port: %s",
  2754. __func__, kcontrol->id.name);
  2755. idx = -EINVAL;
  2756. }
  2757. return idx;
  2758. }
  2759. static int msm_meta_mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2760. struct snd_ctl_elem_value *ucontrol)
  2761. {
  2762. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2763. if (idx < 0)
  2764. return idx;
  2765. ucontrol->value.enumerated.item[0] =
  2766. mi2s_get_sample_rate_val(meta_mi2s_rx_cfg[idx].sample_rate);
  2767. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2768. idx, meta_mi2s_rx_cfg[idx].sample_rate,
  2769. ucontrol->value.enumerated.item[0]);
  2770. return 0;
  2771. }
  2772. static int msm_meta_mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2773. struct snd_ctl_elem_value *ucontrol)
  2774. {
  2775. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2776. if (idx < 0)
  2777. return idx;
  2778. meta_mi2s_rx_cfg[idx].sample_rate =
  2779. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2780. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2781. idx, meta_mi2s_rx_cfg[idx].sample_rate,
  2782. ucontrol->value.enumerated.item[0]);
  2783. return 0;
  2784. }
  2785. static int msm_meta_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2786. struct snd_ctl_elem_value *ucontrol)
  2787. {
  2788. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2789. if (idx < 0)
  2790. return idx;
  2791. ucontrol->value.enumerated.item[0] = meta_mi2s_rx_cfg[idx].channels - 1;
  2792. pr_debug("%s: meta_mi2s_[%d]_rx_ch = %d\n", __func__,
  2793. idx, meta_mi2s_rx_cfg[idx].channels);
  2794. return 0;
  2795. }
  2796. static int msm_meta_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2797. struct snd_ctl_elem_value *ucontrol)
  2798. {
  2799. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2800. if (idx < 0)
  2801. return idx;
  2802. meta_mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2803. pr_debug("%s: meta_mi2s_[%d]_rx_ch = %d\n", __func__,
  2804. idx, meta_mi2s_rx_cfg[idx].channels);
  2805. return 1;
  2806. }
  2807. static int msm_meta_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2808. struct snd_ctl_elem_value *ucontrol)
  2809. {
  2810. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2811. if (idx < 0)
  2812. return idx;
  2813. ucontrol->value.enumerated.item[0] =
  2814. mi2s_auxpcm_get_format_value(meta_mi2s_rx_cfg[idx].bit_format);
  2815. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2816. idx, meta_mi2s_rx_cfg[idx].bit_format,
  2817. ucontrol->value.enumerated.item[0]);
  2818. return 0;
  2819. }
  2820. static int msm_meta_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2821. struct snd_ctl_elem_value *ucontrol)
  2822. {
  2823. struct msm_asoc_mach_data *pdata = NULL;
  2824. struct snd_soc_card *card = NULL;
  2825. int idx = msm_meta_mi2s_get_port_idx(kcontrol);
  2826. card = kcontrol->private_data;
  2827. pdata = snd_soc_card_get_drvdata(card);
  2828. if (idx < 0)
  2829. return idx;
  2830. /* check for PRIM_META_MI2S and CSRAx to allow 24bit BE config only */
  2831. if ((idx == PRIM_META_MI2S) && pdata->codec_is_csra) {
  2832. meta_mi2s_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2833. pr_debug("%s: Keeping default format idx[%d]_rx_format = %d, item = %d\n",
  2834. __func__, idx, meta_mi2s_rx_cfg[idx].bit_format,
  2835. ucontrol->value.enumerated.item[0]);
  2836. } else {
  2837. meta_mi2s_rx_cfg[idx].bit_format =
  2838. mi2s_auxpcm_get_format(
  2839. ucontrol->value.enumerated.item[0]);
  2840. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2841. idx, meta_mi2s_rx_cfg[idx].bit_format,
  2842. ucontrol->value.enumerated.item[0]);
  2843. }
  2844. return 0;
  2845. }
  2846. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  2847. struct snd_ctl_elem_value *ucontrol)
  2848. {
  2849. int idx = aux_pcm_get_port_idx(kcontrol);
  2850. if (idx < 0)
  2851. return idx;
  2852. ucontrol->value.enumerated.item[0] =
  2853. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  2854. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2855. idx, aux_pcm_rx_cfg[idx].bit_format,
  2856. ucontrol->value.enumerated.item[0]);
  2857. return 0;
  2858. }
  2859. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  2860. struct snd_ctl_elem_value *ucontrol)
  2861. {
  2862. int idx = aux_pcm_get_port_idx(kcontrol);
  2863. if (idx < 0)
  2864. return idx;
  2865. aux_pcm_rx_cfg[idx].bit_format =
  2866. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2867. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2868. idx, aux_pcm_rx_cfg[idx].bit_format,
  2869. ucontrol->value.enumerated.item[0]);
  2870. return 0;
  2871. }
  2872. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  2873. struct snd_ctl_elem_value *ucontrol)
  2874. {
  2875. int idx = aux_pcm_get_port_idx(kcontrol);
  2876. if (idx < 0)
  2877. return idx;
  2878. ucontrol->value.enumerated.item[0] =
  2879. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  2880. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2881. idx, aux_pcm_tx_cfg[idx].bit_format,
  2882. ucontrol->value.enumerated.item[0]);
  2883. return 0;
  2884. }
  2885. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  2886. struct snd_ctl_elem_value *ucontrol)
  2887. {
  2888. int idx = aux_pcm_get_port_idx(kcontrol);
  2889. if (idx < 0)
  2890. return idx;
  2891. aux_pcm_tx_cfg[idx].bit_format =
  2892. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2893. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2894. idx, aux_pcm_tx_cfg[idx].bit_format,
  2895. ucontrol->value.enumerated.item[0]);
  2896. return 0;
  2897. }
  2898. static int spdif_get_port_idx(struct snd_kcontrol *kcontrol)
  2899. {
  2900. int idx;
  2901. if (strnstr(kcontrol->id.name, "PRIM_SPDIF_RX",
  2902. sizeof("PRIM_SPDIF_RX")))
  2903. idx = PRIM_SPDIF_RX;
  2904. else if (strnstr(kcontrol->id.name, "SEC_SPDIF_RX",
  2905. sizeof("SEC_SPDIF_RX")))
  2906. idx = SEC_SPDIF_RX;
  2907. else if (strnstr(kcontrol->id.name, "PRIM_SPDIF_TX",
  2908. sizeof("PRIM_SPDIF_TX")))
  2909. idx = PRIM_SPDIF_TX;
  2910. else if (strnstr(kcontrol->id.name, "SEC_SPDIF_TX",
  2911. sizeof("SEC_SPDIF_TX")))
  2912. idx = SEC_SPDIF_TX;
  2913. else {
  2914. pr_err("%s: unsupported channel: %s",
  2915. __func__, kcontrol->id.name);
  2916. idx = -EINVAL;
  2917. }
  2918. return idx;
  2919. }
  2920. static int spdif_get_sample_rate_val(int sample_rate)
  2921. {
  2922. int sample_rate_val;
  2923. switch (sample_rate) {
  2924. case SAMPLING_RATE_32KHZ:
  2925. sample_rate_val = 0;
  2926. break;
  2927. case SAMPLING_RATE_44P1KHZ:
  2928. sample_rate_val = 1;
  2929. break;
  2930. case SAMPLING_RATE_48KHZ:
  2931. sample_rate_val = 2;
  2932. break;
  2933. case SAMPLING_RATE_88P2KHZ:
  2934. sample_rate_val = 3;
  2935. break;
  2936. case SAMPLING_RATE_96KHZ:
  2937. sample_rate_val = 4;
  2938. break;
  2939. case SAMPLING_RATE_176P4KHZ:
  2940. sample_rate_val = 5;
  2941. break;
  2942. case SAMPLING_RATE_192KHZ:
  2943. sample_rate_val = 6;
  2944. break;
  2945. default:
  2946. sample_rate_val = 2;
  2947. break;
  2948. }
  2949. return sample_rate_val;
  2950. }
  2951. static int spdif_get_sample_rate(int value)
  2952. {
  2953. int sample_rate;
  2954. switch (value) {
  2955. case 0:
  2956. sample_rate = SAMPLING_RATE_32KHZ;
  2957. break;
  2958. case 1:
  2959. sample_rate = SAMPLING_RATE_44P1KHZ;
  2960. break;
  2961. case 2:
  2962. sample_rate = SAMPLING_RATE_48KHZ;
  2963. break;
  2964. case 3:
  2965. sample_rate = SAMPLING_RATE_88P2KHZ;
  2966. break;
  2967. case 4:
  2968. sample_rate = SAMPLING_RATE_96KHZ;
  2969. break;
  2970. case 5:
  2971. sample_rate = SAMPLING_RATE_176P4KHZ;
  2972. break;
  2973. case 6:
  2974. sample_rate = SAMPLING_RATE_192KHZ;
  2975. break;
  2976. default:
  2977. sample_rate = SAMPLING_RATE_48KHZ;
  2978. break;
  2979. }
  2980. return sample_rate;
  2981. }
  2982. static int spdif_get_format(int value)
  2983. {
  2984. int format;
  2985. switch (value) {
  2986. case 0:
  2987. format = SNDRV_PCM_FORMAT_S16_LE;
  2988. break;
  2989. case 1:
  2990. format = SNDRV_PCM_FORMAT_S24_LE;
  2991. break;
  2992. default:
  2993. format = SNDRV_PCM_FORMAT_S16_LE;
  2994. break;
  2995. }
  2996. return format;
  2997. }
  2998. static int spdif_get_format_value(int format)
  2999. {
  3000. int value;
  3001. switch (format) {
  3002. case SNDRV_PCM_FORMAT_S16_LE:
  3003. value = 0;
  3004. break;
  3005. case SNDRV_PCM_FORMAT_S24_LE:
  3006. value = 1;
  3007. break;
  3008. default:
  3009. value = 0;
  3010. break;
  3011. }
  3012. return value;
  3013. }
  3014. static int msm_spdif_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  3015. struct snd_ctl_elem_value *ucontrol)
  3016. {
  3017. int idx = spdif_get_port_idx(kcontrol);
  3018. if (idx < 0)
  3019. return idx;
  3020. spdif_rx_cfg[idx].sample_rate =
  3021. spdif_get_sample_rate(ucontrol->value.enumerated.item[0]);
  3022. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  3023. idx, spdif_rx_cfg[idx].sample_rate,
  3024. ucontrol->value.enumerated.item[0]);
  3025. return 0;
  3026. }
  3027. static int msm_spdif_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  3028. struct snd_ctl_elem_value *ucontrol)
  3029. {
  3030. int idx = spdif_get_port_idx(kcontrol);
  3031. if (idx < 0)
  3032. return idx;
  3033. ucontrol->value.enumerated.item[0] =
  3034. spdif_get_sample_rate_val(spdif_rx_cfg[idx].sample_rate);
  3035. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  3036. idx, spdif_rx_cfg[idx].sample_rate,
  3037. ucontrol->value.enumerated.item[0]);
  3038. return 0;
  3039. }
  3040. static int msm_spdif_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  3041. struct snd_ctl_elem_value *ucontrol)
  3042. {
  3043. int idx = spdif_get_port_idx(kcontrol);
  3044. if (idx < 0)
  3045. return idx;
  3046. spdif_tx_cfg[idx].sample_rate =
  3047. spdif_get_sample_rate(ucontrol->value.enumerated.item[0]);
  3048. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  3049. idx, spdif_tx_cfg[idx].sample_rate,
  3050. ucontrol->value.enumerated.item[0]);
  3051. return 0;
  3052. }
  3053. static int msm_spdif_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  3054. struct snd_ctl_elem_value *ucontrol)
  3055. {
  3056. int idx = spdif_get_port_idx(kcontrol);
  3057. if (idx < 0)
  3058. return idx;
  3059. ucontrol->value.enumerated.item[0] =
  3060. spdif_get_sample_rate_val(spdif_tx_cfg[idx].sample_rate);
  3061. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  3062. idx, spdif_tx_cfg[idx].sample_rate,
  3063. ucontrol->value.enumerated.item[0]);
  3064. return 0;
  3065. }
  3066. static int msm_spdif_rx_ch_get(struct snd_kcontrol *kcontrol,
  3067. struct snd_ctl_elem_value *ucontrol)
  3068. {
  3069. int idx = spdif_get_port_idx(kcontrol);
  3070. if (idx < 0)
  3071. return idx;
  3072. pr_debug("%s: msm_spdif_[%d]_rx_ch = %d\n", __func__,
  3073. idx, spdif_rx_cfg[idx].channels);
  3074. ucontrol->value.enumerated.item[0] = spdif_rx_cfg[idx].channels - 1;
  3075. return 0;
  3076. }
  3077. static int msm_spdif_rx_ch_put(struct snd_kcontrol *kcontrol,
  3078. struct snd_ctl_elem_value *ucontrol)
  3079. {
  3080. int idx = spdif_get_port_idx(kcontrol);
  3081. if (idx < 0)
  3082. return idx;
  3083. spdif_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  3084. pr_debug("%s: msm_spdif_[%d]_rx_ch = %d\n", __func__,
  3085. idx, spdif_rx_cfg[idx].channels);
  3086. return 1;
  3087. }
  3088. static int msm_spdif_tx_ch_get(struct snd_kcontrol *kcontrol,
  3089. struct snd_ctl_elem_value *ucontrol)
  3090. {
  3091. int idx = spdif_get_port_idx(kcontrol);
  3092. if (idx < 0)
  3093. return idx;
  3094. pr_debug("%s: msm_spdif_[%d]_tx_ch = %d\n", __func__,
  3095. idx, spdif_tx_cfg[idx].channels);
  3096. ucontrol->value.enumerated.item[0] = spdif_tx_cfg[idx].channels - 1;
  3097. return 0;
  3098. }
  3099. static int msm_spdif_tx_ch_put(struct snd_kcontrol *kcontrol,
  3100. struct snd_ctl_elem_value *ucontrol)
  3101. {
  3102. int idx = spdif_get_port_idx(kcontrol);
  3103. if (idx < 0)
  3104. return idx;
  3105. spdif_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  3106. pr_debug("%s: msm_spdif_[%d]_tx_ch = %d\n", __func__,
  3107. idx, spdif_tx_cfg[idx].channels);
  3108. return 1;
  3109. }
  3110. static int msm_spdif_rx_format_get(struct snd_kcontrol *kcontrol,
  3111. struct snd_ctl_elem_value *ucontrol)
  3112. {
  3113. int idx = spdif_get_port_idx(kcontrol);
  3114. if (idx < 0)
  3115. return idx;
  3116. ucontrol->value.enumerated.item[0] =
  3117. spdif_get_format_value(spdif_rx_cfg[idx].bit_format);
  3118. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  3119. idx, spdif_rx_cfg[idx].bit_format,
  3120. ucontrol->value.enumerated.item[0]);
  3121. return 0;
  3122. }
  3123. static int msm_spdif_rx_format_put(struct snd_kcontrol *kcontrol,
  3124. struct snd_ctl_elem_value *ucontrol)
  3125. {
  3126. int idx = spdif_get_port_idx(kcontrol);
  3127. if (idx < 0)
  3128. return idx;
  3129. spdif_rx_cfg[idx].bit_format =
  3130. spdif_get_format(ucontrol->value.enumerated.item[0]);
  3131. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  3132. idx, spdif_rx_cfg[idx].bit_format,
  3133. ucontrol->value.enumerated.item[0]);
  3134. return 0;
  3135. }
  3136. static int msm_spdif_tx_format_get(struct snd_kcontrol *kcontrol,
  3137. struct snd_ctl_elem_value *ucontrol)
  3138. {
  3139. int idx = spdif_get_port_idx(kcontrol);
  3140. if (idx < 0)
  3141. return idx;
  3142. ucontrol->value.enumerated.item[0] =
  3143. spdif_get_format_value(spdif_tx_cfg[idx].bit_format);
  3144. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  3145. idx, spdif_tx_cfg[idx].bit_format,
  3146. ucontrol->value.enumerated.item[0]);
  3147. return 0;
  3148. }
  3149. static int msm_spdif_tx_format_put(struct snd_kcontrol *kcontrol,
  3150. struct snd_ctl_elem_value *ucontrol)
  3151. {
  3152. int idx = spdif_get_port_idx(kcontrol);
  3153. if (idx < 0)
  3154. return idx;
  3155. spdif_tx_cfg[idx].bit_format =
  3156. spdif_get_format(ucontrol->value.enumerated.item[0]);
  3157. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  3158. idx, spdif_tx_cfg[idx].bit_format,
  3159. ucontrol->value.enumerated.item[0]);
  3160. return 0;
  3161. }
  3162. static int afe_lb_tx_ch_get(struct snd_kcontrol *kcontrol,
  3163. struct snd_ctl_elem_value *ucontrol)
  3164. {
  3165. pr_debug("%s: afe_lb_tx_ch = %d\n", __func__,
  3166. afe_lb_tx_cfg.channels);
  3167. ucontrol->value.integer.value[0] = afe_lb_tx_cfg.channels - 1;
  3168. return 0;
  3169. }
  3170. static int afe_lb_tx_ch_put(struct snd_kcontrol *kcontrol,
  3171. struct snd_ctl_elem_value *ucontrol)
  3172. {
  3173. afe_lb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  3174. pr_debug("%s: afe_lb_tx_ch = %d\n", __func__, afe_lb_tx_cfg.channels);
  3175. return 0;
  3176. }
  3177. static int afe_lb_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  3178. struct snd_ctl_elem_value *ucontrol)
  3179. {
  3180. int sample_rate_val;
  3181. switch (afe_lb_tx_cfg.sample_rate) {
  3182. case SAMPLING_RATE_384KHZ:
  3183. sample_rate_val = 12;
  3184. break;
  3185. case SAMPLING_RATE_352P8KHZ:
  3186. sample_rate_val = 11;
  3187. break;
  3188. case SAMPLING_RATE_192KHZ:
  3189. sample_rate_val = 10;
  3190. break;
  3191. case SAMPLING_RATE_176P4KHZ:
  3192. sample_rate_val = 9;
  3193. break;
  3194. case SAMPLING_RATE_96KHZ:
  3195. sample_rate_val = 8;
  3196. break;
  3197. case SAMPLING_RATE_88P2KHZ:
  3198. sample_rate_val = 7;
  3199. break;
  3200. case SAMPLING_RATE_48KHZ:
  3201. sample_rate_val = 6;
  3202. break;
  3203. case SAMPLING_RATE_44P1KHZ:
  3204. sample_rate_val = 5;
  3205. break;
  3206. case SAMPLING_RATE_32KHZ:
  3207. sample_rate_val = 4;
  3208. break;
  3209. case SAMPLING_RATE_22P05KHZ:
  3210. sample_rate_val = 3;
  3211. break;
  3212. case SAMPLING_RATE_16KHZ:
  3213. sample_rate_val = 2;
  3214. break;
  3215. case SAMPLING_RATE_11P025KHZ:
  3216. sample_rate_val = 1;
  3217. break;
  3218. case SAMPLING_RATE_8KHZ:
  3219. sample_rate_val = 0;
  3220. break;
  3221. default:
  3222. sample_rate_val = 6;
  3223. break;
  3224. }
  3225. ucontrol->value.integer.value[0] = sample_rate_val;
  3226. pr_debug("%s: afe_lb_tx_sample_rate = %d\n", __func__,
  3227. afe_lb_tx_cfg.sample_rate);
  3228. return 0;
  3229. }
  3230. static int afe_lb_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  3231. struct snd_ctl_elem_value *ucontrol)
  3232. {
  3233. switch (ucontrol->value.integer.value[0]) {
  3234. case 12:
  3235. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  3236. break;
  3237. case 11:
  3238. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  3239. break;
  3240. case 10:
  3241. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  3242. break;
  3243. case 9:
  3244. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  3245. break;
  3246. case 8:
  3247. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  3248. break;
  3249. case 7:
  3250. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  3251. break;
  3252. case 6:
  3253. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  3254. break;
  3255. case 5:
  3256. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  3257. break;
  3258. case 4:
  3259. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  3260. break;
  3261. case 3:
  3262. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  3263. break;
  3264. case 2:
  3265. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  3266. break;
  3267. case 1:
  3268. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  3269. break;
  3270. case 0:
  3271. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  3272. break;
  3273. default:
  3274. afe_lb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  3275. break;
  3276. }
  3277. pr_debug("%s: control value = %ld, afe_lb_tx_sample_rate = %d\n",
  3278. __func__, ucontrol->value.integer.value[0],
  3279. afe_lb_tx_cfg.sample_rate);
  3280. return 0;
  3281. }
  3282. static int afe_lb_tx_format_get(struct snd_kcontrol *kcontrol,
  3283. struct snd_ctl_elem_value *ucontrol)
  3284. {
  3285. switch (afe_lb_tx_cfg.bit_format) {
  3286. case SNDRV_PCM_FORMAT_S32_LE:
  3287. ucontrol->value.integer.value[0] = 3;
  3288. break;
  3289. case SNDRV_PCM_FORMAT_S24_3LE:
  3290. ucontrol->value.integer.value[0] = 2;
  3291. break;
  3292. case SNDRV_PCM_FORMAT_S24_LE:
  3293. ucontrol->value.integer.value[0] = 1;
  3294. break;
  3295. case SNDRV_PCM_FORMAT_S16_LE:
  3296. default:
  3297. ucontrol->value.integer.value[0] = 0;
  3298. break;
  3299. }
  3300. pr_debug("%s: afe_lb_tx_format = %d, ucontrol value = %ld\n",
  3301. __func__, afe_lb_tx_cfg.bit_format,
  3302. ucontrol->value.integer.value[0]);
  3303. return 0;
  3304. }
  3305. static int afe_lb_tx_format_put(struct snd_kcontrol *kcontrol,
  3306. struct snd_ctl_elem_value *ucontrol)
  3307. {
  3308. switch (ucontrol->value.integer.value[0]) {
  3309. case 3:
  3310. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  3311. break;
  3312. case 2:
  3313. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  3314. break;
  3315. case 1:
  3316. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  3317. break;
  3318. case 0:
  3319. default:
  3320. afe_lb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  3321. break;
  3322. }
  3323. pr_debug("%s: afe_lb_tx_format = %d, ucontrol value = %ld\n",
  3324. __func__, afe_lb_tx_cfg.bit_format,
  3325. ucontrol->value.integer.value[0]);
  3326. return 0;
  3327. }
  3328. static const struct snd_kcontrol_new msm_snd_sb_controls[] = {
  3329. SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
  3330. slim_rx_ch_get, slim_rx_ch_put),
  3331. SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
  3332. slim_rx_ch_get, slim_rx_ch_put),
  3333. SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
  3334. slim_tx_ch_get, slim_tx_ch_put),
  3335. SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
  3336. slim_tx_ch_get, slim_tx_ch_put),
  3337. SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
  3338. slim_rx_ch_get, slim_rx_ch_put),
  3339. SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
  3340. slim_rx_ch_get, slim_rx_ch_put),
  3341. SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
  3342. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3343. SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
  3344. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3345. SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
  3346. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3347. SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
  3348. slim_tx_bit_format_get, slim_tx_bit_format_put),
  3349. SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
  3350. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3351. SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
  3352. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3353. SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
  3354. slim_tx_sample_rate_get, slim_tx_sample_rate_put),
  3355. SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
  3356. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3357. SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
  3358. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3359. };
  3360. static const struct snd_kcontrol_new msm_snd_va_controls[] = {
  3361. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  3362. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3363. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  3364. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3365. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  3366. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3367. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  3368. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3369. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3370. va_cdc_dma_tx_0_sample_rate,
  3371. cdc_dma_tx_sample_rate_get,
  3372. cdc_dma_tx_sample_rate_put),
  3373. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3374. va_cdc_dma_tx_1_sample_rate,
  3375. cdc_dma_tx_sample_rate_get,
  3376. cdc_dma_tx_sample_rate_put),
  3377. };
  3378. static const struct snd_kcontrol_new msm_snd_wsa_controls[] = {
  3379. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3380. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3381. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3382. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3383. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3384. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3385. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3386. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3387. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3388. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3389. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3390. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3391. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3392. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3393. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3394. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3395. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3396. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3397. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3398. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3399. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3400. wsa_cdc_dma_rx_0_sample_rate,
  3401. cdc_dma_rx_sample_rate_get,
  3402. cdc_dma_rx_sample_rate_put),
  3403. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3404. wsa_cdc_dma_rx_1_sample_rate,
  3405. cdc_dma_rx_sample_rate_get,
  3406. cdc_dma_rx_sample_rate_put),
  3407. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3408. wsa_cdc_dma_tx_0_sample_rate,
  3409. cdc_dma_tx_sample_rate_get,
  3410. cdc_dma_tx_sample_rate_put),
  3411. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3412. wsa_cdc_dma_tx_1_sample_rate,
  3413. cdc_dma_tx_sample_rate_get,
  3414. cdc_dma_tx_sample_rate_put),
  3415. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3416. wsa_cdc_dma_tx_2_sample_rate,
  3417. cdc_dma_tx_sample_rate_get,
  3418. cdc_dma_tx_sample_rate_put),
  3419. };
  3420. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3421. SOC_ENUM_EXT("BT_TX SampleRate", bt_sample_rate_sink,
  3422. msm_bt_sample_rate_sink_get,
  3423. msm_bt_sample_rate_sink_put),
  3424. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3425. msm_bt_sample_rate_get,
  3426. msm_bt_sample_rate_put),
  3427. SOC_ENUM_EXT("BT_RX SampleRate", bt_sample_rate,
  3428. msm_bt_sample_rate_get,
  3429. msm_bt_sample_rate_put),
  3430. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3431. proxy_rx_ch_get, proxy_rx_ch_put),
  3432. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3433. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3434. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3435. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3436. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3437. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3438. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3439. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3440. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3441. usb_audio_rx_sample_rate_get,
  3442. usb_audio_rx_sample_rate_put),
  3443. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3444. usb_audio_tx_sample_rate_get,
  3445. usb_audio_tx_sample_rate_put),
  3446. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3447. tdm_rx_sample_rate_get,
  3448. tdm_rx_sample_rate_put),
  3449. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3450. tdm_tx_sample_rate_get,
  3451. tdm_tx_sample_rate_put),
  3452. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3453. tdm_rx_format_get,
  3454. tdm_rx_format_put),
  3455. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3456. tdm_tx_format_get,
  3457. tdm_tx_format_put),
  3458. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3459. tdm_rx_ch_get,
  3460. tdm_rx_ch_put),
  3461. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3462. tdm_tx_ch_get,
  3463. tdm_tx_ch_put),
  3464. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3465. tdm_rx_sample_rate_get,
  3466. tdm_rx_sample_rate_put),
  3467. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3468. tdm_tx_sample_rate_get,
  3469. tdm_tx_sample_rate_put),
  3470. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3471. tdm_rx_format_get,
  3472. tdm_rx_format_put),
  3473. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3474. tdm_tx_format_get,
  3475. tdm_tx_format_put),
  3476. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3477. tdm_rx_ch_get,
  3478. tdm_rx_ch_put),
  3479. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3480. tdm_tx_ch_get,
  3481. tdm_tx_ch_put),
  3482. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3483. tdm_rx_sample_rate_get,
  3484. tdm_rx_sample_rate_put),
  3485. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3486. tdm_tx_sample_rate_get,
  3487. tdm_tx_sample_rate_put),
  3488. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3489. tdm_rx_format_get,
  3490. tdm_rx_format_put),
  3491. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3492. tdm_tx_format_get,
  3493. tdm_tx_format_put),
  3494. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3495. tdm_rx_ch_get,
  3496. tdm_rx_ch_put),
  3497. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3498. tdm_tx_ch_get,
  3499. tdm_tx_ch_put),
  3500. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3501. tdm_rx_sample_rate_get,
  3502. tdm_rx_sample_rate_put),
  3503. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3504. tdm_tx_sample_rate_get,
  3505. tdm_tx_sample_rate_put),
  3506. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3507. tdm_rx_format_get,
  3508. tdm_rx_format_put),
  3509. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3510. tdm_tx_format_get,
  3511. tdm_tx_format_put),
  3512. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3513. tdm_rx_ch_get,
  3514. tdm_rx_ch_put),
  3515. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3516. tdm_tx_ch_get,
  3517. tdm_tx_ch_put),
  3518. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3519. tdm_rx_sample_rate_get,
  3520. tdm_rx_sample_rate_put),
  3521. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3522. tdm_tx_sample_rate_get,
  3523. tdm_tx_sample_rate_put),
  3524. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3525. tdm_rx_format_get,
  3526. tdm_rx_format_put),
  3527. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3528. tdm_tx_format_get,
  3529. tdm_tx_format_put),
  3530. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3531. tdm_rx_ch_get,
  3532. tdm_rx_ch_put),
  3533. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3534. tdm_tx_ch_get,
  3535. tdm_tx_ch_put),
  3536. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3537. aux_pcm_rx_sample_rate_get,
  3538. aux_pcm_rx_sample_rate_put),
  3539. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3540. aux_pcm_rx_sample_rate_get,
  3541. aux_pcm_rx_sample_rate_put),
  3542. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3543. aux_pcm_rx_sample_rate_get,
  3544. aux_pcm_rx_sample_rate_put),
  3545. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3546. aux_pcm_rx_sample_rate_get,
  3547. aux_pcm_rx_sample_rate_put),
  3548. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3549. aux_pcm_rx_sample_rate_get,
  3550. aux_pcm_rx_sample_rate_put),
  3551. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3552. aux_pcm_tx_sample_rate_get,
  3553. aux_pcm_tx_sample_rate_put),
  3554. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3555. aux_pcm_tx_sample_rate_get,
  3556. aux_pcm_tx_sample_rate_put),
  3557. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3558. aux_pcm_tx_sample_rate_get,
  3559. aux_pcm_tx_sample_rate_put),
  3560. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3561. aux_pcm_tx_sample_rate_get,
  3562. aux_pcm_tx_sample_rate_put),
  3563. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3564. aux_pcm_tx_sample_rate_get,
  3565. aux_pcm_tx_sample_rate_put),
  3566. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3567. aux_pcm_tx_sample_rate_get,
  3568. aux_pcm_tx_sample_rate_put),
  3569. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3570. mi2s_rx_sample_rate_get,
  3571. mi2s_rx_sample_rate_put),
  3572. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3573. mi2s_rx_sample_rate_get,
  3574. mi2s_rx_sample_rate_put),
  3575. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3576. mi2s_rx_sample_rate_get,
  3577. mi2s_rx_sample_rate_put),
  3578. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3579. mi2s_rx_sample_rate_get,
  3580. mi2s_rx_sample_rate_put),
  3581. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3582. mi2s_rx_sample_rate_get,
  3583. mi2s_rx_sample_rate_put),
  3584. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3585. mi2s_rx_sample_rate_get,
  3586. mi2s_rx_sample_rate_put),
  3587. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3588. mi2s_tx_sample_rate_get,
  3589. mi2s_tx_sample_rate_put),
  3590. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3591. mi2s_tx_sample_rate_get,
  3592. mi2s_tx_sample_rate_put),
  3593. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3594. mi2s_tx_sample_rate_get,
  3595. mi2s_tx_sample_rate_put),
  3596. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3597. mi2s_tx_sample_rate_get,
  3598. mi2s_tx_sample_rate_put),
  3599. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3600. mi2s_tx_sample_rate_get,
  3601. mi2s_tx_sample_rate_put),
  3602. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3603. mi2s_tx_sample_rate_get,
  3604. mi2s_tx_sample_rate_put),
  3605. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3606. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3607. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3608. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3609. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3610. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3611. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3612. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3613. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3614. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3615. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3616. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3617. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3618. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3619. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3620. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3621. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3622. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3623. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3624. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3625. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3626. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3627. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3628. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3629. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3630. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3631. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3632. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3633. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3634. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3635. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3636. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3637. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3638. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3639. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3640. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3641. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3642. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3643. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3644. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3645. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3646. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3647. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3648. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3649. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3650. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3651. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3652. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3653. SOC_ENUM_EXT("PRIM_META_MI2S_RX SampleRate",
  3654. prim_meta_mi2s_rx_sample_rate,
  3655. msm_meta_mi2s_rx_sample_rate_get,
  3656. msm_meta_mi2s_rx_sample_rate_put),
  3657. SOC_ENUM_EXT("SEC_META_MI2S_RX SampleRate",
  3658. sec_meta_mi2s_rx_sample_rate,
  3659. msm_meta_mi2s_rx_sample_rate_get,
  3660. msm_meta_mi2s_rx_sample_rate_put),
  3661. SOC_ENUM_EXT("PRIM_META_MI2S_RX Channels", prim_meta_mi2s_rx_chs,
  3662. msm_meta_mi2s_rx_ch_get,
  3663. msm_meta_mi2s_rx_ch_put),
  3664. SOC_ENUM_EXT("SEC_META_MI2S_RX Channels", sec_meta_mi2s_rx_chs,
  3665. msm_meta_mi2s_rx_ch_get,
  3666. msm_meta_mi2s_rx_ch_put),
  3667. SOC_ENUM_EXT("PRIM_META_MI2S_RX Format", mi2s_rx_format,
  3668. msm_meta_mi2s_rx_format_get,
  3669. msm_meta_mi2s_rx_format_put),
  3670. SOC_ENUM_EXT("SEC_META_MI2S_RX Format", mi2s_rx_format,
  3671. msm_meta_mi2s_rx_format_get,
  3672. msm_meta_mi2s_rx_format_put),
  3673. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3674. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3675. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3676. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3677. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3678. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3679. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3680. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3681. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3682. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3683. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3684. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3685. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3686. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3687. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3688. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3689. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3690. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3691. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3692. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3693. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3694. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3695. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3696. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3697. SOC_SINGLE_MULTI_EXT("VAD CFG", SND_SOC_NOPM, 0, 1000, 0, 3, NULL,
  3698. msm_snd_vad_cfg_put),
  3699. SOC_ENUM_EXT("PRIM_SPDIF_RX SampleRate", spdif_rx_sample_rate,
  3700. msm_spdif_rx_sample_rate_get,
  3701. msm_spdif_rx_sample_rate_put),
  3702. SOC_ENUM_EXT("PRIM_SPDIF_TX SampleRate", spdif_tx_sample_rate,
  3703. msm_spdif_tx_sample_rate_get,
  3704. msm_spdif_tx_sample_rate_put),
  3705. SOC_ENUM_EXT("SEC_SPDIF_RX SampleRate", spdif_rx_sample_rate,
  3706. msm_spdif_rx_sample_rate_get,
  3707. msm_spdif_rx_sample_rate_put),
  3708. SOC_ENUM_EXT("SEC_SPDIF_TX SampleRate", spdif_tx_sample_rate,
  3709. msm_spdif_tx_sample_rate_get,
  3710. msm_spdif_tx_sample_rate_put),
  3711. SOC_ENUM_EXT("PRIM_SPDIF_RX Channels", spdif_rx_chs,
  3712. msm_spdif_rx_ch_get, msm_spdif_rx_ch_put),
  3713. SOC_ENUM_EXT("PRIM_SPDIF_TX Channels", spdif_tx_chs,
  3714. msm_spdif_tx_ch_get, msm_spdif_tx_ch_put),
  3715. SOC_ENUM_EXT("SEC_SPDIF_RX Channels", spdif_rx_chs,
  3716. msm_spdif_rx_ch_get, msm_spdif_rx_ch_put),
  3717. SOC_ENUM_EXT("SEC_SPDIF_TX Channels", spdif_tx_chs,
  3718. msm_spdif_tx_ch_get, msm_spdif_tx_ch_put),
  3719. SOC_ENUM_EXT("PRIM_SPDIF_RX Format", spdif_rx_format,
  3720. msm_spdif_rx_format_get, msm_spdif_rx_format_put),
  3721. SOC_ENUM_EXT("PRIM_SPDIF_TX Format", spdif_tx_format,
  3722. msm_spdif_tx_format_get, msm_spdif_tx_format_put),
  3723. SOC_ENUM_EXT("SEC_SPDIF_RX Format", spdif_rx_format,
  3724. msm_spdif_rx_format_get, msm_spdif_rx_format_put),
  3725. SOC_ENUM_EXT("SEC_SPDIF_TX Format", spdif_tx_format,
  3726. msm_spdif_tx_format_get, msm_spdif_tx_format_put),
  3727. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_lb_tx_chs,
  3728. afe_lb_tx_ch_get, afe_lb_tx_ch_put),
  3729. SOC_ENUM_EXT("AFE_LOOPBACK_TX Format", afe_lb_tx_format,
  3730. afe_lb_tx_format_get, afe_lb_tx_format_put),
  3731. SOC_ENUM_EXT("AFE_LOOPBACK_TX SampleRate", afe_lb_tx_sample_rate,
  3732. afe_lb_tx_sample_rate_get,
  3733. afe_lb_tx_sample_rate_put),
  3734. };
  3735. static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component,
  3736. int enable, bool dapm)
  3737. {
  3738. int ret = 0;
  3739. if (!strcmp(component.name, "tasha_codec")) {
  3740. ret = tasha_cdc_mclk_enable(component, enable, dapm);
  3741. } else {
  3742. dev_err(component->dev, "%s: unknown codec to enable ext clk\n",
  3743. __func__);
  3744. ret = -EINVAL;
  3745. }
  3746. return ret;
  3747. }
  3748. static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_component *component,
  3749. int enable, bool dapm)
  3750. {
  3751. int ret = 0;
  3752. if (!strcmp(component.name, "tasha_codec")) {
  3753. ret = tasha_cdc_mclk_tx_enable(component, enable, dapm);
  3754. } else {
  3755. dev_err(component->dev, "%s: unknown codec to enable TX ext clk\n",
  3756. __func__);
  3757. ret = -EINVAL;
  3758. }
  3759. return ret;
  3760. }
  3761. static int msm_mclk_tx_event(struct snd_soc_dapm_widget *w,
  3762. struct snd_kcontrol *kcontrol, int event)
  3763. {
  3764. struct snd_soc_component *component =
  3765. snd_soc_dapm_to_component(w->dapm);
  3766. pr_debug("%s: event = %d\n", __func__, event);
  3767. switch (event) {
  3768. case SND_SOC_DAPM_PRE_PMU:
  3769. return msm_snd_enable_codec_ext_tx_clk(component, 1, true);
  3770. case SND_SOC_DAPM_POST_PMD:
  3771. return msm_snd_enable_codec_ext_tx_clk(component, 0, true);
  3772. }
  3773. return 0;
  3774. }
  3775. static int msm_mclk_event(struct snd_soc_dapm_widget *w,
  3776. struct snd_kcontrol *kcontrol, int event)
  3777. {
  3778. struct snd_soc_component *component =
  3779. snd_soc_dapm_to_component(w->dapm);
  3780. pr_debug("%s: event = %d\n", __func__, event);
  3781. switch (event) {
  3782. case SND_SOC_DAPM_PRE_PMU:
  3783. return msm_snd_enable_codec_ext_clk(component, 1, true);
  3784. case SND_SOC_DAPM_POST_PMD:
  3785. return msm_snd_enable_codec_ext_clk(component, 0, true);
  3786. }
  3787. return 0;
  3788. }
  3789. static int msm_lineout_booster_ctrl_event(struct snd_soc_dapm_widget *w,
  3790. struct snd_kcontrol *k, int event)
  3791. {
  3792. struct snd_soc_component *component =
  3793. snd_soc_dapm_to_component(w->dapm);
  3794. struct snd_soc_card *card = component->card;
  3795. struct msm_asoc_mach_data *pdata =
  3796. snd_soc_card_get_drvdata(card);
  3797. pr_debug("%s: event = %d\n", __func__, event);
  3798. switch (event) {
  3799. case SND_SOC_DAPM_POST_PMU:
  3800. msm_cdc_pinctrl_select_active_state(
  3801. pdata->lineout_booster_gpio_p);
  3802. break;
  3803. case SND_SOC_DAPM_PRE_PMD:
  3804. msm_cdc_pinctrl_select_sleep_state(
  3805. pdata->lineout_booster_gpio_p);
  3806. break;
  3807. }
  3808. return 0;
  3809. }
  3810. static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
  3811. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  3812. msm_mclk_event,
  3813. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  3814. SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
  3815. msm_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  3816. SND_SOC_DAPM_SPK("lineout booster", msm_lineout_booster_ctrl_event),
  3817. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3818. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3819. };
  3820. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3821. struct snd_kcontrol *kcontrol, int event)
  3822. {
  3823. struct msm_asoc_mach_data *pdata = NULL;
  3824. struct snd_soc_component *component =
  3825. snd_soc_dapm_to_component(w->dapm);
  3826. int ret = 0;
  3827. uint32_t dmic_idx;
  3828. int *dmic_gpio_cnt;
  3829. struct device_node *dmic_gpio;
  3830. char *wname;
  3831. wname = strpbrk(w->name, "01234567");
  3832. if (!wname) {
  3833. dev_err(component->dev, "%s: widget not found\n", __func__);
  3834. return -EINVAL;
  3835. }
  3836. ret = kstrtouint(wname, 10, &dmic_idx);
  3837. if (ret < 0) {
  3838. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3839. __func__);
  3840. return -EINVAL;
  3841. }
  3842. pdata = snd_soc_card_get_drvdata(component->card);
  3843. switch (dmic_idx) {
  3844. case 0:
  3845. case 1:
  3846. dmic_gpio_cnt = &pdata->dmic_01_gpio_cnt;
  3847. dmic_gpio = pdata->dmic_01_gpio_p;
  3848. break;
  3849. case 2:
  3850. case 3:
  3851. dmic_gpio_cnt = &pdata->dmic_23_gpio_cnt;
  3852. dmic_gpio = pdata->dmic_23_gpio_p;
  3853. break;
  3854. case 4:
  3855. case 5:
  3856. dmic_gpio_cnt = &pdata->dmic_45_gpio_cnt;
  3857. dmic_gpio = pdata->dmic_45_gpio_p;
  3858. break;
  3859. case 6:
  3860. case 7:
  3861. dmic_gpio_cnt = &pdata->dmic_67_gpio_cnt;
  3862. dmic_gpio = pdata->dmic_67_gpio_p;
  3863. break;
  3864. default:
  3865. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3866. __func__);
  3867. return -EINVAL;
  3868. }
  3869. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3870. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3871. switch (event) {
  3872. case SND_SOC_DAPM_PRE_PMU:
  3873. (*dmic_gpio_cnt)++;
  3874. if (*dmic_gpio_cnt == 1) {
  3875. ret = msm_cdc_pinctrl_select_active_state(
  3876. dmic_gpio);
  3877. if (ret < 0) {
  3878. dev_err(component->dev, "%s: gpio set cannot be activated %sd\n",
  3879. __func__, "dmic_gpio");
  3880. return ret;
  3881. }
  3882. }
  3883. break;
  3884. case SND_SOC_DAPM_POST_PMD:
  3885. (*dmic_gpio_cnt)--;
  3886. if (*dmic_gpio_cnt == 0) {
  3887. ret = msm_cdc_pinctrl_select_sleep_state(
  3888. dmic_gpio);
  3889. if (ret < 0) {
  3890. dev_err(component->dev, "%s: gpio set cannot be de-activated %sd\n",
  3891. __func__, "dmic_gpio");
  3892. return ret;
  3893. }
  3894. }
  3895. break;
  3896. default:
  3897. dev_err(component->dev, "%s: invalid DAPM event %d\n",
  3898. __func__, event);
  3899. return -EINVAL;
  3900. }
  3901. return 0;
  3902. }
  3903. static const struct snd_soc_dapm_widget msm_va_dapm_widgets[] = {
  3904. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3905. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3906. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3907. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3908. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  3909. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  3910. SND_SOC_DAPM_MIC("Digital Mic6", msm_dmic_event),
  3911. SND_SOC_DAPM_MIC("Digital Mic7", msm_dmic_event),
  3912. };
  3913. static const struct snd_soc_dapm_widget msm_wsa_dapm_widgets[] = {
  3914. };
  3915. static inline int param_is_mask(int p)
  3916. {
  3917. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  3918. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  3919. }
  3920. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  3921. int n)
  3922. {
  3923. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  3924. }
  3925. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  3926. unsigned int bit)
  3927. {
  3928. if (bit >= SNDRV_MASK_MAX)
  3929. return;
  3930. if (param_is_mask(n)) {
  3931. struct snd_mask *m = param_to_mask(p, n);
  3932. m->bits[0] = 0;
  3933. m->bits[1] = 0;
  3934. m->bits[bit >> 5] |= (1 << (bit & 31));
  3935. }
  3936. }
  3937. static int msm_slim_get_ch_from_beid(int32_t be_id)
  3938. {
  3939. int ch_id = 0;
  3940. switch (be_id) {
  3941. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  3942. ch_id = SLIM_RX_0;
  3943. break;
  3944. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  3945. ch_id = SLIM_RX_1;
  3946. break;
  3947. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  3948. ch_id = SLIM_RX_2;
  3949. break;
  3950. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  3951. ch_id = SLIM_RX_3;
  3952. break;
  3953. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  3954. ch_id = SLIM_RX_4;
  3955. break;
  3956. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  3957. ch_id = SLIM_RX_6;
  3958. break;
  3959. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  3960. ch_id = SLIM_TX_0;
  3961. break;
  3962. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  3963. ch_id = SLIM_TX_3;
  3964. break;
  3965. default:
  3966. ch_id = SLIM_RX_0;
  3967. break;
  3968. }
  3969. return ch_id;
  3970. }
  3971. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  3972. {
  3973. int idx = 0;
  3974. switch (be_id) {
  3975. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3976. idx = WSA_CDC_DMA_RX_0;
  3977. break;
  3978. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3979. idx = WSA_CDC_DMA_TX_0;
  3980. break;
  3981. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3982. idx = WSA_CDC_DMA_RX_1;
  3983. break;
  3984. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3985. idx = WSA_CDC_DMA_TX_1;
  3986. break;
  3987. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3988. idx = WSA_CDC_DMA_TX_2;
  3989. break;
  3990. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3991. idx = VA_CDC_DMA_TX_0;
  3992. break;
  3993. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3994. idx = VA_CDC_DMA_TX_1;
  3995. break;
  3996. default:
  3997. idx = VA_CDC_DMA_TX_0;
  3998. break;
  3999. }
  4000. return idx;
  4001. }
  4002. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  4003. struct snd_pcm_hw_params *params)
  4004. {
  4005. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4006. struct snd_interval *rate = hw_param_interval(params,
  4007. SNDRV_PCM_HW_PARAM_RATE);
  4008. struct snd_interval *channels = hw_param_interval(params,
  4009. SNDRV_PCM_HW_PARAM_CHANNELS);
  4010. int rc = 0;
  4011. int idx;
  4012. void *config = NULL;
  4013. struct snd_soc_component *component = NULL;
  4014. pr_debug("%s: format = %d, rate = %d\n",
  4015. __func__, params_format(params), params_rate(params));
  4016. switch (dai_link->id) {
  4017. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  4018. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  4019. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  4020. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  4021. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  4022. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  4023. idx = msm_slim_get_ch_from_beid(dai_link->id);
  4024. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4025. slim_rx_cfg[idx].bit_format);
  4026. rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
  4027. channels->min = channels->max = slim_rx_cfg[idx].channels;
  4028. break;
  4029. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  4030. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  4031. idx = msm_slim_get_ch_from_beid(dai_link->id);
  4032. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4033. slim_tx_cfg[idx].bit_format);
  4034. rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
  4035. channels->min = channels->max = slim_tx_cfg[idx].channels;
  4036. break;
  4037. case MSM_BACKEND_DAI_SLIMBUS_1_TX:
  4038. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4039. slim_tx_cfg[1].bit_format);
  4040. rate->min = rate->max = slim_tx_cfg[1].sample_rate;
  4041. channels->min = channels->max = slim_tx_cfg[1].channels;
  4042. break;
  4043. case MSM_BACKEND_DAI_SLIMBUS_4_TX:
  4044. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4045. SNDRV_PCM_FORMAT_S32_LE);
  4046. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  4047. channels->min = channels->max = msm_vi_feed_tx_ch;
  4048. break;
  4049. case MSM_BACKEND_DAI_SLIMBUS_5_RX:
  4050. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4051. slim_rx_cfg[5].bit_format);
  4052. rate->min = rate->max = slim_rx_cfg[5].sample_rate;
  4053. channels->min = channels->max = slim_rx_cfg[5].channels;
  4054. break;
  4055. case MSM_BACKEND_DAI_SLIMBUS_5_TX:
  4056. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4057. if (!component) {
  4058. pr_err("%s: component is NULL\n", __func__);
  4059. return -EINVAL;
  4060. }
  4061. rate->min = rate->max = SAMPLING_RATE_16KHZ;
  4062. channels->min = channels->max = 1;
  4063. config = msm_codec_fn.get_afe_config_fn(component,
  4064. AFE_SLIMBUS_SLAVE_PORT_CONFIG);
  4065. if (config) {
  4066. rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
  4067. config, SLIMBUS_5_TX);
  4068. if (rc)
  4069. pr_err("%s: Failed to set slimbus slave port config %d\n",
  4070. __func__, rc);
  4071. }
  4072. break;
  4073. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  4074. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4075. slim_rx_cfg[SLIM_RX_7].bit_format);
  4076. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  4077. channels->min = channels->max =
  4078. slim_rx_cfg[SLIM_RX_7].channels;
  4079. break;
  4080. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  4081. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  4082. channels->min = channels->max =
  4083. slim_tx_cfg[SLIM_TX_7].channels;
  4084. break;
  4085. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  4086. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  4087. channels->min = channels->max =
  4088. slim_tx_cfg[SLIM_TX_8].channels;
  4089. break;
  4090. case MSM_BACKEND_DAI_SLIMBUS_9_TX:
  4091. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4092. slim_tx_cfg[SLIM_TX_9].bit_format);
  4093. rate->min = rate->max = slim_tx_cfg[SLIM_TX_9].sample_rate;
  4094. channels->min = channels->max =
  4095. slim_tx_cfg[SLIM_TX_9].channels;
  4096. break;
  4097. case MSM_BACKEND_DAI_USB_RX:
  4098. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4099. usb_rx_cfg.bit_format);
  4100. rate->min = rate->max = usb_rx_cfg.sample_rate;
  4101. channels->min = channels->max = usb_rx_cfg.channels;
  4102. break;
  4103. case MSM_BACKEND_DAI_USB_TX:
  4104. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4105. usb_tx_cfg.bit_format);
  4106. rate->min = rate->max = usb_tx_cfg.sample_rate;
  4107. channels->min = channels->max = usb_tx_cfg.channels;
  4108. break;
  4109. case MSM_BACKEND_DAI_AFE_PCM_RX:
  4110. channels->min = channels->max = proxy_rx_cfg.channels;
  4111. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4112. break;
  4113. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  4114. channels->min = channels->max =
  4115. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  4116. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4117. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  4118. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  4119. break;
  4120. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  4121. channels->min = channels->max =
  4122. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  4123. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4124. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  4125. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  4126. break;
  4127. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  4128. channels->min = channels->max =
  4129. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  4130. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4131. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  4132. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  4133. break;
  4134. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  4135. channels->min = channels->max =
  4136. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  4137. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4138. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  4139. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  4140. break;
  4141. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  4142. channels->min = channels->max =
  4143. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  4144. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4145. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  4146. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  4147. break;
  4148. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  4149. channels->min = channels->max =
  4150. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  4151. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4152. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  4153. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  4154. break;
  4155. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  4156. channels->min = channels->max =
  4157. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  4158. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4159. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  4160. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  4161. break;
  4162. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  4163. channels->min = channels->max =
  4164. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  4165. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4166. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  4167. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  4168. break;
  4169. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  4170. channels->min = channels->max =
  4171. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  4172. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4173. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  4174. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  4175. break;
  4176. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  4177. channels->min = channels->max =
  4178. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  4179. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4180. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  4181. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  4182. break;
  4183. case MSM_BACKEND_DAI_AUXPCM_RX:
  4184. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4185. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  4186. rate->min = rate->max =
  4187. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  4188. channels->min = channels->max =
  4189. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  4190. break;
  4191. case MSM_BACKEND_DAI_AUXPCM_TX:
  4192. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4193. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  4194. rate->min = rate->max =
  4195. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  4196. channels->min = channels->max =
  4197. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  4198. break;
  4199. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  4200. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4201. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  4202. rate->min = rate->max =
  4203. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  4204. channels->min = channels->max =
  4205. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  4206. break;
  4207. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  4208. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4209. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  4210. rate->min = rate->max =
  4211. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  4212. channels->min = channels->max =
  4213. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  4214. break;
  4215. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  4216. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4217. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  4218. rate->min = rate->max =
  4219. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  4220. channels->min = channels->max =
  4221. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  4222. break;
  4223. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  4224. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4225. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  4226. rate->min = rate->max =
  4227. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  4228. channels->min = channels->max =
  4229. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  4230. break;
  4231. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  4232. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4233. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  4234. rate->min = rate->max =
  4235. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  4236. channels->min = channels->max =
  4237. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  4238. break;
  4239. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  4240. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4241. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  4242. rate->min = rate->max =
  4243. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  4244. channels->min = channels->max =
  4245. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  4246. break;
  4247. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  4248. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4249. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  4250. rate->min = rate->max =
  4251. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  4252. channels->min = channels->max =
  4253. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  4254. break;
  4255. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  4256. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4257. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  4258. rate->min = rate->max =
  4259. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  4260. channels->min = channels->max =
  4261. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  4262. break;
  4263. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  4264. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4265. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  4266. rate->min = rate->max =
  4267. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  4268. channels->min = channels->max =
  4269. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  4270. break;
  4271. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  4272. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4273. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  4274. rate->min = rate->max =
  4275. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  4276. channels->min = channels->max =
  4277. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  4278. break;
  4279. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  4280. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4281. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  4282. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  4283. channels->min = channels->max =
  4284. mi2s_rx_cfg[PRIM_MI2S].channels;
  4285. break;
  4286. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  4287. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4288. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  4289. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  4290. channels->min = channels->max =
  4291. mi2s_tx_cfg[PRIM_MI2S].channels;
  4292. break;
  4293. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  4294. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4295. mi2s_rx_cfg[SEC_MI2S].bit_format);
  4296. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  4297. channels->min = channels->max =
  4298. mi2s_rx_cfg[SEC_MI2S].channels;
  4299. break;
  4300. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  4301. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4302. mi2s_tx_cfg[SEC_MI2S].bit_format);
  4303. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  4304. channels->min = channels->max =
  4305. mi2s_tx_cfg[SEC_MI2S].channels;
  4306. break;
  4307. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  4308. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4309. mi2s_rx_cfg[TERT_MI2S].bit_format);
  4310. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  4311. channels->min = channels->max =
  4312. mi2s_rx_cfg[TERT_MI2S].channels;
  4313. break;
  4314. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  4315. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4316. mi2s_tx_cfg[TERT_MI2S].bit_format);
  4317. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  4318. channels->min = channels->max =
  4319. mi2s_tx_cfg[TERT_MI2S].channels;
  4320. break;
  4321. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  4322. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4323. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  4324. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  4325. channels->min = channels->max =
  4326. mi2s_rx_cfg[QUAT_MI2S].channels;
  4327. break;
  4328. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  4329. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4330. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  4331. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  4332. channels->min = channels->max =
  4333. mi2s_tx_cfg[QUAT_MI2S].channels;
  4334. break;
  4335. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4336. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4337. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  4338. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  4339. channels->min = channels->max =
  4340. mi2s_rx_cfg[QUIN_MI2S].channels;
  4341. break;
  4342. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4343. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4344. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  4345. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  4346. channels->min = channels->max =
  4347. mi2s_tx_cfg[QUIN_MI2S].channels;
  4348. break;
  4349. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  4350. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4351. mi2s_rx_cfg[SEN_MI2S].bit_format);
  4352. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  4353. channels->min = channels->max =
  4354. mi2s_rx_cfg[SEN_MI2S].channels;
  4355. break;
  4356. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  4357. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4358. mi2s_tx_cfg[SEN_MI2S].bit_format);
  4359. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  4360. channels->min = channels->max =
  4361. mi2s_tx_cfg[SEN_MI2S].channels;
  4362. break;
  4363. case MSM_BACKEND_DAI_PRI_META_MI2S_RX:
  4364. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4365. meta_mi2s_rx_cfg[PRIM_META_MI2S].bit_format);
  4366. rate->min = rate->max =
  4367. meta_mi2s_rx_cfg[PRIM_META_MI2S].sample_rate;
  4368. channels->min = channels->max =
  4369. meta_mi2s_rx_cfg[PRIM_META_MI2S].channels;
  4370. break;
  4371. case MSM_BACKEND_DAI_SEC_META_MI2S_RX:
  4372. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4373. meta_mi2s_rx_cfg[SEC_META_MI2S].bit_format);
  4374. rate->min = rate->max =
  4375. meta_mi2s_rx_cfg[SEC_META_MI2S].sample_rate;
  4376. channels->min = channels->max =
  4377. meta_mi2s_rx_cfg[SEC_META_MI2S].channels;
  4378. break;
  4379. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4380. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4381. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4382. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4383. cdc_dma_rx_cfg[idx].bit_format);
  4384. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  4385. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  4386. break;
  4387. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4388. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4389. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4390. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4391. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4392. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4393. cdc_dma_tx_cfg[idx].bit_format);
  4394. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4395. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  4396. break;
  4397. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4398. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4399. SNDRV_PCM_FORMAT_S32_LE);
  4400. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  4401. channels->min = channels->max = msm_vi_feed_tx_ch;
  4402. break;
  4403. case MSM_BACKEND_DAI_PRI_SPDIF_RX:
  4404. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4405. spdif_rx_cfg[PRIM_SPDIF_RX].bit_format);
  4406. rate->min = rate->max =
  4407. spdif_rx_cfg[PRIM_SPDIF_RX].sample_rate;
  4408. channels->min = channels->max =
  4409. spdif_rx_cfg[PRIM_SPDIF_RX].channels;
  4410. break;
  4411. case MSM_BACKEND_DAI_PRI_SPDIF_TX:
  4412. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4413. spdif_tx_cfg[PRIM_SPDIF_TX].bit_format);
  4414. rate->min = rate->max =
  4415. spdif_tx_cfg[PRIM_SPDIF_TX].sample_rate;
  4416. channels->min = channels->max =
  4417. spdif_tx_cfg[PRIM_SPDIF_TX].channels;
  4418. break;
  4419. case MSM_BACKEND_DAI_SEC_SPDIF_RX:
  4420. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4421. spdif_rx_cfg[SEC_SPDIF_RX].bit_format);
  4422. rate->min = rate->max =
  4423. spdif_rx_cfg[SEC_SPDIF_RX].sample_rate;
  4424. channels->min = channels->max =
  4425. spdif_rx_cfg[SEC_SPDIF_RX].channels;
  4426. break;
  4427. case MSM_BACKEND_DAI_SEC_SPDIF_TX:
  4428. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4429. spdif_tx_cfg[SEC_SPDIF_TX].bit_format);
  4430. rate->min = rate->max =
  4431. spdif_tx_cfg[SEC_SPDIF_TX].sample_rate;
  4432. channels->min = channels->max =
  4433. spdif_tx_cfg[SEC_SPDIF_TX].channels;
  4434. break;
  4435. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  4436. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4437. afe_lb_tx_cfg.bit_format);
  4438. rate->min = rate->max = afe_lb_tx_cfg.sample_rate;
  4439. channels->min = channels->max = afe_lb_tx_cfg.channels;
  4440. break;
  4441. default:
  4442. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4443. break;
  4444. }
  4445. return rc;
  4446. }
  4447. static int msm_afe_set_config(struct snd_soc_component *component)
  4448. {
  4449. int ret = 0;
  4450. void *config_data = NULL;
  4451. if (!msm_codec_fn.get_afe_config_fn) {
  4452. dev_err(component->dev, "%s: codec get afe config not init'ed\n",
  4453. __func__);
  4454. return -EINVAL;
  4455. }
  4456. config_data = msm_codec_fn.get_afe_config_fn(component,
  4457. AFE_CDC_REGISTERS_CONFIG);
  4458. if (config_data) {
  4459. ret = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  4460. if (ret) {
  4461. dev_err(component->dev,
  4462. "%s: Failed to set codec registers config %d\n",
  4463. __func__, ret);
  4464. return ret;
  4465. }
  4466. }
  4467. config_data = msm_codec_fn.get_afe_config_fn(component,
  4468. AFE_CDC_REGISTER_PAGE_CONFIG);
  4469. if (config_data) {
  4470. ret = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
  4471. 0);
  4472. if (ret)
  4473. dev_err(component->dev,
  4474. "%s: Failed to set cdc register page config\n",
  4475. __func__);
  4476. }
  4477. config_data = msm_codec_fn.get_afe_config_fn(component,
  4478. AFE_SLIMBUS_SLAVE_CONFIG);
  4479. if (config_data) {
  4480. ret = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  4481. if (ret) {
  4482. dev_err(component->dev,
  4483. "%s: Failed to set slimbus slave config %d\n",
  4484. __func__, ret);
  4485. return ret;
  4486. }
  4487. }
  4488. return 0;
  4489. }
  4490. static void msm_afe_clear_config(void)
  4491. {
  4492. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  4493. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  4494. }
  4495. static int msm_adsp_power_up_config(struct snd_soc_component *component,
  4496. struct snd_card *card)
  4497. {
  4498. int ret = 0;
  4499. unsigned long timeout;
  4500. int adsp_ready = 0;
  4501. bool snd_card_online = 0;
  4502. timeout = jiffies +
  4503. msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
  4504. do {
  4505. if (!snd_card_online) {
  4506. snd_card_online = snd_card_is_online_state(card);
  4507. pr_debug("%s: Sound card is %s\n", __func__,
  4508. snd_card_online ? "Online" : "Offline");
  4509. }
  4510. if (!adsp_ready) {
  4511. adsp_ready = q6core_is_adsp_ready();
  4512. pr_debug("%s: ADSP Audio is %s\n", __func__,
  4513. adsp_ready ? "ready" : "not ready");
  4514. }
  4515. if (snd_card_online && adsp_ready)
  4516. break;
  4517. /*
  4518. * Sound card/ADSP will be coming up after subsystem restart and
  4519. * it might not be fully up when the control reaches
  4520. * here. So, wait for 50msec before checking ADSP state
  4521. */
  4522. msleep(50);
  4523. } while (time_after(timeout, jiffies));
  4524. if (!snd_card_online || !adsp_ready) {
  4525. pr_err("%s: Timeout. Sound card is %s, ADSP Audio is %s\n",
  4526. __func__,
  4527. snd_card_online ? "Online" : "Offline",
  4528. adsp_ready ? "ready" : "not ready");
  4529. ret = -ETIMEDOUT;
  4530. goto err;
  4531. }
  4532. ret = msm_afe_set_config(component);
  4533. if (ret)
  4534. pr_err("%s: Failed to set AFE config. err %d\n",
  4535. __func__, ret);
  4536. return 0;
  4537. err:
  4538. return ret;
  4539. }
  4540. static int qcs405_notifier_service_cb(struct notifier_block *this,
  4541. unsigned long opcode, void *ptr)
  4542. {
  4543. int ret;
  4544. struct snd_soc_card *card = NULL;
  4545. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  4546. struct snd_soc_pcm_runtime *rtd;
  4547. struct snd_soc_dai *codec_dai;
  4548. struct snd_soc_component *component;
  4549. pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
  4550. switch (opcode) {
  4551. case AUDIO_NOTIFIER_SERVICE_DOWN:
  4552. /*
  4553. * Use flag to ignore initial boot notifications
  4554. * On initial boot msm_adsp_power_up_config is
  4555. * called on init. There is no need to clear
  4556. * and set the config again on initial boot.
  4557. */
  4558. if (is_initial_boot)
  4559. break;
  4560. msm_afe_clear_config();
  4561. break;
  4562. case AUDIO_NOTIFIER_SERVICE_UP:
  4563. if (is_initial_boot) {
  4564. is_initial_boot = false;
  4565. break;
  4566. }
  4567. if (!spdev)
  4568. return -EINVAL;
  4569. card = platform_get_drvdata(spdev);
  4570. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  4571. if (!rtd) {
  4572. dev_err(card->dev,
  4573. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  4574. __func__, be_dl_name);
  4575. ret = -EINVAL;
  4576. goto err;
  4577. }
  4578. codec_dai = rtd->codec_dai;
  4579. if (!strcmp(dev_name(codec_dai->dev), "tasha_codec"))
  4580. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4581. ret = msm_adsp_power_up_config(component, card->snd_card);
  4582. if (ret < 0) {
  4583. dev_err(card->dev,
  4584. "%s: msm_adsp_power_up_config failed ret = %d!\n",
  4585. __func__, ret);
  4586. goto err;
  4587. }
  4588. break;
  4589. default:
  4590. break;
  4591. }
  4592. err:
  4593. return NOTIFY_OK;
  4594. }
  4595. static struct notifier_block service_nb = {
  4596. .notifier_call = qcs405_notifier_service_cb,
  4597. .priority = -INT_MAX,
  4598. };
  4599. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  4600. {
  4601. int ret = 0;
  4602. void *config_data;
  4603. struct snd_soc_component *component;
  4604. struct snd_soc_dapm_context *dapm;
  4605. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4606. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4607. struct snd_card *card;
  4608. struct msm_asoc_mach_data *pdata =
  4609. snd_soc_card_get_drvdata(rtd->card);
  4610. /*
  4611. * Codec SLIMBUS configuration
  4612. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
  4613. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  4614. * TX14, TX15, TX16
  4615. */
  4616. unsigned int rx_ch[TASHA_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
  4617. 151, 152, 153, 154, 155, 156};
  4618. unsigned int tx_ch[TASHA_TX_MAX] = {128, 129, 130, 131, 132, 133,
  4619. 134, 135, 136, 137, 138, 139,
  4620. 140, 141, 142, 143};
  4621. pr_info("%s: dev_name:%s\n", __func__, dev_name(cpu_dai->dev));
  4622. rtd->pmdown_time = 0;
  4623. if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
  4624. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4625. dapm = snd_soc_component_get_dapm(component);
  4626. }
  4627. ret = snd_soc_add_component_controls(component, msm_snd_sb_controls,
  4628. ARRAY_SIZE(msm_snd_sb_controls));
  4629. if (ret < 0) {
  4630. pr_err("%s: add_codec_controls failed, err %d\n",
  4631. __func__, ret);
  4632. return ret;
  4633. }
  4634. snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
  4635. ARRAY_SIZE(msm_dapm_widgets));
  4636. snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
  4637. ARRAY_SIZE(wcd_audio_paths));
  4638. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
  4639. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
  4640. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  4641. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  4642. snd_soc_dapm_ignore_suspend(dapm, "lineout booster");
  4643. snd_soc_dapm_sync(dapm);
  4644. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4645. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4646. msm_codec_fn.get_afe_config_fn = tasha_get_afe_config;
  4647. ret = msm_adsp_power_up_config(component, rtd->card->snd_card);
  4648. if (ret) {
  4649. dev_err(component->dev, "%s: Failed to set AFE config %d\n",
  4650. __func__, ret);
  4651. goto err;
  4652. }
  4653. config_data = msm_codec_fn.get_afe_config_fn(component,
  4654. AFE_AANC_VERSION);
  4655. if (config_data) {
  4656. ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  4657. if (ret) {
  4658. dev_err(component->dev, "%s: Failed to set aanc version %d\n",
  4659. __func__, ret);
  4660. goto err;
  4661. }
  4662. }
  4663. card = rtd->card->snd_card;
  4664. if (!pdata->codec_root)
  4665. pdata->codec_root = snd_info_create_subdir(card->module,
  4666. "codecs", card->proc_root);
  4667. if (!pdata->codec_root) {
  4668. dev_dbg(codec->dev, "%s: Cannot create codecs module entry\n",
  4669. __func__);
  4670. ret = 0;
  4671. goto err;
  4672. }
  4673. tasha_codec_info_create_codec_entry(pdata->codec_root, component);
  4674. codec_reg_done = true;
  4675. return 0;
  4676. err:
  4677. return ret;
  4678. }
  4679. static int msm_va_cdc_dma_init(struct snd_soc_pcm_runtime *rtd)
  4680. {
  4681. int ret = 0;
  4682. struct snd_soc_component *component;
  4683. struct snd_soc_dapm_context *dapm;
  4684. struct snd_card *card;
  4685. struct msm_asoc_mach_data *pdata =
  4686. snd_soc_card_get_drvdata(rtd->card);
  4687. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4688. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  4689. if (!component) {
  4690. pr_err("%s: component is NULL\n", __func__);
  4691. return -EINVAL;
  4692. }
  4693. dapm = snd_soc_component_get_dapm(component);
  4694. ret = snd_soc_add_component_controls(component, msm_snd_va_controls,
  4695. ARRAY_SIZE(msm_snd_va_controls));
  4696. if (ret < 0) {
  4697. dev_err(component->dev, "%s: add_component_controls for va failed, err %d\n",
  4698. __func__, ret);
  4699. return ret;
  4700. }
  4701. snd_soc_dapm_new_controls(dapm, msm_va_dapm_widgets,
  4702. ARRAY_SIZE(msm_va_dapm_widgets));
  4703. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  4704. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  4705. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  4706. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  4707. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  4708. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  4709. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  4710. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  4711. snd_soc_dapm_sync(dapm);
  4712. card = rtd->card->snd_card;
  4713. if (!pdata->codec_root)
  4714. pdata->codec_root = snd_info_create_subdir(card->module,
  4715. "codecs", card->proc_root);
  4716. if (!pdata->codec_root) {
  4717. dev_dbg(codec->dev, "%s: Cannot create codecs module entry\n",
  4718. __func__);
  4719. ret = 0;
  4720. goto done;
  4721. }
  4722. bolero_info_create_codec_entry(pdata->codec_root, component);
  4723. done:
  4724. return ret;
  4725. }
  4726. static int msm_wsa_cdc_dma_init(struct snd_soc_pcm_runtime *rtd)
  4727. {
  4728. int ret = 0;
  4729. struct snd_soc_component *component = NULL;
  4730. struct snd_soc_dapm_context *dapm = NULL;
  4731. struct snd_soc_component *aux_comp = NULL;
  4732. struct snd_card *card = NULL;
  4733. struct msm_asoc_mach_data *pdata =
  4734. snd_soc_card_get_drvdata(rtd->card);
  4735. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  4736. if (!component) {
  4737. pr_err("%s: component is NULL\n", __func__);
  4738. return -EINVAL;
  4739. }
  4740. dapm = snd_soc_component_get_dapm(component);
  4741. ret = snd_soc_add_component_controls(component, msm_snd_wsa_controls,
  4742. ARRAY_SIZE(msm_snd_wsa_controls));
  4743. if (ret < 0) {
  4744. dev_err(component->dev, "%s: add_codec_controls for wsa failed, err %d\n",
  4745. __func__, ret);
  4746. return ret;
  4747. }
  4748. snd_soc_dapm_new_controls(dapm, msm_wsa_dapm_widgets,
  4749. ARRAY_SIZE(msm_wsa_dapm_widgets));
  4750. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  4751. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  4752. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  4753. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  4754. snd_soc_dapm_sync(dapm);
  4755. /*
  4756. * Send speaker configuration only for WSA8810.
  4757. * Default configuration is for WSA8815.
  4758. */
  4759. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  4760. __func__, rtd->card->num_aux_devs);
  4761. if (rtd->card->num_aux_devs &&
  4762. !list_empty(&rtd->card->component_dev_list)) {
  4763. aux_comp = list_first_entry(
  4764. &rtd->card->component_dev_list,
  4765. struct snd_soc_component,
  4766. card_aux_list);
  4767. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  4768. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  4769. wsa_macro_set_spkr_mode(component,
  4770. WSA_MACRO_SPKR_MODE_1);
  4771. wsa_macro_set_spkr_gain_offset(component,
  4772. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  4773. }
  4774. }
  4775. card = rtd->card->snd_card;
  4776. if (!pdata->codec_root)
  4777. pdata->codec_root = snd_info_create_subdir(card->module,
  4778. "codecs", card->proc_root);
  4779. if (!pdata->codec_root) {
  4780. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  4781. __func__);
  4782. ret = 0;
  4783. goto done;
  4784. }
  4785. bolero_info_create_codec_entry(pdata->codec_root, component);
  4786. done:
  4787. return ret;
  4788. }
  4789. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  4790. {
  4791. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4792. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161, 162};
  4793. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4794. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4795. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4796. }
  4797. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  4798. struct snd_pcm_hw_params *params)
  4799. {
  4800. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4801. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4802. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4803. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4804. int ret = 0;
  4805. u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  4806. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4807. u32 user_set_tx_ch = 0;
  4808. u32 rx_ch_count;
  4809. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4810. ret = snd_soc_dai_get_channel_map(codec_dai,
  4811. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4812. if (ret < 0) {
  4813. pr_err("%s: failed to get codec chan map, err:%d\n",
  4814. __func__, ret);
  4815. goto err;
  4816. }
  4817. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
  4818. pr_debug("%s: rx_5_ch=%d\n", __func__,
  4819. slim_rx_cfg[5].channels);
  4820. rx_ch_count = slim_rx_cfg[5].channels;
  4821. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
  4822. pr_debug("%s: rx_2_ch=%d\n", __func__,
  4823. slim_rx_cfg[2].channels);
  4824. rx_ch_count = slim_rx_cfg[2].channels;
  4825. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
  4826. pr_debug("%s: rx_6_ch=%d\n", __func__,
  4827. slim_rx_cfg[6].channels);
  4828. rx_ch_count = slim_rx_cfg[6].channels;
  4829. } else {
  4830. pr_debug("%s: rx_0_ch=%d\n", __func__,
  4831. slim_rx_cfg[0].channels);
  4832. rx_ch_count = slim_rx_cfg[0].channels;
  4833. }
  4834. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4835. rx_ch_count, rx_ch);
  4836. if (ret < 0) {
  4837. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4838. __func__, ret);
  4839. goto err;
  4840. }
  4841. } else {
  4842. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  4843. codec_dai->name, codec_dai->id, user_set_tx_ch);
  4844. ret = snd_soc_dai_get_channel_map(codec_dai,
  4845. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4846. if (ret < 0) {
  4847. pr_err("%s: failed to get tx codec chan map, err:%d\n",
  4848. __func__, ret);
  4849. goto err;
  4850. }
  4851. /* For <codec>_tx1 case */
  4852. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
  4853. user_set_tx_ch = slim_tx_cfg[0].channels;
  4854. /* For <codec>_tx3 case */
  4855. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
  4856. user_set_tx_ch = slim_tx_cfg[1].channels;
  4857. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
  4858. user_set_tx_ch = msm_vi_feed_tx_ch;
  4859. else
  4860. user_set_tx_ch = tx_ch_cnt;
  4861. pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
  4862. __func__, slim_tx_cfg[0].channels, user_set_tx_ch,
  4863. tx_ch_cnt, dai_link->id);
  4864. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4865. user_set_tx_ch, tx_ch, 0, 0);
  4866. if (ret < 0)
  4867. pr_err("%s: failed to set tx cpu chan map, err:%d\n",
  4868. __func__, ret);
  4869. }
  4870. err:
  4871. return ret;
  4872. }
  4873. static int msm_snd_auxpcm_startup(struct snd_pcm_substream *substream)
  4874. {
  4875. int ret = 0;
  4876. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4877. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4878. ret = qcs405_send_island_vad_config(dai_link->id);
  4879. if (ret) {
  4880. pr_err("%s: send island/vad cfg failed, err = %d\n",
  4881. __func__, ret);
  4882. }
  4883. return ret;
  4884. }
  4885. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4886. {
  4887. int ret = 0;
  4888. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4889. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4890. ret = qcs405_send_island_vad_config(dai_link->id);
  4891. if (ret) {
  4892. pr_err("%s: send island/vad cfg failed, err = %d\n",
  4893. __func__, ret);
  4894. }
  4895. return ret;
  4896. }
  4897. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4898. struct snd_pcm_hw_params *params)
  4899. {
  4900. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4901. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4902. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4903. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4904. int ret = 0;
  4905. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4906. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4907. u32 user_set_tx_ch = 0;
  4908. u32 user_set_rx_ch = 0;
  4909. u32 ch_id;
  4910. ret = snd_soc_dai_get_channel_map(codec_dai,
  4911. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4912. &rx_ch_cdc_dma);
  4913. if (ret < 0) {
  4914. pr_err("%s: failed to get codec chan map, err:%d\n",
  4915. __func__, ret);
  4916. goto err;
  4917. }
  4918. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4919. switch (dai_link->id) {
  4920. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4921. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4922. {
  4923. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4924. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4925. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4926. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4927. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4928. user_set_rx_ch, &rx_ch_cdc_dma);
  4929. if (ret < 0) {
  4930. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4931. __func__, ret);
  4932. goto err;
  4933. }
  4934. }
  4935. break;
  4936. }
  4937. } else {
  4938. switch (dai_link->id) {
  4939. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4940. {
  4941. user_set_tx_ch = msm_vi_feed_tx_ch;
  4942. }
  4943. break;
  4944. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4945. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4946. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4947. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4948. {
  4949. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4950. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4951. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4952. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4953. }
  4954. break;
  4955. }
  4956. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4957. &tx_ch_cdc_dma, 0, 0);
  4958. if (ret < 0) {
  4959. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4960. __func__, ret);
  4961. goto err;
  4962. }
  4963. }
  4964. err:
  4965. return ret;
  4966. }
  4967. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4968. struct snd_pcm_hw_params *params)
  4969. {
  4970. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4971. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4972. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4973. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4974. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4975. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4976. int ret;
  4977. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4978. codec_dai->name, codec_dai->id);
  4979. ret = snd_soc_dai_get_channel_map(codec_dai,
  4980. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4981. if (ret) {
  4982. dev_err(rtd->dev,
  4983. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4984. __func__, ret);
  4985. goto err;
  4986. }
  4987. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4988. __func__, tx_ch_cnt, dai_link->id);
  4989. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4990. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4991. if (ret)
  4992. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4993. __func__, ret);
  4994. err:
  4995. return ret;
  4996. }
  4997. static int msm_get_port_id(int be_id)
  4998. {
  4999. int afe_port_id;
  5000. switch (be_id) {
  5001. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  5002. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  5003. break;
  5004. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  5005. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  5006. break;
  5007. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  5008. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  5009. break;
  5010. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  5011. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  5012. break;
  5013. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  5014. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  5015. break;
  5016. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  5017. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  5018. break;
  5019. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  5020. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  5021. break;
  5022. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  5023. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  5024. break;
  5025. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  5026. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  5027. break;
  5028. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  5029. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  5030. break;
  5031. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  5032. afe_port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  5033. break;
  5034. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  5035. afe_port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  5036. break;
  5037. default:
  5038. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  5039. afe_port_id = -EINVAL;
  5040. }
  5041. return afe_port_id;
  5042. }
  5043. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  5044. {
  5045. u32 bit_per_sample;
  5046. switch (bit_format) {
  5047. case SNDRV_PCM_FORMAT_S32_LE:
  5048. case SNDRV_PCM_FORMAT_S24_3LE:
  5049. case SNDRV_PCM_FORMAT_S24_LE:
  5050. bit_per_sample = 32;
  5051. break;
  5052. case SNDRV_PCM_FORMAT_S16_LE:
  5053. default:
  5054. bit_per_sample = 16;
  5055. break;
  5056. }
  5057. return bit_per_sample;
  5058. }
  5059. static void update_mi2s_clk_val(int dai_id, int stream)
  5060. {
  5061. u32 bit_per_sample;
  5062. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  5063. bit_per_sample =
  5064. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  5065. mi2s_clk[dai_id].clk_freq_in_hz =
  5066. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  5067. } else {
  5068. bit_per_sample =
  5069. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  5070. mi2s_clk[dai_id].clk_freq_in_hz =
  5071. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  5072. }
  5073. }
  5074. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  5075. {
  5076. int ret = 0;
  5077. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5078. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5079. int port_id = 0;
  5080. int index = cpu_dai->id;
  5081. port_id = msm_get_port_id(rtd->dai_link->id);
  5082. if (port_id < 0) {
  5083. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  5084. ret = port_id;
  5085. goto err;
  5086. }
  5087. if (enable) {
  5088. update_mi2s_clk_val(index, substream->stream);
  5089. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  5090. mi2s_clk[index].clk_freq_in_hz);
  5091. }
  5092. mi2s_clk[index].enable = enable;
  5093. ret = afe_set_lpass_clock_v2(port_id,
  5094. &mi2s_clk[index]);
  5095. if (ret < 0) {
  5096. dev_err(rtd->card->dev,
  5097. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5098. __func__, port_id, ret);
  5099. goto err;
  5100. }
  5101. err:
  5102. return ret;
  5103. }
  5104. static int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  5105. struct snd_pcm_hw_params *params)
  5106. {
  5107. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5108. struct snd_interval *rate = hw_param_interval(params,
  5109. SNDRV_PCM_HW_PARAM_RATE);
  5110. struct snd_interval *channels = hw_param_interval(params,
  5111. SNDRV_PCM_HW_PARAM_CHANNELS);
  5112. if (cpu_dai->id == AFE_PORT_ID_QUATERNARY_TDM_RX) {
  5113. channels->min = channels->max =
  5114. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  5115. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  5116. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  5117. rate->min = rate->max =
  5118. tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  5119. } else if (cpu_dai->id == AFE_PORT_ID_SECONDARY_TDM_RX) {
  5120. channels->min = channels->max =
  5121. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  5122. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  5123. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  5124. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  5125. } else if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_RX) {
  5126. channels->min = channels->max =
  5127. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  5128. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  5129. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  5130. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  5131. } else {
  5132. pr_err("%s: dai id 0x%x not supported\n",
  5133. __func__, cpu_dai->id);
  5134. return -EINVAL;
  5135. }
  5136. pr_debug("%s: dai id = 0x%x channels = %d rate = %d format = 0x%x\n",
  5137. __func__, cpu_dai->id, channels->max, rate->max,
  5138. params_format(params));
  5139. return 0;
  5140. }
  5141. static int qcs405_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  5142. struct snd_pcm_hw_params *params)
  5143. {
  5144. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5145. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5146. int ret = 0;
  5147. int slot_width = 32;
  5148. int channels, slots = 8;
  5149. unsigned int slot_mask, rate, clk_freq;
  5150. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  5151. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  5152. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  5153. switch (cpu_dai->id) {
  5154. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5155. channels = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  5156. break;
  5157. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5158. channels = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  5159. break;
  5160. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5161. channels = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  5162. break;
  5163. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5164. channels = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  5165. break;
  5166. case AFE_PORT_ID_QUINARY_TDM_RX:
  5167. channels = tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  5168. break;
  5169. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5170. channels = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  5171. break;
  5172. case AFE_PORT_ID_SECONDARY_TDM_TX:
  5173. channels = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  5174. break;
  5175. case AFE_PORT_ID_TERTIARY_TDM_TX:
  5176. channels = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  5177. break;
  5178. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  5179. channels = tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  5180. break;
  5181. case AFE_PORT_ID_QUINARY_TDM_TX:
  5182. channels = tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  5183. break;
  5184. default:
  5185. pr_err("%s: dai id 0x%x not supported\n",
  5186. __func__, cpu_dai->id);
  5187. return -EINVAL;
  5188. }
  5189. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  5190. /*2 slot config - bits 0 and 1 set for the first two slots */
  5191. slot_mask = 0x0000FFFF >> (16-channels);
  5192. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  5193. __func__, slot_width, slots);
  5194. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  5195. slots, slot_width);
  5196. if (ret < 0) {
  5197. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  5198. __func__, ret);
  5199. goto end;
  5200. }
  5201. ret = snd_soc_dai_set_channel_map(cpu_dai,
  5202. 0, NULL, channels, slot_offset);
  5203. if (ret < 0) {
  5204. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  5205. __func__, ret);
  5206. goto end;
  5207. }
  5208. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  5209. /*2 slot config - bits 0 and 1 set for the first two slots */
  5210. slot_mask = 0x0000FFFF >> (16-channels);
  5211. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  5212. __func__, slot_width, slots);
  5213. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  5214. slots, slot_width);
  5215. if (ret < 0) {
  5216. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  5217. __func__, ret);
  5218. goto end;
  5219. }
  5220. ret = snd_soc_dai_set_channel_map(cpu_dai,
  5221. channels, slot_offset, 0, NULL);
  5222. if (ret < 0) {
  5223. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  5224. __func__, ret);
  5225. goto end;
  5226. }
  5227. } else {
  5228. ret = -EINVAL;
  5229. pr_err("%s: invalid use case, err:%d\n",
  5230. __func__, ret);
  5231. goto end;
  5232. }
  5233. rate = params_rate(params);
  5234. clk_freq = rate * slot_width * slots;
  5235. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  5236. if (ret < 0)
  5237. pr_err("%s: failed to set tdm clk, err:%d\n",
  5238. __func__, ret);
  5239. end:
  5240. return ret;
  5241. }
  5242. static int msm_get_tdm_mode(u32 port_id)
  5243. {
  5244. u32 tdm_mode;
  5245. switch (port_id) {
  5246. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5247. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5248. tdm_mode = TDM_PRI;
  5249. break;
  5250. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5251. case AFE_PORT_ID_SECONDARY_TDM_TX:
  5252. tdm_mode = TDM_SEC;
  5253. break;
  5254. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5255. case AFE_PORT_ID_TERTIARY_TDM_TX:
  5256. tdm_mode = TDM_TERT;
  5257. break;
  5258. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5259. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  5260. tdm_mode = TDM_QUAT;
  5261. break;
  5262. case AFE_PORT_ID_QUINARY_TDM_RX:
  5263. case AFE_PORT_ID_QUINARY_TDM_TX:
  5264. tdm_mode = TDM_QUIN;
  5265. break;
  5266. default:
  5267. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  5268. tdm_mode = -EINVAL;
  5269. }
  5270. return tdm_mode;
  5271. }
  5272. static int qcs405_tdm_snd_startup(struct snd_pcm_substream *substream)
  5273. {
  5274. int ret = 0;
  5275. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5276. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5277. struct snd_soc_card *card = rtd->card;
  5278. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5279. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  5280. u32 tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  5281. if (tdm_mode >= TDM_INTERFACE_MAX) {
  5282. ret = -EINVAL;
  5283. pr_err("%s: Invalid TDM interface %d\n",
  5284. __func__, ret);
  5285. return ret;
  5286. }
  5287. if (pdata->mi2s_gpio_p[tdm_mode]) {
  5288. ret = msm_cdc_pinctrl_select_active_state(
  5289. pdata->mi2s_gpio_p[tdm_mode]);
  5290. if (ret)
  5291. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  5292. __func__, ret);
  5293. }
  5294. /* Enable Mic bias for TDM Mics */
  5295. if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_TX) {
  5296. if (pdata->tdm_micb_supply) {
  5297. ret = regulator_set_voltage(pdata->tdm_micb_supply,
  5298. pdata->tdm_micb_voltage,
  5299. pdata->tdm_micb_voltage);
  5300. if (ret) {
  5301. pr_err("%s: Setting voltage failed, err = %d\n",
  5302. __func__, ret);
  5303. return ret;
  5304. }
  5305. ret = regulator_set_load(pdata->tdm_micb_supply,
  5306. pdata->tdm_micb_current);
  5307. if (ret) {
  5308. pr_err("%s: Setting current failed, err = %d\n",
  5309. __func__, ret);
  5310. return ret;
  5311. }
  5312. ret = regulator_enable(pdata->tdm_micb_supply);
  5313. if (ret) {
  5314. pr_err("%s: regulator enable failed, err = %d\n",
  5315. __func__, ret);
  5316. return ret;
  5317. }
  5318. }
  5319. }
  5320. ret = qcs405_send_island_vad_config(dai_link->id);
  5321. if (ret) {
  5322. pr_err("%s: send island/vad cfg failed, err = %d\n",
  5323. __func__, ret);
  5324. return ret;
  5325. }
  5326. return ret;
  5327. }
  5328. static void qcs405_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  5329. {
  5330. int ret = 0;
  5331. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5332. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5333. struct snd_soc_card *card = rtd->card;
  5334. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5335. u32 tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  5336. if (cpu_dai->id == AFE_PORT_ID_QUINARY_TDM_TX) {
  5337. if (pdata->tdm_micb_supply) {
  5338. ret = regulator_disable(pdata->tdm_micb_supply);
  5339. if (ret)
  5340. pr_err("%s: regulator disable failed, err = %d\n",
  5341. __func__, ret);
  5342. regulator_set_voltage(pdata->tdm_micb_supply, 0,
  5343. pdata->tdm_micb_voltage);
  5344. regulator_set_load(pdata->tdm_micb_supply, 0);
  5345. }
  5346. }
  5347. if (pdata->mi2s_gpio_p[tdm_mode]) {
  5348. ret = msm_cdc_pinctrl_select_sleep_state(
  5349. pdata->mi2s_gpio_p[tdm_mode]);
  5350. if (ret)
  5351. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  5352. __func__, ret);
  5353. }
  5354. }
  5355. static struct snd_soc_ops qcs405_tdm_be_ops = {
  5356. .hw_params = qcs405_tdm_snd_hw_params,
  5357. .startup = qcs405_tdm_snd_startup,
  5358. .shutdown = qcs405_tdm_snd_shutdown
  5359. };
  5360. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  5361. {
  5362. cpumask_t mask;
  5363. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  5364. pm_qos_remove_request(&substream->latency_pm_qos_req);
  5365. cpumask_clear(&mask);
  5366. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  5367. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  5368. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  5369. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  5370. pm_qos_add_request(&substream->latency_pm_qos_req,
  5371. PM_QOS_CPU_DMA_LATENCY,
  5372. MSM_LL_QOS_VALUE);
  5373. return 0;
  5374. }
  5375. static struct snd_soc_ops msm_fe_qos_ops = {
  5376. .prepare = msm_fe_qos_prepare,
  5377. };
  5378. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  5379. {
  5380. int ret = 0;
  5381. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5382. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5383. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  5384. int index = cpu_dai->id;
  5385. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  5386. struct snd_soc_card *card = rtd->card;
  5387. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5388. dev_dbg(rtd->card->dev,
  5389. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5390. __func__, substream->name, substream->stream,
  5391. cpu_dai->name, cpu_dai->id);
  5392. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5393. ret = -EINVAL;
  5394. dev_err(rtd->card->dev,
  5395. "%s: CPU DAI id (%d) out of range\n",
  5396. __func__, cpu_dai->id);
  5397. goto err;
  5398. }
  5399. /*
  5400. * Mutex protection in case the same MI2S
  5401. * interface using for both TX and RX so
  5402. * that the same clock won't be enable twice.
  5403. */
  5404. mutex_lock(&mi2s_intf_conf[index].lock);
  5405. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  5406. /* Check if msm needs to provide the clock to the interface */
  5407. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  5408. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  5409. fmt = SND_SOC_DAIFMT_CBM_CFM;
  5410. }
  5411. ret = msm_mi2s_set_sclk(substream, true);
  5412. if (ret < 0) {
  5413. dev_err(rtd->card->dev,
  5414. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  5415. __func__, ret);
  5416. goto clean_up;
  5417. }
  5418. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  5419. if (ret < 0) {
  5420. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  5421. __func__, index, ret);
  5422. goto clk_off;
  5423. }
  5424. if (pdata->mi2s_gpio_p[index])
  5425. msm_cdc_pinctrl_select_active_state(
  5426. pdata->mi2s_gpio_p[index]);
  5427. }
  5428. ret = qcs405_send_island_vad_config(dai_link->id);
  5429. if (ret) {
  5430. pr_err("%s: send island/vad cfg failed, err = %d\n",
  5431. __func__, ret);
  5432. return ret;
  5433. }
  5434. clk_off:
  5435. if (ret < 0)
  5436. msm_mi2s_set_sclk(substream, false);
  5437. clean_up:
  5438. if (ret < 0)
  5439. mi2s_intf_conf[index].ref_cnt--;
  5440. mutex_unlock(&mi2s_intf_conf[index].lock);
  5441. err:
  5442. return ret;
  5443. }
  5444. static int msm_mi2s_snd_hw_free(struct snd_pcm_substream *substream)
  5445. {
  5446. int i, data_format = 0;
  5447. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5448. int index = rtd->cpu_dai->id;
  5449. struct snd_soc_card *card = rtd->card;
  5450. struct snd_soc_component *component;
  5451. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  5452. data_format = mi2s_rx_cfg[index].data_format;
  5453. else
  5454. data_format = mi2s_tx_cfg[index].data_format;
  5455. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5456. substream->name, substream->stream);
  5457. /* Call csra mute function if data format is DSD, else return */
  5458. if (data_format != AFE_DSD_DATA)
  5459. return 0;
  5460. for (i = 0; i < card->num_aux_devs; i++) {
  5461. component =
  5462. soc_find_component(card->aux_dev[i].codec_of_node,
  5463. NULL);
  5464. csra66x0_hw_free_mute(component);
  5465. }
  5466. return 0;
  5467. }
  5468. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  5469. {
  5470. int ret;
  5471. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5472. int index = rtd->cpu_dai->id;
  5473. struct snd_soc_card *card = rtd->card;
  5474. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5475. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5476. substream->name, substream->stream);
  5477. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5478. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  5479. return;
  5480. }
  5481. mutex_lock(&mi2s_intf_conf[index].lock);
  5482. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  5483. if (pdata->mi2s_gpio_p[index])
  5484. msm_cdc_pinctrl_select_sleep_state(
  5485. pdata->mi2s_gpio_p[index]);
  5486. ret = msm_mi2s_set_sclk(substream, false);
  5487. if (ret < 0)
  5488. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  5489. __func__, index, ret);
  5490. }
  5491. mutex_unlock(&mi2s_intf_conf[index].lock);
  5492. }
  5493. static int msm_meta_mi2s_set_sclk(struct snd_pcm_substream *substream,
  5494. int member_id, bool enable)
  5495. {
  5496. int ret = 0;
  5497. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5498. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5499. int be_id = 0;
  5500. int port_id = 0;
  5501. int index = cpu_dai->id;
  5502. u32 bit_per_sample = 0;
  5503. switch (member_id) {
  5504. case PRIM_MI2S:
  5505. be_id = MSM_BACKEND_DAI_PRI_MI2S_RX;
  5506. break;
  5507. case SEC_MI2S:
  5508. be_id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX;
  5509. break;
  5510. case TERT_MI2S:
  5511. be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX;
  5512. break;
  5513. case QUAT_MI2S:
  5514. be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX;
  5515. break;
  5516. default:
  5517. dev_err(rtd->card->dev, "%s: Invalid member_id\n", __func__);
  5518. ret = -EINVAL;
  5519. goto err;
  5520. }
  5521. port_id = msm_get_port_id(be_id);
  5522. if (port_id < 0) {
  5523. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  5524. ret = port_id;
  5525. goto err;
  5526. }
  5527. if (enable) {
  5528. bit_per_sample =
  5529. get_mi2s_bits_per_sample(
  5530. meta_mi2s_rx_cfg[index].bit_format);
  5531. mi2s_clk[member_id].clk_freq_in_hz =
  5532. meta_mi2s_rx_cfg[index].sample_rate * 2 *
  5533. bit_per_sample;
  5534. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  5535. mi2s_clk[member_id].clk_freq_in_hz);
  5536. }
  5537. mi2s_clk[member_id].enable = enable;
  5538. ret = afe_set_lpass_clock_v2(port_id, &mi2s_clk[member_id]);
  5539. if (ret < 0) {
  5540. dev_err(rtd->card->dev,
  5541. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5542. __func__, port_id, ret);
  5543. goto err;
  5544. }
  5545. err:
  5546. return ret;
  5547. }
  5548. static int msm_meta_mi2s_snd_startup(struct snd_pcm_substream *substream)
  5549. {
  5550. int ret = 0;
  5551. int i = 0;
  5552. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5553. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5554. int index = cpu_dai->id;
  5555. int member_port = 0;
  5556. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  5557. struct snd_soc_card *card = rtd->card;
  5558. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5559. dev_dbg(rtd->card->dev,
  5560. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5561. __func__, substream->name, substream->stream,
  5562. cpu_dai->name, cpu_dai->id);
  5563. if (index < PRIM_META_MI2S || index >= META_MI2S_MAX) {
  5564. ret = -EINVAL;
  5565. dev_err(rtd->card->dev,
  5566. "%s: CPU DAI id (%d) out of range\n",
  5567. __func__, cpu_dai->id);
  5568. goto err;
  5569. }
  5570. for (i = 0; i < meta_mi2s_intf_conf[index].num_member_ports; i++) {
  5571. member_port = meta_mi2s_intf_conf[index].member_port[i];
  5572. if (!mi2s_intf_conf[member_port].msm_is_mi2s_master) {
  5573. mi2s_clk[member_port].clk_id =
  5574. mi2s_ebit_clk[member_port];
  5575. fmt = SND_SOC_DAIFMT_CBM_CFM;
  5576. }
  5577. ret = msm_meta_mi2s_set_sclk(substream, member_port, true);
  5578. if (ret < 0) {
  5579. dev_err(rtd->card->dev,
  5580. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  5581. __func__, ret);
  5582. goto clk_off;
  5583. }
  5584. meta_mi2s_intf_conf[index].clk_enable[i] = true;
  5585. if (i == 0) {
  5586. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  5587. if (ret < 0) {
  5588. pr_err("%s: set fmt cpu dai failed for META_MI2S (%d), err:%d\n",
  5589. __func__, index, ret);
  5590. goto clk_off;
  5591. }
  5592. }
  5593. if (pdata->mi2s_gpio_p[member_port])
  5594. msm_cdc_pinctrl_select_active_state(
  5595. pdata->mi2s_gpio_p[member_port]);
  5596. }
  5597. return 0;
  5598. clk_off:
  5599. for (i = 0; i < meta_mi2s_intf_conf[index].num_member_ports; i++) {
  5600. member_port = meta_mi2s_intf_conf[index].member_port[i];
  5601. if (pdata->mi2s_gpio_p[member_port])
  5602. msm_cdc_pinctrl_select_sleep_state(
  5603. pdata->mi2s_gpio_p[member_port]);
  5604. if (meta_mi2s_intf_conf[index].clk_enable[i]) {
  5605. msm_meta_mi2s_set_sclk(substream, member_port, false);
  5606. meta_mi2s_intf_conf[index].clk_enable[i] = false;
  5607. }
  5608. }
  5609. err:
  5610. return ret;
  5611. }
  5612. static void msm_meta_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  5613. {
  5614. int ret = 0;
  5615. int i = 0;
  5616. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5617. int index = rtd->cpu_dai->id;
  5618. int member_port = 0;
  5619. struct snd_soc_card *card = rtd->card;
  5620. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5621. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5622. substream->name, substream->stream);
  5623. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5624. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  5625. return;
  5626. }
  5627. for (i = 0; i < meta_mi2s_intf_conf[index].num_member_ports; i++) {
  5628. member_port = meta_mi2s_intf_conf[index].member_port[i];
  5629. if (pdata->mi2s_gpio_p[member_port])
  5630. msm_cdc_pinctrl_select_sleep_state(
  5631. pdata->mi2s_gpio_p[member_port]);
  5632. ret = msm_meta_mi2s_set_sclk(substream, member_port, false);
  5633. if (ret < 0)
  5634. pr_err("%s:clock disable failed for META MI2S (%d); ret=%d\n",
  5635. __func__, index, ret);
  5636. }
  5637. }
  5638. static int msm_spdif_set_clk(struct snd_pcm_substream *substream, bool enable)
  5639. {
  5640. int ret = 0;
  5641. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5642. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5643. int port_id = cpu_dai->id;
  5644. struct afe_clk_set clk_cfg;
  5645. clk_cfg.clk_set_minor_version = Q6AFE_LPASS_CLK_CONFIG_API_VERSION;
  5646. clk_cfg.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO;
  5647. clk_cfg.clk_root = Q6AFE_LPASS_CLK_ROOT_DEFAULT;
  5648. clk_cfg.enable = enable;
  5649. /* Set core clock (based on sample rate for RX, fixed for TX) */
  5650. switch (port_id) {
  5651. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  5652. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_OUTPUT_CORE;
  5653. /* rate x 2ch x 2_for_biphase_coding x 32_bits_per_sample */
  5654. clk_cfg.clk_freq_in_hz =
  5655. spdif_rx_cfg[PRIM_SPDIF_RX].sample_rate * 2 * 2 * 32;
  5656. break;
  5657. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  5658. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_SEC_SPDIF_OUTPUT_CORE;
  5659. clk_cfg.clk_freq_in_hz =
  5660. spdif_rx_cfg[SEC_SPDIF_RX].sample_rate * 2 * 2 * 32;
  5661. break;
  5662. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  5663. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_INPUT_CORE;
  5664. clk_cfg.clk_freq_in_hz = SPDIF_TX_CORE_CLK_163_P84_MHZ;
  5665. break;
  5666. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  5667. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_SEC_SPDIF_INPUT_CORE;
  5668. clk_cfg.clk_freq_in_hz = SPDIF_TX_CORE_CLK_163_P84_MHZ;
  5669. break;
  5670. }
  5671. ret = afe_set_lpass_clock_v2(port_id, &clk_cfg);
  5672. if (ret < 0) {
  5673. dev_err(rtd->card->dev,
  5674. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5675. __func__, port_id, ret);
  5676. goto err;
  5677. }
  5678. /* Set NPL clock for RX in addition */
  5679. switch (port_id) {
  5680. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  5681. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_PRI_SPDIF_OUTPUT_NPL;
  5682. ret = afe_set_lpass_clock_v2(port_id, &clk_cfg);
  5683. if (ret < 0) {
  5684. dev_err(rtd->card->dev,
  5685. "%s: afe NPL failed port 0x%x, err:%d\n",
  5686. __func__, port_id, ret);
  5687. goto err;
  5688. }
  5689. break;
  5690. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  5691. clk_cfg.clk_id = AFE_CLOCK_SET_CLOCK_ID_SEC_SPDIF_OUTPUT_NPL;
  5692. ret = afe_set_lpass_clock_v2(port_id, &clk_cfg);
  5693. if (ret < 0) {
  5694. dev_err(rtd->card->dev,
  5695. "%s: afe NPL failed for port 0x%x, err:%d\n",
  5696. __func__, port_id, ret);
  5697. goto err;
  5698. }
  5699. break;
  5700. }
  5701. if (enable) {
  5702. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  5703. clk_cfg.clk_freq_in_hz);
  5704. }
  5705. err:
  5706. return ret;
  5707. }
  5708. static int msm_spdif_snd_startup(struct snd_pcm_substream *substream)
  5709. {
  5710. int ret = 0;
  5711. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5712. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5713. int port_id = cpu_dai->id;
  5714. dev_dbg(rtd->card->dev,
  5715. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5716. __func__, substream->name, substream->stream,
  5717. cpu_dai->name, cpu_dai->id);
  5718. if (port_id < AFE_PORT_ID_PRIMARY_SPDIF_RX ||
  5719. port_id > AFE_PORT_ID_SECONDARY_SPDIF_TX) {
  5720. ret = -EINVAL;
  5721. dev_err(rtd->card->dev,
  5722. "%s: CPU DAI id (%d) out of range\n",
  5723. __func__, cpu_dai->id);
  5724. goto err;
  5725. }
  5726. ret = msm_spdif_set_clk(substream, true);
  5727. if (ret < 0) {
  5728. dev_err(rtd->card->dev,
  5729. "%s: afe lpass clock failed to enable (%d), err:%d\n",
  5730. __func__, port_id, ret);
  5731. }
  5732. err:
  5733. return ret;
  5734. }
  5735. static void msm_spdif_snd_shutdown(struct snd_pcm_substream *substream)
  5736. {
  5737. int ret;
  5738. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5739. int port_id = rtd->cpu_dai->id;
  5740. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5741. substream->name, substream->stream);
  5742. if (port_id < AFE_PORT_ID_PRIMARY_SPDIF_RX ||
  5743. port_id > AFE_PORT_ID_SECONDARY_SPDIF_TX) {
  5744. pr_err("%s:invalid SPDIF DAI(%d)\n", __func__, port_id);
  5745. return;
  5746. }
  5747. ret = msm_spdif_set_clk(substream, false);
  5748. if (ret < 0)
  5749. pr_err("%s:clock disable failed for SPDIF (%d); ret=%d\n",
  5750. __func__, port_id, ret);
  5751. }
  5752. static struct snd_soc_ops msm_mi2s_be_ops = {
  5753. .startup = msm_mi2s_snd_startup,
  5754. .hw_free = msm_mi2s_snd_hw_free,
  5755. .shutdown = msm_mi2s_snd_shutdown,
  5756. };
  5757. static struct snd_soc_ops msm_meta_mi2s_be_ops = {
  5758. .startup = msm_meta_mi2s_snd_startup,
  5759. .shutdown = msm_meta_mi2s_snd_shutdown,
  5760. };
  5761. static struct snd_soc_ops msm_auxpcm_be_ops = {
  5762. .startup = msm_snd_auxpcm_startup,
  5763. };
  5764. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  5765. .startup = msm_snd_cdc_dma_startup,
  5766. .hw_params = msm_snd_cdc_dma_hw_params,
  5767. };
  5768. static struct snd_soc_ops msm_be_ops = {
  5769. .hw_params = msm_snd_hw_params,
  5770. };
  5771. static struct snd_soc_ops msm_wcn_ops = {
  5772. .hw_params = msm_wcn_hw_params,
  5773. };
  5774. static struct snd_soc_ops msm_spdif_be_ops = {
  5775. .startup = msm_spdif_snd_startup,
  5776. .shutdown = msm_spdif_snd_shutdown,
  5777. };
  5778. /* Digital audio interface glue - connects codec <---> CPU */
  5779. static struct snd_soc_dai_link msm_common_dai_links[] = {
  5780. /* FrontEnd DAI Links */
  5781. {
  5782. .name = MSM_DAILINK_NAME(Media1),
  5783. .stream_name = "MultiMedia1",
  5784. .cpu_dai_name = "MultiMedia1",
  5785. .platform_name = "msm-pcm-dsp.0",
  5786. .dynamic = 1,
  5787. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5788. .dpcm_playback = 1,
  5789. .dpcm_capture = 1,
  5790. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5791. SND_SOC_DPCM_TRIGGER_POST},
  5792. .codec_dai_name = "snd-soc-dummy-dai",
  5793. .codec_name = "snd-soc-dummy",
  5794. .ignore_suspend = 1,
  5795. /* this dainlink has playback support */
  5796. .ignore_pmdown_time = 1,
  5797. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  5798. },
  5799. {
  5800. .name = MSM_DAILINK_NAME(Media2),
  5801. .stream_name = "MultiMedia2",
  5802. .cpu_dai_name = "MultiMedia2",
  5803. .platform_name = "msm-pcm-dsp.0",
  5804. .dynamic = 1,
  5805. .dpcm_playback = 1,
  5806. .dpcm_capture = 1,
  5807. .codec_dai_name = "snd-soc-dummy-dai",
  5808. .codec_name = "snd-soc-dummy",
  5809. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5810. SND_SOC_DPCM_TRIGGER_POST},
  5811. .ignore_suspend = 1,
  5812. /* this dainlink has playback support */
  5813. .ignore_pmdown_time = 1,
  5814. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  5815. },
  5816. {
  5817. .name = "VoiceMMode1",
  5818. .stream_name = "VoiceMMode1",
  5819. .cpu_dai_name = "VoiceMMode1",
  5820. .platform_name = "msm-pcm-voice",
  5821. .dynamic = 1,
  5822. .dpcm_playback = 1,
  5823. .dpcm_capture = 1,
  5824. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5825. SND_SOC_DPCM_TRIGGER_POST},
  5826. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5827. .ignore_suspend = 1,
  5828. .ignore_pmdown_time = 1,
  5829. .codec_dai_name = "snd-soc-dummy-dai",
  5830. .codec_name = "snd-soc-dummy",
  5831. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  5832. },
  5833. {
  5834. .name = "MSM VoIP",
  5835. .stream_name = "VoIP",
  5836. .cpu_dai_name = "VoIP",
  5837. .platform_name = "msm-voip-dsp",
  5838. .dynamic = 1,
  5839. .dpcm_playback = 1,
  5840. .dpcm_capture = 1,
  5841. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5842. SND_SOC_DPCM_TRIGGER_POST},
  5843. .codec_dai_name = "snd-soc-dummy-dai",
  5844. .codec_name = "snd-soc-dummy",
  5845. .ignore_suspend = 1,
  5846. /* this dainlink has playback support */
  5847. .ignore_pmdown_time = 1,
  5848. .id = MSM_FRONTEND_DAI_VOIP,
  5849. },
  5850. {
  5851. .name = MSM_DAILINK_NAME(ULL),
  5852. .stream_name = "MultiMedia3",
  5853. .cpu_dai_name = "MultiMedia3",
  5854. .platform_name = "msm-pcm-dsp.2",
  5855. .dynamic = 1,
  5856. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5857. .dpcm_playback = 1,
  5858. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5859. SND_SOC_DPCM_TRIGGER_POST},
  5860. .codec_dai_name = "snd-soc-dummy-dai",
  5861. .codec_name = "snd-soc-dummy",
  5862. .ignore_suspend = 1,
  5863. /* this dainlink has playback support */
  5864. .ignore_pmdown_time = 1,
  5865. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  5866. },
  5867. /* Hostless PCM purpose */
  5868. {
  5869. .name = "SLIMBUS_0 Hostless",
  5870. .stream_name = "SLIMBUS_0 Hostless",
  5871. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  5872. .platform_name = "msm-pcm-hostless",
  5873. .dynamic = 1,
  5874. .dpcm_playback = 1,
  5875. .dpcm_capture = 1,
  5876. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5877. SND_SOC_DPCM_TRIGGER_POST},
  5878. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5879. .ignore_suspend = 1,
  5880. /* this dailink has playback support */
  5881. .ignore_pmdown_time = 1,
  5882. .codec_dai_name = "snd-soc-dummy-dai",
  5883. .codec_name = "snd-soc-dummy",
  5884. },
  5885. {
  5886. .name = "MSM AFE-PCM RX",
  5887. .stream_name = "AFE-PROXY RX",
  5888. .cpu_dai_name = "msm-dai-q6-dev.241",
  5889. .codec_name = "msm-stub-codec.1",
  5890. .codec_dai_name = "msm-stub-rx",
  5891. .platform_name = "msm-pcm-afe",
  5892. .dpcm_playback = 1,
  5893. .ignore_suspend = 1,
  5894. /* this dainlink has playback support */
  5895. .ignore_pmdown_time = 1,
  5896. },
  5897. {
  5898. .name = "MSM AFE-PCM TX",
  5899. .stream_name = "AFE-PROXY TX",
  5900. .cpu_dai_name = "msm-dai-q6-dev.240",
  5901. .codec_name = "msm-stub-codec.1",
  5902. .codec_dai_name = "msm-stub-tx",
  5903. .platform_name = "msm-pcm-afe",
  5904. .dpcm_capture = 1,
  5905. .ignore_suspend = 1,
  5906. },
  5907. {
  5908. .name = MSM_DAILINK_NAME(Compress1),
  5909. .stream_name = "Compress1",
  5910. .cpu_dai_name = "MultiMedia4",
  5911. .platform_name = "msm-compress-dsp",
  5912. .dynamic = 1,
  5913. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  5914. .dpcm_playback = 1,
  5915. .dpcm_capture = 1,
  5916. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5917. SND_SOC_DPCM_TRIGGER_POST},
  5918. .codec_dai_name = "snd-soc-dummy-dai",
  5919. .codec_name = "snd-soc-dummy",
  5920. .ignore_suspend = 1,
  5921. .ignore_pmdown_time = 1,
  5922. /* this dainlink has playback support */
  5923. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  5924. },
  5925. {
  5926. .name = "AUXPCM Hostless",
  5927. .stream_name = "AUXPCM Hostless",
  5928. .cpu_dai_name = "AUXPCM_HOSTLESS",
  5929. .platform_name = "msm-pcm-hostless",
  5930. .dynamic = 1,
  5931. .dpcm_playback = 1,
  5932. .dpcm_capture = 1,
  5933. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5934. SND_SOC_DPCM_TRIGGER_POST},
  5935. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5936. .ignore_suspend = 1,
  5937. /* this dainlink has playback support */
  5938. .ignore_pmdown_time = 1,
  5939. .codec_dai_name = "snd-soc-dummy-dai",
  5940. .codec_name = "snd-soc-dummy",
  5941. },
  5942. {
  5943. .name = "SLIMBUS_1 Hostless",
  5944. .stream_name = "SLIMBUS_1 Hostless",
  5945. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  5946. .platform_name = "msm-pcm-hostless",
  5947. .dynamic = 1,
  5948. .dpcm_playback = 1,
  5949. .dpcm_capture = 1,
  5950. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5951. SND_SOC_DPCM_TRIGGER_POST},
  5952. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5953. .ignore_suspend = 1,
  5954. /* this dailink has playback support */
  5955. .ignore_pmdown_time = 1,
  5956. .codec_dai_name = "snd-soc-dummy-dai",
  5957. .codec_name = "snd-soc-dummy",
  5958. },
  5959. {
  5960. .name = "SLIMBUS_3 Hostless",
  5961. .stream_name = "SLIMBUS_3 Hostless",
  5962. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  5963. .platform_name = "msm-pcm-hostless",
  5964. .dynamic = 1,
  5965. .dpcm_playback = 1,
  5966. .dpcm_capture = 1,
  5967. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5968. SND_SOC_DPCM_TRIGGER_POST},
  5969. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5970. .ignore_suspend = 1,
  5971. /* this dailink has playback support */
  5972. .ignore_pmdown_time = 1,
  5973. .codec_dai_name = "snd-soc-dummy-dai",
  5974. .codec_name = "snd-soc-dummy",
  5975. },
  5976. {
  5977. .name = "SLIMBUS_4 Hostless",
  5978. .stream_name = "SLIMBUS_4 Hostless",
  5979. .cpu_dai_name = "SLIMBUS4_HOSTLESS",
  5980. .platform_name = "msm-pcm-hostless",
  5981. .dynamic = 1,
  5982. .dpcm_playback = 1,
  5983. .dpcm_capture = 1,
  5984. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5985. SND_SOC_DPCM_TRIGGER_POST},
  5986. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5987. .ignore_suspend = 1,
  5988. /* this dailink has playback support */
  5989. .ignore_pmdown_time = 1,
  5990. .codec_dai_name = "snd-soc-dummy-dai",
  5991. .codec_name = "snd-soc-dummy",
  5992. },
  5993. {
  5994. .name = MSM_DAILINK_NAME(LowLatency),
  5995. .stream_name = "MultiMedia5",
  5996. .cpu_dai_name = "MultiMedia5",
  5997. .platform_name = "msm-pcm-dsp.1",
  5998. .dynamic = 1,
  5999. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6000. .dpcm_playback = 1,
  6001. .dpcm_capture = 1,
  6002. .codec_dai_name = "snd-soc-dummy-dai",
  6003. .codec_name = "snd-soc-dummy",
  6004. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6005. SND_SOC_DPCM_TRIGGER_POST},
  6006. .ignore_suspend = 1,
  6007. /* this dainlink has playback support */
  6008. .ignore_pmdown_time = 1,
  6009. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  6010. .ops = &msm_fe_qos_ops,
  6011. },
  6012. {
  6013. .name = "Listen 1 Audio Service",
  6014. .stream_name = "Listen 1 Audio Service",
  6015. .cpu_dai_name = "LSM1",
  6016. .platform_name = "msm-lsm-client",
  6017. .dynamic = 1,
  6018. .dpcm_capture = 1,
  6019. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6020. SND_SOC_DPCM_TRIGGER_POST },
  6021. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6022. .ignore_suspend = 1,
  6023. .codec_dai_name = "snd-soc-dummy-dai",
  6024. .codec_name = "snd-soc-dummy",
  6025. .id = MSM_FRONTEND_DAI_LSM1,
  6026. },
  6027. /* Multiple Tunnel instances */
  6028. {
  6029. .name = MSM_DAILINK_NAME(Compress2),
  6030. .stream_name = "Compress2",
  6031. .cpu_dai_name = "MultiMedia7",
  6032. .platform_name = "msm-compress-dsp",
  6033. .dynamic = 1,
  6034. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6035. .dpcm_playback = 1,
  6036. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6037. SND_SOC_DPCM_TRIGGER_POST},
  6038. .codec_dai_name = "snd-soc-dummy-dai",
  6039. .codec_name = "snd-soc-dummy",
  6040. .ignore_suspend = 1,
  6041. .ignore_pmdown_time = 1,
  6042. /* this dainlink has playback support */
  6043. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  6044. },
  6045. {
  6046. .name = MSM_DAILINK_NAME(MultiMedia10),
  6047. .stream_name = "MultiMedia10",
  6048. .cpu_dai_name = "MultiMedia10",
  6049. .platform_name = "msm-pcm-dsp.1",
  6050. .dynamic = 1,
  6051. .dpcm_playback = 1,
  6052. .dpcm_capture = 1,
  6053. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6054. SND_SOC_DPCM_TRIGGER_POST},
  6055. .codec_dai_name = "snd-soc-dummy-dai",
  6056. .codec_name = "snd-soc-dummy",
  6057. .ignore_suspend = 1,
  6058. .ignore_pmdown_time = 1,
  6059. /* this dainlink has playback support */
  6060. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  6061. },
  6062. {
  6063. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  6064. .stream_name = "MM_NOIRQ",
  6065. .cpu_dai_name = "MultiMedia8",
  6066. .platform_name = "msm-pcm-dsp-noirq",
  6067. .dynamic = 1,
  6068. .dpcm_playback = 1,
  6069. .dpcm_capture = 1,
  6070. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6071. SND_SOC_DPCM_TRIGGER_POST},
  6072. .codec_dai_name = "snd-soc-dummy-dai",
  6073. .codec_name = "snd-soc-dummy",
  6074. .ignore_suspend = 1,
  6075. .ignore_pmdown_time = 1,
  6076. /* this dainlink has playback support */
  6077. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  6078. .ops = &msm_fe_qos_ops,
  6079. },
  6080. /* HDMI Hostless */
  6081. {
  6082. .name = "HDMI_RX_HOSTLESS",
  6083. .stream_name = "HDMI_RX_HOSTLESS",
  6084. .cpu_dai_name = "HDMI_HOSTLESS",
  6085. .platform_name = "msm-pcm-hostless",
  6086. .dynamic = 1,
  6087. .dpcm_playback = 1,
  6088. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6089. SND_SOC_DPCM_TRIGGER_POST},
  6090. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6091. .ignore_suspend = 1,
  6092. .ignore_pmdown_time = 1,
  6093. .codec_dai_name = "snd-soc-dummy-dai",
  6094. .codec_name = "snd-soc-dummy",
  6095. },
  6096. {
  6097. .name = "VoiceMMode2",
  6098. .stream_name = "VoiceMMode2",
  6099. .cpu_dai_name = "VoiceMMode2",
  6100. .platform_name = "msm-pcm-voice",
  6101. .dynamic = 1,
  6102. .dpcm_playback = 1,
  6103. .dpcm_capture = 1,
  6104. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6105. SND_SOC_DPCM_TRIGGER_POST},
  6106. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6107. .ignore_suspend = 1,
  6108. .ignore_pmdown_time = 1,
  6109. .codec_dai_name = "snd-soc-dummy-dai",
  6110. .codec_name = "snd-soc-dummy",
  6111. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  6112. },
  6113. /* LSM FE */
  6114. {
  6115. .name = "Listen 2 Audio Service",
  6116. .stream_name = "Listen 2 Audio Service",
  6117. .cpu_dai_name = "LSM2",
  6118. .platform_name = "msm-lsm-client",
  6119. .dynamic = 1,
  6120. .dpcm_capture = 1,
  6121. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6122. SND_SOC_DPCM_TRIGGER_POST },
  6123. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6124. .ignore_suspend = 1,
  6125. .codec_dai_name = "snd-soc-dummy-dai",
  6126. .codec_name = "snd-soc-dummy",
  6127. .id = MSM_FRONTEND_DAI_LSM2,
  6128. },
  6129. {
  6130. .name = "Listen 3 Audio Service",
  6131. .stream_name = "Listen 3 Audio Service",
  6132. .cpu_dai_name = "LSM3",
  6133. .platform_name = "msm-lsm-client",
  6134. .dynamic = 1,
  6135. .dpcm_capture = 1,
  6136. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6137. SND_SOC_DPCM_TRIGGER_POST },
  6138. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6139. .ignore_suspend = 1,
  6140. .codec_dai_name = "snd-soc-dummy-dai",
  6141. .codec_name = "snd-soc-dummy",
  6142. .id = MSM_FRONTEND_DAI_LSM3,
  6143. },
  6144. {
  6145. .name = "Listen 4 Audio Service",
  6146. .stream_name = "Listen 4 Audio Service",
  6147. .cpu_dai_name = "LSM4",
  6148. .platform_name = "msm-lsm-client",
  6149. .dynamic = 1,
  6150. .dpcm_capture = 1,
  6151. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6152. SND_SOC_DPCM_TRIGGER_POST },
  6153. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6154. .ignore_suspend = 1,
  6155. .codec_dai_name = "snd-soc-dummy-dai",
  6156. .codec_name = "snd-soc-dummy",
  6157. .id = MSM_FRONTEND_DAI_LSM4,
  6158. },
  6159. {
  6160. .name = "Listen 5 Audio Service",
  6161. .stream_name = "Listen 5 Audio Service",
  6162. .cpu_dai_name = "LSM5",
  6163. .platform_name = "msm-lsm-client",
  6164. .dynamic = 1,
  6165. .dpcm_capture = 1,
  6166. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6167. SND_SOC_DPCM_TRIGGER_POST },
  6168. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6169. .ignore_suspend = 1,
  6170. .codec_dai_name = "snd-soc-dummy-dai",
  6171. .codec_name = "snd-soc-dummy",
  6172. .id = MSM_FRONTEND_DAI_LSM5,
  6173. },
  6174. {
  6175. .name = "Listen 6 Audio Service",
  6176. .stream_name = "Listen 6 Audio Service",
  6177. .cpu_dai_name = "LSM6",
  6178. .platform_name = "msm-lsm-client",
  6179. .dynamic = 1,
  6180. .dpcm_capture = 1,
  6181. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6182. SND_SOC_DPCM_TRIGGER_POST },
  6183. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6184. .ignore_suspend = 1,
  6185. .codec_dai_name = "snd-soc-dummy-dai",
  6186. .codec_name = "snd-soc-dummy",
  6187. .id = MSM_FRONTEND_DAI_LSM6,
  6188. },
  6189. {
  6190. .name = "Listen 7 Audio Service",
  6191. .stream_name = "Listen 7 Audio Service",
  6192. .cpu_dai_name = "LSM7",
  6193. .platform_name = "msm-lsm-client",
  6194. .dynamic = 1,
  6195. .dpcm_capture = 1,
  6196. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6197. SND_SOC_DPCM_TRIGGER_POST },
  6198. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6199. .ignore_suspend = 1,
  6200. .codec_dai_name = "snd-soc-dummy-dai",
  6201. .codec_name = "snd-soc-dummy",
  6202. .id = MSM_FRONTEND_DAI_LSM7,
  6203. },
  6204. {
  6205. .name = "Listen 8 Audio Service",
  6206. .stream_name = "Listen 8 Audio Service",
  6207. .cpu_dai_name = "LSM8",
  6208. .platform_name = "msm-lsm-client",
  6209. .dynamic = 1,
  6210. .dpcm_capture = 1,
  6211. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  6212. SND_SOC_DPCM_TRIGGER_POST },
  6213. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6214. .ignore_suspend = 1,
  6215. .codec_dai_name = "snd-soc-dummy-dai",
  6216. .codec_name = "snd-soc-dummy",
  6217. .id = MSM_FRONTEND_DAI_LSM8,
  6218. },
  6219. {
  6220. .name = MSM_DAILINK_NAME(Media9),
  6221. .stream_name = "MultiMedia9",
  6222. .cpu_dai_name = "MultiMedia9",
  6223. .platform_name = "msm-pcm-dsp.0",
  6224. .dynamic = 1,
  6225. .dpcm_playback = 1,
  6226. .dpcm_capture = 1,
  6227. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6228. SND_SOC_DPCM_TRIGGER_POST},
  6229. .codec_dai_name = "snd-soc-dummy-dai",
  6230. .codec_name = "snd-soc-dummy",
  6231. .ignore_suspend = 1,
  6232. /* this dainlink has playback support */
  6233. .ignore_pmdown_time = 1,
  6234. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  6235. },
  6236. {
  6237. .name = MSM_DAILINK_NAME(Compress4),
  6238. .stream_name = "Compress4",
  6239. .cpu_dai_name = "MultiMedia11",
  6240. .platform_name = "msm-compress-dsp",
  6241. .dynamic = 1,
  6242. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6243. .dpcm_playback = 1,
  6244. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6245. SND_SOC_DPCM_TRIGGER_POST},
  6246. .codec_dai_name = "snd-soc-dummy-dai",
  6247. .codec_name = "snd-soc-dummy",
  6248. .ignore_suspend = 1,
  6249. .ignore_pmdown_time = 1,
  6250. /* this dainlink has playback support */
  6251. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  6252. },
  6253. {
  6254. .name = MSM_DAILINK_NAME(Compress5),
  6255. .stream_name = "Compress5",
  6256. .cpu_dai_name = "MultiMedia12",
  6257. .platform_name = "msm-compress-dsp",
  6258. .dynamic = 1,
  6259. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6260. .dpcm_playback = 1,
  6261. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6262. SND_SOC_DPCM_TRIGGER_POST},
  6263. .codec_dai_name = "snd-soc-dummy-dai",
  6264. .codec_name = "snd-soc-dummy",
  6265. .ignore_suspend = 1,
  6266. .ignore_pmdown_time = 1,
  6267. /* this dainlink has playback support */
  6268. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  6269. },
  6270. {
  6271. .name = MSM_DAILINK_NAME(Compress6),
  6272. .stream_name = "Compress6",
  6273. .cpu_dai_name = "MultiMedia13",
  6274. .platform_name = "msm-compress-dsp",
  6275. .dynamic = 1,
  6276. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6277. .dpcm_playback = 1,
  6278. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6279. SND_SOC_DPCM_TRIGGER_POST},
  6280. .codec_dai_name = "snd-soc-dummy-dai",
  6281. .codec_name = "snd-soc-dummy",
  6282. .ignore_suspend = 1,
  6283. .ignore_pmdown_time = 1,
  6284. /* this dainlink has playback support */
  6285. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  6286. },
  6287. {
  6288. .name = MSM_DAILINK_NAME(Compress7),
  6289. .stream_name = "Compress7",
  6290. .cpu_dai_name = "MultiMedia14",
  6291. .platform_name = "msm-compress-dsp",
  6292. .dynamic = 1,
  6293. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6294. .dpcm_playback = 1,
  6295. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6296. SND_SOC_DPCM_TRIGGER_POST},
  6297. .codec_dai_name = "snd-soc-dummy-dai",
  6298. .codec_name = "snd-soc-dummy",
  6299. .ignore_suspend = 1,
  6300. .ignore_pmdown_time = 1,
  6301. /* this dainlink has playback support */
  6302. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  6303. },
  6304. {
  6305. .name = MSM_DAILINK_NAME(Compress8),
  6306. .stream_name = "Compress8",
  6307. .cpu_dai_name = "MultiMedia15",
  6308. .platform_name = "msm-compress-dsp",
  6309. .dynamic = 1,
  6310. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6311. .dpcm_playback = 1,
  6312. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6313. SND_SOC_DPCM_TRIGGER_POST},
  6314. .codec_dai_name = "snd-soc-dummy-dai",
  6315. .codec_name = "snd-soc-dummy",
  6316. .ignore_suspend = 1,
  6317. .ignore_pmdown_time = 1,
  6318. /* this dainlink has playback support */
  6319. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  6320. },
  6321. {
  6322. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  6323. .stream_name = "MM_NOIRQ_2",
  6324. .cpu_dai_name = "MultiMedia16",
  6325. .platform_name = "msm-pcm-dsp-noirq",
  6326. .dynamic = 1,
  6327. .dpcm_playback = 1,
  6328. .dpcm_capture = 1,
  6329. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6330. SND_SOC_DPCM_TRIGGER_POST},
  6331. .codec_dai_name = "snd-soc-dummy-dai",
  6332. .codec_name = "snd-soc-dummy",
  6333. .ignore_suspend = 1,
  6334. .ignore_pmdown_time = 1,
  6335. /* this dainlink has playback support */
  6336. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  6337. },
  6338. {
  6339. .name = "SLIMBUS_8 Hostless",
  6340. .stream_name = "SLIMBUS8_HOSTLESS Capture",
  6341. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  6342. .platform_name = "msm-pcm-hostless",
  6343. .dynamic = 1,
  6344. .dpcm_capture = 1,
  6345. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6346. SND_SOC_DPCM_TRIGGER_POST},
  6347. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6348. .ignore_suspend = 1,
  6349. .codec_dai_name = "snd-soc-dummy-dai",
  6350. .codec_name = "snd-soc-dummy",
  6351. },
  6352. /* Hostless PCM purpose */
  6353. {
  6354. .name = "CDC_DMA Hostless",
  6355. .stream_name = "CDC_DMA Hostless",
  6356. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  6357. .platform_name = "msm-pcm-hostless",
  6358. .dynamic = 1,
  6359. .dpcm_playback = 1,
  6360. .dpcm_capture = 1,
  6361. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6362. SND_SOC_DPCM_TRIGGER_POST},
  6363. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6364. .ignore_suspend = 1,
  6365. /* this dailink has playback support */
  6366. .ignore_pmdown_time = 1,
  6367. .codec_dai_name = "snd-soc-dummy-dai",
  6368. .codec_name = "snd-soc-dummy",
  6369. },
  6370. };
  6371. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  6372. {
  6373. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  6374. .stream_name = "WSA CDC DMA0 Capture",
  6375. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  6376. .platform_name = "msm-pcm-hostless",
  6377. .codec_name = "bolero_codec",
  6378. .codec_dai_name = "wsa_macro_vifeedback",
  6379. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  6380. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6381. .ignore_suspend = 1,
  6382. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6383. .ops = &msm_cdc_dma_be_ops,
  6384. },
  6385. };
  6386. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  6387. {
  6388. .name = MSM_DAILINK_NAME(ASM Loopback),
  6389. .stream_name = "MultiMedia6",
  6390. .cpu_dai_name = "MultiMedia6",
  6391. .platform_name = "msm-pcm-loopback",
  6392. .dynamic = 1,
  6393. .dpcm_playback = 1,
  6394. .dpcm_capture = 1,
  6395. .codec_dai_name = "snd-soc-dummy-dai",
  6396. .codec_name = "snd-soc-dummy",
  6397. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6398. SND_SOC_DPCM_TRIGGER_POST},
  6399. .ignore_suspend = 1,
  6400. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6401. .ignore_pmdown_time = 1,
  6402. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  6403. },
  6404. {
  6405. .name = "USB Audio Hostless",
  6406. .stream_name = "USB Audio Hostless",
  6407. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  6408. .platform_name = "msm-pcm-hostless",
  6409. .dynamic = 1,
  6410. .dpcm_playback = 1,
  6411. .dpcm_capture = 1,
  6412. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6413. SND_SOC_DPCM_TRIGGER_POST},
  6414. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6415. .ignore_suspend = 1,
  6416. .ignore_pmdown_time = 1,
  6417. .codec_dai_name = "snd-soc-dummy-dai",
  6418. .codec_name = "snd-soc-dummy",
  6419. },
  6420. {
  6421. .name = "SLIMBUS_7 Hostless",
  6422. .stream_name = "SLIMBUS_7 Hostless",
  6423. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  6424. .platform_name = "msm-pcm-hostless",
  6425. .dynamic = 1,
  6426. .dpcm_capture = 1,
  6427. .dpcm_playback = 1,
  6428. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6429. SND_SOC_DPCM_TRIGGER_POST},
  6430. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6431. .ignore_suspend = 1,
  6432. .ignore_pmdown_time = 1,
  6433. .codec_dai_name = "snd-soc-dummy-dai",
  6434. .codec_name = "snd-soc-dummy",
  6435. },
  6436. {
  6437. .name = MSM_DAILINK_NAME(Compr Capture2),
  6438. .stream_name = "Compr Capture2",
  6439. .cpu_dai_name = "MultiMedia18",
  6440. .platform_name = "msm-compress-dsp",
  6441. .dynamic = 1,
  6442. .dpcm_capture = 1,
  6443. .codec_dai_name = "snd-soc-dummy-dai",
  6444. .codec_name = "snd-soc-dummy",
  6445. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6446. SND_SOC_DPCM_TRIGGER_POST},
  6447. .ignore_pmdown_time = 1,
  6448. .id = MSM_FRONTEND_DAI_MULTIMEDIA18,
  6449. },
  6450. {
  6451. .name = MSM_DAILINK_NAME(Transcode Loopback Playback),
  6452. .stream_name = "Transcode Loopback Playback",
  6453. .cpu_dai_name = "MultiMedia26",
  6454. .platform_name = "msm-transcode-loopback",
  6455. .dynamic = 1,
  6456. .dpcm_playback = 1,
  6457. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6458. SND_SOC_DPCM_TRIGGER_POST},
  6459. .codec_dai_name = "snd-soc-dummy-dai",
  6460. .codec_name = "snd-soc-dummy",
  6461. .ignore_suspend = 1,
  6462. .ignore_pmdown_time = 1,
  6463. /* this dailink has playback support */
  6464. .id = MSM_FRONTEND_DAI_MULTIMEDIA26,
  6465. },
  6466. {
  6467. .name = MSM_DAILINK_NAME(Transcode Loopback Capture),
  6468. .stream_name = "Transcode Loopback Capture",
  6469. .cpu_dai_name = "MultiMedia27",
  6470. .platform_name = "msm-transcode-loopback",
  6471. .dynamic = 1,
  6472. .dpcm_capture = 1,
  6473. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6474. SND_SOC_DPCM_TRIGGER_POST},
  6475. .codec_dai_name = "snd-soc-dummy-dai",
  6476. .codec_name = "snd-soc-dummy",
  6477. .ignore_suspend = 1,
  6478. .ignore_pmdown_time = 1,
  6479. .id = MSM_FRONTEND_DAI_MULTIMEDIA27,
  6480. },
  6481. {
  6482. .name = MSM_DAILINK_NAME(Compr Capture3),
  6483. .stream_name = "Compr Capture3",
  6484. .cpu_dai_name = "MultiMedia19",
  6485. .platform_name = "msm-compress-dsp",
  6486. .dynamic = 1,
  6487. .dpcm_capture = 1,
  6488. .codec_dai_name = "snd-soc-dummy-dai",
  6489. .codec_name = "snd-soc-dummy",
  6490. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6491. SND_SOC_DPCM_TRIGGER_POST},
  6492. .ignore_pmdown_time = 1,
  6493. .id = MSM_FRONTEND_DAI_MULTIMEDIA19,
  6494. },
  6495. {
  6496. .name = MSM_DAILINK_NAME(Compr Capture4),
  6497. .stream_name = "Compr Capture4",
  6498. .cpu_dai_name = "MultiMedia28",
  6499. .platform_name = "msm-compress-dsp",
  6500. .dynamic = 1,
  6501. .dpcm_capture = 1,
  6502. .codec_dai_name = "snd-soc-dummy-dai",
  6503. .codec_name = "snd-soc-dummy",
  6504. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6505. SND_SOC_DPCM_TRIGGER_POST},
  6506. .ignore_pmdown_time = 1,
  6507. .id = MSM_FRONTEND_DAI_MULTIMEDIA28,
  6508. },
  6509. {
  6510. .name = MSM_DAILINK_NAME(Compr Capture5),
  6511. .stream_name = "Compr Capture5",
  6512. .cpu_dai_name = "MultiMedia29",
  6513. .platform_name = "msm-compress-dsp",
  6514. .dynamic = 1,
  6515. .dpcm_capture = 1,
  6516. .codec_dai_name = "snd-soc-dummy-dai",
  6517. .codec_name = "snd-soc-dummy",
  6518. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6519. SND_SOC_DPCM_TRIGGER_POST},
  6520. .ignore_pmdown_time = 1,
  6521. .id = MSM_FRONTEND_DAI_MULTIMEDIA29,
  6522. },
  6523. {
  6524. .name = MSM_DAILINK_NAME(Compr Capture6),
  6525. .stream_name = "Compr Capture6",
  6526. .cpu_dai_name = "MultiMedia30",
  6527. .platform_name = "msm-compress-dsp",
  6528. .dynamic = 1,
  6529. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  6530. .dpcm_capture = 1,
  6531. .codec_dai_name = "snd-soc-dummy-dai",
  6532. .codec_name = "snd-soc-dummy",
  6533. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6534. SND_SOC_DPCM_TRIGGER_POST},
  6535. .ignore_pmdown_time = 1,
  6536. .id = MSM_FRONTEND_DAI_MULTIMEDIA30,
  6537. },
  6538. };
  6539. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  6540. /* Backend AFE DAI Links */
  6541. {
  6542. .name = LPASS_BE_AFE_PCM_RX,
  6543. .stream_name = "AFE Playback",
  6544. .cpu_dai_name = "msm-dai-q6-dev.224",
  6545. .platform_name = "msm-pcm-routing",
  6546. .codec_name = "msm-stub-codec.1",
  6547. .codec_dai_name = "msm-stub-rx",
  6548. .no_pcm = 1,
  6549. .dpcm_playback = 1,
  6550. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  6551. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6552. /* this dainlink has playback support */
  6553. .ignore_pmdown_time = 1,
  6554. .ignore_suspend = 1,
  6555. },
  6556. {
  6557. .name = LPASS_BE_AFE_PCM_TX,
  6558. .stream_name = "AFE Capture",
  6559. .cpu_dai_name = "msm-dai-q6-dev.225",
  6560. .platform_name = "msm-pcm-routing",
  6561. .codec_name = "msm-stub-codec.1",
  6562. .codec_dai_name = "msm-stub-tx",
  6563. .no_pcm = 1,
  6564. .dpcm_capture = 1,
  6565. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  6566. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6567. .ignore_suspend = 1,
  6568. },
  6569. /* Incall Record Uplink BACK END DAI Link */
  6570. {
  6571. .name = LPASS_BE_INCALL_RECORD_TX,
  6572. .stream_name = "Voice Uplink Capture",
  6573. .cpu_dai_name = "msm-dai-q6-dev.32772",
  6574. .platform_name = "msm-pcm-routing",
  6575. .codec_name = "msm-stub-codec.1",
  6576. .codec_dai_name = "msm-stub-tx",
  6577. .no_pcm = 1,
  6578. .dpcm_capture = 1,
  6579. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  6580. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6581. .ignore_suspend = 1,
  6582. },
  6583. /* Incall Record Downlink BACK END DAI Link */
  6584. {
  6585. .name = LPASS_BE_INCALL_RECORD_RX,
  6586. .stream_name = "Voice Downlink Capture",
  6587. .cpu_dai_name = "msm-dai-q6-dev.32771",
  6588. .platform_name = "msm-pcm-routing",
  6589. .codec_name = "msm-stub-codec.1",
  6590. .codec_dai_name = "msm-stub-tx",
  6591. .no_pcm = 1,
  6592. .dpcm_capture = 1,
  6593. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  6594. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6595. .ignore_suspend = 1,
  6596. },
  6597. /* Incall Music BACK END DAI Link */
  6598. {
  6599. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  6600. .stream_name = "Voice Farend Playback",
  6601. .cpu_dai_name = "msm-dai-q6-dev.32773",
  6602. .platform_name = "msm-pcm-routing",
  6603. .codec_name = "msm-stub-codec.1",
  6604. .codec_dai_name = "msm-stub-rx",
  6605. .no_pcm = 1,
  6606. .dpcm_playback = 1,
  6607. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  6608. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6609. .ignore_suspend = 1,
  6610. .ignore_pmdown_time = 1,
  6611. },
  6612. /* Incall Music 2 BACK END DAI Link */
  6613. {
  6614. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  6615. .stream_name = "Voice2 Farend Playback",
  6616. .cpu_dai_name = "msm-dai-q6-dev.32770",
  6617. .platform_name = "msm-pcm-routing",
  6618. .codec_name = "msm-stub-codec.1",
  6619. .codec_dai_name = "msm-stub-rx",
  6620. .no_pcm = 1,
  6621. .dpcm_playback = 1,
  6622. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  6623. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6624. .ignore_suspend = 1,
  6625. .ignore_pmdown_time = 1,
  6626. },
  6627. {
  6628. .name = LPASS_BE_USB_AUDIO_RX,
  6629. .stream_name = "USB Audio Playback",
  6630. .cpu_dai_name = "msm-dai-q6-dev.28672",
  6631. .platform_name = "msm-pcm-routing",
  6632. .codec_name = "msm-stub-codec.1",
  6633. .codec_dai_name = "msm-stub-rx",
  6634. .no_pcm = 1,
  6635. .dpcm_playback = 1,
  6636. .id = MSM_BACKEND_DAI_USB_RX,
  6637. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6638. .ignore_pmdown_time = 1,
  6639. .ignore_suspend = 1,
  6640. },
  6641. {
  6642. .name = LPASS_BE_USB_AUDIO_TX,
  6643. .stream_name = "USB Audio Capture",
  6644. .cpu_dai_name = "msm-dai-q6-dev.28673",
  6645. .platform_name = "msm-pcm-routing",
  6646. .codec_name = "msm-stub-codec.1",
  6647. .codec_dai_name = "msm-stub-tx",
  6648. .no_pcm = 1,
  6649. .dpcm_capture = 1,
  6650. .id = MSM_BACKEND_DAI_USB_TX,
  6651. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6652. .ignore_suspend = 1,
  6653. },
  6654. {
  6655. .name = LPASS_BE_PRI_TDM_RX_0,
  6656. .stream_name = "Primary TDM0 Playback",
  6657. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  6658. .platform_name = "msm-pcm-routing",
  6659. .codec_name = "msm-stub-codec.1",
  6660. .codec_dai_name = "msm-stub-rx",
  6661. .no_pcm = 1,
  6662. .dpcm_playback = 1,
  6663. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  6664. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6665. .ops = &qcs405_tdm_be_ops,
  6666. .ignore_suspend = 1,
  6667. .ignore_pmdown_time = 1,
  6668. },
  6669. {
  6670. .name = LPASS_BE_PRI_TDM_TX_0,
  6671. .stream_name = "Primary TDM0 Capture",
  6672. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  6673. .platform_name = "msm-pcm-routing",
  6674. .codec_name = "msm-stub-codec.1",
  6675. .codec_dai_name = "msm-stub-tx",
  6676. .no_pcm = 1,
  6677. .dpcm_capture = 1,
  6678. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  6679. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6680. .ops = &qcs405_tdm_be_ops,
  6681. .ignore_suspend = 1,
  6682. },
  6683. {
  6684. .name = LPASS_BE_SEC_TDM_RX_0,
  6685. .stream_name = "Secondary TDM0 Playback",
  6686. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  6687. .platform_name = "msm-pcm-routing",
  6688. .codec_name = "msm-stub-codec.1",
  6689. .codec_dai_name = "msm-stub-rx",
  6690. .no_pcm = 1,
  6691. .dpcm_playback = 1,
  6692. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  6693. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6694. .ops = &qcs405_tdm_be_ops,
  6695. .ignore_suspend = 1,
  6696. .ignore_pmdown_time = 1,
  6697. },
  6698. {
  6699. .name = LPASS_BE_SEC_TDM_TX_0,
  6700. .stream_name = "Secondary TDM0 Capture",
  6701. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  6702. .platform_name = "msm-pcm-routing",
  6703. .codec_name = "msm-stub-codec.1",
  6704. .codec_dai_name = "msm-stub-tx",
  6705. .no_pcm = 1,
  6706. .dpcm_capture = 1,
  6707. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  6708. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6709. .ops = &qcs405_tdm_be_ops,
  6710. .ignore_suspend = 1,
  6711. },
  6712. {
  6713. .name = LPASS_BE_TERT_TDM_RX_0,
  6714. .stream_name = "Tertiary TDM0 Playback",
  6715. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  6716. .platform_name = "msm-pcm-routing",
  6717. .codec_name = "msm-stub-codec.1",
  6718. .codec_dai_name = "msm-stub-rx",
  6719. .no_pcm = 1,
  6720. .dpcm_playback = 1,
  6721. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  6722. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6723. .ops = &qcs405_tdm_be_ops,
  6724. .ignore_suspend = 1,
  6725. .ignore_pmdown_time = 1,
  6726. },
  6727. {
  6728. .name = LPASS_BE_TERT_TDM_TX_0,
  6729. .stream_name = "Tertiary TDM0 Capture",
  6730. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  6731. .platform_name = "msm-pcm-routing",
  6732. .codec_name = "msm-stub-codec.1",
  6733. .codec_dai_name = "msm-stub-tx",
  6734. .no_pcm = 1,
  6735. .dpcm_capture = 1,
  6736. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  6737. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6738. .ops = &qcs405_tdm_be_ops,
  6739. .ignore_suspend = 1,
  6740. },
  6741. {
  6742. .name = LPASS_BE_QUAT_TDM_RX_0,
  6743. .stream_name = "Quaternary TDM0 Playback",
  6744. .cpu_dai_name = "msm-dai-q6-tdm.36912",
  6745. .platform_name = "msm-pcm-routing",
  6746. .codec_name = "msm-stub-codec.1",
  6747. .codec_dai_name = "msm-stub-rx",
  6748. .no_pcm = 1,
  6749. .dpcm_playback = 1,
  6750. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  6751. .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
  6752. .ops = &qcs405_tdm_be_ops,
  6753. .ignore_suspend = 1,
  6754. .ignore_pmdown_time = 1,
  6755. },
  6756. {
  6757. .name = LPASS_BE_QUAT_TDM_TX_0,
  6758. .stream_name = "Quaternary TDM0 Capture",
  6759. .cpu_dai_name = "msm-dai-q6-tdm.36913",
  6760. .platform_name = "msm-pcm-routing",
  6761. .codec_name = "msm-stub-codec.1",
  6762. .codec_dai_name = "msm-stub-tx",
  6763. .no_pcm = 1,
  6764. .dpcm_capture = 1,
  6765. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  6766. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6767. .ops = &qcs405_tdm_be_ops,
  6768. .ignore_suspend = 1,
  6769. },
  6770. {
  6771. .name = LPASS_BE_QUIN_TDM_RX_0,
  6772. .stream_name = "Quinary TDM0 Playback",
  6773. .cpu_dai_name = "msm-dai-q6-tdm.36928",
  6774. .platform_name = "msm-pcm-routing",
  6775. .codec_name = "msm-stub-codec.1",
  6776. .codec_dai_name = "msm-stub-rx",
  6777. .no_pcm = 1,
  6778. .dpcm_playback = 1,
  6779. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  6780. .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
  6781. .ops = &qcs405_tdm_be_ops,
  6782. .ignore_suspend = 1,
  6783. .ignore_pmdown_time = 1,
  6784. },
  6785. {
  6786. .name = LPASS_BE_QUIN_TDM_TX_0,
  6787. .stream_name = "Quinary TDM0 Capture",
  6788. .cpu_dai_name = "msm-dai-q6-tdm.36929",
  6789. .platform_name = "msm-pcm-routing",
  6790. .codec_name = "msm-stub-codec.1",
  6791. .codec_dai_name = "msm-stub-tx",
  6792. .no_pcm = 1,
  6793. .dpcm_capture = 1,
  6794. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  6795. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6796. .ops = &qcs405_tdm_be_ops,
  6797. .ignore_suspend = 1,
  6798. },
  6799. };
  6800. static struct snd_soc_dai_link msm_tasha_be_dai_links[] = {
  6801. {
  6802. .name = LPASS_BE_SLIMBUS_0_RX,
  6803. .stream_name = "Slimbus Playback",
  6804. .cpu_dai_name = "msm-dai-q6-dev.16384",
  6805. .platform_name = "msm-pcm-routing",
  6806. .codec_name = "tasha_codec",
  6807. .codec_dai_name = "tasha_mix_rx1",
  6808. .no_pcm = 1,
  6809. .dpcm_playback = 1,
  6810. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  6811. .init = &msm_audrx_init,
  6812. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6813. /* this dainlink has playback support */
  6814. .ignore_pmdown_time = 1,
  6815. .ignore_suspend = 1,
  6816. .ops = &msm_be_ops,
  6817. },
  6818. {
  6819. .name = LPASS_BE_SLIMBUS_0_TX,
  6820. .stream_name = "Slimbus Capture",
  6821. .cpu_dai_name = "msm-dai-q6-dev.16385",
  6822. .platform_name = "msm-pcm-routing",
  6823. .codec_name = "tasha_codec",
  6824. .codec_dai_name = "tasha_tx1",
  6825. .no_pcm = 1,
  6826. .dpcm_capture = 1,
  6827. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  6828. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6829. .ignore_suspend = 1,
  6830. .ops = &msm_be_ops,
  6831. },
  6832. {
  6833. .name = LPASS_BE_SLIMBUS_1_RX,
  6834. .stream_name = "Slimbus1 Playback",
  6835. .cpu_dai_name = "msm-dai-q6-dev.16386",
  6836. .platform_name = "msm-pcm-routing",
  6837. .codec_name = "tasha_codec",
  6838. .codec_dai_name = "tasha_mix_rx1",
  6839. .no_pcm = 1,
  6840. .dpcm_playback = 1,
  6841. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  6842. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6843. .ops = &msm_be_ops,
  6844. /* dai link has playback support */
  6845. .ignore_pmdown_time = 1,
  6846. .ignore_suspend = 1,
  6847. },
  6848. {
  6849. .name = LPASS_BE_SLIMBUS_1_TX,
  6850. .stream_name = "Slimbus1 Capture",
  6851. .cpu_dai_name = "msm-dai-q6-dev.16387",
  6852. .platform_name = "msm-pcm-routing",
  6853. .codec_name = "tasha_codec",
  6854. .codec_dai_name = "tasha_tx3",
  6855. .no_pcm = 1,
  6856. .dpcm_capture = 1,
  6857. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  6858. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6859. .ops = &msm_be_ops,
  6860. .ignore_suspend = 1,
  6861. },
  6862. {
  6863. .name = LPASS_BE_SLIMBUS_2_RX,
  6864. .stream_name = "Slimbus2 Playback",
  6865. .cpu_dai_name = "msm-dai-q6-dev.16388",
  6866. .platform_name = "msm-pcm-routing",
  6867. .codec_name = "tasha_codec",
  6868. .codec_dai_name = "tasha_rx2",
  6869. .no_pcm = 1,
  6870. .dpcm_playback = 1,
  6871. .id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
  6872. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6873. .ops = &msm_be_ops,
  6874. .ignore_pmdown_time = 1,
  6875. .ignore_suspend = 1,
  6876. },
  6877. {
  6878. .name = LPASS_BE_SLIMBUS_3_RX,
  6879. .stream_name = "Slimbus3 Playback",
  6880. .cpu_dai_name = "msm-dai-q6-dev.16390",
  6881. .platform_name = "msm-pcm-routing",
  6882. .codec_name = "tasha_codec",
  6883. .codec_dai_name = "tasha_mix_rx1",
  6884. .no_pcm = 1,
  6885. .dpcm_playback = 1,
  6886. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  6887. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6888. .ops = &msm_be_ops,
  6889. /* dai link has playback support */
  6890. .ignore_pmdown_time = 1,
  6891. .ignore_suspend = 1,
  6892. },
  6893. {
  6894. .name = LPASS_BE_SLIMBUS_3_TX,
  6895. .stream_name = "Slimbus3 Capture",
  6896. .cpu_dai_name = "msm-dai-q6-dev.16391",
  6897. .platform_name = "msm-pcm-routing",
  6898. .codec_name = "tasha_codec",
  6899. .codec_dai_name = "tasha_tx1",
  6900. .no_pcm = 1,
  6901. .dpcm_capture = 1,
  6902. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  6903. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6904. .ops = &msm_be_ops,
  6905. .ignore_suspend = 1,
  6906. },
  6907. {
  6908. .name = LPASS_BE_SLIMBUS_4_RX,
  6909. .stream_name = "Slimbus4 Playback",
  6910. .cpu_dai_name = "msm-dai-q6-dev.16392",
  6911. .platform_name = "msm-pcm-routing",
  6912. .codec_name = "tasha_codec",
  6913. .codec_dai_name = "tasha_mix_rx1",
  6914. .no_pcm = 1,
  6915. .dpcm_playback = 1,
  6916. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  6917. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6918. .ops = &msm_be_ops,
  6919. /* dai link has playback support */
  6920. .ignore_pmdown_time = 1,
  6921. .ignore_suspend = 1,
  6922. },
  6923. {
  6924. .name = LPASS_BE_SLIMBUS_5_RX,
  6925. .stream_name = "Slimbus5 Playback",
  6926. .cpu_dai_name = "msm-dai-q6-dev.16394",
  6927. .platform_name = "msm-pcm-routing",
  6928. .codec_name = "tasha_codec",
  6929. .codec_dai_name = "tasha_rx3",
  6930. .no_pcm = 1,
  6931. .dpcm_playback = 1,
  6932. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  6933. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6934. .ops = &msm_be_ops,
  6935. /* dai link has playback support */
  6936. .ignore_pmdown_time = 1,
  6937. .ignore_suspend = 1,
  6938. },
  6939. {
  6940. .name = LPASS_BE_SLIMBUS_6_RX,
  6941. .stream_name = "Slimbus6 Playback",
  6942. .cpu_dai_name = "msm-dai-q6-dev.16396",
  6943. .platform_name = "msm-pcm-routing",
  6944. .codec_name = "tasha_codec",
  6945. .codec_dai_name = "tasha_rx4",
  6946. .no_pcm = 1,
  6947. .dpcm_playback = 1,
  6948. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  6949. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6950. .ops = &msm_be_ops,
  6951. /* dai link has playback support */
  6952. .ignore_pmdown_time = 1,
  6953. .ignore_suspend = 1,
  6954. },
  6955. /* Slimbus VI Recording */
  6956. {
  6957. .name = LPASS_BE_SLIMBUS_TX_VI,
  6958. .stream_name = "Slimbus4 Capture",
  6959. .cpu_dai_name = "msm-dai-q6-dev.16393",
  6960. .platform_name = "msm-pcm-routing",
  6961. .codec_name = "tasha_codec",
  6962. .codec_dai_name = "tasha_vifeedback",
  6963. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  6964. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6965. .ops = &msm_be_ops,
  6966. .ignore_suspend = 1,
  6967. .no_pcm = 1,
  6968. .dpcm_capture = 1,
  6969. .ignore_pmdown_time = 1,
  6970. },
  6971. };
  6972. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  6973. {
  6974. .name = LPASS_BE_SLIMBUS_7_RX,
  6975. .stream_name = "Slimbus7 Playback",
  6976. .cpu_dai_name = "msm-dai-q6-dev.16398",
  6977. .platform_name = "msm-pcm-routing",
  6978. .codec_name = "btfmslim_slave",
  6979. /* BT codec driver determines capabilities based on
  6980. * dai name, bt codecdai name should always contains
  6981. * supported usecase information
  6982. */
  6983. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  6984. .no_pcm = 1,
  6985. .dpcm_playback = 1,
  6986. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  6987. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6988. .ops = &msm_wcn_ops,
  6989. /* dai link has playback support */
  6990. .ignore_pmdown_time = 1,
  6991. .ignore_suspend = 1,
  6992. },
  6993. {
  6994. .name = LPASS_BE_SLIMBUS_7_TX,
  6995. .stream_name = "Slimbus7 Capture",
  6996. .cpu_dai_name = "msm-dai-q6-dev.16399",
  6997. .platform_name = "msm-pcm-routing",
  6998. .codec_name = "btfmslim_slave",
  6999. .codec_dai_name = "btfm_bt_sco_slim_tx",
  7000. .no_pcm = 1,
  7001. .dpcm_capture = 1,
  7002. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  7003. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7004. .ops = &msm_wcn_ops,
  7005. .ignore_suspend = 1,
  7006. },
  7007. {
  7008. .name = LPASS_BE_SLIMBUS_8_TX,
  7009. .stream_name = "Slimbus8 Capture",
  7010. .cpu_dai_name = "msm-dai-q6-dev.16401",
  7011. .platform_name = "msm-pcm-routing",
  7012. .codec_name = "btfmslim_slave",
  7013. .codec_dai_name = "btfm_fm_slim_tx",
  7014. .no_pcm = 1,
  7015. .dpcm_capture = 1,
  7016. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  7017. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7018. .init = &msm_wcn_init,
  7019. .ops = &msm_wcn_ops,
  7020. .ignore_suspend = 1,
  7021. },
  7022. {
  7023. .name = LPASS_BE_SLIMBUS_9_TX,
  7024. .stream_name = "Slimbus9 Capture",
  7025. .cpu_dai_name = "msm-dai-q6-dev.16403",
  7026. .platform_name = "msm-pcm-routing",
  7027. .codec_name = "btfmslim_slave",
  7028. .codec_dai_name = "btfm_bt_split_a2dp_slim_tx",
  7029. .no_pcm = 1,
  7030. .dpcm_capture = 1,
  7031. .id = MSM_BACKEND_DAI_SLIMBUS_9_TX,
  7032. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7033. .ops = &msm_wcn_ops,
  7034. .ignore_suspend = 1,
  7035. },
  7036. };
  7037. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  7038. {
  7039. .name = LPASS_BE_PRI_MI2S_RX,
  7040. .stream_name = "Primary MI2S Playback",
  7041. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  7042. .platform_name = "msm-pcm-routing",
  7043. .codec_name = "msm-stub-codec.1",
  7044. .codec_dai_name = "msm-stub-rx",
  7045. .no_pcm = 1,
  7046. .dpcm_playback = 1,
  7047. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  7048. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7049. .ops = &msm_mi2s_be_ops,
  7050. .ignore_suspend = 1,
  7051. .ignore_pmdown_time = 1,
  7052. },
  7053. {
  7054. .name = LPASS_BE_PRI_MI2S_TX,
  7055. .stream_name = "Primary MI2S Capture",
  7056. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  7057. .platform_name = "msm-pcm-routing",
  7058. .codec_name = "msm-stub-codec.1",
  7059. .codec_dai_name = "msm-stub-tx",
  7060. .no_pcm = 1,
  7061. .dpcm_capture = 1,
  7062. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  7063. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7064. .ops = &msm_mi2s_be_ops,
  7065. .ignore_suspend = 1,
  7066. },
  7067. {
  7068. .name = LPASS_BE_SEC_MI2S_RX,
  7069. .stream_name = "Secondary MI2S Playback",
  7070. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  7071. .platform_name = "msm-pcm-routing",
  7072. .codec_name = "msm-stub-codec.1",
  7073. .codec_dai_name = "msm-stub-rx",
  7074. .no_pcm = 1,
  7075. .dpcm_playback = 1,
  7076. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  7077. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7078. .ops = &msm_mi2s_be_ops,
  7079. .ignore_suspend = 1,
  7080. .ignore_pmdown_time = 1,
  7081. },
  7082. {
  7083. .name = LPASS_BE_SEC_MI2S_TX,
  7084. .stream_name = "Secondary MI2S Capture",
  7085. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  7086. .platform_name = "msm-pcm-routing",
  7087. .codec_name = "msm-stub-codec.1",
  7088. .codec_dai_name = "msm-stub-tx",
  7089. .no_pcm = 1,
  7090. .dpcm_capture = 1,
  7091. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  7092. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7093. .ops = &msm_mi2s_be_ops,
  7094. .ignore_suspend = 1,
  7095. },
  7096. {
  7097. .name = LPASS_BE_TERT_MI2S_RX,
  7098. .stream_name = "Tertiary MI2S Playback",
  7099. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  7100. .platform_name = "msm-pcm-routing",
  7101. .codec_name = "msm-stub-codec.1",
  7102. .codec_dai_name = "msm-stub-rx",
  7103. .no_pcm = 1,
  7104. .dpcm_playback = 1,
  7105. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  7106. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7107. .ops = &msm_mi2s_be_ops,
  7108. .ignore_suspend = 1,
  7109. .ignore_pmdown_time = 1,
  7110. },
  7111. {
  7112. .name = LPASS_BE_TERT_MI2S_TX,
  7113. .stream_name = "Tertiary MI2S Capture",
  7114. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  7115. .platform_name = "msm-pcm-routing",
  7116. .codec_name = "msm-stub-codec.1",
  7117. .codec_dai_name = "msm-stub-tx",
  7118. .no_pcm = 1,
  7119. .dpcm_capture = 1,
  7120. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  7121. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7122. .ops = &msm_mi2s_be_ops,
  7123. .ignore_suspend = 1,
  7124. },
  7125. {
  7126. .name = LPASS_BE_QUAT_MI2S_RX,
  7127. .stream_name = "Quaternary MI2S Playback",
  7128. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  7129. .platform_name = "msm-pcm-routing",
  7130. .codec_name = "msm-stub-codec.1",
  7131. .codec_dai_name = "msm-stub-rx",
  7132. .no_pcm = 1,
  7133. .dpcm_playback = 1,
  7134. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  7135. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7136. .ops = &msm_mi2s_be_ops,
  7137. .ignore_suspend = 1,
  7138. .ignore_pmdown_time = 1,
  7139. },
  7140. {
  7141. .name = LPASS_BE_QUAT_MI2S_TX,
  7142. .stream_name = "Quaternary MI2S Capture",
  7143. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  7144. .platform_name = "msm-pcm-routing",
  7145. .codec_name = "msm-stub-codec.1",
  7146. .codec_dai_name = "msm-stub-tx",
  7147. .no_pcm = 1,
  7148. .dpcm_capture = 1,
  7149. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  7150. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7151. .ops = &msm_mi2s_be_ops,
  7152. .ignore_suspend = 1,
  7153. },
  7154. {
  7155. .name = LPASS_BE_QUIN_MI2S_RX,
  7156. .stream_name = "Quinary MI2S Playback",
  7157. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  7158. .platform_name = "msm-pcm-routing",
  7159. .codec_name = "msm-stub-codec.1",
  7160. .codec_dai_name = "msm-stub-rx",
  7161. .no_pcm = 1,
  7162. .dpcm_playback = 1,
  7163. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  7164. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7165. .ops = &msm_mi2s_be_ops,
  7166. .ignore_suspend = 1,
  7167. .ignore_pmdown_time = 1,
  7168. },
  7169. {
  7170. .name = LPASS_BE_QUIN_MI2S_TX,
  7171. .stream_name = "Quinary MI2S Capture",
  7172. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  7173. .platform_name = "msm-pcm-routing",
  7174. .codec_name = "msm-stub-codec.1",
  7175. .codec_dai_name = "msm-stub-tx",
  7176. .no_pcm = 1,
  7177. .dpcm_capture = 1,
  7178. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  7179. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7180. .ops = &msm_mi2s_be_ops,
  7181. .ignore_suspend = 1,
  7182. },
  7183. };
  7184. static struct snd_soc_dai_link msm_meta_mi2s_be_dai_links[] = {
  7185. {
  7186. .name = LPASS_BE_PRI_META_MI2S_RX,
  7187. .stream_name = "Primary META MI2S Playback",
  7188. .cpu_dai_name = "msm-dai-q6-meta-mi2s.4864",
  7189. .platform_name = "msm-pcm-routing",
  7190. .codec_name = "msm-stub-codec.1",
  7191. .codec_dai_name = "msm-stub-rx",
  7192. .no_pcm = 1,
  7193. .dpcm_playback = 1,
  7194. .id = MSM_BACKEND_DAI_PRI_META_MI2S_RX,
  7195. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7196. .ops = &msm_meta_mi2s_be_ops,
  7197. .ignore_suspend = 1,
  7198. .ignore_pmdown_time = 1,
  7199. },
  7200. {
  7201. .name = LPASS_BE_SEC_META_MI2S_RX,
  7202. .stream_name = "Secondary META MI2S Playback",
  7203. .cpu_dai_name = "msm-dai-q6-meta-mi2s.4866",
  7204. .platform_name = "msm-pcm-routing",
  7205. .codec_name = "msm-stub-codec.1",
  7206. .codec_dai_name = "msm-stub-rx",
  7207. .no_pcm = 1,
  7208. .dpcm_playback = 1,
  7209. .id = MSM_BACKEND_DAI_SEC_META_MI2S_RX,
  7210. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7211. .ops = &msm_meta_mi2s_be_ops,
  7212. .ignore_suspend = 1,
  7213. .ignore_pmdown_time = 1,
  7214. },
  7215. };
  7216. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  7217. /* Primary AUX PCM Backend DAI Links */
  7218. {
  7219. .name = LPASS_BE_AUXPCM_RX,
  7220. .stream_name = "AUX PCM Playback",
  7221. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  7222. .platform_name = "msm-pcm-routing",
  7223. .codec_name = "msm-stub-codec.1",
  7224. .codec_dai_name = "msm-stub-rx",
  7225. .no_pcm = 1,
  7226. .dpcm_playback = 1,
  7227. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  7228. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7229. .ops = &msm_auxpcm_be_ops,
  7230. .ignore_pmdown_time = 1,
  7231. .ignore_suspend = 1,
  7232. },
  7233. {
  7234. .name = LPASS_BE_AUXPCM_TX,
  7235. .stream_name = "AUX PCM Capture",
  7236. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  7237. .platform_name = "msm-pcm-routing",
  7238. .codec_name = "msm-stub-codec.1",
  7239. .codec_dai_name = "msm-stub-tx",
  7240. .no_pcm = 1,
  7241. .dpcm_capture = 1,
  7242. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  7243. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7244. .ops = &msm_auxpcm_be_ops,
  7245. .ignore_suspend = 1,
  7246. },
  7247. /* Secondary AUX PCM Backend DAI Links */
  7248. {
  7249. .name = LPASS_BE_SEC_AUXPCM_RX,
  7250. .stream_name = "Sec AUX PCM Playback",
  7251. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  7252. .platform_name = "msm-pcm-routing",
  7253. .codec_name = "msm-stub-codec.1",
  7254. .codec_dai_name = "msm-stub-rx",
  7255. .no_pcm = 1,
  7256. .dpcm_playback = 1,
  7257. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  7258. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7259. .ops = &msm_auxpcm_be_ops,
  7260. .ignore_pmdown_time = 1,
  7261. .ignore_suspend = 1,
  7262. },
  7263. {
  7264. .name = LPASS_BE_SEC_AUXPCM_TX,
  7265. .stream_name = "Sec AUX PCM Capture",
  7266. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  7267. .platform_name = "msm-pcm-routing",
  7268. .codec_name = "msm-stub-codec.1",
  7269. .codec_dai_name = "msm-stub-tx",
  7270. .no_pcm = 1,
  7271. .dpcm_capture = 1,
  7272. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  7273. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7274. .ops = &msm_auxpcm_be_ops,
  7275. .ignore_suspend = 1,
  7276. },
  7277. /* Tertiary AUX PCM Backend DAI Links */
  7278. {
  7279. .name = LPASS_BE_TERT_AUXPCM_RX,
  7280. .stream_name = "Tert AUX PCM Playback",
  7281. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  7282. .platform_name = "msm-pcm-routing",
  7283. .codec_name = "msm-stub-codec.1",
  7284. .codec_dai_name = "msm-stub-rx",
  7285. .no_pcm = 1,
  7286. .dpcm_playback = 1,
  7287. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  7288. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7289. .ops = &msm_auxpcm_be_ops,
  7290. .ignore_suspend = 1,
  7291. },
  7292. {
  7293. .name = LPASS_BE_TERT_AUXPCM_TX,
  7294. .stream_name = "Tert AUX PCM Capture",
  7295. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  7296. .platform_name = "msm-pcm-routing",
  7297. .codec_name = "msm-stub-codec.1",
  7298. .codec_dai_name = "msm-stub-tx",
  7299. .no_pcm = 1,
  7300. .dpcm_capture = 1,
  7301. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  7302. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7303. .ops = &msm_auxpcm_be_ops,
  7304. .ignore_suspend = 1,
  7305. },
  7306. /* Quaternary AUX PCM Backend DAI Links */
  7307. {
  7308. .name = LPASS_BE_QUAT_AUXPCM_RX,
  7309. .stream_name = "Quat AUX PCM Playback",
  7310. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  7311. .platform_name = "msm-pcm-routing",
  7312. .codec_name = "msm-stub-codec.1",
  7313. .codec_dai_name = "msm-stub-rx",
  7314. .no_pcm = 1,
  7315. .dpcm_playback = 1,
  7316. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  7317. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7318. .ops = &msm_auxpcm_be_ops,
  7319. .ignore_pmdown_time = 1,
  7320. .ignore_suspend = 1,
  7321. },
  7322. {
  7323. .name = LPASS_BE_QUAT_AUXPCM_TX,
  7324. .stream_name = "Quat AUX PCM Capture",
  7325. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  7326. .platform_name = "msm-pcm-routing",
  7327. .codec_name = "msm-stub-codec.1",
  7328. .codec_dai_name = "msm-stub-tx",
  7329. .no_pcm = 1,
  7330. .dpcm_capture = 1,
  7331. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  7332. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7333. .ops = &msm_auxpcm_be_ops,
  7334. .ignore_suspend = 1,
  7335. },
  7336. /* Quinary AUX PCM Backend DAI Links */
  7337. {
  7338. .name = LPASS_BE_QUIN_AUXPCM_RX,
  7339. .stream_name = "Quin AUX PCM Playback",
  7340. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  7341. .platform_name = "msm-pcm-routing",
  7342. .codec_name = "msm-stub-codec.1",
  7343. .codec_dai_name = "msm-stub-rx",
  7344. .no_pcm = 1,
  7345. .dpcm_playback = 1,
  7346. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  7347. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7348. .ops = &msm_auxpcm_be_ops,
  7349. .ignore_pmdown_time = 1,
  7350. .ignore_suspend = 1,
  7351. },
  7352. {
  7353. .name = LPASS_BE_QUIN_AUXPCM_TX,
  7354. .stream_name = "Quin AUX PCM Capture",
  7355. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  7356. .platform_name = "msm-pcm-routing",
  7357. .codec_name = "msm-stub-codec.1",
  7358. .codec_dai_name = "msm-stub-tx",
  7359. .no_pcm = 1,
  7360. .dpcm_capture = 1,
  7361. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  7362. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7363. .ops = &msm_auxpcm_be_ops,
  7364. .ignore_suspend = 1,
  7365. },
  7366. };
  7367. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  7368. /* WSA CDC DMA Backend DAI Links */
  7369. {
  7370. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  7371. .stream_name = "WSA CDC DMA0 Playback",
  7372. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  7373. .platform_name = "msm-pcm-routing",
  7374. .codec_name = "bolero_codec",
  7375. .codec_dai_name = "wsa_macro_rx1",
  7376. .no_pcm = 1,
  7377. .dpcm_playback = 1,
  7378. .init = &msm_wsa_cdc_dma_init,
  7379. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  7380. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7381. .ignore_pmdown_time = 1,
  7382. .ignore_suspend = 1,
  7383. .ops = &msm_cdc_dma_be_ops,
  7384. },
  7385. {
  7386. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  7387. .stream_name = "WSA CDC DMA1 Playback",
  7388. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  7389. .platform_name = "msm-pcm-routing",
  7390. .codec_name = "bolero_codec",
  7391. .codec_dai_name = "wsa_macro_rx_mix",
  7392. .no_pcm = 1,
  7393. .dpcm_playback = 1,
  7394. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  7395. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7396. .ignore_pmdown_time = 1,
  7397. .ignore_suspend = 1,
  7398. .ops = &msm_cdc_dma_be_ops,
  7399. },
  7400. {
  7401. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  7402. .stream_name = "WSA CDC DMA1 Capture",
  7403. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  7404. .platform_name = "msm-pcm-routing",
  7405. .codec_name = "bolero_codec",
  7406. .codec_dai_name = "wsa_macro_echo",
  7407. .no_pcm = 1,
  7408. .dpcm_capture = 1,
  7409. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  7410. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7411. .ignore_suspend = 1,
  7412. .ops = &msm_cdc_dma_be_ops,
  7413. },
  7414. };
  7415. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  7416. {
  7417. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  7418. .stream_name = "VA CDC DMA0 Capture",
  7419. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  7420. .platform_name = "msm-pcm-routing",
  7421. .codec_name = "bolero_codec",
  7422. .codec_dai_name = "va_macro_tx1",
  7423. .no_pcm = 1,
  7424. .dpcm_capture = 1,
  7425. .init = &msm_va_cdc_dma_init,
  7426. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  7427. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7428. .ignore_suspend = 1,
  7429. .ops = &msm_cdc_dma_be_ops,
  7430. },
  7431. {
  7432. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  7433. .stream_name = "VA CDC DMA1 Capture",
  7434. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  7435. .platform_name = "msm-pcm-routing",
  7436. .codec_name = "bolero_codec",
  7437. .codec_dai_name = "va_macro_tx2",
  7438. .no_pcm = 1,
  7439. .dpcm_capture = 1,
  7440. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  7441. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7442. .ignore_suspend = 1,
  7443. .ops = &msm_cdc_dma_be_ops,
  7444. },
  7445. };
  7446. static struct snd_soc_dai_link msm_spdif_be_dai_links[] = {
  7447. {
  7448. .name = LPASS_BE_PRI_SPDIF_RX,
  7449. .stream_name = "Primary SPDIF Playback",
  7450. .cpu_dai_name = "msm-dai-q6-spdif.20480",
  7451. .platform_name = "msm-pcm-routing",
  7452. .codec_name = "msm-stub-codec.1",
  7453. .codec_dai_name = "msm-stub-rx",
  7454. .no_pcm = 1,
  7455. .dpcm_playback = 1,
  7456. .id = MSM_BACKEND_DAI_PRI_SPDIF_RX,
  7457. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7458. .ops = &msm_spdif_be_ops,
  7459. .ignore_suspend = 1,
  7460. .ignore_pmdown_time = 1,
  7461. },
  7462. {
  7463. .name = LPASS_BE_PRI_SPDIF_TX,
  7464. .stream_name = "Primary SPDIF Capture",
  7465. .cpu_dai_name = "msm-dai-q6-spdif.20481",
  7466. .platform_name = "msm-pcm-routing",
  7467. .codec_name = "msm-stub-codec.1",
  7468. .codec_dai_name = "msm-stub-tx",
  7469. .no_pcm = 1,
  7470. .dpcm_capture = 1,
  7471. .id = MSM_BACKEND_DAI_PRI_SPDIF_TX,
  7472. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7473. .ops = &msm_spdif_be_ops,
  7474. .ignore_suspend = 1,
  7475. },
  7476. {
  7477. .name = LPASS_BE_SEC_SPDIF_RX,
  7478. .stream_name = "Secondary SPDIF Playback",
  7479. .cpu_dai_name = "msm-dai-q6-spdif.20482",
  7480. .platform_name = "msm-pcm-routing",
  7481. .codec_name = "msm-stub-codec.1",
  7482. .codec_dai_name = "msm-stub-rx",
  7483. .no_pcm = 1,
  7484. .dpcm_playback = 1,
  7485. .id = MSM_BACKEND_DAI_SEC_SPDIF_RX,
  7486. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7487. .ops = &msm_spdif_be_ops,
  7488. .ignore_suspend = 1,
  7489. .ignore_pmdown_time = 1,
  7490. },
  7491. {
  7492. .name = LPASS_BE_SEC_SPDIF_TX,
  7493. .stream_name = "Secondary SPDIF Capture",
  7494. .cpu_dai_name = "msm-dai-q6-spdif.20483",
  7495. .platform_name = "msm-pcm-routing",
  7496. .codec_name = "msm-stub-codec.1",
  7497. .codec_dai_name = "msm-stub-tx",
  7498. .no_pcm = 1,
  7499. .dpcm_capture = 1,
  7500. .id = MSM_BACKEND_DAI_SEC_SPDIF_TX,
  7501. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7502. .ops = &msm_spdif_be_ops,
  7503. .ignore_suspend = 1,
  7504. },
  7505. };
  7506. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  7507. {
  7508. .name = LPASS_BE_AFE_LOOPBACK_TX,
  7509. .stream_name = "AFE Loopback Capture",
  7510. .cpu_dai_name = "msm-dai-q6-dev.24577",
  7511. .platform_name = "msm-pcm-routing",
  7512. .codec_name = "msm-stub-codec.1",
  7513. .codec_dai_name = "msm-stub-tx",
  7514. .no_pcm = 1,
  7515. .dpcm_capture = 1,
  7516. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  7517. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7518. .ignore_pmdown_time = 1,
  7519. .ignore_suspend = 1,
  7520. },
  7521. };
  7522. static struct snd_soc_dai_link msm_qcs405_dai_links[
  7523. ARRAY_SIZE(msm_common_dai_links) +
  7524. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  7525. ARRAY_SIZE(msm_common_be_dai_links) +
  7526. ARRAY_SIZE(msm_tasha_be_dai_links) +
  7527. ARRAY_SIZE(msm_wcn_be_dai_links) +
  7528. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  7529. ARRAY_SIZE(msm_meta_mi2s_be_dai_links) +
  7530. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  7531. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  7532. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  7533. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  7534. ARRAY_SIZE(msm_spdif_be_dai_links) +
  7535. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link)];
  7536. static int msm_snd_card_tasha_late_probe(struct snd_soc_card *card)
  7537. {
  7538. int ret = 0;
  7539. ret = audio_notifier_register("qcs405", AUDIO_NOTIFIER_ADSP_DOMAIN,
  7540. &service_nb);
  7541. if (ret < 0)
  7542. pr_err("%s: Audio notifier register failed ret = %d\n",
  7543. __func__, ret);
  7544. return ret;
  7545. }
  7546. static int msm_snd_vad_cfg_put(struct snd_kcontrol *kcontrol,
  7547. struct snd_ctl_elem_value *ucontrol)
  7548. {
  7549. int ret = 0;
  7550. int port_id;
  7551. uint32_t vad_enable = ucontrol->value.integer.value[0];
  7552. uint32_t preroll_config = ucontrol->value.integer.value[1];
  7553. uint32_t vad_intf = ucontrol->value.integer.value[2];
  7554. if ((preroll_config < 0) || (preroll_config > 1000) ||
  7555. (vad_enable < 0) || (vad_enable > 1) ||
  7556. (vad_intf > MSM_BACKEND_DAI_MAX)) {
  7557. pr_err("%s: Invalid arguments\n", __func__);
  7558. ret = -EINVAL;
  7559. goto done;
  7560. }
  7561. pr_debug("%s: vad_enable=%d preroll_config=%d vad_intf=%d\n", __func__,
  7562. vad_enable, preroll_config, vad_intf);
  7563. ret = msm_island_vad_get_portid_from_beid(vad_intf, &port_id);
  7564. if (ret) {
  7565. pr_err("%s: Invalid vad interface\n", __func__);
  7566. goto done;
  7567. }
  7568. afe_set_vad_cfg(vad_enable, preroll_config, port_id);
  7569. done:
  7570. return ret;
  7571. }
  7572. static int msm_snd_card_codec_late_probe(struct snd_soc_card *card)
  7573. {
  7574. int ret = 0;
  7575. uint32_t tasha_codec = 0;
  7576. ret = afe_cal_init_hwdep(card);
  7577. if (ret) {
  7578. dev_err(card->dev, "afe cal hwdep init failed (%d)\n", ret);
  7579. ret = 0;
  7580. }
  7581. /* tasha late probe when it is present */
  7582. ret = of_property_read_u32(card->dev->of_node, "qcom,tasha-codec",
  7583. &tasha_codec);
  7584. if (ret) {
  7585. dev_err(card->dev, "%s: No DT match tasha codec\n", __func__);
  7586. ret = 0;
  7587. } else {
  7588. if (tasha_codec) {
  7589. ret = msm_snd_card_tasha_late_probe(card);
  7590. if (ret)
  7591. dev_err(card->dev, "%s: tasha late probe err\n",
  7592. __func__);
  7593. }
  7594. }
  7595. return ret;
  7596. }
  7597. struct snd_soc_card snd_soc_card_qcs405_msm = {
  7598. .name = "qcs405-snd-card",
  7599. .controls = msm_snd_controls,
  7600. .num_controls = ARRAY_SIZE(msm_snd_controls),
  7601. .late_probe = msm_snd_card_codec_late_probe,
  7602. };
  7603. static int msm_populate_dai_link_component_of_node(
  7604. struct snd_soc_card *card)
  7605. {
  7606. int i, index, ret = 0;
  7607. struct device *cdev = card->dev;
  7608. struct snd_soc_dai_link *dai_link = card->dai_link;
  7609. struct device_node *np;
  7610. if (!cdev) {
  7611. pr_err("%s: Sound card device memory NULL\n", __func__);
  7612. return -ENODEV;
  7613. }
  7614. for (i = 0; i < card->num_links; i++) {
  7615. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  7616. continue;
  7617. /* populate platform_of_node for snd card dai links */
  7618. if (dai_link[i].platform_name &&
  7619. !dai_link[i].platform_of_node) {
  7620. index = of_property_match_string(cdev->of_node,
  7621. "asoc-platform-names",
  7622. dai_link[i].platform_name);
  7623. if (index < 0) {
  7624. pr_err("%s: No match found for platform name: %s\n",
  7625. __func__, dai_link[i].platform_name);
  7626. ret = index;
  7627. goto err;
  7628. }
  7629. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  7630. index);
  7631. if (!np) {
  7632. pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
  7633. __func__, dai_link[i].platform_name,
  7634. index);
  7635. ret = -ENODEV;
  7636. goto err;
  7637. }
  7638. dai_link[i].platform_of_node = np;
  7639. dai_link[i].platform_name = NULL;
  7640. }
  7641. /* populate cpu_of_node for snd card dai links */
  7642. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  7643. index = of_property_match_string(cdev->of_node,
  7644. "asoc-cpu-names",
  7645. dai_link[i].cpu_dai_name);
  7646. if (index >= 0) {
  7647. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  7648. index);
  7649. if (!np) {
  7650. pr_err("%s: retrieving phandle for cpu dai %s failed\n",
  7651. __func__,
  7652. dai_link[i].cpu_dai_name);
  7653. ret = -ENODEV;
  7654. goto err;
  7655. }
  7656. dai_link[i].cpu_of_node = np;
  7657. dai_link[i].cpu_dai_name = NULL;
  7658. }
  7659. }
  7660. /* populate codec_of_node for snd card dai links */
  7661. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  7662. index = of_property_match_string(cdev->of_node,
  7663. "asoc-codec-names",
  7664. dai_link[i].codec_name);
  7665. if (index < 0)
  7666. continue;
  7667. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  7668. index);
  7669. if (!np) {
  7670. pr_err("%s: retrieving phandle for codec %s failed\n",
  7671. __func__, dai_link[i].codec_name);
  7672. ret = -ENODEV;
  7673. goto err;
  7674. }
  7675. dai_link[i].codec_of_node = np;
  7676. dai_link[i].codec_name = NULL;
  7677. }
  7678. }
  7679. err:
  7680. return ret;
  7681. }
  7682. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  7683. /* FrontEnd DAI Links */
  7684. {
  7685. .name = "MSMSTUB Media1",
  7686. .stream_name = "MultiMedia1",
  7687. .cpu_dai_name = "MultiMedia1",
  7688. .platform_name = "msm-pcm-dsp.0",
  7689. .dynamic = 1,
  7690. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  7691. .dpcm_playback = 1,
  7692. .dpcm_capture = 1,
  7693. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  7694. SND_SOC_DPCM_TRIGGER_POST},
  7695. .codec_dai_name = "snd-soc-dummy-dai",
  7696. .codec_name = "snd-soc-dummy",
  7697. .ignore_suspend = 1,
  7698. /* this dainlink has playback support */
  7699. .ignore_pmdown_time = 1,
  7700. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  7701. },
  7702. };
  7703. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  7704. /* Backend DAI Links */
  7705. {
  7706. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  7707. .stream_name = "VA CDC DMA0 Capture",
  7708. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  7709. .platform_name = "msm-pcm-routing",
  7710. .codec_name = "bolero_codec",
  7711. .codec_dai_name = "va_macro_tx1",
  7712. .no_pcm = 1,
  7713. .dpcm_capture = 1,
  7714. .init = &msm_va_cdc_dma_init,
  7715. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  7716. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7717. .ignore_suspend = 1,
  7718. .ops = &msm_cdc_dma_be_ops,
  7719. },
  7720. {
  7721. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  7722. .stream_name = "VA CDC DMA1 Capture",
  7723. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  7724. .platform_name = "msm-pcm-routing",
  7725. .codec_name = "bolero_codec",
  7726. .codec_dai_name = "va_macro_tx2",
  7727. .no_pcm = 1,
  7728. .dpcm_capture = 1,
  7729. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  7730. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7731. .ignore_suspend = 1,
  7732. .ops = &msm_cdc_dma_be_ops,
  7733. },
  7734. };
  7735. static struct snd_soc_dai_link msm_stub_dai_links[
  7736. ARRAY_SIZE(msm_stub_fe_dai_links) +
  7737. ARRAY_SIZE(msm_stub_be_dai_links)];
  7738. struct snd_soc_card snd_soc_card_stub_msm = {
  7739. .name = "qcs405-stub-snd-card",
  7740. };
  7741. static const struct of_device_id qcs405_asoc_machine_of_match[] = {
  7742. { .compatible = "qcom,qcs405-asoc-snd",
  7743. .data = "codec"},
  7744. { .compatible = "qcom,qcs405-asoc-snd-stub",
  7745. .data = "stub_codec"},
  7746. {},
  7747. };
  7748. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  7749. {
  7750. struct snd_soc_card *card = NULL;
  7751. struct snd_soc_dai_link *dailink;
  7752. int total_links = 0;
  7753. uint32_t tasha_codec = 0, auxpcm_audio_intf = 0;
  7754. uint32_t va_bolero_codec = 0, wsa_bolero_codec = 0, mi2s_audio_intf = 0;
  7755. uint32_t spdif_audio_intf = 0, wcn_audio_intf = 0;
  7756. uint32_t afe_loopback_intf = 0, meta_mi2s_intf = 0;
  7757. const struct of_device_id *match;
  7758. char __iomem *spdif_cfg, *spdif_pin_ctl;
  7759. int rc = 0;
  7760. match = of_match_node(qcs405_asoc_machine_of_match, dev->of_node);
  7761. if (!match) {
  7762. dev_err(dev, "%s: No DT match found for sound card\n",
  7763. __func__);
  7764. return NULL;
  7765. }
  7766. if (!strcmp(match->data, "codec")) {
  7767. card = &snd_soc_card_qcs405_msm;
  7768. memcpy(msm_qcs405_dai_links + total_links,
  7769. msm_common_dai_links,
  7770. sizeof(msm_common_dai_links));
  7771. total_links += ARRAY_SIZE(msm_common_dai_links);
  7772. rc = of_property_read_u32(dev->of_node, "qcom,wsa-bolero-codec",
  7773. &wsa_bolero_codec);
  7774. if (rc) {
  7775. dev_dbg(dev, "%s: No DT match WSA Macro codec\n",
  7776. __func__);
  7777. } else {
  7778. if (wsa_bolero_codec) {
  7779. dev_dbg(dev, "%s(): WSA macro in bolero codec present\n",
  7780. __func__);
  7781. memcpy(msm_qcs405_dai_links + total_links,
  7782. msm_bolero_fe_dai_links,
  7783. sizeof(msm_bolero_fe_dai_links));
  7784. total_links +=
  7785. ARRAY_SIZE(msm_bolero_fe_dai_links);
  7786. }
  7787. }
  7788. memcpy(msm_qcs405_dai_links + total_links,
  7789. msm_common_misc_fe_dai_links,
  7790. sizeof(msm_common_misc_fe_dai_links));
  7791. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  7792. memcpy(msm_qcs405_dai_links + total_links,
  7793. msm_common_be_dai_links,
  7794. sizeof(msm_common_be_dai_links));
  7795. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  7796. rc = of_property_read_u32(dev->of_node, "qcom,tasha-codec",
  7797. &tasha_codec);
  7798. if (rc) {
  7799. dev_dbg(dev, "%s: No DT match tasha codec\n",
  7800. __func__);
  7801. } else {
  7802. if (tasha_codec) {
  7803. memcpy(msm_qcs405_dai_links + total_links,
  7804. msm_tasha_be_dai_links,
  7805. sizeof(msm_tasha_be_dai_links));
  7806. total_links +=
  7807. ARRAY_SIZE(msm_tasha_be_dai_links);
  7808. }
  7809. }
  7810. rc = of_property_read_u32(dev->of_node, "qcom,va-bolero-codec",
  7811. &va_bolero_codec);
  7812. if (rc) {
  7813. dev_dbg(dev, "%s: No DT match VA Macro codec\n",
  7814. __func__);
  7815. } else {
  7816. if (va_bolero_codec) {
  7817. dev_dbg(dev, "%s(): VA macro in bolero codec present\n",
  7818. __func__);
  7819. memcpy(msm_qcs405_dai_links + total_links,
  7820. msm_va_cdc_dma_be_dai_links,
  7821. sizeof(msm_va_cdc_dma_be_dai_links));
  7822. total_links +=
  7823. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  7824. }
  7825. }
  7826. if (wsa_bolero_codec) {
  7827. dev_dbg(dev, "%s(): WSAmacro in bolero codec present\n",
  7828. __func__);
  7829. memcpy(msm_qcs405_dai_links + total_links,
  7830. msm_wsa_cdc_dma_be_dai_links,
  7831. sizeof(msm_wsa_cdc_dma_be_dai_links));
  7832. total_links +=
  7833. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  7834. }
  7835. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  7836. &mi2s_audio_intf);
  7837. if (rc) {
  7838. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  7839. __func__);
  7840. } else {
  7841. if (mi2s_audio_intf) {
  7842. memcpy(msm_qcs405_dai_links + total_links,
  7843. msm_mi2s_be_dai_links,
  7844. sizeof(msm_mi2s_be_dai_links));
  7845. total_links +=
  7846. ARRAY_SIZE(msm_mi2s_be_dai_links);
  7847. }
  7848. }
  7849. rc = of_property_read_u32(dev->of_node, "qcom,meta-mi2s-intf",
  7850. &meta_mi2s_intf);
  7851. if (rc) {
  7852. dev_dbg(dev, "%s: No DT match META-MI2S interface\n",
  7853. __func__);
  7854. } else {
  7855. if (meta_mi2s_intf) {
  7856. memcpy(msm_qcs405_dai_links + total_links,
  7857. msm_meta_mi2s_be_dai_links,
  7858. sizeof(msm_meta_mi2s_be_dai_links));
  7859. total_links +=
  7860. ARRAY_SIZE(msm_meta_mi2s_be_dai_links);
  7861. }
  7862. }
  7863. rc = of_property_read_u32(dev->of_node,
  7864. "qcom,auxpcm-audio-intf",
  7865. &auxpcm_audio_intf);
  7866. if (rc) {
  7867. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  7868. __func__);
  7869. } else {
  7870. if (auxpcm_audio_intf) {
  7871. memcpy(msm_qcs405_dai_links + total_links,
  7872. msm_auxpcm_be_dai_links,
  7873. sizeof(msm_auxpcm_be_dai_links));
  7874. total_links +=
  7875. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  7876. }
  7877. }
  7878. rc = of_property_read_u32(dev->of_node, "qcom,spdif-audio-intf",
  7879. &spdif_audio_intf);
  7880. if (rc) {
  7881. dev_dbg(dev, "%s: No DT match SPDIF audio interface\n",
  7882. __func__);
  7883. } else {
  7884. if (spdif_audio_intf) {
  7885. memcpy(msm_qcs405_dai_links + total_links,
  7886. msm_spdif_be_dai_links,
  7887. sizeof(msm_spdif_be_dai_links));
  7888. total_links +=
  7889. ARRAY_SIZE(msm_spdif_be_dai_links);
  7890. /* enable spdif coax pins */
  7891. spdif_cfg = ioremap(TLMM_EAST_SPARE, 0x4);
  7892. spdif_pin_ctl =
  7893. ioremap(TLMM_SPDIF_HDMI_ARC_CTL, 0x4);
  7894. iowrite32(0xc0, spdif_cfg);
  7895. iowrite32(0x2220, spdif_pin_ctl);
  7896. }
  7897. }
  7898. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  7899. &wcn_audio_intf);
  7900. if (rc) {
  7901. dev_dbg(dev, "%s: No DT match WCN audio interface\n",
  7902. __func__);
  7903. } else {
  7904. if (wcn_audio_intf) {
  7905. memcpy(msm_qcs405_dai_links + total_links,
  7906. msm_wcn_be_dai_links,
  7907. sizeof(msm_wcn_be_dai_links));
  7908. total_links +=
  7909. ARRAY_SIZE(msm_wcn_be_dai_links);
  7910. }
  7911. }
  7912. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  7913. &afe_loopback_intf);
  7914. if (rc) {
  7915. dev_dbg(dev, "%s: No DT match AFE loopback audio interface\n",
  7916. __func__);
  7917. } else {
  7918. if (afe_loopback_intf) {
  7919. memcpy(msm_qcs405_dai_links + total_links,
  7920. msm_afe_rxtx_lb_be_dai_link,
  7921. sizeof(msm_afe_rxtx_lb_be_dai_link));
  7922. total_links +=
  7923. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  7924. }
  7925. }
  7926. dailink = msm_qcs405_dai_links;
  7927. } else if (!strcmp(match->data, "stub_codec")) {
  7928. card = &snd_soc_card_stub_msm;
  7929. memcpy(msm_stub_dai_links + total_links,
  7930. msm_stub_fe_dai_links,
  7931. sizeof(msm_stub_fe_dai_links));
  7932. total_links += ARRAY_SIZE(msm_stub_fe_dai_links);
  7933. memcpy(msm_stub_dai_links + total_links,
  7934. msm_stub_be_dai_links,
  7935. sizeof(msm_stub_be_dai_links));
  7936. total_links += ARRAY_SIZE(msm_stub_be_dai_links);
  7937. dailink = msm_stub_dai_links;
  7938. }
  7939. if (card) {
  7940. card->dai_link = dailink;
  7941. card->num_links = total_links;
  7942. }
  7943. return card;
  7944. }
  7945. static int msm_wsa881x_init(struct snd_soc_component *component)
  7946. {
  7947. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  7948. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  7949. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  7950. SPKR_L_BOOST, SPKR_L_VI};
  7951. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  7952. SPKR_R_BOOST, SPKR_R_VI};
  7953. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  7954. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  7955. struct msm_asoc_mach_data *pdata;
  7956. struct snd_soc_dapm_context *dapm;
  7957. int ret = 0;
  7958. if (!component) {
  7959. pr_err("%s component is NULL\n", __func__);
  7960. return -EINVAL;
  7961. }
  7962. dapm = snd_soc_component_get_dapm(component);
  7963. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  7964. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  7965. __func__, component->name);
  7966. wsa881x_set_channel_map(component, &spkleft_ports[0],
  7967. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  7968. &ch_rate[0], &spkleft_port_types[0]);
  7969. if (dapm->component) {
  7970. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  7971. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  7972. }
  7973. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  7974. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  7975. __func__, component->name);
  7976. wsa881x_set_channel_map(component, &spkright_ports[0],
  7977. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  7978. &ch_rate[0], &spkright_port_types[0]);
  7979. if (dapm->component) {
  7980. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  7981. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  7982. }
  7983. } else {
  7984. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  7985. component->name);
  7986. ret = -EINVAL;
  7987. goto err;
  7988. }
  7989. pdata = snd_soc_card_get_drvdata(component->card);
  7990. if (pdata && pdata->codec_root)
  7991. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  7992. component);
  7993. err:
  7994. return ret;
  7995. }
  7996. static int msm_init_wsa_dev(struct platform_device *pdev,
  7997. struct snd_soc_card *card)
  7998. {
  7999. struct device_node *wsa_of_node;
  8000. u32 wsa_max_devs;
  8001. u32 wsa_dev_cnt;
  8002. int i;
  8003. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  8004. const char *wsa_auxdev_name_prefix[1];
  8005. char *dev_name_str = NULL;
  8006. int found = 0;
  8007. int ret = 0;
  8008. /* Get maximum WSA device count for this platform */
  8009. ret = of_property_read_u32(pdev->dev.of_node,
  8010. "qcom,wsa-max-devs", &wsa_max_devs);
  8011. if (ret) {
  8012. dev_info(&pdev->dev,
  8013. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  8014. __func__, pdev->dev.of_node->full_name, ret);
  8015. card->num_aux_devs = 0;
  8016. return 0;
  8017. }
  8018. if (wsa_max_devs == 0) {
  8019. dev_warn(&pdev->dev,
  8020. "%s: Max WSA devices is 0 for this target?\n",
  8021. __func__);
  8022. card->num_aux_devs = 0;
  8023. return 0;
  8024. }
  8025. /* Get count of WSA device phandles for this platform */
  8026. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  8027. "qcom,wsa-devs", NULL);
  8028. if (wsa_dev_cnt == -ENOENT) {
  8029. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  8030. __func__);
  8031. goto err;
  8032. } else if (wsa_dev_cnt <= 0) {
  8033. dev_err(&pdev->dev,
  8034. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  8035. __func__, wsa_dev_cnt);
  8036. ret = -EINVAL;
  8037. goto err;
  8038. }
  8039. /*
  8040. * Expect total phandles count to be NOT less than maximum possible
  8041. * WSA count. However, if it is less, then assign same value to
  8042. * max count as well.
  8043. */
  8044. if (wsa_dev_cnt < wsa_max_devs) {
  8045. dev_dbg(&pdev->dev,
  8046. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  8047. __func__, wsa_max_devs, wsa_dev_cnt);
  8048. wsa_max_devs = wsa_dev_cnt;
  8049. }
  8050. /* Make sure prefix string passed for each WSA device */
  8051. ret = of_property_count_strings(pdev->dev.of_node,
  8052. "qcom,wsa-aux-dev-prefix");
  8053. if (ret != wsa_dev_cnt) {
  8054. dev_err(&pdev->dev,
  8055. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  8056. __func__, wsa_dev_cnt, ret);
  8057. ret = -EINVAL;
  8058. goto err;
  8059. }
  8060. /*
  8061. * Alloc mem to store phandle and index info of WSA device, if already
  8062. * registered with ALSA core
  8063. */
  8064. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  8065. sizeof(struct msm_wsa881x_dev_info),
  8066. GFP_KERNEL);
  8067. if (!wsa881x_dev_info) {
  8068. ret = -ENOMEM;
  8069. goto err;
  8070. }
  8071. /*
  8072. * search and check whether all WSA devices are already
  8073. * registered with ALSA core or not. If found a node, store
  8074. * the node and the index in a local array of struct for later
  8075. * use.
  8076. */
  8077. for (i = 0; i < wsa_dev_cnt; i++) {
  8078. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  8079. "qcom,wsa-devs", i);
  8080. if (unlikely(!wsa_of_node)) {
  8081. /* we should not be here */
  8082. dev_err(&pdev->dev,
  8083. "%s: wsa dev node is not present\n",
  8084. __func__);
  8085. ret = -EINVAL;
  8086. goto err_free_dev_info;
  8087. }
  8088. if (soc_find_component(wsa_of_node, NULL)) {
  8089. /* WSA device registered with ALSA core */
  8090. wsa881x_dev_info[found].of_node = wsa_of_node;
  8091. wsa881x_dev_info[found].index = i;
  8092. found++;
  8093. if (found == wsa_max_devs)
  8094. break;
  8095. }
  8096. }
  8097. if (found < wsa_max_devs) {
  8098. dev_err(&pdev->dev,
  8099. "%s: failed to find %d components. Found only %d\n",
  8100. __func__, wsa_max_devs, found);
  8101. return -EPROBE_DEFER;
  8102. }
  8103. dev_info(&pdev->dev,
  8104. "%s: found %d wsa881x devices registered with ALSA core\n",
  8105. __func__, found);
  8106. card->num_aux_devs = wsa_max_devs;
  8107. card->num_configs = wsa_max_devs;
  8108. /* Alloc array of AUX devs struct */
  8109. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8110. sizeof(struct snd_soc_aux_dev),
  8111. GFP_KERNEL);
  8112. if (!msm_aux_dev) {
  8113. ret = -ENOMEM;
  8114. goto err_free_dev_info;
  8115. }
  8116. /* Alloc array of codec conf struct */
  8117. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8118. sizeof(struct snd_soc_codec_conf),
  8119. GFP_KERNEL);
  8120. if (!msm_codec_conf) {
  8121. ret = -ENOMEM;
  8122. goto err_free_aux_dev;
  8123. }
  8124. for (i = 0; i < card->num_aux_devs; i++) {
  8125. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  8126. GFP_KERNEL);
  8127. if (!dev_name_str) {
  8128. ret = -ENOMEM;
  8129. goto err_free_cdc_conf;
  8130. }
  8131. ret = of_property_read_string_index(pdev->dev.of_node,
  8132. "qcom,wsa-aux-dev-prefix",
  8133. wsa881x_dev_info[i].index,
  8134. wsa_auxdev_name_prefix);
  8135. if (ret) {
  8136. dev_err(&pdev->dev,
  8137. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  8138. __func__, ret);
  8139. ret = -EINVAL;
  8140. goto err_free_dev_name_str;
  8141. }
  8142. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  8143. msm_aux_dev[i].name = dev_name_str;
  8144. msm_aux_dev[i].codec_name = NULL;
  8145. msm_aux_dev[i].codec_of_node =
  8146. wsa881x_dev_info[i].of_node;
  8147. msm_aux_dev[i].init = msm_wsa881x_init;
  8148. msm_codec_conf[i].dev_name = NULL;
  8149. msm_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
  8150. msm_codec_conf[i].of_node =
  8151. wsa881x_dev_info[i].of_node;
  8152. }
  8153. card->codec_conf = msm_codec_conf;
  8154. card->aux_dev = msm_aux_dev;
  8155. return 0;
  8156. err_free_dev_name_str:
  8157. devm_kfree(&pdev->dev, dev_name_str);
  8158. err_free_cdc_conf:
  8159. devm_kfree(&pdev->dev, msm_codec_conf);
  8160. err_free_aux_dev:
  8161. devm_kfree(&pdev->dev, msm_aux_dev);
  8162. err_free_dev_info:
  8163. devm_kfree(&pdev->dev, wsa881x_dev_info);
  8164. err:
  8165. return ret;
  8166. }
  8167. static int msm_csra66x0_init(struct snd_soc_component *component)
  8168. {
  8169. if (!component) {
  8170. pr_err("%s component is NULL\n", __func__);
  8171. return -EINVAL;
  8172. }
  8173. return 0;
  8174. }
  8175. static int msm_init_csra_dev(struct platform_device *pdev,
  8176. struct snd_soc_card *card)
  8177. {
  8178. struct device_node *csra_of_node;
  8179. u32 csra_max_devs;
  8180. u32 csra_dev_cnt;
  8181. char *dev_name_str = NULL;
  8182. struct msm_csra66x0_dev_info *csra66x0_dev_info;
  8183. const char *csra_auxdev_name_prefix[1];
  8184. int i;
  8185. int found = 0;
  8186. int ret = 0;
  8187. /* Get maximum CSRA device count for this platform */
  8188. ret = of_property_read_u32(pdev->dev.of_node,
  8189. "qcom,csra-max-devs", &csra_max_devs);
  8190. if (ret) {
  8191. dev_info(&pdev->dev,
  8192. "%s: csra-max-devs property missing in DT %s, ret = %d\n",
  8193. __func__, pdev->dev.of_node->full_name, ret);
  8194. card->num_aux_devs = 0;
  8195. return 0;
  8196. }
  8197. if (csra_max_devs == 0) {
  8198. dev_warn(&pdev->dev,
  8199. "%s: Max CSRA devices is 0 for this target?\n",
  8200. __func__);
  8201. return 0;
  8202. }
  8203. /* Get count of CSRA device phandles for this platform */
  8204. csra_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  8205. "qcom,csra-devs", NULL);
  8206. if (csra_dev_cnt == -ENOENT) {
  8207. dev_warn(&pdev->dev, "%s: No csra device defined in DT.\n",
  8208. __func__);
  8209. goto err;
  8210. } else if (csra_dev_cnt <= 0) {
  8211. dev_err(&pdev->dev,
  8212. "%s: Error reading csra device from DT. csra_dev_cnt = %d\n",
  8213. __func__, csra_dev_cnt);
  8214. ret = -EINVAL;
  8215. goto err;
  8216. }
  8217. /*
  8218. * Expect total phandles count to be NOT less than maximum possible
  8219. * CSRA count. However, if it is less, then assign same value to
  8220. * max count as well.
  8221. */
  8222. if (csra_dev_cnt < csra_max_devs) {
  8223. dev_dbg(&pdev->dev,
  8224. "%s: csra_max_devs = %d cannot exceed csra_dev_cnt = %d\n",
  8225. __func__, csra_max_devs, csra_dev_cnt);
  8226. csra_max_devs = csra_dev_cnt;
  8227. }
  8228. /* Make sure prefix string passed for each CSRA device */
  8229. ret = of_property_count_strings(pdev->dev.of_node,
  8230. "qcom,csra-aux-dev-prefix");
  8231. if (ret != csra_dev_cnt) {
  8232. dev_err(&pdev->dev,
  8233. "%s: expecting %d csra prefix. Defined only %d in DT\n",
  8234. __func__, csra_dev_cnt, ret);
  8235. ret = -EINVAL;
  8236. goto err;
  8237. }
  8238. /*
  8239. * Alloc mem to store phandle and index info of CSRA device, if already
  8240. * registered with ALSA core
  8241. */
  8242. csra66x0_dev_info = devm_kcalloc(&pdev->dev, csra_max_devs,
  8243. sizeof(struct msm_csra66x0_dev_info),
  8244. GFP_KERNEL);
  8245. if (!csra66x0_dev_info) {
  8246. ret = -ENOMEM;
  8247. goto err;
  8248. }
  8249. /*
  8250. * search and check whether all CSRA devices are already
  8251. * registered with ALSA core or not. If found a node, store
  8252. * the node and the index in a local array of struct for later
  8253. * use.
  8254. */
  8255. for (i = 0; i < csra_dev_cnt; i++) {
  8256. csra_of_node = of_parse_phandle(pdev->dev.of_node,
  8257. "qcom,csra-devs", i);
  8258. if (unlikely(!csra_of_node)) {
  8259. /* we should not be here */
  8260. dev_err(&pdev->dev,
  8261. "%s: csra dev node is not present\n",
  8262. __func__);
  8263. ret = -EINVAL;
  8264. goto err_free_dev_info;
  8265. }
  8266. if (soc_find_component(csra_of_node, NULL)) {
  8267. /* CSRA device registered with ALSA core */
  8268. csra66x0_dev_info[found].of_node = csra_of_node;
  8269. csra66x0_dev_info[found].index = i;
  8270. found++;
  8271. if (found == csra_max_devs)
  8272. break;
  8273. }
  8274. }
  8275. if (found < csra_max_devs) {
  8276. dev_dbg(&pdev->dev,
  8277. "%s: failed to find %d components. Found only %d\n",
  8278. __func__, csra_max_devs, found);
  8279. return -EPROBE_DEFER;
  8280. }
  8281. dev_info(&pdev->dev,
  8282. "%s: found %d csra66x0 devices registered with ALSA core\n",
  8283. __func__, found);
  8284. card->num_aux_devs = csra_max_devs;
  8285. card->num_configs = csra_max_devs;
  8286. /* Alloc array of AUX devs struct */
  8287. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8288. sizeof(struct snd_soc_aux_dev), GFP_KERNEL);
  8289. if (!msm_aux_dev) {
  8290. ret = -ENOMEM;
  8291. goto err_free_dev_info;
  8292. }
  8293. /* Alloc array of codec conf struct */
  8294. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8295. sizeof(struct snd_soc_codec_conf), GFP_KERNEL);
  8296. if (!msm_codec_conf) {
  8297. ret = -ENOMEM;
  8298. goto err_free_aux_dev;
  8299. }
  8300. for (i = 0; i < card->num_aux_devs; i++) {
  8301. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  8302. GFP_KERNEL);
  8303. if (!dev_name_str) {
  8304. ret = -ENOMEM;
  8305. goto err_free_cdc_conf;
  8306. }
  8307. ret = of_property_read_string_index(pdev->dev.of_node,
  8308. "qcom,csra-aux-dev-prefix",
  8309. csra66x0_dev_info[i].index,
  8310. csra_auxdev_name_prefix);
  8311. if (ret) {
  8312. dev_err(&pdev->dev,
  8313. "%s: failed to read csra aux dev prefix, ret = %d\n",
  8314. __func__, ret);
  8315. ret = -EINVAL;
  8316. goto err_free_dev_name_str;
  8317. }
  8318. snprintf(dev_name_str, strlen("csra66x0.%d"), "csra66x0.%d", i);
  8319. msm_aux_dev[i].name = dev_name_str;
  8320. msm_aux_dev[i].codec_name = NULL;
  8321. msm_aux_dev[i].codec_of_node =
  8322. csra66x0_dev_info[i].of_node;
  8323. msm_aux_dev[i].init = msm_csra66x0_init; /* codec specific init */
  8324. msm_codec_conf[i].dev_name = NULL;
  8325. msm_codec_conf[i].name_prefix = csra_auxdev_name_prefix[0];
  8326. msm_codec_conf[i].of_node = csra66x0_dev_info[i].of_node;
  8327. }
  8328. card->codec_conf = msm_codec_conf;
  8329. card->aux_dev = msm_aux_dev;
  8330. return 0;
  8331. err_free_dev_name_str:
  8332. devm_kfree(&pdev->dev, dev_name_str);
  8333. err_free_cdc_conf:
  8334. devm_kfree(&pdev->dev, msm_codec_conf);
  8335. err_free_aux_dev:
  8336. devm_kfree(&pdev->dev, msm_aux_dev);
  8337. err_free_dev_info:
  8338. devm_kfree(&pdev->dev, csra66x0_dev_info);
  8339. err:
  8340. return ret;
  8341. }
  8342. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  8343. {
  8344. int count;
  8345. u32 mi2s_master_slave[MI2S_MAX];
  8346. int ret;
  8347. for (count = 0; count < MI2S_MAX; count++) {
  8348. mutex_init(&mi2s_intf_conf[count].lock);
  8349. mi2s_intf_conf[count].ref_cnt = 0;
  8350. }
  8351. ret = of_property_read_u32_array(pdev->dev.of_node,
  8352. "qcom,msm-mi2s-master",
  8353. mi2s_master_slave, MI2S_MAX);
  8354. if (ret) {
  8355. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  8356. __func__);
  8357. } else {
  8358. for (count = 0; count < MI2S_MAX; count++) {
  8359. mi2s_intf_conf[count].msm_is_mi2s_master =
  8360. mi2s_master_slave[count];
  8361. }
  8362. }
  8363. }
  8364. static void msm_i2s_auxpcm_deinit(void)
  8365. {
  8366. int count;
  8367. for (count = 0; count < MI2S_MAX; count++) {
  8368. mutex_destroy(&mi2s_intf_conf[count].lock);
  8369. mi2s_intf_conf[count].ref_cnt = 0;
  8370. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  8371. }
  8372. }
  8373. static void msm_meta_mi2s_init(struct platform_device *pdev)
  8374. {
  8375. int rc = 0;
  8376. int i = 0;
  8377. int index = 0;
  8378. bool parse_of = false;
  8379. struct snd_soc_card *card = platform_get_drvdata(pdev);
  8380. struct snd_soc_dai_link *dai_link = card->dai_link;
  8381. dev_dbg(&pdev->dev, "%s: read from DT\n", __func__);
  8382. for (index = 0; index < META_MI2S_MAX; index++) {
  8383. meta_mi2s_intf_conf[index].num_member_ports = 0;
  8384. meta_mi2s_intf_conf[index].member_port[0] = 0;
  8385. meta_mi2s_intf_conf[index].member_port[1] = 0;
  8386. meta_mi2s_intf_conf[index].member_port[2] = 0;
  8387. meta_mi2s_intf_conf[index].member_port[3] = 0;
  8388. meta_mi2s_intf_conf[index].clk_enable[0] = false;
  8389. meta_mi2s_intf_conf[index].clk_enable[1] = false;
  8390. meta_mi2s_intf_conf[index].clk_enable[2] = false;
  8391. meta_mi2s_intf_conf[index].clk_enable[3] = false;
  8392. }
  8393. /* get member port info to set matching clocks for involved ports */
  8394. for (i = 0; i < card->num_links; i++) {
  8395. if (dai_link[i].id == MSM_BACKEND_DAI_PRI_META_MI2S_RX) {
  8396. parse_of = true;
  8397. index = PRIM_META_MI2S;
  8398. } else if (dai_link[i].id == MSM_BACKEND_DAI_SEC_META_MI2S_RX) {
  8399. parse_of = true;
  8400. index = SEC_META_MI2S;
  8401. } else {
  8402. parse_of = false;
  8403. }
  8404. if (parse_of && dai_link[i].cpu_of_node) {
  8405. rc = of_property_read_u32(dai_link[i].cpu_of_node,
  8406. "qcom,msm-mi2s-num-members",
  8407. &meta_mi2s_intf_conf[index].num_member_ports);
  8408. if (rc) {
  8409. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  8410. __func__, "qcom,msm-mi2s-num-members");
  8411. }
  8412. if (meta_mi2s_intf_conf[index].num_member_ports >
  8413. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  8414. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  8415. __func__,
  8416. meta_mi2s_intf_conf[index].num_member_ports);
  8417. }
  8418. if (meta_mi2s_intf_conf[index].num_member_ports > 0) {
  8419. rc = of_property_read_u32_array(
  8420. dai_link[i].cpu_of_node,
  8421. "qcom,msm-mi2s-member-id",
  8422. meta_mi2s_intf_conf[index].member_port,
  8423. meta_mi2s_intf_conf[index].num_member_ports);
  8424. if (rc) {
  8425. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  8426. __func__,
  8427. "qcom,msm-mi2s-member-id");
  8428. }
  8429. }
  8430. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  8431. dev_name(&pdev->dev),
  8432. meta_mi2s_intf_conf[index].num_member_ports);
  8433. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  8434. meta_mi2s_intf_conf[index].member_port[0],
  8435. meta_mi2s_intf_conf[index].member_port[1],
  8436. meta_mi2s_intf_conf[index].member_port[2],
  8437. meta_mi2s_intf_conf[index].member_port[3]);
  8438. }
  8439. }
  8440. }
  8441. static int msm_scan_i2c_addr(struct platform_device *pdev,
  8442. uint32_t busnum, uint32_t addr)
  8443. {
  8444. struct i2c_adapter *adap;
  8445. u8 rbuf;
  8446. struct i2c_msg msg;
  8447. int status = 0;
  8448. adap = i2c_get_adapter(busnum);
  8449. if (!adap) {
  8450. dev_err(&pdev->dev, "%s: Cannot get I2C adapter %d\n",
  8451. __func__, busnum);
  8452. return -EBUSY;
  8453. }
  8454. /* to test presence, read one byte from device */
  8455. msg.addr = addr;
  8456. msg.flags = I2C_M_RD;
  8457. msg.len = 1;
  8458. msg.buf = &rbuf;
  8459. status = i2c_transfer(adap, &msg, 1);
  8460. i2c_put_adapter(adap);
  8461. if (status != 1) {
  8462. dev_dbg(&pdev->dev, "%s: I2C read from addr 0x%02x failed\n",
  8463. __func__, addr);
  8464. return -ENODEV;
  8465. }
  8466. dev_dbg(&pdev->dev, "%s: I2C read from addr 0x%02x successful\n",
  8467. __func__, addr);
  8468. return 0;
  8469. }
  8470. static int msm_detect_ep92_dev(struct platform_device *pdev,
  8471. struct snd_soc_card *card)
  8472. {
  8473. int i;
  8474. uint32_t ep92_busnum = 0;
  8475. uint32_t ep92_reg = 0;
  8476. const char *ep92_name = NULL;
  8477. struct snd_soc_dai_link *dai;
  8478. int rc = 0;
  8479. rc = of_property_read_u32(pdev->dev.of_node, "qcom,ep92-busnum",
  8480. &ep92_busnum);
  8481. if (rc) {
  8482. dev_info(&pdev->dev, "%s: No DT match ep92-reg\n", __func__);
  8483. return 0;
  8484. }
  8485. rc = of_property_read_u32(pdev->dev.of_node, "qcom,ep92-reg",
  8486. &ep92_reg);
  8487. if (rc) {
  8488. dev_info(&pdev->dev, "%s: No DT match ep92-busnum\n", __func__);
  8489. return 0;
  8490. }
  8491. rc = of_property_read_string(pdev->dev.of_node, "qcom,ep92-name",
  8492. &ep92_name);
  8493. if (rc) {
  8494. dev_info(&pdev->dev, "%s: No DT match ep92-name\n", __func__);
  8495. return 0;
  8496. }
  8497. /* check I2C bus for connected ep92 chip */
  8498. if (msm_scan_i2c_addr(pdev, ep92_busnum, ep92_reg) < 0) {
  8499. /* check a second time after a short delay */
  8500. msleep(20);
  8501. if (msm_scan_i2c_addr(pdev, ep92_busnum, ep92_reg) < 0) {
  8502. dev_info(&pdev->dev, "%s: No ep92 device found\n",
  8503. __func__);
  8504. /* continue with snd_card registration without ep92 */
  8505. return 0;
  8506. }
  8507. }
  8508. dev_info(&pdev->dev, "%s: ep92 device found\n", __func__);
  8509. /* update codec info in MI2S dai link */
  8510. dai = &msm_mi2s_be_dai_links[0];
  8511. for (i=0; i<ARRAY_SIZE(msm_mi2s_be_dai_links); i++) {
  8512. if (strcmp(dai->name, LPASS_BE_SEC_MI2S_TX) == 0) {
  8513. dev_dbg(&pdev->dev,
  8514. "%s: Set Sec MI2S dai to ep92 codec\n",
  8515. __func__);
  8516. dai->codec_name = ep92_name;
  8517. dai->codec_dai_name = "ep92-hdmi";
  8518. break;
  8519. }
  8520. dai++;
  8521. }
  8522. /* update codec info in SPDIF dai link */
  8523. dai = &msm_spdif_be_dai_links[0];
  8524. for (i=0; i<ARRAY_SIZE(msm_spdif_be_dai_links); i++) {
  8525. if (strcmp(dai->name, LPASS_BE_SEC_SPDIF_TX) == 0) {
  8526. dev_dbg(&pdev->dev,
  8527. "%s: Set Sec SPDIF dai to ep92 codec\n",
  8528. __func__);
  8529. dai->codec_name = ep92_name;
  8530. dai->codec_dai_name = "ep92-arc";
  8531. break;
  8532. }
  8533. dai++;
  8534. }
  8535. return 0;
  8536. }
  8537. static int msm_asoc_machine_probe(struct platform_device *pdev)
  8538. {
  8539. struct snd_soc_card *card;
  8540. struct msm_asoc_mach_data *pdata;
  8541. int ret;
  8542. u32 val;
  8543. const char *micb_supply_str = "tdm-vdd-micb-supply";
  8544. const char *micb_supply_str1 = "tdm-vdd-micb";
  8545. const char *micb_voltage_str = "qcom,tdm-vdd-micb-voltage";
  8546. const char *micb_current_str = "qcom,tdm-vdd-micb-current";
  8547. if (!pdev->dev.of_node) {
  8548. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  8549. return -EINVAL;
  8550. }
  8551. pdata = devm_kzalloc(&pdev->dev,
  8552. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  8553. if (!pdata)
  8554. return -ENOMEM;
  8555. /* test for ep92 HDMI bridge and update dai links accordingly */
  8556. ret = msm_detect_ep92_dev(pdev, card);
  8557. if (ret)
  8558. goto err;
  8559. card = populate_snd_card_dailinks(&pdev->dev);
  8560. if (!card) {
  8561. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  8562. ret = -EINVAL;
  8563. goto err;
  8564. }
  8565. card->dev = &pdev->dev;
  8566. platform_set_drvdata(pdev, card);
  8567. snd_soc_card_set_drvdata(card, pdata);
  8568. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  8569. if (ret) {
  8570. dev_err(&pdev->dev, "parse card name failed, err:%d\n",
  8571. ret);
  8572. goto err;
  8573. }
  8574. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  8575. if (ret) {
  8576. dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
  8577. ret);
  8578. goto err;
  8579. }
  8580. ret = msm_populate_dai_link_component_of_node(card);
  8581. if (ret) {
  8582. ret = -EPROBE_DEFER;
  8583. goto err;
  8584. }
  8585. ret = of_property_read_u32(pdev->dev.of_node, "qcom,csra-codec", &val);
  8586. if (ret) {
  8587. dev_info(&pdev->dev, "no 'qcom,csra-codec' in DT\n");
  8588. val = 0;
  8589. }
  8590. if (val) {
  8591. pdata->codec_is_csra = true;
  8592. mi2s_rx_cfg[PRIM_MI2S].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  8593. meta_mi2s_rx_cfg[PRIM_META_MI2S].bit_format =
  8594. SNDRV_PCM_FORMAT_S24_LE;
  8595. ret = msm_init_csra_dev(pdev, card);
  8596. if (ret)
  8597. goto err;
  8598. } else {
  8599. pdata->codec_is_csra = false;
  8600. ret = msm_init_wsa_dev(pdev, card);
  8601. if (ret)
  8602. goto err;
  8603. }
  8604. pdata->dmic_01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8605. "qcom,cdc-dmic01-gpios", 0);
  8606. pdata->dmic_23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8607. "qcom,cdc-dmic23-gpios", 0);
  8608. pdata->dmic_45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8609. "qcom,cdc-dmic45-gpios", 0);
  8610. pdata->dmic_67_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8611. "qcom,cdc-dmic67-gpios", 0);
  8612. pdata->lineout_booster_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8613. "qcom,lineout-booster-gpio", 0);
  8614. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8615. "qcom,pri-mi2s-gpios", 0);
  8616. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8617. "qcom,sec-mi2s-gpios", 0);
  8618. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8619. "qcom,tert-mi2s-gpios", 0);
  8620. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8621. "qcom,quat-mi2s-gpios", 0);
  8622. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8623. "qcom,quin-mi2s-gpios", 0);
  8624. if (of_parse_phandle(pdev->dev.of_node, micb_supply_str, 0)) {
  8625. pdata->tdm_micb_supply = devm_regulator_get(&pdev->dev,
  8626. micb_supply_str1);
  8627. if (IS_ERR(pdata->tdm_micb_supply)) {
  8628. ret = PTR_ERR(pdata->tdm_micb_supply);
  8629. dev_err(&pdev->dev,
  8630. "%s:Failed to get micbias supply for TDM Mic %d\n",
  8631. __func__, ret);
  8632. }
  8633. ret = of_property_read_u32(pdev->dev.of_node,
  8634. micb_voltage_str,
  8635. &pdata->tdm_micb_voltage);
  8636. if (ret) {
  8637. dev_err(&pdev->dev,
  8638. "%s:Looking up %s property in node %s failed\n",
  8639. __func__, micb_voltage_str,
  8640. pdev->dev.of_node->full_name);
  8641. }
  8642. ret = of_property_read_u32(pdev->dev.of_node,
  8643. micb_current_str,
  8644. &pdata->tdm_micb_current);
  8645. if (ret) {
  8646. dev_err(&pdev->dev,
  8647. "%s:Looking up %s property in node %s failed\n",
  8648. __func__, micb_current_str,
  8649. pdev->dev.of_node->full_name);
  8650. }
  8651. }
  8652. ret = devm_snd_soc_register_card(&pdev->dev, card);
  8653. if (ret == -EPROBE_DEFER) {
  8654. if (codec_reg_done)
  8655. ret = -EINVAL;
  8656. goto err;
  8657. } else if (ret) {
  8658. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  8659. ret);
  8660. goto err;
  8661. }
  8662. dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
  8663. spdev = pdev;
  8664. ret = msm_mdf_mem_init();
  8665. if (ret)
  8666. dev_err(&pdev->dev, "msm_mdf_mem_init failed (%d)\n",
  8667. ret);
  8668. msm_i2s_auxpcm_init(pdev);
  8669. msm_meta_mi2s_init(pdev);
  8670. is_initial_boot = true;
  8671. return 0;
  8672. err:
  8673. return ret;
  8674. }
  8675. static int msm_asoc_machine_remove(struct platform_device *pdev)
  8676. {
  8677. audio_notifier_deregister("qcs405");
  8678. msm_i2s_auxpcm_deinit();
  8679. msm_mdf_mem_deinit();
  8680. return 0;
  8681. }
  8682. static struct platform_driver qcs405_asoc_machine_driver = {
  8683. .driver = {
  8684. .name = DRV_NAME,
  8685. .owner = THIS_MODULE,
  8686. .pm = &snd_soc_pm_ops,
  8687. .of_match_table = qcs405_asoc_machine_of_match,
  8688. .suppress_bind_attrs = true,
  8689. },
  8690. .probe = msm_asoc_machine_probe,
  8691. .remove = msm_asoc_machine_remove,
  8692. };
  8693. module_platform_driver(qcs405_asoc_machine_driver);
  8694. MODULE_DESCRIPTION("ALSA SoC QCS405 Machine driver");
  8695. MODULE_LICENSE("GPL v2");
  8696. MODULE_ALIAS("platform:" DRV_NAME);
  8697. MODULE_DEVICE_TABLE(of, qcs405_asoc_machine_of_match);