1209ff23fSmrg/* 2209ff23fSmrg * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and 3209ff23fSmrg * VA Linux Systems Inc., Fremont, California. 4209ff23fSmrg * 5209ff23fSmrg * All Rights Reserved. 6209ff23fSmrg * 7209ff23fSmrg * Permission is hereby granted, free of charge, to any person obtaining 8209ff23fSmrg * a copy of this software and associated documentation files (the 9209ff23fSmrg * "Software"), to deal in the Software without restriction, including 10209ff23fSmrg * without limitation on the rights to use, copy, modify, merge, 11209ff23fSmrg * publish, distribute, sublicense, and/or sell copies of the Software, 12209ff23fSmrg * and to permit persons to whom the Software is furnished to do so, 13209ff23fSmrg * subject to the following conditions: 14209ff23fSmrg * 15209ff23fSmrg * The above copyright notice and this permission notice (including the 16209ff23fSmrg * next paragraph) shall be included in all copies or substantial 17209ff23fSmrg * portions of the Software. 18209ff23fSmrg * 19209ff23fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20209ff23fSmrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21209ff23fSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22209ff23fSmrg * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR 23209ff23fSmrg * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24209ff23fSmrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25209ff23fSmrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26209ff23fSmrg * DEALINGS IN THE SOFTWARE. 27209ff23fSmrg */ 28209ff23fSmrg 29209ff23fSmrg/* 30209ff23fSmrg * Authors: 31209ff23fSmrg * Kevin E. Martin <martin@xfree86.org> 32209ff23fSmrg * Rickard E. Faith <faith@valinux.com> 33209ff23fSmrg * Alan Hourihane <alanh@fairlite.demon.co.uk> 34209ff23fSmrg * 35209ff23fSmrg */ 36209ff23fSmrg 37209ff23fSmrg#ifndef _RADEON_H_ 38209ff23fSmrg#define _RADEON_H_ 39209ff23fSmrg 40209ff23fSmrg#include <stdlib.h> /* For abs() */ 41209ff23fSmrg#include <unistd.h> /* For usleep() */ 42209ff23fSmrg#include <sys/time.h> /* For gettimeofday() */ 43209ff23fSmrg 44209ff23fSmrg#include "config.h" 4568105dcbSveego 46209ff23fSmrg#include "xf86str.h" 47209ff23fSmrg#include "compiler.h" 4843df4709Smrg#include "xf86fbman.h" 49209ff23fSmrg 50209ff23fSmrg /* PCI support */ 51209ff23fSmrg#include "xf86Pci.h" 52209ff23fSmrg 5343df4709Smrg#ifdef USE_EXA 54209ff23fSmrg#include "exa.h" 5543df4709Smrg#endif 5643df4709Smrg#ifdef USE_XAA 5743df4709Smrg#include "xaa.h" 5843df4709Smrg#endif 59209ff23fSmrg 60209ff23fSmrg /* Exa and Cursor Support */ 6143df4709Smrg#include "vbe.h" 62209ff23fSmrg#include "xf86Cursor.h" 63209ff23fSmrg 64209ff23fSmrg /* DDC support */ 65209ff23fSmrg#include "xf86DDC.h" 66209ff23fSmrg 67209ff23fSmrg /* Xv support */ 68209ff23fSmrg#include "xf86xv.h" 69209ff23fSmrg 70209ff23fSmrg#include "radeon_probe.h" 7143df4709Smrg#include "radeon_tv.h" 72209ff23fSmrg 73209ff23fSmrg /* DRI support */ 7443df4709Smrg#ifdef XF86DRI 7543df4709Smrg#define _XF86DRI_SERVER_ 7643df4709Smrg#include "dri.h" 7743df4709Smrg#include "GL/glxint.h" 78b7e1c893Smrg#include "xf86drm.h" 79ad43ddacSmrg#include "radeon_drm.h" 80b7e1c893Smrg 81209ff23fSmrg#ifdef DAMAGE 82209ff23fSmrg#include "damage.h" 83209ff23fSmrg#include "globals.h" 84209ff23fSmrg#endif 8543df4709Smrg#endif 86209ff23fSmrg 87209ff23fSmrg#include "xf86Crtc.h" 88209ff23fSmrg#include "X11/Xatom.h" 89209ff23fSmrg 9043df4709Smrg#ifdef XF86DRM_MODE 91ad43ddacSmrg#include "radeon_bo.h" 92ad43ddacSmrg#include "radeon_cs.h" 93ad43ddacSmrg#include "radeon_dri2.h" 94ad43ddacSmrg#include "drmmode_display.h" 9540732134Srjs#include "radeon_surface.h" 9643df4709Smrg#else 9743df4709Smrg#include "radeon_dummy_bufmgr.h" 9843df4709Smrg#endif 99ad43ddacSmrg 100209ff23fSmrg /* Render support */ 101209ff23fSmrg#ifdef RENDER 102209ff23fSmrg#include "picturestr.h" 103209ff23fSmrg#endif 104209ff23fSmrg 10568105dcbSveego#include "compat-api.h" 10668105dcbSveego 107ad43ddacSmrg#include "simple_list.h" 108209ff23fSmrg#include "atipcirename.h" 109209ff23fSmrg 110209ff23fSmrg#ifndef MAX 111209ff23fSmrg#define MAX(a,b) ((a)>(b)?(a):(b)) 112209ff23fSmrg#endif 113209ff23fSmrg#ifndef MIN 114209ff23fSmrg#define MIN(a,b) ((a)>(b)?(b):(a)) 115209ff23fSmrg#endif 116209ff23fSmrg 117b7e1c893Smrg#if HAVE_BYTESWAP_H 118b7e1c893Smrg#include <byteswap.h> 119b7e1c893Smrg#elif defined(USE_SYS_ENDIAN_H) 120b7e1c893Smrg#include <sys/endian.h> 121b7e1c893Smrg#else 122b7e1c893Smrg#define bswap_16(value) \ 123b7e1c893Smrg ((((value) & 0xff) << 8) | ((value) >> 8)) 124b7e1c893Smrg 125b7e1c893Smrg#define bswap_32(value) \ 126b7e1c893Smrg (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ 127b7e1c893Smrg (uint32_t)bswap_16((uint16_t)((value) >> 16))) 128b7e1c893Smrg 129b7e1c893Smrg#define bswap_64(value) \ 130b7e1c893Smrg (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ 131b7e1c893Smrg << 32) | \ 132b7e1c893Smrg (uint64_t)bswap_32((uint32_t)((value) >> 32))) 133b7e1c893Smrg#endif 134b7e1c893Smrg 135b7e1c893Smrg#if X_BYTE_ORDER == X_BIG_ENDIAN 136b7e1c893Smrg#define le32_to_cpu(x) bswap_32(x) 137b7e1c893Smrg#define le16_to_cpu(x) bswap_16(x) 138b7e1c893Smrg#define cpu_to_le32(x) bswap_32(x) 139b7e1c893Smrg#define cpu_to_le16(x) bswap_16(x) 140b7e1c893Smrg#else 141b7e1c893Smrg#define le32_to_cpu(x) (x) 142b7e1c893Smrg#define le16_to_cpu(x) (x) 143b7e1c893Smrg#define cpu_to_le32(x) (x) 144b7e1c893Smrg#define cpu_to_le16(x) (x) 145b7e1c893Smrg#endif 146b7e1c893Smrg 147209ff23fSmrg/* Provide substitutes for gcc's __FUNCTION__ on other compilers */ 148209ff23fSmrg#if !defined(__GNUC__) && !defined(__FUNCTION__) 149209ff23fSmrg# define __FUNCTION__ __func__ /* C99 */ 150209ff23fSmrg#endif 151209ff23fSmrg 15243df4709Smrg#ifndef HAVE_XF86MODEBANDWIDTH 15343df4709Smrgextern unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth); 15443df4709Smrg#define MODE_BANDWIDTH MODE_BAD 15543df4709Smrg#endif 15643df4709Smrg 157209ff23fSmrgtypedef enum { 15843df4709Smrg OPTION_NOACCEL, 159209ff23fSmrg OPTION_SW_CURSOR, 16043df4709Smrg OPTION_DAC_6BIT, 16143df4709Smrg OPTION_DAC_8BIT, 16243df4709Smrg#ifdef XF86DRI 16343df4709Smrg OPTION_BUS_TYPE, 16443df4709Smrg OPTION_CP_PIO, 16543df4709Smrg OPTION_USEC_TIMEOUT, 16643df4709Smrg OPTION_AGP_MODE, 16743df4709Smrg OPTION_AGP_FW, 16843df4709Smrg OPTION_GART_SIZE, 16943df4709Smrg OPTION_GART_SIZE_OLD, 17043df4709Smrg OPTION_RING_SIZE, 17143df4709Smrg OPTION_BUFFER_SIZE, 17243df4709Smrg OPTION_DEPTH_MOVE, 173209ff23fSmrg OPTION_PAGE_FLIP, 17443df4709Smrg OPTION_NO_BACKBUFFER, 17543df4709Smrg OPTION_XV_DMA, 17643df4709Smrg OPTION_FBTEX_PERCENT, 17743df4709Smrg OPTION_DEPTH_BITS, 17843df4709Smrg OPTION_PCIAPER_SIZE, 17943df4709Smrg#ifdef USE_EXA 18043df4709Smrg OPTION_ACCEL_DFS, 181ad43ddacSmrg OPTION_EXA_PIXMAPS, 18243df4709Smrg#endif 18343df4709Smrg#endif 18443df4709Smrg OPTION_IGNORE_EDID, 18543df4709Smrg OPTION_CUSTOM_EDID, 18643df4709Smrg OPTION_DISP_PRIORITY, 18743df4709Smrg OPTION_PANEL_SIZE, 18843df4709Smrg OPTION_MIN_DOTCLOCK, 189209ff23fSmrg OPTION_COLOR_TILING, 19040732134Srjs OPTION_COLOR_TILING_2D, 19143df4709Smrg#ifdef XvExtension 19243df4709Smrg OPTION_VIDEO_KEY, 19343df4709Smrg OPTION_RAGE_THEATRE_CRYSTAL, 19443df4709Smrg OPTION_RAGE_THEATRE_TUNER_PORT, 19543df4709Smrg OPTION_RAGE_THEATRE_COMPOSITE_PORT, 19643df4709Smrg OPTION_RAGE_THEATRE_SVIDEO_PORT, 19743df4709Smrg OPTION_TUNER_TYPE, 19843df4709Smrg OPTION_RAGE_THEATRE_MICROC_PATH, 19943df4709Smrg OPTION_RAGE_THEATRE_MICROC_TYPE, 20043df4709Smrg OPTION_SCALER_WIDTH, 20143df4709Smrg#endif 202209ff23fSmrg#ifdef RENDER 203209ff23fSmrg OPTION_RENDER_ACCEL, 204209ff23fSmrg OPTION_SUBPIXEL_ORDER, 205209ff23fSmrg#endif 20643df4709Smrg OPTION_SHOWCACHE, 20743df4709Smrg OPTION_CLOCK_GATING, 20843df4709Smrg OPTION_BIOS_HOTKEYS, 20943df4709Smrg OPTION_VGA_ACCESS, 21043df4709Smrg OPTION_REVERSE_DDC, 21143df4709Smrg OPTION_LVDS_PROBE_PLL, 212209ff23fSmrg OPTION_ACCELMETHOD, 21343df4709Smrg OPTION_CONNECTORTABLE, 21443df4709Smrg OPTION_DRI, 21543df4709Smrg OPTION_DEFAULT_CONNECTOR_TABLE, 21643df4709Smrg#if defined(__powerpc__) 21743df4709Smrg OPTION_MAC_MODEL, 21843df4709Smrg#endif 21943df4709Smrg OPTION_DEFAULT_TMDS_PLL, 22043df4709Smrg OPTION_TVDAC_LOAD_DETECT, 22143df4709Smrg OPTION_FORCE_TVOUT, 22243df4709Smrg OPTION_TVSTD, 22343df4709Smrg OPTION_IGNORE_LID_STATUS, 22443df4709Smrg OPTION_DEFAULT_TVDAC_ADJ, 22543df4709Smrg OPTION_INT10, 226b7e1c893Smrg OPTION_EXA_VSYNC, 22743df4709Smrg OPTION_ATOM_TVOUT, 22843df4709Smrg OPTION_R4XX_ATOM, 22943df4709Smrg OPTION_FORCE_LOW_POWER, 23043df4709Smrg OPTION_DYNAMIC_PM, 23143df4709Smrg OPTION_NEW_PLL, 232921a55d8Smrg OPTION_ZAPHOD_HEADS, 23343df4709Smrg OPTION_SWAPBUFFERS_WAIT 234209ff23fSmrg} RADEONOpts; 235209ff23fSmrg 236209ff23fSmrg 23743df4709Smrg#define RADEON_IDLE_RETRY 16 /* Fall out of idle loops after this count */ 23843df4709Smrg#define RADEON_TIMEOUT 2000000 /* Fall out of wait loops after this count */ 239209ff23fSmrg 240209ff23fSmrg#define RADEON_VSYNC_TIMEOUT 20000 /* Maximum wait for VSYNC (in usecs) */ 241209ff23fSmrg 242209ff23fSmrg/* Buffer are aligned on 4096 byte boundaries */ 243ad43ddacSmrg#define RADEON_GPU_PAGE_SIZE 4096 244ad43ddacSmrg#define RADEON_BUFFER_ALIGN (RADEON_GPU_PAGE_SIZE - 1) 24543df4709Smrg#define RADEON_VBIOS_SIZE 0x00010000 24643df4709Smrg#define RADEON_USE_RMX 0x80000000 /* mode flag for using RMX 24743df4709Smrg * Need to comfirm this is not used 24843df4709Smrg * for something else. 24943df4709Smrg */ 250209ff23fSmrg 251209ff23fSmrg#define xFixedToFloat(f) (((float) (f)) / 65536) 252209ff23fSmrg 253209ff23fSmrg#define RADEON_LOGLEVEL_DEBUG 4 254209ff23fSmrg 255209ff23fSmrg/* for Xv, outputs */ 256209ff23fSmrg#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) 257209ff23fSmrg 258209ff23fSmrg/* Other macros */ 259209ff23fSmrg#define RADEON_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 260209ff23fSmrg#define RADEON_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) 261209ff23fSmrg#define RADEONPTR(pScrn) ((RADEONInfoPtr)(pScrn)->driverPrivate) 262209ff23fSmrg 26343df4709Smrgtypedef struct { 26443df4709Smrg int revision; 26543df4709Smrg uint16_t rr1_offset; 26643df4709Smrg uint16_t rr2_offset; 26743df4709Smrg uint16_t dyn_clk_offset; 26843df4709Smrg uint16_t pll_offset; 26943df4709Smrg uint16_t mem_config_offset; 27043df4709Smrg uint16_t mem_reset_offset; 27143df4709Smrg uint16_t short_mem_offset; 27243df4709Smrg uint16_t rr3_offset; 27343df4709Smrg uint16_t rr4_offset; 27443df4709Smrg} RADEONBIOSInitTable; 27543df4709Smrg 27643df4709Smrg#define RADEON_PLL_USE_BIOS_DIVS (1 << 0) 27743df4709Smrg#define RADEON_PLL_NO_ODD_POST_DIV (1 << 1) 27843df4709Smrg#define RADEON_PLL_USE_REF_DIV (1 << 2) 27943df4709Smrg#define RADEON_PLL_LEGACY (1 << 3) 28043df4709Smrg#define RADEON_PLL_PREFER_LOW_REF_DIV (1 << 4) 28143df4709Smrg#define RADEON_PLL_PREFER_HIGH_REF_DIV (1 << 5) 28243df4709Smrg#define RADEON_PLL_PREFER_LOW_FB_DIV (1 << 6) 28343df4709Smrg#define RADEON_PLL_PREFER_HIGH_FB_DIV (1 << 7) 28443df4709Smrg#define RADEON_PLL_PREFER_LOW_POST_DIV (1 << 8) 28543df4709Smrg#define RADEON_PLL_PREFER_HIGH_POST_DIV (1 << 9) 28643df4709Smrg#define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10) 28743df4709Smrg#define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11) 28843df4709Smrg#define RADEON_PLL_USE_POST_DIV (1 << 12) 28943df4709Smrg 29043df4709Smrgtypedef struct { 29143df4709Smrg uint32_t reference_freq; 29243df4709Smrg uint32_t reference_div; 29343df4709Smrg uint32_t post_div; 29443df4709Smrg uint32_t pll_in_min; 29543df4709Smrg uint32_t pll_in_max; 29643df4709Smrg uint32_t pll_out_min; 29743df4709Smrg uint32_t pll_out_max; 29843df4709Smrg uint16_t xclk; 29943df4709Smrg 30043df4709Smrg uint32_t min_ref_div; 30143df4709Smrg uint32_t max_ref_div; 30243df4709Smrg uint32_t min_post_div; 30343df4709Smrg uint32_t max_post_div; 30443df4709Smrg uint32_t min_feedback_div; 30543df4709Smrg uint32_t max_feedback_div; 30643df4709Smrg uint32_t min_frac_feedback_div; 30743df4709Smrg uint32_t max_frac_feedback_div; 30843df4709Smrg uint32_t best_vco; 30943df4709Smrg} RADEONPLLRec, *RADEONPLLPtr; 31043df4709Smrg 31143df4709Smrgtypedef struct { 31243df4709Smrg int bitsPerPixel; 31343df4709Smrg int depth; 31443df4709Smrg int displayWidth; 31543df4709Smrg int displayHeight; 31643df4709Smrg int pixel_code; 31743df4709Smrg int pixel_bytes; 31843df4709Smrg DisplayModePtr mode; 31943df4709Smrg} RADEONFBLayout; 32043df4709Smrg 321209ff23fSmrg#define IS_RV100_VARIANT ((info->ChipFamily == CHIP_FAMILY_RV100) || \ 322209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV200) || \ 323209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS100) || \ 324209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS200) || \ 325209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV250) || \ 326209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV280) || \ 327209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS300)) 328209ff23fSmrg 329209ff23fSmrg 330209ff23fSmrg#define IS_R300_VARIANT ((info->ChipFamily == CHIP_FAMILY_R300) || \ 331209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV350) || \ 332209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_R350) || \ 333209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV380) || \ 334209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_R420) || \ 335209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV410) || \ 336209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS400) || \ 337209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS480)) 338209ff23fSmrg 339209ff23fSmrg#define IS_AVIVO_VARIANT ((info->ChipFamily >= CHIP_FAMILY_RV515)) 340209ff23fSmrg 341209ff23fSmrg#define IS_DCE3_VARIANT ((info->ChipFamily >= CHIP_FAMILY_RV620)) 342209ff23fSmrg 343b7e1c893Smrg#define IS_DCE32_VARIANT ((info->ChipFamily >= CHIP_FAMILY_RV730)) 344b7e1c893Smrg 345ad43ddacSmrg#define IS_DCE4_VARIANT ((info->ChipFamily >= CHIP_FAMILY_CEDAR)) 346ad43ddacSmrg 347921a55d8Smrg#define IS_DCE41_VARIANT ((info->ChipFamily >= CHIP_FAMILY_PALM)) 348921a55d8Smrg 349921a55d8Smrg#define IS_DCE5_VARIANT ((info->ChipFamily >= CHIP_FAMILY_BARTS)) 350921a55d8Smrg 351921a55d8Smrg#define IS_EVERGREEN_3D (info->ChipFamily >= CHIP_FAMILY_CEDAR) 352921a55d8Smrg 353b7e1c893Smrg#define IS_R600_3D (info->ChipFamily >= CHIP_FAMILY_R600) 354b7e1c893Smrg 355209ff23fSmrg#define IS_R500_3D ((info->ChipFamily == CHIP_FAMILY_RV515) || \ 356209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_R520) || \ 357209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV530) || \ 358209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_R580) || \ 359209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV560) || \ 360209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV570)) 361209ff23fSmrg 362ad43ddacSmrg#define IS_R400_3D ((info->ChipFamily == CHIP_FAMILY_R420) || \ 36343df4709Smrg (info->ChipFamily == CHIP_FAMILY_RV410) || \ 36443df4709Smrg (info->ChipFamily == CHIP_FAMILY_RS690) || \ 36543df4709Smrg (info->ChipFamily == CHIP_FAMILY_RS600) || \ 36643df4709Smrg (info->ChipFamily == CHIP_FAMILY_RS740)) 367ad43ddacSmrg 368209ff23fSmrg#define IS_R300_3D ((info->ChipFamily == CHIP_FAMILY_R300) || \ 369209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV350) || \ 370209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_R350) || \ 371209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV380) || \ 372209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_R420) || \ 373209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RV410) || \ 374209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS690) || \ 375209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS600) || \ 376209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS740) || \ 377209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS400) || \ 378209ff23fSmrg (info->ChipFamily == CHIP_FAMILY_RS480)) 379209ff23fSmrg 380ad43ddacSmrg#define IS_R200_3D ((info->ChipFamily == CHIP_FAMILY_RV250) || \ 381ad43ddacSmrg (info->ChipFamily == CHIP_FAMILY_RV280) || \ 382ad43ddacSmrg (info->ChipFamily == CHIP_FAMILY_RS300) || \ 383ad43ddacSmrg (info->ChipFamily == CHIP_FAMILY_R200)) 384ad43ddacSmrg 38543df4709Smrg/* 38643df4709Smrg * Errata workarounds 38743df4709Smrg */ 38843df4709Smrgtypedef enum { 38943df4709Smrg CHIP_ERRATA_R300_CG = 0x00000001, 39043df4709Smrg CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002, 39143df4709Smrg CHIP_ERRATA_PLL_DELAY = 0x00000004 39243df4709Smrg} RADEONErrata; 393ad43ddacSmrg 39443df4709Smrgtypedef enum { 39543df4709Smrg RADEON_DVOCHIP_NONE, 39643df4709Smrg RADEON_SIL_164, 39743df4709Smrg RADEON_SIL_1178 39843df4709Smrg} RADEONExtTMDSChip; 399ad43ddacSmrg 40043df4709Smrg#if defined(__powerpc__) 40143df4709Smrgtypedef enum { 40243df4709Smrg RADEON_MAC_NONE, 40343df4709Smrg RADEON_MAC_IBOOK, 40443df4709Smrg RADEON_MAC_POWERBOOK_EXTERNAL, 40543df4709Smrg RADEON_MAC_POWERBOOK_INTERNAL, 40643df4709Smrg RADEON_MAC_POWERBOOK_VGA, 40743df4709Smrg RADEON_MAC_MINI_EXTERNAL, 40843df4709Smrg RADEON_MAC_MINI_INTERNAL, 40943df4709Smrg RADEON_MAC_IMAC_G5_ISIGHT, 41043df4709Smrg RADEON_MAC_EMAC, 41143df4709Smrg RADEON_MAC_SAM440EP 41243df4709Smrg} RADEONMacModel; 41343df4709Smrg#endif 4146322c902Smrg 41543df4709Smrgtypedef enum { 41643df4709Smrg CARD_PCI, 41743df4709Smrg CARD_AGP, 41843df4709Smrg CARD_PCIE 41943df4709Smrg} RADEONCardType; 4206322c902Smrg 42143df4709Smrgtypedef enum { 42243df4709Smrg POWER_DEFAULT, 42343df4709Smrg POWER_LOW, 42443df4709Smrg POWER_HIGH 42543df4709Smrg} RADEONPMType; 4266322c902Smrg 42743df4709Smrgtypedef struct { 42843df4709Smrg RADEONPMType type; 42943df4709Smrg uint32_t sclk; 43043df4709Smrg uint32_t mclk; 43143df4709Smrg uint32_t pcie_lanes; 43243df4709Smrg uint32_t flags; 43343df4709Smrg} RADEONPowerMode; 4346322c902Smrg 43543df4709Smrgtypedef struct { 43643df4709Smrg /* power modes */ 43743df4709Smrg int num_modes; 43843df4709Smrg int current_mode; 43943df4709Smrg RADEONPowerMode mode[3]; 4406322c902Smrg 44143df4709Smrg Bool clock_gating_enabled; 44243df4709Smrg Bool dynamic_mode_enabled; 44343df4709Smrg Bool force_low_power_enabled; 44443df4709Smrg} RADEONPowerManagement; 445ad43ddacSmrg 44643df4709Smrgtypedef struct _atomBiosHandle *atomBiosHandlePtr; 447209ff23fSmrg 448ad43ddacSmrgstruct radeon_exa_pixmap_priv { 449ad43ddacSmrg struct radeon_bo *bo; 450c4ae5be6Smrg uint32_t tiling_flags; 45143df4709Smrg#ifdef XF86DRM_MODE 45240732134Srjs struct radeon_surface surface; 45343df4709Smrg#endif 454ad43ddacSmrg Bool bo_mapped; 455ad43ddacSmrg}; 456ad43ddacSmrg 457ad43ddacSmrg#define RADEON_2D_EXA_COPY 1 458ad43ddacSmrg#define RADEON_2D_EXA_SOLID 2 459ad43ddacSmrg 460ad43ddacSmrgstruct radeon_2d_state { 461ad43ddacSmrg int op; // 462ad43ddacSmrg uint32_t dst_pitch_offset; 463ad43ddacSmrg uint32_t src_pitch_offset; 464ad43ddacSmrg uint32_t dp_gui_master_cntl; 465ad43ddacSmrg uint32_t dp_cntl; 466ad43ddacSmrg uint32_t dp_write_mask; 467ad43ddacSmrg uint32_t dp_brush_frgd_clr; 468ad43ddacSmrg uint32_t dp_brush_bkgd_clr; 469ad43ddacSmrg uint32_t dp_src_frgd_clr; 470ad43ddacSmrg uint32_t dp_src_bkgd_clr; 471ad43ddacSmrg uint32_t default_sc_bottom_right; 472ad43ddacSmrg struct radeon_bo *dst_bo; 473ad43ddacSmrg struct radeon_bo *src_bo; 474ad43ddacSmrg}; 475ad43ddacSmrg 47643df4709Smrg#ifdef XF86DRI 47743df4709Smrgstruct radeon_cp { 47843df4709Smrg Bool CPRuns; /* CP is running */ 47943df4709Smrg Bool CPInUse; /* CP has been used by X server */ 48043df4709Smrg Bool CPStarted; /* CP has started */ 48143df4709Smrg int CPMode; /* CP mode that server/clients use */ 48243df4709Smrg int CPFifoSize; /* Size of the CP command FIFO */ 48343df4709Smrg int CPusecTimeout; /* CP timeout in usecs */ 48443df4709Smrg Bool needCacheFlush; 48543df4709Smrg 48643df4709Smrg /* CP accleration */ 48743df4709Smrg drmBufPtr indirectBuffer; 48843df4709Smrg int indirectStart; 48943df4709Smrg 49043df4709Smrg /* Debugging info for BEGIN_RING/ADVANCE_RING pairs. */ 49143df4709Smrg int dma_begin_count; 49243df4709Smrg char *dma_debug_func; 49343df4709Smrg int dma_debug_lineno; 49443df4709Smrg 49543df4709Smrg }; 49643df4709Smrg 49743df4709Smrgtypedef struct { 49843df4709Smrg /* Nothing here yet */ 49943df4709Smrg int dummy; 50043df4709Smrg} RADEONConfigPrivRec, *RADEONConfigPrivPtr; 50143df4709Smrg 50243df4709Smrgtypedef struct { 50343df4709Smrg /* Nothing here yet */ 50443df4709Smrg int dummy; 50543df4709Smrg} RADEONDRIContextRec, *RADEONDRIContextPtr; 50643df4709Smrg 50743df4709Smrgstruct radeon_dri { 50843df4709Smrg Bool noBackBuffer; 50943df4709Smrg 51043df4709Smrg Bool newMemoryMap; 51143df4709Smrg drmVersionPtr pLibDRMVersion; 51243df4709Smrg drmVersionPtr pKernelDRMVersion; 51343df4709Smrg DRIInfoPtr pDRIInfo; 51443df4709Smrg int drmFD; 51543df4709Smrg int numVisualConfigs; 51643df4709Smrg __GLXvisualConfig *pVisualConfigs; 51743df4709Smrg RADEONConfigPrivPtr pVisualConfigsPriv; 51843df4709Smrg Bool (*DRICloseScreen)(CLOSE_SCREEN_ARGS_DECL); 51943df4709Smrg 52043df4709Smrg drm_handle_t fbHandle; 52143df4709Smrg 52243df4709Smrg drmSize registerSize; 52343df4709Smrg drm_handle_t registerHandle; 52443df4709Smrg 52543df4709Smrg drmSize pciSize; 52643df4709Smrg drm_handle_t pciMemHandle; 52743df4709Smrg unsigned char *PCI; /* Map */ 52843df4709Smrg 52943df4709Smrg Bool depthMoves; /* Enable depth moves -- slow! */ 53043df4709Smrg Bool allowPageFlip; /* Enable 3d page flipping */ 53143df4709Smrg#ifdef DAMAGE 53243df4709Smrg DamagePtr pDamage; 53343df4709Smrg RegionRec driRegion; 53443df4709Smrg#endif 53543df4709Smrg Bool have3DWindows; /* Are there any 3d clients? */ 53643df4709Smrg 53743df4709Smrg int pciAperSize; 53843df4709Smrg drmSize gartSize; 53943df4709Smrg drm_handle_t agpMemHandle; /* Handle from drmAgpAlloc */ 54043df4709Smrg unsigned long gartOffset; 54143df4709Smrg unsigned char *AGP; /* Map */ 54243df4709Smrg int agpMode; 54343df4709Smrg 54443df4709Smrg uint32_t pciCommand; 54543df4709Smrg 54643df4709Smrg /* CP ring buffer data */ 54743df4709Smrg unsigned long ringStart; /* Offset into GART space */ 54843df4709Smrg drm_handle_t ringHandle; /* Handle from drmAddMap */ 54943df4709Smrg drmSize ringMapSize; /* Size of map */ 55043df4709Smrg int ringSize; /* Size of ring (in MB) */ 55143df4709Smrg drmAddress ring; /* Map */ 55243df4709Smrg int ringSizeLog2QW; 55343df4709Smrg 55443df4709Smrg unsigned long ringReadOffset; /* Offset into GART space */ 55543df4709Smrg drm_handle_t ringReadPtrHandle; /* Handle from drmAddMap */ 55643df4709Smrg drmSize ringReadMapSize; /* Size of map */ 55743df4709Smrg drmAddress ringReadPtr; /* Map */ 55843df4709Smrg 55943df4709Smrg /* CP vertex/indirect buffer data */ 56043df4709Smrg unsigned long bufStart; /* Offset into GART space */ 56143df4709Smrg drm_handle_t bufHandle; /* Handle from drmAddMap */ 56243df4709Smrg drmSize bufMapSize; /* Size of map */ 56343df4709Smrg int bufSize; /* Size of buffers (in MB) */ 56443df4709Smrg drmAddress buf; /* Map */ 56543df4709Smrg int bufNumBufs; /* Number of buffers */ 56643df4709Smrg drmBufMapPtr buffers; /* Buffer map */ 56743df4709Smrg 56843df4709Smrg /* CP GART Texture data */ 56943df4709Smrg unsigned long gartTexStart; /* Offset into GART space */ 57043df4709Smrg drm_handle_t gartTexHandle; /* Handle from drmAddMap */ 57143df4709Smrg drmSize gartTexMapSize; /* Size of map */ 57243df4709Smrg int gartTexSize; /* Size of GART tex space (in MB) */ 57343df4709Smrg drmAddress gartTex; /* Map */ 57443df4709Smrg int log2GARTTexGran; 57543df4709Smrg 57643df4709Smrg /* DRI screen private data */ 57743df4709Smrg int fbX; 57843df4709Smrg int fbY; 57943df4709Smrg int backX; 58043df4709Smrg int backY; 58143df4709Smrg int depthX; 58243df4709Smrg int depthY; 58343df4709Smrg 58443df4709Smrg int frontOffset; 58543df4709Smrg int frontPitch; 58643df4709Smrg int backOffset; 58743df4709Smrg int backPitch; 58843df4709Smrg int depthOffset; 58943df4709Smrg int depthPitch; 59043df4709Smrg int depthBits; 59143df4709Smrg int textureOffset; 59243df4709Smrg int textureSize; 59343df4709Smrg int log2TexGran; 59443df4709Smrg 59543df4709Smrg int pciGartSize; 59643df4709Smrg uint32_t pciGartOffset; 59743df4709Smrg void *pciGartBackup; 59843df4709Smrg 59943df4709Smrg int irq; 60043df4709Smrg 60143df4709Smrg#ifdef USE_XAA 60243df4709Smrg uint32_t frontPitchOffset; 60343df4709Smrg uint32_t backPitchOffset; 60443df4709Smrg uint32_t depthPitchOffset; 60543df4709Smrg 60643df4709Smrg /* offscreen memory management */ 60743df4709Smrg int backLines; 60843df4709Smrg FBAreaPtr backArea; 60943df4709Smrg int depthTexLines; 61043df4709Smrg FBAreaPtr depthTexArea; 61143df4709Smrg#endif 61243df4709Smrg 61343df4709Smrg}; 61443df4709Smrg#endif 61543df4709Smrg 616ad43ddacSmrg#define DMA_BO_FREE_TIME 1000 617ad43ddacSmrg 618ad43ddacSmrgstruct radeon_dma_bo { 619ad43ddacSmrg struct radeon_dma_bo *next, *prev; 620ad43ddacSmrg struct radeon_bo *bo; 621ad43ddacSmrg int expire_counter; 622ad43ddacSmrg}; 623ad43ddacSmrg 624ad43ddacSmrgstruct r600_accel_object { 625ad43ddacSmrg uint32_t pitch; 626ad43ddacSmrg uint32_t width; 627ad43ddacSmrg uint32_t height; 62843df4709Smrg uint32_t offset; 629ad43ddacSmrg int bpp; 630ad43ddacSmrg uint32_t domain; 631ad43ddacSmrg struct radeon_bo *bo; 632b13dfe66Smrg uint32_t tiling_flags; 63343df4709Smrg#if defined(XF86DRM_MODE) 63440732134Srjs struct radeon_surface *surface; 63543df4709Smrg#endif 636ad43ddacSmrg}; 637ad43ddacSmrg 638921a55d8Smrgstruct radeon_vbo_object { 639921a55d8Smrg int vb_offset; 64043df4709Smrg uint64_t vb_mc_addr; 641921a55d8Smrg int vb_total; 64243df4709Smrg void *vb_ptr; 643921a55d8Smrg uint32_t vb_size; 644921a55d8Smrg uint32_t vb_op_vert_size; 645921a55d8Smrg int32_t vb_start_op; 646921a55d8Smrg struct radeon_bo *vb_bo; 647921a55d8Smrg unsigned verts_per_op; 648921a55d8Smrg}; 649921a55d8Smrg 650b7e1c893Smrgstruct radeon_accel_state { 65143df4709Smrg /* common accel data */ 65243df4709Smrg int fifo_slots; /* Free slots in the FIFO (64 max) */ 65343df4709Smrg /* Computed values for Radeon */ 65443df4709Smrg uint32_t dp_gui_master_cntl; 65543df4709Smrg uint32_t dp_gui_master_cntl_clip; 65643df4709Smrg uint32_t trans_color; 657b7e1c893Smrg /* Saved values for ScreenToScreenCopy */ 658b7e1c893Smrg int xdir; 659b7e1c893Smrg int ydir; 66043df4709Smrg uint32_t dst_pitch_offset; 661209ff23fSmrg 662b7e1c893Smrg /* render accel */ 663b7e1c893Smrg unsigned short texW[2]; 664b7e1c893Smrg unsigned short texH[2]; 665b7e1c893Smrg Bool XInited3D; /* X itself has the 3D context */ 666b7e1c893Smrg int num_gb_pipes; 667b7e1c893Smrg Bool has_tcl; 668c4ae5be6Smrg Bool allowHWDFS; 669209ff23fSmrg 67043df4709Smrg#ifdef USE_EXA 671b7e1c893Smrg /* EXA */ 672b7e1c893Smrg ExaDriverPtr exa; 673b7e1c893Smrg int exaSyncMarker; 674b7e1c893Smrg int exaMarkerSynced; 675b7e1c893Smrg int engineMode; 676b7e1c893Smrg#define EXA_ENGINEMODE_UNKNOWN 0 677b7e1c893Smrg#define EXA_ENGINEMODE_2D 1 678b7e1c893Smrg#define EXA_ENGINEMODE_3D 2 679209ff23fSmrg 680ad43ddacSmrg int composite_op; 681ad43ddacSmrg PicturePtr dst_pic; 682ad43ddacSmrg PicturePtr msk_pic; 683ad43ddacSmrg PicturePtr src_pic; 684ad43ddacSmrg PixmapPtr dst_pix; 685ad43ddacSmrg PixmapPtr msk_pix; 686ad43ddacSmrg PixmapPtr src_pix; 687b7e1c893Smrg Bool is_transform[2]; 688b7e1c893Smrg PictTransform *transform[2]; 689b7e1c893Smrg /* Whether we are tiling horizontally and vertically */ 690b7e1c893Smrg Bool need_src_tile_x; 691b7e1c893Smrg Bool need_src_tile_y; 692b7e1c893Smrg /* Size of tiles ... set to 65536x65536 if not tiling in that direction */ 693b7e1c893Smrg Bool src_tile_width; 694b7e1c893Smrg Bool src_tile_height; 695ad43ddacSmrg uint32_t *draw_header; 696ad43ddacSmrg unsigned vtx_count; 697ad43ddacSmrg unsigned num_vtx; 698b7e1c893Smrg Bool vsync; 699b7e1c893Smrg 70043df4709Smrg drmBufPtr ib; 70143df4709Smrg 702921a55d8Smrg struct radeon_vbo_object vbo; 703921a55d8Smrg struct radeon_vbo_object cbuf; 704921a55d8Smrg 705ad43ddacSmrg /* where to discard IB from if we cancel operation */ 706ad43ddacSmrg uint32_t ib_reset_op; 70743df4709Smrg#ifdef XF86DRM_MODE 708ad43ddacSmrg struct radeon_dma_bo bo_free; 709ad43ddacSmrg struct radeon_dma_bo bo_wait; 710ad43ddacSmrg struct radeon_dma_bo bo_reserved; 711ad43ddacSmrg Bool use_vbos; 71243df4709Smrg#endif 7130974d292Smrg void (*finish_op)(ScrnInfoPtr, int); 714b7e1c893Smrg // shader storage 71543df4709Smrg ExaOffscreenArea *shaders; 716ad43ddacSmrg struct radeon_bo *shaders_bo; 717b7e1c893Smrg uint32_t solid_vs_offset; 718b7e1c893Smrg uint32_t solid_ps_offset; 719b7e1c893Smrg uint32_t copy_vs_offset; 720b7e1c893Smrg uint32_t copy_ps_offset; 721b7e1c893Smrg uint32_t comp_vs_offset; 722b7e1c893Smrg uint32_t comp_ps_offset; 723b7e1c893Smrg uint32_t xv_vs_offset; 724b7e1c893Smrg uint32_t xv_ps_offset; 725921a55d8Smrg // shader consts 726921a55d8Smrg uint32_t solid_vs_const_offset; 727921a55d8Smrg uint32_t solid_ps_const_offset; 728921a55d8Smrg uint32_t copy_vs_const_offset; 729921a55d8Smrg uint32_t copy_ps_const_offset; 730921a55d8Smrg uint32_t comp_vs_const_offset; 731921a55d8Smrg uint32_t comp_ps_const_offset; 732921a55d8Smrg uint32_t comp_mask_ps_const_offset; 733921a55d8Smrg uint32_t xv_vs_const_offset; 734921a55d8Smrg uint32_t xv_ps_const_offset; 735b7e1c893Smrg 736b7e1c893Smrg //size/addr stuff 737ad43ddacSmrg struct r600_accel_object src_obj[2]; 738ad43ddacSmrg struct r600_accel_object dst_obj; 739b7e1c893Smrg uint32_t src_size[2]; 740b7e1c893Smrg uint32_t dst_size; 741ad43ddacSmrg 742b7e1c893Smrg uint32_t vs_size; 743b7e1c893Smrg uint64_t vs_mc_addr; 744b7e1c893Smrg uint32_t ps_size; 745b7e1c893Smrg uint64_t ps_mc_addr; 746b7e1c893Smrg 74743df4709Smrg // UTS/DFS 74843df4709Smrg drmBufPtr scratch; 74943df4709Smrg 75040732134Srjs // solid/copy 75143df4709Smrg ExaOffscreenArea *copy_area; 752ad43ddacSmrg struct radeon_bo *copy_area_bo; 753b7e1c893Smrg Bool same_surface; 754b7e1c893Smrg int rop; 755b7e1c893Smrg uint32_t planemask; 75640732134Srjs uint32_t fg; 757b7e1c893Smrg 758b7e1c893Smrg // composite 759b7e1c893Smrg Bool component_alpha; 760b7e1c893Smrg Bool src_alpha; 761ad43ddacSmrg // vline 762ad43ddacSmrg xf86CrtcPtr vline_crtc; 763ad43ddacSmrg int vline_y1; 764ad43ddacSmrg int vline_y2; 76543df4709Smrg#endif 76643df4709Smrg 76743df4709Smrg#ifdef USE_XAA 76843df4709Smrg /* XAA */ 76943df4709Smrg XAAInfoRecPtr accel; 77043df4709Smrg /* ScanlineScreenToScreenColorExpand support */ 77143df4709Smrg unsigned char *scratch_buffer[1]; 77243df4709Smrg unsigned char *scratch_save; 77343df4709Smrg int scanline_x; 77443df4709Smrg int scanline_y; 77543df4709Smrg int scanline_w; 77643df4709Smrg int scanline_h; 77743df4709Smrg int scanline_h_w; 77843df4709Smrg int scanline_words; 77943df4709Smrg int scanline_direct; 78043df4709Smrg int scanline_bpp; /* Only used for ImageWrite */ 78143df4709Smrg int scanline_fg; 78243df4709Smrg int scanline_bg; 78343df4709Smrg int scanline_hpass; 78443df4709Smrg int scanline_x1clip; 78543df4709Smrg int scanline_x2clip; 78643df4709Smrg /* Saved values for DashedTwoPointLine */ 78743df4709Smrg int dashLen; 78843df4709Smrg uint32_t dashPattern; 78943df4709Smrg int dash_fg; 79043df4709Smrg int dash_bg; 79143df4709Smrg 79243df4709Smrg FBLinearPtr RenderTex; 79343df4709Smrg void (*RenderCallback)(ScrnInfoPtr); 79443df4709Smrg Time RenderTimeout; 79543df4709Smrg /* 79643df4709Smrg * XAAForceTransBlit is used to change the behavior of the XAA 79743df4709Smrg * SetupForScreenToScreenCopy function, to make it DGA-friendly. 79843df4709Smrg */ 79943df4709Smrg Bool XAAForceTransBlit; 80043df4709Smrg#endif 801209ff23fSmrg 802b7e1c893Smrg}; 803b7e1c893Smrg 804b7e1c893Smrgtypedef struct { 805b7e1c893Smrg EntityInfoPtr pEnt; 806b7e1c893Smrg pciVideoPtr PciInfo; 80743df4709Smrg#ifndef XSERVER_LIBPCIACCESS 80843df4709Smrg PCITAG PciTag; 80943df4709Smrg#endif 810b7e1c893Smrg int Chipset; 811b7e1c893Smrg RADEONChipFamily ChipFamily; 81243df4709Smrg RADEONErrata ChipErrata; 81343df4709Smrg 81443df4709Smrg unsigned long long LinearAddr; /* Frame buffer physical address */ 81543df4709Smrg unsigned long long MMIOAddr; /* MMIO region physical address */ 81643df4709Smrg unsigned long long BIOSAddr; /* BIOS physical address */ 81743df4709Smrg uint64_t fbLocation; 81843df4709Smrg uint32_t gartLocation; 81943df4709Smrg uint32_t mc_fb_location; 82043df4709Smrg uint32_t mc_agp_location; 82143df4709Smrg uint32_t mc_agp_location_hi; 82243df4709Smrg 82343df4709Smrg void *MMIO; /* Map of MMIO region */ 82443df4709Smrg void *FB; /* Map of frame buffer */ 82543df4709Smrg uint8_t *VBIOS; /* Video BIOS pointer */ 82643df4709Smrg 82743df4709Smrg Bool IsAtomBios; /* New BIOS used in R420 etc. */ 82843df4709Smrg int ROMHeaderStart; /* Start of the ROM Info Table */ 82943df4709Smrg int MasterDataStart; /* Offset for Master Data Table for ATOM BIOS */ 83043df4709Smrg 83143df4709Smrg uint32_t MemCntl; 83243df4709Smrg uint32_t BusCntl; 83343df4709Smrg unsigned long MMIOSize; /* MMIO region physical address */ 83443df4709Smrg unsigned long FbMapSize; /* Size of frame buffer, in bytes */ 83543df4709Smrg unsigned long FbSecureSize; /* Size of secured fb area at end of 83643df4709Smrg framebuffer */ 83743df4709Smrg 83843df4709Smrg Bool IsMobility; /* Mobile chips for laptops */ 83943df4709Smrg Bool IsIGP; /* IGP chips */ 84043df4709Smrg Bool HasSingleDAC; /* only TVDAC on chip */ 84143df4709Smrg Bool ddc_mode; /* Validate mode by matching exactly 84243df4709Smrg * the modes supported in DDC data 84343df4709Smrg */ 84443df4709Smrg Bool R300CGWorkaround; 84543df4709Smrg 84643df4709Smrg /* EDID or BIOS values for FPs */ 84743df4709Smrg int RefDivider; 84843df4709Smrg int FeedbackDivider; 84943df4709Smrg int PostDivider; 85043df4709Smrg Bool UseBiosDividers; 85143df4709Smrg /* EDID data using DDC interface */ 85243df4709Smrg Bool ddc_bios; 85343df4709Smrg Bool ddc1; 85443df4709Smrg Bool ddc2; 85543df4709Smrg 85643df4709Smrg RADEONPLLRec pll; 85743df4709Smrg int default_dispclk; 85843df4709Smrg int dp_extclk; 85943df4709Smrg 86043df4709Smrg int RamWidth; 86143df4709Smrg float sclk; /* in MHz */ 86243df4709Smrg float mclk; /* in MHz */ 86343df4709Smrg Bool IsDDR; 86443df4709Smrg int DispPriority; 86543df4709Smrg 86643df4709Smrg RADEONSavePtr SavedReg; /* Original (text) mode */ 86743df4709Smrg RADEONSavePtr ModeReg; /* Current mode */ 86868105dcbSveego Bool (*CloseScreen)(CLOSE_SCREEN_ARGS_DECL); 869b7e1c893Smrg 87068105dcbSveego void (*BlockHandler)(BLOCKHANDLER_ARGS_DECL); 871b7e1c893Smrg 87243df4709Smrg Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ 87343df4709Smrg 87443df4709Smrg xf86CursorInfoPtr cursor; 87543df4709Smrg#ifdef ARGB_CURSOR 87643df4709Smrg Bool cursor_argb; 87743df4709Smrg#endif 87843df4709Smrg int cursor_fg; 87943df4709Smrg int cursor_bg; 880b7e1c893Smrg 881b7e1c893Smrg int pix24bpp; /* Depth of pixmap for 24bpp fb */ 882b7e1c893Smrg Bool dac6bits; /* Use 6 bit DAC? */ 883b7e1c893Smrg 88443df4709Smrg RADEONFBLayout CurrentLayout; 885b7e1c893Smrg 88643df4709Smrg#ifdef XF86DRI 887b7e1c893Smrg Bool directRenderingEnabled; 88843df4709Smrg Bool directRenderingInited; 88943df4709Smrg RADEONCardType cardType; /* Current card is a PCI card */ 89043df4709Smrg struct radeon_cp *cp; 89143df4709Smrg struct radeon_dri *dri; 89243df4709Smrg#ifdef XF86DRM_MODE 893ad43ddacSmrg struct radeon_dri2 dri2; 89443df4709Smrg#endif 89543df4709Smrg#ifdef USE_EXA 89643df4709Smrg Bool accelDFS; 89743df4709Smrg#endif 89843df4709Smrg Bool DMAForXv; 89943df4709Smrg#endif /* XF86DRI */ 900209ff23fSmrg 901b7e1c893Smrg /* accel */ 902b7e1c893Smrg Bool RenderAccel; /* Render */ 903b7e1c893Smrg Bool allowColorTiling; 90440732134Srjs Bool allowColorTiling2D; 90543df4709Smrg Bool tilingEnabled; /* mirror of sarea->tiling_enabled */ 906b7e1c893Smrg struct radeon_accel_state *accel_state; 907b7e1c893Smrg Bool accelOn; 90843df4709Smrg Bool useEXA; 90943df4709Smrg#ifdef USE_EXA 910ad43ddacSmrg Bool exa_pixmaps; 911ad43ddacSmrg Bool exa_force_create; 912b7e1c893Smrg XF86ModReqInfo exaReq; 91343df4709Smrg#endif 91443df4709Smrg#ifdef USE_XAA 91543df4709Smrg XF86ModReqInfo xaaReq; 91643df4709Smrg#endif 917b7e1c893Smrg 91843df4709Smrg /* XVideo */ 91943df4709Smrg XF86VideoAdaptorPtr adaptor; 92043df4709Smrg void (*VideoTimerCallback)(ScrnInfoPtr, Time); 92143df4709Smrg int videoKey; 92243df4709Smrg int RageTheatreCrystal; 92343df4709Smrg int RageTheatreTunerPort; 92443df4709Smrg int RageTheatreCompositePort; 92543df4709Smrg int RageTheatreSVideoPort; 92643df4709Smrg int tunerType; 92733fda08dSchristos const char* RageTheatreMicrocPath; 92833fda08dSchristos const char* RageTheatreMicrocType; 92943df4709Smrg Bool MM_TABLE_valid; 93043df4709Smrg struct { 93143df4709Smrg uint8_t table_revision; 93243df4709Smrg uint8_t table_size; 93343df4709Smrg uint8_t tuner_type; 93443df4709Smrg uint8_t audio_chip; 93543df4709Smrg uint8_t product_id; 93643df4709Smrg uint8_t tuner_voltage_teletext_fm; 93743df4709Smrg uint8_t i2s_config; /* configuration of the sound chip */ 93843df4709Smrg uint8_t video_decoder_type; 93943df4709Smrg uint8_t video_decoder_host_config; 94043df4709Smrg uint8_t input[5]; 94143df4709Smrg } MM_TABLE; 94243df4709Smrg uint16_t video_decoder_type; 94343df4709Smrg int overlay_scaler_buffer_width; 94443df4709Smrg int ecp_div; 945ad43ddacSmrg unsigned int xv_max_width; 946ad43ddacSmrg unsigned int xv_max_height; 947209ff23fSmrg 948209ff23fSmrg /* general */ 949209ff23fSmrg OptionInfoPtr Options; 950209ff23fSmrg 95143df4709Smrg DisplayModePtr currentMode, savedCurrentMode; 952209ff23fSmrg 95343df4709Smrg /* special handlings for DELL triple-head server */ 95443df4709Smrg Bool IsDellServer; 95543df4709Smrg 95643df4709Smrg Bool VGAAccess; 95743df4709Smrg 95843df4709Smrg int MaxSurfaceWidth; 95943df4709Smrg int MaxLines; 96043df4709Smrg 96143df4709Smrg Bool want_vblank_interrupts; 96243df4709Smrg RADEONBIOSConnector BiosConnector[RADEON_MAX_BIOS_CONNECTOR]; 96343df4709Smrg radeon_encoder_ptr encoders[RADEON_MAX_BIOS_CONNECTOR]; 96443df4709Smrg RADEONBIOSInitTable BiosTable; 96543df4709Smrg 96643df4709Smrg /* save crtc state for console restore */ 96743df4709Smrg Bool crtc_on; 96843df4709Smrg Bool crtc2_on; 96943df4709Smrg 97043df4709Smrg Bool InternalTVOut; 97143df4709Smrg 97243df4709Smrg#if defined(__powerpc__) 97343df4709Smrg RADEONMacModel MacModel; 9746322c902Smrg#endif 97543df4709Smrg RADEONExtTMDSChip ext_tmds_chip; 97643df4709Smrg 97743df4709Smrg atomBiosHandlePtr atomBIOS; 97843df4709Smrg unsigned long FbFreeStart, FbFreeSize; 97943df4709Smrg unsigned char* BIOSCopy; 98043df4709Smrg 98143df4709Smrg CreateScreenResourcesProcPtr CreateScreenResources; 98243df4709Smrg 98343df4709Smrg /* if no devices are connected at server startup */ 98443df4709Smrg Bool first_load_no_devices; 985209ff23fSmrg 986209ff23fSmrg Bool IsSecondary; 98743df4709Smrg Bool IsPrimary; 988209ff23fSmrg 989209ff23fSmrg Bool r600_shadow_fb; 990209ff23fSmrg void *fb_shadow; 991209ff23fSmrg 99243df4709Smrg /* some server chips have a hardcoded edid in the bios so that they work with KVMs */ 99343df4709Smrg Bool get_hardcoded_edid_from_bios; 99443df4709Smrg 99543df4709Smrg int virtualX; 99643df4709Smrg int virtualY; 99743df4709Smrg 99843df4709Smrg Bool r4xx_atom; 99943df4709Smrg 100043df4709Smrg /* pm */ 100143df4709Smrg RADEONPowerManagement pm; 100243df4709Smrg 100343df4709Smrg /* igp info */ 100443df4709Smrg float igp_sideport_mclk; 100543df4709Smrg float igp_system_mclk; 100643df4709Smrg float igp_ht_link_clk; 100743df4709Smrg float igp_ht_link_width; 100843df4709Smrg 100943df4709Smrg int can_resize; 1010ad43ddacSmrg void (*reemit_current2d)(ScrnInfoPtr pScrn, int op); // emit the current 2D state into the IB 1011ad43ddacSmrg struct radeon_2d_state state_2d; 101243df4709Smrg Bool kms_enabled; 1013ad43ddacSmrg struct radeon_bo *front_bo; 101443df4709Smrg#ifdef XF86DRM_MODE 1015ad43ddacSmrg struct radeon_bo_manager *bufmgr; 1016ad43ddacSmrg struct radeon_cs_manager *csm; 1017ad43ddacSmrg struct radeon_cs *cs; 1018ad43ddacSmrg 101940732134Srjs struct radeon_bo *cursor_bo[32]; 1020ad43ddacSmrg uint64_t vram_size; 1021ad43ddacSmrg uint64_t gart_size; 1022ad43ddacSmrg drmmode_rec drmmode; 10230974d292Smrg /* r6xx+ tile config */ 1024b13dfe66Smrg Bool have_tiling_info; 10250974d292Smrg uint32_t tile_config; 10260974d292Smrg int group_bytes; 10270974d292Smrg int num_channels; 10280974d292Smrg int num_banks; 10290974d292Smrg int r7xx_bank_op; 103040732134Srjs struct radeon_surface_manager *surf_man; 103140732134Srjs struct radeon_surface front_surface; 103243df4709Smrg#else 103343df4709Smrg /* fake bool */ 103443df4709Smrg Bool cs; 103543df4709Smrg#endif 1036ad43ddacSmrg 1037ad43ddacSmrg /* Xv bicubic filtering */ 1038ad43ddacSmrg struct radeon_bo *bicubic_bo; 103943df4709Smrg void *bicubic_memory; 104043df4709Smrg int bicubic_offset; 1041921a55d8Smrg /* kms pageflipping */ 1042921a55d8Smrg Bool allowPageFlip; 1043921a55d8Smrg 1044921a55d8Smrg /* Perform vsync'ed SwapBuffers? */ 1045921a55d8Smrg Bool swapBuffersWait; 104643df4709Smrg} RADEONInfoRec, *RADEONInfoPtr; 1047209ff23fSmrg 104843df4709Smrg#define RADEONWaitForFifo(pScrn, entries) \ 104943df4709Smrgdo { \ 105043df4709Smrg if (info->accel_state->fifo_slots < entries) \ 105143df4709Smrg RADEONWaitForFifoFunction(pScrn, entries); \ 105243df4709Smrg info->accel_state->fifo_slots -= entries; \ 105343df4709Smrg} while (0) 10546322c902Smrg 105543df4709Smrg/* legacy_crtc.c */ 105643df4709Smrgextern void legacy_crtc_dpms(xf86CrtcPtr crtc, int mode); 105743df4709Smrgextern void legacy_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, 105843df4709Smrg DisplayModePtr adjusted_mode, int x, int y); 105943df4709Smrgextern void RADEONRestoreCommonRegisters(ScrnInfoPtr pScrn, 106043df4709Smrg RADEONSavePtr restore); 106143df4709Smrgextern void RADEONRestoreCrtcRegisters(ScrnInfoPtr pScrn, 106243df4709Smrg RADEONSavePtr restore); 106343df4709Smrgextern void RADEONRestoreCrtc2Registers(ScrnInfoPtr pScrn, 106443df4709Smrg RADEONSavePtr restore); 106543df4709Smrgextern void RADEONRestorePLLRegisters(ScrnInfoPtr pScrn, 106643df4709Smrg RADEONSavePtr restore); 106743df4709Smrgextern void RADEONRestorePLL2Registers(ScrnInfoPtr pScrn, 106843df4709Smrg RADEONSavePtr restore); 106943df4709Smrgextern void RADEONSaveCommonRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save); 107043df4709Smrgextern void RADEONSaveCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save); 107143df4709Smrgextern void RADEONSaveCrtc2Registers(ScrnInfoPtr pScrn, RADEONSavePtr save); 107243df4709Smrgextern void RADEONSavePLLRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save); 107343df4709Smrgextern void RADEONSavePLL2Registers(ScrnInfoPtr pScrn, RADEONSavePtr save); 107443df4709Smrg 107543df4709Smrg/* legacy_output.c */ 107643df4709Smrgextern RADEONMonitorType legacy_dac_detect(xf86OutputPtr output); 107743df4709Smrgextern void legacy_output_dpms(xf86OutputPtr output, int mode); 107843df4709Smrgextern void legacy_output_mode_set(xf86OutputPtr output, DisplayModePtr mode, 107943df4709Smrg DisplayModePtr adjusted_mode); 108043df4709Smrgextern I2CDevPtr RADEONDVODeviceInit(I2CBusPtr b, I2CSlaveAddr addr); 108143df4709Smrgextern Bool RADEONDVOReadByte(I2CDevPtr dvo, int addr, uint8_t *ch); 108243df4709Smrgextern Bool RADEONDVOWriteByte(I2CDevPtr dvo, int addr, uint8_t ch); 108343df4709Smrgextern void RADEONRestoreDACRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore); 108443df4709Smrgextern void RADEONRestoreFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore); 108543df4709Smrgextern void RADEONRestoreFP2Registers(ScrnInfoPtr pScrn, RADEONSavePtr restore); 108643df4709Smrgextern void RADEONRestoreLVDSRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore); 108743df4709Smrgextern void RADEONRestoreRMXRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore); 108843df4709Smrgextern void RADEONSaveDACRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save); 108943df4709Smrgextern void RADEONSaveFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save); 109043df4709Smrgextern void radeon_save_palette_on_demand(ScrnInfoPtr pScrn, int palID); 109143df4709Smrg 109243df4709Smrgextern void RADEONGetTVDacAdjInfo(ScrnInfoPtr pScrn, radeon_tvdac_ptr tvdac); 109343df4709Smrgextern void RADEONGetTMDSInfoFromTable(ScrnInfoPtr pScrn, radeon_tmds_ptr tmds); 109443df4709Smrgextern void RADEONGetTMDSInfo(ScrnInfoPtr pScrn, radeon_tmds_ptr tmds); 109543df4709Smrgextern void RADEONGetExtTMDSInfo(ScrnInfoPtr pScrn, radeon_dvo_ptr dvo); 109643df4709Smrgextern void RADEONGetLVDSInfo(ScrnInfoPtr pScrn, radeon_lvds_ptr lvds); 1097b7e1c893Smrg 1098209ff23fSmrg/* radeon_accel.c */ 1099209ff23fSmrgextern Bool RADEONAccelInit(ScreenPtr pScreen); 110043df4709Smrgextern void RADEONEngineFlush(ScrnInfoPtr pScrn); 1101209ff23fSmrgextern void RADEONEngineInit(ScrnInfoPtr pScrn); 110243df4709Smrgextern void RADEONEngineReset(ScrnInfoPtr pScrn); 110343df4709Smrgextern void RADEONEngineRestore(ScrnInfoPtr pScrn); 110443df4709Smrgextern uint8_t *RADEONHostDataBlit(ScrnInfoPtr pScrn, unsigned int cpp, 110543df4709Smrg unsigned int w, uint32_t dstPitchOff, 110643df4709Smrg uint32_t *bufPitch, int x, int *y, 110743df4709Smrg unsigned int *h, unsigned int *hpass); 110843df4709Smrgextern void RADEONHostDataBlitCopyPass(ScrnInfoPtr pScrn, 110943df4709Smrg unsigned int bpp, 111043df4709Smrg uint8_t *dst, uint8_t *src, 111143df4709Smrg unsigned int hpass, 111243df4709Smrg unsigned int dstPitch, 111343df4709Smrg unsigned int srcPitch); 1114209ff23fSmrgextern void RADEONCopySwap(uint8_t *dst, uint8_t *src, unsigned int size, int swap); 111543df4709Smrgextern void RADEONHostDataParams(ScrnInfoPtr pScrn, uint8_t *dst, 111643df4709Smrg uint32_t pitch, int cpp, 111743df4709Smrg uint32_t *dstPitchOffset, int *x, int *y); 1118209ff23fSmrgextern void RADEONInit3DEngine(ScrnInfoPtr pScrn); 111943df4709Smrgextern void RADEONWaitForFifoFunction(ScrnInfoPtr pScrn, int entries); 112043df4709Smrg#ifdef XF86DRI 112143df4709Smrgextern drmBufPtr RADEONCPGetBuffer(ScrnInfoPtr pScrn); 112243df4709Smrgextern void RADEONCPFlushIndirect(ScrnInfoPtr pScrn, int discard); 112343df4709Smrgextern void RADEONCPReleaseIndirect(ScrnInfoPtr pScrn); 112443df4709Smrgextern int RADEONCPStop(ScrnInfoPtr pScrn, RADEONInfoPtr info); 112543df4709Smrg# ifdef USE_XAA 112643df4709Smrgextern Bool RADEONSetupMemXAA_DRI(ScreenPtr pScreen); 112743df4709Smrg# endif 112843df4709Smrguint32_t radeonGetPixmapOffset(PixmapPtr pPix); 112943df4709Smrg#endif 11302f39173dSmrgextern int radeon_cs_space_remaining(ScrnInfoPtr pScrn); 1131209ff23fSmrg 113243df4709Smrg#ifdef USE_XAA 113343df4709Smrg/* radeon_accelfuncs.c */ 113443df4709Smrgextern void RADEONAccelInitMMIO(ScreenPtr pScreen, XAAInfoRecPtr a); 113543df4709Smrgextern Bool RADEONSetupMemXAA(ScreenPtr pScreen); 113643df4709Smrg#endif 113743df4709Smrg 113843df4709Smrg/* radeon_bios.c */ 113943df4709Smrgextern Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10); 114043df4709Smrgextern Bool RADEONGetClockInfoFromBIOS(ScrnInfoPtr pScrn); 114143df4709Smrgextern Bool RADEONGetConnectorInfoFromBIOS(ScrnInfoPtr pScrn); 114243df4709Smrgextern Bool RADEONGetDAC2InfoFromBIOS(ScrnInfoPtr pScrn, radeon_tvdac_ptr tvdac); 114343df4709Smrgextern Bool RADEONGetExtTMDSInfoFromBIOS (ScrnInfoPtr pScrn, radeon_dvo_ptr dvo); 114443df4709Smrgextern xf86MonPtr RADEONGetHardCodedEDIDFromBIOS(xf86OutputPtr output); 114543df4709Smrgextern Bool RADEONGetBIOSInitTableOffsets(ScrnInfoPtr pScrn); 114643df4709Smrgextern Bool RADEONGetLVDSInfoFromBIOS(ScrnInfoPtr pScrn, radeon_lvds_ptr lvds); 114743df4709Smrgextern Bool RADEONGetTMDSInfoFromBIOS(ScrnInfoPtr pScrn, radeon_tmds_ptr tmds); 114843df4709Smrgextern Bool RADEONGetTVInfoFromBIOS(xf86OutputPtr output); 114943df4709Smrgextern Bool RADEONInitExtTMDSInfoFromBIOS (xf86OutputPtr output); 115043df4709Smrgextern Bool RADEONPostCardFromBIOSTables(ScrnInfoPtr pScrn); 115143df4709Smrgextern Bool radeon_card_posted(ScrnInfoPtr pScrn); 11526322c902Smrg 115343df4709Smrg/* radeon_commonfuncs.c */ 115443df4709Smrg#ifdef XF86DRI 115543df4709Smrgextern void RADEONWaitForIdleCP(ScrnInfoPtr pScrn); 115643df4709Smrgextern void RADEONWaitForVLineCP(ScrnInfoPtr pScrn, PixmapPtr pPix, 115743df4709Smrg xf86CrtcPtr crtc, int start, int stop); 115843df4709Smrg#endif 115943df4709Smrgextern void RADEONWaitForIdleMMIO(ScrnInfoPtr pScrn); 116043df4709Smrgextern void RADEONWaitForVLineMMIO(ScrnInfoPtr pScrn, PixmapPtr pPix, 116143df4709Smrg xf86CrtcPtr crtc, int start, int stop); 116243df4709Smrg 116343df4709Smrg/* radeon_crtc.c */ 116443df4709Smrgextern void radeon_crtc_dpms(xf86CrtcPtr crtc, int mode); 116543df4709Smrgextern void radeon_do_crtc_dpms(xf86CrtcPtr crtc, int mode); 116643df4709Smrgextern void radeon_crtc_load_lut(xf86CrtcPtr crtc); 116743df4709Smrgextern void radeon_crtc_modeset_ioctl(xf86CrtcPtr crtc, Bool post); 116843df4709Smrgextern Bool RADEONAllocateControllers(ScrnInfoPtr pScrn, int mask); 116943df4709Smrgextern void RADEONBlank(ScrnInfoPtr pScrn); 117043df4709Smrgextern void RADEONComputePLL(xf86CrtcPtr crtc, 117143df4709Smrg RADEONPLLPtr pll, unsigned long freq, 117243df4709Smrg uint32_t *chosen_dot_clock_freq, 117343df4709Smrg uint32_t *chosen_feedback_div, 117443df4709Smrg uint32_t *chosen_frac_feedback_div, 117543df4709Smrg uint32_t *chosen_reference_div, 117643df4709Smrg uint32_t *chosen_post_div, int flags); 117743df4709Smrgextern DisplayModePtr RADEONCrtcFindClosestMode(xf86CrtcPtr crtc, 117843df4709Smrg DisplayModePtr pMode); 117943df4709Smrgextern void RADEONUnblank(ScrnInfoPtr pScrn); 118043df4709Smrgextern Bool RADEONSetTiling(ScrnInfoPtr pScrn); 118143df4709Smrgextern void RADEONInitDispBandwidth(ScrnInfoPtr pScrn); 118243df4709Smrg 118343df4709Smrg/* radeon_cursor.c */ 118443df4709Smrgextern Bool RADEONCursorInit(ScreenPtr pScreen); 118543df4709Smrgextern void radeon_crtc_hide_cursor(xf86CrtcPtr crtc); 118643df4709Smrgextern void radeon_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image); 118743df4709Smrgextern void radeon_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg); 118843df4709Smrgextern void radeon_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y); 118943df4709Smrgextern void radeon_crtc_show_cursor(xf86CrtcPtr crtc); 119043df4709Smrg 119143df4709Smrg#ifdef XF86DRI 119243df4709Smrg/* radeon_dri.c */ 119343df4709Smrgextern void RADEONDRIAllocatePCIGARTTable(ScreenPtr pScreen); 119443df4709Smrgextern void RADEONDRICloseScreen(ScreenPtr pScreen); 119543df4709Smrgextern Bool RADEONDRIFinishScreenInit(ScreenPtr pScreen); 119643df4709Smrgextern int RADEONDRIGetPciAperTableSize(ScrnInfoPtr pScrn); 119743df4709Smrgextern Bool RADEONDRIGetVersion(ScrnInfoPtr pScrn); 119843df4709Smrgextern void RADEONDRIResume(ScreenPtr pScreen); 119943df4709Smrgextern Bool RADEONDRIScreenInit(ScreenPtr pScreen); 120043df4709Smrgextern int RADEONDRISetParam(ScrnInfoPtr pScrn, 120143df4709Smrg unsigned int param, int64_t value); 120243df4709Smrgextern Bool RADEONDRISetVBlankInterrupt(ScrnInfoPtr pScrn, Bool on); 120343df4709Smrgextern void RADEONDRIStop(ScreenPtr pScreen); 120443df4709Smrg#endif 1205209ff23fSmrg 120643df4709Smrg/* radeon_driver.c */ 120743df4709Smrgextern void RADEONDoAdjustFrame(ScrnInfoPtr pScrn, int x, int y, Bool clone); 120843df4709Smrgextern void RADEONChangeSurfaces(ScrnInfoPtr pScrn); 120943df4709Smrgextern RADEONEntPtr RADEONEntPriv(ScrnInfoPtr pScrn); 121043df4709Smrgextern int RADEONMinBits(int val); 121143df4709Smrgextern unsigned RADEONINMC(ScrnInfoPtr pScrn, int addr); 121243df4709Smrgextern unsigned RADEONINPLL(ScrnInfoPtr pScrn, int addr); 121343df4709Smrgextern unsigned RADEONINPCIE(ScrnInfoPtr pScrn, int addr); 121443df4709Smrgextern unsigned R600INPCIE_PORT(ScrnInfoPtr pScrn, int addr); 121543df4709Smrgextern void RADEONOUTMC(ScrnInfoPtr pScrn, int addr, uint32_t data); 121643df4709Smrgextern void RADEONOUTPLL(ScrnInfoPtr pScrn, int addr, uint32_t data); 121743df4709Smrgextern void RADEONOUTPCIE(ScrnInfoPtr pScrn, int addr, uint32_t data); 121843df4709Smrgextern void R600OUTPCIE_PORT(ScrnInfoPtr pScrn, int addr, uint32_t data); 121943df4709Smrgextern void RADEONPllErrataAfterData(RADEONInfoPtr info); 122043df4709Smrgextern void RADEONPllErrataAfterIndex(RADEONInfoPtr info); 122143df4709Smrgextern void RADEONWaitForVerticalSync(ScrnInfoPtr pScrn); 122243df4709Smrgextern void RADEONWaitForVerticalSync2(ScrnInfoPtr pScrn); 122343df4709Smrgextern void RADEONInitMemMapRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, 122443df4709Smrg RADEONInfoPtr info); 122543df4709Smrgextern void RADEONRestoreMemMapRegisters(ScrnInfoPtr pScrn, 122643df4709Smrg RADEONSavePtr restore); 122743df4709Smrgextern Bool 122843df4709SmrgRADEONZaphodStringMatches(ScrnInfoPtr pScrn, const char *s, char *output_name); 122943df4709Smrg 123043df4709SmrgBool RADEONGetRec(ScrnInfoPtr pScrn); 123143df4709Smrgvoid RADEONFreeRec(ScrnInfoPtr pScrn); 123243df4709SmrgBool RADEONPreInitVisual(ScrnInfoPtr pScrn); 123343df4709SmrgBool RADEONPreInitWeight(ScrnInfoPtr pScrn); 123443df4709Smrg 123543df4709Smrgextern Bool RADEON_DP_I2CInit(ScrnInfoPtr pScrn, I2CBusPtr *bus_ptr, 123643df4709Smrg char *name, xf86OutputPtr output); 123743df4709Smrgextern void RADEON_DP_GetDPCD(xf86OutputPtr output); 123843df4709Smrgextern int RADEON_DP_GetSinkType(xf86OutputPtr output); 123943df4709Smrg 124043df4709Smrg/* radeon_pm.c */ 124143df4709Smrgextern void RADEONPMInit(ScrnInfoPtr pScrn); 124243df4709Smrgextern void RADEONPMBlockHandler(ScrnInfoPtr pScrn); 124343df4709Smrgextern void RADEONPMEnterVT(ScrnInfoPtr pScrn); 124443df4709Smrgextern void RADEONPMLeaveVT(ScrnInfoPtr pScrn); 124543df4709Smrgextern void RADEONPMFini(ScrnInfoPtr pScrn); 124643df4709Smrg 124743df4709Smrg#ifdef USE_EXA 1248209ff23fSmrg/* radeon_exa.c */ 124940732134Srjsextern unsigned eg_tile_split(unsigned tile_split); 125043df4709Smrgextern Bool RADEONSetupMemEXA(ScreenPtr pScreen); 1251b13dfe66Smrgextern Bool radeon_transform_is_affine_or_scaled(PictTransformPtr t); 1252209ff23fSmrg 1253209ff23fSmrg/* radeon_exa_funcs.c */ 125443df4709Smrgextern void RADEONCopyCP(PixmapPtr pDst, int srcX, int srcY, int dstX, 125543df4709Smrg int dstY, int w, int h); 125643df4709Smrgextern void RADEONCopyMMIO(PixmapPtr pDst, int srcX, int srcY, int dstX, 125743df4709Smrg int dstY, int w, int h); 125843df4709Smrgextern Bool RADEONDrawInitCP(ScreenPtr pScreen); 125943df4709Smrgextern Bool RADEONDrawInitMMIO(ScreenPtr pScreen); 126043df4709Smrgextern void RADEONDoPrepareCopyCP(ScrnInfoPtr pScrn, 126143df4709Smrg uint32_t src_pitch_offset, 126243df4709Smrg uint32_t dst_pitch_offset, 126343df4709Smrg uint32_t datatype, int rop, 126443df4709Smrg Pixel planemask); 126543df4709Smrgextern void RADEONDoPrepareCopyMMIO(ScrnInfoPtr pScrn, 126643df4709Smrg uint32_t src_pitch_offset, 126743df4709Smrg uint32_t dst_pitch_offset, 126843df4709Smrg uint32_t datatype, int rop, 126943df4709Smrg Pixel planemask); 1270b7e1c893Smrgextern Bool R600DrawInit(ScreenPtr pScreen); 1271b7e1c893Smrgextern Bool R600LoadShaders(ScrnInfoPtr pScrn); 127243df4709Smrg#ifdef XF86DRM_MODE 1273921a55d8Smrgextern Bool EVERGREENDrawInit(ScreenPtr pScreen); 127443df4709Smrg#endif 127543df4709Smrg#endif 1276209ff23fSmrg 127743df4709Smrg#if defined(XF86DRI) && defined(USE_EXA) 1278209ff23fSmrg/* radeon_exa.c */ 1279209ff23fSmrgextern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); 1280209ff23fSmrgextern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, 1281209ff23fSmrg uint32_t *pitch_offset); 128243df4709Smrgextern unsigned long long RADEONTexOffsetStart(PixmapPtr pPix); 128343df4709Smrg#endif 1284209ff23fSmrg 128543df4709Smrg/* radeon_modes.c */ 128643df4709Smrgextern void RADEONSetPitch(ScrnInfoPtr pScrn); 128743df4709Smrgextern DisplayModePtr RADEONProbeOutputModes(xf86OutputPtr output); 128843df4709Smrg 128943df4709Smrg/* radeon_output.c */ 129043df4709Smrgextern RADEONI2CBusRec atom_setup_i2c_bus(int ddc_line); 129143df4709Smrgextern RADEONI2CBusRec legacy_setup_i2c_bus(int ddc_line); 129243df4709Smrgextern void RADEONGetPanelInfo(ScrnInfoPtr pScrn); 129343df4709Smrgextern void RADEONInitConnector(xf86OutputPtr output); 129443df4709Smrgextern void RADEONPrintPortMap(ScrnInfoPtr pScrn); 129543df4709Smrgextern void RADEONSetOutputType(ScrnInfoPtr pScrn, 129643df4709Smrg RADEONOutputPrivatePtr radeon_output); 129743df4709Smrgextern Bool RADEONSetupConnectors(ScrnInfoPtr pScrn); 129843df4709Smrgextern Bool RADEONI2CDoLock(xf86OutputPtr output, I2CBusPtr b, Bool lock_state); 129943df4709Smrg 130043df4709Smrgextern Bool radeon_dp_mode_fixup(xf86OutputPtr output, DisplayModePtr mode, DisplayModePtr adjusted_mode); 130143df4709Smrg 130243df4709Smrg/* radeon_tv.c */ 130343df4709Smrgextern void RADEONSaveTVRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save); 130443df4709Smrgextern void RADEONAdjustCrtcRegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save, 130543df4709Smrg DisplayModePtr mode, xf86OutputPtr output); 130643df4709Smrgextern void RADEONAdjustPLLRegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save, 130743df4709Smrg DisplayModePtr mode, xf86OutputPtr output); 130843df4709Smrgextern void RADEONAdjustCrtc2RegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save, 130943df4709Smrg DisplayModePtr mode, xf86OutputPtr output); 131043df4709Smrgextern void RADEONAdjustPLL2RegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save, 131143df4709Smrg DisplayModePtr mode, xf86OutputPtr output); 131243df4709Smrgextern void RADEONInitTVRegisters(xf86OutputPtr output, RADEONSavePtr save, 131343df4709Smrg DisplayModePtr mode, BOOL IsPrimary); 131443df4709Smrgextern void RADEONRestoreTVRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore); 131543df4709Smrgextern void RADEONUpdateHVPosition(xf86OutputPtr output, DisplayModePtr mode); 1316209ff23fSmrg 1317209ff23fSmrg/* radeon_video.c */ 1318209ff23fSmrgextern void RADEONInitVideo(ScreenPtr pScreen); 1319209ff23fSmrgextern void RADEONResetVideo(ScrnInfoPtr pScrn); 1320ad43ddacSmrgextern Bool radeon_load_bicubic_texture(ScrnInfoPtr pScrn); 1321ad43ddacSmrgextern xf86CrtcPtr radeon_pick_best_crtc(ScrnInfoPtr pScrn, 1322ad43ddacSmrg int x1, int x2, int y1, int y2); 1323209ff23fSmrg 132443df4709Smrg/* radeon_legacy_memory.c */ 132543df4709Smrgextern uint32_t 132643df4709Smrgradeon_legacy_allocate_memory(ScrnInfoPtr pScrn, 132743df4709Smrg void **mem_struct, 132843df4709Smrg int size, 132943df4709Smrg int align, 133043df4709Smrg int domain); 133143df4709Smrgextern void 133243df4709Smrgradeon_legacy_free_memory(ScrnInfoPtr pScrn, 133343df4709Smrg void *mem_struct); 133443df4709Smrg 133543df4709Smrg#ifdef XF86DRM_MODE 1336ad43ddacSmrgextern void radeon_cs_flush_indirect(ScrnInfoPtr pScrn); 1337ad43ddacSmrgextern void radeon_ddx_cs_start(ScrnInfoPtr pScrn, 1338ad43ddacSmrg int num, const char *file, 1339ad43ddacSmrg const char *func, int line); 134043df4709Smrgvoid radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, int new_fb_size); 134143df4709Smrgstruct radeon_surface *radeon_get_pixmap_surface(PixmapPtr pPix); 134243df4709Smrg#endif 134343df4709Smrgstruct radeon_bo *radeon_get_pixmap_bo(PixmapPtr pPix); 134443df4709Smrgvoid radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo); 134543df4709Smrguint32_t radeon_get_pixmap_tiling(PixmapPtr pPix); 1346209ff23fSmrg 134743df4709Smrg#ifdef XF86DRI 134843df4709Smrg# ifdef USE_XAA 134943df4709Smrg/* radeon_accelfuncs.c */ 135043df4709Smrgextern void RADEONAccelInitCP(ScreenPtr pScreen, XAAInfoRecPtr a); 135143df4709Smrg# endif 1352209ff23fSmrg 135343df4709Smrg#define RADEONCP_START(pScrn, info) \ 135443df4709Smrgdo { \ 135543df4709Smrg int _ret = drmCommandNone(info->dri->drmFD, DRM_RADEON_CP_START); \ 135643df4709Smrg if (_ret) { \ 135743df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 135843df4709Smrg "%s: CP start %d\n", __FUNCTION__, _ret); \ 135943df4709Smrg } \ 136043df4709Smrg info->cp->CPStarted = TRUE; \ 136143df4709Smrg} while (0) 1362209ff23fSmrg 136343df4709Smrg#define RADEONCP_RELEASE(pScrn, info) \ 136443df4709Smrgdo { \ 136543df4709Smrg if (info->cs) { \ 136643df4709Smrg radeon_cs_flush_indirect(pScrn); \ 136743df4709Smrg } else if (info->cp->CPInUse) { \ 136843df4709Smrg RADEON_PURGE_CACHE(); \ 136943df4709Smrg RADEON_WAIT_UNTIL_IDLE(); \ 137043df4709Smrg RADEONCPReleaseIndirect(pScrn); \ 137143df4709Smrg info->cp->CPInUse = FALSE; \ 137243df4709Smrg } \ 137343df4709Smrg} while (0) 1374209ff23fSmrg 137543df4709Smrg#define RADEONCP_STOP(pScrn, info) \ 137643df4709Smrgdo { \ 137743df4709Smrg int _ret; \ 137843df4709Smrg if (info->cp->CPStarted) { \ 137943df4709Smrg _ret = RADEONCPStop(pScrn, info); \ 138043df4709Smrg if (_ret) { \ 138143df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 138243df4709Smrg "%s: CP stop %d\n", __FUNCTION__, _ret); \ 138343df4709Smrg } \ 138443df4709Smrg info->cp->CPStarted = FALSE; \ 138543df4709Smrg } \ 138643df4709Smrg if (info->ChipFamily < CHIP_FAMILY_R600) \ 138743df4709Smrg RADEONEngineRestore(pScrn); \ 138843df4709Smrg info->cp->CPRuns = FALSE; \ 138943df4709Smrg} while (0) 1390209ff23fSmrg 139143df4709Smrg#define RADEONCP_RESET(pScrn, info) \ 139243df4709Smrgdo { \ 139343df4709Smrg int _ret = drmCommandNone(info->dri->drmFD, DRM_RADEON_CP_RESET); \ 139443df4709Smrg if (_ret) { \ 139543df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 139643df4709Smrg "%s: CP reset %d\n", __FUNCTION__, _ret); \ 139743df4709Smrg } \ 139843df4709Smrg} while (0) 139943df4709Smrg 140043df4709Smrg#define RADEONCP_REFRESH(pScrn, info) \ 140143df4709Smrgdo { \ 140243df4709Smrg if (!info->cp->CPInUse && !info->cs) { \ 140343df4709Smrg if (info->cp->needCacheFlush) { \ 140443df4709Smrg RADEON_PURGE_CACHE(); \ 140543df4709Smrg RADEON_PURGE_ZCACHE(); \ 140643df4709Smrg info->cp->needCacheFlush = FALSE; \ 140743df4709Smrg } \ 140843df4709Smrg RADEON_WAIT_UNTIL_IDLE(); \ 140943df4709Smrg info->cp->CPInUse = TRUE; \ 141043df4709Smrg } \ 141143df4709Smrg} while (0) 1412209ff23fSmrg 1413209ff23fSmrg 1414209ff23fSmrg#define CP_PACKET0(reg, n) \ 1415209ff23fSmrg (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) 1416209ff23fSmrg#define CP_PACKET1(reg0, reg1) \ 1417209ff23fSmrg (RADEON_CP_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2)) 1418209ff23fSmrg#define CP_PACKET2() \ 1419209ff23fSmrg (RADEON_CP_PACKET2) 1420209ff23fSmrg#define CP_PACKET3(pkt, n) \ 1421209ff23fSmrg (RADEON_CP_PACKET3 | (pkt) | ((n) << 16)) 1422209ff23fSmrg 1423209ff23fSmrg 1424209ff23fSmrg#define RADEON_VERBOSE 0 1425209ff23fSmrg 142643df4709Smrg#define RING_LOCALS uint32_t *__head = NULL; int __expected; int __count = 0 142743df4709Smrg 1428209ff23fSmrg#define BEGIN_RING(n) do { \ 1429209ff23fSmrg if (RADEON_VERBOSE) { \ 1430209ff23fSmrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, \ 1431209ff23fSmrg "BEGIN_RING(%d) in %s\n", (unsigned int)n, __FUNCTION__);\ 1432209ff23fSmrg } \ 143343df4709Smrg if (info->cs) { radeon_ddx_cs_start(pScrn, n, __FILE__, __func__, __LINE__); } else { \ 143443df4709Smrg if (++info->cp->dma_begin_count != 1) { \ 143543df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 143643df4709Smrg "BEGIN_RING without end at %s:%d\n", \ 143743df4709Smrg info->cp->dma_debug_func, info->cp->dma_debug_lineno); \ 143843df4709Smrg info->cp->dma_begin_count = 1; \ 143943df4709Smrg } \ 144043df4709Smrg info->cp->dma_debug_func = __FILE__; \ 144143df4709Smrg info->cp->dma_debug_lineno = __LINE__; \ 144243df4709Smrg if (!info->cp->indirectBuffer) { \ 144343df4709Smrg info->cp->indirectBuffer = RADEONCPGetBuffer(pScrn); \ 144443df4709Smrg info->cp->indirectStart = 0; \ 144543df4709Smrg } else if (info->cp->indirectBuffer->used + (n) * (int)sizeof(uint32_t) > \ 144643df4709Smrg info->cp->indirectBuffer->total) { \ 144743df4709Smrg RADEONCPFlushIndirect(pScrn, 1); \ 144843df4709Smrg } \ 144943df4709Smrg __expected = n; \ 145043df4709Smrg __head = (pointer)((char *)info->cp->indirectBuffer->address + \ 145143df4709Smrg info->cp->indirectBuffer->used); \ 145243df4709Smrg __count = 0; \ 145343df4709Smrg } \ 1454209ff23fSmrg} while (0) 1455209ff23fSmrg 1456209ff23fSmrg#define ADVANCE_RING() do { \ 145743df4709Smrg if (info->cs) radeon_cs_end(info->cs, __FILE__, __func__, __LINE__); else { \ 145843df4709Smrg if (info->cp->dma_begin_count-- != 1) { \ 145943df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 146043df4709Smrg "ADVANCE_RING without begin at %s:%d\n", \ 146143df4709Smrg __FILE__, __LINE__); \ 146243df4709Smrg info->cp->dma_begin_count = 0; \ 146343df4709Smrg } \ 146443df4709Smrg if (__count != __expected) { \ 146543df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 146643df4709Smrg "ADVANCE_RING count != expected (%d vs %d) at %s:%d\n", \ 146743df4709Smrg __count, __expected, __FILE__, __LINE__); \ 146843df4709Smrg } \ 146943df4709Smrg if (RADEON_VERBOSE) { \ 147043df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, \ 147143df4709Smrg "ADVANCE_RING() start: %d used: %d count: %d\n", \ 147243df4709Smrg info->cp->indirectStart, \ 147343df4709Smrg info->cp->indirectBuffer->used, \ 147443df4709Smrg __count * (int)sizeof(uint32_t)); \ 147543df4709Smrg } \ 147643df4709Smrg info->cp->indirectBuffer->used += __count * (int)sizeof(uint32_t); \ 147743df4709Smrg } \ 1478ad43ddacSmrg } while (0) 1479209ff23fSmrg 1480209ff23fSmrg#define OUT_RING(x) do { \ 1481209ff23fSmrg if (RADEON_VERBOSE) { \ 1482209ff23fSmrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, \ 1483209ff23fSmrg " OUT_RING(0x%08x)\n", (unsigned int)(x)); \ 1484209ff23fSmrg } \ 148543df4709Smrg if (info->cs) radeon_cs_write_dword(info->cs, (x)); else \ 148643df4709Smrg __head[__count++] = (x); \ 1487209ff23fSmrg} while (0) 1488209ff23fSmrg 1489209ff23fSmrg#define OUT_RING_REG(reg, val) \ 1490209ff23fSmrgdo { \ 1491209ff23fSmrg OUT_RING(CP_PACKET0(reg, 0)); \ 1492209ff23fSmrg OUT_RING(val); \ 1493209ff23fSmrg} while (0) 1494209ff23fSmrg 1495ad43ddacSmrg#define OUT_RING_RELOC(x, read_domains, write_domain) \ 1496ad43ddacSmrg do { \ 1497ad43ddacSmrg int _ret; \ 1498ad43ddacSmrg _ret = radeon_cs_write_reloc(info->cs, x, read_domains, write_domain, 0); \ 1499ad43ddacSmrg if (_ret) ErrorF("reloc emit failure %d\n", _ret); \ 1500ad43ddacSmrg } while(0) 1501ad43ddacSmrg 1502ad43ddacSmrg 1503209ff23fSmrg#define FLUSH_RING() \ 1504209ff23fSmrgdo { \ 1505209ff23fSmrg if (RADEON_VERBOSE) \ 1506209ff23fSmrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, \ 1507209ff23fSmrg "FLUSH_RING in %s\n", __FUNCTION__); \ 150843df4709Smrg if (info->cs) \ 150943df4709Smrg radeon_cs_flush_indirect(pScrn); \ 151043df4709Smrg else if (info->cp->indirectBuffer) \ 151143df4709Smrg RADEONCPFlushIndirect(pScrn, 0); \ 151243df4709Smrg} while (0) 151343df4709Smrg 151443df4709Smrg 151543df4709Smrg#define RADEON_WAIT_UNTIL_2D_IDLE() \ 151643df4709Smrgdo { \ 151743df4709Smrg if (info->ChipFamily < CHIP_FAMILY_R600) { \ 151843df4709Smrg BEGIN_RING(2); \ 151943df4709Smrg OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 152043df4709Smrg OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \ 152143df4709Smrg RADEON_WAIT_HOST_IDLECLEAN)); \ 152243df4709Smrg ADVANCE_RING(); \ 152343df4709Smrg } \ 152443df4709Smrg} while (0) 152543df4709Smrg 152643df4709Smrg#define RADEON_WAIT_UNTIL_3D_IDLE() \ 152743df4709Smrgdo { \ 152843df4709Smrg if (info->ChipFamily < CHIP_FAMILY_R600) { \ 152943df4709Smrg BEGIN_RING(2); \ 153043df4709Smrg OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 153143df4709Smrg OUT_RING((RADEON_WAIT_3D_IDLECLEAN | \ 153243df4709Smrg RADEON_WAIT_HOST_IDLECLEAN)); \ 153343df4709Smrg ADVANCE_RING(); \ 153443df4709Smrg } \ 153543df4709Smrg} while (0) 153643df4709Smrg 153743df4709Smrg#define RADEON_WAIT_UNTIL_IDLE() \ 153843df4709Smrgdo { \ 153943df4709Smrg if (RADEON_VERBOSE) { \ 154043df4709Smrg xf86DrvMsg(pScrn->scrnIndex, X_INFO, \ 154143df4709Smrg "WAIT_UNTIL_IDLE() in %s\n", __FUNCTION__); \ 154243df4709Smrg } \ 154343df4709Smrg if (info->ChipFamily < CHIP_FAMILY_R600) { \ 154443df4709Smrg BEGIN_RING(2); \ 154543df4709Smrg OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 154643df4709Smrg OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \ 154743df4709Smrg RADEON_WAIT_3D_IDLECLEAN | \ 154843df4709Smrg RADEON_WAIT_HOST_IDLECLEAN)); \ 154943df4709Smrg ADVANCE_RING(); \ 155043df4709Smrg } \ 1551209ff23fSmrg} while (0) 1552209ff23fSmrg 155343df4709Smrg#define RADEON_PURGE_CACHE() \ 155443df4709Smrgdo { \ 155543df4709Smrg if (info->ChipFamily < CHIP_FAMILY_R600) { \ 155643df4709Smrg BEGIN_RING(2); \ 155743df4709Smrg if (info->ChipFamily <= CHIP_FAMILY_RV280) { \ 155843df4709Smrg OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \ 155943df4709Smrg OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \ 156043df4709Smrg } else { \ 156143df4709Smrg OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \ 156243df4709Smrg OUT_RING(R300_RB3D_DC_FLUSH_ALL); \ 156343df4709Smrg } \ 156443df4709Smrg ADVANCE_RING(); \ 156543df4709Smrg } \ 156643df4709Smrg} while (0) 156743df4709Smrg 156843df4709Smrg#define RADEON_PURGE_ZCACHE() \ 156943df4709Smrgdo { \ 157043df4709Smrg if (info->ChipFamily < CHIP_FAMILY_R600) { \ 157143df4709Smrg BEGIN_RING(2); \ 157243df4709Smrg if (info->ChipFamily <= CHIP_FAMILY_RV280) { \ 157343df4709Smrg OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \ 157443df4709Smrg OUT_RING(RADEON_RB3D_ZC_FLUSH_ALL); \ 157543df4709Smrg } else { \ 157643df4709Smrg OUT_RING(CP_PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0)); \ 157743df4709Smrg OUT_RING(R300_ZC_FLUSH_ALL); \ 157843df4709Smrg } \ 157943df4709Smrg ADVANCE_RING(); \ 158043df4709Smrg } \ 158143df4709Smrg} while (0) 158243df4709Smrg 158343df4709Smrg#endif /* XF86DRI */ 158443df4709Smrg 158543df4709Smrg#if defined(XF86DRI) && defined(USE_EXA) 158643df4709Smrg 158743df4709Smrg#ifdef XF86DRM_MODE 1588ad43ddacSmrg#define CS_FULL(cs) ((cs)->cdw > 15 * 1024) 158943df4709Smrg#else 159043df4709Smrg#define CS_FULL(cs) FALSE 159143df4709Smrg#endif 1592ad43ddacSmrg 1593b7e1c893Smrg#define RADEON_SWITCH_TO_2D() \ 1594b7e1c893Smrgdo { \ 1595b7e1c893Smrg uint32_t flush = 0; \ 1596b7e1c893Smrg switch (info->accel_state->engineMode) { \ 1597b7e1c893Smrg case EXA_ENGINEMODE_UNKNOWN: \ 1598b7e1c893Smrg flush = 1; \ 1599ad43ddacSmrg break; \ 1600ad43ddacSmrg case EXA_ENGINEMODE_3D: \ 160143df4709Smrg flush = !info->cs || CS_FULL(info->cs); \ 1602ad43ddacSmrg break; \ 1603b7e1c893Smrg case EXA_ENGINEMODE_2D: \ 160443df4709Smrg flush = info->cs && CS_FULL(info->cs); \ 1605b7e1c893Smrg break; \ 1606b7e1c893Smrg } \ 1607ad43ddacSmrg if (flush) { \ 160843df4709Smrg if (info->cs) \ 160943df4709Smrg radeon_cs_flush_indirect(pScrn); \ 161043df4709Smrg else if (info->directRenderingEnabled) \ 161143df4709Smrg RADEONCPFlushIndirect(pScrn, 1); \ 1612ad43ddacSmrg } \ 1613b7e1c893Smrg info->accel_state->engineMode = EXA_ENGINEMODE_2D; \ 1614b7e1c893Smrg} while (0); 1615b7e1c893Smrg 1616b7e1c893Smrg#define RADEON_SWITCH_TO_3D() \ 1617b7e1c893Smrgdo { \ 1618b7e1c893Smrg uint32_t flush = 0; \ 1619b7e1c893Smrg switch (info->accel_state->engineMode) { \ 1620b7e1c893Smrg case EXA_ENGINEMODE_UNKNOWN: \ 1621b7e1c893Smrg flush = 1; \ 1622ad43ddacSmrg break; \ 1623ad43ddacSmrg case EXA_ENGINEMODE_2D: \ 162443df4709Smrg flush = !info->cs || CS_FULL(info->cs); \ 1625ad43ddacSmrg break; \ 1626b7e1c893Smrg case EXA_ENGINEMODE_3D: \ 162743df4709Smrg flush = info->cs && CS_FULL(info->cs); \ 1628b7e1c893Smrg break; \ 1629b7e1c893Smrg } \ 1630b7e1c893Smrg if (flush) { \ 163143df4709Smrg if (info->cs) \ 163243df4709Smrg radeon_cs_flush_indirect(pScrn); \ 163343df4709Smrg else if (info->directRenderingEnabled) \ 163443df4709Smrg RADEONCPFlushIndirect(pScrn, 1); \ 1635b7e1c893Smrg } \ 1636ad43ddacSmrg if (!info->accel_state->XInited3D) \ 1637ad43ddacSmrg RADEONInit3DEngine(pScrn); \ 1638b7e1c893Smrg info->accel_state->engineMode = EXA_ENGINEMODE_3D; \ 1639b7e1c893Smrg} while (0); 164043df4709Smrg#else 164143df4709Smrg#define RADEON_SWITCH_TO_2D() 164243df4709Smrg#define RADEON_SWITCH_TO_3D() 164343df4709Smrg#endif 1644b7e1c893Smrg 164543df4709Smrgstatic __inline__ void RADEON_MARK_SYNC(RADEONInfoPtr info, ScrnInfoPtr pScrn) 164643df4709Smrg{ 164743df4709Smrg#ifdef USE_EXA 164843df4709Smrg if (info->useEXA) 164943df4709Smrg exaMarkSync(pScrn->pScreen); 165043df4709Smrg#endif 165143df4709Smrg#ifdef USE_XAA 165243df4709Smrg if (!info->useEXA) 165343df4709Smrg SET_SYNC_FLAG(info->accel_state->accel); 165443df4709Smrg#endif 165543df4709Smrg} 1656209ff23fSmrg 1657209ff23fSmrgstatic __inline__ void RADEON_SYNC(RADEONInfoPtr info, ScrnInfoPtr pScrn) 1658209ff23fSmrg{ 165943df4709Smrg#ifdef USE_EXA 166043df4709Smrg if (info->useEXA && pScrn->pScreen) 1661209ff23fSmrg exaWaitSync(pScrn->pScreen); 166243df4709Smrg#endif 166343df4709Smrg#ifdef USE_XAA 166443df4709Smrg if (!info->useEXA && info->accel_state->accel) 166543df4709Smrg info->accel_state->accel->Sync(pScrn); 166643df4709Smrg#endif 1667209ff23fSmrg} 1668209ff23fSmrg 166943df4709Smrgstatic __inline__ void radeon_init_timeout(struct timeval *endtime, 167043df4709Smrg unsigned int timeout) 167143df4709Smrg{ 167243df4709Smrg gettimeofday(endtime, NULL); 167343df4709Smrg endtime->tv_usec += timeout; 167443df4709Smrg endtime->tv_sec += endtime->tv_usec / 1000000; 167543df4709Smrg endtime->tv_usec %= 1000000; 167643df4709Smrg} 16776322c902Smrg 167843df4709Smrgstatic __inline__ int radeon_timedout(const struct timeval *endtime) 1679209ff23fSmrg{ 168043df4709Smrg struct timeval now; 168143df4709Smrg gettimeofday(&now, NULL); 168243df4709Smrg return now.tv_sec == endtime->tv_sec ? 168343df4709Smrg now.tv_usec > endtime->tv_usec : now.tv_sec > endtime->tv_sec; 1684209ff23fSmrg} 1685209ff23fSmrg 168643df4709Smrgenum { 168743df4709Smrg RADEON_CREATE_PIXMAP_TILING_MACRO = 0x10000000, 168843df4709Smrg RADEON_CREATE_PIXMAP_TILING_MICRO = 0x20000000, 168943df4709Smrg RADEON_CREATE_PIXMAP_DEPTH = 0x40000000, /* for r200 */ 169043df4709Smrg RADEON_CREATE_PIXMAP_SZBUFFER = 0x80000000, /* for eg */ 169143df4709Smrg}; 1692ad43ddacSmrg 1693209ff23fSmrg#endif /* _RADEON_H_ */ 1694