drm/nouveau/fifo: add method to lookup fifo chid related to a given object
authorBen Skeggs <bskeggs@redhat.com>
Fri, 10 Aug 2012 04:02:44 +0000 (14:02 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 3 Oct 2012 03:13:03 +0000 (13:13 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/core/engine/fifo/base.c
drivers/gpu/drm/nouveau/core/include/engine/fifo.h

index edeb76ee648c159673d02471f2dd034a1d1c14e2..2a7c13d55acae88030e755eccd24529d6b27416a 100644 (file)
@@ -132,6 +132,21 @@ _nouveau_fifo_channel_wr32(struct nouveau_object *object, u32 addr, u32 data)
        iowrite32_native(data, chan->user + addr);
 }
 
+int
+nouveau_fifo_chid(struct nouveau_fifo *priv, struct nouveau_object *object)
+{
+       int engidx = nv_hclass(priv) & 0xff;
+
+       while (object && object->parent) {
+               if ( nv_iclass(object->parent, NV_ENGCTX_CLASS) &&
+                   (nv_hclass(object->parent) & 0xff) == engidx)
+                       return nouveau_fifo_chan(object)->chid;
+               object = object->parent;
+       }
+
+       return -1;
+}
+
 void
 nouveau_fifo_destroy(struct nouveau_fifo *priv)
 {
@@ -160,6 +175,7 @@ nouveau_fifo_create_(struct nouveau_object *parent,
        if (!priv->channel)
                return -ENOMEM;
 
+       priv->chid = nouveau_fifo_chid;
        spin_lock_init(&priv->lock);
        return 0;
 }
index 65ee929a75f0f1f10da014462c80b47301751dba..f2133872bd7c9d20f13ba83c39b587b456261293 100644 (file)
@@ -70,6 +70,7 @@ struct nouveau_fifo {
        u16 min;
        u16 max;
 
+       int  (*chid)(struct nouveau_fifo *, struct nouveau_object *);
        void (*pause)(struct nouveau_fifo *, unsigned long *);
        void (*start)(struct nouveau_fifo *, unsigned long *);
 };