nv50_grctx.c 66 KB

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