aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2015-03-04 19:25:43 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-03-10 04:59:35 -0400
commitead8610d42105a3d01f755522f11b96c60dc648f (patch)
tree7cbbdcbf073515c3e717edc1f128544148ddf62e /drivers/gpu/drm/drm_crtc.c
parent2a97acd6376922bb9d23b5f4421745d2a6690060 (diff)
drm: Share plane pixel format check code between legacy and atomic
Both the legacy and atomic helpers need to check whether a plane supports a given pixel format. The code is currently duplicated, share it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [danvet: Slightly extend the docbook.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r--drivers/gpu/drm/drm_crtc.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index c83e4db0adf7..447db50e6838 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2408,6 +2408,27 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
2408 return 0; 2408 return 0;
2409} 2409}
2410 2410
2411/**
2412 * drm_plane_check_pixel_format - Check if the plane supports the pixel format
2413 * @plane: plane to check for format support
2414 * @format: the pixel format
2415 *
2416 * Returns:
2417 * Zero of @plane has @format in its list of supported pixel formats, -EINVAL
2418 * otherwise.
2419 */
2420int drm_plane_check_pixel_format(const struct drm_plane *plane, u32 format)
2421{
2422 unsigned int i;
2423
2424 for (i = 0; i < plane->format_count; i++) {
2425 if (format == plane->format_types[i])
2426 return 0;
2427 }
2428
2429 return -EINVAL;
2430}
2431
2411/* 2432/*
2412 * setplane_internal - setplane handler for internal callers 2433 * setplane_internal - setplane handler for internal callers
2413 * 2434 *
@@ -2428,7 +2449,6 @@ static int __setplane_internal(struct drm_plane *plane,
2428{ 2449{
2429 int ret = 0; 2450 int ret = 0;
2430 unsigned int fb_width, fb_height; 2451 unsigned int fb_width, fb_height;
2431 unsigned int i;
2432 2452
2433 /* No fb means shut it down */ 2453 /* No fb means shut it down */
2434 if (!fb) { 2454 if (!fb) {
@@ -2451,13 +2471,10 @@ static int __setplane_internal(struct drm_plane *plane,
2451 } 2471 }
2452 2472
2453 /* Check whether this plane supports the fb pixel format. */ 2473 /* Check whether this plane supports the fb pixel format. */
2454 for (i = 0; i < plane->format_count; i++) 2474 ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
2455 if (fb->pixel_format == plane->format_types[i]) 2475 if (ret) {
2456 break;
2457 if (i == plane->format_count) {
2458 DRM_DEBUG_KMS("Invalid pixel format %s\n", 2476 DRM_DEBUG_KMS("Invalid pixel format %s\n",
2459 drm_get_format_name(fb->pixel_format)); 2477 drm_get_format_name(fb->pixel_format));
2460 ret = -EINVAL;
2461 goto out; 2478 goto out;
2462 } 2479 }
2463 2480