dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, daniel@ffwll.ch, sam@ravnborg.org,
	kraxel@redhat.com, emil.velikov@collabora.com,
	noralf@tronnes.org, zboszor@pr.hu
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 5/7] drm/udl: Convert to drm_atomic_helper_dirtyfb()
Date: Tue, 26 Nov 2019 14:47:05 +0100	[thread overview]
Message-ID: <20191126134707.22385-6-tzimmermann@suse.de> (raw)
In-Reply-To: <20191126134707.22385-1-tzimmermann@suse.de>

The infrastruture for atomic modesetting allows us to use the generic
code for dirty-FB and damage handling. Switch over udl and remove the
driver's implementation.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/udl/udl_drv.h     |  5 ---
 drivers/gpu/drm/udl/udl_fb.c      | 67 -------------------------------
 drivers/gpu/drm/udl/udl_modeset.c | 11 +++--
 3 files changed, 8 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 77b57d6abd23..c6fd5c08f5fc 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -89,11 +89,6 @@ void udl_urb_completion(struct urb *urb);
 int udl_init(struct udl_device *udl);
 void udl_fini(struct drm_device *dev);
 
-struct drm_framebuffer *
-udl_fb_user_fb_create(struct drm_device *dev,
-		      struct drm_file *file,
-		      const struct drm_mode_fb_cmd2 *mode_cmd);
-
 int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
 		     const char *front, char **urb_buf_ptr,
 		     u32 byte_offset, u32 device_byte_offset, u32 byte_width,
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index c1996ac73a1f..ed01ebaaf468 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -9,14 +9,9 @@
  */
 
 #include <linux/moduleparam.h>
-#include <linux/dma-buf.h>
 
-#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>
 
 #include "udl_drv.h"
 
@@ -152,65 +147,3 @@ int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
 	drm_gem_shmem_vunmap(fb->obj[0], vaddr);
 	return ret;
 }
-
-static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
-				      struct drm_file *file,
-				      unsigned flags, unsigned color,
-				      struct drm_clip_rect *clips,
-				      unsigned num_clips)
-{
-	struct udl_device *udl = fb->dev->dev_private;
-	struct dma_buf_attachment *import_attach;
-	int i;
-	int ret = 0;
-
-	drm_modeset_lock_all(fb->dev);
-
-	spin_lock(&udl->active_fb_16_lock);
-	if (udl->active_fb_16 != fb) {
-		spin_unlock(&udl->active_fb_16_lock);
-		goto unlock;
-	}
-	spin_unlock(&udl->active_fb_16_lock);
-
-	import_attach = fb->obj[0]->import_attach;
-
-	if (import_attach) {
-		ret = dma_buf_begin_cpu_access(import_attach->dmabuf,
-					       DMA_FROM_DEVICE);
-		if (ret)
-			goto unlock;
-	}
-
-	for (i = 0; i < num_clips; i++) {
-		ret = udl_handle_damage(fb, clips[i].x1, clips[i].y1,
-					clips[i].x2 - clips[i].x1,
-					clips[i].y2 - clips[i].y1);
-		if (ret)
-			break;
-	}
-
-	if (import_attach)
-		ret = dma_buf_end_cpu_access(import_attach->dmabuf,
-					     DMA_FROM_DEVICE);
-
- unlock:
-	drm_modeset_unlock_all(fb->dev);
-
-	return ret;
-}
-
-static const struct drm_framebuffer_funcs udlfb_funcs = {
-	.destroy	= drm_gem_fb_destroy,
-	.create_handle	= drm_gem_fb_create_handle,
-	.dirty		= udl_user_framebuffer_dirty,
-};
-
-struct drm_framebuffer *
-udl_fb_user_fb_create(struct drm_device *dev,
-		   struct drm_file *file,
-		   const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-	return drm_gem_fb_create_with_funcs(dev, file, mode_cmd,
-					    &udlfb_funcs);
-}
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 1b5a46a91cb4..aade61ad097b 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -11,6 +11,7 @@
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_damage_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_vblank.h>
@@ -364,7 +365,9 @@ udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
 {
 	struct drm_device *dev = pipe->crtc.dev;
 	struct udl_device *udl = dev->dev_private;
-	struct drm_framebuffer *fb = pipe->plane.state->fb;
+	struct drm_plane_state *state = pipe->plane.state;
+	struct drm_framebuffer *fb = state->fb;
+	struct drm_rect rect;
 
 	spin_lock(&udl->active_fb_16_lock);
 	udl->active_fb_16 = fb;
@@ -373,7 +376,9 @@ udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
 	if (!fb)
 		return;
 
-	udl_handle_damage(fb, 0, 0, fb->width, fb->height);
+	if (drm_atomic_helper_damage_merged(old_plane_state, state, &rect))
+		udl_handle_damage(fb, rect.x1, rect.y1, rect.x2 - rect.x1,
+				  rect.y2 - rect.y1);
 }
 
 static const
@@ -391,7 +396,7 @@ struct drm_simple_display_pipe_funcs udl_simple_display_pipe_funcs = {
  */
 
 static const struct drm_mode_config_funcs udl_mode_funcs = {
-	.fb_create = udl_fb_user_fb_create,
+	.fb_create = drm_gem_fb_create_with_dirty,
 	.atomic_check  = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
 };
-- 
2.23.0

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

  parent reply	other threads:[~2019-11-26 13:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 13:47 [PATCH 0/7] drm/udl: Convert to simple-pipe helpers and clean up Thomas Zimmermann
2019-11-26 13:47 ` [PATCH 1/7] drm/udl: Init connector before encoder and CRTC Thomas Zimmermann
2019-11-28 14:02   ` Daniel Vetter
2019-11-26 13:47 ` [PATCH 2/7] drm/udl: Convert to struct drm_simple_display_pipe Thomas Zimmermann
2019-11-28 14:09   ` Daniel Vetter
2019-11-26 13:47 ` [PATCH 3/7] drm/udl: Remove unused encoder and CRTC code Thomas Zimmermann
2019-11-28 14:10   ` Daniel Vetter
2019-11-26 13:47 ` [PATCH 4/7] drm/udl: Set preferred color depth to 16 bpp Thomas Zimmermann
2019-11-26 13:47 ` Thomas Zimmermann [this message]
2019-11-28 14:13   ` [PATCH 5/7] drm/udl: Convert to drm_atomic_helper_dirtyfb() Daniel Vetter
2019-11-29 18:04   ` Emil Velikov
2019-11-29 18:38     ` Daniel Vetter
2019-11-26 13:47 ` [PATCH 6/7] drm/udl: Remove struct udl_device.active_fb_16 Thomas Zimmermann
2019-11-28 14:14   ` Daniel Vetter
2019-11-26 13:47 ` [PATCH 7/7] drm/udl: Move udl_handle_damage() into udl_modeset.c Thomas Zimmermann
2019-11-28 14:15   ` Daniel Vetter
2019-12-02  9:27   ` Emil Velikov
2019-12-03 11:31     ` Thomas Zimmermann

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=20191126134707.22385-6-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.velikov@collabora.com \
    --cc=kraxel@redhat.com \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    --cc=zboszor@pr.hu \
    /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