From patchwork Thu Sep 10 09:24:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 11767251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3C2592C for ; Thu, 10 Sep 2020 09:24:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DD1521556 for ; Thu, 10 Sep 2020 09:24:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=agner.ch header.i=@agner.ch header.b="dWMGUS7x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DD1521556 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=agner.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 264536E8CF; Thu, 10 Sep 2020 09:24:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kmu-office.ch (mail.kmu-office.ch [IPv6:2a02:418:6a02::a2]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43EE76E8D3 for ; Thu, 10 Sep 2020 09:24:29 +0000 (UTC) Received: from trochilidae.toradex.int (unknown [IPv6:2a02:169:3df5::edf]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 266E55C2439; Thu, 10 Sep 2020 11:24:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1599729867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pmvcvc8l1oZY91clZosyrKEM990jYEwMdTOvqb94DXg=; b=dWMGUS7xYmmDqh2WtrNr0RdbKLto63rbVsBKZB0epH9FVEg19ZzuPIns0aKNZfhObEv5XR 52ea7HDXsFh0L5ff4o6uQrm84fPLcBRvLkeu5/LsySrprb4FuF+IjwegxzchNJ69CQGg47 IDouurCC7V+AidzAWOcZ1J4NqfT1OIk= From: Stefan Agner To: marex@denx.de, stefan@agner.ch, laurent.pinchart@ideasonboard.com, daniel@ffwll.ch Subject: [RFC PATCH 2/3] drm/atomic-helper: add REQUIRE_MATCHING_FB flag Date: Thu, 10 Sep 2020 11:24:24 +0200 Message-Id: <20200910092425.1016976-2-stefan@agner.ch> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910092425.1016976-1-stefan@agner.ch> References: <20200910092425.1016976-1-stefan@agner.ch> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, tomi.valkeinen@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add flag which checks that the framebuffer size matches the plane size exactly. This is useful for display controller which can't handle framebuffers other than the plane/CRTC size. Signed-off-by: Stefan Agner --- drivers/gpu/drm/drm_atomic_helper.c | 7 +++++++ drivers/gpu/drm/selftests/test-drm_plane_helper.c | 9 +++++++++ include/drm/drm_atomic_helper.h | 1 + 3 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 755572a37f3f..8bc7f8c2e566 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -802,6 +802,7 @@ int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state, int hscale, vscale; bool can_position = flags & DRM_PLANE_CAN_POSITION; bool can_update_disabled = flags & DRM_PLANE_CAN_UPDATE_DISABLED; + bool require_matching_fb = flags & DRM_PLANE_REQUIRE_MATCHING_FB; WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state->crtc); @@ -860,6 +861,12 @@ int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state, return -EINVAL; } + if (require_matching_fb && (drm_rect_width(src) != fb->width || + drm_rect_height(src) != fb->height)) { + DRM_DEBUG_KMS("Framebuffer size must match plane size.\n"); + return -EINVAL; + } + return 0; } EXPORT_SYMBOL(drm_atomic_helper_check_plane_state); diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/selftests/test-drm_plane_helper.c index 01e95b2d572f..2c81bbef830e 100644 --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c +++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c @@ -139,6 +139,15 @@ int igt_check_plane_state(void *ignored) FAIL_ON(!check_src_eq(&plane_state, 0, 0, 1023 << 16, 767 << 16)); FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1023, 767)); + /* Check whether requiring same size framebuffer works correctly. */ + set_src(&plane_state, 0, 0, 1024 << 16, 768 << 16); + set_crtc(&plane_state, 0, 0, 1024, 768); + ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_REQUIRE_MATCHING_FB); + FAIL(!ret, "Should not be able to use different size framebuffer with REQUIRE_MATCHING_FB\n"); + /* Simple scaling tests. */ set_src(&plane_state, 0, 0, 512 << 16, 384 << 16); set_crtc(&plane_state, 0, 0, 1024, 768); diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index bb9957b4f91b..244b730e84d3 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -43,6 +43,7 @@ int drm_atomic_helper_check_modeset(struct drm_device *dev, #define DRM_PLANE_CAN_POSITION BIT(0) #define DRM_PLANE_CAN_UPDATE_DISABLED BIT(1) +#define DRM_PLANE_REQUIRE_MATCHING_FB BIT(2) int drm_atomic_helper_check_plane_state(struct drm_plane_state *plane_state, const struct drm_crtc_state *crtc_state,