From patchwork Mon Oct 10 17:02:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13002762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E8750C433FE for ; Mon, 10 Oct 2022 17:02:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 86F4F10E68B; Mon, 10 Oct 2022 17:02:25 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id A21E010E68C for ; Mon, 10 Oct 2022 17:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665421334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qk5ghpsK8PDbqTdW6PF39RiS96AoGnZ+OQsYu95yzaM=; b=bULl6ig8vOXy1W7MOeZf0Y5jtrfT1yPvY5GzwXZs5fT/3syhYT9jD7bJi68NsjY4iL30IX Aw3ki5JmiPZ+b/0oKTZ+gQ6TqoGBN0HGhypG4QOk6N8k43Uwi9aaG7HjrIoD6+QREk113T /uRyOny3dEz4j5rrMMhXGoGrYvnBxoo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-59-2pJFQee9NUeRbz5Pb4x4-A-1; Mon, 10 Oct 2022 13:02:13 -0400 X-MC-Unique: 2pJFQee9NUeRbz5Pb4x4-A-1 Received: by mail-wr1-f69.google.com with SMTP id j8-20020adfa548000000b0022e2bf8f48fso2968087wrb.23 for ; Mon, 10 Oct 2022 10:02:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qk5ghpsK8PDbqTdW6PF39RiS96AoGnZ+OQsYu95yzaM=; b=bQ3mAA1/gs467JyKABv4wGth/nmbNMR0tEoGRXTwH3AIWzqRLRfWJEm4J9Rx97mZD8 19DS/VfJr4DQ94TSb3flTOWxkOE9Va6kRUD3Qa05EYIQzK1HDTAQwBV2z+pW5wjmQ0S1 eP4+iqmnn0evEfhLEnIcwgjsrZzOhbcqHFW9ToF7jPXt5Mf/IDUGIxEcIYyIg8/Bfr1x 6YVkIcIcgd9FE304IfE0Am2fNsYebbM5QwmdhXpHe1rvjSV+GabYYQd/31Dk7tXfOp46 2oIs5vrMSdU7+EswSfnzEedTrc+z6pXvOz9gbaNa3Cx2XxxsWoTmtJUl5Xs9z7YkS1on Tgdg== X-Gm-Message-State: ACrzQf0kmsQw6pIRvDh9+CecYf66ZkEOfsU8JjfcLGr+2TSpqtE9M/SF e4TB3fFNp//bYBkWivbY9RVtfd5sFZjAXbSSID1OeyFU6zfVnt8muFUB1VZS5ZXEfXI+fN1DZDs /do+w7dVBAxgzN08YRWdNbvdQ61eC X-Received: by 2002:adf:f40e:0:b0:22e:2ce4:e6a2 with SMTP id g14-20020adff40e000000b0022e2ce4e6a2mr13064930wro.30.1665421332362; Mon, 10 Oct 2022 10:02:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wesICMOp8cUSjDeGz35jt9FwoGQdTtaZeMl/ecyL4tTVqGmDsyFU6F3dnEkiGT8nn8IDAsQ== X-Received: by 2002:adf:f40e:0:b0:22e:2ce4:e6a2 with SMTP id g14-20020adff40e000000b0022e2ce4e6a2mr13064918wro.30.1665421332153; Mon, 10 Oct 2022 10:02:12 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id z5-20020a056000110500b0022b11a27e39sm9160551wrw.1.2022.10.10.10.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:02:11 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/simpledrm: Do not call drm_atomic_add_affected_planes() Date: Mon, 10 Oct 2022 19:02:01 +0200 Message-Id: <20221010170203.274949-2-javierm@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221010170203.274949-1-javierm@redhat.com> References: <20221010170203.274949-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: David Airlie , dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Thomas Zimmermann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no need to add planes to the atomic state. Remove the call to drm_atomic_add_affected_planes() from simpledrm. On full modesets, the DRM helpers already add a CRTC's planes to the atomic state; see drm_atomic_helper_check_modeset(). There's no reason to call drm_atomic_add_affected_planes() unconditionally in the CRTC's atomic_check() in simpledrm. It's also too late, as the atomic_check() of the added planes will not be called before the commit. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/tiny/simpledrm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index ecd49a8f3334..f03f17f62a56 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -549,17 +549,11 @@ static int simpledrm_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *new_state) { struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc); - int ret; if (!new_crtc_state->enable) - goto out; - - ret = drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); - if (ret) - return ret; + return 0; -out: - return drm_atomic_add_affected_planes(new_state, crtc); + return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); } /* From patchwork Mon Oct 10 17:02:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13002761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F3187C43217 for ; Mon, 10 Oct 2022 17:02:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11E2410E688; Mon, 10 Oct 2022 17:02:25 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id F24F710E68C for ; Mon, 10 Oct 2022 17:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665421336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I8yaCP9ce66rAwzKDzbvHaA4XIfJFeHvOc66mwQOMSw=; b=Ish7IujUkvYklivIpEuHb+sZMe7ZHRv/osePyAougDSjKtvGwhQCADaaEJ/qG0J4bMTRel 3TNIkYl8e2ATwdkOV168J8fSqvKBUeL0E8iMSLpBm7WaHo2HWw8ujXU4nKmFevJb3x4q8u XF+lrw9JeS/3hAFIykGDJIW0aiHaN2E= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-154-67xLh28TOki7BbIGaMIrXQ-1; Mon, 10 Oct 2022 13:02:15 -0400 X-MC-Unique: 67xLh28TOki7BbIGaMIrXQ-1 Received: by mail-wr1-f72.google.com with SMTP id m20-20020adfa3d4000000b0022e2fa93dd1so2930675wrb.2 for ; Mon, 10 Oct 2022 10:02:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I8yaCP9ce66rAwzKDzbvHaA4XIfJFeHvOc66mwQOMSw=; b=6CdacgUelhDPKrHlQqy4bzLoVDcuLPqjsRRsl4VCggY/qEH42mLvxDHp+H8n+jyI0j 0Z+GqpVezSdV22vtrkSPklsau5drL/0RM9xh26hlH6t+mgwPFSrSMiLBMl/O74ggFkBz jG/9WQEPXwEhFxxI5QLaIVEfJGygs5WARI43ZT1c2sTSkGZHkXn7r4Eg69W3C/FGGeQQ RXMjBW7j+FH28r4cDNZrAJQer5Mf+WQ20Nr79rIGQJ8jkZXmoKewPsp5FR4Vv8lBeLNw ikP+3ukzbhrnocVbqqi1kIjaRTOgcRL0OIbnNHwWjOwzFg4AX0ayTXaGHhuobYmVhXq7 rcMw== X-Gm-Message-State: ACrzQf1ciw2uOjsqubd8CbfitYbuqFzm6e1uyPoKLdXGWcRoQEuIIQLw QY5i/k6DB23Md5jAShbfVnz1z15amchdnkepB4bVqnNgNFCFsvs2HEvJieTwIHpfLuSr/7X1JIA HoZciSPM2F4yWnLNSVtGIJLaM49/Q X-Received: by 2002:a05:600c:474a:b0:3b4:cb3f:2f5f with SMTP id w10-20020a05600c474a00b003b4cb3f2f5fmr20670167wmo.8.1665421333926; Mon, 10 Oct 2022 10:02:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uoZMFHRFdDBTfXNtCkF5Ow1u9w/7KAhe9C2I3BrwodOqtSA6YYTQBJx7Lw3zEPjHmeE9VwQ== X-Received: by 2002:a05:600c:474a:b0:3b4:cb3f:2f5f with SMTP id w10-20020a05600c474a00b003b4cb3f2f5fmr20670150wmo.8.1665421333696; Mon, 10 Oct 2022 10:02:13 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id z5-20020a056000110500b0022b11a27e39sm9160551wrw.1.2022.10.10.10.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:02:13 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 2/3] drm/ssd130x: Do not call drm_atomic_add_affected_planes() Date: Mon, 10 Oct 2022 19:02:02 +0200 Message-Id: <20221010170203.274949-3-javierm@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221010170203.274949-1-javierm@redhat.com> References: <20221010170203.274949-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: David Airlie , dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Thomas Zimmermann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no need to add planes to the atomic state. Remove the call to drm_atomic_add_affected_planes() from ssd130x. On full modesets, the DRM helpers already add a CRTC's planes to the atomic state; see drm_atomic_helper_check_modeset(). There's no reason to call drm_atomic_add_affected_planes() unconditionally in the CRTC's atomic_check() in ssd130x. It's also too late, as the atomic_check() of the added planes will not be called before the commit. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/solomon/ssd130x.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index 57e48355c008..0d4ab65233db 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -649,17 +649,11 @@ static int ssd130x_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *new_state) { struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc); - int ret; if (!new_crtc_state->enable) - goto out; - - ret = drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); - if (ret) - return ret; + return 0; -out: - return drm_atomic_add_affected_planes(new_state, crtc); + return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); } /* From patchwork Mon Oct 10 17:02:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13002763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4E415C4332F for ; Mon, 10 Oct 2022 17:02:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF51610E68C; Mon, 10 Oct 2022 17:02:40 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6315410E688 for ; Mon, 10 Oct 2022 17:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665421337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YUvuSJvCKaC4wzR9m0+Cm+eAjqQDPWwMTFGQwXn6Lfs=; b=HD7m+IXzAuF9tmuFA811bn+Oj/BfmU1cxYQnlQf1TFiArT1EQC+3rKjQnLSvIHx003oEZt Alcu5fr4jeUWoNz/pneGRsxIdAl/SghcdgR9VmOGVjMhomsDsAmkbkfwJ6SteVavqs3RaI GEVeNzaeCdQ8ckj+Uw10VyorTSzOa0I= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-593-OS1eKrkONm-7lk_vI-pRhA-1; Mon, 10 Oct 2022 13:02:16 -0400 X-MC-Unique: OS1eKrkONm-7lk_vI-pRhA-1 Received: by mail-wm1-f71.google.com with SMTP id l1-20020a7bc341000000b003bfe1273d6cso3235231wmj.4 for ; Mon, 10 Oct 2022 10:02:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YUvuSJvCKaC4wzR9m0+Cm+eAjqQDPWwMTFGQwXn6Lfs=; b=OALw0qDKVd4pDslZdr8l5qtE52oZljQFdy0IjtQS9xleGQr5fKU7P3NsB87u3EdXOx EASqY4tZ5vpEnkoWzRhs9j+M0JIdTc/M1b8IxEw0kqWCJ0RUX7+oovsGmZDLB42+ftAn 5Vv3GARCvVMWEJMZH5G6L1xVYxGLLJxVjJir3cofqCCsVQ/tHY++om0yGTeet9ixwz4D AhF8FAMdsVVAEF8cmU7GObx9+NOZtJ9HvMLa1vINry/obK6OchAwOvsJBHrjlHRS8ggi g77QeAtmulx1PnkxK204qmdej8DURdN+Dr++qtqP/JGst/PvVggOMKf7vdv75DncgTT3 yDlw== X-Gm-Message-State: ACrzQf2AwHutatHm3zCxYzWQihjgkQa1E6y82v53oRJG6zbBaNvw8GjM VkL+mWb8vPS4sJwq3J3Kj1kesnRi93E+G69h1W2eqfDn6plPb/3OyktNyieIIRZbt/1VRjiIxjg HQHArUnWAAcFSyYcdQSq5r3TC6YL9 X-Received: by 2002:adf:e64a:0:b0:22c:db6c:5b72 with SMTP id b10-20020adfe64a000000b0022cdb6c5b72mr13112295wrn.356.1665421335416; Mon, 10 Oct 2022 10:02:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pVLFc/Zjx0wEtIfD8w+Dsx1klKtaRxVvzYBAj1jOqK5N5Un3lUp2LkATHQInMjHJVBVWfpQ== X-Received: by 2002:adf:e64a:0:b0:22c:db6c:5b72 with SMTP id b10-20020adfe64a000000b0022cdb6c5b72mr13112264wrn.356.1665421335125; Mon, 10 Oct 2022 10:02:15 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id z5-20020a056000110500b0022b11a27e39sm9160551wrw.1.2022.10.10.10.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:02:14 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm/crtc-helper: Add a drm_crtc_helper_atomic_check() helper Date: Mon, 10 Oct 2022 19:02:03 +0200 Message-Id: <20221010170203.274949-4-javierm@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221010170203.274949-1-javierm@redhat.com> References: <20221010170203.274949-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Thomas Zimmermann , David Airlie , Javier Martinez Canillas , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Provides a default CRTC state check handler for CRTCs that only have one primary plane attached. There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a CRTC helper and make drivers use it. Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/drm_crtc_helper.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/solomon/ssd130x.c | 14 ++------------ drivers/gpu/drm/tiny/simpledrm.c | 14 ++------------ include/drm/drm_crtc_helper.h | 2 ++ 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 457448cc60f7..4ad3abaa98f4 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -421,6 +421,30 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, } EXPORT_SYMBOL(drm_crtc_helper_set_mode); +/** + * drm_crtc_helper_atomic_check() - Helper to check CRTC atomic-state + * @crtc: CRTC to check + * @state: atomic state object + * + * Provides a default CRTC-state check handler for CRTCs that only have + * one primary plane attached to it. + * + * This is often the case for the CRTC of simple framebuffers. + * + * RETURNS: + * Zero on success, or an errno code otherwise. + */ +int drm_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state) +{ + struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); + + if (!new_crtc_state->enable) + return 0; + + return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); +} +EXPORT_SYMBOL(drm_crtc_helper_atomic_check); + static void drm_crtc_helper_disable(struct drm_crtc *crtc) { diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index 0d4ab65233db..f2795f90ea69 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -645,17 +646,6 @@ static enum drm_mode_status ssd130x_crtc_helper_mode_valid(struct drm_crtc *crtc return MODE_OK; } -static int ssd130x_crtc_helper_atomic_check(struct drm_crtc *crtc, - struct drm_atomic_state *new_state) -{ - struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc); - - if (!new_crtc_state->enable) - return 0; - - return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); -} - /* * The CRTC is always enabled. Screen updates are performed by * the primary plane's atomic_update function. Disabling clears @@ -663,7 +653,7 @@ static int ssd130x_crtc_helper_atomic_check(struct drm_crtc *crtc, */ static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs = { .mode_valid = ssd130x_crtc_helper_mode_valid, - .atomic_check = ssd130x_crtc_helper_atomic_check, + .atomic_check = drm_crtc_helper_atomic_check, }; static void ssd130x_crtc_reset(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index f03f17f62a56..cbb100753154 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -545,17 +546,6 @@ static enum drm_mode_status simpledrm_crtc_helper_mode_valid(struct drm_crtc *cr return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sdev->mode); } -static int simpledrm_crtc_helper_atomic_check(struct drm_crtc *crtc, - struct drm_atomic_state *new_state) -{ - struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc); - - if (!new_crtc_state->enable) - return 0; - - return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state); -} - /* * The CRTC is always enabled. Screen updates are performed by * the primary plane's atomic_update function. Disabling clears @@ -563,7 +553,7 @@ static int simpledrm_crtc_helper_atomic_check(struct drm_crtc *crtc, */ static const struct drm_crtc_helper_funcs simpledrm_crtc_helper_funcs = { .mode_valid = simpledrm_crtc_helper_mode_valid, - .atomic_check = simpledrm_crtc_helper_atomic_check, + .atomic_check = drm_crtc_helper_atomic_check, }; static const struct drm_crtc_funcs simpledrm_crtc_funcs = { diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h index a6d520d5b6ca..1840db247f69 100644 --- a/include/drm/drm_crtc_helper.h +++ b/include/drm/drm_crtc_helper.h @@ -50,6 +50,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, int x, int y, struct drm_framebuffer *old_fb); +int drm_crtc_helper_atomic_check(struct drm_crtc *crtc, + struct drm_atomic_state *state); bool drm_helper_crtc_in_use(struct drm_crtc *crtc); bool drm_helper_encoder_in_use(struct drm_encoder *encoder);