msm-dai-q6-v2.c 386 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/init.h>
  5. #include <linux/module.h>
  6. #include <linux/device.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/bitops.h>
  9. #include <linux/slab.h>
  10. #include <linux/clk.h>
  11. #include <linux/of_device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <sound/pcm_params.h>
  16. #include <dsp/apr_audio-v2.h>
  17. #include <dsp/q6afe-v2.h>
  18. #include <dsp/sp_params.h>
  19. #include <dsp/q6core.h>
  20. #include "msm-dai-q6-v2.h"
  21. #include <asoc/core.h>
  22. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  23. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  24. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  25. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  26. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  27. #define MSM_DAI_SEN_AUXPCM_DT_DEV_ID 6
  28. #define MSM_DAI_TWS_CHANNEL_MODE_ONE 1
  29. #define MSM_DAI_TWS_CHANNEL_MODE_TWO 2
  30. #define spdif_clock_value(rate) (2*rate*32*2)
  31. #define CHANNEL_STATUS_SIZE 24
  32. #define CHANNEL_STATUS_MASK_INIT 0x0
  33. #define CHANNEL_STATUS_MASK 0x4
  34. #define PREEMPH_MASK 0x38
  35. #define PREEMPH_SHIFT 3
  36. #define GET_PREEMPH(b) ((b & PREEMPH_MASK) >> PREEMPH_SHIFT)
  37. #define AFE_API_VERSION_CLOCK_SET 1
  38. #define MSM_DAI_SYSFS_ENTRY_MAX_LEN 64
  39. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  40. SNDRV_PCM_FMTBIT_S24_LE | \
  41. SNDRV_PCM_FMTBIT_S32_LE)
  42. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id);
  43. enum {
  44. ENC_FMT_NONE,
  45. DEC_FMT_NONE = ENC_FMT_NONE,
  46. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  47. DEC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  48. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  49. DEC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  50. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  51. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  52. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  53. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  54. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  55. DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  56. DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
  57. ENC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  58. DEC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  59. };
  60. enum {
  61. SPKR_1,
  62. SPKR_2,
  63. };
  64. static const struct afe_clk_set lpass_clk_set_default = {
  65. AFE_API_VERSION_CLOCK_SET,
  66. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  67. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  68. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  69. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  70. 0,
  71. };
  72. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  73. AFE_API_VERSION_I2S_CONFIG,
  74. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  75. 0,
  76. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  77. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  78. Q6AFE_LPASS_MODE_CLK1_VALID,
  79. 0,
  80. };
  81. enum {
  82. STATUS_PORT_STARTED, /* track if AFE port has started */
  83. /* track AFE Tx port status for bi-directional transfers */
  84. STATUS_TX_PORT,
  85. /* track AFE Rx port status for bi-directional transfers */
  86. STATUS_RX_PORT,
  87. STATUS_MAX
  88. };
  89. enum {
  90. RATE_8KHZ,
  91. RATE_16KHZ,
  92. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  93. };
  94. enum {
  95. IDX_PRIMARY_TDM_RX_0,
  96. IDX_PRIMARY_TDM_RX_1,
  97. IDX_PRIMARY_TDM_RX_2,
  98. IDX_PRIMARY_TDM_RX_3,
  99. IDX_PRIMARY_TDM_RX_4,
  100. IDX_PRIMARY_TDM_RX_5,
  101. IDX_PRIMARY_TDM_RX_6,
  102. IDX_PRIMARY_TDM_RX_7,
  103. IDX_PRIMARY_TDM_TX_0,
  104. IDX_PRIMARY_TDM_TX_1,
  105. IDX_PRIMARY_TDM_TX_2,
  106. IDX_PRIMARY_TDM_TX_3,
  107. IDX_PRIMARY_TDM_TX_4,
  108. IDX_PRIMARY_TDM_TX_5,
  109. IDX_PRIMARY_TDM_TX_6,
  110. IDX_PRIMARY_TDM_TX_7,
  111. IDX_SECONDARY_TDM_RX_0,
  112. IDX_SECONDARY_TDM_RX_1,
  113. IDX_SECONDARY_TDM_RX_2,
  114. IDX_SECONDARY_TDM_RX_3,
  115. IDX_SECONDARY_TDM_RX_4,
  116. IDX_SECONDARY_TDM_RX_5,
  117. IDX_SECONDARY_TDM_RX_6,
  118. IDX_SECONDARY_TDM_RX_7,
  119. IDX_SECONDARY_TDM_TX_0,
  120. IDX_SECONDARY_TDM_TX_1,
  121. IDX_SECONDARY_TDM_TX_2,
  122. IDX_SECONDARY_TDM_TX_3,
  123. IDX_SECONDARY_TDM_TX_4,
  124. IDX_SECONDARY_TDM_TX_5,
  125. IDX_SECONDARY_TDM_TX_6,
  126. IDX_SECONDARY_TDM_TX_7,
  127. IDX_TERTIARY_TDM_RX_0,
  128. IDX_TERTIARY_TDM_RX_1,
  129. IDX_TERTIARY_TDM_RX_2,
  130. IDX_TERTIARY_TDM_RX_3,
  131. IDX_TERTIARY_TDM_RX_4,
  132. IDX_TERTIARY_TDM_RX_5,
  133. IDX_TERTIARY_TDM_RX_6,
  134. IDX_TERTIARY_TDM_RX_7,
  135. IDX_TERTIARY_TDM_TX_0,
  136. IDX_TERTIARY_TDM_TX_1,
  137. IDX_TERTIARY_TDM_TX_2,
  138. IDX_TERTIARY_TDM_TX_3,
  139. IDX_TERTIARY_TDM_TX_4,
  140. IDX_TERTIARY_TDM_TX_5,
  141. IDX_TERTIARY_TDM_TX_6,
  142. IDX_TERTIARY_TDM_TX_7,
  143. IDX_QUATERNARY_TDM_RX_0,
  144. IDX_QUATERNARY_TDM_RX_1,
  145. IDX_QUATERNARY_TDM_RX_2,
  146. IDX_QUATERNARY_TDM_RX_3,
  147. IDX_QUATERNARY_TDM_RX_4,
  148. IDX_QUATERNARY_TDM_RX_5,
  149. IDX_QUATERNARY_TDM_RX_6,
  150. IDX_QUATERNARY_TDM_RX_7,
  151. IDX_QUATERNARY_TDM_TX_0,
  152. IDX_QUATERNARY_TDM_TX_1,
  153. IDX_QUATERNARY_TDM_TX_2,
  154. IDX_QUATERNARY_TDM_TX_3,
  155. IDX_QUATERNARY_TDM_TX_4,
  156. IDX_QUATERNARY_TDM_TX_5,
  157. IDX_QUATERNARY_TDM_TX_6,
  158. IDX_QUATERNARY_TDM_TX_7,
  159. IDX_QUINARY_TDM_RX_0,
  160. IDX_QUINARY_TDM_RX_1,
  161. IDX_QUINARY_TDM_RX_2,
  162. IDX_QUINARY_TDM_RX_3,
  163. IDX_QUINARY_TDM_RX_4,
  164. IDX_QUINARY_TDM_RX_5,
  165. IDX_QUINARY_TDM_RX_6,
  166. IDX_QUINARY_TDM_RX_7,
  167. IDX_QUINARY_TDM_TX_0,
  168. IDX_QUINARY_TDM_TX_1,
  169. IDX_QUINARY_TDM_TX_2,
  170. IDX_QUINARY_TDM_TX_3,
  171. IDX_QUINARY_TDM_TX_4,
  172. IDX_QUINARY_TDM_TX_5,
  173. IDX_QUINARY_TDM_TX_6,
  174. IDX_QUINARY_TDM_TX_7,
  175. IDX_SENARY_TDM_RX_0,
  176. IDX_SENARY_TDM_RX_1,
  177. IDX_SENARY_TDM_RX_2,
  178. IDX_SENARY_TDM_RX_3,
  179. IDX_SENARY_TDM_RX_4,
  180. IDX_SENARY_TDM_RX_5,
  181. IDX_SENARY_TDM_RX_6,
  182. IDX_SENARY_TDM_RX_7,
  183. IDX_SENARY_TDM_TX_0,
  184. IDX_SENARY_TDM_TX_1,
  185. IDX_SENARY_TDM_TX_2,
  186. IDX_SENARY_TDM_TX_3,
  187. IDX_SENARY_TDM_TX_4,
  188. IDX_SENARY_TDM_TX_5,
  189. IDX_SENARY_TDM_TX_6,
  190. IDX_SENARY_TDM_TX_7,
  191. IDX_TDM_MAX,
  192. };
  193. enum {
  194. IDX_GROUP_PRIMARY_TDM_RX,
  195. IDX_GROUP_PRIMARY_TDM_TX,
  196. IDX_GROUP_SECONDARY_TDM_RX,
  197. IDX_GROUP_SECONDARY_TDM_TX,
  198. IDX_GROUP_TERTIARY_TDM_RX,
  199. IDX_GROUP_TERTIARY_TDM_TX,
  200. IDX_GROUP_QUATERNARY_TDM_RX,
  201. IDX_GROUP_QUATERNARY_TDM_TX,
  202. IDX_GROUP_QUINARY_TDM_RX,
  203. IDX_GROUP_QUINARY_TDM_TX,
  204. IDX_GROUP_SENARY_TDM_RX,
  205. IDX_GROUP_SENARY_TDM_TX,
  206. IDX_GROUP_TDM_MAX,
  207. };
  208. struct msm_dai_q6_dai_data {
  209. DECLARE_BITMAP(status_mask, STATUS_MAX);
  210. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  211. u32 rate;
  212. u32 channels;
  213. u32 bitwidth;
  214. u32 cal_mode;
  215. u32 afe_rx_in_channels;
  216. u16 afe_rx_in_bitformat;
  217. u32 afe_tx_out_channels;
  218. u16 afe_tx_out_bitformat;
  219. struct afe_enc_config enc_config;
  220. struct afe_dec_config dec_config;
  221. struct afe_ttp_config ttp_config;
  222. union afe_port_config port_config;
  223. u16 vi_feed_mono;
  224. u32 xt_logging_disable;
  225. };
  226. struct msm_dai_q6_spdif_dai_data {
  227. DECLARE_BITMAP(status_mask, STATUS_MAX);
  228. u32 rate;
  229. u32 channels;
  230. u32 bitwidth;
  231. u16 port_id;
  232. struct afe_spdif_port_config spdif_port;
  233. struct afe_event_fmt_update fmt_event;
  234. struct kobject *kobj;
  235. };
  236. struct msm_dai_q6_spdif_event_msg {
  237. struct afe_port_mod_evt_rsp_hdr evt_hdr;
  238. struct afe_event_fmt_update fmt_event;
  239. };
  240. struct msm_dai_q6_mi2s_dai_config {
  241. u16 pdata_mi2s_lines;
  242. struct msm_dai_q6_dai_data mi2s_dai_data;
  243. };
  244. struct msm_dai_q6_mi2s_dai_data {
  245. u32 is_island_dai;
  246. struct msm_dai_q6_mi2s_dai_config tx_dai;
  247. struct msm_dai_q6_mi2s_dai_config rx_dai;
  248. };
  249. struct msm_dai_q6_meta_mi2s_dai_data {
  250. DECLARE_BITMAP(status_mask, STATUS_MAX);
  251. u16 num_member_ports;
  252. u16 member_port_id[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  253. u16 channel_mode[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  254. u32 rate;
  255. u32 channels;
  256. u32 bitwidth;
  257. union afe_port_config port_config;
  258. };
  259. struct msm_dai_q6_cdc_dma_dai_data {
  260. DECLARE_BITMAP(status_mask, STATUS_MAX);
  261. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  262. u32 rate;
  263. u32 channels;
  264. u32 bitwidth;
  265. u32 is_island_dai;
  266. u32 xt_logging_disable;
  267. union afe_port_config port_config;
  268. u32 cdc_dma_data_align;
  269. };
  270. struct msm_dai_q6_auxpcm_dai_data {
  271. /* BITMAP to track Rx and Tx port usage count */
  272. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  273. struct mutex rlock; /* auxpcm dev resource lock */
  274. u16 rx_pid; /* AUXPCM RX AFE port ID */
  275. u16 tx_pid; /* AUXPCM TX AFE port ID */
  276. u16 afe_clk_ver;
  277. u32 is_island_dai;
  278. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  279. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  280. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  281. };
  282. struct msm_dai_q6_tdm_dai_data {
  283. DECLARE_BITMAP(status_mask, STATUS_MAX);
  284. u32 rate;
  285. u32 channels;
  286. u32 bitwidth;
  287. u32 num_group_ports;
  288. u32 is_island_dai;
  289. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  290. union afe_port_group_config group_cfg; /* hold tdm group config */
  291. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  292. struct afe_param_id_tdm_lane_cfg lane_cfg; /* hold tdm lane config */
  293. };
  294. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  295. * 0: linear PCM
  296. * 1: non-linear PCM
  297. * 2: PCM data in IEC 60968 container
  298. * 3: compressed data in IEC 60958 container
  299. * 9: DSD over PCM (DoP) with marker byte
  300. */
  301. static const char *const mi2s_format[] = {
  302. "LPCM",
  303. "Compr",
  304. "LPCM-60958",
  305. "Compr-60958",
  306. "NA4",
  307. "NA5",
  308. "NA6",
  309. "NA7",
  310. "NA8",
  311. "DSD_DOP_W_MARKER"
  312. };
  313. static const char *const mi2s_vi_feed_mono[] = {
  314. "Left",
  315. "Right",
  316. };
  317. static const struct soc_enum mi2s_config_enum[] = {
  318. SOC_ENUM_SINGLE_EXT(10, mi2s_format),
  319. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  320. };
  321. static const char *const cdc_dma_format[] = {
  322. "UNPACKED",
  323. "PACKED_16B",
  324. };
  325. static const struct soc_enum cdc_dma_config_enum[] = {
  326. SOC_ENUM_SINGLE_EXT(2, cdc_dma_format),
  327. };
  328. static const char *const sb_format[] = {
  329. "UNPACKED",
  330. "PACKED_16B",
  331. "DSD_DOP",
  332. };
  333. static const struct soc_enum sb_config_enum[] = {
  334. SOC_ENUM_SINGLE_EXT(3, sb_format),
  335. };
  336. static const char * const xt_logging_disable_text[] = {
  337. "FALSE",
  338. "TRUE",
  339. };
  340. static const struct soc_enum xt_logging_disable_enum[] = {
  341. SOC_ENUM_SINGLE_EXT(2, xt_logging_disable_text),
  342. };
  343. static const char *const tdm_data_format[] = {
  344. "LPCM",
  345. "Compr",
  346. "Gen Compr"
  347. };
  348. static const char *const tdm_header_type[] = {
  349. "Invalid",
  350. "Default",
  351. "Entertainment",
  352. };
  353. static const struct soc_enum tdm_config_enum[] = {
  354. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  355. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  356. };
  357. static DEFINE_MUTEX(tdm_mutex);
  358. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  359. static struct afe_param_id_tdm_lane_cfg tdm_lane_cfg = {
  360. AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX,
  361. 0x0,
  362. };
  363. /* cache of group cfg per parent node */
  364. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  365. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  366. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  367. 0,
  368. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  369. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  370. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  371. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  372. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  373. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  374. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  375. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  376. 8,
  377. 48000,
  378. 32,
  379. 8,
  380. 32,
  381. 0xFF,
  382. };
  383. static u32 num_tdm_group_ports;
  384. static struct afe_clk_set tdm_clk_set = {
  385. AFE_API_VERSION_CLOCK_SET,
  386. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  387. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  388. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  389. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  390. 0,
  391. };
  392. static int msm_dai_q6_get_tdm_clk_ref(u16 id)
  393. {
  394. switch (id) {
  395. case IDX_GROUP_PRIMARY_TDM_RX:
  396. case IDX_GROUP_PRIMARY_TDM_TX:
  397. return atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_RX]) +
  398. atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_TX]);
  399. case IDX_GROUP_SECONDARY_TDM_RX:
  400. case IDX_GROUP_SECONDARY_TDM_TX:
  401. return atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_RX]) +
  402. atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_TX]);
  403. case IDX_GROUP_TERTIARY_TDM_RX:
  404. case IDX_GROUP_TERTIARY_TDM_TX:
  405. return atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_RX]) +
  406. atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_TX]);
  407. case IDX_GROUP_QUATERNARY_TDM_RX:
  408. case IDX_GROUP_QUATERNARY_TDM_TX:
  409. return atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_RX]) +
  410. atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_TX]);
  411. case IDX_GROUP_QUINARY_TDM_RX:
  412. case IDX_GROUP_QUINARY_TDM_TX:
  413. return atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_RX]) +
  414. atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_TX]);
  415. case IDX_GROUP_SENARY_TDM_RX:
  416. case IDX_GROUP_SENARY_TDM_TX:
  417. return atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_RX]) +
  418. atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_TX]);
  419. default: return -EINVAL;
  420. }
  421. }
  422. int msm_dai_q6_get_group_idx(u16 id)
  423. {
  424. switch (id) {
  425. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  426. case AFE_PORT_ID_PRIMARY_TDM_RX:
  427. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  428. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  429. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  430. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  431. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  432. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  433. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  434. return IDX_GROUP_PRIMARY_TDM_RX;
  435. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  436. case AFE_PORT_ID_PRIMARY_TDM_TX:
  437. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  438. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  439. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  440. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  441. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  442. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  443. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  444. return IDX_GROUP_PRIMARY_TDM_TX;
  445. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  446. case AFE_PORT_ID_SECONDARY_TDM_RX:
  447. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  448. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  449. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  450. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  451. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  452. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  453. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  454. return IDX_GROUP_SECONDARY_TDM_RX;
  455. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  456. case AFE_PORT_ID_SECONDARY_TDM_TX:
  457. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  458. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  459. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  460. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  461. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  462. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  463. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  464. return IDX_GROUP_SECONDARY_TDM_TX;
  465. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  466. case AFE_PORT_ID_TERTIARY_TDM_RX:
  467. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  468. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  469. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  470. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  471. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  472. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  473. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  474. return IDX_GROUP_TERTIARY_TDM_RX;
  475. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  476. case AFE_PORT_ID_TERTIARY_TDM_TX:
  477. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  478. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  479. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  480. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  481. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  482. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  483. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  484. return IDX_GROUP_TERTIARY_TDM_TX;
  485. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  486. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  487. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  488. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  489. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  490. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  491. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  492. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  493. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  494. return IDX_GROUP_QUATERNARY_TDM_RX;
  495. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  496. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  497. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  498. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  499. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  500. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  501. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  502. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  503. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  504. return IDX_GROUP_QUATERNARY_TDM_TX;
  505. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  506. case AFE_PORT_ID_QUINARY_TDM_RX:
  507. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  508. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  509. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  510. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  511. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  512. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  513. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  514. return IDX_GROUP_QUINARY_TDM_RX;
  515. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  516. case AFE_PORT_ID_QUINARY_TDM_TX:
  517. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  518. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  519. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  520. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  521. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  522. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  523. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  524. return IDX_GROUP_QUINARY_TDM_TX;
  525. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  526. case AFE_PORT_ID_SENARY_TDM_RX:
  527. case AFE_PORT_ID_SENARY_TDM_RX_1:
  528. case AFE_PORT_ID_SENARY_TDM_RX_2:
  529. case AFE_PORT_ID_SENARY_TDM_RX_3:
  530. case AFE_PORT_ID_SENARY_TDM_RX_4:
  531. case AFE_PORT_ID_SENARY_TDM_RX_5:
  532. case AFE_PORT_ID_SENARY_TDM_RX_6:
  533. case AFE_PORT_ID_SENARY_TDM_RX_7:
  534. return IDX_GROUP_SENARY_TDM_RX;
  535. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  536. case AFE_PORT_ID_SENARY_TDM_TX:
  537. case AFE_PORT_ID_SENARY_TDM_TX_1:
  538. case AFE_PORT_ID_SENARY_TDM_TX_2:
  539. case AFE_PORT_ID_SENARY_TDM_TX_3:
  540. case AFE_PORT_ID_SENARY_TDM_TX_4:
  541. case AFE_PORT_ID_SENARY_TDM_TX_5:
  542. case AFE_PORT_ID_SENARY_TDM_TX_6:
  543. case AFE_PORT_ID_SENARY_TDM_TX_7:
  544. return IDX_GROUP_SENARY_TDM_TX;
  545. default: return -EINVAL;
  546. }
  547. }
  548. int msm_dai_q6_get_port_idx(u16 id)
  549. {
  550. switch (id) {
  551. case AFE_PORT_ID_PRIMARY_TDM_RX:
  552. return IDX_PRIMARY_TDM_RX_0;
  553. case AFE_PORT_ID_PRIMARY_TDM_TX:
  554. return IDX_PRIMARY_TDM_TX_0;
  555. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  556. return IDX_PRIMARY_TDM_RX_1;
  557. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  558. return IDX_PRIMARY_TDM_TX_1;
  559. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  560. return IDX_PRIMARY_TDM_RX_2;
  561. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  562. return IDX_PRIMARY_TDM_TX_2;
  563. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  564. return IDX_PRIMARY_TDM_RX_3;
  565. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  566. return IDX_PRIMARY_TDM_TX_3;
  567. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  568. return IDX_PRIMARY_TDM_RX_4;
  569. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  570. return IDX_PRIMARY_TDM_TX_4;
  571. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  572. return IDX_PRIMARY_TDM_RX_5;
  573. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  574. return IDX_PRIMARY_TDM_TX_5;
  575. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  576. return IDX_PRIMARY_TDM_RX_6;
  577. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  578. return IDX_PRIMARY_TDM_TX_6;
  579. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  580. return IDX_PRIMARY_TDM_RX_7;
  581. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  582. return IDX_PRIMARY_TDM_TX_7;
  583. case AFE_PORT_ID_SECONDARY_TDM_RX:
  584. return IDX_SECONDARY_TDM_RX_0;
  585. case AFE_PORT_ID_SECONDARY_TDM_TX:
  586. return IDX_SECONDARY_TDM_TX_0;
  587. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  588. return IDX_SECONDARY_TDM_RX_1;
  589. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  590. return IDX_SECONDARY_TDM_TX_1;
  591. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  592. return IDX_SECONDARY_TDM_RX_2;
  593. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  594. return IDX_SECONDARY_TDM_TX_2;
  595. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  596. return IDX_SECONDARY_TDM_RX_3;
  597. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  598. return IDX_SECONDARY_TDM_TX_3;
  599. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  600. return IDX_SECONDARY_TDM_RX_4;
  601. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  602. return IDX_SECONDARY_TDM_TX_4;
  603. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  604. return IDX_SECONDARY_TDM_RX_5;
  605. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  606. return IDX_SECONDARY_TDM_TX_5;
  607. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  608. return IDX_SECONDARY_TDM_RX_6;
  609. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  610. return IDX_SECONDARY_TDM_TX_6;
  611. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  612. return IDX_SECONDARY_TDM_RX_7;
  613. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  614. return IDX_SECONDARY_TDM_TX_7;
  615. case AFE_PORT_ID_TERTIARY_TDM_RX:
  616. return IDX_TERTIARY_TDM_RX_0;
  617. case AFE_PORT_ID_TERTIARY_TDM_TX:
  618. return IDX_TERTIARY_TDM_TX_0;
  619. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  620. return IDX_TERTIARY_TDM_RX_1;
  621. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  622. return IDX_TERTIARY_TDM_TX_1;
  623. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  624. return IDX_TERTIARY_TDM_RX_2;
  625. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  626. return IDX_TERTIARY_TDM_TX_2;
  627. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  628. return IDX_TERTIARY_TDM_RX_3;
  629. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  630. return IDX_TERTIARY_TDM_TX_3;
  631. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  632. return IDX_TERTIARY_TDM_RX_4;
  633. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  634. return IDX_TERTIARY_TDM_TX_4;
  635. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  636. return IDX_TERTIARY_TDM_RX_5;
  637. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  638. return IDX_TERTIARY_TDM_TX_5;
  639. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  640. return IDX_TERTIARY_TDM_RX_6;
  641. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  642. return IDX_TERTIARY_TDM_TX_6;
  643. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  644. return IDX_TERTIARY_TDM_RX_7;
  645. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  646. return IDX_TERTIARY_TDM_TX_7;
  647. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  648. return IDX_QUATERNARY_TDM_RX_0;
  649. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  650. return IDX_QUATERNARY_TDM_TX_0;
  651. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  652. return IDX_QUATERNARY_TDM_RX_1;
  653. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  654. return IDX_QUATERNARY_TDM_TX_1;
  655. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  656. return IDX_QUATERNARY_TDM_RX_2;
  657. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  658. return IDX_QUATERNARY_TDM_TX_2;
  659. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  660. return IDX_QUATERNARY_TDM_RX_3;
  661. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  662. return IDX_QUATERNARY_TDM_TX_3;
  663. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  664. return IDX_QUATERNARY_TDM_RX_4;
  665. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  666. return IDX_QUATERNARY_TDM_TX_4;
  667. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  668. return IDX_QUATERNARY_TDM_RX_5;
  669. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  670. return IDX_QUATERNARY_TDM_TX_5;
  671. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  672. return IDX_QUATERNARY_TDM_RX_6;
  673. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  674. return IDX_QUATERNARY_TDM_TX_6;
  675. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  676. return IDX_QUATERNARY_TDM_RX_7;
  677. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  678. return IDX_QUATERNARY_TDM_TX_7;
  679. case AFE_PORT_ID_QUINARY_TDM_RX:
  680. return IDX_QUINARY_TDM_RX_0;
  681. case AFE_PORT_ID_QUINARY_TDM_TX:
  682. return IDX_QUINARY_TDM_TX_0;
  683. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  684. return IDX_QUINARY_TDM_RX_1;
  685. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  686. return IDX_QUINARY_TDM_TX_1;
  687. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  688. return IDX_QUINARY_TDM_RX_2;
  689. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  690. return IDX_QUINARY_TDM_TX_2;
  691. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  692. return IDX_QUINARY_TDM_RX_3;
  693. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  694. return IDX_QUINARY_TDM_TX_3;
  695. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  696. return IDX_QUINARY_TDM_RX_4;
  697. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  698. return IDX_QUINARY_TDM_TX_4;
  699. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  700. return IDX_QUINARY_TDM_RX_5;
  701. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  702. return IDX_QUINARY_TDM_TX_5;
  703. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  704. return IDX_QUINARY_TDM_RX_6;
  705. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  706. return IDX_QUINARY_TDM_TX_6;
  707. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  708. return IDX_QUINARY_TDM_RX_7;
  709. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  710. return IDX_QUINARY_TDM_TX_7;
  711. case AFE_PORT_ID_SENARY_TDM_RX:
  712. return IDX_SENARY_TDM_RX_0;
  713. case AFE_PORT_ID_SENARY_TDM_TX:
  714. return IDX_SENARY_TDM_TX_0;
  715. case AFE_PORT_ID_SENARY_TDM_RX_1:
  716. return IDX_SENARY_TDM_RX_1;
  717. case AFE_PORT_ID_SENARY_TDM_TX_1:
  718. return IDX_SENARY_TDM_TX_1;
  719. case AFE_PORT_ID_SENARY_TDM_RX_2:
  720. return IDX_SENARY_TDM_RX_2;
  721. case AFE_PORT_ID_SENARY_TDM_TX_2:
  722. return IDX_SENARY_TDM_TX_2;
  723. case AFE_PORT_ID_SENARY_TDM_RX_3:
  724. return IDX_SENARY_TDM_RX_3;
  725. case AFE_PORT_ID_SENARY_TDM_TX_3:
  726. return IDX_SENARY_TDM_TX_3;
  727. case AFE_PORT_ID_SENARY_TDM_RX_4:
  728. return IDX_SENARY_TDM_RX_4;
  729. case AFE_PORT_ID_SENARY_TDM_TX_4:
  730. return IDX_SENARY_TDM_TX_4;
  731. case AFE_PORT_ID_SENARY_TDM_RX_5:
  732. return IDX_SENARY_TDM_RX_5;
  733. case AFE_PORT_ID_SENARY_TDM_TX_5:
  734. return IDX_SENARY_TDM_TX_5;
  735. case AFE_PORT_ID_SENARY_TDM_RX_6:
  736. return IDX_SENARY_TDM_RX_6;
  737. case AFE_PORT_ID_SENARY_TDM_TX_6:
  738. return IDX_SENARY_TDM_TX_6;
  739. case AFE_PORT_ID_SENARY_TDM_RX_7:
  740. return IDX_SENARY_TDM_RX_7;
  741. case AFE_PORT_ID_SENARY_TDM_TX_7:
  742. return IDX_SENARY_TDM_TX_7;
  743. default: return -EINVAL;
  744. }
  745. }
  746. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  747. {
  748. /* Max num of slots is bits per frame divided
  749. * by bits per sample which is 16
  750. */
  751. switch (frame_rate) {
  752. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  753. return 0;
  754. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  755. return 1;
  756. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  757. return 2;
  758. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  759. return 4;
  760. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  761. return 8;
  762. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  763. return 16;
  764. default:
  765. pr_err("%s Invalid bits per frame %d\n",
  766. __func__, frame_rate);
  767. return 0;
  768. }
  769. }
  770. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  771. {
  772. struct snd_soc_dapm_route intercon;
  773. struct snd_soc_dapm_context *dapm;
  774. if (!dai) {
  775. pr_err("%s: Invalid params dai\n", __func__);
  776. return -EINVAL;
  777. }
  778. if (!dai->driver) {
  779. pr_err("%s: Invalid params dai driver\n", __func__);
  780. return -EINVAL;
  781. }
  782. dapm = snd_soc_component_get_dapm(dai->component);
  783. memset(&intercon, 0, sizeof(intercon));
  784. if (dai->driver->playback.stream_name &&
  785. dai->driver->playback.aif_name) {
  786. dev_dbg(dai->dev, "%s: add route for widget %s",
  787. __func__, dai->driver->playback.stream_name);
  788. intercon.source = dai->driver->playback.aif_name;
  789. intercon.sink = dai->driver->playback.stream_name;
  790. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  791. __func__, intercon.source, intercon.sink);
  792. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  793. snd_soc_dapm_ignore_suspend(dapm, intercon.sink);
  794. }
  795. if (dai->driver->capture.stream_name &&
  796. dai->driver->capture.aif_name) {
  797. dev_dbg(dai->dev, "%s: add route for widget %s",
  798. __func__, dai->driver->capture.stream_name);
  799. intercon.sink = dai->driver->capture.aif_name;
  800. intercon.source = dai->driver->capture.stream_name;
  801. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  802. __func__, intercon.source, intercon.sink);
  803. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  804. snd_soc_dapm_ignore_suspend(dapm, intercon.source);
  805. }
  806. return 0;
  807. }
  808. static int msm_dai_q6_auxpcm_hw_params(
  809. struct snd_pcm_substream *substream,
  810. struct snd_pcm_hw_params *params,
  811. struct snd_soc_dai *dai)
  812. {
  813. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  814. dev_get_drvdata(dai->dev);
  815. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  816. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  817. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  818. int rc = 0, slot_mapping_copy_len = 0;
  819. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  820. params_rate(params) != 16000)) {
  821. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  822. __func__, params_channels(params), params_rate(params));
  823. return -EINVAL;
  824. }
  825. mutex_lock(&aux_dai_data->rlock);
  826. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  827. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  828. /* AUXPCM DAI in use */
  829. if (dai_data->rate != params_rate(params)) {
  830. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  831. __func__);
  832. rc = -EINVAL;
  833. }
  834. mutex_unlock(&aux_dai_data->rlock);
  835. return rc;
  836. }
  837. dai_data->channels = params_channels(params);
  838. dai_data->rate = params_rate(params);
  839. if (dai_data->rate == 8000) {
  840. dai_data->port_config.pcm.pcm_cfg_minor_version =
  841. AFE_API_VERSION_PCM_CONFIG;
  842. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  843. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  844. dai_data->port_config.pcm.frame_setting =
  845. auxpcm_pdata->mode_8k.frame;
  846. dai_data->port_config.pcm.quantype =
  847. auxpcm_pdata->mode_8k.quant;
  848. dai_data->port_config.pcm.ctrl_data_out_enable =
  849. auxpcm_pdata->mode_8k.data;
  850. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  851. dai_data->port_config.pcm.num_channels = dai_data->channels;
  852. dai_data->port_config.pcm.bit_width = 16;
  853. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  854. auxpcm_pdata->mode_8k.num_slots)
  855. slot_mapping_copy_len =
  856. ARRAY_SIZE(
  857. dai_data->port_config.pcm.slot_number_mapping)
  858. * sizeof(uint16_t);
  859. else
  860. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  861. * sizeof(uint16_t);
  862. if (auxpcm_pdata->mode_8k.slot_mapping) {
  863. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  864. auxpcm_pdata->mode_8k.slot_mapping,
  865. slot_mapping_copy_len);
  866. } else {
  867. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  868. __func__);
  869. mutex_unlock(&aux_dai_data->rlock);
  870. return -EINVAL;
  871. }
  872. } else {
  873. dai_data->port_config.pcm.pcm_cfg_minor_version =
  874. AFE_API_VERSION_PCM_CONFIG;
  875. dai_data->port_config.pcm.aux_mode =
  876. auxpcm_pdata->mode_16k.mode;
  877. dai_data->port_config.pcm.sync_src =
  878. auxpcm_pdata->mode_16k.sync;
  879. dai_data->port_config.pcm.frame_setting =
  880. auxpcm_pdata->mode_16k.frame;
  881. dai_data->port_config.pcm.quantype =
  882. auxpcm_pdata->mode_16k.quant;
  883. dai_data->port_config.pcm.ctrl_data_out_enable =
  884. auxpcm_pdata->mode_16k.data;
  885. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  886. dai_data->port_config.pcm.num_channels = dai_data->channels;
  887. dai_data->port_config.pcm.bit_width = 16;
  888. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  889. auxpcm_pdata->mode_16k.num_slots)
  890. slot_mapping_copy_len =
  891. ARRAY_SIZE(
  892. dai_data->port_config.pcm.slot_number_mapping)
  893. * sizeof(uint16_t);
  894. else
  895. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  896. * sizeof(uint16_t);
  897. if (auxpcm_pdata->mode_16k.slot_mapping) {
  898. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  899. auxpcm_pdata->mode_16k.slot_mapping,
  900. slot_mapping_copy_len);
  901. } else {
  902. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  903. __func__);
  904. mutex_unlock(&aux_dai_data->rlock);
  905. return -EINVAL;
  906. }
  907. }
  908. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  909. __func__, dai_data->port_config.pcm.aux_mode,
  910. dai_data->port_config.pcm.sync_src,
  911. dai_data->port_config.pcm.frame_setting);
  912. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  913. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  914. __func__, dai_data->port_config.pcm.quantype,
  915. dai_data->port_config.pcm.ctrl_data_out_enable,
  916. dai_data->port_config.pcm.slot_number_mapping[0],
  917. dai_data->port_config.pcm.slot_number_mapping[1],
  918. dai_data->port_config.pcm.slot_number_mapping[2],
  919. dai_data->port_config.pcm.slot_number_mapping[3]);
  920. mutex_unlock(&aux_dai_data->rlock);
  921. return rc;
  922. }
  923. static int msm_dai_q6_auxpcm_set_clk(
  924. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  925. u16 port_id, bool enable)
  926. {
  927. int rc;
  928. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  929. aux_dai_data->afe_clk_ver, port_id, enable);
  930. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  931. aux_dai_data->clk_set.enable = enable;
  932. rc = afe_set_lpass_clock_v2(port_id,
  933. &aux_dai_data->clk_set);
  934. } else {
  935. if (!enable)
  936. aux_dai_data->clk_cfg.clk_val1 = 0;
  937. rc = afe_set_lpass_clock(port_id,
  938. &aux_dai_data->clk_cfg);
  939. }
  940. return rc;
  941. }
  942. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  943. struct snd_soc_dai *dai)
  944. {
  945. int rc = 0;
  946. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  947. dev_get_drvdata(dai->dev);
  948. mutex_lock(&aux_dai_data->rlock);
  949. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  950. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  951. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  952. __func__, dai->id);
  953. goto exit;
  954. }
  955. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  956. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  957. clear_bit(STATUS_TX_PORT,
  958. aux_dai_data->auxpcm_port_status);
  959. else {
  960. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  961. __func__);
  962. goto exit;
  963. }
  964. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  965. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  966. clear_bit(STATUS_RX_PORT,
  967. aux_dai_data->auxpcm_port_status);
  968. else {
  969. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  970. __func__);
  971. goto exit;
  972. }
  973. }
  974. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  975. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  976. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  977. __func__);
  978. goto exit;
  979. }
  980. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  981. __func__, dai->id);
  982. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  983. if (rc < 0)
  984. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  985. rc = afe_close(aux_dai_data->tx_pid);
  986. if (rc < 0)
  987. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  988. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  989. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  990. exit:
  991. mutex_unlock(&aux_dai_data->rlock);
  992. }
  993. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  994. struct snd_soc_dai *dai)
  995. {
  996. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  997. dev_get_drvdata(dai->dev);
  998. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  999. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  1000. int rc = 0;
  1001. u32 pcm_clk_rate;
  1002. auxpcm_pdata = dai->dev->platform_data;
  1003. mutex_lock(&aux_dai_data->rlock);
  1004. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  1005. if (test_bit(STATUS_TX_PORT,
  1006. aux_dai_data->auxpcm_port_status)) {
  1007. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  1008. __func__);
  1009. goto exit;
  1010. } else
  1011. set_bit(STATUS_TX_PORT,
  1012. aux_dai_data->auxpcm_port_status);
  1013. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1014. if (test_bit(STATUS_RX_PORT,
  1015. aux_dai_data->auxpcm_port_status)) {
  1016. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  1017. __func__);
  1018. goto exit;
  1019. } else
  1020. set_bit(STATUS_RX_PORT,
  1021. aux_dai_data->auxpcm_port_status);
  1022. }
  1023. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  1024. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1025. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  1026. goto exit;
  1027. }
  1028. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  1029. __func__, dai->id);
  1030. rc = afe_q6_interface_prepare();
  1031. if (rc < 0) {
  1032. dev_err(dai->dev, "fail to open AFE APR\n");
  1033. goto fail;
  1034. }
  1035. /*
  1036. * For AUX PCM Interface the below sequence of clk
  1037. * settings and afe_open is a strict requirement.
  1038. *
  1039. * Also using afe_open instead of afe_port_start_nowait
  1040. * to make sure the port is open before deasserting the
  1041. * clock line. This is required because pcm register is
  1042. * not written before clock deassert. Hence the hw does
  1043. * not get updated with new setting if the below clock
  1044. * assert/deasset and afe_open sequence is not followed.
  1045. */
  1046. if (dai_data->rate == 8000) {
  1047. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  1048. } else if (dai_data->rate == 16000) {
  1049. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  1050. } else {
  1051. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  1052. dai_data->rate);
  1053. rc = -EINVAL;
  1054. goto fail;
  1055. }
  1056. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  1057. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  1058. sizeof(struct afe_clk_set));
  1059. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  1060. switch (dai->id) {
  1061. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  1062. if (pcm_clk_rate)
  1063. aux_dai_data->clk_set.clk_id =
  1064. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  1065. else
  1066. aux_dai_data->clk_set.clk_id =
  1067. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  1068. break;
  1069. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  1070. if (pcm_clk_rate)
  1071. aux_dai_data->clk_set.clk_id =
  1072. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  1073. else
  1074. aux_dai_data->clk_set.clk_id =
  1075. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  1076. break;
  1077. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  1078. if (pcm_clk_rate)
  1079. aux_dai_data->clk_set.clk_id =
  1080. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  1081. else
  1082. aux_dai_data->clk_set.clk_id =
  1083. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  1084. break;
  1085. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  1086. if (pcm_clk_rate)
  1087. aux_dai_data->clk_set.clk_id =
  1088. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  1089. else
  1090. aux_dai_data->clk_set.clk_id =
  1091. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  1092. break;
  1093. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  1094. if (pcm_clk_rate)
  1095. aux_dai_data->clk_set.clk_id =
  1096. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  1097. else
  1098. aux_dai_data->clk_set.clk_id =
  1099. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  1100. break;
  1101. case MSM_DAI_SEN_AUXPCM_DT_DEV_ID:
  1102. if (pcm_clk_rate)
  1103. aux_dai_data->clk_set.clk_id =
  1104. Q6AFE_LPASS_CLK_ID_SEN_PCM_IBIT;
  1105. else
  1106. aux_dai_data->clk_set.clk_id =
  1107. Q6AFE_LPASS_CLK_ID_SEN_PCM_EBIT;
  1108. break;
  1109. default:
  1110. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  1111. __func__, dai->id);
  1112. break;
  1113. }
  1114. } else {
  1115. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  1116. sizeof(struct afe_clk_cfg));
  1117. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  1118. }
  1119. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1120. aux_dai_data->rx_pid, true);
  1121. if (rc < 0) {
  1122. dev_err(dai->dev,
  1123. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  1124. __func__);
  1125. goto fail;
  1126. }
  1127. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1128. aux_dai_data->tx_pid, true);
  1129. if (rc < 0) {
  1130. dev_err(dai->dev,
  1131. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  1132. __func__);
  1133. goto fail;
  1134. }
  1135. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  1136. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  1137. goto exit;
  1138. fail:
  1139. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  1140. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1141. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  1142. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1143. exit:
  1144. mutex_unlock(&aux_dai_data->rlock);
  1145. return rc;
  1146. }
  1147. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  1148. int cmd, struct snd_soc_dai *dai)
  1149. {
  1150. int rc = 0;
  1151. pr_debug("%s:port:%d cmd:%d\n",
  1152. __func__, dai->id, cmd);
  1153. switch (cmd) {
  1154. case SNDRV_PCM_TRIGGER_START:
  1155. case SNDRV_PCM_TRIGGER_RESUME:
  1156. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  1157. /* afe_open will be called from prepare */
  1158. return 0;
  1159. case SNDRV_PCM_TRIGGER_STOP:
  1160. case SNDRV_PCM_TRIGGER_SUSPEND:
  1161. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  1162. return 0;
  1163. default:
  1164. pr_err("%s: cmd %d\n", __func__, cmd);
  1165. rc = -EINVAL;
  1166. }
  1167. return rc;
  1168. }
  1169. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  1170. {
  1171. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  1172. int rc;
  1173. aux_dai_data = dev_get_drvdata(dai->dev);
  1174. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  1175. __func__, dai->id);
  1176. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  1177. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1178. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  1179. if (rc < 0)
  1180. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  1181. rc = afe_close(aux_dai_data->tx_pid);
  1182. if (rc < 0)
  1183. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1184. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1185. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1186. }
  1187. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1188. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1189. return 0;
  1190. }
  1191. static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol,
  1192. struct snd_ctl_elem_value *ucontrol)
  1193. {
  1194. int value = ucontrol->value.integer.value[0];
  1195. u16 port_id = (u16)kcontrol->private_value;
  1196. pr_debug("%s: island mode = %d\n", __func__, value);
  1197. trace_printk("%s: island mode = %d\n", __func__, value);
  1198. afe_set_island_mode_cfg(port_id, value);
  1199. return 0;
  1200. }
  1201. static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol,
  1202. struct snd_ctl_elem_value *ucontrol)
  1203. {
  1204. int value;
  1205. u16 port_id = (u16)kcontrol->private_value;
  1206. afe_get_island_mode_cfg(port_id, &value);
  1207. ucontrol->value.integer.value[0] = value;
  1208. return 0;
  1209. }
  1210. static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1211. {
  1212. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1213. kfree(knew);
  1214. }
  1215. static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card,
  1216. const char *dai_name,
  1217. int dai_id, void *dai_data)
  1218. {
  1219. const char *mx_ctl_name = "TX island";
  1220. char *mixer_str = NULL;
  1221. int dai_str_len = 0, ctl_len = 0;
  1222. int rc = 0;
  1223. struct snd_kcontrol_new *knew = NULL;
  1224. struct snd_kcontrol *kctl = NULL;
  1225. dai_str_len = strlen(dai_name) + 1;
  1226. /* Add island related mixer controls */
  1227. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1228. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1229. if (!mixer_str)
  1230. return -ENOMEM;
  1231. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1232. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1233. if (!knew) {
  1234. kfree(mixer_str);
  1235. return -ENOMEM;
  1236. }
  1237. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1238. knew->info = snd_ctl_boolean_mono_info;
  1239. knew->get = msm_dai_q6_island_mode_get;
  1240. knew->put = msm_dai_q6_island_mode_put;
  1241. knew->name = mixer_str;
  1242. knew->private_value = dai_id;
  1243. kctl = snd_ctl_new1(knew, knew);
  1244. if (!kctl) {
  1245. kfree(knew);
  1246. kfree(mixer_str);
  1247. return -ENOMEM;
  1248. }
  1249. kctl->private_free = island_mx_ctl_private_free;
  1250. rc = snd_ctl_add(card, kctl);
  1251. if (rc < 0)
  1252. pr_err("%s: err add config ctl, DAI = %s\n",
  1253. __func__, dai_name);
  1254. kfree(mixer_str);
  1255. return rc;
  1256. }
  1257. /*
  1258. * For single CPU DAI registration, the dai id needs to be
  1259. * set explicitly in the dai probe as ASoC does not read
  1260. * the cpu->driver->id field rather it assigns the dai id
  1261. * from the device name that is in the form %s.%d. This dai
  1262. * id should be assigned to back-end AFE port id and used
  1263. * during dai prepare. For multiple dai registration, it
  1264. * is not required to call this function, however the dai->
  1265. * driver->id field must be defined and set to corresponding
  1266. * AFE Port id.
  1267. */
  1268. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  1269. {
  1270. if (!dai->driver) {
  1271. dev_err(dai->dev, "DAI driver is not set\n");
  1272. return;
  1273. }
  1274. if (!dai->driver->id) {
  1275. dev_dbg(dai->dev, "DAI driver id is not set\n");
  1276. return;
  1277. }
  1278. dai->id = dai->driver->id;
  1279. }
  1280. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1281. {
  1282. int rc = 0;
  1283. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  1284. if (!dai) {
  1285. pr_err("%s: Invalid params dai\n", __func__);
  1286. return -EINVAL;
  1287. }
  1288. if (!dai->dev) {
  1289. pr_err("%s: Invalid params dai dev\n", __func__);
  1290. return -EINVAL;
  1291. }
  1292. msm_dai_q6_set_dai_id(dai);
  1293. dai_data = dev_get_drvdata(dai->dev);
  1294. if (dai_data->is_island_dai)
  1295. rc = msm_dai_q6_add_island_mx_ctls(
  1296. dai->component->card->snd_card,
  1297. dai->name, dai_data->tx_pid,
  1298. (void *)dai_data);
  1299. rc = msm_dai_q6_dai_add_route(dai);
  1300. return rc;
  1301. }
  1302. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1303. .prepare = msm_dai_q6_auxpcm_prepare,
  1304. .trigger = msm_dai_q6_auxpcm_trigger,
  1305. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1306. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1307. };
  1308. static const struct snd_soc_component_driver
  1309. msm_dai_q6_aux_pcm_dai_component = {
  1310. .name = "msm-auxpcm-dev",
  1311. };
  1312. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1313. {
  1314. .playback = {
  1315. .stream_name = "AUX PCM Playback",
  1316. .aif_name = "AUX_PCM_RX",
  1317. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1318. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1319. .channels_min = 1,
  1320. .channels_max = 1,
  1321. .rate_max = 16000,
  1322. .rate_min = 8000,
  1323. },
  1324. .capture = {
  1325. .stream_name = "AUX PCM Capture",
  1326. .aif_name = "AUX_PCM_TX",
  1327. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1328. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1329. .channels_min = 1,
  1330. .channels_max = 1,
  1331. .rate_max = 16000,
  1332. .rate_min = 8000,
  1333. },
  1334. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1335. .name = "Pri AUX PCM",
  1336. .ops = &msm_dai_q6_auxpcm_ops,
  1337. .probe = msm_dai_q6_aux_pcm_probe,
  1338. .remove = msm_dai_q6_dai_auxpcm_remove,
  1339. },
  1340. {
  1341. .playback = {
  1342. .stream_name = "Sec AUX PCM Playback",
  1343. .aif_name = "SEC_AUX_PCM_RX",
  1344. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1345. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1346. .channels_min = 1,
  1347. .channels_max = 1,
  1348. .rate_max = 16000,
  1349. .rate_min = 8000,
  1350. },
  1351. .capture = {
  1352. .stream_name = "Sec AUX PCM Capture",
  1353. .aif_name = "SEC_AUX_PCM_TX",
  1354. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1355. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1356. .channels_min = 1,
  1357. .channels_max = 1,
  1358. .rate_max = 16000,
  1359. .rate_min = 8000,
  1360. },
  1361. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1362. .name = "Sec AUX PCM",
  1363. .ops = &msm_dai_q6_auxpcm_ops,
  1364. .probe = msm_dai_q6_aux_pcm_probe,
  1365. .remove = msm_dai_q6_dai_auxpcm_remove,
  1366. },
  1367. {
  1368. .playback = {
  1369. .stream_name = "Tert AUX PCM Playback",
  1370. .aif_name = "TERT_AUX_PCM_RX",
  1371. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1372. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1373. .channels_min = 1,
  1374. .channels_max = 1,
  1375. .rate_max = 16000,
  1376. .rate_min = 8000,
  1377. },
  1378. .capture = {
  1379. .stream_name = "Tert AUX PCM Capture",
  1380. .aif_name = "TERT_AUX_PCM_TX",
  1381. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1382. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1383. .channels_min = 1,
  1384. .channels_max = 1,
  1385. .rate_max = 16000,
  1386. .rate_min = 8000,
  1387. },
  1388. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1389. .name = "Tert AUX PCM",
  1390. .ops = &msm_dai_q6_auxpcm_ops,
  1391. .probe = msm_dai_q6_aux_pcm_probe,
  1392. .remove = msm_dai_q6_dai_auxpcm_remove,
  1393. },
  1394. {
  1395. .playback = {
  1396. .stream_name = "Quat AUX PCM Playback",
  1397. .aif_name = "QUAT_AUX_PCM_RX",
  1398. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1399. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1400. .channels_min = 1,
  1401. .channels_max = 1,
  1402. .rate_max = 16000,
  1403. .rate_min = 8000,
  1404. },
  1405. .capture = {
  1406. .stream_name = "Quat AUX PCM Capture",
  1407. .aif_name = "QUAT_AUX_PCM_TX",
  1408. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1409. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1410. .channels_min = 1,
  1411. .channels_max = 1,
  1412. .rate_max = 16000,
  1413. .rate_min = 8000,
  1414. },
  1415. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1416. .name = "Quat AUX PCM",
  1417. .ops = &msm_dai_q6_auxpcm_ops,
  1418. .probe = msm_dai_q6_aux_pcm_probe,
  1419. .remove = msm_dai_q6_dai_auxpcm_remove,
  1420. },
  1421. {
  1422. .playback = {
  1423. .stream_name = "Quin AUX PCM Playback",
  1424. .aif_name = "QUIN_AUX_PCM_RX",
  1425. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1426. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1427. .channels_min = 1,
  1428. .channels_max = 1,
  1429. .rate_max = 16000,
  1430. .rate_min = 8000,
  1431. },
  1432. .capture = {
  1433. .stream_name = "Quin AUX PCM Capture",
  1434. .aif_name = "QUIN_AUX_PCM_TX",
  1435. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1436. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1437. .channels_min = 1,
  1438. .channels_max = 1,
  1439. .rate_max = 16000,
  1440. .rate_min = 8000,
  1441. },
  1442. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1443. .name = "Quin AUX PCM",
  1444. .ops = &msm_dai_q6_auxpcm_ops,
  1445. .probe = msm_dai_q6_aux_pcm_probe,
  1446. .remove = msm_dai_q6_dai_auxpcm_remove,
  1447. },
  1448. {
  1449. .playback = {
  1450. .stream_name = "Sen AUX PCM Playback",
  1451. .aif_name = "SEN_AUX_PCM_RX",
  1452. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1453. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1454. .channels_min = 1,
  1455. .channels_max = 1,
  1456. .rate_max = 16000,
  1457. .rate_min = 8000,
  1458. },
  1459. .capture = {
  1460. .stream_name = "Sen AUX PCM Capture",
  1461. .aif_name = "SEN_AUX_PCM_TX",
  1462. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1463. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1464. .channels_min = 1,
  1465. .channels_max = 1,
  1466. .rate_max = 16000,
  1467. .rate_min = 8000,
  1468. },
  1469. .id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID,
  1470. .name = "Sen AUX PCM",
  1471. .ops = &msm_dai_q6_auxpcm_ops,
  1472. .probe = msm_dai_q6_aux_pcm_probe,
  1473. .remove = msm_dai_q6_dai_auxpcm_remove,
  1474. },
  1475. };
  1476. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1477. struct snd_ctl_elem_value *ucontrol)
  1478. {
  1479. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1480. int value = ucontrol->value.integer.value[0];
  1481. dai_data->spdif_port.cfg.data_format = value;
  1482. pr_debug("%s: value = %d\n", __func__, value);
  1483. return 0;
  1484. }
  1485. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1486. struct snd_ctl_elem_value *ucontrol)
  1487. {
  1488. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1489. ucontrol->value.integer.value[0] =
  1490. dai_data->spdif_port.cfg.data_format;
  1491. return 0;
  1492. }
  1493. static int msm_dai_q6_spdif_source_put(struct snd_kcontrol *kcontrol,
  1494. struct snd_ctl_elem_value *ucontrol)
  1495. {
  1496. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1497. int value = ucontrol->value.integer.value[0];
  1498. dai_data->spdif_port.cfg.src_sel = value;
  1499. pr_debug("%s: value = %d\n", __func__, value);
  1500. return 0;
  1501. }
  1502. static int msm_dai_q6_spdif_source_get(struct snd_kcontrol *kcontrol,
  1503. struct snd_ctl_elem_value *ucontrol)
  1504. {
  1505. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1506. ucontrol->value.integer.value[0] =
  1507. dai_data->spdif_port.cfg.src_sel;
  1508. return 0;
  1509. }
  1510. static const char * const spdif_format[] = {
  1511. "LPCM",
  1512. "Compr"
  1513. };
  1514. static const char * const spdif_source[] = {
  1515. "Optical", "EXT-ARC", "Coaxial", "VT-ARC"
  1516. };
  1517. static const struct soc_enum spdif_rx_config_enum[] = {
  1518. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1519. };
  1520. static const struct soc_enum spdif_tx_config_enum[] = {
  1521. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_source), spdif_source),
  1522. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1523. };
  1524. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1525. struct snd_ctl_elem_value *ucontrol)
  1526. {
  1527. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1528. int ret = 0;
  1529. dai_data->spdif_port.ch_status.status_type =
  1530. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1531. memset(dai_data->spdif_port.ch_status.status_mask,
  1532. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1533. dai_data->spdif_port.ch_status.status_mask[0] =
  1534. CHANNEL_STATUS_MASK;
  1535. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1536. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1537. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1538. pr_debug("%s: Port already started. Dynamic update\n",
  1539. __func__);
  1540. ret = afe_send_spdif_ch_status_cfg(
  1541. &dai_data->spdif_port.ch_status,
  1542. dai_data->port_id);
  1543. }
  1544. return ret;
  1545. }
  1546. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1547. struct snd_ctl_elem_value *ucontrol)
  1548. {
  1549. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1550. memcpy(ucontrol->value.iec958.status,
  1551. dai_data->spdif_port.ch_status.status_bits,
  1552. CHANNEL_STATUS_SIZE);
  1553. return 0;
  1554. }
  1555. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1556. struct snd_ctl_elem_info *uinfo)
  1557. {
  1558. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1559. uinfo->count = 1;
  1560. return 0;
  1561. }
  1562. static const struct snd_kcontrol_new spdif_rx_config_controls[] = {
  1563. /* Primary SPDIF output */
  1564. {
  1565. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1566. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1567. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1568. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1569. .info = msm_dai_q6_spdif_chstatus_info,
  1570. .get = msm_dai_q6_spdif_chstatus_get,
  1571. .put = msm_dai_q6_spdif_chstatus_put,
  1572. },
  1573. SOC_ENUM_EXT("PRI SPDIF RX Format", spdif_rx_config_enum[0],
  1574. msm_dai_q6_spdif_format_get,
  1575. msm_dai_q6_spdif_format_put),
  1576. /* Secondary SPDIF output */
  1577. {
  1578. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1579. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1580. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1581. .name = SNDRV_CTL_NAME_IEC958("SEC", PLAYBACK, PCM_STREAM),
  1582. .info = msm_dai_q6_spdif_chstatus_info,
  1583. .get = msm_dai_q6_spdif_chstatus_get,
  1584. .put = msm_dai_q6_spdif_chstatus_put,
  1585. },
  1586. SOC_ENUM_EXT("SEC SPDIF RX Format", spdif_rx_config_enum[0],
  1587. msm_dai_q6_spdif_format_get,
  1588. msm_dai_q6_spdif_format_put)
  1589. };
  1590. static const struct snd_kcontrol_new spdif_tx_config_controls[] = {
  1591. SOC_ENUM_EXT("PRI SPDIF TX Source", spdif_tx_config_enum[0],
  1592. msm_dai_q6_spdif_source_get,
  1593. msm_dai_q6_spdif_source_put),
  1594. SOC_ENUM_EXT("PRI SPDIF TX Format", spdif_tx_config_enum[1],
  1595. msm_dai_q6_spdif_format_get,
  1596. msm_dai_q6_spdif_format_put),
  1597. SOC_ENUM_EXT("SEC SPDIF TX Source", spdif_tx_config_enum[0],
  1598. msm_dai_q6_spdif_source_get,
  1599. msm_dai_q6_spdif_source_put),
  1600. SOC_ENUM_EXT("SEC SPDIF TX Format", spdif_tx_config_enum[1],
  1601. msm_dai_q6_spdif_format_get,
  1602. msm_dai_q6_spdif_format_put)
  1603. };
  1604. static void msm_dai_q6_spdif_process_event(uint32_t opcode, uint32_t token,
  1605. uint32_t *payload, void *private_data)
  1606. {
  1607. struct msm_dai_q6_spdif_event_msg *evt;
  1608. struct msm_dai_q6_spdif_dai_data *dai_data;
  1609. int preemph_old = 0;
  1610. int preemph_new = 0;
  1611. evt = (struct msm_dai_q6_spdif_event_msg *)payload;
  1612. dai_data = (struct msm_dai_q6_spdif_dai_data *)private_data;
  1613. preemph_old = GET_PREEMPH(dai_data->fmt_event.channel_status[0]);
  1614. preemph_new = GET_PREEMPH(evt->fmt_event.channel_status[0]);
  1615. pr_debug("%s: old state %d, fmt %d, rate %d, preemph %d\n",
  1616. __func__, dai_data->fmt_event.status,
  1617. dai_data->fmt_event.data_format,
  1618. dai_data->fmt_event.sample_rate,
  1619. preemph_old);
  1620. pr_debug("%s: new state %d, fmt %d, rate %d, preemph %d\n",
  1621. __func__, evt->fmt_event.status,
  1622. evt->fmt_event.data_format,
  1623. evt->fmt_event.sample_rate,
  1624. preemph_new);
  1625. dai_data->fmt_event.status = evt->fmt_event.status;
  1626. dai_data->fmt_event.data_format = evt->fmt_event.data_format;
  1627. dai_data->fmt_event.sample_rate = evt->fmt_event.sample_rate;
  1628. dai_data->fmt_event.channel_status[0] =
  1629. evt->fmt_event.channel_status[0];
  1630. dai_data->fmt_event.channel_status[1] =
  1631. evt->fmt_event.channel_status[1];
  1632. dai_data->fmt_event.channel_status[2] =
  1633. evt->fmt_event.channel_status[2];
  1634. dai_data->fmt_event.channel_status[3] =
  1635. evt->fmt_event.channel_status[3];
  1636. dai_data->fmt_event.channel_status[4] =
  1637. evt->fmt_event.channel_status[4];
  1638. dai_data->fmt_event.channel_status[5] =
  1639. evt->fmt_event.channel_status[5];
  1640. }
  1641. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1642. struct snd_pcm_hw_params *params,
  1643. struct snd_soc_dai *dai)
  1644. {
  1645. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1646. dai_data->channels = params_channels(params);
  1647. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1648. switch (params_format(params)) {
  1649. case SNDRV_PCM_FORMAT_S16_LE:
  1650. dai_data->spdif_port.cfg.bit_width = 16;
  1651. break;
  1652. case SNDRV_PCM_FORMAT_S24_LE:
  1653. case SNDRV_PCM_FORMAT_S24_3LE:
  1654. dai_data->spdif_port.cfg.bit_width = 24;
  1655. break;
  1656. default:
  1657. pr_err("%s: format %d\n",
  1658. __func__, params_format(params));
  1659. return -EINVAL;
  1660. }
  1661. dai_data->rate = params_rate(params);
  1662. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1663. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1664. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1665. AFE_API_VERSION_SPDIF_CONFIG_V2;
  1666. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1667. dai_data->channels, dai_data->rate,
  1668. dai_data->spdif_port.cfg.bit_width);
  1669. dai_data->spdif_port.cfg.reserved = 0;
  1670. return 0;
  1671. }
  1672. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1673. struct snd_soc_dai *dai)
  1674. {
  1675. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1676. int rc = 0;
  1677. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1678. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1679. __func__, *dai_data->status_mask);
  1680. return;
  1681. }
  1682. rc = afe_close(dai->id);
  1683. if (rc < 0)
  1684. dev_err(dai->dev, "fail to close AFE port\n");
  1685. dai_data->fmt_event.status = 0; /* report invalid line state */
  1686. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1687. *dai_data->status_mask);
  1688. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1689. }
  1690. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1691. struct snd_soc_dai *dai)
  1692. {
  1693. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1694. int rc = 0;
  1695. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1696. rc = afe_spdif_reg_event_cfg(dai->id,
  1697. AFE_MODULE_REGISTER_EVENT_FLAG,
  1698. msm_dai_q6_spdif_process_event,
  1699. dai_data);
  1700. if (rc < 0)
  1701. dev_err(dai->dev,
  1702. "fail to register event for port 0x%x\n",
  1703. dai->id);
  1704. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1705. dai_data->rate);
  1706. if (rc < 0)
  1707. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1708. dai->id);
  1709. else
  1710. set_bit(STATUS_PORT_STARTED,
  1711. dai_data->status_mask);
  1712. }
  1713. return rc;
  1714. }
  1715. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_state(struct device *dev,
  1716. struct device_attribute *attr, char *buf)
  1717. {
  1718. ssize_t ret;
  1719. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1720. if (!dai_data) {
  1721. pr_err("%s: invalid input\n", __func__);
  1722. return -EINVAL;
  1723. }
  1724. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1725. dai_data->fmt_event.status);
  1726. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.status);
  1727. return ret;
  1728. }
  1729. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_format(struct device *dev,
  1730. struct device_attribute *attr, char *buf)
  1731. {
  1732. ssize_t ret;
  1733. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1734. if (!dai_data) {
  1735. pr_err("%s: invalid input\n", __func__);
  1736. return -EINVAL;
  1737. }
  1738. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1739. dai_data->fmt_event.data_format);
  1740. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.data_format);
  1741. return ret;
  1742. }
  1743. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_rate(struct device *dev,
  1744. struct device_attribute *attr, char *buf)
  1745. {
  1746. ssize_t ret;
  1747. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1748. if (!dai_data) {
  1749. pr_err("%s: invalid input\n", __func__);
  1750. return -EINVAL;
  1751. }
  1752. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1753. dai_data->fmt_event.sample_rate);
  1754. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.sample_rate);
  1755. return ret;
  1756. }
  1757. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_preemph(struct device *dev,
  1758. struct device_attribute *attr, char *buf)
  1759. {
  1760. ssize_t ret;
  1761. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1762. int preemph = 0;
  1763. if (!dai_data) {
  1764. pr_err("%s: invalid input\n", __func__);
  1765. return -EINVAL;
  1766. }
  1767. preemph = GET_PREEMPH(dai_data->fmt_event.channel_status[0]);
  1768. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n", preemph);
  1769. pr_debug("%s: '%d'\n", __func__, preemph);
  1770. return ret;
  1771. }
  1772. static DEVICE_ATTR(audio_state, 0444, msm_dai_q6_spdif_sysfs_rda_audio_state,
  1773. NULL);
  1774. static DEVICE_ATTR(audio_format, 0444, msm_dai_q6_spdif_sysfs_rda_audio_format,
  1775. NULL);
  1776. static DEVICE_ATTR(audio_rate, 0444, msm_dai_q6_spdif_sysfs_rda_audio_rate,
  1777. NULL);
  1778. static DEVICE_ATTR(audio_preemph, 0444,
  1779. msm_dai_q6_spdif_sysfs_rda_audio_preemph, NULL);
  1780. static struct attribute *msm_dai_q6_spdif_fs_attrs[] = {
  1781. &dev_attr_audio_state.attr,
  1782. &dev_attr_audio_format.attr,
  1783. &dev_attr_audio_rate.attr,
  1784. &dev_attr_audio_preemph.attr,
  1785. NULL,
  1786. };
  1787. static struct attribute_group msm_dai_q6_spdif_fs_attrs_group = {
  1788. .attrs = msm_dai_q6_spdif_fs_attrs,
  1789. };
  1790. static int msm_dai_q6_spdif_sysfs_create(struct snd_soc_dai *dai,
  1791. struct msm_dai_q6_spdif_dai_data *dai_data)
  1792. {
  1793. int rc;
  1794. rc = sysfs_create_group(&dai->dev->kobj,
  1795. &msm_dai_q6_spdif_fs_attrs_group);
  1796. if (rc) {
  1797. pr_err("%s: failed, rc=%d\n", __func__, rc);
  1798. return rc;
  1799. }
  1800. dai_data->kobj = &dai->dev->kobj;
  1801. return 0;
  1802. }
  1803. static void msm_dai_q6_spdif_sysfs_remove(struct snd_soc_dai *dai,
  1804. struct msm_dai_q6_spdif_dai_data *dai_data)
  1805. {
  1806. if (dai_data->kobj)
  1807. sysfs_remove_group(dai_data->kobj,
  1808. &msm_dai_q6_spdif_fs_attrs_group);
  1809. dai_data->kobj = NULL;
  1810. }
  1811. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1812. {
  1813. struct msm_dai_q6_spdif_dai_data *dai_data;
  1814. int rc = 0;
  1815. struct snd_soc_dapm_route intercon;
  1816. struct snd_soc_dapm_context *dapm;
  1817. if (!dai) {
  1818. pr_err("%s: dai not found!!\n", __func__);
  1819. return -EINVAL;
  1820. }
  1821. if (!dai->dev) {
  1822. pr_err("%s: Invalid params dai dev\n", __func__);
  1823. return -EINVAL;
  1824. }
  1825. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1826. GFP_KERNEL);
  1827. if (!dai_data)
  1828. return -ENOMEM;
  1829. else
  1830. dev_set_drvdata(dai->dev, dai_data);
  1831. msm_dai_q6_set_dai_id(dai);
  1832. dai_data->port_id = dai->id;
  1833. switch (dai->id) {
  1834. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  1835. rc = snd_ctl_add(dai->component->card->snd_card,
  1836. snd_ctl_new1(&spdif_rx_config_controls[1],
  1837. dai_data));
  1838. break;
  1839. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  1840. rc = snd_ctl_add(dai->component->card->snd_card,
  1841. snd_ctl_new1(&spdif_rx_config_controls[3],
  1842. dai_data));
  1843. break;
  1844. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  1845. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1846. rc = snd_ctl_add(dai->component->card->snd_card,
  1847. snd_ctl_new1(&spdif_tx_config_controls[0],
  1848. dai_data));
  1849. rc = snd_ctl_add(dai->component->card->snd_card,
  1850. snd_ctl_new1(&spdif_tx_config_controls[1],
  1851. dai_data));
  1852. break;
  1853. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  1854. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1855. rc = snd_ctl_add(dai->component->card->snd_card,
  1856. snd_ctl_new1(&spdif_tx_config_controls[2],
  1857. dai_data));
  1858. rc = snd_ctl_add(dai->component->card->snd_card,
  1859. snd_ctl_new1(&spdif_tx_config_controls[3],
  1860. dai_data));
  1861. break;
  1862. }
  1863. if (rc < 0)
  1864. dev_err(dai->dev,
  1865. "%s: err add config ctl, DAI = %s\n",
  1866. __func__, dai->name);
  1867. dapm = snd_soc_component_get_dapm(dai->component);
  1868. memset(&intercon, 0, sizeof(intercon));
  1869. if (!rc && dai && dai->driver) {
  1870. if (dai->driver->playback.stream_name &&
  1871. dai->driver->playback.aif_name) {
  1872. dev_dbg(dai->dev, "%s: add route for widget %s",
  1873. __func__, dai->driver->playback.stream_name);
  1874. intercon.source = dai->driver->playback.aif_name;
  1875. intercon.sink = dai->driver->playback.stream_name;
  1876. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1877. __func__, intercon.source, intercon.sink);
  1878. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1879. }
  1880. if (dai->driver->capture.stream_name &&
  1881. dai->driver->capture.aif_name) {
  1882. dev_dbg(dai->dev, "%s: add route for widget %s",
  1883. __func__, dai->driver->capture.stream_name);
  1884. intercon.sink = dai->driver->capture.aif_name;
  1885. intercon.source = dai->driver->capture.stream_name;
  1886. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1887. __func__, intercon.source, intercon.sink);
  1888. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1889. }
  1890. }
  1891. return rc;
  1892. }
  1893. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1894. {
  1895. struct msm_dai_q6_spdif_dai_data *dai_data;
  1896. int rc;
  1897. dai_data = dev_get_drvdata(dai->dev);
  1898. /* If AFE port is still up, close it */
  1899. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1900. rc = afe_spdif_reg_event_cfg(dai->id,
  1901. AFE_MODULE_DEREGISTER_EVENT_FLAG,
  1902. NULL,
  1903. dai_data);
  1904. if (rc < 0)
  1905. dev_err(dai->dev,
  1906. "fail to deregister event for port 0x%x\n",
  1907. dai->id);
  1908. rc = afe_close(dai->id); /* can block */
  1909. if (rc < 0)
  1910. dev_err(dai->dev, "fail to close AFE port\n");
  1911. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1912. }
  1913. msm_dai_q6_spdif_sysfs_remove(dai, dai_data);
  1914. kfree(dai_data);
  1915. return 0;
  1916. }
  1917. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1918. .prepare = msm_dai_q6_spdif_prepare,
  1919. .hw_params = msm_dai_q6_spdif_hw_params,
  1920. .shutdown = msm_dai_q6_spdif_shutdown,
  1921. };
  1922. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai[] = {
  1923. {
  1924. .playback = {
  1925. .stream_name = "Primary SPDIF Playback",
  1926. .aif_name = "PRI_SPDIF_RX",
  1927. .rates = SNDRV_PCM_RATE_32000 |
  1928. SNDRV_PCM_RATE_44100 |
  1929. SNDRV_PCM_RATE_48000 |
  1930. SNDRV_PCM_RATE_88200 |
  1931. SNDRV_PCM_RATE_96000 |
  1932. SNDRV_PCM_RATE_176400 |
  1933. SNDRV_PCM_RATE_192000,
  1934. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1935. SNDRV_PCM_FMTBIT_S24_LE,
  1936. .channels_min = 1,
  1937. .channels_max = 2,
  1938. .rate_min = 32000,
  1939. .rate_max = 192000,
  1940. },
  1941. .name = "PRI_SPDIF_RX",
  1942. .ops = &msm_dai_q6_spdif_ops,
  1943. .id = AFE_PORT_ID_PRIMARY_SPDIF_RX,
  1944. .probe = msm_dai_q6_spdif_dai_probe,
  1945. .remove = msm_dai_q6_spdif_dai_remove,
  1946. },
  1947. {
  1948. .playback = {
  1949. .stream_name = "Secondary SPDIF Playback",
  1950. .aif_name = "SEC_SPDIF_RX",
  1951. .rates = SNDRV_PCM_RATE_32000 |
  1952. SNDRV_PCM_RATE_44100 |
  1953. SNDRV_PCM_RATE_48000 |
  1954. SNDRV_PCM_RATE_88200 |
  1955. SNDRV_PCM_RATE_96000 |
  1956. SNDRV_PCM_RATE_176400 |
  1957. SNDRV_PCM_RATE_192000,
  1958. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1959. SNDRV_PCM_FMTBIT_S24_LE,
  1960. .channels_min = 1,
  1961. .channels_max = 2,
  1962. .rate_min = 32000,
  1963. .rate_max = 192000,
  1964. },
  1965. .name = "SEC_SPDIF_RX",
  1966. .ops = &msm_dai_q6_spdif_ops,
  1967. .id = AFE_PORT_ID_SECONDARY_SPDIF_RX,
  1968. .probe = msm_dai_q6_spdif_dai_probe,
  1969. .remove = msm_dai_q6_spdif_dai_remove,
  1970. },
  1971. };
  1972. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_tx_dai[] = {
  1973. {
  1974. .capture = {
  1975. .stream_name = "Primary SPDIF Capture",
  1976. .aif_name = "PRI_SPDIF_TX",
  1977. .rates = SNDRV_PCM_RATE_32000 |
  1978. SNDRV_PCM_RATE_44100 |
  1979. SNDRV_PCM_RATE_48000 |
  1980. SNDRV_PCM_RATE_88200 |
  1981. SNDRV_PCM_RATE_96000 |
  1982. SNDRV_PCM_RATE_176400 |
  1983. SNDRV_PCM_RATE_192000,
  1984. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1985. SNDRV_PCM_FMTBIT_S24_LE,
  1986. .channels_min = 1,
  1987. .channels_max = 2,
  1988. .rate_min = 32000,
  1989. .rate_max = 192000,
  1990. },
  1991. .name = "PRI_SPDIF_TX",
  1992. .ops = &msm_dai_q6_spdif_ops,
  1993. .id = AFE_PORT_ID_PRIMARY_SPDIF_TX,
  1994. .probe = msm_dai_q6_spdif_dai_probe,
  1995. .remove = msm_dai_q6_spdif_dai_remove,
  1996. },
  1997. {
  1998. .capture = {
  1999. .stream_name = "Secondary SPDIF Capture",
  2000. .aif_name = "SEC_SPDIF_TX",
  2001. .rates = SNDRV_PCM_RATE_32000 |
  2002. SNDRV_PCM_RATE_44100 |
  2003. SNDRV_PCM_RATE_48000 |
  2004. SNDRV_PCM_RATE_88200 |
  2005. SNDRV_PCM_RATE_96000 |
  2006. SNDRV_PCM_RATE_176400 |
  2007. SNDRV_PCM_RATE_192000,
  2008. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2009. SNDRV_PCM_FMTBIT_S24_LE,
  2010. .channels_min = 1,
  2011. .channels_max = 2,
  2012. .rate_min = 32000,
  2013. .rate_max = 192000,
  2014. },
  2015. .name = "SEC_SPDIF_TX",
  2016. .ops = &msm_dai_q6_spdif_ops,
  2017. .id = AFE_PORT_ID_SECONDARY_SPDIF_TX,
  2018. .probe = msm_dai_q6_spdif_dai_probe,
  2019. .remove = msm_dai_q6_spdif_dai_remove,
  2020. },
  2021. };
  2022. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  2023. .name = "msm-dai-q6-spdif",
  2024. };
  2025. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  2026. struct snd_soc_dai *dai)
  2027. {
  2028. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2029. int rc = 0;
  2030. uint16_t ttp_gen_enable = dai_data->ttp_config.ttp_gen_enable.enable;
  2031. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2032. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  2033. int bitwidth = 0;
  2034. switch (dai_data->afe_rx_in_bitformat) {
  2035. case SNDRV_PCM_FORMAT_S32_LE:
  2036. bitwidth = 32;
  2037. break;
  2038. case SNDRV_PCM_FORMAT_S24_LE:
  2039. bitwidth = 24;
  2040. break;
  2041. case SNDRV_PCM_FORMAT_S16_LE:
  2042. default:
  2043. bitwidth = 16;
  2044. break;
  2045. }
  2046. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  2047. __func__, dai_data->enc_config.format);
  2048. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  2049. dai_data->rate,
  2050. dai_data->afe_rx_in_channels,
  2051. bitwidth,
  2052. &dai_data->enc_config, NULL);
  2053. if (rc < 0)
  2054. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  2055. __func__, rc);
  2056. } else if (dai_data->dec_config.format != DEC_FMT_NONE) {
  2057. int bitwidth = 0;
  2058. /*
  2059. * If bitwidth is not configured set default value to
  2060. * zero, so that decoder port config uses slim device
  2061. * bit width value in afe decoder config.
  2062. */
  2063. switch (dai_data->afe_tx_out_bitformat) {
  2064. case SNDRV_PCM_FORMAT_S32_LE:
  2065. bitwidth = 32;
  2066. break;
  2067. case SNDRV_PCM_FORMAT_S24_LE:
  2068. bitwidth = 24;
  2069. break;
  2070. case SNDRV_PCM_FORMAT_S16_LE:
  2071. bitwidth = 16;
  2072. break;
  2073. default:
  2074. bitwidth = 0;
  2075. break;
  2076. }
  2077. if (ttp_gen_enable == true) {
  2078. pr_debug("%s: calling AFE_PORT_START_V3 with dec format: %d\n",
  2079. __func__, dai_data->dec_config.format);
  2080. rc = afe_port_start_v3(dai->id,
  2081. &dai_data->port_config,
  2082. dai_data->rate,
  2083. dai_data->afe_tx_out_channels,
  2084. bitwidth,
  2085. NULL, &dai_data->dec_config,
  2086. &dai_data->ttp_config);
  2087. } else {
  2088. pr_debug("%s: calling AFE_PORT_START_V2 with dec format: %d\n",
  2089. __func__, dai_data->dec_config.format);
  2090. rc = afe_port_start_v2(dai->id,
  2091. &dai_data->port_config,
  2092. dai_data->rate,
  2093. dai_data->afe_tx_out_channels,
  2094. bitwidth,
  2095. NULL, &dai_data->dec_config);
  2096. }
  2097. if (rc < 0) {
  2098. pr_err("%s: fail to open AFE port 0x%x\n",
  2099. __func__, dai->id);
  2100. }
  2101. } else {
  2102. rc = afe_port_start(dai->id, &dai_data->port_config,
  2103. dai_data->rate);
  2104. }
  2105. if (rc < 0)
  2106. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  2107. dai->id);
  2108. else
  2109. set_bit(STATUS_PORT_STARTED,
  2110. dai_data->status_mask);
  2111. }
  2112. return rc;
  2113. }
  2114. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  2115. struct snd_soc_dai *dai, int stream)
  2116. {
  2117. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2118. dai_data->channels = params_channels(params);
  2119. switch (dai_data->channels) {
  2120. case 2:
  2121. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2122. break;
  2123. case 1:
  2124. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2125. break;
  2126. default:
  2127. return -EINVAL;
  2128. pr_err("%s: err channels %d\n",
  2129. __func__, dai_data->channels);
  2130. break;
  2131. }
  2132. switch (params_format(params)) {
  2133. case SNDRV_PCM_FORMAT_S16_LE:
  2134. case SNDRV_PCM_FORMAT_SPECIAL:
  2135. dai_data->port_config.i2s.bit_width = 16;
  2136. break;
  2137. case SNDRV_PCM_FORMAT_S24_LE:
  2138. case SNDRV_PCM_FORMAT_S24_3LE:
  2139. dai_data->port_config.i2s.bit_width = 24;
  2140. break;
  2141. default:
  2142. pr_err("%s: format %d\n",
  2143. __func__, params_format(params));
  2144. return -EINVAL;
  2145. }
  2146. dai_data->rate = params_rate(params);
  2147. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2148. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2149. AFE_API_VERSION_I2S_CONFIG;
  2150. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2151. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  2152. dai_data->channels, dai_data->rate);
  2153. dai_data->port_config.i2s.channel_mode = 1;
  2154. return 0;
  2155. }
  2156. static u16 num_of_bits_set(u16 sd_line_mask)
  2157. {
  2158. u8 num_bits_set = 0;
  2159. while (sd_line_mask) {
  2160. num_bits_set++;
  2161. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  2162. }
  2163. return num_bits_set;
  2164. }
  2165. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  2166. struct snd_soc_dai *dai, int stream)
  2167. {
  2168. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2169. struct msm_i2s_data *i2s_pdata =
  2170. (struct msm_i2s_data *) dai->dev->platform_data;
  2171. dai_data->channels = params_channels(params);
  2172. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  2173. switch (dai_data->channels) {
  2174. case 2:
  2175. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2176. break;
  2177. case 1:
  2178. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2179. break;
  2180. default:
  2181. pr_warn("%s: greater than stereo has not been validated %d",
  2182. __func__, dai_data->channels);
  2183. break;
  2184. }
  2185. }
  2186. dai_data->rate = params_rate(params);
  2187. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2188. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2189. AFE_API_VERSION_I2S_CONFIG;
  2190. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2191. /* Q6 only supports 16 as now */
  2192. dai_data->port_config.i2s.bit_width = 16;
  2193. dai_data->port_config.i2s.channel_mode = 1;
  2194. return 0;
  2195. }
  2196. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  2197. struct snd_soc_dai *dai, int stream)
  2198. {
  2199. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2200. dai_data->channels = params_channels(params);
  2201. dai_data->rate = params_rate(params);
  2202. switch (params_format(params)) {
  2203. case SNDRV_PCM_FORMAT_S16_LE:
  2204. case SNDRV_PCM_FORMAT_SPECIAL:
  2205. dai_data->port_config.slim_sch.bit_width = 16;
  2206. break;
  2207. case SNDRV_PCM_FORMAT_S24_LE:
  2208. case SNDRV_PCM_FORMAT_S24_3LE:
  2209. dai_data->port_config.slim_sch.bit_width = 24;
  2210. break;
  2211. case SNDRV_PCM_FORMAT_S32_LE:
  2212. dai_data->port_config.slim_sch.bit_width = 32;
  2213. break;
  2214. default:
  2215. pr_err("%s: format %d\n",
  2216. __func__, params_format(params));
  2217. return -EINVAL;
  2218. }
  2219. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  2220. AFE_API_VERSION_SLIMBUS_CONFIG;
  2221. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  2222. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  2223. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  2224. "num_channel %hu shared_ch_mapping[0] %hu\n"
  2225. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  2226. "sample_rate %d\n", __func__,
  2227. dai_data->port_config.slim_sch.slimbus_dev_id,
  2228. dai_data->port_config.slim_sch.bit_width,
  2229. dai_data->port_config.slim_sch.data_format,
  2230. dai_data->port_config.slim_sch.num_channels,
  2231. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2232. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  2233. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  2234. dai_data->rate);
  2235. return 0;
  2236. }
  2237. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  2238. struct snd_soc_dai *dai, int stream)
  2239. {
  2240. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2241. dai_data->channels = params_channels(params);
  2242. dai_data->rate = params_rate(params);
  2243. switch (params_format(params)) {
  2244. case SNDRV_PCM_FORMAT_S16_LE:
  2245. case SNDRV_PCM_FORMAT_SPECIAL:
  2246. dai_data->port_config.usb_audio.bit_width = 16;
  2247. break;
  2248. case SNDRV_PCM_FORMAT_S24_LE:
  2249. case SNDRV_PCM_FORMAT_S24_3LE:
  2250. dai_data->port_config.usb_audio.bit_width = 24;
  2251. break;
  2252. case SNDRV_PCM_FORMAT_S32_LE:
  2253. dai_data->port_config.usb_audio.bit_width = 32;
  2254. break;
  2255. default:
  2256. dev_err(dai->dev, "%s: invalid format %d\n",
  2257. __func__, params_format(params));
  2258. return -EINVAL;
  2259. }
  2260. dai_data->port_config.usb_audio.cfg_minor_version =
  2261. AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG;
  2262. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  2263. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  2264. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  2265. "num_channel %hu sample_rate %d\n", __func__,
  2266. dai_data->port_config.usb_audio.dev_token,
  2267. dai_data->port_config.usb_audio.bit_width,
  2268. dai_data->port_config.usb_audio.data_format,
  2269. dai_data->port_config.usb_audio.num_channels,
  2270. dai_data->port_config.usb_audio.sample_rate);
  2271. return 0;
  2272. }
  2273. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  2274. struct snd_soc_dai *dai, int stream)
  2275. {
  2276. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2277. dai_data->channels = params_channels(params);
  2278. dai_data->rate = params_rate(params);
  2279. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  2280. dai_data->channels, dai_data->rate);
  2281. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  2282. pr_debug("%s: setting bt_fm parameters\n", __func__);
  2283. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  2284. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  2285. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  2286. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  2287. dai_data->port_config.int_bt_fm.bit_width = 16;
  2288. return 0;
  2289. }
  2290. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  2291. struct snd_soc_dai *dai)
  2292. {
  2293. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2294. dai_data->rate = params_rate(params);
  2295. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  2296. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  2297. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  2298. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  2299. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  2300. AFE_API_VERSION_RT_PROXY_CONFIG;
  2301. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  2302. dai_data->port_config.rtproxy.interleaved = 1;
  2303. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  2304. dai_data->port_config.rtproxy.jitter_allowance =
  2305. dai_data->port_config.rtproxy.frame_size/2;
  2306. dai_data->port_config.rtproxy.low_water_mark = 0;
  2307. dai_data->port_config.rtproxy.high_water_mark = 0;
  2308. return 0;
  2309. }
  2310. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  2311. struct snd_soc_dai *dai, int stream)
  2312. {
  2313. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2314. dai_data->channels = params_channels(params);
  2315. dai_data->rate = params_rate(params);
  2316. /* Q6 only supports 16 as now */
  2317. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  2318. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  2319. dai_data->port_config.pseudo_port.num_channels =
  2320. params_channels(params);
  2321. dai_data->port_config.pseudo_port.bit_width = 16;
  2322. dai_data->port_config.pseudo_port.data_format = 0;
  2323. dai_data->port_config.pseudo_port.timing_mode =
  2324. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  2325. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  2326. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  2327. "timing Mode %hu sample_rate %d\n", __func__,
  2328. dai_data->port_config.pseudo_port.bit_width,
  2329. dai_data->port_config.pseudo_port.num_channels,
  2330. dai_data->port_config.pseudo_port.data_format,
  2331. dai_data->port_config.pseudo_port.timing_mode,
  2332. dai_data->port_config.pseudo_port.sample_rate);
  2333. return 0;
  2334. }
  2335. /* Current implementation assumes hw_param is called once
  2336. * This may not be the case but what to do when ADM and AFE
  2337. * port are already opened and parameter changes
  2338. */
  2339. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  2340. struct snd_pcm_hw_params *params,
  2341. struct snd_soc_dai *dai)
  2342. {
  2343. int rc = 0;
  2344. switch (dai->id) {
  2345. case PRIMARY_I2S_TX:
  2346. case PRIMARY_I2S_RX:
  2347. case SECONDARY_I2S_RX:
  2348. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  2349. break;
  2350. case MI2S_RX:
  2351. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  2352. break;
  2353. case SLIMBUS_0_RX:
  2354. case SLIMBUS_1_RX:
  2355. case SLIMBUS_2_RX:
  2356. case SLIMBUS_3_RX:
  2357. case SLIMBUS_4_RX:
  2358. case SLIMBUS_5_RX:
  2359. case SLIMBUS_6_RX:
  2360. case SLIMBUS_7_RX:
  2361. case SLIMBUS_8_RX:
  2362. case SLIMBUS_9_RX:
  2363. case SLIMBUS_0_TX:
  2364. case SLIMBUS_1_TX:
  2365. case SLIMBUS_2_TX:
  2366. case SLIMBUS_3_TX:
  2367. case SLIMBUS_4_TX:
  2368. case SLIMBUS_5_TX:
  2369. case SLIMBUS_6_TX:
  2370. case SLIMBUS_7_TX:
  2371. case SLIMBUS_8_TX:
  2372. case SLIMBUS_9_TX:
  2373. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  2374. substream->stream);
  2375. break;
  2376. case INT_BT_SCO_RX:
  2377. case INT_BT_SCO_TX:
  2378. case INT_BT_A2DP_RX:
  2379. case INT_FM_RX:
  2380. case INT_FM_TX:
  2381. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  2382. break;
  2383. case AFE_PORT_ID_USB_RX:
  2384. case AFE_PORT_ID_USB_TX:
  2385. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  2386. substream->stream);
  2387. break;
  2388. case RT_PROXY_DAI_001_TX:
  2389. case RT_PROXY_DAI_001_RX:
  2390. case RT_PROXY_DAI_002_TX:
  2391. case RT_PROXY_DAI_002_RX:
  2392. case RT_PROXY_DAI_003_TX:
  2393. case RT_PROXY_PORT_002_TX:
  2394. case RT_PROXY_PORT_002_RX:
  2395. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  2396. break;
  2397. case VOICE_PLAYBACK_TX:
  2398. case VOICE2_PLAYBACK_TX:
  2399. case VOICE_RECORD_RX:
  2400. case VOICE_RECORD_TX:
  2401. rc = msm_dai_q6_pseudo_port_hw_params(params,
  2402. dai, substream->stream);
  2403. break;
  2404. default:
  2405. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  2406. rc = -EINVAL;
  2407. break;
  2408. }
  2409. return rc;
  2410. }
  2411. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  2412. struct snd_soc_dai *dai)
  2413. {
  2414. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2415. int rc = 0;
  2416. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2417. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2418. rc = afe_close(dai->id); /* can block */
  2419. if (rc < 0)
  2420. dev_err(dai->dev, "fail to close AFE port\n");
  2421. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  2422. *dai_data->status_mask);
  2423. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2424. }
  2425. }
  2426. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2427. {
  2428. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2429. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2430. case SND_SOC_DAIFMT_CBS_CFS:
  2431. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  2432. break;
  2433. case SND_SOC_DAIFMT_CBM_CFM:
  2434. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  2435. break;
  2436. default:
  2437. pr_err("%s: fmt 0x%x\n",
  2438. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  2439. return -EINVAL;
  2440. }
  2441. return 0;
  2442. }
  2443. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2444. {
  2445. int rc = 0;
  2446. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  2447. dai->id, fmt);
  2448. switch (dai->id) {
  2449. case PRIMARY_I2S_TX:
  2450. case PRIMARY_I2S_RX:
  2451. case MI2S_RX:
  2452. case SECONDARY_I2S_RX:
  2453. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  2454. break;
  2455. default:
  2456. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2457. rc = -EINVAL;
  2458. break;
  2459. }
  2460. return rc;
  2461. }
  2462. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  2463. unsigned int tx_num, unsigned int *tx_slot,
  2464. unsigned int rx_num, unsigned int *rx_slot)
  2465. {
  2466. int rc = 0;
  2467. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2468. unsigned int i = 0;
  2469. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  2470. switch (dai->id) {
  2471. case SLIMBUS_0_RX:
  2472. case SLIMBUS_1_RX:
  2473. case SLIMBUS_2_RX:
  2474. case SLIMBUS_3_RX:
  2475. case SLIMBUS_4_RX:
  2476. case SLIMBUS_5_RX:
  2477. case SLIMBUS_6_RX:
  2478. case SLIMBUS_7_RX:
  2479. case SLIMBUS_8_RX:
  2480. case SLIMBUS_9_RX:
  2481. /*
  2482. * channel number to be between 128 and 255.
  2483. * For RX port use channel numbers
  2484. * from 138 to 144 for pre-Taiko
  2485. * from 144 to 159 for Taiko
  2486. */
  2487. if (!rx_slot) {
  2488. pr_err("%s: rx slot not found\n", __func__);
  2489. return -EINVAL;
  2490. }
  2491. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2492. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  2493. return -EINVAL;
  2494. }
  2495. for (i = 0; i < rx_num; i++) {
  2496. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2497. rx_slot[i];
  2498. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2499. __func__, i, rx_slot[i]);
  2500. }
  2501. dai_data->port_config.slim_sch.num_channels = rx_num;
  2502. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  2503. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  2504. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2505. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2506. break;
  2507. case SLIMBUS_0_TX:
  2508. case SLIMBUS_1_TX:
  2509. case SLIMBUS_2_TX:
  2510. case SLIMBUS_3_TX:
  2511. case SLIMBUS_4_TX:
  2512. case SLIMBUS_5_TX:
  2513. case SLIMBUS_6_TX:
  2514. case SLIMBUS_7_TX:
  2515. case SLIMBUS_8_TX:
  2516. case SLIMBUS_9_TX:
  2517. /*
  2518. * channel number to be between 128 and 255.
  2519. * For TX port use channel numbers
  2520. * from 128 to 137 for pre-Taiko
  2521. * from 128 to 143 for Taiko
  2522. */
  2523. if (!tx_slot) {
  2524. pr_err("%s: tx slot not found\n", __func__);
  2525. return -EINVAL;
  2526. }
  2527. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2528. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  2529. return -EINVAL;
  2530. }
  2531. for (i = 0; i < tx_num; i++) {
  2532. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2533. tx_slot[i];
  2534. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2535. __func__, i, tx_slot[i]);
  2536. }
  2537. dai_data->port_config.slim_sch.num_channels = tx_num;
  2538. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  2539. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  2540. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2541. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2542. break;
  2543. default:
  2544. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2545. rc = -EINVAL;
  2546. break;
  2547. }
  2548. return rc;
  2549. }
  2550. /* all ports with excursion logging requirement can use this digital_mute api */
  2551. static int msm_dai_q6_spk_digital_mute(struct snd_soc_dai *dai,
  2552. int mute)
  2553. {
  2554. int port_id = dai->id;
  2555. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2556. if (mute && !dai_data->xt_logging_disable)
  2557. afe_get_sp_xt_logging_data(port_id);
  2558. return 0;
  2559. }
  2560. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2561. .prepare = msm_dai_q6_prepare,
  2562. .hw_params = msm_dai_q6_hw_params,
  2563. .shutdown = msm_dai_q6_shutdown,
  2564. .set_fmt = msm_dai_q6_set_fmt,
  2565. .set_channel_map = msm_dai_q6_set_channel_map,
  2566. };
  2567. static struct snd_soc_dai_ops msm_dai_slimbus_0_rx_ops = {
  2568. .prepare = msm_dai_q6_prepare,
  2569. .hw_params = msm_dai_q6_hw_params,
  2570. .shutdown = msm_dai_q6_shutdown,
  2571. .set_fmt = msm_dai_q6_set_fmt,
  2572. .set_channel_map = msm_dai_q6_set_channel_map,
  2573. .digital_mute = msm_dai_q6_spk_digital_mute,
  2574. };
  2575. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2576. struct snd_ctl_elem_value *ucontrol)
  2577. {
  2578. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2579. u16 port_id = ((struct soc_enum *)
  2580. kcontrol->private_value)->reg;
  2581. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2582. pr_debug("%s: setting cal_mode to %d\n",
  2583. __func__, dai_data->cal_mode);
  2584. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2585. return 0;
  2586. }
  2587. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2588. struct snd_ctl_elem_value *ucontrol)
  2589. {
  2590. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2591. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2592. return 0;
  2593. }
  2594. static int msm_dai_q6_cdc_dma_xt_logging_disable_put(
  2595. struct snd_kcontrol *kcontrol,
  2596. struct snd_ctl_elem_value *ucontrol)
  2597. {
  2598. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  2599. if (dai_data) {
  2600. dai_data->xt_logging_disable = ucontrol->value.integer.value[0];
  2601. pr_debug("%s: setting xt logging disable to %d\n",
  2602. __func__, dai_data->xt_logging_disable);
  2603. }
  2604. return 0;
  2605. }
  2606. static int msm_dai_q6_cdc_dma_xt_logging_disable_get(
  2607. struct snd_kcontrol *kcontrol,
  2608. struct snd_ctl_elem_value *ucontrol)
  2609. {
  2610. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  2611. if (dai_data)
  2612. ucontrol->value.integer.value[0] = dai_data->xt_logging_disable;
  2613. return 0;
  2614. }
  2615. static int msm_dai_q6_sb_xt_logging_disable_put(
  2616. struct snd_kcontrol *kcontrol,
  2617. struct snd_ctl_elem_value *ucontrol)
  2618. {
  2619. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2620. if (dai_data) {
  2621. dai_data->xt_logging_disable = ucontrol->value.integer.value[0];
  2622. pr_debug("%s: setting xt logging disable to %d\n",
  2623. __func__, dai_data->xt_logging_disable);
  2624. }
  2625. return 0;
  2626. }
  2627. static int msm_dai_q6_sb_xt_logging_disable_get(struct snd_kcontrol *kcontrol,
  2628. struct snd_ctl_elem_value *ucontrol)
  2629. {
  2630. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2631. if (dai_data)
  2632. ucontrol->value.integer.value[0] = dai_data->xt_logging_disable;
  2633. return 0;
  2634. }
  2635. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2636. struct snd_ctl_elem_value *ucontrol)
  2637. {
  2638. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2639. int value = ucontrol->value.integer.value[0];
  2640. if (dai_data) {
  2641. dai_data->port_config.slim_sch.data_format = value;
  2642. pr_debug("%s: format = %d\n", __func__, value);
  2643. }
  2644. return 0;
  2645. }
  2646. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2647. struct snd_ctl_elem_value *ucontrol)
  2648. {
  2649. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2650. if (dai_data)
  2651. ucontrol->value.integer.value[0] =
  2652. dai_data->port_config.slim_sch.data_format;
  2653. return 0;
  2654. }
  2655. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2656. struct snd_ctl_elem_value *ucontrol)
  2657. {
  2658. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2659. u32 val = ucontrol->value.integer.value[0];
  2660. if (dai_data) {
  2661. dai_data->port_config.usb_audio.dev_token = val;
  2662. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2663. dai_data->port_config.usb_audio.dev_token);
  2664. } else {
  2665. pr_err("%s: dai_data is NULL\n", __func__);
  2666. }
  2667. return 0;
  2668. }
  2669. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2670. struct snd_ctl_elem_value *ucontrol)
  2671. {
  2672. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2673. if (dai_data) {
  2674. ucontrol->value.integer.value[0] =
  2675. dai_data->port_config.usb_audio.dev_token;
  2676. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2677. dai_data->port_config.usb_audio.dev_token);
  2678. } else {
  2679. pr_err("%s: dai_data is NULL\n", __func__);
  2680. }
  2681. return 0;
  2682. }
  2683. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2684. struct snd_ctl_elem_value *ucontrol)
  2685. {
  2686. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2687. u32 val = ucontrol->value.integer.value[0];
  2688. if (dai_data) {
  2689. dai_data->port_config.usb_audio.endian = val;
  2690. pr_debug("%s: endian = 0x%x\n", __func__,
  2691. dai_data->port_config.usb_audio.endian);
  2692. } else {
  2693. pr_err("%s: dai_data is NULL\n", __func__);
  2694. return -EINVAL;
  2695. }
  2696. return 0;
  2697. }
  2698. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2699. struct snd_ctl_elem_value *ucontrol)
  2700. {
  2701. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2702. if (dai_data) {
  2703. ucontrol->value.integer.value[0] =
  2704. dai_data->port_config.usb_audio.endian;
  2705. pr_debug("%s: endian = 0x%x\n", __func__,
  2706. dai_data->port_config.usb_audio.endian);
  2707. } else {
  2708. pr_err("%s: dai_data is NULL\n", __func__);
  2709. return -EINVAL;
  2710. }
  2711. return 0;
  2712. }
  2713. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2714. struct snd_ctl_elem_value *ucontrol)
  2715. {
  2716. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2717. u32 val = ucontrol->value.integer.value[0];
  2718. if (!dai_data) {
  2719. pr_err("%s: dai_data is NULL\n", __func__);
  2720. return -EINVAL;
  2721. }
  2722. dai_data->port_config.usb_audio.service_interval = val;
  2723. pr_debug("%s: new service interval = %u\n", __func__,
  2724. dai_data->port_config.usb_audio.service_interval);
  2725. return 0;
  2726. }
  2727. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2728. struct snd_ctl_elem_value *ucontrol)
  2729. {
  2730. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2731. if (!dai_data) {
  2732. pr_err("%s: dai_data is NULL\n", __func__);
  2733. return -EINVAL;
  2734. }
  2735. ucontrol->value.integer.value[0] =
  2736. dai_data->port_config.usb_audio.service_interval;
  2737. pr_debug("%s: service interval = %d\n", __func__,
  2738. dai_data->port_config.usb_audio.service_interval);
  2739. return 0;
  2740. }
  2741. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2742. struct snd_ctl_elem_info *uinfo)
  2743. {
  2744. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2745. uinfo->count = sizeof(struct afe_enc_config);
  2746. return 0;
  2747. }
  2748. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2749. struct snd_ctl_elem_value *ucontrol)
  2750. {
  2751. int ret = 0;
  2752. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2753. if (dai_data) {
  2754. int format_size = sizeof(dai_data->enc_config.format);
  2755. pr_debug("%s: encoder config for %d format\n",
  2756. __func__, dai_data->enc_config.format);
  2757. memcpy(ucontrol->value.bytes.data,
  2758. &dai_data->enc_config.format,
  2759. format_size);
  2760. switch (dai_data->enc_config.format) {
  2761. case ENC_FMT_SBC:
  2762. memcpy(ucontrol->value.bytes.data + format_size,
  2763. &dai_data->enc_config.data,
  2764. sizeof(struct asm_sbc_enc_cfg_t));
  2765. break;
  2766. case ENC_FMT_AAC_V2:
  2767. memcpy(ucontrol->value.bytes.data + format_size,
  2768. &dai_data->enc_config.data,
  2769. sizeof(struct asm_aac_enc_cfg_t));
  2770. break;
  2771. case ENC_FMT_APTX:
  2772. memcpy(ucontrol->value.bytes.data + format_size,
  2773. &dai_data->enc_config.data,
  2774. sizeof(struct asm_aptx_enc_cfg_t));
  2775. break;
  2776. case ENC_FMT_APTX_HD:
  2777. memcpy(ucontrol->value.bytes.data + format_size,
  2778. &dai_data->enc_config.data,
  2779. sizeof(struct asm_custom_enc_cfg_t));
  2780. break;
  2781. case ENC_FMT_CELT:
  2782. memcpy(ucontrol->value.bytes.data + format_size,
  2783. &dai_data->enc_config.data,
  2784. sizeof(struct asm_celt_enc_cfg_t));
  2785. break;
  2786. case ENC_FMT_LDAC:
  2787. memcpy(ucontrol->value.bytes.data + format_size,
  2788. &dai_data->enc_config.data,
  2789. sizeof(struct asm_ldac_enc_cfg_t));
  2790. break;
  2791. case ENC_FMT_APTX_ADAPTIVE:
  2792. memcpy(ucontrol->value.bytes.data + format_size,
  2793. &dai_data->enc_config.data,
  2794. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2795. break;
  2796. case ENC_FMT_APTX_AD_SPEECH:
  2797. memcpy(ucontrol->value.bytes.data + format_size,
  2798. &dai_data->enc_config.data,
  2799. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2800. break;
  2801. default:
  2802. pr_debug("%s: unknown format = %d\n",
  2803. __func__, dai_data->enc_config.format);
  2804. ret = -EINVAL;
  2805. break;
  2806. }
  2807. }
  2808. return ret;
  2809. }
  2810. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2811. struct snd_ctl_elem_value *ucontrol)
  2812. {
  2813. int ret = 0;
  2814. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2815. if (dai_data) {
  2816. int format_size = sizeof(dai_data->enc_config.format);
  2817. memset(&dai_data->enc_config, 0x0,
  2818. sizeof(struct afe_enc_config));
  2819. memcpy(&dai_data->enc_config.format,
  2820. ucontrol->value.bytes.data,
  2821. format_size);
  2822. pr_debug("%s: Received encoder config for %d format\n",
  2823. __func__, dai_data->enc_config.format);
  2824. switch (dai_data->enc_config.format) {
  2825. case ENC_FMT_SBC:
  2826. memcpy(&dai_data->enc_config.data,
  2827. ucontrol->value.bytes.data + format_size,
  2828. sizeof(struct asm_sbc_enc_cfg_t));
  2829. break;
  2830. case ENC_FMT_AAC_V2:
  2831. memcpy(&dai_data->enc_config.data,
  2832. ucontrol->value.bytes.data + format_size,
  2833. sizeof(struct asm_aac_enc_cfg_t));
  2834. break;
  2835. case ENC_FMT_APTX:
  2836. memcpy(&dai_data->enc_config.data,
  2837. ucontrol->value.bytes.data + format_size,
  2838. sizeof(struct asm_aptx_enc_cfg_t));
  2839. break;
  2840. case ENC_FMT_APTX_HD:
  2841. memcpy(&dai_data->enc_config.data,
  2842. ucontrol->value.bytes.data + format_size,
  2843. sizeof(struct asm_custom_enc_cfg_t));
  2844. break;
  2845. case ENC_FMT_CELT:
  2846. memcpy(&dai_data->enc_config.data,
  2847. ucontrol->value.bytes.data + format_size,
  2848. sizeof(struct asm_celt_enc_cfg_t));
  2849. break;
  2850. case ENC_FMT_LDAC:
  2851. memcpy(&dai_data->enc_config.data,
  2852. ucontrol->value.bytes.data + format_size,
  2853. sizeof(struct asm_ldac_enc_cfg_t));
  2854. break;
  2855. case ENC_FMT_APTX_ADAPTIVE:
  2856. memcpy(&dai_data->enc_config.data,
  2857. ucontrol->value.bytes.data + format_size,
  2858. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2859. break;
  2860. case ENC_FMT_APTX_AD_SPEECH:
  2861. memcpy(&dai_data->enc_config.data,
  2862. ucontrol->value.bytes.data + format_size,
  2863. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2864. break;
  2865. default:
  2866. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2867. __func__, dai_data->enc_config.format);
  2868. ret = -EINVAL;
  2869. break;
  2870. }
  2871. } else
  2872. ret = -EINVAL;
  2873. return ret;
  2874. }
  2875. static const char *const afe_chs_text[] = {"Zero", "One", "Two"};
  2876. static const struct soc_enum afe_chs_enum[] = {
  2877. SOC_ENUM_SINGLE_EXT(3, afe_chs_text),
  2878. };
  2879. static const char *const afe_bit_format_text[] = {"S16_LE", "S24_LE",
  2880. "S32_LE"};
  2881. static const struct soc_enum afe_bit_format_enum[] = {
  2882. SOC_ENUM_SINGLE_EXT(3, afe_bit_format_text),
  2883. };
  2884. static const char *const tws_chs_mode_text[] = {"Zero", "One", "Two"};
  2885. static const struct soc_enum tws_chs_mode_enum[] = {
  2886. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tws_chs_mode_text), tws_chs_mode_text),
  2887. };
  2888. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2889. struct snd_ctl_elem_value *ucontrol)
  2890. {
  2891. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2892. if (dai_data) {
  2893. ucontrol->value.integer.value[0] = dai_data->afe_rx_in_channels;
  2894. pr_debug("%s:afe input channel = %d\n",
  2895. __func__, dai_data->afe_rx_in_channels);
  2896. }
  2897. return 0;
  2898. }
  2899. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2900. struct snd_ctl_elem_value *ucontrol)
  2901. {
  2902. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2903. if (dai_data) {
  2904. dai_data->afe_rx_in_channels = ucontrol->value.integer.value[0];
  2905. pr_debug("%s: updating afe input channel : %d\n",
  2906. __func__, dai_data->afe_rx_in_channels);
  2907. }
  2908. return 0;
  2909. }
  2910. static int msm_dai_q6_tws_channel_mode_get(struct snd_kcontrol *kcontrol,
  2911. struct snd_ctl_elem_value *ucontrol)
  2912. {
  2913. struct snd_soc_dai *dai = kcontrol->private_data;
  2914. struct msm_dai_q6_dai_data *dai_data = NULL;
  2915. if (dai)
  2916. dai_data = dev_get_drvdata(dai->dev);
  2917. if (dai_data) {
  2918. ucontrol->value.integer.value[0] =
  2919. dai_data->enc_config.mono_mode;
  2920. pr_debug("%s:tws channel mode = %d\n",
  2921. __func__, dai_data->enc_config.mono_mode);
  2922. }
  2923. return 0;
  2924. }
  2925. static int msm_dai_q6_tws_channel_mode_put(struct snd_kcontrol *kcontrol,
  2926. struct snd_ctl_elem_value *ucontrol)
  2927. {
  2928. struct snd_soc_dai *dai = kcontrol->private_data;
  2929. struct msm_dai_q6_dai_data *dai_data = NULL;
  2930. int ret = 0;
  2931. u32 format = 0;
  2932. if (dai)
  2933. dai_data = dev_get_drvdata(dai->dev);
  2934. if (dai_data)
  2935. format = dai_data->enc_config.format;
  2936. else
  2937. goto exit;
  2938. if (format == ENC_FMT_APTX || format == ENC_FMT_APTX_ADAPTIVE) {
  2939. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2940. ret = afe_set_tws_channel_mode(format,
  2941. dai->id, ucontrol->value.integer.value[0]);
  2942. if (ret < 0) {
  2943. pr_err("%s: channel mode setting failed for TWS\n",
  2944. __func__);
  2945. goto exit;
  2946. } else {
  2947. pr_debug("%s: updating tws channel mode : %d\n",
  2948. __func__, dai_data->enc_config.mono_mode);
  2949. }
  2950. }
  2951. if (ucontrol->value.integer.value[0] ==
  2952. MSM_DAI_TWS_CHANNEL_MODE_ONE ||
  2953. ucontrol->value.integer.value[0] ==
  2954. MSM_DAI_TWS_CHANNEL_MODE_TWO)
  2955. dai_data->enc_config.mono_mode =
  2956. ucontrol->value.integer.value[0];
  2957. else
  2958. return -EINVAL;
  2959. }
  2960. exit:
  2961. return ret;
  2962. }
  2963. static int msm_dai_q6_afe_input_bit_format_get(
  2964. struct snd_kcontrol *kcontrol,
  2965. struct snd_ctl_elem_value *ucontrol)
  2966. {
  2967. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2968. if (!dai_data) {
  2969. pr_err("%s: Invalid dai data\n", __func__);
  2970. return -EINVAL;
  2971. }
  2972. switch (dai_data->afe_rx_in_bitformat) {
  2973. case SNDRV_PCM_FORMAT_S32_LE:
  2974. ucontrol->value.integer.value[0] = 2;
  2975. break;
  2976. case SNDRV_PCM_FORMAT_S24_LE:
  2977. ucontrol->value.integer.value[0] = 1;
  2978. break;
  2979. case SNDRV_PCM_FORMAT_S16_LE:
  2980. default:
  2981. ucontrol->value.integer.value[0] = 0;
  2982. break;
  2983. }
  2984. pr_debug("%s: afe input bit format : %ld\n",
  2985. __func__, ucontrol->value.integer.value[0]);
  2986. return 0;
  2987. }
  2988. static int msm_dai_q6_afe_input_bit_format_put(
  2989. struct snd_kcontrol *kcontrol,
  2990. struct snd_ctl_elem_value *ucontrol)
  2991. {
  2992. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2993. if (!dai_data) {
  2994. pr_err("%s: Invalid dai data\n", __func__);
  2995. return -EINVAL;
  2996. }
  2997. switch (ucontrol->value.integer.value[0]) {
  2998. case 2:
  2999. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  3000. break;
  3001. case 1:
  3002. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  3003. break;
  3004. case 0:
  3005. default:
  3006. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  3007. break;
  3008. }
  3009. pr_debug("%s: updating afe input bit format : %d\n",
  3010. __func__, dai_data->afe_rx_in_bitformat);
  3011. return 0;
  3012. }
  3013. static int msm_dai_q6_afe_output_bit_format_get(
  3014. struct snd_kcontrol *kcontrol,
  3015. struct snd_ctl_elem_value *ucontrol)
  3016. {
  3017. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3018. if (!dai_data) {
  3019. pr_err("%s: Invalid dai data\n", __func__);
  3020. return -EINVAL;
  3021. }
  3022. switch (dai_data->afe_tx_out_bitformat) {
  3023. case SNDRV_PCM_FORMAT_S32_LE:
  3024. ucontrol->value.integer.value[0] = 2;
  3025. break;
  3026. case SNDRV_PCM_FORMAT_S24_LE:
  3027. ucontrol->value.integer.value[0] = 1;
  3028. break;
  3029. case SNDRV_PCM_FORMAT_S16_LE:
  3030. default:
  3031. ucontrol->value.integer.value[0] = 0;
  3032. break;
  3033. }
  3034. pr_debug("%s: afe output bit format : %ld\n",
  3035. __func__, ucontrol->value.integer.value[0]);
  3036. return 0;
  3037. }
  3038. static int msm_dai_q6_afe_output_bit_format_put(
  3039. struct snd_kcontrol *kcontrol,
  3040. struct snd_ctl_elem_value *ucontrol)
  3041. {
  3042. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3043. if (!dai_data) {
  3044. pr_err("%s: Invalid dai data\n", __func__);
  3045. return -EINVAL;
  3046. }
  3047. switch (ucontrol->value.integer.value[0]) {
  3048. case 2:
  3049. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  3050. break;
  3051. case 1:
  3052. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  3053. break;
  3054. case 0:
  3055. default:
  3056. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  3057. break;
  3058. }
  3059. pr_debug("%s: updating afe output bit format : %d\n",
  3060. __func__, dai_data->afe_tx_out_bitformat);
  3061. return 0;
  3062. }
  3063. static int msm_dai_q6_afe_output_channel_get(struct snd_kcontrol *kcontrol,
  3064. struct snd_ctl_elem_value *ucontrol)
  3065. {
  3066. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3067. if (dai_data) {
  3068. ucontrol->value.integer.value[0] =
  3069. dai_data->afe_tx_out_channels;
  3070. pr_debug("%s:afe output channel = %d\n",
  3071. __func__, dai_data->afe_tx_out_channels);
  3072. }
  3073. return 0;
  3074. }
  3075. static int msm_dai_q6_afe_output_channel_put(struct snd_kcontrol *kcontrol,
  3076. struct snd_ctl_elem_value *ucontrol)
  3077. {
  3078. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3079. if (dai_data) {
  3080. dai_data->afe_tx_out_channels =
  3081. ucontrol->value.integer.value[0];
  3082. pr_debug("%s: updating afe output channel : %d\n",
  3083. __func__, dai_data->afe_tx_out_channels);
  3084. }
  3085. return 0;
  3086. }
  3087. static int msm_dai_q6_afe_scrambler_mode_get(
  3088. struct snd_kcontrol *kcontrol,
  3089. struct snd_ctl_elem_value *ucontrol)
  3090. {
  3091. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3092. if (!dai_data) {
  3093. pr_err("%s: Invalid dai data\n", __func__);
  3094. return -EINVAL;
  3095. }
  3096. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  3097. return 0;
  3098. }
  3099. static int msm_dai_q6_afe_scrambler_mode_put(
  3100. struct snd_kcontrol *kcontrol,
  3101. struct snd_ctl_elem_value *ucontrol)
  3102. {
  3103. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3104. if (!dai_data) {
  3105. pr_err("%s: Invalid dai data\n", __func__);
  3106. return -EINVAL;
  3107. }
  3108. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  3109. pr_debug("%s: afe scrambler mode : %d\n",
  3110. __func__, dai_data->enc_config.scrambler_mode);
  3111. return 0;
  3112. }
  3113. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  3114. {
  3115. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3116. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3117. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3118. .name = "SLIM_7_RX Encoder Config",
  3119. .info = msm_dai_q6_afe_enc_cfg_info,
  3120. .get = msm_dai_q6_afe_enc_cfg_get,
  3121. .put = msm_dai_q6_afe_enc_cfg_put,
  3122. },
  3123. SOC_ENUM_EXT("AFE Input Channels", afe_chs_enum[0],
  3124. msm_dai_q6_afe_input_channel_get,
  3125. msm_dai_q6_afe_input_channel_put),
  3126. SOC_ENUM_EXT("AFE Input Bit Format", afe_bit_format_enum[0],
  3127. msm_dai_q6_afe_input_bit_format_get,
  3128. msm_dai_q6_afe_input_bit_format_put),
  3129. SOC_SINGLE_EXT("AFE Scrambler Mode",
  3130. 0, 0, 1, 0,
  3131. msm_dai_q6_afe_scrambler_mode_get,
  3132. msm_dai_q6_afe_scrambler_mode_put),
  3133. SOC_ENUM_EXT("TWS Channel Mode", tws_chs_mode_enum[0],
  3134. msm_dai_q6_tws_channel_mode_get,
  3135. msm_dai_q6_tws_channel_mode_put),
  3136. {
  3137. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3138. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3139. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3140. .name = "SLIM_7_RX APTX_AD Enc Cfg",
  3141. .info = msm_dai_q6_afe_enc_cfg_info,
  3142. .get = msm_dai_q6_afe_enc_cfg_get,
  3143. .put = msm_dai_q6_afe_enc_cfg_put,
  3144. }
  3145. };
  3146. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  3147. struct snd_ctl_elem_info *uinfo)
  3148. {
  3149. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3150. uinfo->count = sizeof(struct afe_dec_config);
  3151. return 0;
  3152. }
  3153. static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3154. struct snd_ctl_elem_value *ucontrol)
  3155. {
  3156. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3157. u32 format_size = 0;
  3158. u32 abr_size = 0;
  3159. if (!dai_data) {
  3160. pr_err("%s: Invalid dai data\n", __func__);
  3161. return -EINVAL;
  3162. }
  3163. format_size = sizeof(dai_data->dec_config.format);
  3164. memcpy(ucontrol->value.bytes.data,
  3165. &dai_data->dec_config.format,
  3166. format_size);
  3167. pr_debug("%s: abr_dec_cfg for %d format\n",
  3168. __func__, dai_data->dec_config.format);
  3169. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3170. memcpy(ucontrol->value.bytes.data + format_size,
  3171. &dai_data->dec_config.abr_dec_cfg,
  3172. sizeof(struct afe_imc_dec_enc_info));
  3173. switch (dai_data->dec_config.format) {
  3174. case DEC_FMT_APTX_AD_SPEECH:
  3175. pr_debug("%s: afe_dec_cfg for %d format\n",
  3176. __func__, dai_data->dec_config.format);
  3177. memcpy(ucontrol->value.bytes.data + format_size + abr_size,
  3178. &dai_data->dec_config.data,
  3179. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3180. break;
  3181. default:
  3182. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3183. __func__, dai_data->dec_config.format);
  3184. break;
  3185. }
  3186. return 0;
  3187. }
  3188. static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3189. struct snd_ctl_elem_value *ucontrol)
  3190. {
  3191. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3192. u32 format_size = 0;
  3193. u32 abr_size = 0;
  3194. if (!dai_data) {
  3195. pr_err("%s: Invalid dai data\n", __func__);
  3196. return -EINVAL;
  3197. }
  3198. memset(&dai_data->dec_config, 0x0,
  3199. sizeof(struct afe_dec_config));
  3200. format_size = sizeof(dai_data->dec_config.format);
  3201. memcpy(&dai_data->dec_config.format,
  3202. ucontrol->value.bytes.data,
  3203. format_size);
  3204. pr_debug("%s: abr_dec_cfg for %d format\n",
  3205. __func__, dai_data->dec_config.format);
  3206. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3207. memcpy(&dai_data->dec_config.abr_dec_cfg,
  3208. ucontrol->value.bytes.data + format_size,
  3209. sizeof(struct afe_imc_dec_enc_info));
  3210. dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
  3211. switch (dai_data->dec_config.format) {
  3212. case DEC_FMT_APTX_AD_SPEECH:
  3213. pr_debug("%s: afe_dec_cfg for %d format\n",
  3214. __func__, dai_data->dec_config.format);
  3215. memcpy(&dai_data->dec_config.data,
  3216. ucontrol->value.bytes.data + format_size + abr_size,
  3217. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3218. break;
  3219. default:
  3220. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3221. __func__, dai_data->dec_config.format);
  3222. break;
  3223. }
  3224. return 0;
  3225. }
  3226. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3227. struct snd_ctl_elem_value *ucontrol)
  3228. {
  3229. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3230. u32 format_size = 0;
  3231. int ret = 0;
  3232. if (!dai_data) {
  3233. pr_err("%s: Invalid dai data\n", __func__);
  3234. return -EINVAL;
  3235. }
  3236. format_size = sizeof(dai_data->dec_config.format);
  3237. memcpy(ucontrol->value.bytes.data,
  3238. &dai_data->dec_config.format,
  3239. format_size);
  3240. switch (dai_data->dec_config.format) {
  3241. case DEC_FMT_AAC_V2:
  3242. memcpy(ucontrol->value.bytes.data + format_size,
  3243. &dai_data->dec_config.data,
  3244. sizeof(struct asm_aac_dec_cfg_v2_t));
  3245. break;
  3246. case DEC_FMT_APTX_ADAPTIVE:
  3247. memcpy(ucontrol->value.bytes.data + format_size,
  3248. &dai_data->dec_config.data,
  3249. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3250. break;
  3251. case DEC_FMT_SBC:
  3252. case DEC_FMT_MP3:
  3253. /* No decoder specific data available */
  3254. break;
  3255. default:
  3256. pr_err("%s: Invalid format %d\n",
  3257. __func__, dai_data->dec_config.format);
  3258. ret = -EINVAL;
  3259. break;
  3260. }
  3261. return ret;
  3262. }
  3263. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3264. struct snd_ctl_elem_value *ucontrol)
  3265. {
  3266. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3267. u32 format_size = 0;
  3268. int ret = 0;
  3269. if (!dai_data) {
  3270. pr_err("%s: Invalid dai data\n", __func__);
  3271. return -EINVAL;
  3272. }
  3273. memset(&dai_data->dec_config, 0x0,
  3274. sizeof(struct afe_dec_config));
  3275. format_size = sizeof(dai_data->dec_config.format);
  3276. memcpy(&dai_data->dec_config.format,
  3277. ucontrol->value.bytes.data,
  3278. format_size);
  3279. pr_debug("%s: Received decoder config for %d format\n",
  3280. __func__, dai_data->dec_config.format);
  3281. switch (dai_data->dec_config.format) {
  3282. case DEC_FMT_AAC_V2:
  3283. memcpy(&dai_data->dec_config.data,
  3284. ucontrol->value.bytes.data + format_size,
  3285. sizeof(struct asm_aac_dec_cfg_v2_t));
  3286. break;
  3287. case DEC_FMT_SBC:
  3288. memcpy(&dai_data->dec_config.data,
  3289. ucontrol->value.bytes.data + format_size,
  3290. sizeof(struct asm_sbc_dec_cfg_t));
  3291. break;
  3292. case DEC_FMT_APTX_ADAPTIVE:
  3293. memcpy(&dai_data->dec_config.data,
  3294. ucontrol->value.bytes.data + format_size,
  3295. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3296. break;
  3297. default:
  3298. pr_err("%s: Invalid format %d\n",
  3299. __func__, dai_data->dec_config.format);
  3300. ret = -EINVAL;
  3301. break;
  3302. }
  3303. return ret;
  3304. }
  3305. static int msm_dai_q6_afe_enable_ttp_info(struct snd_kcontrol *kcontrol,
  3306. struct snd_ctl_elem_info *uinfo)
  3307. {
  3308. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3309. uinfo->count = sizeof(struct afe_ttp_gen_enable_t);
  3310. return 0;
  3311. }
  3312. static int msm_dai_q6_afe_enable_ttp_get(struct snd_kcontrol *kcontrol,
  3313. struct snd_ctl_elem_value *ucontrol)
  3314. {
  3315. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3316. pr_debug("%s:\n", __func__);
  3317. if (!dai_data) {
  3318. pr_err("%s: Invalid dai data\n", __func__);
  3319. return -EINVAL;
  3320. }
  3321. memcpy(ucontrol->value.bytes.data,
  3322. &dai_data->ttp_config.ttp_gen_enable,
  3323. sizeof(struct afe_ttp_gen_enable_t));
  3324. return 0;
  3325. }
  3326. static int msm_dai_q6_afe_enable_ttp_put(struct snd_kcontrol *kcontrol,
  3327. struct snd_ctl_elem_value *ucontrol)
  3328. {
  3329. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3330. pr_debug("%s:\n", __func__);
  3331. if (!dai_data) {
  3332. pr_err("%s: Invalid dai data\n", __func__);
  3333. return -EINVAL;
  3334. }
  3335. memcpy(&dai_data->ttp_config.ttp_gen_enable,
  3336. ucontrol->value.bytes.data,
  3337. sizeof(struct afe_ttp_gen_enable_t));
  3338. return 0;
  3339. }
  3340. static int msm_dai_q6_afe_ttp_cfg_info(struct snd_kcontrol *kcontrol,
  3341. struct snd_ctl_elem_info *uinfo)
  3342. {
  3343. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3344. uinfo->count = sizeof(struct afe_ttp_gen_cfg_t);
  3345. return 0;
  3346. }
  3347. static int msm_dai_q6_afe_ttp_cfg_get(struct snd_kcontrol *kcontrol,
  3348. struct snd_ctl_elem_value *ucontrol)
  3349. {
  3350. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3351. pr_debug("%s:\n", __func__);
  3352. if (!dai_data) {
  3353. pr_err("%s: Invalid dai data\n", __func__);
  3354. return -EINVAL;
  3355. }
  3356. memcpy(ucontrol->value.bytes.data,
  3357. &dai_data->ttp_config.ttp_gen_cfg,
  3358. sizeof(struct afe_ttp_gen_cfg_t));
  3359. return 0;
  3360. }
  3361. static int msm_dai_q6_afe_ttp_cfg_put(struct snd_kcontrol *kcontrol,
  3362. struct snd_ctl_elem_value *ucontrol)
  3363. {
  3364. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3365. pr_debug("%s: Received ttp config\n", __func__);
  3366. if (!dai_data) {
  3367. pr_err("%s: Invalid dai data\n", __func__);
  3368. return -EINVAL;
  3369. }
  3370. memcpy(&dai_data->ttp_config.ttp_gen_cfg,
  3371. ucontrol->value.bytes.data, sizeof(struct afe_ttp_gen_cfg_t));
  3372. return 0;
  3373. }
  3374. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  3375. {
  3376. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3377. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3378. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3379. .name = "SLIM_7_TX Decoder Config",
  3380. .info = msm_dai_q6_afe_dec_cfg_info,
  3381. .get = msm_dai_q6_afe_feedback_dec_cfg_get,
  3382. .put = msm_dai_q6_afe_feedback_dec_cfg_put,
  3383. },
  3384. {
  3385. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3386. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3387. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3388. .name = "SLIM_9_TX Decoder Config",
  3389. .info = msm_dai_q6_afe_dec_cfg_info,
  3390. .get = msm_dai_q6_afe_dec_cfg_get,
  3391. .put = msm_dai_q6_afe_dec_cfg_put,
  3392. },
  3393. SOC_ENUM_EXT("AFE Output Channels", afe_chs_enum[0],
  3394. msm_dai_q6_afe_output_channel_get,
  3395. msm_dai_q6_afe_output_channel_put),
  3396. SOC_ENUM_EXT("AFE Output Bit Format", afe_bit_format_enum[0],
  3397. msm_dai_q6_afe_output_bit_format_get,
  3398. msm_dai_q6_afe_output_bit_format_put),
  3399. };
  3400. static const struct snd_kcontrol_new afe_ttp_config_controls[] = {
  3401. {
  3402. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3403. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3404. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3405. .name = "TTP Enable",
  3406. .info = msm_dai_q6_afe_enable_ttp_info,
  3407. .get = msm_dai_q6_afe_enable_ttp_get,
  3408. .put = msm_dai_q6_afe_enable_ttp_put,
  3409. },
  3410. {
  3411. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3412. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3413. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3414. .name = "AFE TTP config",
  3415. .info = msm_dai_q6_afe_ttp_cfg_info,
  3416. .get = msm_dai_q6_afe_ttp_cfg_get,
  3417. .put = msm_dai_q6_afe_ttp_cfg_put,
  3418. },
  3419. };
  3420. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  3421. struct snd_ctl_elem_info *uinfo)
  3422. {
  3423. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3424. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  3425. return 0;
  3426. }
  3427. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  3428. struct snd_ctl_elem_value *ucontrol)
  3429. {
  3430. int ret = -EINVAL;
  3431. struct afe_param_id_dev_timing_stats timing_stats;
  3432. struct snd_soc_dai *dai = kcontrol->private_data;
  3433. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3434. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3435. pr_debug("%s: afe port not started. dai_data->status_mask = %ld\n",
  3436. __func__, *dai_data->status_mask);
  3437. goto done;
  3438. }
  3439. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  3440. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  3441. if (ret) {
  3442. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  3443. __func__, dai->id, ret);
  3444. goto done;
  3445. }
  3446. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  3447. sizeof(struct afe_param_id_dev_timing_stats));
  3448. done:
  3449. return ret;
  3450. }
  3451. static const char * const afe_cal_mode_text[] = {
  3452. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  3453. };
  3454. static const struct soc_enum slim_2_rx_enum =
  3455. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3456. afe_cal_mode_text);
  3457. static const struct soc_enum rt_proxy_1_rx_enum =
  3458. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3459. afe_cal_mode_text);
  3460. static const struct soc_enum rt_proxy_1_tx_enum =
  3461. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3462. afe_cal_mode_text);
  3463. static const struct snd_kcontrol_new sb_config_controls[] = {
  3464. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  3465. msm_dai_q6_sb_format_get,
  3466. msm_dai_q6_sb_format_put),
  3467. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  3468. msm_dai_q6_cal_info_get,
  3469. msm_dai_q6_cal_info_put),
  3470. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  3471. msm_dai_q6_sb_format_get,
  3472. msm_dai_q6_sb_format_put),
  3473. SOC_ENUM_EXT("SLIM_0_RX XTLoggingDisable", xt_logging_disable_enum[0],
  3474. msm_dai_q6_sb_xt_logging_disable_get,
  3475. msm_dai_q6_sb_xt_logging_disable_put),
  3476. };
  3477. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  3478. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  3479. msm_dai_q6_cal_info_get,
  3480. msm_dai_q6_cal_info_put),
  3481. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  3482. msm_dai_q6_cal_info_get,
  3483. msm_dai_q6_cal_info_put),
  3484. };
  3485. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  3486. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  3487. msm_dai_q6_usb_audio_cfg_get,
  3488. msm_dai_q6_usb_audio_cfg_put),
  3489. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  3490. msm_dai_q6_usb_audio_endian_cfg_get,
  3491. msm_dai_q6_usb_audio_endian_cfg_put),
  3492. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  3493. msm_dai_q6_usb_audio_cfg_get,
  3494. msm_dai_q6_usb_audio_cfg_put),
  3495. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  3496. msm_dai_q6_usb_audio_endian_cfg_get,
  3497. msm_dai_q6_usb_audio_endian_cfg_put),
  3498. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  3499. UINT_MAX, 0,
  3500. msm_dai_q6_usb_audio_svc_interval_get,
  3501. msm_dai_q6_usb_audio_svc_interval_put),
  3502. };
  3503. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  3504. {
  3505. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3506. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3507. .name = "SLIMBUS_0_RX DRIFT",
  3508. .info = msm_dai_q6_slim_rx_drift_info,
  3509. .get = msm_dai_q6_slim_rx_drift_get,
  3510. },
  3511. {
  3512. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3513. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3514. .name = "SLIMBUS_6_RX DRIFT",
  3515. .info = msm_dai_q6_slim_rx_drift_info,
  3516. .get = msm_dai_q6_slim_rx_drift_get,
  3517. },
  3518. {
  3519. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3520. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3521. .name = "SLIMBUS_7_RX DRIFT",
  3522. .info = msm_dai_q6_slim_rx_drift_info,
  3523. .get = msm_dai_q6_slim_rx_drift_get,
  3524. },
  3525. };
  3526. static inline void msm_dai_q6_set_slim_dev_id(struct snd_soc_dai *dai)
  3527. {
  3528. int rc = 0;
  3529. int slim_dev_id = 0;
  3530. const char *q6_slim_dev_id = "qcom,msm-dai-q6-slim-dev-id";
  3531. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3532. dai_data->port_config.slim_sch.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1;
  3533. rc = of_property_read_u32(dai->dev->of_node, q6_slim_dev_id,
  3534. &slim_dev_id);
  3535. if (rc) {
  3536. dev_dbg(dai->dev,
  3537. "%s: missing %s in dt node\n", __func__, q6_slim_dev_id);
  3538. return;
  3539. }
  3540. dev_dbg(dai->dev, "%s: slim_dev_id = %d\n", __func__, slim_dev_id);
  3541. if (slim_dev_id >= AFE_SLIMBUS_DEVICE_1 &&
  3542. slim_dev_id <= AFE_SLIMBUS_DEVICE_2)
  3543. dai_data->port_config.slim_sch.slimbus_dev_id = slim_dev_id;
  3544. }
  3545. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  3546. {
  3547. struct msm_dai_q6_dai_data *dai_data;
  3548. int rc = 0;
  3549. if (!dai) {
  3550. pr_err("%s: Invalid params dai\n", __func__);
  3551. return -EINVAL;
  3552. }
  3553. if (!dai->dev) {
  3554. pr_err("%s: Invalid params dai dev\n", __func__);
  3555. return -EINVAL;
  3556. }
  3557. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  3558. if (!dai_data)
  3559. return -ENOMEM;
  3560. else
  3561. dev_set_drvdata(dai->dev, dai_data);
  3562. msm_dai_q6_set_dai_id(dai);
  3563. if ((dai->id >= SLIMBUS_0_RX) && (dai->id <= SLIMBUS_9_TX))
  3564. msm_dai_q6_set_slim_dev_id(dai);
  3565. switch (dai->id) {
  3566. case SLIMBUS_4_TX:
  3567. rc = snd_ctl_add(dai->component->card->snd_card,
  3568. snd_ctl_new1(&sb_config_controls[0],
  3569. dai_data));
  3570. break;
  3571. case SLIMBUS_2_RX:
  3572. rc = snd_ctl_add(dai->component->card->snd_card,
  3573. snd_ctl_new1(&sb_config_controls[1],
  3574. dai_data));
  3575. rc = snd_ctl_add(dai->component->card->snd_card,
  3576. snd_ctl_new1(&sb_config_controls[2],
  3577. dai_data));
  3578. break;
  3579. case SLIMBUS_7_RX:
  3580. rc = snd_ctl_add(dai->component->card->snd_card,
  3581. snd_ctl_new1(&afe_enc_config_controls[0],
  3582. dai_data));
  3583. rc = snd_ctl_add(dai->component->card->snd_card,
  3584. snd_ctl_new1(&afe_enc_config_controls[1],
  3585. dai_data));
  3586. rc = snd_ctl_add(dai->component->card->snd_card,
  3587. snd_ctl_new1(&afe_enc_config_controls[2],
  3588. dai_data));
  3589. rc = snd_ctl_add(dai->component->card->snd_card,
  3590. snd_ctl_new1(&afe_enc_config_controls[3],
  3591. dai_data));
  3592. rc = snd_ctl_add(dai->component->card->snd_card,
  3593. snd_ctl_new1(&afe_enc_config_controls[4],
  3594. dai));
  3595. rc = snd_ctl_add(dai->component->card->snd_card,
  3596. snd_ctl_new1(&afe_enc_config_controls[5],
  3597. dai_data));
  3598. rc = snd_ctl_add(dai->component->card->snd_card,
  3599. snd_ctl_new1(&avd_drift_config_controls[2],
  3600. dai));
  3601. break;
  3602. case SLIMBUS_7_TX:
  3603. rc = snd_ctl_add(dai->component->card->snd_card,
  3604. snd_ctl_new1(&afe_dec_config_controls[0],
  3605. dai_data));
  3606. break;
  3607. case SLIMBUS_9_TX:
  3608. rc = snd_ctl_add(dai->component->card->snd_card,
  3609. snd_ctl_new1(&afe_dec_config_controls[1],
  3610. dai_data));
  3611. rc = snd_ctl_add(dai->component->card->snd_card,
  3612. snd_ctl_new1(&afe_dec_config_controls[2],
  3613. dai_data));
  3614. rc = snd_ctl_add(dai->component->card->snd_card,
  3615. snd_ctl_new1(&afe_dec_config_controls[3],
  3616. dai_data));
  3617. rc = snd_ctl_add(dai->component->card->snd_card,
  3618. snd_ctl_new1(&afe_ttp_config_controls[0],
  3619. dai_data));
  3620. rc = snd_ctl_add(dai->component->card->snd_card,
  3621. snd_ctl_new1(&afe_ttp_config_controls[1],
  3622. dai_data));
  3623. break;
  3624. case RT_PROXY_DAI_001_RX:
  3625. rc = snd_ctl_add(dai->component->card->snd_card,
  3626. snd_ctl_new1(&rt_proxy_config_controls[0],
  3627. dai_data));
  3628. break;
  3629. case RT_PROXY_DAI_001_TX:
  3630. rc = snd_ctl_add(dai->component->card->snd_card,
  3631. snd_ctl_new1(&rt_proxy_config_controls[1],
  3632. dai_data));
  3633. break;
  3634. case AFE_PORT_ID_USB_RX:
  3635. rc = snd_ctl_add(dai->component->card->snd_card,
  3636. snd_ctl_new1(&usb_audio_cfg_controls[0],
  3637. dai_data));
  3638. rc = snd_ctl_add(dai->component->card->snd_card,
  3639. snd_ctl_new1(&usb_audio_cfg_controls[1],
  3640. dai_data));
  3641. rc = snd_ctl_add(dai->component->card->snd_card,
  3642. snd_ctl_new1(&usb_audio_cfg_controls[4],
  3643. dai_data));
  3644. break;
  3645. case AFE_PORT_ID_USB_TX:
  3646. rc = snd_ctl_add(dai->component->card->snd_card,
  3647. snd_ctl_new1(&usb_audio_cfg_controls[2],
  3648. dai_data));
  3649. rc = snd_ctl_add(dai->component->card->snd_card,
  3650. snd_ctl_new1(&usb_audio_cfg_controls[3],
  3651. dai_data));
  3652. break;
  3653. case SLIMBUS_0_RX:
  3654. rc = snd_ctl_add(dai->component->card->snd_card,
  3655. snd_ctl_new1(&avd_drift_config_controls[0],
  3656. dai));
  3657. rc = snd_ctl_add(dai->component->card->snd_card,
  3658. snd_ctl_new1(&sb_config_controls[3],
  3659. dai_data));
  3660. break;
  3661. case SLIMBUS_6_RX:
  3662. rc = snd_ctl_add(dai->component->card->snd_card,
  3663. snd_ctl_new1(&avd_drift_config_controls[1],
  3664. dai));
  3665. break;
  3666. }
  3667. if (rc < 0)
  3668. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  3669. __func__, dai->name);
  3670. rc = msm_dai_q6_dai_add_route(dai);
  3671. return rc;
  3672. }
  3673. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  3674. {
  3675. struct msm_dai_q6_dai_data *dai_data;
  3676. int rc;
  3677. dai_data = dev_get_drvdata(dai->dev);
  3678. /* If AFE port is still up, close it */
  3679. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3680. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  3681. rc = afe_close(dai->id); /* can block */
  3682. if (rc < 0)
  3683. dev_err(dai->dev, "fail to close AFE port\n");
  3684. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3685. }
  3686. kfree(dai_data);
  3687. return 0;
  3688. }
  3689. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  3690. {
  3691. .playback = {
  3692. .stream_name = "AFE Playback",
  3693. .aif_name = "PCM_RX",
  3694. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3695. SNDRV_PCM_RATE_16000,
  3696. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3697. SNDRV_PCM_FMTBIT_S24_LE,
  3698. .channels_min = 1,
  3699. .channels_max = 2,
  3700. .rate_min = 8000,
  3701. .rate_max = 48000,
  3702. },
  3703. .ops = &msm_dai_q6_ops,
  3704. .id = RT_PROXY_DAI_001_RX,
  3705. .probe = msm_dai_q6_dai_probe,
  3706. .remove = msm_dai_q6_dai_remove,
  3707. },
  3708. {
  3709. .playback = {
  3710. .stream_name = "AFE-PROXY RX",
  3711. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3712. SNDRV_PCM_RATE_16000,
  3713. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3714. SNDRV_PCM_FMTBIT_S24_LE,
  3715. .channels_min = 1,
  3716. .channels_max = 2,
  3717. .rate_min = 8000,
  3718. .rate_max = 48000,
  3719. },
  3720. .ops = &msm_dai_q6_ops,
  3721. .id = RT_PROXY_DAI_002_RX,
  3722. .probe = msm_dai_q6_dai_probe,
  3723. .remove = msm_dai_q6_dai_remove,
  3724. },
  3725. };
  3726. static struct snd_soc_dai_driver msm_dai_q6_afe_lb_tx_dai[] = {
  3727. {
  3728. .capture = {
  3729. .stream_name = "AFE Loopback Capture",
  3730. .aif_name = "AFE_LOOPBACK_TX",
  3731. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3732. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3733. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3734. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3735. SNDRV_PCM_RATE_192000,
  3736. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  3737. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_3LE |
  3738. SNDRV_PCM_FMTBIT_S32_LE ),
  3739. .channels_min = 1,
  3740. .channels_max = 8,
  3741. .rate_min = 8000,
  3742. .rate_max = 192000,
  3743. },
  3744. .id = AFE_LOOPBACK_TX,
  3745. .probe = msm_dai_q6_dai_probe,
  3746. .remove = msm_dai_q6_dai_remove,
  3747. },
  3748. };
  3749. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  3750. {
  3751. .capture = {
  3752. .stream_name = "AFE Capture",
  3753. .aif_name = "PCM_TX",
  3754. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3755. SNDRV_PCM_RATE_16000,
  3756. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3757. .channels_min = 1,
  3758. .channels_max = 8,
  3759. .rate_min = 8000,
  3760. .rate_max = 48000,
  3761. },
  3762. .ops = &msm_dai_q6_ops,
  3763. .id = RT_PROXY_DAI_002_TX,
  3764. .probe = msm_dai_q6_dai_probe,
  3765. .remove = msm_dai_q6_dai_remove,
  3766. },
  3767. {
  3768. .capture = {
  3769. .stream_name = "AFE-PROXY TX",
  3770. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3771. SNDRV_PCM_RATE_16000,
  3772. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3773. .channels_min = 1,
  3774. .channels_max = 8,
  3775. .rate_min = 8000,
  3776. .rate_max = 48000,
  3777. },
  3778. .ops = &msm_dai_q6_ops,
  3779. .id = RT_PROXY_DAI_001_TX,
  3780. .probe = msm_dai_q6_dai_probe,
  3781. .remove = msm_dai_q6_dai_remove,
  3782. },
  3783. };
  3784. static struct snd_soc_dai_driver msm_dai_q6_afe_cap_dai = {
  3785. .capture = {
  3786. .stream_name = "AFE-PROXY TX1",
  3787. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3788. SNDRV_PCM_RATE_16000,
  3789. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3790. .channels_min = 1,
  3791. .channels_max = 8,
  3792. .rate_min = 8000,
  3793. .rate_max = 48000,
  3794. },
  3795. .ops = &msm_dai_q6_ops,
  3796. .id = RT_PROXY_DAI_003_TX,
  3797. .probe = msm_dai_q6_dai_probe,
  3798. .remove = msm_dai_q6_dai_remove,
  3799. };
  3800. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  3801. .playback = {
  3802. .stream_name = "Internal BT-SCO Playback",
  3803. .aif_name = "INT_BT_SCO_RX",
  3804. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3805. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3806. .channels_min = 1,
  3807. .channels_max = 1,
  3808. .rate_max = 16000,
  3809. .rate_min = 8000,
  3810. },
  3811. .ops = &msm_dai_q6_ops,
  3812. .id = INT_BT_SCO_RX,
  3813. .probe = msm_dai_q6_dai_probe,
  3814. .remove = msm_dai_q6_dai_remove,
  3815. };
  3816. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  3817. .playback = {
  3818. .stream_name = "Internal BT-A2DP Playback",
  3819. .aif_name = "INT_BT_A2DP_RX",
  3820. .rates = SNDRV_PCM_RATE_48000,
  3821. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3822. .channels_min = 1,
  3823. .channels_max = 2,
  3824. .rate_max = 48000,
  3825. .rate_min = 48000,
  3826. },
  3827. .ops = &msm_dai_q6_ops,
  3828. .id = INT_BT_A2DP_RX,
  3829. .probe = msm_dai_q6_dai_probe,
  3830. .remove = msm_dai_q6_dai_remove,
  3831. };
  3832. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  3833. .capture = {
  3834. .stream_name = "Internal BT-SCO Capture",
  3835. .aif_name = "INT_BT_SCO_TX",
  3836. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3837. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3838. .channels_min = 1,
  3839. .channels_max = 1,
  3840. .rate_max = 16000,
  3841. .rate_min = 8000,
  3842. },
  3843. .ops = &msm_dai_q6_ops,
  3844. .id = INT_BT_SCO_TX,
  3845. .probe = msm_dai_q6_dai_probe,
  3846. .remove = msm_dai_q6_dai_remove,
  3847. };
  3848. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  3849. .playback = {
  3850. .stream_name = "Internal FM Playback",
  3851. .aif_name = "INT_FM_RX",
  3852. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3853. SNDRV_PCM_RATE_16000,
  3854. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3855. .channels_min = 2,
  3856. .channels_max = 2,
  3857. .rate_max = 48000,
  3858. .rate_min = 8000,
  3859. },
  3860. .ops = &msm_dai_q6_ops,
  3861. .id = INT_FM_RX,
  3862. .probe = msm_dai_q6_dai_probe,
  3863. .remove = msm_dai_q6_dai_remove,
  3864. };
  3865. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  3866. .capture = {
  3867. .stream_name = "Internal FM Capture",
  3868. .aif_name = "INT_FM_TX",
  3869. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3870. SNDRV_PCM_RATE_16000,
  3871. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3872. .channels_min = 2,
  3873. .channels_max = 2,
  3874. .rate_max = 48000,
  3875. .rate_min = 8000,
  3876. },
  3877. .ops = &msm_dai_q6_ops,
  3878. .id = INT_FM_TX,
  3879. .probe = msm_dai_q6_dai_probe,
  3880. .remove = msm_dai_q6_dai_remove,
  3881. };
  3882. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  3883. {
  3884. .playback = {
  3885. .stream_name = "Voice Farend Playback",
  3886. .aif_name = "VOICE_PLAYBACK_TX",
  3887. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3888. SNDRV_PCM_RATE_16000,
  3889. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3890. .channels_min = 1,
  3891. .channels_max = 2,
  3892. .rate_min = 8000,
  3893. .rate_max = 48000,
  3894. },
  3895. .ops = &msm_dai_q6_ops,
  3896. .id = VOICE_PLAYBACK_TX,
  3897. .probe = msm_dai_q6_dai_probe,
  3898. .remove = msm_dai_q6_dai_remove,
  3899. },
  3900. {
  3901. .playback = {
  3902. .stream_name = "Voice2 Farend Playback",
  3903. .aif_name = "VOICE2_PLAYBACK_TX",
  3904. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3905. SNDRV_PCM_RATE_16000,
  3906. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3907. .channels_min = 1,
  3908. .channels_max = 2,
  3909. .rate_min = 8000,
  3910. .rate_max = 48000,
  3911. },
  3912. .ops = &msm_dai_q6_ops,
  3913. .id = VOICE2_PLAYBACK_TX,
  3914. .probe = msm_dai_q6_dai_probe,
  3915. .remove = msm_dai_q6_dai_remove,
  3916. },
  3917. };
  3918. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  3919. {
  3920. .capture = {
  3921. .stream_name = "Voice Uplink Capture",
  3922. .aif_name = "INCALL_RECORD_TX",
  3923. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3924. SNDRV_PCM_RATE_16000,
  3925. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3926. .channels_min = 1,
  3927. .channels_max = 2,
  3928. .rate_min = 8000,
  3929. .rate_max = 48000,
  3930. },
  3931. .ops = &msm_dai_q6_ops,
  3932. .id = VOICE_RECORD_TX,
  3933. .probe = msm_dai_q6_dai_probe,
  3934. .remove = msm_dai_q6_dai_remove,
  3935. },
  3936. {
  3937. .capture = {
  3938. .stream_name = "Voice Downlink Capture",
  3939. .aif_name = "INCALL_RECORD_RX",
  3940. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3941. SNDRV_PCM_RATE_16000,
  3942. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3943. .channels_min = 1,
  3944. .channels_max = 2,
  3945. .rate_min = 8000,
  3946. .rate_max = 48000,
  3947. },
  3948. .ops = &msm_dai_q6_ops,
  3949. .id = VOICE_RECORD_RX,
  3950. .probe = msm_dai_q6_dai_probe,
  3951. .remove = msm_dai_q6_dai_remove,
  3952. },
  3953. };
  3954. static struct snd_soc_dai_driver msm_dai_q6_proxy_tx_dai = {
  3955. .capture = {
  3956. .stream_name = "Proxy Capture",
  3957. .aif_name = "PROXY_TX",
  3958. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3959. SNDRV_PCM_RATE_16000,
  3960. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3961. .channels_min = 1,
  3962. .channels_max = 2,
  3963. .rate_min = 8000,
  3964. .rate_max = 48000,
  3965. },
  3966. .ops = &msm_dai_q6_ops,
  3967. .id = RT_PROXY_PORT_002_TX,
  3968. .probe = msm_dai_q6_dai_probe,
  3969. .remove = msm_dai_q6_dai_remove,
  3970. };
  3971. static struct snd_soc_dai_driver msm_dai_q6_proxy_rx_dai = {
  3972. .playback = {
  3973. .stream_name = "Proxy Playback",
  3974. .aif_name = "PROXY_RX",
  3975. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3976. SNDRV_PCM_RATE_16000,
  3977. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3978. .channels_min = 1,
  3979. .channels_max = 2,
  3980. .rate_min = 8000,
  3981. .rate_max = 48000,
  3982. },
  3983. .ops = &msm_dai_q6_ops,
  3984. .id = RT_PROXY_PORT_002_RX,
  3985. .probe = msm_dai_q6_dai_probe,
  3986. .remove = msm_dai_q6_dai_remove,
  3987. };
  3988. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  3989. .playback = {
  3990. .stream_name = "USB Audio Playback",
  3991. .aif_name = "USB_AUDIO_RX",
  3992. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3993. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3994. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3995. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3996. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3997. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3998. SNDRV_PCM_RATE_384000,
  3999. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  4000. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  4001. .channels_min = 1,
  4002. .channels_max = 8,
  4003. .rate_max = 384000,
  4004. .rate_min = 8000,
  4005. },
  4006. .ops = &msm_dai_q6_ops,
  4007. .id = AFE_PORT_ID_USB_RX,
  4008. .probe = msm_dai_q6_dai_probe,
  4009. .remove = msm_dai_q6_dai_remove,
  4010. };
  4011. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  4012. .capture = {
  4013. .stream_name = "USB Audio Capture",
  4014. .aif_name = "USB_AUDIO_TX",
  4015. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4016. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4017. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4018. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  4019. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  4020. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  4021. SNDRV_PCM_RATE_384000,
  4022. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  4023. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  4024. .channels_min = 1,
  4025. .channels_max = 8,
  4026. .rate_max = 384000,
  4027. .rate_min = 8000,
  4028. },
  4029. .ops = &msm_dai_q6_ops,
  4030. .id = AFE_PORT_ID_USB_TX,
  4031. .probe = msm_dai_q6_dai_probe,
  4032. .remove = msm_dai_q6_dai_remove,
  4033. };
  4034. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  4035. {
  4036. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  4037. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  4038. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  4039. uint32_t val = 0;
  4040. const char *intf_name;
  4041. int rc = 0, i = 0, len = 0;
  4042. const uint32_t *slot_mapping_array = NULL;
  4043. u32 array_length = 0;
  4044. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  4045. GFP_KERNEL);
  4046. if (!dai_data)
  4047. return -ENOMEM;
  4048. rc = of_property_read_u32(pdev->dev.of_node,
  4049. "qcom,msm-dai-is-island-supported",
  4050. &dai_data->is_island_dai);
  4051. if (rc)
  4052. dev_dbg(&pdev->dev, "island supported entry not found\n");
  4053. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  4054. GFP_KERNEL);
  4055. if (!auxpcm_pdata) {
  4056. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  4057. goto fail_pdata_nomem;
  4058. }
  4059. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  4060. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  4061. rc = of_property_read_u32_array(pdev->dev.of_node,
  4062. "qcom,msm-cpudai-auxpcm-mode",
  4063. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4064. if (rc) {
  4065. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  4066. __func__);
  4067. goto fail_invalid_dt;
  4068. }
  4069. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  4070. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  4071. rc = of_property_read_u32_array(pdev->dev.of_node,
  4072. "qcom,msm-cpudai-auxpcm-sync",
  4073. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4074. if (rc) {
  4075. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  4076. __func__);
  4077. goto fail_invalid_dt;
  4078. }
  4079. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  4080. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  4081. rc = of_property_read_u32_array(pdev->dev.of_node,
  4082. "qcom,msm-cpudai-auxpcm-frame",
  4083. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4084. if (rc) {
  4085. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  4086. __func__);
  4087. goto fail_invalid_dt;
  4088. }
  4089. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  4090. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  4091. rc = of_property_read_u32_array(pdev->dev.of_node,
  4092. "qcom,msm-cpudai-auxpcm-quant",
  4093. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4094. if (rc) {
  4095. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  4096. __func__);
  4097. goto fail_invalid_dt;
  4098. }
  4099. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  4100. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  4101. rc = of_property_read_u32_array(pdev->dev.of_node,
  4102. "qcom,msm-cpudai-auxpcm-num-slots",
  4103. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4104. if (rc) {
  4105. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  4106. __func__);
  4107. goto fail_invalid_dt;
  4108. }
  4109. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  4110. if (auxpcm_pdata->mode_8k.num_slots >
  4111. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  4112. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  4113. __func__,
  4114. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  4115. auxpcm_pdata->mode_8k.num_slots);
  4116. rc = -EINVAL;
  4117. goto fail_invalid_dt;
  4118. }
  4119. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  4120. if (auxpcm_pdata->mode_16k.num_slots >
  4121. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  4122. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  4123. __func__,
  4124. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  4125. auxpcm_pdata->mode_16k.num_slots);
  4126. rc = -EINVAL;
  4127. goto fail_invalid_dt;
  4128. }
  4129. slot_mapping_array = of_get_property(pdev->dev.of_node,
  4130. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  4131. if (slot_mapping_array == NULL) {
  4132. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  4133. __func__);
  4134. rc = -EINVAL;
  4135. goto fail_invalid_dt;
  4136. }
  4137. array_length = auxpcm_pdata->mode_8k.num_slots +
  4138. auxpcm_pdata->mode_16k.num_slots;
  4139. if (len != sizeof(uint32_t) * array_length) {
  4140. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  4141. __func__, len, sizeof(uint32_t) * array_length);
  4142. rc = -EINVAL;
  4143. goto fail_invalid_dt;
  4144. }
  4145. auxpcm_pdata->mode_8k.slot_mapping =
  4146. kzalloc(sizeof(uint16_t) *
  4147. auxpcm_pdata->mode_8k.num_slots,
  4148. GFP_KERNEL);
  4149. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  4150. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  4151. __func__);
  4152. rc = -ENOMEM;
  4153. goto fail_invalid_dt;
  4154. }
  4155. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  4156. auxpcm_pdata->mode_8k.slot_mapping[i] =
  4157. (u16)be32_to_cpu(slot_mapping_array[i]);
  4158. auxpcm_pdata->mode_16k.slot_mapping =
  4159. kzalloc(sizeof(uint16_t) *
  4160. auxpcm_pdata->mode_16k.num_slots,
  4161. GFP_KERNEL);
  4162. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  4163. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  4164. __func__);
  4165. rc = -ENOMEM;
  4166. goto fail_invalid_16k_slot_mapping;
  4167. }
  4168. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  4169. auxpcm_pdata->mode_16k.slot_mapping[i] =
  4170. (u16)be32_to_cpu(slot_mapping_array[i +
  4171. auxpcm_pdata->mode_8k.num_slots]);
  4172. rc = of_property_read_u32_array(pdev->dev.of_node,
  4173. "qcom,msm-cpudai-auxpcm-data",
  4174. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4175. if (rc) {
  4176. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  4177. __func__);
  4178. goto fail_invalid_dt1;
  4179. }
  4180. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  4181. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  4182. rc = of_property_read_u32_array(pdev->dev.of_node,
  4183. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  4184. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  4185. if (rc) {
  4186. dev_err(&pdev->dev,
  4187. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  4188. __func__);
  4189. goto fail_invalid_dt1;
  4190. }
  4191. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  4192. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  4193. rc = of_property_read_string(pdev->dev.of_node,
  4194. "qcom,msm-auxpcm-interface", &intf_name);
  4195. if (rc) {
  4196. dev_err(&pdev->dev,
  4197. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  4198. __func__);
  4199. goto fail_nodev_intf;
  4200. }
  4201. if (!strcmp(intf_name, "primary")) {
  4202. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  4203. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  4204. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  4205. i = 0;
  4206. } else if (!strcmp(intf_name, "secondary")) {
  4207. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  4208. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  4209. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  4210. i = 1;
  4211. } else if (!strcmp(intf_name, "tertiary")) {
  4212. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  4213. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  4214. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  4215. i = 2;
  4216. } else if (!strcmp(intf_name, "quaternary")) {
  4217. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  4218. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  4219. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  4220. i = 3;
  4221. } else if (!strcmp(intf_name, "quinary")) {
  4222. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  4223. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  4224. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  4225. i = 4;
  4226. } else if (!strcmp(intf_name, "senary")) {
  4227. dai_data->rx_pid = AFE_PORT_ID_SENARY_PCM_RX;
  4228. dai_data->tx_pid = AFE_PORT_ID_SENARY_PCM_TX;
  4229. pdev->id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID;
  4230. i = 5;
  4231. } else {
  4232. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  4233. __func__, intf_name);
  4234. goto fail_invalid_intf;
  4235. }
  4236. rc = of_property_read_u32(pdev->dev.of_node,
  4237. "qcom,msm-cpudai-afe-clk-ver", &val);
  4238. if (rc)
  4239. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  4240. else
  4241. dai_data->afe_clk_ver = val;
  4242. mutex_init(&dai_data->rlock);
  4243. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  4244. dev_set_drvdata(&pdev->dev, dai_data);
  4245. pdev->dev.platform_data = (void *) auxpcm_pdata;
  4246. rc = snd_soc_register_component(&pdev->dev,
  4247. &msm_dai_q6_aux_pcm_dai_component,
  4248. &msm_dai_q6_aux_pcm_dai[i], 1);
  4249. if (rc) {
  4250. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  4251. __func__, rc);
  4252. goto fail_reg_dai;
  4253. }
  4254. return rc;
  4255. fail_reg_dai:
  4256. fail_invalid_intf:
  4257. fail_nodev_intf:
  4258. fail_invalid_dt1:
  4259. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  4260. fail_invalid_16k_slot_mapping:
  4261. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  4262. fail_invalid_dt:
  4263. kfree(auxpcm_pdata);
  4264. fail_pdata_nomem:
  4265. kfree(dai_data);
  4266. return rc;
  4267. }
  4268. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  4269. {
  4270. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  4271. dai_data = dev_get_drvdata(&pdev->dev);
  4272. snd_soc_unregister_component(&pdev->dev);
  4273. mutex_destroy(&dai_data->rlock);
  4274. kfree(dai_data);
  4275. kfree(pdev->dev.platform_data);
  4276. return 0;
  4277. }
  4278. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  4279. { .compatible = "qcom,msm-auxpcm-dev", },
  4280. {}
  4281. };
  4282. static struct platform_driver msm_auxpcm_dev_driver = {
  4283. .probe = msm_auxpcm_dev_probe,
  4284. .remove = msm_auxpcm_dev_remove,
  4285. .driver = {
  4286. .name = "msm-auxpcm-dev",
  4287. .owner = THIS_MODULE,
  4288. .of_match_table = msm_auxpcm_dev_dt_match,
  4289. .suppress_bind_attrs = true,
  4290. },
  4291. };
  4292. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  4293. {
  4294. .playback = {
  4295. .stream_name = "Slimbus Playback",
  4296. .aif_name = "SLIMBUS_0_RX",
  4297. .rates = SNDRV_PCM_RATE_8000_384000,
  4298. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4299. .channels_min = 1,
  4300. .channels_max = 8,
  4301. .rate_min = 8000,
  4302. .rate_max = 384000,
  4303. },
  4304. .ops = &msm_dai_slimbus_0_rx_ops,
  4305. .id = SLIMBUS_0_RX,
  4306. .probe = msm_dai_q6_dai_probe,
  4307. .remove = msm_dai_q6_dai_remove,
  4308. },
  4309. {
  4310. .playback = {
  4311. .stream_name = "Slimbus1 Playback",
  4312. .aif_name = "SLIMBUS_1_RX",
  4313. .rates = SNDRV_PCM_RATE_8000_384000,
  4314. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4315. .channels_min = 1,
  4316. .channels_max = 2,
  4317. .rate_min = 8000,
  4318. .rate_max = 384000,
  4319. },
  4320. .ops = &msm_dai_q6_ops,
  4321. .id = SLIMBUS_1_RX,
  4322. .probe = msm_dai_q6_dai_probe,
  4323. .remove = msm_dai_q6_dai_remove,
  4324. },
  4325. {
  4326. .playback = {
  4327. .stream_name = "Slimbus2 Playback",
  4328. .aif_name = "SLIMBUS_2_RX",
  4329. .rates = SNDRV_PCM_RATE_8000_384000,
  4330. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4331. .channels_min = 1,
  4332. .channels_max = 8,
  4333. .rate_min = 8000,
  4334. .rate_max = 384000,
  4335. },
  4336. .ops = &msm_dai_q6_ops,
  4337. .id = SLIMBUS_2_RX,
  4338. .probe = msm_dai_q6_dai_probe,
  4339. .remove = msm_dai_q6_dai_remove,
  4340. },
  4341. {
  4342. .playback = {
  4343. .stream_name = "Slimbus3 Playback",
  4344. .aif_name = "SLIMBUS_3_RX",
  4345. .rates = SNDRV_PCM_RATE_8000_384000,
  4346. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4347. .channels_min = 1,
  4348. .channels_max = 2,
  4349. .rate_min = 8000,
  4350. .rate_max = 384000,
  4351. },
  4352. .ops = &msm_dai_q6_ops,
  4353. .id = SLIMBUS_3_RX,
  4354. .probe = msm_dai_q6_dai_probe,
  4355. .remove = msm_dai_q6_dai_remove,
  4356. },
  4357. {
  4358. .playback = {
  4359. .stream_name = "Slimbus4 Playback",
  4360. .aif_name = "SLIMBUS_4_RX",
  4361. .rates = SNDRV_PCM_RATE_8000_384000,
  4362. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4363. .channels_min = 1,
  4364. .channels_max = 2,
  4365. .rate_min = 8000,
  4366. .rate_max = 384000,
  4367. },
  4368. .ops = &msm_dai_q6_ops,
  4369. .id = SLIMBUS_4_RX,
  4370. .probe = msm_dai_q6_dai_probe,
  4371. .remove = msm_dai_q6_dai_remove,
  4372. },
  4373. {
  4374. .playback = {
  4375. .stream_name = "Slimbus6 Playback",
  4376. .aif_name = "SLIMBUS_6_RX",
  4377. .rates = SNDRV_PCM_RATE_8000_384000,
  4378. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4379. .channels_min = 1,
  4380. .channels_max = 2,
  4381. .rate_min = 8000,
  4382. .rate_max = 384000,
  4383. },
  4384. .ops = &msm_dai_q6_ops,
  4385. .id = SLIMBUS_6_RX,
  4386. .probe = msm_dai_q6_dai_probe,
  4387. .remove = msm_dai_q6_dai_remove,
  4388. },
  4389. {
  4390. .playback = {
  4391. .stream_name = "Slimbus5 Playback",
  4392. .aif_name = "SLIMBUS_5_RX",
  4393. .rates = SNDRV_PCM_RATE_8000_384000,
  4394. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4395. .channels_min = 1,
  4396. .channels_max = 2,
  4397. .rate_min = 8000,
  4398. .rate_max = 384000,
  4399. },
  4400. .ops = &msm_dai_q6_ops,
  4401. .id = SLIMBUS_5_RX,
  4402. .probe = msm_dai_q6_dai_probe,
  4403. .remove = msm_dai_q6_dai_remove,
  4404. },
  4405. {
  4406. .playback = {
  4407. .stream_name = "Slimbus7 Playback",
  4408. .aif_name = "SLIMBUS_7_RX",
  4409. .rates = SNDRV_PCM_RATE_8000_384000,
  4410. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4411. .channels_min = 1,
  4412. .channels_max = 8,
  4413. .rate_min = 8000,
  4414. .rate_max = 384000,
  4415. },
  4416. .ops = &msm_dai_q6_ops,
  4417. .id = SLIMBUS_7_RX,
  4418. .probe = msm_dai_q6_dai_probe,
  4419. .remove = msm_dai_q6_dai_remove,
  4420. },
  4421. {
  4422. .playback = {
  4423. .stream_name = "Slimbus8 Playback",
  4424. .aif_name = "SLIMBUS_8_RX",
  4425. .rates = SNDRV_PCM_RATE_8000_384000,
  4426. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4427. .channels_min = 1,
  4428. .channels_max = 8,
  4429. .rate_min = 8000,
  4430. .rate_max = 384000,
  4431. },
  4432. .ops = &msm_dai_q6_ops,
  4433. .id = SLIMBUS_8_RX,
  4434. .probe = msm_dai_q6_dai_probe,
  4435. .remove = msm_dai_q6_dai_remove,
  4436. },
  4437. {
  4438. .playback = {
  4439. .stream_name = "Slimbus9 Playback",
  4440. .aif_name = "SLIMBUS_9_RX",
  4441. .rates = SNDRV_PCM_RATE_8000_384000,
  4442. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4443. .channels_min = 1,
  4444. .channels_max = 8,
  4445. .rate_min = 8000,
  4446. .rate_max = 384000,
  4447. },
  4448. .ops = &msm_dai_q6_ops,
  4449. .id = SLIMBUS_9_RX,
  4450. .probe = msm_dai_q6_dai_probe,
  4451. .remove = msm_dai_q6_dai_remove,
  4452. },
  4453. };
  4454. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  4455. {
  4456. .capture = {
  4457. .stream_name = "Slimbus Capture",
  4458. .aif_name = "SLIMBUS_0_TX",
  4459. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4460. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4461. SNDRV_PCM_RATE_192000,
  4462. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4463. SNDRV_PCM_FMTBIT_S24_LE |
  4464. SNDRV_PCM_FMTBIT_S24_3LE,
  4465. .channels_min = 1,
  4466. .channels_max = 8,
  4467. .rate_min = 8000,
  4468. .rate_max = 192000,
  4469. },
  4470. .ops = &msm_dai_q6_ops,
  4471. .id = SLIMBUS_0_TX,
  4472. .probe = msm_dai_q6_dai_probe,
  4473. .remove = msm_dai_q6_dai_remove,
  4474. },
  4475. {
  4476. .capture = {
  4477. .stream_name = "Slimbus1 Capture",
  4478. .aif_name = "SLIMBUS_1_TX",
  4479. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4480. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4481. SNDRV_PCM_RATE_192000,
  4482. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4483. SNDRV_PCM_FMTBIT_S24_LE |
  4484. SNDRV_PCM_FMTBIT_S24_3LE,
  4485. .channels_min = 1,
  4486. .channels_max = 2,
  4487. .rate_min = 8000,
  4488. .rate_max = 192000,
  4489. },
  4490. .ops = &msm_dai_q6_ops,
  4491. .id = SLIMBUS_1_TX,
  4492. .probe = msm_dai_q6_dai_probe,
  4493. .remove = msm_dai_q6_dai_remove,
  4494. },
  4495. {
  4496. .capture = {
  4497. .stream_name = "Slimbus2 Capture",
  4498. .aif_name = "SLIMBUS_2_TX",
  4499. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4500. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4501. SNDRV_PCM_RATE_192000,
  4502. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4503. SNDRV_PCM_FMTBIT_S24_LE,
  4504. .channels_min = 1,
  4505. .channels_max = 8,
  4506. .rate_min = 8000,
  4507. .rate_max = 192000,
  4508. },
  4509. .ops = &msm_dai_q6_ops,
  4510. .id = SLIMBUS_2_TX,
  4511. .probe = msm_dai_q6_dai_probe,
  4512. .remove = msm_dai_q6_dai_remove,
  4513. },
  4514. {
  4515. .capture = {
  4516. .stream_name = "Slimbus3 Capture",
  4517. .aif_name = "SLIMBUS_3_TX",
  4518. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4519. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4520. SNDRV_PCM_RATE_192000,
  4521. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4522. SNDRV_PCM_FMTBIT_S24_LE,
  4523. .channels_min = 2,
  4524. .channels_max = 4,
  4525. .rate_min = 8000,
  4526. .rate_max = 192000,
  4527. },
  4528. .ops = &msm_dai_q6_ops,
  4529. .id = SLIMBUS_3_TX,
  4530. .probe = msm_dai_q6_dai_probe,
  4531. .remove = msm_dai_q6_dai_remove,
  4532. },
  4533. {
  4534. .capture = {
  4535. .stream_name = "Slimbus4 Capture",
  4536. .aif_name = "SLIMBUS_4_TX",
  4537. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4538. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4539. SNDRV_PCM_RATE_192000,
  4540. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4541. SNDRV_PCM_FMTBIT_S24_LE |
  4542. SNDRV_PCM_FMTBIT_S32_LE,
  4543. .channels_min = 2,
  4544. .channels_max = 4,
  4545. .rate_min = 8000,
  4546. .rate_max = 192000,
  4547. },
  4548. .ops = &msm_dai_q6_ops,
  4549. .id = SLIMBUS_4_TX,
  4550. .probe = msm_dai_q6_dai_probe,
  4551. .remove = msm_dai_q6_dai_remove,
  4552. },
  4553. {
  4554. .capture = {
  4555. .stream_name = "Slimbus5 Capture",
  4556. .aif_name = "SLIMBUS_5_TX",
  4557. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4558. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4559. SNDRV_PCM_RATE_192000,
  4560. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4561. SNDRV_PCM_FMTBIT_S24_LE,
  4562. .channels_min = 1,
  4563. .channels_max = 8,
  4564. .rate_min = 8000,
  4565. .rate_max = 192000,
  4566. },
  4567. .ops = &msm_dai_q6_ops,
  4568. .id = SLIMBUS_5_TX,
  4569. .probe = msm_dai_q6_dai_probe,
  4570. .remove = msm_dai_q6_dai_remove,
  4571. },
  4572. {
  4573. .capture = {
  4574. .stream_name = "Slimbus6 Capture",
  4575. .aif_name = "SLIMBUS_6_TX",
  4576. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4577. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4578. SNDRV_PCM_RATE_192000,
  4579. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4580. SNDRV_PCM_FMTBIT_S24_LE,
  4581. .channels_min = 1,
  4582. .channels_max = 2,
  4583. .rate_min = 8000,
  4584. .rate_max = 192000,
  4585. },
  4586. .ops = &msm_dai_q6_ops,
  4587. .id = SLIMBUS_6_TX,
  4588. .probe = msm_dai_q6_dai_probe,
  4589. .remove = msm_dai_q6_dai_remove,
  4590. },
  4591. {
  4592. .capture = {
  4593. .stream_name = "Slimbus7 Capture",
  4594. .aif_name = "SLIMBUS_7_TX",
  4595. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4596. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4597. SNDRV_PCM_RATE_192000,
  4598. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4599. SNDRV_PCM_FMTBIT_S24_LE |
  4600. SNDRV_PCM_FMTBIT_S32_LE,
  4601. .channels_min = 1,
  4602. .channels_max = 8,
  4603. .rate_min = 8000,
  4604. .rate_max = 192000,
  4605. },
  4606. .ops = &msm_dai_q6_ops,
  4607. .id = SLIMBUS_7_TX,
  4608. .probe = msm_dai_q6_dai_probe,
  4609. .remove = msm_dai_q6_dai_remove,
  4610. },
  4611. {
  4612. .capture = {
  4613. .stream_name = "Slimbus8 Capture",
  4614. .aif_name = "SLIMBUS_8_TX",
  4615. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4616. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4617. SNDRV_PCM_RATE_192000,
  4618. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4619. SNDRV_PCM_FMTBIT_S24_LE |
  4620. SNDRV_PCM_FMTBIT_S32_LE,
  4621. .channels_min = 1,
  4622. .channels_max = 8,
  4623. .rate_min = 8000,
  4624. .rate_max = 192000,
  4625. },
  4626. .ops = &msm_dai_q6_ops,
  4627. .id = SLIMBUS_8_TX,
  4628. .probe = msm_dai_q6_dai_probe,
  4629. .remove = msm_dai_q6_dai_remove,
  4630. },
  4631. {
  4632. .capture = {
  4633. .stream_name = "Slimbus9 Capture",
  4634. .aif_name = "SLIMBUS_9_TX",
  4635. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4636. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  4637. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  4638. SNDRV_PCM_RATE_192000,
  4639. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4640. SNDRV_PCM_FMTBIT_S24_LE |
  4641. SNDRV_PCM_FMTBIT_S32_LE,
  4642. .channels_min = 1,
  4643. .channels_max = 8,
  4644. .rate_min = 8000,
  4645. .rate_max = 192000,
  4646. },
  4647. .ops = &msm_dai_q6_ops,
  4648. .id = SLIMBUS_9_TX,
  4649. .probe = msm_dai_q6_dai_probe,
  4650. .remove = msm_dai_q6_dai_remove,
  4651. },
  4652. };
  4653. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  4654. struct snd_ctl_elem_value *ucontrol)
  4655. {
  4656. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4657. int value = ucontrol->value.integer.value[0];
  4658. dai_data->port_config.i2s.data_format = value;
  4659. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  4660. __func__, value, dai_data->port_config.i2s.mono_stereo,
  4661. dai_data->port_config.i2s.channel_mode);
  4662. return 0;
  4663. }
  4664. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  4665. struct snd_ctl_elem_value *ucontrol)
  4666. {
  4667. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4668. ucontrol->value.integer.value[0] =
  4669. dai_data->port_config.i2s.data_format;
  4670. return 0;
  4671. }
  4672. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  4673. struct snd_ctl_elem_value *ucontrol)
  4674. {
  4675. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4676. int value = ucontrol->value.integer.value[0];
  4677. dai_data->vi_feed_mono = value;
  4678. pr_debug("%s: value = %d\n", __func__, value);
  4679. return 0;
  4680. }
  4681. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  4682. struct snd_ctl_elem_value *ucontrol)
  4683. {
  4684. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4685. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  4686. return 0;
  4687. }
  4688. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  4689. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  4690. msm_dai_q6_mi2s_format_get,
  4691. msm_dai_q6_mi2s_format_put),
  4692. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  4693. msm_dai_q6_mi2s_format_get,
  4694. msm_dai_q6_mi2s_format_put),
  4695. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  4696. msm_dai_q6_mi2s_format_get,
  4697. msm_dai_q6_mi2s_format_put),
  4698. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  4699. msm_dai_q6_mi2s_format_get,
  4700. msm_dai_q6_mi2s_format_put),
  4701. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  4702. msm_dai_q6_mi2s_format_get,
  4703. msm_dai_q6_mi2s_format_put),
  4704. SOC_ENUM_EXT("SENARY MI2S RX Format", mi2s_config_enum[0],
  4705. msm_dai_q6_mi2s_format_get,
  4706. msm_dai_q6_mi2s_format_put),
  4707. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  4708. msm_dai_q6_mi2s_format_get,
  4709. msm_dai_q6_mi2s_format_put),
  4710. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  4711. msm_dai_q6_mi2s_format_get,
  4712. msm_dai_q6_mi2s_format_put),
  4713. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  4714. msm_dai_q6_mi2s_format_get,
  4715. msm_dai_q6_mi2s_format_put),
  4716. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  4717. msm_dai_q6_mi2s_format_get,
  4718. msm_dai_q6_mi2s_format_put),
  4719. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  4720. msm_dai_q6_mi2s_format_get,
  4721. msm_dai_q6_mi2s_format_put),
  4722. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  4723. msm_dai_q6_mi2s_format_get,
  4724. msm_dai_q6_mi2s_format_put),
  4725. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  4726. msm_dai_q6_mi2s_format_get,
  4727. msm_dai_q6_mi2s_format_put),
  4728. };
  4729. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  4730. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  4731. msm_dai_q6_mi2s_vi_feed_mono_get,
  4732. msm_dai_q6_mi2s_vi_feed_mono_put),
  4733. };
  4734. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  4735. {
  4736. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4737. dev_get_drvdata(dai->dev);
  4738. struct msm_mi2s_pdata *mi2s_pdata =
  4739. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  4740. struct snd_kcontrol *kcontrol = NULL;
  4741. int rc = 0;
  4742. const struct snd_kcontrol_new *ctrl = NULL;
  4743. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  4744. u16 dai_id = 0;
  4745. dai->id = mi2s_pdata->intf_id;
  4746. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4747. if (dai->id == MSM_PRIM_MI2S)
  4748. ctrl = &mi2s_config_controls[0];
  4749. if (dai->id == MSM_SEC_MI2S)
  4750. ctrl = &mi2s_config_controls[1];
  4751. if (dai->id == MSM_TERT_MI2S)
  4752. ctrl = &mi2s_config_controls[2];
  4753. if (dai->id == MSM_QUAT_MI2S)
  4754. ctrl = &mi2s_config_controls[3];
  4755. if (dai->id == MSM_QUIN_MI2S)
  4756. ctrl = &mi2s_config_controls[4];
  4757. if (dai->id == MSM_SENARY_MI2S)
  4758. ctrl = &mi2s_config_controls[5];
  4759. }
  4760. if (ctrl) {
  4761. kcontrol = snd_ctl_new1(ctrl,
  4762. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  4763. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  4764. if (rc < 0) {
  4765. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  4766. __func__, dai->name);
  4767. goto rtn;
  4768. }
  4769. }
  4770. ctrl = NULL;
  4771. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4772. if (dai->id == MSM_PRIM_MI2S)
  4773. ctrl = &mi2s_config_controls[6];
  4774. if (dai->id == MSM_SEC_MI2S)
  4775. ctrl = &mi2s_config_controls[7];
  4776. if (dai->id == MSM_TERT_MI2S)
  4777. ctrl = &mi2s_config_controls[8];
  4778. if (dai->id == MSM_QUAT_MI2S)
  4779. ctrl = &mi2s_config_controls[9];
  4780. if (dai->id == MSM_QUIN_MI2S)
  4781. ctrl = &mi2s_config_controls[10];
  4782. if (dai->id == MSM_SENARY_MI2S)
  4783. ctrl = &mi2s_config_controls[11];
  4784. if (dai->id == MSM_INT5_MI2S)
  4785. ctrl = &mi2s_config_controls[12];
  4786. }
  4787. if (ctrl) {
  4788. rc = snd_ctl_add(dai->component->card->snd_card,
  4789. snd_ctl_new1(ctrl,
  4790. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4791. if (rc < 0) {
  4792. if (kcontrol)
  4793. snd_ctl_remove(dai->component->card->snd_card,
  4794. kcontrol);
  4795. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  4796. __func__, dai->name);
  4797. }
  4798. }
  4799. if (dai->id == MSM_INT5_MI2S)
  4800. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  4801. if (vi_feed_ctrl) {
  4802. rc = snd_ctl_add(dai->component->card->snd_card,
  4803. snd_ctl_new1(vi_feed_ctrl,
  4804. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4805. if (rc < 0) {
  4806. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  4807. __func__, dai->name);
  4808. }
  4809. }
  4810. if (mi2s_dai_data->is_island_dai) {
  4811. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  4812. &dai_id);
  4813. rc = msm_dai_q6_add_island_mx_ctls(
  4814. dai->component->card->snd_card,
  4815. dai->name, dai_id,
  4816. (void *)mi2s_dai_data);
  4817. }
  4818. rc = msm_dai_q6_dai_add_route(dai);
  4819. rtn:
  4820. return rc;
  4821. }
  4822. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  4823. {
  4824. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4825. dev_get_drvdata(dai->dev);
  4826. int rc;
  4827. /* If AFE port is still up, close it */
  4828. if (test_bit(STATUS_PORT_STARTED,
  4829. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  4830. rc = afe_close(MI2S_RX); /* can block */
  4831. if (rc < 0)
  4832. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  4833. clear_bit(STATUS_PORT_STARTED,
  4834. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  4835. }
  4836. if (test_bit(STATUS_PORT_STARTED,
  4837. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4838. rc = afe_close(MI2S_TX); /* can block */
  4839. if (rc < 0)
  4840. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  4841. clear_bit(STATUS_PORT_STARTED,
  4842. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  4843. }
  4844. return 0;
  4845. }
  4846. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  4847. struct snd_soc_dai *dai)
  4848. {
  4849. return 0;
  4850. }
  4851. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  4852. {
  4853. int ret = 0;
  4854. switch (stream) {
  4855. case SNDRV_PCM_STREAM_PLAYBACK:
  4856. switch (mi2s_id) {
  4857. case MSM_PRIM_MI2S:
  4858. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4859. break;
  4860. case MSM_SEC_MI2S:
  4861. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4862. break;
  4863. case MSM_TERT_MI2S:
  4864. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4865. break;
  4866. case MSM_QUAT_MI2S:
  4867. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4868. break;
  4869. case MSM_SEC_MI2S_SD1:
  4870. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  4871. break;
  4872. case MSM_QUIN_MI2S:
  4873. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4874. break;
  4875. case MSM_SENARY_MI2S:
  4876. *port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  4877. break;
  4878. case MSM_INT0_MI2S:
  4879. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  4880. break;
  4881. case MSM_INT1_MI2S:
  4882. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  4883. break;
  4884. case MSM_INT2_MI2S:
  4885. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  4886. break;
  4887. case MSM_INT3_MI2S:
  4888. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  4889. break;
  4890. case MSM_INT4_MI2S:
  4891. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  4892. break;
  4893. case MSM_INT5_MI2S:
  4894. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  4895. break;
  4896. case MSM_INT6_MI2S:
  4897. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  4898. break;
  4899. default:
  4900. pr_err("%s: playback err id 0x%x\n",
  4901. __func__, mi2s_id);
  4902. ret = -1;
  4903. break;
  4904. }
  4905. break;
  4906. case SNDRV_PCM_STREAM_CAPTURE:
  4907. switch (mi2s_id) {
  4908. case MSM_PRIM_MI2S:
  4909. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4910. break;
  4911. case MSM_SEC_MI2S:
  4912. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4913. break;
  4914. case MSM_TERT_MI2S:
  4915. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4916. break;
  4917. case MSM_QUAT_MI2S:
  4918. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4919. break;
  4920. case MSM_QUIN_MI2S:
  4921. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4922. break;
  4923. case MSM_SENARY_MI2S:
  4924. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  4925. break;
  4926. case MSM_INT0_MI2S:
  4927. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  4928. break;
  4929. case MSM_INT1_MI2S:
  4930. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  4931. break;
  4932. case MSM_INT2_MI2S:
  4933. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  4934. break;
  4935. case MSM_INT3_MI2S:
  4936. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  4937. break;
  4938. case MSM_INT4_MI2S:
  4939. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  4940. break;
  4941. case MSM_INT5_MI2S:
  4942. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  4943. break;
  4944. case MSM_INT6_MI2S:
  4945. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  4946. break;
  4947. default:
  4948. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  4949. ret = -1;
  4950. break;
  4951. }
  4952. break;
  4953. default:
  4954. pr_err("%s: default err %d\n", __func__, stream);
  4955. ret = -1;
  4956. break;
  4957. }
  4958. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  4959. return ret;
  4960. }
  4961. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  4962. struct snd_soc_dai *dai)
  4963. {
  4964. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4965. dev_get_drvdata(dai->dev);
  4966. struct msm_dai_q6_dai_data *dai_data =
  4967. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4968. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4969. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4970. u16 port_id = 0;
  4971. int rc = 0;
  4972. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4973. &port_id) != 0) {
  4974. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4975. __func__, port_id);
  4976. return -EINVAL;
  4977. }
  4978. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  4979. "dai_data->channels = %u sample_rate = %u\n", __func__,
  4980. dai->id, port_id, dai_data->channels, dai_data->rate);
  4981. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4982. /* PORT START should be set if prepare called
  4983. * in active state.
  4984. */
  4985. rc = afe_port_start(port_id, &dai_data->port_config,
  4986. dai_data->rate);
  4987. if (rc < 0)
  4988. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  4989. dai->id);
  4990. else
  4991. set_bit(STATUS_PORT_STARTED,
  4992. dai_data->status_mask);
  4993. }
  4994. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4995. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4996. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  4997. __func__);
  4998. }
  4999. return rc;
  5000. }
  5001. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  5002. struct snd_pcm_hw_params *params,
  5003. struct snd_soc_dai *dai)
  5004. {
  5005. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5006. dev_get_drvdata(dai->dev);
  5007. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  5008. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5009. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  5010. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  5011. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  5012. dai_data->channels = params_channels(params);
  5013. switch (dai_data->channels) {
  5014. case 15:
  5015. case 16:
  5016. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5017. case AFE_PORT_I2S_16CHS:
  5018. dai_data->port_config.i2s.channel_mode
  5019. = AFE_PORT_I2S_16CHS;
  5020. break;
  5021. default:
  5022. goto error_invalid_data;
  5023. };
  5024. break;
  5025. case 13:
  5026. case 14:
  5027. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5028. case AFE_PORT_I2S_14CHS:
  5029. case AFE_PORT_I2S_16CHS:
  5030. dai_data->port_config.i2s.channel_mode
  5031. = AFE_PORT_I2S_14CHS;
  5032. break;
  5033. default:
  5034. goto error_invalid_data;
  5035. };
  5036. break;
  5037. case 11:
  5038. case 12:
  5039. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5040. case AFE_PORT_I2S_12CHS:
  5041. case AFE_PORT_I2S_14CHS:
  5042. case AFE_PORT_I2S_16CHS:
  5043. dai_data->port_config.i2s.channel_mode
  5044. = AFE_PORT_I2S_12CHS;
  5045. break;
  5046. default:
  5047. goto error_invalid_data;
  5048. };
  5049. break;
  5050. case 9:
  5051. case 10:
  5052. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5053. case AFE_PORT_I2S_10CHS:
  5054. case AFE_PORT_I2S_12CHS:
  5055. case AFE_PORT_I2S_14CHS:
  5056. case AFE_PORT_I2S_16CHS:
  5057. dai_data->port_config.i2s.channel_mode
  5058. = AFE_PORT_I2S_10CHS;
  5059. break;
  5060. default:
  5061. goto error_invalid_data;
  5062. };
  5063. break;
  5064. case 8:
  5065. case 7:
  5066. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  5067. goto error_invalid_data;
  5068. else
  5069. if (mi2s_dai_config->pdata_mi2s_lines
  5070. == AFE_PORT_I2S_8CHS_2)
  5071. dai_data->port_config.i2s.channel_mode =
  5072. AFE_PORT_I2S_8CHS_2;
  5073. else
  5074. dai_data->port_config.i2s.channel_mode =
  5075. AFE_PORT_I2S_8CHS;
  5076. break;
  5077. case 6:
  5078. case 5:
  5079. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  5080. goto error_invalid_data;
  5081. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  5082. break;
  5083. case 4:
  5084. case 3:
  5085. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5086. case AFE_PORT_I2S_SD0:
  5087. case AFE_PORT_I2S_SD1:
  5088. case AFE_PORT_I2S_SD2:
  5089. case AFE_PORT_I2S_SD3:
  5090. case AFE_PORT_I2S_SD4:
  5091. case AFE_PORT_I2S_SD5:
  5092. case AFE_PORT_I2S_SD6:
  5093. case AFE_PORT_I2S_SD7:
  5094. goto error_invalid_data;
  5095. break;
  5096. case AFE_PORT_I2S_QUAD01:
  5097. case AFE_PORT_I2S_QUAD23:
  5098. case AFE_PORT_I2S_QUAD45:
  5099. case AFE_PORT_I2S_QUAD67:
  5100. dai_data->port_config.i2s.channel_mode =
  5101. mi2s_dai_config->pdata_mi2s_lines;
  5102. break;
  5103. case AFE_PORT_I2S_8CHS_2:
  5104. dai_data->port_config.i2s.channel_mode =
  5105. AFE_PORT_I2S_QUAD45;
  5106. break;
  5107. default:
  5108. dai_data->port_config.i2s.channel_mode =
  5109. AFE_PORT_I2S_QUAD01;
  5110. break;
  5111. };
  5112. break;
  5113. case 2:
  5114. case 1:
  5115. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  5116. goto error_invalid_data;
  5117. switch (mi2s_dai_config->pdata_mi2s_lines) {
  5118. case AFE_PORT_I2S_SD0:
  5119. case AFE_PORT_I2S_SD1:
  5120. case AFE_PORT_I2S_SD2:
  5121. case AFE_PORT_I2S_SD3:
  5122. case AFE_PORT_I2S_SD4:
  5123. case AFE_PORT_I2S_SD5:
  5124. case AFE_PORT_I2S_SD6:
  5125. case AFE_PORT_I2S_SD7:
  5126. dai_data->port_config.i2s.channel_mode =
  5127. mi2s_dai_config->pdata_mi2s_lines;
  5128. break;
  5129. case AFE_PORT_I2S_QUAD01:
  5130. case AFE_PORT_I2S_6CHS:
  5131. case AFE_PORT_I2S_8CHS:
  5132. case AFE_PORT_I2S_10CHS:
  5133. case AFE_PORT_I2S_12CHS:
  5134. case AFE_PORT_I2S_14CHS:
  5135. case AFE_PORT_I2S_16CHS:
  5136. if (dai_data->vi_feed_mono == SPKR_1)
  5137. dai_data->port_config.i2s.channel_mode =
  5138. AFE_PORT_I2S_SD0;
  5139. else
  5140. dai_data->port_config.i2s.channel_mode =
  5141. AFE_PORT_I2S_SD1;
  5142. break;
  5143. case AFE_PORT_I2S_QUAD23:
  5144. dai_data->port_config.i2s.channel_mode =
  5145. AFE_PORT_I2S_SD2;
  5146. break;
  5147. case AFE_PORT_I2S_QUAD45:
  5148. dai_data->port_config.i2s.channel_mode =
  5149. AFE_PORT_I2S_SD4;
  5150. break;
  5151. case AFE_PORT_I2S_QUAD67:
  5152. dai_data->port_config.i2s.channel_mode =
  5153. AFE_PORT_I2S_SD6;
  5154. break;
  5155. }
  5156. if (dai_data->channels == 2)
  5157. dai_data->port_config.i2s.mono_stereo =
  5158. MSM_AFE_CH_STEREO;
  5159. else
  5160. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  5161. break;
  5162. default:
  5163. pr_err("%s: default err channels %d\n",
  5164. __func__, dai_data->channels);
  5165. goto error_invalid_data;
  5166. }
  5167. dai_data->rate = params_rate(params);
  5168. switch (params_format(params)) {
  5169. case SNDRV_PCM_FORMAT_S16_LE:
  5170. case SNDRV_PCM_FORMAT_SPECIAL:
  5171. dai_data->port_config.i2s.bit_width = 16;
  5172. dai_data->bitwidth = 16;
  5173. break;
  5174. case SNDRV_PCM_FORMAT_S24_LE:
  5175. case SNDRV_PCM_FORMAT_S24_3LE:
  5176. dai_data->port_config.i2s.bit_width = 24;
  5177. dai_data->bitwidth = 24;
  5178. break;
  5179. case SNDRV_PCM_FORMAT_S32_LE:
  5180. dai_data->port_config.i2s.bit_width = 32;
  5181. dai_data->bitwidth = 32;
  5182. break;
  5183. default:
  5184. pr_err("%s: format %d\n",
  5185. __func__, params_format(params));
  5186. return -EINVAL;
  5187. }
  5188. dai_data->port_config.i2s.i2s_cfg_minor_version =
  5189. AFE_API_VERSION_I2S_CONFIG;
  5190. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  5191. if ((test_bit(STATUS_PORT_STARTED,
  5192. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  5193. test_bit(STATUS_PORT_STARTED,
  5194. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  5195. (test_bit(STATUS_PORT_STARTED,
  5196. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  5197. test_bit(STATUS_PORT_STARTED,
  5198. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  5199. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  5200. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  5201. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  5202. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  5203. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  5204. "Tx sample_rate = %u bit_width = %hu\n"
  5205. "Rx sample_rate = %u bit_width = %hu\n"
  5206. , __func__,
  5207. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  5208. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  5209. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  5210. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  5211. return -EINVAL;
  5212. }
  5213. }
  5214. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  5215. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  5216. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  5217. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  5218. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  5219. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  5220. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  5221. i2s->sample_rate, i2s->data_format, i2s->reserved);
  5222. return 0;
  5223. error_invalid_data:
  5224. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  5225. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  5226. return -EINVAL;
  5227. }
  5228. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  5229. {
  5230. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5231. dev_get_drvdata(dai->dev);
  5232. if (test_bit(STATUS_PORT_STARTED,
  5233. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  5234. test_bit(STATUS_PORT_STARTED,
  5235. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  5236. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  5237. __func__);
  5238. return -EPERM;
  5239. }
  5240. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  5241. case SND_SOC_DAIFMT_CBS_CFS:
  5242. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5243. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5244. break;
  5245. case SND_SOC_DAIFMT_CBM_CFM:
  5246. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5247. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5248. break;
  5249. default:
  5250. pr_err("%s: fmt %d\n",
  5251. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  5252. return -EINVAL;
  5253. }
  5254. return 0;
  5255. }
  5256. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  5257. struct snd_soc_dai *dai)
  5258. {
  5259. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5260. dev_get_drvdata(dai->dev);
  5261. struct msm_dai_q6_dai_data *dai_data =
  5262. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5263. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5264. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5265. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  5266. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5267. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  5268. }
  5269. return 0;
  5270. }
  5271. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  5272. struct snd_soc_dai *dai)
  5273. {
  5274. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5275. dev_get_drvdata(dai->dev);
  5276. struct msm_dai_q6_dai_data *dai_data =
  5277. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5278. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5279. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5280. u16 port_id = 0;
  5281. int rc = 0;
  5282. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  5283. &port_id) != 0) {
  5284. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5285. __func__, port_id);
  5286. }
  5287. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  5288. __func__, port_id);
  5289. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5290. rc = afe_close(port_id);
  5291. if (rc < 0)
  5292. dev_err(dai->dev, "fail to close AFE port\n");
  5293. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  5294. }
  5295. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  5296. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5297. }
  5298. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  5299. .startup = msm_dai_q6_mi2s_startup,
  5300. .prepare = msm_dai_q6_mi2s_prepare,
  5301. .hw_params = msm_dai_q6_mi2s_hw_params,
  5302. .hw_free = msm_dai_q6_mi2s_hw_free,
  5303. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  5304. .shutdown = msm_dai_q6_mi2s_shutdown,
  5305. };
  5306. /* Channel min and max are initialized base on platform data */
  5307. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  5308. {
  5309. .playback = {
  5310. .stream_name = "Primary MI2S Playback",
  5311. .aif_name = "PRI_MI2S_RX",
  5312. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5313. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5314. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5315. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5316. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5317. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5318. SNDRV_PCM_RATE_384000,
  5319. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5320. SNDRV_PCM_FMTBIT_S24_LE |
  5321. SNDRV_PCM_FMTBIT_S24_3LE,
  5322. .rate_min = 8000,
  5323. .rate_max = 384000,
  5324. },
  5325. .capture = {
  5326. .stream_name = "Primary MI2S Capture",
  5327. .aif_name = "PRI_MI2S_TX",
  5328. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5329. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5330. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5331. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5332. SNDRV_PCM_RATE_192000,
  5333. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5334. .rate_min = 8000,
  5335. .rate_max = 192000,
  5336. },
  5337. .ops = &msm_dai_q6_mi2s_ops,
  5338. .name = "Primary MI2S",
  5339. .id = MSM_PRIM_MI2S,
  5340. .probe = msm_dai_q6_dai_mi2s_probe,
  5341. .remove = msm_dai_q6_dai_mi2s_remove,
  5342. },
  5343. {
  5344. .playback = {
  5345. .stream_name = "Secondary MI2S Playback",
  5346. .aif_name = "SEC_MI2S_RX",
  5347. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5348. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5349. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5350. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5351. SNDRV_PCM_RATE_192000,
  5352. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5353. .rate_min = 8000,
  5354. .rate_max = 192000,
  5355. },
  5356. .capture = {
  5357. .stream_name = "Secondary MI2S Capture",
  5358. .aif_name = "SEC_MI2S_TX",
  5359. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5360. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5361. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5362. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5363. SNDRV_PCM_RATE_192000,
  5364. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5365. .rate_min = 8000,
  5366. .rate_max = 192000,
  5367. },
  5368. .ops = &msm_dai_q6_mi2s_ops,
  5369. .name = "Secondary MI2S",
  5370. .id = MSM_SEC_MI2S,
  5371. .probe = msm_dai_q6_dai_mi2s_probe,
  5372. .remove = msm_dai_q6_dai_mi2s_remove,
  5373. },
  5374. {
  5375. .playback = {
  5376. .stream_name = "Tertiary MI2S Playback",
  5377. .aif_name = "TERT_MI2S_RX",
  5378. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5379. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5380. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5381. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5382. SNDRV_PCM_RATE_192000,
  5383. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5384. .rate_min = 8000,
  5385. .rate_max = 192000,
  5386. },
  5387. .capture = {
  5388. .stream_name = "Tertiary MI2S Capture",
  5389. .aif_name = "TERT_MI2S_TX",
  5390. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5391. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5392. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5393. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5394. SNDRV_PCM_RATE_192000,
  5395. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5396. .rate_min = 8000,
  5397. .rate_max = 192000,
  5398. },
  5399. .ops = &msm_dai_q6_mi2s_ops,
  5400. .name = "Tertiary MI2S",
  5401. .id = MSM_TERT_MI2S,
  5402. .probe = msm_dai_q6_dai_mi2s_probe,
  5403. .remove = msm_dai_q6_dai_mi2s_remove,
  5404. },
  5405. {
  5406. .playback = {
  5407. .stream_name = "Quaternary MI2S Playback",
  5408. .aif_name = "QUAT_MI2S_RX",
  5409. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5410. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5411. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5412. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5413. SNDRV_PCM_RATE_192000,
  5414. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5415. .rate_min = 8000,
  5416. .rate_max = 192000,
  5417. },
  5418. .capture = {
  5419. .stream_name = "Quaternary MI2S Capture",
  5420. .aif_name = "QUAT_MI2S_TX",
  5421. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5422. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5423. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5424. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5425. SNDRV_PCM_RATE_192000,
  5426. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5427. .rate_min = 8000,
  5428. .rate_max = 192000,
  5429. },
  5430. .ops = &msm_dai_q6_mi2s_ops,
  5431. .name = "Quaternary MI2S",
  5432. .id = MSM_QUAT_MI2S,
  5433. .probe = msm_dai_q6_dai_mi2s_probe,
  5434. .remove = msm_dai_q6_dai_mi2s_remove,
  5435. },
  5436. {
  5437. .playback = {
  5438. .stream_name = "Quinary MI2S Playback",
  5439. .aif_name = "QUIN_MI2S_RX",
  5440. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5441. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5442. SNDRV_PCM_RATE_192000,
  5443. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5444. .rate_min = 8000,
  5445. .rate_max = 192000,
  5446. },
  5447. .capture = {
  5448. .stream_name = "Quinary MI2S Capture",
  5449. .aif_name = "QUIN_MI2S_TX",
  5450. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5451. SNDRV_PCM_RATE_16000,
  5452. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5453. .rate_min = 8000,
  5454. .rate_max = 48000,
  5455. },
  5456. .ops = &msm_dai_q6_mi2s_ops,
  5457. .name = "Quinary MI2S",
  5458. .id = MSM_QUIN_MI2S,
  5459. .probe = msm_dai_q6_dai_mi2s_probe,
  5460. .remove = msm_dai_q6_dai_mi2s_remove,
  5461. },
  5462. {
  5463. .playback = {
  5464. .stream_name = "Senary MI2S Playback",
  5465. .aif_name = "SEN_MI2S_RX",
  5466. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5467. SNDRV_PCM_RATE_16000,
  5468. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5469. .rate_min = 8000,
  5470. .rate_max = 48000,
  5471. },
  5472. .capture = {
  5473. .stream_name = "Senary MI2S Capture",
  5474. .aif_name = "SENARY_MI2S_TX",
  5475. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5476. SNDRV_PCM_RATE_16000,
  5477. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5478. .rate_min = 8000,
  5479. .rate_max = 48000,
  5480. },
  5481. .ops = &msm_dai_q6_mi2s_ops,
  5482. .name = "Senary MI2S",
  5483. .id = MSM_SENARY_MI2S,
  5484. .probe = msm_dai_q6_dai_mi2s_probe,
  5485. .remove = msm_dai_q6_dai_mi2s_remove,
  5486. },
  5487. {
  5488. .playback = {
  5489. .stream_name = "Secondary MI2S Playback SD1",
  5490. .aif_name = "SEC_MI2S_RX_SD1",
  5491. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5492. SNDRV_PCM_RATE_16000,
  5493. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5494. .rate_min = 8000,
  5495. .rate_max = 48000,
  5496. },
  5497. .id = MSM_SEC_MI2S_SD1,
  5498. },
  5499. {
  5500. .playback = {
  5501. .stream_name = "INT0 MI2S Playback",
  5502. .aif_name = "INT0_MI2S_RX",
  5503. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5504. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  5505. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  5506. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5507. SNDRV_PCM_FMTBIT_S24_LE |
  5508. SNDRV_PCM_FMTBIT_S24_3LE,
  5509. .rate_min = 8000,
  5510. .rate_max = 192000,
  5511. },
  5512. .capture = {
  5513. .stream_name = "INT0 MI2S Capture",
  5514. .aif_name = "INT0_MI2S_TX",
  5515. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5516. SNDRV_PCM_RATE_16000,
  5517. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5518. .rate_min = 8000,
  5519. .rate_max = 48000,
  5520. },
  5521. .ops = &msm_dai_q6_mi2s_ops,
  5522. .name = "INT0 MI2S",
  5523. .id = MSM_INT0_MI2S,
  5524. .probe = msm_dai_q6_dai_mi2s_probe,
  5525. .remove = msm_dai_q6_dai_mi2s_remove,
  5526. },
  5527. {
  5528. .playback = {
  5529. .stream_name = "INT1 MI2S Playback",
  5530. .aif_name = "INT1_MI2S_RX",
  5531. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5532. SNDRV_PCM_RATE_16000,
  5533. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5534. SNDRV_PCM_FMTBIT_S24_LE |
  5535. SNDRV_PCM_FMTBIT_S24_3LE,
  5536. .rate_min = 8000,
  5537. .rate_max = 48000,
  5538. },
  5539. .capture = {
  5540. .stream_name = "INT1 MI2S Capture",
  5541. .aif_name = "INT1_MI2S_TX",
  5542. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5543. SNDRV_PCM_RATE_16000,
  5544. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5545. .rate_min = 8000,
  5546. .rate_max = 48000,
  5547. },
  5548. .ops = &msm_dai_q6_mi2s_ops,
  5549. .name = "INT1 MI2S",
  5550. .id = MSM_INT1_MI2S,
  5551. .probe = msm_dai_q6_dai_mi2s_probe,
  5552. .remove = msm_dai_q6_dai_mi2s_remove,
  5553. },
  5554. {
  5555. .playback = {
  5556. .stream_name = "INT2 MI2S Playback",
  5557. .aif_name = "INT2_MI2S_RX",
  5558. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5559. SNDRV_PCM_RATE_16000,
  5560. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5561. SNDRV_PCM_FMTBIT_S24_LE |
  5562. SNDRV_PCM_FMTBIT_S24_3LE,
  5563. .rate_min = 8000,
  5564. .rate_max = 48000,
  5565. },
  5566. .capture = {
  5567. .stream_name = "INT2 MI2S Capture",
  5568. .aif_name = "INT2_MI2S_TX",
  5569. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5570. SNDRV_PCM_RATE_16000,
  5571. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5572. .rate_min = 8000,
  5573. .rate_max = 48000,
  5574. },
  5575. .ops = &msm_dai_q6_mi2s_ops,
  5576. .name = "INT2 MI2S",
  5577. .id = MSM_INT2_MI2S,
  5578. .probe = msm_dai_q6_dai_mi2s_probe,
  5579. .remove = msm_dai_q6_dai_mi2s_remove,
  5580. },
  5581. {
  5582. .playback = {
  5583. .stream_name = "INT3 MI2S Playback",
  5584. .aif_name = "INT3_MI2S_RX",
  5585. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5586. SNDRV_PCM_RATE_16000,
  5587. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5588. SNDRV_PCM_FMTBIT_S24_LE |
  5589. SNDRV_PCM_FMTBIT_S24_3LE,
  5590. .rate_min = 8000,
  5591. .rate_max = 48000,
  5592. },
  5593. .capture = {
  5594. .stream_name = "INT3 MI2S Capture",
  5595. .aif_name = "INT3_MI2S_TX",
  5596. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5597. SNDRV_PCM_RATE_16000,
  5598. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5599. .rate_min = 8000,
  5600. .rate_max = 48000,
  5601. },
  5602. .ops = &msm_dai_q6_mi2s_ops,
  5603. .name = "INT3 MI2S",
  5604. .id = MSM_INT3_MI2S,
  5605. .probe = msm_dai_q6_dai_mi2s_probe,
  5606. .remove = msm_dai_q6_dai_mi2s_remove,
  5607. },
  5608. {
  5609. .playback = {
  5610. .stream_name = "INT4 MI2S Playback",
  5611. .aif_name = "INT4_MI2S_RX",
  5612. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5613. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5614. SNDRV_PCM_RATE_192000,
  5615. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5616. SNDRV_PCM_FMTBIT_S24_LE |
  5617. SNDRV_PCM_FMTBIT_S24_3LE,
  5618. .rate_min = 8000,
  5619. .rate_max = 192000,
  5620. },
  5621. .capture = {
  5622. .stream_name = "INT4 MI2S Capture",
  5623. .aif_name = "INT4_MI2S_TX",
  5624. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5625. SNDRV_PCM_RATE_16000,
  5626. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5627. .rate_min = 8000,
  5628. .rate_max = 48000,
  5629. },
  5630. .ops = &msm_dai_q6_mi2s_ops,
  5631. .name = "INT4 MI2S",
  5632. .id = MSM_INT4_MI2S,
  5633. .probe = msm_dai_q6_dai_mi2s_probe,
  5634. .remove = msm_dai_q6_dai_mi2s_remove,
  5635. },
  5636. {
  5637. .playback = {
  5638. .stream_name = "INT5 MI2S Playback",
  5639. .aif_name = "INT5_MI2S_RX",
  5640. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5641. SNDRV_PCM_RATE_16000,
  5642. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5643. SNDRV_PCM_FMTBIT_S24_LE |
  5644. SNDRV_PCM_FMTBIT_S24_3LE,
  5645. .rate_min = 8000,
  5646. .rate_max = 48000,
  5647. },
  5648. .capture = {
  5649. .stream_name = "INT5 MI2S Capture",
  5650. .aif_name = "INT5_MI2S_TX",
  5651. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5652. SNDRV_PCM_RATE_16000,
  5653. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5654. .rate_min = 8000,
  5655. .rate_max = 48000,
  5656. },
  5657. .ops = &msm_dai_q6_mi2s_ops,
  5658. .name = "INT5 MI2S",
  5659. .id = MSM_INT5_MI2S,
  5660. .probe = msm_dai_q6_dai_mi2s_probe,
  5661. .remove = msm_dai_q6_dai_mi2s_remove,
  5662. },
  5663. {
  5664. .playback = {
  5665. .stream_name = "INT6 MI2S Playback",
  5666. .aif_name = "INT6_MI2S_RX",
  5667. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5668. SNDRV_PCM_RATE_16000,
  5669. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5670. SNDRV_PCM_FMTBIT_S24_LE |
  5671. SNDRV_PCM_FMTBIT_S24_3LE,
  5672. .rate_min = 8000,
  5673. .rate_max = 48000,
  5674. },
  5675. .capture = {
  5676. .stream_name = "INT6 MI2S Capture",
  5677. .aif_name = "INT6_MI2S_TX",
  5678. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5679. SNDRV_PCM_RATE_16000,
  5680. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5681. .rate_min = 8000,
  5682. .rate_max = 48000,
  5683. },
  5684. .ops = &msm_dai_q6_mi2s_ops,
  5685. .name = "INT6 MI2S",
  5686. .id = MSM_INT6_MI2S,
  5687. .probe = msm_dai_q6_dai_mi2s_probe,
  5688. .remove = msm_dai_q6_dai_mi2s_remove,
  5689. },
  5690. };
  5691. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  5692. unsigned int *ch_cnt)
  5693. {
  5694. u8 num_of_sd_lines;
  5695. num_of_sd_lines = num_of_bits_set(sd_lines);
  5696. switch (num_of_sd_lines) {
  5697. case 0:
  5698. pr_debug("%s: no line is assigned\n", __func__);
  5699. break;
  5700. case 1:
  5701. switch (sd_lines) {
  5702. case MSM_MI2S_SD0:
  5703. *config_ptr = AFE_PORT_I2S_SD0;
  5704. break;
  5705. case MSM_MI2S_SD1:
  5706. *config_ptr = AFE_PORT_I2S_SD1;
  5707. break;
  5708. case MSM_MI2S_SD2:
  5709. *config_ptr = AFE_PORT_I2S_SD2;
  5710. break;
  5711. case MSM_MI2S_SD3:
  5712. *config_ptr = AFE_PORT_I2S_SD3;
  5713. break;
  5714. case MSM_MI2S_SD4:
  5715. *config_ptr = AFE_PORT_I2S_SD4;
  5716. break;
  5717. case MSM_MI2S_SD5:
  5718. *config_ptr = AFE_PORT_I2S_SD5;
  5719. break;
  5720. case MSM_MI2S_SD6:
  5721. *config_ptr = AFE_PORT_I2S_SD6;
  5722. break;
  5723. case MSM_MI2S_SD7:
  5724. *config_ptr = AFE_PORT_I2S_SD7;
  5725. break;
  5726. default:
  5727. pr_err("%s: invalid SD lines %d\n",
  5728. __func__, sd_lines);
  5729. goto error_invalid_data;
  5730. }
  5731. break;
  5732. case 2:
  5733. switch (sd_lines) {
  5734. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  5735. *config_ptr = AFE_PORT_I2S_QUAD01;
  5736. break;
  5737. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5738. *config_ptr = AFE_PORT_I2S_QUAD23;
  5739. break;
  5740. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5741. *config_ptr = AFE_PORT_I2S_QUAD45;
  5742. break;
  5743. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5744. *config_ptr = AFE_PORT_I2S_QUAD67;
  5745. break;
  5746. default:
  5747. pr_err("%s: invalid SD lines %d\n",
  5748. __func__, sd_lines);
  5749. goto error_invalid_data;
  5750. }
  5751. break;
  5752. case 3:
  5753. switch (sd_lines) {
  5754. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  5755. *config_ptr = AFE_PORT_I2S_6CHS;
  5756. break;
  5757. default:
  5758. pr_err("%s: invalid SD lines %d\n",
  5759. __func__, sd_lines);
  5760. goto error_invalid_data;
  5761. }
  5762. break;
  5763. case 4:
  5764. switch (sd_lines) {
  5765. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5766. *config_ptr = AFE_PORT_I2S_8CHS;
  5767. break;
  5768. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5769. *config_ptr = AFE_PORT_I2S_8CHS_2;
  5770. break;
  5771. default:
  5772. pr_err("%s: invalid SD lines %d\n",
  5773. __func__, sd_lines);
  5774. goto error_invalid_data;
  5775. }
  5776. break;
  5777. case 5:
  5778. switch (sd_lines) {
  5779. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5780. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  5781. *config_ptr = AFE_PORT_I2S_10CHS;
  5782. break;
  5783. default:
  5784. pr_err("%s: invalid SD lines %d\n",
  5785. __func__, sd_lines);
  5786. goto error_invalid_data;
  5787. }
  5788. break;
  5789. case 6:
  5790. switch (sd_lines) {
  5791. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5792. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5793. *config_ptr = AFE_PORT_I2S_12CHS;
  5794. break;
  5795. default:
  5796. pr_err("%s: invalid SD lines %d\n",
  5797. __func__, sd_lines);
  5798. goto error_invalid_data;
  5799. }
  5800. break;
  5801. case 7:
  5802. switch (sd_lines) {
  5803. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5804. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  5805. *config_ptr = AFE_PORT_I2S_14CHS;
  5806. break;
  5807. default:
  5808. pr_err("%s: invalid SD lines %d\n",
  5809. __func__, sd_lines);
  5810. goto error_invalid_data;
  5811. }
  5812. break;
  5813. case 8:
  5814. switch (sd_lines) {
  5815. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5816. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5817. *config_ptr = AFE_PORT_I2S_16CHS;
  5818. break;
  5819. default:
  5820. pr_err("%s: invalid SD lines %d\n",
  5821. __func__, sd_lines);
  5822. goto error_invalid_data;
  5823. }
  5824. break;
  5825. default:
  5826. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  5827. goto error_invalid_data;
  5828. }
  5829. *ch_cnt = num_of_sd_lines;
  5830. return 0;
  5831. error_invalid_data:
  5832. pr_err("%s: invalid data\n", __func__);
  5833. return -EINVAL;
  5834. }
  5835. static u16 msm_dai_q6_mi2s_get_num_channels(u16 config)
  5836. {
  5837. switch (config) {
  5838. case AFE_PORT_I2S_SD0:
  5839. case AFE_PORT_I2S_SD1:
  5840. case AFE_PORT_I2S_SD2:
  5841. case AFE_PORT_I2S_SD3:
  5842. case AFE_PORT_I2S_SD4:
  5843. case AFE_PORT_I2S_SD5:
  5844. case AFE_PORT_I2S_SD6:
  5845. case AFE_PORT_I2S_SD7:
  5846. return 2;
  5847. case AFE_PORT_I2S_QUAD01:
  5848. case AFE_PORT_I2S_QUAD23:
  5849. case AFE_PORT_I2S_QUAD45:
  5850. case AFE_PORT_I2S_QUAD67:
  5851. return 4;
  5852. case AFE_PORT_I2S_6CHS:
  5853. return 6;
  5854. case AFE_PORT_I2S_8CHS:
  5855. case AFE_PORT_I2S_8CHS_2:
  5856. return 8;
  5857. case AFE_PORT_I2S_10CHS:
  5858. return 10;
  5859. case AFE_PORT_I2S_12CHS:
  5860. return 12;
  5861. case AFE_PORT_I2S_14CHS:
  5862. return 14;
  5863. case AFE_PORT_I2S_16CHS:
  5864. return 16;
  5865. default:
  5866. pr_err("%s: invalid config\n", __func__);
  5867. return 0;
  5868. }
  5869. }
  5870. static int msm_dai_q6_mi2s_platform_data_validation(
  5871. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  5872. {
  5873. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  5874. struct msm_mi2s_pdata *mi2s_pdata =
  5875. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  5876. unsigned int ch_cnt;
  5877. int rc = 0;
  5878. u16 sd_line;
  5879. if (mi2s_pdata == NULL) {
  5880. pr_err("%s: mi2s_pdata NULL", __func__);
  5881. return -EINVAL;
  5882. }
  5883. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  5884. &sd_line, &ch_cnt);
  5885. if (rc < 0) {
  5886. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  5887. goto rtn;
  5888. }
  5889. if (ch_cnt) {
  5890. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5891. sd_line;
  5892. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  5893. dai_driver->playback.channels_min = 1;
  5894. dai_driver->playback.channels_max = ch_cnt << 1;
  5895. } else {
  5896. dai_driver->playback.channels_min = 0;
  5897. dai_driver->playback.channels_max = 0;
  5898. }
  5899. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  5900. &sd_line, &ch_cnt);
  5901. if (rc < 0) {
  5902. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  5903. goto rtn;
  5904. }
  5905. if (ch_cnt) {
  5906. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5907. sd_line;
  5908. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  5909. dai_driver->capture.channels_min = 1;
  5910. dai_driver->capture.channels_max = ch_cnt << 1;
  5911. } else {
  5912. dai_driver->capture.channels_min = 0;
  5913. dai_driver->capture.channels_max = 0;
  5914. }
  5915. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  5916. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  5917. dai_data->tx_dai.pdata_mi2s_lines);
  5918. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  5919. __func__, dai_driver->playback.channels_max,
  5920. dai_driver->capture.channels_max);
  5921. rtn:
  5922. return rc;
  5923. }
  5924. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  5925. .name = "msm-dai-q6-mi2s",
  5926. };
  5927. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  5928. {
  5929. struct msm_dai_q6_mi2s_dai_data *dai_data;
  5930. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  5931. u32 tx_line = 0;
  5932. u32 rx_line = 0;
  5933. u32 mi2s_intf = 0;
  5934. struct msm_mi2s_pdata *mi2s_pdata;
  5935. int rc;
  5936. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  5937. &mi2s_intf);
  5938. if (rc) {
  5939. dev_err(&pdev->dev,
  5940. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  5941. goto rtn;
  5942. }
  5943. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  5944. mi2s_intf);
  5945. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  5946. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  5947. dev_err(&pdev->dev,
  5948. "%s: Invalid MI2S ID %u from Device Tree\n",
  5949. __func__, mi2s_intf);
  5950. rc = -ENXIO;
  5951. goto rtn;
  5952. }
  5953. pdev->id = mi2s_intf;
  5954. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  5955. if (!mi2s_pdata) {
  5956. rc = -ENOMEM;
  5957. goto rtn;
  5958. }
  5959. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  5960. &rx_line);
  5961. if (rc) {
  5962. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  5963. "qcom,msm-mi2s-rx-lines");
  5964. goto free_pdata;
  5965. }
  5966. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  5967. &tx_line);
  5968. if (rc) {
  5969. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  5970. "qcom,msm-mi2s-tx-lines");
  5971. goto free_pdata;
  5972. }
  5973. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  5974. dev_name(&pdev->dev), rx_line, tx_line);
  5975. mi2s_pdata->rx_sd_lines = rx_line;
  5976. mi2s_pdata->tx_sd_lines = tx_line;
  5977. mi2s_pdata->intf_id = mi2s_intf;
  5978. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  5979. GFP_KERNEL);
  5980. if (!dai_data) {
  5981. rc = -ENOMEM;
  5982. goto free_pdata;
  5983. } else
  5984. dev_set_drvdata(&pdev->dev, dai_data);
  5985. rc = of_property_read_u32(pdev->dev.of_node,
  5986. "qcom,msm-dai-is-island-supported",
  5987. &dai_data->is_island_dai);
  5988. if (rc)
  5989. dev_dbg(&pdev->dev, "island supported entry not found\n");
  5990. pdev->dev.platform_data = mi2s_pdata;
  5991. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  5992. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  5993. if (rc < 0)
  5994. goto free_dai_data;
  5995. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  5996. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  5997. if (rc < 0)
  5998. goto err_register;
  5999. return 0;
  6000. err_register:
  6001. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  6002. free_dai_data:
  6003. kfree(dai_data);
  6004. free_pdata:
  6005. kfree(mi2s_pdata);
  6006. rtn:
  6007. return rc;
  6008. }
  6009. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  6010. {
  6011. snd_soc_unregister_component(&pdev->dev);
  6012. return 0;
  6013. }
  6014. static int msm_dai_q6_dai_meta_mi2s_probe(struct snd_soc_dai *dai)
  6015. {
  6016. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  6017. (struct msm_meta_mi2s_pdata *) dai->dev->platform_data;
  6018. int rc = 0;
  6019. dai->id = meta_mi2s_pdata->intf_id;
  6020. rc = msm_dai_q6_dai_add_route(dai);
  6021. return rc;
  6022. }
  6023. static int msm_dai_q6_dai_meta_mi2s_remove(struct snd_soc_dai *dai)
  6024. {
  6025. return 0;
  6026. }
  6027. static int msm_dai_q6_meta_mi2s_startup(struct snd_pcm_substream *substream,
  6028. struct snd_soc_dai *dai)
  6029. {
  6030. return 0;
  6031. }
  6032. static int msm_meta_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  6033. {
  6034. int ret = 0;
  6035. switch (stream) {
  6036. case SNDRV_PCM_STREAM_PLAYBACK:
  6037. switch (mi2s_id) {
  6038. case MSM_PRIM_META_MI2S:
  6039. *port_id = AFE_PORT_ID_PRIMARY_META_MI2S_RX;
  6040. break;
  6041. case MSM_SEC_META_MI2S:
  6042. *port_id = AFE_PORT_ID_SECONDARY_META_MI2S_RX;
  6043. break;
  6044. default:
  6045. pr_err("%s: playback err id 0x%x\n",
  6046. __func__, mi2s_id);
  6047. ret = -1;
  6048. break;
  6049. }
  6050. break;
  6051. case SNDRV_PCM_STREAM_CAPTURE:
  6052. switch (mi2s_id) {
  6053. default:
  6054. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  6055. ret = -1;
  6056. break;
  6057. }
  6058. break;
  6059. default:
  6060. pr_err("%s: default err %d\n", __func__, stream);
  6061. ret = -1;
  6062. break;
  6063. }
  6064. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  6065. return ret;
  6066. }
  6067. static int msm_dai_q6_meta_mi2s_prepare(struct snd_pcm_substream *substream,
  6068. struct snd_soc_dai *dai)
  6069. {
  6070. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6071. dev_get_drvdata(dai->dev);
  6072. u16 port_id = 0;
  6073. int rc = 0;
  6074. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  6075. &port_id) != 0) {
  6076. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  6077. __func__, port_id);
  6078. return -EINVAL;
  6079. }
  6080. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  6081. "dai_data->channels = %u sample_rate = %u\n", __func__,
  6082. dai->id, port_id, dai_data->channels, dai_data->rate);
  6083. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6084. /* PORT START should be set if prepare called
  6085. * in active state.
  6086. */
  6087. rc = afe_port_start(port_id, &dai_data->port_config,
  6088. dai_data->rate);
  6089. if (rc < 0)
  6090. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  6091. dai->id);
  6092. else
  6093. set_bit(STATUS_PORT_STARTED,
  6094. dai_data->status_mask);
  6095. }
  6096. return rc;
  6097. }
  6098. static int msm_dai_q6_meta_mi2s_hw_params(struct snd_pcm_substream *substream,
  6099. struct snd_pcm_hw_params *params,
  6100. struct snd_soc_dai *dai)
  6101. {
  6102. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6103. dev_get_drvdata(dai->dev);
  6104. struct afe_param_id_meta_i2s_cfg *port_cfg =
  6105. &dai_data->port_config.meta_i2s;
  6106. int idx = 0;
  6107. u16 port_channels = 0;
  6108. u16 channels_left = 0;
  6109. dai_data->channels = params_channels(params);
  6110. channels_left = dai_data->channels;
  6111. /* map requested channels to channels that member ports provide */
  6112. for (idx = 0; idx < dai_data->num_member_ports; idx++) {
  6113. port_channels = msm_dai_q6_mi2s_get_num_channels(
  6114. dai_data->channel_mode[idx]);
  6115. if (channels_left >= port_channels) {
  6116. port_cfg->member_port_id[idx] =
  6117. dai_data->member_port_id[idx];
  6118. port_cfg->member_port_channel_mode[idx] =
  6119. dai_data->channel_mode[idx];
  6120. channels_left -= port_channels;
  6121. } else {
  6122. switch (channels_left) {
  6123. case 15:
  6124. case 16:
  6125. switch (dai_data->channel_mode[idx]) {
  6126. case AFE_PORT_I2S_16CHS:
  6127. port_cfg->member_port_channel_mode[idx]
  6128. = AFE_PORT_I2S_16CHS;
  6129. break;
  6130. default:
  6131. goto error_invalid_data;
  6132. };
  6133. break;
  6134. case 13:
  6135. case 14:
  6136. switch (dai_data->channel_mode[idx]) {
  6137. case AFE_PORT_I2S_14CHS:
  6138. case AFE_PORT_I2S_16CHS:
  6139. port_cfg->member_port_channel_mode[idx]
  6140. = AFE_PORT_I2S_14CHS;
  6141. break;
  6142. default:
  6143. goto error_invalid_data;
  6144. };
  6145. break;
  6146. case 11:
  6147. case 12:
  6148. switch (dai_data->channel_mode[idx]) {
  6149. case AFE_PORT_I2S_12CHS:
  6150. case AFE_PORT_I2S_14CHS:
  6151. case AFE_PORT_I2S_16CHS:
  6152. port_cfg->member_port_channel_mode[idx]
  6153. = AFE_PORT_I2S_12CHS;
  6154. break;
  6155. default:
  6156. goto error_invalid_data;
  6157. };
  6158. break;
  6159. case 9:
  6160. case 10:
  6161. switch (dai_data->channel_mode[idx]) {
  6162. case AFE_PORT_I2S_10CHS:
  6163. case AFE_PORT_I2S_12CHS:
  6164. case AFE_PORT_I2S_14CHS:
  6165. case AFE_PORT_I2S_16CHS:
  6166. port_cfg->member_port_channel_mode[idx]
  6167. = AFE_PORT_I2S_10CHS;
  6168. break;
  6169. default:
  6170. goto error_invalid_data;
  6171. };
  6172. break;
  6173. case 8:
  6174. case 7:
  6175. switch (dai_data->channel_mode[idx]) {
  6176. case AFE_PORT_I2S_8CHS:
  6177. case AFE_PORT_I2S_10CHS:
  6178. case AFE_PORT_I2S_12CHS:
  6179. case AFE_PORT_I2S_14CHS:
  6180. case AFE_PORT_I2S_16CHS:
  6181. port_cfg->member_port_channel_mode[idx]
  6182. = AFE_PORT_I2S_8CHS;
  6183. break;
  6184. case AFE_PORT_I2S_8CHS_2:
  6185. port_cfg->member_port_channel_mode[idx]
  6186. = AFE_PORT_I2S_8CHS_2;
  6187. break;
  6188. default:
  6189. goto error_invalid_data;
  6190. };
  6191. break;
  6192. case 6:
  6193. case 5:
  6194. switch (dai_data->channel_mode[idx]) {
  6195. case AFE_PORT_I2S_6CHS:
  6196. case AFE_PORT_I2S_8CHS:
  6197. case AFE_PORT_I2S_10CHS:
  6198. case AFE_PORT_I2S_12CHS:
  6199. case AFE_PORT_I2S_14CHS:
  6200. case AFE_PORT_I2S_16CHS:
  6201. port_cfg->member_port_channel_mode[idx]
  6202. = AFE_PORT_I2S_6CHS;
  6203. break;
  6204. default:
  6205. goto error_invalid_data;
  6206. };
  6207. break;
  6208. case 4:
  6209. case 3:
  6210. switch (dai_data->channel_mode[idx]) {
  6211. case AFE_PORT_I2S_SD0:
  6212. case AFE_PORT_I2S_SD1:
  6213. case AFE_PORT_I2S_SD2:
  6214. case AFE_PORT_I2S_SD3:
  6215. case AFE_PORT_I2S_SD4:
  6216. case AFE_PORT_I2S_SD5:
  6217. case AFE_PORT_I2S_SD6:
  6218. case AFE_PORT_I2S_SD7:
  6219. goto error_invalid_data;
  6220. case AFE_PORT_I2S_QUAD01:
  6221. case AFE_PORT_I2S_QUAD23:
  6222. case AFE_PORT_I2S_QUAD45:
  6223. case AFE_PORT_I2S_QUAD67:
  6224. port_cfg->member_port_channel_mode[idx]
  6225. = dai_data->channel_mode[idx];
  6226. break;
  6227. case AFE_PORT_I2S_8CHS_2:
  6228. port_cfg->member_port_channel_mode[idx]
  6229. = AFE_PORT_I2S_QUAD45;
  6230. break;
  6231. default:
  6232. port_cfg->member_port_channel_mode[idx]
  6233. = AFE_PORT_I2S_QUAD01;
  6234. };
  6235. break;
  6236. case 2:
  6237. case 1:
  6238. if (dai_data->channel_mode[idx] <
  6239. AFE_PORT_I2S_SD0)
  6240. goto error_invalid_data;
  6241. switch (dai_data->channel_mode[idx]) {
  6242. case AFE_PORT_I2S_SD0:
  6243. case AFE_PORT_I2S_SD1:
  6244. case AFE_PORT_I2S_SD2:
  6245. case AFE_PORT_I2S_SD3:
  6246. case AFE_PORT_I2S_SD4:
  6247. case AFE_PORT_I2S_SD5:
  6248. case AFE_PORT_I2S_SD6:
  6249. case AFE_PORT_I2S_SD7:
  6250. port_cfg->member_port_channel_mode[idx]
  6251. = dai_data->channel_mode[idx];
  6252. break;
  6253. case AFE_PORT_I2S_QUAD01:
  6254. case AFE_PORT_I2S_6CHS:
  6255. case AFE_PORT_I2S_8CHS:
  6256. case AFE_PORT_I2S_10CHS:
  6257. case AFE_PORT_I2S_12CHS:
  6258. case AFE_PORT_I2S_14CHS:
  6259. case AFE_PORT_I2S_16CHS:
  6260. port_cfg->member_port_channel_mode[idx]
  6261. = AFE_PORT_I2S_SD0;
  6262. break;
  6263. case AFE_PORT_I2S_QUAD23:
  6264. port_cfg->member_port_channel_mode[idx]
  6265. = AFE_PORT_I2S_SD2;
  6266. break;
  6267. case AFE_PORT_I2S_QUAD45:
  6268. case AFE_PORT_I2S_8CHS_2:
  6269. port_cfg->member_port_channel_mode[idx]
  6270. = AFE_PORT_I2S_SD4;
  6271. break;
  6272. case AFE_PORT_I2S_QUAD67:
  6273. port_cfg->member_port_channel_mode[idx]
  6274. = AFE_PORT_I2S_SD6;
  6275. break;
  6276. }
  6277. break;
  6278. case 0:
  6279. port_cfg->member_port_channel_mode[idx] = 0;
  6280. }
  6281. if (port_cfg->member_port_channel_mode[idx] == 0) {
  6282. port_cfg->member_port_id[idx] =
  6283. AFE_PORT_ID_INVALID;
  6284. } else {
  6285. port_cfg->member_port_id[idx] =
  6286. dai_data->member_port_id[idx];
  6287. channels_left -=
  6288. msm_dai_q6_mi2s_get_num_channels(
  6289. port_cfg->member_port_channel_mode[idx]);
  6290. }
  6291. }
  6292. }
  6293. if (channels_left > 0) {
  6294. pr_err("%s: too many channels %d\n",
  6295. __func__, dai_data->channels);
  6296. return -EINVAL;
  6297. }
  6298. dai_data->rate = params_rate(params);
  6299. port_cfg->sample_rate = dai_data->rate;
  6300. switch (params_format(params)) {
  6301. case SNDRV_PCM_FORMAT_S16_LE:
  6302. case SNDRV_PCM_FORMAT_SPECIAL:
  6303. port_cfg->bit_width = 16;
  6304. dai_data->bitwidth = 16;
  6305. break;
  6306. case SNDRV_PCM_FORMAT_S24_LE:
  6307. case SNDRV_PCM_FORMAT_S24_3LE:
  6308. port_cfg->bit_width = 24;
  6309. dai_data->bitwidth = 24;
  6310. break;
  6311. default:
  6312. pr_err("%s: format %d\n",
  6313. __func__, params_format(params));
  6314. return -EINVAL;
  6315. }
  6316. port_cfg->minor_version = AFE_API_VERSION_META_I2S_CONFIG;
  6317. port_cfg->data_format = AFE_LINEAR_PCM_DATA;
  6318. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  6319. "bit_width = %hu ws_src = 0x%x sample_rate = %u\n"
  6320. "member_ports 0x%x 0x%x 0x%x 0x%x\n"
  6321. "sd_lines 0x%x 0x%x 0x%x 0x%x\n",
  6322. __func__, dai->id, dai_data->channels,
  6323. port_cfg->bit_width, port_cfg->ws_src, port_cfg->sample_rate,
  6324. port_cfg->member_port_id[0],
  6325. port_cfg->member_port_id[1],
  6326. port_cfg->member_port_id[2],
  6327. port_cfg->member_port_id[3],
  6328. port_cfg->member_port_channel_mode[0],
  6329. port_cfg->member_port_channel_mode[1],
  6330. port_cfg->member_port_channel_mode[2],
  6331. port_cfg->member_port_channel_mode[3]);
  6332. return 0;
  6333. error_invalid_data:
  6334. pr_err("%s: error when assigning member port %d channels (channels_left %d)\n",
  6335. __func__, idx, channels_left);
  6336. return -EINVAL;
  6337. }
  6338. static int msm_dai_q6_meta_mi2s_set_fmt(struct snd_soc_dai *dai,
  6339. unsigned int fmt)
  6340. {
  6341. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6342. dev_get_drvdata(dai->dev);
  6343. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6344. dev_err(dai->dev, "%s: err chg meta i2s mode while dai running",
  6345. __func__);
  6346. return -EPERM;
  6347. }
  6348. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  6349. case SND_SOC_DAIFMT_CBS_CFS:
  6350. dai_data->port_config.meta_i2s.ws_src = 1;
  6351. break;
  6352. case SND_SOC_DAIFMT_CBM_CFM:
  6353. dai_data->port_config.meta_i2s.ws_src = 0;
  6354. break;
  6355. default:
  6356. pr_err("%s: fmt %d\n",
  6357. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  6358. return -EINVAL;
  6359. }
  6360. return 0;
  6361. }
  6362. static void msm_dai_q6_meta_mi2s_shutdown(struct snd_pcm_substream *substream,
  6363. struct snd_soc_dai *dai)
  6364. {
  6365. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6366. dev_get_drvdata(dai->dev);
  6367. u16 port_id = 0;
  6368. int rc = 0;
  6369. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  6370. &port_id) != 0) {
  6371. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  6372. __func__, port_id);
  6373. }
  6374. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  6375. __func__, port_id);
  6376. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6377. rc = afe_close(port_id);
  6378. if (rc < 0)
  6379. dev_err(dai->dev, "fail to close AFE port\n");
  6380. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  6381. }
  6382. }
  6383. static struct snd_soc_dai_ops msm_dai_q6_meta_mi2s_ops = {
  6384. .startup = msm_dai_q6_meta_mi2s_startup,
  6385. .prepare = msm_dai_q6_meta_mi2s_prepare,
  6386. .hw_params = msm_dai_q6_meta_mi2s_hw_params,
  6387. .set_fmt = msm_dai_q6_meta_mi2s_set_fmt,
  6388. .shutdown = msm_dai_q6_meta_mi2s_shutdown,
  6389. };
  6390. /* Channel min and max are initialized base on platform data */
  6391. static struct snd_soc_dai_driver msm_dai_q6_meta_mi2s_dai[] = {
  6392. {
  6393. .playback = {
  6394. .stream_name = "Primary META MI2S Playback",
  6395. .aif_name = "PRI_META_MI2S_RX",
  6396. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6397. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6398. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6399. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  6400. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  6401. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  6402. SNDRV_PCM_RATE_384000,
  6403. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6404. SNDRV_PCM_FMTBIT_S24_LE |
  6405. SNDRV_PCM_FMTBIT_S24_3LE,
  6406. .rate_min = 8000,
  6407. .rate_max = 384000,
  6408. },
  6409. .ops = &msm_dai_q6_meta_mi2s_ops,
  6410. .name = "Primary META MI2S",
  6411. .id = AFE_PORT_ID_PRIMARY_META_MI2S_RX,
  6412. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6413. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6414. },
  6415. {
  6416. .playback = {
  6417. .stream_name = "Secondary META MI2S Playback",
  6418. .aif_name = "SEC_META_MI2S_RX",
  6419. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6420. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6421. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6422. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  6423. SNDRV_PCM_RATE_192000,
  6424. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  6425. .rate_min = 8000,
  6426. .rate_max = 192000,
  6427. },
  6428. .ops = &msm_dai_q6_meta_mi2s_ops,
  6429. .name = "Secondary META MI2S",
  6430. .id = AFE_PORT_ID_SECONDARY_META_MI2S_RX,
  6431. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6432. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6433. },
  6434. };
  6435. static int msm_dai_q6_meta_mi2s_platform_data_validation(
  6436. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  6437. {
  6438. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6439. dev_get_drvdata(&pdev->dev);
  6440. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  6441. (struct msm_meta_mi2s_pdata *) pdev->dev.platform_data;
  6442. int rc = 0;
  6443. int idx = 0;
  6444. u16 channel_mode = 0;
  6445. unsigned int ch_cnt = 0;
  6446. unsigned int ch_cnt_sum = 0;
  6447. struct afe_param_id_meta_i2s_cfg *port_cfg =
  6448. &dai_data->port_config.meta_i2s;
  6449. if (meta_mi2s_pdata == NULL) {
  6450. pr_err("%s: meta_mi2s_pdata NULL", __func__);
  6451. return -EINVAL;
  6452. }
  6453. dai_data->num_member_ports = meta_mi2s_pdata->num_member_ports;
  6454. for (idx = 0; idx < meta_mi2s_pdata->num_member_ports; idx++) {
  6455. rc = msm_dai_q6_mi2s_get_lineconfig(
  6456. meta_mi2s_pdata->sd_lines[idx],
  6457. &channel_mode,
  6458. &ch_cnt);
  6459. if (rc < 0) {
  6460. dev_err(&pdev->dev, "invalid META MI2S RX sd line config\n");
  6461. goto rtn;
  6462. }
  6463. if (ch_cnt) {
  6464. msm_mi2s_get_port_id(meta_mi2s_pdata->member_port[idx],
  6465. SNDRV_PCM_STREAM_PLAYBACK,
  6466. &dai_data->member_port_id[idx]);
  6467. dai_data->channel_mode[idx] = channel_mode;
  6468. port_cfg->member_port_id[idx] =
  6469. dai_data->member_port_id[idx];
  6470. port_cfg->member_port_channel_mode[idx] = channel_mode;
  6471. }
  6472. ch_cnt_sum += ch_cnt;
  6473. }
  6474. if (ch_cnt_sum) {
  6475. dai_driver->playback.channels_min = 1;
  6476. dai_driver->playback.channels_max = ch_cnt_sum << 1;
  6477. } else {
  6478. dai_driver->playback.channels_min = 0;
  6479. dai_driver->playback.channels_max = 0;
  6480. }
  6481. dev_dbg(&pdev->dev, "%s: sdline 0x%x 0x%x 0x%x 0x%x\n", __func__,
  6482. dai_data->channel_mode[0], dai_data->channel_mode[1],
  6483. dai_data->channel_mode[2], dai_data->channel_mode[3]);
  6484. dev_dbg(&pdev->dev, "%s: playback ch_max %d\n",
  6485. __func__, dai_driver->playback.channels_max);
  6486. rtn:
  6487. return rc;
  6488. }
  6489. static const struct snd_soc_component_driver msm_q6_meta_mi2s_dai_component = {
  6490. .name = "msm-dai-q6-meta-mi2s",
  6491. };
  6492. static int msm_dai_q6_meta_mi2s_dev_probe(struct platform_device *pdev)
  6493. {
  6494. struct msm_dai_q6_meta_mi2s_dai_data *dai_data;
  6495. const char *q6_meta_mi2s_dev_id = "qcom,msm-dai-q6-meta-mi2s-dev-id";
  6496. u32 dev_id = 0;
  6497. u32 meta_mi2s_intf = 0;
  6498. struct msm_meta_mi2s_pdata *meta_mi2s_pdata;
  6499. int rc;
  6500. rc = of_property_read_u32(pdev->dev.of_node, q6_meta_mi2s_dev_id,
  6501. &dev_id);
  6502. if (rc) {
  6503. dev_err(&pdev->dev,
  6504. "%s: missing %s in dt node\n", __func__,
  6505. q6_meta_mi2s_dev_id);
  6506. goto rtn;
  6507. }
  6508. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  6509. dev_id);
  6510. switch (dev_id) {
  6511. case AFE_PORT_ID_PRIMARY_META_MI2S_RX:
  6512. meta_mi2s_intf = 0;
  6513. break;
  6514. case AFE_PORT_ID_SECONDARY_META_MI2S_RX:
  6515. meta_mi2s_intf = 1;
  6516. break;
  6517. default:
  6518. dev_err(&pdev->dev,
  6519. "%s: Invalid META MI2S ID 0x%x from Device Tree\n",
  6520. __func__, dev_id);
  6521. rc = -ENXIO;
  6522. goto rtn;
  6523. }
  6524. pdev->id = dev_id;
  6525. meta_mi2s_pdata = kzalloc(sizeof(struct msm_meta_mi2s_pdata),
  6526. GFP_KERNEL);
  6527. if (!meta_mi2s_pdata) {
  6528. rc = -ENOMEM;
  6529. goto rtn;
  6530. }
  6531. rc = of_property_read_u32(pdev->dev.of_node,
  6532. "qcom,msm-mi2s-num-members",
  6533. &meta_mi2s_pdata->num_member_ports);
  6534. if (rc) {
  6535. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  6536. __func__, "qcom,msm-mi2s-num-members");
  6537. goto free_pdata;
  6538. }
  6539. if (meta_mi2s_pdata->num_member_ports >
  6540. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  6541. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  6542. __func__, meta_mi2s_pdata->num_member_ports);
  6543. goto free_pdata;
  6544. }
  6545. rc = of_property_read_u32_array(pdev->dev.of_node,
  6546. "qcom,msm-mi2s-member-id",
  6547. meta_mi2s_pdata->member_port,
  6548. meta_mi2s_pdata->num_member_ports);
  6549. if (rc) {
  6550. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  6551. __func__, "qcom,msm-mi2s-member-id");
  6552. goto free_pdata;
  6553. }
  6554. rc = of_property_read_u32_array(pdev->dev.of_node,
  6555. "qcom,msm-mi2s-rx-lines",
  6556. meta_mi2s_pdata->sd_lines,
  6557. meta_mi2s_pdata->num_member_ports);
  6558. if (rc) {
  6559. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n",
  6560. __func__, "qcom,msm-mi2s-rx-lines");
  6561. goto free_pdata;
  6562. }
  6563. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  6564. dev_name(&pdev->dev), meta_mi2s_pdata->num_member_ports);
  6565. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  6566. meta_mi2s_pdata->member_port[0],
  6567. meta_mi2s_pdata->member_port[1],
  6568. meta_mi2s_pdata->member_port[2],
  6569. meta_mi2s_pdata->member_port[3]);
  6570. dev_dbg(&pdev->dev, "sd-lines array (0x%x, 0x%x, 0x%x, 0x%x)\n",
  6571. meta_mi2s_pdata->sd_lines[0],
  6572. meta_mi2s_pdata->sd_lines[1],
  6573. meta_mi2s_pdata->sd_lines[2],
  6574. meta_mi2s_pdata->sd_lines[3]);
  6575. meta_mi2s_pdata->intf_id = meta_mi2s_intf;
  6576. dai_data = kzalloc(sizeof(struct msm_dai_q6_meta_mi2s_dai_data),
  6577. GFP_KERNEL);
  6578. if (!dai_data) {
  6579. rc = -ENOMEM;
  6580. goto free_pdata;
  6581. } else
  6582. dev_set_drvdata(&pdev->dev, dai_data);
  6583. pdev->dev.platform_data = meta_mi2s_pdata;
  6584. rc = msm_dai_q6_meta_mi2s_platform_data_validation(pdev,
  6585. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf]);
  6586. if (rc < 0)
  6587. goto free_dai_data;
  6588. rc = snd_soc_register_component(&pdev->dev,
  6589. &msm_q6_meta_mi2s_dai_component,
  6590. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf], 1);
  6591. if (rc < 0)
  6592. goto err_register;
  6593. return 0;
  6594. err_register:
  6595. dev_err(&pdev->dev, "fail to %s\n", __func__);
  6596. free_dai_data:
  6597. kfree(dai_data);
  6598. free_pdata:
  6599. kfree(meta_mi2s_pdata);
  6600. rtn:
  6601. return rc;
  6602. }
  6603. static int msm_dai_q6_meta_mi2s_dev_remove(struct platform_device *pdev)
  6604. {
  6605. snd_soc_unregister_component(&pdev->dev);
  6606. return 0;
  6607. }
  6608. static const struct snd_soc_component_driver msm_dai_q6_component = {
  6609. .name = "msm-dai-q6-dev",
  6610. };
  6611. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  6612. {
  6613. int rc, id, i, len;
  6614. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6615. char stream_name[80];
  6616. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6617. if (rc) {
  6618. dev_err(&pdev->dev,
  6619. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6620. return rc;
  6621. }
  6622. pdev->id = id;
  6623. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6624. dev_name(&pdev->dev), pdev->id);
  6625. switch (id) {
  6626. case SLIMBUS_0_RX:
  6627. strlcpy(stream_name, "Slimbus Playback", 80);
  6628. goto register_slim_playback;
  6629. case SLIMBUS_2_RX:
  6630. strlcpy(stream_name, "Slimbus2 Playback", 80);
  6631. goto register_slim_playback;
  6632. case SLIMBUS_1_RX:
  6633. strlcpy(stream_name, "Slimbus1 Playback", 80);
  6634. goto register_slim_playback;
  6635. case SLIMBUS_3_RX:
  6636. strlcpy(stream_name, "Slimbus3 Playback", 80);
  6637. goto register_slim_playback;
  6638. case SLIMBUS_4_RX:
  6639. strlcpy(stream_name, "Slimbus4 Playback", 80);
  6640. goto register_slim_playback;
  6641. case SLIMBUS_5_RX:
  6642. strlcpy(stream_name, "Slimbus5 Playback", 80);
  6643. goto register_slim_playback;
  6644. case SLIMBUS_6_RX:
  6645. strlcpy(stream_name, "Slimbus6 Playback", 80);
  6646. goto register_slim_playback;
  6647. case SLIMBUS_7_RX:
  6648. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  6649. goto register_slim_playback;
  6650. case SLIMBUS_8_RX:
  6651. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  6652. goto register_slim_playback;
  6653. case SLIMBUS_9_RX:
  6654. strlcpy(stream_name, "Slimbus9 Playback", sizeof(stream_name));
  6655. goto register_slim_playback;
  6656. register_slim_playback:
  6657. rc = -ENODEV;
  6658. len = strnlen(stream_name, 80);
  6659. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  6660. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  6661. !strcmp(stream_name,
  6662. msm_dai_q6_slimbus_rx_dai[i]
  6663. .playback.stream_name)) {
  6664. rc = snd_soc_register_component(&pdev->dev,
  6665. &msm_dai_q6_component,
  6666. &msm_dai_q6_slimbus_rx_dai[i], 1);
  6667. break;
  6668. }
  6669. }
  6670. if (rc)
  6671. pr_err("%s: Device not found stream name %s\n",
  6672. __func__, stream_name);
  6673. break;
  6674. case SLIMBUS_0_TX:
  6675. strlcpy(stream_name, "Slimbus Capture", 80);
  6676. goto register_slim_capture;
  6677. case SLIMBUS_1_TX:
  6678. strlcpy(stream_name, "Slimbus1 Capture", 80);
  6679. goto register_slim_capture;
  6680. case SLIMBUS_2_TX:
  6681. strlcpy(stream_name, "Slimbus2 Capture", 80);
  6682. goto register_slim_capture;
  6683. case SLIMBUS_3_TX:
  6684. strlcpy(stream_name, "Slimbus3 Capture", 80);
  6685. goto register_slim_capture;
  6686. case SLIMBUS_4_TX:
  6687. strlcpy(stream_name, "Slimbus4 Capture", 80);
  6688. goto register_slim_capture;
  6689. case SLIMBUS_5_TX:
  6690. strlcpy(stream_name, "Slimbus5 Capture", 80);
  6691. goto register_slim_capture;
  6692. case SLIMBUS_6_TX:
  6693. strlcpy(stream_name, "Slimbus6 Capture", 80);
  6694. goto register_slim_capture;
  6695. case SLIMBUS_7_TX:
  6696. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  6697. goto register_slim_capture;
  6698. case SLIMBUS_8_TX:
  6699. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  6700. goto register_slim_capture;
  6701. case SLIMBUS_9_TX:
  6702. strlcpy(stream_name, "Slimbus9 Capture", sizeof(stream_name));
  6703. goto register_slim_capture;
  6704. register_slim_capture:
  6705. rc = -ENODEV;
  6706. len = strnlen(stream_name, 80);
  6707. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  6708. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  6709. !strcmp(stream_name,
  6710. msm_dai_q6_slimbus_tx_dai[i]
  6711. .capture.stream_name)) {
  6712. rc = snd_soc_register_component(&pdev->dev,
  6713. &msm_dai_q6_component,
  6714. &msm_dai_q6_slimbus_tx_dai[i], 1);
  6715. break;
  6716. }
  6717. }
  6718. if (rc)
  6719. pr_err("%s: Device not found stream name %s\n",
  6720. __func__, stream_name);
  6721. break;
  6722. case AFE_LOOPBACK_TX:
  6723. rc = snd_soc_register_component(&pdev->dev,
  6724. &msm_dai_q6_component,
  6725. &msm_dai_q6_afe_lb_tx_dai[0],
  6726. 1);
  6727. break;
  6728. case INT_BT_SCO_RX:
  6729. rc = snd_soc_register_component(&pdev->dev,
  6730. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  6731. break;
  6732. case INT_BT_SCO_TX:
  6733. rc = snd_soc_register_component(&pdev->dev,
  6734. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  6735. break;
  6736. case INT_BT_A2DP_RX:
  6737. rc = snd_soc_register_component(&pdev->dev,
  6738. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  6739. break;
  6740. case INT_FM_RX:
  6741. rc = snd_soc_register_component(&pdev->dev,
  6742. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  6743. break;
  6744. case INT_FM_TX:
  6745. rc = snd_soc_register_component(&pdev->dev,
  6746. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  6747. break;
  6748. case AFE_PORT_ID_USB_RX:
  6749. rc = snd_soc_register_component(&pdev->dev,
  6750. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  6751. break;
  6752. case AFE_PORT_ID_USB_TX:
  6753. rc = snd_soc_register_component(&pdev->dev,
  6754. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  6755. break;
  6756. case RT_PROXY_DAI_001_RX:
  6757. strlcpy(stream_name, "AFE Playback", 80);
  6758. goto register_afe_playback;
  6759. case RT_PROXY_DAI_002_RX:
  6760. strlcpy(stream_name, "AFE-PROXY RX", 80);
  6761. register_afe_playback:
  6762. rc = -ENODEV;
  6763. len = strnlen(stream_name, 80);
  6764. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  6765. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  6766. !strcmp(stream_name,
  6767. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  6768. rc = snd_soc_register_component(&pdev->dev,
  6769. &msm_dai_q6_component,
  6770. &msm_dai_q6_afe_rx_dai[i], 1);
  6771. break;
  6772. }
  6773. }
  6774. if (rc)
  6775. pr_err("%s: Device not found stream name %s\n",
  6776. __func__, stream_name);
  6777. break;
  6778. case RT_PROXY_DAI_001_TX:
  6779. strlcpy(stream_name, "AFE-PROXY TX", 80);
  6780. goto register_afe_capture;
  6781. case RT_PROXY_DAI_002_TX:
  6782. strlcpy(stream_name, "AFE Capture", 80);
  6783. register_afe_capture:
  6784. rc = -ENODEV;
  6785. len = strnlen(stream_name, 80);
  6786. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  6787. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  6788. !strcmp(stream_name,
  6789. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  6790. rc = snd_soc_register_component(&pdev->dev,
  6791. &msm_dai_q6_component,
  6792. &msm_dai_q6_afe_tx_dai[i], 1);
  6793. break;
  6794. }
  6795. }
  6796. if (rc)
  6797. pr_err("%s: Device not found stream name %s\n",
  6798. __func__, stream_name);
  6799. break;
  6800. case RT_PROXY_DAI_003_TX:
  6801. rc = snd_soc_register_component(&pdev->dev,
  6802. &msm_dai_q6_component, &msm_dai_q6_afe_cap_dai, 1);
  6803. break;
  6804. case VOICE_PLAYBACK_TX:
  6805. strlcpy(stream_name, "Voice Farend Playback", 80);
  6806. goto register_voice_playback;
  6807. case VOICE2_PLAYBACK_TX:
  6808. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  6809. register_voice_playback:
  6810. rc = -ENODEV;
  6811. len = strnlen(stream_name, 80);
  6812. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  6813. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  6814. && !strcmp(stream_name,
  6815. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  6816. rc = snd_soc_register_component(&pdev->dev,
  6817. &msm_dai_q6_component,
  6818. &msm_dai_q6_voc_playback_dai[i], 1);
  6819. break;
  6820. }
  6821. }
  6822. if (rc)
  6823. pr_err("%s Device not found stream name %s\n",
  6824. __func__, stream_name);
  6825. break;
  6826. case VOICE_RECORD_RX:
  6827. strlcpy(stream_name, "Voice Downlink Capture", 80);
  6828. goto register_uplink_capture;
  6829. case VOICE_RECORD_TX:
  6830. strlcpy(stream_name, "Voice Uplink Capture", 80);
  6831. register_uplink_capture:
  6832. rc = -ENODEV;
  6833. len = strnlen(stream_name, 80);
  6834. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  6835. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  6836. && !strcmp(stream_name,
  6837. msm_dai_q6_incall_record_dai[i].
  6838. capture.stream_name)) {
  6839. rc = snd_soc_register_component(&pdev->dev,
  6840. &msm_dai_q6_component,
  6841. &msm_dai_q6_incall_record_dai[i], 1);
  6842. break;
  6843. }
  6844. }
  6845. if (rc)
  6846. pr_err("%s: Device not found stream name %s\n",
  6847. __func__, stream_name);
  6848. break;
  6849. case RT_PROXY_PORT_002_RX:
  6850. rc = snd_soc_register_component(&pdev->dev,
  6851. &msm_dai_q6_component, &msm_dai_q6_proxy_rx_dai, 1);
  6852. break;
  6853. case RT_PROXY_PORT_002_TX:
  6854. rc = snd_soc_register_component(&pdev->dev,
  6855. &msm_dai_q6_component, &msm_dai_q6_proxy_tx_dai, 1);
  6856. break;
  6857. default:
  6858. rc = -ENODEV;
  6859. break;
  6860. }
  6861. return rc;
  6862. }
  6863. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  6864. {
  6865. snd_soc_unregister_component(&pdev->dev);
  6866. return 0;
  6867. }
  6868. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  6869. { .compatible = "qcom,msm-dai-q6-dev", },
  6870. { }
  6871. };
  6872. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  6873. static struct platform_driver msm_dai_q6_dev = {
  6874. .probe = msm_dai_q6_dev_probe,
  6875. .remove = msm_dai_q6_dev_remove,
  6876. .driver = {
  6877. .name = "msm-dai-q6-dev",
  6878. .owner = THIS_MODULE,
  6879. .of_match_table = msm_dai_q6_dev_dt_match,
  6880. .suppress_bind_attrs = true,
  6881. },
  6882. };
  6883. static int msm_dai_q6_probe(struct platform_device *pdev)
  6884. {
  6885. int rc;
  6886. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6887. dev_name(&pdev->dev), pdev->id);
  6888. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6889. if (rc) {
  6890. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6891. __func__, rc);
  6892. } else
  6893. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6894. return rc;
  6895. }
  6896. static int msm_dai_q6_remove(struct platform_device *pdev)
  6897. {
  6898. of_platform_depopulate(&pdev->dev);
  6899. return 0;
  6900. }
  6901. static const struct of_device_id msm_dai_q6_dt_match[] = {
  6902. { .compatible = "qcom,msm-dai-q6", },
  6903. { }
  6904. };
  6905. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  6906. static struct platform_driver msm_dai_q6 = {
  6907. .probe = msm_dai_q6_probe,
  6908. .remove = msm_dai_q6_remove,
  6909. .driver = {
  6910. .name = "msm-dai-q6",
  6911. .owner = THIS_MODULE,
  6912. .of_match_table = msm_dai_q6_dt_match,
  6913. .suppress_bind_attrs = true,
  6914. },
  6915. };
  6916. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  6917. {
  6918. int rc;
  6919. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6920. if (rc) {
  6921. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6922. __func__, rc);
  6923. } else
  6924. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6925. return rc;
  6926. }
  6927. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  6928. {
  6929. return 0;
  6930. }
  6931. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  6932. { .compatible = "qcom,msm-dai-mi2s", },
  6933. { }
  6934. };
  6935. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  6936. static struct platform_driver msm_dai_mi2s_q6 = {
  6937. .probe = msm_dai_mi2s_q6_probe,
  6938. .remove = msm_dai_mi2s_q6_remove,
  6939. .driver = {
  6940. .name = "msm-dai-mi2s",
  6941. .owner = THIS_MODULE,
  6942. .of_match_table = msm_dai_mi2s_dt_match,
  6943. .suppress_bind_attrs = true,
  6944. },
  6945. };
  6946. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  6947. { .compatible = "qcom,msm-dai-q6-mi2s", },
  6948. { }
  6949. };
  6950. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  6951. static struct platform_driver msm_dai_q6_mi2s_driver = {
  6952. .probe = msm_dai_q6_mi2s_dev_probe,
  6953. .remove = msm_dai_q6_mi2s_dev_remove,
  6954. .driver = {
  6955. .name = "msm-dai-q6-mi2s",
  6956. .owner = THIS_MODULE,
  6957. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  6958. .suppress_bind_attrs = true,
  6959. },
  6960. };
  6961. static const struct of_device_id msm_dai_q6_meta_mi2s_dev_dt_match[] = {
  6962. { .compatible = "qcom,msm-dai-q6-meta-mi2s", },
  6963. { }
  6964. };
  6965. MODULE_DEVICE_TABLE(of, msm_dai_q6_meta_mi2s_dev_dt_match);
  6966. static struct platform_driver msm_dai_q6_meta_mi2s_driver = {
  6967. .probe = msm_dai_q6_meta_mi2s_dev_probe,
  6968. .remove = msm_dai_q6_meta_mi2s_dev_remove,
  6969. .driver = {
  6970. .name = "msm-dai-q6-meta-mi2s",
  6971. .owner = THIS_MODULE,
  6972. .of_match_table = msm_dai_q6_meta_mi2s_dev_dt_match,
  6973. .suppress_bind_attrs = true,
  6974. },
  6975. };
  6976. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  6977. {
  6978. int rc, id;
  6979. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6980. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6981. if (rc) {
  6982. dev_err(&pdev->dev,
  6983. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6984. return rc;
  6985. }
  6986. pdev->id = id;
  6987. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6988. dev_name(&pdev->dev), pdev->id);
  6989. switch (pdev->id) {
  6990. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  6991. rc = snd_soc_register_component(&pdev->dev,
  6992. &msm_dai_spdif_q6_component,
  6993. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  6994. break;
  6995. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  6996. rc = snd_soc_register_component(&pdev->dev,
  6997. &msm_dai_spdif_q6_component,
  6998. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  6999. break;
  7000. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  7001. rc = snd_soc_register_component(&pdev->dev,
  7002. &msm_dai_spdif_q6_component,
  7003. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  7004. break;
  7005. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  7006. rc = snd_soc_register_component(&pdev->dev,
  7007. &msm_dai_spdif_q6_component,
  7008. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  7009. break;
  7010. default:
  7011. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  7012. rc = -ENODEV;
  7013. break;
  7014. }
  7015. return rc;
  7016. }
  7017. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  7018. {
  7019. snd_soc_unregister_component(&pdev->dev);
  7020. return 0;
  7021. }
  7022. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  7023. {.compatible = "qcom,msm-dai-q6-spdif"},
  7024. {}
  7025. };
  7026. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  7027. static struct platform_driver msm_dai_q6_spdif_driver = {
  7028. .probe = msm_dai_q6_spdif_dev_probe,
  7029. .remove = msm_dai_q6_spdif_dev_remove,
  7030. .driver = {
  7031. .name = "msm-dai-q6-spdif",
  7032. .owner = THIS_MODULE,
  7033. .of_match_table = msm_dai_q6_spdif_dt_match,
  7034. .suppress_bind_attrs = true,
  7035. },
  7036. };
  7037. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  7038. struct afe_clk_set *clk_set, u32 mode)
  7039. {
  7040. switch (group_id) {
  7041. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  7042. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  7043. if (mode)
  7044. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  7045. else
  7046. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  7047. break;
  7048. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  7049. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  7050. if (mode)
  7051. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  7052. else
  7053. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  7054. break;
  7055. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  7056. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  7057. if (mode)
  7058. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  7059. else
  7060. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  7061. break;
  7062. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  7063. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  7064. if (mode)
  7065. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  7066. else
  7067. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  7068. break;
  7069. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  7070. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  7071. if (mode)
  7072. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  7073. else
  7074. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  7075. break;
  7076. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  7077. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  7078. if (mode)
  7079. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_IBIT;
  7080. else
  7081. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_EBIT;
  7082. break;
  7083. default:
  7084. return -EINVAL;
  7085. }
  7086. return 0;
  7087. }
  7088. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  7089. {
  7090. int rc = 0;
  7091. const uint32_t *port_id_array = NULL;
  7092. uint32_t array_length = 0;
  7093. int i = 0;
  7094. int group_idx = 0;
  7095. u32 clk_mode = 0;
  7096. /* extract tdm group info into static */
  7097. rc = of_property_read_u32(pdev->dev.of_node,
  7098. "qcom,msm-cpudai-tdm-group-id",
  7099. (u32 *)&tdm_group_cfg.group_id);
  7100. if (rc) {
  7101. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  7102. __func__, "qcom,msm-cpudai-tdm-group-id");
  7103. goto rtn;
  7104. }
  7105. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  7106. __func__, tdm_group_cfg.group_id);
  7107. rc = of_property_read_u32(pdev->dev.of_node,
  7108. "qcom,msm-cpudai-tdm-group-num-ports",
  7109. &num_tdm_group_ports);
  7110. if (rc) {
  7111. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  7112. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  7113. goto rtn;
  7114. }
  7115. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  7116. __func__, num_tdm_group_ports);
  7117. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  7118. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  7119. __func__, num_tdm_group_ports,
  7120. AFE_GROUP_DEVICE_NUM_PORTS);
  7121. rc = -EINVAL;
  7122. goto rtn;
  7123. }
  7124. port_id_array = of_get_property(pdev->dev.of_node,
  7125. "qcom,msm-cpudai-tdm-group-port-id",
  7126. &array_length);
  7127. if (port_id_array == NULL) {
  7128. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  7129. __func__);
  7130. rc = -EINVAL;
  7131. goto rtn;
  7132. }
  7133. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  7134. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  7135. __func__, array_length,
  7136. sizeof(uint32_t) * num_tdm_group_ports);
  7137. rc = -EINVAL;
  7138. goto rtn;
  7139. }
  7140. for (i = 0; i < num_tdm_group_ports; i++)
  7141. tdm_group_cfg.port_id[i] =
  7142. (u16)be32_to_cpu(port_id_array[i]);
  7143. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  7144. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  7145. tdm_group_cfg.port_id[i] =
  7146. AFE_PORT_INVALID;
  7147. /* extract tdm clk info into static */
  7148. rc = of_property_read_u32(pdev->dev.of_node,
  7149. "qcom,msm-cpudai-tdm-clk-rate",
  7150. &tdm_clk_set.clk_freq_in_hz);
  7151. if (rc) {
  7152. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  7153. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  7154. goto rtn;
  7155. }
  7156. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  7157. __func__, tdm_clk_set.clk_freq_in_hz);
  7158. /* initialize static tdm clk attribute to default value */
  7159. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  7160. /* extract tdm clk attribute into static */
  7161. if (of_find_property(pdev->dev.of_node,
  7162. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  7163. rc = of_property_read_u16(pdev->dev.of_node,
  7164. "qcom,msm-cpudai-tdm-clk-attribute",
  7165. &tdm_clk_set.clk_attri);
  7166. if (rc) {
  7167. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  7168. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  7169. goto rtn;
  7170. }
  7171. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  7172. __func__, tdm_clk_set.clk_attri);
  7173. } else
  7174. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  7175. /* extract tdm lane cfg to static */
  7176. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  7177. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  7178. if (of_find_property(pdev->dev.of_node,
  7179. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  7180. rc = of_property_read_u16(pdev->dev.of_node,
  7181. "qcom,msm-cpudai-tdm-lane-mask",
  7182. &tdm_lane_cfg.lane_mask);
  7183. if (rc) {
  7184. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  7185. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  7186. goto rtn;
  7187. }
  7188. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  7189. __func__, tdm_lane_cfg.lane_mask);
  7190. } else
  7191. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  7192. /* extract tdm clk src master/slave info into static */
  7193. rc = of_property_read_u32(pdev->dev.of_node,
  7194. "qcom,msm-cpudai-tdm-clk-internal",
  7195. &clk_mode);
  7196. if (rc) {
  7197. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  7198. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  7199. goto rtn;
  7200. }
  7201. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  7202. __func__, clk_mode);
  7203. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  7204. &tdm_clk_set, clk_mode);
  7205. if (rc) {
  7206. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  7207. __func__, tdm_group_cfg.group_id);
  7208. goto rtn;
  7209. }
  7210. /* other initializations within device group */
  7211. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  7212. if (group_idx < 0) {
  7213. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  7214. __func__, tdm_group_cfg.group_id);
  7215. rc = -EINVAL;
  7216. goto rtn;
  7217. }
  7218. atomic_set(&tdm_group_ref[group_idx], 0);
  7219. /* probe child node info */
  7220. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  7221. if (rc) {
  7222. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  7223. __func__, rc);
  7224. goto rtn;
  7225. } else
  7226. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  7227. rtn:
  7228. return rc;
  7229. }
  7230. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  7231. {
  7232. return 0;
  7233. }
  7234. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  7235. { .compatible = "qcom,msm-dai-tdm", },
  7236. {}
  7237. };
  7238. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  7239. static struct platform_driver msm_dai_tdm_q6 = {
  7240. .probe = msm_dai_tdm_q6_probe,
  7241. .remove = msm_dai_tdm_q6_remove,
  7242. .driver = {
  7243. .name = "msm-dai-tdm",
  7244. .owner = THIS_MODULE,
  7245. .of_match_table = msm_dai_tdm_dt_match,
  7246. .suppress_bind_attrs = true,
  7247. },
  7248. };
  7249. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  7250. struct snd_ctl_elem_value *ucontrol)
  7251. {
  7252. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7253. int value = ucontrol->value.integer.value[0];
  7254. switch (value) {
  7255. case 0:
  7256. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  7257. break;
  7258. case 1:
  7259. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  7260. break;
  7261. case 2:
  7262. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  7263. break;
  7264. default:
  7265. pr_err("%s: data_format invalid\n", __func__);
  7266. break;
  7267. }
  7268. pr_debug("%s: data_format = %d\n",
  7269. __func__, dai_data->port_cfg.tdm.data_format);
  7270. return 0;
  7271. }
  7272. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  7273. struct snd_ctl_elem_value *ucontrol)
  7274. {
  7275. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7276. ucontrol->value.integer.value[0] =
  7277. dai_data->port_cfg.tdm.data_format;
  7278. pr_debug("%s: data_format = %d\n",
  7279. __func__, dai_data->port_cfg.tdm.data_format);
  7280. return 0;
  7281. }
  7282. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  7283. struct snd_ctl_elem_value *ucontrol)
  7284. {
  7285. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7286. int value = ucontrol->value.integer.value[0];
  7287. dai_data->port_cfg.custom_tdm_header.header_type = value;
  7288. pr_debug("%s: header_type = %d\n",
  7289. __func__,
  7290. dai_data->port_cfg.custom_tdm_header.header_type);
  7291. return 0;
  7292. }
  7293. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  7294. struct snd_ctl_elem_value *ucontrol)
  7295. {
  7296. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7297. ucontrol->value.integer.value[0] =
  7298. dai_data->port_cfg.custom_tdm_header.header_type;
  7299. pr_debug("%s: header_type = %d\n",
  7300. __func__,
  7301. dai_data->port_cfg.custom_tdm_header.header_type);
  7302. return 0;
  7303. }
  7304. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  7305. struct snd_ctl_elem_value *ucontrol)
  7306. {
  7307. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7308. int i = 0;
  7309. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7310. dai_data->port_cfg.custom_tdm_header.header[i] =
  7311. (u16)ucontrol->value.integer.value[i];
  7312. pr_debug("%s: header #%d = 0x%x\n",
  7313. __func__, i,
  7314. dai_data->port_cfg.custom_tdm_header.header[i]);
  7315. }
  7316. return 0;
  7317. }
  7318. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  7319. struct snd_ctl_elem_value *ucontrol)
  7320. {
  7321. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7322. int i = 0;
  7323. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7324. ucontrol->value.integer.value[i] =
  7325. dai_data->port_cfg.custom_tdm_header.header[i];
  7326. pr_debug("%s: header #%d = 0x%x\n",
  7327. __func__, i,
  7328. dai_data->port_cfg.custom_tdm_header.header[i]);
  7329. }
  7330. return 0;
  7331. }
  7332. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  7333. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  7334. msm_dai_q6_tdm_data_format_get,
  7335. msm_dai_q6_tdm_data_format_put),
  7336. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  7337. msm_dai_q6_tdm_data_format_get,
  7338. msm_dai_q6_tdm_data_format_put),
  7339. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  7340. msm_dai_q6_tdm_data_format_get,
  7341. msm_dai_q6_tdm_data_format_put),
  7342. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  7343. msm_dai_q6_tdm_data_format_get,
  7344. msm_dai_q6_tdm_data_format_put),
  7345. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  7346. msm_dai_q6_tdm_data_format_get,
  7347. msm_dai_q6_tdm_data_format_put),
  7348. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  7349. msm_dai_q6_tdm_data_format_get,
  7350. msm_dai_q6_tdm_data_format_put),
  7351. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  7352. msm_dai_q6_tdm_data_format_get,
  7353. msm_dai_q6_tdm_data_format_put),
  7354. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  7355. msm_dai_q6_tdm_data_format_get,
  7356. msm_dai_q6_tdm_data_format_put),
  7357. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  7358. msm_dai_q6_tdm_data_format_get,
  7359. msm_dai_q6_tdm_data_format_put),
  7360. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  7361. msm_dai_q6_tdm_data_format_get,
  7362. msm_dai_q6_tdm_data_format_put),
  7363. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  7364. msm_dai_q6_tdm_data_format_get,
  7365. msm_dai_q6_tdm_data_format_put),
  7366. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  7367. msm_dai_q6_tdm_data_format_get,
  7368. msm_dai_q6_tdm_data_format_put),
  7369. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  7370. msm_dai_q6_tdm_data_format_get,
  7371. msm_dai_q6_tdm_data_format_put),
  7372. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  7373. msm_dai_q6_tdm_data_format_get,
  7374. msm_dai_q6_tdm_data_format_put),
  7375. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  7376. msm_dai_q6_tdm_data_format_get,
  7377. msm_dai_q6_tdm_data_format_put),
  7378. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  7379. msm_dai_q6_tdm_data_format_get,
  7380. msm_dai_q6_tdm_data_format_put),
  7381. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  7382. msm_dai_q6_tdm_data_format_get,
  7383. msm_dai_q6_tdm_data_format_put),
  7384. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  7385. msm_dai_q6_tdm_data_format_get,
  7386. msm_dai_q6_tdm_data_format_put),
  7387. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  7388. msm_dai_q6_tdm_data_format_get,
  7389. msm_dai_q6_tdm_data_format_put),
  7390. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  7391. msm_dai_q6_tdm_data_format_get,
  7392. msm_dai_q6_tdm_data_format_put),
  7393. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  7394. msm_dai_q6_tdm_data_format_get,
  7395. msm_dai_q6_tdm_data_format_put),
  7396. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  7397. msm_dai_q6_tdm_data_format_get,
  7398. msm_dai_q6_tdm_data_format_put),
  7399. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  7400. msm_dai_q6_tdm_data_format_get,
  7401. msm_dai_q6_tdm_data_format_put),
  7402. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  7403. msm_dai_q6_tdm_data_format_get,
  7404. msm_dai_q6_tdm_data_format_put),
  7405. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  7406. msm_dai_q6_tdm_data_format_get,
  7407. msm_dai_q6_tdm_data_format_put),
  7408. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  7409. msm_dai_q6_tdm_data_format_get,
  7410. msm_dai_q6_tdm_data_format_put),
  7411. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  7412. msm_dai_q6_tdm_data_format_get,
  7413. msm_dai_q6_tdm_data_format_put),
  7414. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  7415. msm_dai_q6_tdm_data_format_get,
  7416. msm_dai_q6_tdm_data_format_put),
  7417. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  7418. msm_dai_q6_tdm_data_format_get,
  7419. msm_dai_q6_tdm_data_format_put),
  7420. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  7421. msm_dai_q6_tdm_data_format_get,
  7422. msm_dai_q6_tdm_data_format_put),
  7423. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  7424. msm_dai_q6_tdm_data_format_get,
  7425. msm_dai_q6_tdm_data_format_put),
  7426. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  7427. msm_dai_q6_tdm_data_format_get,
  7428. msm_dai_q6_tdm_data_format_put),
  7429. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  7430. msm_dai_q6_tdm_data_format_get,
  7431. msm_dai_q6_tdm_data_format_put),
  7432. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  7433. msm_dai_q6_tdm_data_format_get,
  7434. msm_dai_q6_tdm_data_format_put),
  7435. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  7436. msm_dai_q6_tdm_data_format_get,
  7437. msm_dai_q6_tdm_data_format_put),
  7438. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  7439. msm_dai_q6_tdm_data_format_get,
  7440. msm_dai_q6_tdm_data_format_put),
  7441. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  7442. msm_dai_q6_tdm_data_format_get,
  7443. msm_dai_q6_tdm_data_format_put),
  7444. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  7445. msm_dai_q6_tdm_data_format_get,
  7446. msm_dai_q6_tdm_data_format_put),
  7447. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  7448. msm_dai_q6_tdm_data_format_get,
  7449. msm_dai_q6_tdm_data_format_put),
  7450. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  7451. msm_dai_q6_tdm_data_format_get,
  7452. msm_dai_q6_tdm_data_format_put),
  7453. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  7454. msm_dai_q6_tdm_data_format_get,
  7455. msm_dai_q6_tdm_data_format_put),
  7456. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  7457. msm_dai_q6_tdm_data_format_get,
  7458. msm_dai_q6_tdm_data_format_put),
  7459. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  7460. msm_dai_q6_tdm_data_format_get,
  7461. msm_dai_q6_tdm_data_format_put),
  7462. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  7463. msm_dai_q6_tdm_data_format_get,
  7464. msm_dai_q6_tdm_data_format_put),
  7465. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  7466. msm_dai_q6_tdm_data_format_get,
  7467. msm_dai_q6_tdm_data_format_put),
  7468. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  7469. msm_dai_q6_tdm_data_format_get,
  7470. msm_dai_q6_tdm_data_format_put),
  7471. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  7472. msm_dai_q6_tdm_data_format_get,
  7473. msm_dai_q6_tdm_data_format_put),
  7474. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  7475. msm_dai_q6_tdm_data_format_get,
  7476. msm_dai_q6_tdm_data_format_put),
  7477. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  7478. msm_dai_q6_tdm_data_format_get,
  7479. msm_dai_q6_tdm_data_format_put),
  7480. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  7481. msm_dai_q6_tdm_data_format_get,
  7482. msm_dai_q6_tdm_data_format_put),
  7483. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  7484. msm_dai_q6_tdm_data_format_get,
  7485. msm_dai_q6_tdm_data_format_put),
  7486. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  7487. msm_dai_q6_tdm_data_format_get,
  7488. msm_dai_q6_tdm_data_format_put),
  7489. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  7490. msm_dai_q6_tdm_data_format_get,
  7491. msm_dai_q6_tdm_data_format_put),
  7492. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  7493. msm_dai_q6_tdm_data_format_get,
  7494. msm_dai_q6_tdm_data_format_put),
  7495. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  7496. msm_dai_q6_tdm_data_format_get,
  7497. msm_dai_q6_tdm_data_format_put),
  7498. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  7499. msm_dai_q6_tdm_data_format_get,
  7500. msm_dai_q6_tdm_data_format_put),
  7501. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  7502. msm_dai_q6_tdm_data_format_get,
  7503. msm_dai_q6_tdm_data_format_put),
  7504. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  7505. msm_dai_q6_tdm_data_format_get,
  7506. msm_dai_q6_tdm_data_format_put),
  7507. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  7508. msm_dai_q6_tdm_data_format_get,
  7509. msm_dai_q6_tdm_data_format_put),
  7510. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  7511. msm_dai_q6_tdm_data_format_get,
  7512. msm_dai_q6_tdm_data_format_put),
  7513. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  7514. msm_dai_q6_tdm_data_format_get,
  7515. msm_dai_q6_tdm_data_format_put),
  7516. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  7517. msm_dai_q6_tdm_data_format_get,
  7518. msm_dai_q6_tdm_data_format_put),
  7519. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  7520. msm_dai_q6_tdm_data_format_get,
  7521. msm_dai_q6_tdm_data_format_put),
  7522. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  7523. msm_dai_q6_tdm_data_format_get,
  7524. msm_dai_q6_tdm_data_format_put),
  7525. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  7526. msm_dai_q6_tdm_data_format_get,
  7527. msm_dai_q6_tdm_data_format_put),
  7528. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  7529. msm_dai_q6_tdm_data_format_get,
  7530. msm_dai_q6_tdm_data_format_put),
  7531. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  7532. msm_dai_q6_tdm_data_format_get,
  7533. msm_dai_q6_tdm_data_format_put),
  7534. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  7535. msm_dai_q6_tdm_data_format_get,
  7536. msm_dai_q6_tdm_data_format_put),
  7537. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  7538. msm_dai_q6_tdm_data_format_get,
  7539. msm_dai_q6_tdm_data_format_put),
  7540. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  7541. msm_dai_q6_tdm_data_format_get,
  7542. msm_dai_q6_tdm_data_format_put),
  7543. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  7544. msm_dai_q6_tdm_data_format_get,
  7545. msm_dai_q6_tdm_data_format_put),
  7546. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  7547. msm_dai_q6_tdm_data_format_get,
  7548. msm_dai_q6_tdm_data_format_put),
  7549. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  7550. msm_dai_q6_tdm_data_format_get,
  7551. msm_dai_q6_tdm_data_format_put),
  7552. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  7553. msm_dai_q6_tdm_data_format_get,
  7554. msm_dai_q6_tdm_data_format_put),
  7555. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  7556. msm_dai_q6_tdm_data_format_get,
  7557. msm_dai_q6_tdm_data_format_put),
  7558. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  7559. msm_dai_q6_tdm_data_format_get,
  7560. msm_dai_q6_tdm_data_format_put),
  7561. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  7562. msm_dai_q6_tdm_data_format_get,
  7563. msm_dai_q6_tdm_data_format_put),
  7564. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7565. msm_dai_q6_tdm_data_format_get,
  7566. msm_dai_q6_tdm_data_format_put),
  7567. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7568. msm_dai_q6_tdm_data_format_get,
  7569. msm_dai_q6_tdm_data_format_put),
  7570. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7571. msm_dai_q6_tdm_data_format_get,
  7572. msm_dai_q6_tdm_data_format_put),
  7573. SOC_ENUM_EXT("SEN_TDM_RX_0 Data Format", tdm_config_enum[0],
  7574. msm_dai_q6_tdm_data_format_get,
  7575. msm_dai_q6_tdm_data_format_put),
  7576. SOC_ENUM_EXT("SEN_TDM_RX_1 Data Format", tdm_config_enum[0],
  7577. msm_dai_q6_tdm_data_format_get,
  7578. msm_dai_q6_tdm_data_format_put),
  7579. SOC_ENUM_EXT("SEN_TDM_RX_2 Data Format", tdm_config_enum[0],
  7580. msm_dai_q6_tdm_data_format_get,
  7581. msm_dai_q6_tdm_data_format_put),
  7582. SOC_ENUM_EXT("SEN_TDM_RX_3 Data Format", tdm_config_enum[0],
  7583. msm_dai_q6_tdm_data_format_get,
  7584. msm_dai_q6_tdm_data_format_put),
  7585. SOC_ENUM_EXT("SEN_TDM_RX_4 Data Format", tdm_config_enum[0],
  7586. msm_dai_q6_tdm_data_format_get,
  7587. msm_dai_q6_tdm_data_format_put),
  7588. SOC_ENUM_EXT("SEN_TDM_RX_5 Data Format", tdm_config_enum[0],
  7589. msm_dai_q6_tdm_data_format_get,
  7590. msm_dai_q6_tdm_data_format_put),
  7591. SOC_ENUM_EXT("SEN_TDM_RX_6 Data Format", tdm_config_enum[0],
  7592. msm_dai_q6_tdm_data_format_get,
  7593. msm_dai_q6_tdm_data_format_put),
  7594. SOC_ENUM_EXT("SEN_TDM_RX_7 Data Format", tdm_config_enum[0],
  7595. msm_dai_q6_tdm_data_format_get,
  7596. msm_dai_q6_tdm_data_format_put),
  7597. SOC_ENUM_EXT("SEN_TDM_TX_0 Data Format", tdm_config_enum[0],
  7598. msm_dai_q6_tdm_data_format_get,
  7599. msm_dai_q6_tdm_data_format_put),
  7600. SOC_ENUM_EXT("SEN_TDM_TX_1 Data Format", tdm_config_enum[0],
  7601. msm_dai_q6_tdm_data_format_get,
  7602. msm_dai_q6_tdm_data_format_put),
  7603. SOC_ENUM_EXT("SEN_TDM_TX_2 Data Format", tdm_config_enum[0],
  7604. msm_dai_q6_tdm_data_format_get,
  7605. msm_dai_q6_tdm_data_format_put),
  7606. SOC_ENUM_EXT("SEN_TDM_TX_3 Data Format", tdm_config_enum[0],
  7607. msm_dai_q6_tdm_data_format_get,
  7608. msm_dai_q6_tdm_data_format_put),
  7609. SOC_ENUM_EXT("SEN_TDM_TX_4 Data Format", tdm_config_enum[0],
  7610. msm_dai_q6_tdm_data_format_get,
  7611. msm_dai_q6_tdm_data_format_put),
  7612. SOC_ENUM_EXT("SEN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7613. msm_dai_q6_tdm_data_format_get,
  7614. msm_dai_q6_tdm_data_format_put),
  7615. SOC_ENUM_EXT("SEN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7616. msm_dai_q6_tdm_data_format_get,
  7617. msm_dai_q6_tdm_data_format_put),
  7618. SOC_ENUM_EXT("SEN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7619. msm_dai_q6_tdm_data_format_get,
  7620. msm_dai_q6_tdm_data_format_put),
  7621. };
  7622. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  7623. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  7624. msm_dai_q6_tdm_header_type_get,
  7625. msm_dai_q6_tdm_header_type_put),
  7626. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  7627. msm_dai_q6_tdm_header_type_get,
  7628. msm_dai_q6_tdm_header_type_put),
  7629. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  7630. msm_dai_q6_tdm_header_type_get,
  7631. msm_dai_q6_tdm_header_type_put),
  7632. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  7633. msm_dai_q6_tdm_header_type_get,
  7634. msm_dai_q6_tdm_header_type_put),
  7635. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  7636. msm_dai_q6_tdm_header_type_get,
  7637. msm_dai_q6_tdm_header_type_put),
  7638. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  7639. msm_dai_q6_tdm_header_type_get,
  7640. msm_dai_q6_tdm_header_type_put),
  7641. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  7642. msm_dai_q6_tdm_header_type_get,
  7643. msm_dai_q6_tdm_header_type_put),
  7644. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  7645. msm_dai_q6_tdm_header_type_get,
  7646. msm_dai_q6_tdm_header_type_put),
  7647. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  7648. msm_dai_q6_tdm_header_type_get,
  7649. msm_dai_q6_tdm_header_type_put),
  7650. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  7651. msm_dai_q6_tdm_header_type_get,
  7652. msm_dai_q6_tdm_header_type_put),
  7653. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  7654. msm_dai_q6_tdm_header_type_get,
  7655. msm_dai_q6_tdm_header_type_put),
  7656. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  7657. msm_dai_q6_tdm_header_type_get,
  7658. msm_dai_q6_tdm_header_type_put),
  7659. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  7660. msm_dai_q6_tdm_header_type_get,
  7661. msm_dai_q6_tdm_header_type_put),
  7662. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  7663. msm_dai_q6_tdm_header_type_get,
  7664. msm_dai_q6_tdm_header_type_put),
  7665. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  7666. msm_dai_q6_tdm_header_type_get,
  7667. msm_dai_q6_tdm_header_type_put),
  7668. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  7669. msm_dai_q6_tdm_header_type_get,
  7670. msm_dai_q6_tdm_header_type_put),
  7671. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  7672. msm_dai_q6_tdm_header_type_get,
  7673. msm_dai_q6_tdm_header_type_put),
  7674. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  7675. msm_dai_q6_tdm_header_type_get,
  7676. msm_dai_q6_tdm_header_type_put),
  7677. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  7678. msm_dai_q6_tdm_header_type_get,
  7679. msm_dai_q6_tdm_header_type_put),
  7680. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  7681. msm_dai_q6_tdm_header_type_get,
  7682. msm_dai_q6_tdm_header_type_put),
  7683. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  7684. msm_dai_q6_tdm_header_type_get,
  7685. msm_dai_q6_tdm_header_type_put),
  7686. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  7687. msm_dai_q6_tdm_header_type_get,
  7688. msm_dai_q6_tdm_header_type_put),
  7689. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  7690. msm_dai_q6_tdm_header_type_get,
  7691. msm_dai_q6_tdm_header_type_put),
  7692. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  7693. msm_dai_q6_tdm_header_type_get,
  7694. msm_dai_q6_tdm_header_type_put),
  7695. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  7696. msm_dai_q6_tdm_header_type_get,
  7697. msm_dai_q6_tdm_header_type_put),
  7698. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  7699. msm_dai_q6_tdm_header_type_get,
  7700. msm_dai_q6_tdm_header_type_put),
  7701. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  7702. msm_dai_q6_tdm_header_type_get,
  7703. msm_dai_q6_tdm_header_type_put),
  7704. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  7705. msm_dai_q6_tdm_header_type_get,
  7706. msm_dai_q6_tdm_header_type_put),
  7707. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  7708. msm_dai_q6_tdm_header_type_get,
  7709. msm_dai_q6_tdm_header_type_put),
  7710. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  7711. msm_dai_q6_tdm_header_type_get,
  7712. msm_dai_q6_tdm_header_type_put),
  7713. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  7714. msm_dai_q6_tdm_header_type_get,
  7715. msm_dai_q6_tdm_header_type_put),
  7716. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  7717. msm_dai_q6_tdm_header_type_get,
  7718. msm_dai_q6_tdm_header_type_put),
  7719. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  7720. msm_dai_q6_tdm_header_type_get,
  7721. msm_dai_q6_tdm_header_type_put),
  7722. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  7723. msm_dai_q6_tdm_header_type_get,
  7724. msm_dai_q6_tdm_header_type_put),
  7725. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  7726. msm_dai_q6_tdm_header_type_get,
  7727. msm_dai_q6_tdm_header_type_put),
  7728. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  7729. msm_dai_q6_tdm_header_type_get,
  7730. msm_dai_q6_tdm_header_type_put),
  7731. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  7732. msm_dai_q6_tdm_header_type_get,
  7733. msm_dai_q6_tdm_header_type_put),
  7734. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  7735. msm_dai_q6_tdm_header_type_get,
  7736. msm_dai_q6_tdm_header_type_put),
  7737. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  7738. msm_dai_q6_tdm_header_type_get,
  7739. msm_dai_q6_tdm_header_type_put),
  7740. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  7741. msm_dai_q6_tdm_header_type_get,
  7742. msm_dai_q6_tdm_header_type_put),
  7743. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  7744. msm_dai_q6_tdm_header_type_get,
  7745. msm_dai_q6_tdm_header_type_put),
  7746. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  7747. msm_dai_q6_tdm_header_type_get,
  7748. msm_dai_q6_tdm_header_type_put),
  7749. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  7750. msm_dai_q6_tdm_header_type_get,
  7751. msm_dai_q6_tdm_header_type_put),
  7752. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  7753. msm_dai_q6_tdm_header_type_get,
  7754. msm_dai_q6_tdm_header_type_put),
  7755. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  7756. msm_dai_q6_tdm_header_type_get,
  7757. msm_dai_q6_tdm_header_type_put),
  7758. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  7759. msm_dai_q6_tdm_header_type_get,
  7760. msm_dai_q6_tdm_header_type_put),
  7761. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  7762. msm_dai_q6_tdm_header_type_get,
  7763. msm_dai_q6_tdm_header_type_put),
  7764. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  7765. msm_dai_q6_tdm_header_type_get,
  7766. msm_dai_q6_tdm_header_type_put),
  7767. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  7768. msm_dai_q6_tdm_header_type_get,
  7769. msm_dai_q6_tdm_header_type_put),
  7770. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  7771. msm_dai_q6_tdm_header_type_get,
  7772. msm_dai_q6_tdm_header_type_put),
  7773. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  7774. msm_dai_q6_tdm_header_type_get,
  7775. msm_dai_q6_tdm_header_type_put),
  7776. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  7777. msm_dai_q6_tdm_header_type_get,
  7778. msm_dai_q6_tdm_header_type_put),
  7779. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  7780. msm_dai_q6_tdm_header_type_get,
  7781. msm_dai_q6_tdm_header_type_put),
  7782. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  7783. msm_dai_q6_tdm_header_type_get,
  7784. msm_dai_q6_tdm_header_type_put),
  7785. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  7786. msm_dai_q6_tdm_header_type_get,
  7787. msm_dai_q6_tdm_header_type_put),
  7788. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  7789. msm_dai_q6_tdm_header_type_get,
  7790. msm_dai_q6_tdm_header_type_put),
  7791. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  7792. msm_dai_q6_tdm_header_type_get,
  7793. msm_dai_q6_tdm_header_type_put),
  7794. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  7795. msm_dai_q6_tdm_header_type_get,
  7796. msm_dai_q6_tdm_header_type_put),
  7797. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  7798. msm_dai_q6_tdm_header_type_get,
  7799. msm_dai_q6_tdm_header_type_put),
  7800. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  7801. msm_dai_q6_tdm_header_type_get,
  7802. msm_dai_q6_tdm_header_type_put),
  7803. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  7804. msm_dai_q6_tdm_header_type_get,
  7805. msm_dai_q6_tdm_header_type_put),
  7806. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  7807. msm_dai_q6_tdm_header_type_get,
  7808. msm_dai_q6_tdm_header_type_put),
  7809. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  7810. msm_dai_q6_tdm_header_type_get,
  7811. msm_dai_q6_tdm_header_type_put),
  7812. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  7813. msm_dai_q6_tdm_header_type_get,
  7814. msm_dai_q6_tdm_header_type_put),
  7815. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  7816. msm_dai_q6_tdm_header_type_get,
  7817. msm_dai_q6_tdm_header_type_put),
  7818. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  7819. msm_dai_q6_tdm_header_type_get,
  7820. msm_dai_q6_tdm_header_type_put),
  7821. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  7822. msm_dai_q6_tdm_header_type_get,
  7823. msm_dai_q6_tdm_header_type_put),
  7824. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  7825. msm_dai_q6_tdm_header_type_get,
  7826. msm_dai_q6_tdm_header_type_put),
  7827. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  7828. msm_dai_q6_tdm_header_type_get,
  7829. msm_dai_q6_tdm_header_type_put),
  7830. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  7831. msm_dai_q6_tdm_header_type_get,
  7832. msm_dai_q6_tdm_header_type_put),
  7833. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  7834. msm_dai_q6_tdm_header_type_get,
  7835. msm_dai_q6_tdm_header_type_put),
  7836. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  7837. msm_dai_q6_tdm_header_type_get,
  7838. msm_dai_q6_tdm_header_type_put),
  7839. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  7840. msm_dai_q6_tdm_header_type_get,
  7841. msm_dai_q6_tdm_header_type_put),
  7842. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  7843. msm_dai_q6_tdm_header_type_get,
  7844. msm_dai_q6_tdm_header_type_put),
  7845. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  7846. msm_dai_q6_tdm_header_type_get,
  7847. msm_dai_q6_tdm_header_type_put),
  7848. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  7849. msm_dai_q6_tdm_header_type_get,
  7850. msm_dai_q6_tdm_header_type_put),
  7851. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  7852. msm_dai_q6_tdm_header_type_get,
  7853. msm_dai_q6_tdm_header_type_put),
  7854. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  7855. msm_dai_q6_tdm_header_type_get,
  7856. msm_dai_q6_tdm_header_type_put),
  7857. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  7858. msm_dai_q6_tdm_header_type_get,
  7859. msm_dai_q6_tdm_header_type_put),
  7860. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  7861. msm_dai_q6_tdm_header_type_get,
  7862. msm_dai_q6_tdm_header_type_put),
  7863. SOC_ENUM_EXT("SEN_TDM_RX_0 Header Type", tdm_config_enum[1],
  7864. msm_dai_q6_tdm_header_type_get,
  7865. msm_dai_q6_tdm_header_type_put),
  7866. SOC_ENUM_EXT("SEN_TDM_RX_1 Header Type", tdm_config_enum[1],
  7867. msm_dai_q6_tdm_header_type_get,
  7868. msm_dai_q6_tdm_header_type_put),
  7869. SOC_ENUM_EXT("SEN_TDM_RX_2 Header Type", tdm_config_enum[1],
  7870. msm_dai_q6_tdm_header_type_get,
  7871. msm_dai_q6_tdm_header_type_put),
  7872. SOC_ENUM_EXT("SEN_TDM_RX_3 Header Type", tdm_config_enum[1],
  7873. msm_dai_q6_tdm_header_type_get,
  7874. msm_dai_q6_tdm_header_type_put),
  7875. SOC_ENUM_EXT("SEN_TDM_RX_4 Header Type", tdm_config_enum[1],
  7876. msm_dai_q6_tdm_header_type_get,
  7877. msm_dai_q6_tdm_header_type_put),
  7878. SOC_ENUM_EXT("SEN_TDM_RX_5 Header Type", tdm_config_enum[1],
  7879. msm_dai_q6_tdm_header_type_get,
  7880. msm_dai_q6_tdm_header_type_put),
  7881. SOC_ENUM_EXT("SEN_TDM_RX_6 Header Type", tdm_config_enum[1],
  7882. msm_dai_q6_tdm_header_type_get,
  7883. msm_dai_q6_tdm_header_type_put),
  7884. SOC_ENUM_EXT("SEN_TDM_RX_7 Header Type", tdm_config_enum[1],
  7885. msm_dai_q6_tdm_header_type_get,
  7886. msm_dai_q6_tdm_header_type_put),
  7887. SOC_ENUM_EXT("SEN_TDM_TX_0 Header Type", tdm_config_enum[1],
  7888. msm_dai_q6_tdm_header_type_get,
  7889. msm_dai_q6_tdm_header_type_put),
  7890. SOC_ENUM_EXT("SEN_TDM_TX_1 Header Type", tdm_config_enum[1],
  7891. msm_dai_q6_tdm_header_type_get,
  7892. msm_dai_q6_tdm_header_type_put),
  7893. SOC_ENUM_EXT("SEN_TDM_TX_2 Header Type", tdm_config_enum[1],
  7894. msm_dai_q6_tdm_header_type_get,
  7895. msm_dai_q6_tdm_header_type_put),
  7896. SOC_ENUM_EXT("SEN_TDM_TX_3 Header Type", tdm_config_enum[1],
  7897. msm_dai_q6_tdm_header_type_get,
  7898. msm_dai_q6_tdm_header_type_put),
  7899. SOC_ENUM_EXT("SEN_TDM_TX_4 Header Type", tdm_config_enum[1],
  7900. msm_dai_q6_tdm_header_type_get,
  7901. msm_dai_q6_tdm_header_type_put),
  7902. SOC_ENUM_EXT("SEN_TDM_TX_5 Header Type", tdm_config_enum[1],
  7903. msm_dai_q6_tdm_header_type_get,
  7904. msm_dai_q6_tdm_header_type_put),
  7905. SOC_ENUM_EXT("SEN_TDM_TX_6 Header Type", tdm_config_enum[1],
  7906. msm_dai_q6_tdm_header_type_get,
  7907. msm_dai_q6_tdm_header_type_put),
  7908. SOC_ENUM_EXT("SEN_TDM_TX_7 Header Type", tdm_config_enum[1],
  7909. msm_dai_q6_tdm_header_type_get,
  7910. msm_dai_q6_tdm_header_type_put),
  7911. };
  7912. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  7913. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  7914. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7915. msm_dai_q6_tdm_header_get,
  7916. msm_dai_q6_tdm_header_put),
  7917. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  7918. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7919. msm_dai_q6_tdm_header_get,
  7920. msm_dai_q6_tdm_header_put),
  7921. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  7922. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7923. msm_dai_q6_tdm_header_get,
  7924. msm_dai_q6_tdm_header_put),
  7925. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  7926. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7927. msm_dai_q6_tdm_header_get,
  7928. msm_dai_q6_tdm_header_put),
  7929. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  7930. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7931. msm_dai_q6_tdm_header_get,
  7932. msm_dai_q6_tdm_header_put),
  7933. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  7934. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7935. msm_dai_q6_tdm_header_get,
  7936. msm_dai_q6_tdm_header_put),
  7937. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  7938. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7939. msm_dai_q6_tdm_header_get,
  7940. msm_dai_q6_tdm_header_put),
  7941. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  7942. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7943. msm_dai_q6_tdm_header_get,
  7944. msm_dai_q6_tdm_header_put),
  7945. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  7946. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7947. msm_dai_q6_tdm_header_get,
  7948. msm_dai_q6_tdm_header_put),
  7949. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  7950. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7951. msm_dai_q6_tdm_header_get,
  7952. msm_dai_q6_tdm_header_put),
  7953. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  7954. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7955. msm_dai_q6_tdm_header_get,
  7956. msm_dai_q6_tdm_header_put),
  7957. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  7958. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7959. msm_dai_q6_tdm_header_get,
  7960. msm_dai_q6_tdm_header_put),
  7961. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  7962. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7963. msm_dai_q6_tdm_header_get,
  7964. msm_dai_q6_tdm_header_put),
  7965. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  7966. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7967. msm_dai_q6_tdm_header_get,
  7968. msm_dai_q6_tdm_header_put),
  7969. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  7970. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7971. msm_dai_q6_tdm_header_get,
  7972. msm_dai_q6_tdm_header_put),
  7973. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  7974. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7975. msm_dai_q6_tdm_header_get,
  7976. msm_dai_q6_tdm_header_put),
  7977. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  7978. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7979. msm_dai_q6_tdm_header_get,
  7980. msm_dai_q6_tdm_header_put),
  7981. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  7982. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7983. msm_dai_q6_tdm_header_get,
  7984. msm_dai_q6_tdm_header_put),
  7985. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  7986. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7987. msm_dai_q6_tdm_header_get,
  7988. msm_dai_q6_tdm_header_put),
  7989. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  7990. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7991. msm_dai_q6_tdm_header_get,
  7992. msm_dai_q6_tdm_header_put),
  7993. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  7994. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7995. msm_dai_q6_tdm_header_get,
  7996. msm_dai_q6_tdm_header_put),
  7997. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  7998. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7999. msm_dai_q6_tdm_header_get,
  8000. msm_dai_q6_tdm_header_put),
  8001. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  8002. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8003. msm_dai_q6_tdm_header_get,
  8004. msm_dai_q6_tdm_header_put),
  8005. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  8006. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8007. msm_dai_q6_tdm_header_get,
  8008. msm_dai_q6_tdm_header_put),
  8009. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  8010. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8011. msm_dai_q6_tdm_header_get,
  8012. msm_dai_q6_tdm_header_put),
  8013. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  8014. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8015. msm_dai_q6_tdm_header_get,
  8016. msm_dai_q6_tdm_header_put),
  8017. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  8018. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8019. msm_dai_q6_tdm_header_get,
  8020. msm_dai_q6_tdm_header_put),
  8021. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  8022. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8023. msm_dai_q6_tdm_header_get,
  8024. msm_dai_q6_tdm_header_put),
  8025. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  8026. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8027. msm_dai_q6_tdm_header_get,
  8028. msm_dai_q6_tdm_header_put),
  8029. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  8030. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8031. msm_dai_q6_tdm_header_get,
  8032. msm_dai_q6_tdm_header_put),
  8033. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  8034. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8035. msm_dai_q6_tdm_header_get,
  8036. msm_dai_q6_tdm_header_put),
  8037. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  8038. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8039. msm_dai_q6_tdm_header_get,
  8040. msm_dai_q6_tdm_header_put),
  8041. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  8042. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8043. msm_dai_q6_tdm_header_get,
  8044. msm_dai_q6_tdm_header_put),
  8045. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  8046. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8047. msm_dai_q6_tdm_header_get,
  8048. msm_dai_q6_tdm_header_put),
  8049. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  8050. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8051. msm_dai_q6_tdm_header_get,
  8052. msm_dai_q6_tdm_header_put),
  8053. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  8054. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8055. msm_dai_q6_tdm_header_get,
  8056. msm_dai_q6_tdm_header_put),
  8057. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  8058. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8059. msm_dai_q6_tdm_header_get,
  8060. msm_dai_q6_tdm_header_put),
  8061. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  8062. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8063. msm_dai_q6_tdm_header_get,
  8064. msm_dai_q6_tdm_header_put),
  8065. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  8066. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8067. msm_dai_q6_tdm_header_get,
  8068. msm_dai_q6_tdm_header_put),
  8069. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  8070. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8071. msm_dai_q6_tdm_header_get,
  8072. msm_dai_q6_tdm_header_put),
  8073. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  8074. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8075. msm_dai_q6_tdm_header_get,
  8076. msm_dai_q6_tdm_header_put),
  8077. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  8078. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8079. msm_dai_q6_tdm_header_get,
  8080. msm_dai_q6_tdm_header_put),
  8081. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  8082. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8083. msm_dai_q6_tdm_header_get,
  8084. msm_dai_q6_tdm_header_put),
  8085. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  8086. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8087. msm_dai_q6_tdm_header_get,
  8088. msm_dai_q6_tdm_header_put),
  8089. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  8090. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8091. msm_dai_q6_tdm_header_get,
  8092. msm_dai_q6_tdm_header_put),
  8093. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  8094. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8095. msm_dai_q6_tdm_header_get,
  8096. msm_dai_q6_tdm_header_put),
  8097. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  8098. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8099. msm_dai_q6_tdm_header_get,
  8100. msm_dai_q6_tdm_header_put),
  8101. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  8102. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8103. msm_dai_q6_tdm_header_get,
  8104. msm_dai_q6_tdm_header_put),
  8105. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  8106. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8107. msm_dai_q6_tdm_header_get,
  8108. msm_dai_q6_tdm_header_put),
  8109. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  8110. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8111. msm_dai_q6_tdm_header_get,
  8112. msm_dai_q6_tdm_header_put),
  8113. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  8114. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8115. msm_dai_q6_tdm_header_get,
  8116. msm_dai_q6_tdm_header_put),
  8117. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  8118. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8119. msm_dai_q6_tdm_header_get,
  8120. msm_dai_q6_tdm_header_put),
  8121. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  8122. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8123. msm_dai_q6_tdm_header_get,
  8124. msm_dai_q6_tdm_header_put),
  8125. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  8126. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8127. msm_dai_q6_tdm_header_get,
  8128. msm_dai_q6_tdm_header_put),
  8129. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  8130. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8131. msm_dai_q6_tdm_header_get,
  8132. msm_dai_q6_tdm_header_put),
  8133. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  8134. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8135. msm_dai_q6_tdm_header_get,
  8136. msm_dai_q6_tdm_header_put),
  8137. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  8138. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8139. msm_dai_q6_tdm_header_get,
  8140. msm_dai_q6_tdm_header_put),
  8141. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  8142. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8143. msm_dai_q6_tdm_header_get,
  8144. msm_dai_q6_tdm_header_put),
  8145. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  8146. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8147. msm_dai_q6_tdm_header_get,
  8148. msm_dai_q6_tdm_header_put),
  8149. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  8150. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8151. msm_dai_q6_tdm_header_get,
  8152. msm_dai_q6_tdm_header_put),
  8153. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  8154. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8155. msm_dai_q6_tdm_header_get,
  8156. msm_dai_q6_tdm_header_put),
  8157. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  8158. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8159. msm_dai_q6_tdm_header_get,
  8160. msm_dai_q6_tdm_header_put),
  8161. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  8162. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8163. msm_dai_q6_tdm_header_get,
  8164. msm_dai_q6_tdm_header_put),
  8165. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  8166. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8167. msm_dai_q6_tdm_header_get,
  8168. msm_dai_q6_tdm_header_put),
  8169. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  8170. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8171. msm_dai_q6_tdm_header_get,
  8172. msm_dai_q6_tdm_header_put),
  8173. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  8174. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8175. msm_dai_q6_tdm_header_get,
  8176. msm_dai_q6_tdm_header_put),
  8177. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  8178. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8179. msm_dai_q6_tdm_header_get,
  8180. msm_dai_q6_tdm_header_put),
  8181. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  8182. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8183. msm_dai_q6_tdm_header_get,
  8184. msm_dai_q6_tdm_header_put),
  8185. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  8186. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8187. msm_dai_q6_tdm_header_get,
  8188. msm_dai_q6_tdm_header_put),
  8189. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  8190. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8191. msm_dai_q6_tdm_header_get,
  8192. msm_dai_q6_tdm_header_put),
  8193. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  8194. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8195. msm_dai_q6_tdm_header_get,
  8196. msm_dai_q6_tdm_header_put),
  8197. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  8198. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8199. msm_dai_q6_tdm_header_get,
  8200. msm_dai_q6_tdm_header_put),
  8201. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  8202. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8203. msm_dai_q6_tdm_header_get,
  8204. msm_dai_q6_tdm_header_put),
  8205. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  8206. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8207. msm_dai_q6_tdm_header_get,
  8208. msm_dai_q6_tdm_header_put),
  8209. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  8210. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8211. msm_dai_q6_tdm_header_get,
  8212. msm_dai_q6_tdm_header_put),
  8213. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  8214. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8215. msm_dai_q6_tdm_header_get,
  8216. msm_dai_q6_tdm_header_put),
  8217. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  8218. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8219. msm_dai_q6_tdm_header_get,
  8220. msm_dai_q6_tdm_header_put),
  8221. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  8222. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8223. msm_dai_q6_tdm_header_get,
  8224. msm_dai_q6_tdm_header_put),
  8225. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  8226. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8227. msm_dai_q6_tdm_header_get,
  8228. msm_dai_q6_tdm_header_put),
  8229. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  8230. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8231. msm_dai_q6_tdm_header_get,
  8232. msm_dai_q6_tdm_header_put),
  8233. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_0 Header",
  8234. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8235. msm_dai_q6_tdm_header_get,
  8236. msm_dai_q6_tdm_header_put),
  8237. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_1 Header",
  8238. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8239. msm_dai_q6_tdm_header_get,
  8240. msm_dai_q6_tdm_header_put),
  8241. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_2 Header",
  8242. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8243. msm_dai_q6_tdm_header_get,
  8244. msm_dai_q6_tdm_header_put),
  8245. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_3 Header",
  8246. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8247. msm_dai_q6_tdm_header_get,
  8248. msm_dai_q6_tdm_header_put),
  8249. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_4 Header",
  8250. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8251. msm_dai_q6_tdm_header_get,
  8252. msm_dai_q6_tdm_header_put),
  8253. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_5 Header",
  8254. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8255. msm_dai_q6_tdm_header_get,
  8256. msm_dai_q6_tdm_header_put),
  8257. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_6 Header",
  8258. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8259. msm_dai_q6_tdm_header_get,
  8260. msm_dai_q6_tdm_header_put),
  8261. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_7 Header",
  8262. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8263. msm_dai_q6_tdm_header_get,
  8264. msm_dai_q6_tdm_header_put),
  8265. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_0 Header",
  8266. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8267. msm_dai_q6_tdm_header_get,
  8268. msm_dai_q6_tdm_header_put),
  8269. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_1 Header",
  8270. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8271. msm_dai_q6_tdm_header_get,
  8272. msm_dai_q6_tdm_header_put),
  8273. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_2 Header",
  8274. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8275. msm_dai_q6_tdm_header_get,
  8276. msm_dai_q6_tdm_header_put),
  8277. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_3 Header",
  8278. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8279. msm_dai_q6_tdm_header_get,
  8280. msm_dai_q6_tdm_header_put),
  8281. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_4 Header",
  8282. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8283. msm_dai_q6_tdm_header_get,
  8284. msm_dai_q6_tdm_header_put),
  8285. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_5 Header",
  8286. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8287. msm_dai_q6_tdm_header_get,
  8288. msm_dai_q6_tdm_header_put),
  8289. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_6 Header",
  8290. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8291. msm_dai_q6_tdm_header_get,
  8292. msm_dai_q6_tdm_header_put),
  8293. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_7 Header",
  8294. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8295. msm_dai_q6_tdm_header_get,
  8296. msm_dai_q6_tdm_header_put),
  8297. };
  8298. static int msm_dai_q6_tdm_set_clk(
  8299. struct msm_dai_q6_tdm_dai_data *dai_data,
  8300. u16 port_id, bool enable)
  8301. {
  8302. int rc = 0;
  8303. dai_data->clk_set.enable = enable;
  8304. rc = afe_set_lpass_clock_v2(port_id,
  8305. &dai_data->clk_set);
  8306. if (rc < 0)
  8307. pr_err("%s: afe lpass clock failed, err:%d\n",
  8308. __func__, rc);
  8309. return rc;
  8310. }
  8311. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  8312. {
  8313. int rc = 0;
  8314. struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL;
  8315. struct snd_kcontrol *data_format_kcontrol = NULL;
  8316. struct snd_kcontrol *header_type_kcontrol = NULL;
  8317. struct snd_kcontrol *header_kcontrol = NULL;
  8318. int port_idx = 0;
  8319. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  8320. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  8321. const struct snd_kcontrol_new *header_ctrl = NULL;
  8322. tdm_dai_data = dev_get_drvdata(dai->dev);
  8323. msm_dai_q6_set_dai_id(dai);
  8324. port_idx = msm_dai_q6_get_port_idx(dai->id);
  8325. if (port_idx < 0) {
  8326. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8327. __func__, dai->id);
  8328. rc = -EINVAL;
  8329. goto rtn;
  8330. }
  8331. data_format_ctrl =
  8332. &tdm_config_controls_data_format[port_idx];
  8333. header_type_ctrl =
  8334. &tdm_config_controls_header_type[port_idx];
  8335. header_ctrl =
  8336. &tdm_config_controls_header[port_idx];
  8337. if (data_format_ctrl) {
  8338. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  8339. tdm_dai_data);
  8340. rc = snd_ctl_add(dai->component->card->snd_card,
  8341. data_format_kcontrol);
  8342. if (rc < 0) {
  8343. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  8344. __func__, dai->name);
  8345. goto rtn;
  8346. }
  8347. }
  8348. if (header_type_ctrl) {
  8349. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  8350. tdm_dai_data);
  8351. rc = snd_ctl_add(dai->component->card->snd_card,
  8352. header_type_kcontrol);
  8353. if (rc < 0) {
  8354. if (data_format_kcontrol)
  8355. snd_ctl_remove(dai->component->card->snd_card,
  8356. data_format_kcontrol);
  8357. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  8358. __func__, dai->name);
  8359. goto rtn;
  8360. }
  8361. }
  8362. if (header_ctrl) {
  8363. header_kcontrol = snd_ctl_new1(header_ctrl,
  8364. tdm_dai_data);
  8365. rc = snd_ctl_add(dai->component->card->snd_card,
  8366. header_kcontrol);
  8367. if (rc < 0) {
  8368. if (header_type_kcontrol)
  8369. snd_ctl_remove(dai->component->card->snd_card,
  8370. header_type_kcontrol);
  8371. if (data_format_kcontrol)
  8372. snd_ctl_remove(dai->component->card->snd_card,
  8373. data_format_kcontrol);
  8374. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  8375. __func__, dai->name);
  8376. goto rtn;
  8377. }
  8378. }
  8379. if (tdm_dai_data->is_island_dai)
  8380. rc = msm_dai_q6_add_island_mx_ctls(
  8381. dai->component->card->snd_card,
  8382. dai->name,
  8383. dai->id, (void *)tdm_dai_data);
  8384. rc = msm_dai_q6_dai_add_route(dai);
  8385. rtn:
  8386. return rc;
  8387. }
  8388. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  8389. {
  8390. int rc = 0;
  8391. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  8392. dev_get_drvdata(dai->dev);
  8393. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  8394. int group_idx = 0;
  8395. atomic_t *group_ref = NULL;
  8396. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8397. if (group_idx < 0) {
  8398. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8399. __func__, dai->id);
  8400. return -EINVAL;
  8401. }
  8402. group_ref = &tdm_group_ref[group_idx];
  8403. /* If AFE port is still up, close it */
  8404. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  8405. rc = afe_close(dai->id); /* can block */
  8406. if (rc < 0) {
  8407. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8408. __func__, dai->id);
  8409. }
  8410. atomic_dec(group_ref);
  8411. clear_bit(STATUS_PORT_STARTED,
  8412. tdm_dai_data->status_mask);
  8413. if (atomic_read(group_ref) == 0) {
  8414. rc = afe_port_group_enable(group_id,
  8415. NULL, false, NULL);
  8416. if (rc < 0) {
  8417. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  8418. group_id);
  8419. }
  8420. }
  8421. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8422. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  8423. dai->id, false);
  8424. if (rc < 0) {
  8425. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8426. __func__, dai->id);
  8427. }
  8428. }
  8429. }
  8430. return 0;
  8431. }
  8432. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  8433. unsigned int tx_mask,
  8434. unsigned int rx_mask,
  8435. int slots, int slot_width)
  8436. {
  8437. int rc = 0;
  8438. struct msm_dai_q6_tdm_dai_data *dai_data =
  8439. dev_get_drvdata(dai->dev);
  8440. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8441. &dai_data->group_cfg.tdm_cfg;
  8442. unsigned int cap_mask;
  8443. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8444. /* HW only supports 16 and 32 bit slot width configuration */
  8445. if ((slot_width != 16) && (slot_width != 32)) {
  8446. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  8447. __func__, slot_width);
  8448. return -EINVAL;
  8449. }
  8450. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  8451. switch (slots) {
  8452. case 1:
  8453. cap_mask = 0x01;
  8454. break;
  8455. case 2:
  8456. cap_mask = 0x03;
  8457. break;
  8458. case 4:
  8459. cap_mask = 0x0F;
  8460. break;
  8461. case 8:
  8462. cap_mask = 0xFF;
  8463. break;
  8464. case 16:
  8465. cap_mask = 0xFFFF;
  8466. break;
  8467. case 32:
  8468. cap_mask = 0xFFFFFFFF;
  8469. break;
  8470. default:
  8471. dev_err(dai->dev, "%s: invalid slots %d\n",
  8472. __func__, slots);
  8473. return -EINVAL;
  8474. }
  8475. switch (dai->id) {
  8476. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8477. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8478. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8479. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8480. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8481. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8482. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8483. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8484. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8485. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8486. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8487. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8488. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8489. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8490. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8491. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8492. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8493. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8494. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8495. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8496. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8497. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8498. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8499. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8500. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8501. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8502. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8503. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8504. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8505. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8506. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8507. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8508. case AFE_PORT_ID_QUINARY_TDM_RX:
  8509. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8510. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8511. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8512. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8513. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8514. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8515. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8516. case AFE_PORT_ID_SENARY_TDM_RX:
  8517. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8518. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8519. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8520. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8521. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8522. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8523. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8524. tdm_group->nslots_per_frame = slots;
  8525. tdm_group->slot_width = slot_width;
  8526. tdm_group->slot_mask = rx_mask & cap_mask;
  8527. break;
  8528. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8529. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8530. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8531. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8532. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8533. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8534. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8535. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8536. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8537. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8538. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8539. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8540. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8541. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8542. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8543. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8544. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8545. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8546. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8547. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8548. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8549. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8550. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8551. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8552. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8553. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8554. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8555. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8556. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8557. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8558. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8559. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8560. case AFE_PORT_ID_QUINARY_TDM_TX:
  8561. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8562. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8563. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8564. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8565. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8566. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8567. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8568. case AFE_PORT_ID_SENARY_TDM_TX:
  8569. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8570. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8571. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8572. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8573. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8574. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8575. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8576. tdm_group->nslots_per_frame = slots;
  8577. tdm_group->slot_width = slot_width;
  8578. tdm_group->slot_mask = tx_mask & cap_mask;
  8579. break;
  8580. default:
  8581. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8582. __func__, dai->id);
  8583. return -EINVAL;
  8584. }
  8585. return rc;
  8586. }
  8587. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  8588. int clk_id, unsigned int freq, int dir)
  8589. {
  8590. struct msm_dai_q6_tdm_dai_data *dai_data =
  8591. dev_get_drvdata(dai->dev);
  8592. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  8593. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  8594. dai_data->clk_set.clk_freq_in_hz = freq;
  8595. } else {
  8596. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8597. __func__, dai->id);
  8598. return -EINVAL;
  8599. }
  8600. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  8601. __func__, dai->id, freq);
  8602. return 0;
  8603. }
  8604. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  8605. unsigned int tx_num, unsigned int *tx_slot,
  8606. unsigned int rx_num, unsigned int *rx_slot)
  8607. {
  8608. int rc = 0;
  8609. struct msm_dai_q6_tdm_dai_data *dai_data =
  8610. dev_get_drvdata(dai->dev);
  8611. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8612. &dai_data->port_cfg.slot_mapping;
  8613. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8614. &dai_data->port_cfg.slot_mapping_v2;
  8615. int i = 0;
  8616. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8617. switch (dai->id) {
  8618. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8619. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8620. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8621. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8622. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8623. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8624. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8625. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8626. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8627. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8628. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8629. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8630. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8631. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8632. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8633. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8634. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8635. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8636. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8637. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8638. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8639. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8640. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8641. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8642. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8643. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8644. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8645. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8646. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8647. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8648. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8649. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8650. case AFE_PORT_ID_QUINARY_TDM_RX:
  8651. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8652. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8653. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8654. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8655. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8656. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8657. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8658. case AFE_PORT_ID_SENARY_TDM_RX:
  8659. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8660. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8661. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8662. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8663. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8664. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8665. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8666. if (q6core_get_avcs_api_version_per_service(
  8667. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8668. if (!rx_slot) {
  8669. dev_err(dai->dev, "%s: rx slot not found\n",
  8670. __func__);
  8671. return -EINVAL;
  8672. }
  8673. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8674. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8675. __func__,
  8676. rx_num);
  8677. return -EINVAL;
  8678. }
  8679. for (i = 0; i < rx_num; i++)
  8680. slot_mapping_v2->offset[i] = rx_slot[i];
  8681. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8682. i++)
  8683. slot_mapping_v2->offset[i] =
  8684. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8685. slot_mapping_v2->num_channel = rx_num;
  8686. } else {
  8687. if (!rx_slot) {
  8688. dev_err(dai->dev, "%s: rx slot not found\n",
  8689. __func__);
  8690. return -EINVAL;
  8691. }
  8692. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8693. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8694. __func__,
  8695. rx_num);
  8696. return -EINVAL;
  8697. }
  8698. for (i = 0; i < rx_num; i++)
  8699. slot_mapping->offset[i] = rx_slot[i];
  8700. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8701. slot_mapping->offset[i] =
  8702. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8703. slot_mapping->num_channel = rx_num;
  8704. }
  8705. break;
  8706. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8707. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8708. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8709. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8710. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8711. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8712. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8713. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8714. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8715. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8716. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8717. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8718. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8719. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8720. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8721. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8722. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8723. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8724. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8725. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8726. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8727. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8728. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8729. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8730. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8731. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8732. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8733. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8734. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8735. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8736. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8737. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8738. case AFE_PORT_ID_QUINARY_TDM_TX:
  8739. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8740. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8741. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8742. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8743. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8744. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8745. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8746. case AFE_PORT_ID_SENARY_TDM_TX:
  8747. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8748. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8749. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8750. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8751. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8752. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8753. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8754. if (q6core_get_avcs_api_version_per_service(
  8755. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8756. if (!tx_slot) {
  8757. dev_err(dai->dev, "%s: tx slot not found\n",
  8758. __func__);
  8759. return -EINVAL;
  8760. }
  8761. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8762. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8763. __func__,
  8764. tx_num);
  8765. return -EINVAL;
  8766. }
  8767. for (i = 0; i < tx_num; i++)
  8768. slot_mapping_v2->offset[i] = tx_slot[i];
  8769. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8770. i++)
  8771. slot_mapping_v2->offset[i] =
  8772. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8773. slot_mapping_v2->num_channel = tx_num;
  8774. } else {
  8775. if (!tx_slot) {
  8776. dev_err(dai->dev, "%s: tx slot not found\n",
  8777. __func__);
  8778. return -EINVAL;
  8779. }
  8780. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8781. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8782. __func__,
  8783. tx_num);
  8784. return -EINVAL;
  8785. }
  8786. for (i = 0; i < tx_num; i++)
  8787. slot_mapping->offset[i] = tx_slot[i];
  8788. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8789. slot_mapping->offset[i] =
  8790. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8791. slot_mapping->num_channel = tx_num;
  8792. }
  8793. break;
  8794. default:
  8795. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8796. __func__, dai->id);
  8797. return -EINVAL;
  8798. }
  8799. return rc;
  8800. }
  8801. static unsigned int tdm_param_set_slot_mask(u16 *slot_offset, int slot_width,
  8802. int slots_per_frame)
  8803. {
  8804. unsigned int i = 0;
  8805. unsigned int slot_index = 0;
  8806. unsigned long slot_mask = 0;
  8807. unsigned int slot_width_bytes = slot_width / 8;
  8808. unsigned int channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT;
  8809. if (q6core_get_avcs_api_version_per_service(
  8810. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  8811. channel_count = AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8812. if (slot_width_bytes == 0) {
  8813. pr_err("%s: slot width is zero\n", __func__);
  8814. return slot_mask;
  8815. }
  8816. for (i = 0; i < channel_count; i++) {
  8817. if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID) {
  8818. slot_index = slot_offset[i] / slot_width_bytes;
  8819. if (slot_index < slots_per_frame)
  8820. set_bit(slot_index, &slot_mask);
  8821. else {
  8822. pr_err("%s: invalid slot map setting\n",
  8823. __func__);
  8824. return 0;
  8825. }
  8826. } else {
  8827. break;
  8828. }
  8829. }
  8830. return slot_mask;
  8831. }
  8832. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  8833. struct snd_pcm_hw_params *params,
  8834. struct snd_soc_dai *dai)
  8835. {
  8836. struct msm_dai_q6_tdm_dai_data *dai_data =
  8837. dev_get_drvdata(dai->dev);
  8838. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8839. &dai_data->group_cfg.tdm_cfg;
  8840. struct afe_param_id_tdm_cfg *tdm =
  8841. &dai_data->port_cfg.tdm;
  8842. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8843. &dai_data->port_cfg.slot_mapping;
  8844. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8845. &dai_data->port_cfg.slot_mapping_v2;
  8846. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  8847. &dai_data->port_cfg.custom_tdm_header;
  8848. pr_debug("%s: dev_name: %s\n",
  8849. __func__, dev_name(dai->dev));
  8850. if ((params_channels(params) == 0) ||
  8851. (params_channels(params) > 32)) {
  8852. dev_err(dai->dev, "%s: invalid param channels %d\n",
  8853. __func__, params_channels(params));
  8854. return -EINVAL;
  8855. }
  8856. switch (params_format(params)) {
  8857. case SNDRV_PCM_FORMAT_S16_LE:
  8858. dai_data->bitwidth = 16;
  8859. break;
  8860. case SNDRV_PCM_FORMAT_S24_LE:
  8861. case SNDRV_PCM_FORMAT_S24_3LE:
  8862. dai_data->bitwidth = 24;
  8863. break;
  8864. case SNDRV_PCM_FORMAT_S32_LE:
  8865. dai_data->bitwidth = 32;
  8866. break;
  8867. default:
  8868. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  8869. __func__, params_format(params));
  8870. return -EINVAL;
  8871. }
  8872. dai_data->channels = params_channels(params);
  8873. dai_data->rate = params_rate(params);
  8874. /*
  8875. * update tdm group config param
  8876. * NOTE: group config is set to the same as slot config.
  8877. */
  8878. tdm_group->bit_width = tdm_group->slot_width;
  8879. /*
  8880. * for multi lane scenario
  8881. * Total number of active channels = number of active lanes * number of active slots.
  8882. */
  8883. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  8884. tdm_group->num_channels = tdm_group->nslots_per_frame
  8885. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  8886. else
  8887. tdm_group->num_channels = tdm_group->nslots_per_frame;
  8888. tdm_group->sample_rate = dai_data->rate;
  8889. pr_debug("%s: TDM GROUP:\n"
  8890. "num_channels=%d sample_rate=%d bit_width=%d\n"
  8891. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  8892. __func__,
  8893. tdm_group->num_channels,
  8894. tdm_group->sample_rate,
  8895. tdm_group->bit_width,
  8896. tdm_group->nslots_per_frame,
  8897. tdm_group->slot_width,
  8898. tdm_group->slot_mask);
  8899. pr_debug("%s: TDM GROUP:\n"
  8900. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  8901. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  8902. __func__,
  8903. tdm_group->port_id[0],
  8904. tdm_group->port_id[1],
  8905. tdm_group->port_id[2],
  8906. tdm_group->port_id[3],
  8907. tdm_group->port_id[4],
  8908. tdm_group->port_id[5],
  8909. tdm_group->port_id[6],
  8910. tdm_group->port_id[7]);
  8911. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  8912. __func__,
  8913. tdm_group->group_id,
  8914. dai_data->lane_cfg.lane_mask);
  8915. /*
  8916. * update tdm config param
  8917. * NOTE: channels/rate/bitwidth are per stream property
  8918. */
  8919. tdm->num_channels = dai_data->channels;
  8920. tdm->sample_rate = dai_data->rate;
  8921. tdm->bit_width = dai_data->bitwidth;
  8922. /*
  8923. * port slot config is the same as group slot config
  8924. * port slot mask should be set according to offset
  8925. */
  8926. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  8927. tdm->slot_width = tdm_group->slot_width;
  8928. if (q6core_get_avcs_api_version_per_service(
  8929. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3)
  8930. tdm->slot_mask = tdm_param_set_slot_mask(
  8931. slot_mapping_v2->offset,
  8932. tdm_group->slot_width,
  8933. tdm_group->nslots_per_frame);
  8934. else
  8935. tdm->slot_mask = tdm_param_set_slot_mask(slot_mapping->offset,
  8936. tdm_group->slot_width,
  8937. tdm_group->nslots_per_frame);
  8938. pr_debug("%s: TDM:\n"
  8939. "num_channels=%d sample_rate=%d bit_width=%d\n"
  8940. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  8941. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  8942. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  8943. __func__,
  8944. tdm->num_channels,
  8945. tdm->sample_rate,
  8946. tdm->bit_width,
  8947. tdm->nslots_per_frame,
  8948. tdm->slot_width,
  8949. tdm->slot_mask,
  8950. tdm->data_format,
  8951. tdm->sync_mode,
  8952. tdm->sync_src,
  8953. tdm->ctrl_data_out_enable,
  8954. tdm->ctrl_invert_sync_pulse,
  8955. tdm->ctrl_sync_data_delay);
  8956. if (q6core_get_avcs_api_version_per_service(
  8957. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8958. /*
  8959. * update slot mapping v2 config param
  8960. * NOTE: channels/rate/bitwidth are per stream property
  8961. */
  8962. slot_mapping_v2->bitwidth = dai_data->bitwidth;
  8963. pr_debug("%s: SLOT MAPPING_V2:\n"
  8964. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  8965. __func__,
  8966. slot_mapping_v2->num_channel,
  8967. slot_mapping_v2->bitwidth,
  8968. slot_mapping_v2->data_align_type);
  8969. pr_debug("%s: SLOT MAPPING V2:\n"
  8970. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  8971. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n"
  8972. "offset[8]=0x%x offset[9]=0x%x offset[10]=0x%x offset[11]=0x%x\n"
  8973. "offset[12]=0x%x offset[13]=0x%x offset[14]=0x%x offset[15]=0x%x\n"
  8974. "offset[16]=0x%x offset[17]=0x%x offset[18]=0x%x offset[19]=0x%x\n"
  8975. "offset[20]=0x%x offset[21]=0x%x offset[22]=0x%x offset[23]=0x%x\n"
  8976. "offset[24]=0x%x offset[25]=0x%x offset[26]=0x%x offset[27]=0x%x\n"
  8977. "offset[28]=0x%x offset[29]=0x%x offset[30]=0x%x offset[31]=0x%x\n",
  8978. __func__,
  8979. slot_mapping_v2->offset[0],
  8980. slot_mapping_v2->offset[1],
  8981. slot_mapping_v2->offset[2],
  8982. slot_mapping_v2->offset[3],
  8983. slot_mapping_v2->offset[4],
  8984. slot_mapping_v2->offset[5],
  8985. slot_mapping_v2->offset[6],
  8986. slot_mapping_v2->offset[7],
  8987. slot_mapping_v2->offset[8],
  8988. slot_mapping_v2->offset[9],
  8989. slot_mapping_v2->offset[10],
  8990. slot_mapping_v2->offset[11],
  8991. slot_mapping_v2->offset[12],
  8992. slot_mapping_v2->offset[13],
  8993. slot_mapping_v2->offset[14],
  8994. slot_mapping_v2->offset[15],
  8995. slot_mapping_v2->offset[16],
  8996. slot_mapping_v2->offset[17],
  8997. slot_mapping_v2->offset[18],
  8998. slot_mapping_v2->offset[19],
  8999. slot_mapping_v2->offset[20],
  9000. slot_mapping_v2->offset[21],
  9001. slot_mapping_v2->offset[22],
  9002. slot_mapping_v2->offset[23],
  9003. slot_mapping_v2->offset[24],
  9004. slot_mapping_v2->offset[25],
  9005. slot_mapping_v2->offset[26],
  9006. slot_mapping_v2->offset[27],
  9007. slot_mapping_v2->offset[28],
  9008. slot_mapping_v2->offset[29],
  9009. slot_mapping_v2->offset[30],
  9010. slot_mapping_v2->offset[31]);
  9011. } else {
  9012. /*
  9013. * update slot mapping config param
  9014. * NOTE: channels/rate/bitwidth are per stream property
  9015. */
  9016. slot_mapping->bitwidth = dai_data->bitwidth;
  9017. pr_debug("%s: SLOT MAPPING:\n"
  9018. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  9019. __func__,
  9020. slot_mapping->num_channel,
  9021. slot_mapping->bitwidth,
  9022. slot_mapping->data_align_type);
  9023. pr_debug("%s: SLOT MAPPING:\n"
  9024. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  9025. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  9026. __func__,
  9027. slot_mapping->offset[0],
  9028. slot_mapping->offset[1],
  9029. slot_mapping->offset[2],
  9030. slot_mapping->offset[3],
  9031. slot_mapping->offset[4],
  9032. slot_mapping->offset[5],
  9033. slot_mapping->offset[6],
  9034. slot_mapping->offset[7]);
  9035. }
  9036. /*
  9037. * update custom header config param
  9038. * NOTE: channels/rate/bitwidth are per playback stream property.
  9039. * custom tdm header only applicable to playback stream.
  9040. */
  9041. if (custom_tdm_header->header_type !=
  9042. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  9043. pr_debug("%s: CUSTOM TDM HEADER:\n"
  9044. "start_offset=0x%x header_width=%d\n"
  9045. "num_frame_repeat=%d header_type=0x%x\n",
  9046. __func__,
  9047. custom_tdm_header->start_offset,
  9048. custom_tdm_header->header_width,
  9049. custom_tdm_header->num_frame_repeat,
  9050. custom_tdm_header->header_type);
  9051. pr_debug("%s: CUSTOM TDM HEADER:\n"
  9052. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  9053. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  9054. __func__,
  9055. custom_tdm_header->header[0],
  9056. custom_tdm_header->header[1],
  9057. custom_tdm_header->header[2],
  9058. custom_tdm_header->header[3],
  9059. custom_tdm_header->header[4],
  9060. custom_tdm_header->header[5],
  9061. custom_tdm_header->header[6],
  9062. custom_tdm_header->header[7]);
  9063. }
  9064. return 0;
  9065. }
  9066. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  9067. struct snd_soc_dai *dai)
  9068. {
  9069. int rc = 0;
  9070. struct msm_dai_q6_tdm_dai_data *dai_data =
  9071. dev_get_drvdata(dai->dev);
  9072. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  9073. int group_idx = 0;
  9074. atomic_t *group_ref = NULL;
  9075. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  9076. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  9077. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  9078. dev_dbg(dai->dev,
  9079. "%s: Custom tdm header not supported\n", __func__);
  9080. group_idx = msm_dai_q6_get_group_idx(dai->id);
  9081. if (group_idx < 0) {
  9082. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  9083. __func__, dai->id);
  9084. return -EINVAL;
  9085. }
  9086. mutex_lock(&tdm_mutex);
  9087. group_ref = &tdm_group_ref[group_idx];
  9088. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9089. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9090. /* TX and RX share the same clk. So enable the clk
  9091. * per TDM interface. */
  9092. rc = msm_dai_q6_tdm_set_clk(dai_data,
  9093. dai->id, true);
  9094. if (rc < 0) {
  9095. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  9096. __func__, dai->id);
  9097. goto rtn;
  9098. }
  9099. }
  9100. /* PORT START should be set if prepare called
  9101. * in active state.
  9102. */
  9103. if (atomic_read(group_ref) == 0) {
  9104. /*
  9105. * if only one port, don't do group enable as there
  9106. * is no group need for only one port
  9107. */
  9108. if (dai_data->num_group_ports > 1) {
  9109. rc = afe_port_group_enable(group_id,
  9110. &dai_data->group_cfg, true,
  9111. &dai_data->lane_cfg);
  9112. if (rc < 0) {
  9113. dev_err(dai->dev,
  9114. "%s: fail to enable AFE group 0x%x\n",
  9115. __func__, group_id);
  9116. goto rtn;
  9117. }
  9118. }
  9119. }
  9120. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  9121. dai_data->rate, dai_data->num_group_ports);
  9122. if (rc < 0) {
  9123. if (atomic_read(group_ref) == 0) {
  9124. afe_port_group_enable(group_id,
  9125. NULL, false, NULL);
  9126. }
  9127. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9128. msm_dai_q6_tdm_set_clk(dai_data,
  9129. dai->id, false);
  9130. }
  9131. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  9132. __func__, dai->id);
  9133. } else {
  9134. set_bit(STATUS_PORT_STARTED,
  9135. dai_data->status_mask);
  9136. atomic_inc(group_ref);
  9137. }
  9138. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  9139. /* NOTE: AFE should error out if HW resource contention */
  9140. }
  9141. rtn:
  9142. mutex_unlock(&tdm_mutex);
  9143. return rc;
  9144. }
  9145. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  9146. struct snd_soc_dai *dai)
  9147. {
  9148. int rc = 0;
  9149. struct msm_dai_q6_tdm_dai_data *dai_data =
  9150. dev_get_drvdata(dai->dev);
  9151. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  9152. int group_idx = 0;
  9153. atomic_t *group_ref = NULL;
  9154. group_idx = msm_dai_q6_get_group_idx(dai->id);
  9155. if (group_idx < 0) {
  9156. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  9157. __func__, dai->id);
  9158. return;
  9159. }
  9160. mutex_lock(&tdm_mutex);
  9161. group_ref = &tdm_group_ref[group_idx];
  9162. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  9163. rc = afe_close(dai->id);
  9164. if (rc < 0) {
  9165. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  9166. __func__, dai->id);
  9167. }
  9168. atomic_dec(group_ref);
  9169. clear_bit(STATUS_PORT_STARTED,
  9170. dai_data->status_mask);
  9171. if (atomic_read(group_ref) == 0) {
  9172. rc = afe_port_group_enable(group_id,
  9173. NULL, false, NULL);
  9174. if (rc < 0) {
  9175. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  9176. __func__, group_id);
  9177. }
  9178. }
  9179. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  9180. rc = msm_dai_q6_tdm_set_clk(dai_data,
  9181. dai->id, false);
  9182. if (rc < 0) {
  9183. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  9184. __func__, dai->id);
  9185. }
  9186. }
  9187. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  9188. /* NOTE: AFE should error out if HW resource contention */
  9189. }
  9190. mutex_unlock(&tdm_mutex);
  9191. }
  9192. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  9193. .prepare = msm_dai_q6_tdm_prepare,
  9194. .hw_params = msm_dai_q6_tdm_hw_params,
  9195. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  9196. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  9197. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  9198. .shutdown = msm_dai_q6_tdm_shutdown,
  9199. };
  9200. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  9201. {
  9202. .playback = {
  9203. .stream_name = "Primary TDM0 Playback",
  9204. .aif_name = "PRI_TDM_RX_0",
  9205. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9206. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9207. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9208. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9209. SNDRV_PCM_FMTBIT_S24_LE |
  9210. SNDRV_PCM_FMTBIT_S32_LE,
  9211. .channels_min = 1,
  9212. .channels_max = 16,
  9213. .rate_min = 8000,
  9214. .rate_max = 352800,
  9215. },
  9216. .name = "PRI_TDM_RX_0",
  9217. .ops = &msm_dai_q6_tdm_ops,
  9218. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  9219. .probe = msm_dai_q6_dai_tdm_probe,
  9220. .remove = msm_dai_q6_dai_tdm_remove,
  9221. },
  9222. {
  9223. .playback = {
  9224. .stream_name = "Primary TDM1 Playback",
  9225. .aif_name = "PRI_TDM_RX_1",
  9226. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9227. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9228. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9229. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9230. SNDRV_PCM_FMTBIT_S24_LE |
  9231. SNDRV_PCM_FMTBIT_S32_LE,
  9232. .channels_min = 1,
  9233. .channels_max = 16,
  9234. .rate_min = 8000,
  9235. .rate_max = 352800,
  9236. },
  9237. .name = "PRI_TDM_RX_1",
  9238. .ops = &msm_dai_q6_tdm_ops,
  9239. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  9240. .probe = msm_dai_q6_dai_tdm_probe,
  9241. .remove = msm_dai_q6_dai_tdm_remove,
  9242. },
  9243. {
  9244. .playback = {
  9245. .stream_name = "Primary TDM2 Playback",
  9246. .aif_name = "PRI_TDM_RX_2",
  9247. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9248. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9249. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9250. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9251. SNDRV_PCM_FMTBIT_S24_LE |
  9252. SNDRV_PCM_FMTBIT_S32_LE,
  9253. .channels_min = 1,
  9254. .channels_max = 16,
  9255. .rate_min = 8000,
  9256. .rate_max = 352800,
  9257. },
  9258. .name = "PRI_TDM_RX_2",
  9259. .ops = &msm_dai_q6_tdm_ops,
  9260. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  9261. .probe = msm_dai_q6_dai_tdm_probe,
  9262. .remove = msm_dai_q6_dai_tdm_remove,
  9263. },
  9264. {
  9265. .playback = {
  9266. .stream_name = "Primary TDM3 Playback",
  9267. .aif_name = "PRI_TDM_RX_3",
  9268. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9269. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9270. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9271. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9272. SNDRV_PCM_FMTBIT_S24_LE |
  9273. SNDRV_PCM_FMTBIT_S32_LE,
  9274. .channels_min = 1,
  9275. .channels_max = 16,
  9276. .rate_min = 8000,
  9277. .rate_max = 352800,
  9278. },
  9279. .name = "PRI_TDM_RX_3",
  9280. .ops = &msm_dai_q6_tdm_ops,
  9281. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  9282. .probe = msm_dai_q6_dai_tdm_probe,
  9283. .remove = msm_dai_q6_dai_tdm_remove,
  9284. },
  9285. {
  9286. .playback = {
  9287. .stream_name = "Primary TDM4 Playback",
  9288. .aif_name = "PRI_TDM_RX_4",
  9289. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9290. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9291. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9292. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9293. SNDRV_PCM_FMTBIT_S24_LE |
  9294. SNDRV_PCM_FMTBIT_S32_LE,
  9295. .channels_min = 1,
  9296. .channels_max = 16,
  9297. .rate_min = 8000,
  9298. .rate_max = 352800,
  9299. },
  9300. .name = "PRI_TDM_RX_4",
  9301. .ops = &msm_dai_q6_tdm_ops,
  9302. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  9303. .probe = msm_dai_q6_dai_tdm_probe,
  9304. .remove = msm_dai_q6_dai_tdm_remove,
  9305. },
  9306. {
  9307. .playback = {
  9308. .stream_name = "Primary TDM5 Playback",
  9309. .aif_name = "PRI_TDM_RX_5",
  9310. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9311. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9312. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9313. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9314. SNDRV_PCM_FMTBIT_S24_LE |
  9315. SNDRV_PCM_FMTBIT_S32_LE,
  9316. .channels_min = 1,
  9317. .channels_max = 16,
  9318. .rate_min = 8000,
  9319. .rate_max = 352800,
  9320. },
  9321. .name = "PRI_TDM_RX_5",
  9322. .ops = &msm_dai_q6_tdm_ops,
  9323. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  9324. .probe = msm_dai_q6_dai_tdm_probe,
  9325. .remove = msm_dai_q6_dai_tdm_remove,
  9326. },
  9327. {
  9328. .playback = {
  9329. .stream_name = "Primary TDM6 Playback",
  9330. .aif_name = "PRI_TDM_RX_6",
  9331. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9332. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9333. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9334. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9335. SNDRV_PCM_FMTBIT_S24_LE |
  9336. SNDRV_PCM_FMTBIT_S32_LE,
  9337. .channels_min = 1,
  9338. .channels_max = 16,
  9339. .rate_min = 8000,
  9340. .rate_max = 352800,
  9341. },
  9342. .name = "PRI_TDM_RX_6",
  9343. .ops = &msm_dai_q6_tdm_ops,
  9344. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  9345. .probe = msm_dai_q6_dai_tdm_probe,
  9346. .remove = msm_dai_q6_dai_tdm_remove,
  9347. },
  9348. {
  9349. .playback = {
  9350. .stream_name = "Primary TDM7 Playback",
  9351. .aif_name = "PRI_TDM_RX_7",
  9352. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9353. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9354. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9355. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9356. SNDRV_PCM_FMTBIT_S24_LE |
  9357. SNDRV_PCM_FMTBIT_S32_LE,
  9358. .channels_min = 1,
  9359. .channels_max = 16,
  9360. .rate_min = 8000,
  9361. .rate_max = 352800,
  9362. },
  9363. .name = "PRI_TDM_RX_7",
  9364. .ops = &msm_dai_q6_tdm_ops,
  9365. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  9366. .probe = msm_dai_q6_dai_tdm_probe,
  9367. .remove = msm_dai_q6_dai_tdm_remove,
  9368. },
  9369. {
  9370. .capture = {
  9371. .stream_name = "Primary TDM0 Capture",
  9372. .aif_name = "PRI_TDM_TX_0",
  9373. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9374. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9375. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9376. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9377. SNDRV_PCM_FMTBIT_S24_LE |
  9378. SNDRV_PCM_FMTBIT_S32_LE,
  9379. .channels_min = 1,
  9380. .channels_max = 16,
  9381. .rate_min = 8000,
  9382. .rate_max = 352800,
  9383. },
  9384. .name = "PRI_TDM_TX_0",
  9385. .ops = &msm_dai_q6_tdm_ops,
  9386. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  9387. .probe = msm_dai_q6_dai_tdm_probe,
  9388. .remove = msm_dai_q6_dai_tdm_remove,
  9389. },
  9390. {
  9391. .capture = {
  9392. .stream_name = "Primary TDM1 Capture",
  9393. .aif_name = "PRI_TDM_TX_1",
  9394. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9395. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9396. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9397. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9398. SNDRV_PCM_FMTBIT_S24_LE |
  9399. SNDRV_PCM_FMTBIT_S32_LE,
  9400. .channels_min = 1,
  9401. .channels_max = 16,
  9402. .rate_min = 8000,
  9403. .rate_max = 352800,
  9404. },
  9405. .name = "PRI_TDM_TX_1",
  9406. .ops = &msm_dai_q6_tdm_ops,
  9407. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  9408. .probe = msm_dai_q6_dai_tdm_probe,
  9409. .remove = msm_dai_q6_dai_tdm_remove,
  9410. },
  9411. {
  9412. .capture = {
  9413. .stream_name = "Primary TDM2 Capture",
  9414. .aif_name = "PRI_TDM_TX_2",
  9415. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9416. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9417. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9418. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9419. SNDRV_PCM_FMTBIT_S24_LE |
  9420. SNDRV_PCM_FMTBIT_S32_LE,
  9421. .channels_min = 1,
  9422. .channels_max = 16,
  9423. .rate_min = 8000,
  9424. .rate_max = 352800,
  9425. },
  9426. .name = "PRI_TDM_TX_2",
  9427. .ops = &msm_dai_q6_tdm_ops,
  9428. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  9429. .probe = msm_dai_q6_dai_tdm_probe,
  9430. .remove = msm_dai_q6_dai_tdm_remove,
  9431. },
  9432. {
  9433. .capture = {
  9434. .stream_name = "Primary TDM3 Capture",
  9435. .aif_name = "PRI_TDM_TX_3",
  9436. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9437. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9438. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9439. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9440. SNDRV_PCM_FMTBIT_S24_LE |
  9441. SNDRV_PCM_FMTBIT_S32_LE,
  9442. .channels_min = 1,
  9443. .channels_max = 16,
  9444. .rate_min = 8000,
  9445. .rate_max = 352800,
  9446. },
  9447. .name = "PRI_TDM_TX_3",
  9448. .ops = &msm_dai_q6_tdm_ops,
  9449. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  9450. .probe = msm_dai_q6_dai_tdm_probe,
  9451. .remove = msm_dai_q6_dai_tdm_remove,
  9452. },
  9453. {
  9454. .capture = {
  9455. .stream_name = "Primary TDM4 Capture",
  9456. .aif_name = "PRI_TDM_TX_4",
  9457. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9458. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9459. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9460. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9461. SNDRV_PCM_FMTBIT_S24_LE |
  9462. SNDRV_PCM_FMTBIT_S32_LE,
  9463. .channels_min = 1,
  9464. .channels_max = 16,
  9465. .rate_min = 8000,
  9466. .rate_max = 352800,
  9467. },
  9468. .name = "PRI_TDM_TX_4",
  9469. .ops = &msm_dai_q6_tdm_ops,
  9470. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  9471. .probe = msm_dai_q6_dai_tdm_probe,
  9472. .remove = msm_dai_q6_dai_tdm_remove,
  9473. },
  9474. {
  9475. .capture = {
  9476. .stream_name = "Primary TDM5 Capture",
  9477. .aif_name = "PRI_TDM_TX_5",
  9478. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9479. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9480. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9481. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9482. SNDRV_PCM_FMTBIT_S24_LE |
  9483. SNDRV_PCM_FMTBIT_S32_LE,
  9484. .channels_min = 1,
  9485. .channels_max = 16,
  9486. .rate_min = 8000,
  9487. .rate_max = 352800,
  9488. },
  9489. .name = "PRI_TDM_TX_5",
  9490. .ops = &msm_dai_q6_tdm_ops,
  9491. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  9492. .probe = msm_dai_q6_dai_tdm_probe,
  9493. .remove = msm_dai_q6_dai_tdm_remove,
  9494. },
  9495. {
  9496. .capture = {
  9497. .stream_name = "Primary TDM6 Capture",
  9498. .aif_name = "PRI_TDM_TX_6",
  9499. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9500. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9501. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9502. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9503. SNDRV_PCM_FMTBIT_S24_LE |
  9504. SNDRV_PCM_FMTBIT_S32_LE,
  9505. .channels_min = 1,
  9506. .channels_max = 16,
  9507. .rate_min = 8000,
  9508. .rate_max = 352800,
  9509. },
  9510. .name = "PRI_TDM_TX_6",
  9511. .ops = &msm_dai_q6_tdm_ops,
  9512. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  9513. .probe = msm_dai_q6_dai_tdm_probe,
  9514. .remove = msm_dai_q6_dai_tdm_remove,
  9515. },
  9516. {
  9517. .capture = {
  9518. .stream_name = "Primary TDM7 Capture",
  9519. .aif_name = "PRI_TDM_TX_7",
  9520. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9521. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9522. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9523. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9524. SNDRV_PCM_FMTBIT_S24_LE |
  9525. SNDRV_PCM_FMTBIT_S32_LE,
  9526. .channels_min = 1,
  9527. .channels_max = 16,
  9528. .rate_min = 8000,
  9529. .rate_max = 352800,
  9530. },
  9531. .name = "PRI_TDM_TX_7",
  9532. .ops = &msm_dai_q6_tdm_ops,
  9533. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  9534. .probe = msm_dai_q6_dai_tdm_probe,
  9535. .remove = msm_dai_q6_dai_tdm_remove,
  9536. },
  9537. {
  9538. .playback = {
  9539. .stream_name = "Secondary TDM0 Playback",
  9540. .aif_name = "SEC_TDM_RX_0",
  9541. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9542. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9543. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9544. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9545. SNDRV_PCM_FMTBIT_S24_LE |
  9546. SNDRV_PCM_FMTBIT_S32_LE,
  9547. .channels_min = 1,
  9548. .channels_max = 16,
  9549. .rate_min = 8000,
  9550. .rate_max = 352800,
  9551. },
  9552. .name = "SEC_TDM_RX_0",
  9553. .ops = &msm_dai_q6_tdm_ops,
  9554. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  9555. .probe = msm_dai_q6_dai_tdm_probe,
  9556. .remove = msm_dai_q6_dai_tdm_remove,
  9557. },
  9558. {
  9559. .playback = {
  9560. .stream_name = "Secondary TDM1 Playback",
  9561. .aif_name = "SEC_TDM_RX_1",
  9562. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9563. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9564. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9565. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9566. SNDRV_PCM_FMTBIT_S24_LE |
  9567. SNDRV_PCM_FMTBIT_S32_LE,
  9568. .channels_min = 1,
  9569. .channels_max = 16,
  9570. .rate_min = 8000,
  9571. .rate_max = 352800,
  9572. },
  9573. .name = "SEC_TDM_RX_1",
  9574. .ops = &msm_dai_q6_tdm_ops,
  9575. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  9576. .probe = msm_dai_q6_dai_tdm_probe,
  9577. .remove = msm_dai_q6_dai_tdm_remove,
  9578. },
  9579. {
  9580. .playback = {
  9581. .stream_name = "Secondary TDM2 Playback",
  9582. .aif_name = "SEC_TDM_RX_2",
  9583. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9584. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9585. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9586. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9587. SNDRV_PCM_FMTBIT_S24_LE |
  9588. SNDRV_PCM_FMTBIT_S32_LE,
  9589. .channels_min = 1,
  9590. .channels_max = 16,
  9591. .rate_min = 8000,
  9592. .rate_max = 352800,
  9593. },
  9594. .name = "SEC_TDM_RX_2",
  9595. .ops = &msm_dai_q6_tdm_ops,
  9596. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  9597. .probe = msm_dai_q6_dai_tdm_probe,
  9598. .remove = msm_dai_q6_dai_tdm_remove,
  9599. },
  9600. {
  9601. .playback = {
  9602. .stream_name = "Secondary TDM3 Playback",
  9603. .aif_name = "SEC_TDM_RX_3",
  9604. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9605. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9606. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9607. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9608. SNDRV_PCM_FMTBIT_S24_LE |
  9609. SNDRV_PCM_FMTBIT_S32_LE,
  9610. .channels_min = 1,
  9611. .channels_max = 16,
  9612. .rate_min = 8000,
  9613. .rate_max = 352800,
  9614. },
  9615. .name = "SEC_TDM_RX_3",
  9616. .ops = &msm_dai_q6_tdm_ops,
  9617. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  9618. .probe = msm_dai_q6_dai_tdm_probe,
  9619. .remove = msm_dai_q6_dai_tdm_remove,
  9620. },
  9621. {
  9622. .playback = {
  9623. .stream_name = "Secondary TDM4 Playback",
  9624. .aif_name = "SEC_TDM_RX_4",
  9625. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9626. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9627. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9628. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9629. SNDRV_PCM_FMTBIT_S24_LE |
  9630. SNDRV_PCM_FMTBIT_S32_LE,
  9631. .channels_min = 1,
  9632. .channels_max = 16,
  9633. .rate_min = 8000,
  9634. .rate_max = 352800,
  9635. },
  9636. .name = "SEC_TDM_RX_4",
  9637. .ops = &msm_dai_q6_tdm_ops,
  9638. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  9639. .probe = msm_dai_q6_dai_tdm_probe,
  9640. .remove = msm_dai_q6_dai_tdm_remove,
  9641. },
  9642. {
  9643. .playback = {
  9644. .stream_name = "Secondary TDM5 Playback",
  9645. .aif_name = "SEC_TDM_RX_5",
  9646. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9647. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9648. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9649. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9650. SNDRV_PCM_FMTBIT_S24_LE |
  9651. SNDRV_PCM_FMTBIT_S32_LE,
  9652. .channels_min = 1,
  9653. .channels_max = 16,
  9654. .rate_min = 8000,
  9655. .rate_max = 352800,
  9656. },
  9657. .name = "SEC_TDM_RX_5",
  9658. .ops = &msm_dai_q6_tdm_ops,
  9659. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  9660. .probe = msm_dai_q6_dai_tdm_probe,
  9661. .remove = msm_dai_q6_dai_tdm_remove,
  9662. },
  9663. {
  9664. .playback = {
  9665. .stream_name = "Secondary TDM6 Playback",
  9666. .aif_name = "SEC_TDM_RX_6",
  9667. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9668. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9669. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9670. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9671. SNDRV_PCM_FMTBIT_S24_LE |
  9672. SNDRV_PCM_FMTBIT_S32_LE,
  9673. .channels_min = 1,
  9674. .channels_max = 16,
  9675. .rate_min = 8000,
  9676. .rate_max = 352800,
  9677. },
  9678. .name = "SEC_TDM_RX_6",
  9679. .ops = &msm_dai_q6_tdm_ops,
  9680. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  9681. .probe = msm_dai_q6_dai_tdm_probe,
  9682. .remove = msm_dai_q6_dai_tdm_remove,
  9683. },
  9684. {
  9685. .playback = {
  9686. .stream_name = "Secondary TDM7 Playback",
  9687. .aif_name = "SEC_TDM_RX_7",
  9688. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9689. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9690. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9691. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9692. SNDRV_PCM_FMTBIT_S24_LE |
  9693. SNDRV_PCM_FMTBIT_S32_LE,
  9694. .channels_min = 1,
  9695. .channels_max = 16,
  9696. .rate_min = 8000,
  9697. .rate_max = 352800,
  9698. },
  9699. .name = "SEC_TDM_RX_7",
  9700. .ops = &msm_dai_q6_tdm_ops,
  9701. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  9702. .probe = msm_dai_q6_dai_tdm_probe,
  9703. .remove = msm_dai_q6_dai_tdm_remove,
  9704. },
  9705. {
  9706. .capture = {
  9707. .stream_name = "Secondary TDM0 Capture",
  9708. .aif_name = "SEC_TDM_TX_0",
  9709. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9710. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9711. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9712. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9713. SNDRV_PCM_FMTBIT_S24_LE |
  9714. SNDRV_PCM_FMTBIT_S32_LE,
  9715. .channels_min = 1,
  9716. .channels_max = 16,
  9717. .rate_min = 8000,
  9718. .rate_max = 352800,
  9719. },
  9720. .name = "SEC_TDM_TX_0",
  9721. .ops = &msm_dai_q6_tdm_ops,
  9722. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  9723. .probe = msm_dai_q6_dai_tdm_probe,
  9724. .remove = msm_dai_q6_dai_tdm_remove,
  9725. },
  9726. {
  9727. .capture = {
  9728. .stream_name = "Secondary TDM1 Capture",
  9729. .aif_name = "SEC_TDM_TX_1",
  9730. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9731. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9732. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9733. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9734. SNDRV_PCM_FMTBIT_S24_LE |
  9735. SNDRV_PCM_FMTBIT_S32_LE,
  9736. .channels_min = 1,
  9737. .channels_max = 16,
  9738. .rate_min = 8000,
  9739. .rate_max = 352800,
  9740. },
  9741. .name = "SEC_TDM_TX_1",
  9742. .ops = &msm_dai_q6_tdm_ops,
  9743. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  9744. .probe = msm_dai_q6_dai_tdm_probe,
  9745. .remove = msm_dai_q6_dai_tdm_remove,
  9746. },
  9747. {
  9748. .capture = {
  9749. .stream_name = "Secondary TDM2 Capture",
  9750. .aif_name = "SEC_TDM_TX_2",
  9751. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9752. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9753. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9754. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9755. SNDRV_PCM_FMTBIT_S24_LE |
  9756. SNDRV_PCM_FMTBIT_S32_LE,
  9757. .channels_min = 1,
  9758. .channels_max = 16,
  9759. .rate_min = 8000,
  9760. .rate_max = 352800,
  9761. },
  9762. .name = "SEC_TDM_TX_2",
  9763. .ops = &msm_dai_q6_tdm_ops,
  9764. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  9765. .probe = msm_dai_q6_dai_tdm_probe,
  9766. .remove = msm_dai_q6_dai_tdm_remove,
  9767. },
  9768. {
  9769. .capture = {
  9770. .stream_name = "Secondary TDM3 Capture",
  9771. .aif_name = "SEC_TDM_TX_3",
  9772. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9773. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9774. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9775. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9776. SNDRV_PCM_FMTBIT_S24_LE |
  9777. SNDRV_PCM_FMTBIT_S32_LE,
  9778. .channels_min = 1,
  9779. .channels_max = 16,
  9780. .rate_min = 8000,
  9781. .rate_max = 352800,
  9782. },
  9783. .name = "SEC_TDM_TX_3",
  9784. .ops = &msm_dai_q6_tdm_ops,
  9785. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  9786. .probe = msm_dai_q6_dai_tdm_probe,
  9787. .remove = msm_dai_q6_dai_tdm_remove,
  9788. },
  9789. {
  9790. .capture = {
  9791. .stream_name = "Secondary TDM4 Capture",
  9792. .aif_name = "SEC_TDM_TX_4",
  9793. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9794. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9795. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9796. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9797. SNDRV_PCM_FMTBIT_S24_LE |
  9798. SNDRV_PCM_FMTBIT_S32_LE,
  9799. .channels_min = 1,
  9800. .channels_max = 16,
  9801. .rate_min = 8000,
  9802. .rate_max = 352800,
  9803. },
  9804. .name = "SEC_TDM_TX_4",
  9805. .ops = &msm_dai_q6_tdm_ops,
  9806. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  9807. .probe = msm_dai_q6_dai_tdm_probe,
  9808. .remove = msm_dai_q6_dai_tdm_remove,
  9809. },
  9810. {
  9811. .capture = {
  9812. .stream_name = "Secondary TDM5 Capture",
  9813. .aif_name = "SEC_TDM_TX_5",
  9814. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9815. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9816. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9817. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9818. SNDRV_PCM_FMTBIT_S24_LE |
  9819. SNDRV_PCM_FMTBIT_S32_LE,
  9820. .channels_min = 1,
  9821. .channels_max = 16,
  9822. .rate_min = 8000,
  9823. .rate_max = 352800,
  9824. },
  9825. .name = "SEC_TDM_TX_5",
  9826. .ops = &msm_dai_q6_tdm_ops,
  9827. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  9828. .probe = msm_dai_q6_dai_tdm_probe,
  9829. .remove = msm_dai_q6_dai_tdm_remove,
  9830. },
  9831. {
  9832. .capture = {
  9833. .stream_name = "Secondary TDM6 Capture",
  9834. .aif_name = "SEC_TDM_TX_6",
  9835. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9836. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9837. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9838. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9839. SNDRV_PCM_FMTBIT_S24_LE |
  9840. SNDRV_PCM_FMTBIT_S32_LE,
  9841. .channels_min = 1,
  9842. .channels_max = 16,
  9843. .rate_min = 8000,
  9844. .rate_max = 352800,
  9845. },
  9846. .name = "SEC_TDM_TX_6",
  9847. .ops = &msm_dai_q6_tdm_ops,
  9848. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  9849. .probe = msm_dai_q6_dai_tdm_probe,
  9850. .remove = msm_dai_q6_dai_tdm_remove,
  9851. },
  9852. {
  9853. .capture = {
  9854. .stream_name = "Secondary TDM7 Capture",
  9855. .aif_name = "SEC_TDM_TX_7",
  9856. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9857. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9858. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9859. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9860. SNDRV_PCM_FMTBIT_S24_LE |
  9861. SNDRV_PCM_FMTBIT_S32_LE,
  9862. .channels_min = 1,
  9863. .channels_max = 16,
  9864. .rate_min = 8000,
  9865. .rate_max = 352800,
  9866. },
  9867. .name = "SEC_TDM_TX_7",
  9868. .ops = &msm_dai_q6_tdm_ops,
  9869. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  9870. .probe = msm_dai_q6_dai_tdm_probe,
  9871. .remove = msm_dai_q6_dai_tdm_remove,
  9872. },
  9873. {
  9874. .playback = {
  9875. .stream_name = "Tertiary TDM0 Playback",
  9876. .aif_name = "TERT_TDM_RX_0",
  9877. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9878. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9879. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9880. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9881. SNDRV_PCM_FMTBIT_S24_LE |
  9882. SNDRV_PCM_FMTBIT_S32_LE,
  9883. .channels_min = 1,
  9884. .channels_max = 16,
  9885. .rate_min = 8000,
  9886. .rate_max = 352800,
  9887. },
  9888. .name = "TERT_TDM_RX_0",
  9889. .ops = &msm_dai_q6_tdm_ops,
  9890. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  9891. .probe = msm_dai_q6_dai_tdm_probe,
  9892. .remove = msm_dai_q6_dai_tdm_remove,
  9893. },
  9894. {
  9895. .playback = {
  9896. .stream_name = "Tertiary TDM1 Playback",
  9897. .aif_name = "TERT_TDM_RX_1",
  9898. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9899. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9900. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9901. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9902. SNDRV_PCM_FMTBIT_S24_LE |
  9903. SNDRV_PCM_FMTBIT_S32_LE,
  9904. .channels_min = 1,
  9905. .channels_max = 16,
  9906. .rate_min = 8000,
  9907. .rate_max = 352800,
  9908. },
  9909. .name = "TERT_TDM_RX_1",
  9910. .ops = &msm_dai_q6_tdm_ops,
  9911. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  9912. .probe = msm_dai_q6_dai_tdm_probe,
  9913. .remove = msm_dai_q6_dai_tdm_remove,
  9914. },
  9915. {
  9916. .playback = {
  9917. .stream_name = "Tertiary TDM2 Playback",
  9918. .aif_name = "TERT_TDM_RX_2",
  9919. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9920. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9921. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9922. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9923. SNDRV_PCM_FMTBIT_S24_LE |
  9924. SNDRV_PCM_FMTBIT_S32_LE,
  9925. .channels_min = 1,
  9926. .channels_max = 16,
  9927. .rate_min = 8000,
  9928. .rate_max = 352800,
  9929. },
  9930. .name = "TERT_TDM_RX_2",
  9931. .ops = &msm_dai_q6_tdm_ops,
  9932. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  9933. .probe = msm_dai_q6_dai_tdm_probe,
  9934. .remove = msm_dai_q6_dai_tdm_remove,
  9935. },
  9936. {
  9937. .playback = {
  9938. .stream_name = "Tertiary TDM3 Playback",
  9939. .aif_name = "TERT_TDM_RX_3",
  9940. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9941. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9942. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9943. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9944. SNDRV_PCM_FMTBIT_S24_LE |
  9945. SNDRV_PCM_FMTBIT_S32_LE,
  9946. .channels_min = 1,
  9947. .channels_max = 16,
  9948. .rate_min = 8000,
  9949. .rate_max = 352800,
  9950. },
  9951. .name = "TERT_TDM_RX_3",
  9952. .ops = &msm_dai_q6_tdm_ops,
  9953. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  9954. .probe = msm_dai_q6_dai_tdm_probe,
  9955. .remove = msm_dai_q6_dai_tdm_remove,
  9956. },
  9957. {
  9958. .playback = {
  9959. .stream_name = "Tertiary TDM4 Playback",
  9960. .aif_name = "TERT_TDM_RX_4",
  9961. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9962. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9963. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9964. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9965. SNDRV_PCM_FMTBIT_S24_LE |
  9966. SNDRV_PCM_FMTBIT_S32_LE,
  9967. .channels_min = 1,
  9968. .channels_max = 16,
  9969. .rate_min = 8000,
  9970. .rate_max = 352800,
  9971. },
  9972. .name = "TERT_TDM_RX_4",
  9973. .ops = &msm_dai_q6_tdm_ops,
  9974. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  9975. .probe = msm_dai_q6_dai_tdm_probe,
  9976. .remove = msm_dai_q6_dai_tdm_remove,
  9977. },
  9978. {
  9979. .playback = {
  9980. .stream_name = "Tertiary TDM5 Playback",
  9981. .aif_name = "TERT_TDM_RX_5",
  9982. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9983. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9984. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9985. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9986. SNDRV_PCM_FMTBIT_S24_LE |
  9987. SNDRV_PCM_FMTBIT_S32_LE,
  9988. .channels_min = 1,
  9989. .channels_max = 16,
  9990. .rate_min = 8000,
  9991. .rate_max = 352800,
  9992. },
  9993. .name = "TERT_TDM_RX_5",
  9994. .ops = &msm_dai_q6_tdm_ops,
  9995. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  9996. .probe = msm_dai_q6_dai_tdm_probe,
  9997. .remove = msm_dai_q6_dai_tdm_remove,
  9998. },
  9999. {
  10000. .playback = {
  10001. .stream_name = "Tertiary TDM6 Playback",
  10002. .aif_name = "TERT_TDM_RX_6",
  10003. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10004. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10005. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10006. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10007. SNDRV_PCM_FMTBIT_S24_LE |
  10008. SNDRV_PCM_FMTBIT_S32_LE,
  10009. .channels_min = 1,
  10010. .channels_max = 16,
  10011. .rate_min = 8000,
  10012. .rate_max = 352800,
  10013. },
  10014. .name = "TERT_TDM_RX_6",
  10015. .ops = &msm_dai_q6_tdm_ops,
  10016. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  10017. .probe = msm_dai_q6_dai_tdm_probe,
  10018. .remove = msm_dai_q6_dai_tdm_remove,
  10019. },
  10020. {
  10021. .playback = {
  10022. .stream_name = "Tertiary TDM7 Playback",
  10023. .aif_name = "TERT_TDM_RX_7",
  10024. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10025. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10026. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10027. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10028. SNDRV_PCM_FMTBIT_S24_LE |
  10029. SNDRV_PCM_FMTBIT_S32_LE,
  10030. .channels_min = 1,
  10031. .channels_max = 16,
  10032. .rate_min = 8000,
  10033. .rate_max = 352800,
  10034. },
  10035. .name = "TERT_TDM_RX_7",
  10036. .ops = &msm_dai_q6_tdm_ops,
  10037. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  10038. .probe = msm_dai_q6_dai_tdm_probe,
  10039. .remove = msm_dai_q6_dai_tdm_remove,
  10040. },
  10041. {
  10042. .capture = {
  10043. .stream_name = "Tertiary TDM0 Capture",
  10044. .aif_name = "TERT_TDM_TX_0",
  10045. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10046. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10047. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10048. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10049. SNDRV_PCM_FMTBIT_S24_LE |
  10050. SNDRV_PCM_FMTBIT_S32_LE,
  10051. .channels_min = 1,
  10052. .channels_max = 16,
  10053. .rate_min = 8000,
  10054. .rate_max = 352800,
  10055. },
  10056. .name = "TERT_TDM_TX_0",
  10057. .ops = &msm_dai_q6_tdm_ops,
  10058. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  10059. .probe = msm_dai_q6_dai_tdm_probe,
  10060. .remove = msm_dai_q6_dai_tdm_remove,
  10061. },
  10062. {
  10063. .capture = {
  10064. .stream_name = "Tertiary TDM1 Capture",
  10065. .aif_name = "TERT_TDM_TX_1",
  10066. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10067. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10068. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10069. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10070. SNDRV_PCM_FMTBIT_S24_LE |
  10071. SNDRV_PCM_FMTBIT_S32_LE,
  10072. .channels_min = 1,
  10073. .channels_max = 16,
  10074. .rate_min = 8000,
  10075. .rate_max = 352800,
  10076. },
  10077. .name = "TERT_TDM_TX_1",
  10078. .ops = &msm_dai_q6_tdm_ops,
  10079. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  10080. .probe = msm_dai_q6_dai_tdm_probe,
  10081. .remove = msm_dai_q6_dai_tdm_remove,
  10082. },
  10083. {
  10084. .capture = {
  10085. .stream_name = "Tertiary TDM2 Capture",
  10086. .aif_name = "TERT_TDM_TX_2",
  10087. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10088. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10089. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10090. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10091. SNDRV_PCM_FMTBIT_S24_LE |
  10092. SNDRV_PCM_FMTBIT_S32_LE,
  10093. .channels_min = 1,
  10094. .channels_max = 16,
  10095. .rate_min = 8000,
  10096. .rate_max = 352800,
  10097. },
  10098. .name = "TERT_TDM_TX_2",
  10099. .ops = &msm_dai_q6_tdm_ops,
  10100. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  10101. .probe = msm_dai_q6_dai_tdm_probe,
  10102. .remove = msm_dai_q6_dai_tdm_remove,
  10103. },
  10104. {
  10105. .capture = {
  10106. .stream_name = "Tertiary TDM3 Capture",
  10107. .aif_name = "TERT_TDM_TX_3",
  10108. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10109. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10110. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10111. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10112. SNDRV_PCM_FMTBIT_S24_LE |
  10113. SNDRV_PCM_FMTBIT_S32_LE,
  10114. .channels_min = 1,
  10115. .channels_max = 16,
  10116. .rate_min = 8000,
  10117. .rate_max = 352800,
  10118. },
  10119. .name = "TERT_TDM_TX_3",
  10120. .ops = &msm_dai_q6_tdm_ops,
  10121. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  10122. .probe = msm_dai_q6_dai_tdm_probe,
  10123. .remove = msm_dai_q6_dai_tdm_remove,
  10124. },
  10125. {
  10126. .capture = {
  10127. .stream_name = "Tertiary TDM4 Capture",
  10128. .aif_name = "TERT_TDM_TX_4",
  10129. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10130. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10131. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10132. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10133. SNDRV_PCM_FMTBIT_S24_LE |
  10134. SNDRV_PCM_FMTBIT_S32_LE,
  10135. .channels_min = 1,
  10136. .channels_max = 16,
  10137. .rate_min = 8000,
  10138. .rate_max = 352800,
  10139. },
  10140. .name = "TERT_TDM_TX_4",
  10141. .ops = &msm_dai_q6_tdm_ops,
  10142. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  10143. .probe = msm_dai_q6_dai_tdm_probe,
  10144. .remove = msm_dai_q6_dai_tdm_remove,
  10145. },
  10146. {
  10147. .capture = {
  10148. .stream_name = "Tertiary TDM5 Capture",
  10149. .aif_name = "TERT_TDM_TX_5",
  10150. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10151. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10152. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10153. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10154. SNDRV_PCM_FMTBIT_S24_LE |
  10155. SNDRV_PCM_FMTBIT_S32_LE,
  10156. .channels_min = 1,
  10157. .channels_max = 16,
  10158. .rate_min = 8000,
  10159. .rate_max = 352800,
  10160. },
  10161. .name = "TERT_TDM_TX_5",
  10162. .ops = &msm_dai_q6_tdm_ops,
  10163. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  10164. .probe = msm_dai_q6_dai_tdm_probe,
  10165. .remove = msm_dai_q6_dai_tdm_remove,
  10166. },
  10167. {
  10168. .capture = {
  10169. .stream_name = "Tertiary TDM6 Capture",
  10170. .aif_name = "TERT_TDM_TX_6",
  10171. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10172. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10173. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10174. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10175. SNDRV_PCM_FMTBIT_S24_LE |
  10176. SNDRV_PCM_FMTBIT_S32_LE,
  10177. .channels_min = 1,
  10178. .channels_max = 16,
  10179. .rate_min = 8000,
  10180. .rate_max = 352800,
  10181. },
  10182. .name = "TERT_TDM_TX_6",
  10183. .ops = &msm_dai_q6_tdm_ops,
  10184. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  10185. .probe = msm_dai_q6_dai_tdm_probe,
  10186. .remove = msm_dai_q6_dai_tdm_remove,
  10187. },
  10188. {
  10189. .capture = {
  10190. .stream_name = "Tertiary TDM7 Capture",
  10191. .aif_name = "TERT_TDM_TX_7",
  10192. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10193. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10194. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10195. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10196. SNDRV_PCM_FMTBIT_S24_LE |
  10197. SNDRV_PCM_FMTBIT_S32_LE,
  10198. .channels_min = 1,
  10199. .channels_max = 16,
  10200. .rate_min = 8000,
  10201. .rate_max = 352800,
  10202. },
  10203. .name = "TERT_TDM_TX_7",
  10204. .ops = &msm_dai_q6_tdm_ops,
  10205. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  10206. .probe = msm_dai_q6_dai_tdm_probe,
  10207. .remove = msm_dai_q6_dai_tdm_remove,
  10208. },
  10209. {
  10210. .playback = {
  10211. .stream_name = "Quaternary TDM0 Playback",
  10212. .aif_name = "QUAT_TDM_RX_0",
  10213. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10214. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10215. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10216. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10217. SNDRV_PCM_FMTBIT_S24_LE |
  10218. SNDRV_PCM_FMTBIT_S32_LE,
  10219. .channels_min = 1,
  10220. .channels_max = 16,
  10221. .rate_min = 8000,
  10222. .rate_max = 352800,
  10223. },
  10224. .name = "QUAT_TDM_RX_0",
  10225. .ops = &msm_dai_q6_tdm_ops,
  10226. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  10227. .probe = msm_dai_q6_dai_tdm_probe,
  10228. .remove = msm_dai_q6_dai_tdm_remove,
  10229. },
  10230. {
  10231. .playback = {
  10232. .stream_name = "Quaternary TDM1 Playback",
  10233. .aif_name = "QUAT_TDM_RX_1",
  10234. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10235. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10236. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10237. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10238. SNDRV_PCM_FMTBIT_S24_LE |
  10239. SNDRV_PCM_FMTBIT_S32_LE,
  10240. .channels_min = 1,
  10241. .channels_max = 16,
  10242. .rate_min = 8000,
  10243. .rate_max = 352800,
  10244. },
  10245. .name = "QUAT_TDM_RX_1",
  10246. .ops = &msm_dai_q6_tdm_ops,
  10247. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  10248. .probe = msm_dai_q6_dai_tdm_probe,
  10249. .remove = msm_dai_q6_dai_tdm_remove,
  10250. },
  10251. {
  10252. .playback = {
  10253. .stream_name = "Quaternary TDM2 Playback",
  10254. .aif_name = "QUAT_TDM_RX_2",
  10255. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10256. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10257. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10258. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10259. SNDRV_PCM_FMTBIT_S24_LE |
  10260. SNDRV_PCM_FMTBIT_S32_LE,
  10261. .channels_min = 1,
  10262. .channels_max = 16,
  10263. .rate_min = 8000,
  10264. .rate_max = 352800,
  10265. },
  10266. .name = "QUAT_TDM_RX_2",
  10267. .ops = &msm_dai_q6_tdm_ops,
  10268. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  10269. .probe = msm_dai_q6_dai_tdm_probe,
  10270. .remove = msm_dai_q6_dai_tdm_remove,
  10271. },
  10272. {
  10273. .playback = {
  10274. .stream_name = "Quaternary TDM3 Playback",
  10275. .aif_name = "QUAT_TDM_RX_3",
  10276. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10277. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10278. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10279. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10280. SNDRV_PCM_FMTBIT_S24_LE |
  10281. SNDRV_PCM_FMTBIT_S32_LE,
  10282. .channels_min = 1,
  10283. .channels_max = 16,
  10284. .rate_min = 8000,
  10285. .rate_max = 352800,
  10286. },
  10287. .name = "QUAT_TDM_RX_3",
  10288. .ops = &msm_dai_q6_tdm_ops,
  10289. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  10290. .probe = msm_dai_q6_dai_tdm_probe,
  10291. .remove = msm_dai_q6_dai_tdm_remove,
  10292. },
  10293. {
  10294. .playback = {
  10295. .stream_name = "Quaternary TDM4 Playback",
  10296. .aif_name = "QUAT_TDM_RX_4",
  10297. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10298. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10299. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10300. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10301. SNDRV_PCM_FMTBIT_S24_LE |
  10302. SNDRV_PCM_FMTBIT_S32_LE,
  10303. .channels_min = 1,
  10304. .channels_max = 16,
  10305. .rate_min = 8000,
  10306. .rate_max = 352800,
  10307. },
  10308. .name = "QUAT_TDM_RX_4",
  10309. .ops = &msm_dai_q6_tdm_ops,
  10310. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  10311. .probe = msm_dai_q6_dai_tdm_probe,
  10312. .remove = msm_dai_q6_dai_tdm_remove,
  10313. },
  10314. {
  10315. .playback = {
  10316. .stream_name = "Quaternary TDM5 Playback",
  10317. .aif_name = "QUAT_TDM_RX_5",
  10318. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10319. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10320. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10321. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10322. SNDRV_PCM_FMTBIT_S24_LE |
  10323. SNDRV_PCM_FMTBIT_S32_LE,
  10324. .channels_min = 1,
  10325. .channels_max = 16,
  10326. .rate_min = 8000,
  10327. .rate_max = 352800,
  10328. },
  10329. .name = "QUAT_TDM_RX_5",
  10330. .ops = &msm_dai_q6_tdm_ops,
  10331. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  10332. .probe = msm_dai_q6_dai_tdm_probe,
  10333. .remove = msm_dai_q6_dai_tdm_remove,
  10334. },
  10335. {
  10336. .playback = {
  10337. .stream_name = "Quaternary TDM6 Playback",
  10338. .aif_name = "QUAT_TDM_RX_6",
  10339. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10340. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10341. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10342. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10343. SNDRV_PCM_FMTBIT_S24_LE |
  10344. SNDRV_PCM_FMTBIT_S32_LE,
  10345. .channels_min = 1,
  10346. .channels_max = 16,
  10347. .rate_min = 8000,
  10348. .rate_max = 352800,
  10349. },
  10350. .name = "QUAT_TDM_RX_6",
  10351. .ops = &msm_dai_q6_tdm_ops,
  10352. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  10353. .probe = msm_dai_q6_dai_tdm_probe,
  10354. .remove = msm_dai_q6_dai_tdm_remove,
  10355. },
  10356. {
  10357. .playback = {
  10358. .stream_name = "Quaternary TDM7 Playback",
  10359. .aif_name = "QUAT_TDM_RX_7",
  10360. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10361. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10362. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10363. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10364. SNDRV_PCM_FMTBIT_S24_LE |
  10365. SNDRV_PCM_FMTBIT_S32_LE,
  10366. .channels_min = 1,
  10367. .channels_max = 16,
  10368. .rate_min = 8000,
  10369. .rate_max = 352800,
  10370. },
  10371. .name = "QUAT_TDM_RX_7",
  10372. .ops = &msm_dai_q6_tdm_ops,
  10373. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  10374. .probe = msm_dai_q6_dai_tdm_probe,
  10375. .remove = msm_dai_q6_dai_tdm_remove,
  10376. },
  10377. {
  10378. .capture = {
  10379. .stream_name = "Quaternary TDM0 Capture",
  10380. .aif_name = "QUAT_TDM_TX_0",
  10381. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10382. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10383. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10384. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10385. SNDRV_PCM_FMTBIT_S24_LE |
  10386. SNDRV_PCM_FMTBIT_S32_LE,
  10387. .channels_min = 1,
  10388. .channels_max = 16,
  10389. .rate_min = 8000,
  10390. .rate_max = 352800,
  10391. },
  10392. .name = "QUAT_TDM_TX_0",
  10393. .ops = &msm_dai_q6_tdm_ops,
  10394. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  10395. .probe = msm_dai_q6_dai_tdm_probe,
  10396. .remove = msm_dai_q6_dai_tdm_remove,
  10397. },
  10398. {
  10399. .capture = {
  10400. .stream_name = "Quaternary TDM1 Capture",
  10401. .aif_name = "QUAT_TDM_TX_1",
  10402. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10403. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10404. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10405. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10406. SNDRV_PCM_FMTBIT_S24_LE |
  10407. SNDRV_PCM_FMTBIT_S32_LE,
  10408. .channels_min = 1,
  10409. .channels_max = 16,
  10410. .rate_min = 8000,
  10411. .rate_max = 352800,
  10412. },
  10413. .name = "QUAT_TDM_TX_1",
  10414. .ops = &msm_dai_q6_tdm_ops,
  10415. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  10416. .probe = msm_dai_q6_dai_tdm_probe,
  10417. .remove = msm_dai_q6_dai_tdm_remove,
  10418. },
  10419. {
  10420. .capture = {
  10421. .stream_name = "Quaternary TDM2 Capture",
  10422. .aif_name = "QUAT_TDM_TX_2",
  10423. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10424. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10425. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10426. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10427. SNDRV_PCM_FMTBIT_S24_LE |
  10428. SNDRV_PCM_FMTBIT_S32_LE,
  10429. .channels_min = 1,
  10430. .channels_max = 16,
  10431. .rate_min = 8000,
  10432. .rate_max = 352800,
  10433. },
  10434. .name = "QUAT_TDM_TX_2",
  10435. .ops = &msm_dai_q6_tdm_ops,
  10436. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  10437. .probe = msm_dai_q6_dai_tdm_probe,
  10438. .remove = msm_dai_q6_dai_tdm_remove,
  10439. },
  10440. {
  10441. .capture = {
  10442. .stream_name = "Quaternary TDM3 Capture",
  10443. .aif_name = "QUAT_TDM_TX_3",
  10444. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10445. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10446. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10447. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10448. SNDRV_PCM_FMTBIT_S24_LE |
  10449. SNDRV_PCM_FMTBIT_S32_LE,
  10450. .channels_min = 1,
  10451. .channels_max = 16,
  10452. .rate_min = 8000,
  10453. .rate_max = 352800,
  10454. },
  10455. .name = "QUAT_TDM_TX_3",
  10456. .ops = &msm_dai_q6_tdm_ops,
  10457. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  10458. .probe = msm_dai_q6_dai_tdm_probe,
  10459. .remove = msm_dai_q6_dai_tdm_remove,
  10460. },
  10461. {
  10462. .capture = {
  10463. .stream_name = "Quaternary TDM4 Capture",
  10464. .aif_name = "QUAT_TDM_TX_4",
  10465. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10466. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10467. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10468. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10469. SNDRV_PCM_FMTBIT_S24_LE |
  10470. SNDRV_PCM_FMTBIT_S32_LE,
  10471. .channels_min = 1,
  10472. .channels_max = 16,
  10473. .rate_min = 8000,
  10474. .rate_max = 352800,
  10475. },
  10476. .name = "QUAT_TDM_TX_4",
  10477. .ops = &msm_dai_q6_tdm_ops,
  10478. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  10479. .probe = msm_dai_q6_dai_tdm_probe,
  10480. .remove = msm_dai_q6_dai_tdm_remove,
  10481. },
  10482. {
  10483. .capture = {
  10484. .stream_name = "Quaternary TDM5 Capture",
  10485. .aif_name = "QUAT_TDM_TX_5",
  10486. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10487. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10488. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10489. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10490. SNDRV_PCM_FMTBIT_S24_LE |
  10491. SNDRV_PCM_FMTBIT_S32_LE,
  10492. .channels_min = 1,
  10493. .channels_max = 16,
  10494. .rate_min = 8000,
  10495. .rate_max = 352800,
  10496. },
  10497. .name = "QUAT_TDM_TX_5",
  10498. .ops = &msm_dai_q6_tdm_ops,
  10499. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  10500. .probe = msm_dai_q6_dai_tdm_probe,
  10501. .remove = msm_dai_q6_dai_tdm_remove,
  10502. },
  10503. {
  10504. .capture = {
  10505. .stream_name = "Quaternary TDM6 Capture",
  10506. .aif_name = "QUAT_TDM_TX_6",
  10507. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10508. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10509. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10510. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10511. SNDRV_PCM_FMTBIT_S24_LE |
  10512. SNDRV_PCM_FMTBIT_S32_LE,
  10513. .channels_min = 1,
  10514. .channels_max = 16,
  10515. .rate_min = 8000,
  10516. .rate_max = 352800,
  10517. },
  10518. .name = "QUAT_TDM_TX_6",
  10519. .ops = &msm_dai_q6_tdm_ops,
  10520. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  10521. .probe = msm_dai_q6_dai_tdm_probe,
  10522. .remove = msm_dai_q6_dai_tdm_remove,
  10523. },
  10524. {
  10525. .capture = {
  10526. .stream_name = "Quaternary TDM7 Capture",
  10527. .aif_name = "QUAT_TDM_TX_7",
  10528. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10529. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10530. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10531. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10532. SNDRV_PCM_FMTBIT_S24_LE |
  10533. SNDRV_PCM_FMTBIT_S32_LE,
  10534. .channels_min = 1,
  10535. .channels_max = 16,
  10536. .rate_min = 8000,
  10537. .rate_max = 352800,
  10538. },
  10539. .name = "QUAT_TDM_TX_7",
  10540. .ops = &msm_dai_q6_tdm_ops,
  10541. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  10542. .probe = msm_dai_q6_dai_tdm_probe,
  10543. .remove = msm_dai_q6_dai_tdm_remove,
  10544. },
  10545. {
  10546. .playback = {
  10547. .stream_name = "Quinary TDM0 Playback",
  10548. .aif_name = "QUIN_TDM_RX_0",
  10549. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10550. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10551. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10552. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10553. SNDRV_PCM_FMTBIT_S24_LE |
  10554. SNDRV_PCM_FMTBIT_S32_LE,
  10555. .channels_min = 1,
  10556. .channels_max = 16,
  10557. .rate_min = 8000,
  10558. .rate_max = 352800,
  10559. },
  10560. .name = "QUIN_TDM_RX_0",
  10561. .ops = &msm_dai_q6_tdm_ops,
  10562. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  10563. .probe = msm_dai_q6_dai_tdm_probe,
  10564. .remove = msm_dai_q6_dai_tdm_remove,
  10565. },
  10566. {
  10567. .playback = {
  10568. .stream_name = "Quinary TDM1 Playback",
  10569. .aif_name = "QUIN_TDM_RX_1",
  10570. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10571. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10572. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10573. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10574. SNDRV_PCM_FMTBIT_S24_LE |
  10575. SNDRV_PCM_FMTBIT_S32_LE,
  10576. .channels_min = 1,
  10577. .channels_max = 16,
  10578. .rate_min = 8000,
  10579. .rate_max = 352800,
  10580. },
  10581. .name = "QUIN_TDM_RX_1",
  10582. .ops = &msm_dai_q6_tdm_ops,
  10583. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  10584. .probe = msm_dai_q6_dai_tdm_probe,
  10585. .remove = msm_dai_q6_dai_tdm_remove,
  10586. },
  10587. {
  10588. .playback = {
  10589. .stream_name = "Quinary TDM2 Playback",
  10590. .aif_name = "QUIN_TDM_RX_2",
  10591. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10592. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10593. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10594. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10595. SNDRV_PCM_FMTBIT_S24_LE |
  10596. SNDRV_PCM_FMTBIT_S32_LE,
  10597. .channels_min = 1,
  10598. .channels_max = 16,
  10599. .rate_min = 8000,
  10600. .rate_max = 352800,
  10601. },
  10602. .name = "QUIN_TDM_RX_2",
  10603. .ops = &msm_dai_q6_tdm_ops,
  10604. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  10605. .probe = msm_dai_q6_dai_tdm_probe,
  10606. .remove = msm_dai_q6_dai_tdm_remove,
  10607. },
  10608. {
  10609. .playback = {
  10610. .stream_name = "Quinary TDM3 Playback",
  10611. .aif_name = "QUIN_TDM_RX_3",
  10612. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10613. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10614. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10615. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10616. SNDRV_PCM_FMTBIT_S24_LE |
  10617. SNDRV_PCM_FMTBIT_S32_LE,
  10618. .channels_min = 1,
  10619. .channels_max = 16,
  10620. .rate_min = 8000,
  10621. .rate_max = 352800,
  10622. },
  10623. .name = "QUIN_TDM_RX_3",
  10624. .ops = &msm_dai_q6_tdm_ops,
  10625. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  10626. .probe = msm_dai_q6_dai_tdm_probe,
  10627. .remove = msm_dai_q6_dai_tdm_remove,
  10628. },
  10629. {
  10630. .playback = {
  10631. .stream_name = "Quinary TDM4 Playback",
  10632. .aif_name = "QUIN_TDM_RX_4",
  10633. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10634. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10635. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10636. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10637. SNDRV_PCM_FMTBIT_S24_LE |
  10638. SNDRV_PCM_FMTBIT_S32_LE,
  10639. .channels_min = 1,
  10640. .channels_max = 16,
  10641. .rate_min = 8000,
  10642. .rate_max = 352800,
  10643. },
  10644. .name = "QUIN_TDM_RX_4",
  10645. .ops = &msm_dai_q6_tdm_ops,
  10646. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  10647. .probe = msm_dai_q6_dai_tdm_probe,
  10648. .remove = msm_dai_q6_dai_tdm_remove,
  10649. },
  10650. {
  10651. .playback = {
  10652. .stream_name = "Quinary TDM5 Playback",
  10653. .aif_name = "QUIN_TDM_RX_5",
  10654. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10655. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10656. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10657. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10658. SNDRV_PCM_FMTBIT_S24_LE |
  10659. SNDRV_PCM_FMTBIT_S32_LE,
  10660. .channels_min = 1,
  10661. .channels_max = 16,
  10662. .rate_min = 8000,
  10663. .rate_max = 352800,
  10664. },
  10665. .name = "QUIN_TDM_RX_5",
  10666. .ops = &msm_dai_q6_tdm_ops,
  10667. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  10668. .probe = msm_dai_q6_dai_tdm_probe,
  10669. .remove = msm_dai_q6_dai_tdm_remove,
  10670. },
  10671. {
  10672. .playback = {
  10673. .stream_name = "Quinary TDM6 Playback",
  10674. .aif_name = "QUIN_TDM_RX_6",
  10675. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10676. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10677. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10678. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10679. SNDRV_PCM_FMTBIT_S24_LE |
  10680. SNDRV_PCM_FMTBIT_S32_LE,
  10681. .channels_min = 1,
  10682. .channels_max = 16,
  10683. .rate_min = 8000,
  10684. .rate_max = 352800,
  10685. },
  10686. .name = "QUIN_TDM_RX_6",
  10687. .ops = &msm_dai_q6_tdm_ops,
  10688. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  10689. .probe = msm_dai_q6_dai_tdm_probe,
  10690. .remove = msm_dai_q6_dai_tdm_remove,
  10691. },
  10692. {
  10693. .playback = {
  10694. .stream_name = "Quinary TDM7 Playback",
  10695. .aif_name = "QUIN_TDM_RX_7",
  10696. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10697. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10698. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10699. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10700. SNDRV_PCM_FMTBIT_S24_LE |
  10701. SNDRV_PCM_FMTBIT_S32_LE,
  10702. .channels_min = 1,
  10703. .channels_max = 16,
  10704. .rate_min = 8000,
  10705. .rate_max = 352800,
  10706. },
  10707. .name = "QUIN_TDM_RX_7",
  10708. .ops = &msm_dai_q6_tdm_ops,
  10709. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  10710. .probe = msm_dai_q6_dai_tdm_probe,
  10711. .remove = msm_dai_q6_dai_tdm_remove,
  10712. },
  10713. {
  10714. .capture = {
  10715. .stream_name = "Quinary TDM0 Capture",
  10716. .aif_name = "QUIN_TDM_TX_0",
  10717. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10718. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10719. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10720. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10721. SNDRV_PCM_FMTBIT_S24_LE |
  10722. SNDRV_PCM_FMTBIT_S32_LE,
  10723. .channels_min = 1,
  10724. .channels_max = 16,
  10725. .rate_min = 8000,
  10726. .rate_max = 352800,
  10727. },
  10728. .name = "QUIN_TDM_TX_0",
  10729. .ops = &msm_dai_q6_tdm_ops,
  10730. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  10731. .probe = msm_dai_q6_dai_tdm_probe,
  10732. .remove = msm_dai_q6_dai_tdm_remove,
  10733. },
  10734. {
  10735. .capture = {
  10736. .stream_name = "Quinary TDM1 Capture",
  10737. .aif_name = "QUIN_TDM_TX_1",
  10738. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10739. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10740. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10741. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10742. SNDRV_PCM_FMTBIT_S24_LE |
  10743. SNDRV_PCM_FMTBIT_S32_LE,
  10744. .channels_min = 1,
  10745. .channels_max = 16,
  10746. .rate_min = 8000,
  10747. .rate_max = 352800,
  10748. },
  10749. .name = "QUIN_TDM_TX_1",
  10750. .ops = &msm_dai_q6_tdm_ops,
  10751. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  10752. .probe = msm_dai_q6_dai_tdm_probe,
  10753. .remove = msm_dai_q6_dai_tdm_remove,
  10754. },
  10755. {
  10756. .capture = {
  10757. .stream_name = "Quinary TDM2 Capture",
  10758. .aif_name = "QUIN_TDM_TX_2",
  10759. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10760. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10761. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10762. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10763. SNDRV_PCM_FMTBIT_S24_LE |
  10764. SNDRV_PCM_FMTBIT_S32_LE,
  10765. .channels_min = 1,
  10766. .channels_max = 16,
  10767. .rate_min = 8000,
  10768. .rate_max = 352800,
  10769. },
  10770. .name = "QUIN_TDM_TX_2",
  10771. .ops = &msm_dai_q6_tdm_ops,
  10772. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  10773. .probe = msm_dai_q6_dai_tdm_probe,
  10774. .remove = msm_dai_q6_dai_tdm_remove,
  10775. },
  10776. {
  10777. .capture = {
  10778. .stream_name = "Quinary TDM3 Capture",
  10779. .aif_name = "QUIN_TDM_TX_3",
  10780. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10781. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10782. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10783. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10784. SNDRV_PCM_FMTBIT_S24_LE |
  10785. SNDRV_PCM_FMTBIT_S32_LE,
  10786. .channels_min = 1,
  10787. .channels_max = 16,
  10788. .rate_min = 8000,
  10789. .rate_max = 352800,
  10790. },
  10791. .name = "QUIN_TDM_TX_3",
  10792. .ops = &msm_dai_q6_tdm_ops,
  10793. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  10794. .probe = msm_dai_q6_dai_tdm_probe,
  10795. .remove = msm_dai_q6_dai_tdm_remove,
  10796. },
  10797. {
  10798. .capture = {
  10799. .stream_name = "Quinary TDM4 Capture",
  10800. .aif_name = "QUIN_TDM_TX_4",
  10801. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10802. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10803. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10804. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10805. SNDRV_PCM_FMTBIT_S24_LE |
  10806. SNDRV_PCM_FMTBIT_S32_LE,
  10807. .channels_min = 1,
  10808. .channels_max = 16,
  10809. .rate_min = 8000,
  10810. .rate_max = 352800,
  10811. },
  10812. .name = "QUIN_TDM_TX_4",
  10813. .ops = &msm_dai_q6_tdm_ops,
  10814. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  10815. .probe = msm_dai_q6_dai_tdm_probe,
  10816. .remove = msm_dai_q6_dai_tdm_remove,
  10817. },
  10818. {
  10819. .capture = {
  10820. .stream_name = "Quinary TDM5 Capture",
  10821. .aif_name = "QUIN_TDM_TX_5",
  10822. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10823. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10824. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10825. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10826. SNDRV_PCM_FMTBIT_S24_LE |
  10827. SNDRV_PCM_FMTBIT_S32_LE,
  10828. .channels_min = 1,
  10829. .channels_max = 16,
  10830. .rate_min = 8000,
  10831. .rate_max = 352800,
  10832. },
  10833. .name = "QUIN_TDM_TX_5",
  10834. .ops = &msm_dai_q6_tdm_ops,
  10835. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  10836. .probe = msm_dai_q6_dai_tdm_probe,
  10837. .remove = msm_dai_q6_dai_tdm_remove,
  10838. },
  10839. {
  10840. .capture = {
  10841. .stream_name = "Quinary TDM6 Capture",
  10842. .aif_name = "QUIN_TDM_TX_6",
  10843. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10844. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10845. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10846. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10847. SNDRV_PCM_FMTBIT_S24_LE |
  10848. SNDRV_PCM_FMTBIT_S32_LE,
  10849. .channels_min = 1,
  10850. .channels_max = 16,
  10851. .rate_min = 8000,
  10852. .rate_max = 352800,
  10853. },
  10854. .name = "QUIN_TDM_TX_6",
  10855. .ops = &msm_dai_q6_tdm_ops,
  10856. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  10857. .probe = msm_dai_q6_dai_tdm_probe,
  10858. .remove = msm_dai_q6_dai_tdm_remove,
  10859. },
  10860. {
  10861. .capture = {
  10862. .stream_name = "Quinary TDM7 Capture",
  10863. .aif_name = "QUIN_TDM_TX_7",
  10864. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10865. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10866. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10867. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10868. SNDRV_PCM_FMTBIT_S24_LE |
  10869. SNDRV_PCM_FMTBIT_S32_LE,
  10870. .channels_min = 1,
  10871. .channels_max = 16,
  10872. .rate_min = 8000,
  10873. .rate_max = 352800,
  10874. },
  10875. .name = "QUIN_TDM_TX_7",
  10876. .ops = &msm_dai_q6_tdm_ops,
  10877. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  10878. .probe = msm_dai_q6_dai_tdm_probe,
  10879. .remove = msm_dai_q6_dai_tdm_remove,
  10880. },
  10881. {
  10882. .playback = {
  10883. .stream_name = "Senary TDM0 Playback",
  10884. .aif_name = "SEN_TDM_RX_0",
  10885. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10886. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10887. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10888. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10889. SNDRV_PCM_FMTBIT_S24_LE |
  10890. SNDRV_PCM_FMTBIT_S32_LE,
  10891. .channels_min = 1,
  10892. .channels_max = 8,
  10893. .rate_min = 8000,
  10894. .rate_max = 352800,
  10895. },
  10896. .name = "SEN_TDM_RX_0",
  10897. .ops = &msm_dai_q6_tdm_ops,
  10898. .id = AFE_PORT_ID_SENARY_TDM_RX,
  10899. .probe = msm_dai_q6_dai_tdm_probe,
  10900. .remove = msm_dai_q6_dai_tdm_remove,
  10901. },
  10902. {
  10903. .playback = {
  10904. .stream_name = "Senary TDM1 Playback",
  10905. .aif_name = "SEN_TDM_RX_1",
  10906. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10907. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10908. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10909. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10910. SNDRV_PCM_FMTBIT_S24_LE |
  10911. SNDRV_PCM_FMTBIT_S32_LE,
  10912. .channels_min = 1,
  10913. .channels_max = 8,
  10914. .rate_min = 8000,
  10915. .rate_max = 352800,
  10916. },
  10917. .name = "SEN_TDM_RX_1",
  10918. .ops = &msm_dai_q6_tdm_ops,
  10919. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  10920. .probe = msm_dai_q6_dai_tdm_probe,
  10921. .remove = msm_dai_q6_dai_tdm_remove,
  10922. },
  10923. {
  10924. .playback = {
  10925. .stream_name = "Senary TDM2 Playback",
  10926. .aif_name = "SEN_TDM_RX_2",
  10927. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10928. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10929. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10930. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10931. SNDRV_PCM_FMTBIT_S24_LE |
  10932. SNDRV_PCM_FMTBIT_S32_LE,
  10933. .channels_min = 1,
  10934. .channels_max = 8,
  10935. .rate_min = 8000,
  10936. .rate_max = 352800,
  10937. },
  10938. .name = "SEN_TDM_RX_2",
  10939. .ops = &msm_dai_q6_tdm_ops,
  10940. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  10941. .probe = msm_dai_q6_dai_tdm_probe,
  10942. .remove = msm_dai_q6_dai_tdm_remove,
  10943. },
  10944. {
  10945. .playback = {
  10946. .stream_name = "Senary TDM3 Playback",
  10947. .aif_name = "SEN_TDM_RX_3",
  10948. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10949. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10950. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10951. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10952. SNDRV_PCM_FMTBIT_S24_LE |
  10953. SNDRV_PCM_FMTBIT_S32_LE,
  10954. .channels_min = 1,
  10955. .channels_max = 8,
  10956. .rate_min = 8000,
  10957. .rate_max = 352800,
  10958. },
  10959. .name = "SEN_TDM_RX_3",
  10960. .ops = &msm_dai_q6_tdm_ops,
  10961. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  10962. .probe = msm_dai_q6_dai_tdm_probe,
  10963. .remove = msm_dai_q6_dai_tdm_remove,
  10964. },
  10965. {
  10966. .playback = {
  10967. .stream_name = "Senary TDM4 Playback",
  10968. .aif_name = "SEN_TDM_RX_4",
  10969. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10970. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10971. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10972. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10973. SNDRV_PCM_FMTBIT_S24_LE |
  10974. SNDRV_PCM_FMTBIT_S32_LE,
  10975. .channels_min = 1,
  10976. .channels_max = 8,
  10977. .rate_min = 8000,
  10978. .rate_max = 352800,
  10979. },
  10980. .name = "SEN_TDM_RX_4",
  10981. .ops = &msm_dai_q6_tdm_ops,
  10982. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  10983. .probe = msm_dai_q6_dai_tdm_probe,
  10984. .remove = msm_dai_q6_dai_tdm_remove,
  10985. },
  10986. {
  10987. .playback = {
  10988. .stream_name = "Senary TDM5 Playback",
  10989. .aif_name = "SEN_TDM_RX_5",
  10990. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10991. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10992. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10993. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10994. SNDRV_PCM_FMTBIT_S24_LE |
  10995. SNDRV_PCM_FMTBIT_S32_LE,
  10996. .channels_min = 1,
  10997. .channels_max = 8,
  10998. .rate_min = 8000,
  10999. .rate_max = 352800,
  11000. },
  11001. .name = "SEN_TDM_RX_5",
  11002. .ops = &msm_dai_q6_tdm_ops,
  11003. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  11004. .probe = msm_dai_q6_dai_tdm_probe,
  11005. .remove = msm_dai_q6_dai_tdm_remove,
  11006. },
  11007. {
  11008. .playback = {
  11009. .stream_name = "Senary TDM6 Playback",
  11010. .aif_name = "SEN_TDM_RX_6",
  11011. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11012. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11013. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11014. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11015. SNDRV_PCM_FMTBIT_S24_LE |
  11016. SNDRV_PCM_FMTBIT_S32_LE,
  11017. .channels_min = 1,
  11018. .channels_max = 8,
  11019. .rate_min = 8000,
  11020. .rate_max = 352800,
  11021. },
  11022. .name = "SEN_TDM_RX_6",
  11023. .ops = &msm_dai_q6_tdm_ops,
  11024. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  11025. .probe = msm_dai_q6_dai_tdm_probe,
  11026. .remove = msm_dai_q6_dai_tdm_remove,
  11027. },
  11028. {
  11029. .playback = {
  11030. .stream_name = "Senary TDM7 Playback",
  11031. .aif_name = "SEN_TDM_RX_7",
  11032. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  11033. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  11034. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11035. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11036. SNDRV_PCM_FMTBIT_S24_LE |
  11037. SNDRV_PCM_FMTBIT_S32_LE,
  11038. .channels_min = 1,
  11039. .channels_max = 8,
  11040. .rate_min = 8000,
  11041. .rate_max = 352800,
  11042. },
  11043. .name = "SEN_TDM_RX_7",
  11044. .ops = &msm_dai_q6_tdm_ops,
  11045. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  11046. .probe = msm_dai_q6_dai_tdm_probe,
  11047. .remove = msm_dai_q6_dai_tdm_remove,
  11048. },
  11049. {
  11050. .capture = {
  11051. .stream_name = "Senary TDM0 Capture",
  11052. .aif_name = "SEN_TDM_TX_0",
  11053. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11054. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11055. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11056. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11057. SNDRV_PCM_FMTBIT_S24_LE |
  11058. SNDRV_PCM_FMTBIT_S32_LE,
  11059. .channels_min = 1,
  11060. .channels_max = 8,
  11061. .rate_min = 8000,
  11062. .rate_max = 352800,
  11063. },
  11064. .name = "SEN_TDM_TX_0",
  11065. .ops = &msm_dai_q6_tdm_ops,
  11066. .id = AFE_PORT_ID_SENARY_TDM_TX,
  11067. .probe = msm_dai_q6_dai_tdm_probe,
  11068. .remove = msm_dai_q6_dai_tdm_remove,
  11069. },
  11070. {
  11071. .capture = {
  11072. .stream_name = "Senary TDM1 Capture",
  11073. .aif_name = "SEN_TDM_TX_1",
  11074. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11075. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11076. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11077. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11078. SNDRV_PCM_FMTBIT_S24_LE |
  11079. SNDRV_PCM_FMTBIT_S32_LE,
  11080. .channels_min = 1,
  11081. .channels_max = 8,
  11082. .rate_min = 8000,
  11083. .rate_max = 352800,
  11084. },
  11085. .name = "SEN_TDM_TX_1",
  11086. .ops = &msm_dai_q6_tdm_ops,
  11087. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  11088. .probe = msm_dai_q6_dai_tdm_probe,
  11089. .remove = msm_dai_q6_dai_tdm_remove,
  11090. },
  11091. {
  11092. .capture = {
  11093. .stream_name = "Senary TDM2 Capture",
  11094. .aif_name = "SEN_TDM_TX_2",
  11095. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11096. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11097. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11098. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11099. SNDRV_PCM_FMTBIT_S24_LE |
  11100. SNDRV_PCM_FMTBIT_S32_LE,
  11101. .channels_min = 1,
  11102. .channels_max = 8,
  11103. .rate_min = 8000,
  11104. .rate_max = 352800,
  11105. },
  11106. .name = "SEN_TDM_TX_2",
  11107. .ops = &msm_dai_q6_tdm_ops,
  11108. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  11109. .probe = msm_dai_q6_dai_tdm_probe,
  11110. .remove = msm_dai_q6_dai_tdm_remove,
  11111. },
  11112. {
  11113. .capture = {
  11114. .stream_name = "Senary TDM3 Capture",
  11115. .aif_name = "SEN_TDM_TX_3",
  11116. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11117. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11118. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11119. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11120. SNDRV_PCM_FMTBIT_S24_LE |
  11121. SNDRV_PCM_FMTBIT_S32_LE,
  11122. .channels_min = 1,
  11123. .channels_max = 8,
  11124. .rate_min = 8000,
  11125. .rate_max = 352800,
  11126. },
  11127. .name = "SEN_TDM_TX_3",
  11128. .ops = &msm_dai_q6_tdm_ops,
  11129. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  11130. .probe = msm_dai_q6_dai_tdm_probe,
  11131. .remove = msm_dai_q6_dai_tdm_remove,
  11132. },
  11133. {
  11134. .capture = {
  11135. .stream_name = "Senary TDM4 Capture",
  11136. .aif_name = "SEN_TDM_TX_4",
  11137. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11138. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11139. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11140. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11141. SNDRV_PCM_FMTBIT_S24_LE |
  11142. SNDRV_PCM_FMTBIT_S32_LE,
  11143. .channels_min = 1,
  11144. .channels_max = 8,
  11145. .rate_min = 8000,
  11146. .rate_max = 352800,
  11147. },
  11148. .name = "SEN_TDM_TX_4",
  11149. .ops = &msm_dai_q6_tdm_ops,
  11150. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  11151. .probe = msm_dai_q6_dai_tdm_probe,
  11152. .remove = msm_dai_q6_dai_tdm_remove,
  11153. },
  11154. {
  11155. .capture = {
  11156. .stream_name = "Senary TDM5 Capture",
  11157. .aif_name = "SEN_TDM_TX_5",
  11158. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11159. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11160. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11161. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11162. SNDRV_PCM_FMTBIT_S24_LE |
  11163. SNDRV_PCM_FMTBIT_S32_LE,
  11164. .channels_min = 1,
  11165. .channels_max = 8,
  11166. .rate_min = 8000,
  11167. .rate_max = 352800,
  11168. },
  11169. .name = "SEN_TDM_TX_5",
  11170. .ops = &msm_dai_q6_tdm_ops,
  11171. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  11172. .probe = msm_dai_q6_dai_tdm_probe,
  11173. .remove = msm_dai_q6_dai_tdm_remove,
  11174. },
  11175. {
  11176. .capture = {
  11177. .stream_name = "Senary TDM6 Capture",
  11178. .aif_name = "SEN_TDM_TX_6",
  11179. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11180. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11181. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11182. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11183. SNDRV_PCM_FMTBIT_S24_LE |
  11184. SNDRV_PCM_FMTBIT_S32_LE,
  11185. .channels_min = 1,
  11186. .channels_max = 8,
  11187. .rate_min = 8000,
  11188. .rate_max = 352800,
  11189. },
  11190. .name = "SEN_TDM_TX_6",
  11191. .ops = &msm_dai_q6_tdm_ops,
  11192. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  11193. .probe = msm_dai_q6_dai_tdm_probe,
  11194. .remove = msm_dai_q6_dai_tdm_remove,
  11195. },
  11196. {
  11197. .capture = {
  11198. .stream_name = "Senary TDM7 Capture",
  11199. .aif_name = "SEN_TDM_TX_7",
  11200. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  11201. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  11202. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  11203. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11204. SNDRV_PCM_FMTBIT_S24_LE |
  11205. SNDRV_PCM_FMTBIT_S32_LE,
  11206. .channels_min = 1,
  11207. .channels_max = 8,
  11208. .rate_min = 8000,
  11209. .rate_max = 352800,
  11210. },
  11211. .name = "SEN_TDM_TX_7",
  11212. .ops = &msm_dai_q6_tdm_ops,
  11213. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  11214. .probe = msm_dai_q6_dai_tdm_probe,
  11215. .remove = msm_dai_q6_dai_tdm_remove,
  11216. },
  11217. };
  11218. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  11219. .name = "msm-dai-q6-tdm",
  11220. };
  11221. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  11222. {
  11223. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  11224. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  11225. int rc = 0;
  11226. u32 tdm_dev_id = 0;
  11227. int port_idx = 0;
  11228. struct device_node *tdm_parent_node = NULL;
  11229. /* retrieve device/afe id */
  11230. rc = of_property_read_u32(pdev->dev.of_node,
  11231. "qcom,msm-cpudai-tdm-dev-id",
  11232. &tdm_dev_id);
  11233. if (rc) {
  11234. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  11235. __func__);
  11236. goto rtn;
  11237. }
  11238. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  11239. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  11240. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  11241. __func__, tdm_dev_id);
  11242. rc = -ENXIO;
  11243. goto rtn;
  11244. }
  11245. pdev->id = tdm_dev_id;
  11246. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  11247. GFP_KERNEL);
  11248. if (!dai_data) {
  11249. rc = -ENOMEM;
  11250. dev_err(&pdev->dev,
  11251. "%s Failed to allocate memory for tdm dai_data\n",
  11252. __func__);
  11253. goto rtn;
  11254. }
  11255. memset(dai_data, 0, sizeof(*dai_data));
  11256. rc = of_property_read_u32(pdev->dev.of_node,
  11257. "qcom,msm-dai-is-island-supported",
  11258. &dai_data->is_island_dai);
  11259. if (rc)
  11260. dev_dbg(&pdev->dev, "island supported entry not found\n");
  11261. /* TDM CFG */
  11262. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  11263. rc = of_property_read_u32(tdm_parent_node,
  11264. "qcom,msm-cpudai-tdm-sync-mode",
  11265. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  11266. if (rc) {
  11267. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  11268. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  11269. goto free_dai_data;
  11270. }
  11271. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  11272. __func__, dai_data->port_cfg.tdm.sync_mode);
  11273. rc = of_property_read_u32(tdm_parent_node,
  11274. "qcom,msm-cpudai-tdm-sync-src",
  11275. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  11276. if (rc) {
  11277. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  11278. __func__, "qcom,msm-cpudai-tdm-sync-src");
  11279. goto free_dai_data;
  11280. }
  11281. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  11282. __func__, dai_data->port_cfg.tdm.sync_src);
  11283. rc = of_property_read_u32(tdm_parent_node,
  11284. "qcom,msm-cpudai-tdm-data-out",
  11285. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11286. if (rc) {
  11287. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  11288. __func__, "qcom,msm-cpudai-tdm-data-out");
  11289. goto free_dai_data;
  11290. }
  11291. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  11292. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11293. rc = of_property_read_u32(tdm_parent_node,
  11294. "qcom,msm-cpudai-tdm-invert-sync",
  11295. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11296. if (rc) {
  11297. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  11298. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  11299. goto free_dai_data;
  11300. }
  11301. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  11302. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11303. rc = of_property_read_u32(tdm_parent_node,
  11304. "qcom,msm-cpudai-tdm-data-delay",
  11305. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11306. if (rc) {
  11307. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  11308. __func__, "qcom,msm-cpudai-tdm-data-delay");
  11309. goto free_dai_data;
  11310. }
  11311. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  11312. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11313. /* TDM CFG -- set default */
  11314. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  11315. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  11316. AFE_API_VERSION_TDM_CONFIG;
  11317. /* TDM SLOT MAPPING CFG */
  11318. rc = of_property_read_u32(pdev->dev.of_node,
  11319. "qcom,msm-cpudai-tdm-data-align",
  11320. &dai_data->port_cfg.slot_mapping.data_align_type);
  11321. if (rc) {
  11322. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  11323. __func__,
  11324. "qcom,msm-cpudai-tdm-data-align");
  11325. goto free_dai_data;
  11326. }
  11327. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  11328. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  11329. /* TDM SLOT MAPPING CFG -- set default */
  11330. dai_data->port_cfg.slot_mapping.minor_version =
  11331. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  11332. dai_data->port_cfg.slot_mapping_v2.minor_version =
  11333. AFE_API_VERSION_SLOT_MAPPING_CONFIG_V2;
  11334. /* CUSTOM TDM HEADER CFG */
  11335. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  11336. if (of_find_property(pdev->dev.of_node,
  11337. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  11338. of_find_property(pdev->dev.of_node,
  11339. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  11340. of_find_property(pdev->dev.of_node,
  11341. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  11342. /* if the property exist */
  11343. rc = of_property_read_u32(pdev->dev.of_node,
  11344. "qcom,msm-cpudai-tdm-header-start-offset",
  11345. (u32 *)&custom_tdm_header->start_offset);
  11346. if (rc) {
  11347. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  11348. __func__,
  11349. "qcom,msm-cpudai-tdm-header-start-offset");
  11350. goto free_dai_data;
  11351. }
  11352. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  11353. __func__, custom_tdm_header->start_offset);
  11354. rc = of_property_read_u32(pdev->dev.of_node,
  11355. "qcom,msm-cpudai-tdm-header-width",
  11356. (u32 *)&custom_tdm_header->header_width);
  11357. if (rc) {
  11358. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  11359. __func__, "qcom,msm-cpudai-tdm-header-width");
  11360. goto free_dai_data;
  11361. }
  11362. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  11363. __func__, custom_tdm_header->header_width);
  11364. rc = of_property_read_u32(pdev->dev.of_node,
  11365. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  11366. (u32 *)&custom_tdm_header->num_frame_repeat);
  11367. if (rc) {
  11368. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  11369. __func__,
  11370. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  11371. goto free_dai_data;
  11372. }
  11373. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  11374. __func__, custom_tdm_header->num_frame_repeat);
  11375. /* CUSTOM TDM HEADER CFG -- set default */
  11376. custom_tdm_header->minor_version =
  11377. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  11378. custom_tdm_header->header_type =
  11379. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11380. } else {
  11381. /* CUSTOM TDM HEADER CFG -- set default */
  11382. custom_tdm_header->header_type =
  11383. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11384. /* proceed with probe */
  11385. }
  11386. /* copy static clk per parent node */
  11387. dai_data->clk_set = tdm_clk_set;
  11388. /* copy static group cfg per parent node */
  11389. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  11390. /* copy static num group ports per parent node */
  11391. dai_data->num_group_ports = num_tdm_group_ports;
  11392. dai_data->lane_cfg = tdm_lane_cfg;
  11393. dev_set_drvdata(&pdev->dev, dai_data);
  11394. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  11395. if (port_idx < 0) {
  11396. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  11397. __func__, tdm_dev_id);
  11398. rc = -EINVAL;
  11399. goto free_dai_data;
  11400. }
  11401. rc = snd_soc_register_component(&pdev->dev,
  11402. &msm_q6_tdm_dai_component,
  11403. &msm_dai_q6_tdm_dai[port_idx], 1);
  11404. if (rc) {
  11405. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  11406. __func__, tdm_dev_id, rc);
  11407. goto err_register;
  11408. }
  11409. return 0;
  11410. err_register:
  11411. free_dai_data:
  11412. kfree(dai_data);
  11413. rtn:
  11414. return rc;
  11415. }
  11416. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  11417. {
  11418. struct msm_dai_q6_tdm_dai_data *dai_data =
  11419. dev_get_drvdata(&pdev->dev);
  11420. snd_soc_unregister_component(&pdev->dev);
  11421. kfree(dai_data);
  11422. return 0;
  11423. }
  11424. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  11425. { .compatible = "qcom,msm-dai-q6-tdm", },
  11426. {}
  11427. };
  11428. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  11429. static struct platform_driver msm_dai_q6_tdm_driver = {
  11430. .probe = msm_dai_q6_tdm_dev_probe,
  11431. .remove = msm_dai_q6_tdm_dev_remove,
  11432. .driver = {
  11433. .name = "msm-dai-q6-tdm",
  11434. .owner = THIS_MODULE,
  11435. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  11436. .suppress_bind_attrs = true,
  11437. },
  11438. };
  11439. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  11440. struct snd_ctl_elem_value *ucontrol)
  11441. {
  11442. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11443. int value = ucontrol->value.integer.value[0];
  11444. dai_data->port_config.cdc_dma.data_format = value;
  11445. pr_debug("%s: format = %d\n", __func__, value);
  11446. return 0;
  11447. }
  11448. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  11449. struct snd_ctl_elem_value *ucontrol)
  11450. {
  11451. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11452. ucontrol->value.integer.value[0] =
  11453. dai_data->port_config.cdc_dma.data_format;
  11454. return 0;
  11455. }
  11456. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  11457. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  11458. msm_dai_q6_cdc_dma_format_get,
  11459. msm_dai_q6_cdc_dma_format_put),
  11460. SOC_ENUM_EXT("WSA_CDC_DMA_0 RX XTLoggingDisable",
  11461. xt_logging_disable_enum[0],
  11462. msm_dai_q6_cdc_dma_xt_logging_disable_get,
  11463. msm_dai_q6_cdc_dma_xt_logging_disable_put),
  11464. };
  11465. /* SOC probe for codec DMA interface */
  11466. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  11467. {
  11468. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  11469. int rc = 0;
  11470. if (!dai) {
  11471. pr_err("%s: Invalid params dai\n", __func__);
  11472. return -EINVAL;
  11473. }
  11474. if (!dai->dev) {
  11475. pr_err("%s: Invalid params dai dev\n", __func__);
  11476. return -EINVAL;
  11477. }
  11478. msm_dai_q6_set_dai_id(dai);
  11479. dai_data = dev_get_drvdata(dai->dev);
  11480. switch (dai->id) {
  11481. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11482. rc = snd_ctl_add(dai->component->card->snd_card,
  11483. snd_ctl_new1(&cdc_dma_config_controls[0],
  11484. dai_data));
  11485. break;
  11486. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11487. rc = snd_ctl_add(dai->component->card->snd_card,
  11488. snd_ctl_new1(&cdc_dma_config_controls[1],
  11489. dai_data));
  11490. break;
  11491. default:
  11492. break;
  11493. }
  11494. if (rc < 0)
  11495. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  11496. __func__, dai->name);
  11497. if (dai_data->is_island_dai)
  11498. rc = msm_dai_q6_add_island_mx_ctls(
  11499. dai->component->card->snd_card,
  11500. dai->name, dai->id,
  11501. (void *)dai_data);
  11502. rc = msm_dai_q6_dai_add_route(dai);
  11503. return rc;
  11504. }
  11505. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  11506. {
  11507. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11508. dev_get_drvdata(dai->dev);
  11509. int rc = 0;
  11510. /* If AFE port is still up, close it */
  11511. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11512. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  11513. dai->id);
  11514. rc = afe_close(dai->id); /* can block */
  11515. if (rc < 0)
  11516. dev_err(dai->dev, "fail to close AFE port\n");
  11517. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11518. }
  11519. return rc;
  11520. }
  11521. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  11522. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  11523. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  11524. {
  11525. int rc = 0;
  11526. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11527. dev_get_drvdata(dai->dev);
  11528. unsigned int ch_mask = 0, ch_num = 0;
  11529. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  11530. switch (dai->id) {
  11531. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11532. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  11533. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  11534. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  11535. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  11536. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  11537. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  11538. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  11539. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  11540. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  11541. if (!rx_ch_mask) {
  11542. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  11543. return -EINVAL;
  11544. }
  11545. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11546. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  11547. __func__, rx_num_ch);
  11548. return -EINVAL;
  11549. }
  11550. ch_mask = *rx_ch_mask;
  11551. ch_num = rx_num_ch;
  11552. break;
  11553. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11554. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  11555. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  11556. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  11557. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  11558. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  11559. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  11560. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  11561. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  11562. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  11563. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  11564. if (!tx_ch_mask) {
  11565. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  11566. return -EINVAL;
  11567. }
  11568. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11569. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  11570. __func__, tx_num_ch);
  11571. return -EINVAL;
  11572. }
  11573. ch_mask = *tx_ch_mask;
  11574. ch_num = tx_num_ch;
  11575. break;
  11576. default:
  11577. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  11578. return -EINVAL;
  11579. }
  11580. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  11581. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  11582. dai->id, ch_num, ch_mask);
  11583. return rc;
  11584. }
  11585. static int msm_dai_q6_cdc_dma_hw_params(
  11586. struct snd_pcm_substream *substream,
  11587. struct snd_pcm_hw_params *params,
  11588. struct snd_soc_dai *dai)
  11589. {
  11590. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11591. dev_get_drvdata(dai->dev);
  11592. switch (params_format(params)) {
  11593. case SNDRV_PCM_FORMAT_S16_LE:
  11594. case SNDRV_PCM_FORMAT_SPECIAL:
  11595. dai_data->port_config.cdc_dma.bit_width = 16;
  11596. break;
  11597. case SNDRV_PCM_FORMAT_S24_LE:
  11598. case SNDRV_PCM_FORMAT_S24_3LE:
  11599. dai_data->port_config.cdc_dma.bit_width = 24;
  11600. break;
  11601. case SNDRV_PCM_FORMAT_S32_LE:
  11602. dai_data->port_config.cdc_dma.bit_width = 32;
  11603. break;
  11604. default:
  11605. dev_err(dai->dev, "%s: format %d\n",
  11606. __func__, params_format(params));
  11607. return -EINVAL;
  11608. }
  11609. dai_data->rate = params_rate(params);
  11610. dai_data->channels = params_channels(params);
  11611. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  11612. AFE_API_VERSION_CODEC_DMA_CONFIG;
  11613. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  11614. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  11615. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  11616. "num_channel %hu sample_rate %d\n", __func__,
  11617. dai_data->port_config.cdc_dma.bit_width,
  11618. dai_data->port_config.cdc_dma.data_format,
  11619. dai_data->port_config.cdc_dma.num_channels,
  11620. dai_data->rate);
  11621. return 0;
  11622. }
  11623. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  11624. struct snd_soc_dai *dai)
  11625. {
  11626. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11627. dev_get_drvdata(dai->dev);
  11628. int rc = 0;
  11629. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11630. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  11631. (dai_data->port_config.cdc_dma.data_format == 1))
  11632. dai_data->port_config.cdc_dma.data_format =
  11633. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  11634. rc = afe_send_cdc_dma_data_align(dai->id,
  11635. dai_data->cdc_dma_data_align);
  11636. if (rc)
  11637. pr_debug("%s: afe send data alignment failed %d\n",
  11638. __func__, rc);
  11639. rc = afe_port_start(dai->id, &dai_data->port_config,
  11640. dai_data->rate);
  11641. if (rc < 0)
  11642. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  11643. dai->id);
  11644. else
  11645. set_bit(STATUS_PORT_STARTED,
  11646. dai_data->status_mask);
  11647. }
  11648. return rc;
  11649. }
  11650. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  11651. struct snd_soc_dai *dai)
  11652. {
  11653. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  11654. int rc = 0;
  11655. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11656. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  11657. dai->id);
  11658. rc = afe_close(dai->id); /* can block */
  11659. if (rc < 0)
  11660. dev_err(dai->dev, "fail to close AFE port\n");
  11661. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  11662. *dai_data->status_mask);
  11663. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11664. }
  11665. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  11666. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  11667. }
  11668. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  11669. .prepare = msm_dai_q6_cdc_dma_prepare,
  11670. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11671. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11672. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11673. };
  11674. static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = {
  11675. .prepare = msm_dai_q6_cdc_dma_prepare,
  11676. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11677. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11678. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11679. .digital_mute = msm_dai_q6_spk_digital_mute,
  11680. };
  11681. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  11682. {
  11683. .playback = {
  11684. .stream_name = "WSA CDC DMA0 Playback",
  11685. .aif_name = "WSA_CDC_DMA_RX_0",
  11686. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11687. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11688. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11689. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11690. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11691. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11692. SNDRV_PCM_RATE_384000,
  11693. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11694. SNDRV_PCM_FMTBIT_S24_LE |
  11695. SNDRV_PCM_FMTBIT_S24_3LE |
  11696. SNDRV_PCM_FMTBIT_S32_LE,
  11697. .channels_min = 1,
  11698. .channels_max = 4,
  11699. .rate_min = 8000,
  11700. .rate_max = 384000,
  11701. },
  11702. .name = "WSA_CDC_DMA_RX_0",
  11703. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11704. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  11705. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11706. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11707. },
  11708. {
  11709. .capture = {
  11710. .stream_name = "WSA CDC DMA0 Capture",
  11711. .aif_name = "WSA_CDC_DMA_TX_0",
  11712. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11713. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11714. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11715. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11716. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11717. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11718. SNDRV_PCM_RATE_384000,
  11719. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11720. SNDRV_PCM_FMTBIT_S24_LE |
  11721. SNDRV_PCM_FMTBIT_S24_3LE |
  11722. SNDRV_PCM_FMTBIT_S32_LE,
  11723. .channels_min = 1,
  11724. .channels_max = 4,
  11725. .rate_min = 8000,
  11726. .rate_max = 384000,
  11727. },
  11728. .name = "WSA_CDC_DMA_TX_0",
  11729. .ops = &msm_dai_q6_cdc_dma_ops,
  11730. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  11731. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11732. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11733. },
  11734. {
  11735. .playback = {
  11736. .stream_name = "WSA CDC DMA1 Playback",
  11737. .aif_name = "WSA_CDC_DMA_RX_1",
  11738. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11739. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11740. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11741. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11742. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11743. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11744. SNDRV_PCM_RATE_384000,
  11745. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11746. SNDRV_PCM_FMTBIT_S24_LE |
  11747. SNDRV_PCM_FMTBIT_S24_3LE |
  11748. SNDRV_PCM_FMTBIT_S32_LE,
  11749. .channels_min = 1,
  11750. .channels_max = 2,
  11751. .rate_min = 8000,
  11752. .rate_max = 384000,
  11753. },
  11754. .name = "WSA_CDC_DMA_RX_1",
  11755. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11756. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  11757. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11758. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11759. },
  11760. {
  11761. .capture = {
  11762. .stream_name = "WSA CDC DMA1 Capture",
  11763. .aif_name = "WSA_CDC_DMA_TX_1",
  11764. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11765. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11766. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11767. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11768. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11769. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11770. SNDRV_PCM_RATE_384000,
  11771. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11772. SNDRV_PCM_FMTBIT_S24_LE |
  11773. SNDRV_PCM_FMTBIT_S24_3LE |
  11774. SNDRV_PCM_FMTBIT_S32_LE,
  11775. .channels_min = 1,
  11776. .channels_max = 2,
  11777. .rate_min = 8000,
  11778. .rate_max = 384000,
  11779. },
  11780. .name = "WSA_CDC_DMA_TX_1",
  11781. .ops = &msm_dai_q6_cdc_dma_ops,
  11782. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  11783. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11784. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11785. },
  11786. {
  11787. .capture = {
  11788. .stream_name = "WSA CDC DMA2 Capture",
  11789. .aif_name = "WSA_CDC_DMA_TX_2",
  11790. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11791. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11792. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11793. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11794. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11795. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11796. SNDRV_PCM_RATE_384000,
  11797. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11798. SNDRV_PCM_FMTBIT_S24_LE |
  11799. SNDRV_PCM_FMTBIT_S24_3LE |
  11800. SNDRV_PCM_FMTBIT_S32_LE,
  11801. .channels_min = 1,
  11802. .channels_max = 1,
  11803. .rate_min = 8000,
  11804. .rate_max = 384000,
  11805. },
  11806. .name = "WSA_CDC_DMA_TX_2",
  11807. .ops = &msm_dai_q6_cdc_dma_ops,
  11808. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  11809. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11810. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11811. },
  11812. {
  11813. .capture = {
  11814. .stream_name = "VA CDC DMA0 Capture",
  11815. .aif_name = "VA_CDC_DMA_TX_0",
  11816. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11817. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11818. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11819. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11820. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11821. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11822. SNDRV_PCM_RATE_384000,
  11823. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11824. SNDRV_PCM_FMTBIT_S24_LE |
  11825. SNDRV_PCM_FMTBIT_S24_3LE,
  11826. .channels_min = 1,
  11827. .channels_max = 8,
  11828. .rate_min = 8000,
  11829. .rate_max = 384000,
  11830. },
  11831. .name = "VA_CDC_DMA_TX_0",
  11832. .ops = &msm_dai_q6_cdc_dma_ops,
  11833. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  11834. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11835. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11836. },
  11837. {
  11838. .capture = {
  11839. .stream_name = "VA CDC DMA1 Capture",
  11840. .aif_name = "VA_CDC_DMA_TX_1",
  11841. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11842. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11843. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11844. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11845. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11846. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11847. SNDRV_PCM_RATE_384000,
  11848. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11849. SNDRV_PCM_FMTBIT_S24_LE |
  11850. SNDRV_PCM_FMTBIT_S24_3LE,
  11851. .channels_min = 1,
  11852. .channels_max = 8,
  11853. .rate_min = 8000,
  11854. .rate_max = 384000,
  11855. },
  11856. .name = "VA_CDC_DMA_TX_1",
  11857. .ops = &msm_dai_q6_cdc_dma_ops,
  11858. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  11859. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11860. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11861. },
  11862. {
  11863. .capture = {
  11864. .stream_name = "VA CDC DMA2 Capture",
  11865. .aif_name = "VA_CDC_DMA_TX_2",
  11866. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11867. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11868. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11869. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11870. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11871. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11872. SNDRV_PCM_RATE_384000,
  11873. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11874. SNDRV_PCM_FMTBIT_S24_LE |
  11875. SNDRV_PCM_FMTBIT_S24_3LE,
  11876. .channels_min = 1,
  11877. .channels_max = 8,
  11878. .rate_min = 8000,
  11879. .rate_max = 384000,
  11880. },
  11881. .name = "VA_CDC_DMA_TX_2",
  11882. .ops = &msm_dai_q6_cdc_dma_ops,
  11883. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  11884. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11885. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11886. },
  11887. {
  11888. .playback = {
  11889. .stream_name = "RX CDC DMA0 Playback",
  11890. .aif_name = "RX_CDC_DMA_RX_0",
  11891. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11892. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11893. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11894. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11895. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11896. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11897. SNDRV_PCM_RATE_384000,
  11898. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11899. SNDRV_PCM_FMTBIT_S24_LE |
  11900. SNDRV_PCM_FMTBIT_S24_3LE |
  11901. SNDRV_PCM_FMTBIT_S32_LE,
  11902. .channels_min = 1,
  11903. .channels_max = 2,
  11904. .rate_min = 8000,
  11905. .rate_max = 384000,
  11906. },
  11907. .ops = &msm_dai_q6_cdc_dma_ops,
  11908. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  11909. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11910. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11911. },
  11912. {
  11913. .capture = {
  11914. .stream_name = "TX CDC DMA0 Capture",
  11915. .aif_name = "TX_CDC_DMA_TX_0",
  11916. .rates = SNDRV_PCM_RATE_8000 |
  11917. SNDRV_PCM_RATE_16000 |
  11918. SNDRV_PCM_RATE_32000 |
  11919. SNDRV_PCM_RATE_48000 |
  11920. SNDRV_PCM_RATE_96000 |
  11921. SNDRV_PCM_RATE_192000 |
  11922. SNDRV_PCM_RATE_384000,
  11923. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11924. SNDRV_PCM_FMTBIT_S24_LE |
  11925. SNDRV_PCM_FMTBIT_S24_3LE |
  11926. SNDRV_PCM_FMTBIT_S32_LE,
  11927. .channels_min = 1,
  11928. .channels_max = 3,
  11929. .rate_min = 8000,
  11930. .rate_max = 384000,
  11931. },
  11932. .ops = &msm_dai_q6_cdc_dma_ops,
  11933. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  11934. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11935. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11936. },
  11937. {
  11938. .playback = {
  11939. .stream_name = "RX CDC DMA1 Playback",
  11940. .aif_name = "RX_CDC_DMA_RX_1",
  11941. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11942. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11943. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11944. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11945. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11946. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11947. SNDRV_PCM_RATE_384000,
  11948. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11949. SNDRV_PCM_FMTBIT_S24_LE |
  11950. SNDRV_PCM_FMTBIT_S24_3LE |
  11951. SNDRV_PCM_FMTBIT_S32_LE,
  11952. .channels_min = 1,
  11953. .channels_max = 2,
  11954. .rate_min = 8000,
  11955. .rate_max = 384000,
  11956. },
  11957. .ops = &msm_dai_q6_cdc_dma_ops,
  11958. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  11959. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11960. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11961. },
  11962. {
  11963. .capture = {
  11964. .stream_name = "TX CDC DMA1 Capture",
  11965. .aif_name = "TX_CDC_DMA_TX_1",
  11966. .rates = SNDRV_PCM_RATE_8000 |
  11967. SNDRV_PCM_RATE_16000 |
  11968. SNDRV_PCM_RATE_32000 |
  11969. SNDRV_PCM_RATE_48000 |
  11970. SNDRV_PCM_RATE_96000 |
  11971. SNDRV_PCM_RATE_192000 |
  11972. SNDRV_PCM_RATE_384000,
  11973. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11974. SNDRV_PCM_FMTBIT_S24_LE |
  11975. SNDRV_PCM_FMTBIT_S24_3LE |
  11976. SNDRV_PCM_FMTBIT_S32_LE,
  11977. .channels_min = 1,
  11978. .channels_max = 3,
  11979. .rate_min = 8000,
  11980. .rate_max = 384000,
  11981. },
  11982. .ops = &msm_dai_q6_cdc_dma_ops,
  11983. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  11984. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11985. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11986. },
  11987. {
  11988. .playback = {
  11989. .stream_name = "RX CDC DMA2 Playback",
  11990. .aif_name = "RX_CDC_DMA_RX_2",
  11991. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11992. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11993. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11994. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11995. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11996. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11997. SNDRV_PCM_RATE_384000,
  11998. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11999. SNDRV_PCM_FMTBIT_S24_LE |
  12000. SNDRV_PCM_FMTBIT_S24_3LE |
  12001. SNDRV_PCM_FMTBIT_S32_LE,
  12002. .channels_min = 1,
  12003. .channels_max = 1,
  12004. .rate_min = 8000,
  12005. .rate_max = 384000,
  12006. },
  12007. .ops = &msm_dai_q6_cdc_dma_ops,
  12008. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  12009. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12010. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12011. },
  12012. {
  12013. .capture = {
  12014. .stream_name = "TX CDC DMA2 Capture",
  12015. .aif_name = "TX_CDC_DMA_TX_2",
  12016. .rates = SNDRV_PCM_RATE_8000 |
  12017. SNDRV_PCM_RATE_16000 |
  12018. SNDRV_PCM_RATE_32000 |
  12019. SNDRV_PCM_RATE_48000 |
  12020. SNDRV_PCM_RATE_96000 |
  12021. SNDRV_PCM_RATE_192000 |
  12022. SNDRV_PCM_RATE_384000,
  12023. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12024. SNDRV_PCM_FMTBIT_S24_LE |
  12025. SNDRV_PCM_FMTBIT_S24_3LE |
  12026. SNDRV_PCM_FMTBIT_S32_LE,
  12027. .channels_min = 1,
  12028. .channels_max = 4,
  12029. .rate_min = 8000,
  12030. .rate_max = 384000,
  12031. },
  12032. .ops = &msm_dai_q6_cdc_dma_ops,
  12033. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  12034. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12035. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12036. }, {
  12037. .playback = {
  12038. .stream_name = "RX CDC DMA3 Playback",
  12039. .aif_name = "RX_CDC_DMA_RX_3",
  12040. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12041. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12042. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12043. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12044. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12045. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12046. SNDRV_PCM_RATE_384000,
  12047. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12048. SNDRV_PCM_FMTBIT_S24_LE |
  12049. SNDRV_PCM_FMTBIT_S24_3LE |
  12050. SNDRV_PCM_FMTBIT_S32_LE,
  12051. .channels_min = 1,
  12052. .channels_max = 1,
  12053. .rate_min = 8000,
  12054. .rate_max = 384000,
  12055. },
  12056. .ops = &msm_dai_q6_cdc_dma_ops,
  12057. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  12058. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12059. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12060. },
  12061. {
  12062. .capture = {
  12063. .stream_name = "TX CDC DMA3 Capture",
  12064. .aif_name = "TX_CDC_DMA_TX_3",
  12065. .rates = SNDRV_PCM_RATE_8000 |
  12066. SNDRV_PCM_RATE_16000 |
  12067. SNDRV_PCM_RATE_32000 |
  12068. SNDRV_PCM_RATE_48000 |
  12069. SNDRV_PCM_RATE_96000 |
  12070. SNDRV_PCM_RATE_192000 |
  12071. SNDRV_PCM_RATE_384000,
  12072. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12073. SNDRV_PCM_FMTBIT_S24_LE |
  12074. SNDRV_PCM_FMTBIT_S24_3LE |
  12075. SNDRV_PCM_FMTBIT_S32_LE,
  12076. .channels_min = 1,
  12077. .channels_max = 8,
  12078. .rate_min = 8000,
  12079. .rate_max = 384000,
  12080. },
  12081. .ops = &msm_dai_q6_cdc_dma_ops,
  12082. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  12083. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12084. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12085. },
  12086. {
  12087. .playback = {
  12088. .stream_name = "RX CDC DMA4 Playback",
  12089. .aif_name = "RX_CDC_DMA_RX_4",
  12090. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12091. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12092. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12093. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12094. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12095. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12096. SNDRV_PCM_RATE_384000,
  12097. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12098. SNDRV_PCM_FMTBIT_S24_LE |
  12099. SNDRV_PCM_FMTBIT_S24_3LE |
  12100. SNDRV_PCM_FMTBIT_S32_LE,
  12101. .channels_min = 1,
  12102. .channels_max = 6,
  12103. .rate_min = 8000,
  12104. .rate_max = 384000,
  12105. },
  12106. .ops = &msm_dai_q6_cdc_dma_ops,
  12107. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  12108. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12109. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12110. },
  12111. {
  12112. .capture = {
  12113. .stream_name = "TX CDC DMA4 Capture",
  12114. .aif_name = "TX_CDC_DMA_TX_4",
  12115. .rates = SNDRV_PCM_RATE_8000 |
  12116. SNDRV_PCM_RATE_16000 |
  12117. SNDRV_PCM_RATE_32000 |
  12118. SNDRV_PCM_RATE_48000 |
  12119. SNDRV_PCM_RATE_96000 |
  12120. SNDRV_PCM_RATE_192000 |
  12121. SNDRV_PCM_RATE_384000,
  12122. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12123. SNDRV_PCM_FMTBIT_S24_LE |
  12124. SNDRV_PCM_FMTBIT_S24_3LE |
  12125. SNDRV_PCM_FMTBIT_S32_LE,
  12126. .channels_min = 1,
  12127. .channels_max = 8,
  12128. .rate_min = 8000,
  12129. .rate_max = 384000,
  12130. },
  12131. .ops = &msm_dai_q6_cdc_dma_ops,
  12132. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  12133. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12134. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12135. },
  12136. {
  12137. .playback = {
  12138. .stream_name = "RX CDC DMA5 Playback",
  12139. .aif_name = "RX_CDC_DMA_RX_5",
  12140. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12141. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12142. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12143. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12144. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12145. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12146. SNDRV_PCM_RATE_384000,
  12147. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12148. SNDRV_PCM_FMTBIT_S24_LE |
  12149. SNDRV_PCM_FMTBIT_S24_3LE |
  12150. SNDRV_PCM_FMTBIT_S32_LE,
  12151. .channels_min = 1,
  12152. .channels_max = 1,
  12153. .rate_min = 8000,
  12154. .rate_max = 384000,
  12155. },
  12156. .ops = &msm_dai_q6_cdc_dma_ops,
  12157. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  12158. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12159. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12160. },
  12161. {
  12162. .capture = {
  12163. .stream_name = "TX CDC DMA5 Capture",
  12164. .aif_name = "TX_CDC_DMA_TX_5",
  12165. .rates = SNDRV_PCM_RATE_8000 |
  12166. SNDRV_PCM_RATE_16000 |
  12167. SNDRV_PCM_RATE_32000 |
  12168. SNDRV_PCM_RATE_48000 |
  12169. SNDRV_PCM_RATE_96000 |
  12170. SNDRV_PCM_RATE_192000 |
  12171. SNDRV_PCM_RATE_384000,
  12172. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12173. SNDRV_PCM_FMTBIT_S24_LE |
  12174. SNDRV_PCM_FMTBIT_S24_3LE |
  12175. SNDRV_PCM_FMTBIT_S32_LE,
  12176. .channels_min = 1,
  12177. .channels_max = 4,
  12178. .rate_min = 8000,
  12179. .rate_max = 384000,
  12180. },
  12181. .ops = &msm_dai_q6_cdc_dma_ops,
  12182. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  12183. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12184. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12185. },
  12186. {
  12187. .playback = {
  12188. .stream_name = "RX CDC DMA6 Playback",
  12189. .aif_name = "RX_CDC_DMA_RX_6",
  12190. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12191. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12192. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12193. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12194. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12195. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12196. SNDRV_PCM_RATE_384000,
  12197. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12198. SNDRV_PCM_FMTBIT_S24_LE |
  12199. SNDRV_PCM_FMTBIT_S24_3LE |
  12200. SNDRV_PCM_FMTBIT_S32_LE,
  12201. .channels_min = 1,
  12202. .channels_max = 4,
  12203. .rate_min = 8000,
  12204. .rate_max = 384000,
  12205. },
  12206. .ops = &msm_dai_q6_cdc_dma_ops,
  12207. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  12208. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12209. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12210. },
  12211. {
  12212. .playback = {
  12213. .stream_name = "RX CDC DMA7 Playback",
  12214. .aif_name = "RX_CDC_DMA_RX_7",
  12215. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  12216. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  12217. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  12218. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  12219. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  12220. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  12221. SNDRV_PCM_RATE_384000,
  12222. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  12223. SNDRV_PCM_FMTBIT_S24_LE |
  12224. SNDRV_PCM_FMTBIT_S24_3LE |
  12225. SNDRV_PCM_FMTBIT_S32_LE,
  12226. .channels_min = 1,
  12227. .channels_max = 2,
  12228. .rate_min = 8000,
  12229. .rate_max = 384000,
  12230. },
  12231. .ops = &msm_dai_q6_cdc_dma_ops,
  12232. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  12233. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12234. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12235. },
  12236. };
  12237. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  12238. .name = "msm-dai-cdc-dma-dev",
  12239. };
  12240. /* DT related probe for each codec DMA interface device */
  12241. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  12242. {
  12243. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  12244. u32 cdc_dma_id = 0;
  12245. int i;
  12246. int rc = 0;
  12247. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  12248. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  12249. &cdc_dma_id);
  12250. if (rc) {
  12251. dev_err(&pdev->dev,
  12252. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  12253. return rc;
  12254. }
  12255. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  12256. dev_name(&pdev->dev), cdc_dma_id);
  12257. pdev->id = cdc_dma_id;
  12258. dai_data = devm_kzalloc(&pdev->dev,
  12259. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  12260. GFP_KERNEL);
  12261. if (!dai_data)
  12262. return -ENOMEM;
  12263. rc = of_property_read_u32(pdev->dev.of_node,
  12264. "qcom,msm-dai-is-island-supported",
  12265. &dai_data->is_island_dai);
  12266. if (rc)
  12267. dev_dbg(&pdev->dev, "island supported entry not found\n");
  12268. rc = of_property_read_u32(pdev->dev.of_node,
  12269. "qcom,msm-cdc-dma-data-align",
  12270. &dai_data->cdc_dma_data_align);
  12271. if (rc)
  12272. dev_dbg(&pdev->dev, "cdc dma data align supported entry not found\n");
  12273. dev_set_drvdata(&pdev->dev, dai_data);
  12274. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  12275. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  12276. return snd_soc_register_component(&pdev->dev,
  12277. &msm_q6_cdc_dma_dai_component,
  12278. &msm_dai_q6_cdc_dma_dai[i], 1);
  12279. }
  12280. }
  12281. return -ENODEV;
  12282. }
  12283. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  12284. {
  12285. snd_soc_unregister_component(&pdev->dev);
  12286. return 0;
  12287. }
  12288. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  12289. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  12290. { }
  12291. };
  12292. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  12293. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  12294. .probe = msm_dai_q6_cdc_dma_dev_probe,
  12295. .remove = msm_dai_q6_cdc_dma_dev_remove,
  12296. .driver = {
  12297. .name = "msm-dai-cdc-dma-dev",
  12298. .owner = THIS_MODULE,
  12299. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  12300. .suppress_bind_attrs = true,
  12301. },
  12302. };
  12303. /* DT related probe for codec DMA interface device group */
  12304. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  12305. {
  12306. int rc;
  12307. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  12308. if (rc) {
  12309. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  12310. __func__, rc);
  12311. } else
  12312. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  12313. return rc;
  12314. }
  12315. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  12316. {
  12317. of_platform_depopulate(&pdev->dev);
  12318. return 0;
  12319. }
  12320. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  12321. { .compatible = "qcom,msm-dai-cdc-dma", },
  12322. { }
  12323. };
  12324. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  12325. static struct platform_driver msm_dai_cdc_dma_q6 = {
  12326. .probe = msm_dai_cdc_dma_q6_probe,
  12327. .remove = msm_dai_cdc_dma_q6_remove,
  12328. .driver = {
  12329. .name = "msm-dai-cdc-dma",
  12330. .owner = THIS_MODULE,
  12331. .of_match_table = msm_dai_cdc_dma_dt_match,
  12332. .suppress_bind_attrs = true,
  12333. },
  12334. };
  12335. int __init msm_dai_q6_init(void)
  12336. {
  12337. int rc;
  12338. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  12339. if (rc) {
  12340. pr_err("%s: fail to register auxpcm dev driver", __func__);
  12341. goto fail;
  12342. }
  12343. rc = platform_driver_register(&msm_dai_q6);
  12344. if (rc) {
  12345. pr_err("%s: fail to register dai q6 driver", __func__);
  12346. goto dai_q6_fail;
  12347. }
  12348. rc = platform_driver_register(&msm_dai_q6_dev);
  12349. if (rc) {
  12350. pr_err("%s: fail to register dai q6 dev driver", __func__);
  12351. goto dai_q6_dev_fail;
  12352. }
  12353. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  12354. if (rc) {
  12355. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  12356. goto dai_q6_mi2s_drv_fail;
  12357. }
  12358. rc = platform_driver_register(&msm_dai_q6_meta_mi2s_driver);
  12359. if (rc) {
  12360. pr_err("%s: fail to register dai META MI2S dev drv\n",
  12361. __func__);
  12362. goto dai_q6_meta_mi2s_drv_fail;
  12363. }
  12364. rc = platform_driver_register(&msm_dai_mi2s_q6);
  12365. if (rc) {
  12366. pr_err("%s: fail to register dai MI2S\n", __func__);
  12367. goto dai_mi2s_q6_fail;
  12368. }
  12369. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  12370. if (rc) {
  12371. pr_err("%s: fail to register dai SPDIF\n", __func__);
  12372. goto dai_spdif_q6_fail;
  12373. }
  12374. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  12375. if (rc) {
  12376. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  12377. goto dai_q6_tdm_drv_fail;
  12378. }
  12379. rc = platform_driver_register(&msm_dai_tdm_q6);
  12380. if (rc) {
  12381. pr_err("%s: fail to register dai TDM\n", __func__);
  12382. goto dai_tdm_q6_fail;
  12383. }
  12384. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  12385. if (rc) {
  12386. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  12387. goto dai_cdc_dma_q6_dev_fail;
  12388. }
  12389. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  12390. if (rc) {
  12391. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  12392. goto dai_cdc_dma_q6_fail;
  12393. }
  12394. return rc;
  12395. dai_cdc_dma_q6_fail:
  12396. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12397. dai_cdc_dma_q6_dev_fail:
  12398. platform_driver_unregister(&msm_dai_tdm_q6);
  12399. dai_tdm_q6_fail:
  12400. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12401. dai_q6_tdm_drv_fail:
  12402. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12403. dai_spdif_q6_fail:
  12404. platform_driver_unregister(&msm_dai_mi2s_q6);
  12405. dai_mi2s_q6_fail:
  12406. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12407. dai_q6_meta_mi2s_drv_fail:
  12408. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12409. dai_q6_mi2s_drv_fail:
  12410. platform_driver_unregister(&msm_dai_q6_dev);
  12411. dai_q6_dev_fail:
  12412. platform_driver_unregister(&msm_dai_q6);
  12413. dai_q6_fail:
  12414. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12415. fail:
  12416. return rc;
  12417. }
  12418. void msm_dai_q6_exit(void)
  12419. {
  12420. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  12421. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12422. platform_driver_unregister(&msm_dai_tdm_q6);
  12423. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12424. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12425. platform_driver_unregister(&msm_dai_mi2s_q6);
  12426. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12427. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12428. platform_driver_unregister(&msm_dai_q6_dev);
  12429. platform_driver_unregister(&msm_dai_q6);
  12430. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12431. }
  12432. /* Module information */
  12433. MODULE_DESCRIPTION("MSM DSP DAI driver");
  12434. MODULE_LICENSE("GPL v2");