| 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 |
|
| 11 |
struct drm_device; |
| 12 |
struct drm_format_info; |
| 13 |
struct drm_framebuffer; |
| 14 |
struct drm_rect; |
| 15 |
|
| 16 |
struct iosys_map; |
| 17 |
|
| 18 |
/** |
| 19 |
* struct drm_format_conv_state - Stores format-conversion state |
| 20 |
* |
| 21 |
* DRM helpers for format conversion store temporary state in |
| 22 |
* struct drm_xfrm_buf. The buffer's resources can be reused |
| 23 |
* among multiple conversion operations. |
| 24 |
* |
| 25 |
* All fields are considered private. |
| 26 |
*/ |
| 27 |
struct drm_format_conv_state { |
| 28 |
/* private: */ |
| 29 |
struct { |
| 30 |
void *mem; |
| 31 |
size_t size; |
| 32 |
bool preallocated; |
| 33 |
} tmp; |
| 34 |
}; |
| 35 |
|
| 36 |
#define __DRM_FORMAT_CONV_STATE_INIT(_mem, _size, _preallocated) { \ |
| 37 |
.tmp = { \ |
| 38 |
.mem = (_mem), \ |
| 39 |
.size = (_size), \ |
| 40 |
.preallocated = (_preallocated), \ |
| 41 |
} \ |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* DRM_FORMAT_CONV_STATE_INIT - Initializer for struct drm_format_conv_state |
| 46 |
* |
| 47 |
* Initializes an instance of struct drm_format_conv_state to default values. |
| 48 |
*/ |
| 49 |
#define DRM_FORMAT_CONV_STATE_INIT \ |
| 50 |
__DRM_FORMAT_CONV_STATE_INIT(NULL, 0, false) |
| 51 |
|
| 52 |
/** |
| 53 |
* DRM_FORMAT_CONV_STATE_INIT_PREALLOCATED - Initializer for struct drm_format_conv_state |
| 54 |
* @_mem: The preallocated memory area |
| 55 |
* @_size: The number of bytes in _mem |
| 56 |
* |
| 57 |
* Initializes an instance of struct drm_format_conv_state to preallocated |
| 58 |
* storage. The caller is responsible for releasing the provided memory range. |
| 59 |
*/ |
| 60 |
#define DRM_FORMAT_CONV_STATE_INIT_PREALLOCATED(_mem, _size) \ |
| 61 |
__DRM_FORMAT_CONV_STATE_INIT(_mem, _size, true) |
| 62 |
|
| 63 |
void drm_format_conv_state_init(struct drm_format_conv_state *state); |
| 64 |
void drm_format_conv_state_copy(struct drm_format_conv_state *state, |
| 65 |
const struct drm_format_conv_state *old_state); |
| 66 |
void *drm_format_conv_state_reserve(struct drm_format_conv_state *state, |
| 67 |
size_t new_size, gfp_t flags); |
| 68 |
void drm_format_conv_state_release(struct drm_format_conv_state *state); |
| 69 |
|
| 70 |
unsigned int drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format, |
| 71 |
const struct drm_rect *clip); |
| 72 |
|
| 73 |
void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 74 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 75 |
const struct drm_rect *clip); |
| 76 |
void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 77 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 78 |
const struct drm_rect *clip, bool cached, |
| 79 |
struct drm_format_conv_state *state); |
| 80 |
void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 81 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 82 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 83 |
void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 84 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 85 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 86 |
void drm_fb_xrgb8888_to_rgb565be(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 87 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 88 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 89 |
void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 90 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 91 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 92 |
void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 93 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 94 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 95 |
void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 96 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 97 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 98 |
void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 99 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 100 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 101 |
void drm_fb_xrgb8888_to_bgr888(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 102 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 103 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 104 |
void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 105 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 106 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 107 |
void drm_fb_xrgb8888_to_abgr8888(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 108 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 109 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 110 |
void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 111 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 112 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 113 |
void drm_fb_xrgb8888_to_bgrx8888(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 114 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 115 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 116 |
void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 117 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 118 |
const struct drm_rect *clip, |
| 119 |
struct drm_format_conv_state *state); |
| 120 |
void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 121 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 122 |
const struct drm_rect *clip, |
| 123 |
struct drm_format_conv_state *state); |
| 124 |
void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 125 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 126 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 127 |
void drm_fb_argb8888_to_argb4444(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 128 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 129 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 130 |
|
| 131 |
void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 132 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 133 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 134 |
|
| 135 |
void drm_fb_xrgb8888_to_gray2(struct iosys_map *dst, const unsigned int *dst_pitch, |
| 136 |
const struct iosys_map *src, const struct drm_framebuffer *fb, |
| 137 |
const struct drm_rect *clip, struct drm_format_conv_state *state); |
| 138 |
|
| 139 |
#endif /* __LINUX_DRM_FORMAT_HELPER_H */ |