12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
27415287eSGerd Hoffmann /*
37415287eSGerd Hoffmann  * Copyright (C) 2016 Noralf Trønnes
47415287eSGerd Hoffmann  */
57415287eSGerd Hoffmann 
67415287eSGerd Hoffmann #ifndef __LINUX_DRM_FORMAT_HELPER_H
77415287eSGerd Hoffmann #define __LINUX_DRM_FORMAT_HELPER_H
87415287eSGerd Hoffmann 
94a85b0b5SThomas Zimmermann #include <linux/types.h>
104a85b0b5SThomas Zimmermann 
114a85b0b5SThomas Zimmermann struct drm_device;
12452290f3SThomas Zimmermann struct drm_format_info;
137415287eSGerd Hoffmann struct drm_framebuffer;
147415287eSGerd Hoffmann struct drm_rect;
157415287eSGerd Hoffmann 
164a85b0b5SThomas Zimmermann struct iosys_map;
174a85b0b5SThomas Zimmermann 
18452290f3SThomas Zimmermann unsigned int drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format,
19452290f3SThomas Zimmermann 				const struct drm_rect *clip);
20452290f3SThomas Zimmermann 
21edbe262aSThomas Zimmermann void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
22504a51d7SThomas Zimmermann 		   const struct iosys_map *src, const struct drm_framebuffer *fb,
23edbe262aSThomas Zimmermann 		   const struct drm_rect *clip);
24ce582859SThomas Zimmermann void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
25504a51d7SThomas Zimmermann 		 const struct iosys_map *src, const struct drm_framebuffer *fb,
26ce582859SThomas Zimmermann 		 const struct drm_rect *clip, bool cached);
27e13140a0SThomas Zimmermann void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
28504a51d7SThomas Zimmermann 			       const struct iosys_map *src, const struct drm_framebuffer *fb,
29e13140a0SThomas Zimmermann 			       const struct drm_rect *clip);
30ab298c29SThomas Zimmermann void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
31504a51d7SThomas Zimmermann 			       const struct iosys_map *src, const struct drm_framebuffer *fb,
3253bc2098SThomas Zimmermann 			       const struct drm_rect *clip, bool swab);
33c4863ce0SThomas Zimmermann void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
34504a51d7SThomas Zimmermann 			       const struct iosys_map *src, const struct drm_framebuffer *fb,
3553bc2098SThomas Zimmermann 			       const struct drm_rect *clip);
36175073d6SThomas Zimmermann void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
37175073d6SThomas Zimmermann 				 const struct iosys_map *src, const struct drm_framebuffer *fb,
38175073d6SThomas Zimmermann 				 const struct drm_rect *clip);
39ce73f456SThomas Zimmermann void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
40504a51d7SThomas Zimmermann 				    const struct iosys_map *src, const struct drm_framebuffer *fb,
41877691b9SHector Martin 				    const struct drm_rect *clip);
42*56119bfbSThomas Zimmermann void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
43*56119bfbSThomas Zimmermann 				    const struct iosys_map *src, const struct drm_framebuffer *fb,
44*56119bfbSThomas Zimmermann 				    const struct drm_rect *clip);
457bef6449SThomas Zimmermann void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch,
46504a51d7SThomas Zimmermann 			      const struct iosys_map *src, const struct drm_framebuffer *fb,
477bef6449SThomas Zimmermann 			      const struct drm_rect *clip);
487415287eSGerd Hoffmann 
4971bf5587SThomas Zimmermann int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format,
50504a51d7SThomas Zimmermann 		const struct iosys_map *src, const struct drm_framebuffer *fb,
5119b20a80SThomas Zimmermann 		const struct drm_rect *rect);
52900d3e4aSThomas Zimmermann 
53b3aca563SThomas Zimmermann void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch,
54504a51d7SThomas Zimmermann 			     const struct iosys_map *src, const struct drm_framebuffer *fb,
55b3aca563SThomas Zimmermann 			     const struct drm_rect *clip);
56bcf8b616SJavier Martinez Canillas 
574a85b0b5SThomas Zimmermann size_t drm_fb_build_fourcc_list(struct drm_device *dev,
584a85b0b5SThomas Zimmermann 				const u32 *native_fourccs, size_t native_nfourccs,
594a85b0b5SThomas Zimmermann 				const u32 *extra_fourccs, size_t extra_nfourccs,
604a85b0b5SThomas Zimmermann 				u32 *fourccs_out, size_t nfourccs_out);
614a85b0b5SThomas Zimmermann 
627415287eSGerd Hoffmann #endif /* __LINUX_DRM_FORMAT_HELPER_H */
63