msm-dai-q6-v2.c 312 KB

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