This 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. Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx> Acked-by: Sam Ravnborg <sam@xxxxxxxxxxxx> Acked-by: Daniel Vetter <daniel.vetter@xxxxxxxx> --- .../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(-) diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c index bf6bfbc5d412..d0ece6ad4a1c 100644 --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c @@ -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; diff --git a/drivers/gpu/drm/tinydrm/ili9225.c b/drivers/gpu/drm/tinydrm/ili9225.c index b0ad58b97227..ad644069089f 100644 --- a/drivers/gpu/drm/tinydrm/ili9225.c +++ b/drivers/gpu/drm/tinydrm/ili9225.c @@ -25,6 +25,7 @@ #include <drm/drm_fourcc.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> @@ -84,7 +85,8 @@ static int ili9225_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; u16 x_start, y_start; u16 x1, x2, y1, y2; int ret = 0; @@ -97,13 +99,12 @@ static int ili9225_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 { @@ -112,34 +113,34 @@ static int ili9225_fb_dirty(struct drm_framebuffer *fb, switch (mipi->rotation) { default: - x1 = clip.x1; - x2 = clip.x2 - 1; - y1 = clip.y1; - y2 = clip.y2 - 1; + x1 = rect->x1; + x2 = rect->x2 - 1; + y1 = rect->y1; + y2 = rect->y2 - 1; x_start = x1; y_start = y1; break; case 90: - x1 = clip.y1; - x2 = clip.y2 - 1; - y1 = fb->width - clip.x2; - y2 = fb->width - clip.x1 - 1; + x1 = rect->y1; + x2 = rect->y2 - 1; + y1 = fb->width - rect->x2; + y2 = fb->width - rect->x1 - 1; x_start = x1; y_start = y2; break; case 180: - x1 = fb->width - clip.x2; - x2 = fb->width - clip.x1 - 1; - y1 = fb->height - clip.y2; - y2 = fb->height - clip.y1 - 1; + x1 = fb->width - rect->x2; + x2 = fb->width - rect->x1 - 1; + y1 = fb->height - rect->y2; + y2 = fb->height - rect->y1 - 1; x_start = x2; y_start = y2; break; case 270: - x1 = fb->height - clip.y2; - x2 = fb->height - clip.y1 - 1; - y1 = clip.x1; - y2 = clip.x2 - 1; + x1 = fb->height - rect->y2; + x2 = fb->height - rect->y1 - 1; + y1 = rect->x1; + y2 = rect->x2 - 1; x_start = x2; y_start = y1; break; @@ -154,7 +155,7 @@ static int ili9225_fb_dirty(struct drm_framebuffer *fb, ili9225_command(mipi, ILI9225_RAM_ADDRESS_SET_2, y_start); ret = mipi_dbi_command_buf(mipi, ILI9225_WRITE_DATA_TO_GRAM, tr, - (clip.x2 - clip.x1) * (clip.y2 - clip.y1) * 2); + (rect->x2 - rect->x1) * (rect->y2 - rect->y1) * 2); return ret; } diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index 10294e1283dd..1e7e8cfc99f0 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -22,6 +22,7 @@ #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fourcc.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> @@ -172,7 +173,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; @@ -221,7 +222,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; @@ -232,13 +234,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 { @@ -246,14 +247,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; } diff --git a/drivers/gpu/drm/tinydrm/repaper.c b/drivers/gpu/drm/tinydrm/repaper.c index b2a8f894946a..238515de449e 100644 --- a/drivers/gpu/drm/tinydrm/repaper.c +++ b/drivers/gpu/drm/tinydrm/repaper.c @@ -30,6 +30,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> @@ -532,7 +533,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; diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c index bf518167760a..a52bc3b02606 100644 --- a/drivers/gpu/drm/tinydrm/st7586.c +++ b/drivers/gpu/drm/tinydrm/st7586.c @@ -21,6 +21,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> @@ -62,7 +63,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; @@ -88,7 +89,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; @@ -118,7 +119,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; @@ -129,30 +131,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; } diff --git a/include/drm/tinydrm/mipi-dbi.h b/include/drm/tinydrm/mipi-dbi.h index b8ba58861986..b52f32897f23 100644 --- a/include/drm/tinydrm/mipi-dbi.h +++ b/include/drm/tinydrm/mipi-dbi.h @@ -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 diff --git a/include/drm/tinydrm/tinydrm-helpers.h b/include/drm/tinydrm/tinydrm-helpers.h index 5b96f0b12c8c..8edb75df4e31 100644 --- a/include/drm/tinydrm/tinydrm-helpers.h +++ b/include/drm/tinydrm/tinydrm-helpers.h @@ -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); -- 2.20.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel