struct drm_encoder base;
};
-struct ast_framebuffer {
- struct drm_framebuffer base;
- struct drm_gem_object *obj;
-};
-
struct ast_fbdev {
struct drm_fb_helper helper; /* must be first */
- struct ast_framebuffer afb;
void *sysram;
int size;
int x1, y1, x2, y2; /* dirty rect */
#define to_ast_crtc(x) container_of(x, struct ast_crtc, base)
#define to_ast_connector(x) container_of(x, struct ast_connector, base)
#define to_ast_encoder(x) container_of(x, struct ast_encoder, base)
-#define to_ast_framebuffer(x) container_of(x, struct ast_framebuffer, base)
struct ast_vbios_stdtable {
u8 misc;
extern int ast_mode_init(struct drm_device *dev);
extern void ast_mode_fini(struct drm_device *dev);
-int ast_framebuffer_init(struct drm_device *dev,
- struct ast_framebuffer *ast_fb,
- const struct drm_mode_fb_cmd2 *mode_cmd,
- struct drm_gem_object *obj);
-
int ast_fbdev_init(struct drm_device *dev);
void ast_fbdev_fini(struct drm_device *dev);
void ast_fbdev_set_suspend(struct drm_device *dev, int state);
#include <drm/drmP.h>
#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_util.h>
-#include <drm/drm_crtc_helper.h>
#include "ast_drv.h"
int i;
struct drm_gem_vram_object *gbo;
int src_offset, dst_offset;
- int bpp = afbdev->afb.base.format->cpp[0];
int ret;
u8 *dst;
bool unmap = false;
bool store_for_later = false;
int x2, y2;
unsigned long flags;
+ struct drm_framebuffer *fb = afbdev->helper.fb;
+ int bpp = fb->format->cpp[0];
- gbo = drm_gem_vram_of_gem(afbdev->afb.obj);
+ gbo = drm_gem_vram_of_gem(fb->obj[0]);
if (drm_can_sleep()) {
/* We pin the BO so it won't be moved during the
for (i = y; i <= y2; i++) {
/* assume equal stride for now */
- src_offset = dst_offset =
- i * afbdev->afb.base.pitches[0] + (x * bpp);
+ src_offset = dst_offset = i * fb->pitches[0] + (x * bpp);
memcpy_toio(dst + dst_offset, afbdev->sysram + src_offset,
(x2 - x + 1) * bpp);
}
ret = PTR_ERR(info);
goto out;
}
- ret = ast_framebuffer_init(dev, &afbdev->afb, &mode_cmd, gobj);
- if (ret)
+ fb = drm_gem_fbdev_fb_create(dev, sizes, 0, gobj, NULL);
+ if (IS_ERR(fb)) {
+ ret = PTR_ERR(fb);
goto out;
+ }
afbdev->sysram = sysram;
afbdev->size = size;
- fb = &afbdev->afb.base;
afbdev->helper.fb = fb;
info->fbops = &astfb_ops;
static void ast_fbdev_destroy(struct drm_device *dev,
struct ast_fbdev *afbdev)
{
- struct ast_framebuffer *afb = &afbdev->afb;
-
drm_helper_force_disable_all(dev);
drm_fb_helper_unregister_fbi(&afbdev->helper);
- if (afb->obj) {
- drm_gem_object_put_unlocked(afb->obj);
- afb->obj = NULL;
- }
drm_fb_helper_fini(&afbdev->helper);
+ drm_framebuffer_put(afbdev->helper.fb);
vfree(afbdev->sysram);
- drm_framebuffer_unregister_private(&afb->base);
- drm_framebuffer_cleanup(&afb->base);
}
int ast_fbdev_init(struct drm_device *dev)
#include <drm/drmP.h>
#include "ast_drv.h"
-
-#include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
void ast_set_index_reg_mask(struct ast_private *ast,
uint32_t base, uint8_t index,
return 0;
}
-static void ast_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
- struct ast_framebuffer *ast_fb = to_ast_framebuffer(fb);
-
- drm_gem_object_put_unlocked(ast_fb->obj);
- drm_framebuffer_cleanup(fb);
- kfree(ast_fb);
-}
-
-static const struct drm_framebuffer_funcs ast_fb_funcs = {
- .destroy = ast_user_framebuffer_destroy,
-};
-
-
-int ast_framebuffer_init(struct drm_device *dev,
- struct ast_framebuffer *ast_fb,
- const struct drm_mode_fb_cmd2 *mode_cmd,
- struct drm_gem_object *obj)
-{
- int ret;
-
- drm_helper_mode_fill_fb_struct(dev, &ast_fb->base, mode_cmd);
- ast_fb->obj = obj;
- ret = drm_framebuffer_init(dev, &ast_fb->base, &ast_fb_funcs);
- if (ret) {
- DRM_ERROR("framebuffer init failed %d\n", ret);
- return ret;
- }
- return 0;
-}
-
-static struct drm_framebuffer *
-ast_user_framebuffer_create(struct drm_device *dev,
- struct drm_file *filp,
- const struct drm_mode_fb_cmd2 *mode_cmd)
-{
- struct drm_gem_object *obj;
- struct ast_framebuffer *ast_fb;
- int ret;
-
- obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
- if (obj == NULL)
- return ERR_PTR(-ENOENT);
-
- ast_fb = kzalloc(sizeof(*ast_fb), GFP_KERNEL);
- if (!ast_fb) {
- drm_gem_object_put_unlocked(obj);
- return ERR_PTR(-ENOMEM);
- }
-
- ret = ast_framebuffer_init(dev, ast_fb, mode_cmd, obj);
- if (ret) {
- drm_gem_object_put_unlocked(obj);
- kfree(ast_fb);
- return ERR_PTR(ret);
- }
- return &ast_fb->base;
-}
-
static const struct drm_mode_config_funcs ast_mode_funcs = {
- .fb_create = ast_user_framebuffer_create,
+ .fb_create = drm_gem_fb_create
};
static u32 ast_get_vram_info(struct drm_device *dev)
int x, int y, int atomic)
{
struct ast_private *ast = crtc->dev->dev_private;
- struct drm_gem_object *obj;
- struct ast_framebuffer *ast_fb;
struct drm_gem_vram_object *gbo;
int ret;
s64 gpu_addr;
void *base;
if (!atomic && fb) {
- ast_fb = to_ast_framebuffer(fb);
- obj = ast_fb->obj;
- gbo = drm_gem_vram_of_gem(obj);
+ gbo = drm_gem_vram_of_gem(fb->obj[0]);
/* unmap if console */
- if (&ast->fbdev->afb == ast_fb)
+ if (ast->fbdev->helper.fb == fb)
drm_gem_vram_kunmap(gbo);
drm_gem_vram_unpin(gbo);
}
- ast_fb = to_ast_framebuffer(crtc->primary->fb);
- obj = ast_fb->obj;
- gbo = drm_gem_vram_of_gem(obj);
+ gbo = drm_gem_vram_of_gem(crtc->primary->fb->obj[0]);
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
if (ret)
goto err_drm_gem_vram_unpin;
}
- if (&ast->fbdev->afb == ast_fb) {
+ if (ast->fbdev->helper.fb == crtc->primary->fb) {
/* if pushing console in kmap it */
base = drm_gem_vram_kmap(gbo, true, NULL);
if (IS_ERR(base)) {
ast_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
if (crtc->primary->fb) {
struct ast_private *ast = crtc->dev->dev_private;
- struct ast_framebuffer *ast_fb = to_ast_framebuffer(crtc->primary->fb);
- struct drm_gem_object *obj = ast_fb->obj;
- struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(obj);
+ struct drm_framebuffer *fb = crtc->primary->fb;
+ struct drm_gem_vram_object *gbo =
+ drm_gem_vram_of_gem(fb->obj[0]);
/* unmap if console */
- if (&ast->fbdev->afb == ast_fb)
+ if (ast->fbdev->helper.fb == fb)
drm_gem_vram_kunmap(gbo);
drm_gem_vram_unpin(gbo);
}