summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/r600/drm/radeon_priv.h
blob: 6bd8d9850f50e05ce7f13b2cd50e301e09f30bb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright © 2009 Jerome Glisse <glisse@freedesktop.org>
 *
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef RADEON_PRIV_H
#define RADEON_PRIV_H

#include <stdint.h>
#include "xf86drm.h"
#include "xf86drmMode.h"
#include <errno.h>
#include "radeon.h"

#include "pipe/p_compiler.h"
#include "util/u_inlines.h"
#include "pipe/p_defines.h"

struct radeon;
struct radeon_ctx;


/*
 * radeon functions
 */
typedef int (*radeon_state_pm4_t)(struct radeon_state *state);
struct radeon_register {
	unsigned			offset;
	unsigned			need_reloc;
	unsigned			bo_id;
	char				name[64];
};

struct radeon_bo {
	struct pipe_reference           reference;
	unsigned			handle;
	unsigned			size;
	unsigned			alignment;
	unsigned			map_count;
	void				*data;
};

struct radeon_sub_type {
	int				shader_type;
	const struct radeon_register	*regs;
	unsigned			nstates;
};

struct radeon_stype_info {
	unsigned			stype;
	unsigned			num;
	unsigned			stride;
	radeon_state_pm4_t		pm4;
	struct radeon_sub_type		reginfo[R600_SHADER_MAX];
	unsigned			base_id;
	unsigned			npm4;
};

struct radeon_ctx {
	struct radeon			*radeon;
	u32				*pm4;
	int				cdwords;
	int				ndwords;
	unsigned			nreloc;
	struct radeon_cs_reloc		*reloc;
	unsigned			nbo;
	struct radeon_ws_bo		**bo;
};

struct radeon {
	int				fd;
	int				refcount;
	unsigned			device;
	unsigned			family;
	unsigned			nstype;
	struct radeon_stype_info	*stype;
	unsigned max_states;
};

struct radeon_ws_bo {
	struct pipe_reference reference;
	struct radeon_bo *bo;
};

extern struct radeon *radeon_new(int fd, unsigned device);
extern struct radeon *radeon_incref(struct radeon *radeon);
extern struct radeon *radeon_decref(struct radeon *radeon);
extern unsigned radeon_family_from_device(unsigned device);
extern int radeon_is_family_compatible(unsigned family1, unsigned family2);

/*
 * r600/r700 context functions
 */
extern int r600_init(struct radeon *radeon);
extern int r600_ctx_draw(struct radeon_ctx *ctx);
extern int r600_ctx_next_reloc(struct radeon_ctx *ctx, unsigned *reloc);

/*
 * radeon state functions
 */
extern u32 radeon_state_register_get(struct radeon_state *state, unsigned offset);
extern int radeon_state_register_set(struct radeon_state *state, unsigned offset, u32 value);
extern struct radeon_state *radeon_state_duplicate(struct radeon_state *state);
extern int radeon_state_replace_always(struct radeon_state *ostate, struct radeon_state *nstate);
extern int radeon_state_pm4_generic(struct radeon_state *state);
extern int radeon_state_reloc(struct radeon_state *state, unsigned id, unsigned bo_id);

/*
 * radeon draw functions
 */
extern int radeon_draw_pm4(struct radeon_draw *draw);

/* bo */
struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
			    unsigned size, unsigned alignment, void *ptr);
int radeon_bo_map(struct radeon *radeon, struct radeon_bo *bo);
void radeon_bo_unmap(struct radeon *radeon, struct radeon_bo *bo);
void radeon_bo_reference(struct radeon *radeon, struct radeon_bo **dst,
			 struct radeon_bo *src);
int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);

#endif