From patchwork Wed May 8 16:09:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10936167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C39F792A for ; Wed, 8 May 2019 16:09:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B15852811E for ; Wed, 8 May 2019 16:09:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A552C28538; Wed, 8 May 2019 16:09:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 338312811E for ; Wed, 8 May 2019 16:09:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6882A897E0; Wed, 8 May 2019 16:09:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98058897E0 for ; Wed, 8 May 2019 16:09:25 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id t1so3623319qtc.12 for ; Wed, 08 May 2019 09:09:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ATJVqwKnuJNVrskurSmrA7uNnNg1EGswZWkepzxe4V0=; b=YnofAU+iLvWGocBf5mkLB0SkC7Q6+NMGQwwyH3Wjwb2lQn1pSbH0GNUa8cYZI5vf1r YrEPpFi8icTWjMiZZmZYAJSefEzlQJs/QOZw9dLztQ4KnvC97RtZSdIilr5tkOxMeDW6 r0HnW8zOmy4Kk4Lf7mNPyodjJrh8Rh20pFShrRVyFjx+Xc2VfNZX8USzhpv/O3+VE2sq TOEUDHgC7JQUiA7RQ1FDAiwOb+yvvIaJWWIX9oHwHcRGHOa4YGOQw4wz+d31hQ0R5Xke jJzr9l/i4i+zjkI7zRGB0aWcj7qoPnKZnOO0fSsIOL9cUevX6m3eufMZHuw2tb4Gkt8G tZMA== X-Gm-Message-State: APjAAAXd3LdewZg7lm+vJL/yGNa0cWMg5U5uRTWbYVu4SE7RSvwSPbdK g7gh6bUgZuKsh4yu3xPxbD7bG024zJ8= X-Google-Smtp-Source: APXvYqxNAXHpT8n2TmVaIrnB5HPtlaM3y7yNdf916J/CD2CsowIaYFGsxsuJy5ivIO/l0/VIXTgvAQ== X-Received: by 2002:a0c:a944:: with SMTP id z4mr31106261qva.119.1557331764507; Wed, 08 May 2019 09:09:24 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id s50sm10936877qts.39.2019.05.08.09.09.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 09:09:23 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 01/11] drm: Add atomic variants of enable/disable to encoder helper funcs Date: Wed, 8 May 2019 12:09:06 -0400 Message-Id: <20190508160920.144739-2-sean@poorly.run> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190508160920.144739-1-sean@poorly.run> References: <20190508160920.144739-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ATJVqwKnuJNVrskurSmrA7uNnNg1EGswZWkepzxe4V0=; b=BiI93sTPDI48u09oo5aW642Ut7uWXIbHaxIRSxvko7OVMBUkzwcWiQ9SVCKGZjYKrM b8BQoBiGYLq0iaQD8r2FC8gFTMdkXikTyh1wLqnQtRAoT7Ee3S68CBurfetg9JHg3lKw cTVwH36YY5I0EWFgVcaEPEiZtqo5Yy/WVCpcQgQvvuBRhluDbtBis8Xng/wsRoQxtl2c iYnYY6memCt2zMpj9lrDxmxGB+jtjUBQ5aUwSLCIFeWrEGWo8EYV8jgf+zyL16ql6dWs 7eKqObYCVHTy3fGe78lul8ytvnDE80Ils3oUQHPuqXVBTICNkraYZAR0x1+N5HTCFnAW F5lg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, David Airlie , Sean Paul , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul This patch adds atomic_enable and atomic_disable callbacks to the encoder helpers. This will allow encoders to make informed decisions in their start-up/shutdown based on the committed state. Aside from the new hooks, this patch also introduces the new signature for .atomic_* functions going forward. Instead of passing object state (well, encoders don't have atomic state, but let's ignore that), we pass the entire atomic state so the driver can inspect more than what's happening locally. This is particularly important for the upcoming self refresh helpers. Changes in v3: - Added patch to the set Changes in v4: - Move atomic_disable above prepare (Daniel) - Add breadcrumb to .enable() docbook (Daniel) Link to v3: https://patchwork.freedesktop.org/patch/msgid/20190502194956.218441-2-sean@poorly.run Cc: Daniel Vetter Cc: Ville Syrjälä Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_atomic_helper.c | 8 +++- include/drm/drm_modeset_helper_vtables.h | 48 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 553415fe8ede..ccf01831f265 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -999,7 +999,9 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) /* Right function depends upon target state. */ if (funcs) { - if (new_conn_state->crtc && funcs->prepare) + if (funcs->atomic_disable) + funcs->atomic_disable(encoder, old_state); + else if (new_conn_state->crtc && funcs->prepare) funcs->prepare(encoder); else if (funcs->disable) funcs->disable(encoder); @@ -1309,7 +1311,9 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, drm_bridge_pre_enable(encoder->bridge); if (funcs) { - if (funcs->enable) + if (funcs->atomic_enable) + funcs->atomic_enable(encoder, old_state); + else if (funcs->enable) funcs->enable(encoder); else if (funcs->commit) funcs->commit(encoder); diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index 8f3602811eb5..aa509c107083 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -675,6 +675,51 @@ struct drm_encoder_helper_funcs { enum drm_connector_status (*detect)(struct drm_encoder *encoder, struct drm_connector *connector); + /** + * @atomic_disable: + * + * This callback should be used to disable the encoder. With the atomic + * drivers it is called before this encoder's CRTC has been shut off + * using their own &drm_crtc_helper_funcs.atomic_disable hook. If that + * sequence is too simple drivers can just add their own driver private + * encoder hooks and call them from CRTC's callback by looping over all + * encoders connected to it using for_each_encoder_on_crtc(). + * + * This callback is a variant of @disable that provides the atomic state + * to the driver. It takes priority over @disable during atomic commits. + * + * This hook is used only by atomic helpers. Atomic drivers don't need + * to implement it if there's no need to disable anything at the encoder + * level. To ensure that runtime PM handling (using either DPMS or the + * new "ACTIVE" property) works @atomic_disable must be the inverse of + * @atomic_enable. + */ + void (*atomic_disable)(struct drm_encoder *encoder, + struct drm_atomic_state *state); + + /** + * @atomic_enable: + * + * This callback should be used to enable the encoder. It is called + * after this encoder's CRTC has been enabled using their own + * &drm_crtc_helper_funcs.atomic_enable hook. If that sequence is + * too simple drivers can just add their own driver private encoder + * hooks and call them from CRTC's callback by looping over all encoders + * connected to it using for_each_encoder_on_crtc(). + * + * This callback is a variant of @enable that provides the atomic state + * to the driver. It is called in place of @enable during atomic + * commits. + * + * This hook is used only by atomic helpers, for symmetry with @disable. + * Atomic drivers don't need to implement it if there's no need to + * enable anything at the encoder level. To ensure that runtime PM + * handling (using either DPMS or the new "ACTIVE" property) works + * @enable must be the inverse of @disable for atomic drivers. + */ + void (*atomic_enable)(struct drm_encoder *encoder, + struct drm_atomic_state *state); + /** * @disable: * @@ -691,6 +736,9 @@ struct drm_encoder_helper_funcs { * handling (using either DPMS or the new "ACTIVE" property) works * @disable must be the inverse of @enable for atomic drivers. * + * For atomic drivers also consider @atomic_disable and save yourself + * from having to read the NOTE below! + * * NOTE: * * With legacy CRTC helpers there's a big semantic difference between