nv50_grctx.c 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333
  1. /*
  2. * Copyright 2009 Marcin Kościelnicki
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #define CP_FLAG_CLEAR 0
  23. #define CP_FLAG_SET 1
  24. #define CP_FLAG_SWAP_DIRECTION ((0 * 32) + 0)
  25. #define CP_FLAG_SWAP_DIRECTION_LOAD 0
  26. #define CP_FLAG_SWAP_DIRECTION_SAVE 1
  27. #define CP_FLAG_UNK01 ((0 * 32) + 1)
  28. #define CP_FLAG_UNK01_CLEAR 0
  29. #define CP_FLAG_UNK01_SET 1
  30. #define CP_FLAG_UNK03 ((0 * 32) + 3)
  31. #define CP_FLAG_UNK03_CLEAR 0
  32. #define CP_FLAG_UNK03_SET 1
  33. #define CP_FLAG_USER_SAVE ((0 * 32) + 5)
  34. #define CP_FLAG_USER_SAVE_NOT_PENDING 0
  35. #define CP_FLAG_USER_SAVE_PENDING 1
  36. #define CP_FLAG_USER_LOAD ((0 * 32) + 6)
  37. #define CP_FLAG_USER_LOAD_NOT_PENDING 0
  38. #define CP_FLAG_USER_LOAD_PENDING 1
  39. #define CP_FLAG_UNK0B ((0 * 32) + 0xb)
  40. #define CP_FLAG_UNK0B_CLEAR 0
  41. #define CP_FLAG_UNK0B_SET 1
  42. #define CP_FLAG_XFER_SWITCH ((0 * 32) + 0xe)
  43. #define CP_FLAG_XFER_SWITCH_DISABLE 0
  44. #define CP_FLAG_XFER_SWITCH_ENABLE 1
  45. #define CP_FLAG_STATE ((0 * 32) + 0x1c)
  46. #define CP_FLAG_STATE_STOPPED 0
  47. #define CP_FLAG_STATE_RUNNING 1
  48. #define CP_FLAG_UNK1D ((0 * 32) + 0x1d)
  49. #define CP_FLAG_UNK1D_CLEAR 0
  50. #define CP_FLAG_UNK1D_SET 1
  51. #define CP_FLAG_UNK20 ((1 * 32) + 0)
  52. #define CP_FLAG_UNK20_CLEAR 0
  53. #define CP_FLAG_UNK20_SET 1
  54. #define CP_FLAG_STATUS ((2 * 32) + 0)
  55. #define CP_FLAG_STATUS_BUSY 0
  56. #define CP_FLAG_STATUS_IDLE 1
  57. #define CP_FLAG_AUTO_SAVE ((2 * 32) + 4)
  58. #define CP_FLAG_AUTO_SAVE_NOT_PENDING 0
  59. #define CP_FLAG_AUTO_SAVE_PENDING 1
  60. #define CP_FLAG_AUTO_LOAD ((2 * 32) + 5)
  61. #define CP_FLAG_AUTO_LOAD_NOT_PENDING 0
  62. #define CP_FLAG_AUTO_LOAD_PENDING 1
  63. #define CP_FLAG_NEWCTX ((2 * 32) + 10)
  64. #define CP_FLAG_NEWCTX_BUSY 0
  65. #define CP_FLAG_NEWCTX_DONE 1
  66. #define CP_FLAG_XFER ((2 * 32) + 11)
  67. #define CP_FLAG_XFER_IDLE 0
  68. #define CP_FLAG_XFER_BUSY 1
  69. #define CP_FLAG_ALWAYS ((2 * 32) + 13)
  70. #define CP_FLAG_ALWAYS_FALSE 0
  71. #define CP_FLAG_ALWAYS_TRUE 1
  72. #define CP_FLAG_INTR ((2 * 32) + 15)
  73. #define CP_FLAG_INTR_NOT_PENDING 0
  74. #define CP_FLAG_INTR_PENDING 1
  75. #define CP_CTX 0x00100000
  76. #define CP_CTX_COUNT 0x000f0000
  77. #define CP_CTX_COUNT_SHIFT 16
  78. #define CP_CTX_REG 0x00003fff
  79. #define CP_LOAD_SR 0x00200000
  80. #define CP_LOAD_SR_VALUE 0x000fffff
  81. #define CP_BRA 0x00400000
  82. #define CP_BRA_IP 0x0001ff00
  83. #define CP_BRA_IP_SHIFT 8
  84. #define CP_BRA_IF_CLEAR 0x00000080
  85. #define CP_BRA_FLAG 0x0000007f
  86. #define CP_WAIT 0x00500000
  87. #define CP_WAIT_SET 0x00000080
  88. #define CP_WAIT_FLAG 0x0000007f
  89. #define CP_SET 0x00700000
  90. #define CP_SET_1 0x00000080
  91. #define CP_SET_FLAG 0x0000007f
  92. #define CP_NEWCTX 0x00600004
  93. #define CP_NEXT_TO_SWAP 0x00600005
  94. #define CP_SET_CONTEXT_POINTER 0x00600006
  95. #define CP_SET_XFER_POINTER 0x00600007
  96. #define CP_ENABLE 0x00600009
  97. #define CP_END 0x0060000c
  98. #define CP_NEXT_TO_CURRENT 0x0060000d
  99. #define CP_DISABLE1 0x0090ffff
  100. #define CP_DISABLE2 0x0091ffff
  101. #define CP_XFER_1 0x008000ff
  102. #define CP_XFER_2 0x008800ff
  103. #define CP_SEEK_1 0x00c000ff
  104. #define CP_SEEK_2 0x00c800ff
  105. #include "drmP.h"
  106. #include "nouveau_drv.h"
  107. #include "nouveau_grctx.h"
  108. #define IS_NVA3F(x) (((x) > 0xa0 && (x) < 0xaa) || (x) == 0xaf)
  109. #define IS_NVAAF(x) ((x) >= 0xaa && (x) <= 0xac)
  110. /*
  111. * This code deals with PGRAPH contexts on NV50 family cards. Like NV40, it's
  112. * the GPU itself that does context-switching, but it needs a special
  113. * microcode to do it. And it's the driver's task to supply this microcode,
  114. * further known as ctxprog, as well as the initial context values, known
  115. * as ctxvals.
  116. *
  117. * Without ctxprog, you cannot switch contexts. Not even in software, since
  118. * the majority of context [xfer strands] isn't accessible directly. You're
  119. * stuck with a single channel, and you also suffer all the problems resulting
  120. * from missing ctxvals, since you cannot load them.
  121. *
  122. * Without ctxvals, you're stuck with PGRAPH's default context. It's enough to
  123. * run 2d operations, but trying to utilise 3d or CUDA will just lock you up,
  124. * since you don't have... some sort of needed setup.
  125. *
  126. * Nouveau will just disable acceleration if not given ctxprog + ctxvals, since
  127. * it's too much hassle to handle no-ctxprog as a special case.
  128. */
  129. /*
  130. * How ctxprogs work.
  131. *
  132. * The ctxprog is written in its own kind of microcode, with very small and
  133. * crappy set of available commands. You upload it to a small [512 insns]
  134. * area of memory on PGRAPH, and it'll be run when PFIFO wants PGRAPH to
  135. * switch channel. or when the driver explicitely requests it. Stuff visible
  136. * to ctxprog consists of: PGRAPH MMIO registers, PGRAPH context strands,
  137. * the per-channel context save area in VRAM [known as ctxvals or grctx],
  138. * 4 flags registers, a scratch register, two grctx pointers, plus many
  139. * random poorly-understood details.
  140. *
  141. * When ctxprog runs, it's supposed to check what operations are asked of it,
  142. * save old context if requested, optionally reset PGRAPH and switch to the
  143. * new channel, and load the new context. Context consists of three major
  144. * parts: subset of MMIO registers and two "xfer areas".
  145. */
  146. /* TODO:
  147. * - document unimplemented bits compared to nvidia
  148. * - NVAx: make a TP subroutine, use it.
  149. * - use 0x4008fc instead of 0x1540?
  150. */
  151. enum cp_label {
  152. cp_check_load = 1,
  153. cp_setup_auto_load,
  154. cp_setup_load,
  155. cp_setup_save,
  156. cp_swap_state,
  157. cp_prepare_exit,
  158. cp_exit,
  159. };
  160. static void nv50_graph_construct_mmio(struct nouveau_grctx *ctx);
  161. static void nv50_graph_construct_xfer1(struct nouveau_grctx *ctx);
  162. static void nv50_graph_construct_xfer2(struct nouveau_grctx *ctx);
  163. /* Main function: construct the ctxprog skeleton, call the other functions. */
  164. int
  165. nv50_grctx_init(struct nouveau_grctx *ctx)
  166. {
  167. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  168. switch (dev_priv->chipset) {
  169. case 0x50:
  170. case 0x84:
  171. case 0x86:
  172. case 0x92:
  173. case 0x94:
  174. case 0x96:
  175. case 0x98:
  176. case 0xa0:
  177. case 0xa3:
  178. case 0xa5:
  179. case 0xa8:
  180. case 0xaa:
  181. case 0xac:
  182. case 0xaf:
  183. break;
  184. default:
  185. NV_ERROR(ctx->dev, "I don't know how to make a ctxprog for "
  186. "your NV%x card.\n", dev_priv->chipset);
  187. NV_ERROR(ctx->dev, "Disabling acceleration. Please contact "
  188. "the devs.\n");
  189. return -ENOSYS;
  190. }
  191. cp_set (ctx, STATE, RUNNING);
  192. cp_set (ctx, XFER_SWITCH, ENABLE);
  193. /* decide whether we're loading/unloading the context */
  194. cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save);
  195. cp_bra (ctx, USER_SAVE, PENDING, cp_setup_save);
  196. cp_name(ctx, cp_check_load);
  197. cp_bra (ctx, AUTO_LOAD, PENDING, cp_setup_auto_load);
  198. cp_bra (ctx, USER_LOAD, PENDING, cp_setup_load);
  199. cp_bra (ctx, ALWAYS, TRUE, cp_exit);
  200. /* setup for context load */
  201. cp_name(ctx, cp_setup_auto_load);
  202. cp_out (ctx, CP_DISABLE1);
  203. cp_out (ctx, CP_DISABLE2);
  204. cp_out (ctx, CP_ENABLE);
  205. cp_out (ctx, CP_NEXT_TO_SWAP);
  206. cp_set (ctx, UNK01, SET);
  207. cp_name(ctx, cp_setup_load);
  208. cp_out (ctx, CP_NEWCTX);
  209. cp_wait(ctx, NEWCTX, BUSY);
  210. cp_set (ctx, UNK1D, CLEAR);
  211. cp_set (ctx, SWAP_DIRECTION, LOAD);
  212. cp_bra (ctx, UNK0B, SET, cp_prepare_exit);
  213. cp_bra (ctx, ALWAYS, TRUE, cp_swap_state);
  214. /* setup for context save */
  215. cp_name(ctx, cp_setup_save);
  216. cp_set (ctx, UNK1D, SET);
  217. cp_wait(ctx, STATUS, BUSY);
  218. cp_wait(ctx, INTR, PENDING);
  219. cp_bra (ctx, STATUS, BUSY, cp_setup_save);
  220. cp_set (ctx, UNK01, SET);
  221. cp_set (ctx, SWAP_DIRECTION, SAVE);
  222. /* general PGRAPH state */
  223. cp_name(ctx, cp_swap_state);
  224. cp_set (ctx, UNK03, SET);
  225. cp_pos (ctx, 0x00004/4);
  226. cp_ctx (ctx, 0x400828, 1); /* needed. otherwise, flickering happens. */
  227. cp_pos (ctx, 0x00100/4);
  228. nv50_graph_construct_mmio(ctx);
  229. nv50_graph_construct_xfer1(ctx);
  230. nv50_graph_construct_xfer2(ctx);
  231. cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_check_load);
  232. cp_set (ctx, UNK20, SET);
  233. cp_set (ctx, SWAP_DIRECTION, SAVE); /* no idea why this is needed, but fixes at least one lockup. */
  234. cp_lsr (ctx, ctx->ctxvals_base);
  235. cp_out (ctx, CP_SET_XFER_POINTER);
  236. cp_lsr (ctx, 4);
  237. cp_out (ctx, CP_SEEK_1);
  238. cp_out (ctx, CP_XFER_1);
  239. cp_wait(ctx, XFER, BUSY);
  240. /* pre-exit state updates */
  241. cp_name(ctx, cp_prepare_exit);
  242. cp_set (ctx, UNK01, CLEAR);
  243. cp_set (ctx, UNK03, CLEAR);
  244. cp_set (ctx, UNK1D, CLEAR);
  245. cp_bra (ctx, USER_SAVE, PENDING, cp_exit);
  246. cp_out (ctx, CP_NEXT_TO_CURRENT);
  247. cp_name(ctx, cp_exit);
  248. cp_set (ctx, USER_SAVE, NOT_PENDING);
  249. cp_set (ctx, USER_LOAD, NOT_PENDING);
  250. cp_set (ctx, XFER_SWITCH, DISABLE);
  251. cp_set (ctx, STATE, STOPPED);
  252. cp_out (ctx, CP_END);
  253. ctx->ctxvals_pos += 0x400; /* padding... no idea why you need it */
  254. return 0;
  255. }
  256. /*
  257. * Constructs MMIO part of ctxprog and ctxvals. Just a matter of knowing which
  258. * registers to save/restore and the default values for them.
  259. */
  260. static void
  261. nv50_graph_construct_mmio_ddata(struct nouveau_grctx *ctx);
  262. static void
  263. nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
  264. {
  265. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  266. int i, j;
  267. int offset, base;
  268. uint32_t units = nv_rd32 (ctx->dev, 0x1540);
  269. /* 0800: DISPATCH */
  270. cp_ctx(ctx, 0x400808, 7);
  271. gr_def(ctx, 0x400814, 0x00000030);
  272. cp_ctx(ctx, 0x400834, 0x32);
  273. if (dev_priv->chipset == 0x50) {
  274. gr_def(ctx, 0x400834, 0xff400040);
  275. gr_def(ctx, 0x400838, 0xfff00080);
  276. gr_def(ctx, 0x40083c, 0xfff70090);
  277. gr_def(ctx, 0x400840, 0xffe806a8);
  278. }
  279. gr_def(ctx, 0x400844, 0x00000002);
  280. if (IS_NVA3F(dev_priv->chipset))
  281. gr_def(ctx, 0x400894, 0x00001000);
  282. gr_def(ctx, 0x4008e8, 0x00000003);
  283. gr_def(ctx, 0x4008ec, 0x00001000);
  284. if (dev_priv->chipset == 0x50)
  285. cp_ctx(ctx, 0x400908, 0xb);
  286. else if (dev_priv->chipset < 0xa0)
  287. cp_ctx(ctx, 0x400908, 0xc);
  288. else
  289. cp_ctx(ctx, 0x400908, 0xe);
  290. if (dev_priv->chipset >= 0xa0)
  291. cp_ctx(ctx, 0x400b00, 0x1);
  292. if (IS_NVA3F(dev_priv->chipset)) {
  293. cp_ctx(ctx, 0x400b10, 0x1);
  294. gr_def(ctx, 0x400b10, 0x0001629d);
  295. cp_ctx(ctx, 0x400b20, 0x1);
  296. gr_def(ctx, 0x400b20, 0x0001629d);
  297. }
  298. nv50_graph_construct_mmio_ddata(ctx);
  299. /* 0C00: VFETCH */
  300. cp_ctx(ctx, 0x400c08, 0x2);
  301. gr_def(ctx, 0x400c08, 0x0000fe0c);
  302. /* 1000 */
  303. if (dev_priv->chipset < 0xa0) {
  304. cp_ctx(ctx, 0x401008, 0x4);
  305. gr_def(ctx, 0x401014, 0x00001000);
  306. } else if (!IS_NVA3F(dev_priv->chipset)) {
  307. cp_ctx(ctx, 0x401008, 0x5);
  308. gr_def(ctx, 0x401018, 0x00001000);
  309. } else {
  310. cp_ctx(ctx, 0x401008, 0x5);
  311. gr_def(ctx, 0x401018, 0x00004000);
  312. }
  313. /* 1400 */
  314. cp_ctx(ctx, 0x401400, 0x8);
  315. cp_ctx(ctx, 0x401424, 0x3);
  316. if (dev_priv->chipset == 0x50)
  317. gr_def(ctx, 0x40142c, 0x0001fd87);
  318. else
  319. gr_def(ctx, 0x40142c, 0x00000187);
  320. cp_ctx(ctx, 0x401540, 0x5);
  321. gr_def(ctx, 0x401550, 0x00001018);
  322. /* 1800: STREAMOUT */
  323. cp_ctx(ctx, 0x401814, 0x1);
  324. gr_def(ctx, 0x401814, 0x000000ff);
  325. if (dev_priv->chipset == 0x50) {
  326. cp_ctx(ctx, 0x40181c, 0xe);
  327. gr_def(ctx, 0x401850, 0x00000004);
  328. } else if (dev_priv->chipset < 0xa0) {
  329. cp_ctx(ctx, 0x40181c, 0xf);
  330. gr_def(ctx, 0x401854, 0x00000004);
  331. } else {
  332. cp_ctx(ctx, 0x40181c, 0x13);
  333. gr_def(ctx, 0x401864, 0x00000004);
  334. }
  335. /* 1C00 */
  336. cp_ctx(ctx, 0x401c00, 0x1);
  337. switch (dev_priv->chipset) {
  338. case 0x50:
  339. gr_def(ctx, 0x401c00, 0x0001005f);
  340. break;
  341. case 0x84:
  342. case 0x86:
  343. case 0x94:
  344. gr_def(ctx, 0x401c00, 0x044d00df);
  345. break;
  346. case 0x92:
  347. case 0x96:
  348. case 0x98:
  349. case 0xa0:
  350. case 0xaa:
  351. case 0xac:
  352. gr_def(ctx, 0x401c00, 0x042500df);
  353. break;
  354. case 0xa3:
  355. case 0xa5:
  356. case 0xa8:
  357. case 0xaf:
  358. gr_def(ctx, 0x401c00, 0x142500df);
  359. break;
  360. }
  361. /* 2000 */
  362. /* 2400 */
  363. cp_ctx(ctx, 0x402400, 0x1);
  364. if (dev_priv->chipset == 0x50)
  365. cp_ctx(ctx, 0x402408, 0x1);
  366. else
  367. cp_ctx(ctx, 0x402408, 0x2);
  368. gr_def(ctx, 0x402408, 0x00000600);
  369. /* 2800: CSCHED */
  370. cp_ctx(ctx, 0x402800, 0x1);
  371. if (dev_priv->chipset == 0x50)
  372. gr_def(ctx, 0x402800, 0x00000006);
  373. /* 2C00: ZCULL */
  374. cp_ctx(ctx, 0x402c08, 0x6);
  375. if (dev_priv->chipset != 0x50)
  376. gr_def(ctx, 0x402c14, 0x01000000);
  377. gr_def(ctx, 0x402c18, 0x000000ff);
  378. if (dev_priv->chipset == 0x50)
  379. cp_ctx(ctx, 0x402ca0, 0x1);
  380. else
  381. cp_ctx(ctx, 0x402ca0, 0x2);
  382. if (dev_priv->chipset < 0xa0)
  383. gr_def(ctx, 0x402ca0, 0x00000400);
  384. else if (!IS_NVA3F(dev_priv->chipset))
  385. gr_def(ctx, 0x402ca0, 0x00000800);
  386. else
  387. gr_def(ctx, 0x402ca0, 0x00000400);
  388. cp_ctx(ctx, 0x402cac, 0x4);
  389. /* 3000: ENG2D */
  390. cp_ctx(ctx, 0x403004, 0x1);
  391. gr_def(ctx, 0x403004, 0x00000001);
  392. /* 3400 */
  393. if (dev_priv->chipset >= 0xa0) {
  394. cp_ctx(ctx, 0x403404, 0x1);
  395. gr_def(ctx, 0x403404, 0x00000001);
  396. }
  397. /* 5000: CCACHE */
  398. cp_ctx(ctx, 0x405000, 0x1);
  399. switch (dev_priv->chipset) {
  400. case 0x50:
  401. gr_def(ctx, 0x405000, 0x00300080);
  402. break;
  403. case 0x84:
  404. case 0xa0:
  405. case 0xa3:
  406. case 0xa5:
  407. case 0xa8:
  408. case 0xaa:
  409. case 0xac:
  410. case 0xaf:
  411. gr_def(ctx, 0x405000, 0x000e0080);
  412. break;
  413. case 0x86:
  414. case 0x92:
  415. case 0x94:
  416. case 0x96:
  417. case 0x98:
  418. gr_def(ctx, 0x405000, 0x00000080);
  419. break;
  420. }
  421. cp_ctx(ctx, 0x405014, 0x1);
  422. gr_def(ctx, 0x405014, 0x00000004);
  423. cp_ctx(ctx, 0x40501c, 0x1);
  424. cp_ctx(ctx, 0x405024, 0x1);
  425. cp_ctx(ctx, 0x40502c, 0x1);
  426. /* 6000? */
  427. if (dev_priv->chipset == 0x50)
  428. cp_ctx(ctx, 0x4063e0, 0x1);
  429. /* 6800: M2MF */
  430. if (dev_priv->chipset < 0x90) {
  431. cp_ctx(ctx, 0x406814, 0x2b);
  432. gr_def(ctx, 0x406818, 0x00000f80);
  433. gr_def(ctx, 0x406860, 0x007f0080);
  434. gr_def(ctx, 0x40689c, 0x007f0080);
  435. } else {
  436. cp_ctx(ctx, 0x406814, 0x4);
  437. if (dev_priv->chipset == 0x98)
  438. gr_def(ctx, 0x406818, 0x00000f80);
  439. else
  440. gr_def(ctx, 0x406818, 0x00001f80);
  441. if (IS_NVA3F(dev_priv->chipset))
  442. gr_def(ctx, 0x40681c, 0x00000030);
  443. cp_ctx(ctx, 0x406830, 0x3);
  444. }
  445. /* 7000: per-ROP group state */
  446. for (i = 0; i < 8; i++) {
  447. if (units & (1<<(i+16))) {
  448. cp_ctx(ctx, 0x407000 + (i<<8), 3);
  449. if (dev_priv->chipset == 0x50)
  450. gr_def(ctx, 0x407000 + (i<<8), 0x1b74f820);
  451. else if (dev_priv->chipset != 0xa5)
  452. gr_def(ctx, 0x407000 + (i<<8), 0x3b74f821);
  453. else
  454. gr_def(ctx, 0x407000 + (i<<8), 0x7b74f821);
  455. gr_def(ctx, 0x407004 + (i<<8), 0x89058001);
  456. if (dev_priv->chipset == 0x50) {
  457. cp_ctx(ctx, 0x407010 + (i<<8), 1);
  458. } else if (dev_priv->chipset < 0xa0) {
  459. cp_ctx(ctx, 0x407010 + (i<<8), 2);
  460. gr_def(ctx, 0x407010 + (i<<8), 0x00001000);
  461. gr_def(ctx, 0x407014 + (i<<8), 0x0000001f);
  462. } else {
  463. cp_ctx(ctx, 0x407010 + (i<<8), 3);
  464. gr_def(ctx, 0x407010 + (i<<8), 0x00001000);
  465. if (dev_priv->chipset != 0xa5)
  466. gr_def(ctx, 0x407014 + (i<<8), 0x000000ff);
  467. else
  468. gr_def(ctx, 0x407014 + (i<<8), 0x000001ff);
  469. }
  470. cp_ctx(ctx, 0x407080 + (i<<8), 4);
  471. if (dev_priv->chipset != 0xa5)
  472. gr_def(ctx, 0x407080 + (i<<8), 0x027c10fa);
  473. else
  474. gr_def(ctx, 0x407080 + (i<<8), 0x827c10fa);
  475. if (dev_priv->chipset == 0x50)
  476. gr_def(ctx, 0x407084 + (i<<8), 0x000000c0);
  477. else
  478. gr_def(ctx, 0x407084 + (i<<8), 0x400000c0);
  479. gr_def(ctx, 0x407088 + (i<<8), 0xb7892080);
  480. if (dev_priv->chipset < 0xa0)
  481. cp_ctx(ctx, 0x407094 + (i<<8), 1);
  482. else if (!IS_NVA3F(dev_priv->chipset))
  483. cp_ctx(ctx, 0x407094 + (i<<8), 3);
  484. else {
  485. cp_ctx(ctx, 0x407094 + (i<<8), 4);
  486. gr_def(ctx, 0x4070a0 + (i<<8), 1);
  487. }
  488. }
  489. }
  490. cp_ctx(ctx, 0x407c00, 0x3);
  491. if (dev_priv->chipset < 0x90)
  492. gr_def(ctx, 0x407c00, 0x00010040);
  493. else if (dev_priv->chipset < 0xa0)
  494. gr_def(ctx, 0x407c00, 0x00390040);
  495. else
  496. gr_def(ctx, 0x407c00, 0x003d0040);
  497. gr_def(ctx, 0x407c08, 0x00000022);
  498. if (dev_priv->chipset >= 0xa0) {
  499. cp_ctx(ctx, 0x407c10, 0x3);
  500. cp_ctx(ctx, 0x407c20, 0x1);
  501. cp_ctx(ctx, 0x407c2c, 0x1);
  502. }
  503. if (dev_priv->chipset < 0xa0) {
  504. cp_ctx(ctx, 0x407d00, 0x9);
  505. } else {
  506. cp_ctx(ctx, 0x407d00, 0x15);
  507. }
  508. if (dev_priv->chipset == 0x98)
  509. gr_def(ctx, 0x407d08, 0x00380040);
  510. else {
  511. if (dev_priv->chipset < 0x90)
  512. gr_def(ctx, 0x407d08, 0x00010040);
  513. else if (dev_priv->chipset < 0xa0)
  514. gr_def(ctx, 0x407d08, 0x00390040);
  515. else
  516. gr_def(ctx, 0x407d08, 0x003d0040);
  517. gr_def(ctx, 0x407d0c, 0x00000022);
  518. }
  519. /* 8000+: per-TP state */
  520. for (i = 0; i < 10; i++) {
  521. if (units & (1<<i)) {
  522. if (dev_priv->chipset < 0xa0)
  523. base = 0x408000 + (i<<12);
  524. else
  525. base = 0x408000 + (i<<11);
  526. if (dev_priv->chipset < 0xa0)
  527. offset = base + 0xc00;
  528. else
  529. offset = base + 0x80;
  530. cp_ctx(ctx, offset + 0x00, 1);
  531. gr_def(ctx, offset + 0x00, 0x0000ff0a);
  532. cp_ctx(ctx, offset + 0x08, 1);
  533. /* per-MP state */
  534. for (j = 0; j < (dev_priv->chipset < 0xa0 ? 2 : 4); j++) {
  535. if (!(units & (1 << (j+24)))) continue;
  536. if (dev_priv->chipset < 0xa0)
  537. offset = base + 0x200 + (j<<7);
  538. else
  539. offset = base + 0x100 + (j<<7);
  540. cp_ctx(ctx, offset, 0x20);
  541. gr_def(ctx, offset + 0x00, 0x01800000);
  542. gr_def(ctx, offset + 0x04, 0x00160000);
  543. gr_def(ctx, offset + 0x08, 0x01800000);
  544. gr_def(ctx, offset + 0x18, 0x0003ffff);
  545. switch (dev_priv->chipset) {
  546. case 0x50:
  547. gr_def(ctx, offset + 0x1c, 0x00080000);
  548. break;
  549. case 0x84:
  550. gr_def(ctx, offset + 0x1c, 0x00880000);
  551. break;
  552. case 0x86:
  553. gr_def(ctx, offset + 0x1c, 0x008c0000);
  554. break;
  555. case 0x92:
  556. case 0x96:
  557. case 0x98:
  558. gr_def(ctx, offset + 0x1c, 0x118c0000);
  559. break;
  560. case 0x94:
  561. gr_def(ctx, offset + 0x1c, 0x10880000);
  562. break;
  563. case 0xa0:
  564. case 0xa5:
  565. gr_def(ctx, offset + 0x1c, 0x310c0000);
  566. break;
  567. case 0xa3:
  568. case 0xa8:
  569. case 0xaa:
  570. case 0xac:
  571. case 0xaf:
  572. gr_def(ctx, offset + 0x1c, 0x300c0000);
  573. break;
  574. }
  575. gr_def(ctx, offset + 0x40, 0x00010401);
  576. if (dev_priv->chipset == 0x50)
  577. gr_def(ctx, offset + 0x48, 0x00000040);
  578. else
  579. gr_def(ctx, offset + 0x48, 0x00000078);
  580. gr_def(ctx, offset + 0x50, 0x000000bf);
  581. gr_def(ctx, offset + 0x58, 0x00001210);
  582. if (dev_priv->chipset == 0x50)
  583. gr_def(ctx, offset + 0x5c, 0x00000080);
  584. else
  585. gr_def(ctx, offset + 0x5c, 0x08000080);
  586. if (dev_priv->chipset >= 0xa0)
  587. gr_def(ctx, offset + 0x68, 0x0000003e);
  588. }
  589. if (dev_priv->chipset < 0xa0)
  590. cp_ctx(ctx, base + 0x300, 0x4);
  591. else
  592. cp_ctx(ctx, base + 0x300, 0x5);
  593. if (dev_priv->chipset == 0x50)
  594. gr_def(ctx, base + 0x304, 0x00007070);
  595. else if (dev_priv->chipset < 0xa0)
  596. gr_def(ctx, base + 0x304, 0x00027070);
  597. else if (!IS_NVA3F(dev_priv->chipset))
  598. gr_def(ctx, base + 0x304, 0x01127070);
  599. else
  600. gr_def(ctx, base + 0x304, 0x05127070);
  601. if (dev_priv->chipset < 0xa0)
  602. cp_ctx(ctx, base + 0x318, 1);
  603. else
  604. cp_ctx(ctx, base + 0x320, 1);
  605. if (dev_priv->chipset == 0x50)
  606. gr_def(ctx, base + 0x318, 0x0003ffff);
  607. else if (dev_priv->chipset < 0xa0)
  608. gr_def(ctx, base + 0x318, 0x03ffffff);
  609. else
  610. gr_def(ctx, base + 0x320, 0x07ffffff);
  611. if (dev_priv->chipset < 0xa0)
  612. cp_ctx(ctx, base + 0x324, 5);
  613. else
  614. cp_ctx(ctx, base + 0x328, 4);
  615. if (dev_priv->chipset < 0xa0) {
  616. cp_ctx(ctx, base + 0x340, 9);
  617. offset = base + 0x340;
  618. } else if (!IS_NVA3F(dev_priv->chipset)) {
  619. cp_ctx(ctx, base + 0x33c, 0xb);
  620. offset = base + 0x344;
  621. } else {
  622. cp_ctx(ctx, base + 0x33c, 0xd);
  623. offset = base + 0x344;
  624. }
  625. gr_def(ctx, offset + 0x0, 0x00120407);
  626. gr_def(ctx, offset + 0x4, 0x05091507);
  627. if (dev_priv->chipset == 0x84)
  628. gr_def(ctx, offset + 0x8, 0x05100202);
  629. else
  630. gr_def(ctx, offset + 0x8, 0x05010202);
  631. gr_def(ctx, offset + 0xc, 0x00030201);
  632. if (dev_priv->chipset == 0xa3)
  633. cp_ctx(ctx, base + 0x36c, 1);
  634. cp_ctx(ctx, base + 0x400, 2);
  635. gr_def(ctx, base + 0x404, 0x00000040);
  636. cp_ctx(ctx, base + 0x40c, 2);
  637. gr_def(ctx, base + 0x40c, 0x0d0c0b0a);
  638. gr_def(ctx, base + 0x410, 0x00141210);
  639. if (dev_priv->chipset < 0xa0)
  640. offset = base + 0x800;
  641. else
  642. offset = base + 0x500;
  643. cp_ctx(ctx, offset, 6);
  644. gr_def(ctx, offset + 0x0, 0x000001f0);
  645. gr_def(ctx, offset + 0x4, 0x00000001);
  646. gr_def(ctx, offset + 0x8, 0x00000003);
  647. if (dev_priv->chipset == 0x50 || IS_NVAAF(dev_priv->chipset))
  648. gr_def(ctx, offset + 0xc, 0x00008000);
  649. gr_def(ctx, offset + 0x14, 0x00039e00);
  650. cp_ctx(ctx, offset + 0x1c, 2);
  651. if (dev_priv->chipset == 0x50)
  652. gr_def(ctx, offset + 0x1c, 0x00000040);
  653. else
  654. gr_def(ctx, offset + 0x1c, 0x00000100);
  655. gr_def(ctx, offset + 0x20, 0x00003800);
  656. if (dev_priv->chipset >= 0xa0) {
  657. cp_ctx(ctx, base + 0x54c, 2);
  658. if (!IS_NVA3F(dev_priv->chipset))
  659. gr_def(ctx, base + 0x54c, 0x003fe006);
  660. else
  661. gr_def(ctx, base + 0x54c, 0x003fe007);
  662. gr_def(ctx, base + 0x550, 0x003fe000);
  663. }
  664. if (dev_priv->chipset < 0xa0)
  665. offset = base + 0xa00;
  666. else
  667. offset = base + 0x680;
  668. cp_ctx(ctx, offset, 1);
  669. gr_def(ctx, offset, 0x00404040);
  670. if (dev_priv->chipset < 0xa0)
  671. offset = base + 0xe00;
  672. else
  673. offset = base + 0x700;
  674. cp_ctx(ctx, offset, 2);
  675. if (dev_priv->chipset < 0xa0)
  676. gr_def(ctx, offset, 0x0077f005);
  677. else if (dev_priv->chipset == 0xa5)
  678. gr_def(ctx, offset, 0x6cf7f007);
  679. else if (dev_priv->chipset == 0xa8)
  680. gr_def(ctx, offset, 0x6cfff007);
  681. else if (dev_priv->chipset == 0xac)
  682. gr_def(ctx, offset, 0x0cfff007);
  683. else
  684. gr_def(ctx, offset, 0x0cf7f007);
  685. if (dev_priv->chipset == 0x50)
  686. gr_def(ctx, offset + 0x4, 0x00007fff);
  687. else if (dev_priv->chipset < 0xa0)
  688. gr_def(ctx, offset + 0x4, 0x003f7fff);
  689. else
  690. gr_def(ctx, offset + 0x4, 0x02bf7fff);
  691. cp_ctx(ctx, offset + 0x2c, 1);
  692. if (dev_priv->chipset == 0x50) {
  693. cp_ctx(ctx, offset + 0x50, 9);
  694. gr_def(ctx, offset + 0x54, 0x000003ff);
  695. gr_def(ctx, offset + 0x58, 0x00000003);
  696. gr_def(ctx, offset + 0x5c, 0x00000003);
  697. gr_def(ctx, offset + 0x60, 0x000001ff);
  698. gr_def(ctx, offset + 0x64, 0x0000001f);
  699. gr_def(ctx, offset + 0x68, 0x0000000f);
  700. gr_def(ctx, offset + 0x6c, 0x0000000f);
  701. } else if (dev_priv->chipset < 0xa0) {
  702. cp_ctx(ctx, offset + 0x50, 1);
  703. cp_ctx(ctx, offset + 0x70, 1);
  704. } else {
  705. cp_ctx(ctx, offset + 0x50, 1);
  706. cp_ctx(ctx, offset + 0x60, 5);
  707. }
  708. }
  709. }
  710. }
  711. static void
  712. dd_emit(struct nouveau_grctx *ctx, int num, uint32_t val) {
  713. int i;
  714. if (val && ctx->mode == NOUVEAU_GRCTX_VALS)
  715. for (i = 0; i < num; i++)
  716. nv_wo32(ctx->data, 4 * (ctx->ctxvals_pos + i), val);
  717. ctx->ctxvals_pos += num;
  718. }
  719. static void
  720. nv50_graph_construct_mmio_ddata(struct nouveau_grctx *ctx)
  721. {
  722. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  723. int base, num;
  724. base = ctx->ctxvals_pos;
  725. /* tesla state */
  726. dd_emit(ctx, 1, 0); /* 00000001 UNK0F90 */
  727. dd_emit(ctx, 1, 0); /* 00000001 UNK135C */
  728. /* SRC_TIC state */
  729. dd_emit(ctx, 1, 0); /* 00000007 SRC_TILE_MODE_Z */
  730. dd_emit(ctx, 1, 2); /* 00000007 SRC_TILE_MODE_Y */
  731. dd_emit(ctx, 1, 1); /* 00000001 SRC_LINEAR #1 */
  732. dd_emit(ctx, 1, 0); /* 000000ff SRC_ADDRESS_HIGH */
  733. dd_emit(ctx, 1, 0); /* 00000001 SRC_SRGB */
  734. if (dev_priv->chipset >= 0x94)
  735. dd_emit(ctx, 1, 0); /* 00000003 eng2d UNK0258 */
  736. dd_emit(ctx, 1, 1); /* 00000fff SRC_DEPTH */
  737. dd_emit(ctx, 1, 0x100); /* 0000ffff SRC_HEIGHT */
  738. /* turing state */
  739. dd_emit(ctx, 1, 0); /* 0000000f TEXTURES_LOG2 */
  740. dd_emit(ctx, 1, 0); /* 0000000f SAMPLERS_LOG2 */
  741. dd_emit(ctx, 1, 0); /* 000000ff CB_DEF_ADDRESS_HIGH */
  742. dd_emit(ctx, 1, 0); /* ffffffff CB_DEF_ADDRESS_LOW */
  743. dd_emit(ctx, 1, 0); /* ffffffff SHARED_SIZE */
  744. dd_emit(ctx, 1, 2); /* ffffffff REG_MODE */
  745. dd_emit(ctx, 1, 1); /* 0000ffff BLOCK_ALLOC_THREADS */
  746. dd_emit(ctx, 1, 1); /* 00000001 LANES32 */
  747. dd_emit(ctx, 1, 0); /* 000000ff UNK370 */
  748. dd_emit(ctx, 1, 0); /* 000000ff USER_PARAM_UNK */
  749. dd_emit(ctx, 1, 0); /* 000000ff USER_PARAM_COUNT */
  750. dd_emit(ctx, 1, 1); /* 000000ff UNK384 bits 8-15 */
  751. dd_emit(ctx, 1, 0x3fffff); /* 003fffff TIC_LIMIT */
  752. dd_emit(ctx, 1, 0x1fff); /* 000fffff TSC_LIMIT */
  753. dd_emit(ctx, 1, 0); /* 0000ffff CB_ADDR_INDEX */
  754. dd_emit(ctx, 1, 1); /* 000007ff BLOCKDIM_X */
  755. dd_emit(ctx, 1, 1); /* 000007ff BLOCKDIM_XMY */
  756. dd_emit(ctx, 1, 0); /* 00000001 BLOCKDIM_XMY_OVERFLOW */
  757. dd_emit(ctx, 1, 1); /* 0003ffff BLOCKDIM_XMYMZ */
  758. dd_emit(ctx, 1, 1); /* 000007ff BLOCKDIM_Y */
  759. dd_emit(ctx, 1, 1); /* 0000007f BLOCKDIM_Z */
  760. dd_emit(ctx, 1, 4); /* 000000ff CP_REG_ALLOC_TEMP */
  761. dd_emit(ctx, 1, 1); /* 00000001 BLOCKDIM_DIRTY */
  762. if (IS_NVA3F(dev_priv->chipset))
  763. dd_emit(ctx, 1, 0); /* 00000003 UNK03E8 */
  764. dd_emit(ctx, 1, 1); /* 0000007f BLOCK_ALLOC_HALFWARPS */
  765. dd_emit(ctx, 1, 1); /* 00000007 LOCAL_WARPS_NO_CLAMP */
  766. dd_emit(ctx, 1, 7); /* 00000007 LOCAL_WARPS_LOG_ALLOC */
  767. dd_emit(ctx, 1, 1); /* 00000007 STACK_WARPS_NO_CLAMP */
  768. dd_emit(ctx, 1, 7); /* 00000007 STACK_WARPS_LOG_ALLOC */
  769. dd_emit(ctx, 1, 1); /* 00001fff BLOCK_ALLOC_REGSLOTS_PACKED */
  770. dd_emit(ctx, 1, 1); /* 00001fff BLOCK_ALLOC_REGSLOTS_STRIDED */
  771. dd_emit(ctx, 1, 1); /* 000007ff BLOCK_ALLOC_THREADS */
  772. /* compat 2d state */
  773. if (dev_priv->chipset == 0x50) {
  774. dd_emit(ctx, 4, 0); /* 0000ffff clip X, Y, W, H */
  775. dd_emit(ctx, 1, 1); /* ffffffff chroma COLOR_FORMAT */
  776. dd_emit(ctx, 1, 1); /* ffffffff pattern COLOR_FORMAT */
  777. dd_emit(ctx, 1, 0); /* ffffffff pattern SHAPE */
  778. dd_emit(ctx, 1, 1); /* ffffffff pattern PATTERN_SELECT */
  779. dd_emit(ctx, 1, 0xa); /* ffffffff surf2d SRC_FORMAT */
  780. dd_emit(ctx, 1, 0); /* ffffffff surf2d DMA_SRC */
  781. dd_emit(ctx, 1, 0); /* 000000ff surf2d SRC_ADDRESS_HIGH */
  782. dd_emit(ctx, 1, 0); /* ffffffff surf2d SRC_ADDRESS_LOW */
  783. dd_emit(ctx, 1, 0x40); /* 0000ffff surf2d SRC_PITCH */
  784. dd_emit(ctx, 1, 0); /* 0000000f surf2d SRC_TILE_MODE_Z */
  785. dd_emit(ctx, 1, 2); /* 0000000f surf2d SRC_TILE_MODE_Y */
  786. dd_emit(ctx, 1, 0x100); /* ffffffff surf2d SRC_HEIGHT */
  787. dd_emit(ctx, 1, 1); /* 00000001 surf2d SRC_LINEAR */
  788. dd_emit(ctx, 1, 0x100); /* ffffffff surf2d SRC_WIDTH */
  789. dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_B_X */
  790. dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_B_Y */
  791. dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_C_X */
  792. dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_C_Y */
  793. dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_D_X */
  794. dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_D_Y */
  795. dd_emit(ctx, 1, 1); /* ffffffff gdirect COLOR_FORMAT */
  796. dd_emit(ctx, 1, 0); /* ffffffff gdirect OPERATION */
  797. dd_emit(ctx, 1, 0); /* 0000ffff gdirect POINT_X */
  798. dd_emit(ctx, 1, 0); /* 0000ffff gdirect POINT_Y */
  799. dd_emit(ctx, 1, 0); /* 0000ffff blit SRC_Y */
  800. dd_emit(ctx, 1, 0); /* ffffffff blit OPERATION */
  801. dd_emit(ctx, 1, 0); /* ffffffff ifc OPERATION */
  802. dd_emit(ctx, 1, 0); /* ffffffff iifc INDEX_FORMAT */
  803. dd_emit(ctx, 1, 0); /* ffffffff iifc LUT_OFFSET */
  804. dd_emit(ctx, 1, 4); /* ffffffff iifc COLOR_FORMAT */
  805. dd_emit(ctx, 1, 0); /* ffffffff iifc OPERATION */
  806. }
  807. /* m2mf state */
  808. dd_emit(ctx, 1, 0); /* ffffffff m2mf LINE_COUNT */
  809. dd_emit(ctx, 1, 0); /* ffffffff m2mf LINE_LENGTH_IN */
  810. dd_emit(ctx, 2, 0); /* ffffffff m2mf OFFSET_IN, OFFSET_OUT */
  811. dd_emit(ctx, 1, 1); /* ffffffff m2mf TILING_DEPTH_OUT */
  812. dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_HEIGHT_OUT */
  813. dd_emit(ctx, 1, 0); /* ffffffff m2mf TILING_POSITION_OUT_Z */
  814. dd_emit(ctx, 1, 1); /* 00000001 m2mf LINEAR_OUT */
  815. dd_emit(ctx, 2, 0); /* 0000ffff m2mf TILING_POSITION_OUT_X, Y */
  816. dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_PITCH_OUT */
  817. dd_emit(ctx, 1, 1); /* ffffffff m2mf TILING_DEPTH_IN */
  818. dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_HEIGHT_IN */
  819. dd_emit(ctx, 1, 0); /* ffffffff m2mf TILING_POSITION_IN_Z */
  820. dd_emit(ctx, 1, 1); /* 00000001 m2mf LINEAR_IN */
  821. dd_emit(ctx, 2, 0); /* 0000ffff m2mf TILING_POSITION_IN_X, Y */
  822. dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_PITCH_IN */
  823. /* more compat 2d state */
  824. if (dev_priv->chipset == 0x50) {
  825. dd_emit(ctx, 1, 1); /* ffffffff line COLOR_FORMAT */
  826. dd_emit(ctx, 1, 0); /* ffffffff line OPERATION */
  827. dd_emit(ctx, 1, 1); /* ffffffff triangle COLOR_FORMAT */
  828. dd_emit(ctx, 1, 0); /* ffffffff triangle OPERATION */
  829. dd_emit(ctx, 1, 0); /* 0000000f sifm TILE_MODE_Z */
  830. dd_emit(ctx, 1, 2); /* 0000000f sifm TILE_MODE_Y */
  831. dd_emit(ctx, 1, 0); /* 000000ff sifm FORMAT_FILTER */
  832. dd_emit(ctx, 1, 1); /* 000000ff sifm FORMAT_ORIGIN */
  833. dd_emit(ctx, 1, 0); /* 0000ffff sifm SRC_PITCH */
  834. dd_emit(ctx, 1, 1); /* 00000001 sifm SRC_LINEAR */
  835. dd_emit(ctx, 1, 0); /* 000000ff sifm SRC_OFFSET_HIGH */
  836. dd_emit(ctx, 1, 0); /* ffffffff sifm SRC_OFFSET */
  837. dd_emit(ctx, 1, 0); /* 0000ffff sifm SRC_HEIGHT */
  838. dd_emit(ctx, 1, 0); /* 0000ffff sifm SRC_WIDTH */
  839. dd_emit(ctx, 1, 3); /* ffffffff sifm COLOR_FORMAT */
  840. dd_emit(ctx, 1, 0); /* ffffffff sifm OPERATION */
  841. dd_emit(ctx, 1, 0); /* ffffffff sifc OPERATION */
  842. }
  843. /* tesla state */
  844. dd_emit(ctx, 1, 0); /* 0000000f GP_TEXTURES_LOG2 */
  845. dd_emit(ctx, 1, 0); /* 0000000f GP_SAMPLERS_LOG2 */
  846. dd_emit(ctx, 1, 0); /* 000000ff */
  847. dd_emit(ctx, 1, 0); /* ffffffff */
  848. dd_emit(ctx, 1, 4); /* 000000ff UNK12B0_0 */
  849. dd_emit(ctx, 1, 0x70); /* 000000ff UNK12B0_1 */
  850. dd_emit(ctx, 1, 0x80); /* 000000ff UNK12B0_3 */
  851. dd_emit(ctx, 1, 0); /* 000000ff UNK12B0_2 */
  852. dd_emit(ctx, 1, 0); /* 0000000f FP_TEXTURES_LOG2 */
  853. dd_emit(ctx, 1, 0); /* 0000000f FP_SAMPLERS_LOG2 */
  854. if (IS_NVA3F(dev_priv->chipset)) {
  855. dd_emit(ctx, 1, 0); /* ffffffff */
  856. dd_emit(ctx, 1, 0); /* 0000007f MULTISAMPLE_SAMPLES_LOG2 */
  857. } else {
  858. dd_emit(ctx, 1, 0); /* 0000000f MULTISAMPLE_SAMPLES_LOG2 */
  859. }
  860. dd_emit(ctx, 1, 0xc); /* 000000ff SEMANTIC_COLOR.BFC0_ID */
  861. if (dev_priv->chipset != 0x50)
  862. dd_emit(ctx, 1, 0); /* 00000001 SEMANTIC_COLOR.CLMP_EN */
  863. dd_emit(ctx, 1, 8); /* 000000ff SEMANTIC_COLOR.COLR_NR */
  864. dd_emit(ctx, 1, 0x14); /* 000000ff SEMANTIC_COLOR.FFC0_ID */
  865. if (dev_priv->chipset == 0x50) {
  866. dd_emit(ctx, 1, 0); /* 000000ff SEMANTIC_LAYER */
  867. dd_emit(ctx, 1, 0); /* 00000001 */
  868. } else {
  869. dd_emit(ctx, 1, 0); /* 00000001 SEMANTIC_PTSZ.ENABLE */
  870. dd_emit(ctx, 1, 0x29); /* 000000ff SEMANTIC_PTSZ.PTSZ_ID */
  871. dd_emit(ctx, 1, 0x27); /* 000000ff SEMANTIC_PRIM */
  872. dd_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
  873. dd_emit(ctx, 1, 8); /* 0000000f SMENATIC_CLIP.CLIP_HIGH */
  874. dd_emit(ctx, 1, 4); /* 000000ff SEMANTIC_CLIP.CLIP_LO */
  875. dd_emit(ctx, 1, 0x27); /* 000000ff UNK0FD4 */
  876. dd_emit(ctx, 1, 0); /* 00000001 UNK1900 */
  877. }
  878. dd_emit(ctx, 1, 0); /* 00000007 RT_CONTROL_MAP0 */
  879. dd_emit(ctx, 1, 1); /* 00000007 RT_CONTROL_MAP1 */
  880. dd_emit(ctx, 1, 2); /* 00000007 RT_CONTROL_MAP2 */
  881. dd_emit(ctx, 1, 3); /* 00000007 RT_CONTROL_MAP3 */
  882. dd_emit(ctx, 1, 4); /* 00000007 RT_CONTROL_MAP4 */
  883. dd_emit(ctx, 1, 5); /* 00000007 RT_CONTROL_MAP5 */
  884. dd_emit(ctx, 1, 6); /* 00000007 RT_CONTROL_MAP6 */
  885. dd_emit(ctx, 1, 7); /* 00000007 RT_CONTROL_MAP7 */
  886. dd_emit(ctx, 1, 1); /* 0000000f RT_CONTROL_COUNT */
  887. dd_emit(ctx, 8, 0); /* 00000001 RT_HORIZ_UNK */
  888. dd_emit(ctx, 8, 0); /* ffffffff RT_ADDRESS_LOW */
  889. dd_emit(ctx, 1, 0xcf); /* 000000ff RT_FORMAT */
  890. dd_emit(ctx, 7, 0); /* 000000ff RT_FORMAT */
  891. if (dev_priv->chipset != 0x50)
  892. dd_emit(ctx, 3, 0); /* 1, 1, 1 */
  893. else
  894. dd_emit(ctx, 2, 0); /* 1, 1 */
  895. dd_emit(ctx, 1, 0); /* ffffffff GP_ENABLE */
  896. dd_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT*/
  897. dd_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
  898. dd_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  899. if (IS_NVA3F(dev_priv->chipset)) {
  900. dd_emit(ctx, 1, 3); /* 00000003 */
  901. dd_emit(ctx, 1, 0); /* 00000001 UNK1418. Alone. */
  902. }
  903. if (dev_priv->chipset != 0x50)
  904. dd_emit(ctx, 1, 3); /* 00000003 UNK15AC */
  905. dd_emit(ctx, 1, 1); /* ffffffff RASTERIZE_ENABLE */
  906. dd_emit(ctx, 1, 0); /* 00000001 FP_CONTROL.EXPORTS_Z */
  907. if (dev_priv->chipset != 0x50)
  908. dd_emit(ctx, 1, 0); /* 00000001 FP_CONTROL.MULTIPLE_RESULTS */
  909. dd_emit(ctx, 1, 0x12); /* 000000ff FP_INTERPOLANT_CTRL.COUNT */
  910. dd_emit(ctx, 1, 0x10); /* 000000ff FP_INTERPOLANT_CTRL.COUNT_NONFLAT */
  911. dd_emit(ctx, 1, 0xc); /* 000000ff FP_INTERPOLANT_CTRL.OFFSET */
  912. dd_emit(ctx, 1, 1); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.W */
  913. dd_emit(ctx, 1, 0); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.X */
  914. dd_emit(ctx, 1, 0); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.Y */
  915. dd_emit(ctx, 1, 0); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.Z */
  916. dd_emit(ctx, 1, 4); /* 000000ff FP_RESULT_COUNT */
  917. dd_emit(ctx, 1, 2); /* ffffffff REG_MODE */
  918. dd_emit(ctx, 1, 4); /* 000000ff FP_REG_ALLOC_TEMP */
  919. if (dev_priv->chipset >= 0xa0)
  920. dd_emit(ctx, 1, 0); /* ffffffff */
  921. dd_emit(ctx, 1, 0); /* 00000001 GP_BUILTIN_RESULT_EN.LAYER_IDX */
  922. dd_emit(ctx, 1, 0); /* ffffffff STRMOUT_ENABLE */
  923. dd_emit(ctx, 1, 0x3fffff); /* 003fffff TIC_LIMIT */
  924. dd_emit(ctx, 1, 0x1fff); /* 000fffff TSC_LIMIT */
  925. dd_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE*/
  926. if (dev_priv->chipset != 0x50)
  927. dd_emit(ctx, 8, 0); /* 00000001 */
  928. if (dev_priv->chipset >= 0xa0) {
  929. dd_emit(ctx, 1, 1); /* 00000007 VTX_ATTR_DEFINE.COMP */
  930. dd_emit(ctx, 1, 1); /* 00000007 VTX_ATTR_DEFINE.SIZE */
  931. dd_emit(ctx, 1, 2); /* 00000007 VTX_ATTR_DEFINE.TYPE */
  932. dd_emit(ctx, 1, 0); /* 000000ff VTX_ATTR_DEFINE.ATTR */
  933. }
  934. dd_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  935. dd_emit(ctx, 1, 0x14); /* 0000001f ZETA_FORMAT */
  936. dd_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  937. dd_emit(ctx, 1, 0); /* 0000000f VP_TEXTURES_LOG2 */
  938. dd_emit(ctx, 1, 0); /* 0000000f VP_SAMPLERS_LOG2 */
  939. if (IS_NVA3F(dev_priv->chipset))
  940. dd_emit(ctx, 1, 0); /* 00000001 */
  941. dd_emit(ctx, 1, 2); /* 00000003 POLYGON_MODE_BACK */
  942. if (dev_priv->chipset >= 0xa0)
  943. dd_emit(ctx, 1, 0); /* 00000003 VTX_ATTR_DEFINE.SIZE - 1 */
  944. dd_emit(ctx, 1, 0); /* 0000ffff CB_ADDR_INDEX */
  945. if (dev_priv->chipset >= 0xa0)
  946. dd_emit(ctx, 1, 0); /* 00000003 */
  947. dd_emit(ctx, 1, 0); /* 00000001 CULL_FACE_ENABLE */
  948. dd_emit(ctx, 1, 1); /* 00000003 CULL_FACE */
  949. dd_emit(ctx, 1, 0); /* 00000001 FRONT_FACE */
  950. dd_emit(ctx, 1, 2); /* 00000003 POLYGON_MODE_FRONT */
  951. dd_emit(ctx, 1, 0x1000); /* 00007fff UNK141C */
  952. if (dev_priv->chipset != 0x50) {
  953. dd_emit(ctx, 1, 0xe00); /* 7fff */
  954. dd_emit(ctx, 1, 0x1000); /* 7fff */
  955. dd_emit(ctx, 1, 0x1e00); /* 7fff */
  956. }
  957. dd_emit(ctx, 1, 0); /* 00000001 BEGIN_END_ACTIVE */
  958. dd_emit(ctx, 1, 1); /* 00000001 POLYGON_MODE_??? */
  959. dd_emit(ctx, 1, 1); /* 000000ff GP_REG_ALLOC_TEMP / 4 rounded up */
  960. dd_emit(ctx, 1, 1); /* 000000ff FP_REG_ALLOC_TEMP... without /4? */
  961. dd_emit(ctx, 1, 1); /* 000000ff VP_REG_ALLOC_TEMP / 4 rounded up */
  962. dd_emit(ctx, 1, 1); /* 00000001 */
  963. dd_emit(ctx, 1, 0); /* 00000001 */
  964. dd_emit(ctx, 1, 0); /* 00000001 VTX_ATTR_MASK_UNK0 nonempty */
  965. dd_emit(ctx, 1, 0); /* 00000001 VTX_ATTR_MASK_UNK1 nonempty */
  966. dd_emit(ctx, 1, 0x200); /* 0003ffff GP_VERTEX_OUTPUT_COUNT*GP_REG_ALLOC_RESULT */
  967. if (IS_NVA3F(dev_priv->chipset))
  968. dd_emit(ctx, 1, 0x200);
  969. dd_emit(ctx, 1, 0); /* 00000001 */
  970. if (dev_priv->chipset < 0xa0) {
  971. dd_emit(ctx, 1, 1); /* 00000001 */
  972. dd_emit(ctx, 1, 0x70); /* 000000ff */
  973. dd_emit(ctx, 1, 0x80); /* 000000ff */
  974. dd_emit(ctx, 1, 0); /* 000000ff */
  975. dd_emit(ctx, 1, 0); /* 00000001 */
  976. dd_emit(ctx, 1, 1); /* 00000001 */
  977. dd_emit(ctx, 1, 0x70); /* 000000ff */
  978. dd_emit(ctx, 1, 0x80); /* 000000ff */
  979. dd_emit(ctx, 1, 0); /* 000000ff */
  980. } else {
  981. dd_emit(ctx, 1, 1); /* 00000001 */
  982. dd_emit(ctx, 1, 0xf0); /* 000000ff */
  983. dd_emit(ctx, 1, 0xff); /* 000000ff */
  984. dd_emit(ctx, 1, 0); /* 000000ff */
  985. dd_emit(ctx, 1, 0); /* 00000001 */
  986. dd_emit(ctx, 1, 1); /* 00000001 */
  987. dd_emit(ctx, 1, 0xf0); /* 000000ff */
  988. dd_emit(ctx, 1, 0xff); /* 000000ff */
  989. dd_emit(ctx, 1, 0); /* 000000ff */
  990. dd_emit(ctx, 1, 9); /* 0000003f UNK114C.COMP,SIZE */
  991. }
  992. /* eng2d state */
  993. dd_emit(ctx, 1, 0); /* 00000001 eng2d COLOR_KEY_ENABLE */
  994. dd_emit(ctx, 1, 0); /* 00000007 eng2d COLOR_KEY_FORMAT */
  995. dd_emit(ctx, 1, 1); /* ffffffff eng2d DST_DEPTH */
  996. dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d DST_FORMAT */
  997. dd_emit(ctx, 1, 0); /* ffffffff eng2d DST_LAYER */
  998. dd_emit(ctx, 1, 1); /* 00000001 eng2d DST_LINEAR */
  999. dd_emit(ctx, 1, 0); /* 00000007 eng2d PATTERN_COLOR_FORMAT */
  1000. dd_emit(ctx, 1, 0); /* 00000007 eng2d OPERATION */
  1001. dd_emit(ctx, 1, 0); /* 00000003 eng2d PATTERN_SELECT */
  1002. dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d SIFC_FORMAT */
  1003. dd_emit(ctx, 1, 0); /* 00000001 eng2d SIFC_BITMAP_ENABLE */
  1004. dd_emit(ctx, 1, 2); /* 00000003 eng2d SIFC_BITMAP_UNK808 */
  1005. dd_emit(ctx, 1, 0); /* ffffffff eng2d BLIT_DU_DX_FRACT */
  1006. dd_emit(ctx, 1, 1); /* ffffffff eng2d BLIT_DU_DX_INT */
  1007. dd_emit(ctx, 1, 0); /* ffffffff eng2d BLIT_DV_DY_FRACT */
  1008. dd_emit(ctx, 1, 1); /* ffffffff eng2d BLIT_DV_DY_INT */
  1009. dd_emit(ctx, 1, 0); /* 00000001 eng2d BLIT_CONTROL_FILTER */
  1010. dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d DRAW_COLOR_FORMAT */
  1011. dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d SRC_FORMAT */
  1012. dd_emit(ctx, 1, 1); /* 00000001 eng2d SRC_LINEAR #2 */
  1013. num = ctx->ctxvals_pos - base;
  1014. ctx->ctxvals_pos = base;
  1015. if (IS_NVA3F(dev_priv->chipset))
  1016. cp_ctx(ctx, 0x404800, num);
  1017. else
  1018. cp_ctx(ctx, 0x405400, num);
  1019. }
  1020. /*
  1021. * xfer areas. These are a pain.
  1022. *
  1023. * There are 2 xfer areas: the first one is big and contains all sorts of
  1024. * stuff, the second is small and contains some per-TP context.
  1025. *
  1026. * Each area is split into 8 "strands". The areas, when saved to grctx,
  1027. * are made of 8-word blocks. Each block contains a single word from
  1028. * each strand. The strands are independent of each other, their
  1029. * addresses are unrelated to each other, and data in them is closely
  1030. * packed together. The strand layout varies a bit between cards: here
  1031. * and there, a single word is thrown out in the middle and the whole
  1032. * strand is offset by a bit from corresponding one on another chipset.
  1033. * For this reason, addresses of stuff in strands are almost useless.
  1034. * Knowing sequence of stuff and size of gaps between them is much more
  1035. * useful, and that's how we build the strands in our generator.
  1036. *
  1037. * NVA0 takes this mess to a whole new level by cutting the old strands
  1038. * into a few dozen pieces [known as genes], rearranging them randomly,
  1039. * and putting them back together to make new strands. Hopefully these
  1040. * genes correspond more or less directly to the same PGRAPH subunits
  1041. * as in 400040 register.
  1042. *
  1043. * The most common value in default context is 0, and when the genes
  1044. * are separated by 0's, gene bounduaries are quite speculative...
  1045. * some of them can be clearly deduced, others can be guessed, and yet
  1046. * others won't be resolved without figuring out the real meaning of
  1047. * given ctxval. For the same reason, ending point of each strand
  1048. * is unknown. Except for strand 0, which is the longest strand and
  1049. * its end corresponds to end of the whole xfer.
  1050. *
  1051. * An unsolved mystery is the seek instruction: it takes an argument
  1052. * in bits 8-18, and that argument is clearly the place in strands to
  1053. * seek to... but the offsets don't seem to correspond to offsets as
  1054. * seen in grctx. Perhaps there's another, real, not randomly-changing
  1055. * addressing in strands, and the xfer insn just happens to skip over
  1056. * the unused bits? NV10-NV30 PIPE comes to mind...
  1057. *
  1058. * As far as I know, there's no way to access the xfer areas directly
  1059. * without the help of ctxprog.
  1060. */
  1061. static void
  1062. xf_emit(struct nouveau_grctx *ctx, int num, uint32_t val) {
  1063. int i;
  1064. if (val && ctx->mode == NOUVEAU_GRCTX_VALS)
  1065. for (i = 0; i < num; i++)
  1066. nv_wo32(ctx->data, 4 * (ctx->ctxvals_pos + (i << 3)), val);
  1067. ctx->ctxvals_pos += num << 3;
  1068. }
  1069. /* Gene declarations... */
  1070. static void nv50_graph_construct_gene_dispatch(struct nouveau_grctx *ctx);
  1071. static void nv50_graph_construct_gene_m2mf(struct nouveau_grctx *ctx);
  1072. static void nv50_graph_construct_gene_ccache(struct nouveau_grctx *ctx);
  1073. static void nv50_graph_construct_gene_unk10xx(struct nouveau_grctx *ctx);
  1074. static void nv50_graph_construct_gene_unk14xx(struct nouveau_grctx *ctx);
  1075. static void nv50_graph_construct_gene_zcull(struct nouveau_grctx *ctx);
  1076. static void nv50_graph_construct_gene_clipid(struct nouveau_grctx *ctx);
  1077. static void nv50_graph_construct_gene_unk24xx(struct nouveau_grctx *ctx);
  1078. static void nv50_graph_construct_gene_vfetch(struct nouveau_grctx *ctx);
  1079. static void nv50_graph_construct_gene_eng2d(struct nouveau_grctx *ctx);
  1080. static void nv50_graph_construct_gene_csched(struct nouveau_grctx *ctx);
  1081. static void nv50_graph_construct_gene_unk1cxx(struct nouveau_grctx *ctx);
  1082. static void nv50_graph_construct_gene_strmout(struct nouveau_grctx *ctx);
  1083. static void nv50_graph_construct_gene_unk34xx(struct nouveau_grctx *ctx);
  1084. static void nv50_graph_construct_gene_ropm1(struct nouveau_grctx *ctx);
  1085. static void nv50_graph_construct_gene_ropm2(struct nouveau_grctx *ctx);
  1086. static void nv50_graph_construct_gene_ropc(struct nouveau_grctx *ctx);
  1087. static void nv50_graph_construct_xfer_tp(struct nouveau_grctx *ctx);
  1088. static void
  1089. nv50_graph_construct_xfer1(struct nouveau_grctx *ctx)
  1090. {
  1091. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1092. int i;
  1093. int offset;
  1094. int size = 0;
  1095. uint32_t units = nv_rd32 (ctx->dev, 0x1540);
  1096. offset = (ctx->ctxvals_pos+0x3f)&~0x3f;
  1097. ctx->ctxvals_base = offset;
  1098. if (dev_priv->chipset < 0xa0) {
  1099. /* Strand 0 */
  1100. ctx->ctxvals_pos = offset;
  1101. nv50_graph_construct_gene_dispatch(ctx);
  1102. nv50_graph_construct_gene_m2mf(ctx);
  1103. nv50_graph_construct_gene_unk24xx(ctx);
  1104. nv50_graph_construct_gene_clipid(ctx);
  1105. nv50_graph_construct_gene_zcull(ctx);
  1106. if ((ctx->ctxvals_pos-offset)/8 > size)
  1107. size = (ctx->ctxvals_pos-offset)/8;
  1108. /* Strand 1 */
  1109. ctx->ctxvals_pos = offset + 0x1;
  1110. nv50_graph_construct_gene_vfetch(ctx);
  1111. nv50_graph_construct_gene_eng2d(ctx);
  1112. nv50_graph_construct_gene_csched(ctx);
  1113. nv50_graph_construct_gene_ropm1(ctx);
  1114. nv50_graph_construct_gene_ropm2(ctx);
  1115. if ((ctx->ctxvals_pos-offset)/8 > size)
  1116. size = (ctx->ctxvals_pos-offset)/8;
  1117. /* Strand 2 */
  1118. ctx->ctxvals_pos = offset + 0x2;
  1119. nv50_graph_construct_gene_ccache(ctx);
  1120. nv50_graph_construct_gene_unk1cxx(ctx);
  1121. nv50_graph_construct_gene_strmout(ctx);
  1122. nv50_graph_construct_gene_unk14xx(ctx);
  1123. nv50_graph_construct_gene_unk10xx(ctx);
  1124. nv50_graph_construct_gene_unk34xx(ctx);
  1125. if ((ctx->ctxvals_pos-offset)/8 > size)
  1126. size = (ctx->ctxvals_pos-offset)/8;
  1127. /* Strand 3: per-ROP group state */
  1128. ctx->ctxvals_pos = offset + 3;
  1129. for (i = 0; i < 6; i++)
  1130. if (units & (1 << (i + 16)))
  1131. nv50_graph_construct_gene_ropc(ctx);
  1132. if ((ctx->ctxvals_pos-offset)/8 > size)
  1133. size = (ctx->ctxvals_pos-offset)/8;
  1134. /* Strands 4-7: per-TP state */
  1135. for (i = 0; i < 4; i++) {
  1136. ctx->ctxvals_pos = offset + 4 + i;
  1137. if (units & (1 << (2 * i)))
  1138. nv50_graph_construct_xfer_tp(ctx);
  1139. if (units & (1 << (2 * i + 1)))
  1140. nv50_graph_construct_xfer_tp(ctx);
  1141. if ((ctx->ctxvals_pos-offset)/8 > size)
  1142. size = (ctx->ctxvals_pos-offset)/8;
  1143. }
  1144. } else {
  1145. /* Strand 0 */
  1146. ctx->ctxvals_pos = offset;
  1147. nv50_graph_construct_gene_dispatch(ctx);
  1148. nv50_graph_construct_gene_m2mf(ctx);
  1149. nv50_graph_construct_gene_unk34xx(ctx);
  1150. nv50_graph_construct_gene_csched(ctx);
  1151. nv50_graph_construct_gene_unk1cxx(ctx);
  1152. nv50_graph_construct_gene_strmout(ctx);
  1153. if ((ctx->ctxvals_pos-offset)/8 > size)
  1154. size = (ctx->ctxvals_pos-offset)/8;
  1155. /* Strand 1 */
  1156. ctx->ctxvals_pos = offset + 1;
  1157. nv50_graph_construct_gene_unk10xx(ctx);
  1158. if ((ctx->ctxvals_pos-offset)/8 > size)
  1159. size = (ctx->ctxvals_pos-offset)/8;
  1160. /* Strand 2 */
  1161. ctx->ctxvals_pos = offset + 2;
  1162. if (dev_priv->chipset == 0xa0)
  1163. nv50_graph_construct_gene_unk14xx(ctx);
  1164. nv50_graph_construct_gene_unk24xx(ctx);
  1165. if ((ctx->ctxvals_pos-offset)/8 > size)
  1166. size = (ctx->ctxvals_pos-offset)/8;
  1167. /* Strand 3 */
  1168. ctx->ctxvals_pos = offset + 3;
  1169. nv50_graph_construct_gene_vfetch(ctx);
  1170. if ((ctx->ctxvals_pos-offset)/8 > size)
  1171. size = (ctx->ctxvals_pos-offset)/8;
  1172. /* Strand 4 */
  1173. ctx->ctxvals_pos = offset + 4;
  1174. nv50_graph_construct_gene_ccache(ctx);
  1175. if ((ctx->ctxvals_pos-offset)/8 > size)
  1176. size = (ctx->ctxvals_pos-offset)/8;
  1177. /* Strand 5 */
  1178. ctx->ctxvals_pos = offset + 5;
  1179. nv50_graph_construct_gene_ropm2(ctx);
  1180. nv50_graph_construct_gene_ropm1(ctx);
  1181. /* per-ROP context */
  1182. for (i = 0; i < 8; i++)
  1183. if (units & (1<<(i+16)))
  1184. nv50_graph_construct_gene_ropc(ctx);
  1185. if ((ctx->ctxvals_pos-offset)/8 > size)
  1186. size = (ctx->ctxvals_pos-offset)/8;
  1187. /* Strand 6 */
  1188. ctx->ctxvals_pos = offset + 6;
  1189. nv50_graph_construct_gene_zcull(ctx);
  1190. nv50_graph_construct_gene_clipid(ctx);
  1191. nv50_graph_construct_gene_eng2d(ctx);
  1192. if (units & (1 << 0))
  1193. nv50_graph_construct_xfer_tp(ctx);
  1194. if (units & (1 << 1))
  1195. nv50_graph_construct_xfer_tp(ctx);
  1196. if (units & (1 << 2))
  1197. nv50_graph_construct_xfer_tp(ctx);
  1198. if (units & (1 << 3))
  1199. nv50_graph_construct_xfer_tp(ctx);
  1200. if ((ctx->ctxvals_pos-offset)/8 > size)
  1201. size = (ctx->ctxvals_pos-offset)/8;
  1202. /* Strand 7 */
  1203. ctx->ctxvals_pos = offset + 7;
  1204. if (dev_priv->chipset == 0xa0) {
  1205. if (units & (1 << 4))
  1206. nv50_graph_construct_xfer_tp(ctx);
  1207. if (units & (1 << 5))
  1208. nv50_graph_construct_xfer_tp(ctx);
  1209. if (units & (1 << 6))
  1210. nv50_graph_construct_xfer_tp(ctx);
  1211. if (units & (1 << 7))
  1212. nv50_graph_construct_xfer_tp(ctx);
  1213. if (units & (1 << 8))
  1214. nv50_graph_construct_xfer_tp(ctx);
  1215. if (units & (1 << 9))
  1216. nv50_graph_construct_xfer_tp(ctx);
  1217. } else {
  1218. nv50_graph_construct_gene_unk14xx(ctx);
  1219. }
  1220. if ((ctx->ctxvals_pos-offset)/8 > size)
  1221. size = (ctx->ctxvals_pos-offset)/8;
  1222. }
  1223. ctx->ctxvals_pos = offset + size * 8;
  1224. ctx->ctxvals_pos = (ctx->ctxvals_pos+0x3f)&~0x3f;
  1225. cp_lsr (ctx, offset);
  1226. cp_out (ctx, CP_SET_XFER_POINTER);
  1227. cp_lsr (ctx, size);
  1228. cp_out (ctx, CP_SEEK_1);
  1229. cp_out (ctx, CP_XFER_1);
  1230. cp_wait(ctx, XFER, BUSY);
  1231. }
  1232. /*
  1233. * non-trivial demagiced parts of ctx init go here
  1234. */
  1235. static void
  1236. nv50_graph_construct_gene_dispatch(struct nouveau_grctx *ctx)
  1237. {
  1238. /* start of strand 0 */
  1239. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1240. /* SEEK */
  1241. if (dev_priv->chipset == 0x50)
  1242. xf_emit(ctx, 5, 0);
  1243. else if (!IS_NVA3F(dev_priv->chipset))
  1244. xf_emit(ctx, 6, 0);
  1245. else
  1246. xf_emit(ctx, 4, 0);
  1247. /* SEEK */
  1248. /* the PGRAPH's internal FIFO */
  1249. if (dev_priv->chipset == 0x50)
  1250. xf_emit(ctx, 8*3, 0);
  1251. else
  1252. xf_emit(ctx, 0x100*3, 0);
  1253. /* and another bonus slot?!? */
  1254. xf_emit(ctx, 3, 0);
  1255. /* and YET ANOTHER bonus slot? */
  1256. if (IS_NVA3F(dev_priv->chipset))
  1257. xf_emit(ctx, 3, 0);
  1258. /* SEEK */
  1259. /* CTX_SWITCH: caches of gr objects bound to subchannels. 8 values, last used index */
  1260. xf_emit(ctx, 9, 0);
  1261. /* SEEK */
  1262. xf_emit(ctx, 9, 0);
  1263. /* SEEK */
  1264. xf_emit(ctx, 9, 0);
  1265. /* SEEK */
  1266. xf_emit(ctx, 9, 0);
  1267. /* SEEK */
  1268. if (dev_priv->chipset < 0x90)
  1269. xf_emit(ctx, 4, 0);
  1270. /* SEEK */
  1271. xf_emit(ctx, 2, 0);
  1272. /* SEEK */
  1273. xf_emit(ctx, 6*2, 0);
  1274. xf_emit(ctx, 2, 0);
  1275. /* SEEK */
  1276. xf_emit(ctx, 2, 0);
  1277. /* SEEK */
  1278. xf_emit(ctx, 6*2, 0);
  1279. xf_emit(ctx, 2, 0);
  1280. /* SEEK */
  1281. if (dev_priv->chipset == 0x50)
  1282. xf_emit(ctx, 0x1c, 0);
  1283. else if (dev_priv->chipset < 0xa0)
  1284. xf_emit(ctx, 0x1e, 0);
  1285. else
  1286. xf_emit(ctx, 0x22, 0);
  1287. /* SEEK */
  1288. xf_emit(ctx, 0x15, 0);
  1289. }
  1290. static void
  1291. nv50_graph_construct_gene_m2mf(struct nouveau_grctx *ctx)
  1292. {
  1293. /* Strand 0, right after dispatch */
  1294. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1295. int smallm2mf = 0;
  1296. if (dev_priv->chipset < 0x92 || dev_priv->chipset == 0x98)
  1297. smallm2mf = 1;
  1298. /* SEEK */
  1299. xf_emit (ctx, 1, 0); /* DMA_NOTIFY instance >> 4 */
  1300. xf_emit (ctx, 1, 0); /* DMA_BUFFER_IN instance >> 4 */
  1301. xf_emit (ctx, 1, 0); /* DMA_BUFFER_OUT instance >> 4 */
  1302. xf_emit (ctx, 1, 0); /* OFFSET_IN */
  1303. xf_emit (ctx, 1, 0); /* OFFSET_OUT */
  1304. xf_emit (ctx, 1, 0); /* PITCH_IN */
  1305. xf_emit (ctx, 1, 0); /* PITCH_OUT */
  1306. xf_emit (ctx, 1, 0); /* LINE_LENGTH */
  1307. xf_emit (ctx, 1, 0); /* LINE_COUNT */
  1308. xf_emit (ctx, 1, 0x21); /* FORMAT: bits 0-4 INPUT_INC, bits 5-9 OUTPUT_INC */
  1309. xf_emit (ctx, 1, 1); /* LINEAR_IN */
  1310. xf_emit (ctx, 1, 0x2); /* TILING_MODE_IN: bits 0-2 y tiling, bits 3-5 z tiling */
  1311. xf_emit (ctx, 1, 0x100); /* TILING_PITCH_IN */
  1312. xf_emit (ctx, 1, 0x100); /* TILING_HEIGHT_IN */
  1313. xf_emit (ctx, 1, 1); /* TILING_DEPTH_IN */
  1314. xf_emit (ctx, 1, 0); /* TILING_POSITION_IN_Z */
  1315. xf_emit (ctx, 1, 0); /* TILING_POSITION_IN */
  1316. xf_emit (ctx, 1, 1); /* LINEAR_OUT */
  1317. xf_emit (ctx, 1, 0x2); /* TILING_MODE_OUT: bits 0-2 y tiling, bits 3-5 z tiling */
  1318. xf_emit (ctx, 1, 0x100); /* TILING_PITCH_OUT */
  1319. xf_emit (ctx, 1, 0x100); /* TILING_HEIGHT_OUT */
  1320. xf_emit (ctx, 1, 1); /* TILING_DEPTH_OUT */
  1321. xf_emit (ctx, 1, 0); /* TILING_POSITION_OUT_Z */
  1322. xf_emit (ctx, 1, 0); /* TILING_POSITION_OUT */
  1323. xf_emit (ctx, 1, 0); /* OFFSET_IN_HIGH */
  1324. xf_emit (ctx, 1, 0); /* OFFSET_OUT_HIGH */
  1325. /* SEEK */
  1326. if (smallm2mf)
  1327. xf_emit(ctx, 0x40, 0); /* 20 * ffffffff, 3ffff */
  1328. else
  1329. xf_emit(ctx, 0x100, 0); /* 80 * ffffffff, 3ffff */
  1330. xf_emit(ctx, 4, 0); /* 1f/7f, 0, 1f/7f, 0 [1f for smallm2mf, 7f otherwise] */
  1331. /* SEEK */
  1332. if (smallm2mf)
  1333. xf_emit(ctx, 0x400, 0); /* ffffffff */
  1334. else
  1335. xf_emit(ctx, 0x800, 0); /* ffffffff */
  1336. xf_emit(ctx, 4, 0); /* ff/1ff, 0, 0, 0 [ff for smallm2mf, 1ff otherwise] */
  1337. /* SEEK */
  1338. xf_emit(ctx, 0x40, 0); /* 20 * bits ffffffff, 3ffff */
  1339. xf_emit(ctx, 0x6, 0); /* 1f, 0, 1f, 0, 1f, 0 */
  1340. }
  1341. static void
  1342. nv50_graph_construct_gene_ccache(struct nouveau_grctx *ctx)
  1343. {
  1344. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1345. xf_emit(ctx, 2, 0); /* RO */
  1346. xf_emit(ctx, 0x800, 0); /* ffffffff */
  1347. switch (dev_priv->chipset) {
  1348. case 0x50:
  1349. case 0x92:
  1350. case 0xa0:
  1351. xf_emit(ctx, 0x2b, 0);
  1352. break;
  1353. case 0x84:
  1354. xf_emit(ctx, 0x29, 0);
  1355. break;
  1356. case 0x94:
  1357. case 0x96:
  1358. case 0xa3:
  1359. xf_emit(ctx, 0x27, 0);
  1360. break;
  1361. case 0x86:
  1362. case 0x98:
  1363. case 0xa5:
  1364. case 0xa8:
  1365. case 0xaa:
  1366. case 0xac:
  1367. case 0xaf:
  1368. xf_emit(ctx, 0x25, 0);
  1369. break;
  1370. }
  1371. /* CB bindings, 0x80 of them. first word is address >> 8, second is
  1372. * size >> 4 | valid << 24 */
  1373. xf_emit(ctx, 0x100, 0); /* ffffffff CB_DEF */
  1374. xf_emit(ctx, 1, 0); /* 0000007f CB_ADDR_BUFFER */
  1375. xf_emit(ctx, 1, 0); /* 0 */
  1376. xf_emit(ctx, 0x30, 0); /* ff SET_PROGRAM_CB */
  1377. xf_emit(ctx, 1, 0); /* 3f last SET_PROGRAM_CB */
  1378. xf_emit(ctx, 4, 0); /* RO */
  1379. xf_emit(ctx, 0x100, 0); /* ffffffff */
  1380. xf_emit(ctx, 8, 0); /* 1f, 0, 0, ... */
  1381. xf_emit(ctx, 8, 0); /* ffffffff */
  1382. xf_emit(ctx, 4, 0); /* ffffffff */
  1383. xf_emit(ctx, 1, 0); /* 3 */
  1384. xf_emit(ctx, 1, 0); /* ffffffff */
  1385. xf_emit(ctx, 1, 0); /* 0000ffff DMA_CODE_CB */
  1386. xf_emit(ctx, 1, 0); /* 0000ffff DMA_TIC */
  1387. xf_emit(ctx, 1, 0); /* 0000ffff DMA_TSC */
  1388. xf_emit(ctx, 1, 0); /* 00000001 LINKED_TSC */
  1389. xf_emit(ctx, 1, 0); /* 000000ff TIC_ADDRESS_HIGH */
  1390. xf_emit(ctx, 1, 0); /* ffffffff TIC_ADDRESS_LOW */
  1391. xf_emit(ctx, 1, 0x3fffff); /* 003fffff TIC_LIMIT */
  1392. xf_emit(ctx, 1, 0); /* 000000ff TSC_ADDRESS_HIGH */
  1393. xf_emit(ctx, 1, 0); /* ffffffff TSC_ADDRESS_LOW */
  1394. xf_emit(ctx, 1, 0x1fff); /* 000fffff TSC_LIMIT */
  1395. xf_emit(ctx, 1, 0); /* 000000ff VP_ADDRESS_HIGH */
  1396. xf_emit(ctx, 1, 0); /* ffffffff VP_ADDRESS_LOW */
  1397. xf_emit(ctx, 1, 0); /* 00ffffff VP_START_ID */
  1398. xf_emit(ctx, 1, 0); /* 000000ff CB_DEF_ADDRESS_HIGH */
  1399. xf_emit(ctx, 1, 0); /* ffffffff CB_DEF_ADDRESS_LOW */
  1400. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1401. xf_emit(ctx, 1, 0); /* 000000ff GP_ADDRESS_HIGH */
  1402. xf_emit(ctx, 1, 0); /* ffffffff GP_ADDRESS_LOW */
  1403. xf_emit(ctx, 1, 0); /* 00ffffff GP_START_ID */
  1404. xf_emit(ctx, 1, 0); /* 000000ff FP_ADDRESS_HIGH */
  1405. xf_emit(ctx, 1, 0); /* ffffffff FP_ADDRESS_LOW */
  1406. xf_emit(ctx, 1, 0); /* 00ffffff FP_START_ID */
  1407. }
  1408. static void
  1409. nv50_graph_construct_gene_unk10xx(struct nouveau_grctx *ctx)
  1410. {
  1411. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1412. int i;
  1413. /* end of area 2 on pre-NVA0, area 1 on NVAx */
  1414. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1415. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1416. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1417. xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
  1418. xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
  1419. xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
  1420. xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
  1421. if (dev_priv->chipset == 0x50)
  1422. xf_emit(ctx, 1, 0x3ff);
  1423. else
  1424. xf_emit(ctx, 1, 0x7ff); /* 000007ff */
  1425. xf_emit(ctx, 1, 0); /* 111/113 */
  1426. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1427. for (i = 0; i < 8; i++) {
  1428. switch (dev_priv->chipset) {
  1429. case 0x50:
  1430. case 0x86:
  1431. case 0x98:
  1432. case 0xaa:
  1433. case 0xac:
  1434. xf_emit(ctx, 0xa0, 0); /* ffffffff */
  1435. break;
  1436. case 0x84:
  1437. case 0x92:
  1438. case 0x94:
  1439. case 0x96:
  1440. xf_emit(ctx, 0x120, 0);
  1441. break;
  1442. case 0xa5:
  1443. case 0xa8:
  1444. xf_emit(ctx, 0x100, 0); /* ffffffff */
  1445. break;
  1446. case 0xa0:
  1447. case 0xa3:
  1448. case 0xaf:
  1449. xf_emit(ctx, 0x400, 0); /* ffffffff */
  1450. break;
  1451. }
  1452. xf_emit(ctx, 4, 0); /* 3f, 0, 0, 0 */
  1453. xf_emit(ctx, 4, 0); /* ffffffff */
  1454. }
  1455. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1456. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1457. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1458. xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
  1459. xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_TEMP */
  1460. xf_emit(ctx, 1, 1); /* 00000001 RASTERIZE_ENABLE */
  1461. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  1462. xf_emit(ctx, 1, 0x27); /* 000000ff UNK0FD4 */
  1463. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  1464. xf_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
  1465. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1466. }
  1467. static void
  1468. nv50_graph_construct_gene_unk34xx(struct nouveau_grctx *ctx)
  1469. {
  1470. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1471. /* end of area 2 on pre-NVA0, area 1 on NVAx */
  1472. xf_emit(ctx, 1, 0); /* 00000001 VIEWPORT_CLIP_RECTS_EN */
  1473. xf_emit(ctx, 1, 0); /* 00000003 VIEWPORT_CLIP_MODE */
  1474. xf_emit(ctx, 0x10, 0x04000000); /* 07ffffff VIEWPORT_CLIP_HORIZ*8, VIEWPORT_CLIP_VERT*8 */
  1475. xf_emit(ctx, 1, 0); /* 00000001 POLYGON_STIPPLE_ENABLE */
  1476. xf_emit(ctx, 0x20, 0); /* ffffffff POLYGON_STIPPLE */
  1477. xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
  1478. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  1479. xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0D64 */
  1480. xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0DF4 */
  1481. xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
  1482. xf_emit(ctx, 1, 0); /* 00000007 */
  1483. xf_emit(ctx, 1, 0x1fe21); /* 0001ffff tesla UNK0FAC */
  1484. if (dev_priv->chipset >= 0xa0)
  1485. xf_emit(ctx, 1, 0x0fac6881);
  1486. if (IS_NVA3F(dev_priv->chipset)) {
  1487. xf_emit(ctx, 1, 1);
  1488. xf_emit(ctx, 3, 0);
  1489. }
  1490. }
  1491. static void
  1492. nv50_graph_construct_gene_unk14xx(struct nouveau_grctx *ctx)
  1493. {
  1494. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1495. /* middle of area 2 on pre-NVA0, beginning of area 2 on NVA0, area 7 on >NVA0 */
  1496. if (dev_priv->chipset != 0x50) {
  1497. xf_emit(ctx, 5, 0); /* ffffffff */
  1498. xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
  1499. xf_emit(ctx, 1, 0); /* 00000001 */
  1500. xf_emit(ctx, 1, 0); /* 000003ff */
  1501. xf_emit(ctx, 1, 0x804); /* 00000fff SEMANTIC_CLIP */
  1502. xf_emit(ctx, 1, 0); /* 00000001 */
  1503. xf_emit(ctx, 2, 4); /* 7f, ff */
  1504. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1505. }
  1506. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1507. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1508. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1509. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1510. xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
  1511. xf_emit(ctx, 1, 0); /* 000000ff VP_CLIP_DISTANCE_ENABLE */
  1512. if (dev_priv->chipset != 0x50)
  1513. xf_emit(ctx, 1, 0); /* 3ff */
  1514. xf_emit(ctx, 1, 0); /* 000000ff tesla UNK1940 */
  1515. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0D7C */
  1516. xf_emit(ctx, 1, 0x804); /* 00000fff SEMANTIC_CLIP */
  1517. xf_emit(ctx, 1, 1); /* 00000001 VIEWPORT_TRANSFORM_EN */
  1518. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  1519. if (dev_priv->chipset != 0x50)
  1520. xf_emit(ctx, 1, 0x7f); /* 000000ff tesla UNK0FFC */
  1521. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1522. xf_emit(ctx, 1, 1); /* 00000001 SHADE_MODEL */
  1523. xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
  1524. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  1525. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1526. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1527. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1528. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1529. xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
  1530. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0D7C */
  1531. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0F8C */
  1532. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1533. xf_emit(ctx, 1, 1); /* 00000001 VIEWPORT_TRANSFORM_EN */
  1534. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1535. xf_emit(ctx, 4, 0); /* ffffffff NOPERSPECTIVE_BITMAP */
  1536. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  1537. xf_emit(ctx, 1, 0); /* 0000000f */
  1538. if (dev_priv->chipset == 0x50)
  1539. xf_emit(ctx, 1, 0x3ff); /* 000003ff tesla UNK0D68 */
  1540. else
  1541. xf_emit(ctx, 1, 0x7ff); /* 000007ff tesla UNK0D68 */
  1542. xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
  1543. xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
  1544. xf_emit(ctx, 0x30, 0); /* ffffffff VIEWPORT_SCALE: X0, Y0, Z0, X1, Y1, ... */
  1545. xf_emit(ctx, 3, 0); /* f, 0, 0 */
  1546. xf_emit(ctx, 3, 0); /* ffffffff last VIEWPORT_SCALE? */
  1547. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1548. xf_emit(ctx, 1, 1); /* 00000001 VIEWPORT_TRANSFORM_EN */
  1549. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  1550. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1924 */
  1551. xf_emit(ctx, 1, 0x10); /* 000000ff VIEW_VOLUME_CLIP_CTRL */
  1552. xf_emit(ctx, 1, 0); /* 00000001 */
  1553. xf_emit(ctx, 0x30, 0); /* ffffffff VIEWPORT_TRANSLATE */
  1554. xf_emit(ctx, 3, 0); /* f, 0, 0 */
  1555. xf_emit(ctx, 3, 0); /* ffffffff */
  1556. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1557. xf_emit(ctx, 2, 0x88); /* 000001ff tesla UNK19D8 */
  1558. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1924 */
  1559. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1560. xf_emit(ctx, 1, 4); /* 0000000f CULL_MODE */
  1561. xf_emit(ctx, 2, 0); /* 07ffffff SCREEN_SCISSOR */
  1562. xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
  1563. xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
  1564. xf_emit(ctx, 0x10, 0); /* 00000001 SCISSOR_ENABLE */
  1565. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  1566. xf_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
  1567. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  1568. xf_emit(ctx, 1, 0); /* 0000000f */
  1569. xf_emit(ctx, 1, 0x3f800000); /* ffffffff LINE_WIDTH */
  1570. xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
  1571. xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
  1572. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  1573. if (IS_NVA3F(dev_priv->chipset))
  1574. xf_emit(ctx, 1, 0); /* 00000001 */
  1575. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  1576. xf_emit(ctx, 1, 0x10); /* 000000ff VIEW_VOLUME_CLIP_CTRL */
  1577. if (dev_priv->chipset != 0x50) {
  1578. xf_emit(ctx, 1, 0); /* ffffffff */
  1579. xf_emit(ctx, 1, 0); /* 00000001 */
  1580. xf_emit(ctx, 1, 0); /* 000003ff */
  1581. }
  1582. xf_emit(ctx, 0x20, 0); /* 10xbits ffffffff, 3fffff. SCISSOR_* */
  1583. xf_emit(ctx, 1, 0); /* f */
  1584. xf_emit(ctx, 1, 0); /* 0? */
  1585. xf_emit(ctx, 1, 0); /* ffffffff */
  1586. xf_emit(ctx, 1, 0); /* 003fffff */
  1587. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1588. xf_emit(ctx, 1, 0x52); /* 000001ff SEMANTIC_PTSZ */
  1589. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  1590. xf_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
  1591. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  1592. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1593. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1594. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1595. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  1596. xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
  1597. xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
  1598. xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
  1599. xf_emit(ctx, 1, 0); /* 0000000f */
  1600. }
  1601. static void
  1602. nv50_graph_construct_gene_zcull(struct nouveau_grctx *ctx)
  1603. {
  1604. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1605. /* end of strand 0 on pre-NVA0, beginning of strand 6 on NVAx */
  1606. /* SEEK */
  1607. xf_emit(ctx, 1, 0x3f); /* 0000003f UNK1590 */
  1608. xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
  1609. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  1610. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  1611. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
  1612. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
  1613. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_REF */
  1614. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
  1615. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
  1616. xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
  1617. xf_emit(ctx, 2, 0x04000000); /* 07ffffff tesla UNK0D6C */
  1618. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  1619. xf_emit(ctx, 1, 0); /* 00000001 CLIPID_ENABLE */
  1620. xf_emit(ctx, 2, 0); /* ffffffff DEPTH_BOUNDS */
  1621. xf_emit(ctx, 1, 0); /* 00000001 */
  1622. xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
  1623. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  1624. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  1625. xf_emit(ctx, 1, 4); /* 0000000f CULL_MODE */
  1626. xf_emit(ctx, 1, 0); /* 0000ffff */
  1627. xf_emit(ctx, 1, 0); /* 00000001 UNK0FB0 */
  1628. xf_emit(ctx, 1, 0); /* 00000001 POLYGON_STIPPLE_ENABLE */
  1629. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  1630. xf_emit(ctx, 1, 0); /* ffffffff */
  1631. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  1632. xf_emit(ctx, 1, 0); /* 000000ff CLEAR_STENCIL */
  1633. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
  1634. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
  1635. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_REF */
  1636. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
  1637. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
  1638. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  1639. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  1640. xf_emit(ctx, 1, 0); /* ffffffff CLEAR_DEPTH */
  1641. xf_emit(ctx, 1, 0); /* 00000007 */
  1642. if (dev_priv->chipset != 0x50)
  1643. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1108 */
  1644. xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
  1645. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  1646. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  1647. xf_emit(ctx, 1, 0x1001); /* 00001fff ZETA_ARRAY_MODE */
  1648. /* SEEK */
  1649. xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
  1650. xf_emit(ctx, 0x10, 0); /* 00000001 SCISSOR_ENABLE */
  1651. xf_emit(ctx, 0x10, 0); /* ffffffff DEPTH_RANGE_NEAR */
  1652. xf_emit(ctx, 0x10, 0x3f800000); /* ffffffff DEPTH_RANGE_FAR */
  1653. xf_emit(ctx, 1, 0x10); /* 7f/ff/3ff VIEW_VOLUME_CLIP_CTRL */
  1654. xf_emit(ctx, 1, 0); /* 00000001 VIEWPORT_CLIP_RECTS_EN */
  1655. xf_emit(ctx, 1, 3); /* 00000003 FP_CTRL_UNK196C */
  1656. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1968 */
  1657. if (dev_priv->chipset != 0x50)
  1658. xf_emit(ctx, 1, 0); /* 0fffffff tesla UNK1104 */
  1659. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK151C */
  1660. }
  1661. static void
  1662. nv50_graph_construct_gene_clipid(struct nouveau_grctx *ctx)
  1663. {
  1664. /* middle of strand 0 on pre-NVA0 [after 24xx], middle of area 6 on NVAx */
  1665. /* SEEK */
  1666. xf_emit(ctx, 1, 0); /* 00000007 UNK0FB4 */
  1667. /* SEEK */
  1668. xf_emit(ctx, 4, 0); /* 07ffffff CLIPID_REGION_HORIZ */
  1669. xf_emit(ctx, 4, 0); /* 07ffffff CLIPID_REGION_VERT */
  1670. xf_emit(ctx, 2, 0); /* 07ffffff SCREEN_SCISSOR */
  1671. xf_emit(ctx, 2, 0x04000000); /* 07ffffff UNK1508 */
  1672. xf_emit(ctx, 1, 0); /* 00000001 CLIPID_ENABLE */
  1673. xf_emit(ctx, 1, 0x80); /* 00003fff CLIPID_WIDTH */
  1674. xf_emit(ctx, 1, 0); /* 000000ff CLIPID_ID */
  1675. xf_emit(ctx, 1, 0); /* 000000ff CLIPID_ADDRESS_HIGH */
  1676. xf_emit(ctx, 1, 0); /* ffffffff CLIPID_ADDRESS_LOW */
  1677. xf_emit(ctx, 1, 0x80); /* 00003fff CLIPID_HEIGHT */
  1678. xf_emit(ctx, 1, 0); /* 0000ffff DMA_CLIPID */
  1679. }
  1680. static void
  1681. nv50_graph_construct_gene_unk24xx(struct nouveau_grctx *ctx)
  1682. {
  1683. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1684. int i;
  1685. /* middle of strand 0 on pre-NVA0 [after m2mf], end of strand 2 on NVAx */
  1686. /* SEEK */
  1687. xf_emit(ctx, 0x33, 0);
  1688. /* SEEK */
  1689. xf_emit(ctx, 2, 0);
  1690. /* SEEK */
  1691. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1692. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1693. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1694. /* SEEK */
  1695. if (IS_NVA3F(dev_priv->chipset)) {
  1696. xf_emit(ctx, 4, 0); /* RO */
  1697. xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
  1698. xf_emit(ctx, 1, 0); /* 1ff */
  1699. xf_emit(ctx, 8, 0); /* 0? */
  1700. xf_emit(ctx, 9, 0); /* ffffffff, 7ff */
  1701. xf_emit(ctx, 4, 0); /* RO */
  1702. xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
  1703. xf_emit(ctx, 1, 0); /* 1ff */
  1704. xf_emit(ctx, 8, 0); /* 0? */
  1705. xf_emit(ctx, 9, 0); /* ffffffff, 7ff */
  1706. } else {
  1707. xf_emit(ctx, 0xc, 0); /* RO */
  1708. /* SEEK */
  1709. xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
  1710. xf_emit(ctx, 1, 0); /* 1ff */
  1711. xf_emit(ctx, 8, 0); /* 0? */
  1712. /* SEEK */
  1713. xf_emit(ctx, 0xc, 0); /* RO */
  1714. /* SEEK */
  1715. xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
  1716. xf_emit(ctx, 1, 0); /* 1ff */
  1717. xf_emit(ctx, 8, 0); /* 0? */
  1718. }
  1719. /* SEEK */
  1720. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1721. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  1722. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  1723. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1724. if (dev_priv->chipset != 0x50)
  1725. xf_emit(ctx, 1, 3); /* 00000003 tesla UNK1100 */
  1726. /* SEEK */
  1727. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1728. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1729. xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
  1730. xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
  1731. xf_emit(ctx, 1, 1); /* 00000001 */
  1732. /* SEEK */
  1733. if (dev_priv->chipset >= 0xa0)
  1734. xf_emit(ctx, 2, 4); /* 000000ff */
  1735. xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
  1736. xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
  1737. xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_ENABLE */
  1738. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1739. xf_emit(ctx, 1, 0x27); /* 000000ff SEMANTIC_PRIM_ID */
  1740. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1741. xf_emit(ctx, 1, 0); /* 0000000f */
  1742. xf_emit(ctx, 1, 1); /* 00000001 */
  1743. for (i = 0; i < 10; i++) {
  1744. /* SEEK */
  1745. xf_emit(ctx, 0x40, 0); /* ffffffff */
  1746. xf_emit(ctx, 0x10, 0); /* 3, 0, 0.... */
  1747. xf_emit(ctx, 0x10, 0); /* ffffffff */
  1748. }
  1749. /* SEEK */
  1750. xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_CTRL */
  1751. xf_emit(ctx, 1, 1); /* 00000001 */
  1752. xf_emit(ctx, 1, 0); /* ffffffff */
  1753. xf_emit(ctx, 4, 0); /* ffffffff NOPERSPECTIVE_BITMAP */
  1754. xf_emit(ctx, 0x10, 0); /* 00ffffff POINT_COORD_REPLACE_MAP */
  1755. xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
  1756. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  1757. if (dev_priv->chipset != 0x50)
  1758. xf_emit(ctx, 1, 0); /* 000003ff */
  1759. }
  1760. static void
  1761. nv50_graph_construct_gene_vfetch(struct nouveau_grctx *ctx)
  1762. {
  1763. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1764. int acnt = 0x10, rep, i;
  1765. /* beginning of strand 1 on pre-NVA0, strand 3 on NVAx */
  1766. if (IS_NVA3F(dev_priv->chipset))
  1767. acnt = 0x20;
  1768. /* SEEK */
  1769. if (dev_priv->chipset >= 0xa0) {
  1770. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK13A4 */
  1771. xf_emit(ctx, 1, 1); /* 00000fff tesla UNK1318 */
  1772. }
  1773. xf_emit(ctx, 1, 0); /* ffffffff VERTEX_BUFFER_FIRST */
  1774. xf_emit(ctx, 1, 0); /* 00000001 PRIMITIVE_RESTART_ENABLE */
  1775. xf_emit(ctx, 1, 0); /* 00000001 UNK0DE8 */
  1776. xf_emit(ctx, 1, 0); /* ffffffff PRIMITIVE_RESTART_INDEX */
  1777. xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
  1778. xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
  1779. xf_emit(ctx, acnt/8, 0); /* ffffffff VTX_ATR_MASK_UNK0DD0 */
  1780. xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
  1781. xf_emit(ctx, 1, 0x20); /* 0000ffff tesla UNK129C */
  1782. xf_emit(ctx, 1, 0); /* 000000ff turing UNK370??? */
  1783. xf_emit(ctx, 1, 0); /* 0000ffff turing USER_PARAM_COUNT */
  1784. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1785. /* SEEK */
  1786. if (IS_NVA3F(dev_priv->chipset))
  1787. xf_emit(ctx, 0xb, 0); /* RO */
  1788. else if (dev_priv->chipset >= 0xa0)
  1789. xf_emit(ctx, 0x9, 0); /* RO */
  1790. else
  1791. xf_emit(ctx, 0x8, 0); /* RO */
  1792. /* SEEK */
  1793. xf_emit(ctx, 1, 0); /* 00000001 EDGE_FLAG */
  1794. xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
  1795. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1796. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  1797. /* SEEK */
  1798. xf_emit(ctx, 0xc, 0); /* RO */
  1799. /* SEEK */
  1800. xf_emit(ctx, 1, 0); /* 7f/ff */
  1801. xf_emit(ctx, 1, 4); /* 7f/ff VP_REG_ALLOC_RESULT */
  1802. xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
  1803. xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
  1804. xf_emit(ctx, 1, 4); /* 000001ff UNK1A28 */
  1805. xf_emit(ctx, 1, 8); /* 000001ff UNK0DF0 */
  1806. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  1807. if (dev_priv->chipset == 0x50)
  1808. xf_emit(ctx, 1, 0x3ff); /* 3ff tesla UNK0D68 */
  1809. else
  1810. xf_emit(ctx, 1, 0x7ff); /* 7ff tesla UNK0D68 */
  1811. if (dev_priv->chipset == 0xa8)
  1812. xf_emit(ctx, 1, 0x1e00); /* 7fff */
  1813. /* SEEK */
  1814. xf_emit(ctx, 0xc, 0); /* RO or close */
  1815. /* SEEK */
  1816. xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
  1817. xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
  1818. xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
  1819. if (dev_priv->chipset > 0x50 && dev_priv->chipset < 0xa0)
  1820. xf_emit(ctx, 2, 0); /* ffffffff */
  1821. else
  1822. xf_emit(ctx, 1, 0); /* ffffffff */
  1823. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK0FD8 */
  1824. /* SEEK */
  1825. if (IS_NVA3F(dev_priv->chipset)) {
  1826. xf_emit(ctx, 0x10, 0); /* 0? */
  1827. xf_emit(ctx, 2, 0); /* weird... */
  1828. xf_emit(ctx, 2, 0); /* RO */
  1829. } else {
  1830. xf_emit(ctx, 8, 0); /* 0? */
  1831. xf_emit(ctx, 1, 0); /* weird... */
  1832. xf_emit(ctx, 2, 0); /* RO */
  1833. }
  1834. /* SEEK */
  1835. xf_emit(ctx, 1, 0); /* ffffffff VB_ELEMENT_BASE */
  1836. xf_emit(ctx, 1, 0); /* ffffffff UNK1438 */
  1837. xf_emit(ctx, acnt, 0); /* 1 tesla UNK1000 */
  1838. if (dev_priv->chipset >= 0xa0)
  1839. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1118? */
  1840. /* SEEK */
  1841. xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_ARRAY_UNK90C */
  1842. xf_emit(ctx, 1, 0); /* f/1f */
  1843. /* SEEK */
  1844. xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_ARRAY_UNK90C */
  1845. xf_emit(ctx, 1, 0); /* f/1f */
  1846. /* SEEK */
  1847. xf_emit(ctx, acnt, 0); /* RO */
  1848. xf_emit(ctx, 2, 0); /* RO */
  1849. /* SEEK */
  1850. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK111C? */
  1851. xf_emit(ctx, 1, 0); /* RO */
  1852. /* SEEK */
  1853. xf_emit(ctx, 1, 0); /* 000000ff UNK15F4_ADDRESS_HIGH */
  1854. xf_emit(ctx, 1, 0); /* ffffffff UNK15F4_ADDRESS_LOW */
  1855. xf_emit(ctx, 1, 0); /* 000000ff UNK0F84_ADDRESS_HIGH */
  1856. xf_emit(ctx, 1, 0); /* ffffffff UNK0F84_ADDRESS_LOW */
  1857. /* SEEK */
  1858. xf_emit(ctx, acnt, 0); /* 00003fff VERTEX_ARRAY_ATTRIB_OFFSET */
  1859. xf_emit(ctx, 3, 0); /* f/1f */
  1860. /* SEEK */
  1861. xf_emit(ctx, acnt, 0); /* 00000fff VERTEX_ARRAY_STRIDE */
  1862. xf_emit(ctx, 3, 0); /* f/1f */
  1863. /* SEEK */
  1864. xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_ARRAY_LOW */
  1865. xf_emit(ctx, 3, 0); /* f/1f */
  1866. /* SEEK */
  1867. xf_emit(ctx, acnt, 0); /* 000000ff VERTEX_ARRAY_HIGH */
  1868. xf_emit(ctx, 3, 0); /* f/1f */
  1869. /* SEEK */
  1870. xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_LIMIT_LOW */
  1871. xf_emit(ctx, 3, 0); /* f/1f */
  1872. /* SEEK */
  1873. xf_emit(ctx, acnt, 0); /* 000000ff VERTEX_LIMIT_HIGH */
  1874. xf_emit(ctx, 3, 0); /* f/1f */
  1875. /* SEEK */
  1876. if (IS_NVA3F(dev_priv->chipset)) {
  1877. xf_emit(ctx, acnt, 0); /* f */
  1878. xf_emit(ctx, 3, 0); /* f/1f */
  1879. }
  1880. /* SEEK */
  1881. if (IS_NVA3F(dev_priv->chipset))
  1882. xf_emit(ctx, 2, 0); /* RO */
  1883. else
  1884. xf_emit(ctx, 5, 0); /* RO */
  1885. /* SEEK */
  1886. xf_emit(ctx, 1, 0); /* ffff DMA_VTXBUF */
  1887. /* SEEK */
  1888. if (dev_priv->chipset < 0xa0) {
  1889. xf_emit(ctx, 0x41, 0); /* RO */
  1890. /* SEEK */
  1891. xf_emit(ctx, 0x11, 0); /* RO */
  1892. } else if (!IS_NVA3F(dev_priv->chipset))
  1893. xf_emit(ctx, 0x50, 0); /* RO */
  1894. else
  1895. xf_emit(ctx, 0x58, 0); /* RO */
  1896. /* SEEK */
  1897. xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
  1898. xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
  1899. xf_emit(ctx, 1, 1); /* 1 UNK0DEC */
  1900. /* SEEK */
  1901. xf_emit(ctx, acnt*4, 0); /* ffffffff VTX_ATTR */
  1902. xf_emit(ctx, 4, 0); /* f/1f, 0, 0, 0 */
  1903. /* SEEK */
  1904. if (IS_NVA3F(dev_priv->chipset))
  1905. xf_emit(ctx, 0x1d, 0); /* RO */
  1906. else
  1907. xf_emit(ctx, 0x16, 0); /* RO */
  1908. /* SEEK */
  1909. xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
  1910. xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
  1911. /* SEEK */
  1912. if (dev_priv->chipset < 0xa0)
  1913. xf_emit(ctx, 8, 0); /* RO */
  1914. else if (IS_NVA3F(dev_priv->chipset))
  1915. xf_emit(ctx, 0xc, 0); /* RO */
  1916. else
  1917. xf_emit(ctx, 7, 0); /* RO */
  1918. /* SEEK */
  1919. xf_emit(ctx, 0xa, 0); /* RO */
  1920. if (dev_priv->chipset == 0xa0)
  1921. rep = 0xc;
  1922. else
  1923. rep = 4;
  1924. for (i = 0; i < rep; i++) {
  1925. /* SEEK */
  1926. if (IS_NVA3F(dev_priv->chipset))
  1927. xf_emit(ctx, 0x20, 0); /* ffffffff */
  1928. xf_emit(ctx, 0x200, 0); /* ffffffff */
  1929. xf_emit(ctx, 4, 0); /* 7f/ff, 0, 0, 0 */
  1930. xf_emit(ctx, 4, 0); /* ffffffff */
  1931. }
  1932. /* SEEK */
  1933. xf_emit(ctx, 1, 0); /* 113/111 */
  1934. xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
  1935. xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
  1936. xf_emit(ctx, acnt/8, 0); /* ffffffff VTX_ATTR_MASK_UNK0DD0 */
  1937. xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
  1938. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  1939. /* SEEK */
  1940. if (IS_NVA3F(dev_priv->chipset))
  1941. xf_emit(ctx, 7, 0); /* weird... */
  1942. else
  1943. xf_emit(ctx, 5, 0); /* weird... */
  1944. }
  1945. static void
  1946. nv50_graph_construct_gene_eng2d(struct nouveau_grctx *ctx)
  1947. {
  1948. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1949. /* middle of strand 1 on pre-NVA0 [after vfetch], middle of strand 6 on NVAx */
  1950. /* SEEK */
  1951. xf_emit(ctx, 2, 0); /* 0001ffff CLIP_X, CLIP_Y */
  1952. xf_emit(ctx, 2, 0); /* 0000ffff CLIP_W, CLIP_H */
  1953. xf_emit(ctx, 1, 0); /* 00000001 CLIP_ENABLE */
  1954. if (dev_priv->chipset < 0xa0) {
  1955. /* this is useless on everything but the original NV50,
  1956. * guess they forgot to nuke it. Or just didn't bother. */
  1957. xf_emit(ctx, 2, 0); /* 0000ffff IFC_CLIP_X, Y */
  1958. xf_emit(ctx, 2, 1); /* 0000ffff IFC_CLIP_W, H */
  1959. xf_emit(ctx, 1, 0); /* 00000001 IFC_CLIP_ENABLE */
  1960. }
  1961. xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
  1962. xf_emit(ctx, 1, 0x100); /* 0001ffff DST_WIDTH */
  1963. xf_emit(ctx, 1, 0x100); /* 0001ffff DST_HEIGHT */
  1964. xf_emit(ctx, 1, 0x11); /* 3f[NV50]/7f[NV84+] DST_FORMAT */
  1965. xf_emit(ctx, 1, 0); /* 0001ffff DRAW_POINT_X */
  1966. xf_emit(ctx, 1, 8); /* 0000000f DRAW_UNK58C */
  1967. xf_emit(ctx, 1, 0); /* 000fffff SIFC_DST_X_FRACT */
  1968. xf_emit(ctx, 1, 0); /* 0001ffff SIFC_DST_X_INT */
  1969. xf_emit(ctx, 1, 0); /* 000fffff SIFC_DST_Y_FRACT */
  1970. xf_emit(ctx, 1, 0); /* 0001ffff SIFC_DST_Y_INT */
  1971. xf_emit(ctx, 1, 0); /* 000fffff SIFC_DX_DU_FRACT */
  1972. xf_emit(ctx, 1, 1); /* 0001ffff SIFC_DX_DU_INT */
  1973. xf_emit(ctx, 1, 0); /* 000fffff SIFC_DY_DV_FRACT */
  1974. xf_emit(ctx, 1, 1); /* 0001ffff SIFC_DY_DV_INT */
  1975. xf_emit(ctx, 1, 1); /* 0000ffff SIFC_WIDTH */
  1976. xf_emit(ctx, 1, 1); /* 0000ffff SIFC_HEIGHT */
  1977. xf_emit(ctx, 1, 0xcf); /* 000000ff SIFC_FORMAT */
  1978. xf_emit(ctx, 1, 2); /* 00000003 SIFC_BITMAP_UNK808 */
  1979. xf_emit(ctx, 1, 0); /* 00000003 SIFC_BITMAP_LINE_PACK_MODE */
  1980. xf_emit(ctx, 1, 0); /* 00000001 SIFC_BITMAP_LSB_FIRST */
  1981. xf_emit(ctx, 1, 0); /* 00000001 SIFC_BITMAP_ENABLE */
  1982. xf_emit(ctx, 1, 0); /* 0000ffff BLIT_DST_X */
  1983. xf_emit(ctx, 1, 0); /* 0000ffff BLIT_DST_Y */
  1984. xf_emit(ctx, 1, 0); /* 000fffff BLIT_DU_DX_FRACT */
  1985. xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DU_DX_INT */
  1986. xf_emit(ctx, 1, 0); /* 000fffff BLIT_DV_DY_FRACT */
  1987. xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DV_DY_INT */
  1988. xf_emit(ctx, 1, 1); /* 0000ffff BLIT_DST_W */
  1989. xf_emit(ctx, 1, 1); /* 0000ffff BLIT_DST_H */
  1990. xf_emit(ctx, 1, 0); /* 000fffff BLIT_SRC_X_FRACT */
  1991. xf_emit(ctx, 1, 0); /* 0001ffff BLIT_SRC_X_INT */
  1992. xf_emit(ctx, 1, 0); /* 000fffff BLIT_SRC_Y_FRACT */
  1993. xf_emit(ctx, 1, 0); /* 00000001 UNK888 */
  1994. xf_emit(ctx, 1, 4); /* 0000003f UNK884 */
  1995. xf_emit(ctx, 1, 0); /* 00000007 UNK880 */
  1996. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK0FB8 */
  1997. xf_emit(ctx, 1, 0x15); /* 000000ff tesla UNK128C */
  1998. xf_emit(ctx, 2, 0); /* 00000007, ffff0ff3 */
  1999. xf_emit(ctx, 1, 0); /* 00000001 UNK260 */
  2000. xf_emit(ctx, 1, 0x4444480); /* 1fffffff UNK870 */
  2001. /* SEEK */
  2002. xf_emit(ctx, 0x10, 0);
  2003. /* SEEK */
  2004. xf_emit(ctx, 0x27, 0);
  2005. }
  2006. static void
  2007. nv50_graph_construct_gene_csched(struct nouveau_grctx *ctx)
  2008. {
  2009. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2010. /* middle of strand 1 on pre-NVA0 [after eng2d], middle of strand 0 on NVAx */
  2011. /* SEEK */
  2012. xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY... what is it doing here??? */
  2013. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1924 */
  2014. xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
  2015. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  2016. xf_emit(ctx, 1, 0); /* 000003ff */
  2017. /* SEEK */
  2018. xf_emit(ctx, 1, 0); /* ffffffff turing UNK364 */
  2019. xf_emit(ctx, 1, 0); /* 0000000f turing UNK36C */
  2020. xf_emit(ctx, 1, 0); /* 0000ffff USER_PARAM_COUNT */
  2021. xf_emit(ctx, 1, 0x100); /* 00ffffff turing UNK384 */
  2022. xf_emit(ctx, 1, 0); /* 0000000f turing UNK2A0 */
  2023. xf_emit(ctx, 1, 0); /* 0000ffff GRIDID */
  2024. xf_emit(ctx, 1, 0x10001); /* ffffffff GRIDDIM_XY */
  2025. xf_emit(ctx, 1, 0); /* ffffffff */
  2026. xf_emit(ctx, 1, 0x10001); /* ffffffff BLOCKDIM_XY */
  2027. xf_emit(ctx, 1, 1); /* 0000ffff BLOCKDIM_Z */
  2028. xf_emit(ctx, 1, 0x10001); /* 00ffffff BLOCK_ALLOC */
  2029. xf_emit(ctx, 1, 1); /* 00000001 LANES32 */
  2030. xf_emit(ctx, 1, 4); /* 000000ff FP_REG_ALLOC_TEMP */
  2031. xf_emit(ctx, 1, 2); /* 00000003 REG_MODE */
  2032. /* SEEK */
  2033. xf_emit(ctx, 0x40, 0); /* ffffffff USER_PARAM */
  2034. switch (dev_priv->chipset) {
  2035. case 0x50:
  2036. case 0x92:
  2037. xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
  2038. xf_emit(ctx, 0x80, 0); /* fff */
  2039. xf_emit(ctx, 2, 0); /* ff, fff */
  2040. xf_emit(ctx, 0x10*2, 0); /* ffffffff, 1f */
  2041. break;
  2042. case 0x84:
  2043. xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
  2044. xf_emit(ctx, 0x60, 0); /* fff */
  2045. xf_emit(ctx, 2, 0); /* ff, fff */
  2046. xf_emit(ctx, 0xc*2, 0); /* ffffffff, 1f */
  2047. break;
  2048. case 0x94:
  2049. case 0x96:
  2050. xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
  2051. xf_emit(ctx, 0x40, 0); /* fff */
  2052. xf_emit(ctx, 2, 0); /* ff, fff */
  2053. xf_emit(ctx, 8*2, 0); /* ffffffff, 1f */
  2054. break;
  2055. case 0x86:
  2056. case 0x98:
  2057. xf_emit(ctx, 4, 0); /* f, 0, 0, 0 */
  2058. xf_emit(ctx, 0x10, 0); /* fff */
  2059. xf_emit(ctx, 2, 0); /* ff, fff */
  2060. xf_emit(ctx, 2*2, 0); /* ffffffff, 1f */
  2061. break;
  2062. case 0xa0:
  2063. xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
  2064. xf_emit(ctx, 0xf0, 0); /* fff */
  2065. xf_emit(ctx, 2, 0); /* ff, fff */
  2066. xf_emit(ctx, 0x1e*2, 0); /* ffffffff, 1f */
  2067. break;
  2068. case 0xa3:
  2069. xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
  2070. xf_emit(ctx, 0x60, 0); /* fff */
  2071. xf_emit(ctx, 2, 0); /* ff, fff */
  2072. xf_emit(ctx, 0xc*2, 0); /* ffffffff, 1f */
  2073. break;
  2074. case 0xa5:
  2075. case 0xaf:
  2076. xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
  2077. xf_emit(ctx, 0x30, 0); /* fff */
  2078. xf_emit(ctx, 2, 0); /* ff, fff */
  2079. xf_emit(ctx, 6*2, 0); /* ffffffff, 1f */
  2080. break;
  2081. case 0xaa:
  2082. xf_emit(ctx, 0x12, 0);
  2083. break;
  2084. case 0xa8:
  2085. case 0xac:
  2086. xf_emit(ctx, 4, 0); /* f, 0, 0, 0 */
  2087. xf_emit(ctx, 0x10, 0); /* fff */
  2088. xf_emit(ctx, 2, 0); /* ff, fff */
  2089. xf_emit(ctx, 2*2, 0); /* ffffffff, 1f */
  2090. break;
  2091. }
  2092. xf_emit(ctx, 1, 0); /* 0000000f */
  2093. xf_emit(ctx, 1, 0); /* 00000000 */
  2094. xf_emit(ctx, 1, 0); /* ffffffff */
  2095. xf_emit(ctx, 1, 0); /* 0000001f */
  2096. xf_emit(ctx, 4, 0); /* ffffffff */
  2097. xf_emit(ctx, 1, 0); /* 00000003 turing UNK35C */
  2098. xf_emit(ctx, 1, 0); /* ffffffff */
  2099. xf_emit(ctx, 4, 0); /* ffffffff */
  2100. xf_emit(ctx, 1, 0); /* 00000003 turing UNK35C */
  2101. xf_emit(ctx, 1, 0); /* ffffffff */
  2102. xf_emit(ctx, 1, 0); /* 000000ff */
  2103. }
  2104. static void
  2105. nv50_graph_construct_gene_unk1cxx(struct nouveau_grctx *ctx)
  2106. {
  2107. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2108. xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
  2109. xf_emit(ctx, 1, 0x3f800000); /* ffffffff LINE_WIDTH */
  2110. xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
  2111. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1658 */
  2112. xf_emit(ctx, 1, 0); /* 00000001 POLYGON_SMOOTH_ENABLE */
  2113. xf_emit(ctx, 3, 0); /* 00000001 POLYGON_OFFSET_*_ENABLE */
  2114. xf_emit(ctx, 1, 4); /* 0000000f CULL_MODE */
  2115. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  2116. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2117. xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_ENABLE */
  2118. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK165C */
  2119. xf_emit(ctx, 0x10, 0); /* 00000001 SCISSOR_ENABLE */
  2120. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2121. xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
  2122. xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
  2123. xf_emit(ctx, 1, 0); /* ffffffff POLYGON_OFFSET_UNITS */
  2124. xf_emit(ctx, 1, 0); /* ffffffff POLYGON_OFFSET_FACTOR */
  2125. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1668 */
  2126. xf_emit(ctx, 2, 0); /* 07ffffff SCREEN_SCISSOR */
  2127. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  2128. xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
  2129. xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
  2130. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2131. xf_emit(ctx, 1, 0x11); /* 0000007f RT_FORMAT */
  2132. xf_emit(ctx, 7, 0); /* 0000007f RT_FORMAT */
  2133. xf_emit(ctx, 8, 0); /* 00000001 RT_HORIZ_LINEAR */
  2134. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  2135. xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
  2136. xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
  2137. if (IS_NVA3F(dev_priv->chipset))
  2138. xf_emit(ctx, 1, 3); /* 00000003 UNK16B4 */
  2139. else if (dev_priv->chipset >= 0xa0)
  2140. xf_emit(ctx, 1, 1); /* 00000001 UNK16B4 */
  2141. xf_emit(ctx, 1, 0); /* 00000003 MULTISAMPLE_CTRL */
  2142. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK0F90 */
  2143. xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
  2144. xf_emit(ctx, 2, 0x04000000); /* 07ffffff tesla UNK0D6C */
  2145. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
  2146. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2147. xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
  2148. xf_emit(ctx, 1, 5); /* 0000000f UNK1408 */
  2149. xf_emit(ctx, 1, 0x52); /* 000001ff SEMANTIC_PTSZ */
  2150. xf_emit(ctx, 1, 0); /* ffffffff POINT_SIZE */
  2151. xf_emit(ctx, 1, 0); /* 00000001 */
  2152. xf_emit(ctx, 1, 0); /* 00000007 tesla UNK0FB4 */
  2153. if (dev_priv->chipset != 0x50) {
  2154. xf_emit(ctx, 1, 0); /* 3ff */
  2155. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK1110 */
  2156. }
  2157. if (IS_NVA3F(dev_priv->chipset))
  2158. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1928 */
  2159. xf_emit(ctx, 0x10, 0); /* ffffffff DEPTH_RANGE_NEAR */
  2160. xf_emit(ctx, 0x10, 0x3f800000); /* ffffffff DEPTH_RANGE_FAR */
  2161. xf_emit(ctx, 1, 0x10); /* 000000ff VIEW_VOLUME_CLIP_CTRL */
  2162. xf_emit(ctx, 0x20, 0); /* 07ffffff VIEWPORT_HORIZ, then VIEWPORT_VERT. (W&0x3fff)<<13 | (X&0x1fff). */
  2163. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK187C */
  2164. xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
  2165. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2166. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2167. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  2168. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
  2169. xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  2170. xf_emit(ctx, 1, 5); /* 0000000f tesla UNK1220 */
  2171. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  2172. xf_emit(ctx, 1, 0); /* 000000ff tesla UNK1A20 */
  2173. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2174. xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
  2175. xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
  2176. if (dev_priv->chipset != 0x50)
  2177. xf_emit(ctx, 1, 3); /* 00000003 tesla UNK1100 */
  2178. if (dev_priv->chipset < 0xa0)
  2179. xf_emit(ctx, 0x1c, 0); /* RO */
  2180. else if (IS_NVA3F(dev_priv->chipset))
  2181. xf_emit(ctx, 0x9, 0);
  2182. xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
  2183. xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
  2184. xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
  2185. xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
  2186. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  2187. xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
  2188. if (dev_priv->chipset != 0x50) {
  2189. xf_emit(ctx, 1, 3); /* 00000003 tesla UNK1100 */
  2190. xf_emit(ctx, 1, 0); /* 3ff */
  2191. }
  2192. /* XXX: the following block could belong either to unk1cxx, or
  2193. * to STRMOUT. Rather hard to tell. */
  2194. if (dev_priv->chipset < 0xa0)
  2195. xf_emit(ctx, 0x25, 0);
  2196. else
  2197. xf_emit(ctx, 0x3b, 0);
  2198. }
  2199. static void
  2200. nv50_graph_construct_gene_strmout(struct nouveau_grctx *ctx)
  2201. {
  2202. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2203. xf_emit(ctx, 1, 0x102); /* 0000ffff STRMOUT_BUFFER_CTRL */
  2204. xf_emit(ctx, 1, 0); /* ffffffff STRMOUT_PRIMITIVE_COUNT */
  2205. xf_emit(ctx, 4, 4); /* 000000ff STRMOUT_NUM_ATTRIBS */
  2206. if (dev_priv->chipset >= 0xa0) {
  2207. xf_emit(ctx, 4, 0); /* ffffffff UNK1A8C */
  2208. xf_emit(ctx, 4, 0); /* ffffffff UNK1780 */
  2209. }
  2210. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  2211. xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
  2212. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2213. if (dev_priv->chipset == 0x50)
  2214. xf_emit(ctx, 1, 0x3ff); /* 000003ff tesla UNK0D68 */
  2215. else
  2216. xf_emit(ctx, 1, 0x7ff); /* 000007ff tesla UNK0D68 */
  2217. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2218. /* SEEK */
  2219. xf_emit(ctx, 1, 0x102); /* 0000ffff STRMOUT_BUFFER_CTRL */
  2220. xf_emit(ctx, 1, 0); /* ffffffff STRMOUT_PRIMITIVE_COUNT */
  2221. xf_emit(ctx, 4, 0); /* 000000ff STRMOUT_ADDRESS_HIGH */
  2222. xf_emit(ctx, 4, 0); /* ffffffff STRMOUT_ADDRESS_LOW */
  2223. xf_emit(ctx, 4, 4); /* 000000ff STRMOUT_NUM_ATTRIBS */
  2224. if (dev_priv->chipset >= 0xa0) {
  2225. xf_emit(ctx, 4, 0); /* ffffffff UNK1A8C */
  2226. xf_emit(ctx, 4, 0); /* ffffffff UNK1780 */
  2227. }
  2228. xf_emit(ctx, 1, 0); /* 0000ffff DMA_STRMOUT */
  2229. xf_emit(ctx, 1, 0); /* 0000ffff DMA_QUERY */
  2230. xf_emit(ctx, 1, 0); /* 000000ff QUERY_ADDRESS_HIGH */
  2231. xf_emit(ctx, 2, 0); /* ffffffff QUERY_ADDRESS_LOW QUERY_COUNTER */
  2232. xf_emit(ctx, 2, 0); /* ffffffff */
  2233. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2234. /* SEEK */
  2235. xf_emit(ctx, 0x20, 0); /* ffffffff STRMOUT_MAP */
  2236. xf_emit(ctx, 1, 0); /* 0000000f */
  2237. xf_emit(ctx, 1, 0); /* 00000000? */
  2238. xf_emit(ctx, 2, 0); /* ffffffff */
  2239. }
  2240. static void
  2241. nv50_graph_construct_gene_ropm1(struct nouveau_grctx *ctx)
  2242. {
  2243. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2244. xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0D64 */
  2245. xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0DF4 */
  2246. xf_emit(ctx, 1, 0); /* 00000007 */
  2247. xf_emit(ctx, 1, 0); /* 000003ff */
  2248. if (IS_NVA3F(dev_priv->chipset))
  2249. xf_emit(ctx, 1, 0x11); /* 000000ff tesla UNK1968 */
  2250. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2251. }
  2252. static void
  2253. nv50_graph_construct_gene_ropm2(struct nouveau_grctx *ctx)
  2254. {
  2255. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2256. /* SEEK */
  2257. xf_emit(ctx, 1, 0); /* 0000ffff DMA_QUERY */
  2258. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2259. xf_emit(ctx, 2, 0); /* ffffffff */
  2260. xf_emit(ctx, 1, 0); /* 000000ff QUERY_ADDRESS_HIGH */
  2261. xf_emit(ctx, 2, 0); /* ffffffff QUERY_ADDRESS_LOW, COUNTER */
  2262. xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
  2263. xf_emit(ctx, 1, 0); /* 7 */
  2264. /* SEEK */
  2265. xf_emit(ctx, 1, 0); /* 0000ffff DMA_QUERY */
  2266. xf_emit(ctx, 1, 0); /* 000000ff QUERY_ADDRESS_HIGH */
  2267. xf_emit(ctx, 2, 0); /* ffffffff QUERY_ADDRESS_LOW, COUNTER */
  2268. xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0D64 */
  2269. xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0DF4 */
  2270. xf_emit(ctx, 1, 0); /* 00000001 eng2d UNK260 */
  2271. xf_emit(ctx, 1, 0); /* ff/3ff */
  2272. xf_emit(ctx, 1, 0); /* 00000007 */
  2273. if (IS_NVA3F(dev_priv->chipset))
  2274. xf_emit(ctx, 1, 0x11); /* 000000ff tesla UNK1968 */
  2275. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2276. }
  2277. static void
  2278. nv50_graph_construct_gene_ropc(struct nouveau_grctx *ctx)
  2279. {
  2280. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2281. int magic2;
  2282. if (dev_priv->chipset == 0x50) {
  2283. magic2 = 0x00003e60;
  2284. } else if (!IS_NVA3F(dev_priv->chipset)) {
  2285. magic2 = 0x001ffe67;
  2286. } else {
  2287. magic2 = 0x00087e67;
  2288. }
  2289. xf_emit(ctx, 1, 0); /* f/7 MUTISAMPLE_SAMPLES_LOG2 */
  2290. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2291. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
  2292. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
  2293. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
  2294. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
  2295. xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
  2296. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2297. xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
  2298. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2299. xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
  2300. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2301. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2302. if (IS_NVA3F(dev_priv->chipset))
  2303. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2304. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
  2305. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
  2306. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
  2307. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
  2308. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2309. if (dev_priv->chipset >= 0xa0 && !IS_NVAAF(dev_priv->chipset))
  2310. xf_emit(ctx, 1, 0x15); /* 000000ff */
  2311. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  2312. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
  2313. xf_emit(ctx, 1, 0x10); /* 3ff/ff VIEW_VOLUME_CLIP_CTRL */
  2314. xf_emit(ctx, 1, 0); /* ffffffff CLEAR_DEPTH */
  2315. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2316. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2317. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2318. if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x92 || dev_priv->chipset == 0x98 || dev_priv->chipset >= 0xa0) {
  2319. xf_emit(ctx, 3, 0); /* ff, ffffffff, ffffffff */
  2320. xf_emit(ctx, 1, 4); /* 7 */
  2321. xf_emit(ctx, 1, 0x400); /* fffffff */
  2322. xf_emit(ctx, 1, 0x300); /* ffff */
  2323. xf_emit(ctx, 1, 0x1001); /* 1fff */
  2324. if (dev_priv->chipset != 0xa0) {
  2325. if (IS_NVA3F(dev_priv->chipset))
  2326. xf_emit(ctx, 1, 0); /* 0000000f UNK15C8 */
  2327. else
  2328. xf_emit(ctx, 1, 0x15); /* ff */
  2329. }
  2330. }
  2331. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  2332. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2333. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
  2334. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
  2335. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2336. xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
  2337. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2338. xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
  2339. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2340. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2341. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
  2342. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
  2343. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2344. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  2345. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
  2346. xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
  2347. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2348. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2349. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2350. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2351. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
  2352. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
  2353. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
  2354. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_REF */
  2355. xf_emit(ctx, 2, 0); /* ffffffff DEPTH_BOUNDS */
  2356. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2357. xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
  2358. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2359. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2360. xf_emit(ctx, 1, 0); /* 0000000f */
  2361. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0FB0 */
  2362. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
  2363. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
  2364. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_REF */
  2365. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2366. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  2367. xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
  2368. xf_emit(ctx, 0x10, 0); /* ffffffff DEPTH_RANGE_NEAR */
  2369. xf_emit(ctx, 0x10, 0x3f800000); /* ffffffff DEPTH_RANGE_FAR */
  2370. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2371. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  2372. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
  2373. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
  2374. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_REF */
  2375. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
  2376. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
  2377. xf_emit(ctx, 2, 0); /* ffffffff DEPTH_BOUNDS */
  2378. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2379. xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
  2380. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2381. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2382. xf_emit(ctx, 1, 0); /* 000000ff CLEAR_STENCIL */
  2383. xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
  2384. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
  2385. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_REF */
  2386. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
  2387. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
  2388. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2389. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  2390. xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
  2391. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2392. xf_emit(ctx, 1, 0x3f); /* 0000003f UNK1590 */
  2393. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  2394. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2395. xf_emit(ctx, 2, 0); /* ffff0ff3, ffff */
  2396. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0FB0 */
  2397. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  2398. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
  2399. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2400. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2401. xf_emit(ctx, 1, 0); /* ffffffff CLEAR_DEPTH */
  2402. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK19CC */
  2403. if (dev_priv->chipset >= 0xa0) {
  2404. xf_emit(ctx, 2, 0);
  2405. xf_emit(ctx, 1, 0x1001);
  2406. xf_emit(ctx, 0xb, 0);
  2407. } else {
  2408. xf_emit(ctx, 1, 0); /* 00000007 */
  2409. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2410. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  2411. xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
  2412. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2413. }
  2414. xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
  2415. xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
  2416. xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
  2417. xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
  2418. xf_emit(ctx, 1, 0x11); /* 3f/7f */
  2419. xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
  2420. if (dev_priv->chipset != 0x50) {
  2421. xf_emit(ctx, 1, 0); /* 0000000f LOGIC_OP */
  2422. xf_emit(ctx, 1, 0); /* 000000ff */
  2423. }
  2424. xf_emit(ctx, 1, 0); /* 00000007 OPERATION */
  2425. xf_emit(ctx, 1, 0); /* ff/3ff */
  2426. xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
  2427. xf_emit(ctx, 2, 1); /* 00000007 BLEND_EQUATION_RGB, ALPHA */
  2428. xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
  2429. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
  2430. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
  2431. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
  2432. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
  2433. xf_emit(ctx, 1, 0); /* 00000001 */
  2434. xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
  2435. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2436. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2437. if (IS_NVA3F(dev_priv->chipset)) {
  2438. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK12E4 */
  2439. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
  2440. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
  2441. xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
  2442. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_RGB */
  2443. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_RGB */
  2444. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_ALPHA */
  2445. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_ALPHA */
  2446. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1140 */
  2447. xf_emit(ctx, 2, 0); /* 00000001 */
  2448. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2449. xf_emit(ctx, 1, 0); /* 0000000f */
  2450. xf_emit(ctx, 1, 0); /* 00000003 */
  2451. xf_emit(ctx, 1, 0); /* ffffffff */
  2452. xf_emit(ctx, 2, 0); /* 00000001 */
  2453. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2454. xf_emit(ctx, 1, 0); /* 00000001 */
  2455. xf_emit(ctx, 1, 0); /* 000003ff */
  2456. } else if (dev_priv->chipset >= 0xa0) {
  2457. xf_emit(ctx, 2, 0); /* 00000001 */
  2458. xf_emit(ctx, 1, 0); /* 00000007 */
  2459. xf_emit(ctx, 1, 0); /* 00000003 */
  2460. xf_emit(ctx, 1, 0); /* ffffffff */
  2461. xf_emit(ctx, 2, 0); /* 00000001 */
  2462. } else {
  2463. xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
  2464. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1430 */
  2465. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2466. }
  2467. xf_emit(ctx, 4, 0); /* ffffffff CLEAR_COLOR */
  2468. xf_emit(ctx, 4, 0); /* ffffffff BLEND_COLOR A R G B */
  2469. xf_emit(ctx, 1, 0); /* 00000fff eng2d UNK2B0 */
  2470. if (dev_priv->chipset >= 0xa0)
  2471. xf_emit(ctx, 2, 0); /* 00000001 */
  2472. xf_emit(ctx, 1, 0); /* 000003ff */
  2473. xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
  2474. xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
  2475. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
  2476. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
  2477. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
  2478. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
  2479. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
  2480. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
  2481. xf_emit(ctx, 1, 0); /* 00000001 UNK19C0 */
  2482. xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
  2483. xf_emit(ctx, 1, 0); /* 0000000f LOGIC_OP */
  2484. if (dev_priv->chipset >= 0xa0)
  2485. xf_emit(ctx, 1, 0); /* 00000001 UNK12E4? NVA3+ only? */
  2486. if (IS_NVA3F(dev_priv->chipset)) {
  2487. xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
  2488. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
  2489. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_RGB */
  2490. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_RGB */
  2491. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
  2492. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_ALPHA */
  2493. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_ALPHA */
  2494. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK15C4 */
  2495. xf_emit(ctx, 1, 0); /* 00000001 */
  2496. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1140 */
  2497. }
  2498. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  2499. xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
  2500. xf_emit(ctx, 1, 0); /* 00000007 PATTERN_COLOR_FORMAT */
  2501. xf_emit(ctx, 2, 0); /* ffffffff PATTERN_MONO_COLOR */
  2502. xf_emit(ctx, 1, 0); /* 00000001 PATTERN_MONO_FORMAT */
  2503. xf_emit(ctx, 2, 0); /* ffffffff PATTERN_MONO_BITMAP */
  2504. xf_emit(ctx, 1, 0); /* 00000003 PATTERN_SELECT */
  2505. xf_emit(ctx, 1, 0); /* 000000ff ROP */
  2506. xf_emit(ctx, 1, 0); /* ffffffff BETA1 */
  2507. xf_emit(ctx, 1, 0); /* ffffffff BETA4 */
  2508. xf_emit(ctx, 1, 0); /* 00000007 OPERATION */
  2509. xf_emit(ctx, 0x50, 0); /* 10x ffffff, ffffff, ffffff, ffffff, 3 PATTERN */
  2510. }
  2511. static void
  2512. nv50_graph_construct_xfer_unk84xx(struct nouveau_grctx *ctx)
  2513. {
  2514. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2515. int magic3;
  2516. switch (dev_priv->chipset) {
  2517. case 0x50:
  2518. magic3 = 0x1000;
  2519. break;
  2520. case 0x86:
  2521. case 0x98:
  2522. case 0xa8:
  2523. case 0xaa:
  2524. case 0xac:
  2525. case 0xaf:
  2526. magic3 = 0x1e00;
  2527. break;
  2528. default:
  2529. magic3 = 0;
  2530. }
  2531. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2532. xf_emit(ctx, 1, 4); /* 7f/ff[NVA0+] VP_REG_ALLOC_RESULT */
  2533. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2534. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2535. xf_emit(ctx, 1, 0); /* 111/113[NVA0+] */
  2536. if (IS_NVA3F(dev_priv->chipset))
  2537. xf_emit(ctx, 0x1f, 0); /* ffffffff */
  2538. else if (dev_priv->chipset >= 0xa0)
  2539. xf_emit(ctx, 0x0f, 0); /* ffffffff */
  2540. else
  2541. xf_emit(ctx, 0x10, 0); /* fffffff VP_RESULT_MAP_1 up */
  2542. xf_emit(ctx, 2, 0); /* f/1f[NVA3], fffffff/ffffffff[NVA0+] */
  2543. xf_emit(ctx, 1, 4); /* 7f/ff VP_REG_ALLOC_RESULT */
  2544. xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
  2545. if (dev_priv->chipset >= 0xa0)
  2546. xf_emit(ctx, 1, 0x03020100); /* ffffffff */
  2547. else
  2548. xf_emit(ctx, 1, 0x00608080); /* fffffff VP_RESULT_MAP_0 */
  2549. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2550. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2551. xf_emit(ctx, 2, 0); /* 111/113, 7f/ff */
  2552. xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
  2553. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2554. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2555. xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
  2556. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  2557. xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
  2558. if (magic3)
  2559. xf_emit(ctx, 1, magic3); /* 00007fff tesla UNK141C */
  2560. xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
  2561. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2562. xf_emit(ctx, 1, 0); /* 111/113 */
  2563. xf_emit(ctx, 0x1f, 0); /* ffffffff GP_RESULT_MAP_1 up */
  2564. xf_emit(ctx, 1, 0); /* 0000001f */
  2565. xf_emit(ctx, 1, 0); /* ffffffff */
  2566. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2567. xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
  2568. xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
  2569. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  2570. xf_emit(ctx, 1, 0x03020100); /* ffffffff GP_RESULT_MAP_0 */
  2571. xf_emit(ctx, 1, 3); /* 00000003 GP_OUTPUT_PRIMITIVE_TYPE */
  2572. if (magic3)
  2573. xf_emit(ctx, 1, magic3); /* 7fff tesla UNK141C */
  2574. xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
  2575. xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
  2576. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2577. xf_emit(ctx, 1, 0); /* 111/113 */
  2578. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2579. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  2580. xf_emit(ctx, 1, 3); /* 00000003 GP_OUTPUT_PRIMITIVE_TYPE */
  2581. xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
  2582. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2583. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK13A0 */
  2584. xf_emit(ctx, 1, 4); /* 7f/ff VP_REG_ALLOC_RESULT */
  2585. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2586. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2587. xf_emit(ctx, 1, 0); /* 111/113 */
  2588. if (dev_priv->chipset == 0x94 || dev_priv->chipset == 0x96)
  2589. xf_emit(ctx, 0x1020, 0); /* 4 x (0x400 x 0xffffffff, ff, 0, 0, 0, 4 x ffffffff) */
  2590. else if (dev_priv->chipset < 0xa0)
  2591. xf_emit(ctx, 0xa20, 0); /* 4 x (0x280 x 0xffffffff, ff, 0, 0, 0, 4 x ffffffff) */
  2592. else if (!IS_NVA3F(dev_priv->chipset))
  2593. xf_emit(ctx, 0x210, 0); /* ffffffff */
  2594. else
  2595. xf_emit(ctx, 0x410, 0); /* ffffffff */
  2596. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  2597. xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
  2598. xf_emit(ctx, 1, 3); /* 00000003 GP_OUTPUT_PRIMITIVE_TYPE */
  2599. xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
  2600. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  2601. }
  2602. static void
  2603. nv50_graph_construct_xfer_tprop(struct nouveau_grctx *ctx)
  2604. {
  2605. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2606. int magic1, magic2;
  2607. if (dev_priv->chipset == 0x50) {
  2608. magic1 = 0x3ff;
  2609. magic2 = 0x00003e60;
  2610. } else if (!IS_NVA3F(dev_priv->chipset)) {
  2611. magic1 = 0x7ff;
  2612. magic2 = 0x001ffe67;
  2613. } else {
  2614. magic1 = 0x7ff;
  2615. magic2 = 0x00087e67;
  2616. }
  2617. xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
  2618. xf_emit(ctx, 1, 0); /* ffffffff ALPHA_TEST_REF */
  2619. xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
  2620. if (IS_NVA3F(dev_priv->chipset))
  2621. xf_emit(ctx, 1, 1); /* 0000000f UNK16A0 */
  2622. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2623. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2624. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
  2625. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
  2626. xf_emit(ctx, 4, 0); /* ffffffff BLEND_COLOR */
  2627. xf_emit(ctx, 1, 0); /* 00000001 UNK19C0 */
  2628. xf_emit(ctx, 1, 0); /* 00000001 UNK0FDC */
  2629. xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
  2630. xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
  2631. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2632. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2633. xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
  2634. xf_emit(ctx, 1, 0); /* ff[NV50]/3ff[NV84+] */
  2635. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  2636. xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
  2637. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
  2638. xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
  2639. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2640. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
  2641. xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
  2642. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK19CC */
  2643. xf_emit(ctx, 1, 0); /* 7 */
  2644. xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
  2645. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2646. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2647. xf_emit(ctx, 1, 0); /* ffffffff COLOR_KEY */
  2648. xf_emit(ctx, 1, 0); /* 00000001 COLOR_KEY_ENABLE */
  2649. xf_emit(ctx, 1, 0); /* 00000007 COLOR_KEY_FORMAT */
  2650. xf_emit(ctx, 2, 0); /* ffffffff SIFC_BITMAP_COLOR */
  2651. xf_emit(ctx, 1, 1); /* 00000001 SIFC_BITMAP_WRITE_BIT0_ENABLE */
  2652. xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
  2653. xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
  2654. if (IS_NVA3F(dev_priv->chipset)) {
  2655. xf_emit(ctx, 1, 3); /* 00000003 tesla UNK16B4 */
  2656. xf_emit(ctx, 1, 0); /* 00000003 */
  2657. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1298 */
  2658. } else if (dev_priv->chipset >= 0xa0) {
  2659. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK16B4 */
  2660. xf_emit(ctx, 1, 0); /* 00000003 */
  2661. } else {
  2662. xf_emit(ctx, 1, 0); /* 00000003 MULTISAMPLE_CTRL */
  2663. }
  2664. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2665. xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
  2666. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
  2667. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
  2668. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
  2669. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
  2670. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
  2671. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
  2672. if (IS_NVA3F(dev_priv->chipset)) {
  2673. xf_emit(ctx, 1, 0); /* 00000001 UNK12E4 */
  2674. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
  2675. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
  2676. xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
  2677. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_SRC_RGB */
  2678. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_DST_RGB */
  2679. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_SRC_ALPHA */
  2680. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_DST_ALPHA */
  2681. xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
  2682. }
  2683. xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
  2684. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2685. xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
  2686. xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
  2687. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2688. xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
  2689. xf_emit(ctx, 1, 0); /* ff/3ff */
  2690. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  2691. xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
  2692. xf_emit(ctx, 1, 0); /* 00000001 FRAMEBUFFER_SRGB */
  2693. xf_emit(ctx, 1, 0); /* 7 */
  2694. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  2695. xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
  2696. xf_emit(ctx, 1, 0); /* 00000007 OPERATION */
  2697. xf_emit(ctx, 1, 0xcf); /* 000000ff SIFC_FORMAT */
  2698. xf_emit(ctx, 1, 0xcf); /* 000000ff DRAW_COLOR_FORMAT */
  2699. xf_emit(ctx, 1, 0xcf); /* 000000ff SRC_FORMAT */
  2700. if (IS_NVA3F(dev_priv->chipset))
  2701. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2702. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2703. xf_emit(ctx, 1, 0); /* 7/f[NVA3] MULTISAMPLE_SAMPLES_LOG2 */
  2704. xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
  2705. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
  2706. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
  2707. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
  2708. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
  2709. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
  2710. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
  2711. xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
  2712. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2713. xf_emit(ctx, 8, 1); /* 00000001 UNK19E0 */
  2714. xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
  2715. xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
  2716. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2717. xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
  2718. xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
  2719. xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
  2720. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2721. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2722. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  2723. xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
  2724. if (IS_NVA3F(dev_priv->chipset))
  2725. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2726. if (dev_priv->chipset == 0x50)
  2727. xf_emit(ctx, 1, 0); /* ff */
  2728. else
  2729. xf_emit(ctx, 3, 0); /* 1, 7, 3ff */
  2730. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  2731. xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
  2732. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2733. xf_emit(ctx, 1, 0); /* 00000007 */
  2734. xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
  2735. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2736. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2737. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2738. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2739. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2740. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2741. xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
  2742. xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
  2743. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2744. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2745. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2746. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2747. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  2748. xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
  2749. xf_emit(ctx, 1, 0); /* 000fffff BLIT_DU_DX_FRACT */
  2750. xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DU_DX_INT */
  2751. xf_emit(ctx, 1, 0); /* 000fffff BLIT_DV_DY_FRACT */
  2752. xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DV_DY_INT */
  2753. xf_emit(ctx, 1, 0); /* ff/3ff */
  2754. xf_emit(ctx, 1, magic1); /* 3ff/7ff tesla UNK0D68 */
  2755. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2756. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
  2757. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2758. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2759. xf_emit(ctx, 1, 0); /* 00000007 */
  2760. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2761. if (IS_NVA3F(dev_priv->chipset))
  2762. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2763. xf_emit(ctx, 8, 0); /* 0000ffff DMA_COLOR */
  2764. xf_emit(ctx, 1, 0); /* 0000ffff DMA_GLOBAL */
  2765. xf_emit(ctx, 1, 0); /* 0000ffff DMA_LOCAL */
  2766. xf_emit(ctx, 1, 0); /* 0000ffff DMA_STACK */
  2767. xf_emit(ctx, 1, 0); /* ff/3ff */
  2768. xf_emit(ctx, 1, 0); /* 0000ffff DMA_DST */
  2769. xf_emit(ctx, 1, 0); /* 7 */
  2770. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2771. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2772. xf_emit(ctx, 8, 0); /* 000000ff RT_ADDRESS_HIGH */
  2773. xf_emit(ctx, 8, 0); /* ffffffff RT_LAYER_STRIDE */
  2774. xf_emit(ctx, 8, 0); /* ffffffff RT_ADDRESS_LOW */
  2775. xf_emit(ctx, 8, 8); /* 0000007f RT_TILE_MODE */
  2776. xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
  2777. xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
  2778. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2779. xf_emit(ctx, 8, 0x400); /* 0fffffff RT_HORIZ */
  2780. xf_emit(ctx, 8, 0x300); /* 0000ffff RT_VERT */
  2781. xf_emit(ctx, 1, 1); /* 00001fff RT_ARRAY_MODE */
  2782. xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
  2783. xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
  2784. xf_emit(ctx, 1, 0x20); /* 00000fff DST_TILE_MODE */
  2785. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  2786. xf_emit(ctx, 1, 0x100); /* 0001ffff DST_HEIGHT */
  2787. xf_emit(ctx, 1, 0); /* 000007ff DST_LAYER */
  2788. xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
  2789. xf_emit(ctx, 1, 0); /* ffffffff DST_ADDRESS_LOW */
  2790. xf_emit(ctx, 1, 0); /* 000000ff DST_ADDRESS_HIGH */
  2791. xf_emit(ctx, 1, 0x40); /* 0007ffff DST_PITCH */
  2792. xf_emit(ctx, 1, 0x100); /* 0001ffff DST_WIDTH */
  2793. xf_emit(ctx, 1, 0); /* 0000ffff */
  2794. xf_emit(ctx, 1, 3); /* 00000003 tesla UNK15AC */
  2795. xf_emit(ctx, 1, 0); /* ff/3ff */
  2796. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  2797. xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
  2798. xf_emit(ctx, 1, 0); /* 00000007 */
  2799. if (IS_NVA3F(dev_priv->chipset))
  2800. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2801. xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
  2802. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2803. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  2804. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2805. xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
  2806. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2807. xf_emit(ctx, 1, 0); /* 0000ffff DMA_ZETA */
  2808. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2809. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2810. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2811. xf_emit(ctx, 2, 0); /* ffff, ff/3ff */
  2812. xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
  2813. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2814. xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
  2815. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
  2816. xf_emit(ctx, 1, 0); /* 00000007 */
  2817. xf_emit(ctx, 1, 0); /* ffffffff ZETA_LAYER_STRIDE */
  2818. xf_emit(ctx, 1, 0); /* 000000ff ZETA_ADDRESS_HIGH */
  2819. xf_emit(ctx, 1, 0); /* ffffffff ZETA_ADDRESS_LOW */
  2820. xf_emit(ctx, 1, 4); /* 00000007 ZETA_TILE_MODE */
  2821. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2822. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2823. xf_emit(ctx, 1, 0x400); /* 0fffffff ZETA_HORIZ */
  2824. xf_emit(ctx, 1, 0x300); /* 0000ffff ZETA_VERT */
  2825. xf_emit(ctx, 1, 0x1001); /* 00001fff ZETA_ARRAY_MODE */
  2826. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2827. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2828. if (IS_NVA3F(dev_priv->chipset))
  2829. xf_emit(ctx, 1, 0); /* 00000001 */
  2830. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2831. xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
  2832. xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
  2833. xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
  2834. xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
  2835. xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
  2836. xf_emit(ctx, 1, 0); /* ff/3ff */
  2837. xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
  2838. xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
  2839. xf_emit(ctx, 1, 0); /* 00000001 FRAMEBUFFER_SRGB */
  2840. xf_emit(ctx, 1, 0); /* 7 */
  2841. xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
  2842. if (IS_NVA3F(dev_priv->chipset)) {
  2843. xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
  2844. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2845. }
  2846. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2847. xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
  2848. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2849. if (dev_priv->chipset >= 0xa0)
  2850. xf_emit(ctx, 1, 0x0fac6881); /* fffffff */
  2851. xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
  2852. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
  2853. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2854. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
  2855. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  2856. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0FB0 */
  2857. xf_emit(ctx, 1, 0); /* ff/3ff */
  2858. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  2859. xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
  2860. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
  2861. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK19CC */
  2862. xf_emit(ctx, 1, 0); /* 00000007 */
  2863. xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
  2864. xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
  2865. xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
  2866. if (IS_NVA3F(dev_priv->chipset)) {
  2867. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2868. xf_emit(ctx, 1, 0); /* 0000000f tesla UNK15C8 */
  2869. }
  2870. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
  2871. if (dev_priv->chipset >= 0xa0) {
  2872. xf_emit(ctx, 3, 0); /* 7/f, 1, ffff0ff3 */
  2873. xf_emit(ctx, 1, 0xfac6881); /* fffffff */
  2874. xf_emit(ctx, 4, 0); /* 1, 1, 1, 3ff */
  2875. xf_emit(ctx, 1, 4); /* 7 */
  2876. xf_emit(ctx, 1, 0); /* 1 */
  2877. xf_emit(ctx, 2, 1); /* 1 */
  2878. xf_emit(ctx, 2, 0); /* 7, f */
  2879. xf_emit(ctx, 1, 1); /* 1 */
  2880. xf_emit(ctx, 1, 0); /* 7/f */
  2881. if (IS_NVA3F(dev_priv->chipset))
  2882. xf_emit(ctx, 0x9, 0); /* 1 */
  2883. else
  2884. xf_emit(ctx, 0x8, 0); /* 1 */
  2885. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2886. xf_emit(ctx, 8, 1); /* 1 */
  2887. xf_emit(ctx, 1, 0x11); /* 7f */
  2888. xf_emit(ctx, 7, 0); /* 7f */
  2889. xf_emit(ctx, 1, 0xfac6881); /* fffffff */
  2890. xf_emit(ctx, 1, 0xf); /* f */
  2891. xf_emit(ctx, 7, 0); /* f */
  2892. xf_emit(ctx, 1, 0x11); /* 7f */
  2893. xf_emit(ctx, 1, 1); /* 1 */
  2894. xf_emit(ctx, 5, 0); /* 1, 7, 3ff, 3, 7 */
  2895. if (IS_NVA3F(dev_priv->chipset)) {
  2896. xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
  2897. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2898. }
  2899. }
  2900. }
  2901. static void
  2902. nv50_graph_construct_xfer_tex(struct nouveau_grctx *ctx)
  2903. {
  2904. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2905. xf_emit(ctx, 2, 0); /* 1 LINKED_TSC. yes, 2. */
  2906. if (dev_priv->chipset != 0x50)
  2907. xf_emit(ctx, 1, 0); /* 3 */
  2908. xf_emit(ctx, 1, 1); /* 1ffff BLIT_DU_DX_INT */
  2909. xf_emit(ctx, 1, 0); /* fffff BLIT_DU_DX_FRACT */
  2910. xf_emit(ctx, 1, 1); /* 1ffff BLIT_DV_DY_INT */
  2911. xf_emit(ctx, 1, 0); /* fffff BLIT_DV_DY_FRACT */
  2912. if (dev_priv->chipset == 0x50)
  2913. xf_emit(ctx, 1, 0); /* 3 BLIT_CONTROL */
  2914. else
  2915. xf_emit(ctx, 2, 0); /* 3ff, 1 */
  2916. xf_emit(ctx, 1, 0x2a712488); /* ffffffff SRC_TIC_0 */
  2917. xf_emit(ctx, 1, 0); /* ffffffff SRC_TIC_1 */
  2918. xf_emit(ctx, 1, 0x4085c000); /* ffffffff SRC_TIC_2 */
  2919. xf_emit(ctx, 1, 0x40); /* ffffffff SRC_TIC_3 */
  2920. xf_emit(ctx, 1, 0x100); /* ffffffff SRC_TIC_4 */
  2921. xf_emit(ctx, 1, 0x10100); /* ffffffff SRC_TIC_5 */
  2922. xf_emit(ctx, 1, 0x02800000); /* ffffffff SRC_TIC_6 */
  2923. xf_emit(ctx, 1, 0); /* ffffffff SRC_TIC_7 */
  2924. if (dev_priv->chipset == 0x50) {
  2925. xf_emit(ctx, 1, 0); /* 00000001 turing UNK358 */
  2926. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34? */
  2927. xf_emit(ctx, 1, 0); /* 00000003 turing UNK37C tesla UNK1690 */
  2928. xf_emit(ctx, 1, 0); /* 00000003 BLIT_CONTROL */
  2929. xf_emit(ctx, 1, 0); /* 00000001 turing UNK32C tesla UNK0F94 */
  2930. } else if (!IS_NVAAF(dev_priv->chipset)) {
  2931. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34? */
  2932. xf_emit(ctx, 1, 0); /* 00000003 */
  2933. xf_emit(ctx, 1, 0); /* 000003ff */
  2934. xf_emit(ctx, 1, 0); /* 00000003 */
  2935. xf_emit(ctx, 1, 0); /* 000003ff */
  2936. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1664 / turing UNK03E8 */
  2937. xf_emit(ctx, 1, 0); /* 00000003 */
  2938. xf_emit(ctx, 1, 0); /* 000003ff */
  2939. } else {
  2940. xf_emit(ctx, 0x6, 0);
  2941. }
  2942. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34 */
  2943. xf_emit(ctx, 1, 0); /* 0000ffff DMA_TEXTURE */
  2944. xf_emit(ctx, 1, 0); /* 0000ffff DMA_SRC */
  2945. }
  2946. static void
  2947. nv50_graph_construct_xfer_unk8cxx(struct nouveau_grctx *ctx)
  2948. {
  2949. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2950. xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
  2951. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2952. xf_emit(ctx, 2, 0); /* 7, ffff0ff3 */
  2953. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2954. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE */
  2955. xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0D64 */
  2956. xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0DF4 */
  2957. xf_emit(ctx, 1, 1); /* 00000001 UNK15B4 */
  2958. xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
  2959. xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
  2960. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK0F98 */
  2961. if (IS_NVA3F(dev_priv->chipset))
  2962. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  2963. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1668 */
  2964. xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
  2965. xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
  2966. xf_emit(ctx, 1, 0); /* 00000001 POLYGON_SMOOTH_ENABLE */
  2967. xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
  2968. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  2969. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1658 */
  2970. xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
  2971. xf_emit(ctx, 1, 0); /* ffff0ff3 */
  2972. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
  2973. xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE */
  2974. xf_emit(ctx, 1, 1); /* 00000001 UNK15B4 */
  2975. xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_ENABLE */
  2976. xf_emit(ctx, 1, 1); /* 00000001 tesla UNK165C */
  2977. xf_emit(ctx, 1, 0x30201000); /* ffffffff tesla UNK1670 */
  2978. xf_emit(ctx, 1, 0x70605040); /* ffffffff tesla UNK1670 */
  2979. xf_emit(ctx, 1, 0xb8a89888); /* ffffffff tesla UNK1670 */
  2980. xf_emit(ctx, 1, 0xf8e8d8c8); /* ffffffff tesla UNK1670 */
  2981. xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
  2982. xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
  2983. }
  2984. static void
  2985. nv50_graph_construct_xfer_tp(struct nouveau_grctx *ctx)
  2986. {
  2987. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2988. if (dev_priv->chipset < 0xa0) {
  2989. nv50_graph_construct_xfer_unk84xx(ctx);
  2990. nv50_graph_construct_xfer_tprop(ctx);
  2991. nv50_graph_construct_xfer_tex(ctx);
  2992. nv50_graph_construct_xfer_unk8cxx(ctx);
  2993. } else {
  2994. nv50_graph_construct_xfer_tex(ctx);
  2995. nv50_graph_construct_xfer_tprop(ctx);
  2996. nv50_graph_construct_xfer_unk8cxx(ctx);
  2997. nv50_graph_construct_xfer_unk84xx(ctx);
  2998. }
  2999. }
  3000. static void
  3001. nv50_graph_construct_xfer_mpc(struct nouveau_grctx *ctx)
  3002. {
  3003. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  3004. int i, mpcnt = 2;
  3005. switch (dev_priv->chipset) {
  3006. case 0x98:
  3007. case 0xaa:
  3008. mpcnt = 1;
  3009. break;
  3010. case 0x50:
  3011. case 0x84:
  3012. case 0x86:
  3013. case 0x92:
  3014. case 0x94:
  3015. case 0x96:
  3016. case 0xa8:
  3017. case 0xac:
  3018. mpcnt = 2;
  3019. break;
  3020. case 0xa0:
  3021. case 0xa3:
  3022. case 0xa5:
  3023. case 0xaf:
  3024. mpcnt = 3;
  3025. break;
  3026. }
  3027. for (i = 0; i < mpcnt; i++) {
  3028. xf_emit(ctx, 1, 0); /* ff */
  3029. xf_emit(ctx, 1, 0x80); /* ffffffff tesla UNK1404 */
  3030. xf_emit(ctx, 1, 0x80007004); /* ffffffff tesla UNK12B0 */
  3031. xf_emit(ctx, 1, 0x04000400); /* ffffffff */
  3032. if (dev_priv->chipset >= 0xa0)
  3033. xf_emit(ctx, 1, 0xc0); /* 00007fff tesla UNK152C */
  3034. xf_emit(ctx, 1, 0x1000); /* 0000ffff tesla UNK0D60 */
  3035. xf_emit(ctx, 1, 0); /* ff/3ff */
  3036. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
  3037. if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x98 || dev_priv->chipset == 0xa8 || IS_NVAAF(dev_priv->chipset)) {
  3038. xf_emit(ctx, 1, 0xe00); /* 7fff */
  3039. xf_emit(ctx, 1, 0x1e00); /* 7fff */
  3040. }
  3041. xf_emit(ctx, 1, 1); /* 000000ff VP_REG_ALLOC_TEMP */
  3042. xf_emit(ctx, 1, 0); /* 00000001 LINKED_TSC */
  3043. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  3044. if (dev_priv->chipset == 0x50)
  3045. xf_emit(ctx, 2, 0x1000); /* 7fff tesla UNK141C */
  3046. xf_emit(ctx, 1, 1); /* 000000ff GP_REG_ALLOC_TEMP */
  3047. xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
  3048. xf_emit(ctx, 1, 4); /* 000000ff FP_REG_ALLOC_TEMP */
  3049. xf_emit(ctx, 1, 2); /* 00000003 REG_MODE */
  3050. if (IS_NVAAF(dev_priv->chipset))
  3051. xf_emit(ctx, 0xb, 0); /* RO */
  3052. else if (dev_priv->chipset >= 0xa0)
  3053. xf_emit(ctx, 0xc, 0); /* RO */
  3054. else
  3055. xf_emit(ctx, 0xa, 0); /* RO */
  3056. }
  3057. xf_emit(ctx, 1, 0x08100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  3058. xf_emit(ctx, 1, 0); /* ff/3ff */
  3059. if (dev_priv->chipset >= 0xa0) {
  3060. xf_emit(ctx, 1, 0x1fe21); /* 0003ffff tesla UNK0FAC */
  3061. }
  3062. xf_emit(ctx, 3, 0); /* 7fff, 0, 0 */
  3063. xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
  3064. xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
  3065. xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
  3066. xf_emit(ctx, 1, 1); /* 00000001 LANES32 */
  3067. xf_emit(ctx, 1, 0x10001); /* 00ffffff BLOCK_ALLOC */
  3068. xf_emit(ctx, 1, 0x10001); /* ffffffff BLOCKDIM_XY */
  3069. xf_emit(ctx, 1, 1); /* 0000ffff BLOCKDIM_Z */
  3070. xf_emit(ctx, 1, 0); /* ffffffff SHARED_SIZE */
  3071. xf_emit(ctx, 1, 0x1fe21); /* 1ffff/3ffff[NVA0+] tesla UNk0FAC */
  3072. xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34 */
  3073. if (IS_NVA3F(dev_priv->chipset))
  3074. xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
  3075. xf_emit(ctx, 1, 0); /* ff/3ff */
  3076. xf_emit(ctx, 1, 0); /* 1 LINKED_TSC */
  3077. xf_emit(ctx, 1, 0); /* ff FP_ADDRESS_HIGH */
  3078. xf_emit(ctx, 1, 0); /* ffffffff FP_ADDRESS_LOW */
  3079. xf_emit(ctx, 1, 0x08100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
  3080. xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
  3081. xf_emit(ctx, 1, 0); /* 000000ff FRAG_COLOR_CLAMP_EN */
  3082. xf_emit(ctx, 1, 2); /* 00000003 REG_MODE */
  3083. xf_emit(ctx, 1, 0x11); /* 0000007f RT_FORMAT */
  3084. xf_emit(ctx, 7, 0); /* 0000007f RT_FORMAT */
  3085. xf_emit(ctx, 1, 0); /* 00000007 */
  3086. xf_emit(ctx, 1, 0xfac6881); /* 0fffffff RT_CONTROL */
  3087. xf_emit(ctx, 1, 0); /* 00000003 MULTISAMPLE_CTRL */
  3088. if (IS_NVA3F(dev_priv->chipset))
  3089. xf_emit(ctx, 1, 3); /* 00000003 tesla UNK16B4 */
  3090. xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
  3091. xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
  3092. xf_emit(ctx, 1, 0); /* 00000001 FRAMEBUFFER_SRGB */
  3093. xf_emit(ctx, 1, 4); /* ffffffff tesla UNK1400 */
  3094. xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
  3095. xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
  3096. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
  3097. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
  3098. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
  3099. xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
  3100. xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
  3101. xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
  3102. xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
  3103. if (IS_NVA3F(dev_priv->chipset)) {
  3104. xf_emit(ctx, 1, 0); /* 00000001 UNK12E4 */
  3105. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_RGB */
  3106. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_RGB */
  3107. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
  3108. xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_ALPHA */
  3109. xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_ALPHA */
  3110. xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
  3111. xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
  3112. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1928 */
  3113. xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
  3114. }
  3115. xf_emit(ctx, 1, 0); /* 00000003 tesla UNK0F90 */
  3116. xf_emit(ctx, 1, 4); /* 000000ff FP_RESULT_COUNT */
  3117. /* XXX: demagic this part some day */
  3118. if (dev_priv->chipset == 0x50)
  3119. xf_emit(ctx, 0x3a0, 0);
  3120. else if (dev_priv->chipset < 0x94)
  3121. xf_emit(ctx, 0x3a2, 0);
  3122. else if (dev_priv->chipset == 0x98 || dev_priv->chipset == 0xaa)
  3123. xf_emit(ctx, 0x39f, 0);
  3124. else
  3125. xf_emit(ctx, 0x3a3, 0);
  3126. xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
  3127. xf_emit(ctx, 1, 0); /* 7 OPERATION */
  3128. xf_emit(ctx, 1, 1); /* 1 DST_LINEAR */
  3129. xf_emit(ctx, 0x2d, 0);
  3130. }
  3131. static void
  3132. nv50_graph_construct_xfer2(struct nouveau_grctx *ctx)
  3133. {
  3134. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  3135. int i;
  3136. uint32_t offset;
  3137. uint32_t units = nv_rd32 (ctx->dev, 0x1540);
  3138. int size = 0;
  3139. offset = (ctx->ctxvals_pos+0x3f)&~0x3f;
  3140. if (dev_priv->chipset < 0xa0) {
  3141. for (i = 0; i < 8; i++) {
  3142. ctx->ctxvals_pos = offset + i;
  3143. /* that little bugger belongs to csched. No idea
  3144. * what it's doing here. */
  3145. if (i == 0)
  3146. xf_emit(ctx, 1, 0x08100c12); /* FP_INTERPOLANT_CTRL */
  3147. if (units & (1 << i))
  3148. nv50_graph_construct_xfer_mpc(ctx);
  3149. if ((ctx->ctxvals_pos-offset)/8 > size)
  3150. size = (ctx->ctxvals_pos-offset)/8;
  3151. }
  3152. } else {
  3153. /* Strand 0: TPs 0, 1 */
  3154. ctx->ctxvals_pos = offset;
  3155. /* that little bugger belongs to csched. No idea
  3156. * what it's doing here. */
  3157. xf_emit(ctx, 1, 0x08100c12); /* FP_INTERPOLANT_CTRL */
  3158. if (units & (1 << 0))
  3159. nv50_graph_construct_xfer_mpc(ctx);
  3160. if (units & (1 << 1))
  3161. nv50_graph_construct_xfer_mpc(ctx);
  3162. if ((ctx->ctxvals_pos-offset)/8 > size)
  3163. size = (ctx->ctxvals_pos-offset)/8;
  3164. /* Strand 1: TPs 2, 3 */
  3165. ctx->ctxvals_pos = offset + 1;
  3166. if (units & (1 << 2))
  3167. nv50_graph_construct_xfer_mpc(ctx);
  3168. if (units & (1 << 3))
  3169. nv50_graph_construct_xfer_mpc(ctx);
  3170. if ((ctx->ctxvals_pos-offset)/8 > size)
  3171. size = (ctx->ctxvals_pos-offset)/8;
  3172. /* Strand 2: TPs 4, 5, 6 */
  3173. ctx->ctxvals_pos = offset + 2;
  3174. if (units & (1 << 4))
  3175. nv50_graph_construct_xfer_mpc(ctx);
  3176. if (units & (1 << 5))
  3177. nv50_graph_construct_xfer_mpc(ctx);
  3178. if (units & (1 << 6))
  3179. nv50_graph_construct_xfer_mpc(ctx);
  3180. if ((ctx->ctxvals_pos-offset)/8 > size)
  3181. size = (ctx->ctxvals_pos-offset)/8;
  3182. /* Strand 3: TPs 7, 8, 9 */
  3183. ctx->ctxvals_pos = offset + 3;
  3184. if (units & (1 << 7))
  3185. nv50_graph_construct_xfer_mpc(ctx);
  3186. if (units & (1 << 8))
  3187. nv50_graph_construct_xfer_mpc(ctx);
  3188. if (units & (1 << 9))
  3189. nv50_graph_construct_xfer_mpc(ctx);
  3190. if ((ctx->ctxvals_pos-offset)/8 > size)
  3191. size = (ctx->ctxvals_pos-offset)/8;
  3192. }
  3193. ctx->ctxvals_pos = offset + size * 8;
  3194. ctx->ctxvals_pos = (ctx->ctxvals_pos+0x3f)&~0x3f;
  3195. cp_lsr (ctx, offset);
  3196. cp_out (ctx, CP_SET_XFER_POINTER);
  3197. cp_lsr (ctx, size);
  3198. cp_out (ctx, CP_SEEK_2);
  3199. cp_out (ctx, CP_XFER_2);
  3200. cp_wait(ctx, XFER, BUSY);
  3201. }