drm/fourcc: Add format info helpers for checking YUV sub-sampling

Display engine drivers often need to distinguish between different types of
YUV sub-sampling. This introduces helpers to check for common sub-sampling
ratios in their commonly-used denomination from the DRM format info.

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-3-paul.kocialkowski@bootlin.com
This commit is contained in:
Paul Kocialkowski 2019-01-18 15:51:12 +01:00 committed by Maxime Ripard
parent 41c8c210a2
commit a211e56e94
No known key found for this signature in database
GPG Key ID: E3EF0D6F671851C5
1 changed files with 75 additions and 0 deletions

View File

@ -185,6 +185,81 @@ drm_format_info_is_yuv_planar(const struct 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.
*/
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;
}
const struct drm_format_info *__drm_format_info(u32 format);
const struct drm_format_info *drm_format_info(u32 format);
const struct drm_format_info *