msm-dai-q6-v2.c 331 KB

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