summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2019-11-14 17:10:25 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2019-11-26 14:34:50 +0300
commit8ed447744bec60b05acf452af889f56934275c99 (patch)
treee6e7b083b40b33f09269ee160a8461d02bc08520 /drivers
parent8344603534e17f9926253a65088f59b787222bc5 (diff)
downloadlinux-8ed447744bec60b05acf452af889f56934275c99.tar.xz
drm/udl: Replace struct udl_framebuffer with generic implementation
The udl driver's struct udl_framebuffer stores a DRM framebuffer with an associated GEM object. This functionality is also provided by generic code. Switch udl over. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20191114141025.32198-6-tzimmermann@suse.de
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/udl/udl_drv.h7
-rw-r--r--drivers/gpu/drm/udl/udl_fb.c62
2 files changed, 6 insertions, 63 deletions
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index c5e3160392cb..66cbe04f832a 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -74,13 +74,6 @@ struct udl_device {
#define to_udl(x) container_of(x, struct udl_device, drm)
-struct udl_framebuffer {
- struct drm_framebuffer base;
- struct drm_gem_shmem_object *shmem;
-};
-
-#define to_udl_fb(x) container_of(x, struct udl_framebuffer, base)
-
/* modeset */
int udl_modeset_init(struct drm_device *dev);
void udl_modeset_restore(struct drm_device *dev);
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index ad7bf165b59b..c1996ac73a1f 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -14,6 +14,7 @@
#include <drm/drm_crtc_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fourcc.h>
+#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_modeset_helper.h>
@@ -199,68 +200,17 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
return ret;
}
-static void udl_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
- struct udl_framebuffer *ufb = to_udl_fb(fb);
-
- if (ufb->shmem)
- drm_gem_object_put_unlocked(&ufb->shmem->base);
-
- drm_framebuffer_cleanup(fb);
- kfree(ufb);
-}
-
static const struct drm_framebuffer_funcs udlfb_funcs = {
- .destroy = udl_user_framebuffer_destroy,
- .dirty = udl_user_framebuffer_dirty,
+ .destroy = drm_gem_fb_destroy,
+ .create_handle = drm_gem_fb_create_handle,
+ .dirty = udl_user_framebuffer_dirty,
};
-
-static int
-udl_framebuffer_init(struct drm_device *dev,
- struct udl_framebuffer *ufb,
- const struct drm_mode_fb_cmd2 *mode_cmd,
- struct drm_gem_shmem_object *shmem)
-{
- int ret;
-
- ufb->shmem = shmem;
- drm_helper_mode_fill_fb_struct(dev, &ufb->base, mode_cmd);
- ret = drm_framebuffer_init(dev, &ufb->base, &udlfb_funcs);
- return ret;
-}
-
struct drm_framebuffer *
udl_fb_user_fb_create(struct drm_device *dev,
struct drm_file *file,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
- struct drm_gem_object *obj;
- struct udl_framebuffer *ufb;
- int ret;
- uint32_t size;
-
- obj = drm_gem_object_lookup(file, mode_cmd->handles[0]);
- if (obj == NULL)
- return ERR_PTR(-ENOENT);
-
- size = mode_cmd->pitches[0] * mode_cmd->height;
- size = ALIGN(size, PAGE_SIZE);
-
- if (size > obj->size) {
- DRM_ERROR("object size not sufficient for fb %d %zu %d %d\n", size, obj->size, mode_cmd->pitches[0], mode_cmd->height);
- return ERR_PTR(-ENOMEM);
- }
-
- ufb = kzalloc(sizeof(*ufb), GFP_KERNEL);
- if (ufb == NULL)
- return ERR_PTR(-ENOMEM);
-
- ret = udl_framebuffer_init(dev, ufb, mode_cmd,
- to_drm_gem_shmem_obj(obj));
- if (ret) {
- kfree(ufb);
- return ERR_PTR(-EINVAL);
- }
- return &ufb->base;
+ return drm_gem_fb_create_with_funcs(dev, file, mode_cmd,
+ &udlfb_funcs);
}