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 
9*4a85b0b5SThomas Zimmermann #include <linux/types.h>
10*4a85b0b5SThomas Zimmermann 
11*4a85b0b5SThomas Zimmermann struct drm_device;
12452290f3SThomas Zimmermann struct drm_format_info;
137415287eSGerd Hoffmann struct drm_framebuffer;
147415287eSGerd Hoffmann struct drm_rect;
157415287eSGerd Hoffmann 
16*4a85b0b5SThomas Zimmermann struct iosys_map;
17*4a85b0b5SThomas 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);
36ce73f456SThomas Zimmermann void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
37504a51d7SThomas Zimmermann 				    const struct iosys_map *src, const struct drm_framebuffer *fb,
38877691b9SHector Martin 				    const struct drm_rect *clip);
397bef6449SThomas Zimmermann void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch,
40504a51d7SThomas Zimmermann 			      const struct iosys_map *src, const struct drm_framebuffer *fb,
417bef6449SThomas Zimmermann 			      const struct drm_rect *clip);
427415287eSGerd Hoffmann 
4371bf5587SThomas Zimmermann int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format,
44504a51d7SThomas Zimmermann 		const struct iosys_map *src, const struct drm_framebuffer *fb,
4519b20a80SThomas Zimmermann 		const struct drm_rect *rect);
46900d3e4aSThomas Zimmermann 
47b3aca563SThomas Zimmermann void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch,
48504a51d7SThomas Zimmermann 			     const struct iosys_map *src, const struct drm_framebuffer *fb,
49b3aca563SThomas Zimmermann 			     const struct drm_rect *clip);
50bcf8b616SJavier Martinez Canillas 
51*4a85b0b5SThomas Zimmermann size_t drm_fb_build_fourcc_list(struct drm_device *dev,
52*4a85b0b5SThomas Zimmermann 				const u32 *native_fourccs, size_t native_nfourccs,
53*4a85b0b5SThomas Zimmermann 				const u32 *extra_fourccs, size_t extra_nfourccs,
54*4a85b0b5SThomas Zimmermann 				u32 *fourccs_out, size_t nfourccs_out);
55*4a85b0b5SThomas Zimmermann 
567415287eSGerd Hoffmann #endif /* __LINUX_DRM_FORMAT_HELPER_H */
57