diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2012-04-05 14:35:17 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-04-20 07:38:00 -0400 |
commit | 01b68b0483627631c738dcfca0dee7e22892c420 (patch) | |
tree | 9eead4bda1b134612d0c564a3a6c2ad690291560 | |
parent | 5a86bd552407bd6b3e0df4e88636797484d06430 (diff) |
drm: Add drm_format_{horz, vert}_chroma_subsampling() utility functions
These functions return the chroma subsampling factors for the specified
pixel format.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 60 | ||||
-rw-r--r-- | 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 2c4e9cf2a1d2..1b79c953b4cc 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -3543,3 +3543,63 @@ int drm_format_plane_cpp(uint32_t format, int plane) | |||
3543 | } | 3543 | } |
3544 | } | 3544 | } |
3545 | EXPORT_SYMBOL(drm_format_plane_cpp); | 3545 | EXPORT_SYMBOL(drm_format_plane_cpp); |
3546 | |||
3547 | /** | ||
3548 | * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor | ||
3549 | * @format: pixel format (DRM_FORMAT_*) | ||
3550 | * | ||
3551 | * RETURNS: | ||
3552 | * The horizontal chroma subsampling factor for the | ||
3553 | * specified pixel format. | ||
3554 | */ | ||
3555 | int drm_format_horz_chroma_subsampling(uint32_t format) | ||
3556 | { | ||
3557 | switch (format) { | ||
3558 | case DRM_FORMAT_YUV411: | ||
3559 | case DRM_FORMAT_YVU411: | ||
3560 | case DRM_FORMAT_YUV410: | ||
3561 | case DRM_FORMAT_YVU410: | ||
3562 | return 4; | ||
3563 | case DRM_FORMAT_YUYV: | ||
3564 | case DRM_FORMAT_YVYU: | ||
3565 | case DRM_FORMAT_UYVY: | ||
3566 | case DRM_FORMAT_VYUY: | ||
3567 | case DRM_FORMAT_NV12: | ||
3568 | case DRM_FORMAT_NV21: | ||
3569 | case DRM_FORMAT_NV16: | ||
3570 | case DRM_FORMAT_NV61: | ||
3571 | case DRM_FORMAT_YUV422: | ||
3572 | case DRM_FORMAT_YVU422: | ||
3573 | case DRM_FORMAT_YUV420: | ||
3574 | case DRM_FORMAT_YVU420: | ||
3575 | return 2; | ||
3576 | default: | ||
3577 | return 1; | ||
3578 | } | ||
3579 | } | ||
3580 | EXPORT_SYMBOL(drm_format_horz_chroma_subsampling); | ||
3581 | |||
3582 | /** | ||
3583 | * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor | ||
3584 | * @format: pixel format (DRM_FORMAT_*) | ||
3585 | * | ||
3586 | * RETURNS: | ||
3587 | * The vertical chroma subsampling factor for the | ||
3588 | * specified pixel format. | ||
3589 | */ | ||
3590 | int drm_format_vert_chroma_subsampling(uint32_t format) | ||
3591 | { | ||
3592 | switch (format) { | ||
3593 | case DRM_FORMAT_YUV410: | ||
3594 | case DRM_FORMAT_YVU410: | ||
3595 | return 4; | ||
3596 | case DRM_FORMAT_YUV420: | ||
3597 | case DRM_FORMAT_YVU420: | ||
3598 | case DRM_FORMAT_NV12: | ||
3599 | case DRM_FORMAT_NV21: | ||
3600 | return 2; | ||
3601 | default: | ||
3602 | return 1; | ||
3603 | } | ||
3604 | } | ||
3605 | EXPORT_SYMBOL(drm_format_vert_chroma_subsampling); | ||
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 2d128eb4293f..2d63a02571ff 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -1028,5 +1028,7 @@ extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, | |||
1028 | int *bpp); | 1028 | int *bpp); |
1029 | extern int drm_format_num_planes(uint32_t format); | 1029 | extern int drm_format_num_planes(uint32_t format); |
1030 | extern int drm_format_plane_cpp(uint32_t format, int plane); | 1030 | extern int drm_format_plane_cpp(uint32_t format, int plane); |
1031 | extern int drm_format_horz_chroma_subsampling(uint32_t format); | ||
1032 | extern int drm_format_vert_chroma_subsampling(uint32_t format); | ||
1031 | 1033 | ||
1032 | #endif /* __DRM_CRTC_H__ */ | 1034 | #endif /* __DRM_CRTC_H__ */ |