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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
/*
* Copyright 2007 Nouveau Project
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __NOUVEAU_DRMIF_H__
#define __NOUVEAU_DRMIF_H__
#include <stdint.h>
#include <xf86drm.h>
#include <nouveau_drm.h>
#include "nouveau_device.h"
#include "pipe/nouveau/nouveau_channel.h"
#include "pipe/nouveau/nouveau_grobj.h"
#include "pipe/nouveau/nouveau_notifier.h"
#include "pipe/nouveau/nouveau_bo.h"
struct nouveau_device_priv {
struct nouveau_device base;
int fd;
drm_context_t ctx;
drmLock *lock;
int needs_close;
struct {
struct nouveau_channel *channel;
struct nouveau_notifier *notify;
struct nouveau_grobj *m2mf;
} bufmgr;
};
#define nouveau_device(n) ((struct nouveau_device_priv *)(n))
extern int
nouveau_device_open_existing(struct nouveau_device **, int close,
int fd, drm_context_t ctx);
extern int
nouveau_device_open(struct nouveau_device **, const char *busid);
extern void
nouveau_device_close(struct nouveau_device **);
extern int
nouveau_device_get_param(struct nouveau_device *, uint64_t param, uint64_t *v);
extern int
nouveau_device_set_param(struct nouveau_device *, uint64_t param, uint64_t val);
struct nouveau_channel_priv {
struct nouveau_channel base;
struct drm_nouveau_channel_alloc drm;
struct {
struct nouveau_grobj *grobj;
uint32_t seq;
} subchannel[8];
uint32_t subc_sequence;
uint32_t *pushbuf;
void *notifier_block;
volatile uint32_t *user;
volatile uint32_t *put;
volatile uint32_t *get;
volatile uint32_t *ref_cnt;
struct {
uint32_t base, max;
uint32_t cur, put;
uint32_t free;
int push_free;
} dma;
struct {
struct nouveau_bo_priv *bo;
uint32_t flags;
} buffers[128];
int nr_buffers;
struct nouveau_bo_reloc *relocs;
int num_relocs;
int max_relocs;
};
#define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
extern int
nouveau_channel_alloc(struct nouveau_device *, uint32_t fb, uint32_t tt,
struct nouveau_channel **);
extern void
nouveau_channel_free(struct nouveau_channel **);
struct nouveau_grobj_priv {
struct nouveau_grobj base;
};
#define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
extern int nouveau_grobj_alloc(struct nouveau_channel *, uint32_t handle,
int class, struct nouveau_grobj **);
extern int nouveau_grobj_ref(struct nouveau_channel *, uint32_t handle,
struct nouveau_grobj **);
extern void nouveau_grobj_free(struct nouveau_grobj **);
struct nouveau_notifier_priv {
struct nouveau_notifier base;
struct drm_nouveau_notifierobj_alloc drm;
volatile void *map;
};
#define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
extern int
nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle, int count,
struct nouveau_notifier **);
extern void
nouveau_notifier_free(struct nouveau_notifier **);
extern void
nouveau_notifier_reset(struct nouveau_notifier *, int id);
extern uint32_t
nouveau_notifier_status(struct nouveau_notifier *, int id);
extern uint32_t
nouveau_notifier_return_val(struct nouveau_notifier *, int id);
extern int
nouveau_notifier_wait_status(struct nouveau_notifier *, int id, int status,
int timeout);
struct nouveau_bo_priv {
struct nouveau_bo base;
struct drm_nouveau_mem_alloc drm;
void *map;
void *sysmem;
int user;
int refcount;
};
struct nouveau_bo_reloc {
struct nouveau_bo_priv *bo;
uint32_t *ptr;
uint32_t flags;
uint32_t data, vor, tor;
};
#define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
extern int
nouveau_bo_init(struct nouveau_device *);
extern void
nouveau_bo_takedown(struct nouveau_device *);
extern int
nouveau_bo_new(struct nouveau_device *, uint32_t flags, int align, int size,
struct nouveau_bo **);
extern int
nouveau_bo_user(struct nouveau_device *, void *ptr, int size,
struct nouveau_bo **);
extern int
nouveau_bo_ref(struct nouveau_device *, uint64_t handle, struct nouveau_bo **);
extern int
nouveau_bo_resize(struct nouveau_bo *, int size);
extern void
nouveau_bo_del(struct nouveau_bo **);
extern int
nouveau_bo_map(struct nouveau_bo *, uint32_t flags);
extern void
nouveau_bo_unmap(struct nouveau_bo *);
extern void
nouveau_bo_emit_reloc(struct nouveau_channel *chan, void *ptr,
struct nouveau_bo *, uint32_t data, uint32_t flags,
uint32_t vor, uint32_t tor);
extern void
nouveau_bo_validate(struct nouveau_channel *);
#endif
|