]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
drm/tinydrm: Use struct drm_rect
authorNoralf Trønnes <noralf@tronnes.org>
Tue, 15 Jan 2019 04:36:41 +0000 (05:36 +0100)
committerNoralf Trønnes <noralf@tronnes.org>
Thu, 17 Jan 2019 09:57:03 +0000 (10:57 +0100)
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@tronnes.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190115043643.2364-4-noralf@tronnes.org
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
drivers/gpu/drm/tinydrm/ili9225.c
drivers/gpu/drm/tinydrm/mipi-dbi.c
drivers/gpu/drm/tinydrm/repaper.c
drivers/gpu/drm/tinydrm/st7586.c
include/drm/tinydrm/mipi-dbi.h
include/drm/tinydrm/tinydrm-helpers.h

index bf6bfbc5d412c8c2bb2e8a14fed1d16a139f1b88..d0ece6ad4a1c4a9ea561b19c4d5189b351a331bc 100644 (file)
@@ -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;
index b0ad58b972272861439a449a03947e2cc50426cf..ad644069089fe60eba97934bb7eedeb6f8612004 100644 (file)
@@ -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;
 }
index 10294e1283dd2c9a2fe3cafb48d8e82f1828e63a..1e7e8cfc99f04c292155a539ec509f3a4dd9a726 100644 (file)
@@ -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;
 }
index b2a8f894946a4a56c2ab67e58e4751c46b447717..238515de449e6a491515b2568355ec8b7dc6cf65 100644 (file)
@@ -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;
 
index bf518167760af4216207d03433788019a42195d9..a52bc3b02606440acb245b036cec5700dd2cbaf7 100644 (file)
@@ -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;
 }
index b8ba5886198678b9fd490a8794e8c794fe47bd47..b52f32897f23cfabfde1b28a1b2d2eef7f3d0e23 100644 (file)
@@ -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
index 5b96f0b12c8cefb76554abf8faf281a5689634e5..8edb75df4e31824ba2d2bf6f672abab6a1135432 100644 (file)
@@ -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);