drm/tinydrm: Use damage helper for dirtyfb
Subsystems (2)
cover drm/tinydrm: Use damage helper for dirtyfb
Hi,
I was really pleased to see that the damage helper had landed. Now I can do framebuffer flushing solely through the display pipe functions. This prepares the ground for the removal of struct tinydrm_device in my next series.
Note:
The damage helper isn't in drm-misc-next yet, it will show up when -rc1 arrives there.
Noralf.
Noralf Trønnes (4):
drm/gem-fb-helper: Add drm_gem_fb_create_with_dirty() drm/damage-helper: Add drm_atomic_helper_damage_merged() drm/tinydrm: Use struct drm_rect
drm/tinydrm: Use damage helper for dirtyfb
drivers/gpu/drm/drm_damage_helper.c | 43 ++++++ drivers/gpu/drm/drm_gem_framebuffer_helper.c | 47 +++++- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 21 +-- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 100 +------------ drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 30 ---- drivers/gpu/drm/tinydrm/hx8357d.c | 2 +- drivers/gpu/drm/tinydrm/ili9225.c | 138 +++++++----------- drivers/gpu/drm/tinydrm/ili9341.c | 2 +- drivers/gpu/drm/tinydrm/mi0283qt.c | 2 +- drivers/gpu/drm/tinydrm/mipi-dbi.c | 87 +++++++---- drivers/gpu/drm/tinydrm/repaper.c | 42 +++--- drivers/gpu/drm/tinydrm/st7586.c | 73 ++++----- drivers/gpu/drm/tinydrm/st7735r.c | 2 +- include/drm/drm_damage_helper.h | 3 + include/drm/drm_gem_framebuffer_helper.h | 3 + include/drm/tinydrm/mipi-dbi.h | 5 +- include/drm/tinydrm/tinydrm-helpers.h | 20 +-- include/drm/tinydrm/tinydrm.h | 26 ---- 18 files changed, 281 insertions(+), 365 deletions(-)
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/4 drm/gem-fb-helper: Add drm_gem_fb_create_with_dirty()
This adds a .fb_create helper that sets the .dirty callback to drm_atomic_helper_dirtyfb().
--- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 47 +++++++++++++++++--- include/drm/drm_gem_framebuffer_helper.h | 3 ++ 2 files changed, 44 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_gem_framebuffer_helper.c +41 -6
@@ -17,6 +17,7 @@#include <drm/drmP.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_uapi.h> +#include <drm/drm_damage_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h>
@@ -136,10 +137,9 @@ EXPORT_SYMBOL(drm_gem_fb_create_handle);* @mode_cmd: Metadata from the userspace framebuffer creation request * @funcs: vtable to be used for the new framebuffer object * -* This can be used to set &drm_framebuffer_funcs for drivers that need the -* &drm_framebuffer_funcs.dirty callback. Use drm_gem_fb_create() if you don't -* need to change &drm_framebuffer_funcs. -* The function does buffer size validation. +* This function can be used to set &drm_framebuffer_funcs for drivers that need +* custom framebuffer callbacks. Use drm_gem_fb_create() if you don't need to +* change &drm_framebuffer_funcs. The function does buffer size validation. * * Returns: * Pointer to a &drm_framebuffer on success or an error pointer on failure.
@@ -215,8 +215,8 @@ static const struct drm_framebuffer_funcs drm_gem_fb_funcs = {* * If your hardware has special alignment or pitch requirements these should be * checked before calling this function. The function does buffer size -* validation. Use drm_gem_fb_create_with_funcs() if you need to set -* &drm_framebuffer_funcs.dirty. +* validation. Use drm_gem_fb_create_with_dirty() if you need framebuffer +* flushing. * * Drivers can use this as their &drm_mode_config_funcs.fb_create callback. * The ADDFB2 IOCTL calls into this callback.
@@ -233,6 +233,41 @@ drm_gem_fb_create(struct drm_device *dev, struct drm_file *file, }EXPORT_SYMBOL_GPL (drm_gem_fb_create); +static const struct drm_framebuffer_funcs drm_gem_fb_funcs_dirtyfb = { + .destroy = drm_gem_fb_destroy, + .create_handle = drm_gem_fb_create_handle, + .dirty = drm_atomic_helper_dirtyfb, +}; + +/** +* drm_gem_fb_create_with_dirty() - Helper function for the +* &drm_mode_config_funcs.fb_create callback +* @dev: DRM device +* @file: DRM file that holds the GEM handle(s) backing the framebuffer +* @mode_cmd: Metadata from the userspace framebuffer creation request +* +* This function creates a new framebuffer object described by +* &drm_mode_fb_cmd2. This description includes handles for the buffer(s) +* backing the framebuffer. drm_atomic_helper_dirtyfb() is used for the dirty +* callback giving framebuffer flushing through the atomic machinery. Use +* drm_gem_fb_create() if you don't need the dirty callback. +* The function does buffer size validation. +* +* Drivers can use this as their &drm_mode_config_funcs.fb_create callback. +* The ADDFB2 IOCTL calls into this callback. +* +* Returns: +* Pointer to a &drm_framebuffer on success or an error pointer on failure. +*/ +struct drm_framebuffer * +drm_gem_fb_create_with_dirty (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, + &drm_gem_fb_funcs_dirtyfb); +} +EXPORT_SYMBOL_GPL (drm_gem_fb_create_with_dirty); +/** * drm_gem_fb_prepare_fb() - Prepare a GEM backed framebuffer * @plane: Plane
include/drm/drm_gem_framebuffer_helper.h +3 -0
@@ -25,6 +25,9 @@ drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,struct drm_framebuffer *drm_gem_fb_create (struct drm_device *dev,struct drm_file *file,const struct drm_mode_fb_cmd2 *mode_cmd); +struct drm_framebuffer * +drm_gem_fb_create_with_dirty (struct drm_device *dev,struct drm_file *file, +const struct drm_mode_fb_cmd2 *mode_cmd);int drm_gem_fb_prepare_fb (struct drm_plane *plane,struct drm_plane_state *state);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/4] drm/gem-fb-helper: Add drm_gem_fb_create_with_dirty()
Quoted 62 lines · Noralf Trønnes
This adds a .fb_create helper that sets the .dirty callback to
drm_atomic_helper_dirtyfb().Signed-off-by Noralf Trønnes <[email protected]>--- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 47 +++++++++++++++++--- include/drm/drm_gem_framebuffer_helper.h | 3 ++ 2 files changed, 44 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_gem_framebuffer_helper.c +18
-6@@ -17,6 +17,7 @@#include <drm/drmP.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_uapi.h> +#include <drm/drm_damage_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> @@ -136,10 +137,9 @@ EXPORT_SYMBOL(drm_gem_fb_create_handle);* @mode_cmd: Metadata from the userspace framebuffer creation request * @funcs: vtable to be used for the new framebuffer object * -* This can be used to set &drm_framebuffer_funcs for drivers that need the -* &drm_framebuffer_funcs.dirty callback. Use drm_gem_fb_create() if you don't -* need to change &drm_framebuffer_funcs. -* The function does buffer size validation. +* This function can be used to set &drm_framebuffer_funcs for drivers that need +* custom framebuffer callbacks. Use drm_gem_fb_create() if you don't need to +* change &drm_framebuffer_funcs. The function does buffer size validation. * * Returns: * Pointer to a &drm_framebuffer on success or an error pointer on failure. @@ -215,8 +215,8 @@ static const struct drm_framebuffer_funcs drm_gem_fb_funcs = {* * If your hardware has special alignment or pitch requirements these should be * checked before calling this function. The function does buffer size -* validation. Use drm_gem_fb_create_with_funcs() if you need to set -* &drm_framebuffer_funcs.dirty. +* validation. Use drm_gem_fb_create_with_dirty() if you need framebuffer +* flushing. * * Drivers can use this as their &drm_mode_config_funcs.fb_create callback. * The ADDFB2 IOCTL calls into this callback. @@ -233,6 +233,41 @@ drm_gem_fb_create(struct drm_device *dev, struct drm_file *file, }EXPORT_SYMBOL_GPL (drm_gem_fb_create); +static const struct drm_framebuffer_funcs drm_gem_fb_funcs_dirtyfb = { + .destroy = drm_gem_fb_destroy, + .create_handle = drm_gem_fb_create_handle, + .dirty = drm_atomic_helper_dirtyfb, +}; + +/** +* drm_gem_fb_create_with_dirty() - Helper function for the +* &drm_mode_config_funcs.fb_create callback +* @dev: DRM device +* @file: DRM file that holds the GEM handle(s) backing the framebuffer +* @mode_cmd: Metadata from the userspace framebuffer creation request
drivers/gpu/drm/drm_gem_framebuffer_helper.c drm_gem_fb_create(struct drm_device *dev, struct drm_file *file, · line 257
Quoted 10 lines
drivers/gpu/drm/drm_gem_framebuffer_helper.c +10
-0+* +* This function creates a new framebuffer object described by +* &drm_mode_fb_cmd2. This description includes handles for the buffer(s) +* backing the framebuffer. drm_atomic_helper_dirtyfb() is used for the dirty +* callback giving framebuffer flushing through the atomic machinery. Use +* drm_gem_fb_create() if you don't need the dirty callback. +* The function does buffer size validation. +* +* Drivers can use this as their &drm_mode_config_funcs.fb_create callback. +* The ADDFB2 IOCTL calls into this callback.
I think would be good to add:
"Drivers should also call drm_plane_enable_fb_damage_clips() on all planes to enable userspace to use damage clips also with the ATOMIC IOCTL."
It's a bit annoying that drivers have to make that separate call too (so some risk for accidents), but I didn't see a good way to avoid that.
With the documentation nit, on the entire series:
Quoted 37 lines
drivers/gpu/drm/drm_gem_framebuffer_helper.c +13
-0+* +* Returns: +* Pointer to a &drm_framebuffer on success or an error pointer on failure. +*/ +struct drm_framebuffer * +drm_gem_fb_create_with_dirty (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, + &drm_gem_fb_funcs_dirtyfb); +} +EXPORT_SYMBOL_GPL (drm_gem_fb_create_with_dirty); +/** * drm_gem_fb_prepare_fb() - Prepare a GEM backed framebuffer * @plane: Plane include/drm/drm_gem_framebuffer_helper.h +3
-0@@ -25,6 +25,9 @@ drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,struct drm_framebuffer *drm_gem_fb_create (struct drm_device *dev,struct drm_file *file,const struct drm_mode_fb_cmd2 *mode_cmd); +struct drm_framebuffer * +drm_gem_fb_create_with_dirty (struct drm_device *dev,struct drm_file *file, +const struct drm_mode_fb_cmd2 *mode_cmd);int drm_gem_fb_prepare_fb (struct drm_plane *plane,struct drm_plane_state *state);Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 drm/damage-helper: Add drm_atomic_helper_damage_merged()
In reply to Noralf TrønnesUseful for drivers that only care about the combined damage.
--- drivers/gpu/drm/drm_damage_helper.c | 43 +++++++++++++++++++++++++++++ include/drm/drm_damage_helper.h | 3 ++ 2 files changed, 46 insertions(+)
drivers/gpu/drm/drm_damage_helper.c +43 -0
@@ -332,3 +332,46 @@ drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,return ret; }EXPORT_SYMBOL (drm_atomic_helper_damage_iter_next); + +/** +* drm_atomic_helper_damage_merged - Merged plane damage +* @old_state: Old plane state for validation. +* @state: Plane state from which to iterate the damage clips. +* @rect: Returns the merged damage rectangle +* +* This function merges any valid plane damage clips into one rectangle and +* returns it in @rect. It also clears the plane damage. +* +* For details see: drm_atomic_helper_damage_iter_init() and +* drm_atomic_helper_damage_iter_next(). +* +* Returns: +* True if there is valid plane damage otherwise false. +*/ +bool drm_atomic_helper_damage_merged (const struct drm_plane_state *old_state, +struct drm_plane_state *state, +struct drm_rect *rect) +{ +struct drm_atomic_helper_damage_iter iter; +struct drm_rect clip; +bool valid = false; + + rect->x1 =INT_MAX ; + rect->y1 =INT_MAX ; + rect->x2 =0 ; + rect->y2 =0 ; + +drm_atomic_helper_damage_iter_init (&iter, old_state, state); +drm_atomic_for_each_plane_damage (&iter, &clip) { + rect->x1 =min (rect->x1, clip.x1); + rect->y1 =min (rect->y1, clip.y1); + rect->x2 =max (rect->x2, clip.x2); + rect->y2 =max (rect->y2, clip.y2); + valid = true; + } + +drm_property_replace_blob (&state->fb_damage_clips,NULL ); + +return valid; +} +EXPORT_SYMBOL (drm_atomic_helper_damage_merged);
include/drm/drm_damage_helper.h +3 -0
@@ -78,6 +78,9 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,bool drm_atomic_helper_damage_iter_next (struct drm_atomic_helper_damage_iter *iter,struct drm_rect *rect); +bool drm_atomic_helper_damage_merged (const struct drm_plane_state *old_state, +struct drm_plane_state *state, +struct drm_rect *rect);/** * drm_helper_get_plane_damage_clips - Returns damage clips in &drm_rect.
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/4] drm/damage-helper: Add drm_atomic_helper_damage_merged()
Den 09.01.2019 18.49, skrev Noralf Trønnes:
Quoted 46 lines
Useful for drivers that only care about the combined damage.
Cc Deepak Rawat <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>--- drivers/gpu/drm/drm_damage_helper.c | 43 +++++++++++++++++++++++++++++ include/drm/drm_damage_helper.h | 3 ++ 2 files changed, 46 insertions(+)drivers/gpu/drm/drm_damage_helper.c +29
-0@@ -332,3 +332,46 @@ drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,return ret; }EXPORT_SYMBOL (drm_atomic_helper_damage_iter_next); + +/** +* drm_atomic_helper_damage_merged - Merged plane damage +* @old_state: Old plane state for validation. +* @state: Plane state from which to iterate the damage clips. +* @rect: Returns the merged damage rectangle +* +* This function merges any valid plane damage clips into one rectangle and +* returns it in @rect. It also clears the plane damage. +* +* For details see: drm_atomic_helper_damage_iter_init() and +* drm_atomic_helper_damage_iter_next(). +* +* Returns: +* True if there is valid plane damage otherwise false. +*/ +bool drm_atomic_helper_damage_merged (const struct drm_plane_state *old_state, +struct drm_plane_state *state, +struct drm_rect *rect) +{ +struct drm_atomic_helper_damage_iter iter; +struct drm_rect clip; +bool valid = false; + + rect->x1 =INT_MAX ; + rect->y1 =INT_MAX ; + rect->x2 =0 ; + rect->y2 =0 ; +
drivers/gpu/drm/drm_damage_helper.c drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, · line 373
Quoted 10 lines
drivers/gpu/drm/drm_damage_helper.c +10
-0+drm_atomic_helper_damage_iter_init (&iter, old_state, state); +drm_atomic_for_each_plane_damage (&iter, &clip) { + rect->x1 =min (rect->x1, clip.x1); + rect->y1 =min (rect->y1, clip.y1); + rect->x2 =max (rect->x2, clip.x2); + rect->y2 =max (rect->y2, clip.y2); + valid = true; + } + +drm_property_replace_blob (&state->fb_damage_clips,NULL );
This clearing isn't necessary, it happens in plane state duplicate/destroy. I had missed fix up commit c75ff001f4fe ("drm: Put damage blob when destroy plane state").
I will amend this in the next version.
Noralf.
Quoted 10 lines
drivers/gpu/drm/drm_damage_helper.c +4
-0+ +return valid; +} +EXPORT_SYMBOL (drm_atomic_helper_damage_merged);include/drm/drm_damage_helper.h +0
-0
include/drm/drm_damage_helper.h drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, · line 86
Quoted 9 lines
include/drm/drm_damage_helper.h +3
-0@@ -78,6 +78,9 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,bool drm_atomic_helper_damage_iter_next (struct drm_atomic_helper_damage_iter *iter,struct drm_rect *rect); +bool drm_atomic_helper_damage_merged (const struct drm_plane_state *old_state, +struct drm_plane_state *state, +struct drm_rect *rect);/** * drm_helper_get_plane_damage_clips - Returns damage clips in &drm_rect.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/4 drm/tinydrm: Use struct drm_rect
In reply to Noralf TrønnesThis prepares for the switch to drm_atomic_helper_dirtyfb() in the next patch. The damage helper returns a drm_rect so switch to that everywhere including using a pointer in the dirty functions.
This is a non-functional change except for the debug print which looks a bit different.
--- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 19 ++++---- drivers/gpu/drm/tinydrm/ili9225.c | 43 ++++++++++--------- drivers/gpu/drm/tinydrm/mipi-dbi.c | 21 ++++----- drivers/gpu/drm/tinydrm/repaper.c | 3 +- drivers/gpu/drm/tinydrm/st7586.c | 27 ++++++------ include/drm/tinydrm/mipi-dbi.h | 3 +- include/drm/tinydrm/tinydrm-helpers.h | 11 ++--- 7 files changed, 67 insertions(+), 60 deletions(-)
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +10 -9
@@ -18,6 +18,7 @@#include <drm/drm_drv.h> #include <drm/drm_fourcc.h> #include <drm/drm_print.h> +#include <drm/drm_rect.h> #include <drm/tinydrm/tinydrm.h> #include <drm/tinydrm/tinydrm-helpers.h> #include <uapi/drm/drm.h>
@@ -41,7 +42,7 @@ MODULE_PARM_DESC(spi_max, "Set a lower SPI max transfer size");* Returns: * true if it's a full clip, false otherwise */ -bool tinydrm_merge_clips (struct drm_clip_rect *dst, +bool tinydrm_merge_clips (struct drm_rect *dst,struct drm_clip_rect *src,unsigned int num_clips,unsigned int flags,u32 max_width,u32 max_height) {
@@ -63,10 +64,10 @@ bool tinydrm_merge_clips(struct drm_clip_rect *dst,for (i =0 ; i < num_clips; i++) {if (flags &DRM_MODE_FB_DIRTY_ANNOTATE_COPY ) i++; - dst->x1 =min (dst->x1, src[i].x1); - dst->x2 =max (dst->x2, src[i].x2); - dst->y1 =min (dst->y1, src[i].y1); - dst->y2 =max (dst->y2, src[i].y2); + dst->x1 =min_t (int, dst->x1, src[i].x1); + dst->x2 =max_t (int, dst->x2, src[i].x2); + dst->y1 =min_t (int, dst->y1, src[i].y1); + dst->y2 =max_t (int, dst->y2, src[i].y2); } if (dst->x2 > max_width || dst->y2 > max_height ||
@@ -122,7 +123,7 @@ EXPORT_SYMBOL(tinydrm_fb_dirty);* @clip: Clip rectangle area to copy */ void tinydrm_memcpy (void *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip) +struct drm_rect *clip) {unsigned int cpp =drm_format_plane_cpp (fb->format->format,0 );unsigned int pitch = fb->pitches[0 ];
@@ -146,7 +147,7 @@ EXPORT_SYMBOL(tinydrm_memcpy);* @clip: Clip rectangle area to copy */ void tinydrm_swab16 (u16 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip) +struct drm_rect *clip) {size_t len = (clip->x2 - clip->x1) *sizeof (u16);unsigned int x, y;
@@ -186,7 +187,7 @@ EXPORT_SYMBOL(tinydrm_swab16);*/ void tinydrm_xrgb8888_to_rgb565 (u16 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip,bool swap) +struct drm_rect *clip,bool swap) {size_t len = (clip->x2 - clip->x1) *sizeof (u32);unsigned int x, y;
@@ -235,7 +236,7 @@ EXPORT_SYMBOL(tinydrm_xrgb8888_to_rgb565);* ITU BT.601 is used for the RGB -> luma (brightness) conversion. */ void tinydrm_xrgb8888_to_gray8 (u8 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip) +struct drm_rect *clip) {unsigned int len = (clip->x2 - clip->x1) *sizeof (u32);unsigned int x, y;
drivers/gpu/drm/tinydrm/ili9225.c +22 -21
89 lines not on this page · raw message
drivers/gpu/drm/tinydrm/mipi-dbi.c +11 -10
@@ -19,6 +19,7 @@#include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> +#include <drm/drm_rect.h> #include <drm/tinydrm/mipi-dbi.h> #include <drm/tinydrm/tinydrm-helpers.h> #include <uapi/drm/drm.h>
@@ -169,7 +170,7 @@ EXPORT_SYMBOL(mipi_dbi_command_buf);* Zero on success, negative error code on failure. */ int mipi_dbi_buf_copy (void *dst,struct drm_framebuffer *fb, -struct drm_clip_rect *clip,bool swap) +struct drm_rect *clip,bool swap) {struct drm_gem_cma_object *cma_obj =drm_fb_cma_get_gem_obj (fb,0 );struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;
@@ -218,7 +219,8 @@ static int mipi_dbi_fb_dirty(struct drm_framebuffer *fb,struct tinydrm_device *tdev = fb->dev->dev_private;struct mipi_dbi *mipi =mipi_dbi_from_tinydrm (tdev);bool swap = mipi->swap_bytes; -struct drm_clip_rect clip; +struct drm_rect clip; +struct drm_rect *rect = &clip;int ret =0 ;bool full;void *tr;
@@ -229,13 +231,12 @@ static int mipi_dbi_fb_dirty(struct drm_framebuffer *fb, full =tinydrm_merge_clips (&clip, clips, num_clips, flags, fb->width, fb->height); -DRM_DEBUG ("Flushing [FB:%d] x1=%u, x2=%u, y1=%u, y2=%u\n" , fb->base.id, - clip.x1, clip.x2, clip.y1, clip.y2); +DRM_DEBUG_KMS ("Flushing [FB:%d] " DRM_RECT_FMT "\n" , fb->base.id,DRM_RECT_ARG (rect));if (!mipi->dc || !full || swap || fb->format->format ==DRM_FORMAT_XRGB8888 ) { tr = mipi->tx_buf; - ret =mipi_dbi_buf_copy (mipi->tx_buf, fb, &clip, swap); + ret =mipi_dbi_buf_copy (mipi->tx_buf, fb, rect, swap);if (ret)return ret; }else {
@@ -243,14 +244,14 @@ static int mipi_dbi_fb_dirty(struct drm_framebuffer *fb, }mipi_dbi_command (mipi,MIPI_DCS_SET_COLUMN_ADDRESS , - (clip.x1 >>8 ) &0xFF , clip.x1 &0xFF , - ((clip.x2 -1 ) >>8 ) &0xFF , (clip.x2 -1 ) &0xFF ); + (rect->x1 >>8 ) &0xff , rect->x1 &0xff , + ((rect->x2 -1 ) >>8 ) &0xff , (rect->x2 -1 ) &0xff );mipi_dbi_command (mipi,MIPI_DCS_SET_PAGE_ADDRESS , - (clip.y1 >>8 ) &0xFF , clip.y1 &0xFF , - ((clip.y2 -1 ) >>8 ) &0xFF , (clip.y2 -1 ) &0xFF ); + (rect->y1 >>8 ) &0xff , rect->y1 &0xff , + ((rect->y2 -1 ) >>8 ) &0xff , (rect->y2 -1 ) &0xff ); ret =mipi_dbi_command_buf (mipi,MIPI_DCS_WRITE_MEMORY_START , tr, - (clip.x2 - clip.x1) * (clip.y2 - clip.y1) *2 ); + (rect->x2 - rect->x1) * (rect->y2 - rect->y1) *2 );return ret; }
drivers/gpu/drm/tinydrm/repaper.c +2 -1
@@ -29,6 +29,7 @@#include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> +#include <drm/drm_rect.h> #include <drm/tinydrm/tinydrm.h> #include <drm/tinydrm/tinydrm-helpers.h>
@@ -531,7 +532,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;struct tinydrm_device *tdev = fb->dev->dev_private;struct repaper_epd *epd =epd_from_tinydrm (tdev); -struct drm_clip_rect clip; +struct drm_rect clip;u8 *buf =NULL ;int ret =0 ;
drivers/gpu/drm/tinydrm/st7586.c +14 -13
@@ -20,6 +20,7 @@#include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> +#include <drm/drm_rect.h> #include <drm/tinydrm/mipi-dbi.h> #include <drm/tinydrm/tinydrm-helpers.h>
@@ -61,7 +62,7 @@ static const u8 st7586_lookup[] = { 0x7, 0x4, 0x2, 0x0 };static void st7586_xrgb8888_to_gray332 (u8 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip) +struct drm_rect *clip) {size_t len = (clip->x2 - clip->x1) * (clip->y2 - clip->y1);unsigned int x, y;
@@ -87,7 +88,7 @@ static void st7586_xrgb8888_to_gray332(u8 *dst, void *vaddr, }static int st7586_buf_copy (void *dst,struct drm_framebuffer *fb, -struct drm_clip_rect *clip) +struct drm_rect *clip) {struct drm_gem_cma_object *cma_obj =drm_fb_cma_get_gem_obj (fb,0 );struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;
@@ -117,7 +118,8 @@ static int st7586_fb_dirty(struct drm_framebuffer *fb, {struct tinydrm_device *tdev = fb->dev->dev_private;struct mipi_dbi *mipi =mipi_dbi_from_tinydrm (tdev); -struct drm_clip_rect clip; +struct drm_rect clip; +struct drm_rect *rect = &clip;int start, end;int ret =0 ;
@@ -128,30 +130,29 @@ static int st7586_fb_dirty(struct drm_framebuffer *fb, fb->height);/* 3 pixels per byte, so grow clip to nearest multiple of 3 */ - clip.x1 =rounddown (clip.x1,3 ); - clip.x2 =roundup (clip.x2,3 ); + rect->x1 =rounddown (rect->x1,3 ); + rect->x2 =roundup (rect->x2,3 ); -DRM_DEBUG ("Flushing [FB:%d] x1=%u, x2=%u, y1=%u, y2=%u\n" , fb->base.id, - clip.x1, clip.x2, clip.y1, clip.y2); +DRM_DEBUG_KMS ("Flushing [FB:%d] " DRM_RECT_FMT "\n" , fb->base.id,DRM_RECT_ARG (rect)); - ret =st7586_buf_copy (mipi->tx_buf, fb, &clip); + ret =st7586_buf_copy (mipi->tx_buf, fb, rect);if (ret)return ret;/* Pixels are packed 3 per byte */ - start = clip.x1 /3 ; - end = clip.x2 /3 ; + start = rect->x1 /3 ; + end = rect->x2 /3 ;mipi_dbi_command (mipi,MIPI_DCS_SET_COLUMN_ADDRESS , (start >>8 ) &0xFF , start &0xFF , (end >>8 ) &0xFF , (end -1 ) &0xFF );mipi_dbi_command (mipi,MIPI_DCS_SET_PAGE_ADDRESS , - (clip.y1 >>8 ) &0xFF , clip.y1 &0xFF , - (clip.y2 >>8 ) &0xFF , (clip.y2 -1 ) &0xFF ); + (rect->y1 >>8 ) &0xFF , rect->y1 &0xFF , + (rect->y2 >>8 ) &0xFF , (rect->y2 -1 ) &0xFF ); ret =mipi_dbi_command_buf (mipi,MIPI_DCS_WRITE_MEMORY_START , (u8 *)mipi->tx_buf, - (end - start) * (clip.y2 - clip.y1)); + (end - start) * (rect->y2 - rect->y1));return ret; }
include/drm/tinydrm/mipi-dbi.h +2 -1
@@ -14,6 +14,7 @@#include <drm/tinydrm/tinydrm.h> +struct drm_rect ;struct spi_device ;struct gpio_desc ;struct regulator ;
@@ -80,7 +81,7 @@ u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len);int mipi_dbi_command_read (struct mipi_dbi *mipi,u8 cmd,u8 *val);int mipi_dbi_command_buf (struct mipi_dbi *mipi,u8 cmd,u8 *data,size_t len);int mipi_dbi_buf_copy (void *dst,struct drm_framebuffer *fb, -struct drm_clip_rect *clip,bool swap); +struct drm_rect *clip,bool swap);/** * mipi_dbi_command - MIPI DCS command with optional parameter(s) * @mipi: MIPI structure
include/drm/tinydrm/tinydrm-helpers.h +6 -5
@@ -13,6 +13,7 @@struct backlight_device ;struct tinydrm_device ;struct drm_clip_rect ; +struct drm_rect ;struct spi_transfer ;struct spi_message ;struct spi_device ;
@@ -33,7 +34,7 @@ static inline bool tinydrm_machine_little_endian(void)#endif } -bool tinydrm_merge_clips (struct drm_clip_rect *dst, +bool tinydrm_merge_clips (struct drm_rect *dst,struct drm_clip_rect *src,unsigned int num_clips,unsigned int flags,u32 max_width,u32 max_height); int tinydrm_fb_dirty(struct drm_framebuffer *fb,
@@ -42,14 +43,14 @@ int tinydrm_fb_dirty(struct drm_framebuffer *fb,struct drm_clip_rect *clips, unsigned int num_clips);void tinydrm_memcpy (void *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip); +struct drm_rect *clip);void tinydrm_swab16 (u16 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip); +struct drm_rect *clip);void tinydrm_xrgb8888_to_rgb565 (u16 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip,bool swap); +struct drm_rect *clip,bool swap);void tinydrm_xrgb8888_to_gray8 (u8 *dst,void *vaddr,struct drm_framebuffer *fb, -struct drm_clip_rect *clip); +struct drm_rect *clip);size_t tinydrm_spi_max_transfer_size (struct spi_device *spi,size_t max_len);bool tinydrm_spi_bpw_supported (struct spi_device *spi,u8 bpw);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 drm/tinydrm: Use damage helper for dirtyfb
In reply to Noralf TrønnesThis switches to drm_atomic_helper_dirtyfb() as the framebuffer dirty handler. All flushing will now happen in the pipe functions.
Also enable the damage plane property for all except repaper which can only do full updates.
ili9225:
This change made ili9225_init() equal to mipi_dbi_init() so use it.
--- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 21 +--- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 91 +--------------- drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 30 ------ drivers/gpu/drm/tinydrm/hx8357d.c | 2 +- drivers/gpu/drm/tinydrm/ili9225.c | 101 ++++++------------ drivers/gpu/drm/tinydrm/ili9341.c | 2 +- drivers/gpu/drm/tinydrm/mi0283qt.c | 2 +- drivers/gpu/drm/tinydrm/mipi-dbi.c | 72 ++++++++----- drivers/gpu/drm/tinydrm/repaper.c | 39 ++++--- drivers/gpu/drm/tinydrm/st7586.c | 50 +++++---- drivers/gpu/drm/tinydrm/st7735r.c | 2 +- include/drm/tinydrm/mipi-dbi.h | 2 + include/drm/tinydrm/tinydrm-helpers.h | 11 +- include/drm/tinydrm/tinydrm.h | 26 ----- 14 files changed, 138 insertions(+), 313 deletions(-)
drivers/gpu/drm/tinydrm/core/tinydrm-core.c +2 -19
@@ -36,31 +36,17 @@* and registers the DRM device using devm_tinydrm_register(). */ -static struct drm_framebuffer * -tinydrm_fb_create (struct drm_device *drm,struct drm_file *file_priv, -const struct drm_mode_fb_cmd2 *mode_cmd) -{ -struct tinydrm_device *tdev = drm->dev_private; - -return drm_gem_fb_create_with_funcs (drm, file_priv, mode_cmd, - tdev->fb_funcs); -} -static const struct drm_mode_config_funcs tinydrm_mode_config_funcs = { - .fb_create = tinydrm_fb_create, + .fb_create = drm_gem_fb_create_with_dirty, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };static int tinydrm_init (struct device *parent,struct tinydrm_device *tdev, -const struct drm_framebuffer_funcs *fb_funcs,struct drm_driver *driver) {struct drm_device *drm; -mutex_init (&tdev->dirty_lock); - tdev->fb_funcs = fb_funcs; -/* * We don't embed drm_device, because that prevent us from using * devm_kzalloc() to allocate tinydrm_device in the driver since
@@ -83,7 +69,6 @@ static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,static void tinydrm_fini (struct tinydrm_device *tdev) {drm_mode_config_cleanup (tdev->drm); -mutex_destroy (&tdev->dirty_lock); tdev->drm->dev_private =NULL ;drm_dev_put (tdev->drm); }
@@ -97,7 +82,6 @@ static void devm_tinydrm_release(void *data)* devm_tinydrm_init - Initialize tinydrm device * @parent: Parent device object * @tdev: tinydrm device -* @fb_funcs: Framebuffer functions * @driver: DRM driver * * This function initializes @tdev, the underlying DRM device and it's
@@ -108,12 +92,11 @@ static void devm_tinydrm_release(void *data)* Zero on success, negative error code on failure. */ int devm_tinydrm_init (struct device *parent,struct tinydrm_device *tdev, -const struct drm_framebuffer_funcs *fb_funcs,struct drm_driver *driver) {int ret; - ret =tinydrm_init (parent, tdev, fb_funcs, driver); + ret =tinydrm_init (parent, tdev, driver);if (ret)return ret;
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +1 -90
105 lines not on this page · raw message
drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c +0 -30
@@ -108,36 +108,6 @@ tinydrm_connector_create(struct drm_device *drm,return connector; } -/** -* tinydrm_display_pipe_update - Display pipe update helper -* @pipe: Simple display pipe -* @old_state: Old plane state -* -* This function does a full framebuffer flush if the plane framebuffer -* has changed. It also handles vblank events. Drivers can use this as their -* &drm_simple_display_pipe_funcs->update callback. -*/ -void tinydrm_display_pipe_update (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *old_state) -{ -struct tinydrm_device *tdev =pipe_to_tinydrm (pipe); -struct drm_framebuffer *fb = pipe->plane.state->fb; -struct drm_crtc *crtc = &tdev->pipe.crtc; - -if (fb && (fb != old_state->fb)) { -if (tdev->fb_dirty) - tdev->fb_dirty (fb,NULL ,0 ,0 ,NULL ,0 ); - } - -if (crtc->state->event) { -spin_lock_irq (&crtc->dev->event_lock); -drm_crtc_send_vblank_event (crtc, crtc->state->event); -spin_unlock_irq (&crtc->dev->event_lock); - crtc->state->event =NULL ; - } -} -EXPORT_SYMBOL (tinydrm_display_pipe_update); -static int tinydrm_rotate_mode (struct drm_display_mode *mode,unsigned int rotation) {
drivers/gpu/drm/tinydrm/hx8357d.c +1 -1
@@ -175,7 +175,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,static const struct drm_simple_display_pipe_funcs hx8357d_pipe_funcs = { .enable = yx240qv29_enable, .disable = mipi_dbi_pipe_disable, - .update = tinydrm_display_pipe_update, + .update = mipi_dbi_pipe_update, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, };
drivers/gpu/drm/tinydrm/ili9225.c +31 -70
154 lines not on this page · raw message
drivers/gpu/drm/tinydrm/ili9341.c +1 -1
@@ -131,7 +131,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,static const struct drm_simple_display_pipe_funcs ili9341_pipe_funcs = { .enable = yx240qv29_enable, .disable = mipi_dbi_pipe_disable, - .update = tinydrm_display_pipe_update, + .update = mipi_dbi_pipe_update, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, };
drivers/gpu/drm/tinydrm/mi0283qt.c +1 -1
@@ -139,7 +139,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe,static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = { .enable = mi0283qt_enable, .disable = mipi_dbi_pipe_disable, - .update = tinydrm_display_pipe_update, + .update = mipi_dbi_pipe_update, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, };
drivers/gpu/drm/tinydrm/mipi-dbi.c +47 -25
140 lines not on this page · raw message
drivers/gpu/drm/tinydrm/repaper.c +22 -17
@@ -26,6 +26,7 @@#include <linux/spi/spi.h> #include <linux/thermal.h> +#include <drm/drm_damage_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
@@ -522,11 +523,7 @@ static void repaper_gray8_to_mono_reversed(u8 *buf, u32 width, u32 height) } } -static int repaper_fb_dirty (struct drm_framebuffer *fb, -struct drm_file *file_priv, -unsigned int flags,unsigned int color, -struct drm_clip_rect *clips, -unsigned int num_clips) +static int repaper_fb_dirty (struct drm_framebuffer *fb) {struct drm_gem_cma_object *cma_obj =drm_fb_cma_get_gem_obj (fb,0 );struct dma_buf_attachment *import_attach = cma_obj->base.import_attach;
@@ -625,12 +622,6 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,return ret; } -static const struct drm_framebuffer_funcs repaper_fb_funcs = { - .destroy = drm_gem_fb_destroy, - .create_handle = drm_gem_fb_create_handle, - .dirty = tinydrm_fb_dirty, -}; -static void power_off (struct repaper_epd *epd) {/* Turn off power and all signals */
@@ -794,9 +785,7 @@ static void repaper_pipe_disable(struct drm_simple_display_pipe *pipe)DRM_DEBUG_DRIVER ("\n" ); -mutex_lock (&tdev->dirty_lock); epd->enabled = false; -mutex_unlock (&tdev->dirty_lock);/* Nothing frame */ for (line =0 ; line < epd->height; line++)
@@ -839,10 +828,28 @@ static void repaper_pipe_disable(struct drm_simple_display_pipe *pipe)power_off (epd); } +static void repaper_pipe_update (struct drm_simple_display_pipe *pipe, +struct drm_plane_state *old_state) +{ +struct drm_plane_state *state = pipe->plane.state; +struct drm_crtc *crtc = &pipe->crtc; +struct drm_rect rect; + +if (drm_atomic_helper_damage_merged (old_state, state, &rect)) +repaper_fb_dirty (state->fb); + +if (crtc->state->event) { +spin_lock_irq (&crtc->dev->event_lock); +drm_crtc_send_vblank_event (crtc, crtc->state->event); +spin_unlock_irq (&crtc->dev->event_lock); + crtc->state->event =NULL ; + } +} +static const struct drm_simple_display_pipe_funcs repaper_pipe_funcs = { .enable = repaper_pipe_enable, .disable = repaper_pipe_disable, - .update = tinydrm_display_pipe_update, + .update = repaper_pipe_update, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, };
@@ -1056,12 +1063,10 @@ static int repaper_probe(struct spi_device *spi) tdev = &epd->tinydrm; - ret =devm_tinydrm_init (dev, tdev, &repaper_fb_funcs, &repaper_driver); + ret =devm_tinydrm_init (dev, tdev, &repaper_driver);if (ret)return ret; - tdev->fb_dirty = repaper_fb_dirty; - ret = tinydrm_display_pipe_init(tdev, &repaper_pipe_funcs, DRM_MODE_CONNECTOR_VIRTUAL, repaper_formats,
drivers/gpu/drm/tinydrm/st7586.c +28 -22
104 lines not on this page · raw message
drivers/gpu/drm/tinydrm/st7735r.c +1 -1
@@ -105,7 +105,7 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe,static const struct drm_simple_display_pipe_funcs jd_t18003_t01_pipe_funcs = { .enable = jd_t18003_t01_pipe_enable, .disable = mipi_dbi_pipe_disable, - .update = tinydrm_display_pipe_update, + .update = mipi_dbi_pipe_update, .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, };
include/drm/tinydrm/mipi-dbi.h +2 -0
@@ -68,6 +68,8 @@ int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi,const struct drm_simple_display_pipe_funcs *pipe_funcs, struct drm_driver *driver, const struct drm_display_mode *mode, unsigned int rotation); +void mipi_dbi_pipe_update (struct drm_simple_display_pipe *pipe, +struct drm_plane_state *old_state);void mipi_dbi_enable_flush (struct mipi_dbi *mipi,struct drm_crtc_state *crtc_state,struct drm_plane_state *plan_state);
include/drm/tinydrm/tinydrm-helpers.h +1 -10
@@ -11,8 +11,7 @@#define __LINUX_TINYDRM_HELPERS_Hstruct backlight_device ; -struct tinydrm_device ; -struct drm_clip_rect ; +struct drm_framebuffer ;struct drm_rect ;struct spi_transfer ;struct spi_message ;
@@ -34,14 +33,6 @@ static inline bool tinydrm_machine_little_endian(void)#endif } -bool tinydrm_merge_clips (struct drm_rect *dst, -struct drm_clip_rect *src,unsigned int num_clips, -unsigned int flags,u32 max_width,u32 max_height); -int tinydrm_fb_dirty (struct drm_framebuffer *fb, -struct drm_file *file_priv, -unsigned int flags,unsigned int color, -struct drm_clip_rect *clips, -unsigned int num_clips);void tinydrm_memcpy (void *dst,void *vaddr,struct drm_framebuffer *fb,struct drm_rect *clip); void tinydrm_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
include/drm/tinydrm/tinydrm.h +0 -26
@@ -10,14 +10,9 @@#ifndef __LINUX_TINYDRM_H#define __LINUX_TINYDRM_H -#include <linux/mutex.h> #include <drm/drm_simple_kms_helper.h> -struct drm_clip_rect ;struct drm_driver ; -struct drm_file ; -struct drm_framebuffer ; -struct drm_framebuffer_funcs ;/** * struct tinydrm_device - tinydrm device
@@ -32,24 +27,6 @@ struct tinydrm_device {* @pipe: Display pipe structure */ struct drm_simple_display_pipe pipe; - -/** -* @dirty_lock: Serializes framebuffer flushing -*/ -struct mutex dirty_lock; - -/** -* @fb_funcs: Framebuffer functions used when creating framebuffers -*/ -const struct drm_framebuffer_funcs *fb_funcs; - -/** -* @fb_dirty: Framebuffer dirty callback -*/ -int (*fb_dirty)(struct drm_framebuffer *framebuffer, -struct drm_file *file_priv,unsigned flags, -unsigned color,struct drm_clip_rect *clips, -unsigned num_clips); }; static inline struct tinydrm_device *
@@ -82,13 +59,10 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe) .clock = 1 /* pass validation */int devm_tinydrm_init (struct device *parent,struct tinydrm_device *tdev, -const struct drm_framebuffer_funcs *fb_funcs,struct drm_driver *driver);int devm_tinydrm_register (struct tinydrm_device *tdev);void tinydrm_shutdown (struct tinydrm_device *tdev); -void tinydrm_display_pipe_update (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *old_state); int tinydrm_display_pipe_init(struct tinydrm_device *tdev, const struct drm_simple_display_pipe_funcs *funcs,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · Noralf Trønnes
This switches to
drm_atomic_helper_dirtyfb()as the framebuffer dirty handler. All flushing will now happen in the pipe functions.Also enable the damage plane property for all except repaper which can only do full updates.
ili9225:
This change madeili9225_init()equal tomipi_dbi_init()so use it.Cc David Lechner <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>---
...
Quoted 7 lines
drivers/gpu/drm/tinydrm/ili9225.c +7
-0+static void ili9225_pipe_update (struct drm_simple_display_pipe *pipe, +struct drm_plane_state *old_state) +{ +struct drm_plane_state *state = pipe->plane.state; +struct drm_crtc *crtc = &pipe->crtc; +struct drm_rect rect; +
drivers/gpu/drm/tinydrm/ili9225.c static int ili9225_fb_dirty(struct drm_framebuffer *fb, · line 175
Quoted 10 lines
drivers/gpu/drm/tinydrm/ili9225.c +10
-0+if (drm_atomic_helper_damage_merged (old_state, state, &rect)) +ili9225_fb_dirty (state->fb, &rect); + +if (crtc->state->event) { +spin_lock_irq (&crtc->dev->event_lock); +drm_crtc_send_vblank_event (crtc, crtc->state->event); +spin_unlock_irq (&crtc->dev->event_lock); + crtc->state->event =NULL ; + } +}
It looks like this function body is repeated 4 times with the only difference being the dirty function. Perhaps a helper function is called for?
Also, I was going to test out this series the displays that I have, but I guess I will wait until it is easier to apply the patches.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Den 11.01.2019 02.06, skrev David Lechner:
Quoted 30 lines · Noralf Trønnes
Quoted 13 lines
This switches to
drm_atomic_helper_dirtyfb()as the framebuffer dirty handler. All flushing will now happen in the pipe functions.Also enable the damage plane property for all except repaper which can only do full updates.
ili9225:
This change madeili9225_init()equal tomipi_dbi_init()so use it.Cc David Lechner <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Noralf Trønnes <[email protected]>---
...
Quoted 13 lines
drivers/gpu/drm/tinydrm/ili9225.c +13
-0+static void ili9225_pipe_update (struct drm_simple_display_pipe *pipe, + struct drm_plane_state *old_state) +{ + struct drm_plane_state *state = pipe->plane.state; + struct drm_crtc *crtc = &pipe->crtc; + struct drm_rect rect; + + if (drm_atomic_helper_damage_merged(old_state, state, &rect)) + ili9225_fb_dirty(state->fb, &rect); + + if (crtc->state->event) { + spin_lock_irq(&crtc->dev->event_lock); + drm_crtc_send_vblank_event(crtc, crtc->state->event);
Quoted 8 lines
Quoted 4 lines
+
spin_unlock_irq(&crtc->dev->event_lock);
+crtc->state->event= NULL;
+ }
+}It looks like this function body is repeated 4 times with the only difference being the dirty function. Perhaps a helper function is called for?
I agree, this is used in several other drivers too. The problem is that this is magic code to me so I wouldn't even know what to call the function and certainly not what to put in the docs. So I left it out. And the drm_crtc_arm_vblank_event() function used elsewhere adds even more mystery to it all.
Quoted 3 lines
Also, I was going to test out this series the displays that I have, but I guess I will wait until it is easier to apply the patches.
I will send a version 2 when Maxime has backmerged -rc1.
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Noralf-Tr-nnes/drm-tinydrm-Use-damage-helper-for-dirtyfb/20190110-194410
Hi Noralf,
New smatch warnings:drivers/gpu/drm/tinydrm/mipi-dbi.c:305 mipi_dbi_enable_flush() warn: variable dereferenced before check 'fb' (see line 299)
Old smatch warnings:drivers/gpu/drm/tinydrm/mipi-dbi.c:108 mipi_dbi_command_is_read() error: buffer overflow 'mipi->read_commands' 21 <= 254 drivers/gpu/drm/tinydrm/mipi-dbi.c:110 mipi_dbi_command_is_read() error: buffer overflow 'mipi->read_commands' 21 <= 254
# https://github.com/0day-ci/linux/commit/50dd14907581e982f534b7718bc3f8c903f46c88
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 50dd14907581e982f534b7718bc3f8c903f46c88
vim +/fb +305 drivers/gpu/drm/tinydrm/mipi-dbi.c
02dd95fe Noralf Trønnes 2017-01-22 281
02dd95fe Noralf Trønnes 2017-01-22 282 /**
22edc8d3 Noralf Trønnes 2018-01-10 283 * mipi_dbi_enable_flush - MIPI DBI enable helper
22edc8d3 Noralf Trønnes 2018-01-10 284 * @mipi: MIPI DBI structure
5685ca0c Noralf Trønnes 2018-07-10 285 * @crtc_state: CRTC state
5685ca0c Noralf Trønnes 2018-07-10 286 * @plane_state: Plane state
22edc8d3 Noralf Trønnes 2018-01-10 287 *
22edc8d3 Noralf Trønnes 2018-01-10 288 * This function sets &mipi_dbi->enabled, flushes the whole framebuffer and
22edc8d3 Noralf Trønnes 2018-01-10 289 * enables the backlight. Drivers can use this in their
22edc8d3 Noralf Trønnes 2018-01-10 290 * &drm_simple_display_pipe_funcs->enable callback.
22edc8d3 Noralf Trønnes 2018-01-10 291 */
e85d3006 Ville Syrjälä 2018-03-23 292 void mipi_dbi_enable_flush(struct mipi_dbi *mipi,
e85d3006 Ville Syrjälä 2018-03-23 293 struct drm_crtc_state *crtc_state,
e85d3006 Ville Syrjälä 2018-03-23 294 struct drm_plane_state *plane_state)
22edc8d3 Noralf Trønnes 2018-01-10 295 {
e85d3006 Ville Syrjälä 2018-03-23 296 struct drm_framebuffer *fb = plane_state->fb;
50dd1490 Noralf Trønnes 2019-01-09 297 struct drm_rect rect = {
50dd1490 Noralf Trønnes 2019-01-09 298 .x1 = 0,
50dd1490 Noralf Trønnes 2019-01-09 @299 .x2 = fb->width,
50dd1490 Noralf Trønnes 2019-01-09 300 .y1 = 0,
50dd1490 Noralf Trønnes 2019-01-09 301 .y2 = fb->height,
50dd1490 Noralf Trønnes 2019-01-09 302 };
22edc8d3 Noralf Trønnes 2018-01-10 303
22edc8d3 Noralf Trønnes 2018-01-10 304 mipi->enabled = true;
22edc8d3 Noralf Trønnes 2018-01-10 @305 if (fb)
50dd1490 Noralf Trønnes 2019-01-09 306 mipi_dbi_fb_dirty(fb, &rect);
22edc8d3 Noralf Trønnes 2018-01-10 307
414147e8 Meghana Madhyastha 2018-01-24 308 backlight_enable(mipi->backlight);
22edc8d3 Noralf Trønnes 2018-01-10 309 }
22edc8d3 Noralf Trønnes 2018-01-10 310 EXPORT_SYMBOL(mipi_dbi_enable_flush);
22edc8d3 Noralf Trønnes 2018-01-10 311 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Noralf.
Quoted 5 lines
I was really pleased to see that the damage helper had landed. Now I can do framebuffer flushing solely through the display pipe functions. This prepares the ground for the removal of struct
tinydrm_devicein my next series.
I browsed through the code - and the code paths I could follow looked good to me.
I missed an update of Documentation/gpu/todo.rst as I think we can close a few items with this patch-set.
You can add my:
to the full series.
Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Den 09.01.2019 19.26, skrev Sam Ravnborg:
Quoted 8 lines
Hi Noralf.
Quoted 5 lines
I was really pleased to see that the damage helper had landed. Now I can do framebuffer flushing solely through the display pipe functions. This prepares the ground for the removal of struct
tinydrm_devicein my next series.
Quoted 5 lines
I browsed through the code - and the code paths I could follow looked good to me.
I missed an update ofDocumentation/gpu/todo.rstas I think we can close a few items with this patch-set.
Yeah, you're right, I forgot about that one. I'll add a patch in the next version.
Quoted 4 lines
You can add my:
Acked-by Sam Ravnborg <[email protected]>to the full series.
Thanks,
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Noralf Trønnes
Hi,
I was really pleased to see that the damage helper had landed. Now I can do framebuffer flushing solely through the display pipe functions. This prepares the ground for the removal of struct
tinydrm_devicein my next series.
Awesome stuff!
Quoted 3 lines
Note:
The damage helper isn't in drm-misc-next yet, it will show up when -rc1 arrives there.
Maxime, can you pls do the backmerge for Noralf, with the above reason?
$ dim backmerge drm-misc-next drm/drm-next
should get the job done.
Cheers, Daniel
Quoted 36 lines
Noralf.
Noralf Trønnes (4):
drm/gem-fb-helper: Adddrm_gem_fb_create_with_dirty()drm/damage-helper: Adddrm_atomic_helper_damage_merged()drm/tinydrm: Use structdrm_rect
drm/tinydrm: Use damage helper for dirtyfbdrivers/gpu/drm/drm_damage_helper.c | 43 ++++++ drivers/gpu/drm/drm_gem_framebuffer_helper.c | 47 +++++- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 21 +-- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 100 +------------ drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 30 ---- drivers/gpu/drm/tinydrm/hx8357d.c | 2 +- drivers/gpu/drm/tinydrm/ili9225.c | 138 +++++++----------- drivers/gpu/drm/tinydrm/ili9341.c | 2 +- drivers/gpu/drm/tinydrm/mi0283qt.c | 2 +- drivers/gpu/drm/tinydrm/mipi-dbi.c | 87 +++++++---- drivers/gpu/drm/tinydrm/repaper.c | 42 +++--- drivers/gpu/drm/tinydrm/st7586.c | 73 ++++----- drivers/gpu/drm/tinydrm/st7735r.c | 2 +- include/drm/drm_damage_helper.h | 3 + include/drm/drm_gem_framebuffer_helper.h | 3 + include/drm/tinydrm/mipi-dbi.h | 5 +- include/drm/tinydrm/tinydrm-helpers.h | 20 +-- include/drm/tinydrm/tinydrm.h | 26 ---- 18 files changed, 281 insertions(+), 365 deletions(-)--
2.20.1_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Noralf Trønnes
Hi,
I was really pleased to see that the damage helper had landed. Now I can
do framebuffer flushing solely through the display pipe functions. This
prepares the ground for the removal of structtinydrm_devicein my next
series.
Hi Noralf,
Not an expert of tinydrm but I followed the code and everything looked alright to me especially the usage of damage iterator.
Yes the code to clear damage on plane state destroy was missing earlier and can be removed from the new helper you have. It is better to have damage in plane state as something else might need it.
Thanks,
Deepak
Quoted 26 lines
Note:
The damage helper isn't in drm-misc-next yet, it will show up when -rc1
arrives there.Noralf.
Noralf Trønnes (4):
drm/gem-fb-helper: Adddrm_gem_fb_create_with_dirty()drm/damage-helper: Adddrm_atomic_helper_damage_merged()drm/tinydrm: Use structdrm_rect
drm/tinydrm: Use damage helper for dirtyfbdrivers/gpu/drm/drm_damage_helper.c | 43 ++++++ drivers/gpu/drm/drm_gem_framebuffer_helper.c | 47 +++++- drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 21 +-- .../gpu/drm/tinydrm/core/tinydrm-helpers.c | 100 +------------ drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 30 ---- drivers/gpu/drm/tinydrm/hx8357d.c | 2 +- drivers/gpu/drm/tinydrm/ili9225.c | 138 +++++++--------- -- drivers/gpu/drm/tinydrm/ili9341.c | 2 +- drivers/gpu/drm/tinydrm/mi0283qt.c | 2 +- drivers/gpu/drm/tinydrm/mipi-dbi.c | 87 +++++++---- drivers/gpu/drm/tinydrm/repaper.c | 42 +++---
Quoted 9 lines
drivers/gpu/drm/tinydrm/st7586.c | 73 ++++----- drivers/gpu/drm/tinydrm/st7735r.c | 2 +- include/drm/drm_damage_helper.h | 3 + include/drm/drm_gem_framebuffer_helper.h | 3 + include/drm/tinydrm/mipi-dbi.h | 5 +- include/drm/tinydrm/tinydrm-helpers.h | 20 +-- include/drm/tinydrm/tinydrm.h | 26 ---- 18 files changed, 281 insertions(+), 365 deletions(-)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel