diff options
author | Paul Kocialkowski <paul.kocialkowski@bootlin.com> | 2019-01-18 09:51:12 -0500 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@bootlin.com> | 2019-01-18 13:00:18 -0500 |
commit | a211e56e947c8dbf37e1682f278bcfe8b20129c4 (patch) | |
tree | 8d29c37b6883803356be4097382828e284e07feb /include/drm | |
parent | 41c8c210a2b4ba8b1b532cdba7ff0112ef76abb2 (diff) |
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
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drm_fourcc.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 01cd353d9302..b3d9d88ab290 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h | |||
@@ -185,6 +185,81 @@ drm_format_info_is_yuv_planar(const struct drm_format_info *info) | |||
185 | return info->is_yuv && info->num_planes == 3; | 185 | return info->is_yuv && info->num_planes == 3; |
186 | } | 186 | } |
187 | 187 | ||
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 | |||
188 | const struct drm_format_info *__drm_format_info(u32 format); | 263 | const struct drm_format_info *__drm_format_info(u32 format); |
189 | const struct drm_format_info *drm_format_info(u32 format); | 264 | const struct drm_format_info *drm_format_info(u32 format); |
190 | const struct drm_format_info * | 265 | const struct drm_format_info * |