/* * 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__
/** * DRM_FORMAT_MAX_PLANES - maximum number of planes a DRM format can have
*/ #define DRM_FORMAT_MAX_PLANES 4u
/* * 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
struct drm_device;
/** * struct drm_format_info - information about a DRM format
*/ struct drm_format_info { /** @format: 4CC format identifier (DRM_FORMAT_*) */
u32 format;
/** * @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.
*/
u8 depth;
/** @num_planes: Number of color planes (1 to 3) */
u8 num_planes;
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.
*/
u8 cpp[DRM_FORMAT_MAX_PLANES];
/** * @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.
*/
u8 char_per_block[DRM_FORMAT_MAX_PLANES];
};
/** * @block_w: * * Block width in pixels, this is intended to be accessed through * drm_format_info_block_width()
*/
u8 block_w[DRM_FORMAT_MAX_PLANES];
/** * @block_h: * * Block height in pixels, this is intended to be accessed through * drm_format_info_block_height()
*/
u8 block_h[DRM_FORMAT_MAX_PLANES];
/** @has_alpha: Does the format embeds an alpha component? */ bool has_alpha;
/** @is_yuv: Is it a YUV format? */ bool is_yuv;
/** @is_color_indexed: Is it a color-indexed format? */ bool is_color_indexed;
};
/** * 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.
*/ staticinlinebool
drm_format_info_is_yuv_packed(conststruct 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.
*/ staticinlinebool
drm_format_info_is_yuv_semiplanar(conststruct 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.
*/ staticinlinebool
drm_format_info_is_yuv_planar(conststruct drm_format_info *info)
{ return info->is_yuv && info->num_planes == 3;
}
/** * 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.
*/ staticinlinebool
drm_format_info_is_yuv_sampling_410(conststruct 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.
*/ staticinlinebool
drm_format_info_is_yuv_sampling_411(conststruct 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.
*/ staticinlinebool
drm_format_info_is_yuv_sampling_420(conststruct 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.
*/ staticinlinebool
drm_format_info_is_yuv_sampling_422(conststruct 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.
*/ staticinlinebool
drm_format_info_is_yuv_sampling_444(conststruct drm_format_info *info)
{ return info->is_yuv && info->hsub == 1 && info->vsub == 1;
}
/** * drm_format_info_plane_width - width of the plane given the first plane * @info: pixel format info * @width: width of the first plane * @plane: plane index * * Returns: * The width of @plane, given that the width of the first plane is @width.
*/ staticinline int drm_format_info_plane_width(conststruct drm_format_info *info, int width, int plane)
{ if (!info || plane >= info->num_planes) return 0;
if (plane == 0) return width;
return DIV_ROUND_UP(width, info->hsub);
}
/** * drm_format_info_plane_height - height of the plane given the first plane * @info: pixel format info * @height: height of the first plane * @plane: plane index * * Returns: * The height of @plane, given that the height of the first plane is @height.
*/ staticinline int drm_format_info_plane_height(conststruct drm_format_info *info, int height, int plane)
{ if (!info || plane >= info->num_planes) return 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.