msm-dai-q6-v2.c 351 KB

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