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: 13028733 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CB46EC433FE for ; Wed, 2 Nov 2022 18:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cQKwZz/YWKvVwqe5RWyobTTd+aAh7nLSBIja6b1zK60=; b=koXnwkxlNQ0eFS Rr6bzfp0UKQwaolAZW3xxsWu8EyNkyjMLrYbwMN+XynuxmvkmK72aTn0QPPcxyqY4e0Wed1nHXbYb m5vjtSNrNxMPCznMHrjaOKTfDSTTyp0XZlJrTH0rNMwthdjt5MH2Rt34/bLW+STmunmQCZHm+kTjp 92z1QbjkWpkVFxNEG1aoptJJQWfNoKwmHgts6EK0eX4gpoSIDggUcGhJFJrPiOuP2zEKg0Xo5it5z fIbVxNpz23DQlhDU6Sm5KNAeJaHiZGlEmEGi94sLjka5CQzYsDKfV24DT8ZWt0O02oTDKprUu9MKV fJQ4ZP630aOplBQUlR0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqI99-00Co3v-NR; Wed, 02 Nov 2022 18:07:27 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqI8s-00Cnqy-0N for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:07:12 +0000 Received: by mail-lj1-x22e.google.com with SMTP id k19so25755729lji.2 for ; Wed, 02 Nov 2022 11:07:08 -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=ToH+iFHU6KU7QMGBMVKM4nbrPSmp373AhUuR7229qP3rDDSeXrf+u0Sxp1QPHfkGCK IK2g7IZ9WveKnsSfWNhchaqd2mNC0BLzAbQ8Dgm2If0cOfjDjFx3FQ7+/8k4Ns7v/033 qxUyvwmuMTbwKKtUCbeFo5Bs6R1FjSHXs/jGYdaapSa1E+4Ly+PdaG9jmH/aOcirfwHf 83EQzKrO1YjLy/VAN2IxNrdsXtlEiGHkn0QZ68pTyYH+Q5Gq4u6QrL3PsydC8dgyr0Nl +DskmqVSO5ixtPRr17oB+HndaI6hh71ZOBdZF4IRKfmWtYde5rzl643G9OvCyvEIglpr flOw== X-Gm-Message-State: ACrzQf0RE9aCT+Sgggqu3VOoWes/3e8KxBjq/q/ttefv+2MU2mlxh3NF EGnZf3RHPGrvwr5RmrBLumam/Q== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221102_110710_362399_BD5F14ED X-CRM114-Status: GOOD ( 14.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); }; /**