Skip to content

Commit 41c8c21

Browse files
paulkocialkowskimripard
authored andcommitted
drm/fourcc: Add format info helpers for checking YUV planes disposition
It is often useful to check whether the DRM format info retrieved from the DRM framebuffer matches a specific YUV planes disposition. This introduces helpers to quickly check that a provided format info matches a YUV format with a specific disposition, in commonly-used terminology. The intent of providing helpers taking the format info instead of the fourcc alone is to avoid the overhead of iterating through all formats when the whole format info structure is available. As a result, these helpers are very simple so they are made inline. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190118145133.21281-2-paul.kocialkowski@bootlin.com
1 parent 0763384 commit 41c8c21

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎include/drm/drm_fourcc.h‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,48 @@ struct drm_format_name_buf {
143143
char str[32];
144144
};
145145

146+
/**
147+
* drm_format_info_is_yuv_packed - check that the format info matches a YUV
148+
* format with data laid in a single plane
149+
* @info: format info
150+
*
151+
* Returns:
152+
* A boolean indicating whether the format info matches a packed YUV format.
153+
*/
154+
static inline bool
155+
drm_format_info_is_yuv_packed(const struct drm_format_info *info)
156+
{
157+
return info->is_yuv && info->num_planes == 1;
158+
}
159+
160+
/**
161+
* drm_format_info_is_yuv_semiplanar - check that the format info matches a YUV
162+
* format with data laid in two planes (luminance and chrominance)
163+
* @info: format info
164+
*
165+
* Returns:
166+
* A boolean indicating whether the format info matches a semiplanar YUV format.
167+
*/
168+
static inline bool
169+
drm_format_info_is_yuv_semiplanar(const struct drm_format_info *info)
170+
{
171+
return info->is_yuv && info->num_planes == 2;
172+
}
173+
174+
/**
175+
* drm_format_info_is_yuv_planar - check that the format info matches a YUV
176+
* format with data laid in three planes (one for each YUV component)
177+
* @info: format info
178+
*
179+
* Returns:
180+
* A boolean indicating whether the format info matches a planar YUV format.
181+
*/
182+
static inline bool
183+
drm_format_info_is_yuv_planar(const struct drm_format_info *info)
184+
{
185+
return info->is_yuv && info->num_planes == 3;
186+
}
187+
146188
const struct drm_format_info *__drm_format_info(u32 format);
147189
const struct drm_format_info *drm_format_info(u32 format);
148190
const struct drm_format_info *

0 commit comments

Comments
 (0)