2019-05-27 14:55:01 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-04-05 17:52:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Noralf Trønnes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_DRM_FORMAT_HELPER_H
|
|
|
|
#define __LINUX_DRM_FORMAT_HELPER_H
|
|
|
|
|
2022-09-05 22:16:48 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct drm_device;
|
2021-11-10 18:36:54 +08:00
|
|
|
struct drm_format_info;
|
2019-04-05 17:52:15 +08:00
|
|
|
struct drm_framebuffer;
|
|
|
|
struct drm_rect;
|
|
|
|
|
2022-09-05 22:16:48 +08:00
|
|
|
struct iosys_map;
|
|
|
|
|
2023-10-09 22:06:30 +08:00
|
|
|
/**
|
|
|
|
* struct drm_format_conv_state - Stores format-conversion state
|
|
|
|
*
|
|
|
|
* DRM helpers for format conversion store temporary state in
|
|
|
|
* struct drm_xfrm_buf. The buffer's resources can be reused
|
|
|
|
* among multiple conversion operations.
|
|
|
|
*
|
|
|
|
* All fields are considered private.
|
|
|
|
*/
|
|
|
|
struct drm_format_conv_state {
|
2024-03-07 02:31:14 +08:00
|
|
|
/* private: */
|
2023-10-09 22:06:30 +08:00
|
|
|
struct {
|
|
|
|
void *mem;
|
|
|
|
size_t size;
|
|
|
|
bool preallocated;
|
|
|
|
} tmp;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define __DRM_FORMAT_CONV_STATE_INIT(_mem, _size, _preallocated) { \
|
|
|
|
.tmp = { \
|
|
|
|
.mem = (_mem), \
|
|
|
|
.size = (_size), \
|
|
|
|
.preallocated = (_preallocated), \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRM_FORMAT_CONV_STATE_INIT - Initializer for struct drm_format_conv_state
|
|
|
|
*
|
|
|
|
* Initializes an instance of struct drm_format_conv_state to default values.
|
|
|
|
*/
|
|
|
|
#define DRM_FORMAT_CONV_STATE_INIT \
|
|
|
|
__DRM_FORMAT_CONV_STATE_INIT(NULL, 0, false)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRM_FORMAT_CONV_STATE_INIT_PREALLOCATED - Initializer for struct drm_format_conv_state
|
|
|
|
* @_mem: The preallocated memory area
|
|
|
|
* @_size: The number of bytes in _mem
|
|
|
|
*
|
|
|
|
* Initializes an instance of struct drm_format_conv_state to preallocated
|
|
|
|
* storage. The caller is responsible for releasing the provided memory range.
|
|
|
|
*/
|
|
|
|
#define DRM_FORMAT_CONV_STATE_INIT_PREALLOCATED(_mem, _size) \
|
|
|
|
__DRM_FORMAT_CONV_STATE_INIT(_mem, _size, true)
|
|
|
|
|
|
|
|
void drm_format_conv_state_init(struct drm_format_conv_state *state);
|
|
|
|
void drm_format_conv_state_copy(struct drm_format_conv_state *state,
|
|
|
|
const struct drm_format_conv_state *old_state);
|
|
|
|
void *drm_format_conv_state_reserve(struct drm_format_conv_state *state,
|
|
|
|
size_t new_size, gfp_t flags);
|
|
|
|
void drm_format_conv_state_release(struct drm_format_conv_state *state);
|
|
|
|
|
2021-11-10 18:36:54 +08:00
|
|
|
unsigned int drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format,
|
|
|
|
const struct drm_rect *clip);
|
|
|
|
|
2022-08-08 20:53:55 +08:00
|
|
|
void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:55 +08:00
|
|
|
const struct drm_rect *clip);
|
2022-08-08 20:53:56 +08:00
|
|
|
void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, bool cached,
|
|
|
|
struct drm_format_conv_state *state);
|
2022-08-08 20:53:57 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2022-08-08 20:53:58 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state,
|
|
|
|
bool swab);
|
2023-01-02 19:29:23 +08:00
|
|
|
void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2023-01-02 19:29:23 +08:00
|
|
|
void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2023-01-02 19:29:23 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2022-08-08 20:53:59 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2023-01-02 19:29:21 +08:00
|
|
|
void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2022-08-08 20:54:02 +08:00
|
|
|
void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip,
|
|
|
|
struct drm_format_conv_state *state);
|
2023-01-02 19:29:22 +08:00
|
|
|
void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip,
|
|
|
|
struct drm_format_conv_state *state);
|
2022-08-08 20:54:03 +08:00
|
|
|
void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2019-04-05 17:52:15 +08:00
|
|
|
|
2022-08-08 20:53:54 +08:00
|
|
|
int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2021-04-30 18:58:33 +08:00
|
|
|
|
2022-08-08 20:54:04 +08:00
|
|
|
void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2023-10-09 22:06:32 +08:00
|
|
|
const struct drm_rect *clip, struct drm_format_conv_state *state);
|
2022-02-14 21:37:06 +08:00
|
|
|
|
2022-09-05 22:16:48 +08:00
|
|
|
size_t drm_fb_build_fourcc_list(struct drm_device *dev,
|
|
|
|
const u32 *native_fourccs, size_t native_nfourccs,
|
|
|
|
u32 *fourccs_out, size_t nfourccs_out);
|
|
|
|
|
2019-04-05 17:52:15 +08:00
|
|
|
#endif /* __LINUX_DRM_FORMAT_HELPER_H */
|