nv50_grctx.c 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367
  1. /*
  2. * Copyright 2009 Marcin Kościelnicki
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #define CP_FLAG_CLEAR 0
  23. #define CP_FLAG_SET 1
  24. #define CP_FLAG_SWAP_DIRECTION ((0 * 32) + 0)
  25. #define CP_FLAG_SWAP_DIRECTION_LOAD 0
  26. #define CP_FLAG_SWAP_DIRECTION_SAVE 1
  27. #define CP_FLAG_UNK01 ((0 * 32) + 1)
  28. #define CP_FLAG_UNK01_CLEAR 0
  29. #define CP_FLAG_UNK01_SET 1
  30. #define CP_FLAG_UNK03 ((0 * 32) + 3)
  31. #define CP_FLAG_UNK03_CLEAR 0
  32. #define CP_FLAG_UNK03_SET 1
  33. #define CP_FLAG_USER_SAVE ((0 * 32) + 5)
  34. #define CP_FLAG_USER_SAVE_NOT_PENDING 0
  35. #define CP_FLAG_USER_SAVE_PENDING 1
  36. #define CP_FLAG_USER_LOAD ((0 * 32) + 6)
  37. #define CP_FLAG_USER_LOAD_NOT_PENDING 0
  38. #define CP_FLAG_USER_LOAD_PENDING 1
  39. #define CP_FLAG_UNK0B ((0 * 32) + 0xb)
  40. #define CP_FLAG_UNK0B_CLEAR 0
  41. #define CP_FLAG_UNK0B_SET 1
  42. #define CP_FLAG_UNK1D ((0 * 32) + 0x1d)
  43. #define CP_FLAG_UNK1D_CLEAR 0
  44. #define CP_FLAG_UNK1D_SET 1
  45. #define CP_FLAG_UNK20 ((1 * 32) + 0)
  46. #define CP_FLAG_UNK20_CLEAR 0
  47. #define CP_FLAG_UNK20_SET 1
  48. #define CP_FLAG_STATUS ((2 * 32) + 0)
  49. #define CP_FLAG_STATUS_BUSY 0
  50. #define CP_FLAG_STATUS_IDLE 1
  51. #define CP_FLAG_AUTO_SAVE ((2 * 32) + 4)
  52. #define CP_FLAG_AUTO_SAVE_NOT_PENDING 0
  53. #define CP_FLAG_AUTO_SAVE_PENDING 1
  54. #define CP_FLAG_AUTO_LOAD ((2 * 32) + 5)
  55. #define CP_FLAG_AUTO_LOAD_NOT_PENDING 0
  56. #define CP_FLAG_AUTO_LOAD_PENDING 1
  57. #define CP_FLAG_XFER ((2 * 32) + 11)
  58. #define CP_FLAG_XFER_IDLE 0
  59. #define CP_FLAG_XFER_BUSY 1
  60. #define CP_FLAG_NEWCTX ((2 * 32) + 12)
  61. #define CP_FLAG_NEWCTX_BUSY 0
  62. #define CP_FLAG_NEWCTX_DONE 1
  63. #define CP_FLAG_ALWAYS ((2 * 32) + 13)
  64. #define CP_FLAG_ALWAYS_FALSE 0
  65. #define CP_FLAG_ALWAYS_TRUE 1
  66. #define CP_CTX 0x00100000
  67. #define CP_CTX_COUNT 0x000f0000
  68. #define CP_CTX_COUNT_SHIFT 16
  69. #define CP_CTX_REG 0x00003fff
  70. #define CP_LOAD_SR 0x00200000
  71. #define CP_LOAD_SR_VALUE 0x000fffff
  72. #define CP_BRA 0x00400000
  73. #define CP_BRA_IP 0x0001ff00
  74. #define CP_BRA_IP_SHIFT 8
  75. #define CP_BRA_IF_CLEAR 0x00000080
  76. #define CP_BRA_FLAG 0x0000007f
  77. #define CP_WAIT 0x00500000
  78. #define CP_WAIT_SET 0x00000080
  79. #define CP_WAIT_FLAG 0x0000007f
  80. #define CP_SET 0x00700000
  81. #define CP_SET_1 0x00000080
  82. #define CP_SET_FLAG 0x0000007f
  83. #define CP_NEWCTX 0x00600004
  84. #define CP_NEXT_TO_SWAP 0x00600005
  85. #define CP_SET_CONTEXT_POINTER 0x00600006
  86. #define CP_SET_XFER_POINTER 0x00600007
  87. #define CP_ENABLE 0x00600009
  88. #define CP_END 0x0060000c
  89. #define CP_NEXT_TO_CURRENT 0x0060000d
  90. #define CP_DISABLE1 0x0090ffff
  91. #define CP_DISABLE2 0x0091ffff
  92. #define CP_XFER_1 0x008000ff
  93. #define CP_XFER_2 0x008800ff
  94. #define CP_SEEK_1 0x00c000ff
  95. #define CP_SEEK_2 0x00c800ff
  96. #include "drmP.h"
  97. #include "nouveau_drv.h"
  98. #include "nouveau_grctx.h"
  99. /*
  100. * This code deals with PGRAPH contexts on NV50 family cards. Like NV40, it's
  101. * the GPU itself that does context-switching, but it needs a special
  102. * microcode to do it. And it's the driver's task to supply this microcode,
  103. * further known as ctxprog, as well as the initial context values, known
  104. * as ctxvals.
  105. *
  106. * Without ctxprog, you cannot switch contexts. Not even in software, since
  107. * the majority of context [xfer strands] isn't accessible directly. You're
  108. * stuck with a single channel, and you also suffer all the problems resulting
  109. * from missing ctxvals, since you cannot load them.
  110. *
  111. * Without ctxvals, you're stuck with PGRAPH's default context. It's enough to
  112. * run 2d operations, but trying to utilise 3d or CUDA will just lock you up,
  113. * since you don't have... some sort of needed setup.
  114. *
  115. * Nouveau will just disable acceleration if not given ctxprog + ctxvals, since
  116. * it's too much hassle to handle no-ctxprog as a special case.
  117. */
  118. /*
  119. * How ctxprogs work.
  120. *
  121. * The ctxprog is written in its own kind of microcode, with very small and
  122. * crappy set of available commands. You upload it to a small [512 insns]
  123. * area of memory on PGRAPH, and it'll be run when PFIFO wants PGRAPH to
  124. * switch channel. or when the driver explicitely requests it. Stuff visible
  125. * to ctxprog consists of: PGRAPH MMIO registers, PGRAPH context strands,
  126. * the per-channel context save area in VRAM [known as ctxvals or grctx],
  127. * 4 flags registers, a scratch register, two grctx pointers, plus many
  128. * random poorly-understood details.
  129. *
  130. * When ctxprog runs, it's supposed to check what operations are asked of it,
  131. * save old context if requested, optionally reset PGRAPH and switch to the
  132. * new channel, and load the new context. Context consists of three major
  133. * parts: subset of MMIO registers and two "xfer areas".
  134. */
  135. /* TODO:
  136. * - document unimplemented bits compared to nvidia
  137. * - NVAx: make a TP subroutine, use it.
  138. * - use 0x4008fc instead of 0x1540?
  139. */
  140. enum cp_label {
  141. cp_check_load = 1,
  142. cp_setup_auto_load,
  143. cp_setup_load,
  144. cp_setup_save,
  145. cp_swap_state,
  146. cp_prepare_exit,
  147. cp_exit,
  148. };
  149. static void nv50_graph_construct_mmio(struct nouveau_grctx *ctx);
  150. static void nv50_graph_construct_xfer1(struct nouveau_grctx *ctx);
  151. static void nv50_graph_construct_xfer2(struct nouveau_grctx *ctx);
  152. /* Main function: construct the ctxprog skeleton, call the other functions. */
  153. int
  154. nv50_grctx_init(struct nouveau_grctx *ctx)
  155. {
  156. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  157. switch (dev_priv->chipset) {
  158. case 0x50:
  159. case 0x84:
  160. case 0x86:
  161. case 0x92:
  162. case 0x94:
  163. case 0x96:
  164. case 0x98:
  165. case 0xa0:
  166. case 0xa5:
  167. case 0xa8:
  168. case 0xaa:
  169. case 0xac:
  170. break;
  171. default:
  172. NV_ERROR(ctx->dev, "I don't know how to make a ctxprog for "
  173. "your NV%x card.\n", dev_priv->chipset);
  174. NV_ERROR(ctx->dev, "Disabling acceleration. Please contact "
  175. "the devs.\n");
  176. return -ENOSYS;
  177. }
  178. /* decide whether we're loading/unloading the context */
  179. cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save);
  180. cp_bra (ctx, USER_SAVE, PENDING, cp_setup_save);
  181. cp_name(ctx, cp_check_load);
  182. cp_bra (ctx, AUTO_LOAD, PENDING, cp_setup_auto_load);
  183. cp_bra (ctx, USER_LOAD, PENDING, cp_setup_load);
  184. cp_bra (ctx, ALWAYS, TRUE, cp_exit);
  185. /* setup for context load */
  186. cp_name(ctx, cp_setup_auto_load);
  187. cp_out (ctx, CP_DISABLE1);
  188. cp_out (ctx, CP_DISABLE2);
  189. cp_out (ctx, CP_ENABLE);
  190. cp_out (ctx, CP_NEXT_TO_SWAP);
  191. cp_set (ctx, UNK01, SET);
  192. cp_name(ctx, cp_setup_load);
  193. cp_out (ctx, CP_NEWCTX);
  194. cp_wait(ctx, NEWCTX, BUSY);
  195. cp_set (ctx, UNK1D, CLEAR);
  196. cp_set (ctx, SWAP_DIRECTION, LOAD);
  197. cp_bra (ctx, UNK0B, SET, cp_prepare_exit);
  198. cp_bra (ctx, ALWAYS, TRUE, cp_swap_state);
  199. /* setup for context save */
  200. cp_name(ctx, cp_setup_save);
  201. cp_set (ctx, UNK1D, SET);
  202. cp_wait(ctx, STATUS, BUSY);
  203. cp_set (ctx, UNK01, SET);
  204. cp_set (ctx, SWAP_DIRECTION, SAVE);
  205. /* general PGRAPH state */
  206. cp_name(ctx, cp_swap_state);
  207. cp_set (ctx, UNK03, SET);
  208. cp_pos (ctx, 0x00004/4);
  209. cp_ctx (ctx, 0x400828, 1); /* needed. otherwise, flickering happens. */
  210. cp_pos (ctx, 0x00100/4);
  211. nv50_graph_construct_mmio(ctx);
  212. nv50_graph_construct_xfer1(ctx);
  213. nv50_graph_construct_xfer2(ctx);
  214. cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_check_load);
  215. cp_set (ctx, UNK20, SET);
  216. cp_set (ctx, SWAP_DIRECTION, SAVE); /* no idea why this is needed, but fixes at least one lockup. */
  217. cp_lsr (ctx, ctx->ctxvals_base);
  218. cp_out (ctx, CP_SET_XFER_POINTER);
  219. cp_lsr (ctx, 4);
  220. cp_out (ctx, CP_SEEK_1);
  221. cp_out (ctx, CP_XFER_1);
  222. cp_wait(ctx, XFER, BUSY);
  223. /* pre-exit state updates */
  224. cp_name(ctx, cp_prepare_exit);
  225. cp_set (ctx, UNK01, CLEAR);
  226. cp_set (ctx, UNK03, CLEAR);
  227. cp_set (ctx, UNK1D, CLEAR);
  228. cp_bra (ctx, USER_SAVE, PENDING, cp_exit);
  229. cp_out (ctx, CP_NEXT_TO_CURRENT);
  230. cp_name(ctx, cp_exit);
  231. cp_set (ctx, USER_SAVE, NOT_PENDING);
  232. cp_set (ctx, USER_LOAD, NOT_PENDING);
  233. cp_out (ctx, CP_END);
  234. ctx->ctxvals_pos += 0x400; /* padding... no idea why you need it */
  235. return 0;
  236. }
  237. /*
  238. * Constructs MMIO part of ctxprog and ctxvals. Just a matter of knowing which
  239. * registers to save/restore and the default values for them.
  240. */
  241. static void
  242. nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
  243. {
  244. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  245. int i, j;
  246. int offset, base;
  247. uint32_t units = nv_rd32 (ctx->dev, 0x1540);
  248. /* 0800 */
  249. cp_ctx(ctx, 0x400808, 7);
  250. gr_def(ctx, 0x400814, 0x00000030);
  251. cp_ctx(ctx, 0x400834, 0x32);
  252. if (dev_priv->chipset == 0x50) {
  253. gr_def(ctx, 0x400834, 0xff400040);
  254. gr_def(ctx, 0x400838, 0xfff00080);
  255. gr_def(ctx, 0x40083c, 0xfff70090);
  256. gr_def(ctx, 0x400840, 0xffe806a8);
  257. }
  258. gr_def(ctx, 0x400844, 0x00000002);
  259. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  260. gr_def(ctx, 0x400894, 0x00001000);
  261. gr_def(ctx, 0x4008e8, 0x00000003);
  262. gr_def(ctx, 0x4008ec, 0x00001000);
  263. if (dev_priv->chipset == 0x50)
  264. cp_ctx(ctx, 0x400908, 0xb);
  265. else if (dev_priv->chipset < 0xa0)
  266. cp_ctx(ctx, 0x400908, 0xc);
  267. else
  268. cp_ctx(ctx, 0x400908, 0xe);
  269. if (dev_priv->chipset >= 0xa0)
  270. cp_ctx(ctx, 0x400b00, 0x1);
  271. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  272. cp_ctx(ctx, 0x400b10, 0x1);
  273. gr_def(ctx, 0x400b10, 0x0001629d);
  274. cp_ctx(ctx, 0x400b20, 0x1);
  275. gr_def(ctx, 0x400b20, 0x0001629d);
  276. }
  277. /* 0C00 */
  278. cp_ctx(ctx, 0x400c08, 0x2);
  279. gr_def(ctx, 0x400c08, 0x0000fe0c);
  280. /* 1000 */
  281. if (dev_priv->chipset < 0xa0) {
  282. cp_ctx(ctx, 0x401008, 0x4);
  283. gr_def(ctx, 0x401014, 0x00001000);
  284. } else if (dev_priv->chipset == 0xa0 || dev_priv->chipset >= 0xaa) {
  285. cp_ctx(ctx, 0x401008, 0x5);
  286. gr_def(ctx, 0x401018, 0x00001000);
  287. } else {
  288. cp_ctx(ctx, 0x401008, 0x5);
  289. gr_def(ctx, 0x401018, 0x00004000);
  290. }
  291. /* 1400 */
  292. cp_ctx(ctx, 0x401400, 0x8);
  293. cp_ctx(ctx, 0x401424, 0x3);
  294. if (dev_priv->chipset == 0x50)
  295. gr_def(ctx, 0x40142c, 0x0001fd87);
  296. else
  297. gr_def(ctx, 0x40142c, 0x00000187);
  298. cp_ctx(ctx, 0x401540, 0x5);
  299. gr_def(ctx, 0x401550, 0x00001018);
  300. /* 1800 */
  301. cp_ctx(ctx, 0x401814, 0x1);
  302. gr_def(ctx, 0x401814, 0x000000ff);
  303. if (dev_priv->chipset == 0x50) {
  304. cp_ctx(ctx, 0x40181c, 0xe);
  305. gr_def(ctx, 0x401850, 0x00000004);
  306. } else if (dev_priv->chipset < 0xa0) {
  307. cp_ctx(ctx, 0x40181c, 0xf);
  308. gr_def(ctx, 0x401854, 0x00000004);
  309. } else {
  310. cp_ctx(ctx, 0x40181c, 0x13);
  311. gr_def(ctx, 0x401864, 0x00000004);
  312. }
  313. /* 1C00 */
  314. cp_ctx(ctx, 0x401c00, 0x1);
  315. switch (dev_priv->chipset) {
  316. case 0x50:
  317. gr_def(ctx, 0x401c00, 0x0001005f);
  318. break;
  319. case 0x84:
  320. case 0x86:
  321. case 0x94:
  322. gr_def(ctx, 0x401c00, 0x044d00df);
  323. break;
  324. case 0x92:
  325. case 0x96:
  326. case 0x98:
  327. case 0xa0:
  328. case 0xaa:
  329. case 0xac:
  330. gr_def(ctx, 0x401c00, 0x042500df);
  331. break;
  332. case 0xa5:
  333. case 0xa8:
  334. gr_def(ctx, 0x401c00, 0x142500df);
  335. break;
  336. }
  337. /* 2400 */
  338. cp_ctx(ctx, 0x402400, 0x1);
  339. if (dev_priv->chipset == 0x50)
  340. cp_ctx(ctx, 0x402408, 0x1);
  341. else
  342. cp_ctx(ctx, 0x402408, 0x2);
  343. gr_def(ctx, 0x402408, 0x00000600);
  344. /* 2800 */
  345. cp_ctx(ctx, 0x402800, 0x1);
  346. if (dev_priv->chipset == 0x50)
  347. gr_def(ctx, 0x402800, 0x00000006);
  348. /* 2C00 */
  349. cp_ctx(ctx, 0x402c08, 0x6);
  350. if (dev_priv->chipset != 0x50)
  351. gr_def(ctx, 0x402c14, 0x01000000);
  352. gr_def(ctx, 0x402c18, 0x000000ff);
  353. if (dev_priv->chipset == 0x50)
  354. cp_ctx(ctx, 0x402ca0, 0x1);
  355. else
  356. cp_ctx(ctx, 0x402ca0, 0x2);
  357. if (dev_priv->chipset < 0xa0)
  358. gr_def(ctx, 0x402ca0, 0x00000400);
  359. else if (dev_priv->chipset == 0xa0 || dev_priv->chipset >= 0xaa)
  360. gr_def(ctx, 0x402ca0, 0x00000800);
  361. else
  362. gr_def(ctx, 0x402ca0, 0x00000400);
  363. cp_ctx(ctx, 0x402cac, 0x4);
  364. /* 3000 */
  365. cp_ctx(ctx, 0x403004, 0x1);
  366. gr_def(ctx, 0x403004, 0x00000001);
  367. /* 3404 */
  368. if (dev_priv->chipset >= 0xa0) {
  369. cp_ctx(ctx, 0x403404, 0x1);
  370. gr_def(ctx, 0x403404, 0x00000001);
  371. }
  372. /* 5000 */
  373. cp_ctx(ctx, 0x405000, 0x1);
  374. switch (dev_priv->chipset) {
  375. case 0x50:
  376. gr_def(ctx, 0x405000, 0x00300080);
  377. break;
  378. case 0x84:
  379. case 0xa0:
  380. case 0xa5:
  381. case 0xa8:
  382. case 0xaa:
  383. case 0xac:
  384. gr_def(ctx, 0x405000, 0x000e0080);
  385. break;
  386. case 0x86:
  387. case 0x92:
  388. case 0x94:
  389. case 0x96:
  390. case 0x98:
  391. gr_def(ctx, 0x405000, 0x00000080);
  392. break;
  393. }
  394. cp_ctx(ctx, 0x405014, 0x1);
  395. gr_def(ctx, 0x405014, 0x00000004);
  396. cp_ctx(ctx, 0x40501c, 0x1);
  397. cp_ctx(ctx, 0x405024, 0x1);
  398. cp_ctx(ctx, 0x40502c, 0x1);
  399. /* 5400 or maybe 4800 */
  400. if (dev_priv->chipset == 0x50) {
  401. offset = 0x405400;
  402. cp_ctx(ctx, 0x405400, 0xea);
  403. } else if (dev_priv->chipset < 0x94) {
  404. offset = 0x405400;
  405. cp_ctx(ctx, 0x405400, 0xcb);
  406. } else if (dev_priv->chipset < 0xa0) {
  407. offset = 0x405400;
  408. cp_ctx(ctx, 0x405400, 0xcc);
  409. } else if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  410. offset = 0x404800;
  411. cp_ctx(ctx, 0x404800, 0xda);
  412. } else {
  413. offset = 0x405400;
  414. cp_ctx(ctx, 0x405400, 0xd4);
  415. }
  416. gr_def(ctx, offset + 0x0c, 0x00000002);
  417. gr_def(ctx, offset + 0x10, 0x00000001);
  418. if (dev_priv->chipset >= 0x94)
  419. offset += 4;
  420. gr_def(ctx, offset + 0x1c, 0x00000001);
  421. gr_def(ctx, offset + 0x20, 0x00000100);
  422. gr_def(ctx, offset + 0x38, 0x00000002);
  423. gr_def(ctx, offset + 0x3c, 0x00000001);
  424. gr_def(ctx, offset + 0x40, 0x00000001);
  425. gr_def(ctx, offset + 0x50, 0x00000001);
  426. gr_def(ctx, offset + 0x54, 0x003fffff);
  427. gr_def(ctx, offset + 0x58, 0x00001fff);
  428. gr_def(ctx, offset + 0x60, 0x00000001);
  429. gr_def(ctx, offset + 0x64, 0x00000001);
  430. gr_def(ctx, offset + 0x6c, 0x00000001);
  431. gr_def(ctx, offset + 0x70, 0x00000001);
  432. gr_def(ctx, offset + 0x74, 0x00000001);
  433. gr_def(ctx, offset + 0x78, 0x00000004);
  434. gr_def(ctx, offset + 0x7c, 0x00000001);
  435. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  436. offset += 4;
  437. gr_def(ctx, offset + 0x80, 0x00000001);
  438. gr_def(ctx, offset + 0x84, 0x00000001);
  439. gr_def(ctx, offset + 0x88, 0x00000007);
  440. gr_def(ctx, offset + 0x8c, 0x00000001);
  441. gr_def(ctx, offset + 0x90, 0x00000007);
  442. gr_def(ctx, offset + 0x94, 0x00000001);
  443. gr_def(ctx, offset + 0x98, 0x00000001);
  444. gr_def(ctx, offset + 0x9c, 0x00000001);
  445. if (dev_priv->chipset == 0x50) {
  446. gr_def(ctx, offset + 0xb0, 0x00000001);
  447. gr_def(ctx, offset + 0xb4, 0x00000001);
  448. gr_def(ctx, offset + 0xbc, 0x00000001);
  449. gr_def(ctx, offset + 0xc0, 0x0000000a);
  450. gr_def(ctx, offset + 0xd0, 0x00000040);
  451. gr_def(ctx, offset + 0xd8, 0x00000002);
  452. gr_def(ctx, offset + 0xdc, 0x00000100);
  453. gr_def(ctx, offset + 0xe0, 0x00000001);
  454. gr_def(ctx, offset + 0xe4, 0x00000100);
  455. gr_def(ctx, offset + 0x100, 0x00000001);
  456. gr_def(ctx, offset + 0x124, 0x00000004);
  457. gr_def(ctx, offset + 0x13c, 0x00000001);
  458. gr_def(ctx, offset + 0x140, 0x00000100);
  459. gr_def(ctx, offset + 0x148, 0x00000001);
  460. gr_def(ctx, offset + 0x154, 0x00000100);
  461. gr_def(ctx, offset + 0x158, 0x00000001);
  462. gr_def(ctx, offset + 0x15c, 0x00000100);
  463. gr_def(ctx, offset + 0x164, 0x00000001);
  464. gr_def(ctx, offset + 0x170, 0x00000100);
  465. gr_def(ctx, offset + 0x174, 0x00000001);
  466. gr_def(ctx, offset + 0x17c, 0x00000001);
  467. gr_def(ctx, offset + 0x188, 0x00000002);
  468. gr_def(ctx, offset + 0x190, 0x00000001);
  469. gr_def(ctx, offset + 0x198, 0x00000001);
  470. gr_def(ctx, offset + 0x1ac, 0x00000003);
  471. offset += 0xd0;
  472. } else {
  473. gr_def(ctx, offset + 0xb0, 0x00000001);
  474. gr_def(ctx, offset + 0xb4, 0x00000100);
  475. gr_def(ctx, offset + 0xbc, 0x00000001);
  476. gr_def(ctx, offset + 0xc8, 0x00000100);
  477. gr_def(ctx, offset + 0xcc, 0x00000001);
  478. gr_def(ctx, offset + 0xd0, 0x00000100);
  479. gr_def(ctx, offset + 0xd8, 0x00000001);
  480. gr_def(ctx, offset + 0xe4, 0x00000100);
  481. }
  482. gr_def(ctx, offset + 0xf8, 0x00000004);
  483. gr_def(ctx, offset + 0xfc, 0x00000070);
  484. gr_def(ctx, offset + 0x100, 0x00000080);
  485. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  486. offset += 4;
  487. gr_def(ctx, offset + 0x114, 0x0000000c);
  488. if (dev_priv->chipset == 0x50)
  489. offset -= 4;
  490. gr_def(ctx, offset + 0x11c, 0x00000008);
  491. gr_def(ctx, offset + 0x120, 0x00000014);
  492. if (dev_priv->chipset == 0x50) {
  493. gr_def(ctx, offset + 0x124, 0x00000026);
  494. offset -= 0x18;
  495. } else {
  496. gr_def(ctx, offset + 0x128, 0x00000029);
  497. gr_def(ctx, offset + 0x12c, 0x00000027);
  498. gr_def(ctx, offset + 0x130, 0x00000026);
  499. gr_def(ctx, offset + 0x134, 0x00000008);
  500. gr_def(ctx, offset + 0x138, 0x00000004);
  501. gr_def(ctx, offset + 0x13c, 0x00000027);
  502. }
  503. gr_def(ctx, offset + 0x148, 0x00000001);
  504. gr_def(ctx, offset + 0x14c, 0x00000002);
  505. gr_def(ctx, offset + 0x150, 0x00000003);
  506. gr_def(ctx, offset + 0x154, 0x00000004);
  507. gr_def(ctx, offset + 0x158, 0x00000005);
  508. gr_def(ctx, offset + 0x15c, 0x00000006);
  509. gr_def(ctx, offset + 0x160, 0x00000007);
  510. gr_def(ctx, offset + 0x164, 0x00000001);
  511. gr_def(ctx, offset + 0x1a8, 0x000000cf);
  512. if (dev_priv->chipset == 0x50)
  513. offset -= 4;
  514. gr_def(ctx, offset + 0x1d8, 0x00000080);
  515. gr_def(ctx, offset + 0x1dc, 0x00000004);
  516. gr_def(ctx, offset + 0x1e0, 0x00000004);
  517. if (dev_priv->chipset == 0x50)
  518. offset -= 4;
  519. else
  520. gr_def(ctx, offset + 0x1e4, 0x00000003);
  521. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  522. gr_def(ctx, offset + 0x1ec, 0x00000003);
  523. offset += 8;
  524. }
  525. gr_def(ctx, offset + 0x1e8, 0x00000001);
  526. if (dev_priv->chipset == 0x50)
  527. offset -= 4;
  528. gr_def(ctx, offset + 0x1f4, 0x00000012);
  529. gr_def(ctx, offset + 0x1f8, 0x00000010);
  530. gr_def(ctx, offset + 0x1fc, 0x0000000c);
  531. gr_def(ctx, offset + 0x200, 0x00000001);
  532. gr_def(ctx, offset + 0x210, 0x00000004);
  533. gr_def(ctx, offset + 0x214, 0x00000002);
  534. gr_def(ctx, offset + 0x218, 0x00000004);
  535. if (dev_priv->chipset >= 0xa0)
  536. offset += 4;
  537. gr_def(ctx, offset + 0x224, 0x003fffff);
  538. gr_def(ctx, offset + 0x228, 0x00001fff);
  539. if (dev_priv->chipset == 0x50)
  540. offset -= 0x20;
  541. else if (dev_priv->chipset >= 0xa0) {
  542. gr_def(ctx, offset + 0x250, 0x00000001);
  543. gr_def(ctx, offset + 0x254, 0x00000001);
  544. gr_def(ctx, offset + 0x258, 0x00000002);
  545. offset += 0x10;
  546. }
  547. gr_def(ctx, offset + 0x250, 0x00000004);
  548. gr_def(ctx, offset + 0x254, 0x00000014);
  549. gr_def(ctx, offset + 0x258, 0x00000001);
  550. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  551. offset += 4;
  552. gr_def(ctx, offset + 0x264, 0x00000002);
  553. if (dev_priv->chipset >= 0xa0)
  554. offset += 8;
  555. gr_def(ctx, offset + 0x270, 0x00000001);
  556. gr_def(ctx, offset + 0x278, 0x00000002);
  557. gr_def(ctx, offset + 0x27c, 0x00001000);
  558. if (dev_priv->chipset == 0x50)
  559. offset -= 0xc;
  560. else {
  561. gr_def(ctx, offset + 0x280, 0x00000e00);
  562. gr_def(ctx, offset + 0x284, 0x00001000);
  563. gr_def(ctx, offset + 0x288, 0x00001e00);
  564. }
  565. gr_def(ctx, offset + 0x290, 0x00000001);
  566. gr_def(ctx, offset + 0x294, 0x00000001);
  567. gr_def(ctx, offset + 0x298, 0x00000001);
  568. gr_def(ctx, offset + 0x29c, 0x00000001);
  569. gr_def(ctx, offset + 0x2a0, 0x00000001);
  570. gr_def(ctx, offset + 0x2b0, 0x00000200);
  571. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  572. gr_def(ctx, offset + 0x2b4, 0x00000200);
  573. offset += 4;
  574. }
  575. if (dev_priv->chipset < 0xa0) {
  576. gr_def(ctx, offset + 0x2b8, 0x00000001);
  577. gr_def(ctx, offset + 0x2bc, 0x00000070);
  578. gr_def(ctx, offset + 0x2c0, 0x00000080);
  579. gr_def(ctx, offset + 0x2cc, 0x00000001);
  580. gr_def(ctx, offset + 0x2d0, 0x00000070);
  581. gr_def(ctx, offset + 0x2d4, 0x00000080);
  582. } else {
  583. gr_def(ctx, offset + 0x2b8, 0x00000001);
  584. gr_def(ctx, offset + 0x2bc, 0x000000f0);
  585. gr_def(ctx, offset + 0x2c0, 0x000000ff);
  586. gr_def(ctx, offset + 0x2cc, 0x00000001);
  587. gr_def(ctx, offset + 0x2d0, 0x000000f0);
  588. gr_def(ctx, offset + 0x2d4, 0x000000ff);
  589. gr_def(ctx, offset + 0x2dc, 0x00000009);
  590. offset += 4;
  591. }
  592. gr_def(ctx, offset + 0x2e4, 0x00000001);
  593. gr_def(ctx, offset + 0x2e8, 0x000000cf);
  594. gr_def(ctx, offset + 0x2f0, 0x00000001);
  595. gr_def(ctx, offset + 0x300, 0x000000cf);
  596. gr_def(ctx, offset + 0x308, 0x00000002);
  597. gr_def(ctx, offset + 0x310, 0x00000001);
  598. gr_def(ctx, offset + 0x318, 0x00000001);
  599. gr_def(ctx, offset + 0x320, 0x000000cf);
  600. gr_def(ctx, offset + 0x324, 0x000000cf);
  601. gr_def(ctx, offset + 0x328, 0x00000001);
  602. /* 6000? */
  603. if (dev_priv->chipset == 0x50)
  604. cp_ctx(ctx, 0x4063e0, 0x1);
  605. /* 6800 */
  606. if (dev_priv->chipset < 0x90) {
  607. cp_ctx(ctx, 0x406814, 0x2b);
  608. gr_def(ctx, 0x406818, 0x00000f80);
  609. gr_def(ctx, 0x406860, 0x007f0080);
  610. gr_def(ctx, 0x40689c, 0x007f0080);
  611. } else {
  612. cp_ctx(ctx, 0x406814, 0x4);
  613. if (dev_priv->chipset == 0x98)
  614. gr_def(ctx, 0x406818, 0x00000f80);
  615. else
  616. gr_def(ctx, 0x406818, 0x00001f80);
  617. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  618. gr_def(ctx, 0x40681c, 0x00000030);
  619. cp_ctx(ctx, 0x406830, 0x3);
  620. }
  621. /* 7000: per-ROP group state */
  622. for (i = 0; i < 8; i++) {
  623. if (units & (1<<(i+16))) {
  624. cp_ctx(ctx, 0x407000 + (i<<8), 3);
  625. if (dev_priv->chipset == 0x50)
  626. gr_def(ctx, 0x407000 + (i<<8), 0x1b74f820);
  627. else if (dev_priv->chipset != 0xa5)
  628. gr_def(ctx, 0x407000 + (i<<8), 0x3b74f821);
  629. else
  630. gr_def(ctx, 0x407000 + (i<<8), 0x7b74f821);
  631. gr_def(ctx, 0x407004 + (i<<8), 0x89058001);
  632. if (dev_priv->chipset == 0x50) {
  633. cp_ctx(ctx, 0x407010 + (i<<8), 1);
  634. } else if (dev_priv->chipset < 0xa0) {
  635. cp_ctx(ctx, 0x407010 + (i<<8), 2);
  636. gr_def(ctx, 0x407010 + (i<<8), 0x00001000);
  637. gr_def(ctx, 0x407014 + (i<<8), 0x0000001f);
  638. } else {
  639. cp_ctx(ctx, 0x407010 + (i<<8), 3);
  640. gr_def(ctx, 0x407010 + (i<<8), 0x00001000);
  641. if (dev_priv->chipset != 0xa5)
  642. gr_def(ctx, 0x407014 + (i<<8), 0x000000ff);
  643. else
  644. gr_def(ctx, 0x407014 + (i<<8), 0x000001ff);
  645. }
  646. cp_ctx(ctx, 0x407080 + (i<<8), 4);
  647. if (dev_priv->chipset != 0xa5)
  648. gr_def(ctx, 0x407080 + (i<<8), 0x027c10fa);
  649. else
  650. gr_def(ctx, 0x407080 + (i<<8), 0x827c10fa);
  651. if (dev_priv->chipset == 0x50)
  652. gr_def(ctx, 0x407084 + (i<<8), 0x000000c0);
  653. else
  654. gr_def(ctx, 0x407084 + (i<<8), 0x400000c0);
  655. gr_def(ctx, 0x407088 + (i<<8), 0xb7892080);
  656. if (dev_priv->chipset < 0xa0)
  657. cp_ctx(ctx, 0x407094 + (i<<8), 1);
  658. else if (dev_priv->chipset <= 0xa0 || dev_priv->chipset >= 0xaa)
  659. cp_ctx(ctx, 0x407094 + (i<<8), 3);
  660. else {
  661. cp_ctx(ctx, 0x407094 + (i<<8), 4);
  662. gr_def(ctx, 0x4070a0 + (i<<8), 1);
  663. }
  664. }
  665. }
  666. cp_ctx(ctx, 0x407c00, 0x3);
  667. if (dev_priv->chipset < 0x90)
  668. gr_def(ctx, 0x407c00, 0x00010040);
  669. else if (dev_priv->chipset < 0xa0)
  670. gr_def(ctx, 0x407c00, 0x00390040);
  671. else
  672. gr_def(ctx, 0x407c00, 0x003d0040);
  673. gr_def(ctx, 0x407c08, 0x00000022);
  674. if (dev_priv->chipset >= 0xa0) {
  675. cp_ctx(ctx, 0x407c10, 0x3);
  676. cp_ctx(ctx, 0x407c20, 0x1);
  677. cp_ctx(ctx, 0x407c2c, 0x1);
  678. }
  679. if (dev_priv->chipset < 0xa0) {
  680. cp_ctx(ctx, 0x407d00, 0x9);
  681. } else {
  682. cp_ctx(ctx, 0x407d00, 0x15);
  683. }
  684. if (dev_priv->chipset == 0x98)
  685. gr_def(ctx, 0x407d08, 0x00380040);
  686. else {
  687. if (dev_priv->chipset < 0x90)
  688. gr_def(ctx, 0x407d08, 0x00010040);
  689. else if (dev_priv->chipset < 0xa0)
  690. gr_def(ctx, 0x407d08, 0x00390040);
  691. else
  692. gr_def(ctx, 0x407d08, 0x003d0040);
  693. gr_def(ctx, 0x407d0c, 0x00000022);
  694. }
  695. /* 8000+: per-TP state */
  696. for (i = 0; i < 10; i++) {
  697. if (units & (1<<i)) {
  698. if (dev_priv->chipset < 0xa0)
  699. base = 0x408000 + (i<<12);
  700. else
  701. base = 0x408000 + (i<<11);
  702. if (dev_priv->chipset < 0xa0)
  703. offset = base + 0xc00;
  704. else
  705. offset = base + 0x80;
  706. cp_ctx(ctx, offset + 0x00, 1);
  707. gr_def(ctx, offset + 0x00, 0x0000ff0a);
  708. cp_ctx(ctx, offset + 0x08, 1);
  709. /* per-MP state */
  710. for (j = 0; j < (dev_priv->chipset < 0xa0 ? 2 : 4); j++) {
  711. if (!(units & (1 << (j+24)))) continue;
  712. if (dev_priv->chipset < 0xa0)
  713. offset = base + 0x200 + (j<<7);
  714. else
  715. offset = base + 0x100 + (j<<7);
  716. cp_ctx(ctx, offset, 0x20);
  717. gr_def(ctx, offset + 0x00, 0x01800000);
  718. gr_def(ctx, offset + 0x04, 0x00160000);
  719. gr_def(ctx, offset + 0x08, 0x01800000);
  720. gr_def(ctx, offset + 0x18, 0x0003ffff);
  721. switch (dev_priv->chipset) {
  722. case 0x50:
  723. gr_def(ctx, offset + 0x1c, 0x00080000);
  724. break;
  725. case 0x84:
  726. gr_def(ctx, offset + 0x1c, 0x00880000);
  727. break;
  728. case 0x86:
  729. gr_def(ctx, offset + 0x1c, 0x008c0000);
  730. break;
  731. case 0x92:
  732. case 0x96:
  733. case 0x98:
  734. gr_def(ctx, offset + 0x1c, 0x118c0000);
  735. break;
  736. case 0x94:
  737. gr_def(ctx, offset + 0x1c, 0x10880000);
  738. break;
  739. case 0xa0:
  740. case 0xa5:
  741. gr_def(ctx, offset + 0x1c, 0x310c0000);
  742. break;
  743. case 0xa8:
  744. case 0xaa:
  745. case 0xac:
  746. gr_def(ctx, offset + 0x1c, 0x300c0000);
  747. break;
  748. }
  749. gr_def(ctx, offset + 0x40, 0x00010401);
  750. if (dev_priv->chipset == 0x50)
  751. gr_def(ctx, offset + 0x48, 0x00000040);
  752. else
  753. gr_def(ctx, offset + 0x48, 0x00000078);
  754. gr_def(ctx, offset + 0x50, 0x000000bf);
  755. gr_def(ctx, offset + 0x58, 0x00001210);
  756. if (dev_priv->chipset == 0x50)
  757. gr_def(ctx, offset + 0x5c, 0x00000080);
  758. else
  759. gr_def(ctx, offset + 0x5c, 0x08000080);
  760. if (dev_priv->chipset >= 0xa0)
  761. gr_def(ctx, offset + 0x68, 0x0000003e);
  762. }
  763. if (dev_priv->chipset < 0xa0)
  764. cp_ctx(ctx, base + 0x300, 0x4);
  765. else
  766. cp_ctx(ctx, base + 0x300, 0x5);
  767. if (dev_priv->chipset == 0x50)
  768. gr_def(ctx, base + 0x304, 0x00007070);
  769. else if (dev_priv->chipset < 0xa0)
  770. gr_def(ctx, base + 0x304, 0x00027070);
  771. else if (dev_priv->chipset <= 0xa0 || dev_priv->chipset >= 0xaa)
  772. gr_def(ctx, base + 0x304, 0x01127070);
  773. else
  774. gr_def(ctx, base + 0x304, 0x05127070);
  775. if (dev_priv->chipset < 0xa0)
  776. cp_ctx(ctx, base + 0x318, 1);
  777. else
  778. cp_ctx(ctx, base + 0x320, 1);
  779. if (dev_priv->chipset == 0x50)
  780. gr_def(ctx, base + 0x318, 0x0003ffff);
  781. else if (dev_priv->chipset < 0xa0)
  782. gr_def(ctx, base + 0x318, 0x03ffffff);
  783. else
  784. gr_def(ctx, base + 0x320, 0x07ffffff);
  785. if (dev_priv->chipset < 0xa0)
  786. cp_ctx(ctx, base + 0x324, 5);
  787. else
  788. cp_ctx(ctx, base + 0x328, 4);
  789. if (dev_priv->chipset < 0xa0) {
  790. cp_ctx(ctx, base + 0x340, 9);
  791. offset = base + 0x340;
  792. } else if (dev_priv->chipset <= 0xa0 || dev_priv->chipset >= 0xaa) {
  793. cp_ctx(ctx, base + 0x33c, 0xb);
  794. offset = base + 0x344;
  795. } else {
  796. cp_ctx(ctx, base + 0x33c, 0xd);
  797. offset = base + 0x344;
  798. }
  799. gr_def(ctx, offset + 0x0, 0x00120407);
  800. gr_def(ctx, offset + 0x4, 0x05091507);
  801. if (dev_priv->chipset == 0x84)
  802. gr_def(ctx, offset + 0x8, 0x05100202);
  803. else
  804. gr_def(ctx, offset + 0x8, 0x05010202);
  805. gr_def(ctx, offset + 0xc, 0x00030201);
  806. cp_ctx(ctx, base + 0x400, 2);
  807. gr_def(ctx, base + 0x404, 0x00000040);
  808. cp_ctx(ctx, base + 0x40c, 2);
  809. gr_def(ctx, base + 0x40c, 0x0d0c0b0a);
  810. gr_def(ctx, base + 0x410, 0x00141210);
  811. if (dev_priv->chipset < 0xa0)
  812. offset = base + 0x800;
  813. else
  814. offset = base + 0x500;
  815. cp_ctx(ctx, offset, 6);
  816. gr_def(ctx, offset + 0x0, 0x000001f0);
  817. gr_def(ctx, offset + 0x4, 0x00000001);
  818. gr_def(ctx, offset + 0x8, 0x00000003);
  819. if (dev_priv->chipset == 0x50 || dev_priv->chipset >= 0xaa)
  820. gr_def(ctx, offset + 0xc, 0x00008000);
  821. gr_def(ctx, offset + 0x14, 0x00039e00);
  822. cp_ctx(ctx, offset + 0x1c, 2);
  823. if (dev_priv->chipset == 0x50)
  824. gr_def(ctx, offset + 0x1c, 0x00000040);
  825. else
  826. gr_def(ctx, offset + 0x1c, 0x00000100);
  827. gr_def(ctx, offset + 0x20, 0x00003800);
  828. if (dev_priv->chipset >= 0xa0) {
  829. cp_ctx(ctx, base + 0x54c, 2);
  830. if (dev_priv->chipset <= 0xa0 || dev_priv->chipset >= 0xaa)
  831. gr_def(ctx, base + 0x54c, 0x003fe006);
  832. else
  833. gr_def(ctx, base + 0x54c, 0x003fe007);
  834. gr_def(ctx, base + 0x550, 0x003fe000);
  835. }
  836. if (dev_priv->chipset < 0xa0)
  837. offset = base + 0xa00;
  838. else
  839. offset = base + 0x680;
  840. cp_ctx(ctx, offset, 1);
  841. gr_def(ctx, offset, 0x00404040);
  842. if (dev_priv->chipset < 0xa0)
  843. offset = base + 0xe00;
  844. else
  845. offset = base + 0x700;
  846. cp_ctx(ctx, offset, 2);
  847. if (dev_priv->chipset < 0xa0)
  848. gr_def(ctx, offset, 0x0077f005);
  849. else if (dev_priv->chipset == 0xa5)
  850. gr_def(ctx, offset, 0x6cf7f007);
  851. else if (dev_priv->chipset == 0xa8)
  852. gr_def(ctx, offset, 0x6cfff007);
  853. else if (dev_priv->chipset == 0xac)
  854. gr_def(ctx, offset, 0x0cfff007);
  855. else
  856. gr_def(ctx, offset, 0x0cf7f007);
  857. if (dev_priv->chipset == 0x50)
  858. gr_def(ctx, offset + 0x4, 0x00007fff);
  859. else if (dev_priv->chipset < 0xa0)
  860. gr_def(ctx, offset + 0x4, 0x003f7fff);
  861. else
  862. gr_def(ctx, offset + 0x4, 0x02bf7fff);
  863. cp_ctx(ctx, offset + 0x2c, 1);
  864. if (dev_priv->chipset == 0x50) {
  865. cp_ctx(ctx, offset + 0x50, 9);
  866. gr_def(ctx, offset + 0x54, 0x000003ff);
  867. gr_def(ctx, offset + 0x58, 0x00000003);
  868. gr_def(ctx, offset + 0x5c, 0x00000003);
  869. gr_def(ctx, offset + 0x60, 0x000001ff);
  870. gr_def(ctx, offset + 0x64, 0x0000001f);
  871. gr_def(ctx, offset + 0x68, 0x0000000f);
  872. gr_def(ctx, offset + 0x6c, 0x0000000f);
  873. } else if(dev_priv->chipset < 0xa0) {
  874. cp_ctx(ctx, offset + 0x50, 1);
  875. cp_ctx(ctx, offset + 0x70, 1);
  876. } else {
  877. cp_ctx(ctx, offset + 0x50, 1);
  878. cp_ctx(ctx, offset + 0x60, 5);
  879. }
  880. }
  881. }
  882. }
  883. /*
  884. * xfer areas. These are a pain.
  885. *
  886. * There are 2 xfer areas: the first one is big and contains all sorts of
  887. * stuff, the second is small and contains some per-TP context.
  888. *
  889. * Each area is split into 8 "strands". The areas, when saved to grctx,
  890. * are made of 8-word blocks. Each block contains a single word from
  891. * each strand. The strands are independent of each other, their
  892. * addresses are unrelated to each other, and data in them is closely
  893. * packed together. The strand layout varies a bit between cards: here
  894. * and there, a single word is thrown out in the middle and the whole
  895. * strand is offset by a bit from corresponding one on another chipset.
  896. * For this reason, addresses of stuff in strands are almost useless.
  897. * Knowing sequence of stuff and size of gaps between them is much more
  898. * useful, and that's how we build the strands in our generator.
  899. *
  900. * NVA0 takes this mess to a whole new level by cutting the old strands
  901. * into a few dozen pieces [known as genes], rearranging them randomly,
  902. * and putting them back together to make new strands. Hopefully these
  903. * genes correspond more or less directly to the same PGRAPH subunits
  904. * as in 400040 register.
  905. *
  906. * The most common value in default context is 0, and when the genes
  907. * are separated by 0's, gene bounduaries are quite speculative...
  908. * some of them can be clearly deduced, others can be guessed, and yet
  909. * others won't be resolved without figuring out the real meaning of
  910. * given ctxval. For the same reason, ending point of each strand
  911. * is unknown. Except for strand 0, which is the longest strand and
  912. * its end corresponds to end of the whole xfer.
  913. *
  914. * An unsolved mystery is the seek instruction: it takes an argument
  915. * in bits 8-18, and that argument is clearly the place in strands to
  916. * seek to... but the offsets don't seem to correspond to offsets as
  917. * seen in grctx. Perhaps there's another, real, not randomly-changing
  918. * addressing in strands, and the xfer insn just happens to skip over
  919. * the unused bits? NV10-NV30 PIPE comes to mind...
  920. *
  921. * As far as I know, there's no way to access the xfer areas directly
  922. * without the help of ctxprog.
  923. */
  924. static inline void
  925. xf_emit(struct nouveau_grctx *ctx, int num, uint32_t val) {
  926. int i;
  927. if (val && ctx->mode == NOUVEAU_GRCTX_VALS)
  928. for (i = 0; i < num; i++)
  929. nv_wo32(ctx->dev, ctx->data, ctx->ctxvals_pos + (i << 3), val);
  930. ctx->ctxvals_pos += num << 3;
  931. }
  932. /* Gene declarations... */
  933. static void nv50_graph_construct_gene_m2mf(struct nouveau_grctx *ctx);
  934. static void nv50_graph_construct_gene_unk1(struct nouveau_grctx *ctx);
  935. static void nv50_graph_construct_gene_unk2(struct nouveau_grctx *ctx);
  936. static void nv50_graph_construct_gene_unk3(struct nouveau_grctx *ctx);
  937. static void nv50_graph_construct_gene_unk4(struct nouveau_grctx *ctx);
  938. static void nv50_graph_construct_gene_unk5(struct nouveau_grctx *ctx);
  939. static void nv50_graph_construct_gene_unk6(struct nouveau_grctx *ctx);
  940. static void nv50_graph_construct_gene_unk7(struct nouveau_grctx *ctx);
  941. static void nv50_graph_construct_gene_unk8(struct nouveau_grctx *ctx);
  942. static void nv50_graph_construct_gene_unk9(struct nouveau_grctx *ctx);
  943. static void nv50_graph_construct_gene_unk10(struct nouveau_grctx *ctx);
  944. static void nv50_graph_construct_gene_ropc(struct nouveau_grctx *ctx);
  945. static void nv50_graph_construct_xfer_tp(struct nouveau_grctx *ctx);
  946. static void
  947. nv50_graph_construct_xfer1(struct nouveau_grctx *ctx)
  948. {
  949. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  950. int i;
  951. int offset;
  952. int size = 0;
  953. uint32_t units = nv_rd32 (ctx->dev, 0x1540);
  954. offset = (ctx->ctxvals_pos+0x3f)&~0x3f;
  955. ctx->ctxvals_base = offset;
  956. if (dev_priv->chipset < 0xa0) {
  957. /* Strand 0 */
  958. ctx->ctxvals_pos = offset;
  959. switch (dev_priv->chipset) {
  960. case 0x50:
  961. xf_emit(ctx, 0x99, 0);
  962. break;
  963. case 0x84:
  964. case 0x86:
  965. xf_emit(ctx, 0x384, 0);
  966. break;
  967. case 0x92:
  968. case 0x94:
  969. case 0x96:
  970. case 0x98:
  971. xf_emit(ctx, 0x380, 0);
  972. break;
  973. }
  974. nv50_graph_construct_gene_m2mf (ctx);
  975. switch (dev_priv->chipset) {
  976. case 0x50:
  977. case 0x84:
  978. case 0x86:
  979. case 0x98:
  980. xf_emit(ctx, 0x4c4, 0);
  981. break;
  982. case 0x92:
  983. case 0x94:
  984. case 0x96:
  985. xf_emit(ctx, 0x984, 0);
  986. break;
  987. }
  988. nv50_graph_construct_gene_unk5(ctx);
  989. if (dev_priv->chipset == 0x50)
  990. xf_emit(ctx, 0xa, 0);
  991. else
  992. xf_emit(ctx, 0xb, 0);
  993. nv50_graph_construct_gene_unk4(ctx);
  994. nv50_graph_construct_gene_unk3(ctx);
  995. if ((ctx->ctxvals_pos-offset)/8 > size)
  996. size = (ctx->ctxvals_pos-offset)/8;
  997. /* Strand 1 */
  998. ctx->ctxvals_pos = offset + 0x1;
  999. nv50_graph_construct_gene_unk6(ctx);
  1000. nv50_graph_construct_gene_unk7(ctx);
  1001. nv50_graph_construct_gene_unk8(ctx);
  1002. switch (dev_priv->chipset) {
  1003. case 0x50:
  1004. case 0x92:
  1005. xf_emit(ctx, 0xfb, 0);
  1006. break;
  1007. case 0x84:
  1008. xf_emit(ctx, 0xd3, 0);
  1009. break;
  1010. case 0x94:
  1011. case 0x96:
  1012. xf_emit(ctx, 0xab, 0);
  1013. break;
  1014. case 0x86:
  1015. case 0x98:
  1016. xf_emit(ctx, 0x6b, 0);
  1017. break;
  1018. }
  1019. xf_emit(ctx, 2, 0x4e3bfdf);
  1020. xf_emit(ctx, 4, 0);
  1021. xf_emit(ctx, 1, 0x0fac6881);
  1022. xf_emit(ctx, 0xb, 0);
  1023. xf_emit(ctx, 2, 0x4e3bfdf);
  1024. if ((ctx->ctxvals_pos-offset)/8 > size)
  1025. size = (ctx->ctxvals_pos-offset)/8;
  1026. /* Strand 2 */
  1027. ctx->ctxvals_pos = offset + 0x2;
  1028. switch (dev_priv->chipset) {
  1029. case 0x50:
  1030. case 0x92:
  1031. xf_emit(ctx, 0xa80, 0);
  1032. break;
  1033. case 0x84:
  1034. xf_emit(ctx, 0xa7e, 0);
  1035. break;
  1036. case 0x94:
  1037. case 0x96:
  1038. xf_emit(ctx, 0xa7c, 0);
  1039. break;
  1040. case 0x86:
  1041. case 0x98:
  1042. xf_emit(ctx, 0xa7a, 0);
  1043. break;
  1044. }
  1045. xf_emit(ctx, 1, 0x3fffff);
  1046. xf_emit(ctx, 2, 0);
  1047. xf_emit(ctx, 1, 0x1fff);
  1048. xf_emit(ctx, 0xe, 0);
  1049. nv50_graph_construct_gene_unk9(ctx);
  1050. nv50_graph_construct_gene_unk2(ctx);
  1051. nv50_graph_construct_gene_unk1(ctx);
  1052. nv50_graph_construct_gene_unk10(ctx);
  1053. if ((ctx->ctxvals_pos-offset)/8 > size)
  1054. size = (ctx->ctxvals_pos-offset)/8;
  1055. /* Strand 3: per-ROP group state */
  1056. ctx->ctxvals_pos = offset + 3;
  1057. for (i = 0; i < 6; i++)
  1058. if (units & (1 << (i + 16)))
  1059. nv50_graph_construct_gene_ropc(ctx);
  1060. if ((ctx->ctxvals_pos-offset)/8 > size)
  1061. size = (ctx->ctxvals_pos-offset)/8;
  1062. /* Strands 4-7: per-TP state */
  1063. for (i = 0; i < 4; i++) {
  1064. ctx->ctxvals_pos = offset + 4 + i;
  1065. if (units & (1 << (2 * i)))
  1066. nv50_graph_construct_xfer_tp(ctx);
  1067. if (units & (1 << (2 * i + 1)))
  1068. nv50_graph_construct_xfer_tp(ctx);
  1069. if ((ctx->ctxvals_pos-offset)/8 > size)
  1070. size = (ctx->ctxvals_pos-offset)/8;
  1071. }
  1072. } else {
  1073. /* Strand 0 */
  1074. ctx->ctxvals_pos = offset;
  1075. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1076. xf_emit(ctx, 0x385, 0);
  1077. else
  1078. xf_emit(ctx, 0x384, 0);
  1079. nv50_graph_construct_gene_m2mf(ctx);
  1080. xf_emit(ctx, 0x950, 0);
  1081. nv50_graph_construct_gene_unk10(ctx);
  1082. xf_emit(ctx, 1, 0x0fac6881);
  1083. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  1084. xf_emit(ctx, 1, 1);
  1085. xf_emit(ctx, 3, 0);
  1086. }
  1087. nv50_graph_construct_gene_unk8(ctx);
  1088. if (dev_priv->chipset == 0xa0)
  1089. xf_emit(ctx, 0x189, 0);
  1090. else if (dev_priv->chipset < 0xa8)
  1091. xf_emit(ctx, 0x99, 0);
  1092. else if (dev_priv->chipset == 0xaa)
  1093. xf_emit(ctx, 0x65, 0);
  1094. else
  1095. xf_emit(ctx, 0x6d, 0);
  1096. nv50_graph_construct_gene_unk9(ctx);
  1097. if ((ctx->ctxvals_pos-offset)/8 > size)
  1098. size = (ctx->ctxvals_pos-offset)/8;
  1099. /* Strand 1 */
  1100. ctx->ctxvals_pos = offset + 1;
  1101. nv50_graph_construct_gene_unk1(ctx);
  1102. if ((ctx->ctxvals_pos-offset)/8 > size)
  1103. size = (ctx->ctxvals_pos-offset)/8;
  1104. /* Strand 2 */
  1105. ctx->ctxvals_pos = offset + 2;
  1106. if (dev_priv->chipset == 0xa0) {
  1107. nv50_graph_construct_gene_unk2(ctx);
  1108. }
  1109. xf_emit(ctx, 0x36, 0);
  1110. nv50_graph_construct_gene_unk5(ctx);
  1111. if ((ctx->ctxvals_pos-offset)/8 > size)
  1112. size = (ctx->ctxvals_pos-offset)/8;
  1113. /* Strand 3 */
  1114. ctx->ctxvals_pos = offset + 3;
  1115. xf_emit(ctx, 1, 0);
  1116. xf_emit(ctx, 1, 1);
  1117. nv50_graph_construct_gene_unk6(ctx);
  1118. if ((ctx->ctxvals_pos-offset)/8 > size)
  1119. size = (ctx->ctxvals_pos-offset)/8;
  1120. /* Strand 4 */
  1121. ctx->ctxvals_pos = offset + 4;
  1122. if (dev_priv->chipset == 0xa0)
  1123. xf_emit(ctx, 0xa80, 0);
  1124. else
  1125. xf_emit(ctx, 0xa7a, 0);
  1126. xf_emit(ctx, 1, 0x3fffff);
  1127. xf_emit(ctx, 2, 0);
  1128. xf_emit(ctx, 1, 0x1fff);
  1129. if ((ctx->ctxvals_pos-offset)/8 > size)
  1130. size = (ctx->ctxvals_pos-offset)/8;
  1131. /* Strand 5 */
  1132. ctx->ctxvals_pos = offset + 5;
  1133. xf_emit(ctx, 1, 0);
  1134. xf_emit(ctx, 1, 0x0fac6881);
  1135. xf_emit(ctx, 0xb, 0);
  1136. xf_emit(ctx, 2, 0x4e3bfdf);
  1137. xf_emit(ctx, 3, 0);
  1138. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1139. xf_emit(ctx, 1, 0x11);
  1140. xf_emit(ctx, 1, 0);
  1141. xf_emit(ctx, 2, 0x4e3bfdf);
  1142. xf_emit(ctx, 2, 0);
  1143. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1144. xf_emit(ctx, 1, 0x11);
  1145. xf_emit(ctx, 1, 0);
  1146. for (i = 0; i < 8; i++)
  1147. if (units & (1<<(i+16)))
  1148. nv50_graph_construct_gene_ropc(ctx);
  1149. if ((ctx->ctxvals_pos-offset)/8 > size)
  1150. size = (ctx->ctxvals_pos-offset)/8;
  1151. /* Strand 6 */
  1152. ctx->ctxvals_pos = offset + 6;
  1153. nv50_graph_construct_gene_unk3(ctx);
  1154. xf_emit(ctx, 0xb, 0);
  1155. nv50_graph_construct_gene_unk4(ctx);
  1156. nv50_graph_construct_gene_unk7(ctx);
  1157. if (units & (1 << 0))
  1158. nv50_graph_construct_xfer_tp(ctx);
  1159. if (units & (1 << 1))
  1160. nv50_graph_construct_xfer_tp(ctx);
  1161. if (units & (1 << 2))
  1162. nv50_graph_construct_xfer_tp(ctx);
  1163. if (units & (1 << 3))
  1164. nv50_graph_construct_xfer_tp(ctx);
  1165. if ((ctx->ctxvals_pos-offset)/8 > size)
  1166. size = (ctx->ctxvals_pos-offset)/8;
  1167. /* Strand 7 */
  1168. ctx->ctxvals_pos = offset + 7;
  1169. if (dev_priv->chipset == 0xa0) {
  1170. if (units & (1 << 4))
  1171. nv50_graph_construct_xfer_tp(ctx);
  1172. if (units & (1 << 5))
  1173. nv50_graph_construct_xfer_tp(ctx);
  1174. if (units & (1 << 6))
  1175. nv50_graph_construct_xfer_tp(ctx);
  1176. if (units & (1 << 7))
  1177. nv50_graph_construct_xfer_tp(ctx);
  1178. if (units & (1 << 8))
  1179. nv50_graph_construct_xfer_tp(ctx);
  1180. if (units & (1 << 9))
  1181. nv50_graph_construct_xfer_tp(ctx);
  1182. } else {
  1183. nv50_graph_construct_gene_unk2(ctx);
  1184. }
  1185. if ((ctx->ctxvals_pos-offset)/8 > size)
  1186. size = (ctx->ctxvals_pos-offset)/8;
  1187. }
  1188. ctx->ctxvals_pos = offset + size * 8;
  1189. ctx->ctxvals_pos = (ctx->ctxvals_pos+0x3f)&~0x3f;
  1190. cp_lsr (ctx, offset);
  1191. cp_out (ctx, CP_SET_XFER_POINTER);
  1192. cp_lsr (ctx, size);
  1193. cp_out (ctx, CP_SEEK_1);
  1194. cp_out (ctx, CP_XFER_1);
  1195. cp_wait(ctx, XFER, BUSY);
  1196. }
  1197. /*
  1198. * non-trivial demagiced parts of ctx init go here
  1199. */
  1200. static void
  1201. nv50_graph_construct_gene_m2mf(struct nouveau_grctx *ctx)
  1202. {
  1203. /* m2mf state */
  1204. xf_emit (ctx, 1, 0); /* DMA_NOTIFY instance >> 4 */
  1205. xf_emit (ctx, 1, 0); /* DMA_BUFFER_IN instance >> 4 */
  1206. xf_emit (ctx, 1, 0); /* DMA_BUFFER_OUT instance >> 4 */
  1207. xf_emit (ctx, 1, 0); /* OFFSET_IN */
  1208. xf_emit (ctx, 1, 0); /* OFFSET_OUT */
  1209. xf_emit (ctx, 1, 0); /* PITCH_IN */
  1210. xf_emit (ctx, 1, 0); /* PITCH_OUT */
  1211. xf_emit (ctx, 1, 0); /* LINE_LENGTH */
  1212. xf_emit (ctx, 1, 0); /* LINE_COUNT */
  1213. xf_emit (ctx, 1, 0x21); /* FORMAT: bits 0-4 INPUT_INC, bits 5-9 OUTPUT_INC */
  1214. xf_emit (ctx, 1, 1); /* LINEAR_IN */
  1215. xf_emit (ctx, 1, 0x2); /* TILING_MODE_IN: bits 0-2 y tiling, bits 3-5 z tiling */
  1216. xf_emit (ctx, 1, 0x100); /* TILING_PITCH_IN */
  1217. xf_emit (ctx, 1, 0x100); /* TILING_HEIGHT_IN */
  1218. xf_emit (ctx, 1, 1); /* TILING_DEPTH_IN */
  1219. xf_emit (ctx, 1, 0); /* TILING_POSITION_IN_Z */
  1220. xf_emit (ctx, 1, 0); /* TILING_POSITION_IN */
  1221. xf_emit (ctx, 1, 1); /* LINEAR_OUT */
  1222. xf_emit (ctx, 1, 0x2); /* TILING_MODE_OUT: bits 0-2 y tiling, bits 3-5 z tiling */
  1223. xf_emit (ctx, 1, 0x100); /* TILING_PITCH_OUT */
  1224. xf_emit (ctx, 1, 0x100); /* TILING_HEIGHT_OUT */
  1225. xf_emit (ctx, 1, 1); /* TILING_DEPTH_OUT */
  1226. xf_emit (ctx, 1, 0); /* TILING_POSITION_OUT_Z */
  1227. xf_emit (ctx, 1, 0); /* TILING_POSITION_OUT */
  1228. xf_emit (ctx, 1, 0); /* OFFSET_IN_HIGH */
  1229. xf_emit (ctx, 1, 0); /* OFFSET_OUT_HIGH */
  1230. }
  1231. static void
  1232. nv50_graph_construct_gene_unk1(struct nouveau_grctx *ctx)
  1233. {
  1234. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1235. /* end of area 2 on pre-NVA0, area 1 on NVAx */
  1236. xf_emit(ctx, 2, 4);
  1237. xf_emit(ctx, 1, 0);
  1238. xf_emit(ctx, 1, 0x80);
  1239. xf_emit(ctx, 1, 4);
  1240. xf_emit(ctx, 1, 0x80c14);
  1241. xf_emit(ctx, 1, 0);
  1242. if (dev_priv->chipset == 0x50)
  1243. xf_emit(ctx, 1, 0x3ff);
  1244. else
  1245. xf_emit(ctx, 1, 0x7ff);
  1246. switch (dev_priv->chipset) {
  1247. case 0x50:
  1248. case 0x86:
  1249. case 0x98:
  1250. case 0xaa:
  1251. case 0xac:
  1252. xf_emit(ctx, 0x542, 0);
  1253. break;
  1254. case 0x84:
  1255. case 0x92:
  1256. case 0x94:
  1257. case 0x96:
  1258. xf_emit(ctx, 0x942, 0);
  1259. break;
  1260. case 0xa0:
  1261. xf_emit(ctx, 0x2042, 0);
  1262. break;
  1263. case 0xa5:
  1264. case 0xa8:
  1265. xf_emit(ctx, 0x842, 0);
  1266. break;
  1267. }
  1268. xf_emit(ctx, 2, 4);
  1269. xf_emit(ctx, 1, 0);
  1270. xf_emit(ctx, 1, 0x80);
  1271. xf_emit(ctx, 1, 4);
  1272. xf_emit(ctx, 1, 1);
  1273. xf_emit(ctx, 1, 0);
  1274. xf_emit(ctx, 1, 0x27);
  1275. xf_emit(ctx, 1, 0);
  1276. xf_emit(ctx, 1, 0x26);
  1277. xf_emit(ctx, 3, 0);
  1278. }
  1279. static void
  1280. nv50_graph_construct_gene_unk10(struct nouveau_grctx *ctx)
  1281. {
  1282. /* end of area 2 on pre-NVA0, area 1 on NVAx */
  1283. xf_emit(ctx, 0x10, 0x04000000);
  1284. xf_emit(ctx, 0x24, 0);
  1285. xf_emit(ctx, 2, 0x04e3bfdf);
  1286. xf_emit(ctx, 2, 0);
  1287. xf_emit(ctx, 1, 0x1fe21);
  1288. }
  1289. static void
  1290. nv50_graph_construct_gene_unk2(struct nouveau_grctx *ctx)
  1291. {
  1292. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1293. /* middle of area 2 on pre-NVA0, beginning of area 2 on NVA0, area 7 on >NVA0 */
  1294. if (dev_priv->chipset != 0x50) {
  1295. xf_emit(ctx, 5, 0);
  1296. xf_emit(ctx, 1, 0x80c14);
  1297. xf_emit(ctx, 2, 0);
  1298. xf_emit(ctx, 1, 0x804);
  1299. xf_emit(ctx, 1, 0);
  1300. xf_emit(ctx, 2, 4);
  1301. xf_emit(ctx, 1, 0x8100c12);
  1302. }
  1303. xf_emit(ctx, 1, 0);
  1304. xf_emit(ctx, 2, 4);
  1305. xf_emit(ctx, 1, 0);
  1306. xf_emit(ctx, 1, 0x10);
  1307. if (dev_priv->chipset == 0x50)
  1308. xf_emit(ctx, 3, 0);
  1309. else
  1310. xf_emit(ctx, 4, 0);
  1311. xf_emit(ctx, 1, 0x804);
  1312. xf_emit(ctx, 1, 1);
  1313. xf_emit(ctx, 1, 0x1a);
  1314. if (dev_priv->chipset != 0x50)
  1315. xf_emit(ctx, 1, 0x7f);
  1316. xf_emit(ctx, 1, 0);
  1317. xf_emit(ctx, 1, 1);
  1318. xf_emit(ctx, 1, 0x80c14);
  1319. xf_emit(ctx, 1, 0);
  1320. xf_emit(ctx, 1, 0x8100c12);
  1321. xf_emit(ctx, 2, 4);
  1322. xf_emit(ctx, 1, 0);
  1323. xf_emit(ctx, 1, 0x10);
  1324. xf_emit(ctx, 3, 0);
  1325. xf_emit(ctx, 1, 1);
  1326. xf_emit(ctx, 1, 0x8100c12);
  1327. xf_emit(ctx, 6, 0);
  1328. if (dev_priv->chipset == 0x50)
  1329. xf_emit(ctx, 1, 0x3ff);
  1330. else
  1331. xf_emit(ctx, 1, 0x7ff);
  1332. xf_emit(ctx, 1, 0x80c14);
  1333. xf_emit(ctx, 0x38, 0);
  1334. xf_emit(ctx, 1, 1);
  1335. xf_emit(ctx, 2, 0);
  1336. xf_emit(ctx, 1, 0x10);
  1337. xf_emit(ctx, 0x38, 0);
  1338. xf_emit(ctx, 2, 0x88);
  1339. xf_emit(ctx, 2, 0);
  1340. xf_emit(ctx, 1, 4);
  1341. xf_emit(ctx, 0x16, 0);
  1342. xf_emit(ctx, 1, 0x26);
  1343. xf_emit(ctx, 2, 0);
  1344. xf_emit(ctx, 1, 0x3f800000);
  1345. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1346. xf_emit(ctx, 4, 0);
  1347. else
  1348. xf_emit(ctx, 3, 0);
  1349. xf_emit(ctx, 1, 0x1a);
  1350. xf_emit(ctx, 1, 0x10);
  1351. if (dev_priv->chipset != 0x50)
  1352. xf_emit(ctx, 0x28, 0);
  1353. else
  1354. xf_emit(ctx, 0x25, 0);
  1355. xf_emit(ctx, 1, 0x52);
  1356. xf_emit(ctx, 1, 0);
  1357. xf_emit(ctx, 1, 0x26);
  1358. xf_emit(ctx, 1, 0);
  1359. xf_emit(ctx, 2, 4);
  1360. xf_emit(ctx, 1, 0);
  1361. xf_emit(ctx, 1, 0x1a);
  1362. xf_emit(ctx, 2, 0);
  1363. xf_emit(ctx, 1, 0x00ffff00);
  1364. xf_emit(ctx, 1, 0);
  1365. }
  1366. static void
  1367. nv50_graph_construct_gene_unk3(struct nouveau_grctx *ctx)
  1368. {
  1369. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1370. /* end of area 0 on pre-NVA0, beginning of area 6 on NVAx */
  1371. xf_emit(ctx, 1, 0x3f);
  1372. xf_emit(ctx, 0xa, 0);
  1373. xf_emit(ctx, 1, 2);
  1374. xf_emit(ctx, 2, 0x04000000);
  1375. xf_emit(ctx, 8, 0);
  1376. xf_emit(ctx, 1, 4);
  1377. xf_emit(ctx, 3, 0);
  1378. xf_emit(ctx, 1, 4);
  1379. if (dev_priv->chipset == 0x50)
  1380. xf_emit(ctx, 0x10, 0);
  1381. else
  1382. xf_emit(ctx, 0x11, 0);
  1383. xf_emit(ctx, 1, 1);
  1384. xf_emit(ctx, 1, 0x1001);
  1385. xf_emit(ctx, 4, 0xffff);
  1386. xf_emit(ctx, 0x20, 0);
  1387. xf_emit(ctx, 0x10, 0x3f800000);
  1388. xf_emit(ctx, 1, 0x10);
  1389. if (dev_priv->chipset == 0x50)
  1390. xf_emit(ctx, 1, 0);
  1391. else
  1392. xf_emit(ctx, 2, 0);
  1393. xf_emit(ctx, 1, 3);
  1394. xf_emit(ctx, 2, 0);
  1395. }
  1396. static void
  1397. nv50_graph_construct_gene_unk4(struct nouveau_grctx *ctx)
  1398. {
  1399. /* middle of area 0 on pre-NVA0, middle of area 6 on NVAx */
  1400. xf_emit(ctx, 2, 0x04000000);
  1401. xf_emit(ctx, 1, 0);
  1402. xf_emit(ctx, 1, 0x80);
  1403. xf_emit(ctx, 3, 0);
  1404. xf_emit(ctx, 1, 0x80);
  1405. xf_emit(ctx, 1, 0);
  1406. }
  1407. static void
  1408. nv50_graph_construct_gene_unk5(struct nouveau_grctx *ctx)
  1409. {
  1410. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1411. /* middle of area 0 on pre-NVA0 [after m2mf], end of area 2 on NVAx */
  1412. xf_emit(ctx, 2, 4);
  1413. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1414. xf_emit(ctx, 0x1c4d, 0);
  1415. else
  1416. xf_emit(ctx, 0x1c4b, 0);
  1417. xf_emit(ctx, 2, 4);
  1418. xf_emit(ctx, 1, 0x8100c12);
  1419. if (dev_priv->chipset != 0x50)
  1420. xf_emit(ctx, 1, 3);
  1421. xf_emit(ctx, 1, 0);
  1422. xf_emit(ctx, 1, 0x8100c12);
  1423. xf_emit(ctx, 1, 0);
  1424. xf_emit(ctx, 1, 0x80c14);
  1425. xf_emit(ctx, 1, 1);
  1426. if (dev_priv->chipset >= 0xa0)
  1427. xf_emit(ctx, 2, 4);
  1428. xf_emit(ctx, 1, 0x80c14);
  1429. xf_emit(ctx, 2, 0);
  1430. xf_emit(ctx, 1, 0x8100c12);
  1431. xf_emit(ctx, 1, 0x27);
  1432. xf_emit(ctx, 2, 0);
  1433. xf_emit(ctx, 1, 1);
  1434. xf_emit(ctx, 0x3c1, 0);
  1435. xf_emit(ctx, 1, 1);
  1436. xf_emit(ctx, 0x16, 0);
  1437. xf_emit(ctx, 1, 0x8100c12);
  1438. xf_emit(ctx, 1, 0);
  1439. }
  1440. static void
  1441. nv50_graph_construct_gene_unk6(struct nouveau_grctx *ctx)
  1442. {
  1443. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1444. /* beginning of area 1 on pre-NVA0 [after m2mf], area 3 on NVAx */
  1445. xf_emit(ctx, 4, 0);
  1446. xf_emit(ctx, 1, 0xf);
  1447. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1448. xf_emit(ctx, 8, 0);
  1449. else
  1450. xf_emit(ctx, 4, 0);
  1451. xf_emit(ctx, 1, 0x20);
  1452. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1453. xf_emit(ctx, 0x11, 0);
  1454. else if (dev_priv->chipset >= 0xa0)
  1455. xf_emit(ctx, 0xf, 0);
  1456. else
  1457. xf_emit(ctx, 0xe, 0);
  1458. xf_emit(ctx, 1, 0x1a);
  1459. xf_emit(ctx, 0xd, 0);
  1460. xf_emit(ctx, 2, 4);
  1461. xf_emit(ctx, 1, 0);
  1462. xf_emit(ctx, 1, 4);
  1463. xf_emit(ctx, 1, 8);
  1464. xf_emit(ctx, 1, 0);
  1465. if (dev_priv->chipset == 0x50)
  1466. xf_emit(ctx, 1, 0x3ff);
  1467. else
  1468. xf_emit(ctx, 1, 0x7ff);
  1469. if (dev_priv->chipset == 0xa8)
  1470. xf_emit(ctx, 1, 0x1e00);
  1471. xf_emit(ctx, 0xc, 0);
  1472. xf_emit(ctx, 1, 0xf);
  1473. if (dev_priv->chipset == 0x50)
  1474. xf_emit(ctx, 0x125, 0);
  1475. else if (dev_priv->chipset < 0xa0)
  1476. xf_emit(ctx, 0x126, 0);
  1477. else if (dev_priv->chipset == 0xa0 || dev_priv->chipset >= 0xaa)
  1478. xf_emit(ctx, 0x124, 0);
  1479. else
  1480. xf_emit(ctx, 0x1f7, 0);
  1481. xf_emit(ctx, 1, 0xf);
  1482. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1483. xf_emit(ctx, 3, 0);
  1484. else
  1485. xf_emit(ctx, 1, 0);
  1486. xf_emit(ctx, 1, 1);
  1487. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1488. xf_emit(ctx, 0xa1, 0);
  1489. else
  1490. xf_emit(ctx, 0x5a, 0);
  1491. xf_emit(ctx, 1, 0xf);
  1492. if (dev_priv->chipset < 0xa0)
  1493. xf_emit(ctx, 0x834, 0);
  1494. else if (dev_priv->chipset == 0xa0)
  1495. xf_emit(ctx, 0x1873, 0);
  1496. else if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1497. xf_emit(ctx, 0x8ba, 0);
  1498. else
  1499. xf_emit(ctx, 0x833, 0);
  1500. xf_emit(ctx, 1, 0xf);
  1501. xf_emit(ctx, 0xf, 0);
  1502. }
  1503. static void
  1504. nv50_graph_construct_gene_unk7(struct nouveau_grctx *ctx)
  1505. {
  1506. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1507. /* middle of area 1 on pre-NVA0 [after m2mf], middle of area 6 on NVAx */
  1508. xf_emit(ctx, 2, 0);
  1509. if (dev_priv->chipset == 0x50)
  1510. xf_emit(ctx, 2, 1);
  1511. else
  1512. xf_emit(ctx, 2, 0);
  1513. xf_emit(ctx, 1, 0);
  1514. xf_emit(ctx, 1, 1);
  1515. xf_emit(ctx, 2, 0x100);
  1516. xf_emit(ctx, 1, 0x11);
  1517. xf_emit(ctx, 1, 0);
  1518. xf_emit(ctx, 1, 8);
  1519. xf_emit(ctx, 5, 0);
  1520. xf_emit(ctx, 1, 1);
  1521. xf_emit(ctx, 1, 0);
  1522. xf_emit(ctx, 3, 1);
  1523. xf_emit(ctx, 1, 0xcf);
  1524. xf_emit(ctx, 1, 2);
  1525. xf_emit(ctx, 6, 0);
  1526. xf_emit(ctx, 1, 1);
  1527. xf_emit(ctx, 1, 0);
  1528. xf_emit(ctx, 3, 1);
  1529. xf_emit(ctx, 4, 0);
  1530. xf_emit(ctx, 1, 4);
  1531. xf_emit(ctx, 1, 0);
  1532. xf_emit(ctx, 1, 1);
  1533. xf_emit(ctx, 1, 0x15);
  1534. xf_emit(ctx, 3, 0);
  1535. xf_emit(ctx, 1, 0x4444480);
  1536. xf_emit(ctx, 0x37, 0);
  1537. }
  1538. static void
  1539. nv50_graph_construct_gene_unk8(struct nouveau_grctx *ctx)
  1540. {
  1541. /* middle of area 1 on pre-NVA0 [after m2mf], middle of area 0 on NVAx */
  1542. xf_emit(ctx, 4, 0);
  1543. xf_emit(ctx, 1, 0x8100c12);
  1544. xf_emit(ctx, 4, 0);
  1545. xf_emit(ctx, 1, 0x100);
  1546. xf_emit(ctx, 2, 0);
  1547. xf_emit(ctx, 1, 0x10001);
  1548. xf_emit(ctx, 1, 0);
  1549. xf_emit(ctx, 1, 0x10001);
  1550. xf_emit(ctx, 1, 1);
  1551. xf_emit(ctx, 1, 0x10001);
  1552. xf_emit(ctx, 1, 1);
  1553. xf_emit(ctx, 1, 4);
  1554. xf_emit(ctx, 1, 2);
  1555. }
  1556. static void
  1557. nv50_graph_construct_gene_unk9(struct nouveau_grctx *ctx)
  1558. {
  1559. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1560. /* middle of area 2 on pre-NVA0 [after m2mf], end of area 0 on NVAx */
  1561. xf_emit(ctx, 1, 0x3f800000);
  1562. xf_emit(ctx, 6, 0);
  1563. xf_emit(ctx, 1, 4);
  1564. xf_emit(ctx, 1, 0x1a);
  1565. xf_emit(ctx, 2, 0);
  1566. xf_emit(ctx, 1, 1);
  1567. xf_emit(ctx, 0x12, 0);
  1568. xf_emit(ctx, 1, 0x00ffff00);
  1569. xf_emit(ctx, 6, 0);
  1570. xf_emit(ctx, 1, 0xf);
  1571. xf_emit(ctx, 7, 0);
  1572. xf_emit(ctx, 1, 0x0fac6881);
  1573. xf_emit(ctx, 1, 0x11);
  1574. xf_emit(ctx, 0xf, 0);
  1575. xf_emit(ctx, 1, 4);
  1576. xf_emit(ctx, 2, 0);
  1577. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1578. xf_emit(ctx, 1, 3);
  1579. else if (dev_priv->chipset >= 0xa0)
  1580. xf_emit(ctx, 1, 1);
  1581. xf_emit(ctx, 2, 0);
  1582. xf_emit(ctx, 1, 2);
  1583. xf_emit(ctx, 2, 0x04000000);
  1584. xf_emit(ctx, 3, 0);
  1585. xf_emit(ctx, 1, 5);
  1586. xf_emit(ctx, 1, 0x52);
  1587. if (dev_priv->chipset == 0x50) {
  1588. xf_emit(ctx, 0x13, 0);
  1589. } else {
  1590. xf_emit(ctx, 4, 0);
  1591. xf_emit(ctx, 1, 1);
  1592. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1593. xf_emit(ctx, 0x11, 0);
  1594. else
  1595. xf_emit(ctx, 0x10, 0);
  1596. }
  1597. xf_emit(ctx, 0x10, 0x3f800000);
  1598. xf_emit(ctx, 1, 0x10);
  1599. xf_emit(ctx, 0x26, 0);
  1600. xf_emit(ctx, 1, 0x8100c12);
  1601. xf_emit(ctx, 1, 5);
  1602. xf_emit(ctx, 2, 0);
  1603. xf_emit(ctx, 1, 1);
  1604. xf_emit(ctx, 1, 0);
  1605. xf_emit(ctx, 4, 0xffff);
  1606. if (dev_priv->chipset != 0x50)
  1607. xf_emit(ctx, 1, 3);
  1608. if (dev_priv->chipset < 0xa0)
  1609. xf_emit(ctx, 0x1f, 0);
  1610. else if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1611. xf_emit(ctx, 0xc, 0);
  1612. else
  1613. xf_emit(ctx, 3, 0);
  1614. xf_emit(ctx, 1, 0x00ffff00);
  1615. xf_emit(ctx, 1, 0x1a);
  1616. if (dev_priv->chipset != 0x50) {
  1617. xf_emit(ctx, 1, 0);
  1618. xf_emit(ctx, 1, 3);
  1619. }
  1620. if (dev_priv->chipset < 0xa0)
  1621. xf_emit(ctx, 0x26, 0);
  1622. else
  1623. xf_emit(ctx, 0x3c, 0);
  1624. xf_emit(ctx, 1, 0x102);
  1625. xf_emit(ctx, 1, 0);
  1626. xf_emit(ctx, 4, 4);
  1627. if (dev_priv->chipset >= 0xa0)
  1628. xf_emit(ctx, 8, 0);
  1629. xf_emit(ctx, 2, 4);
  1630. xf_emit(ctx, 1, 0);
  1631. if (dev_priv->chipset == 0x50)
  1632. xf_emit(ctx, 1, 0x3ff);
  1633. else
  1634. xf_emit(ctx, 1, 0x7ff);
  1635. xf_emit(ctx, 1, 0);
  1636. xf_emit(ctx, 1, 0x102);
  1637. xf_emit(ctx, 9, 0);
  1638. xf_emit(ctx, 4, 4);
  1639. xf_emit(ctx, 0x2c, 0);
  1640. }
  1641. static void
  1642. nv50_graph_construct_gene_ropc(struct nouveau_grctx *ctx)
  1643. {
  1644. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1645. int magic2;
  1646. if (dev_priv->chipset == 0x50) {
  1647. magic2 = 0x00003e60;
  1648. } else if (dev_priv->chipset <= 0xa0 || dev_priv->chipset >= 0xaa) {
  1649. magic2 = 0x001ffe67;
  1650. } else {
  1651. magic2 = 0x00087e67;
  1652. }
  1653. xf_emit(ctx, 8, 0);
  1654. xf_emit(ctx, 1, 2);
  1655. xf_emit(ctx, 1, 0);
  1656. xf_emit(ctx, 1, magic2);
  1657. xf_emit(ctx, 4, 0);
  1658. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1659. xf_emit(ctx, 1, 1);
  1660. xf_emit(ctx, 7, 0);
  1661. if (dev_priv->chipset >= 0xa0 && dev_priv->chipset < 0xaa)
  1662. xf_emit(ctx, 1, 0x15);
  1663. xf_emit(ctx, 1, 0);
  1664. xf_emit(ctx, 1, 1);
  1665. xf_emit(ctx, 1, 0x10);
  1666. xf_emit(ctx, 2, 0);
  1667. xf_emit(ctx, 1, 1);
  1668. xf_emit(ctx, 4, 0);
  1669. if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x92 || dev_priv->chipset == 0x98 || dev_priv->chipset >= 0xa0) {
  1670. xf_emit(ctx, 1, 4);
  1671. xf_emit(ctx, 1, 0x400);
  1672. xf_emit(ctx, 1, 0x300);
  1673. xf_emit(ctx, 1, 0x1001);
  1674. if (dev_priv->chipset != 0xa0) {
  1675. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1676. xf_emit(ctx, 1, 0);
  1677. else
  1678. xf_emit(ctx, 1, 0x15);
  1679. }
  1680. xf_emit(ctx, 3, 0);
  1681. }
  1682. xf_emit(ctx, 2, 0);
  1683. xf_emit(ctx, 1, 2);
  1684. xf_emit(ctx, 8, 0);
  1685. xf_emit(ctx, 1, 1);
  1686. xf_emit(ctx, 1, 0x10);
  1687. xf_emit(ctx, 1, 0);
  1688. xf_emit(ctx, 1, 1);
  1689. xf_emit(ctx, 0x13, 0);
  1690. xf_emit(ctx, 1, 0x10);
  1691. xf_emit(ctx, 0x10, 0);
  1692. xf_emit(ctx, 0x10, 0x3f800000);
  1693. xf_emit(ctx, 0x19, 0);
  1694. xf_emit(ctx, 1, 0x10);
  1695. xf_emit(ctx, 1, 0);
  1696. xf_emit(ctx, 1, 0x3f);
  1697. xf_emit(ctx, 6, 0);
  1698. xf_emit(ctx, 1, 1);
  1699. xf_emit(ctx, 1, 0);
  1700. xf_emit(ctx, 1, 1);
  1701. xf_emit(ctx, 1, 0);
  1702. xf_emit(ctx, 1, 1);
  1703. if (dev_priv->chipset >= 0xa0) {
  1704. xf_emit(ctx, 2, 0);
  1705. xf_emit(ctx, 1, 0x1001);
  1706. xf_emit(ctx, 0xb, 0);
  1707. } else {
  1708. xf_emit(ctx, 0xc, 0);
  1709. }
  1710. xf_emit(ctx, 1, 0x11);
  1711. xf_emit(ctx, 7, 0);
  1712. xf_emit(ctx, 1, 0xf);
  1713. xf_emit(ctx, 7, 0);
  1714. xf_emit(ctx, 1, 0x11);
  1715. if (dev_priv->chipset == 0x50)
  1716. xf_emit(ctx, 4, 0);
  1717. else
  1718. xf_emit(ctx, 6, 0);
  1719. xf_emit(ctx, 3, 1);
  1720. xf_emit(ctx, 1, 2);
  1721. xf_emit(ctx, 1, 1);
  1722. xf_emit(ctx, 1, 2);
  1723. xf_emit(ctx, 1, 1);
  1724. xf_emit(ctx, 1, 0);
  1725. xf_emit(ctx, 1, magic2);
  1726. xf_emit(ctx, 1, 0);
  1727. xf_emit(ctx, 1, 0x0fac6881);
  1728. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  1729. xf_emit(ctx, 1, 0);
  1730. xf_emit(ctx, 0x18, 1);
  1731. xf_emit(ctx, 8, 2);
  1732. xf_emit(ctx, 8, 1);
  1733. xf_emit(ctx, 8, 2);
  1734. xf_emit(ctx, 8, 1);
  1735. xf_emit(ctx, 3, 0);
  1736. xf_emit(ctx, 1, 1);
  1737. xf_emit(ctx, 5, 0);
  1738. xf_emit(ctx, 1, 1);
  1739. xf_emit(ctx, 0x16, 0);
  1740. } else {
  1741. if (dev_priv->chipset >= 0xa0)
  1742. xf_emit(ctx, 0x1b, 0);
  1743. else
  1744. xf_emit(ctx, 0x15, 0);
  1745. }
  1746. xf_emit(ctx, 1, 1);
  1747. xf_emit(ctx, 1, 2);
  1748. xf_emit(ctx, 2, 1);
  1749. xf_emit(ctx, 1, 2);
  1750. xf_emit(ctx, 2, 1);
  1751. if (dev_priv->chipset >= 0xa0)
  1752. xf_emit(ctx, 4, 0);
  1753. else
  1754. xf_emit(ctx, 3, 0);
  1755. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  1756. xf_emit(ctx, 0x10, 1);
  1757. xf_emit(ctx, 8, 2);
  1758. xf_emit(ctx, 0x10, 1);
  1759. xf_emit(ctx, 8, 2);
  1760. xf_emit(ctx, 8, 1);
  1761. xf_emit(ctx, 3, 0);
  1762. }
  1763. xf_emit(ctx, 1, 0x11);
  1764. xf_emit(ctx, 1, 1);
  1765. xf_emit(ctx, 0x5b, 0);
  1766. }
  1767. static void
  1768. nv50_graph_construct_xfer_tp_x1(struct nouveau_grctx *ctx)
  1769. {
  1770. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1771. int magic3;
  1772. if (dev_priv->chipset == 0x50)
  1773. magic3 = 0x1000;
  1774. else if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x98 || dev_priv->chipset >= 0xa8)
  1775. magic3 = 0x1e00;
  1776. else
  1777. magic3 = 0;
  1778. xf_emit(ctx, 1, 0);
  1779. xf_emit(ctx, 1, 4);
  1780. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1781. xf_emit(ctx, 0x24, 0);
  1782. else if (dev_priv->chipset >= 0xa0)
  1783. xf_emit(ctx, 0x14, 0);
  1784. else
  1785. xf_emit(ctx, 0x15, 0);
  1786. xf_emit(ctx, 2, 4);
  1787. if (dev_priv->chipset >= 0xa0)
  1788. xf_emit(ctx, 1, 0x03020100);
  1789. else
  1790. xf_emit(ctx, 1, 0x00608080);
  1791. xf_emit(ctx, 4, 0);
  1792. xf_emit(ctx, 1, 4);
  1793. xf_emit(ctx, 2, 0);
  1794. xf_emit(ctx, 2, 4);
  1795. xf_emit(ctx, 1, 0x80);
  1796. if (magic3)
  1797. xf_emit(ctx, 1, magic3);
  1798. xf_emit(ctx, 1, 4);
  1799. xf_emit(ctx, 0x24, 0);
  1800. xf_emit(ctx, 1, 4);
  1801. xf_emit(ctx, 1, 0x80);
  1802. xf_emit(ctx, 1, 4);
  1803. xf_emit(ctx, 1, 0x03020100);
  1804. xf_emit(ctx, 1, 3);
  1805. if (magic3)
  1806. xf_emit(ctx, 1, magic3);
  1807. xf_emit(ctx, 1, 4);
  1808. xf_emit(ctx, 4, 0);
  1809. xf_emit(ctx, 1, 4);
  1810. xf_emit(ctx, 1, 3);
  1811. xf_emit(ctx, 3, 0);
  1812. xf_emit(ctx, 1, 4);
  1813. if (dev_priv->chipset == 0x94 || dev_priv->chipset == 0x96)
  1814. xf_emit(ctx, 0x1024, 0);
  1815. else if (dev_priv->chipset < 0xa0)
  1816. xf_emit(ctx, 0xa24, 0);
  1817. else if (dev_priv->chipset == 0xa0 || dev_priv->chipset >= 0xaa)
  1818. xf_emit(ctx, 0x214, 0);
  1819. else
  1820. xf_emit(ctx, 0x414, 0);
  1821. xf_emit(ctx, 1, 4);
  1822. xf_emit(ctx, 1, 3);
  1823. xf_emit(ctx, 2, 0);
  1824. }
  1825. static void
  1826. nv50_graph_construct_xfer_tp_x2(struct nouveau_grctx *ctx)
  1827. {
  1828. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  1829. int magic1, magic2;
  1830. if (dev_priv->chipset == 0x50) {
  1831. magic1 = 0x3ff;
  1832. magic2 = 0x00003e60;
  1833. } else if (dev_priv->chipset <= 0xa0 || dev_priv->chipset >= 0xaa) {
  1834. magic1 = 0x7ff;
  1835. magic2 = 0x001ffe67;
  1836. } else {
  1837. magic1 = 0x7ff;
  1838. magic2 = 0x00087e67;
  1839. }
  1840. xf_emit(ctx, 3, 0);
  1841. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1842. xf_emit(ctx, 1, 1);
  1843. xf_emit(ctx, 0xc, 0);
  1844. xf_emit(ctx, 1, 0xf);
  1845. xf_emit(ctx, 0xb, 0);
  1846. xf_emit(ctx, 1, 4);
  1847. xf_emit(ctx, 4, 0xffff);
  1848. xf_emit(ctx, 8, 0);
  1849. xf_emit(ctx, 1, 1);
  1850. xf_emit(ctx, 3, 0);
  1851. xf_emit(ctx, 1, 1);
  1852. xf_emit(ctx, 5, 0);
  1853. xf_emit(ctx, 1, 1);
  1854. xf_emit(ctx, 2, 0);
  1855. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  1856. xf_emit(ctx, 1, 3);
  1857. xf_emit(ctx, 1, 0);
  1858. } else if (dev_priv->chipset >= 0xa0)
  1859. xf_emit(ctx, 1, 1);
  1860. xf_emit(ctx, 0xa, 0);
  1861. xf_emit(ctx, 2, 1);
  1862. xf_emit(ctx, 1, 2);
  1863. xf_emit(ctx, 2, 1);
  1864. xf_emit(ctx, 1, 2);
  1865. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  1866. xf_emit(ctx, 1, 0);
  1867. xf_emit(ctx, 0x18, 1);
  1868. xf_emit(ctx, 8, 2);
  1869. xf_emit(ctx, 8, 1);
  1870. xf_emit(ctx, 8, 2);
  1871. xf_emit(ctx, 8, 1);
  1872. xf_emit(ctx, 1, 0);
  1873. }
  1874. xf_emit(ctx, 1, 1);
  1875. xf_emit(ctx, 1, 0);
  1876. xf_emit(ctx, 1, 0x11);
  1877. xf_emit(ctx, 7, 0);
  1878. xf_emit(ctx, 1, 0x0fac6881);
  1879. xf_emit(ctx, 2, 0);
  1880. xf_emit(ctx, 1, 4);
  1881. xf_emit(ctx, 3, 0);
  1882. xf_emit(ctx, 1, 0x11);
  1883. xf_emit(ctx, 1, 1);
  1884. xf_emit(ctx, 1, 0);
  1885. xf_emit(ctx, 3, 0xcf);
  1886. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1887. xf_emit(ctx, 1, 1);
  1888. xf_emit(ctx, 0xa, 0);
  1889. xf_emit(ctx, 2, 1);
  1890. xf_emit(ctx, 1, 2);
  1891. xf_emit(ctx, 2, 1);
  1892. xf_emit(ctx, 1, 2);
  1893. xf_emit(ctx, 1, 1);
  1894. xf_emit(ctx, 1, 0);
  1895. xf_emit(ctx, 8, 1);
  1896. xf_emit(ctx, 1, 0x11);
  1897. xf_emit(ctx, 7, 0);
  1898. xf_emit(ctx, 1, 0x0fac6881);
  1899. xf_emit(ctx, 1, 0xf);
  1900. xf_emit(ctx, 7, 0);
  1901. xf_emit(ctx, 1, magic2);
  1902. xf_emit(ctx, 2, 0);
  1903. xf_emit(ctx, 1, 0x11);
  1904. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1905. xf_emit(ctx, 2, 1);
  1906. else
  1907. xf_emit(ctx, 1, 1);
  1908. if(dev_priv->chipset == 0x50)
  1909. xf_emit(ctx, 1, 0);
  1910. else
  1911. xf_emit(ctx, 3, 0);
  1912. xf_emit(ctx, 1, 4);
  1913. xf_emit(ctx, 5, 0);
  1914. xf_emit(ctx, 1, 1);
  1915. xf_emit(ctx, 4, 0);
  1916. xf_emit(ctx, 1, 0x11);
  1917. xf_emit(ctx, 7, 0);
  1918. xf_emit(ctx, 1, 0x0fac6881);
  1919. xf_emit(ctx, 3, 0);
  1920. xf_emit(ctx, 1, 0x11);
  1921. xf_emit(ctx, 1, 1);
  1922. xf_emit(ctx, 1, 0);
  1923. xf_emit(ctx, 1, 1);
  1924. xf_emit(ctx, 1, 0);
  1925. xf_emit(ctx, 1, 1);
  1926. xf_emit(ctx, 1, 0);
  1927. xf_emit(ctx, 1, magic1);
  1928. xf_emit(ctx, 1, 0);
  1929. xf_emit(ctx, 1, 1);
  1930. xf_emit(ctx, 1, 0);
  1931. xf_emit(ctx, 1, 1);
  1932. xf_emit(ctx, 2, 0);
  1933. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1934. xf_emit(ctx, 1, 1);
  1935. xf_emit(ctx, 0x28, 0);
  1936. xf_emit(ctx, 8, 8);
  1937. xf_emit(ctx, 1, 0x11);
  1938. xf_emit(ctx, 7, 0);
  1939. xf_emit(ctx, 1, 0x0fac6881);
  1940. xf_emit(ctx, 8, 0x400);
  1941. xf_emit(ctx, 8, 0x300);
  1942. xf_emit(ctx, 1, 1);
  1943. xf_emit(ctx, 1, 0xf);
  1944. xf_emit(ctx, 7, 0);
  1945. xf_emit(ctx, 1, 0x20);
  1946. xf_emit(ctx, 1, 0x11);
  1947. xf_emit(ctx, 1, 0x100);
  1948. xf_emit(ctx, 1, 0);
  1949. xf_emit(ctx, 1, 1);
  1950. xf_emit(ctx, 2, 0);
  1951. xf_emit(ctx, 1, 0x40);
  1952. xf_emit(ctx, 1, 0x100);
  1953. xf_emit(ctx, 1, 0);
  1954. xf_emit(ctx, 1, 3);
  1955. xf_emit(ctx, 4, 0);
  1956. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1957. xf_emit(ctx, 1, 1);
  1958. xf_emit(ctx, 1, magic2);
  1959. xf_emit(ctx, 3, 0);
  1960. xf_emit(ctx, 1, 2);
  1961. xf_emit(ctx, 1, 0x0fac6881);
  1962. xf_emit(ctx, 9, 0);
  1963. xf_emit(ctx, 1, 1);
  1964. xf_emit(ctx, 4, 0);
  1965. xf_emit(ctx, 1, 4);
  1966. xf_emit(ctx, 1, 0);
  1967. xf_emit(ctx, 1, 1);
  1968. xf_emit(ctx, 1, 0x400);
  1969. xf_emit(ctx, 1, 0x300);
  1970. xf_emit(ctx, 1, 0x1001);
  1971. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1972. xf_emit(ctx, 4, 0);
  1973. else
  1974. xf_emit(ctx, 3, 0);
  1975. xf_emit(ctx, 1, 0x11);
  1976. xf_emit(ctx, 7, 0);
  1977. xf_emit(ctx, 1, 0x0fac6881);
  1978. xf_emit(ctx, 1, 0xf);
  1979. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  1980. xf_emit(ctx, 0x15, 0);
  1981. xf_emit(ctx, 1, 1);
  1982. xf_emit(ctx, 3, 0);
  1983. } else
  1984. xf_emit(ctx, 0x17, 0);
  1985. if (dev_priv->chipset >= 0xa0)
  1986. xf_emit(ctx, 1, 0x0fac6881);
  1987. xf_emit(ctx, 1, magic2);
  1988. xf_emit(ctx, 3, 0);
  1989. xf_emit(ctx, 1, 0x11);
  1990. xf_emit(ctx, 2, 0);
  1991. xf_emit(ctx, 1, 4);
  1992. xf_emit(ctx, 1, 0);
  1993. xf_emit(ctx, 2, 1);
  1994. xf_emit(ctx, 3, 0);
  1995. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  1996. xf_emit(ctx, 2, 1);
  1997. else
  1998. xf_emit(ctx, 1, 1);
  1999. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  2000. xf_emit(ctx, 2, 0);
  2001. else if (dev_priv->chipset != 0x50)
  2002. xf_emit(ctx, 1, 0);
  2003. }
  2004. static void
  2005. nv50_graph_construct_xfer_tp_x3(struct nouveau_grctx *ctx)
  2006. {
  2007. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2008. xf_emit(ctx, 3, 0);
  2009. xf_emit(ctx, 1, 1);
  2010. xf_emit(ctx, 1, 0);
  2011. xf_emit(ctx, 1, 1);
  2012. if (dev_priv->chipset == 0x50)
  2013. xf_emit(ctx, 2, 0);
  2014. else
  2015. xf_emit(ctx, 3, 0);
  2016. xf_emit(ctx, 1, 0x2a712488);
  2017. xf_emit(ctx, 1, 0);
  2018. xf_emit(ctx, 1, 0x4085c000);
  2019. xf_emit(ctx, 1, 0x40);
  2020. xf_emit(ctx, 1, 0x100);
  2021. xf_emit(ctx, 1, 0x10100);
  2022. xf_emit(ctx, 1, 0x02800000);
  2023. }
  2024. static void
  2025. nv50_graph_construct_xfer_tp_x4(struct nouveau_grctx *ctx)
  2026. {
  2027. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2028. xf_emit(ctx, 2, 0x04e3bfdf);
  2029. xf_emit(ctx, 1, 1);
  2030. xf_emit(ctx, 1, 0);
  2031. xf_emit(ctx, 1, 0x00ffff00);
  2032. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  2033. xf_emit(ctx, 2, 1);
  2034. else
  2035. xf_emit(ctx, 1, 1);
  2036. xf_emit(ctx, 2, 0);
  2037. xf_emit(ctx, 1, 0x00ffff00);
  2038. xf_emit(ctx, 8, 0);
  2039. xf_emit(ctx, 1, 1);
  2040. xf_emit(ctx, 1, 0);
  2041. xf_emit(ctx, 1, 1);
  2042. xf_emit(ctx, 1, 0x30201000);
  2043. xf_emit(ctx, 1, 0x70605040);
  2044. xf_emit(ctx, 1, 0xb8a89888);
  2045. xf_emit(ctx, 1, 0xf8e8d8c8);
  2046. xf_emit(ctx, 1, 0);
  2047. xf_emit(ctx, 1, 0x1a);
  2048. }
  2049. static void
  2050. nv50_graph_construct_xfer_tp_x5(struct nouveau_grctx *ctx)
  2051. {
  2052. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2053. xf_emit(ctx, 3, 0);
  2054. xf_emit(ctx, 1, 0xfac6881);
  2055. xf_emit(ctx, 4, 0);
  2056. xf_emit(ctx, 1, 4);
  2057. xf_emit(ctx, 1, 0);
  2058. xf_emit(ctx, 2, 1);
  2059. xf_emit(ctx, 2, 0);
  2060. xf_emit(ctx, 1, 1);
  2061. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  2062. xf_emit(ctx, 0xb, 0);
  2063. else
  2064. xf_emit(ctx, 0xa, 0);
  2065. xf_emit(ctx, 8, 1);
  2066. xf_emit(ctx, 1, 0x11);
  2067. xf_emit(ctx, 7, 0);
  2068. xf_emit(ctx, 1, 0xfac6881);
  2069. xf_emit(ctx, 1, 0xf);
  2070. xf_emit(ctx, 7, 0);
  2071. xf_emit(ctx, 1, 0x11);
  2072. xf_emit(ctx, 1, 1);
  2073. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  2074. xf_emit(ctx, 6, 0);
  2075. xf_emit(ctx, 1, 1);
  2076. xf_emit(ctx, 6, 0);
  2077. } else {
  2078. xf_emit(ctx, 0xb, 0);
  2079. }
  2080. }
  2081. static void
  2082. nv50_graph_construct_xfer_tp(struct nouveau_grctx *ctx)
  2083. {
  2084. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2085. if (dev_priv->chipset < 0xa0) {
  2086. nv50_graph_construct_xfer_tp_x1(ctx);
  2087. nv50_graph_construct_xfer_tp_x2(ctx);
  2088. nv50_graph_construct_xfer_tp_x3(ctx);
  2089. if (dev_priv->chipset == 0x50)
  2090. xf_emit(ctx, 0xf, 0);
  2091. else
  2092. xf_emit(ctx, 0x12, 0);
  2093. nv50_graph_construct_xfer_tp_x4(ctx);
  2094. } else {
  2095. nv50_graph_construct_xfer_tp_x3(ctx);
  2096. if (dev_priv->chipset < 0xaa)
  2097. xf_emit(ctx, 0xc, 0);
  2098. else
  2099. xf_emit(ctx, 0xa, 0);
  2100. nv50_graph_construct_xfer_tp_x2(ctx);
  2101. nv50_graph_construct_xfer_tp_x5(ctx);
  2102. nv50_graph_construct_xfer_tp_x4(ctx);
  2103. nv50_graph_construct_xfer_tp_x1(ctx);
  2104. }
  2105. }
  2106. static void
  2107. nv50_graph_construct_xfer_tp2(struct nouveau_grctx *ctx)
  2108. {
  2109. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2110. int i, mpcnt;
  2111. if (dev_priv->chipset == 0x98 || dev_priv->chipset == 0xaa)
  2112. mpcnt = 1;
  2113. else if (dev_priv->chipset < 0xa0 || dev_priv->chipset >= 0xa8)
  2114. mpcnt = 2;
  2115. else
  2116. mpcnt = 3;
  2117. for (i = 0; i < mpcnt; i++) {
  2118. xf_emit(ctx, 1, 0);
  2119. xf_emit(ctx, 1, 0x80);
  2120. xf_emit(ctx, 1, 0x80007004);
  2121. xf_emit(ctx, 1, 0x04000400);
  2122. if (dev_priv->chipset >= 0xa0)
  2123. xf_emit(ctx, 1, 0xc0);
  2124. xf_emit(ctx, 1, 0x1000);
  2125. xf_emit(ctx, 2, 0);
  2126. if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x98 || dev_priv->chipset >= 0xa8) {
  2127. xf_emit(ctx, 1, 0xe00);
  2128. xf_emit(ctx, 1, 0x1e00);
  2129. }
  2130. xf_emit(ctx, 1, 1);
  2131. xf_emit(ctx, 2, 0);
  2132. if (dev_priv->chipset == 0x50)
  2133. xf_emit(ctx, 2, 0x1000);
  2134. xf_emit(ctx, 1, 1);
  2135. xf_emit(ctx, 1, 0);
  2136. xf_emit(ctx, 1, 4);
  2137. xf_emit(ctx, 1, 2);
  2138. if (dev_priv->chipset >= 0xaa)
  2139. xf_emit(ctx, 0xb, 0);
  2140. else if (dev_priv->chipset >= 0xa0)
  2141. xf_emit(ctx, 0xc, 0);
  2142. else
  2143. xf_emit(ctx, 0xa, 0);
  2144. }
  2145. xf_emit(ctx, 1, 0x08100c12);
  2146. xf_emit(ctx, 1, 0);
  2147. if (dev_priv->chipset >= 0xa0) {
  2148. xf_emit(ctx, 1, 0x1fe21);
  2149. }
  2150. xf_emit(ctx, 5, 0);
  2151. xf_emit(ctx, 4, 0xffff);
  2152. xf_emit(ctx, 1, 1);
  2153. xf_emit(ctx, 2, 0x10001);
  2154. xf_emit(ctx, 1, 1);
  2155. xf_emit(ctx, 1, 0);
  2156. xf_emit(ctx, 1, 0x1fe21);
  2157. xf_emit(ctx, 1, 0);
  2158. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  2159. xf_emit(ctx, 1, 1);
  2160. xf_emit(ctx, 4, 0);
  2161. xf_emit(ctx, 1, 0x08100c12);
  2162. xf_emit(ctx, 1, 4);
  2163. xf_emit(ctx, 1, 0);
  2164. xf_emit(ctx, 1, 2);
  2165. xf_emit(ctx, 1, 0x11);
  2166. xf_emit(ctx, 8, 0);
  2167. xf_emit(ctx, 1, 0xfac6881);
  2168. xf_emit(ctx, 1, 0);
  2169. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa)
  2170. xf_emit(ctx, 1, 3);
  2171. xf_emit(ctx, 3, 0);
  2172. xf_emit(ctx, 1, 4);
  2173. xf_emit(ctx, 9, 0);
  2174. xf_emit(ctx, 1, 2);
  2175. xf_emit(ctx, 2, 1);
  2176. xf_emit(ctx, 1, 2);
  2177. xf_emit(ctx, 3, 1);
  2178. xf_emit(ctx, 1, 0);
  2179. if (dev_priv->chipset > 0xa0 && dev_priv->chipset < 0xaa) {
  2180. xf_emit(ctx, 8, 2);
  2181. xf_emit(ctx, 0x10, 1);
  2182. xf_emit(ctx, 8, 2);
  2183. xf_emit(ctx, 0x18, 1);
  2184. xf_emit(ctx, 3, 0);
  2185. }
  2186. xf_emit(ctx, 1, 4);
  2187. if (dev_priv->chipset == 0x50)
  2188. xf_emit(ctx, 0x3a0, 0);
  2189. else if (dev_priv->chipset < 0x94)
  2190. xf_emit(ctx, 0x3a2, 0);
  2191. else if (dev_priv->chipset == 0x98 || dev_priv->chipset == 0xaa)
  2192. xf_emit(ctx, 0x39f, 0);
  2193. else
  2194. xf_emit(ctx, 0x3a3, 0);
  2195. xf_emit(ctx, 1, 0x11);
  2196. xf_emit(ctx, 1, 0);
  2197. xf_emit(ctx, 1, 1);
  2198. xf_emit(ctx, 0x2d, 0);
  2199. }
  2200. static void
  2201. nv50_graph_construct_xfer2(struct nouveau_grctx *ctx)
  2202. {
  2203. struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
  2204. int i;
  2205. uint32_t offset;
  2206. uint32_t units = nv_rd32 (ctx->dev, 0x1540);
  2207. int size = 0;
  2208. offset = (ctx->ctxvals_pos+0x3f)&~0x3f;
  2209. if (dev_priv->chipset < 0xa0) {
  2210. for (i = 0; i < 8; i++) {
  2211. ctx->ctxvals_pos = offset + i;
  2212. if (i == 0)
  2213. xf_emit(ctx, 1, 0x08100c12);
  2214. if (units & (1 << i))
  2215. nv50_graph_construct_xfer_tp2(ctx);
  2216. if ((ctx->ctxvals_pos-offset)/8 > size)
  2217. size = (ctx->ctxvals_pos-offset)/8;
  2218. }
  2219. } else {
  2220. /* Strand 0: TPs 0, 1 */
  2221. ctx->ctxvals_pos = offset;
  2222. xf_emit(ctx, 1, 0x08100c12);
  2223. if (units & (1 << 0))
  2224. nv50_graph_construct_xfer_tp2(ctx);
  2225. if (units & (1 << 1))
  2226. nv50_graph_construct_xfer_tp2(ctx);
  2227. if ((ctx->ctxvals_pos-offset)/8 > size)
  2228. size = (ctx->ctxvals_pos-offset)/8;
  2229. /* Strand 0: TPs 2, 3 */
  2230. ctx->ctxvals_pos = offset + 1;
  2231. if (units & (1 << 2))
  2232. nv50_graph_construct_xfer_tp2(ctx);
  2233. if (units & (1 << 3))
  2234. nv50_graph_construct_xfer_tp2(ctx);
  2235. if ((ctx->ctxvals_pos-offset)/8 > size)
  2236. size = (ctx->ctxvals_pos-offset)/8;
  2237. /* Strand 0: TPs 4, 5, 6 */
  2238. ctx->ctxvals_pos = offset + 2;
  2239. if (units & (1 << 4))
  2240. nv50_graph_construct_xfer_tp2(ctx);
  2241. if (units & (1 << 5))
  2242. nv50_graph_construct_xfer_tp2(ctx);
  2243. if (units & (1 << 6))
  2244. nv50_graph_construct_xfer_tp2(ctx);
  2245. if ((ctx->ctxvals_pos-offset)/8 > size)
  2246. size = (ctx->ctxvals_pos-offset)/8;
  2247. /* Strand 0: TPs 7, 8, 9 */
  2248. ctx->ctxvals_pos = offset + 3;
  2249. if (units & (1 << 7))
  2250. nv50_graph_construct_xfer_tp2(ctx);
  2251. if (units & (1 << 8))
  2252. nv50_graph_construct_xfer_tp2(ctx);
  2253. if (units & (1 << 9))
  2254. nv50_graph_construct_xfer_tp2(ctx);
  2255. if ((ctx->ctxvals_pos-offset)/8 > size)
  2256. size = (ctx->ctxvals_pos-offset)/8;
  2257. }
  2258. ctx->ctxvals_pos = offset + size * 8;
  2259. ctx->ctxvals_pos = (ctx->ctxvals_pos+0x3f)&~0x3f;
  2260. cp_lsr (ctx, offset);
  2261. cp_out (ctx, CP_SET_XFER_POINTER);
  2262. cp_lsr (ctx, size);
  2263. cp_out (ctx, CP_SEEK_2);
  2264. cp_out (ctx, CP_XFER_2);
  2265. cp_wait(ctx, XFER, BUSY);
  2266. }