msm-dai-q6-v2.c 323 KB

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