Am 05.04.2012 20:35, schrieb ville.syrjala@xxxxxxxxxxxxxxx: > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > > These functions return the chroma subsampling factors for the specified > pixel format. Hmm not really related but looking at it this reminds me these formats always look a bit underspecified wrt chroma subsample positions. Are these fixed, undefined, or what (even mpeg1 and mpeg2 differ there, and let's not even talk about the big mess that interlaced mpeg2 is)? Roland > > Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/drm_crtc.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ > include/drm/drm_crtc.h | 2 + > 2 files changed, 62 insertions(+), 0 deletions(-) > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > index 74979ae..95f15c8 100644 > --- a/drivers/gpu/drm/drm_crtc.c > +++ b/drivers/gpu/drm/drm_crtc.c > @@ -3531,3 +3531,63 @@ int drm_format_plane_cpp(uint32_t format, int plane) > } > } > EXPORT_SYMBOL(drm_format_plane_cpp); > + > +/** > + * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor > + * @format: pixel format (DRM_FORMAT_*) > + * > + * RETURNS: > + * The horizontal chroma subsampling factor for the > + * specified pixel format. > + */ > +int drm_format_horz_chroma_subsampling(uint32_t format) > +{ > + switch (format) { > + case DRM_FORMAT_YUV411: > + case DRM_FORMAT_YVU411: > + case DRM_FORMAT_YUV410: > + case DRM_FORMAT_YVU410: > + return 4; > + case DRM_FORMAT_YUYV: > + case DRM_FORMAT_YVYU: > + case DRM_FORMAT_UYVY: > + case DRM_FORMAT_VYUY: > + case DRM_FORMAT_NV12: > + case DRM_FORMAT_NV21: > + case DRM_FORMAT_NV16: > + case DRM_FORMAT_NV61: > + case DRM_FORMAT_YUV422: > + case DRM_FORMAT_YVU422: > + case DRM_FORMAT_YUV420: > + case DRM_FORMAT_YVU420: > + return 2; > + default: > + return 1; > + } > +} > +EXPORT_SYMBOL(drm_format_horz_chroma_subsampling); > + > +/** > + * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor > + * @format: pixel format (DRM_FORMAT_*) > + * > + * RETURNS: > + * The vertical chroma subsampling factor for the > + * specified pixel format. > + */ > +int drm_format_vert_chroma_subsampling(uint32_t format) > +{ > + switch (format) { > + case DRM_FORMAT_YUV410: > + case DRM_FORMAT_YVU410: > + return 4; > + case DRM_FORMAT_YUV420: > + case DRM_FORMAT_YVU420: > + case DRM_FORMAT_NV12: > + case DRM_FORMAT_NV21: > + return 2; > + default: > + return 1; > + } > +} > +EXPORT_SYMBOL(drm_format_vert_chroma_subsampling); > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h > index ae7be55..824ab09 100644 > --- a/include/drm/drm_crtc.h > +++ b/include/drm/drm_crtc.h > @@ -1025,5 +1025,7 @@ extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, > int *bpp); > extern int drm_format_num_planes(uint32_t format); > extern int drm_format_plane_cpp(uint32_t format, int plane); > +extern int drm_format_horz_chroma_subsampling(uint32_t format); > +extern int drm_format_vert_chroma_subsampling(uint32_t format); > > #endif /* __DRM_CRTC_H__ */ _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel