2016-06-09 03:54:08 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef __DRM_FOURCC_H__
|
|
|
|
#define __DRM_FOURCC_H__
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <uapi/drm/drm_fourcc.h>
|
|
|
|
|
2018-09-05 00:04:41 -06:00
|
|
|
/*
|
|
|
|
* DRM formats are little endian. Define host endian variants for the
|
|
|
|
* most common formats here, to reduce the #ifdefs needed in drivers.
|
|
|
|
*
|
|
|
|
* Note that the DRM_FORMAT_BIG_ENDIAN flag should only be used in
|
|
|
|
* case the format can't be specified otherwise, so we don't end up
|
|
|
|
* with two values describing the same format.
|
|
|
|
*/
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
# define DRM_FORMAT_HOST_XRGB1555 (DRM_FORMAT_XRGB1555 | \
|
|
|
|
DRM_FORMAT_BIG_ENDIAN)
|
|
|
|
# define DRM_FORMAT_HOST_RGB565 (DRM_FORMAT_RGB565 | \
|
|
|
|
DRM_FORMAT_BIG_ENDIAN)
|
|
|
|
# define DRM_FORMAT_HOST_XRGB8888 DRM_FORMAT_BGRX8888
|
|
|
|
# define DRM_FORMAT_HOST_ARGB8888 DRM_FORMAT_BGRA8888
|
|
|
|
#else
|
|
|
|
# define DRM_FORMAT_HOST_XRGB1555 DRM_FORMAT_XRGB1555
|
|
|
|
# define DRM_FORMAT_HOST_RGB565 DRM_FORMAT_RGB565
|
|
|
|
# define DRM_FORMAT_HOST_XRGB8888 DRM_FORMAT_XRGB8888
|
|
|
|
# define DRM_FORMAT_HOST_ARGB8888 DRM_FORMAT_ARGB8888
|
|
|
|
#endif
|
|
|
|
|
2017-03-21 12:12:16 -06:00
|
|
|
struct drm_device;
|
|
|
|
struct drm_mode_fb_cmd2;
|
|
|
|
|
2016-10-17 16:41:09 -06:00
|
|
|
/**
|
|
|
|
* struct drm_format_info - information about a DRM format
|
|
|
|
*/
|
|
|
|
struct drm_format_info {
|
2018-10-19 04:57:44 -06:00
|
|
|
/** @format: 4CC format identifier (DRM_FORMAT_*) */
|
2016-10-17 16:41:09 -06:00
|
|
|
u32 format;
|
2018-10-19 04:57:44 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @depth:
|
|
|
|
*
|
|
|
|
* Color depth (number of bits per pixel excluding padding bits),
|
|
|
|
* valid for a subset of RGB formats only. This is a legacy field, do
|
|
|
|
* not use in new code and set to 0 for new formats.
|
|
|
|
*/
|
2016-10-17 16:41:09 -06:00
|
|
|
u8 depth;
|
2018-10-19 04:57:44 -06:00
|
|
|
|
|
|
|
/** @num_planes: Number of color planes (1 to 3) */
|
2016-10-17 16:41:09 -06:00
|
|
|
u8 num_planes;
|
2018-10-19 04:57:44 -06:00
|
|
|
|
drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info
For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.
What's implemented here is to add three new members to drm_format_info
that could describe such formats:
- char_per_block[3]
- block_w[3]
- block_h[3]
char_per_block will be put in a union alongside cpp, for transparent
compatibility with the existing format descriptions.
Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.
Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.
Using that the following drm core functions had been updated to
generically handle both block and non-block formats:
- drm_fb_cma_get_gem_addr: for block formats it will just return the
beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
helpers I just added some warnings in case the block width/height
are greater than 1.
Changes since v3:
- Add helper function for computing the minimum required pitch.
- Improve/cleanup documentation
Changes since v8:
- Fixed build on 32bits arm architectures, with:
- return DIV_ROUND_UP((u64)buffer_width * info->char_per_block[plane],
+ return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane],
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181101170055.5433-1-alexandru-cosmin.gheorghe@arm.com
2018-11-01 11:02:05 -06:00
|
|
|
union {
|
|
|
|
/**
|
|
|
|
* @cpp:
|
|
|
|
*
|
|
|
|
* Number of bytes per pixel (per plane), this is aliased with
|
|
|
|
* @char_per_block. It is deprecated in favour of using the
|
|
|
|
* triplet @char_per_block, @block_w, @block_h for better
|
|
|
|
* describing the pixel format.
|
|
|
|
*/
|
2019-10-28 14:40:38 -06:00
|
|
|
u8 cpp[4];
|
drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info
For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.
What's implemented here is to add three new members to drm_format_info
that could describe such formats:
- char_per_block[3]
- block_w[3]
- block_h[3]
char_per_block will be put in a union alongside cpp, for transparent
compatibility with the existing format descriptions.
Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.
Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.
Using that the following drm core functions had been updated to
generically handle both block and non-block formats:
- drm_fb_cma_get_gem_addr: for block formats it will just return the
beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
helpers I just added some warnings in case the block width/height
are greater than 1.
Changes since v3:
- Add helper function for computing the minimum required pitch.
- Improve/cleanup documentation
Changes since v8:
- Fixed build on 32bits arm architectures, with:
- return DIV_ROUND_UP((u64)buffer_width * info->char_per_block[plane],
+ return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane],
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181101170055.5433-1-alexandru-cosmin.gheorghe@arm.com
2018-11-01 11:02:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @char_per_block:
|
|
|
|
*
|
|
|
|
* Number of bytes per block (per plane), where blocks are
|
|
|
|
* defined as a rectangle of pixels which are stored next to
|
|
|
|
* each other in a byte aligned memory region. Together with
|
|
|
|
* @block_w and @block_h this is used to properly describe tiles
|
|
|
|
* in tiled formats or to describe groups of pixels in packed
|
|
|
|
* formats for which the memory needed for a single pixel is not
|
|
|
|
* byte aligned.
|
|
|
|
*
|
|
|
|
* @cpp has been kept for historical reasons because there are
|
|
|
|
* a lot of places in drivers where it's used. In drm core for
|
|
|
|
* generic code paths the preferred way is to use
|
|
|
|
* @char_per_block, drm_format_info_block_width() and
|
|
|
|
* drm_format_info_block_height() which allows handling both
|
|
|
|
* block and non-block formats in the same way.
|
|
|
|
*
|
|
|
|
* For formats that are intended to be used only with non-linear
|
|
|
|
* modifiers both @cpp and @char_per_block must be 0 in the
|
|
|
|
* generic format table. Drivers could supply accurate
|
|
|
|
* information from their drm_mode_config.get_format_info hook
|
|
|
|
* if they want the core to be validating the pitch.
|
|
|
|
*/
|
2019-10-28 14:40:38 -06:00
|
|
|
u8 char_per_block[4];
|
drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info
For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.
What's implemented here is to add three new members to drm_format_info
that could describe such formats:
- char_per_block[3]
- block_w[3]
- block_h[3]
char_per_block will be put in a union alongside cpp, for transparent
compatibility with the existing format descriptions.
Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.
Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.
Using that the following drm core functions had been updated to
generically handle both block and non-block formats:
- drm_fb_cma_get_gem_addr: for block formats it will just return the
beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
helpers I just added some warnings in case the block width/height
are greater than 1.
Changes since v3:
- Add helper function for computing the minimum required pitch.
- Improve/cleanup documentation
Changes since v8:
- Fixed build on 32bits arm architectures, with:
- return DIV_ROUND_UP((u64)buffer_width * info->char_per_block[plane],
+ return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane],
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181101170055.5433-1-alexandru-cosmin.gheorghe@arm.com
2018-11-01 11:02:05 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @block_w:
|
|
|
|
*
|
|
|
|
* Block width in pixels, this is intended to be accessed through
|
|
|
|
* drm_format_info_block_width()
|
|
|
|
*/
|
2019-10-28 14:40:38 -06:00
|
|
|
u8 block_w[4];
|
drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info
For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.
What's implemented here is to add three new members to drm_format_info
that could describe such formats:
- char_per_block[3]
- block_w[3]
- block_h[3]
char_per_block will be put in a union alongside cpp, for transparent
compatibility with the existing format descriptions.
Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.
Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.
Using that the following drm core functions had been updated to
generically handle both block and non-block formats:
- drm_fb_cma_get_gem_addr: for block formats it will just return the
beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
helpers I just added some warnings in case the block width/height
are greater than 1.
Changes since v3:
- Add helper function for computing the minimum required pitch.
- Improve/cleanup documentation
Changes since v8:
- Fixed build on 32bits arm architectures, with:
- return DIV_ROUND_UP((u64)buffer_width * info->char_per_block[plane],
+ return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane],
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181101170055.5433-1-alexandru-cosmin.gheorghe@arm.com
2018-11-01 11:02:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @block_h:
|
|
|
|
*
|
|
|
|
* Block height in pixels, this is intended to be accessed through
|
|
|
|
* drm_format_info_block_height()
|
|
|
|
*/
|
2019-10-28 14:40:38 -06:00
|
|
|
u8 block_h[4];
|
2018-10-19 04:57:44 -06:00
|
|
|
|
|
|
|
/** @hsub: Horizontal chroma subsampling factor */
|
2016-10-17 16:41:09 -06:00
|
|
|
u8 hsub;
|
2018-10-19 04:57:44 -06:00
|
|
|
/** @vsub: Vertical chroma subsampling factor */
|
2016-10-17 16:41:09 -06:00
|
|
|
u8 vsub;
|
2018-10-19 04:57:44 -06:00
|
|
|
|
|
|
|
/** @has_alpha: Does the format embeds an alpha component? */
|
2017-12-22 07:29:26 -07:00
|
|
|
bool has_alpha;
|
2018-10-19 04:57:44 -06:00
|
|
|
|
|
|
|
/** @is_yuv: Is it a YUV format? */
|
2018-07-17 11:13:42 -06:00
|
|
|
bool is_yuv;
|
2016-10-17 16:41:09 -06:00
|
|
|
};
|
|
|
|
|
2016-11-11 18:12:56 -07:00
|
|
|
/**
|
|
|
|
* struct drm_format_name_buf - name of a DRM format
|
|
|
|
* @str: string buffer containing the format name
|
|
|
|
*/
|
|
|
|
struct drm_format_name_buf {
|
|
|
|
char str[32];
|
|
|
|
};
|
|
|
|
|
2019-01-18 07:51:11 -07:00
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_packed - check that the format info matches a YUV
|
|
|
|
* format with data laid in a single plane
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a packed YUV format.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_packed(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->num_planes == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_semiplanar - check that the format info matches a YUV
|
|
|
|
* format with data laid in two planes (luminance and chrominance)
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a semiplanar YUV format.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_semiplanar(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->num_planes == 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_planar - check that the format info matches a YUV
|
|
|
|
* format with data laid in three planes (one for each YUV component)
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a planar YUV format.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_planar(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->num_planes == 3;
|
|
|
|
}
|
|
|
|
|
2019-01-18 07:51:12 -07:00
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_sampling_410 - check that the format info matches a
|
|
|
|
* YUV format with 4:1:0 sub-sampling
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a YUV format with 4:1:0
|
|
|
|
* sub-sampling.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_sampling_410(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->hsub == 4 && info->vsub == 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_sampling_411 - check that the format info matches a
|
|
|
|
* YUV format with 4:1:1 sub-sampling
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a YUV format with 4:1:1
|
|
|
|
* sub-sampling.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_sampling_411(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->hsub == 4 && info->vsub == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_sampling_420 - check that the format info matches a
|
|
|
|
* YUV format with 4:2:0 sub-sampling
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a YUV format with 4:2:0
|
|
|
|
* sub-sampling.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_sampling_420(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->hsub == 2 && info->vsub == 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_sampling_422 - check that the format info matches a
|
|
|
|
* YUV format with 4:2:2 sub-sampling
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a YUV format with 4:2:2
|
|
|
|
* sub-sampling.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_sampling_422(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->hsub == 2 && info->vsub == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_is_yuv_sampling_444 - check that the format info matches a
|
|
|
|
* YUV format with 4:4:4 sub-sampling
|
|
|
|
* @info: format info
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* A boolean indicating whether the format info matches a YUV format with 4:4:4
|
|
|
|
* sub-sampling.
|
|
|
|
*/
|
|
|
|
static inline bool
|
|
|
|
drm_format_info_is_yuv_sampling_444(const struct drm_format_info *info)
|
|
|
|
{
|
|
|
|
return info->is_yuv && info->hsub == 1 && info->vsub == 1;
|
|
|
|
}
|
|
|
|
|
2019-05-16 04:31:50 -06:00
|
|
|
/**
|
|
|
|
* drm_format_info_plane_width - width of the plane given the first plane
|
2019-05-21 05:09:06 -06:00
|
|
|
* @info: pixel format info
|
2019-05-16 04:31:50 -06:00
|
|
|
* @width: width of the first plane
|
|
|
|
* @plane: plane index
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The width of @plane, given that the width of the first plane is @width.
|
|
|
|
*/
|
|
|
|
static inline
|
|
|
|
int drm_format_info_plane_width(const struct drm_format_info *info, int width,
|
|
|
|
int plane)
|
|
|
|
{
|
|
|
|
if (!info || plane >= info->num_planes)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (plane == 0)
|
|
|
|
return width;
|
|
|
|
|
|
|
|
return width / info->hsub;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_format_info_plane_height - height of the plane given the first plane
|
2019-05-21 05:09:06 -06:00
|
|
|
* @info: pixel format info
|
2019-05-16 04:31:50 -06:00
|
|
|
* @height: height of the first plane
|
|
|
|
* @plane: plane index
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The height of @plane, given that the height of the first plane is @height.
|
|
|
|
*/
|
|
|
|
static inline
|
|
|
|
int drm_format_info_plane_height(const struct drm_format_info *info, int height,
|
|
|
|
int plane)
|
|
|
|
{
|
|
|
|
if (!info || plane >= info->num_planes)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (plane == 0)
|
|
|
|
return height;
|
|
|
|
|
|
|
|
return height / info->vsub;
|
|
|
|
}
|
|
|
|
|
2016-10-17 16:41:12 -06:00
|
|
|
const struct drm_format_info *__drm_format_info(u32 format);
|
2016-10-17 16:41:09 -06:00
|
|
|
const struct drm_format_info *drm_format_info(u32 format);
|
2017-03-21 12:12:16 -06:00
|
|
|
const struct drm_format_info *
|
|
|
|
drm_get_format_info(struct drm_device *dev,
|
|
|
|
const struct drm_mode_fb_cmd2 *mode_cmd);
|
2016-08-29 02:27:54 -06:00
|
|
|
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
|
2018-09-21 07:46:59 -06:00
|
|
|
uint32_t drm_driver_legacy_fb_format(struct drm_device *dev,
|
|
|
|
uint32_t bpp, uint32_t depth);
|
drm/fourcc: Add char_per_block, block_w and block_h in drm_format_info
For some pixel formats .cpp structure in drm_format info it's not
enough to describe the peculiarities of the pixel layout, for example
tiled formats or packed formats at bit level.
What's implemented here is to add three new members to drm_format_info
that could describe such formats:
- char_per_block[3]
- block_w[3]
- block_h[3]
char_per_block will be put in a union alongside cpp, for transparent
compatibility with the existing format descriptions.
Regarding, block_w and block_h they are intended to be used through
their equivalent getters drm_format_info_block_width /
drm_format_info_block_height, the reason of the getters is to abstract
the fact that for normal formats block_w and block_h will be unset/0,
but the methods will be returning 1.
Additionally, convenience function drm_format_info_min_pitch had been
added that computes the minimum required pitch for a given pixel
format and buffer width.
Using that the following drm core functions had been updated to
generically handle both block and non-block formats:
- drm_fb_cma_get_gem_addr: for block formats it will just return the
beginning of the block.
- framebuffer_check: Use the newly added drm_format_info_min_pitch.
- drm_gem_fb_create_with_funcs: Use the newly added
drm_format_info_min_pitch.
- In places where is not expecting to handle block formats, like fbdev
helpers I just added some warnings in case the block width/height
are greater than 1.
Changes since v3:
- Add helper function for computing the minimum required pitch.
- Improve/cleanup documentation
Changes since v8:
- Fixed build on 32bits arm architectures, with:
- return DIV_ROUND_UP((u64)buffer_width * info->char_per_block[plane],
+ return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane],
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181101170055.5433-1-alexandru-cosmin.gheorghe@arm.com
2018-11-01 11:02:05 -06:00
|
|
|
unsigned int drm_format_info_block_width(const struct drm_format_info *info,
|
|
|
|
int plane);
|
|
|
|
unsigned int drm_format_info_block_height(const struct drm_format_info *info,
|
|
|
|
int plane);
|
|
|
|
uint64_t drm_format_info_min_pitch(const struct drm_format_info *info,
|
|
|
|
int plane, unsigned int buffer_width);
|
2016-11-11 18:12:56 -07:00
|
|
|
const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
|
2016-06-09 03:54:08 -06:00
|
|
|
|
|
|
|
#endif /* __DRM_FOURCC_H__ */
|