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