c5b8023d9d151ee6fec694085ac011ddc40aea66
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_screen.h
1 /**************************************************************************
2
3 Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
4 VA Linux Systems Inc., Fremont, California.
5
6 All Rights Reserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
15
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 **************************************************************************/
29
30 /*
31 * Authors:
32 * Kevin E. Martin <martin@valinux.com>
33 * Gareth Hughes <gareth@valinux.com>
34 */
35
36 #ifndef __RADEON_SCREEN_H__
37 #define __RADEON_SCREEN_H__
38
39 /*
40 * IMPORTS: these headers contain all the DRI, X and kernel-related
41 * definitions that we need.
42 */
43 #include <xf86drm.h>
44 #include <radeon_drm.h>
45 #include "dri_util.h"
46 #include "radeon_chipset.h"
47 #include "radeon_reg.h"
48 #include "util/xmlconfig.h"
49
50 #define DRI_CONF_COLOR_REDUCTION_ROUND 0
51 #define DRI_CONF_COLOR_REDUCTION_DITHER 1
52 #define DRI_CONF_COLOR_REDUCTION(def) \
53 DRI_CONF_OPT_BEGIN_V(color_reduction,enum,def,"0:1") \
54 DRI_CONF_DESC_BEGIN(en,"Initial color reduction method") \
55 DRI_CONF_ENUM(0,"Round colors") \
56 DRI_CONF_ENUM(1,"Dither colors") \
57 DRI_CONF_DESC_END \
58 DRI_CONF_OPT_END
59
60 #define DRI_CONF_DITHER_XERRORDIFF 0
61 #define DRI_CONF_DITHER_XERRORDIFFRESET 1
62 #define DRI_CONF_DITHER_ORDERED 2
63 #define DRI_CONF_DITHER_MODE(def) \
64 DRI_CONF_OPT_BEGIN_V(dither_mode,enum,def,"0:2") \
65 DRI_CONF_DESC_BEGIN(en,"Color dithering method") \
66 DRI_CONF_ENUM(0,"Horizontal error diffusion") \
67 DRI_CONF_ENUM(1,"Horizontal error diffusion, reset error at line start") \
68 DRI_CONF_ENUM(2,"Ordered 2D color dithering") \
69 DRI_CONF_DESC_END \
70 DRI_CONF_OPT_END
71
72
73 #define DRI_CONF_TCL_SW 0
74 #define DRI_CONF_TCL_PIPELINED 1
75 #define DRI_CONF_TCL_VTXFMT 2
76 #define DRI_CONF_TCL_CODEGEN 3
77
78 typedef struct {
79 drm_handle_t handle; /* Handle to the DRM region */
80 drmSize size; /* Size of the DRM region */
81 drmAddress map; /* Mapping of the DRM region */
82 } radeonRegionRec, *radeonRegionPtr;
83
84 typedef struct radeon_screen {
85 int chip_family;
86 int chip_flags;
87 int cpp;
88 int card_type;
89 int device_id; /* PCI ID */
90 int AGPMode;
91 unsigned int irq; /* IRQ number (0 means none) */
92
93 unsigned int fbLocation;
94 unsigned int frontOffset;
95 unsigned int frontPitch;
96 unsigned int backOffset;
97 unsigned int backPitch;
98
99 unsigned int depthOffset;
100 unsigned int depthPitch;
101
102 /* Shared texture data */
103 int numTexHeaps;
104 int texOffset[RADEON_NR_TEX_HEAPS];
105 int texSize[RADEON_NR_TEX_HEAPS];
106 int logTexGranularity[RADEON_NR_TEX_HEAPS];
107
108 radeonRegionRec mmio;
109 radeonRegionRec status;
110 radeonRegionRec gartTextures;
111
112 drmBufMapPtr buffers;
113
114 __volatile__ uint32_t *scratch;
115
116 __DRIscreen *driScreen;
117 unsigned int gart_buffer_offset; /* offset in card memory space */
118 unsigned int gart_texture_offset; /* offset in card memory space */
119 unsigned int gart_base;
120
121 GLboolean depthHasSurface;
122
123 /* Configuration cache with default values for all contexts */
124 driOptionCache optionCache;
125
126 int num_gb_pipes;
127 int num_z_pipes;
128 struct radeon_bo_manager *bom;
129
130 } radeonScreenRec, *radeonScreenPtr;
131
132 struct __DRIimageRec {
133 struct radeon_bo *bo;
134 GLenum internal_format;
135 uint32_t dri_format;
136 GLuint format;
137 GLenum data_type;
138 int width, height; /* in pixels */
139 int pitch; /* in pixels */
140 int cpp;
141 void *data;
142 };
143
144 #ifdef RADEON_R200
145 /* These defines are to ensure that r200_dri's symbols don't conflict with
146 * radeon's when linked together.
147 */
148 #define get_radeon_buffer_object r200_get_radeon_buffer_object
149 #define radeonInitBufferObjectFuncs r200_radeonInitBufferObjectFuncs
150 #define radeonDestroyContext r200_radeonDestroyContext
151 #define radeonInitContext r200_radeonInitContext
152 #define radeonMakeCurrent r200_radeonMakeCurrent
153 #define radeon_prepare_render r200_radeon_prepare_render
154 #define radeonUnbindContext r200_radeonUnbindContext
155 #define radeon_update_renderbuffers r200_radeon_update_renderbuffers
156 #define radeonCountStateEmitSize r200_radeonCountStateEmitSize
157 #define radeon_draw_buffer r200_radeon_draw_buffer
158 #define radeonDrawBuffer r200_radeonDrawBuffer
159 #define radeonEmitState r200_radeonEmitState
160 #define radeonFinish r200_radeonFinish
161 #define radeonFlush r200_radeonFlush
162 #define radeonGetAge r200_radeonGetAge
163 #define radeonReadBuffer r200_radeonReadBuffer
164 #define radeonScissor r200_radeonScissor
165 #define radeonSetCliprects r200_radeonSetCliprects
166 #define radeonUpdateScissor r200_radeonUpdateScissor
167 #define radeonUserClear r200_radeonUserClear
168 #define radeon_viewport r200_radeon_viewport
169 #define radeon_window_moved r200_radeon_window_moved
170 #define rcommonBeginBatch r200_rcommonBeginBatch
171 #define rcommonDestroyCmdBuf r200_rcommonDestroyCmdBuf
172 #define rcommonEnsureCmdBufSpace r200_rcommonEnsureCmdBufSpace
173 #define rcommonFlushCmdBuf r200_rcommonFlushCmdBuf
174 #define rcommonFlushCmdBufLocked r200_rcommonFlushCmdBufLocked
175 #define rcommonInitCmdBuf r200_rcommonInitCmdBuf
176 #define radeonAllocDmaRegion r200_radeonAllocDmaRegion
177 #define radeonEmitVec12 r200_radeonEmitVec12
178 #define radeonEmitVec16 r200_radeonEmitVec16
179 #define radeonEmitVec4 r200_radeonEmitVec4
180 #define radeonEmitVec8 r200_radeonEmitVec8
181 #define radeonFreeDmaRegions r200_radeonFreeDmaRegions
182 #define radeon_init_dma r200_radeon_init_dma
183 #define radeonRefillCurrentDmaRegion r200_radeonRefillCurrentDmaRegion
184 #define radeonReleaseArrays r200_radeonReleaseArrays
185 #define radeonReleaseDmaRegions r200_radeonReleaseDmaRegions
186 #define radeonReturnDmaRegion r200_radeonReturnDmaRegion
187 #define rcommonAllocDmaLowVerts r200_rcommonAllocDmaLowVerts
188 #define rcommon_emit_vecfog r200_rcommon_emit_vecfog
189 #define rcommon_emit_vector r200_rcommon_emit_vector
190 #define rcommon_flush_last_swtcl_prim r200_rcommon_flush_last_swtcl_prim
191 #define _radeon_debug_add_indent r200__radeon_debug_add_indent
192 #define _radeon_debug_remove_indent r200__radeon_debug_remove_indent
193 #define radeon_init_debug r200_radeon_init_debug
194 #define _radeon_print r200__radeon_print
195 #define radeon_create_renderbuffer r200_radeon_create_renderbuffer
196 #define radeon_fbo_init r200_radeon_fbo_init
197 #define radeon_renderbuffer_set_bo r200_radeon_renderbuffer_set_bo
198 #define radeonComputeFogBlendFactor r200_radeonComputeFogBlendFactor
199 #define radeonInitStaticFogData r200_radeonInitStaticFogData
200 #define get_base_teximage_offset r200_get_base_teximage_offset
201 #define get_texture_image_row_stride r200_get_texture_image_row_stride
202 #define get_texture_image_size r200_get_texture_image_size
203 #define radeon_miptree_create r200_radeon_miptree_create
204 #define radeon_miptree_image_offset r200_radeon_miptree_image_offset
205 #define radeon_miptree_matches_image r200_radeon_miptree_matches_image
206 #define radeon_miptree_reference r200_radeon_miptree_reference
207 #define radeon_miptree_unreference r200_radeon_miptree_unreference
208 #define radeon_try_alloc_miptree r200_radeon_try_alloc_miptree
209 #define radeon_validate_texture_miptree r200_radeon_validate_texture_miptree
210 #define radeonReadPixels r200_radeonReadPixels
211 #define radeon_check_query_active r200_radeon_check_query_active
212 #define radeonEmitQueryEnd r200_radeonEmitQueryEnd
213 #define radeon_emit_queryobj r200_radeon_emit_queryobj
214 #define radeonInitQueryObjFunctions r200_radeonInitQueryObjFunctions
215 #define radeonInitSpanFuncs r200_radeonInitSpanFuncs
216 #define copy_rows r200_copy_rows
217 #define radeonChooseTextureFormat r200_radeonChooseTextureFormat
218 #define radeonChooseTextureFormat_mesa r200_radeonChooseTextureFormat_mesa
219 #define radeonFreeTextureImageBuffer r200_radeonFreeTextureImageBuffer
220 #define radeon_image_target_texture_2d r200_radeon_image_target_texture_2d
221 #define radeon_init_common_texture_funcs r200_radeon_init_common_texture_funcs
222 #define radeonIsFormatRenderable r200_radeonIsFormatRenderable
223 #define radeonNewTextureImage r200_radeonNewTextureImage
224 #define _radeon_texformat_al88 r200__radeon_texformat_al88
225 #define _radeon_texformat_argb1555 r200__radeon_texformat_argb1555
226 #define _radeon_texformat_argb4444 r200__radeon_texformat_argb4444
227 #define _radeon_texformat_argb8888 r200__radeon_texformat_argb8888
228 #define _radeon_texformat_rgb565 r200__radeon_texformat_rgb565
229 #define _radeon_texformat_rgba8888 r200__radeon_texformat_rgba8888
230 #define radeonCopyTexSubImage r200_radeonCopyTexSubImage
231 #define get_tile_size r200_get_tile_size
232 #define tile_image r200_tile_image
233 #define untile_image r200_untile_image
234 #define set_re_cntl_d3d r200_set_re_cntl_d3d
235 #define radeonDestroyBuffer r200_radeonDestroyBuffer
236 #define radeonVendorString r200_radeonVendorString
237 #define radeonGetRendererString r200_radeonGetRendererString
238 #endif
239
240 extern void radeonDestroyBuffer(__DRIdrawable *driDrawPriv);
241 const __DRIextension **__driDriverGetExtensions_radeon(void);
242 const __DRIextension **__driDriverGetExtensions_r200(void);
243
244 #endif /* __RADEON_SCREEN_H__ */