Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5329548yba; Wed, 8 May 2019 11:25:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkLUdABr4fRS7aaz+Fmx++jnKYrBQwuyMmBaT77ujvJOHHm3DjwvS7+sr62qsKmHeIkKGg X-Received: by 2002:a63:5041:: with SMTP id q1mr49365016pgl.386.1557339946047; Wed, 08 May 2019 11:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557339946; cv=none; d=google.com; s=arc-20160816; b=nb4iUhW8Exg7DjgmKSu5vboK6F5wy4Gz+TLXAjdkaE8EhveRpgKYYwmVkW/QeHc8Gt MMVcqvUTF7LlP3iBgdA+u2umJSCMpAbLAxqNPLGdBocqsSd/pLjr1qLxM+N4aOMculgP dutKl8dTczHXLUdbj896FOEdIk3pbzqjePAtwYOoKw7ee+E9mqf1OoG2/R5ISi0FzOdO 0jcyydY1WzFdz+I4O2jj2PQEOQAqoCfhOx/md2w86lAIxE8jfC+mCUKJ/Usv0jakCs0L TavJGJ8LCHcK5K8CWNcg4pZBxD7wm3CwUlFHdnGmb8sS1ur3GUjRnzhsIkZkvDEUpf9l dqRw== 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:cc:to:from :dkim-signature; bh=ATJVqwKnuJNVrskurSmrA7uNnNg1EGswZWkepzxe4V0=; b=JgAa+omRYSDj4kO1hhQMvJKbUYOelHft4Y3zFHlrjFOExWKNWJI8U7CdsOasYCEV25 xlcaKYn96DKjLH3MU4eOd9QNkDhX0+oyxSzVy1sMr3A/H+FloqlzWb7XAerdWJoD52+a ThIBhqANFsIIxwXuuPb7tfPQ9epaX6ExX3QEVwyC9B5HnA85hz276N4IQOmYETdBJU6q UtRUNlmr0HSgjAabXbfEsBIkvtyHcBcGvtM6ecGmFig6VPUjlhG3Xj8vGPsq5QPV9TPK hT2bk1SKFyniVyqghGg2F1tM1XoZFe/n+KQ7Ny5OmQxLyXDaAGQSTgxBqfXtipXMWuM/ 1tdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=BiI93sTP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si22136312pgl.539.2019.05.08.11.25.27; Wed, 08 May 2019 11:25:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=BiI93sTP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727635AbfEHQJ0 (ORCPT + 99 others); Wed, 8 May 2019 12:09:26 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35589 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727054AbfEHQJZ (ORCPT ); Wed, 8 May 2019 12:09:25 -0400 Received: by mail-qt1-f196.google.com with SMTP id d20so6281307qto.2 for ; Wed, 08 May 2019 09:09:25 -0700 (PDT) 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-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=h6+hrhSUeS9D27kGwkak4PfFfSWAEFLY7mKAuTFIknNqZ+235NfK2o/aegWyjlSXhr 76Qk7miro2dqFaexDiXuB+cvnP46uYvMhxyY/ovlGMMr3OtIu0hAFv4PpaGdZYAmR2/M KN9Rz0cC7JyoeudHrHKX7XyvtQqPL8ipZJRCDrqK1qYOa5tvOJGC9idvjSIwdf1/9MBI vTOAnRoLzI3RpugvYsOUp7zvKw/4olcQXepLHqQeCVSS9fXCWGv35ODShke6jFWdy1w/ ZBTJG1Htdmv6N95SWFv+ry+t1YV1ovZW9p3dGxkLrtLFne0c772A8fW07TKiHRnsoGwn Uqaw== X-Gm-Message-State: APjAAAWMVkNFpG7zLRc0g5Cd2fgLr97eBqo6UxC0kV3IroeU0IOM1nD5 dDdnjZ5Vyh0bslyLpbvSBX0kXg== 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 Cc: Sean Paul , Daniel Vetter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , linux-kernel@vger.kernel.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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- Sean Paul, Software Engineer, Google / Chromium OS