No empty .Rs/.Re
[netbsd-mini2440.git] / sys / external / bsd / drm / dist / libdrm / nouveau / nouveau_private.h
blob32a90529f376530e7a5b12721b07cfe4d4815c5d
1 /*
2 * Copyright 2007 Nouveau Project
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
23 #ifndef __NOUVEAU_PRIVATE_H__
24 #define __NOUVEAU_PRIVATE_H__
26 #include <stdint.h>
27 #include <xf86drm.h>
28 #include <nouveau_drm.h>
30 #include "nouveau_drmif.h"
31 #include "nouveau_device.h"
32 #include "nouveau_channel.h"
33 #include "nouveau_grobj.h"
34 #include "nouveau_notifier.h"
35 #include "nouveau_bo.h"
36 #include "nouveau_resource.h"
37 #include "nouveau_pushbuf.h"
39 #define NOUVEAU_PUSHBUF_MAX_BUFFERS 1024
40 #define NOUVEAU_PUSHBUF_MAX_RELOCS 1024
41 struct nouveau_pushbuf_priv {
42 struct nouveau_pushbuf base;
44 int use_cal;
45 struct nouveau_bo *buffer;
47 unsigned *pushbuf;
48 unsigned size;
50 struct drm_nouveau_gem_pushbuf_bo *buffers;
51 unsigned nr_buffers;
52 struct drm_nouveau_gem_pushbuf_reloc *relocs;
53 unsigned nr_relocs;
55 /*XXX: nomm */
56 struct nouveau_fence *fence;
58 #define nouveau_pushbuf(n) ((struct nouveau_pushbuf_priv *)(n))
60 #define pbbo_to_ptr(o) ((uint64_t)(unsigned long)(o))
61 #define ptr_to_pbbo(h) ((struct nouveau_pushbuf_bo *)(unsigned long)(h))
62 #define pbrel_to_ptr(o) ((uint64_t)(unsigned long)(o))
63 #define ptr_to_pbrel(h) ((struct nouveau_pushbuf_reloc *)(unsigned long)(h))
64 #define bo_to_ptr(o) ((uint64_t)(unsigned long)(o))
65 #define ptr_to_bo(h) ((struct nouveau_bo_priv *)(unsigned long)(h))
67 int
68 nouveau_pushbuf_init(struct nouveau_channel *);
70 struct nouveau_dma_priv {
71 uint32_t base;
72 uint32_t max;
73 uint32_t cur;
74 uint32_t put;
75 uint32_t free;
77 int push_free;
78 } dma;
80 struct nouveau_channel_priv {
81 struct nouveau_channel base;
83 struct drm_nouveau_channel_alloc drm;
85 void *notifier_block;
87 struct nouveau_pushbuf_priv pb;
89 /*XXX: nomm */
90 volatile uint32_t *user, *put, *get, *ref_cnt;
91 uint32_t *pushbuf;
92 struct nouveau_dma_priv struct_dma;
93 struct nouveau_dma_priv *dma;
94 struct nouveau_fence *fence_head;
95 struct nouveau_fence *fence_tail;
96 uint32_t fence_sequence;
97 struct nouveau_grobj *fence_grobj;
98 struct nouveau_notifier *fence_ntfy;
100 #define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
102 struct nouveau_fence {
103 struct nouveau_channel *channel;
106 struct nouveau_fence_cb {
107 struct nouveau_fence_cb *next;
108 void (*func)(void *);
109 void *priv;
112 struct nouveau_fence_priv {
113 struct nouveau_fence base;
114 int refcount;
116 struct nouveau_fence *next;
117 struct nouveau_fence_cb *signal_cb;
119 uint32_t sequence;
120 int emitted;
121 int signalled;
123 #define nouveau_fence(n) ((struct nouveau_fence_priv *)(n))
126 nouveau_fence_new(struct nouveau_channel *, struct nouveau_fence **);
129 nouveau_fence_ref(struct nouveau_fence *, struct nouveau_fence **);
132 nouveau_fence_signal_cb(struct nouveau_fence *, void (*)(void *), void *);
134 void
135 nouveau_fence_emit(struct nouveau_fence *);
138 nouveau_fence_wait(struct nouveau_fence **);
140 void
141 nouveau_fence_flush(struct nouveau_channel *);
143 struct nouveau_grobj_priv {
144 struct nouveau_grobj base;
146 #define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
148 struct nouveau_notifier_priv {
149 struct nouveau_notifier base;
151 struct drm_nouveau_notifierobj_alloc drm;
152 volatile void *map;
154 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
156 struct nouveau_bo_priv {
157 struct nouveau_bo base;
158 int refcount;
160 /* Buffer configuration + usage hints */
161 unsigned flags;
162 unsigned size;
163 unsigned align;
164 int user;
166 /* Tracking */
167 struct drm_nouveau_gem_pushbuf_bo *pending;
168 struct nouveau_channel *pending_channel;
169 int write_marker;
171 /* Userspace object */
172 void *sysmem;
174 /* Kernel object */
175 uint32_t global_handle;
176 drm_handle_t handle;
177 void *map;
179 /* Last known information from kernel on buffer status */
180 int pinned;
181 uint64_t offset;
182 uint32_t domain;
184 /*XXX: nomm stuff */
185 struct nouveau_fence *fence;
186 struct nouveau_fence *wr_fence;
188 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
191 nouveau_bo_init(struct nouveau_device *);
193 void
194 nouveau_bo_takedown(struct nouveau_device *);
196 struct drm_nouveau_gem_pushbuf_bo *
197 nouveau_bo_emit_buffer(struct nouveau_channel *, struct nouveau_bo *);
200 nouveau_bo_validate_nomm(struct nouveau_bo_priv *, uint32_t);
202 #include "nouveau_dma.h"
203 #endif