nv50_grctx.c 124 KB

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