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"
36 struct nouveau_device_priv {
37 struct nouveau_device base;
44 #define nouveau_device(n) ((struct nouveau_device_priv *)(n))
47 nouveau_device_open_existing(struct nouveau_device **, int close,
48 int fd, drm_context_t ctx);
51 nouveau_device_open(struct nouveau_device **, const char *busid);
54 nouveau_device_close(struct nouveau_device **);
57 nouveau_device_get_param(struct nouveau_device *, uint64_t param, uint64_t *v);
60 nouveau_device_set_param(struct nouveau_device *, uint64_t param, uint64_t val);
62 struct nouveau_channel_priv {
63 struct nouveau_channel base;
65 struct drm_nouveau_channel_alloc drm;
68 struct nouveau_grobj *grobj;
71 uint32_t subc_sequence;
76 volatile uint32_t *user;
77 volatile uint32_t *put;
78 volatile uint32_t *get;
79 volatile uint32_t *ref_cnt;
89 struct nouveau_bo_reloc *relocs;
93 #define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
96 nouveau_channel_alloc(struct nouveau_device *, uint32_t fb, uint32_t tt,
97 struct nouveau_channel **);
100 nouveau_channel_free(struct nouveau_channel **);
102 struct nouveau_grobj_priv {
103 struct nouveau_grobj base;
105 #define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
107 extern int nouveau_grobj_alloc(struct nouveau_channel *, uint32_t handle,
108 int class, struct nouveau_grobj **);
109 extern int nouveau_grobj_ref(struct nouveau_channel *, uint32_t handle,
110 struct nouveau_grobj **);
111 extern void nouveau_grobj_free(struct nouveau_grobj **);
114 struct nouveau_notifier_priv {
115 struct nouveau_notifier base;
117 struct drm_nouveau_notifierobj_alloc drm;
120 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
123 nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle, int count,
124 struct nouveau_notifier **);
127 nouveau_notifier_free(struct nouveau_notifier **);
130 nouveau_notifier_reset(struct nouveau_notifier *, int id);
133 nouveau_notifier_status(struct nouveau_notifier *, int id);
136 nouveau_notifier_return_val(struct nouveau_notifier *, int id);
139 nouveau_notifier_wait_status(struct nouveau_notifier *, int id, int status,
142 struct nouveau_bo_priv {
143 struct nouveau_bo base;
145 struct drm_nouveau_mem_alloc drm;
151 struct nouveau_bo_reloc {
152 struct nouveau_bo_priv *bo;
155 uint32_t data, vor, tor;
158 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
161 nouveau_bo_new(struct nouveau_device *, uint32_t flags, int align, int size,
162 struct nouveau_bo **);
165 nouveau_bo_ref(struct nouveau_device *, uint64_t handle, struct nouveau_bo **);
168 nouveau_bo_del(struct nouveau_bo **);
171 nouveau_bo_map(struct nouveau_bo *, uint32_t flags);
174 nouveau_bo_unmap(struct nouveau_bo *);
177 nouveau_bo_emit_reloc(struct nouveau_channel *chan, void *ptr,
178 struct nouveau_bo *, uint32_t data, uint32_t flags,
179 uint32_t vor, uint32_t tor);
182 nouveau_bo_validate(struct nouveau_channel *);