#ifndef ___ATISTRUCT_H___
#define ___ATISTRUCT_H___ 1
#include "atibank.h"
#include "aticlock.h"
#include "atiregs.h"
#include "xaa.h"
#include "xf86Cursor.h"
#include "xf86Pci.h"
#include "xf86Resources.h"
#define CacheSlotOf(____Register) ((____Register) / UnitOf(DWORD_SELECT))
typedef struct _ATIHWRec
{
CARD8 clock;
CARD8 crtc;
CARD8 lut[256 * 3];
#ifndef AVOID_CPIO
CARD8 genmo, crt[25], seq[5], gra[9], attr[21];
CARD8 a3, a6, a7, ab, ac, ad, ae,
b0, b1, b2, b3, b5, b6, b8, b9, ba, bd, be, bf;
CARD8 shadow_vga[25];
#endif
CARD8 dac_read, dac_write, dac_mask;
CARD8 ibmrgb514[0x0092U];
CARD8 pll_vclk_cntl, pll_vclk_post_div,
pll_vclk0_fb_div, pll_vclk1_fb_div,
pll_vclk2_fb_div, pll_vclk3_fb_div,
pll_xclk_cntl, pll_ext_vpll_cntl;
CARD32 crtc_h_total_disp, crtc_h_sync_strt_wid,
crtc_v_total_disp, crtc_v_sync_strt_wid,
crtc_off_pitch, crtc_gen_cntl, dsp_config, dsp_on_off,
ovr_clr, ovr_wid_left_right, ovr_wid_top_bottom,
cur_clr0, cur_clr1, cur_offset,
cur_horz_vert_posn, cur_horz_vert_off,
clock_cntl, bus_cntl, mem_cntl, mem_vga_wp_sel, mem_vga_rp_sel,
dac_cntl, gen_test_cntl, config_cntl, mpp_config, mpp_strobe_seq,
tvo_cntl;
CARD32 lcd_index, config_panel, lcd_gen_ctrl,
horz_stretching, vert_stretching, ext_vert_stretch;
CARD32 shadow_h_total_disp, shadow_h_sync_strt_wid,
shadow_v_total_disp, shadow_v_sync_strt_wid;
CARD32 dst_off_pitch;
CARD16 dst_x, dst_y, dst_height;
CARD32 dst_bres_err, dst_bres_inc, dst_bres_dec, dst_cntl;
CARD32 src_off_pitch;
CARD16 src_x, src_y, src_width1, src_height1,
src_x_start, src_y_start, src_width2, src_height2;
CARD32 src_cntl;
CARD32 host_cntl;
CARD32 pat_reg0, pat_reg1, pat_cntl;
CARD16 sc_left, sc_right, sc_top, sc_bottom;
CARD32 dp_bkgd_clr, dp_frgd_clr, dp_write_mask, dp_chain_mask,
dp_pix_width, dp_mix, dp_src;
CARD32 clr_cmp_clr, clr_cmp_msk, clr_cmp_cntl;
CARD32 context_mask, context_load_cntl;
CARD32 overlay_y_x_start, overlay_y_x_end, overlay_graphics_key_clr,
overlay_graphics_key_msk, overlay_key_cntl, overlay_scale_inc,
overlay_scale_cntl, scaler_height_width, scaler_test,
scaler_buf0_offset, scaler_buf1_offset, scaler_buf_pitch,
video_format, overlay_exclusive_horz, overlay_exclusive_vert,
buf0_offset, buf0_pitch, buf1_offset, buf1_pitch,
scaler_colour_cntl, scaler_h_coeff0, scaler_h_coeff1,
scaler_h_coeff2, scaler_h_coeff3, scaler_h_coeff4, gui_cntl,
scaler_buf0_offset_u, scaler_buf0_offset_v, scaler_buf1_offset_u,
scaler_buf1_offset_v;
const CARD8 *ClockMap, *ClockUnmap;
int FeedbackDivider, ReferenceDivider, PostDivider;
#ifndef AVOID_CPIO
pointer frame_buffer;
ATIBankProcPtr SetBank;
unsigned int nBank, nPlane;
#endif
} ATIHWRec;
typedef struct _ATIRec
{
CARD8 Chipset;
CARD8 Adapter;
#ifndef AVOID_CPIO
CARD8 VGAAdapter;
#endif
CARD32 config_chip_id;
CARD16 ChipType;
CARD8 Chip;
CARD8 ChipClass, ChipRevision, ChipRev, ChipVersion, ChipFoundry;
#ifndef AVOID_CPIO
CARD8 Coprocessor, ChipHasSUBSYS_CNTL;
#endif
CARD8 CPIODecoding;
IOADDRESS CPIOBase;
#ifndef AVOID_CPIO
IOADDRESS CPIO_VGABase;
IOADDRESS CPIO_VGAWonder;
CARD8 B2Reg;
CARD8 VGAOffset;
#endif
#ifndef AVOID_CPIO
IOADDRESS CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE,
CPIO_DAC_WAIT;
#endif
CARD16 DAC;
CARD8 rgbBits;
pciVideoPtr PCIInfo;
CARD8 BusType;
CARD8 SharedAccelerator;
#ifndef AVOID_CPIO
CARD8 SharedVGA;
resRange VGAWonderResources[2];
#endif
CARD8 MemoryType;
int VideoRAM;
unsigned long BIOSBase;
CARD8 I2CType, Tuner, Decoder, Audio;
pointer pMemory, pShadow;
pointer pMemoryLE;
unsigned long LinearBase;
int LinearSize, FBPitch;
#ifndef AVOID_CPIO
miBankInfoRec BankInfo;
pointer pBank;
CARD8 UseSmallApertures;
#endif
pointer pMMIO, pBlock[2];
unsigned long Block0Base, Block1Base;
XAAInfoRecPtr pXAAInfo;
int nAvailableFIFOEntries, nFIFOEntries, nHostFIFOEntries;
CARD8 EngineIsBusy, EngineIsLocked, XModifier;
CARD32 dst_cntl;
CARD32 sc_left_right, sc_top_bottom;
CARD16 sc_left, sc_right, sc_top, sc_bottom;
pointer pHOST_DATA;
CARD32 *ExpansionBitmapScanlinePtr[2];
int ExpansionBitmapWidth;
xf86CursorInfoPtr pCursorInfo;
pointer pCursorPage, pCursorImage;
unsigned long CursorBase;
CARD32 CursorOffset;
CARD16 CursorXOffset, CursorYOffset;
CARD8 Cursor;
CARD32 MMIOCache[CacheSlotOf(DWORD_SELECT) + 1];
CARD8 MMIOCached[(CacheSlotOf(DWORD_SELECT) + 8) >> 3];
int ClockNumberToProgramme, ReferenceNumerator, ReferenceDenominator;
int ProgrammableClock, maxClock;
ClockRec ClockDescriptor;
CARD16 BIOSClocks[16];
CARD8 Clock;
int XCLKFeedbackDivider, XCLKReferenceDivider, XCLKPostDivider;
CARD16 XCLKMaxRASDelay, XCLKPageFaultDelay,
DisplayLoopLatency, DisplayFIFODepth;
int LCDPanelID, LCDClock, LCDHorizontal, LCDVertical;
unsigned LCDHSyncStart, LCDHSyncWidth, LCDHBlankWidth;
unsigned LCDVSyncStart, LCDVSyncWidth, LCDVBlankWidth;
int LCDVBlendFIFOSize;
int AdjustDepth, AdjustMaxX, AdjustMaxY;
unsigned long AdjustMask, AdjustMaxBase;
DisplayModePtr currentMode;
CARD8 depth, bitsPerPixel;
short int displayWidth;
int pitchInc;
rgb weight;
#ifndef AVOID_DGA
DGAModePtr pDGAMode;
DGAFunctionRec ATIDGAFunctions;
int nDGAMode;
CARD8 XAAForceTransBlit;
#endif
DevUnion XVPortPrivate[1];
FBLinearPtr pXVBuffer;
RegionRec VideoClip;
int SurfacePitch, SurfaceOffset;
CARD8 AutoPaint, DoubleBuffer, CurrentBuffer, ActiveSurface;
struct
{
CARD32 crtc_int_cntl, crtc_gen_cntl, i2c_cntl_0, hw_debug,
scratch_reg3, bus_cntl, lcd_index, mem_cntl, i2c_cntl_1,
dac_cntl, gen_test_cntl, mpp_config, mpp_strobe_seq, tvo_cntl;
#ifndef AVOID_CPIO
CARD32 config_cntl;
CARD16 clock_sel, misc_options, mem_bndry, mem_cfg;
CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be;
CARD8 crt03, crt11;
CARD8 shadow_crt03, shadow_crt11;
#endif
} LockData;
ATIHWRec OldHW, NewHW;
int MaximumInterlacedPitch;
Bool InterlacedSeen;
int iEntity;
CARD8 OptionAccel:1;
CARD8 OptionBIOSDisplay:1;
CARD8 OptionBlend:1;
CARD8 OptionCRTDisplay:1;
CARD8 OptionCSync:1;
CARD8 OptionDevel:1;
#ifndef AVOID_CPIO
CARD8 OptionLinear:1;
#endif
CARD8 OptionMMIOCache:1;
CARD8 OptionTestMMIOCache:1;
CARD8 OptionPanelDisplay:1;
CARD8 OptionProbeClocks:1;
CARD8 OptionShadowFB:1;
CARD8 OptionLCDSync:1;
CARD8 Unlocked, Mapped, Closeable;
CARD8 MMIOInLinear;
CloseScreenProcPtr CloseScreen;
} ATIRec;
#define ATIPTR(_p) ((ATIPtr)((_p)->driverPrivate))
#endif