radeon_drv.h 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172
  1. /* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
  2. *
  3. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  4. * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
  5. * All rights reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the next
  15. * paragraph) shall be included in all copies or substantial portions of the
  16. * Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  22. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24. * DEALINGS IN THE SOFTWARE.
  25. *
  26. * Authors:
  27. * Kevin E. Martin <martin@valinux.com>
  28. * Gareth Hughes <gareth@valinux.com>
  29. */
  30. #ifndef __RADEON_DRV_H__
  31. #define __RADEON_DRV_H__
  32. #include <linux/firmware.h>
  33. #include <linux/platform_device.h>
  34. #include "radeon_family.h"
  35. /* General customization:
  36. */
  37. #define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
  38. #define DRIVER_NAME "radeon"
  39. #define DRIVER_DESC "ATI Radeon"
  40. #define DRIVER_DATE "20080528"
  41. /* Interface history:
  42. *
  43. * 1.1 - ??
  44. * 1.2 - Add vertex2 ioctl (keith)
  45. * - Add stencil capability to clear ioctl (gareth, keith)
  46. * - Increase MAX_TEXTURE_LEVELS (brian)
  47. * 1.3 - Add cmdbuf ioctl (keith)
  48. * - Add support for new radeon packets (keith)
  49. * - Add getparam ioctl (keith)
  50. * - Add flip-buffers ioctl, deprecate fullscreen foo (keith).
  51. * 1.4 - Add scratch registers to get_param ioctl.
  52. * 1.5 - Add r200 packets to cmdbuf ioctl
  53. * - Add r200 function to init ioctl
  54. * - Add 'scalar2' instruction to cmdbuf
  55. * 1.6 - Add static GART memory manager
  56. * Add irq handler (won't be turned on unless X server knows to)
  57. * Add irq ioctls and irq_active getparam.
  58. * Add wait command for cmdbuf ioctl
  59. * Add GART offset query for getparam
  60. * 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5]
  61. * and R200_PP_CUBIC_OFFSET_F1_[0..5].
  62. * Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
  63. * R200_EMIT_PP_CUBIC_OFFSETS_[0..5]. (brian)
  64. * 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
  65. * Add 'GET' queries for starting additional clients on different VT's.
  66. * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl.
  67. * Add texture rectangle support for r100.
  68. * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which
  69. * clients use to tell the DRM where they think the framebuffer is
  70. * located in the card's address space
  71. * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color
  72. * and GL_EXT_blend_[func|equation]_separate on r200
  73. * 1.12- Add R300 CP microcode support - this just loads the CP on r300
  74. * (No 3D support yet - just microcode loading).
  75. * 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters
  76. * - Add hyperz support, add hyperz flags to clear ioctl.
  77. * 1.14- Add support for color tiling
  78. * - Add R100/R200 surface allocation/free support
  79. * 1.15- Add support for texture micro tiling
  80. * - Add support for r100 cube maps
  81. * 1.16- Add R200_EMIT_PP_TRI_PERF_CNTL packet to support brilinear
  82. * texture filtering on r200
  83. * 1.17- Add initial support for R300 (3D).
  84. * 1.18- Add support for GL_ATI_fragment_shader, new packets
  85. * R200_EMIT_PP_AFS_0/1, R200_EMIT_PP_TXCTLALL_0-5 (replaces
  86. * R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and R200_EMIT_ATF_TFACTOR
  87. * (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6)
  88. * 1.19- Add support for gart table in FB memory and PCIE r300
  89. * 1.20- Add support for r300 texrect
  90. * 1.21- Add support for card type getparam
  91. * 1.22- Add support for texture cache flushes (R300_TX_CNTL)
  92. * 1.23- Add new radeon memory map work from benh
  93. * 1.24- Add general-purpose packet for manipulating scratch registers (r300)
  94. * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL,
  95. * new packet type)
  96. * 1.26- Add support for variable size PCI(E) gart aperture
  97. * 1.27- Add support for IGP GART
  98. * 1.28- Add support for VBL on CRTC2
  99. * 1.29- R500 3D cmd buffer support
  100. * 1.30- Add support for occlusion queries
  101. * 1.31- Add support for num Z pipes from GET_PARAM
  102. * 1.32- fixes for rv740 setup
  103. * 1.33- Add r6xx/r7xx const buffer support
  104. */
  105. #define DRIVER_MAJOR 1
  106. #define DRIVER_MINOR 33
  107. #define DRIVER_PATCHLEVEL 0
  108. enum radeon_cp_microcode_version {
  109. UCODE_R100,
  110. UCODE_R200,
  111. UCODE_R300,
  112. };
  113. typedef struct drm_radeon_freelist {
  114. unsigned int age;
  115. struct drm_buf *buf;
  116. struct drm_radeon_freelist *next;
  117. struct drm_radeon_freelist *prev;
  118. } drm_radeon_freelist_t;
  119. typedef struct drm_radeon_ring_buffer {
  120. u32 *start;
  121. u32 *end;
  122. int size;
  123. int size_l2qw;
  124. int rptr_update; /* Double Words */
  125. int rptr_update_l2qw; /* log2 Quad Words */
  126. int fetch_size; /* Double Words */
  127. int fetch_size_l2ow; /* log2 Oct Words */
  128. u32 tail;
  129. u32 tail_mask;
  130. int space;
  131. int high_mark;
  132. } drm_radeon_ring_buffer_t;
  133. typedef struct drm_radeon_depth_clear_t {
  134. u32 rb3d_cntl;
  135. u32 rb3d_zstencilcntl;
  136. u32 se_cntl;
  137. } drm_radeon_depth_clear_t;
  138. struct drm_radeon_driver_file_fields {
  139. int64_t radeon_fb_delta;
  140. };
  141. struct mem_block {
  142. struct mem_block *next;
  143. struct mem_block *prev;
  144. int start;
  145. int size;
  146. struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
  147. };
  148. struct radeon_surface {
  149. int refcount;
  150. u32 lower;
  151. u32 upper;
  152. u32 flags;
  153. };
  154. struct radeon_virt_surface {
  155. int surface_index;
  156. u32 lower;
  157. u32 upper;
  158. u32 flags;
  159. struct drm_file *file_priv;
  160. #define PCIGART_FILE_PRIV ((void *) -1L)
  161. };
  162. #define RADEON_FLUSH_EMITED (1 << 0)
  163. #define RADEON_PURGE_EMITED (1 << 1)
  164. struct drm_radeon_master_private {
  165. drm_local_map_t *sarea;
  166. drm_radeon_sarea_t *sarea_priv;
  167. };
  168. typedef struct drm_radeon_private {
  169. drm_radeon_ring_buffer_t ring;
  170. u32 fb_location;
  171. u32 fb_size;
  172. int new_memmap;
  173. int gart_size;
  174. u32 gart_vm_start;
  175. unsigned long gart_buffers_offset;
  176. int cp_mode;
  177. int cp_running;
  178. drm_radeon_freelist_t *head;
  179. drm_radeon_freelist_t *tail;
  180. int last_buf;
  181. int writeback_works;
  182. int usec_timeout;
  183. int microcode_version;
  184. struct {
  185. u32 boxes;
  186. int freelist_timeouts;
  187. int freelist_loops;
  188. int requested_bufs;
  189. int last_frame_reads;
  190. int last_clear_reads;
  191. int clears;
  192. int texture_uploads;
  193. } stats;
  194. int do_boxes;
  195. int page_flipping;
  196. u32 color_fmt;
  197. unsigned int front_offset;
  198. unsigned int front_pitch;
  199. unsigned int back_offset;
  200. unsigned int back_pitch;
  201. u32 depth_fmt;
  202. unsigned int depth_offset;
  203. unsigned int depth_pitch;
  204. u32 front_pitch_offset;
  205. u32 back_pitch_offset;
  206. u32 depth_pitch_offset;
  207. drm_radeon_depth_clear_t depth_clear;
  208. unsigned long ring_offset;
  209. unsigned long ring_rptr_offset;
  210. unsigned long buffers_offset;
  211. unsigned long gart_textures_offset;
  212. drm_local_map_t *sarea;
  213. drm_local_map_t *cp_ring;
  214. drm_local_map_t *ring_rptr;
  215. drm_local_map_t *gart_textures;
  216. struct mem_block *gart_heap;
  217. struct mem_block *fb_heap;
  218. /* SW interrupt */
  219. wait_queue_head_t swi_queue;
  220. atomic_t swi_emitted;
  221. int vblank_crtc;
  222. uint32_t irq_enable_reg;
  223. uint32_t r500_disp_irq_reg;
  224. struct radeon_surface surfaces[RADEON_MAX_SURFACES];
  225. struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES];
  226. unsigned long pcigart_offset;
  227. unsigned int pcigart_offset_set;
  228. struct drm_ati_pcigart_info gart_info;
  229. u32 scratch_ages[5];
  230. int have_z_offset;
  231. /* starting from here on, data is preserved across an open */
  232. uint32_t flags; /* see radeon_chip_flags */
  233. resource_size_t fb_aper_offset;
  234. int num_gb_pipes;
  235. int num_z_pipes;
  236. int track_flush;
  237. drm_local_map_t *mmio;
  238. /* r6xx/r7xx pipe/shader config */
  239. int r600_max_pipes;
  240. int r600_max_tile_pipes;
  241. int r600_max_simds;
  242. int r600_max_backends;
  243. int r600_max_gprs;
  244. int r600_max_threads;
  245. int r600_max_stack_entries;
  246. int r600_max_hw_contexts;
  247. int r600_max_gs_threads;
  248. int r600_sx_max_export_size;
  249. int r600_sx_max_export_pos_size;
  250. int r600_sx_max_export_smx_size;
  251. int r600_sq_num_cf_insts;
  252. int r700_sx_num_of_sets;
  253. int r700_sc_prim_fifo_size;
  254. int r700_sc_hiz_tile_fifo_size;
  255. int r700_sc_earlyz_tile_fifo_fize;
  256. int r600_group_size;
  257. int r600_npipes;
  258. int r600_nbanks;
  259. struct mutex cs_mutex;
  260. u32 cs_id_scnt;
  261. u32 cs_id_wcnt;
  262. /* r6xx/r7xx drm blit vertex buffer */
  263. struct drm_buf *blit_vb;
  264. /* firmware */
  265. const struct firmware *me_fw, *pfp_fw;
  266. } drm_radeon_private_t;
  267. typedef struct drm_radeon_buf_priv {
  268. u32 age;
  269. } drm_radeon_buf_priv_t;
  270. struct drm_buffer;
  271. typedef struct drm_radeon_kcmd_buffer {
  272. int bufsz;
  273. struct drm_buffer *buffer;
  274. int nbox;
  275. struct drm_clip_rect __user *boxes;
  276. } drm_radeon_kcmd_buffer_t;
  277. extern int radeon_no_wb;
  278. extern struct drm_ioctl_desc radeon_ioctls[];
  279. extern int radeon_max_ioctl;
  280. extern u32 radeon_get_ring_head(drm_radeon_private_t *dev_priv);
  281. extern void radeon_set_ring_head(drm_radeon_private_t *dev_priv, u32 val);
  282. #define GET_RING_HEAD(dev_priv) radeon_get_ring_head(dev_priv)
  283. #define SET_RING_HEAD(dev_priv, val) radeon_set_ring_head(dev_priv, val)
  284. /* Check whether the given hardware address is inside the framebuffer or the
  285. * GART area.
  286. */
  287. static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
  288. u64 off)
  289. {
  290. u32 fb_start = dev_priv->fb_location;
  291. u32 fb_end = fb_start + dev_priv->fb_size - 1;
  292. u32 gart_start = dev_priv->gart_vm_start;
  293. u32 gart_end = gart_start + dev_priv->gart_size - 1;
  294. return ((off >= fb_start && off <= fb_end) ||
  295. (off >= gart_start && off <= gart_end));
  296. }
  297. /* radeon_state.c */
  298. extern void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_master *master, struct drm_buf *buf);
  299. /* radeon_cp.c */
  300. extern int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
  301. extern int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv);
  302. extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv);
  303. extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
  304. extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv);
  305. extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv);
  306. extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
  307. extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
  308. extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
  309. extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv);
  310. extern void radeon_write_agp_location(drm_radeon_private_t *dev_priv, u32 agp_loc);
  311. extern void radeon_write_agp_base(drm_radeon_private_t *dev_priv, u64 agp_base);
  312. extern u32 RADEON_READ_MM(drm_radeon_private_t *dev_priv, int addr);
  313. extern void radeon_freelist_reset(struct drm_device * dev);
  314. extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
  315. extern int radeon_wait_ring(drm_radeon_private_t * dev_priv, int n);
  316. extern int radeon_do_cp_idle(drm_radeon_private_t * dev_priv);
  317. extern int radeon_driver_preinit(struct drm_device *dev, unsigned long flags);
  318. extern int radeon_presetup(struct drm_device *dev);
  319. extern int radeon_driver_postcleanup(struct drm_device *dev);
  320. extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
  321. extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
  322. extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv);
  323. extern void radeon_mem_takedown(struct mem_block **heap);
  324. extern void radeon_mem_release(struct drm_file *file_priv,
  325. struct mem_block *heap);
  326. extern void radeon_enable_bm(struct drm_radeon_private *dev_priv);
  327. extern u32 radeon_read_ring_rptr(drm_radeon_private_t *dev_priv, u32 off);
  328. extern void radeon_write_ring_rptr(drm_radeon_private_t *dev_priv, u32 off, u32 val);
  329. /* radeon_irq.c */
  330. extern void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state);
  331. extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv);
  332. extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
  333. extern void radeon_do_release(struct drm_device * dev);
  334. extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
  335. extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
  336. extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
  337. extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
  338. extern void radeon_driver_irq_preinstall(struct drm_device * dev);
  339. extern int radeon_driver_irq_postinstall(struct drm_device *dev);
  340. extern void radeon_driver_irq_uninstall(struct drm_device * dev);
  341. extern void radeon_enable_interrupt(struct drm_device *dev);
  342. extern int radeon_vblank_crtc_get(struct drm_device *dev);
  343. extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
  344. extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
  345. extern int radeon_driver_unload(struct drm_device *dev);
  346. extern int radeon_driver_firstopen(struct drm_device *dev);
  347. extern void radeon_driver_preclose(struct drm_device *dev,
  348. struct drm_file *file_priv);
  349. extern void radeon_driver_postclose(struct drm_device *dev,
  350. struct drm_file *file_priv);
  351. extern void radeon_driver_lastclose(struct drm_device * dev);
  352. extern int radeon_driver_open(struct drm_device *dev,
  353. struct drm_file *file_priv);
  354. extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
  355. unsigned long arg);
  356. extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd,
  357. unsigned long arg);
  358. extern int radeon_master_create(struct drm_device *dev, struct drm_master *master);
  359. extern void radeon_master_destroy(struct drm_device *dev, struct drm_master *master);
  360. extern void radeon_cp_dispatch_flip(struct drm_device *dev, struct drm_master *master);
  361. /* r300_cmdbuf.c */
  362. extern void r300_init_reg_flags(struct drm_device *dev);
  363. extern int r300_do_cp_cmdbuf(struct drm_device *dev,
  364. struct drm_file *file_priv,
  365. drm_radeon_kcmd_buffer_t *cmdbuf);
  366. /* r600_cp.c */
  367. extern int r600_do_engine_reset(struct drm_device *dev);
  368. extern int r600_do_cleanup_cp(struct drm_device *dev);
  369. extern int r600_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
  370. struct drm_file *file_priv);
  371. extern int r600_do_resume_cp(struct drm_device *dev, struct drm_file *file_priv);
  372. extern int r600_do_cp_idle(drm_radeon_private_t *dev_priv);
  373. extern void r600_do_cp_start(drm_radeon_private_t *dev_priv);
  374. extern void r600_do_cp_reset(drm_radeon_private_t *dev_priv);
  375. extern void r600_do_cp_stop(drm_radeon_private_t *dev_priv);
  376. extern int r600_cp_dispatch_indirect(struct drm_device *dev,
  377. struct drm_buf *buf, int start, int end);
  378. extern int r600_page_table_init(struct drm_device *dev);
  379. extern void r600_page_table_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info);
  380. extern int r600_cs_legacy_ioctl(struct drm_device *dev, void *data, struct drm_file *fpriv);
  381. extern void r600_cp_dispatch_swap(struct drm_device *dev, struct drm_file *file_priv);
  382. extern int r600_cp_dispatch_texture(struct drm_device *dev,
  383. struct drm_file *file_priv,
  384. drm_radeon_texture_t *tex,
  385. drm_radeon_tex_image_t *image);
  386. /* r600_blit.c */
  387. extern int r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv);
  388. extern void r600_done_blit_copy(struct drm_device *dev);
  389. extern void r600_blit_copy(struct drm_device *dev,
  390. uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
  391. int size_bytes);
  392. extern void r600_blit_swap(struct drm_device *dev,
  393. uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
  394. int sx, int sy, int dx, int dy,
  395. int w, int h, int src_pitch, int dst_pitch, int cpp);
  396. /* atpx handler */
  397. #if defined(CONFIG_VGA_SWITCHEROO)
  398. void radeon_register_atpx_handler(void);
  399. void radeon_unregister_atpx_handler(void);
  400. #else
  401. static inline void radeon_register_atpx_handler(void) {}
  402. static inline void radeon_unregister_atpx_handler(void) {}
  403. #endif
  404. /* Flags for stats.boxes
  405. */
  406. #define RADEON_BOX_DMA_IDLE 0x1
  407. #define RADEON_BOX_RING_FULL 0x2
  408. #define RADEON_BOX_FLIP 0x4
  409. #define RADEON_BOX_WAIT_IDLE 0x8
  410. #define RADEON_BOX_TEXTURE_LOAD 0x10
  411. /* Register definitions, register access macros and drmAddMap constants
  412. * for Radeon kernel driver.
  413. */
  414. #define RADEON_MM_INDEX 0x0000
  415. #define RADEON_MM_DATA 0x0004
  416. #define RADEON_AGP_COMMAND 0x0f60
  417. #define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config */
  418. # define RADEON_AGP_ENABLE (1<<8)
  419. #define RADEON_AUX_SCISSOR_CNTL 0x26f0
  420. # define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24)
  421. # define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25)
  422. # define RADEON_EXCLUSIVE_SCISSOR_2 (1 << 26)
  423. # define RADEON_SCISSOR_0_ENABLE (1 << 28)
  424. # define RADEON_SCISSOR_1_ENABLE (1 << 29)
  425. # define RADEON_SCISSOR_2_ENABLE (1 << 30)
  426. /*
  427. * PCIE radeons (rv370/rv380, rv410, r423/r430/r480, r5xx)
  428. * don't have an explicit bus mastering disable bit. It's handled
  429. * by the PCI D-states. PMI_BM_DIS disables D-state bus master
  430. * handling, not bus mastering itself.
  431. */
  432. #define RADEON_BUS_CNTL 0x0030
  433. /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
  434. # define RADEON_BUS_MASTER_DIS (1 << 6)
  435. /* rs600/rs690/rs740 */
  436. # define RS600_BUS_MASTER_DIS (1 << 14)
  437. # define RS600_MSI_REARM (1 << 20)
  438. /* see RS400_MSI_REARM in AIC_CNTL for rs480 */
  439. #define RADEON_BUS_CNTL1 0x0034
  440. # define RADEON_PMI_BM_DIS (1 << 2)
  441. # define RADEON_PMI_INT_DIS (1 << 3)
  442. #define RV370_BUS_CNTL 0x004c
  443. # define RV370_PMI_BM_DIS (1 << 5)
  444. # define RV370_PMI_INT_DIS (1 << 6)
  445. #define RADEON_MSI_REARM_EN 0x0160
  446. /* rv370/rv380, rv410, r423/r430/r480, r5xx */
  447. # define RV370_MSI_REARM_EN (1 << 0)
  448. #define RADEON_CLOCK_CNTL_DATA 0x000c
  449. # define RADEON_PLL_WR_EN (1 << 7)
  450. #define RADEON_CLOCK_CNTL_INDEX 0x0008
  451. #define RADEON_CONFIG_APER_SIZE 0x0108
  452. #define RADEON_CONFIG_MEMSIZE 0x00f8
  453. #define RADEON_CRTC_OFFSET 0x0224
  454. #define RADEON_CRTC_OFFSET_CNTL 0x0228
  455. # define RADEON_CRTC_TILE_EN (1 << 15)
  456. # define RADEON_CRTC_OFFSET_FLIP_CNTL (1 << 16)
  457. #define RADEON_CRTC2_OFFSET 0x0324
  458. #define RADEON_CRTC2_OFFSET_CNTL 0x0328
  459. #define RADEON_PCIE_INDEX 0x0030
  460. #define RADEON_PCIE_DATA 0x0034
  461. #define RADEON_PCIE_TX_GART_CNTL 0x10
  462. # define RADEON_PCIE_TX_GART_EN (1 << 0)
  463. # define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0 << 1)
  464. # define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1 << 1)
  465. # define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3 << 1)
  466. # define RADEON_PCIE_TX_GART_MODE_32_128_CACHE (0 << 3)
  467. # define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE (1 << 3)
  468. # define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN (1 << 5)
  469. # define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1 << 8)
  470. #define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11
  471. #define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12
  472. #define RADEON_PCIE_TX_GART_BASE 0x13
  473. #define RADEON_PCIE_TX_GART_START_LO 0x14
  474. #define RADEON_PCIE_TX_GART_START_HI 0x15
  475. #define RADEON_PCIE_TX_GART_END_LO 0x16
  476. #define RADEON_PCIE_TX_GART_END_HI 0x17
  477. #define RS480_NB_MC_INDEX 0x168
  478. # define RS480_NB_MC_IND_WR_EN (1 << 8)
  479. #define RS480_NB_MC_DATA 0x16c
  480. #define RS690_MC_INDEX 0x78
  481. # define RS690_MC_INDEX_MASK 0x1ff
  482. # define RS690_MC_INDEX_WR_EN (1 << 9)
  483. # define RS690_MC_INDEX_WR_ACK 0x7f
  484. #define RS690_MC_DATA 0x7c
  485. /* MC indirect registers */
  486. #define RS480_MC_MISC_CNTL 0x18
  487. # define RS480_DISABLE_GTW (1 << 1)
  488. /* switch between MCIND GART and MM GART registers. 0 = mmgart, 1 = mcind gart */
  489. # define RS480_GART_INDEX_REG_EN (1 << 12)
  490. # define RS690_BLOCK_GFX_D3_EN (1 << 14)
  491. #define RS480_K8_FB_LOCATION 0x1e
  492. #define RS480_GART_FEATURE_ID 0x2b
  493. # define RS480_HANG_EN (1 << 11)
  494. # define RS480_TLB_ENABLE (1 << 18)
  495. # define RS480_P2P_ENABLE (1 << 19)
  496. # define RS480_GTW_LAC_EN (1 << 25)
  497. # define RS480_2LEVEL_GART (0 << 30)
  498. # define RS480_1LEVEL_GART (1 << 30)
  499. # define RS480_PDC_EN (1 << 31)
  500. #define RS480_GART_BASE 0x2c
  501. #define RS480_GART_CACHE_CNTRL 0x2e
  502. # define RS480_GART_CACHE_INVALIDATE (1 << 0) /* wait for it to clear */
  503. #define RS480_AGP_ADDRESS_SPACE_SIZE 0x38
  504. # define RS480_GART_EN (1 << 0)
  505. # define RS480_VA_SIZE_32MB (0 << 1)
  506. # define RS480_VA_SIZE_64MB (1 << 1)
  507. # define RS480_VA_SIZE_128MB (2 << 1)
  508. # define RS480_VA_SIZE_256MB (3 << 1)
  509. # define RS480_VA_SIZE_512MB (4 << 1)
  510. # define RS480_VA_SIZE_1GB (5 << 1)
  511. # define RS480_VA_SIZE_2GB (6 << 1)
  512. #define RS480_AGP_MODE_CNTL 0x39
  513. # define RS480_POST_GART_Q_SIZE (1 << 18)
  514. # define RS480_NONGART_SNOOP (1 << 19)
  515. # define RS480_AGP_RD_BUF_SIZE (1 << 20)
  516. # define RS480_REQ_TYPE_SNOOP_SHIFT 22
  517. # define RS480_REQ_TYPE_SNOOP_MASK 0x3
  518. # define RS480_REQ_TYPE_SNOOP_DIS (1 << 24)
  519. #define RS480_MC_MISC_UMA_CNTL 0x5f
  520. #define RS480_MC_MCLK_CNTL 0x7a
  521. #define RS480_MC_UMA_DUALCH_CNTL 0x86
  522. #define RS690_MC_FB_LOCATION 0x100
  523. #define RS690_MC_AGP_LOCATION 0x101
  524. #define RS690_MC_AGP_BASE 0x102
  525. #define RS690_MC_AGP_BASE_2 0x103
  526. #define RS600_MC_INDEX 0x70
  527. # define RS600_MC_ADDR_MASK 0xffff
  528. # define RS600_MC_IND_SEQ_RBS_0 (1 << 16)
  529. # define RS600_MC_IND_SEQ_RBS_1 (1 << 17)
  530. # define RS600_MC_IND_SEQ_RBS_2 (1 << 18)
  531. # define RS600_MC_IND_SEQ_RBS_3 (1 << 19)
  532. # define RS600_MC_IND_AIC_RBS (1 << 20)
  533. # define RS600_MC_IND_CITF_ARB0 (1 << 21)
  534. # define RS600_MC_IND_CITF_ARB1 (1 << 22)
  535. # define RS600_MC_IND_WR_EN (1 << 23)
  536. #define RS600_MC_DATA 0x74
  537. #define RS600_MC_STATUS 0x0
  538. # define RS600_MC_IDLE (1 << 1)
  539. #define RS600_MC_FB_LOCATION 0x4
  540. #define RS600_MC_AGP_LOCATION 0x5
  541. #define RS600_AGP_BASE 0x6
  542. #define RS600_AGP_BASE_2 0x7
  543. #define RS600_MC_CNTL1 0x9
  544. # define RS600_ENABLE_PAGE_TABLES (1 << 26)
  545. #define RS600_MC_PT0_CNTL 0x100
  546. # define RS600_ENABLE_PT (1 << 0)
  547. # define RS600_EFFECTIVE_L2_CACHE_SIZE(x) ((x) << 15)
  548. # define RS600_EFFECTIVE_L2_QUEUE_SIZE(x) ((x) << 21)
  549. # define RS600_INVALIDATE_ALL_L1_TLBS (1 << 28)
  550. # define RS600_INVALIDATE_L2_CACHE (1 << 29)
  551. #define RS600_MC_PT0_CONTEXT0_CNTL 0x102
  552. # define RS600_ENABLE_PAGE_TABLE (1 << 0)
  553. # define RS600_PAGE_TABLE_TYPE_FLAT (0 << 1)
  554. #define RS600_MC_PT0_SYSTEM_APERTURE_LOW_ADDR 0x112
  555. #define RS600_MC_PT0_SYSTEM_APERTURE_HIGH_ADDR 0x114
  556. #define RS600_MC_PT0_CONTEXT0_DEFAULT_READ_ADDR 0x11c
  557. #define RS600_MC_PT0_CONTEXT0_FLAT_BASE_ADDR 0x12c
  558. #define RS600_MC_PT0_CONTEXT0_FLAT_START_ADDR 0x13c
  559. #define RS600_MC_PT0_CONTEXT0_FLAT_END_ADDR 0x14c
  560. #define RS600_MC_PT0_CLIENT0_CNTL 0x16c
  561. # define RS600_ENABLE_TRANSLATION_MODE_OVERRIDE (1 << 0)
  562. # define RS600_TRANSLATION_MODE_OVERRIDE (1 << 1)
  563. # define RS600_SYSTEM_ACCESS_MODE_MASK (3 << 8)
  564. # define RS600_SYSTEM_ACCESS_MODE_PA_ONLY (0 << 8)
  565. # define RS600_SYSTEM_ACCESS_MODE_USE_SYS_MAP (1 << 8)
  566. # define RS600_SYSTEM_ACCESS_MODE_IN_SYS (2 << 8)
  567. # define RS600_SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 8)
  568. # define RS600_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASSTHROUGH (0 << 10)
  569. # define RS600_SYSTEM_APERTURE_UNMAPPED_ACCESS_DEFAULT_PAGE (1 << 10)
  570. # define RS600_EFFECTIVE_L1_CACHE_SIZE(x) ((x) << 11)
  571. # define RS600_ENABLE_FRAGMENT_PROCESSING (1 << 14)
  572. # define RS600_EFFECTIVE_L1_QUEUE_SIZE(x) ((x) << 15)
  573. # define RS600_INVALIDATE_L1_TLB (1 << 20)
  574. #define R520_MC_IND_INDEX 0x70
  575. #define R520_MC_IND_WR_EN (1 << 24)
  576. #define R520_MC_IND_DATA 0x74
  577. #define RV515_MC_FB_LOCATION 0x01
  578. #define RV515_MC_AGP_LOCATION 0x02
  579. #define RV515_MC_AGP_BASE 0x03
  580. #define RV515_MC_AGP_BASE_2 0x04
  581. #define R520_MC_FB_LOCATION 0x04
  582. #define R520_MC_AGP_LOCATION 0x05
  583. #define R520_MC_AGP_BASE 0x06
  584. #define R520_MC_AGP_BASE_2 0x07
  585. #define RADEON_MPP_TB_CONFIG 0x01c0
  586. #define RADEON_MEM_CNTL 0x0140
  587. #define RADEON_MEM_SDRAM_MODE_REG 0x0158
  588. #define RADEON_AGP_BASE_2 0x015c /* r200+ only */
  589. #define RS480_AGP_BASE_2 0x0164
  590. #define RADEON_AGP_BASE 0x0170
  591. /* pipe config regs */
  592. #define R400_GB_PIPE_SELECT 0x402c
  593. #define RV530_GB_PIPE_SELECT2 0x4124
  594. #define R500_DYN_SCLK_PWMEM_PIPE 0x000d /* PLL */
  595. #define R300_GB_TILE_CONFIG 0x4018
  596. # define R300_ENABLE_TILING (1 << 0)
  597. # define R300_PIPE_COUNT_RV350 (0 << 1)
  598. # define R300_PIPE_COUNT_R300 (3 << 1)
  599. # define R300_PIPE_COUNT_R420_3P (6 << 1)
  600. # define R300_PIPE_COUNT_R420 (7 << 1)
  601. # define R300_TILE_SIZE_8 (0 << 4)
  602. # define R300_TILE_SIZE_16 (1 << 4)
  603. # define R300_TILE_SIZE_32 (2 << 4)
  604. # define R300_SUBPIXEL_1_12 (0 << 16)
  605. # define R300_SUBPIXEL_1_16 (1 << 16)
  606. #define R300_DST_PIPE_CONFIG 0x170c
  607. # define R300_PIPE_AUTO_CONFIG (1 << 31)
  608. #define R300_RB2D_DSTCACHE_MODE 0x3428
  609. # define R300_DC_AUTOFLUSH_ENABLE (1 << 8)
  610. # define R300_DC_DC_DISABLE_IGNORE_PE (1 << 17)
  611. #define RADEON_RB3D_COLOROFFSET 0x1c40
  612. #define RADEON_RB3D_COLORPITCH 0x1c48
  613. #define RADEON_SRC_X_Y 0x1590
  614. #define RADEON_DP_GUI_MASTER_CNTL 0x146c
  615. # define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
  616. # define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
  617. # define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4)
  618. # define RADEON_GMC_BRUSH_NONE (15 << 4)
  619. # define RADEON_GMC_DST_16BPP (4 << 8)
  620. # define RADEON_GMC_DST_24BPP (5 << 8)
  621. # define RADEON_GMC_DST_32BPP (6 << 8)
  622. # define RADEON_GMC_DST_DATATYPE_SHIFT 8
  623. # define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12)
  624. # define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24)
  625. # define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24)
  626. # define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28)
  627. # define RADEON_GMC_WR_MSK_DIS (1 << 30)
  628. # define RADEON_ROP3_S 0x00cc0000
  629. # define RADEON_ROP3_P 0x00f00000
  630. #define RADEON_DP_WRITE_MASK 0x16cc
  631. #define RADEON_SRC_PITCH_OFFSET 0x1428
  632. #define RADEON_DST_PITCH_OFFSET 0x142c
  633. #define RADEON_DST_PITCH_OFFSET_C 0x1c80
  634. # define RADEON_DST_TILE_LINEAR (0 << 30)
  635. # define RADEON_DST_TILE_MACRO (1 << 30)
  636. # define RADEON_DST_TILE_MICRO (2 << 30)
  637. # define RADEON_DST_TILE_BOTH (3 << 30)
  638. #define RADEON_SCRATCH_REG0 0x15e0
  639. #define RADEON_SCRATCH_REG1 0x15e4
  640. #define RADEON_SCRATCH_REG2 0x15e8
  641. #define RADEON_SCRATCH_REG3 0x15ec
  642. #define RADEON_SCRATCH_REG4 0x15f0
  643. #define RADEON_SCRATCH_REG5 0x15f4
  644. #define RADEON_SCRATCH_UMSK 0x0770
  645. #define RADEON_SCRATCH_ADDR 0x0774
  646. #define RADEON_SCRATCHOFF( x ) (RADEON_SCRATCH_REG_OFFSET + 4*(x))
  647. extern u32 radeon_get_scratch(drm_radeon_private_t *dev_priv, int index);
  648. #define GET_SCRATCH(dev_priv, x) radeon_get_scratch(dev_priv, x)
  649. #define R600_SCRATCH_REG0 0x8500
  650. #define R600_SCRATCH_REG1 0x8504
  651. #define R600_SCRATCH_REG2 0x8508
  652. #define R600_SCRATCH_REG3 0x850c
  653. #define R600_SCRATCH_REG4 0x8510
  654. #define R600_SCRATCH_REG5 0x8514
  655. #define R600_SCRATCH_REG6 0x8518
  656. #define R600_SCRATCH_REG7 0x851c
  657. #define R600_SCRATCH_UMSK 0x8540
  658. #define R600_SCRATCH_ADDR 0x8544
  659. #define R600_SCRATCHOFF(x) (R600_SCRATCH_REG_OFFSET + 4*(x))
  660. #define RADEON_GEN_INT_CNTL 0x0040
  661. # define RADEON_CRTC_VBLANK_MASK (1 << 0)
  662. # define RADEON_CRTC2_VBLANK_MASK (1 << 9)
  663. # define RADEON_GUI_IDLE_INT_ENABLE (1 << 19)
  664. # define RADEON_SW_INT_ENABLE (1 << 25)
  665. #define RADEON_GEN_INT_STATUS 0x0044
  666. # define RADEON_CRTC_VBLANK_STAT (1 << 0)
  667. # define RADEON_CRTC_VBLANK_STAT_ACK (1 << 0)
  668. # define RADEON_CRTC2_VBLANK_STAT (1 << 9)
  669. # define RADEON_CRTC2_VBLANK_STAT_ACK (1 << 9)
  670. # define RADEON_GUI_IDLE_INT_TEST_ACK (1 << 19)
  671. # define RADEON_SW_INT_TEST (1 << 25)
  672. # define RADEON_SW_INT_TEST_ACK (1 << 25)
  673. # define RADEON_SW_INT_FIRE (1 << 26)
  674. # define R500_DISPLAY_INT_STATUS (1 << 0)
  675. #define RADEON_HOST_PATH_CNTL 0x0130
  676. # define RADEON_HDP_SOFT_RESET (1 << 26)
  677. # define RADEON_HDP_WC_TIMEOUT_MASK (7 << 28)
  678. # define RADEON_HDP_WC_TIMEOUT_28BCLK (7 << 28)
  679. #define RADEON_ISYNC_CNTL 0x1724
  680. # define RADEON_ISYNC_ANY2D_IDLE3D (1 << 0)
  681. # define RADEON_ISYNC_ANY3D_IDLE2D (1 << 1)
  682. # define RADEON_ISYNC_TRIG2D_IDLE3D (1 << 2)
  683. # define RADEON_ISYNC_TRIG3D_IDLE2D (1 << 3)
  684. # define RADEON_ISYNC_WAIT_IDLEGUI (1 << 4)
  685. # define RADEON_ISYNC_CPSCRATCH_IDLEGUI (1 << 5)
  686. #define RADEON_RBBM_GUICNTL 0x172c
  687. # define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
  688. # define RADEON_HOST_DATA_SWAP_16BIT (1 << 0)
  689. # define RADEON_HOST_DATA_SWAP_32BIT (2 << 0)
  690. # define RADEON_HOST_DATA_SWAP_HDW (3 << 0)
  691. #define RADEON_MC_AGP_LOCATION 0x014c
  692. #define RADEON_MC_FB_LOCATION 0x0148
  693. #define RADEON_MCLK_CNTL 0x0012
  694. # define RADEON_FORCEON_MCLKA (1 << 16)
  695. # define RADEON_FORCEON_MCLKB (1 << 17)
  696. # define RADEON_FORCEON_YCLKA (1 << 18)
  697. # define RADEON_FORCEON_YCLKB (1 << 19)
  698. # define RADEON_FORCEON_MC (1 << 20)
  699. # define RADEON_FORCEON_AIC (1 << 21)
  700. #define RADEON_PP_BORDER_COLOR_0 0x1d40
  701. #define RADEON_PP_BORDER_COLOR_1 0x1d44
  702. #define RADEON_PP_BORDER_COLOR_2 0x1d48
  703. #define RADEON_PP_CNTL 0x1c38
  704. # define RADEON_SCISSOR_ENABLE (1 << 1)
  705. #define RADEON_PP_LUM_MATRIX 0x1d00
  706. #define RADEON_PP_MISC 0x1c14
  707. #define RADEON_PP_ROT_MATRIX_0 0x1d58
  708. #define RADEON_PP_TXFILTER_0 0x1c54
  709. #define RADEON_PP_TXOFFSET_0 0x1c5c
  710. #define RADEON_PP_TXFILTER_1 0x1c6c
  711. #define RADEON_PP_TXFILTER_2 0x1c84
  712. #define R300_RB2D_DSTCACHE_CTLSTAT 0x342c /* use R300_DSTCACHE_CTLSTAT */
  713. #define R300_DSTCACHE_CTLSTAT 0x1714
  714. # define R300_RB2D_DC_FLUSH (3 << 0)
  715. # define R300_RB2D_DC_FREE (3 << 2)
  716. # define R300_RB2D_DC_FLUSH_ALL 0xf
  717. # define R300_RB2D_DC_BUSY (1 << 31)
  718. #define RADEON_RB3D_CNTL 0x1c3c
  719. # define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
  720. # define RADEON_PLANE_MASK_ENABLE (1 << 1)
  721. # define RADEON_DITHER_ENABLE (1 << 2)
  722. # define RADEON_ROUND_ENABLE (1 << 3)
  723. # define RADEON_SCALE_DITHER_ENABLE (1 << 4)
  724. # define RADEON_DITHER_INIT (1 << 5)
  725. # define RADEON_ROP_ENABLE (1 << 6)
  726. # define RADEON_STENCIL_ENABLE (1 << 7)
  727. # define RADEON_Z_ENABLE (1 << 8)
  728. # define RADEON_ZBLOCK16 (1 << 15)
  729. #define RADEON_RB3D_DEPTHOFFSET 0x1c24
  730. #define RADEON_RB3D_DEPTHCLEARVALUE 0x3230
  731. #define RADEON_RB3D_DEPTHPITCH 0x1c28
  732. #define RADEON_RB3D_PLANEMASK 0x1d84
  733. #define RADEON_RB3D_STENCILREFMASK 0x1d7c
  734. #define RADEON_RB3D_ZCACHE_MODE 0x3250
  735. #define RADEON_RB3D_ZCACHE_CTLSTAT 0x3254
  736. # define RADEON_RB3D_ZC_FLUSH (1 << 0)
  737. # define RADEON_RB3D_ZC_FREE (1 << 2)
  738. # define RADEON_RB3D_ZC_FLUSH_ALL 0x5
  739. # define RADEON_RB3D_ZC_BUSY (1 << 31)
  740. #define R300_ZB_ZCACHE_CTLSTAT 0x4f18
  741. # define R300_ZC_FLUSH (1 << 0)
  742. # define R300_ZC_FREE (1 << 1)
  743. # define R300_ZC_BUSY (1 << 31)
  744. #define RADEON_RB3D_DSTCACHE_CTLSTAT 0x325c
  745. # define RADEON_RB3D_DC_FLUSH (3 << 0)
  746. # define RADEON_RB3D_DC_FREE (3 << 2)
  747. # define RADEON_RB3D_DC_FLUSH_ALL 0xf
  748. # define RADEON_RB3D_DC_BUSY (1 << 31)
  749. #define R300_RB3D_DSTCACHE_CTLSTAT 0x4e4c
  750. # define R300_RB3D_DC_FLUSH (2 << 0)
  751. # define R300_RB3D_DC_FREE (2 << 2)
  752. # define R300_RB3D_DC_FINISH (1 << 4)
  753. #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
  754. # define RADEON_Z_TEST_MASK (7 << 4)
  755. # define RADEON_Z_TEST_ALWAYS (7 << 4)
  756. # define RADEON_Z_HIERARCHY_ENABLE (1 << 8)
  757. # define RADEON_STENCIL_TEST_ALWAYS (7 << 12)
  758. # define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16)
  759. # define RADEON_STENCIL_ZPASS_REPLACE (2 << 20)
  760. # define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24)
  761. # define RADEON_Z_COMPRESSION_ENABLE (1 << 28)
  762. # define RADEON_FORCE_Z_DIRTY (1 << 29)
  763. # define RADEON_Z_WRITE_ENABLE (1 << 30)
  764. # define RADEON_Z_DECOMPRESSION_ENABLE (1 << 31)
  765. #define RADEON_RBBM_SOFT_RESET 0x00f0
  766. # define RADEON_SOFT_RESET_CP (1 << 0)
  767. # define RADEON_SOFT_RESET_HI (1 << 1)
  768. # define RADEON_SOFT_RESET_SE (1 << 2)
  769. # define RADEON_SOFT_RESET_RE (1 << 3)
  770. # define RADEON_SOFT_RESET_PP (1 << 4)
  771. # define RADEON_SOFT_RESET_E2 (1 << 5)
  772. # define RADEON_SOFT_RESET_RB (1 << 6)
  773. # define RADEON_SOFT_RESET_HDP (1 << 7)
  774. /*
  775. * 6:0 Available slots in the FIFO
  776. * 8 Host Interface active
  777. * 9 CP request active
  778. * 10 FIFO request active
  779. * 11 Host Interface retry active
  780. * 12 CP retry active
  781. * 13 FIFO retry active
  782. * 14 FIFO pipeline busy
  783. * 15 Event engine busy
  784. * 16 CP command stream busy
  785. * 17 2D engine busy
  786. * 18 2D portion of render backend busy
  787. * 20 3D setup engine busy
  788. * 26 GA engine busy
  789. * 27 CBA 2D engine busy
  790. * 31 2D engine busy or 3D engine busy or FIFO not empty or CP busy or
  791. * command stream queue not empty or Ring Buffer not empty
  792. */
  793. #define RADEON_RBBM_STATUS 0x0e40
  794. /* Same as the previous RADEON_RBBM_STATUS; this is a mirror of that register. */
  795. /* #define RADEON_RBBM_STATUS 0x1740 */
  796. /* bits 6:0 are dword slots available in the cmd fifo */
  797. # define RADEON_RBBM_FIFOCNT_MASK 0x007f
  798. # define RADEON_HIRQ_ON_RBB (1 << 8)
  799. # define RADEON_CPRQ_ON_RBB (1 << 9)
  800. # define RADEON_CFRQ_ON_RBB (1 << 10)
  801. # define RADEON_HIRQ_IN_RTBUF (1 << 11)
  802. # define RADEON_CPRQ_IN_RTBUF (1 << 12)
  803. # define RADEON_CFRQ_IN_RTBUF (1 << 13)
  804. # define RADEON_PIPE_BUSY (1 << 14)
  805. # define RADEON_ENG_EV_BUSY (1 << 15)
  806. # define RADEON_CP_CMDSTRM_BUSY (1 << 16)
  807. # define RADEON_E2_BUSY (1 << 17)
  808. # define RADEON_RB2D_BUSY (1 << 18)
  809. # define RADEON_RB3D_BUSY (1 << 19) /* not used on r300 */
  810. # define RADEON_VAP_BUSY (1 << 20)
  811. # define RADEON_RE_BUSY (1 << 21) /* not used on r300 */
  812. # define RADEON_TAM_BUSY (1 << 22) /* not used on r300 */
  813. # define RADEON_TDM_BUSY (1 << 23) /* not used on r300 */
  814. # define RADEON_PB_BUSY (1 << 24) /* not used on r300 */
  815. # define RADEON_TIM_BUSY (1 << 25) /* not used on r300 */
  816. # define RADEON_GA_BUSY (1 << 26)
  817. # define RADEON_CBA2D_BUSY (1 << 27)
  818. # define RADEON_RBBM_ACTIVE (1 << 31)
  819. #define RADEON_RE_LINE_PATTERN 0x1cd0
  820. #define RADEON_RE_MISC 0x26c4
  821. #define RADEON_RE_TOP_LEFT 0x26c0
  822. #define RADEON_RE_WIDTH_HEIGHT 0x1c44
  823. #define RADEON_RE_STIPPLE_ADDR 0x1cc8
  824. #define RADEON_RE_STIPPLE_DATA 0x1ccc
  825. #define RADEON_SCISSOR_TL_0 0x1cd8
  826. #define RADEON_SCISSOR_BR_0 0x1cdc
  827. #define RADEON_SCISSOR_TL_1 0x1ce0
  828. #define RADEON_SCISSOR_BR_1 0x1ce4
  829. #define RADEON_SCISSOR_TL_2 0x1ce8
  830. #define RADEON_SCISSOR_BR_2 0x1cec
  831. #define RADEON_SE_COORD_FMT 0x1c50
  832. #define RADEON_SE_CNTL 0x1c4c
  833. # define RADEON_FFACE_CULL_CW (0 << 0)
  834. # define RADEON_BFACE_SOLID (3 << 1)
  835. # define RADEON_FFACE_SOLID (3 << 3)
  836. # define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
  837. # define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
  838. # define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
  839. # define RADEON_ALPHA_SHADE_FLAT (1 << 10)
  840. # define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
  841. # define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
  842. # define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
  843. # define RADEON_FOG_SHADE_FLAT (1 << 14)
  844. # define RADEON_FOG_SHADE_GOURAUD (2 << 14)
  845. # define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
  846. # define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
  847. # define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
  848. # define RADEON_ROUND_MODE_TRUNC (0 << 28)
  849. # define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
  850. #define RADEON_SE_CNTL_STATUS 0x2140
  851. #define RADEON_SE_LINE_WIDTH 0x1db8
  852. #define RADEON_SE_VPORT_XSCALE 0x1d98
  853. #define RADEON_SE_ZBIAS_FACTOR 0x1db0
  854. #define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
  855. #define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
  856. #define RADEON_SE_TCL_VECTOR_INDX_REG 0x2200
  857. # define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT 16
  858. # define RADEON_VEC_INDX_DWORD_COUNT_SHIFT 28
  859. #define RADEON_SE_TCL_VECTOR_DATA_REG 0x2204
  860. #define RADEON_SE_TCL_SCALAR_INDX_REG 0x2208
  861. # define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT 16
  862. #define RADEON_SE_TCL_SCALAR_DATA_REG 0x220C
  863. #define RADEON_SURFACE_ACCESS_FLAGS 0x0bf8
  864. #define RADEON_SURFACE_ACCESS_CLR 0x0bfc
  865. #define RADEON_SURFACE_CNTL 0x0b00
  866. # define RADEON_SURF_TRANSLATION_DIS (1 << 8)
  867. # define RADEON_NONSURF_AP0_SWP_MASK (3 << 20)
  868. # define RADEON_NONSURF_AP0_SWP_LITTLE (0 << 20)
  869. # define RADEON_NONSURF_AP0_SWP_BIG16 (1 << 20)
  870. # define RADEON_NONSURF_AP0_SWP_BIG32 (2 << 20)
  871. # define RADEON_NONSURF_AP1_SWP_MASK (3 << 22)
  872. # define RADEON_NONSURF_AP1_SWP_LITTLE (0 << 22)
  873. # define RADEON_NONSURF_AP1_SWP_BIG16 (1 << 22)
  874. # define RADEON_NONSURF_AP1_SWP_BIG32 (2 << 22)
  875. #define RADEON_SURFACE0_INFO 0x0b0c
  876. # define RADEON_SURF_PITCHSEL_MASK (0x1ff << 0)
  877. # define RADEON_SURF_TILE_MODE_MASK (3 << 16)
  878. # define RADEON_SURF_TILE_MODE_MACRO (0 << 16)
  879. # define RADEON_SURF_TILE_MODE_MICRO (1 << 16)
  880. # define RADEON_SURF_TILE_MODE_32BIT_Z (2 << 16)
  881. # define RADEON_SURF_TILE_MODE_16BIT_Z (3 << 16)
  882. #define RADEON_SURFACE0_LOWER_BOUND 0x0b04
  883. #define RADEON_SURFACE0_UPPER_BOUND 0x0b08
  884. # define RADEON_SURF_ADDRESS_FIXED_MASK (0x3ff << 0)
  885. #define RADEON_SURFACE1_INFO 0x0b1c
  886. #define RADEON_SURFACE1_LOWER_BOUND 0x0b14
  887. #define RADEON_SURFACE1_UPPER_BOUND 0x0b18
  888. #define RADEON_SURFACE2_INFO 0x0b2c
  889. #define RADEON_SURFACE2_LOWER_BOUND 0x0b24
  890. #define RADEON_SURFACE2_UPPER_BOUND 0x0b28
  891. #define RADEON_SURFACE3_INFO 0x0b3c
  892. #define RADEON_SURFACE3_LOWER_BOUND 0x0b34
  893. #define RADEON_SURFACE3_UPPER_BOUND 0x0b38
  894. #define RADEON_SURFACE4_INFO 0x0b4c
  895. #define RADEON_SURFACE4_LOWER_BOUND 0x0b44
  896. #define RADEON_SURFACE4_UPPER_BOUND 0x0b48
  897. #define RADEON_SURFACE5_INFO 0x0b5c
  898. #define RADEON_SURFACE5_LOWER_BOUND 0x0b54
  899. #define RADEON_SURFACE5_UPPER_BOUND 0x0b58
  900. #define RADEON_SURFACE6_INFO 0x0b6c
  901. #define RADEON_SURFACE6_LOWER_BOUND 0x0b64
  902. #define RADEON_SURFACE6_UPPER_BOUND 0x0b68
  903. #define RADEON_SURFACE7_INFO 0x0b7c
  904. #define RADEON_SURFACE7_LOWER_BOUND 0x0b74
  905. #define RADEON_SURFACE7_UPPER_BOUND 0x0b78
  906. #define RADEON_SW_SEMAPHORE 0x013c
  907. #define RADEON_WAIT_UNTIL 0x1720
  908. # define RADEON_WAIT_CRTC_PFLIP (1 << 0)
  909. # define RADEON_WAIT_2D_IDLE (1 << 14)
  910. # define RADEON_WAIT_3D_IDLE (1 << 15)
  911. # define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
  912. # define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
  913. # define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
  914. #define RADEON_RB3D_ZMASKOFFSET 0x3234
  915. #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
  916. # define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
  917. # define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
  918. /* CP registers */
  919. #define RADEON_CP_ME_RAM_ADDR 0x07d4
  920. #define RADEON_CP_ME_RAM_RADDR 0x07d8
  921. #define RADEON_CP_ME_RAM_DATAH 0x07dc
  922. #define RADEON_CP_ME_RAM_DATAL 0x07e0
  923. #define RADEON_CP_RB_BASE 0x0700
  924. #define RADEON_CP_RB_CNTL 0x0704
  925. # define RADEON_BUF_SWAP_32BIT (2 << 16)
  926. # define RADEON_RB_NO_UPDATE (1 << 27)
  927. # define RADEON_RB_RPTR_WR_ENA (1 << 31)
  928. #define RADEON_CP_RB_RPTR_ADDR 0x070c
  929. #define RADEON_CP_RB_RPTR 0x0710
  930. #define RADEON_CP_RB_WPTR 0x0714
  931. #define RADEON_CP_RB_WPTR_DELAY 0x0718
  932. # define RADEON_PRE_WRITE_TIMER_SHIFT 0
  933. # define RADEON_PRE_WRITE_LIMIT_SHIFT 23
  934. #define RADEON_CP_IB_BASE 0x0738
  935. #define RADEON_CP_CSQ_CNTL 0x0740
  936. # define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
  937. # define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
  938. # define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
  939. # define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
  940. # define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
  941. # define RADEON_CSQ_PRIBM_INDBM (4 << 28)
  942. # define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
  943. #define R300_CP_RESYNC_ADDR 0x0778
  944. #define R300_CP_RESYNC_DATA 0x077c
  945. #define RADEON_AIC_CNTL 0x01d0
  946. # define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
  947. # define RS400_MSI_REARM (1 << 3)
  948. #define RADEON_AIC_STAT 0x01d4
  949. #define RADEON_AIC_PT_BASE 0x01d8
  950. #define RADEON_AIC_LO_ADDR 0x01dc
  951. #define RADEON_AIC_HI_ADDR 0x01e0
  952. #define RADEON_AIC_TLB_ADDR 0x01e4
  953. #define RADEON_AIC_TLB_DATA 0x01e8
  954. /* CP command packets */
  955. #define RADEON_CP_PACKET0 0x00000000
  956. # define RADEON_ONE_REG_WR (1 << 15)
  957. #define RADEON_CP_PACKET1 0x40000000
  958. #define RADEON_CP_PACKET2 0x80000000
  959. #define RADEON_CP_PACKET3 0xC0000000
  960. # define RADEON_CP_NOP 0x00001000
  961. # define RADEON_CP_NEXT_CHAR 0x00001900
  962. # define RADEON_CP_PLY_NEXTSCAN 0x00001D00
  963. # define RADEON_CP_SET_SCISSORS 0x00001E00
  964. /* GEN_INDX_PRIM is unsupported starting with R300 */
  965. # define RADEON_3D_RNDR_GEN_INDX_PRIM 0x00002300
  966. # define RADEON_WAIT_FOR_IDLE 0x00002600
  967. # define RADEON_3D_DRAW_VBUF 0x00002800
  968. # define RADEON_3D_DRAW_IMMD 0x00002900
  969. # define RADEON_3D_DRAW_INDX 0x00002A00
  970. # define RADEON_CP_LOAD_PALETTE 0x00002C00
  971. # define RADEON_3D_LOAD_VBPNTR 0x00002F00
  972. # define RADEON_MPEG_IDCT_MACROBLOCK 0x00003000
  973. # define RADEON_MPEG_IDCT_MACROBLOCK_REV 0x00003100
  974. # define RADEON_3D_CLEAR_ZMASK 0x00003200
  975. # define RADEON_CP_INDX_BUFFER 0x00003300
  976. # define RADEON_CP_3D_DRAW_VBUF_2 0x00003400
  977. # define RADEON_CP_3D_DRAW_IMMD_2 0x00003500
  978. # define RADEON_CP_3D_DRAW_INDX_2 0x00003600
  979. # define RADEON_3D_CLEAR_HIZ 0x00003700
  980. # define RADEON_CP_3D_CLEAR_CMASK 0x00003802
  981. # define RADEON_CNTL_HOSTDATA_BLT 0x00009400
  982. # define RADEON_CNTL_PAINT_MULTI 0x00009A00
  983. # define RADEON_CNTL_BITBLT_MULTI 0x00009B00
  984. # define RADEON_CNTL_SET_SCISSORS 0xC0001E00
  985. # define R600_IT_INDIRECT_BUFFER_END 0x00001700
  986. # define R600_IT_SET_PREDICATION 0x00002000
  987. # define R600_IT_REG_RMW 0x00002100
  988. # define R600_IT_COND_EXEC 0x00002200
  989. # define R600_IT_PRED_EXEC 0x00002300
  990. # define R600_IT_START_3D_CMDBUF 0x00002400
  991. # define R600_IT_DRAW_INDEX_2 0x00002700
  992. # define R600_IT_CONTEXT_CONTROL 0x00002800
  993. # define R600_IT_DRAW_INDEX_IMMD_BE 0x00002900
  994. # define R600_IT_INDEX_TYPE 0x00002A00
  995. # define R600_IT_DRAW_INDEX 0x00002B00
  996. # define R600_IT_DRAW_INDEX_AUTO 0x00002D00
  997. # define R600_IT_DRAW_INDEX_IMMD 0x00002E00
  998. # define R600_IT_NUM_INSTANCES 0x00002F00
  999. # define R600_IT_STRMOUT_BUFFER_UPDATE 0x00003400
  1000. # define R600_IT_INDIRECT_BUFFER_MP 0x00003800
  1001. # define R600_IT_MEM_SEMAPHORE 0x00003900
  1002. # define R600_IT_MPEG_INDEX 0x00003A00
  1003. # define R600_IT_WAIT_REG_MEM 0x00003C00
  1004. # define R600_IT_MEM_WRITE 0x00003D00
  1005. # define R600_IT_INDIRECT_BUFFER 0x00003200
  1006. # define R600_IT_SURFACE_SYNC 0x00004300
  1007. # define R600_CB0_DEST_BASE_ENA (1 << 6)
  1008. # define R600_TC_ACTION_ENA (1 << 23)
  1009. # define R600_VC_ACTION_ENA (1 << 24)
  1010. # define R600_CB_ACTION_ENA (1 << 25)
  1011. # define R600_DB_ACTION_ENA (1 << 26)
  1012. # define R600_SH_ACTION_ENA (1 << 27)
  1013. # define R600_SMX_ACTION_ENA (1 << 28)
  1014. # define R600_IT_ME_INITIALIZE 0x00004400
  1015. # define R600_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
  1016. # define R600_IT_COND_WRITE 0x00004500
  1017. # define R600_IT_EVENT_WRITE 0x00004600
  1018. # define R600_IT_EVENT_WRITE_EOP 0x00004700
  1019. # define R600_IT_ONE_REG_WRITE 0x00005700
  1020. # define R600_IT_SET_CONFIG_REG 0x00006800
  1021. # define R600_SET_CONFIG_REG_OFFSET 0x00008000
  1022. # define R600_SET_CONFIG_REG_END 0x0000ac00
  1023. # define R600_IT_SET_CONTEXT_REG 0x00006900
  1024. # define R600_SET_CONTEXT_REG_OFFSET 0x00028000
  1025. # define R600_SET_CONTEXT_REG_END 0x00029000
  1026. # define R600_IT_SET_ALU_CONST 0x00006A00
  1027. # define R600_SET_ALU_CONST_OFFSET 0x00030000
  1028. # define R600_SET_ALU_CONST_END 0x00032000
  1029. # define R600_IT_SET_BOOL_CONST 0x00006B00
  1030. # define R600_SET_BOOL_CONST_OFFSET 0x0003e380
  1031. # define R600_SET_BOOL_CONST_END 0x00040000
  1032. # define R600_IT_SET_LOOP_CONST 0x00006C00
  1033. # define R600_SET_LOOP_CONST_OFFSET 0x0003e200
  1034. # define R600_SET_LOOP_CONST_END 0x0003e380
  1035. # define R600_IT_SET_RESOURCE 0x00006D00
  1036. # define R600_SET_RESOURCE_OFFSET 0x00038000
  1037. # define R600_SET_RESOURCE_END 0x0003c000
  1038. # define R600_SQ_TEX_VTX_INVALID_TEXTURE 0x0
  1039. # define R600_SQ_TEX_VTX_INVALID_BUFFER 0x1
  1040. # define R600_SQ_TEX_VTX_VALID_TEXTURE 0x2
  1041. # define R600_SQ_TEX_VTX_VALID_BUFFER 0x3
  1042. # define R600_IT_SET_SAMPLER 0x00006E00
  1043. # define R600_SET_SAMPLER_OFFSET 0x0003c000
  1044. # define R600_SET_SAMPLER_END 0x0003cff0
  1045. # define R600_IT_SET_CTL_CONST 0x00006F00
  1046. # define R600_SET_CTL_CONST_OFFSET 0x0003cff0
  1047. # define R600_SET_CTL_CONST_END 0x0003e200
  1048. # define R600_IT_SURFACE_BASE_UPDATE 0x00007300
  1049. #define RADEON_CP_PACKET_MASK 0xC0000000
  1050. #define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000
  1051. #define RADEON_CP_PACKET0_REG_MASK 0x000007ff
  1052. #define RADEON_CP_PACKET1_REG0_MASK 0x000007ff
  1053. #define RADEON_CP_PACKET1_REG1_MASK 0x003ff800
  1054. #define RADEON_VTX_Z_PRESENT (1 << 31)
  1055. #define RADEON_VTX_PKCOLOR_PRESENT (1 << 3)
  1056. #define RADEON_PRIM_TYPE_NONE (0 << 0)
  1057. #define RADEON_PRIM_TYPE_POINT (1 << 0)
  1058. #define RADEON_PRIM_TYPE_LINE (2 << 0)
  1059. #define RADEON_PRIM_TYPE_LINE_STRIP (3 << 0)
  1060. #define RADEON_PRIM_TYPE_TRI_LIST (4 << 0)
  1061. #define RADEON_PRIM_TYPE_TRI_FAN (5 << 0)
  1062. #define RADEON_PRIM_TYPE_TRI_STRIP (6 << 0)
  1063. #define RADEON_PRIM_TYPE_TRI_TYPE2 (7 << 0)
  1064. #define RADEON_PRIM_TYPE_RECT_LIST (8 << 0)
  1065. #define RADEON_PRIM_TYPE_3VRT_POINT_LIST (9 << 0)
  1066. #define RADEON_PRIM_TYPE_3VRT_LINE_LIST (10 << 0)
  1067. #define RADEON_PRIM_TYPE_MASK 0xf
  1068. #define RADEON_PRIM_WALK_IND (1 << 4)
  1069. #define RADEON_PRIM_WALK_LIST (2 << 4)
  1070. #define RADEON_PRIM_WALK_RING (3 << 4)
  1071. #define RADEON_COLOR_ORDER_BGRA (0 << 6)
  1072. #define RADEON_COLOR_ORDER_RGBA (1 << 6)
  1073. #define RADEON_MAOS_ENABLE (1 << 7)
  1074. #define RADEON_VTX_FMT_R128_MODE (0 << 8)
  1075. #define RADEON_VTX_FMT_RADEON_MODE (1 << 8)
  1076. #define RADEON_NUM_VERTICES_SHIFT 16
  1077. #define RADEON_COLOR_FORMAT_CI8 2
  1078. #define RADEON_COLOR_FORMAT_ARGB1555 3
  1079. #define RADEON_COLOR_FORMAT_RGB565 4
  1080. #define RADEON_COLOR_FORMAT_ARGB8888 6
  1081. #define RADEON_COLOR_FORMAT_RGB332 7
  1082. #define RADEON_COLOR_FORMAT_RGB8 9
  1083. #define RADEON_COLOR_FORMAT_ARGB4444 15
  1084. #define RADEON_TXFORMAT_I8 0
  1085. #define RADEON_TXFORMAT_AI88 1
  1086. #define RADEON_TXFORMAT_RGB332 2
  1087. #define RADEON_TXFORMAT_ARGB1555 3
  1088. #define RADEON_TXFORMAT_RGB565 4
  1089. #define RADEON_TXFORMAT_ARGB4444 5
  1090. #define RADEON_TXFORMAT_ARGB8888 6
  1091. #define RADEON_TXFORMAT_RGBA8888 7
  1092. #define RADEON_TXFORMAT_Y8 8
  1093. #define RADEON_TXFORMAT_VYUY422 10
  1094. #define RADEON_TXFORMAT_YVYU422 11
  1095. #define RADEON_TXFORMAT_DXT1 12
  1096. #define RADEON_TXFORMAT_DXT23 14
  1097. #define RADEON_TXFORMAT_DXT45 15
  1098. #define R200_PP_TXCBLEND_0 0x2f00
  1099. #define R200_PP_TXCBLEND_1 0x2f10
  1100. #define R200_PP_TXCBLEND_2 0x2f20
  1101. #define R200_PP_TXCBLEND_3 0x2f30
  1102. #define R200_PP_TXCBLEND_4 0x2f40
  1103. #define R200_PP_TXCBLEND_5 0x2f50
  1104. #define R200_PP_TXCBLEND_6 0x2f60
  1105. #define R200_PP_TXCBLEND_7 0x2f70
  1106. #define R200_SE_TCL_LIGHT_MODEL_CTL_0 0x2268
  1107. #define R200_PP_TFACTOR_0 0x2ee0
  1108. #define R200_SE_VTX_FMT_0 0x2088
  1109. #define R200_SE_VAP_CNTL 0x2080
  1110. #define R200_SE_TCL_MATRIX_SEL_0 0x2230
  1111. #define R200_SE_TCL_TEX_PROC_CTL_2 0x22a8
  1112. #define R200_SE_TCL_UCP_VERT_BLEND_CTL 0x22c0
  1113. #define R200_PP_TXFILTER_5 0x2ca0
  1114. #define R200_PP_TXFILTER_4 0x2c80
  1115. #define R200_PP_TXFILTER_3 0x2c60
  1116. #define R200_PP_TXFILTER_2 0x2c40
  1117. #define R200_PP_TXFILTER_1 0x2c20
  1118. #define R200_PP_TXFILTER_0 0x2c00
  1119. #define R200_PP_TXOFFSET_5 0x2d78
  1120. #define R200_PP_TXOFFSET_4 0x2d60
  1121. #define R200_PP_TXOFFSET_3 0x2d48
  1122. #define R200_PP_TXOFFSET_2 0x2d30
  1123. #define R200_PP_TXOFFSET_1 0x2d18
  1124. #define R200_PP_TXOFFSET_0 0x2d00
  1125. #define R200_PP_CUBIC_FACES_0 0x2c18
  1126. #define R200_PP_CUBIC_FACES_1 0x2c38
  1127. #define R200_PP_CUBIC_FACES_2 0x2c58
  1128. #define R200_PP_CUBIC_FACES_3 0x2c78
  1129. #define R200_PP_CUBIC_FACES_4 0x2c98
  1130. #define R200_PP_CUBIC_FACES_5 0x2cb8
  1131. #define R200_PP_CUBIC_OFFSET_F1_0 0x2d04
  1132. #define R200_PP_CUBIC_OFFSET_F2_0 0x2d08
  1133. #define R200_PP_CUBIC_OFFSET_F3_0 0x2d0c
  1134. #define R200_PP_CUBIC_OFFSET_F4_0 0x2d10
  1135. #define R200_PP_CUBIC_OFFSET_F5_0 0x2d14
  1136. #define R200_PP_CUBIC_OFFSET_F1_1 0x2d1c
  1137. #define R200_PP_CUBIC_OFFSET_F2_1 0x2d20
  1138. #define R200_PP_CUBIC_OFFSET_F3_1 0x2d24
  1139. #define R200_PP_CUBIC_OFFSET_F4_1 0x2d28
  1140. #define R200_PP_CUBIC_OFFSET_F5_1 0x2d2c
  1141. #define R200_PP_CUBIC_OFFSET_F1_2 0x2d34
  1142. #define R200_PP_CUBIC_OFFSET_F2_2 0x2d38
  1143. #define R200_PP_CUBIC_OFFSET_F3_2 0x2d3c
  1144. #define R200_PP_CUBIC_OFFSET_F4_2 0x2d40
  1145. #define R200_PP_CUBIC_OFFSET_F5_2 0x2d44
  1146. #define R200_PP_CUBIC_OFFSET_F1_3 0x2d4c
  1147. #define R200_PP_CUBIC_OFFSET_F2_3 0x2d50
  1148. #define R200_PP_CUBIC_OFFSET_F3_3 0x2d54
  1149. #define R200_PP_CUBIC_OFFSET_F4_3 0x2d58
  1150. #define R200_PP_CUBIC_OFFSET_F5_3 0x2d5c
  1151. #define R200_PP_CUBIC_OFFSET_F1_4 0x2d64
  1152. #define R200_PP_CUBIC_OFFSET_F2_4 0x2d68
  1153. #define R200_PP_CUBIC_OFFSET_F3_4 0x2d6c
  1154. #define R200_PP_CUBIC_OFFSET_F4_4 0x2d70
  1155. #define R200_PP_CUBIC_OFFSET_F5_4 0x2d74
  1156. #define R200_PP_CUBIC_OFFSET_F1_5 0x2d7c
  1157. #define R200_PP_CUBIC_OFFSET_F2_5 0x2d80
  1158. #define R200_PP_CUBIC_OFFSET_F3_5 0x2d84
  1159. #define R200_PP_CUBIC_OFFSET_F4_5 0x2d88
  1160. #define R200_PP_CUBIC_OFFSET_F5_5 0x2d8c
  1161. #define R200_RE_AUX_SCISSOR_CNTL 0x26f0
  1162. #define R200_SE_VTE_CNTL 0x20b0
  1163. #define R200_SE_TCL_OUTPUT_VTX_COMP_SEL 0x2250
  1164. #define R200_PP_TAM_DEBUG3 0x2d9c
  1165. #define R200_PP_CNTL_X 0x2cc4
  1166. #define R200_SE_VAP_CNTL_STATUS 0x2140
  1167. #define R200_RE_SCISSOR_TL_0 0x1cd8
  1168. #define R200_RE_SCISSOR_TL_1 0x1ce0
  1169. #define R200_RE_SCISSOR_TL_2 0x1ce8
  1170. #define R200_RB3D_DEPTHXY_OFFSET 0x1d60
  1171. #define R200_RE_AUX_SCISSOR_CNTL 0x26f0
  1172. #define R200_SE_VTX_STATE_CNTL 0x2180
  1173. #define R200_RE_POINTSIZE 0x2648
  1174. #define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254
  1175. #define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */
  1176. #define RADEON_PP_TEX_SIZE_1 0x1d0c
  1177. #define RADEON_PP_TEX_SIZE_2 0x1d14
  1178. #define RADEON_PP_CUBIC_FACES_0 0x1d24
  1179. #define RADEON_PP_CUBIC_FACES_1 0x1d28
  1180. #define RADEON_PP_CUBIC_FACES_2 0x1d2c
  1181. #define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */
  1182. #define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00
  1183. #define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14
  1184. #define RADEON_SE_TCL_STATE_FLUSH 0x2284
  1185. #define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001
  1186. #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000
  1187. #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012
  1188. #define SE_VTE_CNTL__VTX_XY_FMT_MASK 0x00000100
  1189. #define SE_VTE_CNTL__VTX_Z_FMT_MASK 0x00000200
  1190. #define SE_VTX_FMT_0__VTX_Z0_PRESENT_MASK 0x00000001
  1191. #define SE_VTX_FMT_0__VTX_W0_PRESENT_MASK 0x00000002
  1192. #define SE_VTX_FMT_0__VTX_COLOR_0_FMT__SHIFT 0x0000000b
  1193. #define R200_3D_DRAW_IMMD_2 0xC0003500
  1194. #define R200_SE_VTX_FMT_1 0x208c
  1195. #define R200_RE_CNTL 0x1c50
  1196. #define R200_RB3D_BLENDCOLOR 0x3218
  1197. #define R200_SE_TCL_POINT_SPRITE_CNTL 0x22c4
  1198. #define R200_PP_TRI_PERF 0x2cf8
  1199. #define R200_PP_AFS_0 0x2f80
  1200. #define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */
  1201. #define R200_VAP_PVS_CNTL_1 0x22D0
  1202. #define RADEON_CRTC_CRNT_FRAME 0x0214
  1203. #define RADEON_CRTC2_CRNT_FRAME 0x0314
  1204. #define R500_D1CRTC_STATUS 0x609c
  1205. #define R500_D2CRTC_STATUS 0x689c
  1206. #define R500_CRTC_V_BLANK (1<<0)
  1207. #define R500_D1CRTC_FRAME_COUNT 0x60a4
  1208. #define R500_D2CRTC_FRAME_COUNT 0x68a4
  1209. #define R500_D1MODE_V_COUNTER 0x6530
  1210. #define R500_D2MODE_V_COUNTER 0x6d30
  1211. #define R500_D1MODE_VBLANK_STATUS 0x6534
  1212. #define R500_D2MODE_VBLANK_STATUS 0x6d34
  1213. #define R500_VBLANK_OCCURED (1<<0)
  1214. #define R500_VBLANK_ACK (1<<4)
  1215. #define R500_VBLANK_STAT (1<<12)
  1216. #define R500_VBLANK_INT (1<<16)
  1217. #define R500_DxMODE_INT_MASK 0x6540
  1218. #define R500_D1MODE_INT_MASK (1<<0)
  1219. #define R500_D2MODE_INT_MASK (1<<8)
  1220. #define R500_DISP_INTERRUPT_STATUS 0x7edc
  1221. #define R500_D1_VBLANK_INTERRUPT (1 << 4)
  1222. #define R500_D2_VBLANK_INTERRUPT (1 << 5)
  1223. /* R6xx/R7xx registers */
  1224. #define R600_MC_VM_FB_LOCATION 0x2180
  1225. #define R600_MC_VM_AGP_TOP 0x2184
  1226. #define R600_MC_VM_AGP_BOT 0x2188
  1227. #define R600_MC_VM_AGP_BASE 0x218c
  1228. #define R600_MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2190
  1229. #define R600_MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2194
  1230. #define R600_MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x2198
  1231. #define R700_MC_VM_FB_LOCATION 0x2024
  1232. #define R700_MC_VM_AGP_TOP 0x2028
  1233. #define R700_MC_VM_AGP_BOT 0x202c
  1234. #define R700_MC_VM_AGP_BASE 0x2030
  1235. #define R700_MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034
  1236. #define R700_MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038
  1237. #define R700_MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203c
  1238. #define R600_MCD_RD_A_CNTL 0x219c
  1239. #define R600_MCD_RD_B_CNTL 0x21a0
  1240. #define R600_MCD_WR_A_CNTL 0x21a4
  1241. #define R600_MCD_WR_B_CNTL 0x21a8
  1242. #define R600_MCD_RD_SYS_CNTL 0x2200
  1243. #define R600_MCD_WR_SYS_CNTL 0x2214
  1244. #define R600_MCD_RD_GFX_CNTL 0x21fc
  1245. #define R600_MCD_RD_HDP_CNTL 0x2204
  1246. #define R600_MCD_RD_PDMA_CNTL 0x2208
  1247. #define R600_MCD_RD_SEM_CNTL 0x220c
  1248. #define R600_MCD_WR_GFX_CNTL 0x2210
  1249. #define R600_MCD_WR_HDP_CNTL 0x2218
  1250. #define R600_MCD_WR_PDMA_CNTL 0x221c
  1251. #define R600_MCD_WR_SEM_CNTL 0x2220
  1252. # define R600_MCD_L1_TLB (1 << 0)
  1253. # define R600_MCD_L1_FRAG_PROC (1 << 1)
  1254. # define R600_MCD_L1_STRICT_ORDERING (1 << 2)
  1255. # define R600_MCD_SYSTEM_ACCESS_MODE_MASK (3 << 6)
  1256. # define R600_MCD_SYSTEM_ACCESS_MODE_PA_ONLY (0 << 6)
  1257. # define R600_MCD_SYSTEM_ACCESS_MODE_USE_SYS_MAP (1 << 6)
  1258. # define R600_MCD_SYSTEM_ACCESS_MODE_IN_SYS (2 << 6)
  1259. # define R600_MCD_SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 6)
  1260. # define R600_MCD_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 8)
  1261. # define R600_MCD_SYSTEM_APERTURE_UNMAPPED_ACCESS_DEFAULT_PAGE (1 << 8)
  1262. # define R600_MCD_SEMAPHORE_MODE (1 << 10)
  1263. # define R600_MCD_WAIT_L2_QUERY (1 << 11)
  1264. # define R600_MCD_EFFECTIVE_L1_TLB_SIZE(x) ((x) << 12)
  1265. # define R600_MCD_EFFECTIVE_L1_QUEUE_SIZE(x) ((x) << 15)
  1266. #define R700_MC_VM_MD_L1_TLB0_CNTL 0x2654
  1267. #define R700_MC_VM_MD_L1_TLB1_CNTL 0x2658
  1268. #define R700_MC_VM_MD_L1_TLB2_CNTL 0x265c
  1269. #define R700_MC_VM_MB_L1_TLB0_CNTL 0x2234
  1270. #define R700_MC_VM_MB_L1_TLB1_CNTL 0x2238
  1271. #define R700_MC_VM_MB_L1_TLB2_CNTL 0x223c
  1272. #define R700_MC_VM_MB_L1_TLB3_CNTL 0x2240
  1273. # define R700_ENABLE_L1_TLB (1 << 0)
  1274. # define R700_ENABLE_L1_FRAGMENT_PROCESSING (1 << 1)
  1275. # define R700_SYSTEM_ACCESS_MODE_IN_SYS (2 << 3)
  1276. # define R700_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 5)
  1277. # define R700_EFFECTIVE_L1_TLB_SIZE(x) ((x) << 15)
  1278. # define R700_EFFECTIVE_L1_QUEUE_SIZE(x) ((x) << 18)
  1279. #define R700_MC_ARB_RAMCFG 0x2760
  1280. # define R700_NOOFBANK_SHIFT 0
  1281. # define R700_NOOFBANK_MASK 0x3
  1282. # define R700_NOOFRANK_SHIFT 2
  1283. # define R700_NOOFRANK_MASK 0x1
  1284. # define R700_NOOFROWS_SHIFT 3
  1285. # define R700_NOOFROWS_MASK 0x7
  1286. # define R700_NOOFCOLS_SHIFT 6
  1287. # define R700_NOOFCOLS_MASK 0x3
  1288. # define R700_CHANSIZE_SHIFT 8
  1289. # define R700_CHANSIZE_MASK 0x1
  1290. # define R700_BURSTLENGTH_SHIFT 9
  1291. # define R700_BURSTLENGTH_MASK 0x1
  1292. #define R600_RAMCFG 0x2408
  1293. # define R600_NOOFBANK_SHIFT 0
  1294. # define R600_NOOFBANK_MASK 0x1
  1295. # define R600_NOOFRANK_SHIFT 1
  1296. # define R600_NOOFRANK_MASK 0x1
  1297. # define R600_NOOFROWS_SHIFT 2
  1298. # define R600_NOOFROWS_MASK 0x7
  1299. # define R600_NOOFCOLS_SHIFT 5
  1300. # define R600_NOOFCOLS_MASK 0x3
  1301. # define R600_CHANSIZE_SHIFT 7
  1302. # define R600_CHANSIZE_MASK 0x1
  1303. # define R600_BURSTLENGTH_SHIFT 8
  1304. # define R600_BURSTLENGTH_MASK 0x1
  1305. #define R600_VM_L2_CNTL 0x1400
  1306. # define R600_VM_L2_CACHE_EN (1 << 0)
  1307. # define R600_VM_L2_FRAG_PROC (1 << 1)
  1308. # define R600_VM_ENABLE_PTE_CACHE_LRU_W (1 << 9)
  1309. # define R600_VM_L2_CNTL_QUEUE_SIZE(x) ((x) << 13)
  1310. # define R700_VM_L2_CNTL_QUEUE_SIZE(x) ((x) << 14)
  1311. #define R600_VM_L2_CNTL2 0x1404
  1312. # define R600_VM_L2_CNTL2_INVALIDATE_ALL_L1_TLBS (1 << 0)
  1313. # define R600_VM_L2_CNTL2_INVALIDATE_L2_CACHE (1 << 1)
  1314. #define R600_VM_L2_CNTL3 0x1408
  1315. # define R600_VM_L2_CNTL3_BANK_SELECT_0(x) ((x) << 0)
  1316. # define R600_VM_L2_CNTL3_BANK_SELECT_1(x) ((x) << 5)
  1317. # define R600_VM_L2_CNTL3_CACHE_UPDATE_MODE(x) ((x) << 10)
  1318. # define R700_VM_L2_CNTL3_BANK_SELECT(x) ((x) << 0)
  1319. # define R700_VM_L2_CNTL3_CACHE_UPDATE_MODE(x) ((x) << 6)
  1320. #define R600_VM_L2_STATUS 0x140c
  1321. #define R600_VM_CONTEXT0_CNTL 0x1410
  1322. # define R600_VM_ENABLE_CONTEXT (1 << 0)
  1323. # define R600_VM_PAGE_TABLE_DEPTH_FLAT (0 << 1)
  1324. #define R600_VM_CONTEXT0_CNTL2 0x1430
  1325. #define R600_VM_CONTEXT0_REQUEST_RESPONSE 0x1470
  1326. #define R600_VM_CONTEXT0_INVALIDATION_LOW_ADDR 0x1490
  1327. #define R600_VM_CONTEXT0_INVALIDATION_HIGH_ADDR 0x14b0
  1328. #define R600_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x1574
  1329. #define R600_VM_CONTEXT0_PAGE_TABLE_START_ADDR 0x1594
  1330. #define R600_VM_CONTEXT0_PAGE_TABLE_END_ADDR 0x15b4
  1331. #define R700_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x153c
  1332. #define R700_VM_CONTEXT0_PAGE_TABLE_START_ADDR 0x155c
  1333. #define R700_VM_CONTEXT0_PAGE_TABLE_END_ADDR 0x157c
  1334. #define R600_HDP_HOST_PATH_CNTL 0x2c00
  1335. #define R600_GRBM_CNTL 0x8000
  1336. # define R600_GRBM_READ_TIMEOUT(x) ((x) << 0)
  1337. #define R600_GRBM_STATUS 0x8010
  1338. # define R600_CMDFIFO_AVAIL_MASK 0x1f
  1339. # define R700_CMDFIFO_AVAIL_MASK 0xf
  1340. # define R600_GUI_ACTIVE (1 << 31)
  1341. #define R600_GRBM_STATUS2 0x8014
  1342. #define R600_GRBM_SOFT_RESET 0x8020
  1343. # define R600_SOFT_RESET_CP (1 << 0)
  1344. #define R600_WAIT_UNTIL 0x8040
  1345. #define R600_CP_SEM_WAIT_TIMER 0x85bc
  1346. #define R600_CP_ME_CNTL 0x86d8
  1347. # define R600_CP_ME_HALT (1 << 28)
  1348. #define R600_CP_QUEUE_THRESHOLDS 0x8760
  1349. # define R600_ROQ_IB1_START(x) ((x) << 0)
  1350. # define R600_ROQ_IB2_START(x) ((x) << 8)
  1351. #define R600_CP_MEQ_THRESHOLDS 0x8764
  1352. # define R700_STQ_SPLIT(x) ((x) << 0)
  1353. # define R600_MEQ_END(x) ((x) << 16)
  1354. # define R600_ROQ_END(x) ((x) << 24)
  1355. #define R600_CP_PERFMON_CNTL 0x87fc
  1356. #define R600_CP_RB_BASE 0xc100
  1357. #define R600_CP_RB_CNTL 0xc104
  1358. # define R600_RB_BUFSZ(x) ((x) << 0)
  1359. # define R600_RB_BLKSZ(x) ((x) << 8)
  1360. # define R600_BUF_SWAP_32BIT (2 << 16)
  1361. # define R600_RB_NO_UPDATE (1 << 27)
  1362. # define R600_RB_RPTR_WR_ENA (1 << 31)
  1363. #define R600_CP_RB_RPTR_WR 0xc108
  1364. #define R600_CP_RB_RPTR_ADDR 0xc10c
  1365. #define R600_CP_RB_RPTR_ADDR_HI 0xc110
  1366. #define R600_CP_RB_WPTR 0xc114
  1367. #define R600_CP_RB_WPTR_ADDR 0xc118
  1368. #define R600_CP_RB_WPTR_ADDR_HI 0xc11c
  1369. #define R600_CP_RB_RPTR 0x8700
  1370. #define R600_CP_RB_WPTR_DELAY 0x8704
  1371. #define R600_CP_PFP_UCODE_ADDR 0xc150
  1372. #define R600_CP_PFP_UCODE_DATA 0xc154
  1373. #define R600_CP_ME_RAM_RADDR 0xc158
  1374. #define R600_CP_ME_RAM_WADDR 0xc15c
  1375. #define R600_CP_ME_RAM_DATA 0xc160
  1376. #define R600_CP_DEBUG 0xc1fc
  1377. #define R600_PA_CL_ENHANCE 0x8a14
  1378. # define R600_CLIP_VTX_REORDER_ENA (1 << 0)
  1379. # define R600_NUM_CLIP_SEQ(x) ((x) << 1)
  1380. #define R600_PA_SC_LINE_STIPPLE_STATE 0x8b10
  1381. #define R600_PA_SC_MULTI_CHIP_CNTL 0x8b20
  1382. #define R700_PA_SC_FORCE_EOV_MAX_CNTS 0x8b24
  1383. # define R700_FORCE_EOV_MAX_CLK_CNT(x) ((x) << 0)
  1384. # define R700_FORCE_EOV_MAX_REZ_CNT(x) ((x) << 16)
  1385. #define R600_PA_SC_AA_SAMPLE_LOCS_2S 0x8b40
  1386. #define R600_PA_SC_AA_SAMPLE_LOCS_4S 0x8b44
  1387. #define R600_PA_SC_AA_SAMPLE_LOCS_8S_WD0 0x8b48
  1388. #define R600_PA_SC_AA_SAMPLE_LOCS_8S_WD1 0x8b4c
  1389. # define R600_S0_X(x) ((x) << 0)
  1390. # define R600_S0_Y(x) ((x) << 4)
  1391. # define R600_S1_X(x) ((x) << 8)
  1392. # define R600_S1_Y(x) ((x) << 12)
  1393. # define R600_S2_X(x) ((x) << 16)
  1394. # define R600_S2_Y(x) ((x) << 20)
  1395. # define R600_S3_X(x) ((x) << 24)
  1396. # define R600_S3_Y(x) ((x) << 28)
  1397. # define R600_S4_X(x) ((x) << 0)
  1398. # define R600_S4_Y(x) ((x) << 4)
  1399. # define R600_S5_X(x) ((x) << 8)
  1400. # define R600_S5_Y(x) ((x) << 12)
  1401. # define R600_S6_X(x) ((x) << 16)
  1402. # define R600_S6_Y(x) ((x) << 20)
  1403. # define R600_S7_X(x) ((x) << 24)
  1404. # define R600_S7_Y(x) ((x) << 28)
  1405. #define R600_PA_SC_FIFO_SIZE 0x8bd0
  1406. # define R600_SC_PRIM_FIFO_SIZE(x) ((x) << 0)
  1407. # define R600_SC_HIZ_TILE_FIFO_SIZE(x) ((x) << 8)
  1408. # define R600_SC_EARLYZ_TILE_FIFO_SIZE(x) ((x) << 16)
  1409. #define R700_PA_SC_FIFO_SIZE_R7XX 0x8bcc
  1410. # define R700_SC_PRIM_FIFO_SIZE(x) ((x) << 0)
  1411. # define R700_SC_HIZ_TILE_FIFO_SIZE(x) ((x) << 12)
  1412. # define R700_SC_EARLYZ_TILE_FIFO_SIZE(x) ((x) << 20)
  1413. #define R600_PA_SC_ENHANCE 0x8bf0
  1414. # define R600_FORCE_EOV_MAX_CLK_CNT(x) ((x) << 0)
  1415. # define R600_FORCE_EOV_MAX_TILE_CNT(x) ((x) << 12)
  1416. #define R600_PA_SC_CLIPRECT_RULE 0x2820c
  1417. #define R700_PA_SC_EDGERULE 0x28230
  1418. #define R600_PA_SC_LINE_STIPPLE 0x28a0c
  1419. #define R600_PA_SC_MODE_CNTL 0x28a4c
  1420. #define R600_PA_SC_AA_CONFIG 0x28c04
  1421. #define R600_SX_EXPORT_BUFFER_SIZES 0x900c
  1422. # define R600_COLOR_BUFFER_SIZE(x) ((x) << 0)
  1423. # define R600_POSITION_BUFFER_SIZE(x) ((x) << 8)
  1424. # define R600_SMX_BUFFER_SIZE(x) ((x) << 16)
  1425. #define R600_SX_DEBUG_1 0x9054
  1426. # define R600_SMX_EVENT_RELEASE (1 << 0)
  1427. # define R600_ENABLE_NEW_SMX_ADDRESS (1 << 16)
  1428. #define R700_SX_DEBUG_1 0x9058
  1429. # define R700_ENABLE_NEW_SMX_ADDRESS (1 << 16)
  1430. #define R600_SX_MISC 0x28350
  1431. #define R600_DB_DEBUG 0x9830
  1432. # define R600_PREZ_MUST_WAIT_FOR_POSTZ_DONE (1 << 31)
  1433. #define R600_DB_WATERMARKS 0x9838
  1434. # define R600_DEPTH_FREE(x) ((x) << 0)
  1435. # define R600_DEPTH_FLUSH(x) ((x) << 5)
  1436. # define R600_DEPTH_PENDING_FREE(x) ((x) << 15)
  1437. # define R600_DEPTH_CACHELINE_FREE(x) ((x) << 20)
  1438. #define R700_DB_DEBUG3 0x98b0
  1439. # define R700_DB_CLK_OFF_DELAY(x) ((x) << 11)
  1440. #define RV700_DB_DEBUG4 0x9b8c
  1441. # define RV700_DISABLE_TILE_COVERED_FOR_PS_ITER (1 << 6)
  1442. #define R600_VGT_CACHE_INVALIDATION 0x88c4
  1443. # define R600_CACHE_INVALIDATION(x) ((x) << 0)
  1444. # define R600_VC_ONLY 0
  1445. # define R600_TC_ONLY 1
  1446. # define R600_VC_AND_TC 2
  1447. # define R700_AUTO_INVLD_EN(x) ((x) << 6)
  1448. # define R700_NO_AUTO 0
  1449. # define R700_ES_AUTO 1
  1450. # define R700_GS_AUTO 2
  1451. # define R700_ES_AND_GS_AUTO 3
  1452. #define R600_VGT_GS_PER_ES 0x88c8
  1453. #define R600_VGT_ES_PER_GS 0x88cc
  1454. #define R600_VGT_GS_PER_VS 0x88e8
  1455. #define R600_VGT_GS_VERTEX_REUSE 0x88d4
  1456. #define R600_VGT_NUM_INSTANCES 0x8974
  1457. #define R600_VGT_STRMOUT_EN 0x28ab0
  1458. #define R600_VGT_EVENT_INITIATOR 0x28a90
  1459. # define R600_CACHE_FLUSH_AND_INV_EVENT (0x16 << 0)
  1460. #define R600_VGT_VERTEX_REUSE_BLOCK_CNTL 0x28c58
  1461. # define R600_VTX_REUSE_DEPTH_MASK 0xff
  1462. #define R600_VGT_OUT_DEALLOC_CNTL 0x28c5c
  1463. # define R600_DEALLOC_DIST_MASK 0x7f
  1464. #define R600_CB_COLOR0_BASE 0x28040
  1465. #define R600_CB_COLOR1_BASE 0x28044
  1466. #define R600_CB_COLOR2_BASE 0x28048
  1467. #define R600_CB_COLOR3_BASE 0x2804c
  1468. #define R600_CB_COLOR4_BASE 0x28050
  1469. #define R600_CB_COLOR5_BASE 0x28054
  1470. #define R600_CB_COLOR6_BASE 0x28058
  1471. #define R600_CB_COLOR7_BASE 0x2805c
  1472. #define R600_CB_COLOR7_FRAG 0x280fc
  1473. #define R600_CB_COLOR0_SIZE 0x28060
  1474. #define R600_CB_COLOR0_VIEW 0x28080
  1475. #define R600_CB_COLOR0_INFO 0x280a0
  1476. #define R600_CB_COLOR0_TILE 0x280c0
  1477. #define R600_CB_COLOR0_FRAG 0x280e0
  1478. #define R600_CB_COLOR0_MASK 0x28100
  1479. #define AVIVO_D1MODE_VLINE_START_END 0x6538
  1480. #define AVIVO_D2MODE_VLINE_START_END 0x6d38
  1481. #define R600_CP_COHER_BASE 0x85f8
  1482. #define R600_DB_DEPTH_BASE 0x2800c
  1483. #define R600_SQ_PGM_START_FS 0x28894
  1484. #define R600_SQ_PGM_START_ES 0x28880
  1485. #define R600_SQ_PGM_START_VS 0x28858
  1486. #define R600_SQ_PGM_RESOURCES_VS 0x28868
  1487. #define R600_SQ_PGM_CF_OFFSET_VS 0x288d0
  1488. #define R600_SQ_PGM_START_GS 0x2886c
  1489. #define R600_SQ_PGM_START_PS 0x28840
  1490. #define R600_SQ_PGM_RESOURCES_PS 0x28850
  1491. #define R600_SQ_PGM_EXPORTS_PS 0x28854
  1492. #define R600_SQ_PGM_CF_OFFSET_PS 0x288cc
  1493. #define R600_VGT_DMA_BASE 0x287e8
  1494. #define R600_VGT_DMA_BASE_HI 0x287e4
  1495. #define R600_VGT_STRMOUT_BASE_OFFSET_0 0x28b10
  1496. #define R600_VGT_STRMOUT_BASE_OFFSET_1 0x28b14
  1497. #define R600_VGT_STRMOUT_BASE_OFFSET_2 0x28b18
  1498. #define R600_VGT_STRMOUT_BASE_OFFSET_3 0x28b1c
  1499. #define R600_VGT_STRMOUT_BASE_OFFSET_HI_0 0x28b44
  1500. #define R600_VGT_STRMOUT_BASE_OFFSET_HI_1 0x28b48
  1501. #define R600_VGT_STRMOUT_BASE_OFFSET_HI_2 0x28b4c
  1502. #define R600_VGT_STRMOUT_BASE_OFFSET_HI_3 0x28b50
  1503. #define R600_VGT_STRMOUT_BUFFER_BASE_0 0x28ad8
  1504. #define R600_VGT_STRMOUT_BUFFER_BASE_1 0x28ae8
  1505. #define R600_VGT_STRMOUT_BUFFER_BASE_2 0x28af8
  1506. #define R600_VGT_STRMOUT_BUFFER_BASE_3 0x28b08
  1507. #define R600_VGT_STRMOUT_BUFFER_OFFSET_0 0x28adc
  1508. #define R600_VGT_STRMOUT_BUFFER_OFFSET_1 0x28aec
  1509. #define R600_VGT_STRMOUT_BUFFER_OFFSET_2 0x28afc
  1510. #define R600_VGT_STRMOUT_BUFFER_OFFSET_3 0x28b0c
  1511. #define R600_VGT_PRIMITIVE_TYPE 0x8958
  1512. #define R600_PA_SC_SCREEN_SCISSOR_TL 0x28030
  1513. #define R600_PA_SC_GENERIC_SCISSOR_TL 0x28240
  1514. #define R600_PA_SC_WINDOW_SCISSOR_TL 0x28204
  1515. #define R600_TC_CNTL 0x9608
  1516. # define R600_TC_L2_SIZE(x) ((x) << 5)
  1517. # define R600_L2_DISABLE_LATE_HIT (1 << 9)
  1518. #define R600_ARB_POP 0x2418
  1519. # define R600_ENABLE_TC128 (1 << 30)
  1520. #define R600_ARB_GDEC_RD_CNTL 0x246c
  1521. #define R600_TA_CNTL_AUX 0x9508
  1522. # define R600_DISABLE_CUBE_WRAP (1 << 0)
  1523. # define R600_DISABLE_CUBE_ANISO (1 << 1)
  1524. # define R700_GETLOD_SELECT(x) ((x) << 2)
  1525. # define R600_SYNC_GRADIENT (1 << 24)
  1526. # define R600_SYNC_WALKER (1 << 25)
  1527. # define R600_SYNC_ALIGNER (1 << 26)
  1528. # define R600_BILINEAR_PRECISION_6_BIT (0 << 31)
  1529. # define R600_BILINEAR_PRECISION_8_BIT (1 << 31)
  1530. #define R700_TCP_CNTL 0x9610
  1531. #define R600_SMX_DC_CTL0 0xa020
  1532. # define R700_USE_HASH_FUNCTION (1 << 0)
  1533. # define R700_CACHE_DEPTH(x) ((x) << 1)
  1534. # define R700_FLUSH_ALL_ON_EVENT (1 << 10)
  1535. # define R700_STALL_ON_EVENT (1 << 11)
  1536. #define R700_SMX_EVENT_CTL 0xa02c
  1537. # define R700_ES_FLUSH_CTL(x) ((x) << 0)
  1538. # define R700_GS_FLUSH_CTL(x) ((x) << 3)
  1539. # define R700_ACK_FLUSH_CTL(x) ((x) << 6)
  1540. # define R700_SYNC_FLUSH_CTL (1 << 8)
  1541. #define R600_SQ_CONFIG 0x8c00
  1542. # define R600_VC_ENABLE (1 << 0)
  1543. # define R600_EXPORT_SRC_C (1 << 1)
  1544. # define R600_DX9_CONSTS (1 << 2)
  1545. # define R600_ALU_INST_PREFER_VECTOR (1 << 3)
  1546. # define R600_DX10_CLAMP (1 << 4)
  1547. # define R600_CLAUSE_SEQ_PRIO(x) ((x) << 8)
  1548. # define R600_PS_PRIO(x) ((x) << 24)
  1549. # define R600_VS_PRIO(x) ((x) << 26)
  1550. # define R600_GS_PRIO(x) ((x) << 28)
  1551. # define R600_ES_PRIO(x) ((x) << 30)
  1552. #define R600_SQ_GPR_RESOURCE_MGMT_1 0x8c04
  1553. # define R600_NUM_PS_GPRS(x) ((x) << 0)
  1554. # define R600_NUM_VS_GPRS(x) ((x) << 16)
  1555. # define R700_DYN_GPR_ENABLE (1 << 27)
  1556. # define R600_NUM_CLAUSE_TEMP_GPRS(x) ((x) << 28)
  1557. #define R600_SQ_GPR_RESOURCE_MGMT_2 0x8c08
  1558. # define R600_NUM_GS_GPRS(x) ((x) << 0)
  1559. # define R600_NUM_ES_GPRS(x) ((x) << 16)
  1560. #define R600_SQ_THREAD_RESOURCE_MGMT 0x8c0c
  1561. # define R600_NUM_PS_THREADS(x) ((x) << 0)
  1562. # define R600_NUM_VS_THREADS(x) ((x) << 8)
  1563. # define R600_NUM_GS_THREADS(x) ((x) << 16)
  1564. # define R600_NUM_ES_THREADS(x) ((x) << 24)
  1565. #define R600_SQ_STACK_RESOURCE_MGMT_1 0x8c10
  1566. # define R600_NUM_PS_STACK_ENTRIES(x) ((x) << 0)
  1567. # define R600_NUM_VS_STACK_ENTRIES(x) ((x) << 16)
  1568. #define R600_SQ_STACK_RESOURCE_MGMT_2 0x8c14
  1569. # define R600_NUM_GS_STACK_ENTRIES(x) ((x) << 0)
  1570. # define R600_NUM_ES_STACK_ENTRIES(x) ((x) << 16)
  1571. #define R600_SQ_MS_FIFO_SIZES 0x8cf0
  1572. # define R600_CACHE_FIFO_SIZE(x) ((x) << 0)
  1573. # define R600_FETCH_FIFO_HIWATER(x) ((x) << 8)
  1574. # define R600_DONE_FIFO_HIWATER(x) ((x) << 16)
  1575. # define R600_ALU_UPDATE_FIFO_HIWATER(x) ((x) << 24)
  1576. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_0 0x8db0
  1577. # define R700_SIMDA_RING0(x) ((x) << 0)
  1578. # define R700_SIMDA_RING1(x) ((x) << 8)
  1579. # define R700_SIMDB_RING0(x) ((x) << 16)
  1580. # define R700_SIMDB_RING1(x) ((x) << 24)
  1581. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_1 0x8db4
  1582. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_2 0x8db8
  1583. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_3 0x8dbc
  1584. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_4 0x8dc0
  1585. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_5 0x8dc4
  1586. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_6 0x8dc8
  1587. #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_7 0x8dcc
  1588. #define R600_SPI_PS_IN_CONTROL_0 0x286cc
  1589. # define R600_NUM_INTERP(x) ((x) << 0)
  1590. # define R600_POSITION_ENA (1 << 8)
  1591. # define R600_POSITION_CENTROID (1 << 9)
  1592. # define R600_POSITION_ADDR(x) ((x) << 10)
  1593. # define R600_PARAM_GEN(x) ((x) << 15)
  1594. # define R600_PARAM_GEN_ADDR(x) ((x) << 19)
  1595. # define R600_BARYC_SAMPLE_CNTL(x) ((x) << 26)
  1596. # define R600_PERSP_GRADIENT_ENA (1 << 28)
  1597. # define R600_LINEAR_GRADIENT_ENA (1 << 29)
  1598. # define R600_POSITION_SAMPLE (1 << 30)
  1599. # define R600_BARYC_AT_SAMPLE_ENA (1 << 31)
  1600. #define R600_SPI_PS_IN_CONTROL_1 0x286d0
  1601. # define R600_GEN_INDEX_PIX (1 << 0)
  1602. # define R600_GEN_INDEX_PIX_ADDR(x) ((x) << 1)
  1603. # define R600_FRONT_FACE_ENA (1 << 8)
  1604. # define R600_FRONT_FACE_CHAN(x) ((x) << 9)
  1605. # define R600_FRONT_FACE_ALL_BITS (1 << 11)
  1606. # define R600_FRONT_FACE_ADDR(x) ((x) << 12)
  1607. # define R600_FOG_ADDR(x) ((x) << 17)
  1608. # define R600_FIXED_PT_POSITION_ENA (1 << 24)
  1609. # define R600_FIXED_PT_POSITION_ADDR(x) ((x) << 25)
  1610. # define R700_POSITION_ULC (1 << 30)
  1611. #define R600_SPI_INPUT_Z 0x286d8
  1612. #define R600_SPI_CONFIG_CNTL 0x9100
  1613. # define R600_GPR_WRITE_PRIORITY(x) ((x) << 0)
  1614. # define R600_DISABLE_INTERP_1 (1 << 5)
  1615. #define R600_SPI_CONFIG_CNTL_1 0x913c
  1616. # define R600_VTX_DONE_DELAY(x) ((x) << 0)
  1617. # define R600_INTERP_ONE_PRIM_PER_ROW (1 << 4)
  1618. #define R600_GB_TILING_CONFIG 0x98f0
  1619. # define R600_PIPE_TILING(x) ((x) << 1)
  1620. # define R600_BANK_TILING(x) ((x) << 4)
  1621. # define R600_GROUP_SIZE(x) ((x) << 6)
  1622. # define R600_ROW_TILING(x) ((x) << 8)
  1623. # define R600_BANK_SWAPS(x) ((x) << 11)
  1624. # define R600_SAMPLE_SPLIT(x) ((x) << 14)
  1625. # define R600_BACKEND_MAP(x) ((x) << 16)
  1626. #define R600_DCP_TILING_CONFIG 0x6ca0
  1627. #define R600_HDP_TILING_CONFIG 0x2f3c
  1628. #define R600_CC_RB_BACKEND_DISABLE 0x98f4
  1629. #define R700_CC_SYS_RB_BACKEND_DISABLE 0x3f88
  1630. # define R600_BACKEND_DISABLE(x) ((x) << 16)
  1631. #define R600_CC_GC_SHADER_PIPE_CONFIG 0x8950
  1632. #define R600_GC_USER_SHADER_PIPE_CONFIG 0x8954
  1633. # define R600_INACTIVE_QD_PIPES(x) ((x) << 8)
  1634. # define R600_INACTIVE_QD_PIPES_MASK (0xff << 8)
  1635. # define R600_INACTIVE_SIMDS(x) ((x) << 16)
  1636. # define R600_INACTIVE_SIMDS_MASK (0xff << 16)
  1637. #define R700_CGTS_SYS_TCC_DISABLE 0x3f90
  1638. #define R700_CGTS_USER_SYS_TCC_DISABLE 0x3f94
  1639. #define R700_CGTS_TCC_DISABLE 0x9148
  1640. #define R700_CGTS_USER_TCC_DISABLE 0x914c
  1641. /* Constants */
  1642. #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
  1643. #define RADEON_LAST_FRAME_REG RADEON_SCRATCH_REG0
  1644. #define RADEON_LAST_DISPATCH_REG RADEON_SCRATCH_REG1
  1645. #define RADEON_LAST_CLEAR_REG RADEON_SCRATCH_REG2
  1646. #define RADEON_LAST_SWI_REG RADEON_SCRATCH_REG3
  1647. #define RADEON_LAST_DISPATCH 1
  1648. #define R600_LAST_FRAME_REG R600_SCRATCH_REG0
  1649. #define R600_LAST_DISPATCH_REG R600_SCRATCH_REG1
  1650. #define R600_LAST_CLEAR_REG R600_SCRATCH_REG2
  1651. #define R600_LAST_SWI_REG R600_SCRATCH_REG3
  1652. #define RADEON_MAX_VB_AGE 0x7fffffff
  1653. #define RADEON_MAX_VB_VERTS (0xffff)
  1654. #define RADEON_RING_HIGH_MARK 128
  1655. #define RADEON_PCIGART_TABLE_SIZE (32*1024)
  1656. #define RADEON_READ(reg) DRM_READ32( dev_priv->mmio, (reg) )
  1657. #define RADEON_WRITE(reg, val) \
  1658. do { \
  1659. if (reg < 0x10000) { \
  1660. DRM_WRITE32(dev_priv->mmio, (reg), (val)); \
  1661. } else { \
  1662. DRM_WRITE32(dev_priv->mmio, RADEON_MM_INDEX, (reg)); \
  1663. DRM_WRITE32(dev_priv->mmio, RADEON_MM_DATA, (val)); \
  1664. } \
  1665. } while (0)
  1666. #define RADEON_READ8(reg) DRM_READ8( dev_priv->mmio, (reg) )
  1667. #define RADEON_WRITE8(reg,val) DRM_WRITE8( dev_priv->mmio, (reg), (val) )
  1668. #define RADEON_WRITE_PLL(addr, val) \
  1669. do { \
  1670. RADEON_WRITE8(RADEON_CLOCK_CNTL_INDEX, \
  1671. ((addr) & 0x1f) | RADEON_PLL_WR_EN ); \
  1672. RADEON_WRITE(RADEON_CLOCK_CNTL_DATA, (val)); \
  1673. } while (0)
  1674. #define RADEON_WRITE_PCIE(addr, val) \
  1675. do { \
  1676. RADEON_WRITE8(RADEON_PCIE_INDEX, \
  1677. ((addr) & 0xff)); \
  1678. RADEON_WRITE(RADEON_PCIE_DATA, (val)); \
  1679. } while (0)
  1680. #define R500_WRITE_MCIND(addr, val) \
  1681. do { \
  1682. RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff)); \
  1683. RADEON_WRITE(R520_MC_IND_DATA, (val)); \
  1684. RADEON_WRITE(R520_MC_IND_INDEX, 0); \
  1685. } while (0)
  1686. #define RS480_WRITE_MCIND(addr, val) \
  1687. do { \
  1688. RADEON_WRITE(RS480_NB_MC_INDEX, \
  1689. ((addr) & 0xff) | RS480_NB_MC_IND_WR_EN); \
  1690. RADEON_WRITE(RS480_NB_MC_DATA, (val)); \
  1691. RADEON_WRITE(RS480_NB_MC_INDEX, 0xff); \
  1692. } while (0)
  1693. #define RS690_WRITE_MCIND(addr, val) \
  1694. do { \
  1695. RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_EN | ((addr) & RS690_MC_INDEX_MASK)); \
  1696. RADEON_WRITE(RS690_MC_DATA, val); \
  1697. RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK); \
  1698. } while (0)
  1699. #define RS600_WRITE_MCIND(addr, val) \
  1700. do { \
  1701. RADEON_WRITE(RS600_MC_INDEX, RS600_MC_IND_WR_EN | RS600_MC_IND_CITF_ARB0 | ((addr) & RS600_MC_ADDR_MASK)); \
  1702. RADEON_WRITE(RS600_MC_DATA, val); \
  1703. } while (0)
  1704. #define IGP_WRITE_MCIND(addr, val) \
  1705. do { \
  1706. if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || \
  1707. ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) \
  1708. RS690_WRITE_MCIND(addr, val); \
  1709. else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS600) \
  1710. RS600_WRITE_MCIND(addr, val); \
  1711. else \
  1712. RS480_WRITE_MCIND(addr, val); \
  1713. } while (0)
  1714. #define CP_PACKET0( reg, n ) \
  1715. (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
  1716. #define CP_PACKET0_TABLE( reg, n ) \
  1717. (RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2))
  1718. #define CP_PACKET1( reg0, reg1 ) \
  1719. (RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2))
  1720. #define CP_PACKET2() \
  1721. (RADEON_CP_PACKET2)
  1722. #define CP_PACKET3( pkt, n ) \
  1723. (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
  1724. /* ================================================================
  1725. * Engine control helper macros
  1726. */
  1727. #define RADEON_WAIT_UNTIL_2D_IDLE() do { \
  1728. OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
  1729. OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
  1730. RADEON_WAIT_HOST_IDLECLEAN) ); \
  1731. } while (0)
  1732. #define RADEON_WAIT_UNTIL_3D_IDLE() do { \
  1733. OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
  1734. OUT_RING( (RADEON_WAIT_3D_IDLECLEAN | \
  1735. RADEON_WAIT_HOST_IDLECLEAN) ); \
  1736. } while (0)
  1737. #define RADEON_WAIT_UNTIL_IDLE() do { \
  1738. OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
  1739. OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
  1740. RADEON_WAIT_3D_IDLECLEAN | \
  1741. RADEON_WAIT_HOST_IDLECLEAN) ); \
  1742. } while (0)
  1743. #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do { \
  1744. OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
  1745. OUT_RING( RADEON_WAIT_CRTC_PFLIP ); \
  1746. } while (0)
  1747. #define RADEON_FLUSH_CACHE() do { \
  1748. if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
  1749. OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \
  1750. OUT_RING(RADEON_RB3D_DC_FLUSH); \
  1751. } else { \
  1752. OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \
  1753. OUT_RING(R300_RB3D_DC_FLUSH); \
  1754. } \
  1755. } while (0)
  1756. #define RADEON_PURGE_CACHE() do { \
  1757. if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
  1758. OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \
  1759. OUT_RING(RADEON_RB3D_DC_FLUSH | RADEON_RB3D_DC_FREE); \
  1760. } else { \
  1761. OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \
  1762. OUT_RING(R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE); \
  1763. } \
  1764. } while (0)
  1765. #define RADEON_FLUSH_ZCACHE() do { \
  1766. if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
  1767. OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \
  1768. OUT_RING(RADEON_RB3D_ZC_FLUSH); \
  1769. } else { \
  1770. OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0)); \
  1771. OUT_RING(R300_ZC_FLUSH); \
  1772. } \
  1773. } while (0)
  1774. #define RADEON_PURGE_ZCACHE() do { \
  1775. if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
  1776. OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \
  1777. OUT_RING(RADEON_RB3D_ZC_FLUSH | RADEON_RB3D_ZC_FREE); \
  1778. } else { \
  1779. OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0)); \
  1780. OUT_RING(R300_ZC_FLUSH | R300_ZC_FREE); \
  1781. } \
  1782. } while (0)
  1783. /* ================================================================
  1784. * Misc helper macros
  1785. */
  1786. /* Perfbox functionality only.
  1787. */
  1788. #define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
  1789. do { \
  1790. if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) { \
  1791. u32 head = GET_RING_HEAD( dev_priv ); \
  1792. if (head == dev_priv->ring.tail) \
  1793. dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE; \
  1794. } \
  1795. } while (0)
  1796. #define VB_AGE_TEST_WITH_RETURN( dev_priv ) \
  1797. do { \
  1798. struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv; \
  1799. drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv; \
  1800. if ( sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE ) { \
  1801. int __ret; \
  1802. if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) \
  1803. __ret = r600_do_cp_idle(dev_priv); \
  1804. else \
  1805. __ret = radeon_do_cp_idle(dev_priv); \
  1806. if ( __ret ) return __ret; \
  1807. sarea_priv->last_dispatch = 0; \
  1808. radeon_freelist_reset( dev ); \
  1809. } \
  1810. } while (0)
  1811. #define RADEON_DISPATCH_AGE( age ) do { \
  1812. OUT_RING( CP_PACKET0( RADEON_LAST_DISPATCH_REG, 0 ) ); \
  1813. OUT_RING( age ); \
  1814. } while (0)
  1815. #define RADEON_FRAME_AGE( age ) do { \
  1816. OUT_RING( CP_PACKET0( RADEON_LAST_FRAME_REG, 0 ) ); \
  1817. OUT_RING( age ); \
  1818. } while (0)
  1819. #define RADEON_CLEAR_AGE( age ) do { \
  1820. OUT_RING( CP_PACKET0( RADEON_LAST_CLEAR_REG, 0 ) ); \
  1821. OUT_RING( age ); \
  1822. } while (0)
  1823. #define R600_DISPATCH_AGE(age) do { \
  1824. OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1)); \
  1825. OUT_RING((R600_LAST_DISPATCH_REG - R600_SET_CONFIG_REG_OFFSET) >> 2); \
  1826. OUT_RING(age); \
  1827. } while (0)
  1828. #define R600_FRAME_AGE(age) do { \
  1829. OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1)); \
  1830. OUT_RING((R600_LAST_FRAME_REG - R600_SET_CONFIG_REG_OFFSET) >> 2); \
  1831. OUT_RING(age); \
  1832. } while (0)
  1833. #define R600_CLEAR_AGE(age) do { \
  1834. OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1)); \
  1835. OUT_RING((R600_LAST_CLEAR_REG - R600_SET_CONFIG_REG_OFFSET) >> 2); \
  1836. OUT_RING(age); \
  1837. } while (0)
  1838. /* ================================================================
  1839. * Ring control
  1840. */
  1841. #define RADEON_VERBOSE 0
  1842. #define RING_LOCALS int write, _nr, _align_nr; unsigned int mask; u32 *ring;
  1843. #define RADEON_RING_ALIGN 16
  1844. #define BEGIN_RING( n ) do { \
  1845. if ( RADEON_VERBOSE ) { \
  1846. DRM_INFO( "BEGIN_RING( %d )\n", (n)); \
  1847. } \
  1848. _align_nr = RADEON_RING_ALIGN - ((dev_priv->ring.tail + n) & (RADEON_RING_ALIGN-1)); \
  1849. _align_nr += n; \
  1850. if (dev_priv->ring.space <= (_align_nr * sizeof(u32))) { \
  1851. COMMIT_RING(); \
  1852. radeon_wait_ring( dev_priv, _align_nr * sizeof(u32)); \
  1853. } \
  1854. _nr = n; dev_priv->ring.space -= (n) * sizeof(u32); \
  1855. ring = dev_priv->ring.start; \
  1856. write = dev_priv->ring.tail; \
  1857. mask = dev_priv->ring.tail_mask; \
  1858. } while (0)
  1859. #define ADVANCE_RING() do { \
  1860. if ( RADEON_VERBOSE ) { \
  1861. DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n", \
  1862. write, dev_priv->ring.tail ); \
  1863. } \
  1864. if (((dev_priv->ring.tail + _nr) & mask) != write) { \
  1865. DRM_ERROR( \
  1866. "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \
  1867. ((dev_priv->ring.tail + _nr) & mask), \
  1868. write, __LINE__); \
  1869. } else \
  1870. dev_priv->ring.tail = write; \
  1871. } while (0)
  1872. extern void radeon_commit_ring(drm_radeon_private_t *dev_priv);
  1873. #define COMMIT_RING() do { \
  1874. radeon_commit_ring(dev_priv); \
  1875. } while(0)
  1876. #define OUT_RING( x ) do { \
  1877. if ( RADEON_VERBOSE ) { \
  1878. DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
  1879. (unsigned int)(x), write ); \
  1880. } \
  1881. ring[write++] = (x); \
  1882. write &= mask; \
  1883. } while (0)
  1884. #define OUT_RING_REG( reg, val ) do { \
  1885. OUT_RING( CP_PACKET0( reg, 0 ) ); \
  1886. OUT_RING( val ); \
  1887. } while (0)
  1888. #define OUT_RING_TABLE( tab, sz ) do { \
  1889. int _size = (sz); \
  1890. int *_tab = (int *)(tab); \
  1891. \
  1892. if (write + _size > mask) { \
  1893. int _i = (mask+1) - write; \
  1894. _size -= _i; \
  1895. while (_i > 0 ) { \
  1896. *(int *)(ring + write) = *_tab++; \
  1897. write++; \
  1898. _i--; \
  1899. } \
  1900. write = 0; \
  1901. _tab += _i; \
  1902. } \
  1903. while (_size > 0) { \
  1904. *(ring + write) = *_tab++; \
  1905. write++; \
  1906. _size--; \
  1907. } \
  1908. write &= mask; \
  1909. } while (0)
  1910. /**
  1911. * Copy given number of dwords from drm buffer to the ring buffer.
  1912. */
  1913. #define OUT_RING_DRM_BUFFER(buf, sz) do { \
  1914. int _size = (sz) * 4; \
  1915. struct drm_buffer *_buf = (buf); \
  1916. int _part_size; \
  1917. while (_size > 0) { \
  1918. _part_size = _size; \
  1919. \
  1920. if (write + _part_size/4 > mask) \
  1921. _part_size = ((mask + 1) - write)*4; \
  1922. \
  1923. if (drm_buffer_index(_buf) + _part_size > PAGE_SIZE) \
  1924. _part_size = PAGE_SIZE - drm_buffer_index(_buf);\
  1925. \
  1926. \
  1927. \
  1928. memcpy(ring + write, &_buf->data[drm_buffer_page(_buf)] \
  1929. [drm_buffer_index(_buf)], _part_size); \
  1930. \
  1931. _size -= _part_size; \
  1932. write = (write + _part_size/4) & mask; \
  1933. drm_buffer_advance(_buf, _part_size); \
  1934. } \
  1935. } while (0)
  1936. #endif /* __RADEON_DRV_H__ */