nv50_grctx.c 67 KB

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