Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Paul Kocialkowski and committed by
Maxime Ripard
41c8c210 07633840

+42
+42
include/drm/drm_fourcc.h
··· 143 143 char str[32]; 144 144 }; 145 145 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 + 146 188 const struct drm_format_info *__drm_format_info(u32 format); 147 189 const struct drm_format_info *drm_format_info(u32 format); 148 190 const struct drm_format_info *