Add destination-buffer pitch as argument to drm_fb_swab(). Done for consistency with the rest of the interface. v2: * update documentation (Noralf)
Unified · Split
| @@ -101,6 +101,7 @@ EXPORT_SYMBOL(drm_fb_memcpy_toio); · 100 unmodified lines | ||
| 101 | 101 | /** |
| 102 | 102 | * drm_fb_swab - Swap bytes into clip buffer |
| 103 | 103 | * @dst: Destination buffer |
| 104 | + * @dst_pitch: Number of bytes between two consecutive scanlines within dst | |
| 104 | 105 | * @src: Source buffer |
| 105 | 106 | * @fb: DRM framebuffer |
| 106 | 107 | * @clip: Clip rectangle area to copy |
| @@ -110,21 +111,27 @@ EXPORT_SYMBOL(drm_fb_memcpy_toio); · 3 unmodified lines | ||
| 110 | 111 | * time to speed up slow uncached reads. |
| 111 | 112 | * |
| 112 | 113 | * This function does not apply clipping on dst, i.e. the destination |
| 113 | − * is a small buffer containing the clip rect only. | |
| 114 | + * is at the top-left corner. | |
| 114 | 115 | */ |
| 115 | −void drm_fb_swab(void *dst, void *src, struct drm_framebuffer *fb, | |
| 116 | − struct drm_rect *clip, bool cached) | |
| 116 | +void drm_fb_swab(void *dst, unsigned int dst_pitch, const void *src, | |
| 117 | + const struct drm_framebuffer *fb, const struct drm_rect *clip, | |
| 118 | + bool cached) | |
| 117 | 119 | { |
| 118 | 120 | u8 cpp = fb->format->cpp[0]; |
| 119 | 121 | size_t len = drm_rect_width(clip) * cpp; |
| 120 | − u16 *src16, *dst16 = dst; | |
| 121 | − u32 *src32, *dst32 = dst; | |
| 122 | + const u16 *src16; | |
| 123 | + const u32 *src32; | |
| 124 | + u16 *dst16; | |
| 125 | + u32 *dst32; | |
| 122 | 126 | unsigned int x, y; |
| 123 | 127 | void *buf = NULL; |
| 124 | 128 | |
| 125 | 129 | if (WARN_ON_ONCE(cpp != 2 && cpp != 4)) |
| 126 | 130 | return; |
| 127 | 131 | |
| 132 | + if (!dst_pitch) | |
| 133 | + dst_pitch = len; | |
| 134 | + | |
| 128 | 135 | if (!cached) |
| 129 | 136 | buf = kmalloc(len, GFP_KERNEL); |
| 130 | 137 | |
| @@ -140,6 +147,9 @@ void drm_fb_swab(void *dst, void *src, struct drm_framebuffer *fb, · 9 unmodified lines | ||
| 140 | 147 | src32 = src; |
| 141 | 148 | } |
| 142 | 149 | |
| 150 | + dst16 = dst; | |
| 151 | + dst32 = dst; | |
| 152 | + | |
| 143 | 153 | for (x = clip->x1; x < clip->x2; x++) { |
| 144 | 154 | if (cpp == 4) |
| 145 | 155 | *dst32++ = swab32(*src32++); |
| @@ -148,6 +158,7 @@ void drm_fb_swab(void *dst, void *src, struct drm_framebuffer *fb, · 2 unmodified lines | ||
| 148 | 158 | } |
| 149 | 159 | |
| 150 | 160 | src += fb->pitches[0]; |
| 161 | + dst += dst_pitch; | |
| 151 | 162 | } |
| 152 | 163 | |
| 153 | 164 | kfree(buf); |
| @@ -211,7 +211,7 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, · 210 unmodified lines | ||
| 211 | 211 | switch (fb->format->format) { |
| 212 | 212 | case DRM_FORMAT_RGB565: |
| 213 | 213 | if (swap) |
| 214 | − drm_fb_swab(dst, src, fb, clip, !gem->import_attach); | |
| 214 | + drm_fb_swab(dst, 0, src, fb, clip, !gem->import_attach); | |
| 215 | 215 | else |
| 216 | 216 | drm_fb_memcpy(dst, 0, src, fb, clip); |
| 217 | 217 | break; |
| @@ -201,7 +201,7 @@ retry: · 200 unmodified lines | ||
| 201 | 201 | len = gud_xrgb8888_to_color(buf, format, vaddr, fb, rect); |
| 202 | 202 | } |
| 203 | 203 | } else if (gud_is_big_endian() && format->cpp[0] > 1) { |
| 204 | − drm_fb_swab(buf, vaddr, fb, rect, !import_attach); | |
| 204 | + drm_fb_swab(buf, 0, vaddr, fb, rect, !import_attach); | |
| 205 | 205 | } else if (compression && !import_attach && pitch == fb->pitches[0]) { |
| 206 | 206 | /* can compress directly from the framebuffer */ |
| 207 | 207 | buf = vaddr + rect->y1 * pitch; |
| @@ -17,8 +17,9 @@ void drm_fb_memcpy(void *dst, unsigned int dst_pitch, const void *vaddr, · 16 unmodified lines | ||
| 17 | 17 | const struct drm_framebuffer *fb, const struct drm_rect *clip); |
| 18 | 18 | void drm_fb_memcpy_toio(void __iomem *dst, unsigned int dst_pitch, const void *vaddr, |
| 19 | 19 | const struct drm_framebuffer *fb, const struct drm_rect *clip); |
| 20 | −void drm_fb_swab(void *dst, void *src, struct drm_framebuffer *fb, | |
| 21 | − struct drm_rect *clip, bool cached); | |
| 20 | +void drm_fb_swab(void *dst, unsigned int dst_pitch, const void *src, | |
| 21 | + const struct drm_framebuffer *fb, const struct drm_rect *clip, | |
| 22 | + bool cached); | |
| 22 | 23 | void drm_fb_xrgb8888_to_rgb332(void *dst, void *vaddr, struct drm_framebuffer *fb, |
| 23 | 24 | struct drm_rect *clip); |
| 24 | 25 | void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr, |