0001-Add-pvr-dri-driver.patch 154 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689
  1. From a97794e871281ac4a8184e65f988bb6d37250500 Mon Sep 17 00:00:00 2001
  2. From: Frank Binns <frank.binns@imgtec.com>
  3. Date: Tue, 14 Apr 2020 09:47:46 +0100
  4. Subject: [PATCH] Add pvr dri driver
  5. ---
  6. meson.build | 19 +-
  7. meson_options.txt | 2 +-
  8. src/mesa/drivers/dri/meson.build | 5 +
  9. src/mesa/drivers/dri/pvr/dri_support.h | 581 +++++++++++++++
  10. src/mesa/drivers/dri/pvr/img_drm_fourcc.h | 113 +++
  11. src/mesa/drivers/dri/pvr/imgpixfmts.h | 307 ++++++++
  12. src/mesa/drivers/dri/pvr/imgyuv.h | 58 ++
  13. src/mesa/drivers/dri/pvr/mesa_context.c | 208 ++++++
  14. src/mesa/drivers/dri/pvr/meson.build | 48 ++
  15. src/mesa/drivers/dri/pvr/pvrcb.c | 328 +++++++++
  16. src/mesa/drivers/dri/pvr/pvrcompat.c | 838 ++++++++++++++++++++++
  17. src/mesa/drivers/dri/pvr/pvrdri.c | 613 ++++++++++++++++
  18. src/mesa/drivers/dri/pvr/pvrdri.h | 188 +++++
  19. src/mesa/drivers/dri/pvr/pvrdri_support.h | 206 ++++++
  20. src/mesa/drivers/dri/pvr/pvrext.c | 704 ++++++++++++++++++
  21. src/mesa/drivers/dri/pvr/pvrmesa.h | 36 +
  22. src/mesa/drivers/dri/pvr/pvrutil.c | 239 ++++++
  23. src/meson.build | 1 +
  24. 18 files changed, 4485 insertions(+), 9 deletions(-)
  25. create mode 100644 src/mesa/drivers/dri/pvr/dri_support.h
  26. create mode 100644 src/mesa/drivers/dri/pvr/img_drm_fourcc.h
  27. create mode 100644 src/mesa/drivers/dri/pvr/imgpixfmts.h
  28. create mode 100644 src/mesa/drivers/dri/pvr/imgyuv.h
  29. create mode 100644 src/mesa/drivers/dri/pvr/mesa_context.c
  30. create mode 100644 src/mesa/drivers/dri/pvr/meson.build
  31. create mode 100644 src/mesa/drivers/dri/pvr/pvrcb.c
  32. create mode 100644 src/mesa/drivers/dri/pvr/pvrcompat.c
  33. create mode 100644 src/mesa/drivers/dri/pvr/pvrdri.c
  34. create mode 100644 src/mesa/drivers/dri/pvr/pvrdri.h
  35. create mode 100644 src/mesa/drivers/dri/pvr/pvrdri_support.h
  36. create mode 100644 src/mesa/drivers/dri/pvr/pvrext.c
  37. create mode 100644 src/mesa/drivers/dri/pvr/pvrmesa.h
  38. create mode 100644 src/mesa/drivers/dri/pvr/pvrutil.c
  39. diff --git a/meson.build b/meson.build
  40. index 155db28..968b4f5 100644
  41. --- a/meson.build
  42. +++ b/meson.build
  43. @@ -171,11 +171,11 @@ if dri_drivers.contains('auto')
  44. if system_has_kms_drm
  45. # TODO: PPC, Sparc
  46. if ['x86', 'x86_64'].contains(host_machine.cpu_family())
  47. - dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
  48. + dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau', 'pvr']
  49. elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
  50. - dri_drivers = []
  51. + dri_drivers = ['pvr']
  52. elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
  53. - dri_drivers = ['r100', 'r200', 'nouveau']
  54. + dri_drivers = ['r100', 'r200', 'nouveau', 'pvr']
  55. else
  56. error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  57. host_machine.cpu_family()))
  58. @@ -194,6 +194,7 @@ with_dri_i965 = dri_drivers.contains('i965')
  59. with_dri_r100 = dri_drivers.contains('r100')
  60. with_dri_r200 = dri_drivers.contains('r200')
  61. with_dri_nouveau = dri_drivers.contains('nouveau')
  62. +with_dri_pvr = dri_drivers.contains('pvr')
  63. with_dri = dri_drivers.length() != 0
  64. @@ -1516,14 +1517,16 @@ _drm_amdgpu_ver = '2.4.107'
  65. _drm_radeon_ver = '2.4.71'
  66. _drm_nouveau_ver = '2.4.102'
  67. _drm_intel_ver = '2.4.75'
  68. +_drm_pvr_ver = '2.4.60'
  69. _drm_ver = '2.4.81'
  70. _libdrm_checks = [
  71. - ['intel', with_dri_i915 or with_gallium_i915],
  72. - ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi],
  73. + ['intel', with_dri_i915 or with_gallium_i915, true],
  74. + ['amdgpu', (with_amd_vk and not with_platform_windows) or with_gallium_radeonsi, true],
  75. ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
  76. - with_gallium_r300 or with_gallium_r600)],
  77. - ['nouveau', (with_gallium_nouveau or with_dri_nouveau)],
  78. + with_gallium_r300 or with_gallium_r600), true],
  79. + ['nouveau', (with_gallium_nouveau or with_dri_nouveau), true],
  80. + ['pvr', with_dri_pvr, false],
  81. ]
  82. # VC4 only needs core libdrm support of this version, not a libdrm_vc4
  83. @@ -1553,7 +1556,7 @@ endif
  84. # Then get each libdrm module
  85. foreach d : _libdrm_checks
  86. - if d[1]
  87. + if d[1] and d[2]
  88. set_variable(
  89. 'dep_libdrm_' + d[0],
  90. dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
  91. diff --git a/meson_options.txt b/meson_options.txt
  92. index 29c402c..dac7910 100644
  93. --- a/meson_options.txt
  94. +++ b/meson_options.txt
  95. @@ -55,7 +55,7 @@ option(
  96. 'dri-drivers',
  97. type : 'array',
  98. value : ['auto'],
  99. - choices : ['auto', 'i915', 'i965', 'r100', 'r200', 'nouveau'],
  100. + choices : ['auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'pvr'],
  101. description : 'List of dri drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
  102. )
  103. option(
  104. diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build
  105. index 239ca96..88a973b 100644
  106. --- a/src/mesa/drivers/dri/meson.build
  107. +++ b/src/mesa/drivers/dri/meson.build
  108. @@ -48,6 +48,11 @@ if with_dri_nouveau
  109. _dri_drivers += libnouveau_vieux
  110. _dri_link += 'nouveau_vieux_dri.so'
  111. endif
  112. +if with_dri_pvr
  113. + subdir('pvr')
  114. + _dri_drivers += libpvr
  115. + _dri_link += 'pvr_dri.so'
  116. +endif
  117. if _dri_drivers != []
  118. libmesa_dri_drivers = shared_library(
  119. diff --git a/src/mesa/drivers/dri/pvr/dri_support.h b/src/mesa/drivers/dri/pvr/dri_support.h
  120. new file mode 100644
  121. index 0000000..6314104
  122. --- /dev/null
  123. +++ b/src/mesa/drivers/dri/pvr/dri_support.h
  124. @@ -0,0 +1,581 @@
  125. +/* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
  126. +/* vi: set ts=8 sw=8 sts=8: */
  127. +/*************************************************************************/ /*!
  128. +@File
  129. +@Title PVR DRI interface definition
  130. +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  131. +@License MIT
  132. +
  133. +The contents of this file are subject to the MIT license as set out below.
  134. +
  135. +Permission is hereby granted, free of charge, to any person obtaining a copy
  136. +of this software and associated documentation files (the "Software"), to deal
  137. +in the Software without restriction, including without limitation the rights
  138. +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  139. +copies of the Software, and to permit persons to whom the Software is
  140. +furnished to do so, subject to the following conditions:
  141. +
  142. +The above copyright notice and this permission notice shall be included in
  143. +all copies or substantial portions of the Software.
  144. +
  145. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  146. +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  147. +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  148. +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  149. +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  150. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  151. +THE SOFTWARE.
  152. +*/ /**************************************************************************/
  153. +
  154. +#if !defined(__PVRDRIIFCE_H__)
  155. +#define __PVRDRIIFCE_H__
  156. +
  157. +#include <stdint.h>
  158. +#include <stdbool.h>
  159. +
  160. +/* API type. */
  161. +typedef enum
  162. +{
  163. + PVRDRI_API_NONE = 0,
  164. + PVRDRI_API_GLES1 = 2,
  165. + PVRDRI_API_GLES2 = 3,
  166. + PVRDRI_API_CL = 4,
  167. + PVRDRI_API_GL_COMPAT = 5,
  168. + PVRDRI_API_GL_CORE = 6,
  169. +} PVRDRIAPIType;
  170. +
  171. +typedef enum
  172. +{
  173. + PVRDRI_CONFIG_ATTRIB_INVALID = 0,
  174. + PVRDRI_CONFIG_ATTRIB_RENDERABLE_TYPE = 1,
  175. + PVRDRI_CONFIG_ATTRIB_RGB_MODE = 2,
  176. + PVRDRI_CONFIG_ATTRIB_DOUBLE_BUFFER_MODE = 3,
  177. + PVRDRI_CONFIG_ATTRIB_RED_BITS = 4,
  178. + PVRDRI_CONFIG_ATTRIB_GREEN_BITS = 5,
  179. + PVRDRI_CONFIG_ATTRIB_BLUE_BITS = 6,
  180. + PVRDRI_CONFIG_ATTRIB_ALPHA_BITS = 7,
  181. + PVRDRI_CONFIG_ATTRIB_RGB_BITS = 8,
  182. + PVRDRI_CONFIG_ATTRIB_DEPTH_BITS = 9,
  183. + PVRDRI_CONFIG_ATTRIB_STENCIL_BITS = 10,
  184. + PVRDRI_CONFIG_ATTRIB_SAMPLE_BUFFERS = 11,
  185. + PVRDRI_CONFIG_ATTRIB_SAMPLES = 12,
  186. + PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGB = 13,
  187. + PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGBA = 14,
  188. + PVRDRI_CONFIG_ATTRIB_YUV_ORDER = 15,
  189. + PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES = 16,
  190. + PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE = 17,
  191. + PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE = 18,
  192. + PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD = 19,
  193. + PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP = 20,
  194. + PVRDRI_CONFIG_ATTRIB_RED_MASK = 21,
  195. + PVRDRI_CONFIG_ATTRIB_GREEN_MASK = 22,
  196. + PVRDRI_CONFIG_ATTRIB_BLUE_MASK = 23,
  197. + PVRDRI_CONFIG_ATTRIB_ALPHA_MASK = 24,
  198. + PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE = 25
  199. +} PVRDRIConfigAttrib;
  200. +
  201. +/* EGL_RENDERABLE_TYPE mask bits */
  202. +#define PVRDRI_API_BIT_GLES 0x0001
  203. +#define PVRDRI_API_BIT_GLES2 0x0004
  204. +#define PVRDRI_API_BIT_GL 0x0008
  205. +#define PVRDRI_API_BIT_GLES3 0x0040
  206. +
  207. +/* Mesa config formats. These need not match their MESA_FORMAT counterparts */
  208. +#define PVRDRI_MESA_FORMAT_NONE 0
  209. +#define PVRDRI_MESA_FORMAT_B8G8R8A8_UNORM 1
  210. +#define PVRDRI_MESA_FORMAT_B8G8R8X8_UNORM 2
  211. +#define PVRDRI_MESA_FORMAT_B5G6R5_UNORM 3
  212. +#define PVRDRI_MESA_FORMAT_R8G8B8A8_UNORM 4
  213. +#define PVRDRI_MESA_FORMAT_R8G8B8X8_UNORM 5
  214. +#define PVRDRI_MESA_FORMAT_YCBCR 6
  215. +#define PVRDRI_MESA_FORMAT_YUV420_2PLANE 7
  216. +#define PVRDRI_MESA_FORMAT_YVU420_2PLANE 8
  217. +#define PVRDRI_MESA_FORMAT_B8G8R8A8_SRGB 9
  218. +#define PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB 10
  219. +
  220. +typedef struct __DRIimageRec __DRIimage;
  221. +
  222. +typedef struct PVRDRIConfigRec PVRDRIConfig;
  223. +
  224. +/* The PVRDRI_GL defines match their EGL_GL counterparts */
  225. +#define PVRDRI_GL_RENDERBUFFER 0x30B9
  226. +#define PVRDRI_GL_TEXTURE_2D 0x30B1
  227. +#define PVRDRI_GL_TEXTURE_3D 0x30B2
  228. +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
  229. +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
  230. +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
  231. +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
  232. +#define PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
  233. +#define PVRDRI_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
  234. +
  235. +struct __DRIscreenRec;
  236. +struct __DRIcontextRec;
  237. +struct __DRIdrawableRec;
  238. +
  239. +struct __DRIconfigRec;
  240. +
  241. +struct DRISUPScreen;
  242. +struct DRISUPContext;
  243. +struct DRISUPDrawable;
  244. +struct DRISUPBuffer;
  245. +
  246. +struct PVRDRIContextConfig
  247. +{
  248. + unsigned int uMajorVersion;
  249. + unsigned int uMinorVersion;
  250. + uint32_t uFlags;
  251. +
  252. + int iResetStrategy;
  253. + unsigned int uPriority;
  254. + int iReleaseBehavior;
  255. +};
  256. +
  257. +/*
  258. + * PVR DRI Support interface V2.
  259. + * This structure may change over time, as older interfaces become obsolete.
  260. + * For example, the v0 interface may be removed if superseded by newer
  261. + * interfaces.
  262. + */
  263. +struct PVRDRISupportInterfaceV2
  264. +{
  265. + struct
  266. + {
  267. + struct DRISUPScreen *(*CreateScreen)
  268. + (struct __DRIscreenRec *psDRIScreen,
  269. + int iFD,
  270. + bool bUseInvalidate,
  271. + void *pvLoaderPrivate,
  272. + const struct __DRIconfigRec ***pppsConfigs,
  273. + int *piMaxGLES1Version,
  274. + int *piMaxGLES2Version);
  275. +
  276. + void (*DestroyScreen)
  277. + (struct DRISUPScreen *psDRISUPScreen);
  278. +
  279. + unsigned int (*CreateContext)
  280. + (PVRDRIAPIType eAPI,
  281. + PVRDRIConfig *psPVRDRIConfig,
  282. + struct PVRDRIContextConfig *psCtxConfig,
  283. + struct __DRIcontextRec *psDRIContext,
  284. + struct DRISUPContext *psDRISUPSharedContext,
  285. + struct DRISUPScreen *psDRISUPScreen,
  286. + struct DRISUPContext **ppsDRISUPContext);
  287. +
  288. + void (*DestroyContext)
  289. + (struct DRISUPContext *psDRISUPContext);
  290. +
  291. + struct DRISUPDrawable *(*CreateDrawable)
  292. + (struct __DRIdrawableRec *psDRIDrawable,
  293. + struct DRISUPScreen *psDRISUPDrawable,
  294. + void *pvLoaderPrivate,
  295. + PVRDRIConfig *psPVRDRIConfig);
  296. +
  297. + void (*DestroyDrawable)
  298. + (struct DRISUPDrawable *psDRISUPDrawable);
  299. +
  300. + bool (*MakeCurrent)
  301. + (struct DRISUPContext *psDRISUPContext,
  302. + struct DRISUPDrawable *psDRISUPWrite,
  303. + struct DRISUPDrawable *psDRISUPRead);
  304. +
  305. + bool (*UnbindContext)
  306. + (struct DRISUPContext *psDRISUPContext);
  307. +
  308. + struct DRISUPBuffer *(*AllocateBuffer)
  309. + (struct DRISUPScreen *psDRISUPScreen,
  310. + unsigned int uAttachment,
  311. + unsigned int uFormat,
  312. + int iWidth,
  313. + int iHeight,
  314. + unsigned int *puName,
  315. + unsigned int *puPitch,
  316. + unsigned int *puCPP,
  317. + unsigned int *puFlags);
  318. +
  319. + void (*ReleaseBuffer)
  320. + (struct DRISUPScreen *psDRISUPScreen,
  321. + struct DRISUPBuffer *psDRISUPBuffer);
  322. +
  323. + /* Functions to support the DRI TexBuffer extension */
  324. + void (*SetTexBuffer2)
  325. + (struct DRISUPContext *psDRISUPContext,
  326. + int iTarget,
  327. + int iFormat,
  328. + struct DRISUPDrawable *psDRISUPDrawable);
  329. +
  330. + void (*ReleaseTexBuffer)
  331. + (struct DRISUPContext *psDRISUPContext,
  332. + int iTarget,
  333. + struct DRISUPDrawable *psDRISUPDrawable);
  334. +
  335. + /* Functions to support the DRI Flush extension */
  336. + void (*Flush)
  337. + (struct DRISUPDrawable *psDRISUPDrawable);
  338. +
  339. + void (*Invalidate)
  340. + (struct DRISUPDrawable *psDRISUPDrawable);
  341. +
  342. + void (*FlushWithFlags)
  343. + (struct DRISUPContext *psDRISUPContext,
  344. + struct DRISUPDrawable *psDRISUPDrawable,
  345. + unsigned int uFlags,
  346. + unsigned int uThrottleReason);
  347. +
  348. + /* Functions to support the DRI Image extension */
  349. + __DRIimage *(*CreateImageFromName)
  350. + (struct DRISUPScreen *psDRISUPScreen,
  351. + int iWidth,
  352. + int iHeight,
  353. + int iFourCC,
  354. + int iName,
  355. + int iPitch,
  356. + void *pvLoaderPrivate);
  357. +
  358. + __DRIimage *(*CreateImageFromRenderbuffer)
  359. + (struct DRISUPContext *psDRISUPContext,
  360. + int iRenderBuffer,
  361. + void *pvLoaderPrivate);
  362. +
  363. + void (*DestroyImage)
  364. + (__DRIimage *psImage);
  365. +
  366. + __DRIimage *(*CreateImage)
  367. + (struct DRISUPScreen *psDRISUPScreen,
  368. + int iWidth,
  369. + int iHeight,
  370. + int iFourCC,
  371. + unsigned int uUse,
  372. + void *pvLoaderPrivate);
  373. +
  374. + bool (*QueryImage)
  375. + (__DRIimage *psImage,
  376. + int iAttrib,
  377. + int *iValue);
  378. +
  379. + __DRIimage *(*DupImage)
  380. + (__DRIimage *psImage,
  381. + void *pvLoaderPrivate);
  382. +
  383. + bool (*ValidateImageUsage)
  384. + (__DRIimage *psImage,
  385. + unsigned int uUse);
  386. +
  387. + __DRIimage *(*CreateImageFromNames)
  388. + (struct DRISUPScreen *psDRISUPScreen,
  389. + int iWidth,
  390. + int iHeight,
  391. + int iFourCC,
  392. + int *piNames,
  393. + int iNumNames,
  394. + int *piStrides,
  395. + int *piOffsets,
  396. + void *pvLoaderPrivate);
  397. + __DRIimage *(*FromPlanar)(__DRIimage *psImage,
  398. + int iPlane,
  399. + void *pvLoaderPrivate);
  400. +
  401. + __DRIimage *(*CreateImageFromTexture)
  402. + (struct DRISUPContext *psDRISUPContext,
  403. + int iTarget,
  404. + unsigned int uTexture,
  405. + int iDepth,
  406. + int iLevel,
  407. + unsigned int *puError,
  408. + void *pvLoaderPrivate);
  409. +
  410. + __DRIimage *(*CreateImageFromFDs)
  411. + (struct DRISUPScreen *psDRISUPcreen,
  412. + int iWidth,
  413. + int iHeight,
  414. + int iFourCC,
  415. + int *piFDs,
  416. + int iNumFDs,
  417. + int *piStrides,
  418. + int *piOffsets,
  419. + void *pvLoaderPrivate);
  420. +
  421. + __DRIimage *(*CreateImageFromDMABufs)
  422. + (struct DRISUPScreen *psDRISUPScreen,
  423. + int iWidth,
  424. + int iHeight,
  425. + int iFourCC,
  426. + int *piFDs,
  427. + int iNumFDs,
  428. + int *piStrides,
  429. + int *piOffsets,
  430. + unsigned int uColorSpace,
  431. + unsigned int uSampleRange,
  432. + unsigned int uHorizSiting,
  433. + unsigned int uVertSiting,
  434. + unsigned int *puError,
  435. + void *pvLoaderPrivate);
  436. +
  437. + int (*GetImageCapabilities)
  438. + (struct DRISUPScreen *psDRISUPScreen);
  439. +
  440. + void (*BlitImage)
  441. + (struct DRISUPContext *psDRISUPContext,
  442. + __DRIimage *psDst,
  443. + __DRIimage *psSrc,
  444. + int iDstX0,
  445. + int iDstY0,
  446. + int iDstWidth,
  447. + int iDstHeight,
  448. + int iSrcX0, int
  449. + iSrcY0,
  450. + int iSrcWidth,
  451. + int iSrcHeight,
  452. + int iFlushFlag);
  453. +
  454. + void *(*MapImage)
  455. + (struct DRISUPContext *psDRISUPContext,
  456. + __DRIimage *psImage,
  457. + int iX0,
  458. + int iY0,
  459. + int iWidth,
  460. + int iHeight,
  461. + unsigned int uFlags,
  462. + int *piStride,
  463. + void **ppvData);
  464. +
  465. + void (*UnmapImage)
  466. + (struct DRISUPContext *psDRISUPContext,
  467. + __DRIimage *psImage,
  468. + void *pvData);
  469. +
  470. + __DRIimage *(*CreateImageWithModifiers)
  471. + (struct DRISUPScreen *psDRISUPScreen,
  472. + int iWidth,
  473. + int iHeight,
  474. + int iFourCC,
  475. + const uint64_t *puModifiers,
  476. + const unsigned int uModifierCount,
  477. + void *pvLoaderPrivate);
  478. +
  479. + __DRIimage *(*CreateImageFromDMABufs2)
  480. + (struct DRISUPScreen *psDRISUPScreen,
  481. + int iWidth,
  482. + int iHeight,
  483. + int iFourCC,
  484. + uint64_t uModifier,
  485. + int *piFDs,
  486. + int iNumFDs,
  487. + int *piStrides,
  488. + int *piOffsets,
  489. + unsigned int uColorSpace,
  490. + unsigned int uSampleRange,
  491. + unsigned int uHorizSiting,
  492. + unsigned int uVertSiting,
  493. + unsigned int *puError,
  494. + void *pvLoaderPrivate);
  495. +
  496. + bool (*QueryDMABufFormats)
  497. + (struct DRISUPScreen *psDRISUPScreen,
  498. + int iMax,
  499. + int *piFormats,
  500. + int *piCount);
  501. +
  502. + bool (*QueryDMABufModifiers)
  503. + (struct DRISUPScreen *psDRISUPScreen,
  504. + int iFourCC,
  505. + int iMax,
  506. + uint64_t *puModifiers,
  507. + unsigned int *piExternalOnly,
  508. + int *piCount);
  509. +
  510. + bool (*QueryDMABufFormatModifierAttribs)
  511. + (struct DRISUPScreen *psDRISUPScreen,
  512. + uint32_t uFourcc,
  513. + uint64_t uModifier,
  514. + int iAttrib,
  515. + uint64_t *puValue);
  516. +
  517. + __DRIimage *(*CreateImageFromRenderBuffer2)
  518. + (struct DRISUPContext *psDRISUPContext,
  519. + int iRenderBuffer,
  520. + void *pvLoaderPrivate,
  521. + unsigned int *puError);
  522. +
  523. + __DRIimage *(*CreateImageFromBuffer)
  524. + (struct DRISUPContext *psDRISUPContext,
  525. + int iTarget,
  526. + void *pvBuffer,
  527. + unsigned int *puError,
  528. + void *pvLoaderPrivate);
  529. +
  530. + /* Functions to support the DRI Renderer Query extension */
  531. + int (*QueryRendererInteger)
  532. + (struct DRISUPScreen *psDRISUPScreen,
  533. + int iAttribute,
  534. + unsigned int *puValue);
  535. +
  536. + int (*QueryRendererString)
  537. + (struct DRISUPScreen *psDRISUPScreen,
  538. + int iAttribute,
  539. + const char **ppszValue);
  540. +
  541. + /* Functions to support the DRI Fence extension */
  542. + void *(*CreateFence)
  543. + (struct DRISUPContext *psDRISUPContext);
  544. +
  545. + void (*DestroyFence)
  546. + (struct DRISUPScreen *psDRISUPScreen,
  547. + void *pvFence);
  548. +
  549. + bool (*ClientWaitSync)
  550. + (struct DRISUPContext *psDRISUPContext,
  551. + void *pvFence,
  552. + unsigned int uFlags,
  553. + uint64_t uTimeout);
  554. +
  555. + void (*ServerWaitSync)
  556. + (struct DRISUPContext *psDRISUPContext,
  557. + void *pvFence,
  558. + unsigned int uFlags);
  559. +
  560. + unsigned int (*GetFenceCapabilities)
  561. + (struct DRISUPScreen *psDRISUPScreen);
  562. +
  563. + void *(*CreateFenceFD)
  564. + (struct DRISUPContext *psDRISUPContext,
  565. + int iFD);
  566. +
  567. + int (*GetFenceFD)
  568. + (struct DRISUPScreen *psDRISUPScreen,
  569. + void *pvFence);
  570. +
  571. + unsigned int (*GetNumAPIProcs)
  572. + (struct DRISUPScreen *psDRISUPScreen,
  573. + PVRDRIAPIType eAPI);
  574. +
  575. + const char *(*GetAPIProcName)
  576. + (struct DRISUPScreen *psDRISUPScreen,
  577. + PVRDRIAPIType eAPI,
  578. + unsigned int uIndex);
  579. +
  580. + void *(*GetAPIProcAddress)
  581. + (struct DRISUPScreen *psDRISUPScreen,
  582. + PVRDRIAPIType eAPI,
  583. + unsigned int uIndex);
  584. +
  585. + void (*SetDamageRegion)
  586. + (struct DRISUPDrawable *psDRISUPDrawable,
  587. + unsigned int uNRects,
  588. + int *piRects);
  589. + } v0;
  590. + /* The v1 interface is an extension of v0, so v0 is required as well */
  591. + struct {
  592. + void *(*GetFenceFromCLEvent)
  593. + (struct DRISUPScreen *psDRISUPScreen,
  594. + intptr_t iCLEvent);
  595. + } v1;
  596. + /* The v2 interface is an extension of v1, so v1 is required as well */
  597. + struct {
  598. + int (*GetAPIVersion)
  599. + (struct DRISUPScreen *psDRISUPScreen,
  600. + PVRDRIAPIType eAPI);
  601. + } v2;
  602. + /*
  603. + * The v3 interface has no additional entry points. It indicates that
  604. + * OpenCL event based fences are available, provided the DDK is built
  605. + * with OpenCL support.
  606. + */
  607. + /* The v4 interface is an extension of v3, so v3 is required as well */
  608. + struct {
  609. + bool (*HaveGetFenceFromCLEvent)(void);
  610. + } v4;
  611. +};
  612. +
  613. +struct PVRDRIImageList {
  614. + uint32_t uImageMask;
  615. + __DRIimage *psBack;
  616. + __DRIimage *psFront;
  617. + __DRIimage *psPrev;
  618. +};
  619. +
  620. +/*
  621. + * PVR DRI Support callback interface V2.
  622. + * This structure may change over time, as older interfaces become obsolete.
  623. + * For example, the v0 interface may be removed if superseded by newer
  624. + * interfaces.
  625. + */
  626. +struct PVRDRICallbacksV2
  627. +{
  628. + struct {
  629. + bool (*RegisterSupportInterface)
  630. + (const void *psInterface,
  631. + unsigned int uVersion,
  632. + unsigned int uMinVersion);
  633. +
  634. + int (*GetBuffers)
  635. + (struct __DRIdrawableRec *psDRIDrawable,
  636. + unsigned int uFourCC,
  637. + uint32_t *puStamp,
  638. + void *pvLoaderPrivate,
  639. + uint32_t uBufferMask,
  640. + struct PVRDRIImageList *psImageList);
  641. +
  642. + bool (*CreateConfigs)
  643. + (struct __DRIconfigRec ***pppsConfigs,
  644. + struct __DRIscreenRec *psDRIScreen,
  645. + int iPVRDRIMesaFormat,
  646. + const uint8_t *puDepthBits,
  647. + const uint8_t *puStencilBits,
  648. + unsigned int uNumDepthStencilBits,
  649. + const unsigned int *puDBModes,
  650. + unsigned int uNumDBModes,
  651. + const uint8_t *puMSAASamples,
  652. + unsigned int uNumMSAAModes,
  653. + bool bEnableAccum,
  654. + bool bColorDepthMatch,
  655. + bool bMutableRenderBuffer,
  656. + int iYUVDepthRange,
  657. + int iYUVCSCStandard,
  658. + uint32_t uMaxPbufferWidth,
  659. + uint32_t uMaxPbufferHeight);
  660. +
  661. + struct __DRIconfigRec **(*ConcatConfigs)
  662. + (struct __DRIscreenRec *psDRIScreen,
  663. + struct __DRIconfigRec **ppsConfigA,
  664. + struct __DRIconfigRec **ppsConfigB);
  665. +
  666. + bool (*ConfigQuery)
  667. + (const PVRDRIConfig *psConfig,
  668. + PVRDRIConfigAttrib eConfigAttrib,
  669. + unsigned int *puValueOut);
  670. +
  671. + __DRIimage *(*LookupEGLImage)
  672. + (struct __DRIscreenRec *psDRIScreen,
  673. + void *pvImage,
  674. + void *pvLoaderPrivate);
  675. +
  676. + unsigned int (*GetCapability)
  677. + (struct __DRIscreenRec *psDRIScreen,
  678. + unsigned int uCapability);
  679. + } v0;
  680. + /* The v1 interface is an extension of v0, so v0 is required as well */
  681. + struct {
  682. + void (*FlushFrontBuffer)
  683. + (struct __DRIdrawableRec *psDRIDrawable,
  684. + void *pvLoaderPrivate);
  685. + } v1;
  686. + /* The v2 interface is an extension of v1, so v1 is required as well */
  687. + struct {
  688. + int (*GetDisplayFD)
  689. + (struct __DRIscreenRec *psDRIScreen,
  690. + void *pvLoaderPrivate);
  691. + } v2;
  692. + /* The v3 interface is an extension of v2, so v2 is required as well */
  693. + struct {
  694. + void *(*DrawableGetReferenceHandle)
  695. + (struct __DRIdrawableRec *psDRIDrawable);
  696. +
  697. + void (*DrawableAddReference)
  698. + (void *pvReferenceHandle);
  699. +
  700. + void (*DrawableRemoveReference)
  701. + (void *pvReferenceHandle);
  702. + } v3;
  703. +};
  704. +
  705. +#endif /* defined(__PVRDRIIFCE_H__) */
  706. diff --git a/src/mesa/drivers/dri/pvr/img_drm_fourcc.h b/src/mesa/drivers/dri/pvr/img_drm_fourcc.h
  707. new file mode 100644
  708. index 0000000..8d570ff
  709. --- /dev/null
  710. +++ b/src/mesa/drivers/dri/pvr/img_drm_fourcc.h
  711. @@ -0,0 +1,113 @@
  712. +/*************************************************************************/ /*!
  713. +@File
  714. +@Title Wrapper around drm_fourcc.h
  715. +@Description FourCCs and DRM framebuffer modifiers that are not in the
  716. + Kernel's and libdrm's drm_fourcc.h can be added here.
  717. +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  718. +@License MIT
  719. +
  720. +The contents of this file are subject to the MIT license as set out below.
  721. +
  722. +Permission is hereby granted, free of charge, to any person obtaining a copy
  723. +of this software and associated documentation files (the "Software"), to deal
  724. +in the Software without restriction, including without limitation the rights
  725. +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  726. +copies of the Software, and to permit persons to whom the Software is
  727. +furnished to do so, subject to the following conditions:
  728. +
  729. +The above copyright notice and this permission notice shall be included in
  730. +all copies or substantial portions of the Software.
  731. +
  732. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  733. +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  734. +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  735. +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  736. +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  737. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  738. +THE SOFTWARE.
  739. +*/ /**************************************************************************/
  740. +
  741. +#ifndef IMG_DRM_FOURCC_H
  742. +#define IMG_DRM_FOURCC_H
  743. +
  744. +#if defined(__KERNEL__)
  745. +#include <drm/drm_fourcc.h>
  746. +#else
  747. +/*
  748. + * Include types.h to workaround versions of libdrm older than 2.4.68
  749. + * not including the correct headers.
  750. + */
  751. +#include <linux/types.h>
  752. +
  753. +#include <drm_fourcc.h>
  754. +#endif
  755. +
  756. +/*
  757. + * Don't get too inspired by this example :)
  758. + * ADF doesn't support DRM modifiers, so the memory layout had to be
  759. + * included in the fourcc name, but the proper way to specify information
  760. + * additional to pixel formats is to use DRM modifiers.
  761. + *
  762. + * See upstream drm_fourcc.h for the proper naming convention.
  763. + */
  764. +#ifndef DRM_FORMAT_BGRA8888_DIRECT_16x4
  765. +#define DRM_FORMAT_BGRA8888_DIRECT_16x4 fourcc_code('I', 'M', 'G', '0')
  766. +#endif
  767. +
  768. +/*
  769. + * Upstream doesn't have a floating point format yet, so let's make one
  770. + * up.
  771. + * Note: The kernel's core DRM needs to know about this format,
  772. + * otherwise it won't be supported and should not be exposed by our
  773. + * kernel modules either.
  774. + * Refer to the provided kernel patch adding this format.
  775. + */
  776. +#if !defined(__KERNEL__)
  777. +#define DRM_FORMAT_ABGR16_IMG fourcc_code('I', 'M', 'G', '1')
  778. +#endif
  779. +
  780. +/*
  781. + * Upstream does not have a packed 10 Bits Per Channel YVU format yet,
  782. + * so let`s make one up.
  783. + * Note: at the moment this format is not intended to be used with
  784. + * a framebuffer, so the kernels core DRM doesn`t need to know
  785. + * about this format. This means that the kernel doesn`t need
  786. + * to be patched.
  787. + */
  788. +#if !defined(__KERNEL__)
  789. +#define DRM_FORMAT_YVU444_PACK10_IMG fourcc_code('I', 'M', 'G', '2')
  790. +#define DRM_FORMAT_YUV422_2PLANE_PACK10_IMG fourcc_code('I', 'M', 'G', '3')
  791. +#define DRM_FORMAT_YUV420_2PLANE_PACK10_IMG fourcc_code('I', 'M', 'G', '4')
  792. +#endif
  793. +
  794. +/*
  795. + * Value chosen in the middle of 255 pool to minimise the chance of hitting
  796. + * the same value potentially defined by other vendors in the drm_fourcc.h
  797. + */
  798. +#define DRM_FORMAT_MOD_VENDOR_PVR 0x92
  799. +
  800. +#ifndef DRM_FORMAT_MOD_VENDOR_NONE
  801. +#define DRM_FORMAT_MOD_VENDOR_NONE 0
  802. +#endif
  803. +
  804. +#ifndef DRM_FORMAT_RESERVED
  805. +#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1)
  806. +#endif
  807. +
  808. +#ifndef fourcc_mod_code
  809. +#define fourcc_mod_code(vendor, val) \
  810. + ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL))
  811. +#endif
  812. +
  813. +#ifndef DRM_FORMAT_MOD_INVALID
  814. +#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED)
  815. +#endif
  816. +
  817. +#ifndef DRM_FORMAT_MOD_LINEAR
  818. +#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)
  819. +#endif
  820. +
  821. +#define DRM_FORMAT_MOD_PVR_FBCDC_8x8_V7 fourcc_mod_code(PVR, 6)
  822. +#define DRM_FORMAT_MOD_PVR_FBCDC_16x4_V7 fourcc_mod_code(PVR, 12)
  823. +
  824. +#endif /* IMG_DRM_FOURCC_H */
  825. diff --git a/src/mesa/drivers/dri/pvr/imgpixfmts.h b/src/mesa/drivers/dri/pvr/imgpixfmts.h
  826. new file mode 100644
  827. index 0000000..da12a0f
  828. --- /dev/null
  829. +++ b/src/mesa/drivers/dri/pvr/imgpixfmts.h
  830. @@ -0,0 +1,307 @@
  831. +/*************************************************************************/ /*!
  832. +@File imgpixfmts.h
  833. +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  834. +@License MIT
  835. +
  836. +The contents of this file are subject to the MIT license as set out below.
  837. +
  838. +Permission is hereby granted, free of charge, to any person obtaining a copy
  839. +of this software and associated documentation files (the "Software"), to deal
  840. +in the Software without restriction, including without limitation the rights
  841. +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  842. +copies of the Software, and to permit persons to whom the Software is
  843. +furnished to do so, subject to the following conditions:
  844. +
  845. +The above copyright notice and this permission notice shall be included in
  846. +all copies or substantial portions of the Software.
  847. +
  848. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  849. +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  850. +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  851. +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  852. +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  853. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  854. +THE SOFTWARE.
  855. +*/ /**************************************************************************/
  856. +
  857. +/******************************************************************************
  858. + **
  859. + ** WARNING: File is autogenerated by parsesystable.py - DO NOT EDIT.
  860. + ** Use fmts_systable.txt to add new formats.
  861. + **
  862. + *****************************************************************************/
  863. +
  864. +#if !defined(IMGPIXFMTS_H)
  865. +#define IMGPIXFMTS_H
  866. +
  867. +typedef enum _IMG_PIXFMT_
  868. +{
  869. + IMG_PIXFMT_UNKNOWN = 0,
  870. + IMG_PIXFMT_RESERVED_1 = 1,
  871. + IMG_PIXFMT_RESERVED_2 = 2,
  872. + IMG_PIXFMT_RESERVED_3 = 3,
  873. + IMG_PIXFMT_RESERVED_4 = 4,
  874. + IMG_PIXFMT_RESERVED_5 = 5,
  875. + IMG_PIXFMT_RESERVED_6 = 6,
  876. + IMG_PIXFMT_RESERVED_7 = 7,
  877. + IMG_PIXFMT_RESERVED_8 = 8,
  878. + IMG_PIXFMT_RESERVED_9 = 9,
  879. + IMG_PIXFMT_RESERVED_10 = 10,
  880. + IMG_PIXFMT_RESERVED_11 = 11,
  881. + IMG_PIXFMT_RESERVED_12 = 12,
  882. + IMG_PIXFMT_RESERVED_13 = 13,
  883. + IMG_PIXFMT_RESERVED_14 = 14,
  884. + IMG_PIXFMT_RESERVED_15 = 15,
  885. + IMG_PIXFMT_RESERVED_16 = 16,
  886. + IMG_PIXFMT_RESERVED_17 = 17,
  887. + IMG_PIXFMT_RESERVED_18 = 18,
  888. + IMG_PIXFMT_RESERVED_19 = 19,
  889. + IMG_PIXFMT_RESERVED_20 = 20,
  890. + IMG_PIXFMT_RESERVED_21 = 21,
  891. + IMG_PIXFMT_RESERVED_22 = 22,
  892. + IMG_PIXFMT_RESERVED_23 = 23,
  893. + IMG_PIXFMT_RESERVED_24 = 24,
  894. + IMG_PIXFMT_R10G10B10A2_UNORM = 25,
  895. + IMG_PIXFMT_RESERVED_26 = 26,
  896. + IMG_PIXFMT_RESERVED_27 = 27,
  897. + IMG_PIXFMT_B10G10R10A2_UNORM = 28,
  898. + IMG_PIXFMT_RESERVED_29 = 29,
  899. + IMG_PIXFMT_RESERVED_30 = 30,
  900. + IMG_PIXFMT_RESERVED_31 = 31,
  901. + IMG_PIXFMT_R8G8B8A8_UNORM = 32,
  902. + IMG_PIXFMT_R8G8B8A8_UNORM_SRGB = 33,
  903. + IMG_PIXFMT_RESERVED_34 = 34,
  904. + IMG_PIXFMT_RESERVED_35 = 35,
  905. + IMG_PIXFMT_RESERVED_36 = 36,
  906. + IMG_PIXFMT_R8G8B8X8_UNORM = 37,
  907. + IMG_PIXFMT_RESERVED_38 = 38,
  908. + IMG_PIXFMT_RESERVED_39 = 39,
  909. + IMG_PIXFMT_RESERVED_40 = 40,
  910. + IMG_PIXFMT_RESERVED_41 = 41,
  911. + IMG_PIXFMT_RESERVED_42 = 42,
  912. + IMG_PIXFMT_RESERVED_43 = 43,
  913. + IMG_PIXFMT_RESERVED_44 = 44,
  914. + IMG_PIXFMT_RESERVED_45 = 45,
  915. + IMG_PIXFMT_RESERVED_46 = 46,
  916. + IMG_PIXFMT_RESERVED_47 = 47,
  917. + IMG_PIXFMT_RESERVED_48 = 48,
  918. + IMG_PIXFMT_RESERVED_49 = 49,
  919. + IMG_PIXFMT_RESERVED_50 = 50,
  920. + IMG_PIXFMT_D32_FLOAT = 51,
  921. + IMG_PIXFMT_RESERVED_52 = 52,
  922. + IMG_PIXFMT_RESERVED_53 = 53,
  923. + IMG_PIXFMT_RESERVED_54 = 54,
  924. + IMG_PIXFMT_RESERVED_55 = 55,
  925. + IMG_PIXFMT_RESERVED_56 = 56,
  926. + IMG_PIXFMT_RESERVED_57 = 57,
  927. + IMG_PIXFMT_D24_UNORM_X8_TYPELESS = 58,
  928. + IMG_PIXFMT_RESERVED_59 = 59,
  929. + IMG_PIXFMT_RESERVED_60 = 60,
  930. + IMG_PIXFMT_RESERVED_61 = 61,
  931. + IMG_PIXFMT_R8G8_UNORM = 62,
  932. + IMG_PIXFMT_RESERVED_63 = 63,
  933. + IMG_PIXFMT_RESERVED_64 = 64,
  934. + IMG_PIXFMT_RESERVED_65 = 65,
  935. + IMG_PIXFMT_RESERVED_66 = 66,
  936. + IMG_PIXFMT_RESERVED_67 = 67,
  937. + IMG_PIXFMT_RESERVED_68 = 68,
  938. + IMG_PIXFMT_D16_UNORM = 69,
  939. + IMG_PIXFMT_RESERVED_70 = 70,
  940. + IMG_PIXFMT_RESERVED_71 = 71,
  941. + IMG_PIXFMT_RESERVED_72 = 72,
  942. + IMG_PIXFMT_RESERVED_73 = 73,
  943. + IMG_PIXFMT_RESERVED_74 = 74,
  944. + IMG_PIXFMT_RESERVED_75 = 75,
  945. + IMG_PIXFMT_R8_UNORM = 76,
  946. + IMG_PIXFMT_RESERVED_77 = 77,
  947. + IMG_PIXFMT_RESERVED_78 = 78,
  948. + IMG_PIXFMT_RESERVED_79 = 79,
  949. + IMG_PIXFMT_RESERVED_80 = 80,
  950. + IMG_PIXFMT_S8_UINT = 81,
  951. + IMG_PIXFMT_RESERVED_82 = 82,
  952. + IMG_PIXFMT_RESERVED_83 = 83,
  953. + IMG_PIXFMT_RESERVED_84 = 84,
  954. + IMG_PIXFMT_B5G6R5_UNORM = 85,
  955. + IMG_PIXFMT_R5G6B5_UNORM = 86,
  956. + IMG_PIXFMT_B5G5R5A1_UNORM = 87,
  957. + IMG_PIXFMT_B5G5R5X1_UNORM = 88,
  958. + IMG_PIXFMT_B8G8R8A8_UNORM = 89,
  959. + IMG_PIXFMT_B8G8R8X8_UNORM = 90,
  960. + IMG_PIXFMT_B8G8R8A8_UINT = 91,
  961. + IMG_PIXFMT_B8G8R8A8_SNORM = 92,
  962. + IMG_PIXFMT_B8G8R8A8_SINT = 93,
  963. + IMG_PIXFMT_B8G8R8A8_UNORM_SRGB = 94,
  964. + IMG_PIXFMT_RESERVED_95 = 95,
  965. + IMG_PIXFMT_RESERVED_96 = 96,
  966. + IMG_PIXFMT_RESERVED_97 = 97,
  967. + IMG_PIXFMT_RESERVED_98 = 98,
  968. + IMG_PIXFMT_RESERVED_99 = 99,
  969. + IMG_PIXFMT_RESERVED_100 = 100,
  970. + IMG_PIXFMT_RESERVED_101 = 101,
  971. + IMG_PIXFMT_RESERVED_102 = 102,
  972. + IMG_PIXFMT_RESERVED_103 = 103,
  973. + IMG_PIXFMT_RESERVED_104 = 104,
  974. + IMG_PIXFMT_RESERVED_105 = 105,
  975. + IMG_PIXFMT_RESERVED_106 = 106,
  976. + IMG_PIXFMT_RESERVED_107 = 107,
  977. + IMG_PIXFMT_RESERVED_108 = 108,
  978. + IMG_PIXFMT_RESERVED_109 = 109,
  979. + IMG_PIXFMT_RESERVED_110 = 110,
  980. + IMG_PIXFMT_RESERVED_111 = 111,
  981. + IMG_PIXFMT_RESERVED_112 = 112,
  982. + IMG_PIXFMT_RESERVED_113 = 113,
  983. + IMG_PIXFMT_RESERVED_114 = 114,
  984. + IMG_PIXFMT_RESERVED_115 = 115,
  985. + IMG_PIXFMT_RESERVED_116 = 116,
  986. + IMG_PIXFMT_RESERVED_117 = 117,
  987. + IMG_PIXFMT_RESERVED_118 = 118,
  988. + IMG_PIXFMT_RESERVED_119 = 119,
  989. + IMG_PIXFMT_RESERVED_120 = 120,
  990. + IMG_PIXFMT_RESERVED_121 = 121,
  991. + IMG_PIXFMT_RESERVED_122 = 122,
  992. + IMG_PIXFMT_RESERVED_123 = 123,
  993. + IMG_PIXFMT_RESERVED_124 = 124,
  994. + IMG_PIXFMT_RESERVED_125 = 125,
  995. + IMG_PIXFMT_RESERVED_126 = 126,
  996. + IMG_PIXFMT_RESERVED_127 = 127,
  997. + IMG_PIXFMT_RESERVED_128 = 128,
  998. + IMG_PIXFMT_RESERVED_129 = 129,
  999. + IMG_PIXFMT_RESERVED_130 = 130,
  1000. + IMG_PIXFMT_RESERVED_131 = 131,
  1001. + IMG_PIXFMT_RESERVED_132 = 132,
  1002. + IMG_PIXFMT_RESERVED_133 = 133,
  1003. + IMG_PIXFMT_RESERVED_134 = 134,
  1004. + IMG_PIXFMT_RESERVED_135 = 135,
  1005. + IMG_PIXFMT_L8_UNORM = 136,
  1006. + IMG_PIXFMT_RESERVED_137 = 137,
  1007. + IMG_PIXFMT_L8A8_UNORM = 138,
  1008. + IMG_PIXFMT_RESERVED_139 = 139,
  1009. + IMG_PIXFMT_RESERVED_140 = 140,
  1010. + IMG_PIXFMT_RESERVED_141 = 141,
  1011. + IMG_PIXFMT_RESERVED_142 = 142,
  1012. + IMG_PIXFMT_RESERVED_143 = 143,
  1013. + IMG_PIXFMT_RESERVED_144 = 144,
  1014. + IMG_PIXFMT_B4G4R4A4_UNORM = 145,
  1015. + IMG_PIXFMT_RESERVED_146 = 146,
  1016. + IMG_PIXFMT_RESERVED_147 = 147,
  1017. + IMG_PIXFMT_RESERVED_148 = 148,
  1018. + IMG_PIXFMT_RESERVED_149 = 149,
  1019. + IMG_PIXFMT_RESERVED_150 = 150,
  1020. + IMG_PIXFMT_RESERVED_151 = 151,
  1021. + IMG_PIXFMT_RESERVED_152 = 152,
  1022. + IMG_PIXFMT_RESERVED_153 = 153,
  1023. + IMG_PIXFMT_RESERVED_154 = 154,
  1024. + IMG_PIXFMT_RESERVED_155 = 155,
  1025. + IMG_PIXFMT_RESERVED_156 = 156,
  1026. + IMG_PIXFMT_RESERVED_157 = 157,
  1027. + IMG_PIXFMT_RESERVED_158 = 158,
  1028. + IMG_PIXFMT_RESERVED_159 = 159,
  1029. + IMG_PIXFMT_R8G8B8_UNORM = 160,
  1030. + IMG_PIXFMT_R8G8B8_UNORM_SRGB = 161,
  1031. + IMG_PIXFMT_RESERVED_162 = 162,
  1032. + IMG_PIXFMT_RESERVED_163 = 163,
  1033. + IMG_PIXFMT_RESERVED_164 = 164,
  1034. + IMG_PIXFMT_RESERVED_165 = 165,
  1035. + IMG_PIXFMT_RESERVED_166 = 166,
  1036. + IMG_PIXFMT_RESERVED_167 = 167,
  1037. + IMG_PIXFMT_RESERVED_168 = 168,
  1038. + IMG_PIXFMT_RESERVED_169 = 169,
  1039. + IMG_PIXFMT_RESERVED_170 = 170,
  1040. + IMG_PIXFMT_UYVY = 171,
  1041. + IMG_PIXFMT_VYUY = 172,
  1042. + IMG_PIXFMT_YUYV = 173,
  1043. + IMG_PIXFMT_YVYU = 174,
  1044. + IMG_PIXFMT_YVU420_2PLANE = 175,
  1045. + IMG_PIXFMT_YUV420_2PLANE = 176,
  1046. + IMG_PIXFMT_YVU420_2PLANE_MACRO_BLOCK = 177,
  1047. + IMG_PIXFMT_YUV420_3PLANE = 178,
  1048. + IMG_PIXFMT_YVU420_3PLANE = 179,
  1049. + IMG_PIXFMT_RESERVED_180 = 180,
  1050. + IMG_PIXFMT_RESERVED_181 = 181,
  1051. + IMG_PIXFMT_RESERVED_182 = 182,
  1052. + IMG_PIXFMT_RESERVED_183 = 183,
  1053. + IMG_PIXFMT_RESERVED_184 = 184,
  1054. + IMG_PIXFMT_RESERVED_185 = 185,
  1055. + IMG_PIXFMT_RESERVED_186 = 186,
  1056. + IMG_PIXFMT_RESERVED_187 = 187,
  1057. + IMG_PIXFMT_RESERVED_188 = 188,
  1058. + IMG_PIXFMT_RESERVED_189 = 189,
  1059. + IMG_PIXFMT_RESERVED_190 = 190,
  1060. + IMG_PIXFMT_RESERVED_191 = 191,
  1061. + IMG_PIXFMT_RESERVED_192 = 192,
  1062. + IMG_PIXFMT_RESERVED_193 = 193,
  1063. + IMG_PIXFMT_RESERVED_194 = 194,
  1064. + IMG_PIXFMT_RESERVED_195 = 195,
  1065. + IMG_PIXFMT_RESERVED_196 = 196,
  1066. + IMG_PIXFMT_RESERVED_197 = 197,
  1067. + IMG_PIXFMT_RESERVED_198 = 198,
  1068. + IMG_PIXFMT_RESERVED_199 = 199,
  1069. + IMG_PIXFMT_RESERVED_200 = 200,
  1070. + IMG_PIXFMT_YVU8_422_2PLANE_PACK8 = 201,
  1071. + IMG_PIXFMT_RESERVED_202 = 202,
  1072. + IMG_PIXFMT_YVU10_444_1PLANE_PACK10 = 203,
  1073. + IMG_PIXFMT_RESERVED_204 = 204,
  1074. + IMG_PIXFMT_RESERVED_205 = 205,
  1075. + IMG_PIXFMT_RESERVED_206 = 206,
  1076. + IMG_PIXFMT_YUV8_422_2PLANE_PACK8 = 207,
  1077. + IMG_PIXFMT_YUV8_444_3PLANE_PACK8 = 208,
  1078. + IMG_PIXFMT_RESERVED_209 = 209,
  1079. + IMG_PIXFMT_RESERVED_210 = 210,
  1080. + IMG_PIXFMT_RESERVED_211 = 211,
  1081. + IMG_PIXFMT_RESERVED_212 = 212,
  1082. + IMG_PIXFMT_RESERVED_213 = 213,
  1083. + IMG_PIXFMT_RESERVED_214 = 214,
  1084. + IMG_PIXFMT_RESERVED_215 = 215,
  1085. + IMG_PIXFMT_RESERVED_216 = 216,
  1086. + IMG_PIXFMT_RESERVED_217 = 217,
  1087. + IMG_PIXFMT_RESERVED_218 = 218,
  1088. + IMG_PIXFMT_RESERVED_219 = 219,
  1089. + IMG_PIXFMT_RESERVED_220 = 220,
  1090. + IMG_PIXFMT_RESERVED_221 = 221,
  1091. + IMG_PIXFMT_RESERVED_222 = 222,
  1092. + IMG_PIXFMT_RESERVED_223 = 223,
  1093. + IMG_PIXFMT_RESERVED_224 = 224,
  1094. + IMG_PIXFMT_RESERVED_225 = 225,
  1095. + IMG_PIXFMT_RESERVED_226 = 226,
  1096. + IMG_PIXFMT_RESERVED_227 = 227,
  1097. + IMG_PIXFMT_RESERVED_228 = 228,
  1098. + IMG_PIXFMT_RESERVED_229 = 229,
  1099. + IMG_PIXFMT_RESERVED_230 = 230,
  1100. + IMG_PIXFMT_RESERVED_231 = 231,
  1101. + IMG_PIXFMT_RESERVED_232 = 232,
  1102. + IMG_PIXFMT_RESERVED_233 = 233,
  1103. + IMG_PIXFMT_RESERVED_234 = 234,
  1104. + IMG_PIXFMT_RESERVED_235 = 235,
  1105. + IMG_PIXFMT_RESERVED_236 = 236,
  1106. + IMG_PIXFMT_RESERVED_237 = 237,
  1107. + IMG_PIXFMT_RESERVED_238 = 238,
  1108. + IMG_PIXFMT_RESERVED_239 = 239,
  1109. + IMG_PIXFMT_RESERVED_240 = 240,
  1110. + IMG_PIXFMT_RESERVED_241 = 241,
  1111. + IMG_PIXFMT_RESERVED_242 = 242,
  1112. + IMG_PIXFMT_RESERVED_243 = 243,
  1113. + IMG_PIXFMT_RESERVED_244 = 244,
  1114. + IMG_PIXFMT_YVU8_420_2PLANE_PACK8_P = 245,
  1115. + IMG_PIXFMT_RESERVED_246 = 246,
  1116. + IMG_PIXFMT_RESERVED_247 = 247,
  1117. + IMG_PIXFMT_RESERVED_248 = 248,
  1118. + IMG_PIXFMT_YUV8_420_2PLANE_PACK8_P = 249,
  1119. + IMG_PIXFMT_RESERVED_250 = 250,
  1120. + IMG_PIXFMT_RESERVED_251 = 251,
  1121. + IMG_PIXFMT_UYVY10_422_1PLANE_PACK10_CUST1 = 252,
  1122. + IMG_PIXFMT_RESERVED_253 = 253,
  1123. + IMG_PIXFMT_RESERVED_254 = 254,
  1124. + IMG_PIXFMT_RESERVED_255 = 255,
  1125. + IMG_PIXFMT_RESERVED_256 = 256,
  1126. + IMG_PIXFMT_RESERVED_257 = 257,
  1127. + IMG_PIXFMT_RESERVED_258 = 258,
  1128. + IMG_PIXFMT_RESERVED_259 = 259,
  1129. + IMG_PIXFMT_RESERVED_260 = 260,
  1130. + IMG_PIXFMT_RESERVED_261 = 261,
  1131. + IMG_PIXFMT_RESERVED_262 = 262,
  1132. + IMG_PIXFMT_RESERVED_263 = 263,
  1133. + IMG_PIXFMT_RESERVED_264 = 264,
  1134. +#define IMG_PIXFMT_ENUM_COUNT 265
  1135. +} IMG_PIXFMT;
  1136. +
  1137. +#endif /* IMGPIXFMTS_H */
  1138. diff --git a/src/mesa/drivers/dri/pvr/imgyuv.h b/src/mesa/drivers/dri/pvr/imgyuv.h
  1139. new file mode 100644
  1140. index 0000000..7ae8fd1
  1141. --- /dev/null
  1142. +++ b/src/mesa/drivers/dri/pvr/imgyuv.h
  1143. @@ -0,0 +1,58 @@
  1144. +/*************************************************************************/ /*!
  1145. +@File
  1146. +@Title YUV defines
  1147. +@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  1148. +@License MIT
  1149. +
  1150. +The contents of this file are subject to the MIT license as set out below.
  1151. +
  1152. +Permission is hereby granted, free of charge, to any person obtaining a copy
  1153. +of this software and associated documentation files (the "Software"), to deal
  1154. +in the Software without restriction, including without limitation the rights
  1155. +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1156. +copies of the Software, and to permit persons to whom the Software is
  1157. +furnished to do so, subject to the following conditions:
  1158. +
  1159. +The above copyright notice and this permission notice shall be included in
  1160. +all copies or substantial portions of the Software.
  1161. +
  1162. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1163. +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1164. +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1165. +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1166. +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1167. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1168. +THE SOFTWARE.
  1169. +*/ /**************************************************************************/
  1170. +
  1171. +#if !defined(IMGYUV_H)
  1172. +#define IMGYUV_H
  1173. +
  1174. +typedef enum
  1175. +{
  1176. + IMG_COLORSPACE_UNDEFINED = 0,
  1177. + IMG_COLORSPACE_BT601_CONFORMANT_RANGE = 1,
  1178. + IMG_COLORSPACE_BT601_FULL_RANGE = 2,
  1179. + IMG_COLORSPACE_BT709_CONFORMANT_RANGE = 3,
  1180. + IMG_COLORSPACE_BT709_FULL_RANGE = 4,
  1181. + IMG_COLORSPACE_BT2020_CONFORMANT_RANGE = 5,
  1182. + IMG_COLORSPACE_BT2020_FULL_RANGE = 6,
  1183. + IMG_COLORSPACE_BT601_CONFORMANT_RANGE_INVERSE = 7,
  1184. + IMG_COLORSPACE_BT601_FULL_RANGE_INVERSE = 8,
  1185. + IMG_COLORSPACE_BT709_CONFORMANT_RANGE_INVERSE = 9,
  1186. + IMG_COLORSPACE_BT709_FULL_RANGE_INVERSE = 10,
  1187. + IMG_COLORSPACE_BT2020_CONFORMANT_RANGE_INVERSE = 11,
  1188. + IMG_COLORSPACE_BT2020_FULL_RANGE_INVERSE = 12
  1189. +} IMG_YUV_COLORSPACE;
  1190. +
  1191. +typedef enum
  1192. +{
  1193. + IMG_CHROMA_INTERP_UNDEFINED = 0,
  1194. + IMG_CHROMA_INTERP_ZERO = 1,
  1195. + IMG_CHROMA_INTERP_QUARTER = 2,
  1196. + IMG_CHROMA_INTERP_HALF = 3,
  1197. + IMG_CHROMA_INTERP_THREEQUARTERS = 4
  1198. +} IMG_YUV_CHROMA_INTERP;
  1199. +
  1200. +
  1201. +#endif /* IMGYUV_H */
  1202. diff --git a/src/mesa/drivers/dri/pvr/mesa_context.c b/src/mesa/drivers/dri/pvr/mesa_context.c
  1203. new file mode 100644
  1204. index 0000000..d36bae5
  1205. --- /dev/null
  1206. +++ b/src/mesa/drivers/dri/pvr/mesa_context.c
  1207. @@ -0,0 +1,208 @@
  1208. +/**
  1209. + * \file context.c
  1210. + * Mesa context/visual/framebuffer management functions.
  1211. + * \author Brian Paul
  1212. + */
  1213. +
  1214. +/*
  1215. + * Mesa 3-D graphics library
  1216. + * Version: 7.1
  1217. + *
  1218. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
  1219. + *
  1220. + * The contents of this file are subject to the MIT license as set out below.
  1221. + *
  1222. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  1223. + * of this software and associated documentation files (the "Software"), to deal
  1224. + * in the Software without restriction, including without limitation the rights
  1225. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1226. + * copies of the Software, and to permit persons to whom the Software is
  1227. + * furnished to do so, subject to the following conditions:
  1228. + *
  1229. + * The above copyright notice and this permission notice shall be included in
  1230. + * all copies or substantial portions of the Software.
  1231. + *
  1232. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1233. + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1234. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1235. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1236. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1237. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1238. + * THE SOFTWARE.
  1239. + */
  1240. +
  1241. +#include <stdlib.h>
  1242. +#include <assert.h>
  1243. +
  1244. +#include "main/version.h"
  1245. +#include "main/errors.h"
  1246. +
  1247. +#include "dri_support.h"
  1248. +#include "dri_util.h"
  1249. +#include "glapi.h"
  1250. +#include "dispatch.h"
  1251. +#include "pvrmesa.h"
  1252. +
  1253. +/**
  1254. + * This is the default function we plug into all dispatch table slots This
  1255. + * helps prevents a segfault when someone calls a GL function without first
  1256. + * checking if the extension is supported.
  1257. + */
  1258. +static int
  1259. +generic_nop(void)
  1260. +{
  1261. + _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)");
  1262. +
  1263. + return 0;
  1264. +}
  1265. +
  1266. +/**
  1267. + * Allocate and initialise a new dispatch table.
  1268. + */
  1269. +static struct _glapi_table *
  1270. +pvrdri_alloc_dispatch_table(void)
  1271. +{
  1272. + unsigned int numEntries = _glapi_get_dispatch_table_size();
  1273. + _glapi_proc *table;
  1274. +
  1275. + table = malloc(numEntries * sizeof(_glapi_proc));
  1276. + if (table)
  1277. + for (unsigned int i = 0; i < numEntries; i++)
  1278. + table[i] = (_glapi_proc) generic_nop;
  1279. +
  1280. + return (struct _glapi_table *) table;
  1281. +}
  1282. +
  1283. +/**
  1284. + * Return a pointer to the pointer to the dispatch table of an API in
  1285. + * PVRDRIScreen.
  1286. + */
  1287. +static struct _glapi_table **
  1288. +pvrdri_get_dispatch_table_ptr(PVRDRIScreen *psPVRScreen, PVRDRIAPIType eAPI)
  1289. +{
  1290. + switch (eAPI) {
  1291. + case PVRDRI_API_GLES1:
  1292. + return &psPVRScreen->psOGLES1Dispatch;
  1293. + case PVRDRI_API_GLES2:
  1294. + return &psPVRScreen->psOGLES2Dispatch;
  1295. + case PVRDRI_API_GL_COMPAT:
  1296. + case PVRDRI_API_GL_CORE:
  1297. + return &psPVRScreen->psOGLDispatch;
  1298. + default:
  1299. + return NULL;
  1300. + }
  1301. +}
  1302. +
  1303. +/**
  1304. + * Return a pointer to the dispatch table of an API.
  1305. + */
  1306. +static struct _glapi_table *
  1307. +pvrdri_get_dispatch_table(PVRDRIScreen *psPVRScreen, PVRDRIAPIType eAPI)
  1308. +{
  1309. + struct _glapi_table **ppsTable =
  1310. + pvrdri_get_dispatch_table_ptr(psPVRScreen, eAPI);
  1311. +
  1312. + return ppsTable ? *ppsTable : NULL;
  1313. +}
  1314. +
  1315. +/**
  1316. + * Free all dispatch tables.
  1317. + */
  1318. +void
  1319. +pvrdri_free_dispatch_tables(PVRDRIScreen *psPVRScreen)
  1320. +{
  1321. + if (psPVRScreen->psOGLES1Dispatch != NULL) {
  1322. + free(psPVRScreen->psOGLES1Dispatch);
  1323. + psPVRScreen->psOGLES1Dispatch = NULL;
  1324. + }
  1325. +
  1326. + if (psPVRScreen->psOGLES2Dispatch != NULL) {
  1327. + free(psPVRScreen->psOGLES2Dispatch);
  1328. + psPVRScreen->psOGLES2Dispatch = NULL;
  1329. + }
  1330. +
  1331. + if (psPVRScreen->psOGLDispatch != NULL) {
  1332. + free(psPVRScreen->psOGLDispatch);
  1333. + psPVRScreen->psOGLDispatch = NULL;
  1334. + }
  1335. +}
  1336. +
  1337. +static void
  1338. +pvrdri_add_mesa_dispatch(struct _glapi_table *psTable, PVRDRIAPIType eAPI,
  1339. + struct DRISUPScreen *psDRISUPScreen,
  1340. + unsigned int uIdx)
  1341. +{
  1342. + const char *asFunc[] = { NULL, NULL };
  1343. + int iOffset;
  1344. + const char *psFunc;
  1345. + _glapi_proc pfFunc;
  1346. +
  1347. + pfFunc = DRISUPGetAPIProcAddress(psDRISUPScreen, eAPI, uIdx);
  1348. + if (pfFunc == NULL)
  1349. + return;
  1350. +
  1351. + psFunc = DRISUPGetAPIProcName(psDRISUPScreen, eAPI, uIdx);
  1352. + assert(psFunc != NULL);
  1353. +
  1354. + asFunc[0] = psFunc;
  1355. + iOffset = _glapi_add_dispatch(asFunc, "");
  1356. + if (iOffset == -1) {
  1357. + _mesa_warning(NULL, "Couldn't add %s to the Mesa dispatch table",
  1358. + psFunc);
  1359. + } else {
  1360. + SET_by_offset(psTable, iOffset, pfFunc);
  1361. + }
  1362. +}
  1363. +
  1364. +static void
  1365. +pvrdri_set_mesa_dispatch(struct _glapi_table *psTable, PVRDRIAPIType eAPI,
  1366. + struct DRISUPScreen *psDRISUPScreen,
  1367. + unsigned int uNumFuncs)
  1368. +{
  1369. + for (unsigned int i = 0; i < uNumFuncs; i++)
  1370. + pvrdri_add_mesa_dispatch(psTable, eAPI, psDRISUPScreen, i);
  1371. +}
  1372. +
  1373. +bool
  1374. +pvrdri_create_dispatch_table(PVRDRIScreen *psPVRScreen, PVRDRIAPIType eAPI)
  1375. +{
  1376. + struct DRISUPScreen *psDRISUPScreen = psPVRScreen->psDRISUPScreen;
  1377. + struct _glapi_table **ppsTable;
  1378. + unsigned int uNumFuncs;
  1379. +
  1380. + ppsTable = pvrdri_get_dispatch_table_ptr(psPVRScreen, eAPI);
  1381. + if (ppsTable == NULL)
  1382. + return false;
  1383. +
  1384. + if (*ppsTable != NULL)
  1385. + return true;
  1386. +
  1387. + uNumFuncs = DRISUPGetNumAPIProcs(psDRISUPScreen, eAPI);
  1388. + if (!uNumFuncs)
  1389. + return false;
  1390. +
  1391. + *ppsTable = pvrdri_alloc_dispatch_table();
  1392. + if (*ppsTable == NULL)
  1393. + return false;
  1394. +
  1395. + pvrdri_set_mesa_dispatch(*ppsTable, eAPI, psDRISUPScreen, uNumFuncs);
  1396. +
  1397. + return true;
  1398. +}
  1399. +
  1400. +void
  1401. +pvrdri_set_null_dispatch_table(void)
  1402. +{
  1403. + _glapi_set_dispatch(NULL);
  1404. +}
  1405. +
  1406. +void
  1407. +pvrdri_set_dispatch_table(PVRDRIContext *psPVRContext)
  1408. +{
  1409. + struct _glapi_table *psTable;
  1410. +
  1411. + psTable = pvrdri_get_dispatch_table(psPVRContext->psPVRScreen,
  1412. + psPVRContext->eAPI);
  1413. +
  1414. + _glapi_set_dispatch(psTable);
  1415. +}
  1416. diff --git a/src/mesa/drivers/dri/pvr/meson.build b/src/mesa/drivers/dri/pvr/meson.build
  1417. new file mode 100644
  1418. index 0000000..59cccf8
  1419. --- /dev/null
  1420. +++ b/src/mesa/drivers/dri/pvr/meson.build
  1421. @@ -0,0 +1,48 @@
  1422. +# Copyright (c) Imagination Technologies Ltd.
  1423. +#
  1424. +# The contents of this file are subject to the MIT license as set out below.
  1425. +#
  1426. +# Permission is hereby granted, free of charge, to any person obtaining a copy
  1427. +# of this software and associated documentation files (the "Software"), to deal
  1428. +# in the Software without restriction, including without limitation the rights
  1429. +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1430. +# copies of the Software, and to permit persons to whom the Software is
  1431. +# furnished to do so, subject to the following conditions:
  1432. +#
  1433. +# The above copyright notice and this permission notice shall be included in
  1434. +# all copies or substantial portions of the Software.
  1435. +#
  1436. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1437. +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1438. +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1439. +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1440. +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1441. +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1442. +# THE SOFTWARE.
  1443. +
  1444. +files_pvr = files(
  1445. + 'mesa_context.c',
  1446. + 'pvrcb.c',
  1447. + 'pvrcompat.c',
  1448. + 'pvrdri.c',
  1449. + 'pvrext.c',
  1450. + 'pvrutil.c',
  1451. +)
  1452. +
  1453. +dep_libpvr = [
  1454. + dep_libdrm,
  1455. +]
  1456. +
  1457. +if with_platform_tizen
  1458. + dep_libpvr += dep_dlog
  1459. +endif
  1460. +
  1461. +libpvr = static_library(
  1462. + 'pvr',
  1463. + [files_pvr, main_dispatch_h],
  1464. + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa,
  1465. + inc_dri_common, inc_util, inc_pvr],
  1466. + c_args : [no_override_init_args],
  1467. + gnu_symbol_visibility : 'hidden',
  1468. + dependencies : [dep_libpvr],
  1469. +)
  1470. diff --git a/src/mesa/drivers/dri/pvr/pvrcb.c b/src/mesa/drivers/dri/pvr/pvrcb.c
  1471. new file mode 100644
  1472. index 0000000..ea8911c
  1473. --- /dev/null
  1474. +++ b/src/mesa/drivers/dri/pvr/pvrcb.c
  1475. @@ -0,0 +1,328 @@
  1476. +/*
  1477. + * Copyright (c) Imagination Technologies Ltd.
  1478. + *
  1479. + * The contents of this file are subject to the MIT license as set out below.
  1480. + *
  1481. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  1482. + * of this software and associated documentation files (the "Software"), to deal
  1483. + * in the Software without restriction, including without limitation the rights
  1484. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1485. + * copies of the Software, and to permit persons to whom the Software is
  1486. + * furnished to do so, subject to the following conditions:
  1487. + *
  1488. + * The above copyright notice and this permission notice shall be included in
  1489. + * all copies or substantial portions of the Software.
  1490. + *
  1491. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1492. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1493. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1494. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1495. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1496. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1497. + * THE SOFTWARE.
  1498. + */
  1499. +
  1500. +#include <assert.h>
  1501. +
  1502. +#include "utils.h"
  1503. +#include "pvrdri.h"
  1504. +
  1505. +int
  1506. +MODSUPGetBuffers(__DRIdrawable *psDRIDrawable, unsigned int uFourCC,
  1507. + uint32_t *puStamp, void *pvLoaderPrivate,
  1508. + uint32_t uBufferMask, struct PVRDRIImageList *psImageList)
  1509. +{
  1510. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  1511. + __DRIscreen *psDRIScreen = psDRIDrawable->driScreenPriv;
  1512. + struct __DRIimageList sDRIList;
  1513. + int res;
  1514. +
  1515. +#if !defined(DRI_IMAGE_HAS_BUFFER_PREV)
  1516. + uBufferMask &= ~PVRDRI_IMAGE_BUFFER_PREV;
  1517. +#endif
  1518. +
  1519. + if (psPVRDrawable->uFourCC != uFourCC) {
  1520. + psPVRDrawable->uDRIFormat = PVRDRIFourCCToDRIFormat(uFourCC);
  1521. + psPVRDrawable->uFourCC = uFourCC;
  1522. + }
  1523. +
  1524. + res = psDRIScreen->image.loader->getBuffers(psDRIDrawable,
  1525. + psPVRDrawable->uDRIFormat,
  1526. + puStamp,
  1527. + pvLoaderPrivate,
  1528. + uBufferMask, &sDRIList);
  1529. +
  1530. + if (res) {
  1531. + psImageList->uImageMask = sDRIList.image_mask;
  1532. + psImageList->psBack = sDRIList.back;
  1533. + psImageList->psFront = sDRIList.front;
  1534. + psImageList->psPrev = sDRIList.prev;
  1535. + }
  1536. +
  1537. + return res;
  1538. +}
  1539. +
  1540. +bool
  1541. +MODSUPCreateConfigs(__DRIconfig ***pppsConfigs, __DRIscreen *psDRIScreen,
  1542. + int iPVRDRIMesaFormat, const uint8_t *puDepthBits,
  1543. + const uint8_t *puStencilBits,
  1544. + unsigned int uNumDepthStencilBits,
  1545. + const unsigned int *puDBModes, unsigned int uNumDBModes,
  1546. + const uint8_t *puMSAASamples, unsigned int uNumMSAAModes,
  1547. + bool bEnableAccum, bool bColorDepthMatch,
  1548. + UNUSED bool bMutableRenderBuffer,
  1549. + int iYUVDepthRange, int iYUVCSCStandard,
  1550. + uint32_t uMaxPbufferWidth, uint32_t uMaxPbufferHeight)
  1551. +{
  1552. + __DRIconfig **ppsConfigs;
  1553. + mesa_format eFormat = PVRDRIMesaFormatToMesaFormat(iPVRDRIMesaFormat);
  1554. + unsigned int i;
  1555. +
  1556. + (void) psDRIScreen;
  1557. +
  1558. + switch (eFormat) {
  1559. + case MESA_FORMAT_NONE:
  1560. + __driUtilMessage("%s: Unknown PVR DRI format: %u",
  1561. + __func__, iPVRDRIMesaFormat);
  1562. + return false;
  1563. + default:
  1564. + break;
  1565. + }
  1566. +
  1567. + /*
  1568. + * The double buffered modes array argument for driCreateConfigs has
  1569. + * entries of type GLenum.
  1570. + */
  1571. + static_assert(sizeof(GLenum) == sizeof(unsigned int),
  1572. + "Size mismatch between GLenum and unsigned int");
  1573. +
  1574. + ppsConfigs = driCreateConfigs(eFormat, puDepthBits, puStencilBits,
  1575. + uNumDepthStencilBits, (GLenum *) puDBModes,
  1576. + uNumDBModes, puMSAASamples, uNumMSAAModes,
  1577. + bEnableAccum, bColorDepthMatch,
  1578. + iYUVDepthRange, iYUVCSCStandard);
  1579. + if (!ppsConfigs)
  1580. + return false;
  1581. +
  1582. + for (i = 0; ppsConfigs[i]; i++) {
  1583. + ppsConfigs[i]->modes.maxPbufferWidth = uMaxPbufferWidth;
  1584. + ppsConfigs[i]->modes.maxPbufferHeight = uMaxPbufferHeight;
  1585. + ppsConfigs[i]->modes.maxPbufferPixels =
  1586. + uMaxPbufferWidth * uMaxPbufferHeight;
  1587. + }
  1588. +
  1589. + *pppsConfigs = ppsConfigs;
  1590. +
  1591. + return true;
  1592. +}
  1593. +
  1594. +__DRIconfig **
  1595. +MODSUPConcatConfigs(__DRIscreen *psDRIScreen,
  1596. + __DRIconfig **ppsConfigA, __DRIconfig **ppsConfigB)
  1597. +{
  1598. + (void) psDRIScreen;
  1599. +
  1600. + return driConcatConfigs(ppsConfigA, ppsConfigB);
  1601. +}
  1602. +
  1603. +struct __DRIimageRec *
  1604. +MODSUPLookupEGLImage(__DRIscreen *psDRIScreen, void *pvImage,
  1605. + void *pvLoaderPrivate)
  1606. +{
  1607. + return psDRIScreen->dri2.image->lookupEGLImage(psDRIScreen,
  1608. + pvImage,
  1609. + pvLoaderPrivate);
  1610. +}
  1611. +
  1612. +
  1613. +unsigned int
  1614. +MODSUPGetCapability(__DRIscreen *psDRIScreen, unsigned int uCapability)
  1615. +{
  1616. + if (psDRIScreen->image.loader->base.version >= 2 &&
  1617. + psDRIScreen->image.loader->getCapability) {
  1618. + enum dri_loader_cap eCapability =
  1619. + (enum dri_loader_cap) uCapability;
  1620. +
  1621. + return psDRIScreen->image.loader->getCapability(
  1622. + psDRIScreen->loaderPrivate,
  1623. + eCapability);
  1624. + }
  1625. +
  1626. + return 0;
  1627. +}
  1628. +
  1629. +int
  1630. +MODSUPGetDisplayFD(__DRIscreen *psDRIScreen, void *pvLoaderPrivate)
  1631. +{
  1632. +#if __DRI_IMAGE_LOADER_VERSION >= 5
  1633. + if (psDRIScreen->image.loader->base.version >= 5 &&
  1634. + psDRIScreen->image.loader->getDisplayFD)
  1635. + return psDRIScreen->image.loader->getDisplayFD(pvLoaderPrivate);
  1636. +#else
  1637. + (void) psDRIScreen;
  1638. + (void) pvLoaderPrivate;
  1639. +#endif
  1640. +
  1641. + return -1;
  1642. +}
  1643. +
  1644. +static bool
  1645. +PVRDRIConfigQueryUnsigned(const PVRDRIConfig *psConfig,
  1646. + PVRDRIConfigAttrib eConfigAttrib,
  1647. + unsigned int *puValueOut)
  1648. +{
  1649. + if (!psConfig || !puValueOut)
  1650. + return false;
  1651. +
  1652. + switch (eConfigAttrib) {
  1653. + case PVRDRI_CONFIG_ATTRIB_RENDERABLE_TYPE:
  1654. + *puValueOut = psConfig->iSupportedAPIs;
  1655. + return true;
  1656. + case PVRDRI_CONFIG_ATTRIB_RGB_MODE:
  1657. + *puValueOut = psConfig->sGLMode.rgbMode;
  1658. + return true;
  1659. + case PVRDRI_CONFIG_ATTRIB_DOUBLE_BUFFER_MODE:
  1660. + *puValueOut = psConfig->sGLMode.doubleBufferMode;
  1661. + return true;
  1662. + case PVRDRI_CONFIG_ATTRIB_RED_BITS:
  1663. + *puValueOut = psConfig->sGLMode.redBits;
  1664. + return true;
  1665. + case PVRDRI_CONFIG_ATTRIB_GREEN_BITS:
  1666. + *puValueOut = psConfig->sGLMode.greenBits;
  1667. + return true;
  1668. + case PVRDRI_CONFIG_ATTRIB_BLUE_BITS:
  1669. + *puValueOut = psConfig->sGLMode.blueBits;
  1670. + return true;
  1671. + case PVRDRI_CONFIG_ATTRIB_ALPHA_BITS:
  1672. + *puValueOut = psConfig->sGLMode.alphaBits;
  1673. + return true;
  1674. + case PVRDRI_CONFIG_ATTRIB_RGB_BITS:
  1675. + *puValueOut = psConfig->sGLMode.rgbBits;
  1676. + return true;
  1677. + case PVRDRI_CONFIG_ATTRIB_DEPTH_BITS:
  1678. + *puValueOut = psConfig->sGLMode.depthBits;
  1679. + return true;
  1680. + case PVRDRI_CONFIG_ATTRIB_STENCIL_BITS:
  1681. + *puValueOut = psConfig->sGLMode.stencilBits;
  1682. + return true;
  1683. + case PVRDRI_CONFIG_ATTRIB_SAMPLE_BUFFERS:
  1684. + *puValueOut = !!psConfig->sGLMode.samples;
  1685. + return true;
  1686. + case PVRDRI_CONFIG_ATTRIB_SAMPLES:
  1687. + *puValueOut = psConfig->sGLMode.samples;
  1688. + return true;
  1689. + case PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGB:
  1690. + *puValueOut = GL_TRUE;
  1691. + return true;
  1692. + case PVRDRI_CONFIG_ATTRIB_BIND_TO_TEXTURE_RGBA:
  1693. + *puValueOut = GL_TRUE;
  1694. + return true;
  1695. +#if defined(__DRI_ATTRIB_YUV_BIT)
  1696. + case PVRDRI_CONFIG_ATTRIB_YUV_ORDER:
  1697. + *puValueOut = psConfig->sGLMode.YUVOrder;
  1698. + return true;
  1699. + case PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES:
  1700. + *puValueOut = psConfig->sGLMode.YUVNumberOfPlanes;
  1701. + return true;
  1702. + case PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE:
  1703. + *puValueOut = psConfig->sGLMode.YUVSubsample;
  1704. + return true;
  1705. + case PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE:
  1706. + *puValueOut = psConfig->sGLMode.YUVDepthRange;
  1707. + return true;
  1708. + case PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD:
  1709. + *puValueOut = psConfig->sGLMode.YUVCSCStandard;
  1710. + return true;
  1711. + case PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP:
  1712. + *puValueOut = psConfig->sGLMode.YUVPlaneBPP;
  1713. + return true;
  1714. +#endif
  1715. +#if !defined(__DRI_ATTRIB_YUV_BIT)
  1716. + case PVRDRI_CONFIG_ATTRIB_YUV_ORDER:
  1717. + case PVRDRI_CONFIG_ATTRIB_YUV_NUM_OF_PLANES:
  1718. + case PVRDRI_CONFIG_ATTRIB_YUV_SUBSAMPLE:
  1719. + case PVRDRI_CONFIG_ATTRIB_YUV_DEPTH_RANGE:
  1720. + case PVRDRI_CONFIG_ATTRIB_YUV_CSC_STANDARD:
  1721. + case PVRDRI_CONFIG_ATTRIB_YUV_PLANE_BPP:
  1722. + return false;
  1723. +#endif
  1724. + case PVRDRI_CONFIG_ATTRIB_RED_MASK:
  1725. + *puValueOut = psConfig->sGLMode.redMask;
  1726. + return true;
  1727. + case PVRDRI_CONFIG_ATTRIB_GREEN_MASK:
  1728. + *puValueOut = psConfig->sGLMode.greenMask;
  1729. + return true;
  1730. + case PVRDRI_CONFIG_ATTRIB_BLUE_MASK:
  1731. + *puValueOut = psConfig->sGLMode.blueMask;
  1732. + return true;
  1733. + case PVRDRI_CONFIG_ATTRIB_ALPHA_MASK:
  1734. + *puValueOut = psConfig->sGLMode.alphaMask;
  1735. + return true;
  1736. + case PVRDRI_CONFIG_ATTRIB_SRGB_CAPABLE:
  1737. + *puValueOut = psConfig->sGLMode.sRGBCapable;
  1738. + return true;
  1739. + case PVRDRI_CONFIG_ATTRIB_INVALID:
  1740. + errorMessage("%s: Invalid attribute", __func__);
  1741. + assert(0);
  1742. + return false;
  1743. + default:
  1744. + return false;
  1745. + }
  1746. +}
  1747. +
  1748. +bool
  1749. +PVRDRIConfigQuery(const PVRDRIConfig *psConfig,
  1750. + PVRDRIConfigAttrib eConfigAttrib, int *piValueOut)
  1751. +{
  1752. + bool bRes;
  1753. + unsigned int uValue;
  1754. +
  1755. + bRes = PVRDRIConfigQueryUnsigned(psConfig, eConfigAttrib, &uValue);
  1756. + if (bRes)
  1757. + *piValueOut = (int) uValue;
  1758. +
  1759. + return bRes;
  1760. +}
  1761. +
  1762. +bool
  1763. +MODSUPConfigQuery(const PVRDRIConfig *psConfig,
  1764. + PVRDRIConfigAttrib eConfigAttrib, unsigned int *puValueOut)
  1765. +{
  1766. + return PVRDRIConfigQueryUnsigned(psConfig, eConfigAttrib, puValueOut);
  1767. +}
  1768. +
  1769. +void
  1770. +MODSUPFlushFrontBuffer(struct __DRIdrawableRec *psDRIDrawable,
  1771. + void *pvLoaderPrivate)
  1772. +{
  1773. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  1774. + __DRIscreen *psDRIScreen = psDRIDrawable->driScreenPriv;
  1775. +
  1776. + if (!psPVRDrawable->sConfig.sGLMode.doubleBufferMode)
  1777. + psDRIScreen->image.loader->flushFrontBuffer(psDRIDrawable,
  1778. + pvLoaderPrivate);
  1779. +}
  1780. +
  1781. +void *
  1782. +MODSUPDrawableGetReferenceHandle(struct __DRIdrawableRec *psDRIDrawable)
  1783. +{
  1784. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  1785. +
  1786. + return psPVRDrawable;
  1787. +}
  1788. +
  1789. +void
  1790. +MODSUPDrawableAddReference(void *pvReferenceHandle)
  1791. +{
  1792. + PVRDRIDrawable *psPVRDrawable = pvReferenceHandle;
  1793. +
  1794. + PVRDRIDrawableAddReference(psPVRDrawable);
  1795. +}
  1796. +
  1797. +void
  1798. +MODSUPDrawableRemoveReference(void *pvReferenceHandle)
  1799. +{
  1800. + PVRDRIDrawable *psPVRDrawable = pvReferenceHandle;
  1801. +
  1802. + PVRDRIDrawableRemoveReference(psPVRDrawable);
  1803. +}
  1804. diff --git a/src/mesa/drivers/dri/pvr/pvrcompat.c b/src/mesa/drivers/dri/pvr/pvrcompat.c
  1805. new file mode 100644
  1806. index 0000000..23a57dd
  1807. --- /dev/null
  1808. +++ b/src/mesa/drivers/dri/pvr/pvrcompat.c
  1809. @@ -0,0 +1,838 @@
  1810. +/*
  1811. + * Copyright (c) Imagination Technologies Ltd.
  1812. + *
  1813. + * The contents of this file are subject to the MIT license as set out below.
  1814. + *
  1815. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  1816. + * of this software and associated documentation files (the "Software"), to deal
  1817. + * in the Software without restriction, including without limitation the rights
  1818. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1819. + * copies of the Software, and to permit persons to whom the Software is
  1820. + * furnished to do so, subject to the following conditions:
  1821. + *
  1822. + * The above copyright notice and this permission notice shall be included in
  1823. + * all copies or substantial portions of the Software.
  1824. + *
  1825. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1826. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1827. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1828. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1829. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1830. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1831. + * THE SOFTWARE.
  1832. + */
  1833. +
  1834. +#include <stddef.h>
  1835. +#include <stdlib.h>
  1836. +#include <string.h>
  1837. +#include <dlfcn.h>
  1838. +#include <pthread.h>
  1839. +#include <assert.h>
  1840. +
  1841. +#include <drm_fourcc.h>
  1842. +
  1843. +#include "pvrdri.h"
  1844. +
  1845. +#ifndef DRM_FORMAT_MOD_INVALID
  1846. +#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)
  1847. +#endif
  1848. +
  1849. +#define _MAKESTRING(x) # x
  1850. +#define MAKESTRING(x) _MAKESTRING(x)
  1851. +
  1852. +#define PVRDRI_SUPPORT_LIB "libpvr_dri_support.so"
  1853. +
  1854. +static void *gpvSupLib;
  1855. +static int giSupLibRef;
  1856. +
  1857. +static struct PVRDRISupportInterfaceV2 gsSupV2;
  1858. +
  1859. +static pthread_mutex_t gsCompatLock = PTHREAD_MUTEX_INITIALIZER;
  1860. +
  1861. +/* Lookup a function, and set the pointer to the function address */
  1862. +#define LookupFunc(func, ptr) \
  1863. + do { \
  1864. + ptr = dlsym(gpvSupLib, MAKESTRING(func)); \
  1865. + } while(0)
  1866. +
  1867. +/* Call a function via the DRI Support interface structure */
  1868. +#define CallFuncV2(field, ...) \
  1869. + do { \
  1870. + if (gsSupV2.field) \
  1871. + return gsSupV2.field(__VA_ARGS__); \
  1872. + } while(0)
  1873. +
  1874. +/* Calculate the start of the PVRDRISupportInterfaceV2 structure */
  1875. +#define PVRDRIInterfaceV2Start(field) \
  1876. + (offsetof(struct PVRDRISupportInterfaceV2, field))
  1877. +
  1878. +/* Calculate the end of the PVRDRISupportInterfaceV2 structure */
  1879. +#define PVRDRIInterfaceV2End(field) \
  1880. + (offsetof(struct PVRDRISupportInterfaceV2, field) + \
  1881. + sizeof((struct PVRDRISupportInterfaceV2 *)0)->field)
  1882. +
  1883. +static void
  1884. +CompatLock(void)
  1885. +{
  1886. + int ret;
  1887. +
  1888. + ret = pthread_mutex_lock(&gsCompatLock);
  1889. + if (ret) {
  1890. + errorMessage("%s: Failed to lock mutex (%d)", __func__, ret);
  1891. + abort();
  1892. + }
  1893. +}
  1894. +
  1895. +static void
  1896. +CompatUnlock(void)
  1897. +{
  1898. + int ret;
  1899. +
  1900. + ret = pthread_mutex_unlock(&gsCompatLock);
  1901. + if (ret) {
  1902. + errorMessage("%s: Failed to unlock mutex (%d)", __func__, ret);
  1903. + abort();
  1904. + }
  1905. +}
  1906. +
  1907. +static void *
  1908. +LoadLib(const char *path)
  1909. +{
  1910. + void *handle;
  1911. +
  1912. + /* Clear the error */
  1913. + (void) dlerror();
  1914. +
  1915. + handle = dlopen(path, RTLD_NOW);
  1916. + if (handle) {
  1917. + __driUtilMessage("Loaded %s", path);
  1918. + } else {
  1919. + const char *error;
  1920. +
  1921. + error = dlerror();
  1922. + if (!error)
  1923. + error = "unknown error";
  1924. +
  1925. + errorMessage("%s: Couldn't load %s: %s", __func__, path, error);
  1926. + }
  1927. +
  1928. + return handle;
  1929. +}
  1930. +
  1931. +static void
  1932. +UnloadLib(void *handle, const char *name)
  1933. +{
  1934. + if (!handle)
  1935. + return;
  1936. +
  1937. + /* Clear the error */
  1938. + (void) dlerror();
  1939. +
  1940. + if (dlclose(handle)) {
  1941. + const char *error;
  1942. +
  1943. + error = dlerror();
  1944. + if (!error)
  1945. + error = "unknown error";
  1946. +
  1947. + errorMessage("%s: Couldn't unload %s: %s", __func__, name, error);
  1948. + } else {
  1949. + __driUtilMessage("Unloaded %s", name);
  1950. + }
  1951. +}
  1952. +
  1953. +static bool
  1954. +LoadSupportLib(void)
  1955. +{
  1956. + gpvSupLib = LoadLib(PVRDRI_SUPPORT_LIB);
  1957. +
  1958. + return gpvSupLib != NULL;
  1959. +}
  1960. +
  1961. +static void
  1962. +UnloadSupportLib(void)
  1963. +{
  1964. + UnloadLib(gpvSupLib, PVRDRI_SUPPORT_LIB);
  1965. + gpvSupLib = NULL;
  1966. +}
  1967. +
  1968. +static void
  1969. +CompatDeinit(void)
  1970. +{
  1971. + UnloadSupportLib();
  1972. + memset(&gsSupV2, 0, sizeof(gsSupV2));
  1973. +}
  1974. +
  1975. +bool
  1976. +PVRDRICompatInit(const struct PVRDRICallbacksV2 *psCallbacksV2,
  1977. + unsigned int uVersionV2, unsigned int uMinVersionV2)
  1978. +{
  1979. + bool (*pfRegisterVersionedCallbacksV2)(const void *pvCallbacks,
  1980. + unsigned int uVersion,
  1981. + unsigned int uMinVersion);
  1982. + bool res;
  1983. +
  1984. + CompatLock();
  1985. + res = (giSupLibRef++ != 0);
  1986. + if (res)
  1987. + goto Exit;
  1988. +
  1989. + res = LoadSupportLib();
  1990. + if (!res)
  1991. + goto Exit;
  1992. +
  1993. + LookupFunc(PVRDRIRegisterVersionedCallbacksV2,
  1994. + pfRegisterVersionedCallbacksV2);
  1995. +
  1996. + res = (pfRegisterVersionedCallbacksV2 != NULL);
  1997. + if (!res)
  1998. + goto Exit;
  1999. +
  2000. + res = pfRegisterVersionedCallbacksV2(psCallbacksV2,
  2001. + uVersionV2, uMinVersionV2);
  2002. +
  2003. +Exit:
  2004. + if (!res) {
  2005. + CompatDeinit();
  2006. + giSupLibRef--;
  2007. + }
  2008. + CompatUnlock();
  2009. +
  2010. + return res;
  2011. +}
  2012. +
  2013. +void
  2014. +PVRDRICompatDeinit(void)
  2015. +{
  2016. + CompatLock();
  2017. + if (--giSupLibRef == 0)
  2018. + CompatDeinit();
  2019. + CompatUnlock();
  2020. +}
  2021. +
  2022. +bool
  2023. +MODSUPRegisterSupportInterfaceV2(const void *pvInterface,
  2024. + unsigned int uVersion,
  2025. + unsigned int uMinVersion)
  2026. +{
  2027. + size_t uStart, uEnd;
  2028. +
  2029. + memset(&gsSupV2, 0, sizeof(gsSupV2));
  2030. +
  2031. + if (uVersion < uMinVersion)
  2032. + return false;
  2033. +
  2034. + /*
  2035. + * Minimum versions we support. To prevent the accumulation of old unused
  2036. + * interfaces in the PVRDRIInterfaceV2 structure, the caller specifies the
  2037. + * minimum version it supports. This will be pointed to be the psInterface
  2038. + * argument. Assuming we support that version, we must copy the structure
  2039. + * passed to us into the correct place in our version of the interface
  2040. + * structure.
  2041. + */
  2042. + switch (uMinVersion) {
  2043. + case 0:
  2044. + uStart = PVRDRIInterfaceV2Start(v0);
  2045. + break;
  2046. + case 1:
  2047. + case 2:
  2048. + case 3:
  2049. + case 4:
  2050. + /* These versions require version 0 */
  2051. + return false;
  2052. + default:
  2053. + return false;
  2054. + }
  2055. +
  2056. + /* The "default" case should be associated with the latest version */
  2057. + switch (uVersion) {
  2058. + default:
  2059. + case 4:
  2060. + /* This version is an extension of versions 0 to 3 */
  2061. + if (uMinVersion > 0)
  2062. + return false;
  2063. +
  2064. + uEnd = PVRDRIInterfaceV2End(v4);
  2065. + break;
  2066. + case 3:
  2067. + /*
  2068. + * This version is an extension of version 2, with no new
  2069. + * entry points.
  2070. + */
  2071. + case 2:
  2072. + /* This version is an extension of versions 0 and 1 */
  2073. + if (uMinVersion > 0)
  2074. + return false;
  2075. +
  2076. + uEnd = PVRDRIInterfaceV2End(v2);
  2077. + break;
  2078. + case 1:
  2079. + /* This version is an extension of version 0 */
  2080. + if (uMinVersion > 0)
  2081. + return false;
  2082. +
  2083. + uEnd = PVRDRIInterfaceV2End(v1);
  2084. + break;
  2085. + case 0:
  2086. + uEnd = PVRDRIInterfaceV2End(v0);
  2087. + break;
  2088. + }
  2089. +
  2090. + memcpy(((char *) &gsSupV2) + uStart, pvInterface, uEnd - uStart);
  2091. +
  2092. + PVRDRIAdjustExtensions(uVersion, uMinVersion);
  2093. +
  2094. + return true;
  2095. +}
  2096. +
  2097. +struct DRISUPScreen *
  2098. +DRISUPCreateScreen(struct __DRIscreenRec *psDRIScreen, int iFD,
  2099. + bool bUseInvalidate, void *pvLoaderPrivate,
  2100. + const struct __DRIconfigRec ***pppsConfigs,
  2101. + int *piMaxGLES1Version, int *piMaxGLES2Version)
  2102. +{
  2103. + CallFuncV2(v0.CreateScreen,
  2104. + psDRIScreen, iFD, bUseInvalidate, pvLoaderPrivate, pppsConfigs,
  2105. + piMaxGLES1Version, piMaxGLES2Version);
  2106. +
  2107. + return NULL;
  2108. +}
  2109. +
  2110. +void
  2111. +DRISUPDestroyScreen(struct DRISUPScreen *psDRISUPScreen)
  2112. +{
  2113. + CallFuncV2(v0.DestroyScreen,
  2114. + psDRISUPScreen);
  2115. +}
  2116. +
  2117. +unsigned int
  2118. +DRISUPCreateContext(PVRDRIAPIType eAPI, PVRDRIConfig *psPVRDRIConfig,
  2119. + struct PVRDRIContextConfig *psCtxConfig,
  2120. + struct __DRIcontextRec *psDRIContext,
  2121. + struct DRISUPContext *psDRISUPSharedContext,
  2122. + struct DRISUPScreen *psDRISUPScreen,
  2123. + struct DRISUPContext **ppsDRISUPContext)
  2124. +{
  2125. + CallFuncV2(v0.CreateContext,
  2126. + eAPI, psPVRDRIConfig, psCtxConfig, psDRIContext,
  2127. + psDRISUPSharedContext, psDRISUPScreen, ppsDRISUPContext);
  2128. +
  2129. + return __DRI_CTX_ERROR_BAD_API;
  2130. +}
  2131. +
  2132. +void
  2133. +DRISUPDestroyContext(struct DRISUPContext *psDRISUPContext)
  2134. +{
  2135. + CallFuncV2(v0.DestroyContext,
  2136. + psDRISUPContext);
  2137. +}
  2138. +
  2139. +struct DRISUPDrawable *
  2140. +DRISUPCreateDrawable(struct __DRIdrawableRec *psDRIDrawable,
  2141. + struct DRISUPScreen *psDRISUPScreen,
  2142. + void *pvLoaderPrivate, PVRDRIConfig *psPVRDRIConfig)
  2143. +{
  2144. + CallFuncV2(v0.CreateDrawable,
  2145. + psDRIDrawable, psDRISUPScreen, pvLoaderPrivate, psPVRDRIConfig);
  2146. +
  2147. + return NULL;
  2148. +}
  2149. +
  2150. +void
  2151. +DRISUPDestroyDrawable(struct DRISUPDrawable *psDRISUPDrawable)
  2152. +{
  2153. + CallFuncV2(v0.DestroyDrawable,
  2154. + psDRISUPDrawable);
  2155. +}
  2156. +
  2157. +bool
  2158. +DRISUPMakeCurrent(struct DRISUPContext *psDRISUPContext,
  2159. + struct DRISUPDrawable *psDRISUPWrite,
  2160. + struct DRISUPDrawable *psDRISUPRead)
  2161. +{
  2162. + CallFuncV2(v0.MakeCurrent,
  2163. + psDRISUPContext, psDRISUPWrite, psDRISUPRead);
  2164. +
  2165. + return false;
  2166. +}
  2167. +
  2168. +bool
  2169. +DRISUPUnbindContext(struct DRISUPContext *psDRISUPContext)
  2170. +{
  2171. + CallFuncV2(v0.UnbindContext,
  2172. + psDRISUPContext);
  2173. +
  2174. + return false;
  2175. +}
  2176. +
  2177. +struct DRISUPBuffer *
  2178. +DRISUPAllocateBuffer(struct DRISUPScreen *psDRISUPScreen,
  2179. + unsigned int uAttachment, unsigned int uFormat,
  2180. + int iWidth, int iHeight, unsigned int *puName,
  2181. + unsigned int *puPitch, unsigned int *puCPP,
  2182. + unsigned int *puFlags)
  2183. +{
  2184. + CallFuncV2(v0.AllocateBuffer,
  2185. + psDRISUPScreen, uAttachment, uFormat, iWidth, iHeight, puName,
  2186. + puPitch, puCPP, puFlags);
  2187. +
  2188. + return NULL;
  2189. +}
  2190. +
  2191. +void
  2192. +DRISUPReleaseBuffer(struct DRISUPScreen *psDRISUPScreen,
  2193. + struct DRISUPBuffer *psDRISUPBuffer)
  2194. +{
  2195. + CallFuncV2(v0.ReleaseBuffer,
  2196. + psDRISUPScreen, psDRISUPBuffer);
  2197. +}
  2198. +
  2199. +void
  2200. +DRISUPSetTexBuffer2(struct DRISUPContext *psDRISUPContext, int iTarget,
  2201. + int iFormat, struct DRISUPDrawable *psDRISUPDrawable)
  2202. +{
  2203. + CallFuncV2(v0.SetTexBuffer2,
  2204. + psDRISUPContext, iTarget, iFormat, psDRISUPDrawable);
  2205. +}
  2206. +
  2207. +void
  2208. +DRISUPReleaseTexBuffer(struct DRISUPContext *psDRISUPContext, int iTarget,
  2209. + struct DRISUPDrawable *psDRISUPDrawable)
  2210. +{
  2211. + CallFuncV2(v0.ReleaseTexBuffer,
  2212. + psDRISUPContext, iTarget, psDRISUPDrawable);
  2213. +}
  2214. +
  2215. +void
  2216. +DRISUPFlush(struct DRISUPDrawable *psDRISUPDrawable)
  2217. +{
  2218. + CallFuncV2(v0.Flush,
  2219. + psDRISUPDrawable);
  2220. +}
  2221. +
  2222. +void
  2223. +DRISUPInvalidate(struct DRISUPDrawable *psDRISUPDrawable)
  2224. +{
  2225. + CallFuncV2(v0.Invalidate,
  2226. + psDRISUPDrawable);
  2227. +}
  2228. +
  2229. +void
  2230. +DRISUPFlushWithFlags(struct DRISUPContext *psDRISUPContext,
  2231. + struct DRISUPDrawable *psDRISUPDrawable,
  2232. + unsigned int uFlags, unsigned int uThrottleReason)
  2233. +{
  2234. + CallFuncV2(v0.FlushWithFlags,
  2235. + psDRISUPContext, psDRISUPDrawable, uFlags, uThrottleReason);
  2236. +}
  2237. +
  2238. +__DRIimage *
  2239. +DRISUPCreateImageFromName(struct DRISUPScreen *psDRISUPScreen,
  2240. + int iWidth, int iHeight, int iFourCC, int iName,
  2241. + int iPitch, void *pvLoaderPrivate)
  2242. +{
  2243. + CallFuncV2(v0.CreateImageFromName,
  2244. + psDRISUPScreen, iWidth, iHeight, iFourCC, iName, iPitch,
  2245. + pvLoaderPrivate);
  2246. +
  2247. + return NULL;
  2248. +}
  2249. +
  2250. +__DRIimage *
  2251. +DRISUPCreateImageFromRenderbuffer(struct DRISUPContext *psDRISUPContext,
  2252. + int iRenderBuffer, void *pvLoaderPrivate)
  2253. +{
  2254. + CallFuncV2(v0.CreateImageFromRenderbuffer,
  2255. + psDRISUPContext, iRenderBuffer, pvLoaderPrivate);
  2256. +
  2257. + return NULL;
  2258. +}
  2259. +
  2260. +void
  2261. +DRISUPDestroyImage(__DRIimage *psImage)
  2262. +{
  2263. + CallFuncV2(v0.DestroyImage, psImage);
  2264. +}
  2265. +
  2266. +__DRIimage *
  2267. +DRISUPCreateImage(struct DRISUPScreen *psDRISUPScreen,
  2268. + int iWidth, int iHeight, int iFourCC, unsigned int uUse,
  2269. + void *pvLoaderPrivate)
  2270. +{
  2271. + CallFuncV2(v0.CreateImage,
  2272. + psDRISUPScreen, iWidth, iHeight, iFourCC, uUse, pvLoaderPrivate);
  2273. +
  2274. + return NULL;
  2275. +}
  2276. +
  2277. +bool
  2278. +DRISUPQueryImage(__DRIimage *psImage, int iAttrib, int *piValue)
  2279. +{
  2280. + CallFuncV2(v0.QueryImage,
  2281. + psImage, iAttrib, piValue);
  2282. +
  2283. + return false;
  2284. +}
  2285. +
  2286. +__DRIimage *
  2287. +DRISUPDupImage(__DRIimage *psImage, void *pvLoaderPrivate)
  2288. +{
  2289. + CallFuncV2(v0.DupImage,
  2290. + psImage, pvLoaderPrivate);
  2291. +
  2292. + return NULL;
  2293. +}
  2294. +
  2295. +bool
  2296. +DRISUPValidateImageUsage(__DRIimage *psImage, unsigned int uUse)
  2297. +{
  2298. + CallFuncV2(v0.ValidateImageUsage,
  2299. + psImage, uUse);
  2300. +
  2301. + return false;
  2302. +}
  2303. +
  2304. +__DRIimage *
  2305. +DRISUPCreateImageFromNames(struct DRISUPScreen *psDRISUPScreen,
  2306. + int iWidth, int iHeight, int iFourCC,
  2307. + int *piNames, int iNumNames,
  2308. + int *piStrides, int *piOffsets,
  2309. + void *pvLoaderPrivate)
  2310. +{
  2311. + CallFuncV2(v0.CreateImageFromNames,
  2312. + psDRISUPScreen, iWidth, iHeight, iFourCC, piNames, iNumNames,
  2313. + piStrides, piOffsets, pvLoaderPrivate);
  2314. +
  2315. + return NULL;
  2316. +}
  2317. +
  2318. +__DRIimage *
  2319. +DRISUPFromPlanar(__DRIimage *psImage, int iPlane, void *pvLoaderPrivate)
  2320. +{
  2321. + CallFuncV2(v0.FromPlanar,
  2322. + psImage, iPlane, pvLoaderPrivate);
  2323. +
  2324. + return NULL;
  2325. +}
  2326. +
  2327. +__DRIimage *
  2328. +DRISUPCreateImageFromTexture(struct DRISUPContext *psDRISUPContext,
  2329. + int iTarget, unsigned int uTexture, int iDepth,
  2330. + int iLevel, unsigned int *puError,
  2331. + void *pvLoaderPrivate)
  2332. +{
  2333. + CallFuncV2(v0.CreateImageFromTexture,
  2334. + psDRISUPContext, iTarget, uTexture, iDepth, iLevel, puError,
  2335. + pvLoaderPrivate);
  2336. +
  2337. + return NULL;
  2338. +}
  2339. +
  2340. +__DRIimage *
  2341. +DRISUPCreateImageFromFDs(struct DRISUPScreen *psDRISUPcreen,
  2342. + int iWidth, int iHeight, int iFourCC,
  2343. + int *piFDs, int iNumFDs, int *piStrides,
  2344. + int *piOffsets, void *pvLoaderPrivate)
  2345. +{
  2346. + CallFuncV2(v0.CreateImageFromFDs,
  2347. + psDRISUPcreen, iWidth, iHeight, iFourCC, piFDs, iNumFDs,
  2348. + piStrides, piOffsets, pvLoaderPrivate);
  2349. +
  2350. + return NULL;
  2351. +}
  2352. +
  2353. +__DRIimage *
  2354. +DRISUPCreateImageFromDmaBufs(struct DRISUPScreen *psDRISUPScreen,
  2355. + int iWidth, int iHeight, int iFourCC,
  2356. + int *piFDs, int iNumFDs,
  2357. + int *piStrides, int *piOffsets,
  2358. + unsigned int uColorSpace,
  2359. + unsigned int uSampleRange,
  2360. + unsigned int uHorizSiting,
  2361. + unsigned int uVertSiting,
  2362. + unsigned int *puError,
  2363. + void *pvLoaderPrivate)
  2364. +{
  2365. + CallFuncV2(v0.CreateImageFromDMABufs,
  2366. + psDRISUPScreen, iWidth, iHeight, iFourCC, piFDs, iNumFDs,
  2367. + piStrides, piOffsets, uColorSpace, uSampleRange,
  2368. + uHorizSiting, uVertSiting, puError, pvLoaderPrivate);
  2369. +
  2370. + return NULL;
  2371. +}
  2372. +
  2373. +int
  2374. +DRISUPGetImageCapabilities(struct DRISUPScreen *psDRISUPScreen)
  2375. +{
  2376. + CallFuncV2(v0.GetImageCapabilities,
  2377. + psDRISUPScreen);
  2378. +
  2379. + return 0;
  2380. +}
  2381. +
  2382. +void
  2383. +DRISUPBlitImage(struct DRISUPContext *psDRISUPContext,
  2384. + __DRIimage *psDst, __DRIimage *psSrc, int iDstX0, int iDstY0,
  2385. + int iDstWidth, int iDstHeight, int iSrcX0, int iSrcY0,
  2386. + int iSrcWidth, int iSrcHeight, int iFlushFlag)
  2387. +{
  2388. + CallFuncV2(v0.BlitImage,
  2389. + psDRISUPContext, psDst, psSrc, iDstX0, iDstY0,
  2390. + iDstWidth, iDstHeight, iSrcX0, iSrcY0,
  2391. + iSrcWidth, iSrcHeight, iFlushFlag);
  2392. +}
  2393. +
  2394. +void *
  2395. +DRISUPMapImage(struct DRISUPContext *psDRISUPContext, __DRIimage* psImage,
  2396. + int iX0, int iY0, int iWidth, int iHeight, unsigned int uFlags,
  2397. + int *piStride, void **ppvData)
  2398. +{
  2399. + CallFuncV2(v0.MapImage,
  2400. + psDRISUPContext, psImage, iX0, iY0, iWidth, iHeight, uFlags,
  2401. + piStride, ppvData);
  2402. +
  2403. + return NULL;
  2404. +}
  2405. +
  2406. +void
  2407. +DRISUPUnmapImage(struct DRISUPContext *psDRISUPContext, __DRIimage *psImage,
  2408. + void *pvData)
  2409. +{
  2410. + CallFuncV2(v0.UnmapImage,
  2411. + psDRISUPContext, psImage, pvData);
  2412. +}
  2413. +
  2414. +__DRIimage *
  2415. +DRISUPCreateImageWithModifiers(struct DRISUPScreen *psDRISUPScreen,
  2416. + int iWidth, int iHeight, int iFourCC,
  2417. + const uint64_t *puModifiers,
  2418. + const unsigned int uModifierCount,
  2419. + void *pvLoaderPrivate)
  2420. +{
  2421. + CallFuncV2(v0.CreateImageWithModifiers,
  2422. + psDRISUPScreen, iWidth, iHeight, iFourCC, puModifiers,
  2423. + uModifierCount, pvLoaderPrivate);
  2424. +
  2425. + return NULL;
  2426. +}
  2427. +
  2428. +__DRIimage *
  2429. +DRISUPCreateImageFromDMABufs2(struct DRISUPScreen *psDRISUPScreen,
  2430. + int iWidth, int iHeight, int iFourCC,
  2431. + uint64_t uModifier, int *piFDs, int iNumFDs,
  2432. + int *piStrides, int *piOffsets,
  2433. + unsigned int uColorSpace,
  2434. + unsigned int uSampleRange,
  2435. + unsigned int uHorizSiting,
  2436. + unsigned int uVertSiting,
  2437. + unsigned int *puError, void *pvLoaderPrivate)
  2438. +{
  2439. + CallFuncV2(v0.CreateImageFromDMABufs2,
  2440. + psDRISUPScreen, iWidth, iHeight, iFourCC, uModifier,
  2441. + piFDs, iNumFDs, piStrides, piOffsets, uColorSpace, uSampleRange,
  2442. + uHorizSiting, uVertSiting, puError, pvLoaderPrivate);
  2443. +
  2444. + return NULL;
  2445. +}
  2446. +
  2447. +bool
  2448. +DRISUPQueryDMABufFormats(struct DRISUPScreen *psDRISUPScreen, int iMax,
  2449. + int *piFormats, int *piCount)
  2450. +{
  2451. + CallFuncV2(v0.QueryDMABufFormats,
  2452. + psDRISUPScreen, iMax, piFormats, piCount);
  2453. +
  2454. + return false;
  2455. +}
  2456. +
  2457. +bool
  2458. +DRISUPQueryDMABufModifiers(struct DRISUPScreen *psDRISUPScreen, int iFourCC,
  2459. + int iMax, uint64_t *puModifiers,
  2460. + unsigned int *piExternalOnly, int *piCount)
  2461. +{
  2462. + CallFuncV2(v0.QueryDMABufModifiers,
  2463. + psDRISUPScreen, iFourCC, iMax, puModifiers, piExternalOnly,
  2464. + piCount);
  2465. +
  2466. + return false;
  2467. +}
  2468. +
  2469. +bool
  2470. +DRISUPQueryDMABufFormatModifierAttribs(struct DRISUPScreen *psDRISUPScreen,
  2471. + uint32_t iFourCC, uint64_t uModifier,
  2472. + int iAttrib, uint64_t *puValue)
  2473. +{
  2474. + CallFuncV2(v0.QueryDMABufFormatModifierAttribs,
  2475. + psDRISUPScreen, iFourCC, uModifier, iAttrib, puValue);
  2476. +
  2477. + return false;
  2478. +}
  2479. +
  2480. +__DRIimage *
  2481. +DRISUPCreateImageFromRenderBuffer2(struct DRISUPContext *psDRISUPContext,
  2482. + int iRenderBuffer, void *pvLoaderPrivate,
  2483. + unsigned int *puError)
  2484. +{
  2485. + CallFuncV2(v0.CreateImageFromRenderBuffer2,
  2486. + psDRISUPContext, iRenderBuffer, pvLoaderPrivate, puError);
  2487. +
  2488. + return NULL;
  2489. +}
  2490. +
  2491. +__DRIimage *
  2492. +DRISUPCreateImageFromBuffer(struct DRISUPContext *psDRISUPContext,
  2493. + int iTarget, void *pvBuffer,
  2494. + unsigned int *puError, void *pvLoaderPrivate)
  2495. +{
  2496. + CallFuncV2(v0.CreateImageFromBuffer,
  2497. + psDRISUPContext, iTarget, pvBuffer, puError, pvLoaderPrivate);
  2498. +
  2499. + return NULL;
  2500. +}
  2501. +
  2502. +int
  2503. +DRISUPQueryRendererInteger(struct DRISUPScreen *psDRISUPScreen,
  2504. + int iAttribute, unsigned int *puValue)
  2505. +{
  2506. + CallFuncV2(v0.QueryRendererInteger,
  2507. + psDRISUPScreen, iAttribute, puValue);
  2508. +
  2509. + return -1;
  2510. +}
  2511. +
  2512. +int
  2513. +DRISUPQueryRendererString(struct DRISUPScreen *psDRISUPScreen,
  2514. + int iAttribute, const char **ppszValue)
  2515. +{
  2516. + CallFuncV2(v0.QueryRendererString,
  2517. + psDRISUPScreen, iAttribute, ppszValue);
  2518. +
  2519. + return -1;
  2520. +}
  2521. +
  2522. +void *
  2523. +DRISUPCreateFence(struct DRISUPContext *psDRISUPContext)
  2524. +{
  2525. + CallFuncV2(v0.CreateFence,
  2526. + psDRISUPContext);
  2527. +
  2528. + return NULL;
  2529. +}
  2530. +
  2531. +void
  2532. +DRISUPDestroyFence(struct DRISUPScreen *psDRISUPScreen, void *pvFence)
  2533. +{
  2534. + CallFuncV2(v0.DestroyFence,
  2535. + psDRISUPScreen, pvFence);
  2536. +}
  2537. +
  2538. +bool
  2539. +DRISUPClientWaitSync(struct DRISUPContext *psDRISUPContext, void *pvFence,
  2540. + unsigned int uFlags, uint64_t uTimeout)
  2541. +{
  2542. + CallFuncV2(v0.ClientWaitSync,
  2543. + psDRISUPContext, pvFence, uFlags, uTimeout);
  2544. +
  2545. + return false;
  2546. +}
  2547. +
  2548. +void
  2549. +DRISUPServerWaitSync(struct DRISUPContext *psDRISUPContext, void *pvFence,
  2550. + unsigned int uFlags)
  2551. +{
  2552. + CallFuncV2(v0.ServerWaitSync,
  2553. + psDRISUPContext, pvFence, uFlags);
  2554. +}
  2555. +
  2556. +unsigned int
  2557. +DRISUPGetFenceCapabilities(struct DRISUPScreen *psDRISUPScreen)
  2558. +{
  2559. + CallFuncV2(v0.GetFenceCapabilities,
  2560. + psDRISUPScreen);
  2561. +
  2562. + return 0;
  2563. +}
  2564. +
  2565. +void *
  2566. +DRISUPCreateFenceFD(struct DRISUPContext *psDRISUPContext, int iFD)
  2567. +{
  2568. + CallFuncV2(v0.CreateFenceFD,
  2569. + psDRISUPContext, iFD);
  2570. +
  2571. + return NULL;
  2572. +}
  2573. +
  2574. +int
  2575. +DRISUPGetFenceFD(struct DRISUPScreen *psDRISUPScreen, void *pvFence)
  2576. +{
  2577. + CallFuncV2(v0.GetFenceFD,
  2578. + psDRISUPScreen, pvFence);
  2579. +
  2580. + return -1;
  2581. +}
  2582. +
  2583. +void *
  2584. +DRISUPGetFenceFromCLEvent(struct DRISUPScreen *psDRISUPScreen,
  2585. + intptr_t iCLEvent)
  2586. +{
  2587. + CallFuncV2(v1.GetFenceFromCLEvent,
  2588. + psDRISUPScreen, iCLEvent);
  2589. +
  2590. + return NULL;
  2591. +}
  2592. +
  2593. +int
  2594. +DRISUPGetAPIVersion(struct DRISUPScreen *psDRISUPScreen,
  2595. + PVRDRIAPIType eAPI)
  2596. +{
  2597. + CallFuncV2(v2.GetAPIVersion,
  2598. + psDRISUPScreen, eAPI);
  2599. +
  2600. + return 0;
  2601. +}
  2602. +
  2603. +unsigned int
  2604. +DRISUPGetNumAPIProcs(struct DRISUPScreen *psDRISUPScreen,
  2605. + PVRDRIAPIType eAPI)
  2606. +{
  2607. + CallFuncV2(v0.GetNumAPIProcs,
  2608. + psDRISUPScreen, eAPI);
  2609. +
  2610. + return 0;
  2611. +}
  2612. +
  2613. +const char *
  2614. +DRISUPGetAPIProcName(struct DRISUPScreen *psDRISUPScreen, PVRDRIAPIType eAPI,
  2615. + unsigned int uIndex)
  2616. +{
  2617. + CallFuncV2(v0.GetAPIProcName,
  2618. + psDRISUPScreen, eAPI, uIndex);
  2619. +
  2620. + return NULL;
  2621. +}
  2622. +
  2623. +void *
  2624. +DRISUPGetAPIProcAddress(struct DRISUPScreen *psDRISUPScreen,
  2625. + PVRDRIAPIType eAPI, unsigned int uIndex)
  2626. +{
  2627. + CallFuncV2(v0.GetAPIProcAddress,
  2628. + psDRISUPScreen, eAPI, uIndex);
  2629. +
  2630. + return NULL;
  2631. +}
  2632. +
  2633. +void
  2634. +DRISUPSetDamageRegion(struct DRISUPDrawable *psDRISUPDrawable,
  2635. + unsigned int uNRects, int *piRects)
  2636. +{
  2637. + CallFuncV2(v0.SetDamageRegion,
  2638. + psDRISUPDrawable, uNRects, piRects);
  2639. +}
  2640. +
  2641. +bool
  2642. +DRISUPHaveGetFenceFromCLEvent(void)
  2643. +{
  2644. + CallFuncV2(v4.HaveGetFenceFromCLEvent);
  2645. +
  2646. + return true;
  2647. +}
  2648. diff --git a/src/mesa/drivers/dri/pvr/pvrdri.c b/src/mesa/drivers/dri/pvr/pvrdri.c
  2649. new file mode 100644
  2650. index 0000000..ab941f7
  2651. --- /dev/null
  2652. +++ b/src/mesa/drivers/dri/pvr/pvrdri.c
  2653. @@ -0,0 +1,613 @@
  2654. +/*
  2655. + * Copyright (c) Imagination Technologies Ltd.
  2656. + *
  2657. + * The contents of this file are subject to the MIT license as set out below.
  2658. + *
  2659. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  2660. + * of this software and associated documentation files (the "Software"), to deal
  2661. + * in the Software without restriction, including without limitation the rights
  2662. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2663. + * copies of the Software, and to permit persons to whom the Software is
  2664. + * furnished to do so, subject to the following conditions:
  2665. + *
  2666. + * The above copyright notice and this permission notice shall be included in
  2667. + * all copies or substantial portions of the Software.
  2668. + *
  2669. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2670. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2671. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2672. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2673. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2674. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2675. + * THE SOFTWARE.
  2676. + */
  2677. +
  2678. +#include <string.h>
  2679. +#include <assert.h>
  2680. +
  2681. +#include "util/u_atomic.h"
  2682. +#include "utils.h"
  2683. +
  2684. +#include "pvrdri.h"
  2685. +#include "pvrmesa.h"
  2686. +
  2687. +#define PVR_IMAGE_LOADER_VER_MIN 1
  2688. +
  2689. +struct PVRBuffer {
  2690. + __DRIbuffer sDRIBuffer;
  2691. + struct DRISUPBuffer *psDRISUPBuffer;
  2692. +};
  2693. +
  2694. +/*************************************************************************//*!
  2695. + Local functions
  2696. + *//**************************************************************************/
  2697. +
  2698. +static bool
  2699. +PVRLoaderIsSupported(__DRIscreen *psDRIScreen)
  2700. +{
  2701. + if (psDRIScreen->image.loader) {
  2702. + if (psDRIScreen->image.loader->base.version < PVR_IMAGE_LOADER_VER_MIN) {
  2703. + __driUtilMessage("%s: Image loader extension version %d but need %d",
  2704. + __func__, psDRIScreen->image.loader->base.version,
  2705. + PVR_IMAGE_LOADER_VER_MIN);
  2706. + return false;
  2707. + } else if (!psDRIScreen->image.loader->getBuffers) {
  2708. + __driUtilMessage("%s: Image loader extension missing support for getBuffers",
  2709. + __func__);
  2710. + return false;
  2711. + }
  2712. + } else {
  2713. + __driUtilMessage("%s: Image loader extension required", __func__);
  2714. + return false;
  2715. + }
  2716. +
  2717. + return true;
  2718. +}
  2719. +
  2720. +static inline struct DRISUPContext *
  2721. +getSharedContextImpl(void *pvSharedContextPrivate)
  2722. +{
  2723. + if (pvSharedContextPrivate == NULL)
  2724. + return NULL;
  2725. +
  2726. + return ((PVRDRIContext *) pvSharedContextPrivate)->psDRISUPContext;
  2727. +}
  2728. +
  2729. +static void
  2730. +PVRDRIScreenAddReference(PVRDRIScreen *psPVRScreen)
  2731. +{
  2732. + int iRefCount = p_atomic_inc_return(&psPVRScreen->iRefCount);
  2733. +
  2734. + (void) iRefCount;
  2735. + assert(iRefCount > 1);
  2736. +}
  2737. +
  2738. +static void
  2739. +PVRDRIScreenRemoveReference(PVRDRIScreen *psPVRScreen)
  2740. +{
  2741. + int iRefCount = p_atomic_dec_return(&psPVRScreen->iRefCount);
  2742. +
  2743. + assert(iRefCount >= 0);
  2744. +
  2745. + if (iRefCount != 0)
  2746. + return;
  2747. +
  2748. + pvrdri_free_dispatch_tables(psPVRScreen);
  2749. + DRISUPDestroyScreen(psPVRScreen->psDRISUPScreen);
  2750. + PVRDRICompatDeinit();
  2751. + free(psPVRScreen);
  2752. +}
  2753. +
  2754. +void
  2755. +PVRDRIDrawableAddReference(PVRDRIDrawable *psPVRDrawable)
  2756. +{
  2757. + int iRefCount = p_atomic_inc_return(&psPVRDrawable->iRefCount);
  2758. +
  2759. + (void) iRefCount;
  2760. + assert(iRefCount > 1);
  2761. +}
  2762. +
  2763. +void
  2764. +PVRDRIDrawableRemoveReference(PVRDRIDrawable *psPVRDrawable)
  2765. +{
  2766. + int iRefCount = p_atomic_dec_return(&psPVRDrawable->iRefCount);
  2767. +
  2768. + assert(iRefCount >= 0);
  2769. +
  2770. + if (iRefCount != 0)
  2771. + return;
  2772. +
  2773. + DRISUPDestroyDrawable(psPVRDrawable->psDRISUPDrawable);
  2774. +
  2775. +#if defined(DEBUG)
  2776. + p_atomic_dec(&psPVRDrawable->psPVRScreen->iDrawableAlloc);
  2777. +#endif
  2778. +
  2779. + PVRDRIScreenRemoveReference(psPVRDrawable->psPVRScreen);
  2780. + free(psPVRDrawable);
  2781. +}
  2782. +
  2783. +static void
  2784. +PVRScreenPrintExtensions(__DRIscreen *psDRIScreen)
  2785. +{
  2786. + /* Don't attempt to print anything if LIBGL_DEBUG isn't in the environment */
  2787. + if (getenv("LIBGL_DEBUG") == NULL)
  2788. + return;
  2789. +
  2790. + if (psDRIScreen->extensions) {
  2791. + const __DRIextension *psScreenExtensionVersionInfo =
  2792. + PVRDRIScreenExtensionVersionInfo();
  2793. + int i;
  2794. + int j;
  2795. +
  2796. + __driUtilMessage("Supported screen extensions:");
  2797. +
  2798. + for (i = 0; psDRIScreen->extensions[i]; i++) {
  2799. + for (j = 0; psScreenExtensionVersionInfo[j].name; j++) {
  2800. + if (strcmp(psDRIScreen->extensions[i]->name,
  2801. + psScreenExtensionVersionInfo[j].name) == 0) {
  2802. + __driUtilMessage("\t%s (supported version: %u - max version: %u)",
  2803. + psDRIScreen->extensions[i]->name,
  2804. + psDRIScreen->extensions[i]->version,
  2805. + psScreenExtensionVersionInfo[j].version);
  2806. + break;
  2807. + }
  2808. + }
  2809. +
  2810. + if (psScreenExtensionVersionInfo[j].name == NULL) {
  2811. + __driUtilMessage("\t%s (supported version: %u - max version: unknown)",
  2812. + psDRIScreen->extensions[i]->name,
  2813. + psDRIScreen->extensions[i]->version);
  2814. + }
  2815. + }
  2816. + } else {
  2817. + __driUtilMessage("No screen extensions found");
  2818. + }
  2819. +}
  2820. +
  2821. +/*************************************************************************//*!
  2822. + Mesa driver API functions
  2823. + *//**************************************************************************/
  2824. +
  2825. +static const __DRIconfig **
  2826. +PVRDRIInitScreen(__DRIscreen *psDRIScreen)
  2827. +{
  2828. + PVRDRIScreen *psPVRScreen;
  2829. + const __DRIconfig **ppsConfigs;
  2830. + int iMaxGLES1Version, iMaxGLES2Version;
  2831. + const struct PVRDRICallbacksV2 sDRICallbacksV2 = {
  2832. + /* Version 0 callbacks */
  2833. + .v0.RegisterSupportInterface = MODSUPRegisterSupportInterfaceV2,
  2834. + .v0.GetBuffers = MODSUPGetBuffers,
  2835. + .v0.CreateConfigs = MODSUPCreateConfigs,
  2836. + .v0.ConcatConfigs = MODSUPConcatConfigs,
  2837. + .v0.ConfigQuery = MODSUPConfigQuery,
  2838. + .v0.LookupEGLImage = MODSUPLookupEGLImage,
  2839. + .v0.GetCapability = MODSUPGetCapability,
  2840. + /* Version 1 callbacks */
  2841. + .v1.FlushFrontBuffer = MODSUPFlushFrontBuffer,
  2842. + /* Version 2 callbacks */
  2843. + .v2.GetDisplayFD = MODSUPGetDisplayFD,
  2844. + /* Version 3 callbacks */
  2845. + .v3.DrawableGetReferenceHandle = MODSUPDrawableGetReferenceHandle,
  2846. + .v3.DrawableAddReference = MODSUPDrawableAddReference,
  2847. + .v3.DrawableRemoveReference = MODSUPDrawableRemoveReference,
  2848. + };
  2849. +
  2850. + if (!PVRLoaderIsSupported(psDRIScreen))
  2851. + return NULL;
  2852. +
  2853. + if (!PVRDRICompatInit(&sDRICallbacksV2, 3, 0))
  2854. + return NULL;
  2855. +
  2856. + psPVRScreen = calloc(1, sizeof(*psPVRScreen));
  2857. + if (psPVRScreen == NULL) {
  2858. + __driUtilMessage("%s: Couldn't allocate PVRDRIScreen", __func__);
  2859. + goto ErrorCompatDeinit;
  2860. + }
  2861. +
  2862. + psDRIScreen->driverPrivate = psPVRScreen;
  2863. + psPVRScreen->psDRIScreen = psDRIScreen;
  2864. + psPVRScreen->iRefCount = 1;
  2865. +
  2866. + psPVRScreen->psDRISUPScreen =
  2867. + DRISUPCreateScreen(psDRIScreen, psDRIScreen->fd,
  2868. + psDRIScreen->dri2.useInvalidate != NULL,
  2869. + psDRIScreen->loaderPrivate,
  2870. + &ppsConfigs, &iMaxGLES1Version, &iMaxGLES2Version);
  2871. + if (!psPVRScreen->psDRISUPScreen)
  2872. + goto ErrorScreenFree;
  2873. +
  2874. + psDRIScreen->max_gl_es1_version = iMaxGLES1Version;
  2875. + psDRIScreen->max_gl_es2_version = iMaxGLES2Version;
  2876. +
  2877. + psDRIScreen->max_gl_compat_version =
  2878. + DRISUPGetAPIVersion(psPVRScreen->psDRISUPScreen, PVRDRI_API_GL_COMPAT);
  2879. + psDRIScreen->max_gl_core_version =
  2880. + DRISUPGetAPIVersion(psPVRScreen->psDRISUPScreen, PVRDRI_API_GL_CORE);
  2881. +
  2882. + psDRIScreen->extensions = PVRDRIScreenExtensions();
  2883. +
  2884. + PVRScreenPrintExtensions(psDRIScreen);
  2885. +
  2886. + return ppsConfigs;
  2887. +
  2888. +ErrorScreenFree:
  2889. + psDRIScreen->driverPrivate = NULL;
  2890. + free(psPVRScreen);
  2891. +
  2892. +ErrorCompatDeinit:
  2893. + PVRDRICompatDeinit();
  2894. +
  2895. + return NULL;
  2896. +}
  2897. +
  2898. +static void
  2899. +PVRDRIDestroyScreen(__DRIscreen *psDRIScreen)
  2900. +{
  2901. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  2902. +
  2903. +#if defined(DEBUG)
  2904. + if (psPVRScreen->iBufferAlloc != 0 ||
  2905. + psPVRScreen->iDrawableAlloc != 0 ||
  2906. + psPVRScreen->iContextAlloc != 0) {
  2907. + errorMessage("%s: Outstanding allocations: Contexts: %d Drawables: %d Buffers: %d",
  2908. + __func__, psPVRScreen->iContextAlloc,
  2909. + psPVRScreen->iDrawableAlloc, psPVRScreen->iBufferAlloc);
  2910. +
  2911. + if (psPVRScreen->iRefCount > 1) {
  2912. + errorMessage("%s: PVRDRIScreen resources will not be freed until its %d references are removed",
  2913. + __func__, psPVRScreen->iRefCount - 1);
  2914. + }
  2915. + }
  2916. +#endif
  2917. +
  2918. + PVRDRIScreenRemoveReference(psPVRScreen);
  2919. +}
  2920. +
  2921. +static int
  2922. +PVRDRIScreenSupportedAPIs(PVRDRIScreen *psPVRScreen)
  2923. +{
  2924. + unsigned int api_mask = psPVRScreen->psDRIScreen->api_mask;
  2925. + int supported = 0;
  2926. +
  2927. + if ((api_mask & (1 << __DRI_API_GLES)) != 0)
  2928. + supported |= PVRDRI_API_BIT_GLES;
  2929. +
  2930. + if ((api_mask & (1 << __DRI_API_GLES2)) != 0)
  2931. + supported |= PVRDRI_API_BIT_GLES2;
  2932. +
  2933. + if ((api_mask & (1 << __DRI_API_GLES3)) != 0)
  2934. + supported |= PVRDRI_API_BIT_GLES3;
  2935. +
  2936. + if ((api_mask & (1 << __DRI_API_OPENGL)) != 0)
  2937. + supported |= PVRDRI_API_BIT_GL;
  2938. +
  2939. + if ((api_mask & (1 << __DRI_API_OPENGL_CORE)) != 0)
  2940. + supported |= PVRDRI_API_BIT_GL;
  2941. +
  2942. + return supported;
  2943. +}
  2944. +
  2945. +static GLboolean
  2946. +PVRDRICreateContext(gl_api eMesaAPI, const struct gl_config *psGLMode,
  2947. + __DRIcontext *psDRIContext,
  2948. + const struct __DriverContextConfig *psCtxConfig,
  2949. + unsigned int *puError, void *pvSharedContextPrivate)
  2950. +{
  2951. + __DRIscreen *psDRIScreen = psDRIContext->driScreenPriv;
  2952. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  2953. + PVRDRIContext *psPVRContext;
  2954. + struct DRISUPContext *psDRISUPContext;
  2955. + struct DRISUPContext *psDRISUPSharedContext;
  2956. + struct PVRDRIContextConfig sCtxConfig;
  2957. + PVRDRIAPIType eAPI;
  2958. +
  2959. + psDRISUPSharedContext = getSharedContextImpl(pvSharedContextPrivate);
  2960. +
  2961. + sCtxConfig.uMajorVersion = psCtxConfig->major_version;
  2962. + sCtxConfig.uMinorVersion = psCtxConfig->minor_version;
  2963. + sCtxConfig.uFlags = psCtxConfig->flags;
  2964. + sCtxConfig.iResetStrategy = __DRI_CTX_RESET_NO_NOTIFICATION;
  2965. + sCtxConfig.uPriority = __DRI_CTX_PRIORITY_MEDIUM;
  2966. + sCtxConfig.iReleaseBehavior = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
  2967. +
  2968. + psPVRContext = calloc(1, sizeof(*psPVRContext));
  2969. + if (psPVRContext == NULL) {
  2970. + __driUtilMessage("%s: Couldn't allocate PVRDRIContext", __func__);
  2971. + *puError = __DRI_CTX_ERROR_NO_MEMORY;
  2972. + return GL_FALSE;
  2973. + }
  2974. +
  2975. + psPVRContext->psDRIContext = psDRIContext;
  2976. + psPVRContext->psPVRScreen = psPVRScreen;
  2977. +
  2978. + if (psGLMode)
  2979. + psPVRContext->sConfig.sGLMode = *psGLMode;
  2980. +
  2981. + switch (eMesaAPI) {
  2982. + case API_OPENGLES:
  2983. + eAPI = PVRDRI_API_GLES1;
  2984. + break;
  2985. + case API_OPENGLES2:
  2986. + eAPI = PVRDRI_API_GLES2;
  2987. + break;
  2988. + case API_OPENGL_COMPAT:
  2989. + eAPI = PVRDRI_API_GL_COMPAT;
  2990. + break;
  2991. + case API_OPENGL_CORE:
  2992. + eAPI = PVRDRI_API_GL_CORE;
  2993. + break;
  2994. + default:
  2995. + __driUtilMessage("%s: Unsupported API: %d",
  2996. + __func__, (int) eMesaAPI);
  2997. + *puError = __DRI_CTX_ERROR_BAD_API;
  2998. + goto ErrorContextFree;
  2999. + }
  3000. + psPVRContext->eAPI = eAPI;
  3001. +
  3002. + if ((psCtxConfig->attribute_mask &
  3003. + __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY) != 0) {
  3004. + sCtxConfig.iResetStrategy = psCtxConfig->reset_strategy;
  3005. + }
  3006. +
  3007. + if ((psCtxConfig->attribute_mask &
  3008. + __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR) != 0) {
  3009. + sCtxConfig.iReleaseBehavior = psCtxConfig->release_behavior;
  3010. + }
  3011. +
  3012. + if ((psCtxConfig->attribute_mask &
  3013. + __DRIVER_CONTEXT_ATTRIB_PRIORITY) != 0) {
  3014. + sCtxConfig.uPriority = psCtxConfig->priority;
  3015. + }
  3016. +
  3017. + *puError = DRISUPCreateContext(eAPI, &psPVRContext->sConfig, &sCtxConfig,
  3018. + psDRIContext, psDRISUPSharedContext,
  3019. + psPVRScreen->psDRISUPScreen,
  3020. + &psDRISUPContext);
  3021. + if (*puError != __DRI_CTX_ERROR_SUCCESS)
  3022. + goto ErrorContextFree;
  3023. +
  3024. + psPVRContext->psDRISUPContext = psDRISUPContext;
  3025. +
  3026. + if (!pvrdri_create_dispatch_table(psPVRScreen, eAPI)) {
  3027. + __driUtilMessage("%s: Couldn't create dispatch table", __func__);
  3028. + *puError = __DRI_CTX_ERROR_BAD_API;
  3029. + goto ErrorContextDestroy;
  3030. + }
  3031. +#if defined(DEBUG)
  3032. + p_atomic_inc(&psPVRScreen->iContextAlloc);
  3033. +#endif
  3034. +
  3035. + psDRIContext->driverPrivate = (void *) psPVRContext;
  3036. + PVRDRIScreenAddReference(psPVRScreen);
  3037. +
  3038. + *puError = __DRI_CTX_ERROR_SUCCESS;
  3039. +
  3040. + return GL_TRUE;
  3041. +
  3042. +ErrorContextDestroy:
  3043. + DRISUPDestroyContext(psPVRContext->psDRISUPContext);
  3044. +
  3045. +ErrorContextFree:
  3046. + free(psPVRContext);
  3047. +
  3048. + return GL_FALSE;
  3049. +}
  3050. +
  3051. +static void
  3052. +PVRDRIDestroyContext(__DRIcontext *psDRIContext)
  3053. +{
  3054. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3055. + PVRDRIScreen *psPVRScreen = psPVRContext->psPVRScreen;
  3056. +
  3057. + DRISUPDestroyContext(psPVRContext->psDRISUPContext);
  3058. +
  3059. +#if defined(DEBUG)
  3060. + p_atomic_dec(&psPVRScreen->iContextAlloc);
  3061. +#endif
  3062. +
  3063. + PVRDRIScreenRemoveReference(psPVRScreen);
  3064. + free(psPVRContext);
  3065. +}
  3066. +
  3067. +static GLboolean
  3068. +PVRDRICreateBuffer(__DRIscreen *psDRIScreen, __DRIdrawable *psDRIDrawable,
  3069. + const struct gl_config *psGLMode, GLboolean bIsPixmap)
  3070. +{
  3071. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3072. + PVRDRIDrawable *psPVRDrawable = NULL;
  3073. +
  3074. + /* No known callers ever set this to true */
  3075. + if (bIsPixmap)
  3076. + return GL_FALSE;
  3077. +
  3078. + if (!psGLMode) {
  3079. + __driUtilMessage("%s: Invalid GL config", __func__);
  3080. + return GL_FALSE;
  3081. + }
  3082. +
  3083. + psPVRDrawable = calloc(1, sizeof(*psPVRDrawable));
  3084. + if (!psPVRDrawable) {
  3085. + __driUtilMessage("%s: Couldn't allocate PVR drawable", __func__);
  3086. + goto ErrorDrawableFree;
  3087. + }
  3088. +
  3089. + psDRIDrawable->driverPrivate = (void *) psPVRDrawable;
  3090. + psPVRDrawable->iRefCount = 1;
  3091. + psPVRDrawable->psDRIDrawable = psDRIDrawable;
  3092. + psPVRDrawable->psPVRScreen = psPVRScreen;
  3093. + psPVRDrawable->sConfig.sGLMode = *psGLMode;
  3094. + psPVRDrawable->sConfig.iSupportedAPIs =
  3095. + PVRDRIScreenSupportedAPIs(psPVRScreen);
  3096. +
  3097. + psPVRDrawable->psDRISUPDrawable =
  3098. + DRISUPCreateDrawable(psDRIDrawable, psPVRScreen->psDRISUPScreen,
  3099. + psDRIDrawable->loaderPrivate,
  3100. + &psPVRDrawable->sConfig);
  3101. + if (!psPVRDrawable->psDRISUPDrawable) {
  3102. + __driUtilMessage("%s: Couldn't create DRI Support drawable",
  3103. + __func__);
  3104. + goto ErrorDrawableFree;
  3105. + }
  3106. +
  3107. + /* Initialisation is completed in MakeCurrent */
  3108. +#if defined(DEBUG)
  3109. + p_atomic_inc(&psPVRScreen->iDrawableAlloc);
  3110. +#endif
  3111. + PVRDRIScreenAddReference(psPVRScreen);
  3112. + return GL_TRUE;
  3113. +
  3114. +ErrorDrawableFree:
  3115. + DRISUPDestroyDrawable(psPVRDrawable->psDRISUPDrawable);
  3116. + free(psPVRDrawable);
  3117. + psDRIDrawable->driverPrivate = NULL;
  3118. +
  3119. + return GL_FALSE;
  3120. +}
  3121. +
  3122. +static void
  3123. +PVRDRIDestroyBuffer(__DRIdrawable *psDRIDrawable)
  3124. +{
  3125. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  3126. +
  3127. + PVRDRIDrawableRemoveReference(psPVRDrawable);
  3128. +}
  3129. +
  3130. +static GLboolean
  3131. +PVRDRIMakeCurrent(__DRIcontext *psDRIContext,
  3132. + __DRIdrawable *psDRIWrite, __DRIdrawable *psDRIRead)
  3133. +{
  3134. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3135. + struct DRISUPDrawable *psDRISUPWrite;
  3136. + struct DRISUPDrawable *psDRISUPRead;
  3137. +
  3138. + if (psDRIWrite) {
  3139. + PVRDRIDrawable *psPVRWrite = psDRIWrite->driverPrivate;
  3140. +
  3141. + psDRISUPWrite = psPVRWrite->psDRISUPDrawable;
  3142. + } else {
  3143. + psDRISUPWrite = NULL;
  3144. + }
  3145. +
  3146. + if (psDRIRead) {
  3147. + PVRDRIDrawable *psPVRRead = psDRIRead->driverPrivate;
  3148. +
  3149. + psDRISUPRead = psPVRRead->psDRISUPDrawable;
  3150. + } else {
  3151. + psDRISUPRead = NULL;
  3152. + }
  3153. +
  3154. + if (!DRISUPMakeCurrent(psPVRContext->psDRISUPContext,
  3155. + psDRISUPWrite, psDRISUPRead))
  3156. + goto ErrorUnlock;
  3157. +
  3158. + pvrdri_set_dispatch_table(psPVRContext);
  3159. +
  3160. + return GL_TRUE;
  3161. +
  3162. +ErrorUnlock:
  3163. + return GL_FALSE;
  3164. +}
  3165. +
  3166. +static GLboolean
  3167. +PVRDRIUnbindContext(__DRIcontext *psDRIContext)
  3168. +{
  3169. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3170. +
  3171. + pvrdri_set_null_dispatch_table();
  3172. + DRISUPUnbindContext(psPVRContext->psDRISUPContext);
  3173. +
  3174. + return GL_TRUE;
  3175. +}
  3176. +
  3177. +static __DRIbuffer *
  3178. +PVRDRIAllocateBuffer(__DRIscreen *psDRIScreen, unsigned int uAttachment,
  3179. + unsigned int uFormat, int iWidth, int iHeight)
  3180. +{
  3181. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3182. + struct PVRBuffer *psBuffer;
  3183. +
  3184. + psBuffer = calloc(1, sizeof(*psBuffer));
  3185. + if (psBuffer == NULL) {
  3186. + __driUtilMessage("%s: Failed to allocate buffer", __func__);
  3187. + return NULL;
  3188. + }
  3189. +
  3190. + psBuffer->psDRISUPBuffer =
  3191. + DRISUPAllocateBuffer(psPVRScreen->psDRISUPScreen, uAttachment, uFormat,
  3192. + iWidth, iHeight, &psBuffer->sDRIBuffer.name,
  3193. + &psBuffer->sDRIBuffer.pitch,
  3194. + &psBuffer->sDRIBuffer.cpp,
  3195. + &psBuffer->sDRIBuffer.flags);
  3196. + if (!psBuffer->psDRISUPBuffer) {
  3197. + __driUtilMessage("%s: Failed to create DRI Support buffer", __func__);
  3198. + goto ErrorFreeDRIBuffer;
  3199. + }
  3200. +
  3201. + psBuffer->sDRIBuffer.attachment = uAttachment;
  3202. +
  3203. +#if defined(DEBUG)
  3204. + p_atomic_inc(&psPVRScreen->iBufferAlloc);
  3205. +#endif
  3206. +
  3207. + return &psBuffer->sDRIBuffer;
  3208. +
  3209. +ErrorFreeDRIBuffer:
  3210. + free(psBuffer);
  3211. +
  3212. + return NULL;
  3213. +}
  3214. +
  3215. +static void
  3216. +PVRDRIReleaseBuffer(__DRIscreen *psDRIScreen, __DRIbuffer *psDRIBuffer)
  3217. +{
  3218. + struct PVRBuffer *psPVRBuffer = (struct PVRBuffer *) psDRIBuffer;
  3219. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3220. +
  3221. + DRISUPReleaseBuffer(psPVRScreen->psDRISUPScreen,
  3222. + psPVRBuffer->psDRISUPBuffer);
  3223. +
  3224. +#if defined(DEBUG)
  3225. + p_atomic_dec(&psPVRScreen->iBufferAlloc);
  3226. +#endif
  3227. +
  3228. + free(psPVRBuffer);
  3229. +}
  3230. +
  3231. +static const struct __DriverAPIRec pvr_driver_api = {
  3232. + .InitScreen = PVRDRIInitScreen,
  3233. + .DestroyScreen = PVRDRIDestroyScreen,
  3234. + .CreateContext = PVRDRICreateContext,
  3235. + .DestroyContext = PVRDRIDestroyContext,
  3236. + .CreateBuffer = PVRDRICreateBuffer,
  3237. + .DestroyBuffer = PVRDRIDestroyBuffer,
  3238. + .SwapBuffers = NULL,
  3239. + .MakeCurrent = PVRDRIMakeCurrent,
  3240. + .UnbindContext = PVRDRIUnbindContext,
  3241. + .AllocateBuffer = PVRDRIAllocateBuffer,
  3242. + .ReleaseBuffer = PVRDRIReleaseBuffer,
  3243. +};
  3244. +
  3245. +static const struct __DRIDriverVtableExtensionRec pvr_vtable = {
  3246. + .base = {__DRI_DRIVER_VTABLE, 1},
  3247. + .vtable = &pvr_driver_api,
  3248. +};
  3249. +
  3250. +static const __DRIextension *pvr_driver_extensions[] = {
  3251. + &driCoreExtension.base,
  3252. + &driImageDriverExtension.base,
  3253. + &driDRI2Extension.base,
  3254. + &pvr_vtable.base,
  3255. + NULL
  3256. +};
  3257. +
  3258. +const __DRIextension **__driDriverGetExtensions_pvr(void);
  3259. +
  3260. +PUBLIC const __DRIextension **
  3261. +__driDriverGetExtensions_pvr(void)
  3262. +{
  3263. + globalDriverAPI = &pvr_driver_api;
  3264. +
  3265. + return pvr_driver_extensions;
  3266. +}
  3267. diff --git a/src/mesa/drivers/dri/pvr/pvrdri.h b/src/mesa/drivers/dri/pvr/pvrdri.h
  3268. new file mode 100644
  3269. index 0000000..fd465bf
  3270. --- /dev/null
  3271. +++ b/src/mesa/drivers/dri/pvr/pvrdri.h
  3272. @@ -0,0 +1,188 @@
  3273. +/*
  3274. + * Copyright (c) Imagination Technologies Ltd.
  3275. + *
  3276. + * The contents of this file are subject to the MIT license as set out below.
  3277. + *
  3278. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  3279. + * of this software and associated documentation files (the "Software"), to deal
  3280. + * in the Software without restriction, including without limitation the rights
  3281. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3282. + * copies of the Software, and to permit persons to whom the Software is
  3283. + * furnished to do so, subject to the following conditions:
  3284. + *
  3285. + * The above copyright notice and this permission notice shall be included in
  3286. + * all copies or substantial portions of the Software.
  3287. + *
  3288. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3289. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3290. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3291. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3292. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3293. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3294. + * THE SOFTWARE.
  3295. + */
  3296. +
  3297. +#if !defined(__PVRDRI_H__)
  3298. +#define __PVRDRI_H__
  3299. +
  3300. +#include <stdbool.h>
  3301. +#include <stdint.h>
  3302. +#include <inttypes.h>
  3303. +
  3304. +#include <glapi/glapi.h>
  3305. +
  3306. +#include "main/mtypes.h"
  3307. +#include "util/macros.h"
  3308. +#include "dri_util.h"
  3309. +#include "pvrdri_support.h"
  3310. +
  3311. +struct PVRDRIConfigRec {
  3312. + struct gl_config sGLMode;
  3313. + int iSupportedAPIs;
  3314. +};
  3315. +
  3316. +/* PVR screen data */
  3317. +typedef struct PVRDRIScreen_TAG {
  3318. + /* DRI screen structure pointer */
  3319. + __DRIscreen *psDRIScreen;
  3320. +
  3321. + /* Opaque PVR DRI Support screen structure pointer */
  3322. + struct DRISUPScreen *psDRISUPScreen;
  3323. +
  3324. + /* Reference count */
  3325. + int iRefCount;
  3326. +
  3327. +#if defined(DEBUG)
  3328. + /* Counters of outstanding allocations */
  3329. + int iContextAlloc;
  3330. + int iDrawableAlloc;
  3331. + int iBufferAlloc;
  3332. +#endif
  3333. +
  3334. + /* PVR OGLES 1 dispatch table */
  3335. + struct _glapi_table *psOGLES1Dispatch;
  3336. + /* PVR OGLES 2/3 dispatch table */
  3337. + struct _glapi_table *psOGLES2Dispatch;
  3338. + /* PVR OGL dispatch table */
  3339. + struct _glapi_table *psOGLDispatch;
  3340. +} PVRDRIScreen;
  3341. +
  3342. +/* PVR context data */
  3343. +typedef struct PVRDRIContext_TAG {
  3344. + /* Pointer to DRI context */
  3345. + __DRIcontext *psDRIContext;
  3346. +
  3347. + /* Opaque PVR DRI Support context structure pointer */
  3348. + struct DRISUPContext *psDRISUPContext;
  3349. +
  3350. + /* Pointer to PVRDRIScreen structure */
  3351. + PVRDRIScreen *psPVRScreen;
  3352. +
  3353. + /* GL config */
  3354. + PVRDRIConfig sConfig;
  3355. +
  3356. + /* API */
  3357. + PVRDRIAPIType eAPI;
  3358. +} PVRDRIContext;
  3359. +
  3360. +/* PVR drawable data */
  3361. +typedef struct PVRDRIDrawable_TAG {
  3362. + PVRDRIScreen *psPVRScreen;
  3363. + __DRIdrawable *psDRIDrawable;
  3364. + int iRefCount;
  3365. + PVRDRIConfig sConfig;
  3366. + struct DRISUPDrawable *psDRISUPDrawable;
  3367. + unsigned int uFourCC;
  3368. + unsigned int uDRIFormat;
  3369. +} PVRDRIDrawable;
  3370. +
  3371. +/*************************************************************************//*!
  3372. + pvrdri.c
  3373. + *//**************************************************************************/
  3374. +void PVRDRIDrawableAddReference(PVRDRIDrawable *psPVRDrawable);
  3375. +void PVRDRIDrawableRemoveReference(PVRDRIDrawable *psPVRDrawable);
  3376. +
  3377. +/*************************************************************************//*!
  3378. + pvrutil.c
  3379. + *//**************************************************************************/
  3380. +
  3381. +void PRINTFLIKE(1, 2) __driUtilMessage(const char *f, ...);
  3382. +void PRINTFLIKE(1, 2) errorMessage(const char *f, ...);
  3383. +
  3384. +mesa_format PVRDRIMesaFormatToMesaFormat(int pvrdri_mesa_format);
  3385. +int PVRDRIFormatToFourCC(int dri_format);
  3386. +int PVRDRIFourCCToDRIFormat(int iFourCC);
  3387. +
  3388. +/*************************************************************************//*!
  3389. + pvrext.c
  3390. + *//**************************************************************************/
  3391. +
  3392. +const __DRIextension **PVRDRIScreenExtensions(void);
  3393. +const __DRIextension *PVRDRIScreenExtensionVersionInfo(void);
  3394. +
  3395. +void PVRDRIAdjustExtensions(unsigned int uVersion, unsigned int uMinVersion);
  3396. +
  3397. +/*************************************************************************//*!
  3398. + pvrcompat.c
  3399. + *//**************************************************************************/
  3400. +
  3401. +bool PVRDRICompatInit(const struct PVRDRICallbacksV2 *psCallbacksV2,
  3402. + unsigned int uVersionV2, unsigned int uMinVersionV2);
  3403. +void PVRDRICompatDeinit(void);
  3404. +
  3405. +bool MODSUPRegisterSupportInterfaceV2(const void *pvInterface,
  3406. + unsigned int uVersion,
  3407. + unsigned int uMinVersion);
  3408. +
  3409. +/*************************************************************************//*!
  3410. + pvrcb.c
  3411. + *//**************************************************************************/
  3412. +
  3413. +int MODSUPGetBuffers(struct __DRIdrawableRec *psDRIDrawable,
  3414. + unsigned int uFourCC, uint32_t *puStamp,
  3415. + void *pvLoaderPrivate, uint32_t uBufferMask,
  3416. + struct PVRDRIImageList *psImageList);
  3417. +
  3418. +bool MODSUPCreateConfigs(struct __DRIconfigRec ***psConfigs,
  3419. + struct __DRIscreenRec *psDRIScreen,
  3420. + int iPVRDRIMesaFormat, const uint8_t *puDepthBits,
  3421. + const uint8_t *puStencilBits,
  3422. + unsigned int uNumDepthStencilBits,
  3423. + const unsigned int *puDBModes,
  3424. + unsigned int uNumDBModes,
  3425. + const uint8_t *puMSAASamples,
  3426. + unsigned int uNumMSAAModes, bool bEnableAccum,
  3427. + bool bColorDepthMatch, bool bMutableRenderBuffer,
  3428. + int iYUVDepthRange, int iYUVCSCStandard,
  3429. + uint32_t uMaxPbufferWidth, uint32_t uMaxPbufferHeight);
  3430. +
  3431. +struct __DRIconfigRec **MODSUPConcatConfigs(struct __DRIscreenRec *psDRIScreen,
  3432. + struct __DRIconfigRec **ppsConfigA,
  3433. + struct __DRIconfigRec **ppsConfigB);
  3434. +
  3435. +__DRIimage *MODSUPLookupEGLImage(struct __DRIscreenRec *psDRIScreen,
  3436. + void *pvImage, void *pvLoaderPrivate);
  3437. +
  3438. +unsigned int MODSUPGetCapability(struct __DRIscreenRec *psDRIScreen,
  3439. + unsigned int uCapability);
  3440. +
  3441. +int MODSUPGetDisplayFD(struct __DRIscreenRec *psDRIScreen,
  3442. + void *pvLoaderPrivate);
  3443. +
  3444. +bool PVRDRIConfigQuery(const PVRDRIConfig *psConfig,
  3445. + PVRDRIConfigAttrib eConfigAttrib, int *piValueOut);
  3446. +
  3447. +bool MODSUPConfigQuery(const PVRDRIConfig *psConfig,
  3448. + PVRDRIConfigAttrib eConfigAttrib,
  3449. + unsigned int *puValueOut);
  3450. +
  3451. +void MODSUPFlushFrontBuffer(struct __DRIdrawableRec *psDRIDrawable,
  3452. + void *pvLoaderPrivate);
  3453. +
  3454. +void *MODSUPDrawableGetReferenceHandle(struct __DRIdrawableRec *psDRIDrawable);
  3455. +
  3456. +void MODSUPDrawableAddReference(void *pvReferenceHandle);
  3457. +
  3458. +void MODSUPDrawableRemoveReference(void *pvReferenceHandle);
  3459. +
  3460. +#endif /* defined(__PVRDRI_H__) */
  3461. diff --git a/src/mesa/drivers/dri/pvr/pvrdri_support.h b/src/mesa/drivers/dri/pvr/pvrdri_support.h
  3462. new file mode 100644
  3463. index 0000000..58ea350
  3464. --- /dev/null
  3465. +++ b/src/mesa/drivers/dri/pvr/pvrdri_support.h
  3466. @@ -0,0 +1,206 @@
  3467. +/*
  3468. + * Copyright (c) Imagination Technologies Ltd.
  3469. + *
  3470. + * The contents of this file are subject to the MIT license as set out below.
  3471. + *
  3472. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  3473. + * of this software and associated documentation files (the "Software"), to deal
  3474. + * in the Software without restriction, including without limitation the rights
  3475. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3476. + * copies of the Software, and to permit persons to whom the Software is
  3477. + * furnished to do so, subject to the following conditions:
  3478. + *
  3479. + * The above copyright notice and this permission notice shall be included in
  3480. + * all copies or substantial portions of the Software.
  3481. + *
  3482. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3483. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3484. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3485. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3486. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3487. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3488. + * THE SOFTWARE.
  3489. + */
  3490. +
  3491. +#if !defined(__PVRDRI_SUPPORT_H__)
  3492. +#define __PVRDRI_SUPPORT_H__
  3493. +
  3494. +#include <stdint.h>
  3495. +#include <stdbool.h>
  3496. +
  3497. +#include "dri_support.h"
  3498. +
  3499. +struct DRISUPScreen *DRISUPCreateScreen(struct __DRIscreenRec *psDRIScreen,
  3500. + int iFD, bool bUseInvalidate,
  3501. + void *pvLoaderPrivate,
  3502. + const struct __DRIconfigRec ***pppsConfigs,
  3503. + int *piMaxGLES1Version,
  3504. + int *piMaxGLES2Version);
  3505. +void DRISUPDestroyScreen(struct DRISUPScreen *psDRISUPScreen);
  3506. +
  3507. +unsigned int DRISUPCreateContext(PVRDRIAPIType eAPI,
  3508. + PVRDRIConfig *psPVRDRIConfig,
  3509. + struct PVRDRIContextConfig *psCtxConfig,
  3510. + struct __DRIcontextRec *psDRIContext,
  3511. + struct DRISUPContext *psDRISUPSharedContext,
  3512. + struct DRISUPScreen *psDRISUPScreen,
  3513. + struct DRISUPContext **ppsDRISUPContext);
  3514. +void DRISUPDestroyContext(struct DRISUPContext *psDRISUPContext);
  3515. +
  3516. +struct DRISUPDrawable *DRISUPCreateDrawable(struct __DRIdrawableRec *psDRIDrawable,
  3517. + struct DRISUPScreen *psDRISUPScreen,
  3518. + void *pvLoaderPrivate,
  3519. + PVRDRIConfig *psPVRDRIConfig);
  3520. +void DRISUPDestroyDrawable(struct DRISUPDrawable *psDRISUPDrawable);
  3521. +
  3522. +bool DRISUPMakeCurrent(struct DRISUPContext *psDRISUPContext,
  3523. + struct DRISUPDrawable *psDRISUPWrite,
  3524. + struct DRISUPDrawable *psDRISUPRead);
  3525. +bool DRISUPUnbindContext(struct DRISUPContext *psDRISUPContext);
  3526. +
  3527. +struct DRISUPBuffer *DRISUPAllocateBuffer(struct DRISUPScreen *psDRISUPScreen,
  3528. + unsigned int uAttchment,
  3529. + unsigned int uFormat,
  3530. + int iWidth, int iHeight,
  3531. + unsigned int *puName,
  3532. + unsigned int *puPitch,
  3533. + unsigned int *puCPP,
  3534. + unsigned int *puFlags);
  3535. +void DRISUPReleaseBuffer(struct DRISUPScreen *psDRISUPScreen,
  3536. + struct DRISUPBuffer *psDRISUPBuffer);
  3537. +void DRISUPSetTexBuffer2(struct DRISUPContext *psDRISUPContext,
  3538. + int iTarget, int iFormat,
  3539. + struct DRISUPDrawable *psDRISUPDrawable);
  3540. +void DRISUPReleaseTexBuffer(struct DRISUPContext *psDRISUPContext,
  3541. + int iTarget,
  3542. + struct DRISUPDrawable *psDRISUPDrawable);
  3543. +
  3544. +void DRISUPFlush(struct DRISUPDrawable *psDRISUPDrawable);
  3545. +void DRISUPInvalidate(struct DRISUPDrawable *psDRISUPDrawable);
  3546. +void DRISUPFlushWithFlags(struct DRISUPContext *psDRISUPContext,
  3547. + struct DRISUPDrawable *psDRISUPDrawable,
  3548. + unsigned int uFlags, unsigned int uThrottleReason);
  3549. +
  3550. +__DRIimage *DRISUPCreateImageFromName(struct DRISUPScreen *psDRISUPScreen,
  3551. + int iWidth, int iHeight, int iFourCC,
  3552. + int iName, int iPitch,
  3553. + void *pvLoaderPrivate);
  3554. +__DRIimage *DRISUPCreateImageFromRenderbuffer(struct DRISUPContext *psDRISUPContext,
  3555. + int iRenderBuffer,
  3556. + void *pvLoaderPrivate);
  3557. +void DRISUPDestroyImage(__DRIimage *psImage);
  3558. +__DRIimage *DRISUPCreateImage(struct DRISUPScreen *psDRISUPScreen,
  3559. + int iWidth, int iHeight, int iFourCC,
  3560. + unsigned int uUse, void *pvLoaderPrivate);
  3561. +bool DRISUPQueryImage(__DRIimage *psImage, int iAttrib, int *piValue);
  3562. +__DRIimage *DRISUPDupImage(__DRIimage *psImage, void *pvLoaderPrivate);
  3563. +bool DRISUPValidateImageUsage(__DRIimage *psImage, unsigned int uUse);
  3564. +__DRIimage *DRISUPCreateImageFromNames(struct DRISUPScreen *psDRISUPScreen,
  3565. + int iWidth, int iHeight, int iFourCC,
  3566. + int *piNames, int iNumNames,
  3567. + int *piStrides, int *piOffsets,
  3568. + void *pvLoaderPrivate);
  3569. +__DRIimage *DRISUPFromPlanar(__DRIimage *psImage, int iPlane,
  3570. + void *pvLoaderPrivate);
  3571. +__DRIimage *DRISUPCreateImageFromTexture(struct DRISUPContext *psDRISUPContext,
  3572. + int iTarget, unsigned int uTexture,
  3573. + int iDepth, int iLevel,
  3574. + unsigned int *puError,
  3575. + void *pvLoaderPrivate);
  3576. +__DRIimage *DRISUPCreateImageFromFDs(struct DRISUPScreen *psDRISUPcreen,
  3577. + int iWidth, int iHeight, int iFourCC,
  3578. + int *piFDs, int iNumFDs,
  3579. + int *piStrides, int *piOffsets,
  3580. + void *pvLoaderPrivate);
  3581. +__DRIimage *DRISUPCreateImageFromDmaBufs(struct DRISUPScreen *psDRISUPScreen,
  3582. + int iWidth, int iHeight, int iFourCC,
  3583. + int *piFDs, int iNumFDs,
  3584. + int *piStrides, int *piOffsets,
  3585. + unsigned int uColorSpace,
  3586. + unsigned int uSampleRange,
  3587. + unsigned int uHorizSiting,
  3588. + unsigned int uVertSiting,
  3589. + unsigned int *puError,
  3590. + void *pvLoaderPrivate);
  3591. +int DRISUPGetImageCapabilities(struct DRISUPScreen *psDRISUPScreen);
  3592. +void DRISUPBlitImage(struct DRISUPContext *psDRISUPContext,
  3593. + __DRIimage *psDst, __DRIimage *psSrc,
  3594. + int iDstX0, int iDstY0, int iDstWidth, int iDstHeight,
  3595. + int iSrcX0, int iSrcY0, int iSrcWidth, int iSrcHeight,
  3596. + int iFlushFlag);
  3597. +void *DRISUPMapImage(struct DRISUPContext *psDRISUPContext,
  3598. + __DRIimage *psImage,
  3599. + int iX0, int iY0, int iWidth, int iHeight,
  3600. + unsigned int uFlags, int *piStride, void **ppvData);
  3601. +void DRISUPUnmapImage(struct DRISUPContext *psDRISUPContext,
  3602. + __DRIimage *psImage, void *pvData);
  3603. +__DRIimage *DRISUPCreateImageWithModifiers(struct DRISUPScreen *psDRISUPScreen,
  3604. + int iWidth, int iHeight, int iFourCC,
  3605. + const uint64_t *puModifiers,
  3606. + const unsigned int uModifierCount,
  3607. + void *pvLoaderPrivate);
  3608. +__DRIimage *DRISUPCreateImageFromDMABufs2(struct DRISUPScreen *psDRISUPScreen,
  3609. + int iWidth, int iHeight,
  3610. + int iFourCC, uint64_t uModifier,
  3611. + int *piFDs, int iNumFDs,
  3612. + int *piStrides, int *piOffsets,
  3613. + unsigned int uColorSpace,
  3614. + unsigned int uSampleRange,
  3615. + unsigned int uHorizSiting,
  3616. + unsigned int uVertSiting,
  3617. + unsigned int *puError,
  3618. + void *pvLoaderPrivate);
  3619. +
  3620. +bool DRISUPQueryDMABufFormats(struct DRISUPScreen *psDRISUPScreen, int iMax,
  3621. + int *piFormats, int *piCount);
  3622. +bool DRISUPQueryDMABufModifiers(struct DRISUPScreen *psDRISUPScreen,
  3623. + int iFourCC, int iMax, uint64_t *puModifiers,
  3624. + unsigned int *piExternalOnly, int *piCount);
  3625. +bool DRISUPQueryDMABufFormatModifierAttribs(struct DRISUPScreen *psDRISUPScreen,
  3626. + uint32_t uFourcc,
  3627. + uint64_t uModifier,
  3628. + int iAttrib, uint64_t *puValue);
  3629. +
  3630. +__DRIimage *DRISUPCreateImageFromRenderBuffer2(struct DRISUPContext *psDRISUPContext,
  3631. + int iRenderBuffer,
  3632. + void *pvLoaderPrivate,
  3633. + unsigned int *puError);
  3634. +
  3635. +__DRIimage *DRISUPCreateImageFromBuffer(struct DRISUPContext *psDRISUPContext,
  3636. + int iTarget, void *pvBuffer,
  3637. + unsigned int *puError,
  3638. + void *pvLoaderPrivate);
  3639. +
  3640. +int DRISUPQueryRendererInteger(struct DRISUPScreen *psDRISUPScreen,
  3641. + int iAttribute, unsigned int *puValue);
  3642. +int DRISUPQueryRendererString(struct DRISUPScreen *psDRISUPScreen,
  3643. + int iAttribute, const char **ppszValue);
  3644. +
  3645. +void *DRISUPCreateFence(struct DRISUPContext *psDRISUPContext);
  3646. +void DRISUPDestroyFence(struct DRISUPScreen *psDRISUPScreen, void *pvFence);
  3647. +bool DRISUPClientWaitSync(struct DRISUPContext *psDRISUPContext,
  3648. + void *pvFence, unsigned int uFlags,
  3649. + uint64_t uTimeout);
  3650. +void DRISUPServerWaitSync(struct DRISUPContext *psDRISUPContext,
  3651. + void *pvFence, unsigned int uFlags);
  3652. +unsigned int DRISUPGetFenceCapabilities(struct DRISUPScreen *psDRISUPScreen);
  3653. +void *DRISUPCreateFenceFD(struct DRISUPContext *psDRISUPContext, int iFD);
  3654. +int DRISUPGetFenceFD(struct DRISUPScreen *psDRISUPScreen, void *pvFence);
  3655. +void *DRISUPGetFenceFromCLEvent(struct DRISUPScreen *psDRISUPScreen,
  3656. + intptr_t iCLEvent);
  3657. +int DRISUPGetAPIVersion(struct DRISUPScreen *psDRISUPScreen,
  3658. + PVRDRIAPIType eAPI);
  3659. +
  3660. +unsigned int DRISUPGetNumAPIProcs(struct DRISUPScreen *psDRISUPScreen,
  3661. + PVRDRIAPIType eAPI);
  3662. +const char *DRISUPGetAPIProcName(struct DRISUPScreen *psDRISUPScreen,
  3663. + PVRDRIAPIType eAPI, unsigned int uIndex);
  3664. +void *DRISUPGetAPIProcAddress(struct DRISUPScreen *psDRISUPScreen,
  3665. + PVRDRIAPIType eAPI, unsigned int uIndex);
  3666. +
  3667. +void DRISUPSetDamageRegion(struct DRISUPDrawable *psDRISUPDrawable,
  3668. + unsigned int uNRects, int *piRects);
  3669. +
  3670. +bool DRISUPHaveGetFenceFromCLEvent(void);
  3671. +
  3672. +#endif /* defined(__PVRDRI_SUPPORT_H__) */
  3673. diff --git a/src/mesa/drivers/dri/pvr/pvrext.c b/src/mesa/drivers/dri/pvr/pvrext.c
  3674. new file mode 100644
  3675. index 0000000..4783996
  3676. --- /dev/null
  3677. +++ b/src/mesa/drivers/dri/pvr/pvrext.c
  3678. @@ -0,0 +1,704 @@
  3679. +/*
  3680. + * Copyright (c) Imagination Technologies Ltd.
  3681. + *
  3682. + * The contents of this file are subject to the MIT license as set out below.
  3683. + *
  3684. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  3685. + * of this software and associated documentation files (the "Software"), to deal
  3686. + * in the Software without restriction, including without limitation the rights
  3687. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3688. + * copies of the Software, and to permit persons to whom the Software is
  3689. + * furnished to do so, subject to the following conditions:
  3690. + *
  3691. + * The above copyright notice and this permission notice shall be included in
  3692. + * all copies or substantial portions of the Software.
  3693. + *
  3694. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3695. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3696. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3697. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3698. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3699. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3700. + * THE SOFTWARE.
  3701. + */
  3702. +
  3703. +/*
  3704. + * EXTENSION SUPPORT
  3705. + *
  3706. + * As the driver supports a range of Mesa versions it can be the case that it
  3707. + * needs to support different extensions and extension versions depending on
  3708. + * the version of Mesa that it's built against. As a guide the following rules
  3709. + * should be followed:
  3710. + *
  3711. + * 1) If an extension appears in some supported versions of Mesa but not others
  3712. + * then it should be protected by the extension define, e.g.:
  3713. + * #if defined(__DRI_IMAGE)
  3714. + * <code>
  3715. + * #endif
  3716. + *
  3717. + * However, if it appears in all versions then there's no need for it to
  3718. + * be protected.
  3719. + *
  3720. + * 2) Each driver supported extension should have a define for the maximum
  3721. + * version supported by the driver. This should be used when initialising
  3722. + * the corresponding extension structure. The Mesa extension version define
  3723. + * should *NOT* be used.
  3724. + *
  3725. + * 3) If the driver supports a range of versions for a given extension then
  3726. + * it should protect the extension code based on the Mesa extension version
  3727. + * define. For example, if the driver has to support versions 7 to 8 of the
  3728. + * __DRI_IMAGE extension then any fields, in the __DRIimageExtension
  3729. + * structure, that appear in version 8 but not 7 should be protected as
  3730. + * follows:
  3731. + * #if (__DRI_IMAGE_VERSION >= 8)
  3732. + * .createImageFromDmaBufs = PVRDRICreateImageFromDmaBufs,
  3733. + * #endif
  3734. + *
  3735. + * Obviously any other associated code should also be protected in the same
  3736. + * way.
  3737. + */
  3738. +
  3739. +#include "dri_util.h"
  3740. +#include "utils.h"
  3741. +
  3742. +#include "dri_support.h"
  3743. +#include "pvrdri.h"
  3744. +
  3745. +#include "EGL/egl.h"
  3746. +#include "EGL/eglext.h"
  3747. +#include "EGL/eglmesaext.h"
  3748. +
  3749. +/* Maximum version numbers for each supported extension */
  3750. +#define PVR_DRI_TEX_BUFFER_VERSION 3
  3751. +#define PVR_DRI2_FLUSH_VERSION 4
  3752. +#define PVR_DRI_IMAGE_VERSION 17
  3753. +#define PVR_DRI2_ROBUSTNESS_VERSION 1
  3754. +#define PVR_DRI2_FENCE_VERSION 2
  3755. +#define PVR_DRI2_RENDERER_QUERY_VERSION 1
  3756. +#define PVR_DRI2_BUFFER_DAMAGE_VERSION 1
  3757. +
  3758. +static void
  3759. +PVRDRIExtSetTexBuffer(__DRIcontext *psDRIContext, GLint iTarget,
  3760. + GLint iFormat, __DRIdrawable *psDRIDrawable)
  3761. +{
  3762. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  3763. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3764. +
  3765. + DRISUPSetTexBuffer2(psPVRContext->psDRISUPContext,
  3766. + iTarget, iFormat, psPVRDrawable->psDRISUPDrawable);
  3767. +}
  3768. +
  3769. +static void
  3770. +PVRDRIExtReleaseTexBuffer(__DRIcontext *psDRIContext, GLint iTarget,
  3771. + __DRIdrawable *psDRIDrawable)
  3772. +{
  3773. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  3774. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3775. +
  3776. + DRISUPReleaseTexBuffer(psPVRContext->psDRISUPContext,
  3777. + iTarget, psPVRDrawable->psDRISUPDrawable);
  3778. +
  3779. +}
  3780. +
  3781. +static __DRItexBufferExtension pvrDRITexBufferExtension = {
  3782. + .base = {
  3783. + .name = __DRI_TEX_BUFFER,
  3784. + .version = PVR_DRI_TEX_BUFFER_VERSION,
  3785. + },
  3786. + .setTexBuffer = NULL,
  3787. + .setTexBuffer2 = PVRDRIExtSetTexBuffer,
  3788. + .releaseTexBuffer = PVRDRIExtReleaseTexBuffer,
  3789. +};
  3790. +
  3791. +static void
  3792. +PVRDRI2Flush(__DRIdrawable *psDRIDrawable)
  3793. +{
  3794. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  3795. +
  3796. + DRISUPFlush(psPVRDrawable->psDRISUPDrawable);
  3797. +}
  3798. +
  3799. +static void
  3800. +PVRDRI2Invalidate(__DRIdrawable *psDRIDrawable)
  3801. +{
  3802. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  3803. +
  3804. + DRISUPInvalidate(psPVRDrawable->psDRISUPDrawable);
  3805. +}
  3806. +
  3807. +static void
  3808. +PVRDRI2FlushWithFlags(__DRIcontext *psDRIContext,
  3809. + __DRIdrawable *psDRIDrawable,
  3810. + unsigned int uFlags,
  3811. + enum __DRI2throttleReason eThrottleReason)
  3812. +{
  3813. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3814. + struct DRISUPDrawable *psDRISUPDrawable;
  3815. +
  3816. + if ((uFlags & __DRI2_FLUSH_DRAWABLE) != 0) {
  3817. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  3818. +
  3819. + psDRISUPDrawable = psPVRDrawable->psDRISUPDrawable;
  3820. + } else {
  3821. + psDRISUPDrawable = NULL;
  3822. + }
  3823. +
  3824. + DRISUPFlushWithFlags(psPVRContext->psDRISUPContext, psDRISUPDrawable,
  3825. + uFlags, (unsigned int) eThrottleReason);
  3826. +}
  3827. +
  3828. +static __DRI2flushExtension pvrDRI2FlushExtension = {
  3829. + .base = {
  3830. + .name = __DRI2_FLUSH,
  3831. + .version = PVR_DRI2_FLUSH_VERSION,
  3832. + },
  3833. + .flush = PVRDRI2Flush,
  3834. + .invalidate = PVRDRI2Invalidate,
  3835. + .flush_with_flags = PVRDRI2FlushWithFlags,
  3836. +};
  3837. +
  3838. +static __DRIimage *
  3839. +PVRDRICreateImageFromName(__DRIscreen *psDRIScreen, int iWidth, int iHeight,
  3840. + int iFormat, int iName, int iPitch,
  3841. + void *pvLoaderPrivate)
  3842. +{
  3843. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3844. + int iFourCC = PVRDRIFormatToFourCC(iFormat);
  3845. +
  3846. + return DRISUPCreateImageFromName(psPVRScreen->psDRISUPScreen,
  3847. + iWidth, iHeight, iFourCC, iName, iPitch,
  3848. + pvLoaderPrivate);
  3849. +}
  3850. +
  3851. +static __DRIimage *
  3852. +PVRDRICreateImageFromRenderbuffer(__DRIcontext *psDRIContext,
  3853. + int iRenderBuffer, void *pvLoaderPrivate)
  3854. +{
  3855. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3856. +
  3857. + return DRISUPCreateImageFromRenderbuffer(psPVRContext->psDRISUPContext,
  3858. + iRenderBuffer, pvLoaderPrivate);
  3859. +}
  3860. +
  3861. +static void
  3862. +PVRDRIDestroyImage(__DRIimage *psImage)
  3863. +{
  3864. + DRISUPDestroyImage(psImage);
  3865. +}
  3866. +
  3867. +static __DRIimage *
  3868. +PVRDRICreateImage(__DRIscreen *psDRIScreen, int iWidth, int iHeight,
  3869. + int iFormat, unsigned int uUse, void *pvLoaderPrivate)
  3870. +{
  3871. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3872. + int iFourCC = PVRDRIFormatToFourCC(iFormat);
  3873. +
  3874. + return DRISUPCreateImage(psPVRScreen->psDRISUPScreen, iWidth, iHeight,
  3875. + iFourCC, uUse, pvLoaderPrivate);
  3876. +}
  3877. +
  3878. +static GLboolean
  3879. +PVRDRIQueryImage(__DRIimage *psImage, int iAttrib, int *piValue)
  3880. +{
  3881. + int iFourCC;
  3882. +
  3883. + switch (iAttrib) {
  3884. + case __DRI_IMAGE_ATTRIB_FORMAT:
  3885. + if (DRISUPQueryImage(psImage,
  3886. + __DRI_IMAGE_ATTRIB_FOURCC, &iFourCC)) {
  3887. + *piValue = PVRDRIFourCCToDRIFormat(iFourCC);
  3888. + return GL_TRUE;
  3889. + }
  3890. + return GL_FALSE;
  3891. + default:
  3892. + return DRISUPQueryImage(psImage, iAttrib, piValue);
  3893. + }
  3894. +
  3895. +}
  3896. +
  3897. +static __DRIimage *
  3898. +PVRDRIDupImage(__DRIimage *psImage, void *pvLoaderPrivate)
  3899. +{
  3900. + return DRISUPDupImage(psImage, pvLoaderPrivate);
  3901. +}
  3902. +
  3903. +static GLboolean
  3904. +PVRDRIValidateImageUsage(__DRIimage *psImage, unsigned int uUse)
  3905. +{
  3906. + return DRISUPValidateImageUsage(psImage, uUse);
  3907. +}
  3908. +
  3909. +static __DRIimage *
  3910. +PVRDRICreateImageFromNames(__DRIscreen *psDRIScreen, int iWidth, int iHeight,
  3911. + int iFourCC, int *piNames, int iNumNames,
  3912. + int *piStrides, int *piOffsets,
  3913. + void *pvLoaderPrivate)
  3914. +{
  3915. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3916. +
  3917. + return DRISUPCreateImageFromNames(psPVRScreen->psDRISUPScreen,
  3918. + iWidth, iHeight, iFourCC,
  3919. + piNames, iNumNames,
  3920. + piStrides, piOffsets, pvLoaderPrivate);
  3921. +}
  3922. +
  3923. +static __DRIimage *
  3924. +PVRDRIFromPlanar(__DRIimage *psImage, int iPlane, void *pvLoaderPrivate)
  3925. +{
  3926. + return DRISUPFromPlanar(psImage, iPlane, pvLoaderPrivate);
  3927. +}
  3928. +
  3929. +static __DRIimage *
  3930. +PVRDRICreateImageFromTexture(__DRIcontext *psDRIContext, int iTarget,
  3931. + unsigned int uTexture, int iDepth, int iLevel,
  3932. + unsigned int *puError, void *pvLoaderPrivate)
  3933. +{
  3934. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  3935. + int iEGLTarget;
  3936. +
  3937. + switch (iTarget) {
  3938. + case GL_TEXTURE_2D:
  3939. + iEGLTarget = PVRDRI_GL_TEXTURE_2D;
  3940. + break;
  3941. + case GL_TEXTURE_3D:
  3942. + iEGLTarget = PVRDRI_GL_TEXTURE_3D;
  3943. + break;
  3944. + case GL_TEXTURE_CUBE_MAP:
  3945. + iEGLTarget = PVRDRI_GL_TEXTURE_CUBE_MAP_POSITIVE_X;
  3946. + break;
  3947. + default:
  3948. + errorMessage("%s: GL Target %d is not supported",
  3949. + __func__, iTarget);
  3950. + *puError = __DRI_IMAGE_ERROR_BAD_PARAMETER;
  3951. + return NULL;
  3952. + }
  3953. +
  3954. + return DRISUPCreateImageFromTexture(psPVRContext->psDRISUPContext,
  3955. + iEGLTarget, uTexture, iDepth, iLevel,
  3956. + puError, pvLoaderPrivate);
  3957. +}
  3958. +
  3959. +static __DRIimage *
  3960. +PVRDRICreateImageFromFds(__DRIscreen *psDRIScreen, int iWidth, int iHeight,
  3961. + int iFourCC, int *piFDs, int iNumFDs,
  3962. + int *piStrides, int *piOffsets,
  3963. + void *pvLoaderPrivate)
  3964. +{
  3965. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3966. +
  3967. + return DRISUPCreateImageFromFDs(psPVRScreen->psDRISUPScreen,
  3968. + iWidth, iHeight, iFourCC, piFDs, iNumFDs,
  3969. + piStrides, piOffsets, pvLoaderPrivate);
  3970. +}
  3971. +
  3972. +static __DRIimage *
  3973. +PVRDRICreateImageFromDmaBufs(__DRIscreen *psDRIScreen,
  3974. + int iWidth, int iHeight, int iFourCC,
  3975. + int *piFDs, int iNumFDs,
  3976. + int *piStrides, int *piOffsets,
  3977. + enum __DRIYUVColorSpace eColorSpace,
  3978. + enum __DRISampleRange eSampleRange,
  3979. + enum __DRIChromaSiting eHorizSiting,
  3980. + enum __DRIChromaSiting eVertSiting,
  3981. + unsigned int *puError, void *pvLoaderPrivate)
  3982. +{
  3983. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  3984. +
  3985. + return DRISUPCreateImageFromDmaBufs(psPVRScreen->psDRISUPScreen,
  3986. + iWidth, iHeight, iFourCC,
  3987. + piFDs, iNumFDs, piStrides, piOffsets,
  3988. + (unsigned int) eColorSpace,
  3989. + (unsigned int) eSampleRange,
  3990. + (unsigned int) eHorizSiting,
  3991. + (unsigned int) eVertSiting,
  3992. + puError, pvLoaderPrivate);
  3993. +}
  3994. +
  3995. +static void
  3996. +PVRDRIBlitImage(__DRIcontext *psDRIContext,
  3997. + __DRIimage *psDst, __DRIimage *psSrc,
  3998. + int iDstX0, int iDstY0, int iDstWidth, int iDstHeight,
  3999. + int iSrcX0, int iSrcY0, int iSrcWidth, int iSrcHeight,
  4000. + int iFlushFlag)
  4001. +{
  4002. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4003. +
  4004. + return DRISUPBlitImage(psPVRContext->psDRISUPContext,
  4005. + psDst, psSrc,
  4006. + iDstX0, iDstY0, iDstWidth, iDstHeight,
  4007. + iSrcX0, iSrcY0, iSrcWidth, iSrcHeight,
  4008. + iFlushFlag);
  4009. +}
  4010. +
  4011. +static int
  4012. +PVRDRIGetCapabilities(__DRIscreen *psDRIScreen)
  4013. +{
  4014. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4015. +
  4016. + return DRISUPGetImageCapabilities(psPVRScreen->psDRISUPScreen);
  4017. +}
  4018. +
  4019. +static void *
  4020. +PVRDRIMapImage(__DRIcontext *psDRIContext, __DRIimage *psImage,
  4021. + int iX0, int iY0, int iWidth, int iHeight,
  4022. + unsigned int iFlags, int *piStride, void **ppvData)
  4023. +{
  4024. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4025. +
  4026. + return DRISUPMapImage(psPVRContext->psDRISUPContext, psImage,
  4027. + iX0, iY0, iWidth, iHeight, iFlags, piStride,
  4028. + ppvData);
  4029. +}
  4030. +
  4031. +static void
  4032. +PVRDRIUnmapImage(__DRIcontext *psDRIContext, __DRIimage *psImage,
  4033. + void *pvData)
  4034. +{
  4035. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4036. +
  4037. + return DRISUPUnmapImage(psPVRContext->psDRISUPContext, psImage, pvData);
  4038. +}
  4039. +
  4040. +static __DRIimage *
  4041. +PVRDRICreateImageWithModifiers(__DRIscreen *psDRIScreen,
  4042. + int iWidth, int iHeight, int iFormat,
  4043. + const uint64_t *puModifiers,
  4044. + const unsigned int uModifierCount,
  4045. + void *pvLoaderPrivate)
  4046. +{
  4047. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4048. + int iFourCC = PVRDRIFormatToFourCC(iFormat);
  4049. +
  4050. + return DRISUPCreateImageWithModifiers(psPVRScreen->psDRISUPScreen,
  4051. + iWidth, iHeight, iFourCC,
  4052. + puModifiers, uModifierCount,
  4053. + pvLoaderPrivate);
  4054. +}
  4055. +
  4056. +static __DRIimage *
  4057. +PVRDRICreateImageFromDmaBufs2(__DRIscreen *psDRIScreen,
  4058. + int iWidth, int iHeight,
  4059. + int iFourCC, uint64_t uModifier,
  4060. + int *piFDs, int iNumFDs,
  4061. + int *piStrides, int *piOffsets,
  4062. + enum __DRIYUVColorSpace eColorSpace,
  4063. + enum __DRISampleRange eSampleRange,
  4064. + enum __DRIChromaSiting eHorizSiting,
  4065. + enum __DRIChromaSiting eVertSiting,
  4066. + unsigned int *puError, void *pvLoaderPrivate)
  4067. +{
  4068. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4069. +
  4070. + return DRISUPCreateImageFromDMABufs2(psPVRScreen->psDRISUPScreen,
  4071. + iWidth, iHeight, iFourCC, uModifier,
  4072. + piFDs, iNumFDs, piStrides, piOffsets,
  4073. + (unsigned int) eColorSpace,
  4074. + (unsigned int) eSampleRange,
  4075. + (unsigned int) eHorizSiting,
  4076. + (unsigned int) eVertSiting,
  4077. + puError, pvLoaderPrivate);
  4078. +}
  4079. +
  4080. +static GLboolean
  4081. +PVRDRIQueryDmaBufFormats(__DRIscreen *psDRIScreen, int iMax,
  4082. + int *piFormats, int *piCount)
  4083. +{
  4084. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4085. +
  4086. + return DRISUPQueryDMABufFormats(psPVRScreen->psDRISUPScreen, iMax,
  4087. + piFormats, piCount);
  4088. +}
  4089. +
  4090. +static GLboolean
  4091. +PVRDRIQueryDmaBufModifiers(__DRIscreen *psDRIScreen, int iFourCC, int iMax,
  4092. + uint64_t *puModifiers,
  4093. + unsigned int *puExternalOnly, int *piCount)
  4094. +{
  4095. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4096. +
  4097. + return DRISUPQueryDMABufModifiers(psPVRScreen->psDRISUPScreen, iFourCC,
  4098. + iMax,
  4099. + puModifiers, puExternalOnly, piCount);
  4100. +}
  4101. +
  4102. +static GLboolean
  4103. +PVRDRIQueryDmaBufFormatModifierAttribs(__DRIscreen *psDRIScreen,
  4104. + uint32_t uFourCC, uint64_t uModifier,
  4105. + int iAttrib, uint64_t *puValue)
  4106. +{
  4107. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4108. + struct DRISUPScreen *psDRISUPScreen = psPVRScreen->psDRISUPScreen;
  4109. +
  4110. + return DRISUPQueryDMABufFormatModifierAttribs(psDRISUPScreen, uFourCC,
  4111. + uModifier, iAttrib, puValue);
  4112. +}
  4113. +
  4114. +static __DRIimage *
  4115. +PVRDRICreateImageFromRenderbuffer2(__DRIcontext *psDRIContext,
  4116. + int iRenderBuffer, void *pvLoaderPrivate,
  4117. + unsigned int *puError)
  4118. +{
  4119. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4120. + struct DRISUPContext *psDRISUPContext = psPVRContext->psDRISUPContext;
  4121. +
  4122. + return DRISUPCreateImageFromRenderBuffer2(psDRISUPContext, iRenderBuffer,
  4123. + pvLoaderPrivate, puError);
  4124. +}
  4125. +
  4126. +#if defined(EGL_IMG_cl_image)
  4127. +static __DRIimage *
  4128. +PVRDRICreateImageFromBuffer(__DRIcontext *psDRIContext, int iTarget,
  4129. + void *pvBuffer, unsigned int *puError,
  4130. + void *pvLoaderPrivate)
  4131. +{
  4132. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4133. +
  4134. + return DRISUPCreateImageFromBuffer(psPVRContext->psDRISUPContext, iTarget,
  4135. + pvBuffer, puError, pvLoaderPrivate);
  4136. +}
  4137. +#endif
  4138. +
  4139. +static __DRIimageExtension pvrDRIImage = {
  4140. + .base = {
  4141. + .name = __DRI_IMAGE,
  4142. + .version = PVR_DRI_IMAGE_VERSION,
  4143. + },
  4144. + .createImageFromName = PVRDRICreateImageFromName,
  4145. + .createImageFromRenderbuffer = PVRDRICreateImageFromRenderbuffer,
  4146. + .destroyImage = PVRDRIDestroyImage,
  4147. + .createImage = PVRDRICreateImage,
  4148. + .queryImage = PVRDRIQueryImage,
  4149. + .dupImage = PVRDRIDupImage,
  4150. + .validateUsage = PVRDRIValidateImageUsage,
  4151. + .createImageFromNames = PVRDRICreateImageFromNames,
  4152. + .fromPlanar = PVRDRIFromPlanar,
  4153. + .createImageFromTexture = PVRDRICreateImageFromTexture,
  4154. + .createImageFromFds = PVRDRICreateImageFromFds,
  4155. + .createImageFromDmaBufs = PVRDRICreateImageFromDmaBufs,
  4156. + .blitImage = PVRDRIBlitImage,
  4157. + .getCapabilities = PVRDRIGetCapabilities,
  4158. + .mapImage = PVRDRIMapImage,
  4159. + .unmapImage = PVRDRIUnmapImage,
  4160. + .createImageWithModifiers = PVRDRICreateImageWithModifiers,
  4161. + .createImageFromDmaBufs2 = PVRDRICreateImageFromDmaBufs2,
  4162. + .queryDmaBufFormats = PVRDRIQueryDmaBufFormats,
  4163. + .queryDmaBufModifiers = PVRDRIQueryDmaBufModifiers,
  4164. + .queryDmaBufFormatModifierAttribs =
  4165. + PVRDRIQueryDmaBufFormatModifierAttribs,
  4166. + .createImageFromRenderbuffer2 = PVRDRICreateImageFromRenderbuffer2,
  4167. +#if defined(EGL_IMG_cl_image)
  4168. + .createImageFromBuffer = PVRDRICreateImageFromBuffer,
  4169. +#endif
  4170. +};
  4171. +
  4172. +static __DRIrobustnessExtension pvrDRIRobustness = {
  4173. + .base = {
  4174. + .name = __DRI2_ROBUSTNESS,
  4175. + .version = PVR_DRI2_ROBUSTNESS_VERSION,
  4176. + }
  4177. +};
  4178. +
  4179. +static int
  4180. +PVRDRIQueryRendererInteger(__DRIscreen *psDRIScreen, int iAttribute,
  4181. + unsigned int *puValue)
  4182. +{
  4183. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4184. + int res;
  4185. +
  4186. + res = DRISUPQueryRendererInteger(psPVRScreen->psDRISUPScreen,
  4187. + iAttribute, puValue);
  4188. + if (res == -1)
  4189. + return driQueryRendererIntegerCommon(psDRIScreen, iAttribute, puValue);
  4190. +
  4191. + return res;
  4192. +}
  4193. +
  4194. +static int
  4195. +PVRDRIQueryRendererString(__DRIscreen *psDRIScreen, int iAttribute,
  4196. + const char **ppszValue)
  4197. +{
  4198. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4199. +
  4200. + return DRISUPQueryRendererString(psPVRScreen->psDRISUPScreen, iAttribute,
  4201. + ppszValue);
  4202. +}
  4203. +
  4204. +static const __DRI2rendererQueryExtension pvrDRIRendererQueryExtension = {
  4205. + .base = {
  4206. + .name = __DRI2_RENDERER_QUERY,
  4207. + .version = PVR_DRI2_RENDERER_QUERY_VERSION,
  4208. + },
  4209. + .queryInteger = PVRDRIQueryRendererInteger,
  4210. + .queryString = PVRDRIQueryRendererString,
  4211. +};
  4212. +
  4213. +
  4214. +static void *
  4215. +PVRDRICreateFenceEXT(__DRIcontext *psDRIContext)
  4216. +{
  4217. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4218. +
  4219. + return DRISUPCreateFence(psPVRContext->psDRISUPContext);
  4220. +}
  4221. +
  4222. +static void
  4223. +PVRDRIDestroyFenceEXT(__DRIscreen *psDRIScreen, void *pvFence)
  4224. +{
  4225. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4226. +
  4227. + return DRISUPDestroyFence(psPVRScreen->psDRISUPScreen, pvFence);
  4228. +}
  4229. +
  4230. +static GLboolean
  4231. +PVRDRIClientWaitSyncEXT(__DRIcontext *psDRIContext, void *pvFence,
  4232. + unsigned int uFlags, uint64_t uTimeout)
  4233. +{
  4234. + struct DRISUPContext *psDRISUPContext;
  4235. +
  4236. + if (psDRIContext) {
  4237. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4238. +
  4239. + psDRISUPContext = psPVRContext->psDRISUPContext;
  4240. + } else {
  4241. + psDRISUPContext = NULL;
  4242. + }
  4243. +
  4244. + return DRISUPClientWaitSync(psDRISUPContext, pvFence, uFlags, uTimeout);
  4245. +}
  4246. +
  4247. +static void
  4248. +PVRDRIServerWaitSyncEXT(__DRIcontext *psDRIContext, void *pvFence,
  4249. + unsigned int uFlags)
  4250. +{
  4251. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4252. +
  4253. + return DRISUPServerWaitSync(psPVRContext->psDRISUPContext, pvFence, uFlags);
  4254. +}
  4255. +
  4256. +static unsigned int
  4257. +PVRDRIGetFenceCapabilitiesEXT(__DRIscreen *psDRIScreen)
  4258. +{
  4259. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4260. +
  4261. + return DRISUPGetFenceCapabilities(psPVRScreen->psDRISUPScreen);
  4262. +}
  4263. +
  4264. +static void *
  4265. +PVRDRICreateFenceFdEXT(__DRIcontext *psDRIContext, int iFD)
  4266. +{
  4267. + PVRDRIContext *psPVRContext = psDRIContext->driverPrivate;
  4268. +
  4269. + return DRISUPCreateFenceFD(psPVRContext->psDRISUPContext, iFD);
  4270. +}
  4271. +
  4272. +static int
  4273. +PVRDRIGetFenceFdEXT(__DRIscreen *psDRIScreen, void *pvFence)
  4274. +{
  4275. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4276. +
  4277. + return DRISUPGetFenceFD(psPVRScreen->psDRISUPScreen, pvFence);
  4278. +}
  4279. +
  4280. +static void *
  4281. +PVRDRIGetFenceFromClEventEXT(__DRIscreen *psDRIScreen, intptr_t iClEvent)
  4282. +{
  4283. + PVRDRIScreen *psPVRScreen = psDRIScreen->driverPrivate;
  4284. +
  4285. + return DRISUPGetFenceFromCLEvent(psPVRScreen->psDRISUPScreen, iClEvent);
  4286. +}
  4287. +
  4288. +__DRI2fenceExtension pvrDRIFenceExtension = {
  4289. + .base = {
  4290. + .name = __DRI2_FENCE,
  4291. + .version = PVR_DRI2_FENCE_VERSION,
  4292. + },
  4293. + .create_fence = PVRDRICreateFenceEXT,
  4294. + .get_fence_from_cl_event = PVRDRIGetFenceFromClEventEXT,
  4295. + .destroy_fence = PVRDRIDestroyFenceEXT,
  4296. + .client_wait_sync = PVRDRIClientWaitSyncEXT,
  4297. + .server_wait_sync = PVRDRIServerWaitSyncEXT,
  4298. + .get_capabilities = PVRDRIGetFenceCapabilitiesEXT,
  4299. + .create_fence_fd = PVRDRICreateFenceFdEXT,
  4300. + .get_fence_fd = PVRDRIGetFenceFdEXT,
  4301. +};
  4302. +
  4303. +static void
  4304. +PVRDRISetDamageRegion(__DRIdrawable *psDRIDrawable,
  4305. + unsigned int uNRects, int *piRects)
  4306. +{
  4307. + PVRDRIDrawable *psPVRDrawable = psDRIDrawable->driverPrivate;
  4308. +
  4309. + DRISUPSetDamageRegion(psPVRDrawable->psDRISUPDrawable, uNRects, piRects);
  4310. +}
  4311. +
  4312. +const __DRI2bufferDamageExtension pvrDRIbufferDamageExtension = {
  4313. + .base = {
  4314. + .name = __DRI2_BUFFER_DAMAGE,
  4315. + .version = PVR_DRI2_BUFFER_DAMAGE_VERSION,
  4316. + },
  4317. + .set_damage_region = PVRDRISetDamageRegion,
  4318. +};
  4319. +
  4320. +/*
  4321. + * Extension lists
  4322. + *
  4323. + * NOTE: When adding a new screen extension asScreenExtensionVersionInfo
  4324. + * should also be updated accordingly.
  4325. + */
  4326. +static const __DRIextension *apsScreenExtensions[] = {
  4327. + &pvrDRITexBufferExtension.base,
  4328. + &pvrDRI2FlushExtension.base,
  4329. + &pvrDRIImage.base,
  4330. + &pvrDRIRobustness.base,
  4331. + &pvrDRIRendererQueryExtension.base,
  4332. + &pvrDRIFenceExtension.base,
  4333. + &pvrDRIbufferDamageExtension.base,
  4334. + &dri2ConfigQueryExtension.base,
  4335. + NULL
  4336. +};
  4337. +
  4338. +static const __DRIextension asScreenExtensionVersionInfo[] = {
  4339. + {.name = __DRI_TEX_BUFFER,.version = __DRI_TEX_BUFFER_VERSION},
  4340. + {.name = __DRI2_FLUSH,.version = __DRI2_FLUSH_VERSION},
  4341. + {.name = __DRI_IMAGE,.version = __DRI_IMAGE_VERSION},
  4342. + {.name = __DRI2_ROBUSTNESS,.version = __DRI2_ROBUSTNESS_VERSION},
  4343. + {.name = __DRI2_RENDERER_QUERY,.version = __DRI2_RENDERER_QUERY_VERSION},
  4344. + {.name = __DRI2_FENCE,.version = __DRI2_FENCE_VERSION},
  4345. + {.name = __DRI2_BUFFER_DAMAGE,.version = __DRI2_BUFFER_DAMAGE_VERSION},
  4346. + {.name = __DRI2_CONFIG_QUERY,.version = __DRI2_CONFIG_QUERY_VERSION},
  4347. + {.name = NULL,.version = 0},
  4348. +};
  4349. +
  4350. +const __DRIextension **
  4351. +PVRDRIScreenExtensions(void)
  4352. +{
  4353. + return apsScreenExtensions;
  4354. +}
  4355. +
  4356. +const __DRIextension *
  4357. +PVRDRIScreenExtensionVersionInfo(void)
  4358. +{
  4359. + return asScreenExtensionVersionInfo;
  4360. +}
  4361. +
  4362. +void
  4363. +PVRDRIAdjustExtensions(unsigned int uVersion, unsigned int uMinVersion)
  4364. +{
  4365. + switch (uVersion) {
  4366. + default:
  4367. + case 4:
  4368. + /* Is the KHR_cl_event2 EGL extension supported? */
  4369. + if (!DRISUPHaveGetFenceFromCLEvent())
  4370. + pvrDRIFenceExtension.get_fence_from_cl_event = NULL;
  4371. +
  4372. + break;
  4373. + case 3:
  4374. + break;
  4375. + case 2:
  4376. + case 1:
  4377. + case 0:
  4378. + /* The KHR_cl_event2 EGL extension is not supported */
  4379. + pvrDRIFenceExtension.get_fence_from_cl_event = NULL;
  4380. + break;
  4381. + }
  4382. +}
  4383. diff --git a/src/mesa/drivers/dri/pvr/pvrmesa.h b/src/mesa/drivers/dri/pvr/pvrmesa.h
  4384. new file mode 100644
  4385. index 0000000..5e1c9c1
  4386. --- /dev/null
  4387. +++ b/src/mesa/drivers/dri/pvr/pvrmesa.h
  4388. @@ -0,0 +1,36 @@
  4389. +/*
  4390. + * Copyright (c) Imagination Technologies Ltd.
  4391. + *
  4392. + * The contents of this file are subject to the MIT license as set out below.
  4393. + *
  4394. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  4395. + * of this software and associated documentation files (the "Software"), to deal
  4396. + * in the Software without restriction, including without limitation the rights
  4397. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4398. + * copies of the Software, and to permit persons to whom the Software is
  4399. + * furnished to do so, subject to the following conditions:
  4400. + *
  4401. + * The above copyright notice and this permission notice shall be included in
  4402. + * all copies or substantial portions of the Software.
  4403. + *
  4404. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4405. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4406. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4407. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4408. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4409. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4410. + * THE SOFTWARE.
  4411. + */
  4412. +
  4413. +#if !defined(__PVRMESA_H__)
  4414. +#define __PVRMESA_H__
  4415. +
  4416. +#include "pvrdri.h"
  4417. +
  4418. +void pvrdri_free_dispatch_tables(PVRDRIScreen *psPVRScreen);
  4419. +bool pvrdri_create_dispatch_table(PVRDRIScreen *psPVRScreen,
  4420. + PVRDRIAPIType eAPI);
  4421. +void pvrdri_set_null_dispatch_table(void);
  4422. +void pvrdri_set_dispatch_table(PVRDRIContext *psPVRContext);
  4423. +
  4424. +#endif /* !defined(__PVRMESA_H__) */
  4425. diff --git a/src/mesa/drivers/dri/pvr/pvrutil.c b/src/mesa/drivers/dri/pvr/pvrutil.c
  4426. new file mode 100644
  4427. index 0000000..945e18c
  4428. --- /dev/null
  4429. +++ b/src/mesa/drivers/dri/pvr/pvrutil.c
  4430. @@ -0,0 +1,239 @@
  4431. +/*
  4432. + * Copyright (c) Imagination Technologies Ltd.
  4433. + *
  4434. + * The contents of this file are subject to the MIT license as set out below.
  4435. + *
  4436. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  4437. + * of this software and associated documentation files (the "Software"), to deal
  4438. + * in the Software without restriction, including without limitation the rights
  4439. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4440. + * copies of the Software, and to permit persons to whom the Software is
  4441. + * furnished to do so, subject to the following conditions:
  4442. + *
  4443. + * The above copyright notice and this permission notice shall be included in
  4444. + * all copies or substantial portions of the Software.
  4445. + *
  4446. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4447. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4448. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4449. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4450. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4451. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4452. + * THE SOFTWARE.
  4453. + */
  4454. +
  4455. +#include <stdarg.h>
  4456. +#include <stdio.h>
  4457. +#include <stdlib.h>
  4458. +#include <assert.h>
  4459. +
  4460. +#include "drm-uapi/drm_fourcc.h"
  4461. +
  4462. +#include "utils.h"
  4463. +#include "dri_util.h"
  4464. +#include "pvrdri.h"
  4465. +
  4466. +#define MESSAGE_LENGTH_MAX 1024
  4467. +
  4468. +/*
  4469. + * Define before including android/log.h and dlog.h as this is used by these
  4470. + * headers.
  4471. + */
  4472. +#define LOG_TAG "PVR-MESA"
  4473. +
  4474. +#if defined(HAVE_ANDROID_PLATFORM)
  4475. +#include <android/log.h>
  4476. +#define err_printf(f, args...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, f, ##args))
  4477. +#define dbg_printf(f, args...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, f, ##args))
  4478. +#elif defined(HAVE_TIZEN_PLATFORM)
  4479. +#include <dlog.h>
  4480. +#define err_printf(f, args...) LOGE(f, ##args)
  4481. +#define dbg_printf(f, args...) LOGD(f, ##args)
  4482. +#else
  4483. +#define err_printf(f, args...) fprintf(stderr, f "\n", ##args)
  4484. +#define dbg_printf(f, args...) fprintf(stderr, "LibGL: " f "\n", ##args)
  4485. +#endif /* HAVE_ANDROID_PLATFORM */
  4486. +
  4487. +/* Standard error message */
  4488. +void PRINTFLIKE(1, 2)
  4489. +errorMessage(const char *f, ...)
  4490. +{
  4491. + char message[MESSAGE_LENGTH_MAX];
  4492. + va_list args;
  4493. +
  4494. + va_start(args, f);
  4495. + vsnprintf(message, sizeof message, f, args);
  4496. + va_end(args);
  4497. +
  4498. + err_printf("%s", message);
  4499. +}
  4500. +
  4501. +void PRINTFLIKE(1, 2)
  4502. +__driUtilMessage(const char *f, ...)
  4503. +{
  4504. + char message[MESSAGE_LENGTH_MAX];
  4505. + va_list args;
  4506. +
  4507. + /*
  4508. + * On Android and Tizen, always print messages; otherwise, only print if
  4509. + * the environment variable LIBGL_DEBUG=verbose.
  4510. + */
  4511. +#if !defined(HAVE_ANDROID_PLATFORM) && !defined(HAVE_TIZEN_PLATFORM)
  4512. + char *ev = getenv("LIBGL_DEBUG");
  4513. +
  4514. + if (!ev || strcmp(ev, "verbose") != 0)
  4515. + return;
  4516. +#endif
  4517. +
  4518. + va_start(args, f);
  4519. + vsnprintf(message, sizeof message, f, args);
  4520. + va_end(args);
  4521. +
  4522. + dbg_printf("%s", message);
  4523. +}
  4524. +
  4525. +mesa_format
  4526. +PVRDRIMesaFormatToMesaFormat(int pvrdri_mesa_format)
  4527. +{
  4528. + switch (pvrdri_mesa_format) {
  4529. + case PVRDRI_MESA_FORMAT_NONE:
  4530. + return MESA_FORMAT_NONE;
  4531. + case PVRDRI_MESA_FORMAT_B8G8R8A8_UNORM:
  4532. + return MESA_FORMAT_B8G8R8A8_UNORM;
  4533. + case PVRDRI_MESA_FORMAT_B8G8R8X8_UNORM:
  4534. + return MESA_FORMAT_B8G8R8X8_UNORM;
  4535. + case PVRDRI_MESA_FORMAT_B5G6R5_UNORM:
  4536. + return MESA_FORMAT_B5G6R5_UNORM;
  4537. + case PVRDRI_MESA_FORMAT_R8G8B8A8_UNORM:
  4538. + return MESA_FORMAT_R8G8B8A8_UNORM;
  4539. + case PVRDRI_MESA_FORMAT_R8G8B8X8_UNORM:
  4540. + return MESA_FORMAT_R8G8B8X8_UNORM;
  4541. + case PVRDRI_MESA_FORMAT_YCBCR:
  4542. + return MESA_FORMAT_YCBCR;
  4543. + case PVRDRI_MESA_FORMAT_YUV420_2PLANE:
  4544. + return MESA_FORMAT_YUV420_2PLANE;
  4545. + case PVRDRI_MESA_FORMAT_YVU420_2PLANE:
  4546. + return MESA_FORMAT_YVU420_2PLANE;
  4547. + case PVRDRI_MESA_FORMAT_B8G8R8A8_SRGB:
  4548. + return MESA_FORMAT_B8G8R8A8_SRGB;
  4549. + case PVRDRI_MESA_FORMAT_R8G8B8A8_SRGB:
  4550. + return MESA_FORMAT_R8G8B8A8_SRGB;
  4551. + default:
  4552. + __driUtilMessage("%s: Unknown format: %d", __func__, pvrdri_mesa_format);
  4553. + break;
  4554. + }
  4555. +
  4556. + return MESA_FORMAT_NONE;
  4557. +}
  4558. +
  4559. +int
  4560. +PVRDRIFormatToFourCC(int dri_format)
  4561. +{
  4562. + switch (dri_format) {
  4563. + case __DRI_IMAGE_FORMAT_RGB565:
  4564. + return DRM_FORMAT_RGB565;
  4565. + case __DRI_IMAGE_FORMAT_XRGB8888:
  4566. + return DRM_FORMAT_XRGB8888;
  4567. + case __DRI_IMAGE_FORMAT_ARGB8888:
  4568. + return DRM_FORMAT_ARGB8888;
  4569. + case __DRI_IMAGE_FORMAT_ABGR8888:
  4570. + return DRM_FORMAT_ABGR8888;
  4571. + case __DRI_IMAGE_FORMAT_XBGR8888:
  4572. + return DRM_FORMAT_XBGR8888;
  4573. + case __DRI_IMAGE_FORMAT_R8:
  4574. + return DRM_FORMAT_R8;
  4575. + case __DRI_IMAGE_FORMAT_GR88:
  4576. + return DRM_FORMAT_GR88;
  4577. + case __DRI_IMAGE_FORMAT_NONE:
  4578. + return 0;
  4579. + case __DRI_IMAGE_FORMAT_XRGB2101010:
  4580. + return DRM_FORMAT_XRGB2101010;
  4581. + case __DRI_IMAGE_FORMAT_ARGB2101010:
  4582. + return DRM_FORMAT_ARGB2101010;
  4583. + case __DRI_IMAGE_FORMAT_SARGB8:
  4584. + return __DRI_IMAGE_FOURCC_SARGB8888;
  4585. + case __DRI_IMAGE_FORMAT_ARGB1555:
  4586. + return DRM_FORMAT_ARGB1555;
  4587. + case __DRI_IMAGE_FORMAT_R16:
  4588. + return DRM_FORMAT_R16;
  4589. + case __DRI_IMAGE_FORMAT_GR1616:
  4590. + return DRM_FORMAT_GR1616;
  4591. + case __DRI_IMAGE_FORMAT_YUYV:
  4592. + return DRM_FORMAT_YUYV;
  4593. + case __DRI_IMAGE_FORMAT_XBGR2101010:
  4594. + return DRM_FORMAT_XBGR2101010;
  4595. + case __DRI_IMAGE_FORMAT_ABGR2101010:
  4596. + return DRM_FORMAT_ABGR2101010;
  4597. + case __DRI_IMAGE_FORMAT_SABGR8:
  4598. + return __DRI_IMAGE_FOURCC_SABGR8888;
  4599. + case __DRI_IMAGE_FORMAT_UYVY:
  4600. + return DRM_FORMAT_UYVY;
  4601. + case __DRI_IMAGE_FORMAT_ARGB4444:
  4602. + return DRM_FORMAT_ARGB4444;
  4603. + case __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG:
  4604. + return DRM_FORMAT_YVU444_PACK10_IMG;
  4605. + case __DRI_IMAGE_FORMAT_BGR888:
  4606. + return DRM_FORMAT_BGR888;
  4607. + default:
  4608. + __driUtilMessage("%s: Unknown format: %d", __func__, dri_format);
  4609. + break;
  4610. + }
  4611. +
  4612. + return 0;
  4613. +}
  4614. +
  4615. +int
  4616. +PVRDRIFourCCToDRIFormat(int iFourCC)
  4617. +{
  4618. + switch (iFourCC) {
  4619. + case 0:
  4620. + return __DRI_IMAGE_FORMAT_NONE;
  4621. + case DRM_FORMAT_RGB565:
  4622. + return __DRI_IMAGE_FORMAT_RGB565;
  4623. + case DRM_FORMAT_XRGB8888:
  4624. + return __DRI_IMAGE_FORMAT_XRGB8888;
  4625. + case DRM_FORMAT_ARGB8888:
  4626. + return __DRI_IMAGE_FORMAT_ARGB8888;
  4627. + case DRM_FORMAT_ABGR8888:
  4628. + return __DRI_IMAGE_FORMAT_ABGR8888;
  4629. + case DRM_FORMAT_XBGR8888:
  4630. + return __DRI_IMAGE_FORMAT_XBGR8888;
  4631. + case DRM_FORMAT_R8:
  4632. + return __DRI_IMAGE_FORMAT_R8;
  4633. + case DRM_FORMAT_GR88:
  4634. + return __DRI_IMAGE_FORMAT_GR88;
  4635. + case DRM_FORMAT_XRGB2101010:
  4636. + return __DRI_IMAGE_FORMAT_XRGB2101010;
  4637. + case DRM_FORMAT_ARGB2101010:
  4638. + return __DRI_IMAGE_FORMAT_ARGB2101010;
  4639. + case __DRI_IMAGE_FOURCC_SARGB8888:
  4640. + return __DRI_IMAGE_FORMAT_SARGB8;
  4641. + case DRM_FORMAT_ARGB1555:
  4642. + return __DRI_IMAGE_FORMAT_ARGB1555;
  4643. + case DRM_FORMAT_R16:
  4644. + return __DRI_IMAGE_FORMAT_R16;
  4645. + case DRM_FORMAT_GR1616:
  4646. + return __DRI_IMAGE_FORMAT_GR1616;
  4647. + case DRM_FORMAT_YUYV:
  4648. + return __DRI_IMAGE_FORMAT_YUYV;
  4649. + case DRM_FORMAT_XBGR2101010:
  4650. + return __DRI_IMAGE_FORMAT_XBGR2101010;
  4651. + case DRM_FORMAT_ABGR2101010:
  4652. + return __DRI_IMAGE_FORMAT_ABGR2101010;
  4653. + case __DRI_IMAGE_FOURCC_SABGR8888:
  4654. + return __DRI_IMAGE_FORMAT_SABGR8;
  4655. + case DRM_FORMAT_UYVY:
  4656. + return __DRI_IMAGE_FORMAT_UYVY;
  4657. + case DRM_FORMAT_ARGB4444:
  4658. + return __DRI_IMAGE_FORMAT_ARGB4444;
  4659. + case DRM_FORMAT_YVU444_PACK10_IMG:
  4660. + return __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG;
  4661. + case DRM_FORMAT_BGR888:
  4662. + return __DRI_IMAGE_FORMAT_BGR888;
  4663. + default:
  4664. + __driUtilMessage("%s: Unknown format: %d", __func__, iFourCC);
  4665. + break;
  4666. + }
  4667. +
  4668. + return 0;
  4669. +}
  4670. diff --git a/src/meson.build b/src/meson.build
  4671. index acc7fe9..c3bab27 100644
  4672. --- a/src/meson.build
  4673. +++ b/src/meson.build
  4674. @@ -25,6 +25,7 @@ inc_gallium = include_directories('gallium/include')
  4675. inc_gallium_aux = include_directories('gallium/auxiliary')
  4676. inc_amd_common = include_directories('amd/common')
  4677. inc_amd_common_llvm = include_directories('amd/llvm')
  4678. +inc_pvr = include_directories('mesa/main', 'mapi/glapi')
  4679. inc_tool = include_directories('tool')
  4680. pps_datasources = []
  4681. pps_includes = []