ctxnv50.c 123 KB

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