XenevaOS
Loading...
Searching...
No Matches
drm_fourcc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22#ifndef __DRM_FOURCC_H__
23#define __DRM_FOURCC_H__
24
25#include <linux/math.h>
26#include <linux/types.h>
27#include <uapi/drm/drm_fourcc.h>
28
32#define DRM_FORMAT_MAX_PLANES 4u
33
34/*
35 * DRM formats are little endian. Define host endian variants for the
36 * most common formats here, to reduce the #ifdefs needed in drivers.
37 *
38 * Note that the DRM_FORMAT_BIG_ENDIAN flag should only be used in
39 * case the format can't be specified otherwise, so we don't end up
40 * with two values describing the same format.
41 */
42#ifdef __BIG_ENDIAN
43# define DRM_FORMAT_HOST_XRGB1555 (DRM_FORMAT_XRGB1555 | \
44 DRM_FORMAT_BIG_ENDIAN)
45# define DRM_FORMAT_HOST_RGB565 (DRM_FORMAT_RGB565 | \
46 DRM_FORMAT_BIG_ENDIAN)
47# define DRM_FORMAT_HOST_XRGB8888 DRM_FORMAT_BGRX8888
48# define DRM_FORMAT_HOST_ARGB8888 DRM_FORMAT_BGRA8888
49#else
50# define DRM_FORMAT_HOST_XRGB1555 DRM_FORMAT_XRGB1555
51# define DRM_FORMAT_HOST_RGB565 DRM_FORMAT_RGB565
52# define DRM_FORMAT_HOST_XRGB8888 DRM_FORMAT_XRGB8888
53# define DRM_FORMAT_HOST_ARGB8888 DRM_FORMAT_ARGB8888
54#endif
55
56struct drm_device;
57
145
154static inline bool
155drm_format_info_is_yuv_packed(const struct drm_format_info *info)
156{
157 return info->is_yuv && info->num_planes == 1;
158}
159
168static inline bool
169drm_format_info_is_yuv_semiplanar(const struct drm_format_info *info)
170{
171 return info->is_yuv && info->num_planes == 2;
172}
173
182static inline bool
183drm_format_info_is_yuv_planar(const struct drm_format_info *info)
184{
185 return info->is_yuv && info->num_planes == 3;
186}
187
197static inline bool
198drm_format_info_is_yuv_sampling_410(const struct drm_format_info *info)
199{
200 return info->is_yuv && info->hsub == 4 && info->vsub == 4;
201}
202
212static inline bool
213drm_format_info_is_yuv_sampling_411(const struct drm_format_info *info)
214{
215 return info->is_yuv && info->hsub == 4 && info->vsub == 1;
216}
217
227static inline bool
228drm_format_info_is_yuv_sampling_420(const struct drm_format_info *info)
229{
230 return info->is_yuv && info->hsub == 2 && info->vsub == 2;
231}
232
242static inline bool
243drm_format_info_is_yuv_sampling_422(const struct drm_format_info *info)
244{
245 return info->is_yuv && info->hsub == 2 && info->vsub == 1;
246}
247
257static inline bool
258drm_format_info_is_yuv_sampling_444(const struct drm_format_info *info)
259{
260 return info->is_yuv && info->hsub == 1 && info->vsub == 1;
261}
262
272static inline
273int drm_format_info_plane_width(const struct drm_format_info *info, int width,
274 int plane)
275{
276 if (!info || plane >= info->num_planes)
277 return 0;
278
279 if (plane == 0)
280 return width;
281
282 return DIV_ROUND_UP(width, info->hsub);
283}
284
294static inline
295int drm_format_info_plane_height(const struct drm_format_info *info, int height,
296 int plane)
297{
298 if (!info || plane >= info->num_planes)
299 return 0;
300
301 if (plane == 0)
302 return height;
303
304 return DIV_ROUND_UP(height, info->vsub);
305}
306
309const struct drm_format_info *
311 u32 pixel_format, u64 modifier);
315uint32_t drm_driver_color_mode_format(struct drm_device *dev, unsigned int color_mode);
316unsigned int drm_format_info_block_width(const struct drm_format_info *info,
317 int plane);
318unsigned int drm_format_info_block_height(const struct drm_format_info *info,
319 int plane);
320unsigned int drm_format_info_bpp(const struct drm_format_info *info, int plane);
322 int plane, unsigned int buffer_width);
323
324#endif /* __DRM_FOURCC_H__ */
size_t bpp
Definition video.cpp:36
unsigned int uint32_t
Definition acefiex.h:163
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
uint64_t drm_format_info_min_pitch(const struct drm_format_info *info, int plane, unsigned int buffer_width)
unsigned int drm_format_info_block_height(const struct drm_format_info *info, int plane)
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
uint32_t drm_driver_legacy_fb_format(struct drm_device *dev, uint32_t bpp, uint32_t depth)
unsigned int drm_format_info_block_width(const struct drm_format_info *info, int plane)
const struct drm_format_info * __drm_format_info(u32 format)
#define DRM_FORMAT_MAX_PLANES
Definition drm_fourcc.h:32
const struct drm_format_info * drm_get_format_info(struct drm_device *dev, u32 pixel_format, u64 modifier)
uint32_t drm_driver_color_mode_format(struct drm_device *dev, unsigned int color_mode)
unsigned int drm_format_info_bpp(const struct drm_format_info *info, int plane)
struct drm_plane * plane
Definition drm_plane.h:828
const struct device * dev
Definition drm_print.h:519
const char const char * format
Definition drm_print.h:516
uint64_t u64
Definition kernel.h:17
uint8_t u8
Definition kernel.h:14
#define DIV_ROUND_UP(n, d)
Definition kernel.h:571
uint32_t u32
Definition kernel.h:16
Definition drm_device.h:75
Definition drm_fourcc.h:61
u8 char_per_block[DRM_FORMAT_MAX_PLANES]
Definition drm_fourcc.h:112
u8 depth
Definition drm_fourcc.h:72
u8 cpp[DRM_FORMAT_MAX_PLANES]
Definition drm_fourcc.h:86
u8 num_planes
Definition drm_fourcc.h:75
u8 block_w[DRM_FORMAT_MAX_PLANES]
Definition drm_fourcc.h:121
u8 hsub
Definition drm_fourcc.h:132
bool is_color_indexed
Definition drm_fourcc.h:143
bool has_alpha
Definition drm_fourcc.h:137
u8 block_h[DRM_FORMAT_MAX_PLANES]
Definition drm_fourcc.h:129
bool is_yuv
Definition drm_fourcc.h:140
u32 format
Definition drm_fourcc.h:63
u8 vsub
Definition drm_fourcc.h:134