drm/nouveau/kms/nv50-: convert core head_olut_set() to new push macros
authorBen Skeggs <bskeggs@redhat.com>
Sat, 20 Jun 2020 22:58:11 +0000 (08:58 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 24 Jul 2020 08:50:54 +0000 (18:50 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
drivers/gpu/drm/nouveau/dispnv50/head.h
drivers/gpu/drm/nouveau/dispnv50/head507d.c
drivers/gpu/drm/nouveau/dispnv50/head827d.c
drivers/gpu/drm/nouveau/dispnv50/head907d.c
drivers/gpu/drm/nouveau/dispnv50/headc37d.c
drivers/gpu/drm/nouveau/dispnv50/headc57d.c

index 2d376e3..be1dafb 100644 (file)
@@ -30,7 +30,7 @@ struct nv50_head_func {
        bool (*olut)(struct nv50_head *, struct nv50_head_atom *, int);
        bool olut_identity;
        int  olut_size;
-       void (*olut_set)(struct nv50_head *, struct nv50_head_atom *);
+       int (*olut_set)(struct nv50_head *, struct nv50_head_atom *);
        void (*olut_clr)(struct nv50_head *);
        void (*core_calc)(struct nv50_head *, struct nv50_head_atom *);
        void (*core_set)(struct nv50_head *, struct nv50_head_atom *);
@@ -70,7 +70,7 @@ extern const struct nv50_head_func head907d;
 int head907d_view(struct nv50_head *, struct nv50_head_atom *);
 int head907d_mode(struct nv50_head *, struct nv50_head_atom *);
 bool head907d_olut(struct nv50_head *, struct nv50_head_atom *, int);
-void head907d_olut_set(struct nv50_head *, struct nv50_head_atom *);
+int head907d_olut_set(struct nv50_head *, struct nv50_head_atom *);
 void head907d_olut_clr(struct nv50_head *);
 void head907d_core_set(struct nv50_head *, struct nv50_head_atom *);
 void head907d_core_clr(struct nv50_head *);
index 516c075..50ff8bc 100644 (file)
@@ -243,17 +243,19 @@ head507d_olut_clr(struct nv50_head *head)
        }
 }
 
-static void
+static int
 head507d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-       struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
-       u32 *push;
-       if ((push = evo_wait(core, 3))) {
-               evo_mthd(push, 0x0840 + (head->base.index * 0x400), 2);
-               evo_data(push, 0x80000000 | asyh->olut.mode << 30);
-               evo_data(push, asyh->olut.offset >> 8);
-               evo_kick(push, core);
-       }
+       struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+       const int i = head->base.index;
+       int ret;
+
+       if ((ret = PUSH_WAIT(push, 3)))
+               return ret;
+
+       PUSH_NVSQ(push, NV507D, 0x0840 + (i * 0x400), 0x80000000 | asyh->olut.mode << 30,
+                               0x0844 + (i * 0x400), asyh->olut.offset >> 8);
+       return 0;
 }
 
 static void
index 1187711..30939bc 100644 (file)
@@ -22,6 +22,8 @@
 #include "head.h"
 #include "core.h"
 
+#include <nvif/push507c.h>
+
 static void
 head827d_curs_clr(struct nv50_head *head)
 {
@@ -88,19 +90,20 @@ head827d_olut_clr(struct nv50_head *head)
        }
 }
 
-static void
+static int
 head827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-       struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
-       u32 *push;
-       if ((push = evo_wait(core, 5))) {
-               evo_mthd(push, 0x0840 + (head->base.index * 0x400), 2);
-               evo_data(push, 0x80000000 | asyh->olut.mode << 30);
-               evo_data(push, asyh->olut.offset >> 8);
-               evo_mthd(push, 0x085c + (head->base.index * 0x400), 1);
-               evo_data(push, asyh->olut.handle);
-               evo_kick(push, core);
-       }
+       struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+       const int i = head->base.index;
+       int ret;
+
+       if ((ret = PUSH_WAIT(push, 5)))
+               return ret;
+
+       PUSH_NVSQ(push, NV827D, 0x0840 + (i * 0x400), 0x80000000 | asyh->olut.mode << 30,
+                               0x0844 + (i * 0x400), asyh->olut.offset >> 8);
+       PUSH_NVSQ(push, NV827D, 0x085c + (i * 0x400), asyh->olut.handle);
+       return 0;
 }
 
 const struct nv50_head_func
index 2ee1931..24e0d7c 100644 (file)
@@ -208,19 +208,20 @@ head907d_olut_clr(struct nv50_head *head)
        }
 }
 
-void
+int
 head907d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-       struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
-       u32 *push;
-       if ((push = evo_wait(core, 5))) {
-               evo_mthd(push, 0x0448 + (head->base.index * 0x300), 2);
-               evo_data(push, 0x80000000 | asyh->olut.mode << 24);
-               evo_data(push, asyh->olut.offset >> 8);
-               evo_mthd(push, 0x045c + (head->base.index * 0x300), 1);
-               evo_data(push, asyh->olut.handle);
-               evo_kick(push, core);
-       }
+       struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+       const int i = head->base.index;
+       int ret;
+
+       if ((ret = PUSH_WAIT(push, 5)))
+               return ret;
+
+       PUSH_NVSQ(push, NV907D, 0x0448 + (i * 0x300), 0x80000000 | asyh->olut.mode << 24,
+                               0x044c + (i * 0x300), asyh->olut.offset >> 8);
+       PUSH_NVSQ(push, NV907D, 0x045c + (i * 0x300), asyh->olut.handle);
+       return 0;
 }
 
 void
index e15a4d3..4363fcc 100644 (file)
@@ -137,20 +137,22 @@ headc37d_olut_clr(struct nv50_head *head)
        }
 }
 
-static void
+static int
 headc37d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-       struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
-       u32 *push;
-       if ((push = evo_wait(core, 4))) {
-               evo_mthd(push, 0x20a4 + (head->base.index * 0x400), 3);
-               evo_data(push, asyh->olut.output_mode << 8 |
-                              asyh->olut.range << 4 |
-                              asyh->olut.size);
-               evo_data(push, asyh->olut.offset >> 8);
-               evo_data(push, asyh->olut.handle);
-               evo_kick(push, core);
-       }
+       struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+       const int i = head->base.index;
+       int ret;
+
+       if ((ret = PUSH_WAIT(push, 4)))
+               return ret;
+
+       PUSH_NVSQ(push, NVC37D, 0x20a4 + (i * 0x400), asyh->olut.output_mode << 8 |
+                                                     asyh->olut.range << 4 |
+                                                     asyh->olut.size,
+                               0x20a8 + (i * 0x400), asyh->olut.offset >> 8,
+                               0x20ac + (i * 0x400), asyh->olut.handle);
+       return 0;
 }
 
 static bool
index 1024436..2f90a24 100644 (file)
@@ -87,21 +87,23 @@ headc57d_olut_clr(struct nv50_head *head)
        }
 }
 
-void
+static int
 headc57d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
 {
-       struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
-       u32 *push;
-       if ((push = evo_wait(core, 4))) {
-               evo_mthd(push, 0x2280 + (head->base.index * 0x400), 4);
-               evo_data(push, asyh->olut.size << 8 |
-                              asyh->olut.mode << 2 |
-                              asyh->olut.output_mode);
-               evo_data(push, 0xffffffff); /* FP_NORM_SCALE. */
-               evo_data(push, asyh->olut.handle);
-               evo_data(push, asyh->olut.offset >> 8);
-               evo_kick(push, core);
-       }
+       struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+       const int i = head->base.index;
+       int ret;
+
+       if ((ret = PUSH_WAIT(push, 5)))
+               return ret;
+
+       PUSH_NVSQ(push, NVC57D, 0x2280 + (i * 0x400), asyh->olut.size << 8 |
+                                                     asyh->olut.mode << 2 |
+                                                     asyh->olut.output_mode,
+                               0x2284 + (i * 0x400), 0xffffffff,
+                               0x2288 + (i * 0x400), asyh->olut.handle,
+                               0x228c + (i * 0x400), asyh->olut.offset >> 8);
+       return 0;
 }
 
 static void