dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Stone <daniels@collabora.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer
Date: Fri, 30 Mar 2018 15:11:20 +0100	[thread overview]
Message-ID: <20180330141138.28987-6-daniels@collabora.com> (raw)
In-Reply-To: <20180330141138.28987-1-daniels@collabora.com>

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.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_fb.c | 60 ++++++++++-----------------------------
 1 file changed, 15 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 5fd22ca73913..3d6b6f3d6808 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -19,6 +19,7 @@
 
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 #include "omap_dmm_tiler.h"
 #include "omap_drv.h"
@@ -51,7 +52,6 @@ static const u32 formats[] = {
 
 /* per-plane info for the fb: */
 struct plane {
-	struct drm_gem_object *bo;
 	u32 pitch;
 	u32 offset;
 	dma_addr_t dma_addr;
@@ -68,36 +68,9 @@ struct omap_framebuffer {
 	struct mutex lock;
 };
 
-static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
-		struct drm_file *file_priv,
-		unsigned int *handle)
-{
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	return drm_gem_handle_create(file_priv,
-			omap_fb->planes[0].bo, handle);
-}
-
-static void omap_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	int i, n = fb->format->num_planes;
-
-	DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
-
-	drm_framebuffer_cleanup(fb);
-
-	for (i = 0; i < n; i++) {
-		struct plane *plane = &omap_fb->planes[i];
-
-		drm_gem_object_unreference_unlocked(plane->bo);
-	}
-
-	kfree(omap_fb);
-}
-
 static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
-	.create_handle = omap_framebuffer_create_handle,
-	.destroy = omap_framebuffer_destroy,
+	.create_handle = drm_gem_fb_create_handle,
+	.destroy = drm_gem_fb_destroy,
 };
 
 static u32 get_linear_addr(struct plane *plane,
@@ -114,10 +87,7 @@ static u32 get_linear_addr(struct plane *plane,
 
 bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
 {
-	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
-	struct plane *plane = &omap_fb->planes[0];
-
-	return omap_gem_flags(plane->bo) & OMAP_BO_TILED;
+	return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED;
 }
 
 /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
@@ -176,7 +146,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 	x = state->src_x >> 16;
 	y = state->src_y >> 16;
 
-	if (omap_gem_flags(plane->bo) & OMAP_BO_TILED) {
+	if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED) {
 		u32 w = state->src_w >> 16;
 		u32 h = state->src_h >> 16;
 
@@ -201,12 +171,12 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 			x += w - 1;
 
 		/* Note: x and y are in TILER units, not pixels */
-		omap_gem_rotated_dma_addr(plane->bo, orient, x, y,
+		omap_gem_rotated_dma_addr(fb->obj[0], orient, x, y,
 					  &info->paddr);
 		info->rotation_type = OMAP_DSS_ROT_TILER;
 		info->rotation = state->rotation ?: DRM_MODE_ROTATE_0;
 		/* Note: stride in TILER units, not pixels */
-		info->screen_width  = omap_gem_tiled_stride(plane->bo, orient);
+		info->screen_width  = omap_gem_tiled_stride(fb->obj[0], orient);
 	} else {
 		switch (state->rotation & DRM_MODE_ROTATE_MASK) {
 		case 0:
@@ -234,8 +204,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 		plane = &omap_fb->planes[1];
 
 		if (info->rotation_type == OMAP_DSS_ROT_TILER) {
-			WARN_ON(!(omap_gem_flags(plane->bo) & OMAP_BO_TILED));
-			omap_gem_rotated_dma_addr(plane->bo, orient, x/2, y/2,
+			WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED));
+			omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2,
 						  &info->p_uv_addr);
 		} else {
 			info->p_uv_addr = get_linear_addr(plane, format, 1, x, y);
@@ -261,10 +231,10 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		ret = omap_gem_pin(plane->bo, &plane->dma_addr);
+		ret = omap_gem_pin(fb->obj[i], &plane->dma_addr);
 		if (ret)
 			goto fail;
-		omap_gem_dma_sync_buffer(plane->bo, DMA_TO_DEVICE);
+		omap_gem_dma_sync_buffer(fb->obj[i], DMA_TO_DEVICE);
 	}
 
 	omap_fb->pin_count++;
@@ -276,7 +246,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 fail:
 	for (i--; i >= 0; i--) {
 		struct plane *plane = &omap_fb->planes[i];
-		omap_gem_unpin(plane->bo);
+		omap_gem_unpin(fb->obj[i]);
 		plane->dma_addr = 0;
 	}
 
@@ -302,7 +272,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		omap_gem_unpin(plane->bo);
+		omap_gem_unpin(fb->obj[i]);
 		plane->dma_addr = 0;
 	}
 
@@ -349,7 +319,7 @@ void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
 		struct plane *plane = &omap_fb->planes[i];
 		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
 				i, plane->offset, plane->pitch);
-		omap_gem_describe(plane->bo, m);
+		omap_gem_describe(fb->obj[i], m);
 	}
 }
 #endif
@@ -454,7 +424,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 			goto fail;
 		}
 
-		plane->bo     = bos[i];
+		fb->obj[i]    = bos[i];
 		plane->offset = mode_cmd->offsets[i];
 		plane->pitch  = pitch;
 		plane->dma_addr  = 0;
-- 
2.16.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-03-30 14:11 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30 14:11 [PATCH 00/24] drm_framebuffer boilerplate removal Daniel Stone
2018-03-30 14:11 ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Daniel Stone
2018-03-30 14:11   ` [PATCH 02/24] drm/cirrus: cirrus_framebuffer -> drm_framebuffer Daniel Stone
2018-05-17 14:25     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 03/24] drm/virtio: Place GEM BOs in drm_framebuffer Daniel Stone
2018-05-17 14:29     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 04/24] drm/rockchip: " Daniel Stone
2018-05-17 13:57     ` Sean Paul
2018-05-17 14:47     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 05/24] drm/rockchip: rockchip_drm_fb -> drm_framebuffer Daniel Stone
2018-05-17 13:08     ` Daniel Stone
2018-05-17 13:42       ` Heiko Stübner
2018-05-17 14:09         ` Daniel Stone
2018-05-17 13:56     ` Sean Paul
2018-05-17 14:46     ` Thierry Reding
2018-03-30 14:11   ` Daniel Stone [this message]
2018-03-30 20:54     ` [PATCH 06/24] drm/omap: Move GEM BO to drm_framebuffer Sebastian Reichel
2018-05-17 14:47     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 07/24] drm/omap: Move buffer pitch/offset " Daniel Stone
2018-03-30 20:53     ` Sebastian Reichel
2018-05-17 13:13       ` Daniel Stone
2018-05-17 14:49     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 08/24] drm/mtk: Promote impossible internal error to WARN_ON Daniel Stone
2018-05-17 13:58     ` Sean Paul
2018-05-17 14:55       ` Thierry Reding
2018-05-18  8:06         ` CK Hu
2018-03-30 14:11   ` [PATCH 09/24] drm/mtk: Move GEM BO to drm_framebuffer Daniel Stone
2018-05-17 13:59     ` Sean Paul
2018-05-17 14:55     ` Thierry Reding
2018-05-18  8:32     ` CK Hu
2018-03-30 14:11   ` [PATCH 10/24] drm/mtk: mtk_drm_fb -> drm_framebuffer Daniel Stone
2018-05-17 13:13     ` Daniel Stone
2018-05-17 13:59     ` Sean Paul
2018-05-17 14:56     ` Thierry Reding
2018-05-18  8:37     ` CK Hu
2018-03-30 14:11   ` [PATCH 11/24] drm/tegra: Remove duplicate framebuffer num_planes Daniel Stone
2018-03-30 14:11   ` [PATCH 12/24] drm/tegra: Move GEM BOs to drm_framebuffer Daniel Stone
2018-03-30 14:11   ` [PATCH 13/24] drm/tegra: tegra_fb -> drm_framebuffer Daniel Stone
2018-05-17 13:11     ` Daniel Stone
2018-05-17 13:46       ` Thierry Reding
2018-03-30 14:11   ` [PATCH 14/24] drm/tegra: Move fbdev unmap special case Daniel Stone
2018-03-30 14:11   ` [PATCH 15/24] drm/tegra: Use drm_gem_fb_destroy Daniel Stone
2018-03-30 14:11   ` [PATCH 16/24] drm/exynos: Move GEM BOs to drm_framebuffer Daniel Stone
2018-04-13  8:55     ` Inki Dae
2018-04-13 10:13       ` Daniel Stone
2018-03-30 14:11   ` [PATCH 17/24] drm/exynos: Move dma_addr out of exynos_drm_fb Daniel Stone
2018-03-30 14:11   ` [PATCH 18/24] drm/exynos: exynos_drm_fb -> drm_framebuffer Daniel Stone
2018-03-30 14:11   ` [PATCH 19/24] drm/armada: Move GEM BO to drm_framebuffer Daniel Stone
2018-05-17 13:15     ` Daniel Stone
2018-05-17 15:26       ` Russell King - ARM Linux
2018-05-17 15:41         ` Daniel Stone
2018-06-26 14:49           ` Russell King - ARM Linux
2018-06-27 10:40             ` Daniel Stone
2018-05-17 14:57     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 20/24] drm/gma500: " Daniel Stone
2018-05-17 15:03     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 21/24] drm/msm: Move GEM BOs " Daniel Stone
2018-05-17 13:12     ` Daniel Stone
2018-05-17 15:05     ` Thierry Reding
2018-03-30 14:11   ` [PATCH 22/24] drm/radeon: Move GEM BO " Daniel Stone
     [not found]     ` <20180330141138.28987-22-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-05-17 15:06       ` Thierry Reding
     [not found]   ` <20180330141138.28987-1-daniels-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-03-30 14:11     ` [PATCH 23/24] drm/radeon: radeon_framebuffer -> drm_framebuffer Daniel Stone
2018-05-17 15:07       ` Thierry Reding
2018-03-30 14:11   ` [PATCH 24/24] drm/amdgpu: Move GEM BO to drm_framebuffer Daniel Stone
2018-05-17 15:08     ` Thierry Reding
2018-05-17 13:54   ` [PATCH 01/24] drm/cirrus: Place GEM BOs in drm_framebuffer Thierry Reding
2018-03-30 14:47 ` [PATCH 00/24] drm_framebuffer boilerplate removal Alex Deucher
2018-03-30 15:00   ` Daniel Stone
     [not found]     ` <CAPj87rOfg18u1xBioeu1D0MoD4My2rZy1Nw3yfA4DhdX2R7g7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-30 15:03       ` Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180330141138.28987-6-daniels@collabora.com \
    --to=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).