diff options
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/mediatek/mtk_drm_fb.c | 38 | ||||
| -rw-r--r-- | drivers/gpu/drm/mediatek/mtk_drm_fb.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/mediatek/mtk_drm_plane.c | 2 |
3 files changed, 6 insertions, 35 deletions
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c index 0d8d506695f9..f130e37123b5 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <drm/drm_crtc_helper.h> | 15 | #include <drm/drm_crtc_helper.h> |
| 16 | #include <drm/drm_fb_helper.h> | 16 | #include <drm/drm_fb_helper.h> |
| 17 | #include <drm/drm_gem.h> | 17 | #include <drm/drm_gem.h> |
| 18 | #include <drm/drm_gem_framebuffer_helper.h> | ||
| 18 | #include <linux/dma-buf.h> | 19 | #include <linux/dma-buf.h> |
| 19 | #include <linux/reservation.h> | 20 | #include <linux/reservation.h> |
| 20 | 21 | ||
| @@ -30,42 +31,13 @@ | |||
| 30 | */ | 31 | */ |
| 31 | struct mtk_drm_fb { | 32 | struct mtk_drm_fb { |
| 32 | struct drm_framebuffer base; | 33 | struct drm_framebuffer base; |
| 33 | /* For now we only support a single plane */ | ||
| 34 | struct drm_gem_object *gem_obj; | ||
| 35 | }; | 34 | }; |
| 36 | 35 | ||
| 37 | #define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base) | 36 | #define to_mtk_fb(x) container_of(x, struct mtk_drm_fb, base) |
| 38 | 37 | ||
| 39 | struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb) | ||
| 40 | { | ||
| 41 | struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb); | ||
| 42 | |||
| 43 | return mtk_fb->gem_obj; | ||
| 44 | } | ||
| 45 | |||
| 46 | static int mtk_drm_fb_create_handle(struct drm_framebuffer *fb, | ||
| 47 | struct drm_file *file_priv, | ||
| 48 | unsigned int *handle) | ||
| 49 | { | ||
| 50 | struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb); | ||
| 51 | |||
| 52 | return drm_gem_handle_create(file_priv, mtk_fb->gem_obj, handle); | ||
| 53 | } | ||
| 54 | |||
| 55 | static void mtk_drm_fb_destroy(struct drm_framebuffer *fb) | ||
| 56 | { | ||
| 57 | struct mtk_drm_fb *mtk_fb = to_mtk_fb(fb); | ||
| 58 | |||
| 59 | drm_framebuffer_cleanup(fb); | ||
| 60 | |||
| 61 | drm_gem_object_put_unlocked(mtk_fb->gem_obj); | ||
| 62 | |||
| 63 | kfree(mtk_fb); | ||
| 64 | } | ||
| 65 | |||
| 66 | static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = { | 38 | static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = { |
| 67 | .create_handle = mtk_drm_fb_create_handle, | 39 | .create_handle = drm_gem_fb_create_handle, |
| 68 | .destroy = mtk_drm_fb_destroy, | 40 | .destroy = drm_gem_fb_destroy, |
| 69 | }; | 41 | }; |
| 70 | 42 | ||
| 71 | static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev, | 43 | static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev, |
| @@ -84,7 +56,7 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev, | |||
| 84 | 56 | ||
| 85 | drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode); | 57 | drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode); |
| 86 | 58 | ||
| 87 | mtk_fb->gem_obj = obj; | 59 | mtk_fb->base.obj[0] = obj; |
| 88 | 60 | ||
| 89 | ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs); | 61 | ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs); |
| 90 | if (ret) { | 62 | if (ret) { |
| @@ -110,7 +82,7 @@ int mtk_fb_wait(struct drm_framebuffer *fb) | |||
| 110 | if (!fb) | 82 | if (!fb) |
| 111 | return 0; | 83 | return 0; |
| 112 | 84 | ||
| 113 | gem = mtk_fb_get_gem_obj(fb); | 85 | gem = fb->obj[0]; |
| 114 | if (!gem || !gem->dma_buf || !gem->dma_buf->resv) | 86 | if (!gem || !gem->dma_buf || !gem->dma_buf->resv) |
| 115 | return 0; | 87 | return 0; |
| 116 | 88 | ||
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h b/drivers/gpu/drm/mediatek/mtk_drm_fb.h index 9b2ae345a4e9..7f976b196a15 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #ifndef MTK_DRM_FB_H | 14 | #ifndef MTK_DRM_FB_H |
| 15 | #define MTK_DRM_FB_H | 15 | #define MTK_DRM_FB_H |
| 16 | 16 | ||
| 17 | struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb); | ||
| 18 | int mtk_fb_wait(struct drm_framebuffer *fb); | 17 | int mtk_fb_wait(struct drm_framebuffer *fb); |
| 19 | struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev, | 18 | struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev, |
| 20 | struct drm_file *file, | 19 | struct drm_file *file, |
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c index 149fc4372917..f7e6aa1b5b7d 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c | |||
| @@ -122,7 +122,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane, | |||
| 122 | if (!crtc || WARN_ON(!fb)) | 122 | if (!crtc || WARN_ON(!fb)) |
| 123 | return; | 123 | return; |
| 124 | 124 | ||
| 125 | gem = mtk_fb_get_gem_obj(fb); | 125 | gem = fb->obj[0]; |
| 126 | mtk_gem = to_mtk_gem_obj(gem); | 126 | mtk_gem = to_mtk_gem_obj(gem); |
| 127 | addr = mtk_gem->dma_addr; | 127 | addr = mtk_gem->dma_addr; |
| 128 | pitch = fb->pitches[0]; | 128 | pitch = fb->pitches[0]; |
