drm/nouveau/kms/nv50-: move drm format->hw conversion into common code
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:28 +0000 (15:01 +1000)
This will be required to support additional HW features.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/dispnv50/base507c.c
drivers/gpu/drm/nouveau/dispnv50/curs507a.c
drivers/gpu/drm/nouveau/dispnv50/wndw.c

index 548a6a67f874b940df3f68a98ac03ec8b3d282f6..43dcbcd49e7190b2060be743957f1251bf56913e 100644 (file)
@@ -186,22 +186,6 @@ base507c_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
        asyh->base.w = asyw->state.fb->width;
        asyh->base.h = asyw->state.fb->height;
 
-       switch (fb->format->format) {
-       case DRM_FORMAT_C8         : asyw->image.format = 0x1e; break;
-       case DRM_FORMAT_RGB565     : asyw->image.format = 0xe8; break;
-       case DRM_FORMAT_XRGB1555   :
-       case DRM_FORMAT_ARGB1555   : asyw->image.format = 0xe9; break;
-       case DRM_FORMAT_XRGB8888   :
-       case DRM_FORMAT_ARGB8888   : asyw->image.format = 0xcf; break;
-       case DRM_FORMAT_XBGR2101010:
-       case DRM_FORMAT_ABGR2101010: asyw->image.format = 0xd1; break;
-       case DRM_FORMAT_XBGR8888   :
-       case DRM_FORMAT_ABGR8888   : asyw->image.format = 0xd5; break;
-       default:
-               WARN_ON(1);
-               return -EINVAL;
-       }
-
        asyw->lut.enable = 1;
        asyw->set.image = true;
        return 0;
index 3e5e98c835a3ccc27c6c314fd9ccbcaa811a83a1..f7e56a88e77d524f6ebc0cad6b654b2db7e5b8a5 100644 (file)
@@ -91,8 +91,8 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
        if (asyw->state.fb->width != asyw->state.fb->height)
                return -EINVAL;
 
-       switch (asyw->state.fb->format->format) {
-       case DRM_FORMAT_ARGB8888: asyh->curs.format = 1; break;
+       switch (asyw->image.format) {
+       case 0xcf: asyh->curs.format = 1; break;
        default:
                WARN_ON(1);
                return -EINVAL;
index 8a7636f8a2421e2059c041afb8cf54c3d3e1bcec..cfd998a85418559f5e16bce867a20d941af6eab2 100644 (file)
@@ -168,6 +168,27 @@ nv50_wndw_atomic_check_release(struct nv50_wndw *wndw,
        asyw->sema.handle = 0;
 }
 
+static int
+nv50_wndw_atomic_check_acquire_rgb(struct nv50_wndw_atom *asyw)
+{
+       switch (asyw->state.fb->format->format) {
+       case DRM_FORMAT_C8         : asyw->image.format = 0x1e; break;
+       case DRM_FORMAT_XRGB8888   :
+       case DRM_FORMAT_ARGB8888   : asyw->image.format = 0xcf; break;
+       case DRM_FORMAT_RGB565     : asyw->image.format = 0xe8; break;
+       case DRM_FORMAT_XRGB1555   :
+       case DRM_FORMAT_ARGB1555   : asyw->image.format = 0xe9; break;
+       case DRM_FORMAT_XBGR2101010:
+       case DRM_FORMAT_ABGR2101010: asyw->image.format = 0xd1; break;
+       case DRM_FORMAT_XBGR8888   :
+       case DRM_FORMAT_ABGR8888   : asyw->image.format = 0xd5; break;
+       default:
+               WARN_ON(1);
+               return -EINVAL;
+       }
+       return 0;
+}
+
 static int
 nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw,
                               struct nv50_wndw_atom *asyw,
@@ -183,6 +204,10 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw,
        asyw->image.h = fb->base.height;
        asyw->image.kind = fb->nvbo->kind;
 
+       ret = nv50_wndw_atomic_check_acquire_rgb(asyw);
+       if (ret)
+               return ret;
+
        if (asyh->state.pageflip_flags & DRM_MODE_PAGE_FLIP_ASYNC)
                asyw->interval = 0;
        else