]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/radeon: radeon_framebuffer -> drm_framebuffer
authorDaniel Stone <daniels@collabora.com>
Fri, 30 Mar 2018 14:11:37 +0000 (15:11 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 11 Apr 2018 18:07:56 +0000 (13:07 -0500)
Since drm_framebuffer can now store GEM objects directly, place them
there rather than in our own subclass. As this makes the framebuffer
create_handle and destroy functions the same as the GEM framebuffer
helper, we can reuse those.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David (ChunMing) Zhou <David1.Zhou@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/atombios_crtc.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_fb.c
drivers/gpu/drm/radeon/radeon_legacy_crtc.c
drivers/gpu/drm/radeon/radeon_mode.h

index 028a811c14625434dac8b13a3eebf3c190fa84f2..efbd5816082d0cd5e67232eaf85d57456c647bf5 100644 (file)
@@ -1145,7 +1145,6 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
-       struct radeon_framebuffer *radeon_fb;
        struct drm_framebuffer *target_fb;
        struct drm_gem_object *obj;
        struct radeon_bo *rbo;
@@ -1164,19 +1163,15 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
                return 0;
        }
 
-       if (atomic) {
-               radeon_fb = to_radeon_framebuffer(fb);
+       if (atomic)
                target_fb = fb;
-       }
-       else {
-               radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
+       else
                target_fb = crtc->primary->fb;
-       }
 
        /* If atomic, assume fb object is pinned & idle & fenced and
         * just update base pointers
         */
-       obj = radeon_fb->base.obj[0];
+       obj = target_fb->obj[0];
        rbo = gem_to_radeon_bo(obj);
        r = radeon_bo_reserve(rbo, false);
        if (unlikely(r != 0))
@@ -1441,8 +1436,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
        WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0);
 
        if (!atomic && fb && fb != crtc->primary->fb) {
-               radeon_fb = to_radeon_framebuffer(fb);
-               rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
+               rbo = gem_to_radeon_bo(fb->obj[0]);
                r = radeon_bo_reserve(rbo, false);
                if (unlikely(r != 0))
                        return r;
@@ -1463,7 +1457,6 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
-       struct radeon_framebuffer *radeon_fb;
        struct drm_gem_object *obj;
        struct radeon_bo *rbo;
        struct drm_framebuffer *target_fb;
@@ -1481,16 +1474,12 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
                return 0;
        }
 
-       if (atomic) {
-               radeon_fb = to_radeon_framebuffer(fb);
+       if (atomic)
                target_fb = fb;
-       }
-       else {
-               radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
+       else
                target_fb = crtc->primary->fb;
-       }
 
-       obj = radeon_fb->base.obj[0];
+       obj = target_fb->obj[0];
        rbo = gem_to_radeon_bo(obj);
        r = radeon_bo_reserve(rbo, false);
        if (unlikely(r != 0))
@@ -1641,8 +1630,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
        WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3);
 
        if (!atomic && fb && fb != crtc->primary->fb) {
-               radeon_fb = to_radeon_framebuffer(fb);
-               rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
+               rbo = gem_to_radeon_bo(fb->obj[0]);
                r = radeon_bo_reserve(rbo, false);
                if (unlikely(r != 0))
                        return r;
@@ -2149,11 +2137,9 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
        atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
        if (crtc->primary->fb) {
                int r;
-               struct radeon_framebuffer *radeon_fb;
                struct radeon_bo *rbo;
 
-               radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-               rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
+               rbo = gem_to_radeon_bo(crtc->primary->fb->obj[0]);
                r = radeon_bo_reserve(rbo, false);
                if (unlikely(r))
                        DRM_ERROR("failed to reserve rbo before unpin\n");
index 30c5bc20a60b8e8703847f0ed77e30edaabdb6e8..90e17e29e12ad654d083fe4c58bd62e5d2ebab2c 100644 (file)
@@ -1587,7 +1587,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
        /* unpin the front buffers and cursors */
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-               struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->primary->fb);
+               struct drm_framebuffer *fb = crtc->primary->fb;
                struct radeon_bo *robj;
 
                if (radeon_crtc->cursor_bo) {
@@ -1599,10 +1599,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
                        }
                }
 
-               if (rfb == NULL || rfb->base.obj[0] == NULL) {
+               if (fb == NULL || fb->obj[0] == NULL) {
                        continue;
                }
-               robj = gem_to_radeon_bo(rfb->base.obj[0]);
+               robj = gem_to_radeon_bo(fb->obj[0]);
                /* don't unpin kernel fb objects */
                if (!radeon_fbdev_robj_is_fb(rdev, robj)) {
                        r = radeon_bo_reserve(robj, false);
index dc300128283d5175d542729cb232ad257c69b7ef..9d3ac8b981dab3d324e2864495c5fe739f4d675f 100644 (file)
@@ -479,8 +479,6 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-       struct radeon_framebuffer *old_radeon_fb;
-       struct radeon_framebuffer *new_radeon_fb;
        struct drm_gem_object *obj;
        struct radeon_flip_work *work;
        struct radeon_bo *new_rbo;
@@ -502,15 +500,13 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
        work->async = (page_flip_flags & DRM_MODE_PAGE_FLIP_ASYNC) != 0;
 
        /* schedule unpin of the old buffer */
-       old_radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
-       obj = old_radeon_fb->base.obj[0];
+       obj = crtc->primary->fb->obj[0];
 
        /* take a reference to the old object */
        drm_gem_object_get(obj);
        work->old_rbo = gem_to_radeon_bo(obj);
 
-       new_radeon_fb = to_radeon_framebuffer(fb);
-       obj = new_radeon_fb->base.obj[0];
+       obj = fb->obj[0];
        new_rbo = gem_to_radeon_bo(obj);
 
        /* pin the new buffer */
@@ -1293,16 +1289,16 @@ static const struct drm_framebuffer_funcs radeon_fb_funcs = {
 
 int
 radeon_framebuffer_init(struct drm_device *dev,
-                       struct radeon_framebuffer *rfb,
+                       struct drm_framebuffer *fb,
                        const struct drm_mode_fb_cmd2 *mode_cmd,
                        struct drm_gem_object *obj)
 {
        int ret;
-       rfb->base.obj[0] = obj;
-       drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
-       ret = drm_framebuffer_init(dev, &rfb->base, &radeon_fb_funcs);
+       fb->obj[0] = obj;
+       drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
+       ret = drm_framebuffer_init(dev, fb, &radeon_fb_funcs);
        if (ret) {
-               rfb->base.obj[0] = NULL;
+               fb->obj[0] = NULL;
                return ret;
        }
        return 0;
@@ -1314,7 +1310,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
                               const struct drm_mode_fb_cmd2 *mode_cmd)
 {
        struct drm_gem_object *obj;
-       struct radeon_framebuffer *radeon_fb;
+       struct drm_framebuffer *fb;
        int ret;
 
        obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -1330,20 +1326,20 @@ radeon_user_framebuffer_create(struct drm_device *dev,
                return ERR_PTR(-EINVAL);
        }
 
-       radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL);
-       if (radeon_fb == NULL) {
+       fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+       if (fb == NULL) {
                drm_gem_object_put_unlocked(obj);
                return ERR_PTR(-ENOMEM);
        }
 
-       ret = radeon_framebuffer_init(dev, radeon_fb, mode_cmd, obj);
+       ret = radeon_framebuffer_init(dev, fb, mode_cmd, obj);
        if (ret) {
-               kfree(radeon_fb);
+               kfree(fb);
                drm_gem_object_put_unlocked(obj);
                return ERR_PTR(ret);
        }
 
-       return &radeon_fb->base;
+       return fb;
 }
 
 static const struct drm_mode_config_funcs radeon_mode_funcs = {
index 6cd99f6a4305e157f1a45d220599d647000c0571..1179034024aeafb81ea5f1b9fc911f1bf845c8d0 100644 (file)
@@ -43,7 +43,7 @@
  */
 struct radeon_fbdev {
        struct drm_fb_helper helper;
-       struct radeon_framebuffer rfb;
+       struct drm_framebuffer fb;
        struct radeon_device *rdev;
 };
 
@@ -246,13 +246,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
 
        info->par = rfbdev;
 
-       ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
+       ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj);
        if (ret) {
                DRM_ERROR("failed to initialize framebuffer %d\n", ret);
                goto out;
        }
 
-       fb = &rfbdev->rfb.base;
+       fb = &rfbdev->fb;
 
        /* setup helper */
        rfbdev->helper.fb = fb;
@@ -308,15 +308,15 @@ out:
 
 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
 {
-       struct radeon_framebuffer *rfb = &rfbdev->rfb;
+       struct drm_framebuffer *fb = &rfbdev->fb;
 
        drm_fb_helper_unregister_fbi(&rfbdev->helper);
 
-       if (rfb->base.obj[0]) {
-               radeonfb_destroy_pinned_object(rfb->base.obj[0]);
-               rfb->base.obj[0] = NULL;
-               drm_framebuffer_unregister_private(&rfb->base);
-               drm_framebuffer_cleanup(&rfb->base);
+       if (fb->obj[0]) {
+               radeonfb_destroy_pinned_object(fb->obj[0]);
+               fb->obj[0] = NULL;
+               drm_framebuffer_unregister_private(fb);
+               drm_framebuffer_cleanup(fb);
        }
        drm_fb_helper_fini(&rfbdev->helper);
 
@@ -400,7 +400,7 @@ bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
        if (!rdev->mode_info.rfbdev)
                return false;
 
-       if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->rfb.base.obj[0]))
+       if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->fb.obj[0]))
                return true;
        return false;
 }
index 50b3f556845acd886ab2775c3db0226a99433b83..35a205ae4318a23a970d9761127642ec46b39156 100644 (file)
@@ -374,7 +374,6 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-       struct radeon_framebuffer *radeon_fb;
        struct drm_framebuffer *target_fb;
        struct drm_gem_object *obj;
        struct radeon_bo *rbo;
@@ -393,14 +392,10 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
                return 0;
        }
 
-       if (atomic) {
-               radeon_fb = to_radeon_framebuffer(fb);
+       if (atomic)
                target_fb = fb;
-       }
-       else {
-               radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
+       else
                target_fb = crtc->primary->fb;
-       }
 
        switch (target_fb->format->cpp[0] * 8) {
        case 8:
@@ -423,7 +418,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
        }
 
        /* Pin framebuffer & get tilling informations */
-       obj = radeon_fb->base.obj[0];
+       obj = target_fb->obj[0];
        rbo = gem_to_radeon_bo(obj);
 retry:
        r = radeon_bo_reserve(rbo, false);
index cd93c80332f71a63b4b75c09ebd2841acb63946a..fd470d6bf3f4301a9c6a77443bc253243b7f1eb2 100644 (file)
@@ -46,7 +46,6 @@ struct radeon_device;
 #define to_radeon_crtc(x) container_of(x, struct radeon_crtc, base)
 #define to_radeon_connector(x) container_of(x, struct radeon_connector, base)
 #define to_radeon_encoder(x) container_of(x, struct radeon_encoder, base)
-#define to_radeon_framebuffer(x) container_of(x, struct radeon_framebuffer, base)
 
 #define RADEON_MAX_HPD_PINS 7
 #define RADEON_MAX_CRTCS 6
@@ -574,10 +573,6 @@ struct radeon_connector {
        int enabled_attribs;
 };
 
-struct radeon_framebuffer {
-       struct drm_framebuffer base;
-};
-
 #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
                                ((em) == ATOM_ENCODER_MODE_DP_MST))
 
@@ -931,7 +926,7 @@ radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc);
 extern void
 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on);
 int radeon_framebuffer_init(struct drm_device *dev,
-                            struct radeon_framebuffer *rfb,
+                            struct drm_framebuffer *rfb,
                             const struct drm_mode_fb_cmd2 *mode_cmd,
                             struct drm_gem_object *obj);