nv50_grctx.c 124 KB

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