msm-dai-q6-v2.c 283 KB

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