From patchwork Wed Nov 2 18:07:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13028743 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 177EEC43219 for ; Wed, 2 Nov 2022 18:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbiKBSHL (ORCPT ); Wed, 2 Nov 2022 14:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbiKBSHK (ORCPT ); Wed, 2 Nov 2022 14:07:10 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 519BA23BF8 for ; Wed, 2 Nov 2022 11:07:09 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id t10so2437008ljj.0 for ; Wed, 02 Nov 2022 11:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/zQozVl2HAGAn3My7u0ClWj7r5VwxG7XjUAjm2DzSHA=; b=yNFT78R6jUf4odwN4fOLdPnR3jqScnZmrHHxBcb8tvCfWVowil5fAX181SBFAuq5sy F1HNTPYtKGKnkU9I+7Z6p0VFuuUuEFU+V3YRR0a1Pu5dbN42W7V/CLLIeFJQAdZTuFhd Lx/bS/4GuWX5Rf6h3HU96F2ZBYK9knVQyZQXNoP52UHKKDpmkB5gWhhV6/eu+Vq+txLk GWjtYuB7qJSLQBOKXJc+IrHXzo8G5eaZte4AkykQrSRus3EhJQfS7hVpeSUUGqJNKlEx xy1aYDw1z++kkISNNOVQlXZijyH7JM7ronJsulgrEPpu+casFreo2dpyeJoHv0P57rpJ wSRg== 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=/zQozVl2HAGAn3My7u0ClWj7r5VwxG7XjUAjm2DzSHA=; b=J0qilEn7U66gYM/TivZH/TBWz7b+nZNsFGTMSa5xE/K1dLnnpWqORJwb6pG3Q0O5Cj L87qbWwHsx8oQo2pMy6XtajlI/8efTeQs30/Kn6lu1T0bzvk4OnRKGuvnPP6eog9G4T2 +6Bctce6S9eEtvkyC+8L+Rrw7yhY8IeOQVaHUG1MHt7s41Putw7d5fmQwxxOQIrVY7W9 GvOLAQIiK7tpy2TCB2NyKPHI0+cVBakGM1WtELSfLTkU4XfKEY81wm5azo/TlMyp/beE Acy/NzWv2Lx+wJDa8OhXBBqz9VzeOXCJB648IpYzencmLChJ/HG97apiDcUajkwZT+Wi pdLA== X-Gm-Message-State: ACrzQf2PSBkJgLIslgZCwuR38kpBQ7apbBHHSYCy5QRCHHm6TZMfQvE6 rmDH2m0CnUYkFab3atvTsl996A== X-Google-Smtp-Source: AMsMyM7OUsAVZk+yxxSO7NSMN9dJ3hYR1adlrIR6L7lRTjEYtcDDrXn2OJsFtXpfh8DXNQH/0CFqCg== X-Received: by 2002:a05:651c:1241:b0:261:9313:9cb9 with SMTP id h1-20020a05651c124100b0026193139cb9mr9965492ljh.213.1667412427676; Wed, 02 Nov 2022 11:07:07 -0700 (PDT) Received: from eriador.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id r15-20020ac24d0f000000b00485caa0f5dfsm2085232lfi.44.2022.11.02.11.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:07:07 -0700 (PDT) From: Dmitry Baryshkov To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Laurentiu Palcu , Lucas Stach , Philipp Zabel , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rob Clark , Sean Paul , Abhinav Kumar , Tomi Valkeinen Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v3 2/7] drm/probe-helper: enable and disable HPD on connectors Date: Wed, 2 Nov 2022 21:07:00 +0300 Message-Id: <20221102180705.459294-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221102180705.459294-1-dmitry.baryshkov@linaro.org> References: <20221102180705.459294-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Introduce two drm_connector_helper_funcs: enable_hpd() and disable_hpd(). They are called by drm_kms_helper_poll_enable() and drm_kms_helper_poll_disable() (and thus drm_kms_helper_poll_init() and drm_kms_helper_poll_fini()) respectively. This allows DRM drivers to rely on drm_kms_helper_poll for enabling and disabling HPD detection rather than doing that manually. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_probe_helper.c | 19 +++++++++++++++++++ include/drm/drm_modeset_helper_vtables.h | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index f97fda3b1d34..a7b4590d8ec1 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -251,6 +251,12 @@ void drm_kms_helper_poll_enable(struct drm_device *dev) drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { + const struct drm_connector_helper_funcs *funcs = + connector->helper_private; + + if (funcs && funcs->enable_hpd) + funcs->enable_hpd(connector); + if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT)) poll = true; @@ -805,12 +811,25 @@ EXPORT_SYMBOL(drm_kms_helper_is_poll_worker); static void drm_kms_helper_poll_disable_fini(struct drm_device *dev, bool fini) { + struct drm_connector *connector; + struct drm_connector_list_iter conn_iter; + if (!dev->mode_config.poll_enabled) return; if (fini) dev->mode_config.poll_enabled = false; + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + const struct drm_connector_helper_funcs *funcs = + connector->helper_private; + + if (funcs && funcs->disable_hpd) + funcs->disable_hpd(connector); + } + drm_connector_list_iter_end(&conn_iter); + cancel_delayed_work_sync(&dev->mode_config.output_poll_work); } diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index fafa70ac1337..7aa1f01223f9 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -1143,6 +1143,28 @@ struct drm_connector_helper_funcs { */ void (*cleanup_writeback_job)(struct drm_writeback_connector *connector, struct drm_writeback_job *job); + + /** + * @enable_hpd: + * + * Enable hot-plug detection for the connector. + * + * This operation is optional. + * + * This callback is used by the drm_kms_helper_poll_enable() helpers. + */ + void (*enable_hpd)(struct drm_connector *connector); + + /** + * @disable_hpd: + * + * Disable hot-plug detection for the connector. + * + * This operation is optional. + * + * This callback is used by the drm_kms_helper_poll_disable() helpers. + */ + void (*disable_hpd)(struct drm_connector *connector); }; /**