dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/ssd130x: Iterate over damage clips instead of using a merged rect
@ 2022-09-30 15:29 Javier Martinez Canillas
  2022-10-05 17:18 ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2022-09-30 15:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jocelyn Falempe, Thomas Zimmermann, David Airlie,
	Javier Martinez Canillas, dri-devel

The drm_atomic_helper_damage_merged() helper merges all the damage clips
into one rectangle. If there are multiple damage clips that aren't close
to each other, the resulting rectangle could be quite big.

Instead of using that function helper, iterate over all the damage clips
and update them one by one.

Suggested-by: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

Changes in v2:
- Move the dst_clip assignment inside the drm_atomic_for_each_plane_damage()
  loop (Thomas Zimmermann).
- Pass dst_clip instead of damage area as argument to ssd130x_fb_blit_rect()
  function (Thomas Zimmermann)

 drivers/gpu/drm/solomon/ssd130x.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index bc41a5ae810a..f456b233d2e7 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -578,21 +578,24 @@ static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
+	struct drm_atomic_helper_damage_iter iter;
 	struct drm_device *drm = plane->dev;
-	struct drm_rect src_clip, dst_clip;
+	struct drm_rect dst_clip;
+	struct drm_rect damage;
 	int idx;
 
-	if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &src_clip))
+	if (!drm_dev_enter(drm, &idx))
 		return;
 
-	dst_clip = plane_state->dst;
-	if (!drm_rect_intersect(&dst_clip, &src_clip))
-		return;
+	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_for_each_plane_damage(&iter, &damage) {
+		dst_clip = plane_state->dst;
 
-	if (!drm_dev_enter(drm, &idx))
-		return;
+		if (!drm_rect_intersect(&dst_clip, &damage))
+			continue;
 
-	ssd130x_fb_blit_rect(plane_state->fb, &shadow_plane_state->data[0], &dst_clip);
+		ssd130x_fb_blit_rect(plane_state->fb, &shadow_plane_state->data[0], &dst_clip);
+	}
 
 	drm_dev_exit(idx);
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drm/ssd130x: Iterate over damage clips instead of using a merged rect
  2022-09-30 15:29 [PATCH v2] drm/ssd130x: Iterate over damage clips instead of using a merged rect Javier Martinez Canillas
@ 2022-10-05 17:18 ` Thomas Zimmermann
  2022-10-05 22:33   ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2022-10-05 17:18 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: David Airlie, Jocelyn Falempe, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 2705 bytes --]



Am 30.09.22 um 17:29 schrieb Javier Martinez Canillas:
> The drm_atomic_helper_damage_merged() helper merges all the damage clips
> into one rectangle. If there are multiple damage clips that aren't close
> to each other, the resulting rectangle could be quite big.
> 
> Instead of using that function helper, iterate over all the damage clips
> and update them one by one.
> 
> Suggested-by: Jocelyn Falempe <jfalempe@redhat.com>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
> 
> Changes in v2:
> - Move the dst_clip assignment inside the drm_atomic_for_each_plane_damage()
>    loop (Thomas Zimmermann).
> - Pass dst_clip instead of damage area as argument to ssd130x_fb_blit_rect()
>    function (Thomas Zimmermann)
> 
>   drivers/gpu/drm/solomon/ssd130x.c | 19 +++++++++++--------
>   1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
> index bc41a5ae810a..f456b233d2e7 100644
> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -578,21 +578,24 @@ static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
>   	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
>   	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
>   	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
> +	struct drm_atomic_helper_damage_iter iter;
>   	struct drm_device *drm = plane->dev;
> -	struct drm_rect src_clip, dst_clip;
> +	struct drm_rect dst_clip;
> +	struct drm_rect damage;
>   	int idx;
>   
> -	if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &src_clip))
> +	if (!drm_dev_enter(drm, &idx))
>   		return;
>   
> -	dst_clip = plane_state->dst;
> -	if (!drm_rect_intersect(&dst_clip, &src_clip))
> -		return;
> +	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
> +	drm_atomic_for_each_plane_damage(&iter, &damage) {
> +		dst_clip = plane_state->dst;
>   
> -	if (!drm_dev_enter(drm, &idx))
> -		return;
> +		if (!drm_rect_intersect(&dst_clip, &damage))
> +			continue;
>   
> -	ssd130x_fb_blit_rect(plane_state->fb, &shadow_plane_state->data[0], &dst_clip);
> +		ssd130x_fb_blit_rect(plane_state->fb, &shadow_plane_state->data[0], &dst_clip);
> +	}
>   
>   	drm_dev_exit(idx);
>   }

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drm/ssd130x: Iterate over damage clips instead of using a merged rect
  2022-10-05 17:18 ` Thomas Zimmermann
@ 2022-10-05 22:33   ` Javier Martinez Canillas
  0 siblings, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2022-10-05 22:33 UTC (permalink / raw)
  To: Thomas Zimmermann, linux-kernel; +Cc: David Airlie, Jocelyn Falempe, dri-devel

On 10/5/22 19:18, Thomas Zimmermann wrote:
> 
> 
> Am 30.09.22 um 17:29 schrieb Javier Martinez Canillas:
>> The drm_atomic_helper_damage_merged() helper merges all the damage clips
>> into one rectangle. If there are multiple damage clips that aren't close
>> to each other, the resulting rectangle could be quite big.
>>
>> Instead of using that function helper, iterate over all the damage clips
>> and update them one by one.
>>
>> Suggested-by: Jocelyn Falempe <jfalempe@redhat.com>
>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> 

Pushed this to drm-misc (drm-misc-next) now. Thanks!

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-05 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 15:29 [PATCH v2] drm/ssd130x: Iterate over damage clips instead of using a merged rect Javier Martinez Canillas
2022-10-05 17:18 ` Thomas Zimmermann
2022-10-05 22:33   ` Javier Martinez Canillas

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).