469a5dce012d8d3dc8552cbad8430734a450860c
[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
34 struct radeon_type {
35 const u32 *header_pm4;
36 const u32 header_cpm4;
37 const u32 *state_pm4;
38 const u32 state_cpm4;
39 const u32 flush_flags;
40 const u32 dirty_flags;
41 };
42
43 typedef int (*radeon_ctx_bo_flush_t)(struct radeon_ctx *ctx, struct radeon_bo *bo, u32 flags, u32 *placement);
44
45 struct radeon {
46 int fd;
47 int refcount;
48 unsigned device;
49 unsigned family;
50 unsigned nstate;
51 const struct radeon_type *type;
52 radeon_ctx_bo_flush_t bo_flush;
53 };
54
55 extern struct radeon *radeon_new(int fd, unsigned device);
56 extern struct radeon *radeon_incref(struct radeon *radeon);
57 extern struct radeon *radeon_decref(struct radeon *radeon);
58 extern unsigned radeon_family_from_device(unsigned device);
59 extern int radeon_is_family_compatible(unsigned family1, unsigned family2);
60 extern int radeon_reg_id(struct radeon *radeon, unsigned offset, unsigned *typeid, unsigned *stateid, unsigned *id);
61 extern unsigned radeon_type_from_id(struct radeon *radeon, unsigned id);
62
63 int radeon_ctx_draw(struct radeon_ctx *ctx);
64 int radeon_ctx_reloc(struct radeon_ctx *ctx, struct radeon_bo *bo,
65 unsigned id, unsigned *placement);
66
67 /*
68 * r600/r700 context functions
69 */
70 extern int r600_init(struct radeon *radeon);
71 extern int r600_ctx_draw(struct radeon_ctx *ctx);
72 extern int r600_ctx_next_reloc(struct radeon_ctx *ctx, unsigned *reloc);
73
74 /*
75 * radeon state functions
76 */
77 extern u32 radeon_state_register_get(struct radeon_state *state, unsigned offset);
78 extern int radeon_state_register_set(struct radeon_state *state, unsigned offset, u32 value);
79 extern struct radeon_state *radeon_state_duplicate(struct radeon_state *state);
80 extern int radeon_state_replace_always(struct radeon_state *ostate, struct radeon_state *nstate);
81 extern int radeon_state_pm4_generic(struct radeon_state *state);
82
83 /*
84 * radeon draw functions
85 */
86 extern int radeon_draw_pm4(struct radeon_draw *draw);
87
88 #endif