Commit 19b20a80 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/format-helper: Streamline blit-helper interface

Move destination-buffer clipping from format-helper blit function into
caller. Rename drm_fb_blit_rect_dstclip() to drm_fb_blit_toio(). Done for
consistency with the rest of the interface. Remove drm_fb_blit_dstclip(),
which isn't required.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20211110103702.374-6-tzimmermann@suse.de
parent 53bc2098
...@@ -472,7 +472,7 @@ void drm_fb_xrgb8888_to_gray8(void *dst, unsigned int dst_pitch, const void *vad ...@@ -472,7 +472,7 @@ void drm_fb_xrgb8888_to_gray8(void *dst, unsigned int dst_pitch, const void *vad
EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8); EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8);
/** /**
* drm_fb_blit_rect_dstclip - Copy parts of a framebuffer to display memory * drm_fb_blit_toio - Copy parts of a framebuffer to display memory
* @dst: The display memory to copy to * @dst: The display memory to copy to
* @dst_pitch: Number of bytes between two consecutive scanlines within dst * @dst_pitch: Number of bytes between two consecutive scanlines within dst
* @dst_format: FOURCC code of the display's color format * @dst_format: FOURCC code of the display's color format
...@@ -484,17 +484,14 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8); ...@@ -484,17 +484,14 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8);
* formats of the display and the framebuffer mismatch, the blit function * formats of the display and the framebuffer mismatch, the blit function
* will attempt to convert between them. * will attempt to convert between them.
* *
* Use drm_fb_blit_dstclip() to copy the full framebuffer.
*
* Returns: * Returns:
* 0 on success, or * 0 on success, or
* -EINVAL if the color-format conversion failed, or * -EINVAL if the color-format conversion failed, or
* a negative error code otherwise. * a negative error code otherwise.
*/ */
int drm_fb_blit_rect_dstclip(void __iomem *dst, unsigned int dst_pitch, int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_format,
uint32_t dst_format, void *vmap, const void *vmap, const struct drm_framebuffer *fb,
struct drm_framebuffer *fb, const struct drm_rect *clip)
struct drm_rect *clip)
{ {
uint32_t fb_format = fb->format->format; uint32_t fb_format = fb->format->format;
...@@ -505,20 +502,16 @@ int drm_fb_blit_rect_dstclip(void __iomem *dst, unsigned int dst_pitch, ...@@ -505,20 +502,16 @@ int drm_fb_blit_rect_dstclip(void __iomem *dst, unsigned int dst_pitch,
dst_format = DRM_FORMAT_XRGB8888; dst_format = DRM_FORMAT_XRGB8888;
if (dst_format == fb_format) { if (dst_format == fb_format) {
dst += clip_offset(clip, dst_pitch, fb->format->cpp[0]);
drm_fb_memcpy_toio(dst, dst_pitch, vmap, fb, clip); drm_fb_memcpy_toio(dst, dst_pitch, vmap, fb, clip);
return 0; return 0;
} else if (dst_format == DRM_FORMAT_RGB565) { } else if (dst_format == DRM_FORMAT_RGB565) {
if (fb_format == DRM_FORMAT_XRGB8888) { if (fb_format == DRM_FORMAT_XRGB8888) {
dst += clip_offset(clip, dst_pitch, fb->format->cpp[0]); drm_fb_xrgb8888_to_rgb565_toio(dst, dst_pitch, vmap, fb, clip, false);
drm_fb_xrgb8888_to_rgb565_toio(dst, dst_pitch, vmap, fb, clip,
false);
return 0; return 0;
} }
} else if (dst_format == DRM_FORMAT_RGB888) { } else if (dst_format == DRM_FORMAT_RGB888) {
if (fb_format == DRM_FORMAT_XRGB8888) { if (fb_format == DRM_FORMAT_XRGB8888) {
dst += clip_offset(clip, dst_pitch, fb->format->cpp[0]);
drm_fb_xrgb8888_to_rgb888_toio(dst, dst_pitch, vmap, fb, clip); drm_fb_xrgb8888_to_rgb888_toio(dst, dst_pitch, vmap, fb, clip);
return 0; return 0;
} }
...@@ -526,36 +519,4 @@ int drm_fb_blit_rect_dstclip(void __iomem *dst, unsigned int dst_pitch, ...@@ -526,36 +519,4 @@ int drm_fb_blit_rect_dstclip(void __iomem *dst, unsigned int dst_pitch,
return -EINVAL; return -EINVAL;
} }
EXPORT_SYMBOL(drm_fb_blit_rect_dstclip); EXPORT_SYMBOL(drm_fb_blit_toio);
/**
* drm_fb_blit_dstclip - Copy framebuffer to display memory
* @dst: The display memory to copy to
* @dst_pitch: Number of bytes between two consecutive scanlines within dst
* @dst_format: FOURCC code of the display's color format
* @vmap: The framebuffer memory to copy from
* @fb: The framebuffer to copy from
*
* This function copies a full framebuffer to display memory. If the formats
* of the display and the framebuffer mismatch, the copy function will
* attempt to convert between them.
*
* See drm_fb_blit_rect_dstclip() for more information.
*
* Returns:
* 0 on success, or a negative error code otherwise.
*/
int drm_fb_blit_dstclip(void __iomem *dst, unsigned int dst_pitch,
uint32_t dst_format, void *vmap,
struct drm_framebuffer *fb)
{
struct drm_rect fullscreen = {
.x1 = 0,
.x2 = fb->width,
.y1 = 0,
.y2 = fb->height,
};
return drm_fb_blit_rect_dstclip(dst, dst_pitch, dst_format, vmap, fb,
&fullscreen);
}
EXPORT_SYMBOL(drm_fb_blit_dstclip);
...@@ -641,6 +641,8 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, ...@@ -641,6 +641,8 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
struct drm_framebuffer *fb = plane_state->fb; struct drm_framebuffer *fb = plane_state->fb;
void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */ void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */
struct drm_device *dev = &sdev->dev; struct drm_device *dev = &sdev->dev;
void __iomem *dst = sdev->screen_base;
struct drm_rect clip;
int idx; int idx;
if (!fb) if (!fb)
...@@ -649,8 +651,11 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, ...@@ -649,8 +651,11 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
if (!drm_dev_enter(dev, &idx)) if (!drm_dev_enter(dev, &idx))
return; return;
drm_fb_blit_dstclip(sdev->screen_base, sdev->pitch, drm_rect_init(&clip, 0, 0, fb->width, fb->height);
sdev->format->format, vmap, fb);
dst += drm_fb_clip_offset(sdev->pitch, sdev->format, &clip);
drm_fb_blit_toio(dst, sdev->pitch, sdev->format->format, vmap, fb, &clip);
drm_dev_exit(idx); drm_dev_exit(idx);
} }
...@@ -680,6 +685,7 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe, ...@@ -680,6 +685,7 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */ void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */
struct drm_framebuffer *fb = plane_state->fb; struct drm_framebuffer *fb = plane_state->fb;
struct drm_device *dev = &sdev->dev; struct drm_device *dev = &sdev->dev;
void __iomem *dst = sdev->screen_base;
struct drm_rect clip; struct drm_rect clip;
int idx; int idx;
...@@ -692,8 +698,8 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe, ...@@ -692,8 +698,8 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
if (!drm_dev_enter(dev, &idx)) if (!drm_dev_enter(dev, &idx))
return; return;
drm_fb_blit_rect_dstclip(sdev->screen_base, sdev->pitch, dst += drm_fb_clip_offset(sdev->pitch, sdev->format, &clip);
sdev->format->format, vmap, fb, &clip); drm_fb_blit_toio(dst, sdev->pitch, sdev->format->format, vmap, fb, &clip);
drm_dev_exit(idx); drm_dev_exit(idx);
} }
......
...@@ -36,12 +36,8 @@ void drm_fb_xrgb8888_to_rgb888_toio(void __iomem *dst, unsigned int dst_pitch, ...@@ -36,12 +36,8 @@ void drm_fb_xrgb8888_to_rgb888_toio(void __iomem *dst, unsigned int dst_pitch,
void drm_fb_xrgb8888_to_gray8(void *dst, unsigned int dst_pitch, const void *vaddr, void drm_fb_xrgb8888_to_gray8(void *dst, unsigned int dst_pitch, const void *vaddr,
const struct drm_framebuffer *fb, const struct drm_rect *clip); const struct drm_framebuffer *fb, const struct drm_rect *clip);
int drm_fb_blit_rect_dstclip(void __iomem *dst, unsigned int dst_pitch, int drm_fb_blit_toio(void __iomem *dst, unsigned int dst_pitch, uint32_t dst_format,
uint32_t dst_format, void *vmap, const void *vmap, const struct drm_framebuffer *fb,
struct drm_framebuffer *fb, const struct drm_rect *rect);
struct drm_rect *rect);
int drm_fb_blit_dstclip(void __iomem *dst, unsigned int dst_pitch,
uint32_t dst_format, void *vmap,
struct drm_framebuffer *fb);
#endif /* __LINUX_DRM_FORMAT_HELPER_H */ #endif /* __LINUX_DRM_FORMAT_HELPER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment