msm-dai-q6-v2.c 262 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944
  1. /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/bitops.h>
  17. #include <linux/slab.h>
  18. #include <linux/clk.h>
  19. #include <linux/of_device.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/soc.h>
  23. #include <sound/pcm_params.h>
  24. #include <dsp/apr_audio-v2.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include "msm-dai-q6-v2.h"
  27. #include "codecs/core.h"
  28. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  29. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  30. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  31. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  32. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  33. #define spdif_clock_value(rate) (2*rate*32*2)
  34. #define CHANNEL_STATUS_SIZE 24
  35. #define CHANNEL_STATUS_MASK_INIT 0x0
  36. #define CHANNEL_STATUS_MASK 0x4
  37. #define AFE_API_VERSION_CLOCK_SET 1
  38. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  39. SNDRV_PCM_FMTBIT_S24_LE | \
  40. SNDRV_PCM_FMTBIT_S32_LE)
  41. enum {
  42. ENC_FMT_NONE,
  43. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  44. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  45. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  46. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  47. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  48. };
  49. enum {
  50. SPKR_1,
  51. SPKR_2,
  52. };
  53. static const struct afe_clk_set lpass_clk_set_default = {
  54. AFE_API_VERSION_CLOCK_SET,
  55. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  56. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  57. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  58. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  59. 0,
  60. };
  61. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  62. AFE_API_VERSION_I2S_CONFIG,
  63. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  64. 0,
  65. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  66. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  67. Q6AFE_LPASS_MODE_CLK1_VALID,
  68. 0,
  69. };
  70. enum {
  71. STATUS_PORT_STARTED, /* track if AFE port has started */
  72. /* track AFE Tx port status for bi-directional transfers */
  73. STATUS_TX_PORT,
  74. /* track AFE Rx port status for bi-directional transfers */
  75. STATUS_RX_PORT,
  76. STATUS_MAX
  77. };
  78. enum {
  79. RATE_8KHZ,
  80. RATE_16KHZ,
  81. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  82. };
  83. enum {
  84. IDX_PRIMARY_TDM_RX_0,
  85. IDX_PRIMARY_TDM_RX_1,
  86. IDX_PRIMARY_TDM_RX_2,
  87. IDX_PRIMARY_TDM_RX_3,
  88. IDX_PRIMARY_TDM_RX_4,
  89. IDX_PRIMARY_TDM_RX_5,
  90. IDX_PRIMARY_TDM_RX_6,
  91. IDX_PRIMARY_TDM_RX_7,
  92. IDX_PRIMARY_TDM_TX_0,
  93. IDX_PRIMARY_TDM_TX_1,
  94. IDX_PRIMARY_TDM_TX_2,
  95. IDX_PRIMARY_TDM_TX_3,
  96. IDX_PRIMARY_TDM_TX_4,
  97. IDX_PRIMARY_TDM_TX_5,
  98. IDX_PRIMARY_TDM_TX_6,
  99. IDX_PRIMARY_TDM_TX_7,
  100. IDX_SECONDARY_TDM_RX_0,
  101. IDX_SECONDARY_TDM_RX_1,
  102. IDX_SECONDARY_TDM_RX_2,
  103. IDX_SECONDARY_TDM_RX_3,
  104. IDX_SECONDARY_TDM_RX_4,
  105. IDX_SECONDARY_TDM_RX_5,
  106. IDX_SECONDARY_TDM_RX_6,
  107. IDX_SECONDARY_TDM_RX_7,
  108. IDX_SECONDARY_TDM_TX_0,
  109. IDX_SECONDARY_TDM_TX_1,
  110. IDX_SECONDARY_TDM_TX_2,
  111. IDX_SECONDARY_TDM_TX_3,
  112. IDX_SECONDARY_TDM_TX_4,
  113. IDX_SECONDARY_TDM_TX_5,
  114. IDX_SECONDARY_TDM_TX_6,
  115. IDX_SECONDARY_TDM_TX_7,
  116. IDX_TERTIARY_TDM_RX_0,
  117. IDX_TERTIARY_TDM_RX_1,
  118. IDX_TERTIARY_TDM_RX_2,
  119. IDX_TERTIARY_TDM_RX_3,
  120. IDX_TERTIARY_TDM_RX_4,
  121. IDX_TERTIARY_TDM_RX_5,
  122. IDX_TERTIARY_TDM_RX_6,
  123. IDX_TERTIARY_TDM_RX_7,
  124. IDX_TERTIARY_TDM_TX_0,
  125. IDX_TERTIARY_TDM_TX_1,
  126. IDX_TERTIARY_TDM_TX_2,
  127. IDX_TERTIARY_TDM_TX_3,
  128. IDX_TERTIARY_TDM_TX_4,
  129. IDX_TERTIARY_TDM_TX_5,
  130. IDX_TERTIARY_TDM_TX_6,
  131. IDX_TERTIARY_TDM_TX_7,
  132. IDX_QUATERNARY_TDM_RX_0,
  133. IDX_QUATERNARY_TDM_RX_1,
  134. IDX_QUATERNARY_TDM_RX_2,
  135. IDX_QUATERNARY_TDM_RX_3,
  136. IDX_QUATERNARY_TDM_RX_4,
  137. IDX_QUATERNARY_TDM_RX_5,
  138. IDX_QUATERNARY_TDM_RX_6,
  139. IDX_QUATERNARY_TDM_RX_7,
  140. IDX_QUATERNARY_TDM_TX_0,
  141. IDX_QUATERNARY_TDM_TX_1,
  142. IDX_QUATERNARY_TDM_TX_2,
  143. IDX_QUATERNARY_TDM_TX_3,
  144. IDX_QUATERNARY_TDM_TX_4,
  145. IDX_QUATERNARY_TDM_TX_5,
  146. IDX_QUATERNARY_TDM_TX_6,
  147. IDX_QUATERNARY_TDM_TX_7,
  148. IDX_QUINARY_TDM_RX_0,
  149. IDX_QUINARY_TDM_RX_1,
  150. IDX_QUINARY_TDM_RX_2,
  151. IDX_QUINARY_TDM_RX_3,
  152. IDX_QUINARY_TDM_RX_4,
  153. IDX_QUINARY_TDM_RX_5,
  154. IDX_QUINARY_TDM_RX_6,
  155. IDX_QUINARY_TDM_RX_7,
  156. IDX_QUINARY_TDM_TX_0,
  157. IDX_QUINARY_TDM_TX_1,
  158. IDX_QUINARY_TDM_TX_2,
  159. IDX_QUINARY_TDM_TX_3,
  160. IDX_QUINARY_TDM_TX_4,
  161. IDX_QUINARY_TDM_TX_5,
  162. IDX_QUINARY_TDM_TX_6,
  163. IDX_QUINARY_TDM_TX_7,
  164. IDX_TDM_MAX,
  165. };
  166. enum {
  167. IDX_GROUP_PRIMARY_TDM_RX,
  168. IDX_GROUP_PRIMARY_TDM_TX,
  169. IDX_GROUP_SECONDARY_TDM_RX,
  170. IDX_GROUP_SECONDARY_TDM_TX,
  171. IDX_GROUP_TERTIARY_TDM_RX,
  172. IDX_GROUP_TERTIARY_TDM_TX,
  173. IDX_GROUP_QUATERNARY_TDM_RX,
  174. IDX_GROUP_QUATERNARY_TDM_TX,
  175. IDX_GROUP_QUINARY_TDM_RX,
  176. IDX_GROUP_QUINARY_TDM_TX,
  177. IDX_GROUP_TDM_MAX,
  178. };
  179. struct msm_dai_q6_dai_data {
  180. DECLARE_BITMAP(status_mask, STATUS_MAX);
  181. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  182. u32 rate;
  183. u32 channels;
  184. u32 bitwidth;
  185. u32 cal_mode;
  186. u32 afe_in_channels;
  187. u16 afe_in_bitformat;
  188. struct afe_enc_config enc_config;
  189. union afe_port_config port_config;
  190. u16 vi_feed_mono;
  191. };
  192. struct msm_dai_q6_spdif_dai_data {
  193. DECLARE_BITMAP(status_mask, STATUS_MAX);
  194. u32 rate;
  195. u32 channels;
  196. u32 bitwidth;
  197. struct afe_spdif_port_config spdif_port;
  198. };
  199. struct msm_dai_q6_mi2s_dai_config {
  200. u16 pdata_mi2s_lines;
  201. struct msm_dai_q6_dai_data mi2s_dai_data;
  202. };
  203. struct msm_dai_q6_mi2s_dai_data {
  204. struct msm_dai_q6_mi2s_dai_config tx_dai;
  205. struct msm_dai_q6_mi2s_dai_config rx_dai;
  206. };
  207. struct msm_dai_q6_auxpcm_dai_data {
  208. /* BITMAP to track Rx and Tx port usage count */
  209. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  210. struct mutex rlock; /* auxpcm dev resource lock */
  211. u16 rx_pid; /* AUXPCM RX AFE port ID */
  212. u16 tx_pid; /* AUXPCM TX AFE port ID */
  213. u16 afe_clk_ver;
  214. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  215. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  216. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  217. };
  218. struct msm_dai_q6_tdm_dai_data {
  219. DECLARE_BITMAP(status_mask, STATUS_MAX);
  220. u32 rate;
  221. u32 channels;
  222. u32 bitwidth;
  223. u32 num_group_ports;
  224. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  225. union afe_port_group_config group_cfg; /* hold tdm group config */
  226. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  227. };
  228. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  229. * 0: linear PCM
  230. * 1: non-linear PCM
  231. * 2: PCM data in IEC 60968 container
  232. * 3: compressed data in IEC 60958 container
  233. */
  234. static const char *const mi2s_format[] = {
  235. "LPCM",
  236. "Compr",
  237. "LPCM-60958",
  238. "Compr-60958"
  239. };
  240. static const char *const mi2s_vi_feed_mono[] = {
  241. "Left",
  242. "Right",
  243. };
  244. static const struct soc_enum mi2s_config_enum[] = {
  245. SOC_ENUM_SINGLE_EXT(4, mi2s_format),
  246. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  247. };
  248. static const char *const sb_format[] = {
  249. "UNPACKED",
  250. "PACKED_16B",
  251. "DSD_DOP",
  252. };
  253. static const struct soc_enum sb_config_enum[] = {
  254. SOC_ENUM_SINGLE_EXT(3, sb_format),
  255. };
  256. static const char *const tdm_data_format[] = {
  257. "LPCM",
  258. "Compr",
  259. "Gen Compr"
  260. };
  261. static const char *const tdm_header_type[] = {
  262. "Invalid",
  263. "Default",
  264. "Entertainment",
  265. };
  266. static const struct soc_enum tdm_config_enum[] = {
  267. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  268. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  269. };
  270. static DEFINE_MUTEX(tdm_mutex);
  271. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  272. /* cache of group cfg per parent node */
  273. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  274. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  275. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  276. 0,
  277. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  278. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  279. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  280. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  281. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  282. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  283. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  284. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  285. 8,
  286. 48000,
  287. 32,
  288. 8,
  289. 32,
  290. 0xFF,
  291. };
  292. static u32 num_tdm_group_ports;
  293. static struct afe_clk_set tdm_clk_set = {
  294. AFE_API_VERSION_CLOCK_SET,
  295. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  296. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  297. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  298. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  299. 0,
  300. };
  301. int msm_dai_q6_get_group_idx(u16 id)
  302. {
  303. switch (id) {
  304. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  305. case AFE_PORT_ID_PRIMARY_TDM_RX:
  306. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  307. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  308. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  309. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  310. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  311. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  312. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  313. return IDX_GROUP_PRIMARY_TDM_RX;
  314. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  315. case AFE_PORT_ID_PRIMARY_TDM_TX:
  316. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  317. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  318. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  319. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  320. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  321. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  322. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  323. return IDX_GROUP_PRIMARY_TDM_TX;
  324. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  325. case AFE_PORT_ID_SECONDARY_TDM_RX:
  326. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  327. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  328. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  329. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  330. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  331. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  332. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  333. return IDX_GROUP_SECONDARY_TDM_RX;
  334. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  335. case AFE_PORT_ID_SECONDARY_TDM_TX:
  336. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  337. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  338. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  339. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  340. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  341. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  342. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  343. return IDX_GROUP_SECONDARY_TDM_TX;
  344. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  345. case AFE_PORT_ID_TERTIARY_TDM_RX:
  346. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  347. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  348. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  349. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  350. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  351. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  352. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  353. return IDX_GROUP_TERTIARY_TDM_RX;
  354. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  355. case AFE_PORT_ID_TERTIARY_TDM_TX:
  356. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  357. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  358. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  359. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  360. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  361. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  362. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  363. return IDX_GROUP_TERTIARY_TDM_TX;
  364. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  365. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  366. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  367. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  368. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  369. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  370. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  371. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  372. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  373. return IDX_GROUP_QUATERNARY_TDM_RX;
  374. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  375. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  376. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  377. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  378. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  379. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  380. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  381. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  382. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  383. return IDX_GROUP_QUATERNARY_TDM_TX;
  384. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  385. case AFE_PORT_ID_QUINARY_TDM_RX:
  386. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  387. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  388. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  389. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  390. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  391. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  392. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  393. return IDX_GROUP_QUINARY_TDM_RX;
  394. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  395. case AFE_PORT_ID_QUINARY_TDM_TX:
  396. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  397. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  398. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  399. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  400. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  401. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  402. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  403. return IDX_GROUP_QUINARY_TDM_TX;
  404. default: return -EINVAL;
  405. }
  406. }
  407. int msm_dai_q6_get_port_idx(u16 id)
  408. {
  409. switch (id) {
  410. case AFE_PORT_ID_PRIMARY_TDM_RX:
  411. return IDX_PRIMARY_TDM_RX_0;
  412. case AFE_PORT_ID_PRIMARY_TDM_TX:
  413. return IDX_PRIMARY_TDM_TX_0;
  414. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  415. return IDX_PRIMARY_TDM_RX_1;
  416. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  417. return IDX_PRIMARY_TDM_TX_1;
  418. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  419. return IDX_PRIMARY_TDM_RX_2;
  420. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  421. return IDX_PRIMARY_TDM_TX_2;
  422. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  423. return IDX_PRIMARY_TDM_RX_3;
  424. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  425. return IDX_PRIMARY_TDM_TX_3;
  426. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  427. return IDX_PRIMARY_TDM_RX_4;
  428. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  429. return IDX_PRIMARY_TDM_TX_4;
  430. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  431. return IDX_PRIMARY_TDM_RX_5;
  432. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  433. return IDX_PRIMARY_TDM_TX_5;
  434. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  435. return IDX_PRIMARY_TDM_RX_6;
  436. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  437. return IDX_PRIMARY_TDM_TX_6;
  438. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  439. return IDX_PRIMARY_TDM_RX_7;
  440. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  441. return IDX_PRIMARY_TDM_TX_7;
  442. case AFE_PORT_ID_SECONDARY_TDM_RX:
  443. return IDX_SECONDARY_TDM_RX_0;
  444. case AFE_PORT_ID_SECONDARY_TDM_TX:
  445. return IDX_SECONDARY_TDM_TX_0;
  446. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  447. return IDX_SECONDARY_TDM_RX_1;
  448. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  449. return IDX_SECONDARY_TDM_TX_1;
  450. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  451. return IDX_SECONDARY_TDM_RX_2;
  452. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  453. return IDX_SECONDARY_TDM_TX_2;
  454. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  455. return IDX_SECONDARY_TDM_RX_3;
  456. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  457. return IDX_SECONDARY_TDM_TX_3;
  458. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  459. return IDX_SECONDARY_TDM_RX_4;
  460. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  461. return IDX_SECONDARY_TDM_TX_4;
  462. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  463. return IDX_SECONDARY_TDM_RX_5;
  464. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  465. return IDX_SECONDARY_TDM_TX_5;
  466. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  467. return IDX_SECONDARY_TDM_RX_6;
  468. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  469. return IDX_SECONDARY_TDM_TX_6;
  470. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  471. return IDX_SECONDARY_TDM_RX_7;
  472. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  473. return IDX_SECONDARY_TDM_TX_7;
  474. case AFE_PORT_ID_TERTIARY_TDM_RX:
  475. return IDX_TERTIARY_TDM_RX_0;
  476. case AFE_PORT_ID_TERTIARY_TDM_TX:
  477. return IDX_TERTIARY_TDM_TX_0;
  478. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  479. return IDX_TERTIARY_TDM_RX_1;
  480. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  481. return IDX_TERTIARY_TDM_TX_1;
  482. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  483. return IDX_TERTIARY_TDM_RX_2;
  484. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  485. return IDX_TERTIARY_TDM_TX_2;
  486. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  487. return IDX_TERTIARY_TDM_RX_3;
  488. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  489. return IDX_TERTIARY_TDM_TX_3;
  490. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  491. return IDX_TERTIARY_TDM_RX_4;
  492. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  493. return IDX_TERTIARY_TDM_TX_4;
  494. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  495. return IDX_TERTIARY_TDM_RX_5;
  496. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  497. return IDX_TERTIARY_TDM_TX_5;
  498. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  499. return IDX_TERTIARY_TDM_RX_6;
  500. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  501. return IDX_TERTIARY_TDM_TX_6;
  502. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  503. return IDX_TERTIARY_TDM_RX_7;
  504. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  505. return IDX_TERTIARY_TDM_TX_7;
  506. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  507. return IDX_QUATERNARY_TDM_RX_0;
  508. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  509. return IDX_QUATERNARY_TDM_TX_0;
  510. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  511. return IDX_QUATERNARY_TDM_RX_1;
  512. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  513. return IDX_QUATERNARY_TDM_TX_1;
  514. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  515. return IDX_QUATERNARY_TDM_RX_2;
  516. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  517. return IDX_QUATERNARY_TDM_TX_2;
  518. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  519. return IDX_QUATERNARY_TDM_RX_3;
  520. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  521. return IDX_QUATERNARY_TDM_TX_3;
  522. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  523. return IDX_QUATERNARY_TDM_RX_4;
  524. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  525. return IDX_QUATERNARY_TDM_TX_4;
  526. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  527. return IDX_QUATERNARY_TDM_RX_5;
  528. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  529. return IDX_QUATERNARY_TDM_TX_5;
  530. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  531. return IDX_QUATERNARY_TDM_RX_6;
  532. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  533. return IDX_QUATERNARY_TDM_TX_6;
  534. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  535. return IDX_QUATERNARY_TDM_RX_7;
  536. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  537. return IDX_QUATERNARY_TDM_TX_7;
  538. case AFE_PORT_ID_QUINARY_TDM_RX:
  539. return IDX_QUINARY_TDM_RX_0;
  540. case AFE_PORT_ID_QUINARY_TDM_TX:
  541. return IDX_QUINARY_TDM_TX_0;
  542. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  543. return IDX_QUINARY_TDM_RX_1;
  544. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  545. return IDX_QUINARY_TDM_TX_1;
  546. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  547. return IDX_QUINARY_TDM_RX_2;
  548. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  549. return IDX_QUINARY_TDM_TX_2;
  550. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  551. return IDX_QUINARY_TDM_RX_3;
  552. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  553. return IDX_QUINARY_TDM_TX_3;
  554. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  555. return IDX_QUINARY_TDM_RX_4;
  556. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  557. return IDX_QUINARY_TDM_TX_4;
  558. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  559. return IDX_QUINARY_TDM_RX_5;
  560. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  561. return IDX_QUINARY_TDM_TX_5;
  562. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  563. return IDX_QUINARY_TDM_RX_6;
  564. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  565. return IDX_QUINARY_TDM_TX_6;
  566. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  567. return IDX_QUINARY_TDM_RX_7;
  568. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  569. return IDX_QUINARY_TDM_TX_7;
  570. default: return -EINVAL;
  571. }
  572. }
  573. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  574. {
  575. /* Max num of slots is bits per frame divided
  576. * by bits per sample which is 16
  577. */
  578. switch (frame_rate) {
  579. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  580. return 0;
  581. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  582. return 1;
  583. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  584. return 2;
  585. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  586. return 4;
  587. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  588. return 8;
  589. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  590. return 16;
  591. default:
  592. pr_err("%s Invalid bits per frame %d\n",
  593. __func__, frame_rate);
  594. return 0;
  595. }
  596. }
  597. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  598. {
  599. struct snd_soc_dapm_route intercon;
  600. struct snd_soc_dapm_context *dapm;
  601. if (!dai) {
  602. pr_err("%s: Invalid params dai\n", __func__);
  603. return -EINVAL;
  604. }
  605. if (!dai->driver) {
  606. pr_err("%s: Invalid params dai driver\n", __func__);
  607. return -EINVAL;
  608. }
  609. dapm = snd_soc_component_get_dapm(dai->component);
  610. memset(&intercon, 0, sizeof(intercon));
  611. if (dai->driver->playback.stream_name &&
  612. dai->driver->playback.aif_name) {
  613. dev_dbg(dai->dev, "%s: add route for widget %s",
  614. __func__, dai->driver->playback.stream_name);
  615. intercon.source = dai->driver->playback.aif_name;
  616. intercon.sink = dai->driver->playback.stream_name;
  617. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  618. __func__, intercon.source, intercon.sink);
  619. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  620. }
  621. if (dai->driver->capture.stream_name &&
  622. dai->driver->capture.aif_name) {
  623. dev_dbg(dai->dev, "%s: add route for widget %s",
  624. __func__, dai->driver->capture.stream_name);
  625. intercon.sink = dai->driver->capture.aif_name;
  626. intercon.source = dai->driver->capture.stream_name;
  627. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  628. __func__, intercon.source, intercon.sink);
  629. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  630. }
  631. return 0;
  632. }
  633. static int msm_dai_q6_auxpcm_hw_params(
  634. struct snd_pcm_substream *substream,
  635. struct snd_pcm_hw_params *params,
  636. struct snd_soc_dai *dai)
  637. {
  638. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  639. dev_get_drvdata(dai->dev);
  640. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  641. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  642. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  643. int rc = 0, slot_mapping_copy_len = 0;
  644. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  645. params_rate(params) != 16000)) {
  646. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  647. __func__, params_channels(params), params_rate(params));
  648. return -EINVAL;
  649. }
  650. mutex_lock(&aux_dai_data->rlock);
  651. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  652. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  653. /* AUXPCM DAI in use */
  654. if (dai_data->rate != params_rate(params)) {
  655. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  656. __func__);
  657. rc = -EINVAL;
  658. }
  659. mutex_unlock(&aux_dai_data->rlock);
  660. return rc;
  661. }
  662. dai_data->channels = params_channels(params);
  663. dai_data->rate = params_rate(params);
  664. if (dai_data->rate == 8000) {
  665. dai_data->port_config.pcm.pcm_cfg_minor_version =
  666. AFE_API_VERSION_PCM_CONFIG;
  667. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  668. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  669. dai_data->port_config.pcm.frame_setting =
  670. auxpcm_pdata->mode_8k.frame;
  671. dai_data->port_config.pcm.quantype =
  672. auxpcm_pdata->mode_8k.quant;
  673. dai_data->port_config.pcm.ctrl_data_out_enable =
  674. auxpcm_pdata->mode_8k.data;
  675. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  676. dai_data->port_config.pcm.num_channels = dai_data->channels;
  677. dai_data->port_config.pcm.bit_width = 16;
  678. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  679. auxpcm_pdata->mode_8k.num_slots)
  680. slot_mapping_copy_len =
  681. ARRAY_SIZE(
  682. dai_data->port_config.pcm.slot_number_mapping)
  683. * sizeof(uint16_t);
  684. else
  685. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  686. * sizeof(uint16_t);
  687. if (auxpcm_pdata->mode_8k.slot_mapping) {
  688. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  689. auxpcm_pdata->mode_8k.slot_mapping,
  690. slot_mapping_copy_len);
  691. } else {
  692. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  693. __func__);
  694. mutex_unlock(&aux_dai_data->rlock);
  695. return -EINVAL;
  696. }
  697. } else {
  698. dai_data->port_config.pcm.pcm_cfg_minor_version =
  699. AFE_API_VERSION_PCM_CONFIG;
  700. dai_data->port_config.pcm.aux_mode =
  701. auxpcm_pdata->mode_16k.mode;
  702. dai_data->port_config.pcm.sync_src =
  703. auxpcm_pdata->mode_16k.sync;
  704. dai_data->port_config.pcm.frame_setting =
  705. auxpcm_pdata->mode_16k.frame;
  706. dai_data->port_config.pcm.quantype =
  707. auxpcm_pdata->mode_16k.quant;
  708. dai_data->port_config.pcm.ctrl_data_out_enable =
  709. auxpcm_pdata->mode_16k.data;
  710. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  711. dai_data->port_config.pcm.num_channels = dai_data->channels;
  712. dai_data->port_config.pcm.bit_width = 16;
  713. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  714. auxpcm_pdata->mode_16k.num_slots)
  715. slot_mapping_copy_len =
  716. ARRAY_SIZE(
  717. dai_data->port_config.pcm.slot_number_mapping)
  718. * sizeof(uint16_t);
  719. else
  720. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  721. * sizeof(uint16_t);
  722. if (auxpcm_pdata->mode_16k.slot_mapping) {
  723. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  724. auxpcm_pdata->mode_16k.slot_mapping,
  725. slot_mapping_copy_len);
  726. } else {
  727. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  728. __func__);
  729. mutex_unlock(&aux_dai_data->rlock);
  730. return -EINVAL;
  731. }
  732. }
  733. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  734. __func__, dai_data->port_config.pcm.aux_mode,
  735. dai_data->port_config.pcm.sync_src,
  736. dai_data->port_config.pcm.frame_setting);
  737. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  738. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  739. __func__, dai_data->port_config.pcm.quantype,
  740. dai_data->port_config.pcm.ctrl_data_out_enable,
  741. dai_data->port_config.pcm.slot_number_mapping[0],
  742. dai_data->port_config.pcm.slot_number_mapping[1],
  743. dai_data->port_config.pcm.slot_number_mapping[2],
  744. dai_data->port_config.pcm.slot_number_mapping[3]);
  745. mutex_unlock(&aux_dai_data->rlock);
  746. return rc;
  747. }
  748. static int msm_dai_q6_auxpcm_set_clk(
  749. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  750. u16 port_id, bool enable)
  751. {
  752. int rc;
  753. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  754. aux_dai_data->afe_clk_ver, port_id, enable);
  755. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  756. aux_dai_data->clk_set.enable = enable;
  757. rc = afe_set_lpass_clock_v2(port_id,
  758. &aux_dai_data->clk_set);
  759. } else {
  760. if (!enable)
  761. aux_dai_data->clk_cfg.clk_val1 = 0;
  762. rc = afe_set_lpass_clock(port_id,
  763. &aux_dai_data->clk_cfg);
  764. }
  765. return rc;
  766. }
  767. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  768. struct snd_soc_dai *dai)
  769. {
  770. int rc = 0;
  771. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  772. dev_get_drvdata(dai->dev);
  773. mutex_lock(&aux_dai_data->rlock);
  774. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  775. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  776. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  777. __func__, dai->id);
  778. goto exit;
  779. }
  780. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  781. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  782. clear_bit(STATUS_TX_PORT,
  783. aux_dai_data->auxpcm_port_status);
  784. else {
  785. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  786. __func__);
  787. goto exit;
  788. }
  789. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  790. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  791. clear_bit(STATUS_RX_PORT,
  792. aux_dai_data->auxpcm_port_status);
  793. else {
  794. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  795. __func__);
  796. goto exit;
  797. }
  798. }
  799. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  800. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  801. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  802. __func__);
  803. goto exit;
  804. }
  805. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  806. __func__, dai->id);
  807. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  808. if (rc < 0)
  809. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  810. rc = afe_close(aux_dai_data->tx_pid);
  811. if (rc < 0)
  812. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  813. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  814. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  815. exit:
  816. mutex_unlock(&aux_dai_data->rlock);
  817. }
  818. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  819. struct snd_soc_dai *dai)
  820. {
  821. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  822. dev_get_drvdata(dai->dev);
  823. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  824. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  825. int rc = 0;
  826. u32 pcm_clk_rate;
  827. auxpcm_pdata = dai->dev->platform_data;
  828. mutex_lock(&aux_dai_data->rlock);
  829. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  830. if (test_bit(STATUS_TX_PORT,
  831. aux_dai_data->auxpcm_port_status)) {
  832. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  833. __func__);
  834. goto exit;
  835. } else
  836. set_bit(STATUS_TX_PORT,
  837. aux_dai_data->auxpcm_port_status);
  838. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  839. if (test_bit(STATUS_RX_PORT,
  840. aux_dai_data->auxpcm_port_status)) {
  841. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  842. __func__);
  843. goto exit;
  844. } else
  845. set_bit(STATUS_RX_PORT,
  846. aux_dai_data->auxpcm_port_status);
  847. }
  848. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  849. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  850. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  851. goto exit;
  852. }
  853. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  854. __func__, dai->id);
  855. rc = afe_q6_interface_prepare();
  856. if (rc < 0) {
  857. dev_err(dai->dev, "fail to open AFE APR\n");
  858. goto fail;
  859. }
  860. /*
  861. * For AUX PCM Interface the below sequence of clk
  862. * settings and afe_open is a strict requirement.
  863. *
  864. * Also using afe_open instead of afe_port_start_nowait
  865. * to make sure the port is open before deasserting the
  866. * clock line. This is required because pcm register is
  867. * not written before clock deassert. Hence the hw does
  868. * not get updated with new setting if the below clock
  869. * assert/deasset and afe_open sequence is not followed.
  870. */
  871. if (dai_data->rate == 8000) {
  872. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  873. } else if (dai_data->rate == 16000) {
  874. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  875. } else {
  876. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  877. dai_data->rate);
  878. rc = -EINVAL;
  879. goto fail;
  880. }
  881. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  882. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  883. sizeof(struct afe_clk_set));
  884. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  885. switch (dai->id) {
  886. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  887. if (pcm_clk_rate)
  888. aux_dai_data->clk_set.clk_id =
  889. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  890. else
  891. aux_dai_data->clk_set.clk_id =
  892. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  893. break;
  894. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  895. if (pcm_clk_rate)
  896. aux_dai_data->clk_set.clk_id =
  897. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  898. else
  899. aux_dai_data->clk_set.clk_id =
  900. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  901. break;
  902. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  903. if (pcm_clk_rate)
  904. aux_dai_data->clk_set.clk_id =
  905. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  906. else
  907. aux_dai_data->clk_set.clk_id =
  908. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  909. break;
  910. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  911. if (pcm_clk_rate)
  912. aux_dai_data->clk_set.clk_id =
  913. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  914. else
  915. aux_dai_data->clk_set.clk_id =
  916. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  917. break;
  918. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  919. if (pcm_clk_rate)
  920. aux_dai_data->clk_set.clk_id =
  921. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  922. else
  923. aux_dai_data->clk_set.clk_id =
  924. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  925. break;
  926. default:
  927. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  928. __func__, dai->id);
  929. break;
  930. }
  931. } else {
  932. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  933. sizeof(struct afe_clk_cfg));
  934. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  935. }
  936. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  937. aux_dai_data->rx_pid, true);
  938. if (rc < 0) {
  939. dev_err(dai->dev,
  940. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  941. __func__);
  942. goto fail;
  943. }
  944. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  945. aux_dai_data->tx_pid, true);
  946. if (rc < 0) {
  947. dev_err(dai->dev,
  948. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  949. __func__);
  950. goto fail;
  951. }
  952. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  953. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  954. goto exit;
  955. fail:
  956. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  957. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  958. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  959. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  960. exit:
  961. mutex_unlock(&aux_dai_data->rlock);
  962. return rc;
  963. }
  964. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  965. int cmd, struct snd_soc_dai *dai)
  966. {
  967. int rc = 0;
  968. pr_debug("%s:port:%d cmd:%d\n",
  969. __func__, dai->id, cmd);
  970. switch (cmd) {
  971. case SNDRV_PCM_TRIGGER_START:
  972. case SNDRV_PCM_TRIGGER_RESUME:
  973. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  974. /* afe_open will be called from prepare */
  975. return 0;
  976. case SNDRV_PCM_TRIGGER_STOP:
  977. case SNDRV_PCM_TRIGGER_SUSPEND:
  978. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  979. return 0;
  980. default:
  981. pr_err("%s: cmd %d\n", __func__, cmd);
  982. rc = -EINVAL;
  983. }
  984. return rc;
  985. }
  986. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  987. {
  988. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  989. int rc;
  990. aux_dai_data = dev_get_drvdata(dai->dev);
  991. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  992. __func__, dai->id);
  993. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  994. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  995. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  996. if (rc < 0)
  997. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  998. rc = afe_close(aux_dai_data->tx_pid);
  999. if (rc < 0)
  1000. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1001. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1002. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1003. }
  1004. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1005. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1006. return 0;
  1007. }
  1008. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1009. {
  1010. int rc = 0;
  1011. if (!dai) {
  1012. pr_err("%s: Invalid params dai\n", __func__);
  1013. return -EINVAL;
  1014. }
  1015. if (!dai->dev) {
  1016. pr_err("%s: Invalid params dai dev\n", __func__);
  1017. return -EINVAL;
  1018. }
  1019. if (!dai->driver->id) {
  1020. dev_warn(dai->dev, "DAI driver id is not set\n");
  1021. return -EINVAL;
  1022. }
  1023. dai->id = dai->driver->id;
  1024. rc = msm_dai_q6_dai_add_route(dai);
  1025. return rc;
  1026. }
  1027. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1028. .prepare = msm_dai_q6_auxpcm_prepare,
  1029. .trigger = msm_dai_q6_auxpcm_trigger,
  1030. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1031. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1032. };
  1033. static const struct snd_soc_component_driver
  1034. msm_dai_q6_aux_pcm_dai_component = {
  1035. .name = "msm-auxpcm-dev",
  1036. };
  1037. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1038. {
  1039. .playback = {
  1040. .stream_name = "AUX PCM Playback",
  1041. .aif_name = "AUX_PCM_RX",
  1042. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1043. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1044. .channels_min = 1,
  1045. .channels_max = 1,
  1046. .rate_max = 16000,
  1047. .rate_min = 8000,
  1048. },
  1049. .capture = {
  1050. .stream_name = "AUX PCM Capture",
  1051. .aif_name = "AUX_PCM_TX",
  1052. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1053. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1054. .channels_min = 1,
  1055. .channels_max = 1,
  1056. .rate_max = 16000,
  1057. .rate_min = 8000,
  1058. },
  1059. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1060. .ops = &msm_dai_q6_auxpcm_ops,
  1061. .probe = msm_dai_q6_aux_pcm_probe,
  1062. .remove = msm_dai_q6_dai_auxpcm_remove,
  1063. },
  1064. {
  1065. .playback = {
  1066. .stream_name = "Sec AUX PCM Playback",
  1067. .aif_name = "SEC_AUX_PCM_RX",
  1068. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1069. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1070. .channels_min = 1,
  1071. .channels_max = 1,
  1072. .rate_max = 16000,
  1073. .rate_min = 8000,
  1074. },
  1075. .capture = {
  1076. .stream_name = "Sec AUX PCM Capture",
  1077. .aif_name = "SEC_AUX_PCM_TX",
  1078. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1079. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1080. .channels_min = 1,
  1081. .channels_max = 1,
  1082. .rate_max = 16000,
  1083. .rate_min = 8000,
  1084. },
  1085. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1086. .ops = &msm_dai_q6_auxpcm_ops,
  1087. .probe = msm_dai_q6_aux_pcm_probe,
  1088. .remove = msm_dai_q6_dai_auxpcm_remove,
  1089. },
  1090. {
  1091. .playback = {
  1092. .stream_name = "Tert AUX PCM Playback",
  1093. .aif_name = "TERT_AUX_PCM_RX",
  1094. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1095. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1096. .channels_min = 1,
  1097. .channels_max = 1,
  1098. .rate_max = 16000,
  1099. .rate_min = 8000,
  1100. },
  1101. .capture = {
  1102. .stream_name = "Tert AUX PCM Capture",
  1103. .aif_name = "TERT_AUX_PCM_TX",
  1104. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1105. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1106. .channels_min = 1,
  1107. .channels_max = 1,
  1108. .rate_max = 16000,
  1109. .rate_min = 8000,
  1110. },
  1111. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1112. .ops = &msm_dai_q6_auxpcm_ops,
  1113. .probe = msm_dai_q6_aux_pcm_probe,
  1114. .remove = msm_dai_q6_dai_auxpcm_remove,
  1115. },
  1116. {
  1117. .playback = {
  1118. .stream_name = "Quat AUX PCM Playback",
  1119. .aif_name = "QUAT_AUX_PCM_RX",
  1120. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1121. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1122. .channels_min = 1,
  1123. .channels_max = 1,
  1124. .rate_max = 16000,
  1125. .rate_min = 8000,
  1126. },
  1127. .capture = {
  1128. .stream_name = "Quat AUX PCM Capture",
  1129. .aif_name = "QUAT_AUX_PCM_TX",
  1130. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1131. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1132. .channels_min = 1,
  1133. .channels_max = 1,
  1134. .rate_max = 16000,
  1135. .rate_min = 8000,
  1136. },
  1137. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1138. .ops = &msm_dai_q6_auxpcm_ops,
  1139. .probe = msm_dai_q6_aux_pcm_probe,
  1140. .remove = msm_dai_q6_dai_auxpcm_remove,
  1141. },
  1142. {
  1143. .playback = {
  1144. .stream_name = "Quin AUX PCM Playback",
  1145. .aif_name = "QUIN_AUX_PCM_RX",
  1146. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1147. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1148. .channels_min = 1,
  1149. .channels_max = 1,
  1150. .rate_max = 16000,
  1151. .rate_min = 8000,
  1152. },
  1153. .capture = {
  1154. .stream_name = "Quin AUX PCM Capture",
  1155. .aif_name = "QUIN_AUX_PCM_TX",
  1156. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1157. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1158. .channels_min = 1,
  1159. .channels_max = 1,
  1160. .rate_max = 16000,
  1161. .rate_min = 8000,
  1162. },
  1163. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1164. .ops = &msm_dai_q6_auxpcm_ops,
  1165. .probe = msm_dai_q6_aux_pcm_probe,
  1166. .remove = msm_dai_q6_dai_auxpcm_remove,
  1167. },
  1168. };
  1169. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1170. struct snd_ctl_elem_value *ucontrol)
  1171. {
  1172. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1173. int value = ucontrol->value.integer.value[0];
  1174. dai_data->spdif_port.cfg.data_format = value;
  1175. pr_debug("%s: value = %d\n", __func__, value);
  1176. return 0;
  1177. }
  1178. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1179. struct snd_ctl_elem_value *ucontrol)
  1180. {
  1181. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1182. ucontrol->value.integer.value[0] =
  1183. dai_data->spdif_port.cfg.data_format;
  1184. return 0;
  1185. }
  1186. static const char * const spdif_format[] = {
  1187. "LPCM",
  1188. "Compr"
  1189. };
  1190. static const struct soc_enum spdif_config_enum[] = {
  1191. SOC_ENUM_SINGLE_EXT(2, spdif_format),
  1192. };
  1193. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1194. struct snd_ctl_elem_value *ucontrol)
  1195. {
  1196. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1197. int ret = 0;
  1198. dai_data->spdif_port.ch_status.status_type =
  1199. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1200. memset(dai_data->spdif_port.ch_status.status_mask,
  1201. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1202. dai_data->spdif_port.ch_status.status_mask[0] =
  1203. CHANNEL_STATUS_MASK;
  1204. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1205. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1206. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1207. pr_debug("%s: Port already started. Dynamic update\n",
  1208. __func__);
  1209. ret = afe_send_spdif_ch_status_cfg(
  1210. &dai_data->spdif_port.ch_status,
  1211. AFE_PORT_ID_SPDIF_RX);
  1212. }
  1213. return ret;
  1214. }
  1215. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1216. struct snd_ctl_elem_value *ucontrol)
  1217. {
  1218. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1219. memcpy(ucontrol->value.iec958.status,
  1220. dai_data->spdif_port.ch_status.status_bits,
  1221. CHANNEL_STATUS_SIZE);
  1222. return 0;
  1223. }
  1224. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1225. struct snd_ctl_elem_info *uinfo)
  1226. {
  1227. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1228. uinfo->count = 1;
  1229. return 0;
  1230. }
  1231. static const struct snd_kcontrol_new spdif_config_controls[] = {
  1232. {
  1233. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1234. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1235. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1236. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1237. .info = msm_dai_q6_spdif_chstatus_info,
  1238. .get = msm_dai_q6_spdif_chstatus_get,
  1239. .put = msm_dai_q6_spdif_chstatus_put,
  1240. },
  1241. SOC_ENUM_EXT("SPDIF RX Format", spdif_config_enum[0],
  1242. msm_dai_q6_spdif_format_get,
  1243. msm_dai_q6_spdif_format_put)
  1244. };
  1245. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1246. struct snd_pcm_hw_params *params,
  1247. struct snd_soc_dai *dai)
  1248. {
  1249. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1250. dai->id = AFE_PORT_ID_SPDIF_RX;
  1251. dai_data->channels = params_channels(params);
  1252. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1253. switch (params_format(params)) {
  1254. case SNDRV_PCM_FORMAT_S16_LE:
  1255. dai_data->spdif_port.cfg.bit_width = 16;
  1256. break;
  1257. case SNDRV_PCM_FORMAT_S24_LE:
  1258. case SNDRV_PCM_FORMAT_S24_3LE:
  1259. dai_data->spdif_port.cfg.bit_width = 24;
  1260. break;
  1261. default:
  1262. pr_err("%s: format %d\n",
  1263. __func__, params_format(params));
  1264. return -EINVAL;
  1265. }
  1266. dai_data->rate = params_rate(params);
  1267. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1268. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1269. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1270. AFE_API_VERSION_SPDIF_CONFIG;
  1271. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1272. dai_data->channels, dai_data->rate,
  1273. dai_data->spdif_port.cfg.bit_width);
  1274. dai_data->spdif_port.cfg.reserved = 0;
  1275. return 0;
  1276. }
  1277. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1278. struct snd_soc_dai *dai)
  1279. {
  1280. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1281. int rc = 0;
  1282. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1283. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1284. __func__, *dai_data->status_mask);
  1285. return;
  1286. }
  1287. rc = afe_close(dai->id);
  1288. if (rc < 0)
  1289. dev_err(dai->dev, "fail to close AFE port\n");
  1290. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1291. *dai_data->status_mask);
  1292. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1293. }
  1294. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1295. struct snd_soc_dai *dai)
  1296. {
  1297. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1298. int rc = 0;
  1299. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1300. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1301. dai_data->rate);
  1302. if (rc < 0)
  1303. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1304. dai->id);
  1305. else
  1306. set_bit(STATUS_PORT_STARTED,
  1307. dai_data->status_mask);
  1308. }
  1309. return rc;
  1310. }
  1311. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1312. {
  1313. struct msm_dai_q6_spdif_dai_data *dai_data;
  1314. const struct snd_kcontrol_new *kcontrol;
  1315. int rc = 0;
  1316. struct snd_soc_dapm_route intercon;
  1317. struct snd_soc_dapm_context *dapm;
  1318. if (!dai) {
  1319. pr_err("%s: dai not found!!\n", __func__);
  1320. return -EINVAL;
  1321. }
  1322. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1323. GFP_KERNEL);
  1324. if (!dai_data) {
  1325. dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
  1326. AFE_PORT_ID_SPDIF_RX);
  1327. rc = -ENOMEM;
  1328. } else
  1329. dev_set_drvdata(dai->dev, dai_data);
  1330. kcontrol = &spdif_config_controls[1];
  1331. dapm = snd_soc_component_get_dapm(dai->component);
  1332. rc = snd_ctl_add(dai->component->card->snd_card,
  1333. snd_ctl_new1(kcontrol, dai_data));
  1334. memset(&intercon, 0, sizeof(intercon));
  1335. if (!rc && dai && dai->driver) {
  1336. if (dai->driver->playback.stream_name &&
  1337. dai->driver->playback.aif_name) {
  1338. dev_dbg(dai->dev, "%s: add route for widget %s",
  1339. __func__, dai->driver->playback.stream_name);
  1340. intercon.source = dai->driver->playback.aif_name;
  1341. intercon.sink = dai->driver->playback.stream_name;
  1342. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1343. __func__, intercon.source, intercon.sink);
  1344. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1345. }
  1346. if (dai->driver->capture.stream_name &&
  1347. dai->driver->capture.aif_name) {
  1348. dev_dbg(dai->dev, "%s: add route for widget %s",
  1349. __func__, dai->driver->capture.stream_name);
  1350. intercon.sink = dai->driver->capture.aif_name;
  1351. intercon.source = dai->driver->capture.stream_name;
  1352. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1353. __func__, intercon.source, intercon.sink);
  1354. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1355. }
  1356. }
  1357. return rc;
  1358. }
  1359. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1360. {
  1361. struct msm_dai_q6_spdif_dai_data *dai_data;
  1362. int rc;
  1363. dai_data = dev_get_drvdata(dai->dev);
  1364. /* If AFE port is still up, close it */
  1365. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1366. rc = afe_close(dai->id); /* can block */
  1367. if (rc < 0)
  1368. dev_err(dai->dev, "fail to close AFE port\n");
  1369. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1370. }
  1371. kfree(dai_data);
  1372. return 0;
  1373. }
  1374. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1375. .prepare = msm_dai_q6_spdif_prepare,
  1376. .hw_params = msm_dai_q6_spdif_hw_params,
  1377. .shutdown = msm_dai_q6_spdif_shutdown,
  1378. };
  1379. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai = {
  1380. .playback = {
  1381. .stream_name = "SPDIF Playback",
  1382. .aif_name = "SPDIF_RX",
  1383. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1384. SNDRV_PCM_RATE_16000,
  1385. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
  1386. .channels_min = 1,
  1387. .channels_max = 4,
  1388. .rate_min = 8000,
  1389. .rate_max = 48000,
  1390. },
  1391. .ops = &msm_dai_q6_spdif_ops,
  1392. .probe = msm_dai_q6_spdif_dai_probe,
  1393. .remove = msm_dai_q6_spdif_dai_remove,
  1394. };
  1395. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  1396. .name = "msm-dai-q6-spdif",
  1397. };
  1398. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  1399. struct snd_soc_dai *dai)
  1400. {
  1401. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1402. int rc = 0;
  1403. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1404. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  1405. int bitwidth = 0;
  1406. if (dai_data->afe_in_bitformat ==
  1407. SNDRV_PCM_FORMAT_S24_LE)
  1408. bitwidth = 24;
  1409. else if (dai_data->afe_in_bitformat ==
  1410. SNDRV_PCM_FORMAT_S16_LE)
  1411. bitwidth = 16;
  1412. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  1413. __func__, dai_data->enc_config.format);
  1414. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1415. dai_data->rate,
  1416. dai_data->afe_in_channels,
  1417. bitwidth,
  1418. &dai_data->enc_config);
  1419. if (rc < 0)
  1420. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  1421. __func__, rc);
  1422. } else {
  1423. rc = afe_port_start(dai->id, &dai_data->port_config,
  1424. dai_data->rate);
  1425. }
  1426. if (rc < 0)
  1427. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1428. dai->id);
  1429. else
  1430. set_bit(STATUS_PORT_STARTED,
  1431. dai_data->status_mask);
  1432. }
  1433. return rc;
  1434. }
  1435. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  1436. struct snd_soc_dai *dai, int stream)
  1437. {
  1438. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1439. dai_data->channels = params_channels(params);
  1440. switch (dai_data->channels) {
  1441. case 2:
  1442. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1443. break;
  1444. case 1:
  1445. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1446. break;
  1447. default:
  1448. return -EINVAL;
  1449. pr_err("%s: err channels %d\n",
  1450. __func__, dai_data->channels);
  1451. break;
  1452. }
  1453. switch (params_format(params)) {
  1454. case SNDRV_PCM_FORMAT_S16_LE:
  1455. case SNDRV_PCM_FORMAT_SPECIAL:
  1456. dai_data->port_config.i2s.bit_width = 16;
  1457. break;
  1458. case SNDRV_PCM_FORMAT_S24_LE:
  1459. case SNDRV_PCM_FORMAT_S24_3LE:
  1460. dai_data->port_config.i2s.bit_width = 24;
  1461. break;
  1462. default:
  1463. pr_err("%s: format %d\n",
  1464. __func__, params_format(params));
  1465. return -EINVAL;
  1466. }
  1467. dai_data->rate = params_rate(params);
  1468. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1469. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1470. AFE_API_VERSION_I2S_CONFIG;
  1471. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1472. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  1473. dai_data->channels, dai_data->rate);
  1474. dai_data->port_config.i2s.channel_mode = 1;
  1475. return 0;
  1476. }
  1477. static u8 num_of_bits_set(u8 sd_line_mask)
  1478. {
  1479. u8 num_bits_set = 0;
  1480. while (sd_line_mask) {
  1481. num_bits_set++;
  1482. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  1483. }
  1484. return num_bits_set;
  1485. }
  1486. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  1487. struct snd_soc_dai *dai, int stream)
  1488. {
  1489. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1490. struct msm_i2s_data *i2s_pdata =
  1491. (struct msm_i2s_data *) dai->dev->platform_data;
  1492. dai_data->channels = params_channels(params);
  1493. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  1494. switch (dai_data->channels) {
  1495. case 2:
  1496. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1497. break;
  1498. case 1:
  1499. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1500. break;
  1501. default:
  1502. pr_warn("%s: greater than stereo has not been validated %d",
  1503. __func__, dai_data->channels);
  1504. break;
  1505. }
  1506. }
  1507. dai_data->rate = params_rate(params);
  1508. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1509. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1510. AFE_API_VERSION_I2S_CONFIG;
  1511. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1512. /* Q6 only supports 16 as now */
  1513. dai_data->port_config.i2s.bit_width = 16;
  1514. dai_data->port_config.i2s.channel_mode = 1;
  1515. return 0;
  1516. }
  1517. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  1518. struct snd_soc_dai *dai, int stream)
  1519. {
  1520. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1521. dai_data->channels = params_channels(params);
  1522. dai_data->rate = params_rate(params);
  1523. switch (params_format(params)) {
  1524. case SNDRV_PCM_FORMAT_S16_LE:
  1525. case SNDRV_PCM_FORMAT_SPECIAL:
  1526. dai_data->port_config.slim_sch.bit_width = 16;
  1527. break;
  1528. case SNDRV_PCM_FORMAT_S24_LE:
  1529. case SNDRV_PCM_FORMAT_S24_3LE:
  1530. dai_data->port_config.slim_sch.bit_width = 24;
  1531. break;
  1532. case SNDRV_PCM_FORMAT_S32_LE:
  1533. dai_data->port_config.slim_sch.bit_width = 32;
  1534. break;
  1535. default:
  1536. pr_err("%s: format %d\n",
  1537. __func__, params_format(params));
  1538. return -EINVAL;
  1539. }
  1540. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  1541. AFE_API_VERSION_SLIMBUS_CONFIG;
  1542. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  1543. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  1544. switch (dai->id) {
  1545. case SLIMBUS_7_RX:
  1546. case SLIMBUS_7_TX:
  1547. case SLIMBUS_8_RX:
  1548. case SLIMBUS_8_TX:
  1549. dai_data->port_config.slim_sch.slimbus_dev_id =
  1550. AFE_SLIMBUS_DEVICE_2;
  1551. break;
  1552. default:
  1553. dai_data->port_config.slim_sch.slimbus_dev_id =
  1554. AFE_SLIMBUS_DEVICE_1;
  1555. break;
  1556. }
  1557. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  1558. "num_channel %hu shared_ch_mapping[0] %hu\n"
  1559. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  1560. "sample_rate %d\n", __func__,
  1561. dai_data->port_config.slim_sch.slimbus_dev_id,
  1562. dai_data->port_config.slim_sch.bit_width,
  1563. dai_data->port_config.slim_sch.data_format,
  1564. dai_data->port_config.slim_sch.num_channels,
  1565. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1566. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  1567. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  1568. dai_data->rate);
  1569. return 0;
  1570. }
  1571. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  1572. struct snd_soc_dai *dai, int stream)
  1573. {
  1574. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1575. dai_data->channels = params_channels(params);
  1576. dai_data->rate = params_rate(params);
  1577. switch (params_format(params)) {
  1578. case SNDRV_PCM_FORMAT_S16_LE:
  1579. case SNDRV_PCM_FORMAT_SPECIAL:
  1580. dai_data->port_config.usb_audio.bit_width = 16;
  1581. break;
  1582. case SNDRV_PCM_FORMAT_S24_LE:
  1583. case SNDRV_PCM_FORMAT_S24_3LE:
  1584. dai_data->port_config.usb_audio.bit_width = 24;
  1585. break;
  1586. case SNDRV_PCM_FORMAT_S32_LE:
  1587. dai_data->port_config.usb_audio.bit_width = 32;
  1588. break;
  1589. default:
  1590. dev_err(dai->dev, "%s: invalid format %d\n",
  1591. __func__, params_format(params));
  1592. return -EINVAL;
  1593. }
  1594. dai_data->port_config.usb_audio.cfg_minor_version =
  1595. AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
  1596. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  1597. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  1598. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  1599. "num_channel %hu sample_rate %d\n", __func__,
  1600. dai_data->port_config.usb_audio.dev_token,
  1601. dai_data->port_config.usb_audio.bit_width,
  1602. dai_data->port_config.usb_audio.data_format,
  1603. dai_data->port_config.usb_audio.num_channels,
  1604. dai_data->port_config.usb_audio.sample_rate);
  1605. return 0;
  1606. }
  1607. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  1608. struct snd_soc_dai *dai, int stream)
  1609. {
  1610. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1611. dai_data->channels = params_channels(params);
  1612. dai_data->rate = params_rate(params);
  1613. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  1614. dai_data->channels, dai_data->rate);
  1615. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  1616. pr_debug("%s: setting bt_fm parameters\n", __func__);
  1617. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  1618. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  1619. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  1620. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  1621. dai_data->port_config.int_bt_fm.bit_width = 16;
  1622. return 0;
  1623. }
  1624. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  1625. struct snd_soc_dai *dai)
  1626. {
  1627. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1628. dai_data->rate = params_rate(params);
  1629. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  1630. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  1631. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  1632. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  1633. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  1634. AFE_API_VERSION_RT_PROXY_CONFIG;
  1635. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  1636. dai_data->port_config.rtproxy.interleaved = 1;
  1637. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  1638. dai_data->port_config.rtproxy.jitter_allowance =
  1639. dai_data->port_config.rtproxy.frame_size/2;
  1640. dai_data->port_config.rtproxy.low_water_mark = 0;
  1641. dai_data->port_config.rtproxy.high_water_mark = 0;
  1642. return 0;
  1643. }
  1644. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  1645. struct snd_soc_dai *dai, int stream)
  1646. {
  1647. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1648. dai_data->channels = params_channels(params);
  1649. dai_data->rate = params_rate(params);
  1650. /* Q6 only supports 16 as now */
  1651. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  1652. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  1653. dai_data->port_config.pseudo_port.num_channels =
  1654. params_channels(params);
  1655. dai_data->port_config.pseudo_port.bit_width = 16;
  1656. dai_data->port_config.pseudo_port.data_format = 0;
  1657. dai_data->port_config.pseudo_port.timing_mode =
  1658. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  1659. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  1660. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  1661. "timing Mode %hu sample_rate %d\n", __func__,
  1662. dai_data->port_config.pseudo_port.bit_width,
  1663. dai_data->port_config.pseudo_port.num_channels,
  1664. dai_data->port_config.pseudo_port.data_format,
  1665. dai_data->port_config.pseudo_port.timing_mode,
  1666. dai_data->port_config.pseudo_port.sample_rate);
  1667. return 0;
  1668. }
  1669. /* Current implementation assumes hw_param is called once
  1670. * This may not be the case but what to do when ADM and AFE
  1671. * port are already opened and parameter changes
  1672. */
  1673. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  1674. struct snd_pcm_hw_params *params,
  1675. struct snd_soc_dai *dai)
  1676. {
  1677. int rc = 0;
  1678. switch (dai->id) {
  1679. case PRIMARY_I2S_TX:
  1680. case PRIMARY_I2S_RX:
  1681. case SECONDARY_I2S_RX:
  1682. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  1683. break;
  1684. case MI2S_RX:
  1685. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  1686. break;
  1687. case SLIMBUS_0_RX:
  1688. case SLIMBUS_1_RX:
  1689. case SLIMBUS_2_RX:
  1690. case SLIMBUS_3_RX:
  1691. case SLIMBUS_4_RX:
  1692. case SLIMBUS_5_RX:
  1693. case SLIMBUS_6_RX:
  1694. case SLIMBUS_7_RX:
  1695. case SLIMBUS_8_RX:
  1696. case SLIMBUS_0_TX:
  1697. case SLIMBUS_1_TX:
  1698. case SLIMBUS_2_TX:
  1699. case SLIMBUS_3_TX:
  1700. case SLIMBUS_4_TX:
  1701. case SLIMBUS_5_TX:
  1702. case SLIMBUS_6_TX:
  1703. case SLIMBUS_7_TX:
  1704. case SLIMBUS_8_TX:
  1705. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  1706. substream->stream);
  1707. break;
  1708. case INT_BT_SCO_RX:
  1709. case INT_BT_SCO_TX:
  1710. case INT_BT_A2DP_RX:
  1711. case INT_FM_RX:
  1712. case INT_FM_TX:
  1713. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  1714. break;
  1715. case AFE_PORT_ID_USB_RX:
  1716. case AFE_PORT_ID_USB_TX:
  1717. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  1718. substream->stream);
  1719. break;
  1720. case RT_PROXY_DAI_001_TX:
  1721. case RT_PROXY_DAI_001_RX:
  1722. case RT_PROXY_DAI_002_TX:
  1723. case RT_PROXY_DAI_002_RX:
  1724. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  1725. break;
  1726. case VOICE_PLAYBACK_TX:
  1727. case VOICE2_PLAYBACK_TX:
  1728. case VOICE_RECORD_RX:
  1729. case VOICE_RECORD_TX:
  1730. rc = msm_dai_q6_pseudo_port_hw_params(params,
  1731. dai, substream->stream);
  1732. break;
  1733. default:
  1734. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  1735. rc = -EINVAL;
  1736. break;
  1737. }
  1738. return rc;
  1739. }
  1740. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  1741. struct snd_soc_dai *dai)
  1742. {
  1743. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1744. int rc = 0;
  1745. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1746. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  1747. rc = afe_close(dai->id); /* can block */
  1748. if (rc < 0)
  1749. dev_err(dai->dev, "fail to close AFE port\n");
  1750. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1751. *dai_data->status_mask);
  1752. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1753. }
  1754. }
  1755. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  1756. {
  1757. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1758. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  1759. case SND_SOC_DAIFMT_CBS_CFS:
  1760. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  1761. break;
  1762. case SND_SOC_DAIFMT_CBM_CFM:
  1763. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  1764. break;
  1765. default:
  1766. pr_err("%s: fmt 0x%x\n",
  1767. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  1768. return -EINVAL;
  1769. }
  1770. return 0;
  1771. }
  1772. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  1773. {
  1774. int rc = 0;
  1775. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  1776. dai->id, fmt);
  1777. switch (dai->id) {
  1778. case PRIMARY_I2S_TX:
  1779. case PRIMARY_I2S_RX:
  1780. case MI2S_RX:
  1781. case SECONDARY_I2S_RX:
  1782. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  1783. break;
  1784. default:
  1785. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  1786. rc = -EINVAL;
  1787. break;
  1788. }
  1789. return rc;
  1790. }
  1791. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  1792. unsigned int tx_num, unsigned int *tx_slot,
  1793. unsigned int rx_num, unsigned int *rx_slot)
  1794. {
  1795. int rc = 0;
  1796. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1797. unsigned int i = 0;
  1798. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  1799. switch (dai->id) {
  1800. case SLIMBUS_0_RX:
  1801. case SLIMBUS_1_RX:
  1802. case SLIMBUS_2_RX:
  1803. case SLIMBUS_3_RX:
  1804. case SLIMBUS_4_RX:
  1805. case SLIMBUS_5_RX:
  1806. case SLIMBUS_6_RX:
  1807. case SLIMBUS_7_RX:
  1808. case SLIMBUS_8_RX:
  1809. /*
  1810. * channel number to be between 128 and 255.
  1811. * For RX port use channel numbers
  1812. * from 138 to 144 for pre-Taiko
  1813. * from 144 to 159 for Taiko
  1814. */
  1815. if (!rx_slot) {
  1816. pr_err("%s: rx slot not found\n", __func__);
  1817. return -EINVAL;
  1818. }
  1819. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  1820. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  1821. return -EINVAL;
  1822. }
  1823. for (i = 0; i < rx_num; i++) {
  1824. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  1825. rx_slot[i];
  1826. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  1827. __func__, i, rx_slot[i]);
  1828. }
  1829. dai_data->port_config.slim_sch.num_channels = rx_num;
  1830. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  1831. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  1832. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1833. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  1834. break;
  1835. case SLIMBUS_0_TX:
  1836. case SLIMBUS_1_TX:
  1837. case SLIMBUS_2_TX:
  1838. case SLIMBUS_3_TX:
  1839. case SLIMBUS_4_TX:
  1840. case SLIMBUS_5_TX:
  1841. case SLIMBUS_6_TX:
  1842. case SLIMBUS_7_TX:
  1843. case SLIMBUS_8_TX:
  1844. /*
  1845. * channel number to be between 128 and 255.
  1846. * For TX port use channel numbers
  1847. * from 128 to 137 for pre-Taiko
  1848. * from 128 to 143 for Taiko
  1849. */
  1850. if (!tx_slot) {
  1851. pr_err("%s: tx slot not found\n", __func__);
  1852. return -EINVAL;
  1853. }
  1854. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  1855. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  1856. return -EINVAL;
  1857. }
  1858. for (i = 0; i < tx_num; i++) {
  1859. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  1860. tx_slot[i];
  1861. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  1862. __func__, i, tx_slot[i]);
  1863. }
  1864. dai_data->port_config.slim_sch.num_channels = tx_num;
  1865. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  1866. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  1867. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1868. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  1869. break;
  1870. default:
  1871. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  1872. rc = -EINVAL;
  1873. break;
  1874. }
  1875. return rc;
  1876. }
  1877. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  1878. .prepare = msm_dai_q6_prepare,
  1879. .hw_params = msm_dai_q6_hw_params,
  1880. .shutdown = msm_dai_q6_shutdown,
  1881. .set_fmt = msm_dai_q6_set_fmt,
  1882. .set_channel_map = msm_dai_q6_set_channel_map,
  1883. };
  1884. /*
  1885. * For single CPU DAI registration, the dai id needs to be
  1886. * set explicitly in the dai probe as ASoC does not read
  1887. * the cpu->driver->id field rather it assigns the dai id
  1888. * from the device name that is in the form %s.%d. This dai
  1889. * id should be assigned to back-end AFE port id and used
  1890. * during dai prepare. For multiple dai registration, it
  1891. * is not required to call this function, however the dai->
  1892. * driver->id field must be defined and set to corresponding
  1893. * AFE Port id.
  1894. */
  1895. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  1896. {
  1897. if (!dai->driver->id) {
  1898. dev_warn(dai->dev, "DAI driver id is not set\n");
  1899. return;
  1900. }
  1901. dai->id = dai->driver->id;
  1902. }
  1903. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  1904. struct snd_ctl_elem_value *ucontrol)
  1905. {
  1906. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1907. u16 port_id = ((struct soc_enum *)
  1908. kcontrol->private_value)->reg;
  1909. dai_data->cal_mode = ucontrol->value.integer.value[0];
  1910. pr_debug("%s: setting cal_mode to %d\n",
  1911. __func__, dai_data->cal_mode);
  1912. afe_set_cal_mode(port_id, dai_data->cal_mode);
  1913. return 0;
  1914. }
  1915. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  1916. struct snd_ctl_elem_value *ucontrol)
  1917. {
  1918. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1919. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  1920. return 0;
  1921. }
  1922. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  1923. struct snd_ctl_elem_value *ucontrol)
  1924. {
  1925. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1926. int value = ucontrol->value.integer.value[0];
  1927. if (dai_data) {
  1928. dai_data->port_config.slim_sch.data_format = value;
  1929. pr_debug("%s: format = %d\n", __func__, value);
  1930. }
  1931. return 0;
  1932. }
  1933. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  1934. struct snd_ctl_elem_value *ucontrol)
  1935. {
  1936. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1937. if (dai_data)
  1938. ucontrol->value.integer.value[0] =
  1939. dai_data->port_config.slim_sch.data_format;
  1940. return 0;
  1941. }
  1942. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  1943. struct snd_ctl_elem_value *ucontrol)
  1944. {
  1945. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1946. u32 val = ucontrol->value.integer.value[0];
  1947. if (dai_data) {
  1948. dai_data->port_config.usb_audio.dev_token = val;
  1949. pr_debug("%s: dev_token = 0x%x\n", __func__,
  1950. dai_data->port_config.usb_audio.dev_token);
  1951. } else {
  1952. pr_err("%s: dai_data is NULL\n", __func__);
  1953. }
  1954. return 0;
  1955. }
  1956. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  1957. struct snd_ctl_elem_value *ucontrol)
  1958. {
  1959. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1960. if (dai_data) {
  1961. ucontrol->value.integer.value[0] =
  1962. dai_data->port_config.usb_audio.dev_token;
  1963. pr_debug("%s: dev_token = 0x%x\n", __func__,
  1964. dai_data->port_config.usb_audio.dev_token);
  1965. } else {
  1966. pr_err("%s: dai_data is NULL\n", __func__);
  1967. }
  1968. return 0;
  1969. }
  1970. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  1971. struct snd_ctl_elem_value *ucontrol)
  1972. {
  1973. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1974. u32 val = ucontrol->value.integer.value[0];
  1975. if (dai_data) {
  1976. dai_data->port_config.usb_audio.endian = val;
  1977. pr_debug("%s: endian = 0x%x\n", __func__,
  1978. dai_data->port_config.usb_audio.endian);
  1979. } else {
  1980. pr_err("%s: dai_data is NULL\n", __func__);
  1981. return -EINVAL;
  1982. }
  1983. return 0;
  1984. }
  1985. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  1986. struct snd_ctl_elem_value *ucontrol)
  1987. {
  1988. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  1989. if (dai_data) {
  1990. ucontrol->value.integer.value[0] =
  1991. dai_data->port_config.usb_audio.endian;
  1992. pr_debug("%s: endian = 0x%x\n", __func__,
  1993. dai_data->port_config.usb_audio.endian);
  1994. } else {
  1995. pr_err("%s: dai_data is NULL\n", __func__);
  1996. return -EINVAL;
  1997. }
  1998. return 0;
  1999. }
  2000. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2001. struct snd_ctl_elem_info *uinfo)
  2002. {
  2003. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2004. uinfo->count = sizeof(struct afe_enc_config);
  2005. return 0;
  2006. }
  2007. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2008. struct snd_ctl_elem_value *ucontrol)
  2009. {
  2010. int ret = 0;
  2011. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2012. if (dai_data) {
  2013. int format_size = sizeof(dai_data->enc_config.format);
  2014. pr_debug("%s:encoder config for %d format\n",
  2015. __func__, dai_data->enc_config.format);
  2016. memcpy(ucontrol->value.bytes.data,
  2017. &dai_data->enc_config.format,
  2018. format_size);
  2019. switch (dai_data->enc_config.format) {
  2020. case ENC_FMT_SBC:
  2021. memcpy(ucontrol->value.bytes.data + format_size,
  2022. &dai_data->enc_config.data,
  2023. sizeof(struct asm_sbc_enc_cfg_t));
  2024. break;
  2025. case ENC_FMT_AAC_V2:
  2026. memcpy(ucontrol->value.bytes.data + format_size,
  2027. &dai_data->enc_config.data,
  2028. sizeof(struct asm_aac_enc_cfg_v2_t));
  2029. break;
  2030. case ENC_FMT_APTX:
  2031. memcpy(ucontrol->value.bytes.data + format_size,
  2032. &dai_data->enc_config.data,
  2033. sizeof(struct asm_aptx_enc_cfg_t));
  2034. break;
  2035. case ENC_FMT_APTX_HD:
  2036. memcpy(ucontrol->value.bytes.data + format_size,
  2037. &dai_data->enc_config.data,
  2038. sizeof(struct asm_custom_enc_cfg_t));
  2039. break;
  2040. case ENC_FMT_CELT:
  2041. memcpy(ucontrol->value.bytes.data + format_size,
  2042. &dai_data->enc_config.data,
  2043. sizeof(struct asm_celt_enc_cfg_t));
  2044. break;
  2045. default:
  2046. pr_debug("%s: unknown format = %d\n",
  2047. __func__, dai_data->enc_config.format);
  2048. ret = -EINVAL;
  2049. break;
  2050. }
  2051. }
  2052. return ret;
  2053. }
  2054. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2055. struct snd_ctl_elem_value *ucontrol)
  2056. {
  2057. int ret = 0;
  2058. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2059. if (dai_data) {
  2060. int format_size = sizeof(dai_data->enc_config.format);
  2061. memset(&dai_data->enc_config, 0x0,
  2062. sizeof(struct afe_enc_config));
  2063. memcpy(&dai_data->enc_config.format,
  2064. ucontrol->value.bytes.data,
  2065. format_size);
  2066. pr_debug("%s: Received encoder config for %d format\n",
  2067. __func__, dai_data->enc_config.format);
  2068. switch (dai_data->enc_config.format) {
  2069. case ENC_FMT_SBC:
  2070. memcpy(&dai_data->enc_config.data,
  2071. ucontrol->value.bytes.data + format_size,
  2072. sizeof(struct asm_sbc_enc_cfg_t));
  2073. break;
  2074. case ENC_FMT_AAC_V2:
  2075. memcpy(&dai_data->enc_config.data,
  2076. ucontrol->value.bytes.data + format_size,
  2077. sizeof(struct asm_aac_enc_cfg_v2_t));
  2078. break;
  2079. case ENC_FMT_APTX:
  2080. memcpy(&dai_data->enc_config.data,
  2081. ucontrol->value.bytes.data + format_size,
  2082. sizeof(struct asm_aptx_enc_cfg_t));
  2083. break;
  2084. case ENC_FMT_APTX_HD:
  2085. memcpy(&dai_data->enc_config.data,
  2086. ucontrol->value.bytes.data + format_size,
  2087. sizeof(struct asm_custom_enc_cfg_t));
  2088. break;
  2089. case ENC_FMT_CELT:
  2090. memcpy(&dai_data->enc_config.data,
  2091. ucontrol->value.bytes.data + format_size,
  2092. sizeof(struct asm_celt_enc_cfg_t));
  2093. break;
  2094. default:
  2095. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2096. __func__, dai_data->enc_config.format);
  2097. ret = -EINVAL;
  2098. break;
  2099. }
  2100. } else
  2101. ret = -EINVAL;
  2102. return ret;
  2103. }
  2104. static const char *const afe_input_chs_text[] = {"Zero", "One", "Two"};
  2105. static const struct soc_enum afe_input_chs_enum[] = {
  2106. SOC_ENUM_SINGLE_EXT(3, afe_input_chs_text),
  2107. };
  2108. static const char *const afe_input_bit_format_text[] = {"S16_LE", "S24_LE"};
  2109. static const struct soc_enum afe_input_bit_format_enum[] = {
  2110. SOC_ENUM_SINGLE_EXT(2, afe_input_bit_format_text),
  2111. };
  2112. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2113. struct snd_ctl_elem_value *ucontrol)
  2114. {
  2115. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2116. if (dai_data) {
  2117. ucontrol->value.integer.value[0] = dai_data->afe_in_channels;
  2118. pr_debug("%s:afe input channel = %d\n",
  2119. __func__, dai_data->afe_in_channels);
  2120. }
  2121. return 0;
  2122. }
  2123. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2124. struct snd_ctl_elem_value *ucontrol)
  2125. {
  2126. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2127. if (dai_data) {
  2128. dai_data->afe_in_channels = ucontrol->value.integer.value[0];
  2129. pr_debug("%s: updating afe input channel : %d\n",
  2130. __func__, dai_data->afe_in_channels);
  2131. }
  2132. return 0;
  2133. }
  2134. static int msm_dai_q6_afe_input_bit_format_get(
  2135. struct snd_kcontrol *kcontrol,
  2136. struct snd_ctl_elem_value *ucontrol)
  2137. {
  2138. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2139. if (!dai_data) {
  2140. pr_err("%s: Invalid dai data\n", __func__);
  2141. return -EINVAL;
  2142. }
  2143. switch (dai_data->afe_in_bitformat) {
  2144. case SNDRV_PCM_FORMAT_S24_LE:
  2145. ucontrol->value.integer.value[0] = 1;
  2146. break;
  2147. case SNDRV_PCM_FORMAT_S16_LE:
  2148. default:
  2149. ucontrol->value.integer.value[0] = 0;
  2150. break;
  2151. }
  2152. pr_debug("%s: afe input bit format : %ld\n",
  2153. __func__, ucontrol->value.integer.value[0]);
  2154. return 0;
  2155. }
  2156. static int msm_dai_q6_afe_input_bit_format_put(
  2157. struct snd_kcontrol *kcontrol,
  2158. struct snd_ctl_elem_value *ucontrol)
  2159. {
  2160. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2161. if (!dai_data) {
  2162. pr_err("%s: Invalid dai data\n", __func__);
  2163. return -EINVAL;
  2164. }
  2165. switch (ucontrol->value.integer.value[0]) {
  2166. case 1:
  2167. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2168. break;
  2169. case 0:
  2170. default:
  2171. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2172. break;
  2173. }
  2174. pr_debug("%s: updating afe input bit format : %d\n",
  2175. __func__, dai_data->afe_in_bitformat);
  2176. return 0;
  2177. }
  2178. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  2179. {
  2180. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2181. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2182. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2183. .name = "SLIM_7_RX Encoder Config",
  2184. .info = msm_dai_q6_afe_enc_cfg_info,
  2185. .get = msm_dai_q6_afe_enc_cfg_get,
  2186. .put = msm_dai_q6_afe_enc_cfg_put,
  2187. },
  2188. SOC_ENUM_EXT("AFE Input Channels", afe_input_chs_enum[0],
  2189. msm_dai_q6_afe_input_channel_get,
  2190. msm_dai_q6_afe_input_channel_put),
  2191. SOC_ENUM_EXT("AFE Input Bit Format", afe_input_bit_format_enum[0],
  2192. msm_dai_q6_afe_input_bit_format_get,
  2193. msm_dai_q6_afe_input_bit_format_put),
  2194. };
  2195. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  2196. struct snd_ctl_elem_info *uinfo)
  2197. {
  2198. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2199. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  2200. return 0;
  2201. }
  2202. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  2203. struct snd_ctl_elem_value *ucontrol)
  2204. {
  2205. int ret = -EINVAL;
  2206. struct afe_param_id_dev_timing_stats timing_stats;
  2207. struct snd_soc_dai *dai = kcontrol->private_data;
  2208. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2209. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2210. pr_err("%s: afe port not started. dai_data->status_mask = %ld\n",
  2211. __func__, *dai_data->status_mask);
  2212. goto done;
  2213. }
  2214. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  2215. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  2216. if (ret) {
  2217. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  2218. __func__, dai->id, ret);
  2219. goto done;
  2220. }
  2221. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  2222. sizeof(struct afe_param_id_dev_timing_stats));
  2223. done:
  2224. return ret;
  2225. }
  2226. static const char * const afe_cal_mode_text[] = {
  2227. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  2228. };
  2229. static const struct soc_enum slim_2_rx_enum =
  2230. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2231. afe_cal_mode_text);
  2232. static const struct soc_enum rt_proxy_1_rx_enum =
  2233. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2234. afe_cal_mode_text);
  2235. static const struct soc_enum rt_proxy_1_tx_enum =
  2236. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2237. afe_cal_mode_text);
  2238. static const struct snd_kcontrol_new sb_config_controls[] = {
  2239. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  2240. msm_dai_q6_sb_format_get,
  2241. msm_dai_q6_sb_format_put),
  2242. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  2243. msm_dai_q6_cal_info_get,
  2244. msm_dai_q6_cal_info_put),
  2245. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  2246. msm_dai_q6_sb_format_get,
  2247. msm_dai_q6_sb_format_put)
  2248. };
  2249. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  2250. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  2251. msm_dai_q6_cal_info_get,
  2252. msm_dai_q6_cal_info_put),
  2253. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  2254. msm_dai_q6_cal_info_get,
  2255. msm_dai_q6_cal_info_put),
  2256. };
  2257. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  2258. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  2259. msm_dai_q6_usb_audio_cfg_get,
  2260. msm_dai_q6_usb_audio_cfg_put),
  2261. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  2262. msm_dai_q6_usb_audio_endian_cfg_get,
  2263. msm_dai_q6_usb_audio_endian_cfg_put),
  2264. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  2265. msm_dai_q6_usb_audio_cfg_get,
  2266. msm_dai_q6_usb_audio_cfg_put),
  2267. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  2268. msm_dai_q6_usb_audio_endian_cfg_get,
  2269. msm_dai_q6_usb_audio_endian_cfg_put),
  2270. };
  2271. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  2272. {
  2273. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2274. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2275. .name = "SLIMBUS_0_RX DRIFT",
  2276. .info = msm_dai_q6_slim_rx_drift_info,
  2277. .get = msm_dai_q6_slim_rx_drift_get,
  2278. },
  2279. {
  2280. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2281. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2282. .name = "SLIMBUS_6_RX DRIFT",
  2283. .info = msm_dai_q6_slim_rx_drift_info,
  2284. .get = msm_dai_q6_slim_rx_drift_get,
  2285. },
  2286. {
  2287. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2288. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2289. .name = "SLIMBUS_7_RX DRIFT",
  2290. .info = msm_dai_q6_slim_rx_drift_info,
  2291. .get = msm_dai_q6_slim_rx_drift_get,
  2292. },
  2293. };
  2294. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  2295. {
  2296. struct msm_dai_q6_dai_data *dai_data;
  2297. int rc = 0;
  2298. if (!dai) {
  2299. pr_err("%s: Invalid params dai\n", __func__);
  2300. return -EINVAL;
  2301. }
  2302. if (!dai->dev) {
  2303. pr_err("%s: Invalid params dai dev\n", __func__);
  2304. return -EINVAL;
  2305. }
  2306. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  2307. if (!dai_data)
  2308. rc = -ENOMEM;
  2309. else
  2310. dev_set_drvdata(dai->dev, dai_data);
  2311. msm_dai_q6_set_dai_id(dai);
  2312. switch (dai->id) {
  2313. case SLIMBUS_4_TX:
  2314. rc = snd_ctl_add(dai->component->card->snd_card,
  2315. snd_ctl_new1(&sb_config_controls[0],
  2316. dai_data));
  2317. break;
  2318. case SLIMBUS_2_RX:
  2319. rc = snd_ctl_add(dai->component->card->snd_card,
  2320. snd_ctl_new1(&sb_config_controls[1],
  2321. dai_data));
  2322. rc = snd_ctl_add(dai->component->card->snd_card,
  2323. snd_ctl_new1(&sb_config_controls[2],
  2324. dai_data));
  2325. break;
  2326. case SLIMBUS_7_RX:
  2327. rc = snd_ctl_add(dai->component->card->snd_card,
  2328. snd_ctl_new1(&afe_enc_config_controls[0],
  2329. dai_data));
  2330. rc = snd_ctl_add(dai->component->card->snd_card,
  2331. snd_ctl_new1(&afe_enc_config_controls[1],
  2332. dai_data));
  2333. rc = snd_ctl_add(dai->component->card->snd_card,
  2334. snd_ctl_new1(&afe_enc_config_controls[2],
  2335. dai_data));
  2336. rc = snd_ctl_add(dai->component->card->snd_card,
  2337. snd_ctl_new1(&avd_drift_config_controls[2],
  2338. dai));
  2339. break;
  2340. case RT_PROXY_DAI_001_RX:
  2341. rc = snd_ctl_add(dai->component->card->snd_card,
  2342. snd_ctl_new1(&rt_proxy_config_controls[0],
  2343. dai_data));
  2344. break;
  2345. case RT_PROXY_DAI_001_TX:
  2346. rc = snd_ctl_add(dai->component->card->snd_card,
  2347. snd_ctl_new1(&rt_proxy_config_controls[1],
  2348. dai_data));
  2349. break;
  2350. case AFE_PORT_ID_USB_RX:
  2351. rc = snd_ctl_add(dai->component->card->snd_card,
  2352. snd_ctl_new1(&usb_audio_cfg_controls[0],
  2353. dai_data));
  2354. rc = snd_ctl_add(dai->component->card->snd_card,
  2355. snd_ctl_new1(&usb_audio_cfg_controls[1],
  2356. dai_data));
  2357. break;
  2358. case AFE_PORT_ID_USB_TX:
  2359. rc = snd_ctl_add(dai->component->card->snd_card,
  2360. snd_ctl_new1(&usb_audio_cfg_controls[2],
  2361. dai_data));
  2362. rc = snd_ctl_add(dai->component->card->snd_card,
  2363. snd_ctl_new1(&usb_audio_cfg_controls[3],
  2364. dai_data));
  2365. break;
  2366. case SLIMBUS_0_RX:
  2367. rc = snd_ctl_add(dai->component->card->snd_card,
  2368. snd_ctl_new1(&avd_drift_config_controls[0],
  2369. dai));
  2370. break;
  2371. case SLIMBUS_6_RX:
  2372. rc = snd_ctl_add(dai->component->card->snd_card,
  2373. snd_ctl_new1(&avd_drift_config_controls[1],
  2374. dai));
  2375. break;
  2376. }
  2377. if (rc < 0)
  2378. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  2379. __func__, dai->name);
  2380. rc = msm_dai_q6_dai_add_route(dai);
  2381. return rc;
  2382. }
  2383. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  2384. {
  2385. struct msm_dai_q6_dai_data *dai_data;
  2386. int rc;
  2387. dai_data = dev_get_drvdata(dai->dev);
  2388. /* If AFE port is still up, close it */
  2389. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2390. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2391. rc = afe_close(dai->id); /* can block */
  2392. if (rc < 0)
  2393. dev_err(dai->dev, "fail to close AFE port\n");
  2394. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2395. }
  2396. kfree(dai_data);
  2397. return 0;
  2398. }
  2399. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  2400. {
  2401. .playback = {
  2402. .stream_name = "AFE Playback",
  2403. .aif_name = "PCM_RX",
  2404. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2405. SNDRV_PCM_RATE_16000,
  2406. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2407. SNDRV_PCM_FMTBIT_S24_LE,
  2408. .channels_min = 1,
  2409. .channels_max = 2,
  2410. .rate_min = 8000,
  2411. .rate_max = 48000,
  2412. },
  2413. .ops = &msm_dai_q6_ops,
  2414. .id = RT_PROXY_DAI_001_RX,
  2415. .probe = msm_dai_q6_dai_probe,
  2416. .remove = msm_dai_q6_dai_remove,
  2417. },
  2418. {
  2419. .playback = {
  2420. .stream_name = "AFE-PROXY RX",
  2421. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2422. SNDRV_PCM_RATE_16000,
  2423. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2424. SNDRV_PCM_FMTBIT_S24_LE,
  2425. .channels_min = 1,
  2426. .channels_max = 2,
  2427. .rate_min = 8000,
  2428. .rate_max = 48000,
  2429. },
  2430. .ops = &msm_dai_q6_ops,
  2431. .id = RT_PROXY_DAI_002_RX,
  2432. .probe = msm_dai_q6_dai_probe,
  2433. .remove = msm_dai_q6_dai_remove,
  2434. },
  2435. };
  2436. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  2437. {
  2438. .capture = {
  2439. .stream_name = "AFE Capture",
  2440. .aif_name = "PCM_TX",
  2441. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2442. SNDRV_PCM_RATE_16000,
  2443. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2444. .channels_min = 1,
  2445. .channels_max = 8,
  2446. .rate_min = 8000,
  2447. .rate_max = 48000,
  2448. },
  2449. .ops = &msm_dai_q6_ops,
  2450. .id = RT_PROXY_DAI_002_TX,
  2451. .probe = msm_dai_q6_dai_probe,
  2452. .remove = msm_dai_q6_dai_remove,
  2453. },
  2454. {
  2455. .capture = {
  2456. .stream_name = "AFE-PROXY TX",
  2457. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2458. SNDRV_PCM_RATE_16000,
  2459. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2460. .channels_min = 1,
  2461. .channels_max = 8,
  2462. .rate_min = 8000,
  2463. .rate_max = 48000,
  2464. },
  2465. .ops = &msm_dai_q6_ops,
  2466. .id = RT_PROXY_DAI_001_TX,
  2467. .probe = msm_dai_q6_dai_probe,
  2468. .remove = msm_dai_q6_dai_remove,
  2469. },
  2470. };
  2471. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  2472. .playback = {
  2473. .stream_name = "Internal BT-SCO Playback",
  2474. .aif_name = "INT_BT_SCO_RX",
  2475. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  2476. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2477. .channels_min = 1,
  2478. .channels_max = 1,
  2479. .rate_max = 16000,
  2480. .rate_min = 8000,
  2481. },
  2482. .ops = &msm_dai_q6_ops,
  2483. .id = INT_BT_SCO_RX,
  2484. .probe = msm_dai_q6_dai_probe,
  2485. .remove = msm_dai_q6_dai_remove,
  2486. };
  2487. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  2488. .playback = {
  2489. .stream_name = "Internal BT-A2DP Playback",
  2490. .aif_name = "INT_BT_A2DP_RX",
  2491. .rates = SNDRV_PCM_RATE_48000,
  2492. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2493. .channels_min = 1,
  2494. .channels_max = 2,
  2495. .rate_max = 48000,
  2496. .rate_min = 48000,
  2497. },
  2498. .ops = &msm_dai_q6_ops,
  2499. .id = INT_BT_A2DP_RX,
  2500. .probe = msm_dai_q6_dai_probe,
  2501. .remove = msm_dai_q6_dai_remove,
  2502. };
  2503. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  2504. .capture = {
  2505. .stream_name = "Internal BT-SCO Capture",
  2506. .aif_name = "INT_BT_SCO_TX",
  2507. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  2508. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2509. .channels_min = 1,
  2510. .channels_max = 1,
  2511. .rate_max = 16000,
  2512. .rate_min = 8000,
  2513. },
  2514. .ops = &msm_dai_q6_ops,
  2515. .id = INT_BT_SCO_TX,
  2516. .probe = msm_dai_q6_dai_probe,
  2517. .remove = msm_dai_q6_dai_remove,
  2518. };
  2519. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  2520. .playback = {
  2521. .stream_name = "Internal FM Playback",
  2522. .aif_name = "INT_FM_RX",
  2523. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2524. SNDRV_PCM_RATE_16000,
  2525. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2526. .channels_min = 2,
  2527. .channels_max = 2,
  2528. .rate_max = 48000,
  2529. .rate_min = 8000,
  2530. },
  2531. .ops = &msm_dai_q6_ops,
  2532. .id = INT_FM_RX,
  2533. .probe = msm_dai_q6_dai_probe,
  2534. .remove = msm_dai_q6_dai_remove,
  2535. };
  2536. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  2537. .capture = {
  2538. .stream_name = "Internal FM Capture",
  2539. .aif_name = "INT_FM_TX",
  2540. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2541. SNDRV_PCM_RATE_16000,
  2542. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2543. .channels_min = 2,
  2544. .channels_max = 2,
  2545. .rate_max = 48000,
  2546. .rate_min = 8000,
  2547. },
  2548. .ops = &msm_dai_q6_ops,
  2549. .id = INT_FM_TX,
  2550. .probe = msm_dai_q6_dai_probe,
  2551. .remove = msm_dai_q6_dai_remove,
  2552. };
  2553. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  2554. {
  2555. .playback = {
  2556. .stream_name = "Voice Farend Playback",
  2557. .aif_name = "VOICE_PLAYBACK_TX",
  2558. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2559. SNDRV_PCM_RATE_16000,
  2560. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2561. .channels_min = 1,
  2562. .channels_max = 2,
  2563. .rate_min = 8000,
  2564. .rate_max = 48000,
  2565. },
  2566. .ops = &msm_dai_q6_ops,
  2567. .id = VOICE_PLAYBACK_TX,
  2568. .probe = msm_dai_q6_dai_probe,
  2569. .remove = msm_dai_q6_dai_remove,
  2570. },
  2571. {
  2572. .playback = {
  2573. .stream_name = "Voice2 Farend Playback",
  2574. .aif_name = "VOICE2_PLAYBACK_TX",
  2575. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2576. SNDRV_PCM_RATE_16000,
  2577. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2578. .channels_min = 1,
  2579. .channels_max = 2,
  2580. .rate_min = 8000,
  2581. .rate_max = 48000,
  2582. },
  2583. .ops = &msm_dai_q6_ops,
  2584. .id = VOICE2_PLAYBACK_TX,
  2585. .probe = msm_dai_q6_dai_probe,
  2586. .remove = msm_dai_q6_dai_remove,
  2587. },
  2588. };
  2589. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  2590. {
  2591. .capture = {
  2592. .stream_name = "Voice Uplink Capture",
  2593. .aif_name = "INCALL_RECORD_TX",
  2594. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2595. SNDRV_PCM_RATE_16000,
  2596. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2597. .channels_min = 1,
  2598. .channels_max = 2,
  2599. .rate_min = 8000,
  2600. .rate_max = 48000,
  2601. },
  2602. .ops = &msm_dai_q6_ops,
  2603. .id = VOICE_RECORD_TX,
  2604. .probe = msm_dai_q6_dai_probe,
  2605. .remove = msm_dai_q6_dai_remove,
  2606. },
  2607. {
  2608. .capture = {
  2609. .stream_name = "Voice Downlink Capture",
  2610. .aif_name = "INCALL_RECORD_RX",
  2611. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2612. SNDRV_PCM_RATE_16000,
  2613. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2614. .channels_min = 1,
  2615. .channels_max = 2,
  2616. .rate_min = 8000,
  2617. .rate_max = 48000,
  2618. },
  2619. .ops = &msm_dai_q6_ops,
  2620. .id = VOICE_RECORD_RX,
  2621. .probe = msm_dai_q6_dai_probe,
  2622. .remove = msm_dai_q6_dai_remove,
  2623. },
  2624. };
  2625. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  2626. .playback = {
  2627. .stream_name = "USB Audio Playback",
  2628. .aif_name = "USB_AUDIO_RX",
  2629. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2630. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2631. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2632. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2633. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2634. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2635. SNDRV_PCM_RATE_384000,
  2636. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  2637. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  2638. .channels_min = 1,
  2639. .channels_max = 8,
  2640. .rate_max = 384000,
  2641. .rate_min = 8000,
  2642. },
  2643. .ops = &msm_dai_q6_ops,
  2644. .id = AFE_PORT_ID_USB_RX,
  2645. .probe = msm_dai_q6_dai_probe,
  2646. .remove = msm_dai_q6_dai_remove,
  2647. };
  2648. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  2649. .capture = {
  2650. .stream_name = "USB Audio Capture",
  2651. .aif_name = "USB_AUDIO_TX",
  2652. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2653. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2654. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2655. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2656. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2657. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2658. SNDRV_PCM_RATE_384000,
  2659. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  2660. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  2661. .channels_min = 1,
  2662. .channels_max = 8,
  2663. .rate_max = 384000,
  2664. .rate_min = 8000,
  2665. },
  2666. .ops = &msm_dai_q6_ops,
  2667. .id = AFE_PORT_ID_USB_TX,
  2668. .probe = msm_dai_q6_dai_probe,
  2669. .remove = msm_dai_q6_dai_remove,
  2670. };
  2671. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  2672. {
  2673. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  2674. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  2675. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  2676. uint32_t val = 0;
  2677. const char *intf_name;
  2678. int rc = 0, i = 0, len = 0;
  2679. const uint32_t *slot_mapping_array = NULL;
  2680. u32 array_length = 0;
  2681. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  2682. GFP_KERNEL);
  2683. if (!dai_data)
  2684. return -ENOMEM;
  2685. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  2686. GFP_KERNEL);
  2687. if (!auxpcm_pdata) {
  2688. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  2689. goto fail_pdata_nomem;
  2690. }
  2691. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  2692. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  2693. rc = of_property_read_u32_array(pdev->dev.of_node,
  2694. "qcom,msm-cpudai-auxpcm-mode",
  2695. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2696. if (rc) {
  2697. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  2698. __func__);
  2699. goto fail_invalid_dt;
  2700. }
  2701. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  2702. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  2703. rc = of_property_read_u32_array(pdev->dev.of_node,
  2704. "qcom,msm-cpudai-auxpcm-sync",
  2705. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2706. if (rc) {
  2707. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  2708. __func__);
  2709. goto fail_invalid_dt;
  2710. }
  2711. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  2712. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  2713. rc = of_property_read_u32_array(pdev->dev.of_node,
  2714. "qcom,msm-cpudai-auxpcm-frame",
  2715. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2716. if (rc) {
  2717. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  2718. __func__);
  2719. goto fail_invalid_dt;
  2720. }
  2721. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  2722. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  2723. rc = of_property_read_u32_array(pdev->dev.of_node,
  2724. "qcom,msm-cpudai-auxpcm-quant",
  2725. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2726. if (rc) {
  2727. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  2728. __func__);
  2729. goto fail_invalid_dt;
  2730. }
  2731. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  2732. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  2733. rc = of_property_read_u32_array(pdev->dev.of_node,
  2734. "qcom,msm-cpudai-auxpcm-num-slots",
  2735. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2736. if (rc) {
  2737. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  2738. __func__);
  2739. goto fail_invalid_dt;
  2740. }
  2741. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  2742. if (auxpcm_pdata->mode_8k.num_slots >
  2743. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  2744. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  2745. __func__,
  2746. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  2747. auxpcm_pdata->mode_8k.num_slots);
  2748. rc = -EINVAL;
  2749. goto fail_invalid_dt;
  2750. }
  2751. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  2752. if (auxpcm_pdata->mode_16k.num_slots >
  2753. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  2754. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  2755. __func__,
  2756. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  2757. auxpcm_pdata->mode_16k.num_slots);
  2758. rc = -EINVAL;
  2759. goto fail_invalid_dt;
  2760. }
  2761. slot_mapping_array = of_get_property(pdev->dev.of_node,
  2762. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  2763. if (slot_mapping_array == NULL) {
  2764. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  2765. __func__);
  2766. rc = -EINVAL;
  2767. goto fail_invalid_dt;
  2768. }
  2769. array_length = auxpcm_pdata->mode_8k.num_slots +
  2770. auxpcm_pdata->mode_16k.num_slots;
  2771. if (len != sizeof(uint32_t) * array_length) {
  2772. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  2773. __func__, len, sizeof(uint32_t) * array_length);
  2774. rc = -EINVAL;
  2775. goto fail_invalid_dt;
  2776. }
  2777. auxpcm_pdata->mode_8k.slot_mapping =
  2778. kzalloc(sizeof(uint16_t) *
  2779. auxpcm_pdata->mode_8k.num_slots,
  2780. GFP_KERNEL);
  2781. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  2782. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  2783. __func__);
  2784. rc = -ENOMEM;
  2785. goto fail_invalid_dt;
  2786. }
  2787. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  2788. auxpcm_pdata->mode_8k.slot_mapping[i] =
  2789. (u16)be32_to_cpu(slot_mapping_array[i]);
  2790. auxpcm_pdata->mode_16k.slot_mapping =
  2791. kzalloc(sizeof(uint16_t) *
  2792. auxpcm_pdata->mode_16k.num_slots,
  2793. GFP_KERNEL);
  2794. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  2795. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  2796. __func__);
  2797. rc = -ENOMEM;
  2798. goto fail_invalid_16k_slot_mapping;
  2799. }
  2800. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  2801. auxpcm_pdata->mode_16k.slot_mapping[i] =
  2802. (u16)be32_to_cpu(slot_mapping_array[i +
  2803. auxpcm_pdata->mode_8k.num_slots]);
  2804. rc = of_property_read_u32_array(pdev->dev.of_node,
  2805. "qcom,msm-cpudai-auxpcm-data",
  2806. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2807. if (rc) {
  2808. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  2809. __func__);
  2810. goto fail_invalid_dt1;
  2811. }
  2812. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  2813. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  2814. rc = of_property_read_u32_array(pdev->dev.of_node,
  2815. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  2816. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2817. if (rc) {
  2818. dev_err(&pdev->dev,
  2819. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  2820. __func__);
  2821. goto fail_invalid_dt1;
  2822. }
  2823. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  2824. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  2825. rc = of_property_read_string(pdev->dev.of_node,
  2826. "qcom,msm-auxpcm-interface", &intf_name);
  2827. if (rc) {
  2828. dev_err(&pdev->dev,
  2829. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  2830. __func__);
  2831. goto fail_nodev_intf;
  2832. }
  2833. if (!strcmp(intf_name, "primary")) {
  2834. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  2835. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  2836. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  2837. i = 0;
  2838. } else if (!strcmp(intf_name, "secondary")) {
  2839. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  2840. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  2841. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  2842. i = 1;
  2843. } else if (!strcmp(intf_name, "tertiary")) {
  2844. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  2845. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  2846. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  2847. i = 2;
  2848. } else if (!strcmp(intf_name, "quaternary")) {
  2849. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  2850. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  2851. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  2852. i = 3;
  2853. } else if (!strcmp(intf_name, "quinary")) {
  2854. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  2855. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  2856. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  2857. i = 4;
  2858. } else {
  2859. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  2860. __func__, intf_name);
  2861. goto fail_invalid_intf;
  2862. }
  2863. rc = of_property_read_u32(pdev->dev.of_node,
  2864. "qcom,msm-cpudai-afe-clk-ver", &val);
  2865. if (rc)
  2866. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  2867. else
  2868. dai_data->afe_clk_ver = val;
  2869. mutex_init(&dai_data->rlock);
  2870. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  2871. dev_set_drvdata(&pdev->dev, dai_data);
  2872. pdev->dev.platform_data = (void *) auxpcm_pdata;
  2873. rc = snd_soc_register_component(&pdev->dev,
  2874. &msm_dai_q6_aux_pcm_dai_component,
  2875. &msm_dai_q6_aux_pcm_dai[i], 1);
  2876. if (rc) {
  2877. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  2878. __func__, rc);
  2879. goto fail_reg_dai;
  2880. }
  2881. return rc;
  2882. fail_reg_dai:
  2883. fail_invalid_intf:
  2884. fail_nodev_intf:
  2885. fail_invalid_dt1:
  2886. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  2887. fail_invalid_16k_slot_mapping:
  2888. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  2889. fail_invalid_dt:
  2890. kfree(auxpcm_pdata);
  2891. fail_pdata_nomem:
  2892. kfree(dai_data);
  2893. return rc;
  2894. }
  2895. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  2896. {
  2897. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  2898. dai_data = dev_get_drvdata(&pdev->dev);
  2899. snd_soc_unregister_component(&pdev->dev);
  2900. mutex_destroy(&dai_data->rlock);
  2901. kfree(dai_data);
  2902. kfree(pdev->dev.platform_data);
  2903. return 0;
  2904. }
  2905. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  2906. { .compatible = "qcom,msm-auxpcm-dev", },
  2907. {}
  2908. };
  2909. static struct platform_driver msm_auxpcm_dev_driver = {
  2910. .probe = msm_auxpcm_dev_probe,
  2911. .remove = msm_auxpcm_dev_remove,
  2912. .driver = {
  2913. .name = "msm-auxpcm-dev",
  2914. .owner = THIS_MODULE,
  2915. .of_match_table = msm_auxpcm_dev_dt_match,
  2916. },
  2917. };
  2918. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  2919. {
  2920. .playback = {
  2921. .stream_name = "Slimbus Playback",
  2922. .aif_name = "SLIMBUS_0_RX",
  2923. .rates = SNDRV_PCM_RATE_8000_384000,
  2924. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2925. .channels_min = 1,
  2926. .channels_max = 8,
  2927. .rate_min = 8000,
  2928. .rate_max = 384000,
  2929. },
  2930. .ops = &msm_dai_q6_ops,
  2931. .id = SLIMBUS_0_RX,
  2932. .probe = msm_dai_q6_dai_probe,
  2933. .remove = msm_dai_q6_dai_remove,
  2934. },
  2935. {
  2936. .playback = {
  2937. .stream_name = "Slimbus1 Playback",
  2938. .aif_name = "SLIMBUS_1_RX",
  2939. .rates = SNDRV_PCM_RATE_8000_384000,
  2940. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2941. .channels_min = 1,
  2942. .channels_max = 2,
  2943. .rate_min = 8000,
  2944. .rate_max = 384000,
  2945. },
  2946. .ops = &msm_dai_q6_ops,
  2947. .id = SLIMBUS_1_RX,
  2948. .probe = msm_dai_q6_dai_probe,
  2949. .remove = msm_dai_q6_dai_remove,
  2950. },
  2951. {
  2952. .playback = {
  2953. .stream_name = "Slimbus2 Playback",
  2954. .aif_name = "SLIMBUS_2_RX",
  2955. .rates = SNDRV_PCM_RATE_8000_384000,
  2956. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2957. .channels_min = 1,
  2958. .channels_max = 8,
  2959. .rate_min = 8000,
  2960. .rate_max = 384000,
  2961. },
  2962. .ops = &msm_dai_q6_ops,
  2963. .id = SLIMBUS_2_RX,
  2964. .probe = msm_dai_q6_dai_probe,
  2965. .remove = msm_dai_q6_dai_remove,
  2966. },
  2967. {
  2968. .playback = {
  2969. .stream_name = "Slimbus3 Playback",
  2970. .aif_name = "SLIMBUS_3_RX",
  2971. .rates = SNDRV_PCM_RATE_8000_384000,
  2972. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2973. .channels_min = 1,
  2974. .channels_max = 2,
  2975. .rate_min = 8000,
  2976. .rate_max = 384000,
  2977. },
  2978. .ops = &msm_dai_q6_ops,
  2979. .id = SLIMBUS_3_RX,
  2980. .probe = msm_dai_q6_dai_probe,
  2981. .remove = msm_dai_q6_dai_remove,
  2982. },
  2983. {
  2984. .playback = {
  2985. .stream_name = "Slimbus4 Playback",
  2986. .aif_name = "SLIMBUS_4_RX",
  2987. .rates = SNDRV_PCM_RATE_8000_384000,
  2988. .formats = DAI_FORMATS_S16_S24_S32_LE,
  2989. .channels_min = 1,
  2990. .channels_max = 2,
  2991. .rate_min = 8000,
  2992. .rate_max = 384000,
  2993. },
  2994. .ops = &msm_dai_q6_ops,
  2995. .id = SLIMBUS_4_RX,
  2996. .probe = msm_dai_q6_dai_probe,
  2997. .remove = msm_dai_q6_dai_remove,
  2998. },
  2999. {
  3000. .playback = {
  3001. .stream_name = "Slimbus6 Playback",
  3002. .aif_name = "SLIMBUS_6_RX",
  3003. .rates = SNDRV_PCM_RATE_8000_384000,
  3004. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3005. .channels_min = 1,
  3006. .channels_max = 2,
  3007. .rate_min = 8000,
  3008. .rate_max = 384000,
  3009. },
  3010. .ops = &msm_dai_q6_ops,
  3011. .id = SLIMBUS_6_RX,
  3012. .probe = msm_dai_q6_dai_probe,
  3013. .remove = msm_dai_q6_dai_remove,
  3014. },
  3015. {
  3016. .playback = {
  3017. .stream_name = "Slimbus5 Playback",
  3018. .aif_name = "SLIMBUS_5_RX",
  3019. .rates = SNDRV_PCM_RATE_8000_384000,
  3020. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3021. .channels_min = 1,
  3022. .channels_max = 2,
  3023. .rate_min = 8000,
  3024. .rate_max = 384000,
  3025. },
  3026. .ops = &msm_dai_q6_ops,
  3027. .id = SLIMBUS_5_RX,
  3028. .probe = msm_dai_q6_dai_probe,
  3029. .remove = msm_dai_q6_dai_remove,
  3030. },
  3031. {
  3032. .playback = {
  3033. .stream_name = "Slimbus7 Playback",
  3034. .aif_name = "SLIMBUS_7_RX",
  3035. .rates = SNDRV_PCM_RATE_8000_384000,
  3036. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3037. .channels_min = 1,
  3038. .channels_max = 8,
  3039. .rate_min = 8000,
  3040. .rate_max = 384000,
  3041. },
  3042. .ops = &msm_dai_q6_ops,
  3043. .id = SLIMBUS_7_RX,
  3044. .probe = msm_dai_q6_dai_probe,
  3045. .remove = msm_dai_q6_dai_remove,
  3046. },
  3047. {
  3048. .playback = {
  3049. .stream_name = "Slimbus8 Playback",
  3050. .aif_name = "SLIMBUS_8_RX",
  3051. .rates = SNDRV_PCM_RATE_8000_384000,
  3052. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3053. .channels_min = 1,
  3054. .channels_max = 8,
  3055. .rate_min = 8000,
  3056. .rate_max = 384000,
  3057. },
  3058. .ops = &msm_dai_q6_ops,
  3059. .id = SLIMBUS_8_RX,
  3060. .probe = msm_dai_q6_dai_probe,
  3061. .remove = msm_dai_q6_dai_remove,
  3062. },
  3063. };
  3064. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  3065. {
  3066. .capture = {
  3067. .stream_name = "Slimbus Capture",
  3068. .aif_name = "SLIMBUS_0_TX",
  3069. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3070. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3071. SNDRV_PCM_RATE_192000,
  3072. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3073. SNDRV_PCM_FMTBIT_S24_LE |
  3074. SNDRV_PCM_FMTBIT_S24_3LE,
  3075. .channels_min = 1,
  3076. .channels_max = 8,
  3077. .rate_min = 8000,
  3078. .rate_max = 192000,
  3079. },
  3080. .ops = &msm_dai_q6_ops,
  3081. .id = SLIMBUS_0_TX,
  3082. .probe = msm_dai_q6_dai_probe,
  3083. .remove = msm_dai_q6_dai_remove,
  3084. },
  3085. {
  3086. .capture = {
  3087. .stream_name = "Slimbus1 Capture",
  3088. .aif_name = "SLIMBUS_1_TX",
  3089. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3090. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3091. SNDRV_PCM_RATE_192000,
  3092. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3093. SNDRV_PCM_FMTBIT_S24_LE |
  3094. SNDRV_PCM_FMTBIT_S24_3LE,
  3095. .channels_min = 1,
  3096. .channels_max = 2,
  3097. .rate_min = 8000,
  3098. .rate_max = 192000,
  3099. },
  3100. .ops = &msm_dai_q6_ops,
  3101. .id = SLIMBUS_1_TX,
  3102. .probe = msm_dai_q6_dai_probe,
  3103. .remove = msm_dai_q6_dai_remove,
  3104. },
  3105. {
  3106. .capture = {
  3107. .stream_name = "Slimbus2 Capture",
  3108. .aif_name = "SLIMBUS_2_TX",
  3109. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3110. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3111. SNDRV_PCM_RATE_192000,
  3112. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3113. SNDRV_PCM_FMTBIT_S24_LE,
  3114. .channels_min = 1,
  3115. .channels_max = 8,
  3116. .rate_min = 8000,
  3117. .rate_max = 192000,
  3118. },
  3119. .ops = &msm_dai_q6_ops,
  3120. .id = SLIMBUS_2_TX,
  3121. .probe = msm_dai_q6_dai_probe,
  3122. .remove = msm_dai_q6_dai_remove,
  3123. },
  3124. {
  3125. .capture = {
  3126. .stream_name = "Slimbus3 Capture",
  3127. .aif_name = "SLIMBUS_3_TX",
  3128. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3129. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3130. SNDRV_PCM_RATE_192000,
  3131. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3132. SNDRV_PCM_FMTBIT_S24_LE,
  3133. .channels_min = 2,
  3134. .channels_max = 4,
  3135. .rate_min = 8000,
  3136. .rate_max = 192000,
  3137. },
  3138. .ops = &msm_dai_q6_ops,
  3139. .id = SLIMBUS_3_TX,
  3140. .probe = msm_dai_q6_dai_probe,
  3141. .remove = msm_dai_q6_dai_remove,
  3142. },
  3143. {
  3144. .capture = {
  3145. .stream_name = "Slimbus4 Capture",
  3146. .aif_name = "SLIMBUS_4_TX",
  3147. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3148. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3149. SNDRV_PCM_RATE_192000,
  3150. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3151. SNDRV_PCM_FMTBIT_S24_LE |
  3152. SNDRV_PCM_FMTBIT_S32_LE,
  3153. .channels_min = 2,
  3154. .channels_max = 4,
  3155. .rate_min = 8000,
  3156. .rate_max = 192000,
  3157. },
  3158. .ops = &msm_dai_q6_ops,
  3159. .id = SLIMBUS_4_TX,
  3160. .probe = msm_dai_q6_dai_probe,
  3161. .remove = msm_dai_q6_dai_remove,
  3162. },
  3163. {
  3164. .capture = {
  3165. .stream_name = "Slimbus5 Capture",
  3166. .aif_name = "SLIMBUS_5_TX",
  3167. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3168. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3169. SNDRV_PCM_RATE_192000,
  3170. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3171. SNDRV_PCM_FMTBIT_S24_LE,
  3172. .channels_min = 1,
  3173. .channels_max = 8,
  3174. .rate_min = 8000,
  3175. .rate_max = 192000,
  3176. },
  3177. .ops = &msm_dai_q6_ops,
  3178. .id = SLIMBUS_5_TX,
  3179. .probe = msm_dai_q6_dai_probe,
  3180. .remove = msm_dai_q6_dai_remove,
  3181. },
  3182. {
  3183. .capture = {
  3184. .stream_name = "Slimbus6 Capture",
  3185. .aif_name = "SLIMBUS_6_TX",
  3186. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3187. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3188. SNDRV_PCM_RATE_192000,
  3189. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3190. SNDRV_PCM_FMTBIT_S24_LE,
  3191. .channels_min = 1,
  3192. .channels_max = 2,
  3193. .rate_min = 8000,
  3194. .rate_max = 192000,
  3195. },
  3196. .ops = &msm_dai_q6_ops,
  3197. .id = SLIMBUS_6_TX,
  3198. .probe = msm_dai_q6_dai_probe,
  3199. .remove = msm_dai_q6_dai_remove,
  3200. },
  3201. {
  3202. .capture = {
  3203. .stream_name = "Slimbus7 Capture",
  3204. .aif_name = "SLIMBUS_7_TX",
  3205. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3206. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3207. SNDRV_PCM_RATE_192000,
  3208. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3209. SNDRV_PCM_FMTBIT_S24_LE |
  3210. SNDRV_PCM_FMTBIT_S32_LE,
  3211. .channels_min = 1,
  3212. .channels_max = 8,
  3213. .rate_min = 8000,
  3214. .rate_max = 192000,
  3215. },
  3216. .ops = &msm_dai_q6_ops,
  3217. .id = SLIMBUS_7_TX,
  3218. .probe = msm_dai_q6_dai_probe,
  3219. .remove = msm_dai_q6_dai_remove,
  3220. },
  3221. {
  3222. .capture = {
  3223. .stream_name = "Slimbus8 Capture",
  3224. .aif_name = "SLIMBUS_8_TX",
  3225. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3226. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3227. SNDRV_PCM_RATE_192000,
  3228. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3229. SNDRV_PCM_FMTBIT_S24_LE |
  3230. SNDRV_PCM_FMTBIT_S32_LE,
  3231. .channels_min = 1,
  3232. .channels_max = 8,
  3233. .rate_min = 8000,
  3234. .rate_max = 192000,
  3235. },
  3236. .ops = &msm_dai_q6_ops,
  3237. .id = SLIMBUS_8_TX,
  3238. .probe = msm_dai_q6_dai_probe,
  3239. .remove = msm_dai_q6_dai_remove,
  3240. },
  3241. };
  3242. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  3243. struct snd_ctl_elem_value *ucontrol)
  3244. {
  3245. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3246. int value = ucontrol->value.integer.value[0];
  3247. dai_data->port_config.i2s.data_format = value;
  3248. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  3249. __func__, value, dai_data->port_config.i2s.mono_stereo,
  3250. dai_data->port_config.i2s.channel_mode);
  3251. return 0;
  3252. }
  3253. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  3254. struct snd_ctl_elem_value *ucontrol)
  3255. {
  3256. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3257. ucontrol->value.integer.value[0] =
  3258. dai_data->port_config.i2s.data_format;
  3259. return 0;
  3260. }
  3261. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  3262. struct snd_ctl_elem_value *ucontrol)
  3263. {
  3264. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3265. int value = ucontrol->value.integer.value[0];
  3266. dai_data->vi_feed_mono = value;
  3267. pr_debug("%s: value = %d\n", __func__, value);
  3268. return 0;
  3269. }
  3270. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  3271. struct snd_ctl_elem_value *ucontrol)
  3272. {
  3273. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3274. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  3275. return 0;
  3276. }
  3277. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  3278. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  3279. msm_dai_q6_mi2s_format_get,
  3280. msm_dai_q6_mi2s_format_put),
  3281. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  3282. msm_dai_q6_mi2s_format_get,
  3283. msm_dai_q6_mi2s_format_put),
  3284. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  3285. msm_dai_q6_mi2s_format_get,
  3286. msm_dai_q6_mi2s_format_put),
  3287. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  3288. msm_dai_q6_mi2s_format_get,
  3289. msm_dai_q6_mi2s_format_put),
  3290. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  3291. msm_dai_q6_mi2s_format_get,
  3292. msm_dai_q6_mi2s_format_put),
  3293. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  3294. msm_dai_q6_mi2s_format_get,
  3295. msm_dai_q6_mi2s_format_put),
  3296. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  3297. msm_dai_q6_mi2s_format_get,
  3298. msm_dai_q6_mi2s_format_put),
  3299. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  3300. msm_dai_q6_mi2s_format_get,
  3301. msm_dai_q6_mi2s_format_put),
  3302. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  3303. msm_dai_q6_mi2s_format_get,
  3304. msm_dai_q6_mi2s_format_put),
  3305. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  3306. msm_dai_q6_mi2s_format_get,
  3307. msm_dai_q6_mi2s_format_put),
  3308. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  3309. msm_dai_q6_mi2s_format_get,
  3310. msm_dai_q6_mi2s_format_put),
  3311. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  3312. msm_dai_q6_mi2s_format_get,
  3313. msm_dai_q6_mi2s_format_put),
  3314. };
  3315. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  3316. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  3317. msm_dai_q6_mi2s_vi_feed_mono_get,
  3318. msm_dai_q6_mi2s_vi_feed_mono_put),
  3319. };
  3320. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  3321. {
  3322. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3323. dev_get_drvdata(dai->dev);
  3324. struct msm_mi2s_pdata *mi2s_pdata =
  3325. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  3326. struct snd_kcontrol *kcontrol = NULL;
  3327. int rc = 0;
  3328. const struct snd_kcontrol_new *ctrl = NULL;
  3329. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  3330. dai->id = mi2s_pdata->intf_id;
  3331. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3332. if (dai->id == MSM_PRIM_MI2S)
  3333. ctrl = &mi2s_config_controls[0];
  3334. if (dai->id == MSM_SEC_MI2S)
  3335. ctrl = &mi2s_config_controls[1];
  3336. if (dai->id == MSM_TERT_MI2S)
  3337. ctrl = &mi2s_config_controls[2];
  3338. if (dai->id == MSM_QUAT_MI2S)
  3339. ctrl = &mi2s_config_controls[3];
  3340. if (dai->id == MSM_QUIN_MI2S)
  3341. ctrl = &mi2s_config_controls[4];
  3342. }
  3343. if (ctrl) {
  3344. kcontrol = snd_ctl_new1(ctrl,
  3345. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  3346. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  3347. if (rc < 0) {
  3348. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  3349. __func__, dai->name);
  3350. goto rtn;
  3351. }
  3352. }
  3353. ctrl = NULL;
  3354. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3355. if (dai->id == MSM_PRIM_MI2S)
  3356. ctrl = &mi2s_config_controls[4];
  3357. if (dai->id == MSM_SEC_MI2S)
  3358. ctrl = &mi2s_config_controls[5];
  3359. if (dai->id == MSM_TERT_MI2S)
  3360. ctrl = &mi2s_config_controls[6];
  3361. if (dai->id == MSM_QUAT_MI2S)
  3362. ctrl = &mi2s_config_controls[7];
  3363. if (dai->id == MSM_QUIN_MI2S)
  3364. ctrl = &mi2s_config_controls[9];
  3365. if (dai->id == MSM_SENARY_MI2S)
  3366. ctrl = &mi2s_config_controls[10];
  3367. if (dai->id == MSM_INT5_MI2S)
  3368. ctrl = &mi2s_config_controls[11];
  3369. }
  3370. if (ctrl) {
  3371. rc = snd_ctl_add(dai->component->card->snd_card,
  3372. snd_ctl_new1(ctrl,
  3373. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3374. if (rc < 0) {
  3375. if (kcontrol)
  3376. snd_ctl_remove(dai->component->card->snd_card,
  3377. kcontrol);
  3378. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  3379. __func__, dai->name);
  3380. }
  3381. }
  3382. if (dai->id == MSM_INT5_MI2S)
  3383. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  3384. if (vi_feed_ctrl) {
  3385. rc = snd_ctl_add(dai->component->card->snd_card,
  3386. snd_ctl_new1(vi_feed_ctrl,
  3387. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3388. if (rc < 0) {
  3389. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  3390. __func__, dai->name);
  3391. }
  3392. }
  3393. rc = msm_dai_q6_dai_add_route(dai);
  3394. rtn:
  3395. return rc;
  3396. }
  3397. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  3398. {
  3399. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3400. dev_get_drvdata(dai->dev);
  3401. int rc;
  3402. /* If AFE port is still up, close it */
  3403. if (test_bit(STATUS_PORT_STARTED,
  3404. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  3405. rc = afe_close(MI2S_RX); /* can block */
  3406. if (rc < 0)
  3407. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  3408. clear_bit(STATUS_PORT_STARTED,
  3409. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  3410. }
  3411. if (test_bit(STATUS_PORT_STARTED,
  3412. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  3413. rc = afe_close(MI2S_TX); /* can block */
  3414. if (rc < 0)
  3415. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  3416. clear_bit(STATUS_PORT_STARTED,
  3417. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  3418. }
  3419. return 0;
  3420. }
  3421. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  3422. struct snd_soc_dai *dai)
  3423. {
  3424. return 0;
  3425. }
  3426. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  3427. {
  3428. int ret = 0;
  3429. switch (stream) {
  3430. case SNDRV_PCM_STREAM_PLAYBACK:
  3431. switch (mi2s_id) {
  3432. case MSM_PRIM_MI2S:
  3433. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  3434. break;
  3435. case MSM_SEC_MI2S:
  3436. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  3437. break;
  3438. case MSM_TERT_MI2S:
  3439. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  3440. break;
  3441. case MSM_QUAT_MI2S:
  3442. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  3443. break;
  3444. case MSM_SEC_MI2S_SD1:
  3445. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  3446. break;
  3447. case MSM_QUIN_MI2S:
  3448. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  3449. break;
  3450. case MSM_INT0_MI2S:
  3451. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  3452. break;
  3453. case MSM_INT1_MI2S:
  3454. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  3455. break;
  3456. case MSM_INT2_MI2S:
  3457. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  3458. break;
  3459. case MSM_INT3_MI2S:
  3460. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  3461. break;
  3462. case MSM_INT4_MI2S:
  3463. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  3464. break;
  3465. case MSM_INT5_MI2S:
  3466. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  3467. break;
  3468. case MSM_INT6_MI2S:
  3469. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  3470. break;
  3471. default:
  3472. pr_err("%s: playback err id 0x%x\n",
  3473. __func__, mi2s_id);
  3474. ret = -1;
  3475. break;
  3476. }
  3477. break;
  3478. case SNDRV_PCM_STREAM_CAPTURE:
  3479. switch (mi2s_id) {
  3480. case MSM_PRIM_MI2S:
  3481. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  3482. break;
  3483. case MSM_SEC_MI2S:
  3484. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  3485. break;
  3486. case MSM_TERT_MI2S:
  3487. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  3488. break;
  3489. case MSM_QUAT_MI2S:
  3490. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  3491. break;
  3492. case MSM_QUIN_MI2S:
  3493. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  3494. break;
  3495. case MSM_SENARY_MI2S:
  3496. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  3497. break;
  3498. case MSM_INT0_MI2S:
  3499. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  3500. break;
  3501. case MSM_INT1_MI2S:
  3502. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  3503. break;
  3504. case MSM_INT2_MI2S:
  3505. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  3506. break;
  3507. case MSM_INT3_MI2S:
  3508. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  3509. break;
  3510. case MSM_INT4_MI2S:
  3511. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  3512. break;
  3513. case MSM_INT5_MI2S:
  3514. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  3515. break;
  3516. case MSM_INT6_MI2S:
  3517. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  3518. break;
  3519. default:
  3520. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  3521. ret = -1;
  3522. break;
  3523. }
  3524. break;
  3525. default:
  3526. pr_err("%s: default err %d\n", __func__, stream);
  3527. ret = -1;
  3528. break;
  3529. }
  3530. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  3531. return ret;
  3532. }
  3533. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  3534. struct snd_soc_dai *dai)
  3535. {
  3536. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3537. dev_get_drvdata(dai->dev);
  3538. struct msm_dai_q6_dai_data *dai_data =
  3539. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3540. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3541. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3542. u16 port_id = 0;
  3543. int rc = 0;
  3544. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  3545. &port_id) != 0) {
  3546. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  3547. __func__, port_id);
  3548. return -EINVAL;
  3549. }
  3550. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  3551. "dai_data->channels = %u sample_rate = %u\n", __func__,
  3552. dai->id, port_id, dai_data->channels, dai_data->rate);
  3553. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3554. /* PORT START should be set if prepare called
  3555. * in active state.
  3556. */
  3557. rc = afe_port_start(port_id, &dai_data->port_config,
  3558. dai_data->rate);
  3559. if (rc < 0)
  3560. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  3561. dai->id);
  3562. else
  3563. set_bit(STATUS_PORT_STARTED,
  3564. dai_data->status_mask);
  3565. }
  3566. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  3567. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3568. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  3569. __func__);
  3570. }
  3571. return rc;
  3572. }
  3573. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  3574. struct snd_pcm_hw_params *params,
  3575. struct snd_soc_dai *dai)
  3576. {
  3577. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3578. dev_get_drvdata(dai->dev);
  3579. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  3580. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3581. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  3582. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  3583. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  3584. dai_data->channels = params_channels(params);
  3585. switch (dai_data->channels) {
  3586. case 8:
  3587. case 7:
  3588. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  3589. goto error_invalid_data;
  3590. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_8CHS;
  3591. break;
  3592. case 6:
  3593. case 5:
  3594. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  3595. goto error_invalid_data;
  3596. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  3597. break;
  3598. case 4:
  3599. case 3:
  3600. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_QUAD01)
  3601. goto error_invalid_data;
  3602. if (mi2s_dai_config->pdata_mi2s_lines == AFE_PORT_I2S_QUAD23)
  3603. dai_data->port_config.i2s.channel_mode =
  3604. mi2s_dai_config->pdata_mi2s_lines;
  3605. else
  3606. dai_data->port_config.i2s.channel_mode =
  3607. AFE_PORT_I2S_QUAD01;
  3608. break;
  3609. case 2:
  3610. case 1:
  3611. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  3612. goto error_invalid_data;
  3613. switch (mi2s_dai_config->pdata_mi2s_lines) {
  3614. case AFE_PORT_I2S_SD0:
  3615. case AFE_PORT_I2S_SD1:
  3616. case AFE_PORT_I2S_SD2:
  3617. case AFE_PORT_I2S_SD3:
  3618. dai_data->port_config.i2s.channel_mode =
  3619. mi2s_dai_config->pdata_mi2s_lines;
  3620. break;
  3621. case AFE_PORT_I2S_QUAD01:
  3622. case AFE_PORT_I2S_6CHS:
  3623. case AFE_PORT_I2S_8CHS:
  3624. if (dai_data->vi_feed_mono == SPKR_1)
  3625. dai_data->port_config.i2s.channel_mode =
  3626. AFE_PORT_I2S_SD0;
  3627. else
  3628. dai_data->port_config.i2s.channel_mode =
  3629. AFE_PORT_I2S_SD1;
  3630. break;
  3631. case AFE_PORT_I2S_QUAD23:
  3632. dai_data->port_config.i2s.channel_mode =
  3633. AFE_PORT_I2S_SD2;
  3634. break;
  3635. }
  3636. if (dai_data->channels == 2)
  3637. dai_data->port_config.i2s.mono_stereo =
  3638. MSM_AFE_CH_STEREO;
  3639. else
  3640. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  3641. break;
  3642. default:
  3643. pr_err("%s: default err channels %d\n",
  3644. __func__, dai_data->channels);
  3645. goto error_invalid_data;
  3646. }
  3647. dai_data->rate = params_rate(params);
  3648. switch (params_format(params)) {
  3649. case SNDRV_PCM_FORMAT_S16_LE:
  3650. case SNDRV_PCM_FORMAT_SPECIAL:
  3651. dai_data->port_config.i2s.bit_width = 16;
  3652. dai_data->bitwidth = 16;
  3653. break;
  3654. case SNDRV_PCM_FORMAT_S24_LE:
  3655. case SNDRV_PCM_FORMAT_S24_3LE:
  3656. dai_data->port_config.i2s.bit_width = 24;
  3657. dai_data->bitwidth = 24;
  3658. break;
  3659. default:
  3660. pr_err("%s: format %d\n",
  3661. __func__, params_format(params));
  3662. return -EINVAL;
  3663. }
  3664. dai_data->port_config.i2s.i2s_cfg_minor_version =
  3665. AFE_API_VERSION_I2S_CONFIG;
  3666. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  3667. if ((test_bit(STATUS_PORT_STARTED,
  3668. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  3669. test_bit(STATUS_PORT_STARTED,
  3670. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  3671. (test_bit(STATUS_PORT_STARTED,
  3672. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  3673. test_bit(STATUS_PORT_STARTED,
  3674. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  3675. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  3676. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  3677. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  3678. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  3679. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  3680. "Tx sample_rate = %u bit_width = %hu\n"
  3681. "Rx sample_rate = %u bit_width = %hu\n"
  3682. , __func__,
  3683. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  3684. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  3685. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  3686. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  3687. return -EINVAL;
  3688. }
  3689. }
  3690. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  3691. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  3692. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  3693. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  3694. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  3695. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  3696. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  3697. i2s->sample_rate, i2s->data_format, i2s->reserved);
  3698. return 0;
  3699. error_invalid_data:
  3700. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  3701. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  3702. return -EINVAL;
  3703. }
  3704. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  3705. {
  3706. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3707. dev_get_drvdata(dai->dev);
  3708. if (test_bit(STATUS_PORT_STARTED,
  3709. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  3710. test_bit(STATUS_PORT_STARTED,
  3711. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  3712. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  3713. __func__);
  3714. return -EPERM;
  3715. }
  3716. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  3717. case SND_SOC_DAIFMT_CBS_CFS:
  3718. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  3719. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  3720. break;
  3721. case SND_SOC_DAIFMT_CBM_CFM:
  3722. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  3723. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  3724. break;
  3725. default:
  3726. pr_err("%s: fmt %d\n",
  3727. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  3728. return -EINVAL;
  3729. }
  3730. return 0;
  3731. }
  3732. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  3733. struct snd_soc_dai *dai)
  3734. {
  3735. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3736. dev_get_drvdata(dai->dev);
  3737. struct msm_dai_q6_dai_data *dai_data =
  3738. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3739. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3740. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3741. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  3742. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3743. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  3744. }
  3745. return 0;
  3746. }
  3747. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  3748. struct snd_soc_dai *dai)
  3749. {
  3750. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3751. dev_get_drvdata(dai->dev);
  3752. struct msm_dai_q6_dai_data *dai_data =
  3753. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3754. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3755. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3756. u16 port_id = 0;
  3757. int rc = 0;
  3758. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  3759. &port_id) != 0) {
  3760. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  3761. __func__, port_id);
  3762. }
  3763. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  3764. __func__, port_id);
  3765. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3766. rc = afe_close(port_id);
  3767. if (rc < 0)
  3768. dev_err(dai->dev, "fail to close AFE port\n");
  3769. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3770. }
  3771. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  3772. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3773. }
  3774. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  3775. .startup = msm_dai_q6_mi2s_startup,
  3776. .prepare = msm_dai_q6_mi2s_prepare,
  3777. .hw_params = msm_dai_q6_mi2s_hw_params,
  3778. .hw_free = msm_dai_q6_mi2s_hw_free,
  3779. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  3780. .shutdown = msm_dai_q6_mi2s_shutdown,
  3781. };
  3782. /* Channel min and max are initialized base on platform data */
  3783. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  3784. {
  3785. .playback = {
  3786. .stream_name = "Primary MI2S Playback",
  3787. .aif_name = "PRI_MI2S_RX",
  3788. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3789. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3790. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3791. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3792. SNDRV_PCM_RATE_192000,
  3793. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3794. SNDRV_PCM_FMTBIT_S24_LE |
  3795. SNDRV_PCM_FMTBIT_S24_3LE,
  3796. .rate_min = 8000,
  3797. .rate_max = 192000,
  3798. },
  3799. .capture = {
  3800. .stream_name = "Primary MI2S Capture",
  3801. .aif_name = "PRI_MI2S_TX",
  3802. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3803. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3804. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3805. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3806. SNDRV_PCM_RATE_192000,
  3807. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3808. .rate_min = 8000,
  3809. .rate_max = 192000,
  3810. },
  3811. .ops = &msm_dai_q6_mi2s_ops,
  3812. .id = MSM_PRIM_MI2S,
  3813. .probe = msm_dai_q6_dai_mi2s_probe,
  3814. .remove = msm_dai_q6_dai_mi2s_remove,
  3815. },
  3816. {
  3817. .playback = {
  3818. .stream_name = "Secondary MI2S Playback",
  3819. .aif_name = "SEC_MI2S_RX",
  3820. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3821. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3822. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3823. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3824. SNDRV_PCM_RATE_192000,
  3825. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3826. .rate_min = 8000,
  3827. .rate_max = 192000,
  3828. },
  3829. .capture = {
  3830. .stream_name = "Secondary MI2S Capture",
  3831. .aif_name = "SEC_MI2S_TX",
  3832. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3833. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3834. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3835. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3836. SNDRV_PCM_RATE_192000,
  3837. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3838. .rate_min = 8000,
  3839. .rate_max = 192000,
  3840. },
  3841. .ops = &msm_dai_q6_mi2s_ops,
  3842. .id = MSM_SEC_MI2S,
  3843. .probe = msm_dai_q6_dai_mi2s_probe,
  3844. .remove = msm_dai_q6_dai_mi2s_remove,
  3845. },
  3846. {
  3847. .playback = {
  3848. .stream_name = "Tertiary MI2S Playback",
  3849. .aif_name = "TERT_MI2S_RX",
  3850. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3851. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3852. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3853. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3854. SNDRV_PCM_RATE_192000,
  3855. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3856. .rate_min = 8000,
  3857. .rate_max = 192000,
  3858. },
  3859. .capture = {
  3860. .stream_name = "Tertiary MI2S Capture",
  3861. .aif_name = "TERT_MI2S_TX",
  3862. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3863. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3864. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3865. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3866. SNDRV_PCM_RATE_192000,
  3867. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3868. .rate_min = 8000,
  3869. .rate_max = 192000,
  3870. },
  3871. .ops = &msm_dai_q6_mi2s_ops,
  3872. .id = MSM_TERT_MI2S,
  3873. .probe = msm_dai_q6_dai_mi2s_probe,
  3874. .remove = msm_dai_q6_dai_mi2s_remove,
  3875. },
  3876. {
  3877. .playback = {
  3878. .stream_name = "Quaternary MI2S Playback",
  3879. .aif_name = "QUAT_MI2S_RX",
  3880. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3881. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3882. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3883. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3884. SNDRV_PCM_RATE_192000,
  3885. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3886. .rate_min = 8000,
  3887. .rate_max = 192000,
  3888. },
  3889. .capture = {
  3890. .stream_name = "Quaternary MI2S Capture",
  3891. .aif_name = "QUAT_MI2S_TX",
  3892. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3893. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3894. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3895. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3896. SNDRV_PCM_RATE_192000,
  3897. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3898. .rate_min = 8000,
  3899. .rate_max = 192000,
  3900. },
  3901. .ops = &msm_dai_q6_mi2s_ops,
  3902. .id = MSM_QUAT_MI2S,
  3903. .probe = msm_dai_q6_dai_mi2s_probe,
  3904. .remove = msm_dai_q6_dai_mi2s_remove,
  3905. },
  3906. {
  3907. .playback = {
  3908. .stream_name = "Secondary MI2S Playback SD1",
  3909. .aif_name = "SEC_MI2S_RX_SD1",
  3910. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3911. SNDRV_PCM_RATE_16000,
  3912. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3913. .rate_min = 8000,
  3914. .rate_max = 48000,
  3915. },
  3916. .id = MSM_SEC_MI2S_SD1,
  3917. },
  3918. {
  3919. .playback = {
  3920. .stream_name = "Quinary MI2S Playback",
  3921. .aif_name = "QUIN_MI2S_RX",
  3922. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3923. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3924. SNDRV_PCM_RATE_192000,
  3925. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3926. .rate_min = 8000,
  3927. .rate_max = 192000,
  3928. },
  3929. .capture = {
  3930. .stream_name = "Quinary MI2S Capture",
  3931. .aif_name = "QUIN_MI2S_TX",
  3932. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3933. SNDRV_PCM_RATE_16000,
  3934. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3935. .rate_min = 8000,
  3936. .rate_max = 48000,
  3937. },
  3938. .ops = &msm_dai_q6_mi2s_ops,
  3939. .id = MSM_QUIN_MI2S,
  3940. .probe = msm_dai_q6_dai_mi2s_probe,
  3941. .remove = msm_dai_q6_dai_mi2s_remove,
  3942. },
  3943. {
  3944. .capture = {
  3945. .stream_name = "Senary_mi2s Capture",
  3946. .aif_name = "SENARY_TX",
  3947. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3948. SNDRV_PCM_RATE_16000,
  3949. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3950. .rate_min = 8000,
  3951. .rate_max = 48000,
  3952. },
  3953. .ops = &msm_dai_q6_mi2s_ops,
  3954. .id = MSM_SENARY_MI2S,
  3955. .probe = msm_dai_q6_dai_mi2s_probe,
  3956. .remove = msm_dai_q6_dai_mi2s_remove,
  3957. },
  3958. {
  3959. .playback = {
  3960. .stream_name = "INT0 MI2S Playback",
  3961. .aif_name = "INT0_MI2S_RX",
  3962. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3963. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  3964. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  3965. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3966. SNDRV_PCM_FMTBIT_S24_LE |
  3967. SNDRV_PCM_FMTBIT_S24_3LE,
  3968. .rate_min = 8000,
  3969. .rate_max = 192000,
  3970. },
  3971. .capture = {
  3972. .stream_name = "INT0 MI2S Capture",
  3973. .aif_name = "INT0_MI2S_TX",
  3974. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3975. SNDRV_PCM_RATE_16000,
  3976. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3977. .rate_min = 8000,
  3978. .rate_max = 48000,
  3979. },
  3980. .ops = &msm_dai_q6_mi2s_ops,
  3981. .id = MSM_INT0_MI2S,
  3982. .probe = msm_dai_q6_dai_mi2s_probe,
  3983. .remove = msm_dai_q6_dai_mi2s_remove,
  3984. },
  3985. {
  3986. .playback = {
  3987. .stream_name = "INT1 MI2S Playback",
  3988. .aif_name = "INT1_MI2S_RX",
  3989. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3990. SNDRV_PCM_RATE_16000,
  3991. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3992. SNDRV_PCM_FMTBIT_S24_LE |
  3993. SNDRV_PCM_FMTBIT_S24_3LE,
  3994. .rate_min = 8000,
  3995. .rate_max = 48000,
  3996. },
  3997. .capture = {
  3998. .stream_name = "INT1 MI2S Capture",
  3999. .aif_name = "INT1_MI2S_TX",
  4000. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4001. SNDRV_PCM_RATE_16000,
  4002. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4003. .rate_min = 8000,
  4004. .rate_max = 48000,
  4005. },
  4006. .ops = &msm_dai_q6_mi2s_ops,
  4007. .id = MSM_INT1_MI2S,
  4008. .probe = msm_dai_q6_dai_mi2s_probe,
  4009. .remove = msm_dai_q6_dai_mi2s_remove,
  4010. },
  4011. {
  4012. .playback = {
  4013. .stream_name = "INT2 MI2S Playback",
  4014. .aif_name = "INT2_MI2S_RX",
  4015. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4016. SNDRV_PCM_RATE_16000,
  4017. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4018. SNDRV_PCM_FMTBIT_S24_LE |
  4019. SNDRV_PCM_FMTBIT_S24_3LE,
  4020. .rate_min = 8000,
  4021. .rate_max = 48000,
  4022. },
  4023. .capture = {
  4024. .stream_name = "INT2 MI2S Capture",
  4025. .aif_name = "INT2_MI2S_TX",
  4026. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4027. SNDRV_PCM_RATE_16000,
  4028. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4029. .rate_min = 8000,
  4030. .rate_max = 48000,
  4031. },
  4032. .ops = &msm_dai_q6_mi2s_ops,
  4033. .id = MSM_INT2_MI2S,
  4034. .probe = msm_dai_q6_dai_mi2s_probe,
  4035. .remove = msm_dai_q6_dai_mi2s_remove,
  4036. },
  4037. {
  4038. .playback = {
  4039. .stream_name = "INT3 MI2S Playback",
  4040. .aif_name = "INT3_MI2S_RX",
  4041. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4042. SNDRV_PCM_RATE_16000,
  4043. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4044. SNDRV_PCM_FMTBIT_S24_LE |
  4045. SNDRV_PCM_FMTBIT_S24_3LE,
  4046. .rate_min = 8000,
  4047. .rate_max = 48000,
  4048. },
  4049. .capture = {
  4050. .stream_name = "INT3 MI2S Capture",
  4051. .aif_name = "INT3_MI2S_TX",
  4052. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4053. SNDRV_PCM_RATE_16000,
  4054. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4055. .rate_min = 8000,
  4056. .rate_max = 48000,
  4057. },
  4058. .ops = &msm_dai_q6_mi2s_ops,
  4059. .id = MSM_INT3_MI2S,
  4060. .probe = msm_dai_q6_dai_mi2s_probe,
  4061. .remove = msm_dai_q6_dai_mi2s_remove,
  4062. },
  4063. {
  4064. .playback = {
  4065. .stream_name = "INT4 MI2S Playback",
  4066. .aif_name = "INT4_MI2S_RX",
  4067. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4068. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4069. SNDRV_PCM_RATE_192000,
  4070. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4071. SNDRV_PCM_FMTBIT_S24_LE |
  4072. SNDRV_PCM_FMTBIT_S24_3LE,
  4073. .rate_min = 8000,
  4074. .rate_max = 192000,
  4075. },
  4076. .capture = {
  4077. .stream_name = "INT4 MI2S Capture",
  4078. .aif_name = "INT4_MI2S_TX",
  4079. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4080. SNDRV_PCM_RATE_16000,
  4081. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4082. .rate_min = 8000,
  4083. .rate_max = 48000,
  4084. },
  4085. .ops = &msm_dai_q6_mi2s_ops,
  4086. .id = MSM_INT4_MI2S,
  4087. .probe = msm_dai_q6_dai_mi2s_probe,
  4088. .remove = msm_dai_q6_dai_mi2s_remove,
  4089. },
  4090. {
  4091. .playback = {
  4092. .stream_name = "INT5 MI2S Playback",
  4093. .aif_name = "INT5_MI2S_RX",
  4094. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4095. SNDRV_PCM_RATE_16000,
  4096. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4097. SNDRV_PCM_FMTBIT_S24_LE |
  4098. SNDRV_PCM_FMTBIT_S24_3LE,
  4099. .rate_min = 8000,
  4100. .rate_max = 48000,
  4101. },
  4102. .capture = {
  4103. .stream_name = "INT5 MI2S Capture",
  4104. .aif_name = "INT5_MI2S_TX",
  4105. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4106. SNDRV_PCM_RATE_16000,
  4107. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4108. .rate_min = 8000,
  4109. .rate_max = 48000,
  4110. },
  4111. .ops = &msm_dai_q6_mi2s_ops,
  4112. .id = MSM_INT5_MI2S,
  4113. .probe = msm_dai_q6_dai_mi2s_probe,
  4114. .remove = msm_dai_q6_dai_mi2s_remove,
  4115. },
  4116. {
  4117. .playback = {
  4118. .stream_name = "INT6 MI2S Playback",
  4119. .aif_name = "INT6_MI2S_RX",
  4120. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4121. SNDRV_PCM_RATE_16000,
  4122. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4123. SNDRV_PCM_FMTBIT_S24_LE |
  4124. SNDRV_PCM_FMTBIT_S24_3LE,
  4125. .rate_min = 8000,
  4126. .rate_max = 48000,
  4127. },
  4128. .capture = {
  4129. .stream_name = "INT6 MI2S Capture",
  4130. .aif_name = "INT6_MI2S_TX",
  4131. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4132. SNDRV_PCM_RATE_16000,
  4133. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4134. .rate_min = 8000,
  4135. .rate_max = 48000,
  4136. },
  4137. .ops = &msm_dai_q6_mi2s_ops,
  4138. .id = MSM_INT6_MI2S,
  4139. .probe = msm_dai_q6_dai_mi2s_probe,
  4140. .remove = msm_dai_q6_dai_mi2s_remove,
  4141. },
  4142. };
  4143. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  4144. unsigned int *ch_cnt)
  4145. {
  4146. u8 num_of_sd_lines;
  4147. num_of_sd_lines = num_of_bits_set(sd_lines);
  4148. switch (num_of_sd_lines) {
  4149. case 0:
  4150. pr_debug("%s: no line is assigned\n", __func__);
  4151. break;
  4152. case 1:
  4153. switch (sd_lines) {
  4154. case MSM_MI2S_SD0:
  4155. *config_ptr = AFE_PORT_I2S_SD0;
  4156. break;
  4157. case MSM_MI2S_SD1:
  4158. *config_ptr = AFE_PORT_I2S_SD1;
  4159. break;
  4160. case MSM_MI2S_SD2:
  4161. *config_ptr = AFE_PORT_I2S_SD2;
  4162. break;
  4163. case MSM_MI2S_SD3:
  4164. *config_ptr = AFE_PORT_I2S_SD3;
  4165. break;
  4166. default:
  4167. pr_err("%s: invalid SD lines %d\n",
  4168. __func__, sd_lines);
  4169. goto error_invalid_data;
  4170. }
  4171. break;
  4172. case 2:
  4173. switch (sd_lines) {
  4174. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  4175. *config_ptr = AFE_PORT_I2S_QUAD01;
  4176. break;
  4177. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4178. *config_ptr = AFE_PORT_I2S_QUAD23;
  4179. break;
  4180. default:
  4181. pr_err("%s: invalid SD lines %d\n",
  4182. __func__, sd_lines);
  4183. goto error_invalid_data;
  4184. }
  4185. break;
  4186. case 3:
  4187. switch (sd_lines) {
  4188. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  4189. *config_ptr = AFE_PORT_I2S_6CHS;
  4190. break;
  4191. default:
  4192. pr_err("%s: invalid SD lines %d\n",
  4193. __func__, sd_lines);
  4194. goto error_invalid_data;
  4195. }
  4196. break;
  4197. case 4:
  4198. switch (sd_lines) {
  4199. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4200. *config_ptr = AFE_PORT_I2S_8CHS;
  4201. break;
  4202. default:
  4203. pr_err("%s: invalid SD lines %d\n",
  4204. __func__, sd_lines);
  4205. goto error_invalid_data;
  4206. }
  4207. break;
  4208. default:
  4209. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  4210. goto error_invalid_data;
  4211. }
  4212. *ch_cnt = num_of_sd_lines;
  4213. return 0;
  4214. error_invalid_data:
  4215. pr_err("%s: invalid data\n", __func__);
  4216. return -EINVAL;
  4217. }
  4218. static int msm_dai_q6_mi2s_platform_data_validation(
  4219. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  4220. {
  4221. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  4222. struct msm_mi2s_pdata *mi2s_pdata =
  4223. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  4224. unsigned int ch_cnt;
  4225. int rc = 0;
  4226. u16 sd_line;
  4227. if (mi2s_pdata == NULL) {
  4228. pr_err("%s: mi2s_pdata NULL", __func__);
  4229. return -EINVAL;
  4230. }
  4231. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  4232. &sd_line, &ch_cnt);
  4233. if (rc < 0) {
  4234. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  4235. goto rtn;
  4236. }
  4237. if (ch_cnt) {
  4238. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4239. sd_line;
  4240. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  4241. dai_driver->playback.channels_min = 1;
  4242. dai_driver->playback.channels_max = ch_cnt << 1;
  4243. } else {
  4244. dai_driver->playback.channels_min = 0;
  4245. dai_driver->playback.channels_max = 0;
  4246. }
  4247. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  4248. &sd_line, &ch_cnt);
  4249. if (rc < 0) {
  4250. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  4251. goto rtn;
  4252. }
  4253. if (ch_cnt) {
  4254. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4255. sd_line;
  4256. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  4257. dai_driver->capture.channels_min = 1;
  4258. dai_driver->capture.channels_max = ch_cnt << 1;
  4259. } else {
  4260. dai_driver->capture.channels_min = 0;
  4261. dai_driver->capture.channels_max = 0;
  4262. }
  4263. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  4264. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  4265. dai_data->tx_dai.pdata_mi2s_lines);
  4266. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  4267. __func__, dai_driver->playback.channels_max,
  4268. dai_driver->capture.channels_max);
  4269. rtn:
  4270. return rc;
  4271. }
  4272. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  4273. .name = "msm-dai-q6-mi2s",
  4274. };
  4275. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  4276. {
  4277. struct msm_dai_q6_mi2s_dai_data *dai_data;
  4278. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  4279. u32 tx_line = 0;
  4280. u32 rx_line = 0;
  4281. u32 mi2s_intf = 0;
  4282. struct msm_mi2s_pdata *mi2s_pdata;
  4283. int rc;
  4284. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  4285. &mi2s_intf);
  4286. if (rc) {
  4287. dev_err(&pdev->dev,
  4288. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  4289. goto rtn;
  4290. }
  4291. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  4292. mi2s_intf);
  4293. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  4294. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  4295. dev_err(&pdev->dev,
  4296. "%s: Invalid MI2S ID %u from Device Tree\n",
  4297. __func__, mi2s_intf);
  4298. rc = -ENXIO;
  4299. goto rtn;
  4300. }
  4301. pdev->id = mi2s_intf;
  4302. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  4303. if (!mi2s_pdata) {
  4304. rc = -ENOMEM;
  4305. goto rtn;
  4306. }
  4307. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  4308. &rx_line);
  4309. if (rc) {
  4310. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  4311. "qcom,msm-mi2s-rx-lines");
  4312. goto free_pdata;
  4313. }
  4314. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  4315. &tx_line);
  4316. if (rc) {
  4317. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  4318. "qcom,msm-mi2s-tx-lines");
  4319. goto free_pdata;
  4320. }
  4321. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  4322. dev_name(&pdev->dev), rx_line, tx_line);
  4323. mi2s_pdata->rx_sd_lines = rx_line;
  4324. mi2s_pdata->tx_sd_lines = tx_line;
  4325. mi2s_pdata->intf_id = mi2s_intf;
  4326. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  4327. GFP_KERNEL);
  4328. if (!dai_data) {
  4329. rc = -ENOMEM;
  4330. goto free_pdata;
  4331. } else
  4332. dev_set_drvdata(&pdev->dev, dai_data);
  4333. pdev->dev.platform_data = mi2s_pdata;
  4334. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  4335. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  4336. if (rc < 0)
  4337. goto free_dai_data;
  4338. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  4339. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  4340. if (rc < 0)
  4341. goto err_register;
  4342. return 0;
  4343. err_register:
  4344. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  4345. free_dai_data:
  4346. kfree(dai_data);
  4347. free_pdata:
  4348. kfree(mi2s_pdata);
  4349. rtn:
  4350. return rc;
  4351. }
  4352. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  4353. {
  4354. snd_soc_unregister_component(&pdev->dev);
  4355. return 0;
  4356. }
  4357. static const struct snd_soc_component_driver msm_dai_q6_component = {
  4358. .name = "msm-dai-q6-dev",
  4359. };
  4360. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  4361. {
  4362. int rc, id, i, len;
  4363. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  4364. char stream_name[80];
  4365. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  4366. if (rc) {
  4367. dev_err(&pdev->dev,
  4368. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  4369. return rc;
  4370. }
  4371. pdev->id = id;
  4372. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4373. dev_name(&pdev->dev), pdev->id);
  4374. switch (id) {
  4375. case SLIMBUS_0_RX:
  4376. strlcpy(stream_name, "Slimbus Playback", 80);
  4377. goto register_slim_playback;
  4378. case SLIMBUS_2_RX:
  4379. strlcpy(stream_name, "Slimbus2 Playback", 80);
  4380. goto register_slim_playback;
  4381. case SLIMBUS_1_RX:
  4382. strlcpy(stream_name, "Slimbus1 Playback", 80);
  4383. goto register_slim_playback;
  4384. case SLIMBUS_3_RX:
  4385. strlcpy(stream_name, "Slimbus3 Playback", 80);
  4386. goto register_slim_playback;
  4387. case SLIMBUS_4_RX:
  4388. strlcpy(stream_name, "Slimbus4 Playback", 80);
  4389. goto register_slim_playback;
  4390. case SLIMBUS_5_RX:
  4391. strlcpy(stream_name, "Slimbus5 Playback", 80);
  4392. goto register_slim_playback;
  4393. case SLIMBUS_6_RX:
  4394. strlcpy(stream_name, "Slimbus6 Playback", 80);
  4395. goto register_slim_playback;
  4396. case SLIMBUS_7_RX:
  4397. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  4398. goto register_slim_playback;
  4399. case SLIMBUS_8_RX:
  4400. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  4401. goto register_slim_playback;
  4402. register_slim_playback:
  4403. rc = -ENODEV;
  4404. len = strnlen(stream_name, 80);
  4405. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  4406. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  4407. !strcmp(stream_name,
  4408. msm_dai_q6_slimbus_rx_dai[i]
  4409. .playback.stream_name)) {
  4410. rc = snd_soc_register_component(&pdev->dev,
  4411. &msm_dai_q6_component,
  4412. &msm_dai_q6_slimbus_rx_dai[i], 1);
  4413. break;
  4414. }
  4415. }
  4416. if (rc)
  4417. pr_err("%s: Device not found stream name %s\n",
  4418. __func__, stream_name);
  4419. break;
  4420. case SLIMBUS_0_TX:
  4421. strlcpy(stream_name, "Slimbus Capture", 80);
  4422. goto register_slim_capture;
  4423. case SLIMBUS_1_TX:
  4424. strlcpy(stream_name, "Slimbus1 Capture", 80);
  4425. goto register_slim_capture;
  4426. case SLIMBUS_2_TX:
  4427. strlcpy(stream_name, "Slimbus2 Capture", 80);
  4428. goto register_slim_capture;
  4429. case SLIMBUS_3_TX:
  4430. strlcpy(stream_name, "Slimbus3 Capture", 80);
  4431. goto register_slim_capture;
  4432. case SLIMBUS_4_TX:
  4433. strlcpy(stream_name, "Slimbus4 Capture", 80);
  4434. goto register_slim_capture;
  4435. case SLIMBUS_5_TX:
  4436. strlcpy(stream_name, "Slimbus5 Capture", 80);
  4437. goto register_slim_capture;
  4438. case SLIMBUS_6_TX:
  4439. strlcpy(stream_name, "Slimbus6 Capture", 80);
  4440. goto register_slim_capture;
  4441. case SLIMBUS_7_TX:
  4442. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  4443. goto register_slim_capture;
  4444. case SLIMBUS_8_TX:
  4445. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  4446. goto register_slim_capture;
  4447. register_slim_capture:
  4448. rc = -ENODEV;
  4449. len = strnlen(stream_name, 80);
  4450. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  4451. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  4452. !strcmp(stream_name,
  4453. msm_dai_q6_slimbus_tx_dai[i]
  4454. .capture.stream_name)) {
  4455. rc = snd_soc_register_component(&pdev->dev,
  4456. &msm_dai_q6_component,
  4457. &msm_dai_q6_slimbus_tx_dai[i], 1);
  4458. break;
  4459. }
  4460. }
  4461. if (rc)
  4462. pr_err("%s: Device not found stream name %s\n",
  4463. __func__, stream_name);
  4464. break;
  4465. case INT_BT_SCO_RX:
  4466. rc = snd_soc_register_component(&pdev->dev,
  4467. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  4468. break;
  4469. case INT_BT_SCO_TX:
  4470. rc = snd_soc_register_component(&pdev->dev,
  4471. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  4472. break;
  4473. case INT_BT_A2DP_RX:
  4474. rc = snd_soc_register_component(&pdev->dev,
  4475. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  4476. break;
  4477. case INT_FM_RX:
  4478. rc = snd_soc_register_component(&pdev->dev,
  4479. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  4480. break;
  4481. case INT_FM_TX:
  4482. rc = snd_soc_register_component(&pdev->dev,
  4483. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  4484. break;
  4485. case AFE_PORT_ID_USB_RX:
  4486. rc = snd_soc_register_component(&pdev->dev,
  4487. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  4488. break;
  4489. case AFE_PORT_ID_USB_TX:
  4490. rc = snd_soc_register_component(&pdev->dev,
  4491. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  4492. break;
  4493. case RT_PROXY_DAI_001_RX:
  4494. strlcpy(stream_name, "AFE Playback", 80);
  4495. goto register_afe_playback;
  4496. case RT_PROXY_DAI_002_RX:
  4497. strlcpy(stream_name, "AFE-PROXY RX", 80);
  4498. register_afe_playback:
  4499. rc = -ENODEV;
  4500. len = strnlen(stream_name, 80);
  4501. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  4502. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  4503. !strcmp(stream_name,
  4504. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  4505. rc = snd_soc_register_component(&pdev->dev,
  4506. &msm_dai_q6_component,
  4507. &msm_dai_q6_afe_rx_dai[i], 1);
  4508. break;
  4509. }
  4510. }
  4511. if (rc)
  4512. pr_err("%s: Device not found stream name %s\n",
  4513. __func__, stream_name);
  4514. break;
  4515. case RT_PROXY_DAI_001_TX:
  4516. strlcpy(stream_name, "AFE-PROXY TX", 80);
  4517. goto register_afe_capture;
  4518. case RT_PROXY_DAI_002_TX:
  4519. strlcpy(stream_name, "AFE Capture", 80);
  4520. register_afe_capture:
  4521. rc = -ENODEV;
  4522. len = strnlen(stream_name, 80);
  4523. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  4524. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  4525. !strcmp(stream_name,
  4526. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  4527. rc = snd_soc_register_component(&pdev->dev,
  4528. &msm_dai_q6_component,
  4529. &msm_dai_q6_afe_tx_dai[i], 1);
  4530. break;
  4531. }
  4532. }
  4533. if (rc)
  4534. pr_err("%s: Device not found stream name %s\n",
  4535. __func__, stream_name);
  4536. break;
  4537. case VOICE_PLAYBACK_TX:
  4538. strlcpy(stream_name, "Voice Farend Playback", 80);
  4539. goto register_voice_playback;
  4540. case VOICE2_PLAYBACK_TX:
  4541. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  4542. register_voice_playback:
  4543. rc = -ENODEV;
  4544. len = strnlen(stream_name, 80);
  4545. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  4546. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  4547. && !strcmp(stream_name,
  4548. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  4549. rc = snd_soc_register_component(&pdev->dev,
  4550. &msm_dai_q6_component,
  4551. &msm_dai_q6_voc_playback_dai[i], 1);
  4552. break;
  4553. }
  4554. }
  4555. if (rc)
  4556. pr_err("%s Device not found stream name %s\n",
  4557. __func__, stream_name);
  4558. break;
  4559. case VOICE_RECORD_RX:
  4560. strlcpy(stream_name, "Voice Downlink Capture", 80);
  4561. goto register_uplink_capture;
  4562. case VOICE_RECORD_TX:
  4563. strlcpy(stream_name, "Voice Uplink Capture", 80);
  4564. register_uplink_capture:
  4565. rc = -ENODEV;
  4566. len = strnlen(stream_name, 80);
  4567. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  4568. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  4569. && !strcmp(stream_name,
  4570. msm_dai_q6_incall_record_dai[i].
  4571. capture.stream_name)) {
  4572. rc = snd_soc_register_component(&pdev->dev,
  4573. &msm_dai_q6_component,
  4574. &msm_dai_q6_incall_record_dai[i], 1);
  4575. break;
  4576. }
  4577. }
  4578. if (rc)
  4579. pr_err("%s: Device not found stream name %s\n",
  4580. __func__, stream_name);
  4581. break;
  4582. default:
  4583. rc = -ENODEV;
  4584. break;
  4585. }
  4586. return rc;
  4587. }
  4588. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  4589. {
  4590. snd_soc_unregister_component(&pdev->dev);
  4591. return 0;
  4592. }
  4593. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  4594. { .compatible = "qcom,msm-dai-q6-dev", },
  4595. { }
  4596. };
  4597. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  4598. static struct platform_driver msm_dai_q6_dev = {
  4599. .probe = msm_dai_q6_dev_probe,
  4600. .remove = msm_dai_q6_dev_remove,
  4601. .driver = {
  4602. .name = "msm-dai-q6-dev",
  4603. .owner = THIS_MODULE,
  4604. .of_match_table = msm_dai_q6_dev_dt_match,
  4605. },
  4606. };
  4607. static int msm_dai_q6_probe(struct platform_device *pdev)
  4608. {
  4609. int rc;
  4610. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4611. dev_name(&pdev->dev), pdev->id);
  4612. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4613. if (rc) {
  4614. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4615. __func__, rc);
  4616. } else
  4617. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4618. return rc;
  4619. }
  4620. static int msm_dai_q6_remove(struct platform_device *pdev)
  4621. {
  4622. return 0;
  4623. }
  4624. static const struct of_device_id msm_dai_q6_dt_match[] = {
  4625. { .compatible = "qcom,msm-dai-q6", },
  4626. { }
  4627. };
  4628. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  4629. static struct platform_driver msm_dai_q6 = {
  4630. .probe = msm_dai_q6_probe,
  4631. .remove = msm_dai_q6_remove,
  4632. .driver = {
  4633. .name = "msm-dai-q6",
  4634. .owner = THIS_MODULE,
  4635. .of_match_table = msm_dai_q6_dt_match,
  4636. },
  4637. };
  4638. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  4639. {
  4640. int rc;
  4641. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4642. if (rc) {
  4643. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4644. __func__, rc);
  4645. } else
  4646. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4647. return rc;
  4648. }
  4649. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  4650. {
  4651. return 0;
  4652. }
  4653. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  4654. { .compatible = "qcom,msm-dai-mi2s", },
  4655. { }
  4656. };
  4657. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  4658. static struct platform_driver msm_dai_mi2s_q6 = {
  4659. .probe = msm_dai_mi2s_q6_probe,
  4660. .remove = msm_dai_mi2s_q6_remove,
  4661. .driver = {
  4662. .name = "msm-dai-mi2s",
  4663. .owner = THIS_MODULE,
  4664. .of_match_table = msm_dai_mi2s_dt_match,
  4665. },
  4666. };
  4667. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  4668. { .compatible = "qcom,msm-dai-q6-mi2s", },
  4669. { }
  4670. };
  4671. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  4672. static struct platform_driver msm_dai_q6_mi2s_driver = {
  4673. .probe = msm_dai_q6_mi2s_dev_probe,
  4674. .remove = msm_dai_q6_mi2s_dev_remove,
  4675. .driver = {
  4676. .name = "msm-dai-q6-mi2s",
  4677. .owner = THIS_MODULE,
  4678. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  4679. },
  4680. };
  4681. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  4682. {
  4683. int rc;
  4684. pdev->id = AFE_PORT_ID_SPDIF_RX;
  4685. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4686. dev_name(&pdev->dev), pdev->id);
  4687. rc = snd_soc_register_component(&pdev->dev,
  4688. &msm_dai_spdif_q6_component,
  4689. &msm_dai_q6_spdif_spdif_rx_dai, 1);
  4690. return rc;
  4691. }
  4692. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  4693. {
  4694. snd_soc_unregister_component(&pdev->dev);
  4695. return 0;
  4696. }
  4697. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  4698. {.compatible = "qcom,msm-dai-q6-spdif"},
  4699. {}
  4700. };
  4701. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  4702. static struct platform_driver msm_dai_q6_spdif_driver = {
  4703. .probe = msm_dai_q6_spdif_dev_probe,
  4704. .remove = msm_dai_q6_spdif_dev_remove,
  4705. .driver = {
  4706. .name = "msm-dai-q6-spdif",
  4707. .owner = THIS_MODULE,
  4708. .of_match_table = msm_dai_q6_spdif_dt_match,
  4709. },
  4710. };
  4711. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  4712. struct afe_clk_set *clk_set, u32 mode)
  4713. {
  4714. switch (group_id) {
  4715. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  4716. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  4717. if (mode)
  4718. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  4719. else
  4720. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  4721. break;
  4722. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  4723. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  4724. if (mode)
  4725. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  4726. else
  4727. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  4728. break;
  4729. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  4730. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  4731. if (mode)
  4732. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  4733. else
  4734. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  4735. break;
  4736. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  4737. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  4738. if (mode)
  4739. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  4740. else
  4741. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  4742. break;
  4743. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  4744. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  4745. if (mode)
  4746. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  4747. else
  4748. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  4749. break;
  4750. default:
  4751. return -EINVAL;
  4752. }
  4753. return 0;
  4754. }
  4755. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  4756. {
  4757. int rc = 0;
  4758. const uint32_t *port_id_array = NULL;
  4759. uint32_t array_length = 0;
  4760. int i = 0;
  4761. int group_idx = 0;
  4762. u32 clk_mode = 0;
  4763. /* extract tdm group info into static */
  4764. rc = of_property_read_u32(pdev->dev.of_node,
  4765. "qcom,msm-cpudai-tdm-group-id",
  4766. (u32 *)&tdm_group_cfg.group_id);
  4767. if (rc) {
  4768. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  4769. __func__, "qcom,msm-cpudai-tdm-group-id");
  4770. goto rtn;
  4771. }
  4772. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  4773. __func__, tdm_group_cfg.group_id);
  4774. dev_info(&pdev->dev, "%s: dev_name: %s group_id: 0x%x\n",
  4775. __func__, dev_name(&pdev->dev), tdm_group_cfg.group_id);
  4776. rc = of_property_read_u32(pdev->dev.of_node,
  4777. "qcom,msm-cpudai-tdm-group-num-ports",
  4778. &num_tdm_group_ports);
  4779. if (rc) {
  4780. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  4781. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  4782. goto rtn;
  4783. }
  4784. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  4785. __func__, num_tdm_group_ports);
  4786. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  4787. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  4788. __func__, num_tdm_group_ports,
  4789. AFE_GROUP_DEVICE_NUM_PORTS);
  4790. rc = -EINVAL;
  4791. goto rtn;
  4792. }
  4793. port_id_array = of_get_property(pdev->dev.of_node,
  4794. "qcom,msm-cpudai-tdm-group-port-id",
  4795. &array_length);
  4796. if (port_id_array == NULL) {
  4797. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  4798. __func__);
  4799. rc = -EINVAL;
  4800. goto rtn;
  4801. }
  4802. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  4803. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  4804. __func__, array_length,
  4805. sizeof(uint32_t) * num_tdm_group_ports);
  4806. rc = -EINVAL;
  4807. goto rtn;
  4808. }
  4809. for (i = 0; i < num_tdm_group_ports; i++)
  4810. tdm_group_cfg.port_id[i] =
  4811. (u16)be32_to_cpu(port_id_array[i]);
  4812. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  4813. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  4814. tdm_group_cfg.port_id[i] =
  4815. AFE_PORT_INVALID;
  4816. /* extract tdm clk info into static */
  4817. rc = of_property_read_u32(pdev->dev.of_node,
  4818. "qcom,msm-cpudai-tdm-clk-rate",
  4819. &tdm_clk_set.clk_freq_in_hz);
  4820. if (rc) {
  4821. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  4822. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  4823. goto rtn;
  4824. }
  4825. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  4826. __func__, tdm_clk_set.clk_freq_in_hz);
  4827. /* initialize static tdm clk attribute to default value */
  4828. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  4829. /* extract tdm clk attribute into static */
  4830. if (of_find_property(pdev->dev.of_node,
  4831. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  4832. rc = of_property_read_u16(pdev->dev.of_node,
  4833. "qcom,msm-cpudai-tdm-clk-attribute",
  4834. &tdm_clk_set.clk_attri);
  4835. if (rc) {
  4836. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  4837. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  4838. goto rtn;
  4839. }
  4840. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  4841. __func__, tdm_clk_set.clk_attri);
  4842. } else
  4843. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  4844. /* extract tdm clk src master/slave info into static */
  4845. rc = of_property_read_u32(pdev->dev.of_node,
  4846. "qcom,msm-cpudai-tdm-clk-internal",
  4847. &clk_mode);
  4848. if (rc) {
  4849. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  4850. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  4851. goto rtn;
  4852. }
  4853. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  4854. __func__, clk_mode);
  4855. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  4856. &tdm_clk_set, clk_mode);
  4857. if (rc) {
  4858. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  4859. __func__, tdm_group_cfg.group_id);
  4860. goto rtn;
  4861. }
  4862. /* other initializations within device group */
  4863. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  4864. if (group_idx < 0) {
  4865. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  4866. __func__, tdm_group_cfg.group_id);
  4867. rc = -EINVAL;
  4868. goto rtn;
  4869. }
  4870. atomic_set(&tdm_group_ref[group_idx], 0);
  4871. /* probe child node info */
  4872. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4873. if (rc) {
  4874. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4875. __func__, rc);
  4876. goto rtn;
  4877. } else
  4878. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4879. rtn:
  4880. return rc;
  4881. }
  4882. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  4883. {
  4884. return 0;
  4885. }
  4886. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  4887. { .compatible = "qcom,msm-dai-tdm", },
  4888. {}
  4889. };
  4890. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  4891. static struct platform_driver msm_dai_tdm_q6 = {
  4892. .probe = msm_dai_tdm_q6_probe,
  4893. .remove = msm_dai_tdm_q6_remove,
  4894. .driver = {
  4895. .name = "msm-dai-tdm",
  4896. .owner = THIS_MODULE,
  4897. .of_match_table = msm_dai_tdm_dt_match,
  4898. },
  4899. };
  4900. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  4901. struct snd_ctl_elem_value *ucontrol)
  4902. {
  4903. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4904. int value = ucontrol->value.integer.value[0];
  4905. switch (value) {
  4906. case 0:
  4907. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  4908. break;
  4909. case 1:
  4910. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  4911. break;
  4912. case 2:
  4913. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  4914. break;
  4915. default:
  4916. pr_err("%s: data_format invalid\n", __func__);
  4917. break;
  4918. }
  4919. pr_debug("%s: data_format = %d\n",
  4920. __func__, dai_data->port_cfg.tdm.data_format);
  4921. return 0;
  4922. }
  4923. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  4924. struct snd_ctl_elem_value *ucontrol)
  4925. {
  4926. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4927. ucontrol->value.integer.value[0] =
  4928. dai_data->port_cfg.tdm.data_format;
  4929. pr_debug("%s: data_format = %d\n",
  4930. __func__, dai_data->port_cfg.tdm.data_format);
  4931. return 0;
  4932. }
  4933. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  4934. struct snd_ctl_elem_value *ucontrol)
  4935. {
  4936. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4937. int value = ucontrol->value.integer.value[0];
  4938. dai_data->port_cfg.custom_tdm_header.header_type = value;
  4939. pr_debug("%s: header_type = %d\n",
  4940. __func__,
  4941. dai_data->port_cfg.custom_tdm_header.header_type);
  4942. return 0;
  4943. }
  4944. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  4945. struct snd_ctl_elem_value *ucontrol)
  4946. {
  4947. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4948. ucontrol->value.integer.value[0] =
  4949. dai_data->port_cfg.custom_tdm_header.header_type;
  4950. pr_debug("%s: header_type = %d\n",
  4951. __func__,
  4952. dai_data->port_cfg.custom_tdm_header.header_type);
  4953. return 0;
  4954. }
  4955. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  4956. struct snd_ctl_elem_value *ucontrol)
  4957. {
  4958. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4959. int i = 0;
  4960. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  4961. dai_data->port_cfg.custom_tdm_header.header[i] =
  4962. (u16)ucontrol->value.integer.value[i];
  4963. pr_debug("%s: header #%d = 0x%x\n",
  4964. __func__, i,
  4965. dai_data->port_cfg.custom_tdm_header.header[i]);
  4966. }
  4967. return 0;
  4968. }
  4969. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  4970. struct snd_ctl_elem_value *ucontrol)
  4971. {
  4972. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  4973. int i = 0;
  4974. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  4975. ucontrol->value.integer.value[i] =
  4976. dai_data->port_cfg.custom_tdm_header.header[i];
  4977. pr_debug("%s: header #%d = 0x%x\n",
  4978. __func__, i,
  4979. dai_data->port_cfg.custom_tdm_header.header[i]);
  4980. }
  4981. return 0;
  4982. }
  4983. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  4984. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  4985. msm_dai_q6_tdm_data_format_get,
  4986. msm_dai_q6_tdm_data_format_put),
  4987. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  4988. msm_dai_q6_tdm_data_format_get,
  4989. msm_dai_q6_tdm_data_format_put),
  4990. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  4991. msm_dai_q6_tdm_data_format_get,
  4992. msm_dai_q6_tdm_data_format_put),
  4993. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  4994. msm_dai_q6_tdm_data_format_get,
  4995. msm_dai_q6_tdm_data_format_put),
  4996. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  4997. msm_dai_q6_tdm_data_format_get,
  4998. msm_dai_q6_tdm_data_format_put),
  4999. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  5000. msm_dai_q6_tdm_data_format_get,
  5001. msm_dai_q6_tdm_data_format_put),
  5002. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  5003. msm_dai_q6_tdm_data_format_get,
  5004. msm_dai_q6_tdm_data_format_put),
  5005. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  5006. msm_dai_q6_tdm_data_format_get,
  5007. msm_dai_q6_tdm_data_format_put),
  5008. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  5009. msm_dai_q6_tdm_data_format_get,
  5010. msm_dai_q6_tdm_data_format_put),
  5011. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  5012. msm_dai_q6_tdm_data_format_get,
  5013. msm_dai_q6_tdm_data_format_put),
  5014. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  5015. msm_dai_q6_tdm_data_format_get,
  5016. msm_dai_q6_tdm_data_format_put),
  5017. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  5018. msm_dai_q6_tdm_data_format_get,
  5019. msm_dai_q6_tdm_data_format_put),
  5020. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  5021. msm_dai_q6_tdm_data_format_get,
  5022. msm_dai_q6_tdm_data_format_put),
  5023. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  5024. msm_dai_q6_tdm_data_format_get,
  5025. msm_dai_q6_tdm_data_format_put),
  5026. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  5027. msm_dai_q6_tdm_data_format_get,
  5028. msm_dai_q6_tdm_data_format_put),
  5029. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  5030. msm_dai_q6_tdm_data_format_get,
  5031. msm_dai_q6_tdm_data_format_put),
  5032. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  5033. msm_dai_q6_tdm_data_format_get,
  5034. msm_dai_q6_tdm_data_format_put),
  5035. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  5036. msm_dai_q6_tdm_data_format_get,
  5037. msm_dai_q6_tdm_data_format_put),
  5038. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  5039. msm_dai_q6_tdm_data_format_get,
  5040. msm_dai_q6_tdm_data_format_put),
  5041. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  5042. msm_dai_q6_tdm_data_format_get,
  5043. msm_dai_q6_tdm_data_format_put),
  5044. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  5045. msm_dai_q6_tdm_data_format_get,
  5046. msm_dai_q6_tdm_data_format_put),
  5047. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  5048. msm_dai_q6_tdm_data_format_get,
  5049. msm_dai_q6_tdm_data_format_put),
  5050. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  5051. msm_dai_q6_tdm_data_format_get,
  5052. msm_dai_q6_tdm_data_format_put),
  5053. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  5054. msm_dai_q6_tdm_data_format_get,
  5055. msm_dai_q6_tdm_data_format_put),
  5056. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  5057. msm_dai_q6_tdm_data_format_get,
  5058. msm_dai_q6_tdm_data_format_put),
  5059. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  5060. msm_dai_q6_tdm_data_format_get,
  5061. msm_dai_q6_tdm_data_format_put),
  5062. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  5063. msm_dai_q6_tdm_data_format_get,
  5064. msm_dai_q6_tdm_data_format_put),
  5065. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  5066. msm_dai_q6_tdm_data_format_get,
  5067. msm_dai_q6_tdm_data_format_put),
  5068. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  5069. msm_dai_q6_tdm_data_format_get,
  5070. msm_dai_q6_tdm_data_format_put),
  5071. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  5072. msm_dai_q6_tdm_data_format_get,
  5073. msm_dai_q6_tdm_data_format_put),
  5074. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  5075. msm_dai_q6_tdm_data_format_get,
  5076. msm_dai_q6_tdm_data_format_put),
  5077. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  5078. msm_dai_q6_tdm_data_format_get,
  5079. msm_dai_q6_tdm_data_format_put),
  5080. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5081. msm_dai_q6_tdm_data_format_get,
  5082. msm_dai_q6_tdm_data_format_put),
  5083. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5084. msm_dai_q6_tdm_data_format_get,
  5085. msm_dai_q6_tdm_data_format_put),
  5086. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5087. msm_dai_q6_tdm_data_format_get,
  5088. msm_dai_q6_tdm_data_format_put),
  5089. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5090. msm_dai_q6_tdm_data_format_get,
  5091. msm_dai_q6_tdm_data_format_put),
  5092. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5093. msm_dai_q6_tdm_data_format_get,
  5094. msm_dai_q6_tdm_data_format_put),
  5095. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5096. msm_dai_q6_tdm_data_format_get,
  5097. msm_dai_q6_tdm_data_format_put),
  5098. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5099. msm_dai_q6_tdm_data_format_get,
  5100. msm_dai_q6_tdm_data_format_put),
  5101. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5102. msm_dai_q6_tdm_data_format_get,
  5103. msm_dai_q6_tdm_data_format_put),
  5104. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5105. msm_dai_q6_tdm_data_format_get,
  5106. msm_dai_q6_tdm_data_format_put),
  5107. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5108. msm_dai_q6_tdm_data_format_get,
  5109. msm_dai_q6_tdm_data_format_put),
  5110. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5111. msm_dai_q6_tdm_data_format_get,
  5112. msm_dai_q6_tdm_data_format_put),
  5113. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5114. msm_dai_q6_tdm_data_format_get,
  5115. msm_dai_q6_tdm_data_format_put),
  5116. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5117. msm_dai_q6_tdm_data_format_get,
  5118. msm_dai_q6_tdm_data_format_put),
  5119. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5120. msm_dai_q6_tdm_data_format_get,
  5121. msm_dai_q6_tdm_data_format_put),
  5122. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5123. msm_dai_q6_tdm_data_format_get,
  5124. msm_dai_q6_tdm_data_format_put),
  5125. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5126. msm_dai_q6_tdm_data_format_get,
  5127. msm_dai_q6_tdm_data_format_put),
  5128. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5129. msm_dai_q6_tdm_data_format_get,
  5130. msm_dai_q6_tdm_data_format_put),
  5131. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5132. msm_dai_q6_tdm_data_format_get,
  5133. msm_dai_q6_tdm_data_format_put),
  5134. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5135. msm_dai_q6_tdm_data_format_get,
  5136. msm_dai_q6_tdm_data_format_put),
  5137. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5138. msm_dai_q6_tdm_data_format_get,
  5139. msm_dai_q6_tdm_data_format_put),
  5140. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5141. msm_dai_q6_tdm_data_format_get,
  5142. msm_dai_q6_tdm_data_format_put),
  5143. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5144. msm_dai_q6_tdm_data_format_get,
  5145. msm_dai_q6_tdm_data_format_put),
  5146. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5147. msm_dai_q6_tdm_data_format_get,
  5148. msm_dai_q6_tdm_data_format_put),
  5149. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5150. msm_dai_q6_tdm_data_format_get,
  5151. msm_dai_q6_tdm_data_format_put),
  5152. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5153. msm_dai_q6_tdm_data_format_get,
  5154. msm_dai_q6_tdm_data_format_put),
  5155. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5156. msm_dai_q6_tdm_data_format_get,
  5157. msm_dai_q6_tdm_data_format_put),
  5158. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5159. msm_dai_q6_tdm_data_format_get,
  5160. msm_dai_q6_tdm_data_format_put),
  5161. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5162. msm_dai_q6_tdm_data_format_get,
  5163. msm_dai_q6_tdm_data_format_put),
  5164. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5165. msm_dai_q6_tdm_data_format_get,
  5166. msm_dai_q6_tdm_data_format_put),
  5167. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5168. msm_dai_q6_tdm_data_format_get,
  5169. msm_dai_q6_tdm_data_format_put),
  5170. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5171. msm_dai_q6_tdm_data_format_get,
  5172. msm_dai_q6_tdm_data_format_put),
  5173. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5174. msm_dai_q6_tdm_data_format_get,
  5175. msm_dai_q6_tdm_data_format_put),
  5176. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  5177. msm_dai_q6_tdm_data_format_get,
  5178. msm_dai_q6_tdm_data_format_put),
  5179. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  5180. msm_dai_q6_tdm_data_format_get,
  5181. msm_dai_q6_tdm_data_format_put),
  5182. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  5183. msm_dai_q6_tdm_data_format_get,
  5184. msm_dai_q6_tdm_data_format_put),
  5185. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  5186. msm_dai_q6_tdm_data_format_get,
  5187. msm_dai_q6_tdm_data_format_put),
  5188. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  5189. msm_dai_q6_tdm_data_format_get,
  5190. msm_dai_q6_tdm_data_format_put),
  5191. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  5192. msm_dai_q6_tdm_data_format_get,
  5193. msm_dai_q6_tdm_data_format_put),
  5194. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  5195. msm_dai_q6_tdm_data_format_get,
  5196. msm_dai_q6_tdm_data_format_put),
  5197. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  5198. msm_dai_q6_tdm_data_format_get,
  5199. msm_dai_q6_tdm_data_format_put),
  5200. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  5201. msm_dai_q6_tdm_data_format_get,
  5202. msm_dai_q6_tdm_data_format_put),
  5203. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  5204. msm_dai_q6_tdm_data_format_get,
  5205. msm_dai_q6_tdm_data_format_put),
  5206. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  5207. msm_dai_q6_tdm_data_format_get,
  5208. msm_dai_q6_tdm_data_format_put),
  5209. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  5210. msm_dai_q6_tdm_data_format_get,
  5211. msm_dai_q6_tdm_data_format_put),
  5212. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  5213. msm_dai_q6_tdm_data_format_get,
  5214. msm_dai_q6_tdm_data_format_put),
  5215. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  5216. msm_dai_q6_tdm_data_format_get,
  5217. msm_dai_q6_tdm_data_format_put),
  5218. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  5219. msm_dai_q6_tdm_data_format_get,
  5220. msm_dai_q6_tdm_data_format_put),
  5221. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  5222. msm_dai_q6_tdm_data_format_get,
  5223. msm_dai_q6_tdm_data_format_put),
  5224. };
  5225. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  5226. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  5227. msm_dai_q6_tdm_header_type_get,
  5228. msm_dai_q6_tdm_header_type_put),
  5229. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  5230. msm_dai_q6_tdm_header_type_get,
  5231. msm_dai_q6_tdm_header_type_put),
  5232. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  5233. msm_dai_q6_tdm_header_type_get,
  5234. msm_dai_q6_tdm_header_type_put),
  5235. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  5236. msm_dai_q6_tdm_header_type_get,
  5237. msm_dai_q6_tdm_header_type_put),
  5238. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  5239. msm_dai_q6_tdm_header_type_get,
  5240. msm_dai_q6_tdm_header_type_put),
  5241. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  5242. msm_dai_q6_tdm_header_type_get,
  5243. msm_dai_q6_tdm_header_type_put),
  5244. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  5245. msm_dai_q6_tdm_header_type_get,
  5246. msm_dai_q6_tdm_header_type_put),
  5247. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  5248. msm_dai_q6_tdm_header_type_get,
  5249. msm_dai_q6_tdm_header_type_put),
  5250. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  5251. msm_dai_q6_tdm_header_type_get,
  5252. msm_dai_q6_tdm_header_type_put),
  5253. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  5254. msm_dai_q6_tdm_header_type_get,
  5255. msm_dai_q6_tdm_header_type_put),
  5256. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  5257. msm_dai_q6_tdm_header_type_get,
  5258. msm_dai_q6_tdm_header_type_put),
  5259. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  5260. msm_dai_q6_tdm_header_type_get,
  5261. msm_dai_q6_tdm_header_type_put),
  5262. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  5263. msm_dai_q6_tdm_header_type_get,
  5264. msm_dai_q6_tdm_header_type_put),
  5265. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  5266. msm_dai_q6_tdm_header_type_get,
  5267. msm_dai_q6_tdm_header_type_put),
  5268. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  5269. msm_dai_q6_tdm_header_type_get,
  5270. msm_dai_q6_tdm_header_type_put),
  5271. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  5272. msm_dai_q6_tdm_header_type_get,
  5273. msm_dai_q6_tdm_header_type_put),
  5274. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  5275. msm_dai_q6_tdm_header_type_get,
  5276. msm_dai_q6_tdm_header_type_put),
  5277. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  5278. msm_dai_q6_tdm_header_type_get,
  5279. msm_dai_q6_tdm_header_type_put),
  5280. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  5281. msm_dai_q6_tdm_header_type_get,
  5282. msm_dai_q6_tdm_header_type_put),
  5283. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  5284. msm_dai_q6_tdm_header_type_get,
  5285. msm_dai_q6_tdm_header_type_put),
  5286. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  5287. msm_dai_q6_tdm_header_type_get,
  5288. msm_dai_q6_tdm_header_type_put),
  5289. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  5290. msm_dai_q6_tdm_header_type_get,
  5291. msm_dai_q6_tdm_header_type_put),
  5292. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  5293. msm_dai_q6_tdm_header_type_get,
  5294. msm_dai_q6_tdm_header_type_put),
  5295. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  5296. msm_dai_q6_tdm_header_type_get,
  5297. msm_dai_q6_tdm_header_type_put),
  5298. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  5299. msm_dai_q6_tdm_header_type_get,
  5300. msm_dai_q6_tdm_header_type_put),
  5301. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  5302. msm_dai_q6_tdm_header_type_get,
  5303. msm_dai_q6_tdm_header_type_put),
  5304. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  5305. msm_dai_q6_tdm_header_type_get,
  5306. msm_dai_q6_tdm_header_type_put),
  5307. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  5308. msm_dai_q6_tdm_header_type_get,
  5309. msm_dai_q6_tdm_header_type_put),
  5310. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  5311. msm_dai_q6_tdm_header_type_get,
  5312. msm_dai_q6_tdm_header_type_put),
  5313. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  5314. msm_dai_q6_tdm_header_type_get,
  5315. msm_dai_q6_tdm_header_type_put),
  5316. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  5317. msm_dai_q6_tdm_header_type_get,
  5318. msm_dai_q6_tdm_header_type_put),
  5319. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  5320. msm_dai_q6_tdm_header_type_get,
  5321. msm_dai_q6_tdm_header_type_put),
  5322. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5323. msm_dai_q6_tdm_header_type_get,
  5324. msm_dai_q6_tdm_header_type_put),
  5325. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5326. msm_dai_q6_tdm_header_type_get,
  5327. msm_dai_q6_tdm_header_type_put),
  5328. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5329. msm_dai_q6_tdm_header_type_get,
  5330. msm_dai_q6_tdm_header_type_put),
  5331. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5332. msm_dai_q6_tdm_header_type_get,
  5333. msm_dai_q6_tdm_header_type_put),
  5334. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5335. msm_dai_q6_tdm_header_type_get,
  5336. msm_dai_q6_tdm_header_type_put),
  5337. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5338. msm_dai_q6_tdm_header_type_get,
  5339. msm_dai_q6_tdm_header_type_put),
  5340. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5341. msm_dai_q6_tdm_header_type_get,
  5342. msm_dai_q6_tdm_header_type_put),
  5343. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5344. msm_dai_q6_tdm_header_type_get,
  5345. msm_dai_q6_tdm_header_type_put),
  5346. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5347. msm_dai_q6_tdm_header_type_get,
  5348. msm_dai_q6_tdm_header_type_put),
  5349. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5350. msm_dai_q6_tdm_header_type_get,
  5351. msm_dai_q6_tdm_header_type_put),
  5352. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5353. msm_dai_q6_tdm_header_type_get,
  5354. msm_dai_q6_tdm_header_type_put),
  5355. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5356. msm_dai_q6_tdm_header_type_get,
  5357. msm_dai_q6_tdm_header_type_put),
  5358. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5359. msm_dai_q6_tdm_header_type_get,
  5360. msm_dai_q6_tdm_header_type_put),
  5361. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5362. msm_dai_q6_tdm_header_type_get,
  5363. msm_dai_q6_tdm_header_type_put),
  5364. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5365. msm_dai_q6_tdm_header_type_get,
  5366. msm_dai_q6_tdm_header_type_put),
  5367. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  5368. msm_dai_q6_tdm_header_type_get,
  5369. msm_dai_q6_tdm_header_type_put),
  5370. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5371. msm_dai_q6_tdm_header_type_get,
  5372. msm_dai_q6_tdm_header_type_put),
  5373. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5374. msm_dai_q6_tdm_header_type_get,
  5375. msm_dai_q6_tdm_header_type_put),
  5376. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5377. msm_dai_q6_tdm_header_type_get,
  5378. msm_dai_q6_tdm_header_type_put),
  5379. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5380. msm_dai_q6_tdm_header_type_get,
  5381. msm_dai_q6_tdm_header_type_put),
  5382. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5383. msm_dai_q6_tdm_header_type_get,
  5384. msm_dai_q6_tdm_header_type_put),
  5385. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5386. msm_dai_q6_tdm_header_type_get,
  5387. msm_dai_q6_tdm_header_type_put),
  5388. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5389. msm_dai_q6_tdm_header_type_get,
  5390. msm_dai_q6_tdm_header_type_put),
  5391. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5392. msm_dai_q6_tdm_header_type_get,
  5393. msm_dai_q6_tdm_header_type_put),
  5394. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5395. msm_dai_q6_tdm_header_type_get,
  5396. msm_dai_q6_tdm_header_type_put),
  5397. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5398. msm_dai_q6_tdm_header_type_get,
  5399. msm_dai_q6_tdm_header_type_put),
  5400. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5401. msm_dai_q6_tdm_header_type_get,
  5402. msm_dai_q6_tdm_header_type_put),
  5403. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5404. msm_dai_q6_tdm_header_type_get,
  5405. msm_dai_q6_tdm_header_type_put),
  5406. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5407. msm_dai_q6_tdm_header_type_get,
  5408. msm_dai_q6_tdm_header_type_put),
  5409. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5410. msm_dai_q6_tdm_header_type_get,
  5411. msm_dai_q6_tdm_header_type_put),
  5412. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5413. msm_dai_q6_tdm_header_type_get,
  5414. msm_dai_q6_tdm_header_type_put),
  5415. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  5416. msm_dai_q6_tdm_header_type_get,
  5417. msm_dai_q6_tdm_header_type_put),
  5418. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  5419. msm_dai_q6_tdm_header_type_get,
  5420. msm_dai_q6_tdm_header_type_put),
  5421. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  5422. msm_dai_q6_tdm_header_type_get,
  5423. msm_dai_q6_tdm_header_type_put),
  5424. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  5425. msm_dai_q6_tdm_header_type_get,
  5426. msm_dai_q6_tdm_header_type_put),
  5427. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  5428. msm_dai_q6_tdm_header_type_get,
  5429. msm_dai_q6_tdm_header_type_put),
  5430. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  5431. msm_dai_q6_tdm_header_type_get,
  5432. msm_dai_q6_tdm_header_type_put),
  5433. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  5434. msm_dai_q6_tdm_header_type_get,
  5435. msm_dai_q6_tdm_header_type_put),
  5436. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  5437. msm_dai_q6_tdm_header_type_get,
  5438. msm_dai_q6_tdm_header_type_put),
  5439. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  5440. msm_dai_q6_tdm_header_type_get,
  5441. msm_dai_q6_tdm_header_type_put),
  5442. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  5443. msm_dai_q6_tdm_header_type_get,
  5444. msm_dai_q6_tdm_header_type_put),
  5445. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  5446. msm_dai_q6_tdm_header_type_get,
  5447. msm_dai_q6_tdm_header_type_put),
  5448. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  5449. msm_dai_q6_tdm_header_type_get,
  5450. msm_dai_q6_tdm_header_type_put),
  5451. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  5452. msm_dai_q6_tdm_header_type_get,
  5453. msm_dai_q6_tdm_header_type_put),
  5454. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  5455. msm_dai_q6_tdm_header_type_get,
  5456. msm_dai_q6_tdm_header_type_put),
  5457. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  5458. msm_dai_q6_tdm_header_type_get,
  5459. msm_dai_q6_tdm_header_type_put),
  5460. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  5461. msm_dai_q6_tdm_header_type_get,
  5462. msm_dai_q6_tdm_header_type_put),
  5463. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  5464. msm_dai_q6_tdm_header_type_get,
  5465. msm_dai_q6_tdm_header_type_put),
  5466. };
  5467. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  5468. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  5469. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5470. msm_dai_q6_tdm_header_get,
  5471. msm_dai_q6_tdm_header_put),
  5472. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  5473. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5474. msm_dai_q6_tdm_header_get,
  5475. msm_dai_q6_tdm_header_put),
  5476. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  5477. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5478. msm_dai_q6_tdm_header_get,
  5479. msm_dai_q6_tdm_header_put),
  5480. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  5481. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5482. msm_dai_q6_tdm_header_get,
  5483. msm_dai_q6_tdm_header_put),
  5484. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  5485. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5486. msm_dai_q6_tdm_header_get,
  5487. msm_dai_q6_tdm_header_put),
  5488. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  5489. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5490. msm_dai_q6_tdm_header_get,
  5491. msm_dai_q6_tdm_header_put),
  5492. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  5493. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5494. msm_dai_q6_tdm_header_get,
  5495. msm_dai_q6_tdm_header_put),
  5496. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  5497. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5498. msm_dai_q6_tdm_header_get,
  5499. msm_dai_q6_tdm_header_put),
  5500. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  5501. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5502. msm_dai_q6_tdm_header_get,
  5503. msm_dai_q6_tdm_header_put),
  5504. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  5505. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5506. msm_dai_q6_tdm_header_get,
  5507. msm_dai_q6_tdm_header_put),
  5508. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  5509. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5510. msm_dai_q6_tdm_header_get,
  5511. msm_dai_q6_tdm_header_put),
  5512. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  5513. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5514. msm_dai_q6_tdm_header_get,
  5515. msm_dai_q6_tdm_header_put),
  5516. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  5517. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5518. msm_dai_q6_tdm_header_get,
  5519. msm_dai_q6_tdm_header_put),
  5520. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  5521. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5522. msm_dai_q6_tdm_header_get,
  5523. msm_dai_q6_tdm_header_put),
  5524. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  5525. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5526. msm_dai_q6_tdm_header_get,
  5527. msm_dai_q6_tdm_header_put),
  5528. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  5529. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5530. msm_dai_q6_tdm_header_get,
  5531. msm_dai_q6_tdm_header_put),
  5532. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  5533. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5534. msm_dai_q6_tdm_header_get,
  5535. msm_dai_q6_tdm_header_put),
  5536. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  5537. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5538. msm_dai_q6_tdm_header_get,
  5539. msm_dai_q6_tdm_header_put),
  5540. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  5541. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5542. msm_dai_q6_tdm_header_get,
  5543. msm_dai_q6_tdm_header_put),
  5544. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  5545. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5546. msm_dai_q6_tdm_header_get,
  5547. msm_dai_q6_tdm_header_put),
  5548. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  5549. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5550. msm_dai_q6_tdm_header_get,
  5551. msm_dai_q6_tdm_header_put),
  5552. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  5553. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5554. msm_dai_q6_tdm_header_get,
  5555. msm_dai_q6_tdm_header_put),
  5556. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  5557. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5558. msm_dai_q6_tdm_header_get,
  5559. msm_dai_q6_tdm_header_put),
  5560. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  5561. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5562. msm_dai_q6_tdm_header_get,
  5563. msm_dai_q6_tdm_header_put),
  5564. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  5565. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5566. msm_dai_q6_tdm_header_get,
  5567. msm_dai_q6_tdm_header_put),
  5568. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  5569. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5570. msm_dai_q6_tdm_header_get,
  5571. msm_dai_q6_tdm_header_put),
  5572. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  5573. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5574. msm_dai_q6_tdm_header_get,
  5575. msm_dai_q6_tdm_header_put),
  5576. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  5577. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5578. msm_dai_q6_tdm_header_get,
  5579. msm_dai_q6_tdm_header_put),
  5580. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  5581. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5582. msm_dai_q6_tdm_header_get,
  5583. msm_dai_q6_tdm_header_put),
  5584. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  5585. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5586. msm_dai_q6_tdm_header_get,
  5587. msm_dai_q6_tdm_header_put),
  5588. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  5589. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5590. msm_dai_q6_tdm_header_get,
  5591. msm_dai_q6_tdm_header_put),
  5592. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  5593. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5594. msm_dai_q6_tdm_header_get,
  5595. msm_dai_q6_tdm_header_put),
  5596. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  5597. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5598. msm_dai_q6_tdm_header_get,
  5599. msm_dai_q6_tdm_header_put),
  5600. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  5601. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5602. msm_dai_q6_tdm_header_get,
  5603. msm_dai_q6_tdm_header_put),
  5604. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  5605. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5606. msm_dai_q6_tdm_header_get,
  5607. msm_dai_q6_tdm_header_put),
  5608. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  5609. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5610. msm_dai_q6_tdm_header_get,
  5611. msm_dai_q6_tdm_header_put),
  5612. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  5613. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5614. msm_dai_q6_tdm_header_get,
  5615. msm_dai_q6_tdm_header_put),
  5616. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  5617. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5618. msm_dai_q6_tdm_header_get,
  5619. msm_dai_q6_tdm_header_put),
  5620. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  5621. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5622. msm_dai_q6_tdm_header_get,
  5623. msm_dai_q6_tdm_header_put),
  5624. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  5625. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5626. msm_dai_q6_tdm_header_get,
  5627. msm_dai_q6_tdm_header_put),
  5628. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  5629. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5630. msm_dai_q6_tdm_header_get,
  5631. msm_dai_q6_tdm_header_put),
  5632. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  5633. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5634. msm_dai_q6_tdm_header_get,
  5635. msm_dai_q6_tdm_header_put),
  5636. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  5637. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5638. msm_dai_q6_tdm_header_get,
  5639. msm_dai_q6_tdm_header_put),
  5640. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  5641. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5642. msm_dai_q6_tdm_header_get,
  5643. msm_dai_q6_tdm_header_put),
  5644. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  5645. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5646. msm_dai_q6_tdm_header_get,
  5647. msm_dai_q6_tdm_header_put),
  5648. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  5649. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5650. msm_dai_q6_tdm_header_get,
  5651. msm_dai_q6_tdm_header_put),
  5652. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  5653. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5654. msm_dai_q6_tdm_header_get,
  5655. msm_dai_q6_tdm_header_put),
  5656. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  5657. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5658. msm_dai_q6_tdm_header_get,
  5659. msm_dai_q6_tdm_header_put),
  5660. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  5661. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5662. msm_dai_q6_tdm_header_get,
  5663. msm_dai_q6_tdm_header_put),
  5664. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  5665. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5666. msm_dai_q6_tdm_header_get,
  5667. msm_dai_q6_tdm_header_put),
  5668. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  5669. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5670. msm_dai_q6_tdm_header_get,
  5671. msm_dai_q6_tdm_header_put),
  5672. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  5673. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5674. msm_dai_q6_tdm_header_get,
  5675. msm_dai_q6_tdm_header_put),
  5676. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  5677. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5678. msm_dai_q6_tdm_header_get,
  5679. msm_dai_q6_tdm_header_put),
  5680. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  5681. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5682. msm_dai_q6_tdm_header_get,
  5683. msm_dai_q6_tdm_header_put),
  5684. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  5685. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5686. msm_dai_q6_tdm_header_get,
  5687. msm_dai_q6_tdm_header_put),
  5688. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  5689. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5690. msm_dai_q6_tdm_header_get,
  5691. msm_dai_q6_tdm_header_put),
  5692. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  5693. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5694. msm_dai_q6_tdm_header_get,
  5695. msm_dai_q6_tdm_header_put),
  5696. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  5697. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5698. msm_dai_q6_tdm_header_get,
  5699. msm_dai_q6_tdm_header_put),
  5700. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  5701. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5702. msm_dai_q6_tdm_header_get,
  5703. msm_dai_q6_tdm_header_put),
  5704. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  5705. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5706. msm_dai_q6_tdm_header_get,
  5707. msm_dai_q6_tdm_header_put),
  5708. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  5709. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5710. msm_dai_q6_tdm_header_get,
  5711. msm_dai_q6_tdm_header_put),
  5712. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  5713. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5714. msm_dai_q6_tdm_header_get,
  5715. msm_dai_q6_tdm_header_put),
  5716. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  5717. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5718. msm_dai_q6_tdm_header_get,
  5719. msm_dai_q6_tdm_header_put),
  5720. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  5721. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5722. msm_dai_q6_tdm_header_get,
  5723. msm_dai_q6_tdm_header_put),
  5724. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  5725. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5726. msm_dai_q6_tdm_header_get,
  5727. msm_dai_q6_tdm_header_put),
  5728. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  5729. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5730. msm_dai_q6_tdm_header_get,
  5731. msm_dai_q6_tdm_header_put),
  5732. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  5733. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5734. msm_dai_q6_tdm_header_get,
  5735. msm_dai_q6_tdm_header_put),
  5736. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  5737. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5738. msm_dai_q6_tdm_header_get,
  5739. msm_dai_q6_tdm_header_put),
  5740. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  5741. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5742. msm_dai_q6_tdm_header_get,
  5743. msm_dai_q6_tdm_header_put),
  5744. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  5745. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5746. msm_dai_q6_tdm_header_get,
  5747. msm_dai_q6_tdm_header_put),
  5748. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  5749. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5750. msm_dai_q6_tdm_header_get,
  5751. msm_dai_q6_tdm_header_put),
  5752. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  5753. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5754. msm_dai_q6_tdm_header_get,
  5755. msm_dai_q6_tdm_header_put),
  5756. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  5757. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5758. msm_dai_q6_tdm_header_get,
  5759. msm_dai_q6_tdm_header_put),
  5760. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  5761. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5762. msm_dai_q6_tdm_header_get,
  5763. msm_dai_q6_tdm_header_put),
  5764. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  5765. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5766. msm_dai_q6_tdm_header_get,
  5767. msm_dai_q6_tdm_header_put),
  5768. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  5769. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5770. msm_dai_q6_tdm_header_get,
  5771. msm_dai_q6_tdm_header_put),
  5772. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  5773. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5774. msm_dai_q6_tdm_header_get,
  5775. msm_dai_q6_tdm_header_put),
  5776. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  5777. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5778. msm_dai_q6_tdm_header_get,
  5779. msm_dai_q6_tdm_header_put),
  5780. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  5781. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5782. msm_dai_q6_tdm_header_get,
  5783. msm_dai_q6_tdm_header_put),
  5784. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  5785. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5786. msm_dai_q6_tdm_header_get,
  5787. msm_dai_q6_tdm_header_put),
  5788. };
  5789. static int msm_dai_q6_tdm_set_clk(
  5790. struct msm_dai_q6_tdm_dai_data *dai_data,
  5791. u16 port_id, bool enable)
  5792. {
  5793. int rc = 0;
  5794. dai_data->clk_set.enable = enable;
  5795. rc = afe_set_lpass_clock_v2(port_id,
  5796. &dai_data->clk_set);
  5797. if (rc < 0)
  5798. pr_err("%s: afe lpass clock failed, err:%d\n",
  5799. __func__, rc);
  5800. return rc;
  5801. }
  5802. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  5803. {
  5804. int rc = 0;
  5805. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  5806. dev_get_drvdata(dai->dev);
  5807. struct snd_kcontrol *data_format_kcontrol = NULL;
  5808. struct snd_kcontrol *header_type_kcontrol = NULL;
  5809. struct snd_kcontrol *header_kcontrol = NULL;
  5810. int port_idx = 0;
  5811. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  5812. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  5813. const struct snd_kcontrol_new *header_ctrl = NULL;
  5814. msm_dai_q6_set_dai_id(dai);
  5815. port_idx = msm_dai_q6_get_port_idx(dai->id);
  5816. if (port_idx < 0) {
  5817. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  5818. __func__, dai->id);
  5819. rc = -EINVAL;
  5820. goto rtn;
  5821. }
  5822. data_format_ctrl =
  5823. &tdm_config_controls_data_format[port_idx];
  5824. header_type_ctrl =
  5825. &tdm_config_controls_header_type[port_idx];
  5826. header_ctrl =
  5827. &tdm_config_controls_header[port_idx];
  5828. if (data_format_ctrl) {
  5829. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  5830. tdm_dai_data);
  5831. rc = snd_ctl_add(dai->component->card->snd_card,
  5832. data_format_kcontrol);
  5833. if (rc < 0) {
  5834. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  5835. __func__, dai->name);
  5836. goto rtn;
  5837. }
  5838. }
  5839. if (header_type_ctrl) {
  5840. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  5841. tdm_dai_data);
  5842. rc = snd_ctl_add(dai->component->card->snd_card,
  5843. header_type_kcontrol);
  5844. if (rc < 0) {
  5845. if (data_format_kcontrol)
  5846. snd_ctl_remove(dai->component->card->snd_card,
  5847. data_format_kcontrol);
  5848. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  5849. __func__, dai->name);
  5850. goto rtn;
  5851. }
  5852. }
  5853. if (header_ctrl) {
  5854. header_kcontrol = snd_ctl_new1(header_ctrl,
  5855. tdm_dai_data);
  5856. rc = snd_ctl_add(dai->component->card->snd_card,
  5857. header_kcontrol);
  5858. if (rc < 0) {
  5859. if (header_type_kcontrol)
  5860. snd_ctl_remove(dai->component->card->snd_card,
  5861. header_type_kcontrol);
  5862. if (data_format_kcontrol)
  5863. snd_ctl_remove(dai->component->card->snd_card,
  5864. data_format_kcontrol);
  5865. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  5866. __func__, dai->name);
  5867. goto rtn;
  5868. }
  5869. }
  5870. rc = msm_dai_q6_dai_add_route(dai);
  5871. rtn:
  5872. return rc;
  5873. }
  5874. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  5875. {
  5876. int rc = 0;
  5877. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  5878. dev_get_drvdata(dai->dev);
  5879. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  5880. int group_idx = 0;
  5881. atomic_t *group_ref = NULL;
  5882. group_idx = msm_dai_q6_get_group_idx(dai->id);
  5883. if (group_idx < 0) {
  5884. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  5885. __func__, dai->id);
  5886. return -EINVAL;
  5887. }
  5888. group_ref = &tdm_group_ref[group_idx];
  5889. /* If AFE port is still up, close it */
  5890. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  5891. rc = afe_close(dai->id); /* can block */
  5892. if (rc < 0) {
  5893. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  5894. __func__, dai->id);
  5895. }
  5896. atomic_dec(group_ref);
  5897. clear_bit(STATUS_PORT_STARTED,
  5898. tdm_dai_data->status_mask);
  5899. if (atomic_read(group_ref) == 0) {
  5900. rc = afe_port_group_enable(group_id,
  5901. NULL, false);
  5902. if (rc < 0) {
  5903. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  5904. group_id);
  5905. }
  5906. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  5907. dai->id, false);
  5908. if (rc < 0) {
  5909. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  5910. __func__, dai->id);
  5911. }
  5912. }
  5913. }
  5914. return 0;
  5915. }
  5916. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  5917. unsigned int tx_mask,
  5918. unsigned int rx_mask,
  5919. int slots, int slot_width)
  5920. {
  5921. int rc = 0;
  5922. struct msm_dai_q6_tdm_dai_data *dai_data =
  5923. dev_get_drvdata(dai->dev);
  5924. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  5925. &dai_data->group_cfg.tdm_cfg;
  5926. unsigned int cap_mask;
  5927. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  5928. /* HW only supports 16 and 32 bit slot width configuration */
  5929. if ((slot_width != 16) && (slot_width != 32)) {
  5930. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  5931. __func__, slot_width);
  5932. return -EINVAL;
  5933. }
  5934. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  5935. switch (slots) {
  5936. case 2:
  5937. cap_mask = 0x03;
  5938. break;
  5939. case 4:
  5940. cap_mask = 0x0F;
  5941. break;
  5942. case 8:
  5943. cap_mask = 0xFF;
  5944. break;
  5945. case 16:
  5946. cap_mask = 0xFFFF;
  5947. break;
  5948. default:
  5949. dev_err(dai->dev, "%s: invalid slots %d\n",
  5950. __func__, slots);
  5951. return -EINVAL;
  5952. }
  5953. switch (dai->id) {
  5954. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5955. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  5956. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  5957. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  5958. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  5959. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  5960. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  5961. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  5962. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5963. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  5964. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  5965. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  5966. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  5967. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  5968. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  5969. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  5970. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5971. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  5972. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  5973. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  5974. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  5975. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  5976. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  5977. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  5978. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5979. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  5980. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  5981. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  5982. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  5983. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  5984. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  5985. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  5986. case AFE_PORT_ID_QUINARY_TDM_RX:
  5987. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  5988. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  5989. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  5990. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  5991. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  5992. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  5993. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  5994. tdm_group->nslots_per_frame = slots;
  5995. tdm_group->slot_width = slot_width;
  5996. tdm_group->slot_mask = rx_mask & cap_mask;
  5997. break;
  5998. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5999. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6000. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6001. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6002. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6003. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6004. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6005. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6006. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6007. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6008. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6009. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6010. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6011. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6012. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6013. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6014. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6015. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6016. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6017. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6018. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6019. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6020. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6021. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6022. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6023. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6024. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6025. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6026. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6027. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6028. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6029. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6030. case AFE_PORT_ID_QUINARY_TDM_TX:
  6031. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6032. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6033. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6034. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6035. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6036. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6037. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6038. tdm_group->nslots_per_frame = slots;
  6039. tdm_group->slot_width = slot_width;
  6040. tdm_group->slot_mask = tx_mask & cap_mask;
  6041. break;
  6042. default:
  6043. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6044. __func__, dai->id);
  6045. return -EINVAL;
  6046. }
  6047. return rc;
  6048. }
  6049. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  6050. int clk_id, unsigned int freq, int dir)
  6051. {
  6052. struct msm_dai_q6_tdm_dai_data *dai_data =
  6053. dev_get_drvdata(dai->dev);
  6054. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  6055. (dai->id <= AFE_PORT_ID_QUINARY_TDM_TX_7)) {
  6056. dai_data->clk_set.clk_freq_in_hz = freq;
  6057. } else {
  6058. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6059. __func__, dai->id);
  6060. return -EINVAL;
  6061. }
  6062. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  6063. __func__, dai->id, freq);
  6064. return 0;
  6065. }
  6066. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  6067. unsigned int tx_num, unsigned int *tx_slot,
  6068. unsigned int rx_num, unsigned int *rx_slot)
  6069. {
  6070. int rc = 0;
  6071. struct msm_dai_q6_tdm_dai_data *dai_data =
  6072. dev_get_drvdata(dai->dev);
  6073. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6074. &dai_data->port_cfg.slot_mapping;
  6075. int i = 0;
  6076. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  6077. switch (dai->id) {
  6078. case AFE_PORT_ID_PRIMARY_TDM_RX:
  6079. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  6080. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  6081. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  6082. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  6083. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  6084. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  6085. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  6086. case AFE_PORT_ID_SECONDARY_TDM_RX:
  6087. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  6088. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  6089. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  6090. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  6091. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  6092. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  6093. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  6094. case AFE_PORT_ID_TERTIARY_TDM_RX:
  6095. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  6096. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  6097. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  6098. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  6099. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  6100. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  6101. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  6102. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  6103. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  6104. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  6105. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  6106. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  6107. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  6108. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  6109. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  6110. case AFE_PORT_ID_QUINARY_TDM_RX:
  6111. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  6112. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6113. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6114. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6115. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6116. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6117. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6118. if (!rx_slot) {
  6119. dev_err(dai->dev, "%s: rx slot not found\n", __func__);
  6120. return -EINVAL;
  6121. }
  6122. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6123. dev_err(dai->dev, "%s: invalid rx num %d\n", __func__,
  6124. rx_num);
  6125. return -EINVAL;
  6126. }
  6127. for (i = 0; i < rx_num; i++)
  6128. slot_mapping->offset[i] = rx_slot[i];
  6129. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6130. slot_mapping->offset[i] =
  6131. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6132. slot_mapping->num_channel = rx_num;
  6133. break;
  6134. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6135. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6136. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6137. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6138. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6139. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6140. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6141. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6142. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6143. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6144. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6145. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6146. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6147. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6148. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6149. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6150. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6151. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6152. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6153. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6154. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6155. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6156. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6157. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6158. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6159. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6160. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6161. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6162. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6163. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6164. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6165. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6166. case AFE_PORT_ID_QUINARY_TDM_TX:
  6167. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6168. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6169. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6170. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6171. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6172. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6173. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6174. if (!tx_slot) {
  6175. dev_err(dai->dev, "%s: tx slot not found\n", __func__);
  6176. return -EINVAL;
  6177. }
  6178. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6179. dev_err(dai->dev, "%s: invalid tx num %d\n", __func__,
  6180. tx_num);
  6181. return -EINVAL;
  6182. }
  6183. for (i = 0; i < tx_num; i++)
  6184. slot_mapping->offset[i] = tx_slot[i];
  6185. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6186. slot_mapping->offset[i] =
  6187. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6188. slot_mapping->num_channel = tx_num;
  6189. break;
  6190. default:
  6191. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6192. __func__, dai->id);
  6193. return -EINVAL;
  6194. }
  6195. return rc;
  6196. }
  6197. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  6198. struct snd_pcm_hw_params *params,
  6199. struct snd_soc_dai *dai)
  6200. {
  6201. struct msm_dai_q6_tdm_dai_data *dai_data =
  6202. dev_get_drvdata(dai->dev);
  6203. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  6204. &dai_data->group_cfg.tdm_cfg;
  6205. struct afe_param_id_tdm_cfg *tdm =
  6206. &dai_data->port_cfg.tdm;
  6207. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6208. &dai_data->port_cfg.slot_mapping;
  6209. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  6210. &dai_data->port_cfg.custom_tdm_header;
  6211. pr_debug("%s: dev_name: %s\n",
  6212. __func__, dev_name(dai->dev));
  6213. if ((params_channels(params) == 0) ||
  6214. (params_channels(params) > 8)) {
  6215. dev_err(dai->dev, "%s: invalid param channels %d\n",
  6216. __func__, params_channels(params));
  6217. return -EINVAL;
  6218. }
  6219. switch (params_format(params)) {
  6220. case SNDRV_PCM_FORMAT_S16_LE:
  6221. dai_data->bitwidth = 16;
  6222. break;
  6223. case SNDRV_PCM_FORMAT_S24_LE:
  6224. case SNDRV_PCM_FORMAT_S24_3LE:
  6225. dai_data->bitwidth = 24;
  6226. break;
  6227. case SNDRV_PCM_FORMAT_S32_LE:
  6228. dai_data->bitwidth = 32;
  6229. break;
  6230. default:
  6231. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  6232. __func__, params_format(params));
  6233. return -EINVAL;
  6234. }
  6235. dai_data->channels = params_channels(params);
  6236. dai_data->rate = params_rate(params);
  6237. /*
  6238. * update tdm group config param
  6239. * NOTE: group config is set to the same as slot config.
  6240. */
  6241. tdm_group->bit_width = tdm_group->slot_width;
  6242. tdm_group->num_channels = tdm_group->nslots_per_frame;
  6243. tdm_group->sample_rate = dai_data->rate;
  6244. pr_debug("%s: TDM GROUP:\n"
  6245. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6246. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  6247. __func__,
  6248. tdm_group->num_channels,
  6249. tdm_group->sample_rate,
  6250. tdm_group->bit_width,
  6251. tdm_group->nslots_per_frame,
  6252. tdm_group->slot_width,
  6253. tdm_group->slot_mask);
  6254. pr_debug("%s: TDM GROUP:\n"
  6255. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  6256. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  6257. __func__,
  6258. tdm_group->port_id[0],
  6259. tdm_group->port_id[1],
  6260. tdm_group->port_id[2],
  6261. tdm_group->port_id[3],
  6262. tdm_group->port_id[4],
  6263. tdm_group->port_id[5],
  6264. tdm_group->port_id[6],
  6265. tdm_group->port_id[7]);
  6266. /*
  6267. * update tdm config param
  6268. * NOTE: channels/rate/bitwidth are per stream property
  6269. */
  6270. tdm->num_channels = dai_data->channels;
  6271. tdm->sample_rate = dai_data->rate;
  6272. tdm->bit_width = dai_data->bitwidth;
  6273. /*
  6274. * port slot config is the same as group slot config
  6275. * port slot mask should be set according to offset
  6276. */
  6277. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  6278. tdm->slot_width = tdm_group->slot_width;
  6279. tdm->slot_mask = tdm_group->slot_mask;
  6280. pr_debug("%s: TDM:\n"
  6281. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6282. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  6283. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  6284. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  6285. __func__,
  6286. tdm->num_channels,
  6287. tdm->sample_rate,
  6288. tdm->bit_width,
  6289. tdm->nslots_per_frame,
  6290. tdm->slot_width,
  6291. tdm->slot_mask,
  6292. tdm->data_format,
  6293. tdm->sync_mode,
  6294. tdm->sync_src,
  6295. tdm->ctrl_data_out_enable,
  6296. tdm->ctrl_invert_sync_pulse,
  6297. tdm->ctrl_sync_data_delay);
  6298. /*
  6299. * update slot mapping config param
  6300. * NOTE: channels/rate/bitwidth are per stream property
  6301. */
  6302. slot_mapping->bitwidth = dai_data->bitwidth;
  6303. pr_debug("%s: SLOT MAPPING:\n"
  6304. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  6305. __func__,
  6306. slot_mapping->num_channel,
  6307. slot_mapping->bitwidth,
  6308. slot_mapping->data_align_type);
  6309. pr_debug("%s: SLOT MAPPING:\n"
  6310. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  6311. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  6312. __func__,
  6313. slot_mapping->offset[0],
  6314. slot_mapping->offset[1],
  6315. slot_mapping->offset[2],
  6316. slot_mapping->offset[3],
  6317. slot_mapping->offset[4],
  6318. slot_mapping->offset[5],
  6319. slot_mapping->offset[6],
  6320. slot_mapping->offset[7]);
  6321. /*
  6322. * update custom header config param
  6323. * NOTE: channels/rate/bitwidth are per playback stream property.
  6324. * custom tdm header only applicable to playback stream.
  6325. */
  6326. if (custom_tdm_header->header_type !=
  6327. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  6328. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6329. "start_offset=0x%x header_width=%d\n"
  6330. "num_frame_repeat=%d header_type=0x%x\n",
  6331. __func__,
  6332. custom_tdm_header->start_offset,
  6333. custom_tdm_header->header_width,
  6334. custom_tdm_header->num_frame_repeat,
  6335. custom_tdm_header->header_type);
  6336. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6337. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  6338. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  6339. __func__,
  6340. custom_tdm_header->header[0],
  6341. custom_tdm_header->header[1],
  6342. custom_tdm_header->header[2],
  6343. custom_tdm_header->header[3],
  6344. custom_tdm_header->header[4],
  6345. custom_tdm_header->header[5],
  6346. custom_tdm_header->header[6],
  6347. custom_tdm_header->header[7]);
  6348. }
  6349. return 0;
  6350. }
  6351. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  6352. struct snd_soc_dai *dai)
  6353. {
  6354. int rc = 0;
  6355. struct msm_dai_q6_tdm_dai_data *dai_data =
  6356. dev_get_drvdata(dai->dev);
  6357. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6358. int group_idx = 0;
  6359. atomic_t *group_ref = NULL;
  6360. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6361. if (group_idx < 0) {
  6362. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6363. __func__, dai->id);
  6364. return -EINVAL;
  6365. }
  6366. mutex_lock(&tdm_mutex);
  6367. group_ref = &tdm_group_ref[group_idx];
  6368. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6369. /* PORT START should be set if prepare called
  6370. * in active state.
  6371. */
  6372. if (atomic_read(group_ref) == 0) {
  6373. /* TX and RX share the same clk.
  6374. * AFE clk is enabled per group to simplify the logic.
  6375. * DSP will monitor the clk count.
  6376. */
  6377. rc = msm_dai_q6_tdm_set_clk(dai_data,
  6378. dai->id, true);
  6379. if (rc < 0) {
  6380. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  6381. __func__, dai->id);
  6382. goto rtn;
  6383. }
  6384. /*
  6385. * if only one port, don't do group enable as there
  6386. * is no group need for only one port
  6387. */
  6388. if (dai_data->num_group_ports > 1) {
  6389. rc = afe_port_group_enable(group_id,
  6390. &dai_data->group_cfg, true);
  6391. if (rc < 0) {
  6392. dev_err(dai->dev,
  6393. "%s: fail to enable AFE group 0x%x\n",
  6394. __func__, group_id);
  6395. goto rtn;
  6396. }
  6397. }
  6398. }
  6399. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  6400. dai_data->rate, dai_data->num_group_ports);
  6401. if (rc < 0) {
  6402. if (atomic_read(group_ref) == 0) {
  6403. afe_port_group_enable(group_id,
  6404. NULL, false);
  6405. msm_dai_q6_tdm_set_clk(dai_data,
  6406. dai->id, false);
  6407. }
  6408. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  6409. __func__, dai->id);
  6410. } else {
  6411. set_bit(STATUS_PORT_STARTED,
  6412. dai_data->status_mask);
  6413. atomic_inc(group_ref);
  6414. }
  6415. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  6416. /* NOTE: AFE should error out if HW resource contention */
  6417. }
  6418. rtn:
  6419. mutex_unlock(&tdm_mutex);
  6420. return rc;
  6421. }
  6422. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  6423. struct snd_soc_dai *dai)
  6424. {
  6425. int rc = 0;
  6426. struct msm_dai_q6_tdm_dai_data *dai_data =
  6427. dev_get_drvdata(dai->dev);
  6428. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6429. int group_idx = 0;
  6430. atomic_t *group_ref = NULL;
  6431. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6432. if (group_idx < 0) {
  6433. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6434. __func__, dai->id);
  6435. return;
  6436. }
  6437. mutex_lock(&tdm_mutex);
  6438. group_ref = &tdm_group_ref[group_idx];
  6439. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6440. rc = afe_close(dai->id);
  6441. if (rc < 0) {
  6442. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  6443. __func__, dai->id);
  6444. }
  6445. atomic_dec(group_ref);
  6446. clear_bit(STATUS_PORT_STARTED,
  6447. dai_data->status_mask);
  6448. if (atomic_read(group_ref) == 0) {
  6449. rc = afe_port_group_enable(group_id,
  6450. NULL, false);
  6451. if (rc < 0) {
  6452. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  6453. __func__, group_id);
  6454. }
  6455. rc = msm_dai_q6_tdm_set_clk(dai_data,
  6456. dai->id, false);
  6457. if (rc < 0) {
  6458. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  6459. __func__, dai->id);
  6460. }
  6461. }
  6462. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  6463. /* NOTE: AFE should error out if HW resource contention */
  6464. }
  6465. mutex_unlock(&tdm_mutex);
  6466. }
  6467. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  6468. .prepare = msm_dai_q6_tdm_prepare,
  6469. .hw_params = msm_dai_q6_tdm_hw_params,
  6470. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  6471. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  6472. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  6473. .shutdown = msm_dai_q6_tdm_shutdown,
  6474. };
  6475. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  6476. {
  6477. .playback = {
  6478. .stream_name = "Primary TDM0 Playback",
  6479. .aif_name = "PRI_TDM_RX_0",
  6480. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6481. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6482. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6483. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6484. SNDRV_PCM_FMTBIT_S24_LE |
  6485. SNDRV_PCM_FMTBIT_S32_LE,
  6486. .channels_min = 1,
  6487. .channels_max = 8,
  6488. .rate_min = 8000,
  6489. .rate_max = 352800,
  6490. },
  6491. .ops = &msm_dai_q6_tdm_ops,
  6492. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  6493. .probe = msm_dai_q6_dai_tdm_probe,
  6494. .remove = msm_dai_q6_dai_tdm_remove,
  6495. },
  6496. {
  6497. .playback = {
  6498. .stream_name = "Primary TDM1 Playback",
  6499. .aif_name = "PRI_TDM_RX_1",
  6500. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6501. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6502. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6503. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6504. SNDRV_PCM_FMTBIT_S24_LE |
  6505. SNDRV_PCM_FMTBIT_S32_LE,
  6506. .channels_min = 1,
  6507. .channels_max = 8,
  6508. .rate_min = 8000,
  6509. .rate_max = 352800,
  6510. },
  6511. .ops = &msm_dai_q6_tdm_ops,
  6512. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  6513. .probe = msm_dai_q6_dai_tdm_probe,
  6514. .remove = msm_dai_q6_dai_tdm_remove,
  6515. },
  6516. {
  6517. .playback = {
  6518. .stream_name = "Primary TDM2 Playback",
  6519. .aif_name = "PRI_TDM_RX_2",
  6520. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6521. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6522. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6523. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6524. SNDRV_PCM_FMTBIT_S24_LE |
  6525. SNDRV_PCM_FMTBIT_S32_LE,
  6526. .channels_min = 1,
  6527. .channels_max = 8,
  6528. .rate_min = 8000,
  6529. .rate_max = 352800,
  6530. },
  6531. .ops = &msm_dai_q6_tdm_ops,
  6532. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  6533. .probe = msm_dai_q6_dai_tdm_probe,
  6534. .remove = msm_dai_q6_dai_tdm_remove,
  6535. },
  6536. {
  6537. .playback = {
  6538. .stream_name = "Primary TDM3 Playback",
  6539. .aif_name = "PRI_TDM_RX_3",
  6540. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6541. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6542. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6543. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6544. SNDRV_PCM_FMTBIT_S24_LE |
  6545. SNDRV_PCM_FMTBIT_S32_LE,
  6546. .channels_min = 1,
  6547. .channels_max = 8,
  6548. .rate_min = 8000,
  6549. .rate_max = 352800,
  6550. },
  6551. .ops = &msm_dai_q6_tdm_ops,
  6552. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  6553. .probe = msm_dai_q6_dai_tdm_probe,
  6554. .remove = msm_dai_q6_dai_tdm_remove,
  6555. },
  6556. {
  6557. .playback = {
  6558. .stream_name = "Primary TDM4 Playback",
  6559. .aif_name = "PRI_TDM_RX_4",
  6560. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6561. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6562. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6563. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6564. SNDRV_PCM_FMTBIT_S24_LE |
  6565. SNDRV_PCM_FMTBIT_S32_LE,
  6566. .channels_min = 1,
  6567. .channels_max = 8,
  6568. .rate_min = 8000,
  6569. .rate_max = 352800,
  6570. },
  6571. .ops = &msm_dai_q6_tdm_ops,
  6572. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  6573. .probe = msm_dai_q6_dai_tdm_probe,
  6574. .remove = msm_dai_q6_dai_tdm_remove,
  6575. },
  6576. {
  6577. .playback = {
  6578. .stream_name = "Primary TDM5 Playback",
  6579. .aif_name = "PRI_TDM_RX_5",
  6580. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6581. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6582. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6583. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6584. SNDRV_PCM_FMTBIT_S24_LE |
  6585. SNDRV_PCM_FMTBIT_S32_LE,
  6586. .channels_min = 1,
  6587. .channels_max = 8,
  6588. .rate_min = 8000,
  6589. .rate_max = 352800,
  6590. },
  6591. .ops = &msm_dai_q6_tdm_ops,
  6592. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  6593. .probe = msm_dai_q6_dai_tdm_probe,
  6594. .remove = msm_dai_q6_dai_tdm_remove,
  6595. },
  6596. {
  6597. .playback = {
  6598. .stream_name = "Primary TDM6 Playback",
  6599. .aif_name = "PRI_TDM_RX_6",
  6600. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6601. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6602. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6603. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6604. SNDRV_PCM_FMTBIT_S24_LE |
  6605. SNDRV_PCM_FMTBIT_S32_LE,
  6606. .channels_min = 1,
  6607. .channels_max = 8,
  6608. .rate_min = 8000,
  6609. .rate_max = 352800,
  6610. },
  6611. .ops = &msm_dai_q6_tdm_ops,
  6612. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  6613. .probe = msm_dai_q6_dai_tdm_probe,
  6614. .remove = msm_dai_q6_dai_tdm_remove,
  6615. },
  6616. {
  6617. .playback = {
  6618. .stream_name = "Primary TDM7 Playback",
  6619. .aif_name = "PRI_TDM_RX_7",
  6620. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6621. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6622. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6623. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6624. SNDRV_PCM_FMTBIT_S24_LE |
  6625. SNDRV_PCM_FMTBIT_S32_LE,
  6626. .channels_min = 1,
  6627. .channels_max = 8,
  6628. .rate_min = 8000,
  6629. .rate_max = 352800,
  6630. },
  6631. .ops = &msm_dai_q6_tdm_ops,
  6632. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  6633. .probe = msm_dai_q6_dai_tdm_probe,
  6634. .remove = msm_dai_q6_dai_tdm_remove,
  6635. },
  6636. {
  6637. .capture = {
  6638. .stream_name = "Primary TDM0 Capture",
  6639. .aif_name = "PRI_TDM_TX_0",
  6640. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6641. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6642. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6643. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6644. SNDRV_PCM_FMTBIT_S24_LE |
  6645. SNDRV_PCM_FMTBIT_S32_LE,
  6646. .channels_min = 1,
  6647. .channels_max = 8,
  6648. .rate_min = 8000,
  6649. .rate_max = 352800,
  6650. },
  6651. .ops = &msm_dai_q6_tdm_ops,
  6652. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  6653. .probe = msm_dai_q6_dai_tdm_probe,
  6654. .remove = msm_dai_q6_dai_tdm_remove,
  6655. },
  6656. {
  6657. .capture = {
  6658. .stream_name = "Primary TDM1 Capture",
  6659. .aif_name = "PRI_TDM_TX_1",
  6660. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6661. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6662. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6663. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6664. SNDRV_PCM_FMTBIT_S24_LE |
  6665. SNDRV_PCM_FMTBIT_S32_LE,
  6666. .channels_min = 1,
  6667. .channels_max = 8,
  6668. .rate_min = 8000,
  6669. .rate_max = 352800,
  6670. },
  6671. .ops = &msm_dai_q6_tdm_ops,
  6672. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  6673. .probe = msm_dai_q6_dai_tdm_probe,
  6674. .remove = msm_dai_q6_dai_tdm_remove,
  6675. },
  6676. {
  6677. .capture = {
  6678. .stream_name = "Primary TDM2 Capture",
  6679. .aif_name = "PRI_TDM_TX_2",
  6680. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6681. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6682. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6683. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6684. SNDRV_PCM_FMTBIT_S24_LE |
  6685. SNDRV_PCM_FMTBIT_S32_LE,
  6686. .channels_min = 1,
  6687. .channels_max = 8,
  6688. .rate_min = 8000,
  6689. .rate_max = 352800,
  6690. },
  6691. .ops = &msm_dai_q6_tdm_ops,
  6692. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  6693. .probe = msm_dai_q6_dai_tdm_probe,
  6694. .remove = msm_dai_q6_dai_tdm_remove,
  6695. },
  6696. {
  6697. .capture = {
  6698. .stream_name = "Primary TDM3 Capture",
  6699. .aif_name = "PRI_TDM_TX_3",
  6700. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6701. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6702. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6703. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6704. SNDRV_PCM_FMTBIT_S24_LE |
  6705. SNDRV_PCM_FMTBIT_S32_LE,
  6706. .channels_min = 1,
  6707. .channels_max = 8,
  6708. .rate_min = 8000,
  6709. .rate_max = 352800,
  6710. },
  6711. .ops = &msm_dai_q6_tdm_ops,
  6712. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  6713. .probe = msm_dai_q6_dai_tdm_probe,
  6714. .remove = msm_dai_q6_dai_tdm_remove,
  6715. },
  6716. {
  6717. .capture = {
  6718. .stream_name = "Primary TDM4 Capture",
  6719. .aif_name = "PRI_TDM_TX_4",
  6720. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6721. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6722. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6723. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6724. SNDRV_PCM_FMTBIT_S24_LE |
  6725. SNDRV_PCM_FMTBIT_S32_LE,
  6726. .channels_min = 1,
  6727. .channels_max = 8,
  6728. .rate_min = 8000,
  6729. .rate_max = 352800,
  6730. },
  6731. .ops = &msm_dai_q6_tdm_ops,
  6732. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  6733. .probe = msm_dai_q6_dai_tdm_probe,
  6734. .remove = msm_dai_q6_dai_tdm_remove,
  6735. },
  6736. {
  6737. .capture = {
  6738. .stream_name = "Primary TDM5 Capture",
  6739. .aif_name = "PRI_TDM_TX_5",
  6740. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6741. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6742. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6743. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6744. SNDRV_PCM_FMTBIT_S24_LE |
  6745. SNDRV_PCM_FMTBIT_S32_LE,
  6746. .channels_min = 1,
  6747. .channels_max = 8,
  6748. .rate_min = 8000,
  6749. .rate_max = 352800,
  6750. },
  6751. .ops = &msm_dai_q6_tdm_ops,
  6752. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  6753. .probe = msm_dai_q6_dai_tdm_probe,
  6754. .remove = msm_dai_q6_dai_tdm_remove,
  6755. },
  6756. {
  6757. .capture = {
  6758. .stream_name = "Primary TDM6 Capture",
  6759. .aif_name = "PRI_TDM_TX_6",
  6760. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6761. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6762. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6763. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6764. SNDRV_PCM_FMTBIT_S24_LE |
  6765. SNDRV_PCM_FMTBIT_S32_LE,
  6766. .channels_min = 1,
  6767. .channels_max = 8,
  6768. .rate_min = 8000,
  6769. .rate_max = 352800,
  6770. },
  6771. .ops = &msm_dai_q6_tdm_ops,
  6772. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  6773. .probe = msm_dai_q6_dai_tdm_probe,
  6774. .remove = msm_dai_q6_dai_tdm_remove,
  6775. },
  6776. {
  6777. .capture = {
  6778. .stream_name = "Primary TDM7 Capture",
  6779. .aif_name = "PRI_TDM_TX_7",
  6780. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6781. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6782. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6783. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6784. SNDRV_PCM_FMTBIT_S24_LE |
  6785. SNDRV_PCM_FMTBIT_S32_LE,
  6786. .channels_min = 1,
  6787. .channels_max = 8,
  6788. .rate_min = 8000,
  6789. .rate_max = 352800,
  6790. },
  6791. .ops = &msm_dai_q6_tdm_ops,
  6792. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  6793. .probe = msm_dai_q6_dai_tdm_probe,
  6794. .remove = msm_dai_q6_dai_tdm_remove,
  6795. },
  6796. {
  6797. .playback = {
  6798. .stream_name = "Secondary TDM0 Playback",
  6799. .aif_name = "SEC_TDM_RX_0",
  6800. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6801. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6802. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6803. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6804. SNDRV_PCM_FMTBIT_S24_LE |
  6805. SNDRV_PCM_FMTBIT_S32_LE,
  6806. .channels_min = 1,
  6807. .channels_max = 8,
  6808. .rate_min = 8000,
  6809. .rate_max = 352800,
  6810. },
  6811. .ops = &msm_dai_q6_tdm_ops,
  6812. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  6813. .probe = msm_dai_q6_dai_tdm_probe,
  6814. .remove = msm_dai_q6_dai_tdm_remove,
  6815. },
  6816. {
  6817. .playback = {
  6818. .stream_name = "Secondary TDM1 Playback",
  6819. .aif_name = "SEC_TDM_RX_1",
  6820. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6821. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6822. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6823. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6824. SNDRV_PCM_FMTBIT_S24_LE |
  6825. SNDRV_PCM_FMTBIT_S32_LE,
  6826. .channels_min = 1,
  6827. .channels_max = 8,
  6828. .rate_min = 8000,
  6829. .rate_max = 352800,
  6830. },
  6831. .ops = &msm_dai_q6_tdm_ops,
  6832. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  6833. .probe = msm_dai_q6_dai_tdm_probe,
  6834. .remove = msm_dai_q6_dai_tdm_remove,
  6835. },
  6836. {
  6837. .playback = {
  6838. .stream_name = "Secondary TDM2 Playback",
  6839. .aif_name = "SEC_TDM_RX_2",
  6840. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6841. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6842. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6843. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6844. SNDRV_PCM_FMTBIT_S24_LE |
  6845. SNDRV_PCM_FMTBIT_S32_LE,
  6846. .channels_min = 1,
  6847. .channels_max = 8,
  6848. .rate_min = 8000,
  6849. .rate_max = 352800,
  6850. },
  6851. .ops = &msm_dai_q6_tdm_ops,
  6852. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  6853. .probe = msm_dai_q6_dai_tdm_probe,
  6854. .remove = msm_dai_q6_dai_tdm_remove,
  6855. },
  6856. {
  6857. .playback = {
  6858. .stream_name = "Secondary TDM3 Playback",
  6859. .aif_name = "SEC_TDM_RX_3",
  6860. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6861. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6862. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6863. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6864. SNDRV_PCM_FMTBIT_S24_LE |
  6865. SNDRV_PCM_FMTBIT_S32_LE,
  6866. .channels_min = 1,
  6867. .channels_max = 8,
  6868. .rate_min = 8000,
  6869. .rate_max = 352800,
  6870. },
  6871. .ops = &msm_dai_q6_tdm_ops,
  6872. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  6873. .probe = msm_dai_q6_dai_tdm_probe,
  6874. .remove = msm_dai_q6_dai_tdm_remove,
  6875. },
  6876. {
  6877. .playback = {
  6878. .stream_name = "Secondary TDM4 Playback",
  6879. .aif_name = "SEC_TDM_RX_4",
  6880. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6881. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6882. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6883. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6884. SNDRV_PCM_FMTBIT_S24_LE |
  6885. SNDRV_PCM_FMTBIT_S32_LE,
  6886. .channels_min = 1,
  6887. .channels_max = 8,
  6888. .rate_min = 8000,
  6889. .rate_max = 352800,
  6890. },
  6891. .ops = &msm_dai_q6_tdm_ops,
  6892. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  6893. .probe = msm_dai_q6_dai_tdm_probe,
  6894. .remove = msm_dai_q6_dai_tdm_remove,
  6895. },
  6896. {
  6897. .playback = {
  6898. .stream_name = "Secondary TDM5 Playback",
  6899. .aif_name = "SEC_TDM_RX_5",
  6900. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6901. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6902. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6903. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6904. SNDRV_PCM_FMTBIT_S24_LE |
  6905. SNDRV_PCM_FMTBIT_S32_LE,
  6906. .channels_min = 1,
  6907. .channels_max = 8,
  6908. .rate_min = 8000,
  6909. .rate_max = 352800,
  6910. },
  6911. .ops = &msm_dai_q6_tdm_ops,
  6912. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  6913. .probe = msm_dai_q6_dai_tdm_probe,
  6914. .remove = msm_dai_q6_dai_tdm_remove,
  6915. },
  6916. {
  6917. .playback = {
  6918. .stream_name = "Secondary TDM6 Playback",
  6919. .aif_name = "SEC_TDM_RX_6",
  6920. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6921. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6922. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6923. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6924. SNDRV_PCM_FMTBIT_S24_LE |
  6925. SNDRV_PCM_FMTBIT_S32_LE,
  6926. .channels_min = 1,
  6927. .channels_max = 8,
  6928. .rate_min = 8000,
  6929. .rate_max = 352800,
  6930. },
  6931. .ops = &msm_dai_q6_tdm_ops,
  6932. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  6933. .probe = msm_dai_q6_dai_tdm_probe,
  6934. .remove = msm_dai_q6_dai_tdm_remove,
  6935. },
  6936. {
  6937. .playback = {
  6938. .stream_name = "Secondary TDM7 Playback",
  6939. .aif_name = "SEC_TDM_RX_7",
  6940. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6941. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6942. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6943. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6944. SNDRV_PCM_FMTBIT_S24_LE |
  6945. SNDRV_PCM_FMTBIT_S32_LE,
  6946. .channels_min = 1,
  6947. .channels_max = 8,
  6948. .rate_min = 8000,
  6949. .rate_max = 352800,
  6950. },
  6951. .ops = &msm_dai_q6_tdm_ops,
  6952. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  6953. .probe = msm_dai_q6_dai_tdm_probe,
  6954. .remove = msm_dai_q6_dai_tdm_remove,
  6955. },
  6956. {
  6957. .capture = {
  6958. .stream_name = "Secondary TDM0 Capture",
  6959. .aif_name = "SEC_TDM_TX_0",
  6960. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6961. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6962. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6963. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6964. SNDRV_PCM_FMTBIT_S24_LE |
  6965. SNDRV_PCM_FMTBIT_S32_LE,
  6966. .channels_min = 1,
  6967. .channels_max = 8,
  6968. .rate_min = 8000,
  6969. .rate_max = 352800,
  6970. },
  6971. .ops = &msm_dai_q6_tdm_ops,
  6972. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  6973. .probe = msm_dai_q6_dai_tdm_probe,
  6974. .remove = msm_dai_q6_dai_tdm_remove,
  6975. },
  6976. {
  6977. .capture = {
  6978. .stream_name = "Secondary TDM1 Capture",
  6979. .aif_name = "SEC_TDM_TX_1",
  6980. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6981. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6982. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6983. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6984. SNDRV_PCM_FMTBIT_S24_LE |
  6985. SNDRV_PCM_FMTBIT_S32_LE,
  6986. .channels_min = 1,
  6987. .channels_max = 8,
  6988. .rate_min = 8000,
  6989. .rate_max = 352800,
  6990. },
  6991. .ops = &msm_dai_q6_tdm_ops,
  6992. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  6993. .probe = msm_dai_q6_dai_tdm_probe,
  6994. .remove = msm_dai_q6_dai_tdm_remove,
  6995. },
  6996. {
  6997. .capture = {
  6998. .stream_name = "Secondary TDM2 Capture",
  6999. .aif_name = "SEC_TDM_TX_2",
  7000. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7001. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7002. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7003. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7004. SNDRV_PCM_FMTBIT_S24_LE |
  7005. SNDRV_PCM_FMTBIT_S32_LE,
  7006. .channels_min = 1,
  7007. .channels_max = 8,
  7008. .rate_min = 8000,
  7009. .rate_max = 352800,
  7010. },
  7011. .ops = &msm_dai_q6_tdm_ops,
  7012. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  7013. .probe = msm_dai_q6_dai_tdm_probe,
  7014. .remove = msm_dai_q6_dai_tdm_remove,
  7015. },
  7016. {
  7017. .capture = {
  7018. .stream_name = "Secondary TDM3 Capture",
  7019. .aif_name = "SEC_TDM_TX_3",
  7020. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7021. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7022. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7023. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7024. SNDRV_PCM_FMTBIT_S24_LE |
  7025. SNDRV_PCM_FMTBIT_S32_LE,
  7026. .channels_min = 1,
  7027. .channels_max = 8,
  7028. .rate_min = 8000,
  7029. .rate_max = 352800,
  7030. },
  7031. .ops = &msm_dai_q6_tdm_ops,
  7032. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  7033. .probe = msm_dai_q6_dai_tdm_probe,
  7034. .remove = msm_dai_q6_dai_tdm_remove,
  7035. },
  7036. {
  7037. .capture = {
  7038. .stream_name = "Secondary TDM4 Capture",
  7039. .aif_name = "SEC_TDM_TX_4",
  7040. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7041. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7042. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7043. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7044. SNDRV_PCM_FMTBIT_S24_LE |
  7045. SNDRV_PCM_FMTBIT_S32_LE,
  7046. .channels_min = 1,
  7047. .channels_max = 8,
  7048. .rate_min = 8000,
  7049. .rate_max = 352800,
  7050. },
  7051. .ops = &msm_dai_q6_tdm_ops,
  7052. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  7053. .probe = msm_dai_q6_dai_tdm_probe,
  7054. .remove = msm_dai_q6_dai_tdm_remove,
  7055. },
  7056. {
  7057. .capture = {
  7058. .stream_name = "Secondary TDM5 Capture",
  7059. .aif_name = "SEC_TDM_TX_5",
  7060. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7061. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7062. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7063. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7064. SNDRV_PCM_FMTBIT_S24_LE |
  7065. SNDRV_PCM_FMTBIT_S32_LE,
  7066. .channels_min = 1,
  7067. .channels_max = 8,
  7068. .rate_min = 8000,
  7069. .rate_max = 352800,
  7070. },
  7071. .ops = &msm_dai_q6_tdm_ops,
  7072. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  7073. .probe = msm_dai_q6_dai_tdm_probe,
  7074. .remove = msm_dai_q6_dai_tdm_remove,
  7075. },
  7076. {
  7077. .capture = {
  7078. .stream_name = "Secondary TDM6 Capture",
  7079. .aif_name = "SEC_TDM_TX_6",
  7080. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7081. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7082. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7083. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7084. SNDRV_PCM_FMTBIT_S24_LE |
  7085. SNDRV_PCM_FMTBIT_S32_LE,
  7086. .channels_min = 1,
  7087. .channels_max = 8,
  7088. .rate_min = 8000,
  7089. .rate_max = 352800,
  7090. },
  7091. .ops = &msm_dai_q6_tdm_ops,
  7092. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  7093. .probe = msm_dai_q6_dai_tdm_probe,
  7094. .remove = msm_dai_q6_dai_tdm_remove,
  7095. },
  7096. {
  7097. .capture = {
  7098. .stream_name = "Secondary TDM7 Capture",
  7099. .aif_name = "SEC_TDM_TX_7",
  7100. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7101. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7102. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7103. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7104. SNDRV_PCM_FMTBIT_S24_LE |
  7105. SNDRV_PCM_FMTBIT_S32_LE,
  7106. .channels_min = 1,
  7107. .channels_max = 8,
  7108. .rate_min = 8000,
  7109. .rate_max = 352800,
  7110. },
  7111. .ops = &msm_dai_q6_tdm_ops,
  7112. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  7113. .probe = msm_dai_q6_dai_tdm_probe,
  7114. .remove = msm_dai_q6_dai_tdm_remove,
  7115. },
  7116. {
  7117. .playback = {
  7118. .stream_name = "Tertiary TDM0 Playback",
  7119. .aif_name = "TERT_TDM_RX_0",
  7120. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7121. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7122. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7123. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7124. SNDRV_PCM_FMTBIT_S24_LE |
  7125. SNDRV_PCM_FMTBIT_S32_LE,
  7126. .channels_min = 1,
  7127. .channels_max = 8,
  7128. .rate_min = 8000,
  7129. .rate_max = 352800,
  7130. },
  7131. .ops = &msm_dai_q6_tdm_ops,
  7132. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  7133. .probe = msm_dai_q6_dai_tdm_probe,
  7134. .remove = msm_dai_q6_dai_tdm_remove,
  7135. },
  7136. {
  7137. .playback = {
  7138. .stream_name = "Tertiary TDM1 Playback",
  7139. .aif_name = "TERT_TDM_RX_1",
  7140. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7141. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7142. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7143. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7144. SNDRV_PCM_FMTBIT_S24_LE |
  7145. SNDRV_PCM_FMTBIT_S32_LE,
  7146. .channels_min = 1,
  7147. .channels_max = 8,
  7148. .rate_min = 8000,
  7149. .rate_max = 352800,
  7150. },
  7151. .ops = &msm_dai_q6_tdm_ops,
  7152. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  7153. .probe = msm_dai_q6_dai_tdm_probe,
  7154. .remove = msm_dai_q6_dai_tdm_remove,
  7155. },
  7156. {
  7157. .playback = {
  7158. .stream_name = "Tertiary TDM2 Playback",
  7159. .aif_name = "TERT_TDM_RX_2",
  7160. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7161. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7162. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7163. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7164. SNDRV_PCM_FMTBIT_S24_LE |
  7165. SNDRV_PCM_FMTBIT_S32_LE,
  7166. .channels_min = 1,
  7167. .channels_max = 8,
  7168. .rate_min = 8000,
  7169. .rate_max = 352800,
  7170. },
  7171. .ops = &msm_dai_q6_tdm_ops,
  7172. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  7173. .probe = msm_dai_q6_dai_tdm_probe,
  7174. .remove = msm_dai_q6_dai_tdm_remove,
  7175. },
  7176. {
  7177. .playback = {
  7178. .stream_name = "Tertiary TDM3 Playback",
  7179. .aif_name = "TERT_TDM_RX_3",
  7180. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7181. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7182. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7183. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7184. SNDRV_PCM_FMTBIT_S24_LE |
  7185. SNDRV_PCM_FMTBIT_S32_LE,
  7186. .channels_min = 1,
  7187. .channels_max = 8,
  7188. .rate_min = 8000,
  7189. .rate_max = 352800,
  7190. },
  7191. .ops = &msm_dai_q6_tdm_ops,
  7192. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  7193. .probe = msm_dai_q6_dai_tdm_probe,
  7194. .remove = msm_dai_q6_dai_tdm_remove,
  7195. },
  7196. {
  7197. .playback = {
  7198. .stream_name = "Tertiary TDM4 Playback",
  7199. .aif_name = "TERT_TDM_RX_4",
  7200. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7201. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7202. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7203. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7204. SNDRV_PCM_FMTBIT_S24_LE |
  7205. SNDRV_PCM_FMTBIT_S32_LE,
  7206. .channels_min = 1,
  7207. .channels_max = 8,
  7208. .rate_min = 8000,
  7209. .rate_max = 352800,
  7210. },
  7211. .ops = &msm_dai_q6_tdm_ops,
  7212. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  7213. .probe = msm_dai_q6_dai_tdm_probe,
  7214. .remove = msm_dai_q6_dai_tdm_remove,
  7215. },
  7216. {
  7217. .playback = {
  7218. .stream_name = "Tertiary TDM5 Playback",
  7219. .aif_name = "TERT_TDM_RX_5",
  7220. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7221. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7222. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7223. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7224. SNDRV_PCM_FMTBIT_S24_LE |
  7225. SNDRV_PCM_FMTBIT_S32_LE,
  7226. .channels_min = 1,
  7227. .channels_max = 8,
  7228. .rate_min = 8000,
  7229. .rate_max = 352800,
  7230. },
  7231. .ops = &msm_dai_q6_tdm_ops,
  7232. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  7233. .probe = msm_dai_q6_dai_tdm_probe,
  7234. .remove = msm_dai_q6_dai_tdm_remove,
  7235. },
  7236. {
  7237. .playback = {
  7238. .stream_name = "Tertiary TDM6 Playback",
  7239. .aif_name = "TERT_TDM_RX_6",
  7240. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7241. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7242. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7243. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7244. SNDRV_PCM_FMTBIT_S24_LE |
  7245. SNDRV_PCM_FMTBIT_S32_LE,
  7246. .channels_min = 1,
  7247. .channels_max = 8,
  7248. .rate_min = 8000,
  7249. .rate_max = 352800,
  7250. },
  7251. .ops = &msm_dai_q6_tdm_ops,
  7252. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  7253. .probe = msm_dai_q6_dai_tdm_probe,
  7254. .remove = msm_dai_q6_dai_tdm_remove,
  7255. },
  7256. {
  7257. .playback = {
  7258. .stream_name = "Tertiary TDM7 Playback",
  7259. .aif_name = "TERT_TDM_RX_7",
  7260. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7261. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7262. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7263. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7264. SNDRV_PCM_FMTBIT_S24_LE |
  7265. SNDRV_PCM_FMTBIT_S32_LE,
  7266. .channels_min = 1,
  7267. .channels_max = 8,
  7268. .rate_min = 8000,
  7269. .rate_max = 352800,
  7270. },
  7271. .ops = &msm_dai_q6_tdm_ops,
  7272. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  7273. .probe = msm_dai_q6_dai_tdm_probe,
  7274. .remove = msm_dai_q6_dai_tdm_remove,
  7275. },
  7276. {
  7277. .capture = {
  7278. .stream_name = "Tertiary TDM0 Capture",
  7279. .aif_name = "TERT_TDM_TX_0",
  7280. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7281. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7282. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7283. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7284. SNDRV_PCM_FMTBIT_S24_LE |
  7285. SNDRV_PCM_FMTBIT_S32_LE,
  7286. .channels_min = 1,
  7287. .channels_max = 8,
  7288. .rate_min = 8000,
  7289. .rate_max = 352800,
  7290. },
  7291. .ops = &msm_dai_q6_tdm_ops,
  7292. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  7293. .probe = msm_dai_q6_dai_tdm_probe,
  7294. .remove = msm_dai_q6_dai_tdm_remove,
  7295. },
  7296. {
  7297. .capture = {
  7298. .stream_name = "Tertiary TDM1 Capture",
  7299. .aif_name = "TERT_TDM_TX_1",
  7300. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7301. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7302. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7303. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7304. SNDRV_PCM_FMTBIT_S24_LE |
  7305. SNDRV_PCM_FMTBIT_S32_LE,
  7306. .channels_min = 1,
  7307. .channels_max = 8,
  7308. .rate_min = 8000,
  7309. .rate_max = 352800,
  7310. },
  7311. .ops = &msm_dai_q6_tdm_ops,
  7312. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  7313. .probe = msm_dai_q6_dai_tdm_probe,
  7314. .remove = msm_dai_q6_dai_tdm_remove,
  7315. },
  7316. {
  7317. .capture = {
  7318. .stream_name = "Tertiary TDM2 Capture",
  7319. .aif_name = "TERT_TDM_TX_2",
  7320. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7321. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7322. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7323. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7324. SNDRV_PCM_FMTBIT_S24_LE |
  7325. SNDRV_PCM_FMTBIT_S32_LE,
  7326. .channels_min = 1,
  7327. .channels_max = 8,
  7328. .rate_min = 8000,
  7329. .rate_max = 352800,
  7330. },
  7331. .ops = &msm_dai_q6_tdm_ops,
  7332. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  7333. .probe = msm_dai_q6_dai_tdm_probe,
  7334. .remove = msm_dai_q6_dai_tdm_remove,
  7335. },
  7336. {
  7337. .capture = {
  7338. .stream_name = "Tertiary TDM3 Capture",
  7339. .aif_name = "TERT_TDM_TX_3",
  7340. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7341. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7342. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7343. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7344. SNDRV_PCM_FMTBIT_S24_LE |
  7345. SNDRV_PCM_FMTBIT_S32_LE,
  7346. .channels_min = 1,
  7347. .channels_max = 8,
  7348. .rate_min = 8000,
  7349. .rate_max = 352800,
  7350. },
  7351. .ops = &msm_dai_q6_tdm_ops,
  7352. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  7353. .probe = msm_dai_q6_dai_tdm_probe,
  7354. .remove = msm_dai_q6_dai_tdm_remove,
  7355. },
  7356. {
  7357. .capture = {
  7358. .stream_name = "Tertiary TDM4 Capture",
  7359. .aif_name = "TERT_TDM_TX_4",
  7360. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7361. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7362. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7363. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7364. SNDRV_PCM_FMTBIT_S24_LE |
  7365. SNDRV_PCM_FMTBIT_S32_LE,
  7366. .channels_min = 1,
  7367. .channels_max = 8,
  7368. .rate_min = 8000,
  7369. .rate_max = 352800,
  7370. },
  7371. .ops = &msm_dai_q6_tdm_ops,
  7372. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  7373. .probe = msm_dai_q6_dai_tdm_probe,
  7374. .remove = msm_dai_q6_dai_tdm_remove,
  7375. },
  7376. {
  7377. .capture = {
  7378. .stream_name = "Tertiary TDM5 Capture",
  7379. .aif_name = "TERT_TDM_TX_5",
  7380. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7381. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7382. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7383. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7384. SNDRV_PCM_FMTBIT_S24_LE |
  7385. SNDRV_PCM_FMTBIT_S32_LE,
  7386. .channels_min = 1,
  7387. .channels_max = 8,
  7388. .rate_min = 8000,
  7389. .rate_max = 352800,
  7390. },
  7391. .ops = &msm_dai_q6_tdm_ops,
  7392. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  7393. .probe = msm_dai_q6_dai_tdm_probe,
  7394. .remove = msm_dai_q6_dai_tdm_remove,
  7395. },
  7396. {
  7397. .capture = {
  7398. .stream_name = "Tertiary TDM6 Capture",
  7399. .aif_name = "TERT_TDM_TX_6",
  7400. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7401. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7402. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7403. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7404. SNDRV_PCM_FMTBIT_S24_LE |
  7405. SNDRV_PCM_FMTBIT_S32_LE,
  7406. .channels_min = 1,
  7407. .channels_max = 8,
  7408. .rate_min = 8000,
  7409. .rate_max = 352800,
  7410. },
  7411. .ops = &msm_dai_q6_tdm_ops,
  7412. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  7413. .probe = msm_dai_q6_dai_tdm_probe,
  7414. .remove = msm_dai_q6_dai_tdm_remove,
  7415. },
  7416. {
  7417. .capture = {
  7418. .stream_name = "Tertiary TDM7 Capture",
  7419. .aif_name = "TERT_TDM_TX_7",
  7420. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7421. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7422. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7423. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7424. SNDRV_PCM_FMTBIT_S24_LE |
  7425. SNDRV_PCM_FMTBIT_S32_LE,
  7426. .channels_min = 1,
  7427. .channels_max = 8,
  7428. .rate_min = 8000,
  7429. .rate_max = 352800,
  7430. },
  7431. .ops = &msm_dai_q6_tdm_ops,
  7432. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  7433. .probe = msm_dai_q6_dai_tdm_probe,
  7434. .remove = msm_dai_q6_dai_tdm_remove,
  7435. },
  7436. {
  7437. .playback = {
  7438. .stream_name = "Quaternary TDM0 Playback",
  7439. .aif_name = "QUAT_TDM_RX_0",
  7440. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7441. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7442. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7443. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7444. SNDRV_PCM_FMTBIT_S24_LE |
  7445. SNDRV_PCM_FMTBIT_S32_LE,
  7446. .channels_min = 1,
  7447. .channels_max = 8,
  7448. .rate_min = 8000,
  7449. .rate_max = 352800,
  7450. },
  7451. .ops = &msm_dai_q6_tdm_ops,
  7452. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  7453. .probe = msm_dai_q6_dai_tdm_probe,
  7454. .remove = msm_dai_q6_dai_tdm_remove,
  7455. },
  7456. {
  7457. .playback = {
  7458. .stream_name = "Quaternary TDM1 Playback",
  7459. .aif_name = "QUAT_TDM_RX_1",
  7460. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7461. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7462. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7463. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7464. SNDRV_PCM_FMTBIT_S24_LE |
  7465. SNDRV_PCM_FMTBIT_S32_LE,
  7466. .channels_min = 1,
  7467. .channels_max = 8,
  7468. .rate_min = 8000,
  7469. .rate_max = 352800,
  7470. },
  7471. .ops = &msm_dai_q6_tdm_ops,
  7472. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  7473. .probe = msm_dai_q6_dai_tdm_probe,
  7474. .remove = msm_dai_q6_dai_tdm_remove,
  7475. },
  7476. {
  7477. .playback = {
  7478. .stream_name = "Quaternary TDM2 Playback",
  7479. .aif_name = "QUAT_TDM_RX_2",
  7480. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7481. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7482. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7483. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7484. SNDRV_PCM_FMTBIT_S24_LE |
  7485. SNDRV_PCM_FMTBIT_S32_LE,
  7486. .channels_min = 1,
  7487. .channels_max = 8,
  7488. .rate_min = 8000,
  7489. .rate_max = 352800,
  7490. },
  7491. .ops = &msm_dai_q6_tdm_ops,
  7492. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  7493. .probe = msm_dai_q6_dai_tdm_probe,
  7494. .remove = msm_dai_q6_dai_tdm_remove,
  7495. },
  7496. {
  7497. .playback = {
  7498. .stream_name = "Quaternary TDM3 Playback",
  7499. .aif_name = "QUAT_TDM_RX_3",
  7500. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7501. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7502. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7503. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7504. SNDRV_PCM_FMTBIT_S24_LE |
  7505. SNDRV_PCM_FMTBIT_S32_LE,
  7506. .channels_min = 1,
  7507. .channels_max = 8,
  7508. .rate_min = 8000,
  7509. .rate_max = 352800,
  7510. },
  7511. .ops = &msm_dai_q6_tdm_ops,
  7512. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  7513. .probe = msm_dai_q6_dai_tdm_probe,
  7514. .remove = msm_dai_q6_dai_tdm_remove,
  7515. },
  7516. {
  7517. .playback = {
  7518. .stream_name = "Quaternary TDM4 Playback",
  7519. .aif_name = "QUAT_TDM_RX_4",
  7520. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7521. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7522. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7523. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7524. SNDRV_PCM_FMTBIT_S24_LE |
  7525. SNDRV_PCM_FMTBIT_S32_LE,
  7526. .channels_min = 1,
  7527. .channels_max = 8,
  7528. .rate_min = 8000,
  7529. .rate_max = 352800,
  7530. },
  7531. .ops = &msm_dai_q6_tdm_ops,
  7532. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  7533. .probe = msm_dai_q6_dai_tdm_probe,
  7534. .remove = msm_dai_q6_dai_tdm_remove,
  7535. },
  7536. {
  7537. .playback = {
  7538. .stream_name = "Quaternary TDM5 Playback",
  7539. .aif_name = "QUAT_TDM_RX_5",
  7540. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7541. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7542. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7543. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7544. SNDRV_PCM_FMTBIT_S24_LE |
  7545. SNDRV_PCM_FMTBIT_S32_LE,
  7546. .channels_min = 1,
  7547. .channels_max = 8,
  7548. .rate_min = 8000,
  7549. .rate_max = 352800,
  7550. },
  7551. .ops = &msm_dai_q6_tdm_ops,
  7552. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  7553. .probe = msm_dai_q6_dai_tdm_probe,
  7554. .remove = msm_dai_q6_dai_tdm_remove,
  7555. },
  7556. {
  7557. .playback = {
  7558. .stream_name = "Quaternary TDM6 Playback",
  7559. .aif_name = "QUAT_TDM_RX_6",
  7560. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7561. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7562. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7563. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7564. SNDRV_PCM_FMTBIT_S24_LE |
  7565. SNDRV_PCM_FMTBIT_S32_LE,
  7566. .channels_min = 1,
  7567. .channels_max = 8,
  7568. .rate_min = 8000,
  7569. .rate_max = 352800,
  7570. },
  7571. .ops = &msm_dai_q6_tdm_ops,
  7572. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  7573. .probe = msm_dai_q6_dai_tdm_probe,
  7574. .remove = msm_dai_q6_dai_tdm_remove,
  7575. },
  7576. {
  7577. .playback = {
  7578. .stream_name = "Quaternary TDM7 Playback",
  7579. .aif_name = "QUAT_TDM_RX_7",
  7580. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7581. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7582. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7583. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7584. SNDRV_PCM_FMTBIT_S24_LE |
  7585. SNDRV_PCM_FMTBIT_S32_LE,
  7586. .channels_min = 1,
  7587. .channels_max = 8,
  7588. .rate_min = 8000,
  7589. .rate_max = 352800,
  7590. },
  7591. .ops = &msm_dai_q6_tdm_ops,
  7592. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  7593. .probe = msm_dai_q6_dai_tdm_probe,
  7594. .remove = msm_dai_q6_dai_tdm_remove,
  7595. },
  7596. {
  7597. .capture = {
  7598. .stream_name = "Quaternary TDM0 Capture",
  7599. .aif_name = "QUAT_TDM_TX_0",
  7600. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7601. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7602. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7603. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7604. SNDRV_PCM_FMTBIT_S24_LE |
  7605. SNDRV_PCM_FMTBIT_S32_LE,
  7606. .channels_min = 1,
  7607. .channels_max = 8,
  7608. .rate_min = 8000,
  7609. .rate_max = 352800,
  7610. },
  7611. .ops = &msm_dai_q6_tdm_ops,
  7612. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  7613. .probe = msm_dai_q6_dai_tdm_probe,
  7614. .remove = msm_dai_q6_dai_tdm_remove,
  7615. },
  7616. {
  7617. .capture = {
  7618. .stream_name = "Quaternary TDM1 Capture",
  7619. .aif_name = "QUAT_TDM_TX_1",
  7620. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7621. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7622. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7623. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7624. SNDRV_PCM_FMTBIT_S24_LE |
  7625. SNDRV_PCM_FMTBIT_S32_LE,
  7626. .channels_min = 1,
  7627. .channels_max = 8,
  7628. .rate_min = 8000,
  7629. .rate_max = 352800,
  7630. },
  7631. .ops = &msm_dai_q6_tdm_ops,
  7632. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  7633. .probe = msm_dai_q6_dai_tdm_probe,
  7634. .remove = msm_dai_q6_dai_tdm_remove,
  7635. },
  7636. {
  7637. .capture = {
  7638. .stream_name = "Quaternary TDM2 Capture",
  7639. .aif_name = "QUAT_TDM_TX_2",
  7640. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7641. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7642. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7643. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7644. SNDRV_PCM_FMTBIT_S24_LE |
  7645. SNDRV_PCM_FMTBIT_S32_LE,
  7646. .channels_min = 1,
  7647. .channels_max = 8,
  7648. .rate_min = 8000,
  7649. .rate_max = 352800,
  7650. },
  7651. .ops = &msm_dai_q6_tdm_ops,
  7652. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  7653. .probe = msm_dai_q6_dai_tdm_probe,
  7654. .remove = msm_dai_q6_dai_tdm_remove,
  7655. },
  7656. {
  7657. .capture = {
  7658. .stream_name = "Quaternary TDM3 Capture",
  7659. .aif_name = "QUAT_TDM_TX_3",
  7660. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7661. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7662. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7663. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7664. SNDRV_PCM_FMTBIT_S24_LE |
  7665. SNDRV_PCM_FMTBIT_S32_LE,
  7666. .channels_min = 1,
  7667. .channels_max = 8,
  7668. .rate_min = 8000,
  7669. .rate_max = 352800,
  7670. },
  7671. .ops = &msm_dai_q6_tdm_ops,
  7672. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  7673. .probe = msm_dai_q6_dai_tdm_probe,
  7674. .remove = msm_dai_q6_dai_tdm_remove,
  7675. },
  7676. {
  7677. .capture = {
  7678. .stream_name = "Quaternary TDM4 Capture",
  7679. .aif_name = "QUAT_TDM_TX_4",
  7680. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7681. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7682. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7683. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7684. SNDRV_PCM_FMTBIT_S24_LE |
  7685. SNDRV_PCM_FMTBIT_S32_LE,
  7686. .channels_min = 1,
  7687. .channels_max = 8,
  7688. .rate_min = 8000,
  7689. .rate_max = 352800,
  7690. },
  7691. .ops = &msm_dai_q6_tdm_ops,
  7692. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  7693. .probe = msm_dai_q6_dai_tdm_probe,
  7694. .remove = msm_dai_q6_dai_tdm_remove,
  7695. },
  7696. {
  7697. .capture = {
  7698. .stream_name = "Quaternary TDM5 Capture",
  7699. .aif_name = "QUAT_TDM_TX_5",
  7700. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7701. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7702. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7703. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7704. SNDRV_PCM_FMTBIT_S24_LE |
  7705. SNDRV_PCM_FMTBIT_S32_LE,
  7706. .channels_min = 1,
  7707. .channels_max = 8,
  7708. .rate_min = 8000,
  7709. .rate_max = 352800,
  7710. },
  7711. .ops = &msm_dai_q6_tdm_ops,
  7712. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  7713. .probe = msm_dai_q6_dai_tdm_probe,
  7714. .remove = msm_dai_q6_dai_tdm_remove,
  7715. },
  7716. {
  7717. .capture = {
  7718. .stream_name = "Quaternary TDM6 Capture",
  7719. .aif_name = "QUAT_TDM_TX_6",
  7720. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7721. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7722. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7723. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7724. SNDRV_PCM_FMTBIT_S24_LE |
  7725. SNDRV_PCM_FMTBIT_S32_LE,
  7726. .channels_min = 1,
  7727. .channels_max = 8,
  7728. .rate_min = 8000,
  7729. .rate_max = 352800,
  7730. },
  7731. .ops = &msm_dai_q6_tdm_ops,
  7732. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  7733. .probe = msm_dai_q6_dai_tdm_probe,
  7734. .remove = msm_dai_q6_dai_tdm_remove,
  7735. },
  7736. {
  7737. .capture = {
  7738. .stream_name = "Quaternary TDM7 Capture",
  7739. .aif_name = "QUAT_TDM_TX_7",
  7740. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7741. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7742. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7743. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7744. SNDRV_PCM_FMTBIT_S24_LE |
  7745. SNDRV_PCM_FMTBIT_S32_LE,
  7746. .channels_min = 1,
  7747. .channels_max = 8,
  7748. .rate_min = 8000,
  7749. .rate_max = 352800,
  7750. },
  7751. .ops = &msm_dai_q6_tdm_ops,
  7752. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  7753. .probe = msm_dai_q6_dai_tdm_probe,
  7754. .remove = msm_dai_q6_dai_tdm_remove,
  7755. },
  7756. {
  7757. .playback = {
  7758. .stream_name = "Quinary TDM0 Playback",
  7759. .aif_name = "QUIN_TDM_RX_0",
  7760. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7761. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7762. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7763. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7764. SNDRV_PCM_FMTBIT_S24_LE |
  7765. SNDRV_PCM_FMTBIT_S32_LE,
  7766. .channels_min = 1,
  7767. .channels_max = 8,
  7768. .rate_min = 8000,
  7769. .rate_max = 352800,
  7770. },
  7771. .ops = &msm_dai_q6_tdm_ops,
  7772. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  7773. .probe = msm_dai_q6_dai_tdm_probe,
  7774. .remove = msm_dai_q6_dai_tdm_remove,
  7775. },
  7776. {
  7777. .playback = {
  7778. .stream_name = "Quinary TDM1 Playback",
  7779. .aif_name = "QUIN_TDM_RX_1",
  7780. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7781. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7782. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7783. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7784. SNDRV_PCM_FMTBIT_S24_LE |
  7785. SNDRV_PCM_FMTBIT_S32_LE,
  7786. .channels_min = 1,
  7787. .channels_max = 8,
  7788. .rate_min = 8000,
  7789. .rate_max = 352800,
  7790. },
  7791. .ops = &msm_dai_q6_tdm_ops,
  7792. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  7793. .probe = msm_dai_q6_dai_tdm_probe,
  7794. .remove = msm_dai_q6_dai_tdm_remove,
  7795. },
  7796. {
  7797. .playback = {
  7798. .stream_name = "Quinary TDM2 Playback",
  7799. .aif_name = "QUIN_TDM_RX_2",
  7800. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7801. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7802. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7803. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7804. SNDRV_PCM_FMTBIT_S24_LE |
  7805. SNDRV_PCM_FMTBIT_S32_LE,
  7806. .channels_min = 1,
  7807. .channels_max = 8,
  7808. .rate_min = 8000,
  7809. .rate_max = 352800,
  7810. },
  7811. .ops = &msm_dai_q6_tdm_ops,
  7812. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  7813. .probe = msm_dai_q6_dai_tdm_probe,
  7814. .remove = msm_dai_q6_dai_tdm_remove,
  7815. },
  7816. {
  7817. .playback = {
  7818. .stream_name = "Quinary TDM3 Playback",
  7819. .aif_name = "QUIN_TDM_RX_3",
  7820. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7821. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7822. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7823. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7824. SNDRV_PCM_FMTBIT_S24_LE |
  7825. SNDRV_PCM_FMTBIT_S32_LE,
  7826. .channels_min = 1,
  7827. .channels_max = 8,
  7828. .rate_min = 8000,
  7829. .rate_max = 352800,
  7830. },
  7831. .ops = &msm_dai_q6_tdm_ops,
  7832. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  7833. .probe = msm_dai_q6_dai_tdm_probe,
  7834. .remove = msm_dai_q6_dai_tdm_remove,
  7835. },
  7836. {
  7837. .playback = {
  7838. .stream_name = "Quinary TDM4 Playback",
  7839. .aif_name = "QUIN_TDM_RX_4",
  7840. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7841. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7842. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7843. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7844. SNDRV_PCM_FMTBIT_S24_LE |
  7845. SNDRV_PCM_FMTBIT_S32_LE,
  7846. .channels_min = 1,
  7847. .channels_max = 8,
  7848. .rate_min = 8000,
  7849. .rate_max = 352800,
  7850. },
  7851. .ops = &msm_dai_q6_tdm_ops,
  7852. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  7853. .probe = msm_dai_q6_dai_tdm_probe,
  7854. .remove = msm_dai_q6_dai_tdm_remove,
  7855. },
  7856. {
  7857. .playback = {
  7858. .stream_name = "Quinary TDM5 Playback",
  7859. .aif_name = "QUIN_TDM_RX_5",
  7860. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7861. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7862. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7863. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7864. SNDRV_PCM_FMTBIT_S24_LE |
  7865. SNDRV_PCM_FMTBIT_S32_LE,
  7866. .channels_min = 1,
  7867. .channels_max = 8,
  7868. .rate_min = 8000,
  7869. .rate_max = 352800,
  7870. },
  7871. .ops = &msm_dai_q6_tdm_ops,
  7872. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  7873. .probe = msm_dai_q6_dai_tdm_probe,
  7874. .remove = msm_dai_q6_dai_tdm_remove,
  7875. },
  7876. {
  7877. .playback = {
  7878. .stream_name = "Quinary TDM6 Playback",
  7879. .aif_name = "QUIN_TDM_RX_6",
  7880. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7881. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7882. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7883. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7884. SNDRV_PCM_FMTBIT_S24_LE |
  7885. SNDRV_PCM_FMTBIT_S32_LE,
  7886. .channels_min = 1,
  7887. .channels_max = 8,
  7888. .rate_min = 8000,
  7889. .rate_max = 352800,
  7890. },
  7891. .ops = &msm_dai_q6_tdm_ops,
  7892. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  7893. .probe = msm_dai_q6_dai_tdm_probe,
  7894. .remove = msm_dai_q6_dai_tdm_remove,
  7895. },
  7896. {
  7897. .playback = {
  7898. .stream_name = "Quinary TDM7 Playback",
  7899. .aif_name = "QUIN_TDM_RX_7",
  7900. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7901. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7902. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7903. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7904. SNDRV_PCM_FMTBIT_S24_LE |
  7905. SNDRV_PCM_FMTBIT_S32_LE,
  7906. .channels_min = 1,
  7907. .channels_max = 8,
  7908. .rate_min = 8000,
  7909. .rate_max = 352800,
  7910. },
  7911. .ops = &msm_dai_q6_tdm_ops,
  7912. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  7913. .probe = msm_dai_q6_dai_tdm_probe,
  7914. .remove = msm_dai_q6_dai_tdm_remove,
  7915. },
  7916. {
  7917. .capture = {
  7918. .stream_name = "Quinary TDM0 Capture",
  7919. .aif_name = "QUIN_TDM_TX_0",
  7920. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7921. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7922. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7923. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7924. SNDRV_PCM_FMTBIT_S24_LE |
  7925. SNDRV_PCM_FMTBIT_S32_LE,
  7926. .channels_min = 1,
  7927. .channels_max = 8,
  7928. .rate_min = 8000,
  7929. .rate_max = 352800,
  7930. },
  7931. .ops = &msm_dai_q6_tdm_ops,
  7932. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  7933. .probe = msm_dai_q6_dai_tdm_probe,
  7934. .remove = msm_dai_q6_dai_tdm_remove,
  7935. },
  7936. {
  7937. .capture = {
  7938. .stream_name = "Quinary TDM1 Capture",
  7939. .aif_name = "QUIN_TDM_TX_1",
  7940. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7941. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7942. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7943. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7944. SNDRV_PCM_FMTBIT_S24_LE |
  7945. SNDRV_PCM_FMTBIT_S32_LE,
  7946. .channels_min = 1,
  7947. .channels_max = 8,
  7948. .rate_min = 8000,
  7949. .rate_max = 352800,
  7950. },
  7951. .ops = &msm_dai_q6_tdm_ops,
  7952. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  7953. .probe = msm_dai_q6_dai_tdm_probe,
  7954. .remove = msm_dai_q6_dai_tdm_remove,
  7955. },
  7956. {
  7957. .capture = {
  7958. .stream_name = "Quinary TDM2 Capture",
  7959. .aif_name = "QUIN_TDM_TX_2",
  7960. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7961. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7962. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7963. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7964. SNDRV_PCM_FMTBIT_S24_LE |
  7965. SNDRV_PCM_FMTBIT_S32_LE,
  7966. .channels_min = 1,
  7967. .channels_max = 8,
  7968. .rate_min = 8000,
  7969. .rate_max = 352800,
  7970. },
  7971. .ops = &msm_dai_q6_tdm_ops,
  7972. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  7973. .probe = msm_dai_q6_dai_tdm_probe,
  7974. .remove = msm_dai_q6_dai_tdm_remove,
  7975. },
  7976. {
  7977. .capture = {
  7978. .stream_name = "Quinary TDM3 Capture",
  7979. .aif_name = "QUIN_TDM_TX_3",
  7980. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7981. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7982. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7983. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7984. SNDRV_PCM_FMTBIT_S24_LE |
  7985. SNDRV_PCM_FMTBIT_S32_LE,
  7986. .channels_min = 1,
  7987. .channels_max = 8,
  7988. .rate_min = 8000,
  7989. .rate_max = 352800,
  7990. },
  7991. .ops = &msm_dai_q6_tdm_ops,
  7992. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  7993. .probe = msm_dai_q6_dai_tdm_probe,
  7994. .remove = msm_dai_q6_dai_tdm_remove,
  7995. },
  7996. {
  7997. .capture = {
  7998. .stream_name = "Quinary TDM4 Capture",
  7999. .aif_name = "QUIN_TDM_TX_4",
  8000. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8001. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8002. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8003. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8004. SNDRV_PCM_FMTBIT_S24_LE |
  8005. SNDRV_PCM_FMTBIT_S32_LE,
  8006. .channels_min = 1,
  8007. .channels_max = 8,
  8008. .rate_min = 8000,
  8009. .rate_max = 352800,
  8010. },
  8011. .ops = &msm_dai_q6_tdm_ops,
  8012. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  8013. .probe = msm_dai_q6_dai_tdm_probe,
  8014. .remove = msm_dai_q6_dai_tdm_remove,
  8015. },
  8016. {
  8017. .capture = {
  8018. .stream_name = "Quinary TDM5 Capture",
  8019. .aif_name = "QUIN_TDM_TX_5",
  8020. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8021. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8022. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8023. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8024. SNDRV_PCM_FMTBIT_S24_LE |
  8025. SNDRV_PCM_FMTBIT_S32_LE,
  8026. .channels_min = 1,
  8027. .channels_max = 8,
  8028. .rate_min = 8000,
  8029. .rate_max = 352800,
  8030. },
  8031. .ops = &msm_dai_q6_tdm_ops,
  8032. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  8033. .probe = msm_dai_q6_dai_tdm_probe,
  8034. .remove = msm_dai_q6_dai_tdm_remove,
  8035. },
  8036. {
  8037. .capture = {
  8038. .stream_name = "Quinary TDM6 Capture",
  8039. .aif_name = "QUIN_TDM_TX_6",
  8040. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8041. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8042. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8043. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8044. SNDRV_PCM_FMTBIT_S24_LE |
  8045. SNDRV_PCM_FMTBIT_S32_LE,
  8046. .channels_min = 1,
  8047. .channels_max = 8,
  8048. .rate_min = 8000,
  8049. .rate_max = 352800,
  8050. },
  8051. .ops = &msm_dai_q6_tdm_ops,
  8052. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  8053. .probe = msm_dai_q6_dai_tdm_probe,
  8054. .remove = msm_dai_q6_dai_tdm_remove,
  8055. },
  8056. {
  8057. .capture = {
  8058. .stream_name = "Quinary TDM7 Capture",
  8059. .aif_name = "QUIN_TDM_TX_7",
  8060. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8061. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8062. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8063. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8064. SNDRV_PCM_FMTBIT_S24_LE |
  8065. SNDRV_PCM_FMTBIT_S32_LE,
  8066. .channels_min = 1,
  8067. .channels_max = 8,
  8068. .rate_min = 8000,
  8069. .rate_max = 352800,
  8070. },
  8071. .ops = &msm_dai_q6_tdm_ops,
  8072. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  8073. .probe = msm_dai_q6_dai_tdm_probe,
  8074. .remove = msm_dai_q6_dai_tdm_remove,
  8075. },
  8076. };
  8077. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  8078. .name = "msm-dai-q6-tdm",
  8079. };
  8080. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  8081. {
  8082. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  8083. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  8084. int rc = 0;
  8085. u32 tdm_dev_id = 0;
  8086. int port_idx = 0;
  8087. struct device_node *tdm_parent_node = NULL;
  8088. /* retrieve device/afe id */
  8089. rc = of_property_read_u32(pdev->dev.of_node,
  8090. "qcom,msm-cpudai-tdm-dev-id",
  8091. &tdm_dev_id);
  8092. if (rc) {
  8093. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  8094. __func__);
  8095. goto rtn;
  8096. }
  8097. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  8098. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  8099. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  8100. __func__, tdm_dev_id);
  8101. rc = -ENXIO;
  8102. goto rtn;
  8103. }
  8104. pdev->id = tdm_dev_id;
  8105. dev_info(&pdev->dev, "%s: dev_name: %s dev_id: 0x%x\n",
  8106. __func__, dev_name(&pdev->dev), tdm_dev_id);
  8107. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  8108. GFP_KERNEL);
  8109. if (!dai_data) {
  8110. rc = -ENOMEM;
  8111. dev_err(&pdev->dev,
  8112. "%s Failed to allocate memory for tdm dai_data\n",
  8113. __func__);
  8114. goto rtn;
  8115. }
  8116. memset(dai_data, 0, sizeof(*dai_data));
  8117. /* TDM CFG */
  8118. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  8119. rc = of_property_read_u32(tdm_parent_node,
  8120. "qcom,msm-cpudai-tdm-sync-mode",
  8121. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  8122. if (rc) {
  8123. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  8124. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  8125. goto free_dai_data;
  8126. }
  8127. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  8128. __func__, dai_data->port_cfg.tdm.sync_mode);
  8129. rc = of_property_read_u32(tdm_parent_node,
  8130. "qcom,msm-cpudai-tdm-sync-src",
  8131. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  8132. if (rc) {
  8133. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  8134. __func__, "qcom,msm-cpudai-tdm-sync-src");
  8135. goto free_dai_data;
  8136. }
  8137. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  8138. __func__, dai_data->port_cfg.tdm.sync_src);
  8139. rc = of_property_read_u32(tdm_parent_node,
  8140. "qcom,msm-cpudai-tdm-data-out",
  8141. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8142. if (rc) {
  8143. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  8144. __func__, "qcom,msm-cpudai-tdm-data-out");
  8145. goto free_dai_data;
  8146. }
  8147. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  8148. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8149. rc = of_property_read_u32(tdm_parent_node,
  8150. "qcom,msm-cpudai-tdm-invert-sync",
  8151. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8152. if (rc) {
  8153. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  8154. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  8155. goto free_dai_data;
  8156. }
  8157. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  8158. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8159. rc = of_property_read_u32(tdm_parent_node,
  8160. "qcom,msm-cpudai-tdm-data-delay",
  8161. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8162. if (rc) {
  8163. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  8164. __func__, "qcom,msm-cpudai-tdm-data-delay");
  8165. goto free_dai_data;
  8166. }
  8167. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  8168. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8169. /* TDM CFG -- set default */
  8170. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  8171. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  8172. AFE_API_VERSION_TDM_CONFIG;
  8173. /* TDM SLOT MAPPING CFG */
  8174. rc = of_property_read_u32(pdev->dev.of_node,
  8175. "qcom,msm-cpudai-tdm-data-align",
  8176. &dai_data->port_cfg.slot_mapping.data_align_type);
  8177. if (rc) {
  8178. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  8179. __func__,
  8180. "qcom,msm-cpudai-tdm-data-align");
  8181. goto free_dai_data;
  8182. }
  8183. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  8184. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  8185. /* TDM SLOT MAPPING CFG -- set default */
  8186. dai_data->port_cfg.slot_mapping.minor_version =
  8187. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  8188. /* CUSTOM TDM HEADER CFG */
  8189. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  8190. if (of_find_property(pdev->dev.of_node,
  8191. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  8192. of_find_property(pdev->dev.of_node,
  8193. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  8194. of_find_property(pdev->dev.of_node,
  8195. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  8196. /* if the property exist */
  8197. rc = of_property_read_u32(pdev->dev.of_node,
  8198. "qcom,msm-cpudai-tdm-header-start-offset",
  8199. (u32 *)&custom_tdm_header->start_offset);
  8200. if (rc) {
  8201. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  8202. __func__,
  8203. "qcom,msm-cpudai-tdm-header-start-offset");
  8204. goto free_dai_data;
  8205. }
  8206. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  8207. __func__, custom_tdm_header->start_offset);
  8208. rc = of_property_read_u32(pdev->dev.of_node,
  8209. "qcom,msm-cpudai-tdm-header-width",
  8210. (u32 *)&custom_tdm_header->header_width);
  8211. if (rc) {
  8212. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  8213. __func__, "qcom,msm-cpudai-tdm-header-width");
  8214. goto free_dai_data;
  8215. }
  8216. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  8217. __func__, custom_tdm_header->header_width);
  8218. rc = of_property_read_u32(pdev->dev.of_node,
  8219. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  8220. (u32 *)&custom_tdm_header->num_frame_repeat);
  8221. if (rc) {
  8222. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  8223. __func__,
  8224. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  8225. goto free_dai_data;
  8226. }
  8227. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  8228. __func__, custom_tdm_header->num_frame_repeat);
  8229. /* CUSTOM TDM HEADER CFG -- set default */
  8230. custom_tdm_header->minor_version =
  8231. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  8232. custom_tdm_header->header_type =
  8233. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8234. } else {
  8235. dev_info(&pdev->dev,
  8236. "%s: Custom tdm header not supported\n", __func__);
  8237. /* CUSTOM TDM HEADER CFG -- set default */
  8238. custom_tdm_header->header_type =
  8239. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8240. /* proceed with probe */
  8241. }
  8242. /* copy static clk per parent node */
  8243. dai_data->clk_set = tdm_clk_set;
  8244. /* copy static group cfg per parent node */
  8245. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  8246. /* copy static num group ports per parent node */
  8247. dai_data->num_group_ports = num_tdm_group_ports;
  8248. dev_set_drvdata(&pdev->dev, dai_data);
  8249. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  8250. if (port_idx < 0) {
  8251. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  8252. __func__, tdm_dev_id);
  8253. rc = -EINVAL;
  8254. goto free_dai_data;
  8255. }
  8256. rc = snd_soc_register_component(&pdev->dev,
  8257. &msm_q6_tdm_dai_component,
  8258. &msm_dai_q6_tdm_dai[port_idx], 1);
  8259. if (rc) {
  8260. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  8261. __func__, tdm_dev_id, rc);
  8262. goto err_register;
  8263. }
  8264. return 0;
  8265. err_register:
  8266. free_dai_data:
  8267. kfree(dai_data);
  8268. rtn:
  8269. return rc;
  8270. }
  8271. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  8272. {
  8273. struct msm_dai_q6_tdm_dai_data *dai_data =
  8274. dev_get_drvdata(&pdev->dev);
  8275. snd_soc_unregister_component(&pdev->dev);
  8276. kfree(dai_data);
  8277. return 0;
  8278. }
  8279. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  8280. { .compatible = "qcom,msm-dai-q6-tdm", },
  8281. {}
  8282. };
  8283. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  8284. static struct platform_driver msm_dai_q6_tdm_driver = {
  8285. .probe = msm_dai_q6_tdm_dev_probe,
  8286. .remove = msm_dai_q6_tdm_dev_remove,
  8287. .driver = {
  8288. .name = "msm-dai-q6-tdm",
  8289. .owner = THIS_MODULE,
  8290. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  8291. },
  8292. };
  8293. int __init msm_dai_q6_init(void)
  8294. {
  8295. int rc;
  8296. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  8297. if (rc) {
  8298. pr_err("%s: fail to register auxpcm dev driver", __func__);
  8299. goto fail;
  8300. }
  8301. rc = platform_driver_register(&msm_dai_q6);
  8302. if (rc) {
  8303. pr_err("%s: fail to register dai q6 driver", __func__);
  8304. goto dai_q6_fail;
  8305. }
  8306. rc = platform_driver_register(&msm_dai_q6_dev);
  8307. if (rc) {
  8308. pr_err("%s: fail to register dai q6 dev driver", __func__);
  8309. goto dai_q6_dev_fail;
  8310. }
  8311. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  8312. if (rc) {
  8313. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  8314. goto dai_q6_mi2s_drv_fail;
  8315. }
  8316. rc = platform_driver_register(&msm_dai_mi2s_q6);
  8317. if (rc) {
  8318. pr_err("%s: fail to register dai MI2S\n", __func__);
  8319. goto dai_mi2s_q6_fail;
  8320. }
  8321. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  8322. if (rc) {
  8323. pr_err("%s: fail to register dai SPDIF\n", __func__);
  8324. goto dai_spdif_q6_fail;
  8325. }
  8326. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  8327. if (rc) {
  8328. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  8329. goto dai_q6_tdm_drv_fail;
  8330. }
  8331. rc = platform_driver_register(&msm_dai_tdm_q6);
  8332. if (rc) {
  8333. pr_err("%s: fail to register dai TDM\n", __func__);
  8334. goto dai_tdm_q6_fail;
  8335. }
  8336. return rc;
  8337. dai_tdm_q6_fail:
  8338. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  8339. dai_q6_tdm_drv_fail:
  8340. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  8341. dai_spdif_q6_fail:
  8342. platform_driver_unregister(&msm_dai_mi2s_q6);
  8343. dai_mi2s_q6_fail:
  8344. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  8345. dai_q6_mi2s_drv_fail:
  8346. platform_driver_unregister(&msm_dai_q6_dev);
  8347. dai_q6_dev_fail:
  8348. platform_driver_unregister(&msm_dai_q6);
  8349. dai_q6_fail:
  8350. platform_driver_unregister(&msm_auxpcm_dev_driver);
  8351. fail:
  8352. return rc;
  8353. }
  8354. void __exit msm_dai_q6_exit(void)
  8355. {
  8356. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  8357. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  8358. platform_driver_unregister(&msm_dai_mi2s_q6);
  8359. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  8360. platform_driver_unregister(&msm_dai_q6_dev);
  8361. platform_driver_unregister(&msm_dai_q6);
  8362. platform_driver_unregister(&msm_auxpcm_dev_driver);
  8363. }
  8364. /* Module information */
  8365. MODULE_DESCRIPTION("MSM DSP DAI driver");
  8366. MODULE_LICENSE("GPL v2");