diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2012-04-05 14:35:16 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-04-20 07:37:32 -0400 |
commit | 5a86bd552407bd6b3e0df4e88636797484d06430 (patch) | |
tree | 1d8f6746b0381b599cb7e5c1afb0490a6a0d009f /drivers/gpu/drm/drm_crtc.c | |
parent | 141670e9b4356b59b5b39a99e10ac0118d12b16d (diff) |
drm: Add drm_format_plane_cpp() utility function
This function returns the bytes per pixel value based on the pixel
format and plane index.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 32ab669f4aed..2c4e9cf2a1d2 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -3498,3 +3498,48 @@ int drm_format_num_planes(uint32_t format) | |||
3498 | } | 3498 | } |
3499 | } | 3499 | } |
3500 | EXPORT_SYMBOL(drm_format_num_planes); | 3500 | EXPORT_SYMBOL(drm_format_num_planes); |
3501 | |||
3502 | /** | ||
3503 | * drm_format_plane_cpp - determine the bytes per pixel value | ||
3504 | * @format: pixel format (DRM_FORMAT_*) | ||
3505 | * @plane: plane index | ||
3506 | * | ||
3507 | * RETURNS: | ||
3508 | * The bytes per pixel value for the specified plane. | ||
3509 | */ | ||
3510 | int drm_format_plane_cpp(uint32_t format, int plane) | ||
3511 | { | ||
3512 | unsigned int depth; | ||
3513 | int bpp; | ||
3514 | |||
3515 | if (plane >= drm_format_num_planes(format)) | ||
3516 | return 0; | ||
3517 | |||
3518 | switch (format) { | ||
3519 | case DRM_FORMAT_YUYV: | ||
3520 | case DRM_FORMAT_YVYU: | ||
3521 | case DRM_FORMAT_UYVY: | ||
3522 | case DRM_FORMAT_VYUY: | ||
3523 | return 2; | ||
3524 | case DRM_FORMAT_NV12: | ||
3525 | case DRM_FORMAT_NV21: | ||
3526 | case DRM_FORMAT_NV16: | ||
3527 | case DRM_FORMAT_NV61: | ||
3528 | return plane ? 2 : 1; | ||
3529 | case DRM_FORMAT_YUV410: | ||
3530 | case DRM_FORMAT_YVU410: | ||
3531 | case DRM_FORMAT_YUV411: | ||
3532 | case DRM_FORMAT_YVU411: | ||
3533 | case DRM_FORMAT_YUV420: | ||
3534 | case DRM_FORMAT_YVU420: | ||
3535 | case DRM_FORMAT_YUV422: | ||
3536 | case DRM_FORMAT_YVU422: | ||
3537 | case DRM_FORMAT_YUV444: | ||
3538 | case DRM_FORMAT_YVU444: | ||
3539 | return 1; | ||
3540 | default: | ||
3541 | drm_fb_get_bpp_depth(format, &depth, &bpp); | ||
3542 | return bpp >> 3; | ||
3543 | } | ||
3544 | } | ||
3545 | EXPORT_SYMBOL(drm_format_plane_cpp); | ||