summaryrefslogtreecommitdiff
path: root/nouveau/nouveau.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-11-24 10:33:56 +1000
committerBen Skeggs <bskeggs@redhat.com>2015-12-22 13:22:20 +1000
commitb845d61de93c762f73463a67a634ecb1ae8c4c35 (patch)
tree08845794f5825f2bb27b89e875d79fd955cf9573 /nouveau/nouveau.c
parentf6b1b5b7c9cf6667d169bad3b33a73e4fe2bc14c (diff)
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/nouveau.c')
-rw-r--r--nouveau/nouveau.c35
1 files changed, 35 insertions, 0 deletions
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)
return obj;
}
+void
+nouveau_drm_del(struct nouveau_drm **pdrm)
+{
+ free(*pdrm);
+ *pdrm = NULL;
+}
+
+int
+nouveau_drm_new(int fd, struct nouveau_drm **pdrm)
+{
+ struct nouveau_drm *drm;
+ drmVersionPtr ver;
+
+#ifdef DEBUG
+ debug_init(getenv("NOUVEAU_LIBDRM_DEBUG"));
+#endif
+
+ if (!(drm = calloc(1, sizeof(*drm))))
+ return -ENOMEM;
+ drm->fd = fd;
+
+ if (!(ver = drmGetVersion(fd))) {
+ nouveau_drm_del(&drm);
+ return -EINVAL;
+ }
+ *pdrm = drm;
+
+ drm->version = (ver->version_major << 24) |
+ (ver->version_minor << 8) |
+ ver->version_patchlevel;
+ drm->nvif = false;
+ drmFreeVersion(ver);
+ return 0;
+}
+
/* this is the old libdrm's version of nouveau_device_wrap(), the symbol
* is kept here to prevent AIGLX from crashing if the DDX is linked against
* the new libdrm, but the DRI driver against the old