Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp280887pxa; Wed, 12 Aug 2020 01:35:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYLXivDgD6O+uPY1J/LTzLHO+kINY7nOh6H8J8opQvAOk5dlD0U14liywktUpLUS+m9AXf X-Received: by 2002:a17:906:7155:: with SMTP id z21mr32158763ejj.282.1597221340959; Wed, 12 Aug 2020 01:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597221340; cv=none; d=google.com; s=arc-20160816; b=SF2VBxS9GU24AFwTFk6KMeSbXjkbjcPtL33tudsJWCwFH9hQq+lYP8DEAV/TDlg3wF T7urajV92nacdLdLcQaqRyR3QFazuelwiyJzMkh5J4/bRuwRtHhtH325eL+QPdGQBDn9 6sNPa6HODHufMVX+5KgJUyLOpaVHS0fLK4nWF4NPEVI/lZXCjHN2DbaUDPX13XAvUxqt 5xCbrsF61lWfNtKQztDx7JNJkpi1mGtzchVe+n12x2H82yAnW3pDJVd0RkW9JjRok2/0 Cc562R1SL1TtSKGoiiBPT88xEh4kYPYiGtzCIdP2TBgDq3AK6EUcwRXkhhs/V2bLkPC+ jMAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=aRMPmdJC14/vjlBStSVBmD0y1635qooApkGvmHpHzis=; b=RHITDwo4fja5OlOaESQAZIVttjxuojb6i8KTXcSQrMgKgUaWR6mWXj9eMJyPOdE7Qt f321pbjISiOGzA+7NckxK0bDZ08nzB1t4pU8/rj1tXKbOYGuePdwGyogSeBg++KT9x3+ GKiB718fO5vT+nRQg0+Ycf0eA4fSMZwYjbXGrZFn+nePEE69u4fe8Fm6uUzKGsZTZ0GQ UEqz5DuWUP4ua2Gmsj1tJ9xD1FMXf6F5oAOdDN5yRAhd272uirtr+eReXD35Q43Loy1n HCB0v/YNb68vdqtq0G7eFcMVHzGhB2IFzSiWBIhB6LhGzT96R35QqzBVOIxJ0Gd/H66u NHcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si735981ejf.687.2020.08.12.01.35.17; Wed, 12 Aug 2020 01:35:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbgHLIeV (ORCPT + 99 others); Wed, 12 Aug 2020 04:34:21 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:54602 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbgHLIeT (ORCPT ); Wed, 12 Aug 2020 04:34:19 -0400 Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id 1D2F4C0C54; Wed, 12 Aug 2020 16:34:15 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [103.29.142.67]) by smtp.263.net (postfix) whith ESMTP id P31771T140662796187392S1597221250509047_; Wed, 12 Aug 2020 16:34:15 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <69b1af1b415bf5000b6580fc378eeefa> X-RL-SENDER: algea.cao@rock-chips.com X-SENDER: algea.cao@rock-chips.com X-LOGIN-NAME: algea.cao@rock-chips.com X-FST-TO: a.hajda@samsung.com X-SENDER-IP: 103.29.142.67 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Algea Cao To: a.hajda@samsung.com, kuankuan.y@gmail.com, hjc@rock-chips.com, tzimmermann@suse.de, dri-devel@lists.freedesktop.org, sam@ravnborg.org, airlied@linux.ie, heiko@sntech.de, jernej.skrabec@siol.net, algea.cao@rock-chips.com, Laurent.pinchart@ideasonboard.com, laurent.pinchart+renesas@ideasonboard.com, jonas@kwiboo.se, mripard@kernel.org, darekm@google.com, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, cychiang@chromium.org, linux-kernel@vger.kernel.org, narmstrong@baylibre.com, jbrunet@baylibre.com, maarten.lankhorst@linux.intel.com, daniel@ffwll.ch Subject: [PATCH 1/6] drm: Add connector atomic_begin/atomic_flush Date: Wed, 12 Aug 2020 16:34:07 +0800 Message-Id: <20200812083407.856-1-algea.cao@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200812083120.743-1-algea.cao@rock-chips.com> References: <20200812083120.743-1-algea.cao@rock-chips.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some situations, connector should get some work done when plane is updating. Such as when change output color format, hdmi should send AVMUTE to make screen black before crtc updating color format, or screen may flash. After color updating, hdmi should clear AVMUTE bring screen back to normal. The process is as follows: AVMUTE -> Update CRTC -> Update HDMI -> Clear AVMUTE So we introduce connector atomic_begin/atomic_flush. Signed-off-by: Algea Cao --- drivers/gpu/drm/drm_atomic_helper.c | 46 ++++++++++++++++++++++++ include/drm/drm_modeset_helper_vtables.h | 19 ++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index f68c69a45752..f4abd700d2c4 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2471,6 +2471,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev, struct drm_atomic_state *old_state, uint32_t flags) { + struct drm_connector *connector; + struct drm_connector_state *old_connector_state, *new_connector_state; struct drm_crtc *crtc; struct drm_crtc_state *old_crtc_state, *new_crtc_state; struct drm_plane *plane; @@ -2479,6 +2481,28 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev, bool active_only = flags & DRM_PLANE_COMMIT_ACTIVE_ONLY; bool no_disable = flags & DRM_PLANE_COMMIT_NO_DISABLE_AFTER_MODESET; + for_each_oldnew_connector_in_state(old_state, connector, + old_connector_state, + new_connector_state, i) { + const struct drm_connector_helper_funcs *funcs; + + if (!connector->state->crtc) + continue; + + if (!connector->state->crtc->state->active) + continue; + + funcs = connector->helper_private; + + if (!funcs || !funcs->atomic_begin) + continue; + + DRM_DEBUG_ATOMIC("flush beginning [CONNECTOR:%d:%s]\n", + connector->base.id, connector->name); + + funcs->atomic_begin(connector, old_connector_state); + } + for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) { const struct drm_crtc_helper_funcs *funcs; @@ -2550,6 +2574,28 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev, funcs->atomic_flush(crtc, old_crtc_state); } + + for_each_oldnew_connector_in_state(old_state, connector, + old_connector_state, + new_connector_state, i) { + const struct drm_connector_helper_funcs *funcs; + + if (!connector->state->crtc) + continue; + + if (!connector->state->crtc->state->active) + continue; + + funcs = connector->helper_private; + + if (!funcs || !funcs->atomic_flush) + continue; + + DRM_DEBUG_ATOMIC("flushing [CONNECTOR:%d:%s]\n", + connector->base.id, connector->name); + + funcs->atomic_flush(connector, old_connector_state); + } } EXPORT_SYMBOL(drm_atomic_helper_commit_planes); diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index 421a30f08463..10f3f2e2fe28 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -1075,6 +1075,25 @@ struct drm_connector_helper_funcs { void (*atomic_commit)(struct drm_connector *connector, struct drm_connector_state *state); + /** + * @atomic_begin: + * + * flush atomic update + * + * This callback is used by the atomic modeset helpers but it is optional. + */ + void (*atomic_begin)(struct drm_connector *connector, + struct drm_connector_state *state); + + /** + * @atomic_begin: + * + * begin atomic update + * + * This callback is used by the atomic modeset helpers but it is optional. + */ + void (*atomic_flush)(struct drm_connector *connector, + struct drm_connector_state *state); /** * @prepare_writeback_job: * -- 2.25.1