Skip to content

Commit a211e56

Browse files
paulkocialkowskimripard
authored andcommitted
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
1 parent 41c8c21 commit a211e56

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

‎include/drm/drm_fourcc.h‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,81 @@ drm_format_info_is_yuv_planar(const struct drm_format_info *info)
185185
return info->is_yuv && info->num_planes == 3;
186186
}
187187

188+
/**
189+
* drm_format_info_is_yuv_sampling_410 - check that the format info matches a
190+
* YUV format with 4:1:0 sub-sampling
191+
* @info: format info
192+
*
193+
* Returns:
194+
* A boolean indicating whether the format info matches a YUV format with 4:1:0
195+
* sub-sampling.
196+
*/
197+
static inline bool
198+
drm_format_info_is_yuv_sampling_410(const struct drm_format_info *info)
199+
{
200+
return info->is_yuv && info->hsub == 4 && info->vsub == 4;
201+
}
202+
203+
/**
204+
* drm_format_info_is_yuv_sampling_411 - check that the format info matches a
205+
* YUV format with 4:1:1 sub-sampling
206+
* @info: format info
207+
*
208+
* Returns:
209+
* A boolean indicating whether the format info matches a YUV format with 4:1:1
210+
* sub-sampling.
211+
*/
212+
static inline bool
213+
drm_format_info_is_yuv_sampling_411(const struct drm_format_info *info)
214+
{
215+
return info->is_yuv && info->hsub == 4 && info->vsub == 1;
216+
}
217+
218+
/**
219+
* drm_format_info_is_yuv_sampling_420 - check that the format info matches a
220+
* YUV format with 4:2:0 sub-sampling
221+
* @info: format info
222+
*
223+
* Returns:
224+
* A boolean indicating whether the format info matches a YUV format with 4:2:0
225+
* sub-sampling.
226+
*/
227+
static inline bool
228+
drm_format_info_is_yuv_sampling_420(const struct drm_format_info *info)
229+
{
230+
return info->is_yuv && info->hsub == 2 && info->vsub == 2;
231+
}
232+
233+
/**
234+
* drm_format_info_is_yuv_sampling_422 - check that the format info matches a
235+
* YUV format with 4:2:2 sub-sampling
236+
* @info: format info
237+
*
238+
* Returns:
239+
* A boolean indicating whether the format info matches a YUV format with 4:2:2
240+
* sub-sampling.
241+
*/
242+
static inline bool
243+
drm_format_info_is_yuv_sampling_422(const struct drm_format_info *info)
244+
{
245+
return info->is_yuv && info->hsub == 2 && info->vsub == 1;
246+
}
247+
248+
/**
249+
* drm_format_info_is_yuv_sampling_444 - check that the format info matches a
250+
* YUV format with 4:4:4 sub-sampling
251+
* @info: format info
252+
*
253+
* Returns:
254+
* A boolean indicating whether the format info matches a YUV format with 4:4:4
255+
* sub-sampling.
256+
*/
257+
static inline bool
258+
drm_format_info_is_yuv_sampling_444(const struct drm_format_info *info)
259+
{
260+
return info->is_yuv && info->hsub == 1 && info->vsub == 1;
261+
}
262+
188263
const struct drm_format_info *__drm_format_info(u32 format);
189264
const struct drm_format_info *drm_format_info(u32 format);
190265
const struct drm_format_info *

0 commit comments

Comments
 (0)