aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs2015-11-23 18:33:56 -0600
committerBen Skeggs2015-12-21 21:22:20 -0600
commitb845d61de93c762f73463a67a634ecb1ae8c4c35 (patch)
tree08845794f5825f2bb27b89e875d79fd955cf9573 /nouveau
parentf6b1b5b7c9cf6667d169bad3b33a73e4fe2bc14c (diff)
downloadexternal-libgbm-b845d61de93c762f73463a67a634ecb1ae8c4c35.tar.gz
external-libgbm-b845d61de93c762f73463a67a634ecb1ae8c4c35.tar.xz
external-libgbm-b845d61de93c762f73463a67a634ecb1ae8c4c35.zip
nouveau: introduce object to represent the kernel client
Because NVIF intentionally lacks some of the paths necessary to be compatible with various mistakes we've made over the years, libdrm needs to know whether a client has been updated and that it's safe to make use of the new kernel interfaces. Clients still using nouveau_device_open()/wrap() will be forced to make use of ABI16 instead of NVIF. v2. - remove lib_version, nothing used it - leave client-provided pointer unmodified on failure Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'nouveau')
-rwxr-xr-xnouveau/nouveau-symbol-check2
-rw-r--r--nouveau/nouveau.c35
-rw-r--r--nouveau/nouveau.h18
3 files changed, 55 insertions, 0 deletions
diff --git a/nouveau/nouveau-symbol-check b/nouveau/nouveau-symbol-check
index 38b6ec52..e360b92d 100755
--- a/nouveau/nouveau-symbol-check
+++ b/nouveau/nouveau-symbol-check
@@ -30,6 +30,8 @@ nouveau_device_del
30nouveau_device_open 30nouveau_device_open
31nouveau_device_open_existing 31nouveau_device_open_existing
32nouveau_device_wrap 32nouveau_device_wrap
33nouveau_drm_del
34nouveau_drm_new
33nouveau_getparam 35nouveau_getparam
34nouveau_object_del 36nouveau_object_del
35nouveau_object_find 37nouveau_object_find
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index 00173034..2b163513 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -195,6 +195,41 @@ nouveau_object_find(struct nouveau_object *obj, uint32_t pclass)
195 return obj; 195 return obj;
196} 196}
197 197
198void
199nouveau_drm_del(struct nouveau_drm **pdrm)
200{
201 free(*pdrm);
202 *pdrm = NULL;
203}
204
205int
206nouveau_drm_new(int fd, struct nouveau_drm **pdrm)
207{
208 struct nouveau_drm *drm;
209 drmVersionPtr ver;
210
211#ifdef DEBUG
212 debug_init(getenv("NOUVEAU_LIBDRM_DEBUG"));
213#endif
214
215 if (!(drm = calloc(1, sizeof(*drm))))
216 return -ENOMEM;
217 drm->fd = fd;
218
219 if (!(ver = drmGetVersion(fd))) {
220 nouveau_drm_del(&drm);
221 return -EINVAL;
222 }
223 *pdrm = drm;
224
225 drm->version = (ver->version_major << 24) |
226 (ver->version_minor << 8) |
227 ver->version_patchlevel;
228 drm->nvif = false;
229 drmFreeVersion(ver);
230 return 0;
231}
232
198/* this is the old libdrm's version of nouveau_device_wrap(), the symbol 233/* this is the old libdrm's version of nouveau_device_wrap(), the symbol
199 * is kept here to prevent AIGLX from crashing if the DDX is linked against 234 * is kept here to prevent AIGLX from crashing if the DDX is linked against
200 * the new libdrm, but the DRI driver against the old 235 * the new libdrm, but the DRI driver against the old
diff --git a/nouveau/nouveau.h b/nouveau/nouveau.h
index 24cda6f1..2287eba8 100644
--- a/nouveau/nouveau.h
+++ b/nouveau/nouveau.h
@@ -22,6 +22,24 @@ struct nouveau_object {
22 void *data; 22 void *data;
23}; 23};
24 24
25struct nouveau_drm {
26 struct nouveau_object client;
27 int fd;
28 uint32_t version;
29 bool nvif;
30};
31
32static inline struct nouveau_drm *
33nouveau_drm(struct nouveau_object *obj)
34{
35 while (obj && obj->parent)
36 obj = obj->parent;
37 return (struct nouveau_drm *)obj;
38}
39
40int nouveau_drm_new(int fd, struct nouveau_drm **);
41void nouveau_drm_del(struct nouveau_drm **);
42
25struct nouveau_fifo { 43struct nouveau_fifo {
26 struct nouveau_object *object; 44 struct nouveau_object *object;
27 uint32_t channel; 45 uint32_t channel;