All of lore.kernel.org
 help / color / mirror / Atom feed
* [libdrm 01/13] nouveau: move more abi16-specific logic into abi16.c
@ 2015-11-26  7:13 Ben Skeggs
       [not found] ` <1448522050-4873-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: Ben Skeggs @ 2015-11-26  7:13 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs

From: Ben Skeggs <bskeggs@redhat.com>

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
 nouveau/abi16.c   | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 nouveau/nouveau.c | 56 +++++++------------------------------------------
 nouveau/private.h |  7 ++-----
 3 files changed, 67 insertions(+), 58 deletions(-)

diff --git a/nouveau/abi16.c b/nouveau/abi16.c
index 59bc436..8f24ba2 100644
--- a/nouveau/abi16.c
+++ b/nouveau/abi16.c
@@ -33,7 +33,7 @@
 #include "private.h"
 
 
-drm_private int
+static int
 abi16_chan_nv04(struct nouveau_object *obj)
 {
 	struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
@@ -57,7 +57,7 @@ abi16_chan_nv04(struct nouveau_object *obj)
 	return 0;
 }
 
-drm_private int
+static int
 abi16_chan_nvc0(struct nouveau_object *obj)
 {
 	struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
@@ -78,7 +78,7 @@ abi16_chan_nvc0(struct nouveau_object *obj)
 	return 0;
 }
 
-drm_private int
+static int
 abi16_chan_nve0(struct nouveau_object *obj)
 {
 	struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
@@ -104,7 +104,7 @@ abi16_chan_nve0(struct nouveau_object *obj)
 	return 0;
 }
 
-drm_private int
+static int
 abi16_engobj(struct nouveau_object *obj)
 {
 	struct drm_nouveau_grobj_alloc req = {
@@ -125,7 +125,7 @@ abi16_engobj(struct nouveau_object *obj)
 	return 0;
 }
 
-drm_private int
+static int
 abi16_ntfy(struct nouveau_object *obj)
 {
 	struct nv04_notify *ntfy = obj->data;
@@ -149,6 +149,58 @@ abi16_ntfy(struct nouveau_object *obj)
 }
 
 drm_private void
+abi16_delete(struct nouveau_object *obj)
+{
+	struct nouveau_device *dev =
+		nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
+	if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
+		struct drm_nouveau_channel_free req;
+		req.channel = obj->handle;
+		drmCommandWrite(dev->fd, DRM_NOUVEAU_CHANNEL_FREE,
+				&req, sizeof(req));
+	} else {
+		struct drm_nouveau_gpuobj_free req;
+		req.channel = obj->parent->handle;
+		req.handle  = obj->handle;
+		drmCommandWrite(dev->fd, DRM_NOUVEAU_GPUOBJ_FREE,
+				&req, sizeof(req));
+	}
+}
+
+drm_private bool
+abi16_object(struct nouveau_object *obj, int (**func)(struct nouveau_object *))
+{
+	struct nouveau_object *parent = obj->parent;
+
+	if ((parent->length != 0 && parent->oclass == NOUVEAU_DEVICE_CLASS)) {
+		if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
+			struct nouveau_device *dev = (void *)parent;
+			if (dev->chipset < 0xc0)
+				*func = abi16_chan_nv04;
+			else
+			if (dev->chipset < 0xe0)
+				*func = abi16_chan_nvc0;
+			else
+				*func = abi16_chan_nve0;
+			return true;
+		}
+	} else
+	if ((parent->length != 0 &&
+	     parent->oclass == NOUVEAU_FIFO_CHANNEL_CLASS)) {
+		if (obj->oclass == NOUVEAU_NOTIFIER_CLASS) {
+			*func = abi16_ntfy;
+			return true;
+		}
+
+		*func = abi16_engobj;
+		return false;
+	}
+
+	*func = NULL;
+	return false;
+}
+
+drm_private void
 abi16_bo_info(struct nouveau_bo *bo, struct drm_nouveau_gem_info *info)
 {
 	struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index 97fd77b..8a0be2f 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -135,6 +135,7 @@ nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev)
 		nvdev->gart_limit_percent = 80;
 	DRMINITLISTHEAD(&nvdev->bo_list);
 	nvdev->base.object.oclass = NOUVEAU_DEVICE_CLASS;
+	nvdev->base.object.length = ~0;
 	nvdev->base.lib_version = 0x01000000;
 	nvdev->base.chipset = chipset;
 	nvdev->base.vram_size = vram;
@@ -251,8 +252,8 @@ nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
 		   uint32_t oclass, void *data, uint32_t length,
 		   struct nouveau_object **pobj)
 {
-	struct nouveau_device *dev;
 	struct nouveau_object *obj;
+	int (*func)(struct nouveau_object *);
 	int ret = -EINVAL;
 
 	if (length == 0)
@@ -267,37 +268,9 @@ nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
 		memcpy(obj->data, data, length);
 	*(struct nouveau_object **)obj->data = obj;
 
-	dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
-	switch (parent->oclass) {
-	case NOUVEAU_DEVICE_CLASS:
-		switch (obj->oclass) {
-		case NOUVEAU_FIFO_CHANNEL_CLASS:
-		{
-			if (dev->chipset < 0xc0)
-				ret = abi16_chan_nv04(obj);
-			else
-			if (dev->chipset < 0xe0)
-				ret = abi16_chan_nvc0(obj);
-			else
-				ret = abi16_chan_nve0(obj);
-		}
-			break;
-		default:
-			break;
-		}
-		break;
-	case NOUVEAU_FIFO_CHANNEL_CLASS:
-		switch (obj->oclass) {
-		case NOUVEAU_NOTIFIER_CLASS:
-			ret = abi16_ntfy(obj);
-			break;
-		default:
-			ret = abi16_engobj(obj);
-			break;
-		}
-	default:
-		break;
-	}
+	abi16_object(obj, &func);
+	if (func)
+		ret = func(obj);
 
 	if (ret) {
 		free(obj);
@@ -312,24 +285,11 @@ void
 nouveau_object_del(struct nouveau_object **pobj)
 {
 	struct nouveau_object *obj = *pobj;
-	struct nouveau_device *dev;
 	if (obj) {
-		dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
-		if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
-			struct drm_nouveau_channel_free req;
-			req.channel = obj->handle;
-			drmCommandWrite(dev->fd, DRM_NOUVEAU_CHANNEL_FREE,
-					&req, sizeof(req));
-		} else {
-			struct drm_nouveau_gpuobj_free req;
-			req.channel = obj->parent->handle;
-			req.handle  = obj->handle;
-			drmCommandWrite(dev->fd, DRM_NOUVEAU_GPUOBJ_FREE,
-					&req, sizeof(req));
-		}
+		abi16_delete(obj);
+		free(obj);
+		*pobj = NULL;
 	}
-	free(obj);
-	*pobj = NULL;
 }
 
 void *
diff --git a/nouveau/private.h b/nouveau/private.h
index e9439f3..5f352a4 100644
--- a/nouveau/private.h
+++ b/nouveau/private.h
@@ -114,11 +114,8 @@ int
 nouveau_device_open_existing(struct nouveau_device **, int, int, drm_context_t);
 
 /* abi16.c */
-drm_private int  abi16_chan_nv04(struct nouveau_object *);
-drm_private int  abi16_chan_nvc0(struct nouveau_object *);
-drm_private int  abi16_chan_nve0(struct nouveau_object *);
-drm_private int  abi16_engobj(struct nouveau_object *);
-drm_private int  abi16_ntfy(struct nouveau_object *);
+drm_private bool abi16_object(struct nouveau_object *, int (**)(struct nouveau_object *));
+drm_private void abi16_delete(struct nouveau_object *);
 drm_private void abi16_bo_info(struct nouveau_bo *, struct drm_nouveau_gem_info *);
 drm_private int  abi16_bo_init(struct nouveau_bo *, uint32_t alignment,
 			       union nouveau_bo_config *);
-- 
2.6.3

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-11-27  1:07 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26  7:13 [libdrm 01/13] nouveau: move more abi16-specific logic into abi16.c Ben Skeggs
     [not found] ` <1448522050-4873-1-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-26  7:13   ` [libdrm 02/13] nouveau: move object functions up, to avoid future foward decls Ben Skeggs
2015-11-26  7:14   ` [libdrm 03/13] nouveau: make it possible to init object in pre-allocated memory Ben Skeggs
2015-11-26  7:14   ` [libdrm 04/13] nouveau: add interface to call an object's methods Ben Skeggs
2015-11-26  7:14   ` [libdrm 05/13] nouveau: add interfaces to query information about supported classes Ben Skeggs
     [not found]     ` <1448522050-4873-5-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-26 20:39       ` Emil Velikov
2015-11-26  7:14   ` [libdrm 06/13] nouveau: introduce object to represent the kernel client Ben Skeggs
     [not found]     ` <1448522050-4873-6-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-26 20:46       ` Emil Velikov
2015-11-26  7:14   ` [libdrm 07/13] nouveau: stack legacy nouveau_device on top of nouveau_drm Ben Skeggs
     [not found]     ` <1448522050-4873-7-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-26 21:01       ` Emil Velikov
2015-11-26  7:14   ` [libdrm 08/13] nouveau: make use of nouveau_drm::fd instead of nouveau_device::fd Ben Skeggs
     [not found]     ` <1448522050-4873-8-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-26 21:06       ` Emil Velikov
2015-11-26  7:14   ` [libdrm 09/13] nouveau: import and install a selection of nvif headers from the kernel Ben Skeggs
     [not found]     ` <1448522050-4873-9-git-send-email-skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-26 21:14       ` Emil Velikov
     [not found]         ` <CACvgo53xNBm-HHMX2GvWh3EVr7v5SEzbJnGsQkEk2khEf1SYOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-27  1:07           ` Ben Skeggs
2015-11-26  7:14   ` [libdrm 10/13] nouveau: add new interface to create a nouveau_device Ben Skeggs
2015-11-26  7:14   ` [libdrm 11/13] nouveau: add support for newer kernel interfaces Ben Skeggs
2015-11-26  7:14   ` [libdrm 12/13] nouveau: clean up nouveau.h, noting deprecated members/functions Ben Skeggs
2015-11-26  7:14   ` [libdrm 13/13] Bump version for release Ben Skeggs
2015-11-26 20:21   ` [libdrm 01/13] nouveau: move more abi16-specific logic into abi16.c Emil Velikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.