nv50_grctx.c 124 KB

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