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
23 #ifndef __NOUVEAU_PRIVATE_H__
24 #define __NOUVEAU_PRIVATE_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
;
45 struct nouveau_bo
*buffer
;
50 struct drm_nouveau_gem_pushbuf_bo
*buffers
;
52 struct drm_nouveau_gem_pushbuf_reloc
*relocs
;
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))
68 nouveau_pushbuf_init(struct nouveau_channel
*);
70 struct nouveau_dma_priv
{
80 struct nouveau_channel_priv
{
81 struct nouveau_channel base
;
83 struct drm_nouveau_channel_alloc drm
;
87 struct nouveau_pushbuf_priv pb
;
90 volatile uint32_t *user
, *put
, *get
, *ref_cnt
;
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 *);
112 struct nouveau_fence_priv
{
113 struct nouveau_fence base
;
116 struct nouveau_fence
*next
;
117 struct nouveau_fence_cb
*signal_cb
;
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 *);
135 nouveau_fence_emit(struct nouveau_fence
*);
138 nouveau_fence_wait(struct nouveau_fence
**);
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
;
154 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
156 struct nouveau_bo_priv
{
157 struct nouveau_bo base
;
160 /* Buffer configuration + usage hints */
167 struct drm_nouveau_gem_pushbuf_bo
*pending
;
168 struct nouveau_channel
*pending_channel
;
171 /* Userspace object */
175 uint32_t global_handle
;
179 /* Last known information from kernel on buffer status */
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
*);
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"