1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2016 Noralf Trønnes
4 */
5
6#ifndef __LINUX_DRM_FORMAT_HELPER_H
7#define __LINUX_DRM_FORMAT_HELPER_H
8
9#include <linux/types.h>
10
11struct drm_device;
12struct drm_format_info;
13struct drm_framebuffer;
14struct drm_rect;
15
16struct iosys_map;
17
18unsigned int drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format,
19				const struct drm_rect *clip);
20
21void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
22		   const struct iosys_map *src, const struct drm_framebuffer *fb,
23		   const struct drm_rect *clip);
24void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
25		 const struct iosys_map *src, const struct drm_framebuffer *fb,
26		 const struct drm_rect *clip, bool cached);
27void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
28			       const struct iosys_map *src, const struct drm_framebuffer *fb,
29			       const struct drm_rect *clip);
30void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
31			       const struct iosys_map *src, const struct drm_framebuffer *fb,
32			       const struct drm_rect *clip, bool swab);
33void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
34				 const struct iosys_map *src, const struct drm_framebuffer *fb,
35				 const struct drm_rect *clip);
36void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
37				 const struct iosys_map *src, const struct drm_framebuffer *fb,
38				 const struct drm_rect *clip);
39void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
40				 const struct iosys_map *src, const struct drm_framebuffer *fb,
41				 const struct drm_rect *clip);
42void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
43			       const struct iosys_map *src, const struct drm_framebuffer *fb,
44			       const struct drm_rect *clip);
45void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
46				 const struct iosys_map *src, const struct drm_framebuffer *fb,
47				 const struct drm_rect *clip);
48void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
49				    const struct iosys_map *src, const struct drm_framebuffer *fb,
50				    const struct drm_rect *clip);
51void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
52				    const struct iosys_map *src, const struct drm_framebuffer *fb,
53				    const struct drm_rect *clip);
54void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch,
55			      const struct iosys_map *src, const struct drm_framebuffer *fb,
56			      const struct drm_rect *clip);
57
58int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format,
59		const struct iosys_map *src, const struct drm_framebuffer *fb,
60		const struct drm_rect *rect);
61
62void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch,
63			     const struct iosys_map *src, const struct drm_framebuffer *fb,
64			     const struct drm_rect *clip);
65
66size_t drm_fb_build_fourcc_list(struct drm_device *dev,
67				const u32 *native_fourccs, size_t native_nfourccs,
68				u32 *fourccs_out, size_t nfourccs_out);
69
70#endif /* __LINUX_DRM_FORMAT_HELPER_H */
71