From patchwork Mon Oct 24 15:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13017740 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 9234AECAAA1 for ; Mon, 24 Oct 2022 15:43:41 +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=JeFrgn+oNUV9XA/Qww72DKx8E2k15+4OepSWXl/1YRk=; b=VzODVJ+/kxQQP3 2q8rssKEPmOnVczPweX3gzXve4qCT3ydeBGX+Nmg7ClS5eJgPF2Na6/GhTudVddmw0yzavGRdqWfU UXZE0Q/CiI/IYIQXdanLnOhGC3Vi6G/tIVsgO45+wsoLNDSwI1iJ5/6knEh5gKFJqNTV13frgxtMZ rQmoh5WfCpAoXAUi5xIZKEnswBgyVLc0GHCHrZ4WOQV/00uX1yrErDml1d3iOAj3QRHCL8tr8m2HL k0DJRJoZbiLbaNHZGxdCyaqSBxGBNGOAaAPy3loJp3Zu9ZpI7uPNsGF1ttrW3GwzW5Mbzb7Qtv/yz 6dKeb6mffMdBsNwMGmPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1omzau-0028bF-WC; Mon, 24 Oct 2022 15:42:29 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1omzY3-00272W-Fj for linux-arm-kernel@lists.infradead.org; Mon, 24 Oct 2022 15:39:33 +0000 Received: by mail-lj1-x22f.google.com with SMTP id z24so3302432ljn.4 for ; Mon, 24 Oct 2022 08:39:30 -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=VCo7VVHuBZW+OG9SunJbQgq/wFHseiwuFZsFQO3WoK8=; b=jbTsuMpSTlZUL62/fo5JZqCwVPNkW3xLmgH/tZ/cNPg5xLCNHLHOpAw9HGT6ESP6s6 b32vL0kKy1JoM4iPMcFn/MQT29nVDRBq787s6fVwBrKnou05GgLonXZ5lC0SUuDBZdSQ VtzoyZx9o5DpyTBUXP7B7OrwnDILVCBlzDoINX3HQ1MMTVVz5yGU4ZkNBode12YN68KL aKSTKB0Dj5rFzdXFUuHxAoy1s+T2YZqcgPVW3R9KiBoP32fV5mMGGHUr1BmTFw6J7/z/ yUgCDhPequlUBxPuedgc7fLYz9ZnKhmjc0dyCPUtPdZFTjNjXsj5YgvSLw2k9sXlI2Yz w3Rw== 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=VCo7VVHuBZW+OG9SunJbQgq/wFHseiwuFZsFQO3WoK8=; b=fpyFHUa25Lh0Sa9UHQc5eMQ3KyTW2WJ71zc1FxhzyFoTEMyud8PxW0Ee1WGnIJb3RK kcUngq4u9Q+4hEinxLCKVCTaTvn85L5FW7AQXoxxGaba6VYtVAQJMlov6xBRlyhSjKfN YRwKkt2d4VLySEcV4aIgpWNJ7sXe5/WDwinVygInir/rBHTKVrdfohYkxF1TkDXqGN5e 3rNdYkA/0Cg6ru60kc0r11jBoWkbjS3rtw2EGPAZc1D7M/osGwW5ab/TreC4tyYnwi2t s5MSaPH/kqoD9x3b4JBCr0YT0XRDIKRhlq1yq480Rbd7G8qBjkB7fbYgoaHtuS8caYOa 1vLQ== X-Gm-Message-State: ACrzQf1QfvFnZNzP3JPzxt53Zf1/ISvO6D2xf5shQk2g8ALG1OCzSO0o SfB4e5FbYEW4ee4XJBjC4SBdVA== X-Google-Smtp-Source: AMsMyM5Z9UayHdOtWdD5WFtJKLY7zt7l5GAE6lRLszfxe+uzm9UMm/n1wBg1DFfcJEV5C7u0Arnj/g== X-Received: by 2002:a2e:a1c9:0:b0:277:101f:e3b2 with SMTP id c9-20020a2ea1c9000000b00277101fe3b2mr1018524ljm.129.1666625969488; Mon, 24 Oct 2022 08:39:29 -0700 (PDT) Received: from eriador.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id f23-20020a19ae17000000b00497b198987bsm452181lfc.26.2022.10.24.08.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 08:39:29 -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 v2 2/7] drm/probe-helper: enable and disable HPD on connectors Date: Mon, 24 Oct 2022 18:39:21 +0300 Message-Id: <20221024153926.3222225-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221024153926.3222225-1-dmitry.baryshkov@linaro.org> References: <20221024153926.3222225-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-20221024_083931_591183_1608B6A9 X-CRM114-Status: GOOD ( 13.29 ) 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 Intruct 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 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); }; /**