randr12: Disable crt load detect again, until i know how to use it properly.
[nouveau] / src / nouveau_drmif.h
1 /*
2  * Copyright 2007 Nouveau Project
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  */
22
23 #ifndef __NOUVEAU_DRMIF_H__
24 #define __NOUVEAU_DRMIF_H__
25
26 #include <stdint.h>
27 #include <xf86drm.h>
28 #include <nouveau_drm.h>
29
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
36 struct nouveau_device_priv {
37         struct nouveau_device base;
38
39         int fd;
40         drm_context_t ctx;
41         drmLock *lock;
42         int needs_close;
43 };
44 #define nouveau_device(n) ((struct nouveau_device_priv *)(n))
45
46 extern int
47 nouveau_device_open_existing(struct nouveau_device **, int close,
48                              int fd, drm_context_t ctx);
49
50 extern int
51 nouveau_device_open(struct nouveau_device **, const char *busid);
52
53 extern void
54 nouveau_device_close(struct nouveau_device **);
55
56 extern int
57 nouveau_device_get_param(struct nouveau_device *, uint64_t param, uint64_t *v);
58
59 extern int
60 nouveau_device_set_param(struct nouveau_device *, uint64_t param, uint64_t val);
61
62 struct nouveau_channel_priv {
63         struct nouveau_channel base;
64
65         struct drm_nouveau_channel_alloc drm;
66
67         struct {
68                 struct nouveau_grobj *grobj;
69                 uint32_t seq;
70         } subchannel[8];
71         uint32_t subc_sequence;
72
73         uint32_t *pushbuf;
74         void     *notifier_block;
75
76         volatile uint32_t *user;
77         volatile uint32_t *put;
78         volatile uint32_t *get;
79         volatile uint32_t *ref_cnt;
80
81         struct {
82                 uint32_t base, max;
83                 uint32_t cur, put;
84                 uint32_t free;
85
86                 int push_free;
87         } dma;
88
89         struct nouveau_bo_reloc *relocs;
90         int num_relocs;
91         int max_relocs;
92 };
93 #define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
94
95 extern int
96 nouveau_channel_alloc(struct nouveau_device *, uint32_t fb, uint32_t tt,
97                       struct nouveau_channel **);
98
99 extern void
100 nouveau_channel_free(struct nouveau_channel **);
101
102 struct nouveau_grobj_priv {
103         struct nouveau_grobj base;
104 };
105 #define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
106
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 **);
112
113
114 struct nouveau_notifier_priv {
115         struct nouveau_notifier base;
116
117         struct drm_nouveau_notifierobj_alloc drm;
118         volatile void *map;
119 };
120 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
121
122 extern int
123 nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle, int count,
124                        struct nouveau_notifier **);
125
126 extern void
127 nouveau_notifier_free(struct nouveau_notifier **);
128
129 extern void
130 nouveau_notifier_reset(struct nouveau_notifier *, int id);
131
132 extern uint32_t
133 nouveau_notifier_status(struct nouveau_notifier *, int id);
134
135 extern uint32_t
136 nouveau_notifier_return_val(struct nouveau_notifier *, int id);
137
138 extern int
139 nouveau_notifier_wait_status(struct nouveau_notifier *, int id, int status,
140                              int timeout);
141
142 struct nouveau_bo_priv {
143         struct nouveau_bo base;
144
145         struct drm_nouveau_mem_alloc drm;
146         void *map;
147
148         int refcount;
149 };
150
151 struct nouveau_bo_reloc {
152         struct nouveau_bo_priv *bo;
153         uint32_t *ptr;
154         uint32_t flags;
155         uint32_t data, vor, tor;
156 };
157
158 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
159
160 extern int
161 nouveau_bo_new(struct nouveau_device *, uint32_t flags, int align, int size,
162                struct nouveau_bo **);
163
164 extern int
165 nouveau_bo_ref(struct nouveau_device *, uint64_t handle, struct nouveau_bo **);
166
167 extern void
168 nouveau_bo_del(struct nouveau_bo **);
169
170 extern int
171 nouveau_bo_map(struct nouveau_bo *, uint32_t flags);
172
173 extern void
174 nouveau_bo_unmap(struct nouveau_bo *);
175
176 extern void
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);
180
181 extern void
182 nouveau_bo_validate(struct nouveau_channel *);
183
184 #endif