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_DRMIF_H__
24 #define __NOUVEAU_DRMIF_H__
28 #include <nouveau_drm.h>
30 #include "nouveau_device.h"
31 #include "nouveau_channel.h"
32 #include "nouveau_grobj.h"
33 #include "nouveau_notifier.h"
34 #include "nouveau_bo.h"
35 #include "nouveau_local.h"
37 struct nouveau_device_priv {
38 struct nouveau_device base;
45 #define nouveau_device(n) ((struct nouveau_device_priv *)(n))
48 nouveau_device_open_existing(struct nouveau_device **, int close,
49 int fd, drm_context_t ctx);
52 nouveau_device_open(struct nouveau_device **, const char *busid);
55 nouveau_device_close(struct nouveau_device **);
58 nouveau_device_get_param(struct nouveau_device *, uint64_t param, uint64_t *v);
61 nouveau_device_set_param(struct nouveau_device *, uint64_t param, uint64_t val);
63 struct nouveau_channel_priv {
64 struct nouveau_channel base;
66 struct drm_nouveau_channel_alloc drm;
69 struct nouveau_grobj *grobj;
72 uint32_t subc_sequence;
77 volatile uint32_t *user;
78 volatile uint32_t *put;
79 volatile uint32_t *get;
80 volatile uint32_t *ref_cnt;
90 struct nouveau_bo_reloc *relocs;
94 #define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
97 nouveau_channel_alloc(struct nouveau_device *, uint32_t fb, uint32_t tt,
98 struct nouveau_channel **);
101 nouveau_channel_free(struct nouveau_channel **);
103 struct nouveau_grobj_priv {
104 struct nouveau_grobj base;
106 #define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
108 NOUVEAU_PRIVATE int nouveau_grobj_alloc(struct nouveau_channel *, uint32_t handle,
109 int class, struct nouveau_grobj **);
110 NOUVEAU_PRIVATE int nouveau_grobj_ref(struct nouveau_channel *, uint32_t handle,
111 struct nouveau_grobj **);
112 NOUVEAU_PRIVATE void nouveau_grobj_free(struct nouveau_grobj **);
115 struct nouveau_notifier_priv {
116 struct nouveau_notifier base;
118 struct drm_nouveau_notifierobj_alloc drm;
121 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
124 nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle, int count,
125 struct nouveau_notifier **);
128 nouveau_notifier_free(struct nouveau_notifier **);
131 nouveau_notifier_reset(struct nouveau_notifier *, int id);
133 NOUVEAU_PRIVATE uint32_t
134 nouveau_notifier_status(struct nouveau_notifier *, int id);
136 NOUVEAU_PRIVATE uint32_t
137 nouveau_notifier_return_val(struct nouveau_notifier *, int id);
140 nouveau_notifier_wait_status(struct nouveau_notifier *, int id, int status,
143 struct nouveau_bo_priv {
144 struct nouveau_bo base;
146 struct drm_nouveau_mem_alloc drm;
152 struct nouveau_bo_reloc {
153 struct nouveau_bo_priv *bo;
156 uint32_t data, vor, tor;
159 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
162 nouveau_bo_new(struct nouveau_device *, uint32_t flags, int align, int size,
163 struct nouveau_bo **);
166 nouveau_bo_ref(struct nouveau_device *, uint64_t handle, struct nouveau_bo **);
169 nouveau_bo_del(struct nouveau_bo **);
172 nouveau_bo_map(struct nouveau_bo *, uint32_t flags);
175 nouveau_bo_unmap(struct nouveau_bo *);
178 nouveau_bo_emit_reloc(struct nouveau_channel *chan, void *ptr,
179 struct nouveau_bo *, uint32_t data, uint32_t flags,
180 uint32_t vor, uint32_t tor);
183 nouveau_bo_validate(struct nouveau_channel *);