drm/nouveau/kms/nv50-: use NVIDIA's headers for core head_dither()
authorBen Skeggs <bskeggs@redhat.com>
Sun, 21 Jun 2020 02:35:48 +0000 (12:35 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 24 Jul 2020 08:51:03 +0000 (18:51 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
drivers/gpu/drm/nouveau/dispnv50/head.c
drivers/gpu/drm/nouveau/dispnv50/head507d.c
drivers/gpu/drm/nouveau/dispnv50/head907d.c
drivers/gpu/drm/nouveau/dispnv50/head917d.c
drivers/gpu/drm/nouveau/dispnv50/headc37d.c
drivers/gpu/drm/nouveau/nouveau_connector.h

index 2d84eaf..841edfa 100644 (file)
@@ -106,9 +106,9 @@ nv50_head_atomic_check_dither(struct nv50_head_atom *armh,
                }
        }
 
-       asyh->dither.enable = mode;
-       asyh->dither.bits = mode >> 1;
-       asyh->dither.mode = mode >> 3;
+       asyh->dither.enable = NVVAL_GET(mode, NV507D, HEAD_SET_DITHER_CONTROL, ENABLE);
+       asyh->dither.bits = NVVAL_GET(mode, NV507D, HEAD_SET_DITHER_CONTROL, BITS);
+       asyh->dither.mode = NVVAL_GET(mode, NV507D, HEAD_SET_DITHER_CONTROL, MODE);
        asyh->set.dither = true;
 }
 
index ed54c65..be9b9fa 100644 (file)
@@ -51,9 +51,11 @@ head507d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
        if ((ret = PUSH_WAIT(push, 2)))
                return ret;
 
-       PUSH_NVSQ(push, NV507D, 0x08a0 + (i * 0x400), asyh->dither.mode << 3 |
-                                                     asyh->dither.bits << 1 |
-                                                     asyh->dither.enable);
+       PUSH_MTHD(push, NV507D, HEAD_SET_DITHER_CONTROL(i),
+                 NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
+                 NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
+                 NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
+                 NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
        return 0;
 }
 
index 44b9693..f595cc7 100644 (file)
@@ -78,9 +78,11 @@ head907d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
        if ((ret = PUSH_WAIT(push, 2)))
                return ret;
 
-       PUSH_NVSQ(push, NV907D, 0x0490 + (i * 0x300), asyh->dither.mode << 3 |
-                                                     asyh->dither.bits << 1 |
-                                                     asyh->dither.enable);
+       PUSH_MTHD(push, NV907D, HEAD_SET_DITHER_CONTROL(i),
+                 NVVAL(NV907D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
+                 NVVAL(NV907D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
+                 NVVAL(NV907D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
+                 NVVAL(NV907D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
        return 0;
 }
 
index 026cfb4..a5d8274 100644 (file)
@@ -36,9 +36,11 @@ head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
        if ((ret = PUSH_WAIT(push, 2)))
                return ret;
 
-       PUSH_NVSQ(push, NV917D, 0x04a0 + (i * 0x300), asyh->dither.mode << 3 |
-                                                     asyh->dither.bits << 1 |
-                                                     asyh->dither.enable);
+       PUSH_MTHD(push, NV917D, HEAD_SET_DITHER_CONTROL(i),
+                 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
+                 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
+                 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
+                 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
        return 0;
 }
 
index 48b8b4d..172773b 100644 (file)
@@ -85,9 +85,12 @@ headc37d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
        if ((ret = PUSH_WAIT(push, 2)))
                return ret;
 
-       PUSH_NVSQ(push, NV907D, 0x2018 + (i * 0x400), asyh->dither.mode << 8 |
-                                                     asyh->dither.bits << 4 |
-                                                     asyh->dither.enable);
+       PUSH_MTHD(push, NVC37D, HEAD_SET_DITHER_CONTROL(i),
+                 NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
+                 NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
+                 NVDEF(NVC37D, HEAD_SET_DITHER_CONTROL, OFFSET_ENABLE, DISABLE) |
+                 NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
+                 NVVAL(NVC37D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
        return 0;
 }
 
index 9e062c7..d6de5cb 100644 (file)
 
 #include <nvif/notify.h>
 
+#include <nvhw/class/cl507d.h>
+#include <nvhw/class/cl907d.h>
+#include <nvhw/drf.h>
+
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_encoder.h>
@@ -56,16 +60,23 @@ struct nouveau_conn_atom {
                 * hw values, and the code relies on this.
                 */
                enum {
-                       DITHERING_MODE_OFF = 0x00,
-                       DITHERING_MODE_ON = 0x01,
-                       DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
-                       DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
-                       DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
+                       DITHERING_MODE_OFF =
+                               NVDEF(NV507D, HEAD_SET_DITHER_CONTROL, ENABLE, DISABLE),
+                       DITHERING_MODE_ON =
+                               NVDEF(NV507D, HEAD_SET_DITHER_CONTROL, ENABLE, ENABLE),
+                       DITHERING_MODE_DYNAMIC2X2 = DITHERING_MODE_ON |
+                               NVDEF(NV507D, HEAD_SET_DITHER_CONTROL, MODE, DYNAMIC_2X2),
+                       DITHERING_MODE_STATIC2X2 = DITHERING_MODE_ON |
+                               NVDEF(NV507D, HEAD_SET_DITHER_CONTROL, MODE, STATIC_2X2),
+                       DITHERING_MODE_TEMPORAL = DITHERING_MODE_ON |
+                               NVDEF(NV907D, HEAD_SET_DITHER_CONTROL, MODE, TEMPORAL),
                        DITHERING_MODE_AUTO
                } mode;
                enum {
-                       DITHERING_DEPTH_6BPC = 0x00,
-                       DITHERING_DEPTH_8BPC = 0x02,
+                       DITHERING_DEPTH_6BPC =
+                               NVDEF(NV507D, HEAD_SET_DITHER_CONTROL, BITS, DITHER_TO_6_BITS),
+                       DITHERING_DEPTH_8BPC =
+                               NVDEF(NV507D, HEAD_SET_DITHER_CONTROL, BITS, DITHER_TO_8_BITS),
                        DITHERING_DEPTH_AUTO
                } depth;
        } dither;