nv50_grctx.c 125 KB

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