162306a36Sopenharmony_ci/* radeon_drm.h -- Public header for the radeon driver -*- linux-c -*-
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
462306a36Sopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
562306a36Sopenharmony_ci * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
662306a36Sopenharmony_ci * All rights reserved.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
962306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
1062306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
1162306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1262306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
1362306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the next
1662306a36Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
1762306a36Sopenharmony_ci * Software.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2062306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2162306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
2262306a36Sopenharmony_ci * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2362306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2462306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2562306a36Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * Authors:
2862306a36Sopenharmony_ci *    Kevin E. Martin <martin@valinux.com>
2962306a36Sopenharmony_ci *    Gareth Hughes <gareth@valinux.com>
3062306a36Sopenharmony_ci *    Keith Whitwell <keith@tungstengraphics.com>
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifndef __RADEON_DRM_H__
3462306a36Sopenharmony_ci#define __RADEON_DRM_H__
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#include "drm.h"
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#if defined(__cplusplus)
3962306a36Sopenharmony_ciextern "C" {
4062306a36Sopenharmony_ci#endif
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/* WARNING: If you change any of these defines, make sure to change the
4362306a36Sopenharmony_ci * defines in the X server file (radeon_sarea.h)
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ci#ifndef __RADEON_SAREA_DEFINES__
4662306a36Sopenharmony_ci#define __RADEON_SAREA_DEFINES__
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* Old style state flags, required for sarea interface (1.1 and 1.2
4962306a36Sopenharmony_ci * clears) and 1.2 drm_vertex2 ioctl.
5062306a36Sopenharmony_ci */
5162306a36Sopenharmony_ci#define RADEON_UPLOAD_CONTEXT		0x00000001
5262306a36Sopenharmony_ci#define RADEON_UPLOAD_VERTFMT		0x00000002
5362306a36Sopenharmony_ci#define RADEON_UPLOAD_LINE		0x00000004
5462306a36Sopenharmony_ci#define RADEON_UPLOAD_BUMPMAP		0x00000008
5562306a36Sopenharmony_ci#define RADEON_UPLOAD_MASKS		0x00000010
5662306a36Sopenharmony_ci#define RADEON_UPLOAD_VIEWPORT		0x00000020
5762306a36Sopenharmony_ci#define RADEON_UPLOAD_SETUP		0x00000040
5862306a36Sopenharmony_ci#define RADEON_UPLOAD_TCL		0x00000080
5962306a36Sopenharmony_ci#define RADEON_UPLOAD_MISC		0x00000100
6062306a36Sopenharmony_ci#define RADEON_UPLOAD_TEX0		0x00000200
6162306a36Sopenharmony_ci#define RADEON_UPLOAD_TEX1		0x00000400
6262306a36Sopenharmony_ci#define RADEON_UPLOAD_TEX2		0x00000800
6362306a36Sopenharmony_ci#define RADEON_UPLOAD_TEX0IMAGES	0x00001000
6462306a36Sopenharmony_ci#define RADEON_UPLOAD_TEX1IMAGES	0x00002000
6562306a36Sopenharmony_ci#define RADEON_UPLOAD_TEX2IMAGES	0x00004000
6662306a36Sopenharmony_ci#define RADEON_UPLOAD_CLIPRECTS		0x00008000	/* handled client-side */
6762306a36Sopenharmony_ci#define RADEON_REQUIRE_QUIESCENCE	0x00010000
6862306a36Sopenharmony_ci#define RADEON_UPLOAD_ZBIAS		0x00020000	/* version 1.2 and newer */
6962306a36Sopenharmony_ci#define RADEON_UPLOAD_ALL		0x003effff
7062306a36Sopenharmony_ci#define RADEON_UPLOAD_CONTEXT_ALL       0x003e01ff
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* New style per-packet identifiers for use in cmd_buffer ioctl with
7362306a36Sopenharmony_ci * the RADEON_EMIT_PACKET command.  Comments relate new packets to old
7462306a36Sopenharmony_ci * state bits and the packet size:
7562306a36Sopenharmony_ci */
7662306a36Sopenharmony_ci#define RADEON_EMIT_PP_MISC                         0	/* context/7 */
7762306a36Sopenharmony_ci#define RADEON_EMIT_PP_CNTL                         1	/* context/3 */
7862306a36Sopenharmony_ci#define RADEON_EMIT_RB3D_COLORPITCH                 2	/* context/1 */
7962306a36Sopenharmony_ci#define RADEON_EMIT_RE_LINE_PATTERN                 3	/* line/2 */
8062306a36Sopenharmony_ci#define RADEON_EMIT_SE_LINE_WIDTH                   4	/* line/1 */
8162306a36Sopenharmony_ci#define RADEON_EMIT_PP_LUM_MATRIX                   5	/* bumpmap/1 */
8262306a36Sopenharmony_ci#define RADEON_EMIT_PP_ROT_MATRIX_0                 6	/* bumpmap/2 */
8362306a36Sopenharmony_ci#define RADEON_EMIT_RB3D_STENCILREFMASK             7	/* masks/3 */
8462306a36Sopenharmony_ci#define RADEON_EMIT_SE_VPORT_XSCALE                 8	/* viewport/6 */
8562306a36Sopenharmony_ci#define RADEON_EMIT_SE_CNTL                         9	/* setup/2 */
8662306a36Sopenharmony_ci#define RADEON_EMIT_SE_CNTL_STATUS                  10	/* setup/1 */
8762306a36Sopenharmony_ci#define RADEON_EMIT_RE_MISC                         11	/* misc/1 */
8862306a36Sopenharmony_ci#define RADEON_EMIT_PP_TXFILTER_0                   12	/* tex0/6 */
8962306a36Sopenharmony_ci#define RADEON_EMIT_PP_BORDER_COLOR_0               13	/* tex0/1 */
9062306a36Sopenharmony_ci#define RADEON_EMIT_PP_TXFILTER_1                   14	/* tex1/6 */
9162306a36Sopenharmony_ci#define RADEON_EMIT_PP_BORDER_COLOR_1               15	/* tex1/1 */
9262306a36Sopenharmony_ci#define RADEON_EMIT_PP_TXFILTER_2                   16	/* tex2/6 */
9362306a36Sopenharmony_ci#define RADEON_EMIT_PP_BORDER_COLOR_2               17	/* tex2/1 */
9462306a36Sopenharmony_ci#define RADEON_EMIT_SE_ZBIAS_FACTOR                 18	/* zbias/2 */
9562306a36Sopenharmony_ci#define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT           19	/* tcl/11 */
9662306a36Sopenharmony_ci#define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED   20	/* material/17 */
9762306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_0                     21	/* tex0/4 */
9862306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_1                     22	/* tex1/4 */
9962306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_2                     23	/* tex2/4 */
10062306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_3                     24	/* tex3/4 */
10162306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_4                     25	/* tex4/4 */
10262306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_5                     26	/* tex5/4 */
10362306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_6                     27	/* /4 */
10462306a36Sopenharmony_ci#define R200_EMIT_PP_TXCBLEND_7                     28	/* /4 */
10562306a36Sopenharmony_ci#define R200_EMIT_TCL_LIGHT_MODEL_CTL_0             29	/* tcl/7 */
10662306a36Sopenharmony_ci#define R200_EMIT_TFACTOR_0                         30	/* tf/7 */
10762306a36Sopenharmony_ci#define R200_EMIT_VTX_FMT_0                         31	/* vtx/5 */
10862306a36Sopenharmony_ci#define R200_EMIT_VAP_CTL                           32	/* vap/1 */
10962306a36Sopenharmony_ci#define R200_EMIT_MATRIX_SELECT_0                   33	/* msl/5 */
11062306a36Sopenharmony_ci#define R200_EMIT_TEX_PROC_CTL_2                    34	/* tcg/5 */
11162306a36Sopenharmony_ci#define R200_EMIT_TCL_UCP_VERT_BLEND_CTL            35	/* tcl/1 */
11262306a36Sopenharmony_ci#define R200_EMIT_PP_TXFILTER_0                     36	/* tex0/6 */
11362306a36Sopenharmony_ci#define R200_EMIT_PP_TXFILTER_1                     37	/* tex1/6 */
11462306a36Sopenharmony_ci#define R200_EMIT_PP_TXFILTER_2                     38	/* tex2/6 */
11562306a36Sopenharmony_ci#define R200_EMIT_PP_TXFILTER_3                     39	/* tex3/6 */
11662306a36Sopenharmony_ci#define R200_EMIT_PP_TXFILTER_4                     40	/* tex4/6 */
11762306a36Sopenharmony_ci#define R200_EMIT_PP_TXFILTER_5                     41	/* tex5/6 */
11862306a36Sopenharmony_ci#define R200_EMIT_PP_TXOFFSET_0                     42	/* tex0/1 */
11962306a36Sopenharmony_ci#define R200_EMIT_PP_TXOFFSET_1                     43	/* tex1/1 */
12062306a36Sopenharmony_ci#define R200_EMIT_PP_TXOFFSET_2                     44	/* tex2/1 */
12162306a36Sopenharmony_ci#define R200_EMIT_PP_TXOFFSET_3                     45	/* tex3/1 */
12262306a36Sopenharmony_ci#define R200_EMIT_PP_TXOFFSET_4                     46	/* tex4/1 */
12362306a36Sopenharmony_ci#define R200_EMIT_PP_TXOFFSET_5                     47	/* tex5/1 */
12462306a36Sopenharmony_ci#define R200_EMIT_VTE_CNTL                          48	/* vte/1 */
12562306a36Sopenharmony_ci#define R200_EMIT_OUTPUT_VTX_COMP_SEL               49	/* vtx/1 */
12662306a36Sopenharmony_ci#define R200_EMIT_PP_TAM_DEBUG3                     50	/* tam/1 */
12762306a36Sopenharmony_ci#define R200_EMIT_PP_CNTL_X                         51	/* cst/1 */
12862306a36Sopenharmony_ci#define R200_EMIT_RB3D_DEPTHXY_OFFSET               52	/* cst/1 */
12962306a36Sopenharmony_ci#define R200_EMIT_RE_AUX_SCISSOR_CNTL               53	/* cst/1 */
13062306a36Sopenharmony_ci#define R200_EMIT_RE_SCISSOR_TL_0                   54	/* cst/2 */
13162306a36Sopenharmony_ci#define R200_EMIT_RE_SCISSOR_TL_1                   55	/* cst/2 */
13262306a36Sopenharmony_ci#define R200_EMIT_RE_SCISSOR_TL_2                   56	/* cst/2 */
13362306a36Sopenharmony_ci#define R200_EMIT_SE_VAP_CNTL_STATUS                57	/* cst/1 */
13462306a36Sopenharmony_ci#define R200_EMIT_SE_VTX_STATE_CNTL                 58	/* cst/1 */
13562306a36Sopenharmony_ci#define R200_EMIT_RE_POINTSIZE                      59	/* cst/1 */
13662306a36Sopenharmony_ci#define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0       60	/* cst/4 */
13762306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_FACES_0                  61
13862306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_OFFSETS_0                62
13962306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_FACES_1                  63
14062306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_OFFSETS_1                64
14162306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_FACES_2                  65
14262306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_OFFSETS_2                66
14362306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_FACES_3                  67
14462306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_OFFSETS_3                68
14562306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_FACES_4                  69
14662306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_OFFSETS_4                70
14762306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_FACES_5                  71
14862306a36Sopenharmony_ci#define R200_EMIT_PP_CUBIC_OFFSETS_5                72
14962306a36Sopenharmony_ci#define RADEON_EMIT_PP_TEX_SIZE_0                   73
15062306a36Sopenharmony_ci#define RADEON_EMIT_PP_TEX_SIZE_1                   74
15162306a36Sopenharmony_ci#define RADEON_EMIT_PP_TEX_SIZE_2                   75
15262306a36Sopenharmony_ci#define R200_EMIT_RB3D_BLENDCOLOR                   76
15362306a36Sopenharmony_ci#define R200_EMIT_TCL_POINT_SPRITE_CNTL             77
15462306a36Sopenharmony_ci#define RADEON_EMIT_PP_CUBIC_FACES_0                78
15562306a36Sopenharmony_ci#define RADEON_EMIT_PP_CUBIC_OFFSETS_T0             79
15662306a36Sopenharmony_ci#define RADEON_EMIT_PP_CUBIC_FACES_1                80
15762306a36Sopenharmony_ci#define RADEON_EMIT_PP_CUBIC_OFFSETS_T1             81
15862306a36Sopenharmony_ci#define RADEON_EMIT_PP_CUBIC_FACES_2                82
15962306a36Sopenharmony_ci#define RADEON_EMIT_PP_CUBIC_OFFSETS_T2             83
16062306a36Sopenharmony_ci#define R200_EMIT_PP_TRI_PERF_CNTL                  84
16162306a36Sopenharmony_ci#define R200_EMIT_PP_AFS_0                          85
16262306a36Sopenharmony_ci#define R200_EMIT_PP_AFS_1                          86
16362306a36Sopenharmony_ci#define R200_EMIT_ATF_TFACTOR                       87
16462306a36Sopenharmony_ci#define R200_EMIT_PP_TXCTLALL_0                     88
16562306a36Sopenharmony_ci#define R200_EMIT_PP_TXCTLALL_1                     89
16662306a36Sopenharmony_ci#define R200_EMIT_PP_TXCTLALL_2                     90
16762306a36Sopenharmony_ci#define R200_EMIT_PP_TXCTLALL_3                     91
16862306a36Sopenharmony_ci#define R200_EMIT_PP_TXCTLALL_4                     92
16962306a36Sopenharmony_ci#define R200_EMIT_PP_TXCTLALL_5                     93
17062306a36Sopenharmony_ci#define R200_EMIT_VAP_PVS_CNTL                      94
17162306a36Sopenharmony_ci#define RADEON_MAX_STATE_PACKETS                    95
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci/* Commands understood by cmd_buffer ioctl.  More can be added but
17462306a36Sopenharmony_ci * obviously these can't be removed or changed:
17562306a36Sopenharmony_ci */
17662306a36Sopenharmony_ci#define RADEON_CMD_PACKET      1	/* emit one of the register packets above */
17762306a36Sopenharmony_ci#define RADEON_CMD_SCALARS     2	/* emit scalar data */
17862306a36Sopenharmony_ci#define RADEON_CMD_VECTORS     3	/* emit vector data */
17962306a36Sopenharmony_ci#define RADEON_CMD_DMA_DISCARD 4	/* discard current dma buf */
18062306a36Sopenharmony_ci#define RADEON_CMD_PACKET3     5	/* emit hw packet */
18162306a36Sopenharmony_ci#define RADEON_CMD_PACKET3_CLIP 6	/* emit hw packet wrapped in cliprects */
18262306a36Sopenharmony_ci#define RADEON_CMD_SCALARS2     7	/* r200 stopgap */
18362306a36Sopenharmony_ci#define RADEON_CMD_WAIT         8	/* emit hw wait commands -- note:
18462306a36Sopenharmony_ci					 *  doesn't make the cpu wait, just
18562306a36Sopenharmony_ci					 *  the graphics hardware */
18662306a36Sopenharmony_ci#define RADEON_CMD_VECLINEAR	9       /* another r200 stopgap */
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_citypedef union {
18962306a36Sopenharmony_ci	int i;
19062306a36Sopenharmony_ci	struct {
19162306a36Sopenharmony_ci		unsigned char cmd_type, pad0, pad1, pad2;
19262306a36Sopenharmony_ci	} header;
19362306a36Sopenharmony_ci	struct {
19462306a36Sopenharmony_ci		unsigned char cmd_type, packet_id, pad0, pad1;
19562306a36Sopenharmony_ci	} packet;
19662306a36Sopenharmony_ci	struct {
19762306a36Sopenharmony_ci		unsigned char cmd_type, offset, stride, count;
19862306a36Sopenharmony_ci	} scalars;
19962306a36Sopenharmony_ci	struct {
20062306a36Sopenharmony_ci		unsigned char cmd_type, offset, stride, count;
20162306a36Sopenharmony_ci	} vectors;
20262306a36Sopenharmony_ci	struct {
20362306a36Sopenharmony_ci		unsigned char cmd_type, addr_lo, addr_hi, count;
20462306a36Sopenharmony_ci	} veclinear;
20562306a36Sopenharmony_ci	struct {
20662306a36Sopenharmony_ci		unsigned char cmd_type, buf_idx, pad0, pad1;
20762306a36Sopenharmony_ci	} dma;
20862306a36Sopenharmony_ci	struct {
20962306a36Sopenharmony_ci		unsigned char cmd_type, flags, pad0, pad1;
21062306a36Sopenharmony_ci	} wait;
21162306a36Sopenharmony_ci} drm_radeon_cmd_header_t;
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci#define RADEON_WAIT_2D  0x1
21462306a36Sopenharmony_ci#define RADEON_WAIT_3D  0x2
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci/* Allowed parameters for R300_CMD_PACKET3
21762306a36Sopenharmony_ci */
21862306a36Sopenharmony_ci#define R300_CMD_PACKET3_CLEAR		0
21962306a36Sopenharmony_ci#define R300_CMD_PACKET3_RAW		1
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci/* Commands understood by cmd_buffer ioctl for R300.
22262306a36Sopenharmony_ci * The interface has not been stabilized, so some of these may be removed
22362306a36Sopenharmony_ci * and eventually reordered before stabilization.
22462306a36Sopenharmony_ci */
22562306a36Sopenharmony_ci#define R300_CMD_PACKET0		1
22662306a36Sopenharmony_ci#define R300_CMD_VPU			2	/* emit vertex program upload */
22762306a36Sopenharmony_ci#define R300_CMD_PACKET3		3	/* emit a packet3 */
22862306a36Sopenharmony_ci#define R300_CMD_END3D			4	/* emit sequence ending 3d rendering */
22962306a36Sopenharmony_ci#define R300_CMD_CP_DELAY		5
23062306a36Sopenharmony_ci#define R300_CMD_DMA_DISCARD		6
23162306a36Sopenharmony_ci#define R300_CMD_WAIT			7
23262306a36Sopenharmony_ci#	define R300_WAIT_2D		0x1
23362306a36Sopenharmony_ci#	define R300_WAIT_3D		0x2
23462306a36Sopenharmony_ci/* these two defines are DOING IT WRONG - however
23562306a36Sopenharmony_ci * we have userspace which relies on using these.
23662306a36Sopenharmony_ci * The wait interface is backwards compat new
23762306a36Sopenharmony_ci * code should use the NEW_WAIT defines below
23862306a36Sopenharmony_ci * THESE ARE NOT BIT FIELDS
23962306a36Sopenharmony_ci */
24062306a36Sopenharmony_ci#	define R300_WAIT_2D_CLEAN	0x3
24162306a36Sopenharmony_ci#	define R300_WAIT_3D_CLEAN	0x4
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci#	define R300_NEW_WAIT_2D_3D	0x3
24462306a36Sopenharmony_ci#	define R300_NEW_WAIT_2D_2D_CLEAN	0x4
24562306a36Sopenharmony_ci#	define R300_NEW_WAIT_3D_3D_CLEAN	0x6
24662306a36Sopenharmony_ci#	define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN	0x8
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci#define R300_CMD_SCRATCH		8
24962306a36Sopenharmony_ci#define R300_CMD_R500FP                 9
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_citypedef union {
25262306a36Sopenharmony_ci	unsigned int u;
25362306a36Sopenharmony_ci	struct {
25462306a36Sopenharmony_ci		unsigned char cmd_type, pad0, pad1, pad2;
25562306a36Sopenharmony_ci	} header;
25662306a36Sopenharmony_ci	struct {
25762306a36Sopenharmony_ci		unsigned char cmd_type, count, reglo, reghi;
25862306a36Sopenharmony_ci	} packet0;
25962306a36Sopenharmony_ci	struct {
26062306a36Sopenharmony_ci		unsigned char cmd_type, count, adrlo, adrhi;
26162306a36Sopenharmony_ci	} vpu;
26262306a36Sopenharmony_ci	struct {
26362306a36Sopenharmony_ci		unsigned char cmd_type, packet, pad0, pad1;
26462306a36Sopenharmony_ci	} packet3;
26562306a36Sopenharmony_ci	struct {
26662306a36Sopenharmony_ci		unsigned char cmd_type, packet;
26762306a36Sopenharmony_ci		unsigned short count;	/* amount of packet2 to emit */
26862306a36Sopenharmony_ci	} delay;
26962306a36Sopenharmony_ci	struct {
27062306a36Sopenharmony_ci		unsigned char cmd_type, buf_idx, pad0, pad1;
27162306a36Sopenharmony_ci	} dma;
27262306a36Sopenharmony_ci	struct {
27362306a36Sopenharmony_ci		unsigned char cmd_type, flags, pad0, pad1;
27462306a36Sopenharmony_ci	} wait;
27562306a36Sopenharmony_ci	struct {
27662306a36Sopenharmony_ci		unsigned char cmd_type, reg, n_bufs, flags;
27762306a36Sopenharmony_ci	} scratch;
27862306a36Sopenharmony_ci	struct {
27962306a36Sopenharmony_ci		unsigned char cmd_type, count, adrlo, adrhi_flags;
28062306a36Sopenharmony_ci	} r500fp;
28162306a36Sopenharmony_ci} drm_r300_cmd_header_t;
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci#define RADEON_FRONT			0x1
28462306a36Sopenharmony_ci#define RADEON_BACK			0x2
28562306a36Sopenharmony_ci#define RADEON_DEPTH			0x4
28662306a36Sopenharmony_ci#define RADEON_STENCIL			0x8
28762306a36Sopenharmony_ci#define RADEON_CLEAR_FASTZ		0x80000000
28862306a36Sopenharmony_ci#define RADEON_USE_HIERZ		0x40000000
28962306a36Sopenharmony_ci#define RADEON_USE_COMP_ZBUF		0x20000000
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci#define R500FP_CONSTANT_TYPE  (1 << 1)
29262306a36Sopenharmony_ci#define R500FP_CONSTANT_CLAMP (1 << 2)
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci/* Primitive types
29562306a36Sopenharmony_ci */
29662306a36Sopenharmony_ci#define RADEON_POINTS			0x1
29762306a36Sopenharmony_ci#define RADEON_LINES			0x2
29862306a36Sopenharmony_ci#define RADEON_LINE_STRIP		0x3
29962306a36Sopenharmony_ci#define RADEON_TRIANGLES		0x4
30062306a36Sopenharmony_ci#define RADEON_TRIANGLE_FAN		0x5
30162306a36Sopenharmony_ci#define RADEON_TRIANGLE_STRIP		0x6
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci/* Vertex/indirect buffer size
30462306a36Sopenharmony_ci */
30562306a36Sopenharmony_ci#define RADEON_BUFFER_SIZE		65536
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci/* Byte offsets for indirect buffer data
30862306a36Sopenharmony_ci */
30962306a36Sopenharmony_ci#define RADEON_INDEX_PRIM_OFFSET	20
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ci#define RADEON_SCRATCH_REG_OFFSET	32
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci#define R600_SCRATCH_REG_OFFSET         256
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ci#define RADEON_NR_SAREA_CLIPRECTS	12
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci/* There are 2 heaps (local/GART).  Each region within a heap is a
31862306a36Sopenharmony_ci * minimum of 64k, and there are at most 64 of them per heap.
31962306a36Sopenharmony_ci */
32062306a36Sopenharmony_ci#define RADEON_LOCAL_TEX_HEAP		0
32162306a36Sopenharmony_ci#define RADEON_GART_TEX_HEAP		1
32262306a36Sopenharmony_ci#define RADEON_NR_TEX_HEAPS		2
32362306a36Sopenharmony_ci#define RADEON_NR_TEX_REGIONS		64
32462306a36Sopenharmony_ci#define RADEON_LOG_TEX_GRANULARITY	16
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci#define RADEON_MAX_TEXTURE_LEVELS	12
32762306a36Sopenharmony_ci#define RADEON_MAX_TEXTURE_UNITS	3
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci#define RADEON_MAX_SURFACES		8
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci/* Blits have strict offset rules.  All blit offset must be aligned on
33262306a36Sopenharmony_ci * a 1K-byte boundary.
33362306a36Sopenharmony_ci */
33462306a36Sopenharmony_ci#define RADEON_OFFSET_SHIFT             10
33562306a36Sopenharmony_ci#define RADEON_OFFSET_ALIGN             (1 << RADEON_OFFSET_SHIFT)
33662306a36Sopenharmony_ci#define RADEON_OFFSET_MASK              (RADEON_OFFSET_ALIGN - 1)
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci#endif				/* __RADEON_SAREA_DEFINES__ */
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_citypedef struct {
34162306a36Sopenharmony_ci	unsigned int red;
34262306a36Sopenharmony_ci	unsigned int green;
34362306a36Sopenharmony_ci	unsigned int blue;
34462306a36Sopenharmony_ci	unsigned int alpha;
34562306a36Sopenharmony_ci} radeon_color_regs_t;
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_citypedef struct {
34862306a36Sopenharmony_ci	/* Context state */
34962306a36Sopenharmony_ci	unsigned int pp_misc;	/* 0x1c14 */
35062306a36Sopenharmony_ci	unsigned int pp_fog_color;
35162306a36Sopenharmony_ci	unsigned int re_solid_color;
35262306a36Sopenharmony_ci	unsigned int rb3d_blendcntl;
35362306a36Sopenharmony_ci	unsigned int rb3d_depthoffset;
35462306a36Sopenharmony_ci	unsigned int rb3d_depthpitch;
35562306a36Sopenharmony_ci	unsigned int rb3d_zstencilcntl;
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci	unsigned int pp_cntl;	/* 0x1c38 */
35862306a36Sopenharmony_ci	unsigned int rb3d_cntl;
35962306a36Sopenharmony_ci	unsigned int rb3d_coloroffset;
36062306a36Sopenharmony_ci	unsigned int re_width_height;
36162306a36Sopenharmony_ci	unsigned int rb3d_colorpitch;
36262306a36Sopenharmony_ci	unsigned int se_cntl;
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci	/* Vertex format state */
36562306a36Sopenharmony_ci	unsigned int se_coord_fmt;	/* 0x1c50 */
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci	/* Line state */
36862306a36Sopenharmony_ci	unsigned int re_line_pattern;	/* 0x1cd0 */
36962306a36Sopenharmony_ci	unsigned int re_line_state;
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci	unsigned int se_line_width;	/* 0x1db8 */
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ci	/* Bumpmap state */
37462306a36Sopenharmony_ci	unsigned int pp_lum_matrix;	/* 0x1d00 */
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci	unsigned int pp_rot_matrix_0;	/* 0x1d58 */
37762306a36Sopenharmony_ci	unsigned int pp_rot_matrix_1;
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci	/* Mask state */
38062306a36Sopenharmony_ci	unsigned int rb3d_stencilrefmask;	/* 0x1d7c */
38162306a36Sopenharmony_ci	unsigned int rb3d_ropcntl;
38262306a36Sopenharmony_ci	unsigned int rb3d_planemask;
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci	/* Viewport state */
38562306a36Sopenharmony_ci	unsigned int se_vport_xscale;	/* 0x1d98 */
38662306a36Sopenharmony_ci	unsigned int se_vport_xoffset;
38762306a36Sopenharmony_ci	unsigned int se_vport_yscale;
38862306a36Sopenharmony_ci	unsigned int se_vport_yoffset;
38962306a36Sopenharmony_ci	unsigned int se_vport_zscale;
39062306a36Sopenharmony_ci	unsigned int se_vport_zoffset;
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci	/* Setup state */
39362306a36Sopenharmony_ci	unsigned int se_cntl_status;	/* 0x2140 */
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci	/* Misc state */
39662306a36Sopenharmony_ci	unsigned int re_top_left;	/* 0x26c0 */
39762306a36Sopenharmony_ci	unsigned int re_misc;
39862306a36Sopenharmony_ci} drm_radeon_context_regs_t;
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_citypedef struct {
40162306a36Sopenharmony_ci	/* Zbias state */
40262306a36Sopenharmony_ci	unsigned int se_zbias_factor;	/* 0x1dac */
40362306a36Sopenharmony_ci	unsigned int se_zbias_constant;
40462306a36Sopenharmony_ci} drm_radeon_context2_regs_t;
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_ci/* Setup registers for each texture unit
40762306a36Sopenharmony_ci */
40862306a36Sopenharmony_citypedef struct {
40962306a36Sopenharmony_ci	unsigned int pp_txfilter;
41062306a36Sopenharmony_ci	unsigned int pp_txformat;
41162306a36Sopenharmony_ci	unsigned int pp_txoffset;
41262306a36Sopenharmony_ci	unsigned int pp_txcblend;
41362306a36Sopenharmony_ci	unsigned int pp_txablend;
41462306a36Sopenharmony_ci	unsigned int pp_tfactor;
41562306a36Sopenharmony_ci	unsigned int pp_border_color;
41662306a36Sopenharmony_ci} drm_radeon_texture_regs_t;
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_citypedef struct {
41962306a36Sopenharmony_ci	unsigned int start;
42062306a36Sopenharmony_ci	unsigned int finish;
42162306a36Sopenharmony_ci	unsigned int prim:8;
42262306a36Sopenharmony_ci	unsigned int stateidx:8;
42362306a36Sopenharmony_ci	unsigned int numverts:16;	/* overloaded as offset/64 for elt prims */
42462306a36Sopenharmony_ci	unsigned int vc_format;	/* vertex format */
42562306a36Sopenharmony_ci} drm_radeon_prim_t;
42662306a36Sopenharmony_ci
42762306a36Sopenharmony_citypedef struct {
42862306a36Sopenharmony_ci	drm_radeon_context_regs_t context;
42962306a36Sopenharmony_ci	drm_radeon_texture_regs_t tex[RADEON_MAX_TEXTURE_UNITS];
43062306a36Sopenharmony_ci	drm_radeon_context2_regs_t context2;
43162306a36Sopenharmony_ci	unsigned int dirty;
43262306a36Sopenharmony_ci} drm_radeon_state_t;
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_citypedef struct {
43562306a36Sopenharmony_ci	/* The channel for communication of state information to the
43662306a36Sopenharmony_ci	 * kernel on firing a vertex buffer with either of the
43762306a36Sopenharmony_ci	 * obsoleted vertex/index ioctls.
43862306a36Sopenharmony_ci	 */
43962306a36Sopenharmony_ci	drm_radeon_context_regs_t context_state;
44062306a36Sopenharmony_ci	drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS];
44162306a36Sopenharmony_ci	unsigned int dirty;
44262306a36Sopenharmony_ci	unsigned int vertsize;
44362306a36Sopenharmony_ci	unsigned int vc_format;
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ci	/* The current cliprects, or a subset thereof.
44662306a36Sopenharmony_ci	 */
44762306a36Sopenharmony_ci	struct drm_clip_rect boxes[RADEON_NR_SAREA_CLIPRECTS];
44862306a36Sopenharmony_ci	unsigned int nbox;
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci	/* Counters for client-side throttling of rendering clients.
45162306a36Sopenharmony_ci	 */
45262306a36Sopenharmony_ci	unsigned int last_frame;
45362306a36Sopenharmony_ci	unsigned int last_dispatch;
45462306a36Sopenharmony_ci	unsigned int last_clear;
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ci	struct drm_tex_region tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS +
45762306a36Sopenharmony_ci						       1];
45862306a36Sopenharmony_ci	unsigned int tex_age[RADEON_NR_TEX_HEAPS];
45962306a36Sopenharmony_ci	int ctx_owner;
46062306a36Sopenharmony_ci	int pfState;		/* number of 3d windows (0,1,2ormore) */
46162306a36Sopenharmony_ci	int pfCurrentPage;	/* which buffer is being displayed? */
46262306a36Sopenharmony_ci	int crtc2_base;		/* CRTC2 frame offset */
46362306a36Sopenharmony_ci	int tiling_enabled;	/* set by drm, read by 2d + 3d clients */
46462306a36Sopenharmony_ci} drm_radeon_sarea_t;
46562306a36Sopenharmony_ci
46662306a36Sopenharmony_ci/* WARNING: If you change any of these defines, make sure to change the
46762306a36Sopenharmony_ci * defines in the Xserver file (xf86drmRadeon.h)
46862306a36Sopenharmony_ci *
46962306a36Sopenharmony_ci * KW: actually it's illegal to change any of this (backwards compatibility).
47062306a36Sopenharmony_ci */
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_ci/* Radeon specific ioctls
47362306a36Sopenharmony_ci * The device specific ioctl range is 0x40 to 0x79.
47462306a36Sopenharmony_ci */
47562306a36Sopenharmony_ci#define DRM_RADEON_CP_INIT    0x00
47662306a36Sopenharmony_ci#define DRM_RADEON_CP_START   0x01
47762306a36Sopenharmony_ci#define DRM_RADEON_CP_STOP    0x02
47862306a36Sopenharmony_ci#define DRM_RADEON_CP_RESET   0x03
47962306a36Sopenharmony_ci#define DRM_RADEON_CP_IDLE    0x04
48062306a36Sopenharmony_ci#define DRM_RADEON_RESET      0x05
48162306a36Sopenharmony_ci#define DRM_RADEON_FULLSCREEN 0x06
48262306a36Sopenharmony_ci#define DRM_RADEON_SWAP       0x07
48362306a36Sopenharmony_ci#define DRM_RADEON_CLEAR      0x08
48462306a36Sopenharmony_ci#define DRM_RADEON_VERTEX     0x09
48562306a36Sopenharmony_ci#define DRM_RADEON_INDICES    0x0A
48662306a36Sopenharmony_ci#define DRM_RADEON_NOT_USED
48762306a36Sopenharmony_ci#define DRM_RADEON_STIPPLE    0x0C
48862306a36Sopenharmony_ci#define DRM_RADEON_INDIRECT   0x0D
48962306a36Sopenharmony_ci#define DRM_RADEON_TEXTURE    0x0E
49062306a36Sopenharmony_ci#define DRM_RADEON_VERTEX2    0x0F
49162306a36Sopenharmony_ci#define DRM_RADEON_CMDBUF     0x10
49262306a36Sopenharmony_ci#define DRM_RADEON_GETPARAM   0x11
49362306a36Sopenharmony_ci#define DRM_RADEON_FLIP       0x12
49462306a36Sopenharmony_ci#define DRM_RADEON_ALLOC      0x13
49562306a36Sopenharmony_ci#define DRM_RADEON_FREE       0x14
49662306a36Sopenharmony_ci#define DRM_RADEON_INIT_HEAP  0x15
49762306a36Sopenharmony_ci#define DRM_RADEON_IRQ_EMIT   0x16
49862306a36Sopenharmony_ci#define DRM_RADEON_IRQ_WAIT   0x17
49962306a36Sopenharmony_ci#define DRM_RADEON_CP_RESUME  0x18
50062306a36Sopenharmony_ci#define DRM_RADEON_SETPARAM   0x19
50162306a36Sopenharmony_ci#define DRM_RADEON_SURF_ALLOC 0x1a
50262306a36Sopenharmony_ci#define DRM_RADEON_SURF_FREE  0x1b
50362306a36Sopenharmony_ci/* KMS ioctl */
50462306a36Sopenharmony_ci#define DRM_RADEON_GEM_INFO		0x1c
50562306a36Sopenharmony_ci#define DRM_RADEON_GEM_CREATE		0x1d
50662306a36Sopenharmony_ci#define DRM_RADEON_GEM_MMAP		0x1e
50762306a36Sopenharmony_ci#define DRM_RADEON_GEM_PREAD		0x21
50862306a36Sopenharmony_ci#define DRM_RADEON_GEM_PWRITE		0x22
50962306a36Sopenharmony_ci#define DRM_RADEON_GEM_SET_DOMAIN	0x23
51062306a36Sopenharmony_ci#define DRM_RADEON_GEM_WAIT_IDLE	0x24
51162306a36Sopenharmony_ci#define DRM_RADEON_CS			0x26
51262306a36Sopenharmony_ci#define DRM_RADEON_INFO			0x27
51362306a36Sopenharmony_ci#define DRM_RADEON_GEM_SET_TILING	0x28
51462306a36Sopenharmony_ci#define DRM_RADEON_GEM_GET_TILING	0x29
51562306a36Sopenharmony_ci#define DRM_RADEON_GEM_BUSY		0x2a
51662306a36Sopenharmony_ci#define DRM_RADEON_GEM_VA		0x2b
51762306a36Sopenharmony_ci#define DRM_RADEON_GEM_OP		0x2c
51862306a36Sopenharmony_ci#define DRM_RADEON_GEM_USERPTR		0x2d
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CP_INIT    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
52162306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CP_START   DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_START)
52262306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CP_STOP    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_STOP, drm_radeon_cp_stop_t)
52362306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CP_RESET   DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_RESET)
52462306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CP_IDLE    DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_IDLE)
52562306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_RESET      DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_RESET)
52662306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_FULLSCREEN, drm_radeon_fullscreen_t)
52762306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_SWAP       DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_SWAP)
52862306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CLEAR      DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CLEAR, drm_radeon_clear_t)
52962306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_VERTEX     DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_VERTEX, drm_radeon_vertex_t)
53062306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_INDICES    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_INDICES, drm_radeon_indices_t)
53162306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_STIPPLE    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_STIPPLE, drm_radeon_stipple_t)
53262306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_INDIRECT   DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INDIRECT, drm_radeon_indirect_t)
53362306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_TEXTURE    DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_TEXTURE, drm_radeon_texture_t)
53462306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_VERTEX2    DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_VERTEX2, drm_radeon_vertex2_t)
53562306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CMDBUF     DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CMDBUF, drm_radeon_cmd_buffer_t)
53662306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GETPARAM   DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GETPARAM, drm_radeon_getparam_t)
53762306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_FLIP       DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_FLIP)
53862306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_ALLOC      DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_ALLOC, drm_radeon_mem_alloc_t)
53962306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_FREE       DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_FREE, drm_radeon_mem_free_t)
54062306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_INIT_HEAP  DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_INIT_HEAP, drm_radeon_mem_init_heap_t)
54162306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_IRQ_EMIT   DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_IRQ_EMIT, drm_radeon_irq_emit_t)
54262306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_IRQ_WAIT   DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_IRQ_WAIT, drm_radeon_irq_wait_t)
54362306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CP_RESUME  DRM_IO(  DRM_COMMAND_BASE + DRM_RADEON_CP_RESUME)
54462306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_SETPARAM   DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SETPARAM, drm_radeon_setparam_t)
54562306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_SURF_ALLOC DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_ALLOC, drm_radeon_surface_alloc_t)
54662306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_SURF_FREE  DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_FREE, drm_radeon_surface_free_t)
54762306a36Sopenharmony_ci/* KMS */
54862306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_INFO	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_INFO, struct drm_radeon_gem_info)
54962306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_CREATE, struct drm_radeon_gem_create)
55062306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_MMAP, struct drm_radeon_gem_mmap)
55162306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_PREAD	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PREAD, struct drm_radeon_gem_pread)
55262306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_PWRITE	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PWRITE, struct drm_radeon_gem_pwrite)
55362306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_SET_DOMAIN	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_DOMAIN, struct drm_radeon_gem_set_domain)
55462306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_WAIT_IDLE	DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_GEM_WAIT_IDLE, struct drm_radeon_gem_wait_idle)
55562306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_CS		DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_CS, struct drm_radeon_cs)
55662306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_INFO		DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INFO, struct drm_radeon_info)
55762306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_SET_TILING	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling)
55862306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_GET_TILING	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling)
55962306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_BUSY	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy)
56062306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_VA		DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_VA, struct drm_radeon_gem_va)
56162306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_OP		DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_OP, struct drm_radeon_gem_op)
56262306a36Sopenharmony_ci#define DRM_IOCTL_RADEON_GEM_USERPTR	DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_USERPTR, struct drm_radeon_gem_userptr)
56362306a36Sopenharmony_ci
56462306a36Sopenharmony_citypedef struct drm_radeon_init {
56562306a36Sopenharmony_ci	enum {
56662306a36Sopenharmony_ci		RADEON_INIT_CP = 0x01,
56762306a36Sopenharmony_ci		RADEON_CLEANUP_CP = 0x02,
56862306a36Sopenharmony_ci		RADEON_INIT_R200_CP = 0x03,
56962306a36Sopenharmony_ci		RADEON_INIT_R300_CP = 0x04,
57062306a36Sopenharmony_ci		RADEON_INIT_R600_CP = 0x05
57162306a36Sopenharmony_ci	} func;
57262306a36Sopenharmony_ci	unsigned long sarea_priv_offset;
57362306a36Sopenharmony_ci	int is_pci;
57462306a36Sopenharmony_ci	int cp_mode;
57562306a36Sopenharmony_ci	int gart_size;
57662306a36Sopenharmony_ci	int ring_size;
57762306a36Sopenharmony_ci	int usec_timeout;
57862306a36Sopenharmony_ci
57962306a36Sopenharmony_ci	unsigned int fb_bpp;
58062306a36Sopenharmony_ci	unsigned int front_offset, front_pitch;
58162306a36Sopenharmony_ci	unsigned int back_offset, back_pitch;
58262306a36Sopenharmony_ci	unsigned int depth_bpp;
58362306a36Sopenharmony_ci	unsigned int depth_offset, depth_pitch;
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_ci	unsigned long fb_offset;
58662306a36Sopenharmony_ci	unsigned long mmio_offset;
58762306a36Sopenharmony_ci	unsigned long ring_offset;
58862306a36Sopenharmony_ci	unsigned long ring_rptr_offset;
58962306a36Sopenharmony_ci	unsigned long buffers_offset;
59062306a36Sopenharmony_ci	unsigned long gart_textures_offset;
59162306a36Sopenharmony_ci} drm_radeon_init_t;
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_citypedef struct drm_radeon_cp_stop {
59462306a36Sopenharmony_ci	int flush;
59562306a36Sopenharmony_ci	int idle;
59662306a36Sopenharmony_ci} drm_radeon_cp_stop_t;
59762306a36Sopenharmony_ci
59862306a36Sopenharmony_citypedef struct drm_radeon_fullscreen {
59962306a36Sopenharmony_ci	enum {
60062306a36Sopenharmony_ci		RADEON_INIT_FULLSCREEN = 0x01,
60162306a36Sopenharmony_ci		RADEON_CLEANUP_FULLSCREEN = 0x02
60262306a36Sopenharmony_ci	} func;
60362306a36Sopenharmony_ci} drm_radeon_fullscreen_t;
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ci#define CLEAR_X1	0
60662306a36Sopenharmony_ci#define CLEAR_Y1	1
60762306a36Sopenharmony_ci#define CLEAR_X2	2
60862306a36Sopenharmony_ci#define CLEAR_Y2	3
60962306a36Sopenharmony_ci#define CLEAR_DEPTH	4
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_citypedef union drm_radeon_clear_rect {
61262306a36Sopenharmony_ci	float f[5];
61362306a36Sopenharmony_ci	unsigned int ui[5];
61462306a36Sopenharmony_ci} drm_radeon_clear_rect_t;
61562306a36Sopenharmony_ci
61662306a36Sopenharmony_citypedef struct drm_radeon_clear {
61762306a36Sopenharmony_ci	unsigned int flags;
61862306a36Sopenharmony_ci	unsigned int clear_color;
61962306a36Sopenharmony_ci	unsigned int clear_depth;
62062306a36Sopenharmony_ci	unsigned int color_mask;
62162306a36Sopenharmony_ci	unsigned int depth_mask;	/* misnamed field:  should be stencil */
62262306a36Sopenharmony_ci	drm_radeon_clear_rect_t __user *depth_boxes;
62362306a36Sopenharmony_ci} drm_radeon_clear_t;
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_citypedef struct drm_radeon_vertex {
62662306a36Sopenharmony_ci	int prim;
62762306a36Sopenharmony_ci	int idx;		/* Index of vertex buffer */
62862306a36Sopenharmony_ci	int count;		/* Number of vertices in buffer */
62962306a36Sopenharmony_ci	int discard;		/* Client finished with buffer? */
63062306a36Sopenharmony_ci} drm_radeon_vertex_t;
63162306a36Sopenharmony_ci
63262306a36Sopenharmony_citypedef struct drm_radeon_indices {
63362306a36Sopenharmony_ci	int prim;
63462306a36Sopenharmony_ci	int idx;
63562306a36Sopenharmony_ci	int start;
63662306a36Sopenharmony_ci	int end;
63762306a36Sopenharmony_ci	int discard;		/* Client finished with buffer? */
63862306a36Sopenharmony_ci} drm_radeon_indices_t;
63962306a36Sopenharmony_ci
64062306a36Sopenharmony_ci/* v1.2 - obsoletes drm_radeon_vertex and drm_radeon_indices
64162306a36Sopenharmony_ci *      - allows multiple primitives and state changes in a single ioctl
64262306a36Sopenharmony_ci *      - supports driver change to emit native primitives
64362306a36Sopenharmony_ci */
64462306a36Sopenharmony_citypedef struct drm_radeon_vertex2 {
64562306a36Sopenharmony_ci	int idx;		/* Index of vertex buffer */
64662306a36Sopenharmony_ci	int discard;		/* Client finished with buffer? */
64762306a36Sopenharmony_ci	int nr_states;
64862306a36Sopenharmony_ci	drm_radeon_state_t __user *state;
64962306a36Sopenharmony_ci	int nr_prims;
65062306a36Sopenharmony_ci	drm_radeon_prim_t __user *prim;
65162306a36Sopenharmony_ci} drm_radeon_vertex2_t;
65262306a36Sopenharmony_ci
65362306a36Sopenharmony_ci/* v1.3 - obsoletes drm_radeon_vertex2
65462306a36Sopenharmony_ci *      - allows arbitrarily large cliprect list
65562306a36Sopenharmony_ci *      - allows updating of tcl packet, vector and scalar state
65662306a36Sopenharmony_ci *      - allows memory-efficient description of state updates
65762306a36Sopenharmony_ci *      - allows state to be emitted without a primitive
65862306a36Sopenharmony_ci *           (for clears, ctx switches)
65962306a36Sopenharmony_ci *      - allows more than one dma buffer to be referenced per ioctl
66062306a36Sopenharmony_ci *      - supports tcl driver
66162306a36Sopenharmony_ci *      - may be extended in future versions with new cmd types, packets
66262306a36Sopenharmony_ci */
66362306a36Sopenharmony_citypedef struct drm_radeon_cmd_buffer {
66462306a36Sopenharmony_ci	int bufsz;
66562306a36Sopenharmony_ci	char __user *buf;
66662306a36Sopenharmony_ci	int nbox;
66762306a36Sopenharmony_ci	struct drm_clip_rect __user *boxes;
66862306a36Sopenharmony_ci} drm_radeon_cmd_buffer_t;
66962306a36Sopenharmony_ci
67062306a36Sopenharmony_citypedef struct drm_radeon_tex_image {
67162306a36Sopenharmony_ci	unsigned int x, y;	/* Blit coordinates */
67262306a36Sopenharmony_ci	unsigned int width, height;
67362306a36Sopenharmony_ci	const void __user *data;
67462306a36Sopenharmony_ci} drm_radeon_tex_image_t;
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_citypedef struct drm_radeon_texture {
67762306a36Sopenharmony_ci	unsigned int offset;
67862306a36Sopenharmony_ci	int pitch;
67962306a36Sopenharmony_ci	int format;
68062306a36Sopenharmony_ci	int width;		/* Texture image coordinates */
68162306a36Sopenharmony_ci	int height;
68262306a36Sopenharmony_ci	drm_radeon_tex_image_t __user *image;
68362306a36Sopenharmony_ci} drm_radeon_texture_t;
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_citypedef struct drm_radeon_stipple {
68662306a36Sopenharmony_ci	unsigned int __user *mask;
68762306a36Sopenharmony_ci} drm_radeon_stipple_t;
68862306a36Sopenharmony_ci
68962306a36Sopenharmony_citypedef struct drm_radeon_indirect {
69062306a36Sopenharmony_ci	int idx;
69162306a36Sopenharmony_ci	int start;
69262306a36Sopenharmony_ci	int end;
69362306a36Sopenharmony_ci	int discard;
69462306a36Sopenharmony_ci} drm_radeon_indirect_t;
69562306a36Sopenharmony_ci
69662306a36Sopenharmony_ci/* enum for card type parameters */
69762306a36Sopenharmony_ci#define RADEON_CARD_PCI 0
69862306a36Sopenharmony_ci#define RADEON_CARD_AGP 1
69962306a36Sopenharmony_ci#define RADEON_CARD_PCIE 2
70062306a36Sopenharmony_ci
70162306a36Sopenharmony_ci/* 1.3: An ioctl to get parameters that aren't available to the 3d
70262306a36Sopenharmony_ci * client any other way.
70362306a36Sopenharmony_ci */
70462306a36Sopenharmony_ci#define RADEON_PARAM_GART_BUFFER_OFFSET    1	/* card offset of 1st GART buffer */
70562306a36Sopenharmony_ci#define RADEON_PARAM_LAST_FRAME            2
70662306a36Sopenharmony_ci#define RADEON_PARAM_LAST_DISPATCH         3
70762306a36Sopenharmony_ci#define RADEON_PARAM_LAST_CLEAR            4
70862306a36Sopenharmony_ci/* Added with DRM version 1.6. */
70962306a36Sopenharmony_ci#define RADEON_PARAM_IRQ_NR                5
71062306a36Sopenharmony_ci#define RADEON_PARAM_GART_BASE             6	/* card offset of GART base */
71162306a36Sopenharmony_ci/* Added with DRM version 1.8. */
71262306a36Sopenharmony_ci#define RADEON_PARAM_REGISTER_HANDLE       7	/* for drmMap() */
71362306a36Sopenharmony_ci#define RADEON_PARAM_STATUS_HANDLE         8
71462306a36Sopenharmony_ci#define RADEON_PARAM_SAREA_HANDLE          9
71562306a36Sopenharmony_ci#define RADEON_PARAM_GART_TEX_HANDLE       10
71662306a36Sopenharmony_ci#define RADEON_PARAM_SCRATCH_OFFSET        11
71762306a36Sopenharmony_ci#define RADEON_PARAM_CARD_TYPE             12
71862306a36Sopenharmony_ci#define RADEON_PARAM_VBLANK_CRTC           13   /* VBLANK CRTC */
71962306a36Sopenharmony_ci#define RADEON_PARAM_FB_LOCATION           14   /* FB location */
72062306a36Sopenharmony_ci#define RADEON_PARAM_NUM_GB_PIPES          15   /* num GB pipes */
72162306a36Sopenharmony_ci#define RADEON_PARAM_DEVICE_ID             16
72262306a36Sopenharmony_ci#define RADEON_PARAM_NUM_Z_PIPES           17   /* num Z pipes */
72362306a36Sopenharmony_ci
72462306a36Sopenharmony_citypedef struct drm_radeon_getparam {
72562306a36Sopenharmony_ci	int param;
72662306a36Sopenharmony_ci	void __user *value;
72762306a36Sopenharmony_ci} drm_radeon_getparam_t;
72862306a36Sopenharmony_ci
72962306a36Sopenharmony_ci/* 1.6: Set up a memory manager for regions of shared memory:
73062306a36Sopenharmony_ci */
73162306a36Sopenharmony_ci#define RADEON_MEM_REGION_GART 1
73262306a36Sopenharmony_ci#define RADEON_MEM_REGION_FB   2
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_citypedef struct drm_radeon_mem_alloc {
73562306a36Sopenharmony_ci	int region;
73662306a36Sopenharmony_ci	int alignment;
73762306a36Sopenharmony_ci	int size;
73862306a36Sopenharmony_ci	int __user *region_offset;	/* offset from start of fb or GART */
73962306a36Sopenharmony_ci} drm_radeon_mem_alloc_t;
74062306a36Sopenharmony_ci
74162306a36Sopenharmony_citypedef struct drm_radeon_mem_free {
74262306a36Sopenharmony_ci	int region;
74362306a36Sopenharmony_ci	int region_offset;
74462306a36Sopenharmony_ci} drm_radeon_mem_free_t;
74562306a36Sopenharmony_ci
74662306a36Sopenharmony_citypedef struct drm_radeon_mem_init_heap {
74762306a36Sopenharmony_ci	int region;
74862306a36Sopenharmony_ci	int size;
74962306a36Sopenharmony_ci	int start;
75062306a36Sopenharmony_ci} drm_radeon_mem_init_heap_t;
75162306a36Sopenharmony_ci
75262306a36Sopenharmony_ci/* 1.6: Userspace can request & wait on irq's:
75362306a36Sopenharmony_ci */
75462306a36Sopenharmony_citypedef struct drm_radeon_irq_emit {
75562306a36Sopenharmony_ci	int __user *irq_seq;
75662306a36Sopenharmony_ci} drm_radeon_irq_emit_t;
75762306a36Sopenharmony_ci
75862306a36Sopenharmony_citypedef struct drm_radeon_irq_wait {
75962306a36Sopenharmony_ci	int irq_seq;
76062306a36Sopenharmony_ci} drm_radeon_irq_wait_t;
76162306a36Sopenharmony_ci
76262306a36Sopenharmony_ci/* 1.10: Clients tell the DRM where they think the framebuffer is located in
76362306a36Sopenharmony_ci * the card's address space, via a new generic ioctl to set parameters
76462306a36Sopenharmony_ci */
76562306a36Sopenharmony_ci
76662306a36Sopenharmony_citypedef struct drm_radeon_setparam {
76762306a36Sopenharmony_ci	unsigned int param;
76862306a36Sopenharmony_ci	__s64 value;
76962306a36Sopenharmony_ci} drm_radeon_setparam_t;
77062306a36Sopenharmony_ci
77162306a36Sopenharmony_ci#define RADEON_SETPARAM_FB_LOCATION    1	/* determined framebuffer location */
77262306a36Sopenharmony_ci#define RADEON_SETPARAM_SWITCH_TILING  2	/* enable/disable color tiling */
77362306a36Sopenharmony_ci#define RADEON_SETPARAM_PCIGART_LOCATION 3	/* PCI Gart Location */
77462306a36Sopenharmony_ci#define RADEON_SETPARAM_NEW_MEMMAP 4		/* Use new memory map */
77562306a36Sopenharmony_ci#define RADEON_SETPARAM_PCIGART_TABLE_SIZE 5    /* PCI GART Table Size */
77662306a36Sopenharmony_ci#define RADEON_SETPARAM_VBLANK_CRTC 6           /* VBLANK CRTC */
77762306a36Sopenharmony_ci/* 1.14: Clients can allocate/free a surface
77862306a36Sopenharmony_ci */
77962306a36Sopenharmony_citypedef struct drm_radeon_surface_alloc {
78062306a36Sopenharmony_ci	unsigned int address;
78162306a36Sopenharmony_ci	unsigned int size;
78262306a36Sopenharmony_ci	unsigned int flags;
78362306a36Sopenharmony_ci} drm_radeon_surface_alloc_t;
78462306a36Sopenharmony_ci
78562306a36Sopenharmony_citypedef struct drm_radeon_surface_free {
78662306a36Sopenharmony_ci	unsigned int address;
78762306a36Sopenharmony_ci} drm_radeon_surface_free_t;
78862306a36Sopenharmony_ci
78962306a36Sopenharmony_ci#define	DRM_RADEON_VBLANK_CRTC1		1
79062306a36Sopenharmony_ci#define	DRM_RADEON_VBLANK_CRTC2		2
79162306a36Sopenharmony_ci
79262306a36Sopenharmony_ci/*
79362306a36Sopenharmony_ci * Kernel modesetting world below.
79462306a36Sopenharmony_ci */
79562306a36Sopenharmony_ci#define RADEON_GEM_DOMAIN_CPU		0x1
79662306a36Sopenharmony_ci#define RADEON_GEM_DOMAIN_GTT		0x2
79762306a36Sopenharmony_ci#define RADEON_GEM_DOMAIN_VRAM		0x4
79862306a36Sopenharmony_ci
79962306a36Sopenharmony_cistruct drm_radeon_gem_info {
80062306a36Sopenharmony_ci	__u64	gart_size;
80162306a36Sopenharmony_ci	__u64	vram_size;
80262306a36Sopenharmony_ci	__u64	vram_visible;
80362306a36Sopenharmony_ci};
80462306a36Sopenharmony_ci
80562306a36Sopenharmony_ci#define RADEON_GEM_NO_BACKING_STORE	(1 << 0)
80662306a36Sopenharmony_ci#define RADEON_GEM_GTT_UC		(1 << 1)
80762306a36Sopenharmony_ci#define RADEON_GEM_GTT_WC		(1 << 2)
80862306a36Sopenharmony_ci/* BO is expected to be accessed by the CPU */
80962306a36Sopenharmony_ci#define RADEON_GEM_CPU_ACCESS		(1 << 3)
81062306a36Sopenharmony_ci/* CPU access is not expected to work for this BO */
81162306a36Sopenharmony_ci#define RADEON_GEM_NO_CPU_ACCESS	(1 << 4)
81262306a36Sopenharmony_ci
81362306a36Sopenharmony_cistruct drm_radeon_gem_create {
81462306a36Sopenharmony_ci	__u64	size;
81562306a36Sopenharmony_ci	__u64	alignment;
81662306a36Sopenharmony_ci	__u32	handle;
81762306a36Sopenharmony_ci	__u32	initial_domain;
81862306a36Sopenharmony_ci	__u32	flags;
81962306a36Sopenharmony_ci};
82062306a36Sopenharmony_ci
82162306a36Sopenharmony_ci/*
82262306a36Sopenharmony_ci * This is not a reliable API and you should expect it to fail for any
82362306a36Sopenharmony_ci * number of reasons and have fallback path that do not use userptr to
82462306a36Sopenharmony_ci * perform any operation.
82562306a36Sopenharmony_ci */
82662306a36Sopenharmony_ci#define RADEON_GEM_USERPTR_READONLY	(1 << 0)
82762306a36Sopenharmony_ci#define RADEON_GEM_USERPTR_ANONONLY	(1 << 1)
82862306a36Sopenharmony_ci#define RADEON_GEM_USERPTR_VALIDATE	(1 << 2)
82962306a36Sopenharmony_ci#define RADEON_GEM_USERPTR_REGISTER	(1 << 3)
83062306a36Sopenharmony_ci
83162306a36Sopenharmony_cistruct drm_radeon_gem_userptr {
83262306a36Sopenharmony_ci	__u64		addr;
83362306a36Sopenharmony_ci	__u64		size;
83462306a36Sopenharmony_ci	__u32		flags;
83562306a36Sopenharmony_ci	__u32		handle;
83662306a36Sopenharmony_ci};
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_ci#define RADEON_TILING_MACRO				0x1
83962306a36Sopenharmony_ci#define RADEON_TILING_MICRO				0x2
84062306a36Sopenharmony_ci#define RADEON_TILING_SWAP_16BIT			0x4
84162306a36Sopenharmony_ci#define RADEON_TILING_SWAP_32BIT			0x8
84262306a36Sopenharmony_ci/* this object requires a surface when mapped - i.e. front buffer */
84362306a36Sopenharmony_ci#define RADEON_TILING_SURFACE				0x10
84462306a36Sopenharmony_ci#define RADEON_TILING_MICRO_SQUARE			0x20
84562306a36Sopenharmony_ci#define RADEON_TILING_EG_BANKW_SHIFT			8
84662306a36Sopenharmony_ci#define RADEON_TILING_EG_BANKW_MASK			0xf
84762306a36Sopenharmony_ci#define RADEON_TILING_EG_BANKH_SHIFT			12
84862306a36Sopenharmony_ci#define RADEON_TILING_EG_BANKH_MASK			0xf
84962306a36Sopenharmony_ci#define RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT	16
85062306a36Sopenharmony_ci#define RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK		0xf
85162306a36Sopenharmony_ci#define RADEON_TILING_EG_TILE_SPLIT_SHIFT		24
85262306a36Sopenharmony_ci#define RADEON_TILING_EG_TILE_SPLIT_MASK		0xf
85362306a36Sopenharmony_ci#define RADEON_TILING_EG_STENCIL_TILE_SPLIT_SHIFT	28
85462306a36Sopenharmony_ci#define RADEON_TILING_EG_STENCIL_TILE_SPLIT_MASK	0xf
85562306a36Sopenharmony_ci
85662306a36Sopenharmony_cistruct drm_radeon_gem_set_tiling {
85762306a36Sopenharmony_ci	__u32	handle;
85862306a36Sopenharmony_ci	__u32	tiling_flags;
85962306a36Sopenharmony_ci	__u32	pitch;
86062306a36Sopenharmony_ci};
86162306a36Sopenharmony_ci
86262306a36Sopenharmony_cistruct drm_radeon_gem_get_tiling {
86362306a36Sopenharmony_ci	__u32	handle;
86462306a36Sopenharmony_ci	__u32	tiling_flags;
86562306a36Sopenharmony_ci	__u32	pitch;
86662306a36Sopenharmony_ci};
86762306a36Sopenharmony_ci
86862306a36Sopenharmony_cistruct drm_radeon_gem_mmap {
86962306a36Sopenharmony_ci	__u32	handle;
87062306a36Sopenharmony_ci	__u32	pad;
87162306a36Sopenharmony_ci	__u64	offset;
87262306a36Sopenharmony_ci	__u64	size;
87362306a36Sopenharmony_ci	__u64	addr_ptr;
87462306a36Sopenharmony_ci};
87562306a36Sopenharmony_ci
87662306a36Sopenharmony_cistruct drm_radeon_gem_set_domain {
87762306a36Sopenharmony_ci	__u32	handle;
87862306a36Sopenharmony_ci	__u32	read_domains;
87962306a36Sopenharmony_ci	__u32	write_domain;
88062306a36Sopenharmony_ci};
88162306a36Sopenharmony_ci
88262306a36Sopenharmony_cistruct drm_radeon_gem_wait_idle {
88362306a36Sopenharmony_ci	__u32	handle;
88462306a36Sopenharmony_ci	__u32	pad;
88562306a36Sopenharmony_ci};
88662306a36Sopenharmony_ci
88762306a36Sopenharmony_cistruct drm_radeon_gem_busy {
88862306a36Sopenharmony_ci	__u32	handle;
88962306a36Sopenharmony_ci	__u32        domain;
89062306a36Sopenharmony_ci};
89162306a36Sopenharmony_ci
89262306a36Sopenharmony_cistruct drm_radeon_gem_pread {
89362306a36Sopenharmony_ci	/** Handle for the object being read. */
89462306a36Sopenharmony_ci	__u32 handle;
89562306a36Sopenharmony_ci	__u32 pad;
89662306a36Sopenharmony_ci	/** Offset into the object to read from */
89762306a36Sopenharmony_ci	__u64 offset;
89862306a36Sopenharmony_ci	/** Length of data to read */
89962306a36Sopenharmony_ci	__u64 size;
90062306a36Sopenharmony_ci	/** Pointer to write the data into. */
90162306a36Sopenharmony_ci	/* void *, but pointers are not 32/64 compatible */
90262306a36Sopenharmony_ci	__u64 data_ptr;
90362306a36Sopenharmony_ci};
90462306a36Sopenharmony_ci
90562306a36Sopenharmony_cistruct drm_radeon_gem_pwrite {
90662306a36Sopenharmony_ci	/** Handle for the object being written to. */
90762306a36Sopenharmony_ci	__u32 handle;
90862306a36Sopenharmony_ci	__u32 pad;
90962306a36Sopenharmony_ci	/** Offset into the object to write to */
91062306a36Sopenharmony_ci	__u64 offset;
91162306a36Sopenharmony_ci	/** Length of data to write */
91262306a36Sopenharmony_ci	__u64 size;
91362306a36Sopenharmony_ci	/** Pointer to read the data from. */
91462306a36Sopenharmony_ci	/* void *, but pointers are not 32/64 compatible */
91562306a36Sopenharmony_ci	__u64 data_ptr;
91662306a36Sopenharmony_ci};
91762306a36Sopenharmony_ci
91862306a36Sopenharmony_ci/* Sets or returns a value associated with a buffer. */
91962306a36Sopenharmony_cistruct drm_radeon_gem_op {
92062306a36Sopenharmony_ci	__u32	handle; /* buffer */
92162306a36Sopenharmony_ci	__u32	op;     /* RADEON_GEM_OP_* */
92262306a36Sopenharmony_ci	__u64	value;  /* input or return value */
92362306a36Sopenharmony_ci};
92462306a36Sopenharmony_ci
92562306a36Sopenharmony_ci#define RADEON_GEM_OP_GET_INITIAL_DOMAIN	0
92662306a36Sopenharmony_ci#define RADEON_GEM_OP_SET_INITIAL_DOMAIN	1
92762306a36Sopenharmony_ci
92862306a36Sopenharmony_ci#define RADEON_VA_MAP			1
92962306a36Sopenharmony_ci#define RADEON_VA_UNMAP			2
93062306a36Sopenharmony_ci
93162306a36Sopenharmony_ci#define RADEON_VA_RESULT_OK		0
93262306a36Sopenharmony_ci#define RADEON_VA_RESULT_ERROR		1
93362306a36Sopenharmony_ci#define RADEON_VA_RESULT_VA_EXIST	2
93462306a36Sopenharmony_ci
93562306a36Sopenharmony_ci#define RADEON_VM_PAGE_VALID		(1 << 0)
93662306a36Sopenharmony_ci#define RADEON_VM_PAGE_READABLE		(1 << 1)
93762306a36Sopenharmony_ci#define RADEON_VM_PAGE_WRITEABLE	(1 << 2)
93862306a36Sopenharmony_ci#define RADEON_VM_PAGE_SYSTEM		(1 << 3)
93962306a36Sopenharmony_ci#define RADEON_VM_PAGE_SNOOPED		(1 << 4)
94062306a36Sopenharmony_ci
94162306a36Sopenharmony_cistruct drm_radeon_gem_va {
94262306a36Sopenharmony_ci	__u32		handle;
94362306a36Sopenharmony_ci	__u32		operation;
94462306a36Sopenharmony_ci	__u32		vm_id;
94562306a36Sopenharmony_ci	__u32		flags;
94662306a36Sopenharmony_ci	__u64		offset;
94762306a36Sopenharmony_ci};
94862306a36Sopenharmony_ci
94962306a36Sopenharmony_ci#define RADEON_CHUNK_ID_RELOCS	0x01
95062306a36Sopenharmony_ci#define RADEON_CHUNK_ID_IB	0x02
95162306a36Sopenharmony_ci#define RADEON_CHUNK_ID_FLAGS	0x03
95262306a36Sopenharmony_ci#define RADEON_CHUNK_ID_CONST_IB	0x04
95362306a36Sopenharmony_ci
95462306a36Sopenharmony_ci/* The first dword of RADEON_CHUNK_ID_FLAGS is a uint32 of these flags: */
95562306a36Sopenharmony_ci#define RADEON_CS_KEEP_TILING_FLAGS 0x01
95662306a36Sopenharmony_ci#define RADEON_CS_USE_VM            0x02
95762306a36Sopenharmony_ci#define RADEON_CS_END_OF_FRAME      0x04 /* a hint from userspace which CS is the last one */
95862306a36Sopenharmony_ci/* The second dword of RADEON_CHUNK_ID_FLAGS is a uint32 that sets the ring type */
95962306a36Sopenharmony_ci#define RADEON_CS_RING_GFX          0
96062306a36Sopenharmony_ci#define RADEON_CS_RING_COMPUTE      1
96162306a36Sopenharmony_ci#define RADEON_CS_RING_DMA          2
96262306a36Sopenharmony_ci#define RADEON_CS_RING_UVD          3
96362306a36Sopenharmony_ci#define RADEON_CS_RING_VCE          4
96462306a36Sopenharmony_ci/* The third dword of RADEON_CHUNK_ID_FLAGS is a sint32 that sets the priority */
96562306a36Sopenharmony_ci/* 0 = normal, + = higher priority, - = lower priority */
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_cistruct drm_radeon_cs_chunk {
96862306a36Sopenharmony_ci	__u32		chunk_id;
96962306a36Sopenharmony_ci	__u32		length_dw;
97062306a36Sopenharmony_ci	__u64		chunk_data;
97162306a36Sopenharmony_ci};
97262306a36Sopenharmony_ci
97362306a36Sopenharmony_ci/* drm_radeon_cs_reloc.flags */
97462306a36Sopenharmony_ci#define RADEON_RELOC_PRIO_MASK		(0xf << 0)
97562306a36Sopenharmony_ci
97662306a36Sopenharmony_cistruct drm_radeon_cs_reloc {
97762306a36Sopenharmony_ci	__u32		handle;
97862306a36Sopenharmony_ci	__u32		read_domains;
97962306a36Sopenharmony_ci	__u32		write_domain;
98062306a36Sopenharmony_ci	__u32		flags;
98162306a36Sopenharmony_ci};
98262306a36Sopenharmony_ci
98362306a36Sopenharmony_cistruct drm_radeon_cs {
98462306a36Sopenharmony_ci	__u32		num_chunks;
98562306a36Sopenharmony_ci	__u32		cs_id;
98662306a36Sopenharmony_ci	/* this points to __u64 * which point to cs chunks */
98762306a36Sopenharmony_ci	__u64		chunks;
98862306a36Sopenharmony_ci	/* updates to the limits after this CS ioctl */
98962306a36Sopenharmony_ci	__u64		gart_limit;
99062306a36Sopenharmony_ci	__u64		vram_limit;
99162306a36Sopenharmony_ci};
99262306a36Sopenharmony_ci
99362306a36Sopenharmony_ci#define RADEON_INFO_DEVICE_ID		0x00
99462306a36Sopenharmony_ci#define RADEON_INFO_NUM_GB_PIPES	0x01
99562306a36Sopenharmony_ci#define RADEON_INFO_NUM_Z_PIPES 	0x02
99662306a36Sopenharmony_ci#define RADEON_INFO_ACCEL_WORKING	0x03
99762306a36Sopenharmony_ci#define RADEON_INFO_CRTC_FROM_ID	0x04
99862306a36Sopenharmony_ci#define RADEON_INFO_ACCEL_WORKING2	0x05
99962306a36Sopenharmony_ci#define RADEON_INFO_TILING_CONFIG	0x06
100062306a36Sopenharmony_ci#define RADEON_INFO_WANT_HYPERZ		0x07
100162306a36Sopenharmony_ci#define RADEON_INFO_WANT_CMASK		0x08 /* get access to CMASK on r300 */
100262306a36Sopenharmony_ci#define RADEON_INFO_CLOCK_CRYSTAL_FREQ	0x09 /* clock crystal frequency */
100362306a36Sopenharmony_ci#define RADEON_INFO_NUM_BACKENDS	0x0a /* DB/backends for r600+ - need for OQ */
100462306a36Sopenharmony_ci#define RADEON_INFO_NUM_TILE_PIPES	0x0b /* tile pipes for r600+ */
100562306a36Sopenharmony_ci#define RADEON_INFO_FUSION_GART_WORKING	0x0c /* fusion writes to GTT were broken before this */
100662306a36Sopenharmony_ci#define RADEON_INFO_BACKEND_MAP		0x0d /* pipe to backend map, needed by mesa */
100762306a36Sopenharmony_ci/* virtual address start, va < start are reserved by the kernel */
100862306a36Sopenharmony_ci#define RADEON_INFO_VA_START		0x0e
100962306a36Sopenharmony_ci/* maximum size of ib using the virtual memory cs */
101062306a36Sopenharmony_ci#define RADEON_INFO_IB_VM_MAX_SIZE	0x0f
101162306a36Sopenharmony_ci/* max pipes - needed for compute shaders */
101262306a36Sopenharmony_ci#define RADEON_INFO_MAX_PIPES		0x10
101362306a36Sopenharmony_ci/* timestamp for GL_ARB_timer_query (OpenGL), returns the current GPU clock */
101462306a36Sopenharmony_ci#define RADEON_INFO_TIMESTAMP		0x11
101562306a36Sopenharmony_ci/* max shader engines (SE) - needed for geometry shaders, etc. */
101662306a36Sopenharmony_ci#define RADEON_INFO_MAX_SE		0x12
101762306a36Sopenharmony_ci/* max SH per SE */
101862306a36Sopenharmony_ci#define RADEON_INFO_MAX_SH_PER_SE	0x13
101962306a36Sopenharmony_ci/* fast fb access is enabled */
102062306a36Sopenharmony_ci#define RADEON_INFO_FASTFB_WORKING	0x14
102162306a36Sopenharmony_ci/* query if a RADEON_CS_RING_* submission is supported */
102262306a36Sopenharmony_ci#define RADEON_INFO_RING_WORKING	0x15
102362306a36Sopenharmony_ci/* SI tile mode array */
102462306a36Sopenharmony_ci#define RADEON_INFO_SI_TILE_MODE_ARRAY	0x16
102562306a36Sopenharmony_ci/* query if CP DMA is supported on the compute ring */
102662306a36Sopenharmony_ci#define RADEON_INFO_SI_CP_DMA_COMPUTE	0x17
102762306a36Sopenharmony_ci/* CIK macrotile mode array */
102862306a36Sopenharmony_ci#define RADEON_INFO_CIK_MACROTILE_MODE_ARRAY	0x18
102962306a36Sopenharmony_ci/* query the number of render backends */
103062306a36Sopenharmony_ci#define RADEON_INFO_SI_BACKEND_ENABLED_MASK	0x19
103162306a36Sopenharmony_ci/* max engine clock - needed for OpenCL */
103262306a36Sopenharmony_ci#define RADEON_INFO_MAX_SCLK		0x1a
103362306a36Sopenharmony_ci/* version of VCE firmware */
103462306a36Sopenharmony_ci#define RADEON_INFO_VCE_FW_VERSION	0x1b
103562306a36Sopenharmony_ci/* version of VCE feedback */
103662306a36Sopenharmony_ci#define RADEON_INFO_VCE_FB_VERSION	0x1c
103762306a36Sopenharmony_ci#define RADEON_INFO_NUM_BYTES_MOVED	0x1d
103862306a36Sopenharmony_ci#define RADEON_INFO_VRAM_USAGE		0x1e
103962306a36Sopenharmony_ci#define RADEON_INFO_GTT_USAGE		0x1f
104062306a36Sopenharmony_ci#define RADEON_INFO_ACTIVE_CU_COUNT	0x20
104162306a36Sopenharmony_ci#define RADEON_INFO_CURRENT_GPU_TEMP	0x21
104262306a36Sopenharmony_ci#define RADEON_INFO_CURRENT_GPU_SCLK	0x22
104362306a36Sopenharmony_ci#define RADEON_INFO_CURRENT_GPU_MCLK	0x23
104462306a36Sopenharmony_ci#define RADEON_INFO_READ_REG		0x24
104562306a36Sopenharmony_ci#define RADEON_INFO_VA_UNMAP_WORKING	0x25
104662306a36Sopenharmony_ci#define RADEON_INFO_GPU_RESET_COUNTER	0x26
104762306a36Sopenharmony_ci
104862306a36Sopenharmony_cistruct drm_radeon_info {
104962306a36Sopenharmony_ci	__u32		request;
105062306a36Sopenharmony_ci	__u32		pad;
105162306a36Sopenharmony_ci	__u64		value;
105262306a36Sopenharmony_ci};
105362306a36Sopenharmony_ci
105462306a36Sopenharmony_ci/* Those correspond to the tile index to use, this is to explicitly state
105562306a36Sopenharmony_ci * the API that is implicitly defined by the tile mode array.
105662306a36Sopenharmony_ci */
105762306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_LINEAR_ALIGNED	8
105862306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_1D			13
105962306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_1D_SCANOUT		9
106062306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_2D_8BPP		14
106162306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_2D_16BPP		15
106262306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_2D_32BPP		16
106362306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_2D_64BPP		17
106462306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_2D_SCANOUT_16BPP	11
106562306a36Sopenharmony_ci#define SI_TILE_MODE_COLOR_2D_SCANOUT_32BPP	12
106662306a36Sopenharmony_ci#define SI_TILE_MODE_DEPTH_STENCIL_1D		4
106762306a36Sopenharmony_ci#define SI_TILE_MODE_DEPTH_STENCIL_2D		0
106862306a36Sopenharmony_ci#define SI_TILE_MODE_DEPTH_STENCIL_2D_2AA	3
106962306a36Sopenharmony_ci#define SI_TILE_MODE_DEPTH_STENCIL_2D_4AA	3
107062306a36Sopenharmony_ci#define SI_TILE_MODE_DEPTH_STENCIL_2D_8AA	2
107162306a36Sopenharmony_ci
107262306a36Sopenharmony_ci#define CIK_TILE_MODE_DEPTH_STENCIL_1D		5
107362306a36Sopenharmony_ci
107462306a36Sopenharmony_ci#if defined(__cplusplus)
107562306a36Sopenharmony_ci}
107662306a36Sopenharmony_ci#endif
107762306a36Sopenharmony_ci
107862306a36Sopenharmony_ci#endif
1079