ctxnv50.c 123 KB

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