drm/nouveau: create base display from common code
authorBen Skeggs <bskeggs@redhat.com>
Wed, 22 Jan 2014 02:58:12 +0000 (12:58 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 23 Jan 2014 03:39:18 +0000 (13:39 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/dispnv04/disp.c
drivers/gpu/drm/nouveau/dispnv04/disp.h
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_display.h
drivers/gpu/drm/nouveau/nouveau_drm.h
drivers/gpu/drm/nouveau/nv50_display.c

index b13ff0fc42de4b2dcaf175e4a1ec3a126f04732c..2f1ed61f7c8c9e39d44c1528410eb4aaeb83fe17 100644 (file)
@@ -77,11 +77,6 @@ nv04_display_create(struct drm_device *dev)
 
        nouveau_hw_save_vga_fonts(dev, 1);
 
-       ret = nouveau_object_new(nv_object(drm), NVDRM_DEVICE, 0xd1500000,
-                                NV04_DISP_CLASS, NULL, 0, &disp->core);
-       if (ret)
-               return ret;
-
        nv04_crtc_create(dev, 0);
        if (nv_two_heads(dev))
                nv04_crtc_create(dev, 1);
index 56a28db040004fe6ecfebb6b3b69c8feda6a85f5..4245fc3dab70e5ce06964cc70296ef4e6929a9b8 100644 (file)
@@ -80,7 +80,6 @@ struct nv04_display {
        struct nv04_mode_state saved_reg;
        uint32_t saved_vga_font[4][16384];
        uint32_t dac_users[4];
-       struct nouveau_object *core;
        struct nouveau_bo *image[2];
 };
 
index 8b757483a1070382ce9c0eae1e217df19c216f86..a22d019bb21719286d56e5c24c0b2e43bed6f8c0 100644 (file)
@@ -407,10 +407,31 @@ nouveau_display_create(struct drm_device *dev)
        drm_kms_helper_poll_disable(dev);
 
        if (drm->vbios.dcb.entries) {
-               if (nv_device(drm->device)->card_type < NV_50)
-                       ret = nv04_display_create(dev);
-               else
-                       ret = nv50_display_create(dev);
+               static const u16 oclass[] = {
+                       NVF0_DISP_CLASS,
+                       NVE0_DISP_CLASS,
+                       NVD0_DISP_CLASS,
+                       NVA3_DISP_CLASS,
+                       NV94_DISP_CLASS,
+                       NVA0_DISP_CLASS,
+                       NV84_DISP_CLASS,
+                       NV50_DISP_CLASS,
+                       NV04_DISP_CLASS,
+               };
+               int i;
+
+               for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {
+                       ret = nouveau_object_new(nv_object(drm), NVDRM_DEVICE,
+                                                NVDRM_DISPLAY, oclass[i],
+                                                NULL, 0, &disp->core);
+               }
+
+               if (ret == 0) {
+                       if (nv_mclass(disp->core) < NV50_DISP_CLASS)
+                               ret = nv04_display_create(dev);
+                       else
+                               ret = nv50_display_create(dev);
+               }
        } else {
                ret = 0;
        }
@@ -439,6 +460,7 @@ void
 nouveau_display_destroy(struct drm_device *dev)
 {
        struct nouveau_display *disp = nouveau_display(dev);
+       struct nouveau_drm *drm = nouveau_drm(dev);
 
        nouveau_backlight_exit(dev);
        nouveau_display_vblank_fini(dev);
@@ -449,6 +471,8 @@ nouveau_display_destroy(struct drm_device *dev)
        if (disp->dtor)
                disp->dtor(dev);
 
+       nouveau_object_del(nv_object(drm), NVDRM_DEVICE, NVDRM_DISPLAY);
+
        nouveau_drm(dev)->display = NULL;
        kfree(disp);
 }
index 8bc8bab90e8d34462f0b484a90710a9094247216..73aa231130b8ddbb8e610881367f6daa81de070f 100644 (file)
@@ -36,6 +36,7 @@ struct nouveau_display {
        int  (*init)(struct drm_device *);
        void (*fini)(struct drm_device *);
 
+       struct nouveau_object *core;
        struct nouveau_eventh **vblank;
 
        struct drm_property *dithering_mode;
index 4b0fb6c66be918857bc6529b3a7c5a7c7a49a498..23ca7a517246feda3e7dfae782683c88c2bc64a5 100644 (file)
@@ -54,6 +54,7 @@ enum nouveau_drm_handle {
        NVDRM_CLIENT  = 0xffffffff,
        NVDRM_DEVICE  = 0xdddddddd,
        NVDRM_CONTROL = 0xdddddddc,
+       NVDRM_DISPLAY = 0xd1500000,
        NVDRM_PUSH    = 0xbbbb0000, /* |= client chid */
        NVDRM_CHAN    = 0xcccc0000, /* |= client chid */
        NVDRM_NVSW    = 0x55550000,
index 4e384a2f99c3627ea0fc6e31f5f0e34ac95e71e8..6ae7a697866e1ccca6e3fc4aa481def0e1e82992 100644 (file)
@@ -2199,16 +2199,6 @@ nv50_display_destroy(struct drm_device *dev)
 int
 nv50_display_create(struct drm_device *dev)
 {
-       static const u16 oclass[] = {
-               NVF0_DISP_CLASS,
-               NVE0_DISP_CLASS,
-               NVD0_DISP_CLASS,
-               NVA3_DISP_CLASS,
-               NV94_DISP_CLASS,
-               NVA0_DISP_CLASS,
-               NV84_DISP_CLASS,
-               NV50_DISP_CLASS,
-       };
        struct nouveau_device *device = nouveau_dev(dev);
        struct nouveau_drm *drm = nouveau_drm(dev);
        struct dcb_table *dcb = &drm->vbios.dcb;
@@ -2225,6 +2215,7 @@ nv50_display_create(struct drm_device *dev)
        nouveau_display(dev)->dtor = nv50_display_destroy;
        nouveau_display(dev)->init = nv50_display_init;
        nouveau_display(dev)->fini = nv50_display_fini;
+       disp->core = nouveau_display(dev)->core;
 
        /* small shared memory area we use for notifiers and semaphores */
        ret = nouveau_bo_new(dev, 4096, 0x1000, TTM_PL_FLAG_VRAM,
@@ -2240,17 +2231,6 @@ nv50_display_create(struct drm_device *dev)
                        nouveau_bo_ref(NULL, &disp->sync);
        }
 
-       if (ret)
-               goto out;
-
-       /* attempt to allocate a supported evo display class */
-       ret = -ENODEV;
-       for (i = 0; ret && i < ARRAY_SIZE(oclass); i++) {
-               ret = nouveau_object_new(nv_object(drm), NVDRM_DEVICE,
-                                        0xd1500000, oclass[i], NULL, 0,
-                                        &disp->core);
-       }
-
        if (ret)
                goto out;