r128.h revision c582b7e3
1c582b7e3Smrg/* 2c582b7e3Smrg * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, 3c582b7e3Smrg * Precision Insight, Inc., Cedar Park, Texas, and 4c582b7e3Smrg * VA Linux Systems Inc., Fremont, California. 5c582b7e3Smrg * 6c582b7e3Smrg * All Rights Reserved. 7c582b7e3Smrg * 8c582b7e3Smrg * Permission is hereby granted, free of charge, to any person obtaining 9c582b7e3Smrg * a copy of this software and associated documentation files (the 10c582b7e3Smrg * "Software"), to deal in the Software without restriction, including 11c582b7e3Smrg * without limitation on the rights to use, copy, modify, merge, 12c582b7e3Smrg * publish, distribute, sublicense, and/or sell copies of the Software, 13c582b7e3Smrg * and to permit persons to whom the Software is furnished to do so, 14c582b7e3Smrg * subject to the following conditions: 15c582b7e3Smrg * 16c582b7e3Smrg * The above copyright notice and this permission notice (including the 17c582b7e3Smrg * next paragraph) shall be included in all copies or substantial 18c582b7e3Smrg * portions of the Software. 19c582b7e3Smrg * 20c582b7e3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21c582b7e3Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22c582b7e3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23c582b7e3Smrg * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX 24c582b7e3Smrg * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25c582b7e3Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26c582b7e3Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27c582b7e3Smrg * OTHER DEALINGS IN THE SOFTWARE. 28c582b7e3Smrg */ 29c582b7e3Smrg 30c582b7e3Smrg/* 31c582b7e3Smrg * Authors: 32c582b7e3Smrg * Rickard E. Faith <faith@valinux.com> 33c582b7e3Smrg * Kevin E. Martin <martin@valinux.com> 34c582b7e3Smrg * 35c582b7e3Smrg */ 36c582b7e3Smrg 37c582b7e3Smrg#ifndef _R128_H_ 38c582b7e3Smrg#define _R128_H_ 39c582b7e3Smrg 40c582b7e3Smrg#include <unistd.h> 41c582b7e3Smrg#include "xf86str.h" 42c582b7e3Smrg 43c582b7e3Smrg /* PCI support */ 44c582b7e3Smrg#include "xf86Pci.h" 45c582b7e3Smrg 46c582b7e3Smrg /* XAA and Cursor Support */ 47c582b7e3Smrg#include "xaa.h" 48c582b7e3Smrg#include "xf86Cursor.h" 49c582b7e3Smrg 50c582b7e3Smrg /* DDC support */ 51c582b7e3Smrg#include "xf86DDC.h" 52c582b7e3Smrg 53c582b7e3Smrg /* Xv support */ 54c582b7e3Smrg#include "xf86xv.h" 55c582b7e3Smrg 56c582b7e3Smrg#include "r128_probe.h" 57c582b7e3Smrg 58c582b7e3Smrg /* DRI support */ 59c582b7e3Smrg#ifdef XF86DRI 60c582b7e3Smrg#define _XF86DRI_SERVER_ 61c582b7e3Smrg#include "r128_dripriv.h" 62c582b7e3Smrg#include "dri.h" 63c582b7e3Smrg#include "GL/glxint.h" 64c582b7e3Smrg#endif 65c582b7e3Smrg 66c582b7e3Smrg#include "atipcirename.h" 67c582b7e3Smrg 68c582b7e3Smrg#define R128_DEBUG 0 /* Turn off debugging output */ 69c582b7e3Smrg#define R128_IDLE_RETRY 32 /* Fall out of idle loops after this count */ 70c582b7e3Smrg#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ 71c582b7e3Smrg#define R128_MMIOSIZE 0x4000 72c582b7e3Smrg 73c582b7e3Smrg#define R128_VBIOS_SIZE 0x00010000 74c582b7e3Smrg 75c582b7e3Smrg#if R128_DEBUG 76c582b7e3Smrg#define R128TRACE(x) \ 77c582b7e3Smrg do { \ 78c582b7e3Smrg ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ 79c582b7e3Smrg ErrorF x; \ 80c582b7e3Smrg } while (0); 81c582b7e3Smrg#else 82c582b7e3Smrg#define R128TRACE(x) 83c582b7e3Smrg#endif 84c582b7e3Smrg 85c582b7e3Smrg 86c582b7e3Smrg/* Other macros */ 87c582b7e3Smrg#define R128_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 88c582b7e3Smrg#define R128_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) 89c582b7e3Smrg#define R128PTR(pScrn) ((R128InfoPtr)(pScrn)->driverPrivate) 90c582b7e3Smrg 91c582b7e3Smrgtypedef struct { /* All values in XCLKS */ 92c582b7e3Smrg int ML; /* Memory Read Latency */ 93c582b7e3Smrg int MB; /* Memory Burst Length */ 94c582b7e3Smrg int Trcd; /* RAS to CAS delay */ 95c582b7e3Smrg int Trp; /* RAS percentage */ 96c582b7e3Smrg int Twr; /* Write Recovery */ 97c582b7e3Smrg int CL; /* CAS Latency */ 98c582b7e3Smrg int Tr2w; /* Read to Write Delay */ 99c582b7e3Smrg int Rloop; /* Loop Latency */ 100c582b7e3Smrg int Rloop_fudge; /* Add to ML to get Rloop */ 101c582b7e3Smrg char *name; 102c582b7e3Smrg} R128RAMRec, *R128RAMPtr; 103c582b7e3Smrg 104c582b7e3Smrgtypedef struct { 105c582b7e3Smrg /* Common registers */ 106c582b7e3Smrg CARD32 ovr_clr; 107c582b7e3Smrg CARD32 ovr_wid_left_right; 108c582b7e3Smrg CARD32 ovr_wid_top_bottom; 109c582b7e3Smrg CARD32 ov0_scale_cntl; 110c582b7e3Smrg CARD32 mpp_tb_config; 111c582b7e3Smrg CARD32 mpp_gp_config; 112c582b7e3Smrg CARD32 subpic_cntl; 113c582b7e3Smrg CARD32 viph_control; 114c582b7e3Smrg CARD32 i2c_cntl_1; 115c582b7e3Smrg CARD32 gen_int_cntl; 116c582b7e3Smrg CARD32 cap0_trig_cntl; 117c582b7e3Smrg CARD32 cap1_trig_cntl; 118c582b7e3Smrg CARD32 bus_cntl; 119c582b7e3Smrg CARD32 config_cntl; 120c582b7e3Smrg 121c582b7e3Smrg /* Other registers to save for VT switches */ 122c582b7e3Smrg CARD32 dp_datatype; 123c582b7e3Smrg CARD32 gen_reset_cntl; 124c582b7e3Smrg CARD32 clock_cntl_index; 125c582b7e3Smrg CARD32 amcgpio_en_reg; 126c582b7e3Smrg CARD32 amcgpio_mask; 127c582b7e3Smrg 128c582b7e3Smrg /* CRTC registers */ 129c582b7e3Smrg CARD32 crtc_gen_cntl; 130c582b7e3Smrg CARD32 crtc_ext_cntl; 131c582b7e3Smrg CARD32 dac_cntl; 132c582b7e3Smrg CARD32 crtc_h_total_disp; 133c582b7e3Smrg CARD32 crtc_h_sync_strt_wid; 134c582b7e3Smrg CARD32 crtc_v_total_disp; 135c582b7e3Smrg CARD32 crtc_v_sync_strt_wid; 136c582b7e3Smrg CARD32 crtc_offset; 137c582b7e3Smrg CARD32 crtc_offset_cntl; 138c582b7e3Smrg CARD32 crtc_pitch; 139c582b7e3Smrg 140c582b7e3Smrg /* CRTC2 registers */ 141c582b7e3Smrg CARD32 crtc2_gen_cntl; 142c582b7e3Smrg CARD32 crtc2_h_total_disp; 143c582b7e3Smrg CARD32 crtc2_h_sync_strt_wid; 144c582b7e3Smrg CARD32 crtc2_v_total_disp; 145c582b7e3Smrg CARD32 crtc2_v_sync_strt_wid; 146c582b7e3Smrg CARD32 crtc2_offset; 147c582b7e3Smrg CARD32 crtc2_offset_cntl; 148c582b7e3Smrg CARD32 crtc2_pitch; 149c582b7e3Smrg 150c582b7e3Smrg /* Flat panel registers */ 151c582b7e3Smrg CARD32 fp_crtc_h_total_disp; 152c582b7e3Smrg CARD32 fp_crtc_v_total_disp; 153c582b7e3Smrg CARD32 fp_gen_cntl; 154c582b7e3Smrg CARD32 fp_h_sync_strt_wid; 155c582b7e3Smrg CARD32 fp_horz_stretch; 156c582b7e3Smrg CARD32 fp_panel_cntl; 157c582b7e3Smrg CARD32 fp_v_sync_strt_wid; 158c582b7e3Smrg CARD32 fp_vert_stretch; 159c582b7e3Smrg CARD32 lvds_gen_cntl; 160c582b7e3Smrg CARD32 tmds_crc; 161c582b7e3Smrg CARD32 tmds_transmitter_cntl; 162c582b7e3Smrg 163c582b7e3Smrg /* Computed values for PLL */ 164c582b7e3Smrg CARD32 dot_clock_freq; 165c582b7e3Smrg CARD32 pll_output_freq; 166c582b7e3Smrg int feedback_div; 167c582b7e3Smrg int post_div; 168c582b7e3Smrg 169c582b7e3Smrg /* PLL registers */ 170c582b7e3Smrg CARD32 ppll_ref_div; 171c582b7e3Smrg CARD32 ppll_div_3; 172c582b7e3Smrg CARD32 htotal_cntl; 173c582b7e3Smrg 174c582b7e3Smrg /* Computed values for PLL2 */ 175c582b7e3Smrg CARD32 dot_clock_freq_2; 176c582b7e3Smrg CARD32 pll_output_freq_2; 177c582b7e3Smrg int feedback_div_2; 178c582b7e3Smrg int post_div_2; 179c582b7e3Smrg 180c582b7e3Smrg /* PLL2 registers */ 181c582b7e3Smrg CARD32 p2pll_ref_div; 182c582b7e3Smrg CARD32 p2pll_div_0; 183c582b7e3Smrg CARD32 htotal_cntl2; 184c582b7e3Smrg 185c582b7e3Smrg /* DDA register */ 186c582b7e3Smrg CARD32 dda_config; 187c582b7e3Smrg CARD32 dda_on_off; 188c582b7e3Smrg 189c582b7e3Smrg /* DDA2 register */ 190c582b7e3Smrg CARD32 dda2_config; 191c582b7e3Smrg CARD32 dda2_on_off; 192c582b7e3Smrg 193c582b7e3Smrg /* Pallet */ 194c582b7e3Smrg Bool palette_valid; 195c582b7e3Smrg CARD32 palette[256]; 196c582b7e3Smrg CARD32 palette2[256]; 197c582b7e3Smrg} R128SaveRec, *R128SavePtr; 198c582b7e3Smrg 199c582b7e3Smrgtypedef struct { 200c582b7e3Smrg CARD16 reference_freq; 201c582b7e3Smrg CARD16 reference_div; 202c582b7e3Smrg unsigned min_pll_freq; 203c582b7e3Smrg unsigned max_pll_freq; 204c582b7e3Smrg CARD16 xclk; 205c582b7e3Smrg} R128PLLRec, *R128PLLPtr; 206c582b7e3Smrg 207c582b7e3Smrgtypedef struct { 208c582b7e3Smrg int bitsPerPixel; 209c582b7e3Smrg int depth; 210c582b7e3Smrg int displayWidth; 211c582b7e3Smrg int pixel_code; 212c582b7e3Smrg int pixel_bytes; 213c582b7e3Smrg DisplayModePtr mode; 214c582b7e3Smrg} R128FBLayout; 215c582b7e3Smrg 216c582b7e3Smrgtypedef enum 217c582b7e3Smrg{ 218c582b7e3Smrg MT_NONE, 219c582b7e3Smrg MT_CRT, 220c582b7e3Smrg MT_LCD, 221c582b7e3Smrg MT_DFP, 222c582b7e3Smrg MT_CTV, 223c582b7e3Smrg MT_STV 224c582b7e3Smrg} R128MonitorType; 225c582b7e3Smrg 226c582b7e3Smrgtypedef struct { 227c582b7e3Smrg EntityInfoPtr pEnt; 228c582b7e3Smrg pciVideoPtr PciInfo; 229c582b7e3Smrg PCITAG PciTag; 230c582b7e3Smrg int Chipset; 231c582b7e3Smrg Bool Primary; 232c582b7e3Smrg 233c582b7e3Smrg Bool FBDev; 234c582b7e3Smrg 235c582b7e3Smrg unsigned long LinearAddr; /* Frame buffer physical address */ 236c582b7e3Smrg unsigned long MMIOAddr; /* MMIO region physical address */ 237c582b7e3Smrg unsigned long BIOSAddr; /* BIOS physical address */ 238c582b7e3Smrg 239c582b7e3Smrg void *MMIO; /* Map of MMIO region */ 240c582b7e3Smrg void *FB; /* Map of frame buffer */ 241c582b7e3Smrg 242c582b7e3Smrg CARD32 MemCntl; 243c582b7e3Smrg CARD32 BusCntl; 244c582b7e3Smrg unsigned long FbMapSize; /* Size of frame buffer, in bytes */ 245c582b7e3Smrg int Flags; /* Saved copy of mode flags */ 246c582b7e3Smrg 247c582b7e3Smrg CARD8 BIOSDisplay; /* Device the BIOS is set to display to */ 248c582b7e3Smrg 249c582b7e3Smrg Bool HasPanelRegs; /* Current chip can connect to a FP */ 250c582b7e3Smrg CARD8 *VBIOS; /* Video BIOS for mode validation on FPs */ 251c582b7e3Smrg int FPBIOSstart; /* Start of the flat panel info */ 252c582b7e3Smrg 253c582b7e3Smrg /* Computed values for FPs */ 254c582b7e3Smrg int PanelXRes; 255c582b7e3Smrg int PanelYRes; 256c582b7e3Smrg int HOverPlus; 257c582b7e3Smrg int HSyncWidth; 258c582b7e3Smrg int HBlank; 259c582b7e3Smrg int VOverPlus; 260c582b7e3Smrg int VSyncWidth; 261c582b7e3Smrg int VBlank; 262c582b7e3Smrg int PanelPwrDly; 263c582b7e3Smrg 264c582b7e3Smrg R128PLLRec pll; 265c582b7e3Smrg R128RAMPtr ram; 266c582b7e3Smrg 267c582b7e3Smrg R128SaveRec SavedReg; /* Original (text) mode */ 268c582b7e3Smrg R128SaveRec ModeReg; /* Current mode */ 269c582b7e3Smrg Bool (*CloseScreen)(int, ScreenPtr); 270c582b7e3Smrg void (*BlockHandler)(int, pointer, pointer, pointer); 271c582b7e3Smrg 272c582b7e3Smrg Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ 273c582b7e3Smrg 274c582b7e3Smrg XAAInfoRecPtr accel; 275c582b7e3Smrg Bool accelOn; 276c582b7e3Smrg xf86CursorInfoPtr cursor; 277c582b7e3Smrg unsigned long cursor_start; 278c582b7e3Smrg unsigned long cursor_end; 279c582b7e3Smrg 280c582b7e3Smrg /* 281c582b7e3Smrg * XAAForceTransBlit is used to change the behavior of the XAA 282c582b7e3Smrg * SetupForScreenToScreenCopy function, to make it DGA-friendly. 283c582b7e3Smrg */ 284c582b7e3Smrg Bool XAAForceTransBlit; 285c582b7e3Smrg 286c582b7e3Smrg int fifo_slots; /* Free slots in the FIFO (64 max) */ 287c582b7e3Smrg int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ 288c582b7e3Smrg Bool dac6bits; /* Use 6 bit DAC? */ 289c582b7e3Smrg 290c582b7e3Smrg /* Computed values for Rage 128 */ 291c582b7e3Smrg int pitch; 292c582b7e3Smrg int datatype; 293c582b7e3Smrg CARD32 dp_gui_master_cntl; 294c582b7e3Smrg 295c582b7e3Smrg /* Saved values for ScreenToScreenCopy */ 296c582b7e3Smrg int xdir; 297c582b7e3Smrg int ydir; 298c582b7e3Smrg 299c582b7e3Smrg /* ScanlineScreenToScreenColorExpand support */ 300c582b7e3Smrg unsigned char *scratch_buffer[1]; 301c582b7e3Smrg unsigned char *scratch_save; 302c582b7e3Smrg int scanline_x; 303c582b7e3Smrg int scanline_y; 304c582b7e3Smrg int scanline_w; 305c582b7e3Smrg int scanline_h; 306c582b7e3Smrg#ifdef XF86DRI 307c582b7e3Smrg int scanline_hpass; 308c582b7e3Smrg int scanline_x1clip; 309c582b7e3Smrg int scanline_x2clip; 310c582b7e3Smrg int scanline_rop; 311c582b7e3Smrg int scanline_fg; 312c582b7e3Smrg int scanline_bg; 313c582b7e3Smrg#endif /* XF86DRI */ 314c582b7e3Smrg int scanline_words; 315c582b7e3Smrg int scanline_direct; 316c582b7e3Smrg int scanline_bpp; /* Only used for ImageWrite */ 317c582b7e3Smrg 318c582b7e3Smrg DGAModePtr DGAModes; 319c582b7e3Smrg int numDGAModes; 320c582b7e3Smrg Bool DGAactive; 321c582b7e3Smrg int DGAViewportStatus; 322c582b7e3Smrg DGAFunctionRec DGAFuncs; 323c582b7e3Smrg 324c582b7e3Smrg R128FBLayout CurrentLayout; 325c582b7e3Smrg#ifdef XF86DRI 326c582b7e3Smrg Bool directRenderingEnabled; 327c582b7e3Smrg DRIInfoPtr pDRIInfo; 328c582b7e3Smrg int drmFD; 329c582b7e3Smrg drm_context_t drmCtx; 330c582b7e3Smrg int numVisualConfigs; 331c582b7e3Smrg __GLXvisualConfig *pVisualConfigs; 332c582b7e3Smrg R128ConfigPrivPtr pVisualConfigsPriv; 333c582b7e3Smrg 334c582b7e3Smrg drm_handle_t fbHandle; 335c582b7e3Smrg 336c582b7e3Smrg drmSize registerSize; 337c582b7e3Smrg drm_handle_t registerHandle; 338c582b7e3Smrg 339c582b7e3Smrg Bool IsPCI; /* Current card is a PCI card */ 340c582b7e3Smrg drmSize pciSize; 341c582b7e3Smrg drm_handle_t pciMemHandle; 342c582b7e3Smrg drmAddress PCI; /* Map */ 343c582b7e3Smrg 344c582b7e3Smrg Bool allowPageFlip; /* Enable 3d page flipping */ 345c582b7e3Smrg Bool have3DWindows; /* Are there any 3d clients? */ 346c582b7e3Smrg int drmMinor; 347c582b7e3Smrg 348c582b7e3Smrg drmSize agpSize; 349c582b7e3Smrg drm_handle_t agpMemHandle; /* Handle from drmAgpAlloc */ 350c582b7e3Smrg unsigned long agpOffset; 351c582b7e3Smrg drmAddress AGP; /* Map */ 352c582b7e3Smrg int agpMode; 353c582b7e3Smrg 354c582b7e3Smrg Bool CCEInUse; /* CCE is currently active */ 355c582b7e3Smrg int CCEMode; /* CCE mode that server/clients use */ 356c582b7e3Smrg int CCEFifoSize; /* Size of the CCE command FIFO */ 357c582b7e3Smrg Bool CCESecure; /* CCE security enabled */ 358c582b7e3Smrg int CCEusecTimeout; /* CCE timeout in usecs */ 359c582b7e3Smrg 360c582b7e3Smrg /* CCE ring buffer data */ 361c582b7e3Smrg unsigned long ringStart; /* Offset into AGP space */ 362c582b7e3Smrg drm_handle_t ringHandle; /* Handle from drmAddMap */ 363c582b7e3Smrg drmSize ringMapSize; /* Size of map */ 364c582b7e3Smrg int ringSize; /* Size of ring (in MB) */ 365c582b7e3Smrg drmAddress ring; /* Map */ 366c582b7e3Smrg int ringSizeLog2QW; 367c582b7e3Smrg 368c582b7e3Smrg unsigned long ringReadOffset; /* Offset into AGP space */ 369c582b7e3Smrg drm_handle_t ringReadPtrHandle; /* Handle from drmAddMap */ 370c582b7e3Smrg drmSize ringReadMapSize; /* Size of map */ 371c582b7e3Smrg drmAddress ringReadPtr; /* Map */ 372c582b7e3Smrg 373c582b7e3Smrg /* CCE vertex/indirect buffer data */ 374c582b7e3Smrg unsigned long bufStart; /* Offset into AGP space */ 375c582b7e3Smrg drm_handle_t bufHandle; /* Handle from drmAddMap */ 376c582b7e3Smrg drmSize bufMapSize; /* Size of map */ 377c582b7e3Smrg int bufSize; /* Size of buffers (in MB) */ 378c582b7e3Smrg drmAddress buf; /* Map */ 379c582b7e3Smrg int bufNumBufs; /* Number of buffers */ 380c582b7e3Smrg drmBufMapPtr buffers; /* Buffer map */ 381c582b7e3Smrg 382c582b7e3Smrg /* CCE AGP Texture data */ 383c582b7e3Smrg unsigned long agpTexStart; /* Offset into AGP space */ 384c582b7e3Smrg drm_handle_t agpTexHandle; /* Handle from drmAddMap */ 385c582b7e3Smrg drmSize agpTexMapSize; /* Size of map */ 386c582b7e3Smrg int agpTexSize; /* Size of AGP tex space (in MB) */ 387c582b7e3Smrg drmAddress agpTex; /* Map */ 388c582b7e3Smrg int log2AGPTexGran; 389c582b7e3Smrg 390c582b7e3Smrg /* CCE 2D accleration */ 391c582b7e3Smrg drmBufPtr indirectBuffer; 392c582b7e3Smrg int indirectStart; 393c582b7e3Smrg 394c582b7e3Smrg /* DRI screen private data */ 395c582b7e3Smrg int fbX; 396c582b7e3Smrg int fbY; 397c582b7e3Smrg int backX; 398c582b7e3Smrg int backY; 399c582b7e3Smrg int depthX; 400c582b7e3Smrg int depthY; 401c582b7e3Smrg 402c582b7e3Smrg int frontOffset; 403c582b7e3Smrg int frontPitch; 404c582b7e3Smrg int backOffset; 405c582b7e3Smrg int backPitch; 406c582b7e3Smrg int depthOffset; 407c582b7e3Smrg int depthPitch; 408c582b7e3Smrg int spanOffset; 409c582b7e3Smrg int textureOffset; 410c582b7e3Smrg int textureSize; 411c582b7e3Smrg int log2TexGran; 412c582b7e3Smrg 413c582b7e3Smrg /* Saved scissor values */ 414c582b7e3Smrg CARD32 sc_left; 415c582b7e3Smrg CARD32 sc_right; 416c582b7e3Smrg CARD32 sc_top; 417c582b7e3Smrg CARD32 sc_bottom; 418c582b7e3Smrg 419c582b7e3Smrg CARD32 re_top_left; 420c582b7e3Smrg CARD32 re_width_height; 421c582b7e3Smrg 422c582b7e3Smrg CARD32 aux_sc_cntl; 423c582b7e3Smrg 424c582b7e3Smrg int irq; 425c582b7e3Smrg CARD32 gen_int_cntl; 426c582b7e3Smrg 427c582b7e3Smrg Bool DMAForXv; 428c582b7e3Smrg#endif 429c582b7e3Smrg 430c582b7e3Smrg XF86VideoAdaptorPtr adaptor; 431c582b7e3Smrg void (*VideoTimerCallback)(ScrnInfoPtr, Time); 432c582b7e3Smrg int videoKey; 433c582b7e3Smrg Bool showCache; 434c582b7e3Smrg OptionInfoPtr Options; 435c582b7e3Smrg 436c582b7e3Smrg Bool isDFP; 437c582b7e3Smrg Bool isPro2; 438c582b7e3Smrg I2CBusPtr pI2CBus; 439c582b7e3Smrg CARD32 DDCReg; 440c582b7e3Smrg 441c582b7e3Smrg Bool VGAAccess; 442c582b7e3Smrg 443c582b7e3Smrg /****** Added for dualhead support *******************/ 444c582b7e3Smrg BOOL HasCRTC2; /* M3/M4 */ 445c582b7e3Smrg BOOL IsSecondary; /* second Screen */ 446c582b7e3Smrg BOOL IsPrimary; /* primary Screen */ 447c582b7e3Smrg BOOL UseCRT; /* force use CRT port as primary */ 448c582b7e3Smrg BOOL SwitchingMode; 449c582b7e3Smrg R128MonitorType DisplayType; /* Monitor connected on*/ 450c582b7e3Smrg 451c582b7e3Smrg} R128InfoRec, *R128InfoPtr; 452c582b7e3Smrg 453c582b7e3Smrg#define R128WaitForFifo(pScrn, entries) \ 454c582b7e3Smrgdo { \ 455c582b7e3Smrg if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \ 456c582b7e3Smrg info->fifo_slots -= entries; \ 457c582b7e3Smrg} while (0) 458c582b7e3Smrg 459c582b7e3Smrgextern R128EntPtr R128EntPriv(ScrnInfoPtr pScrn); 460c582b7e3Smrgextern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries); 461c582b7e3Smrgextern void R128WaitForIdle(ScrnInfoPtr pScrn); 462c582b7e3Smrgextern void R128EngineReset(ScrnInfoPtr pScrn); 463c582b7e3Smrgextern void R128EngineFlush(ScrnInfoPtr pScrn); 464c582b7e3Smrg 465c582b7e3Smrgextern unsigned R128INPLL(ScrnInfoPtr pScrn, int addr); 466c582b7e3Smrgextern void R128WaitForVerticalSync(ScrnInfoPtr pScrn); 467c582b7e3Smrg 468c582b7e3Smrgextern Bool R128AccelInit(ScreenPtr pScreen); 469c582b7e3Smrgextern void R128EngineInit(ScrnInfoPtr pScrn); 470c582b7e3Smrgextern Bool R128CursorInit(ScreenPtr pScreen); 471c582b7e3Smrgextern Bool R128DGAInit(ScreenPtr pScreen); 472c582b7e3Smrg 473c582b7e3Smrgextern int R128MinBits(int val); 474c582b7e3Smrg 475c582b7e3Smrgextern void R128InitVideo(ScreenPtr pScreen); 476c582b7e3Smrg 477c582b7e3Smrg#ifdef XF86DRI 478c582b7e3Smrgextern Bool R128DRIScreenInit(ScreenPtr pScreen); 479c582b7e3Smrgextern void R128DRICloseScreen(ScreenPtr pScreen); 480c582b7e3Smrgextern Bool R128DRIFinishScreenInit(ScreenPtr pScreen); 481c582b7e3Smrg 482c582b7e3Smrg#define R128CCE_START(pScrn, info) \ 483c582b7e3Smrgdo { \ 484c582b7e3Smrg int _ret = drmCommandNone(info->drmFD, DRM_R128_CCE_START); \ 485c582b7e3Smrg if (_ret) { \ 486c582b7e3Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 487c582b7e3Smrg "%s: CCE start %d\n", __FUNCTION__, _ret); \ 488c582b7e3Smrg } \ 489c582b7e3Smrg} while (0) 490c582b7e3Smrg 491c582b7e3Smrg#define R128CCE_STOP(pScrn, info) \ 492c582b7e3Smrgdo { \ 493c582b7e3Smrg int _ret = R128CCEStop(pScrn); \ 494c582b7e3Smrg if (_ret) { \ 495c582b7e3Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 496c582b7e3Smrg "%s: CCE stop %d\n", __FUNCTION__, _ret); \ 497c582b7e3Smrg } \ 498c582b7e3Smrg} while (0) 499c582b7e3Smrg 500c582b7e3Smrg#define R128CCE_RESET(pScrn, info) \ 501c582b7e3Smrgdo { \ 502c582b7e3Smrg if (info->directRenderingEnabled \ 503c582b7e3Smrg && R128CCE_USE_RING_BUFFER(info->CCEMode)) { \ 504c582b7e3Smrg int _ret = drmCommandNone(info->drmFD, DRM_R128_CCE_RESET); \ 505c582b7e3Smrg if (_ret) { \ 506c582b7e3Smrg xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ 507c582b7e3Smrg "%s: CCE reset %d\n", __FUNCTION__, _ret); \ 508c582b7e3Smrg } \ 509c582b7e3Smrg } \ 510c582b7e3Smrg} while (0) 511c582b7e3Smrg 512c582b7e3Smrgextern drmBufPtr R128CCEGetBuffer(ScrnInfoPtr pScrn); 513c582b7e3Smrg#endif 514c582b7e3Smrg 515c582b7e3Smrgextern void R128CCEFlushIndirect(ScrnInfoPtr pScrn, int discard); 516c582b7e3Smrgextern void R128CCEReleaseIndirect(ScrnInfoPtr pScrn); 517c582b7e3Smrgextern void R128CCEWaitForIdle(ScrnInfoPtr pScrn); 518c582b7e3Smrgextern int R128CCEStop(ScrnInfoPtr pScrn); 519c582b7e3Smrg 520c582b7e3Smrg 521c582b7e3Smrg#define CCE_PACKET0( reg, n ) \ 522c582b7e3Smrg (R128_CCE_PACKET0 | ((n) << 16) | ((reg) >> 2)) 523c582b7e3Smrg#define CCE_PACKET1( reg0, reg1 ) \ 524c582b7e3Smrg (R128_CCE_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2)) 525c582b7e3Smrg#define CCE_PACKET2() \ 526c582b7e3Smrg (R128_CCE_PACKET2) 527c582b7e3Smrg#define CCE_PACKET3( pkt, n ) \ 528c582b7e3Smrg (R128_CCE_PACKET3 | (pkt) | ((n) << 16)) 529c582b7e3Smrg 530c582b7e3Smrg 531c582b7e3Smrg#define R128_VERBOSE 0 532c582b7e3Smrg 533c582b7e3Smrg#define RING_LOCALS CARD32 *__head; int __count; 534c582b7e3Smrg 535c582b7e3Smrg#define R128CCE_REFRESH(pScrn, info) \ 536c582b7e3Smrgdo { \ 537c582b7e3Smrg if ( R128_VERBOSE ) { \ 538c582b7e3Smrg xf86DrvMsg( pScrn->scrnIndex, X_INFO, "REFRESH( %d ) in %s\n", \ 539c582b7e3Smrg !info->CCEInUse , __FUNCTION__ ); \ 540c582b7e3Smrg } \ 541c582b7e3Smrg if ( !info->CCEInUse ) { \ 542c582b7e3Smrg R128CCEWaitForIdle(pScrn); \ 543c582b7e3Smrg BEGIN_RING( 6 ); \ 544c582b7e3Smrg OUT_RING_REG( R128_RE_TOP_LEFT, info->re_top_left ); \ 545c582b7e3Smrg OUT_RING_REG( R128_RE_WIDTH_HEIGHT, info->re_width_height ); \ 546c582b7e3Smrg OUT_RING_REG( R128_AUX_SC_CNTL, info->aux_sc_cntl ); \ 547c582b7e3Smrg ADVANCE_RING(); \ 548c582b7e3Smrg info->CCEInUse = TRUE; \ 549c582b7e3Smrg } \ 550c582b7e3Smrg} while (0) 551c582b7e3Smrg 552c582b7e3Smrg#define BEGIN_RING( n ) do { \ 553c582b7e3Smrg if ( R128_VERBOSE ) { \ 554c582b7e3Smrg xf86DrvMsg( pScrn->scrnIndex, X_INFO, \ 555c582b7e3Smrg "BEGIN_RING( %d ) in %s\n", n, __FUNCTION__ ); \ 556c582b7e3Smrg } \ 557c582b7e3Smrg if ( !info->indirectBuffer ) { \ 558c582b7e3Smrg info->indirectBuffer = R128CCEGetBuffer( pScrn ); \ 559c582b7e3Smrg info->indirectStart = 0; \ 560c582b7e3Smrg } else if ( (info->indirectBuffer->used + 4*(n)) > \ 561c582b7e3Smrg info->indirectBuffer->total ) { \ 562c582b7e3Smrg R128CCEFlushIndirect( pScrn, 1 ); \ 563c582b7e3Smrg } \ 564c582b7e3Smrg __head = (pointer)((char *)info->indirectBuffer->address + \ 565c582b7e3Smrg info->indirectBuffer->used); \ 566c582b7e3Smrg __count = 0; \ 567c582b7e3Smrg} while (0) 568c582b7e3Smrg 569c582b7e3Smrg#define ADVANCE_RING() do { \ 570c582b7e3Smrg if ( R128_VERBOSE ) { \ 571c582b7e3Smrg xf86DrvMsg( pScrn->scrnIndex, X_INFO, \ 572c582b7e3Smrg "ADVANCE_RING() used: %d+%d=%d/%d\n", \ 573c582b7e3Smrg info->indirectBuffer->used - info->indirectStart, \ 574c582b7e3Smrg __count * (int)sizeof(CARD32), \ 575c582b7e3Smrg info->indirectBuffer->used - info->indirectStart + \ 576c582b7e3Smrg __count * (int)sizeof(CARD32), \ 577c582b7e3Smrg info->indirectBuffer->total - info->indirectStart ); \ 578c582b7e3Smrg } \ 579c582b7e3Smrg info->indirectBuffer->used += __count * (int)sizeof(CARD32); \ 580c582b7e3Smrg} while (0) 581c582b7e3Smrg 582c582b7e3Smrg#define OUT_RING( x ) do { \ 583c582b7e3Smrg if ( R128_VERBOSE ) { \ 584c582b7e3Smrg xf86DrvMsg( pScrn->scrnIndex, X_INFO, \ 585c582b7e3Smrg " OUT_RING( 0x%08x )\n", (unsigned int)(x) ); \ 586c582b7e3Smrg } \ 587c582b7e3Smrg MMIO_OUT32(&__head[__count++], 0, (x)); \ 588c582b7e3Smrg} while (0) 589c582b7e3Smrg 590c582b7e3Smrg#define OUT_RING_REG( reg, val ) \ 591c582b7e3Smrgdo { \ 592c582b7e3Smrg OUT_RING( CCE_PACKET0( reg, 0 ) ); \ 593c582b7e3Smrg OUT_RING( val ); \ 594c582b7e3Smrg} while (0) 595c582b7e3Smrg 596c582b7e3Smrg#define FLUSH_RING() \ 597c582b7e3Smrgdo { \ 598c582b7e3Smrg if ( R128_VERBOSE ) \ 599c582b7e3Smrg xf86DrvMsg( pScrn->scrnIndex, X_INFO, \ 600c582b7e3Smrg "FLUSH_RING in %s\n", __FUNCTION__ ); \ 601c582b7e3Smrg if ( info->indirectBuffer ) { \ 602c582b7e3Smrg R128CCEFlushIndirect( pScrn, 0 ); \ 603c582b7e3Smrg } \ 604c582b7e3Smrg} while (0) 605c582b7e3Smrg 606c582b7e3Smrg#endif 607