dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, sean@poorly.run, daniel@ffwll.ch,
	kraxel@redhat.com, emil.velikov@collabora.com, sam@ravnborg.org,
	noralf@tronnes.org
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 4/5] drm/udl: Call udl_handle_damage() with DRM framebuffer
Date: Thu, 14 Nov 2019 15:10:24 +0100	[thread overview]
Message-ID: <20191114141025.32198-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20191114141025.32198-1-tzimmermann@suse.de>

Simplifying the udl code before replacing struct udl_framebuffer.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/udl/udl_drv.h     |  2 +-
 drivers/gpu/drm/udl/udl_fb.c      | 35 ++++++++++++++++---------------
 drivers/gpu/drm/udl/udl_modeset.c | 15 +++++++------
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index a0946b955739..c5e3160392cb 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -110,7 +110,7 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
 struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
 						    size_t size);
 
-int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
+int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
 		      int width, int height);
 
 int udl_drop_usb(struct drm_device *dev);
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index e9a4bbd5b195..ad7bf165b59b 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -60,10 +60,10 @@ static uint16_t rgb16(uint32_t col)
 }
 #endif
 
-int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
+int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
 		      int width, int height)
 {
-	struct drm_device *dev = fb->base.dev;
+	struct drm_device *dev = fb->dev;
 	struct udl_device *udl = to_udl(dev);
 	int i, ret;
 	char *cmd;
@@ -75,17 +75,19 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 	int log_bpp;
 	void *vaddr;
 
-	BUG_ON(!is_power_of_2(fb->base.format->cpp[0]));
-	log_bpp = __ffs(fb->base.format->cpp[0]);
+	if (WARN_ON(!is_power_of_2(fb->format->cpp[0])))
+		return -EINVAL;
+
+	log_bpp = __ffs(fb->format->cpp[0]);
 
 	spin_lock(&udl->active_fb_16_lock);
-	if (udl->active_fb_16 != &fb->base) {
+	if (udl->active_fb_16 != fb) {
 		spin_unlock(&udl->active_fb_16_lock);
 		return 0;
 	}
 	spin_unlock(&udl->active_fb_16_lock);
 
-	vaddr = drm_gem_shmem_vmap(&fb->shmem->base);
+	vaddr = drm_gem_shmem_vmap(fb->obj[0]);
 	if (IS_ERR(vaddr)) {
 		DRM_ERROR("failed to vmap fb\n");
 		return 0;
@@ -96,8 +98,8 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 	x = aligned_x;
 
 	if ((width <= 0) ||
-	    (x + width > fb->base.width) ||
-	    (y + height > fb->base.height)) {
+	    (x + width > fb->width) ||
+	    (y + height > fb->height)) {
 		ret = -EINVAL;
 		goto err_drm_gem_shmem_vunmap;
 	}
@@ -110,9 +112,9 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 	cmd = urb->transfer_buffer;
 
 	for (i = y; i < y + height ; i++) {
-		const int line_offset = fb->base.pitches[0] * i;
+		const int line_offset = fb->pitches[0] * i;
 		const int byte_offset = line_offset + (x << log_bpp);
-		const int dev_byte_offset = (fb->base.width * i + x) << log_bpp;
+		const int dev_byte_offset = (fb->width * i + x) << log_bpp;
 		if (udl_render_hline(dev, log_bpp, &urb, (char *)vaddr,
 				     &cmd, byte_offset, dev_byte_offset,
 				     width << log_bpp,
@@ -141,12 +143,12 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 		   &udl->cpu_kcycles_used);
 
 out:
-	drm_gem_shmem_vunmap(&fb->shmem->base, vaddr);
+	drm_gem_shmem_vunmap(fb->obj[0], vaddr);
 
 	return 0;
 
 err_drm_gem_shmem_vunmap:
-	drm_gem_shmem_vunmap(&fb->shmem->base, vaddr);
+	drm_gem_shmem_vunmap(fb->obj[0], vaddr);
 	return ret;
 }
 
@@ -156,7 +158,6 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 				      struct drm_clip_rect *clips,
 				      unsigned num_clips)
 {
-	struct udl_framebuffer *ufb = to_udl_fb(fb);
 	struct udl_device *udl = fb->dev->dev_private;
 	struct dma_buf_attachment *import_attach;
 	int i;
@@ -171,7 +172,7 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 	}
 	spin_unlock(&udl->active_fb_16_lock);
 
-	import_attach = ufb->shmem->base.import_attach;
+	import_attach = fb->obj[0]->import_attach;
 
 	if (import_attach) {
 		ret = dma_buf_begin_cpu_access(import_attach->dmabuf,
@@ -181,9 +182,9 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 	}
 
 	for (i = 0; i < num_clips; i++) {
-		ret = udl_handle_damage(ufb, clips[i].x1, clips[i].y1,
-				  clips[i].x2 - clips[i].x1,
-				  clips[i].y2 - clips[i].y1);
+		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;
 	}
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 44a741f463c9..91af25caed64 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -301,7 +301,7 @@ static int udl_crtc_mode_set(struct drm_crtc *crtc,
 
 {
 	struct drm_device *dev = crtc->dev;
-	struct udl_framebuffer *ufb = to_udl_fb(crtc->primary->fb);
+	struct drm_framebuffer *fb = crtc->primary->fb;
 	struct udl_device *udl = dev->dev_private;
 	char *buf;
 	char *wrptr;
@@ -333,12 +333,12 @@ static int udl_crtc_mode_set(struct drm_crtc *crtc,
 	wrptr = udl_dummy_render(wrptr);
 
 	spin_lock(&udl->active_fb_16_lock);
-	udl->active_fb_16 = &ufb->base;
+	udl->active_fb_16 = fb;
 	spin_unlock(&udl->active_fb_16_lock);
 	udl->mode_buf_len = wrptr - buf;
 
 	/* damage all of it */
-	udl_handle_damage(ufb, 0, 0, ufb->base.width, ufb->base.height);
+	udl_handle_damage(fb, 0, 0, fb->width, fb->height);
 	return 0;
 }
 
@@ -360,7 +360,6 @@ static int udl_crtc_page_flip(struct drm_crtc *crtc,
 			      uint32_t page_flip_flags,
 			      struct drm_modeset_acquire_ctx *ctx)
 {
-	struct udl_framebuffer *ufb = to_udl_fb(fb);
 	struct drm_device *dev = crtc->dev;
 	struct udl_device *udl = dev->dev_private;
 
@@ -368,7 +367,7 @@ static int udl_crtc_page_flip(struct drm_crtc *crtc,
 	udl->active_fb_16 = fb;
 	spin_unlock(&udl->active_fb_16_lock);
 
-	udl_handle_damage(ufb, 0, 0, fb->width, fb->height);
+	udl_handle_damage(fb, 0, 0, fb->width, fb->height);
 
 	spin_lock_irq(&dev->event_lock);
 	if (event)
@@ -448,13 +447,13 @@ int udl_modeset_init(struct drm_device *dev)
 void udl_modeset_restore(struct drm_device *dev)
 {
 	struct udl_device *udl = dev->dev_private;
-	struct udl_framebuffer *ufb;
+	struct drm_framebuffer *fb;
 
 	if (!udl->crtc || !udl->crtc->primary->fb)
 		return;
 	udl_crtc_commit(udl->crtc);
-	ufb = to_udl_fb(udl->crtc->primary->fb);
-	udl_handle_damage(ufb, 0, 0, ufb->base.width, ufb->base.height);
+	fb = udl->crtc->primary->fb;
+	udl_handle_damage(fb, 0, 0, fb->width, fb->height);
 }
 
 void udl_modeset_cleanup(struct drm_device *dev)
-- 
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-14 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14 14:10 [PATCH 0/5] drm/udl: Convert to GEM framebuffer helpers Thomas Zimmermann
2019-11-14 14:10 ` [PATCH 1/5] drm/udl: Unmap buffer object after damage update Thomas Zimmermann
2019-11-14 14:10 ` [PATCH 2/5] drm/udl: Remove udl implementation of GEM's free_object() Thomas Zimmermann
2019-11-14 14:10 ` [PATCH 3/5] drm/udl: Store active framebuffer in device structure Thomas Zimmermann
2019-11-14 14:10 ` Thomas Zimmermann [this message]
2019-11-14 14:10 ` [PATCH 5/5] drm/udl: Replace struct udl_framebuffer with generic implementation Thomas Zimmermann
2019-11-25 18:39 ` [PATCH 0/5] drm/udl: Convert to GEM framebuffer helpers Sam Ravnborg
2019-11-26  8:49   ` 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=20191114141025.32198-5-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=sean@poorly.run \
    /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