r600g: adapt to latest interfaces changes
[mesa.git] / src / gallium / winsys / r600 / drm / radeon_priv.h
1 /*
2 * Copyright © 2009 Jerome Glisse <glisse@freedesktop.org>
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17 #ifndef RADEON_PRIV_H
18 #define RADEON_PRIV_H
19
20 #include <stdint.h>
21 #include "xf86drm.h"
22 #include "xf86drmMode.h"
23 #include <errno.h>
24 #include "radeon.h"
25
26 struct radeon;
27 struct radeon_ctx;
28
29 /*
30 * radeon functions
31 */
32 typedef int (*radeon_state_pm4_t)(struct radeon_state *state);
33 struct radeon_register {
34 unsigned offset;
35 unsigned need_reloc;
36 unsigned bo_id;
37 char name[64];
38 };
39
40 struct radeon_type {
41 unsigned npm4;
42 unsigned id;
43 unsigned range_start;
44 unsigned range_end;
45 unsigned stride;
46 unsigned immediate;
47 char name[64];
48 unsigned nstates;
49 radeon_state_pm4_t pm4;
50 const struct radeon_register *regs;
51 };
52
53 struct radeon {
54 int fd;
55 int refcount;
56 unsigned device;
57 unsigned family;
58 unsigned nstate;
59 unsigned ntype;
60 const struct radeon_type *type;
61 };
62
63 extern struct radeon *radeon_new(int fd, unsigned device);
64 extern struct radeon *radeon_incref(struct radeon *radeon);
65 extern struct radeon *radeon_decref(struct radeon *radeon);
66 extern unsigned radeon_family_from_device(unsigned device);
67 extern int radeon_is_family_compatible(unsigned family1, unsigned family2);
68 extern int radeon_reg_id(struct radeon *radeon, unsigned offset, unsigned *typeid, unsigned *stateid, unsigned *id);
69 extern unsigned radeon_type_from_id(struct radeon *radeon, unsigned id);
70
71 /*
72 * radeon context functions
73 */
74 #pragma pack(1)
75 struct radeon_cs_reloc {
76 uint32_t handle;
77 uint32_t read_domain;
78 uint32_t write_domain;
79 uint32_t flags;
80 };
81 #pragma pack()
82
83 struct radeon_ctx {
84 int refcount;
85 struct radeon *radeon;
86 u32 *pm4;
87 u32 cpm4;
88 u32 draw_cpm4;
89 unsigned id;
90 unsigned next_id;
91 unsigned nreloc;
92 struct radeon_cs_reloc *reloc;
93 unsigned nbo;
94 struct radeon_bo **bo;
95 unsigned ndraw;
96 struct radeon_draw *cdraw;
97 struct radeon_draw **draw;
98 unsigned nstate;
99 struct radeon_state **state;
100 };
101
102 int radeon_ctx_set_bo_new(struct radeon_ctx *ctx, struct radeon_bo *bo);
103 struct radeon_bo *radeon_ctx_get_bo(struct radeon_ctx *ctx, unsigned reloc);
104 void radeon_ctx_get_placement(struct radeon_ctx *ctx, unsigned reloc, u32 *placement);
105 int radeon_ctx_set_draw_new(struct radeon_ctx *ctx, struct radeon_draw *draw);
106 int radeon_ctx_draw(struct radeon_ctx *ctx);
107
108 /*
109 * r600/r700 context functions
110 */
111 extern int r600_init(struct radeon *radeon);
112 extern int r600_ctx_draw(struct radeon_ctx *ctx);
113 extern int r600_ctx_next_reloc(struct radeon_ctx *ctx, unsigned *reloc);
114
115 /*
116 * radeon state functions
117 */
118 extern u32 radeon_state_register_get(struct radeon_state *state, unsigned offset);
119 extern int radeon_state_register_set(struct radeon_state *state, unsigned offset, u32 value);
120 extern struct radeon_state *radeon_state_duplicate(struct radeon_state *state);
121 extern int radeon_state_replace_always(struct radeon_state *ostate, struct radeon_state *nstate);
122 extern int radeon_state_pm4_generic(struct radeon_state *state);
123 extern int radeon_state_reloc(struct radeon_state *state, unsigned id, unsigned bo_id);
124
125 /*
126 * radeon draw functions
127 */
128 extern int radeon_draw_pm4(struct radeon_draw *draw);
129
130 #endif