提交 9a0f0c9d 编写于 作者: D Daniel Stone 提交者: Alex Deucher

drm/radeon: radeon_framebuffer -> drm_framebuffer

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: NAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: NDaniel 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: NAlex Deucher <alexander.deucher@amd.com>
上级 a110dfe3
...@@ -1145,7 +1145,6 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -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 radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct radeon_framebuffer *radeon_fb;
struct drm_framebuffer *target_fb; struct drm_framebuffer *target_fb;
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct radeon_bo *rbo; struct radeon_bo *rbo;
...@@ -1164,19 +1163,15 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -1164,19 +1163,15 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
return 0; return 0;
} }
if (atomic) { if (atomic)
radeon_fb = to_radeon_framebuffer(fb);
target_fb = fb; target_fb = fb;
} else
else {
radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
target_fb = crtc->primary->fb; target_fb = crtc->primary->fb;
}
/* If atomic, assume fb object is pinned & idle & fenced and /* If atomic, assume fb object is pinned & idle & fenced and
* just update base pointers * just update base pointers
*/ */
obj = radeon_fb->base.obj[0]; obj = target_fb->obj[0];
rbo = gem_to_radeon_bo(obj); rbo = gem_to_radeon_bo(obj);
r = radeon_bo_reserve(rbo, false); r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0)) if (unlikely(r != 0))
...@@ -1441,8 +1436,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -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); WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0);
if (!atomic && fb && fb != crtc->primary->fb) { if (!atomic && fb && fb != crtc->primary->fb) {
radeon_fb = to_radeon_framebuffer(fb); rbo = gem_to_radeon_bo(fb->obj[0]);
rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
r = radeon_bo_reserve(rbo, false); r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0)) if (unlikely(r != 0))
return r; return r;
...@@ -1463,7 +1457,6 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -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 radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct radeon_framebuffer *radeon_fb;
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct radeon_bo *rbo; struct radeon_bo *rbo;
struct drm_framebuffer *target_fb; struct drm_framebuffer *target_fb;
...@@ -1481,16 +1474,12 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -1481,16 +1474,12 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
return 0; return 0;
} }
if (atomic) { if (atomic)
radeon_fb = to_radeon_framebuffer(fb);
target_fb = fb; target_fb = fb;
} else
else {
radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
target_fb = crtc->primary->fb; target_fb = crtc->primary->fb;
}
obj = radeon_fb->base.obj[0]; obj = target_fb->obj[0];
rbo = gem_to_radeon_bo(obj); rbo = gem_to_radeon_bo(obj);
r = radeon_bo_reserve(rbo, false); r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0)) if (unlikely(r != 0))
...@@ -1641,8 +1630,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -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); WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3);
if (!atomic && fb && fb != crtc->primary->fb) { if (!atomic && fb && fb != crtc->primary->fb) {
radeon_fb = to_radeon_framebuffer(fb); rbo = gem_to_radeon_bo(fb->obj[0]);
rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
r = radeon_bo_reserve(rbo, false); r = radeon_bo_reserve(rbo, false);
if (unlikely(r != 0)) if (unlikely(r != 0))
return r; return r;
...@@ -2149,11 +2137,9 @@ static void atombios_crtc_disable(struct drm_crtc *crtc) ...@@ -2149,11 +2137,9 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
if (crtc->primary->fb) { if (crtc->primary->fb) {
int r; int r;
struct radeon_framebuffer *radeon_fb;
struct radeon_bo *rbo; struct radeon_bo *rbo;
radeon_fb = to_radeon_framebuffer(crtc->primary->fb); rbo = gem_to_radeon_bo(crtc->primary->fb->obj[0]);
rbo = gem_to_radeon_bo(radeon_fb->base.obj[0]);
r = radeon_bo_reserve(rbo, false); r = radeon_bo_reserve(rbo, false);
if (unlikely(r)) if (unlikely(r))
DRM_ERROR("failed to reserve rbo before unpin\n"); DRM_ERROR("failed to reserve rbo before unpin\n");
......
...@@ -1587,7 +1587,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, ...@@ -1587,7 +1587,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend,
/* unpin the front buffers and cursors */ /* unpin the front buffers and cursors */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 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; struct radeon_bo *robj;
if (radeon_crtc->cursor_bo) { if (radeon_crtc->cursor_bo) {
...@@ -1599,10 +1599,10 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, ...@@ -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; continue;
} }
robj = gem_to_radeon_bo(rfb->base.obj[0]); robj = gem_to_radeon_bo(fb->obj[0]);
/* don't unpin kernel fb objects */ /* don't unpin kernel fb objects */
if (!radeon_fbdev_robj_is_fb(rdev, robj)) { if (!radeon_fbdev_robj_is_fb(rdev, robj)) {
r = radeon_bo_reserve(robj, false); r = radeon_bo_reserve(robj, false);
......
...@@ -479,8 +479,6 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc, ...@@ -479,8 +479,6 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 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 drm_gem_object *obj;
struct radeon_flip_work *work; struct radeon_flip_work *work;
struct radeon_bo *new_rbo; struct radeon_bo *new_rbo;
...@@ -502,15 +500,13 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc, ...@@ -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; work->async = (page_flip_flags & DRM_MODE_PAGE_FLIP_ASYNC) != 0;
/* schedule unpin of the old buffer */ /* schedule unpin of the old buffer */
old_radeon_fb = to_radeon_framebuffer(crtc->primary->fb); obj = crtc->primary->fb->obj[0];
obj = old_radeon_fb->base.obj[0];
/* take a reference to the old object */ /* take a reference to the old object */
drm_gem_object_get(obj); drm_gem_object_get(obj);
work->old_rbo = gem_to_radeon_bo(obj); work->old_rbo = gem_to_radeon_bo(obj);
new_radeon_fb = to_radeon_framebuffer(fb); obj = fb->obj[0];
obj = new_radeon_fb->base.obj[0];
new_rbo = gem_to_radeon_bo(obj); new_rbo = gem_to_radeon_bo(obj);
/* pin the new buffer */ /* pin the new buffer */
...@@ -1293,16 +1289,16 @@ static const struct drm_framebuffer_funcs radeon_fb_funcs = { ...@@ -1293,16 +1289,16 @@ static const struct drm_framebuffer_funcs radeon_fb_funcs = {
int int
radeon_framebuffer_init(struct drm_device *dev, radeon_framebuffer_init(struct drm_device *dev,
struct radeon_framebuffer *rfb, struct drm_framebuffer *fb,
const struct drm_mode_fb_cmd2 *mode_cmd, const struct drm_mode_fb_cmd2 *mode_cmd,
struct drm_gem_object *obj) struct drm_gem_object *obj)
{ {
int ret; int ret;
rfb->base.obj[0] = obj; fb->obj[0] = obj;
drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd); drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
ret = drm_framebuffer_init(dev, &rfb->base, &radeon_fb_funcs); ret = drm_framebuffer_init(dev, fb, &radeon_fb_funcs);
if (ret) { if (ret) {
rfb->base.obj[0] = NULL; fb->obj[0] = NULL;
return ret; return ret;
} }
return 0; return 0;
...@@ -1314,7 +1310,7 @@ radeon_user_framebuffer_create(struct drm_device *dev, ...@@ -1314,7 +1310,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd) const struct drm_mode_fb_cmd2 *mode_cmd)
{ {
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct radeon_framebuffer *radeon_fb; struct drm_framebuffer *fb;
int ret; int ret;
obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
...@@ -1330,20 +1326,20 @@ radeon_user_framebuffer_create(struct drm_device *dev, ...@@ -1330,20 +1326,20 @@ radeon_user_framebuffer_create(struct drm_device *dev,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL); fb = kzalloc(sizeof(*fb), GFP_KERNEL);
if (radeon_fb == NULL) { if (fb == NULL) {
drm_gem_object_put_unlocked(obj); drm_gem_object_put_unlocked(obj);
return ERR_PTR(-ENOMEM); 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) { if (ret) {
kfree(radeon_fb); kfree(fb);
drm_gem_object_put_unlocked(obj); drm_gem_object_put_unlocked(obj);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
return &radeon_fb->base; return fb;
} }
static const struct drm_mode_config_funcs radeon_mode_funcs = { static const struct drm_mode_config_funcs radeon_mode_funcs = {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
*/ */
struct radeon_fbdev { struct radeon_fbdev {
struct drm_fb_helper helper; struct drm_fb_helper helper;
struct radeon_framebuffer rfb; struct drm_framebuffer fb;
struct radeon_device *rdev; struct radeon_device *rdev;
}; };
...@@ -246,13 +246,13 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -246,13 +246,13 @@ static int radeonfb_create(struct drm_fb_helper *helper,
info->par = rfbdev; 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) { if (ret) {
DRM_ERROR("failed to initialize framebuffer %d\n", ret); DRM_ERROR("failed to initialize framebuffer %d\n", ret);
goto out; goto out;
} }
fb = &rfbdev->rfb.base; fb = &rfbdev->fb;
/* setup helper */ /* setup helper */
rfbdev->helper.fb = fb; rfbdev->helper.fb = fb;
...@@ -308,15 +308,15 @@ static int radeonfb_create(struct drm_fb_helper *helper, ...@@ -308,15 +308,15 @@ static int radeonfb_create(struct drm_fb_helper *helper,
static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev) 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); drm_fb_helper_unregister_fbi(&rfbdev->helper);
if (rfb->base.obj[0]) { if (fb->obj[0]) {
radeonfb_destroy_pinned_object(rfb->base.obj[0]); radeonfb_destroy_pinned_object(fb->obj[0]);
rfb->base.obj[0] = NULL; fb->obj[0] = NULL;
drm_framebuffer_unregister_private(&rfb->base); drm_framebuffer_unregister_private(fb);
drm_framebuffer_cleanup(&rfb->base); drm_framebuffer_cleanup(fb);
} }
drm_fb_helper_fini(&rfbdev->helper); drm_fb_helper_fini(&rfbdev->helper);
...@@ -400,7 +400,7 @@ bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj) ...@@ -400,7 +400,7 @@ bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
if (!rdev->mode_info.rfbdev) if (!rdev->mode_info.rfbdev)
return false; 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 true;
return false; return false;
} }
......
...@@ -374,7 +374,6 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -374,7 +374,6 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct radeon_framebuffer *radeon_fb;
struct drm_framebuffer *target_fb; struct drm_framebuffer *target_fb;
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct radeon_bo *rbo; struct radeon_bo *rbo;
...@@ -393,14 +392,10 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -393,14 +392,10 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
return 0; return 0;
} }
if (atomic) { if (atomic)
radeon_fb = to_radeon_framebuffer(fb);
target_fb = fb; target_fb = fb;
} else
else {
radeon_fb = to_radeon_framebuffer(crtc->primary->fb);
target_fb = crtc->primary->fb; target_fb = crtc->primary->fb;
}
switch (target_fb->format->cpp[0] * 8) { switch (target_fb->format->cpp[0] * 8) {
case 8: case 8:
...@@ -423,7 +418,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc, ...@@ -423,7 +418,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
} }
/* Pin framebuffer & get tilling informations */ /* Pin framebuffer & get tilling informations */
obj = radeon_fb->base.obj[0]; obj = target_fb->obj[0];
rbo = gem_to_radeon_bo(obj); rbo = gem_to_radeon_bo(obj);
retry: retry:
r = radeon_bo_reserve(rbo, false); r = radeon_bo_reserve(rbo, false);
......
...@@ -46,7 +46,6 @@ struct radeon_device; ...@@ -46,7 +46,6 @@ struct radeon_device;
#define to_radeon_crtc(x) container_of(x, struct radeon_crtc, base) #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_connector(x) container_of(x, struct radeon_connector, base)
#define to_radeon_encoder(x) container_of(x, struct radeon_encoder, 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_HPD_PINS 7
#define RADEON_MAX_CRTCS 6 #define RADEON_MAX_CRTCS 6
...@@ -574,10 +573,6 @@ struct radeon_connector { ...@@ -574,10 +573,6 @@ struct radeon_connector {
int enabled_attribs; int enabled_attribs;
}; };
struct radeon_framebuffer {
struct drm_framebuffer base;
};
#define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \ #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
((em) == ATOM_ENCODER_MODE_DP_MST)) ((em) == ATOM_ENCODER_MODE_DP_MST))
...@@ -931,7 +926,7 @@ radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc); ...@@ -931,7 +926,7 @@ radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc);
extern void extern void
radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on); radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on);
int radeon_framebuffer_init(struct drm_device *dev, int radeon_framebuffer_init(struct drm_device *dev,
struct radeon_framebuffer *rfb, struct drm_framebuffer *rfb,
const struct drm_mode_fb_cmd2 *mode_cmd, const struct drm_mode_fb_cmd2 *mode_cmd,
struct drm_gem_object *obj); struct drm_gem_object *obj);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册