From: Jani Nikula <jani.nikula@linux.intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
airlied@redhat.com, kuohsiang_chou@aspeedtech.com,
airlied@linux.ie, daniel@ffwll.ch,
maarten.lankhorst@linux.intel.com, mripard@kernel.org
Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: [PATCH v2 3/5] drm/ast: Support output polling
Date: Tue, 07 Jun 2022 13:03:40 +0300 [thread overview]
Message-ID: <87pmjkpz7n.fsf@intel.com> (raw)
In-Reply-To: <20220531111502.4470-4-tzimmermann@suse.de>
On Tue, 31 May 2022, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Enable output polling for all connectors. VGA always uses EDID for this. As
> there's currently no interrupt handling for the ast devices, we have to use
> that trick for the various DP and DVI ports as well.
In general, please don't add new helper functions under "drm/ast"
subject prefix. These will go under the radar. I only stumbled on this
by accident.
Please don't add new helper functions around get_modes and EDID
reading. I've been putting a lot of effort into changing how EDID will
be handled going forward, and this will just make it harder. See
e.g. [1], though there are pending review comments.
Please don't use connector->edid_blob_ptr for basically anything in the
drivers, or for logic regarding detection. It's way too overloaded
already, and difficult to untangle.
BR,
Jani.
[1] https://patchwork.freedesktop.org/series/104309/
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/ast/ast_mode.c | 14 ++++++++----
> drivers/gpu/drm/drm_probe_helper.c | 35 ++++++++++++++++++++++++++++++
> include/drm/drm_probe_helper.h | 3 +++
> 3 files changed, 48 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 4ff8ec1c8931..bbc566c4c768 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1319,6 +1319,7 @@ static int ast_vga_connector_helper_get_modes(struct drm_connector *connector)
>
> static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = {
> .get_modes = ast_vga_connector_helper_get_modes,
> + .detect_ctx = drm_connector_helper_detect_ctx_from_edid,
> };
>
> static const struct drm_connector_funcs ast_vga_connector_funcs = {
> @@ -1354,7 +1355,7 @@ static int ast_vga_connector_init(struct drm_device *dev,
> connector->interlace_allowed = 0;
> connector->doublescan_allowed = 0;
>
> - connector->polled = DRM_CONNECTOR_POLL_CONNECT;
> + connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
>
> return 0;
> }
> @@ -1390,6 +1391,7 @@ static int ast_vga_output_init(struct ast_private *ast)
>
> static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = {
> .get_modes = ast_vga_connector_helper_get_modes, // same as VGA connector
> + .detect_ctx = drm_connector_helper_detect_ctx_from_edid,
> };
>
> static const struct drm_connector_funcs ast_sil164_connector_funcs = {
> @@ -1425,7 +1427,7 @@ static int ast_sil164_connector_init(struct drm_device *dev,
> connector->interlace_allowed = 0;
> connector->doublescan_allowed = 0;
>
> - connector->polled = DRM_CONNECTOR_POLL_CONNECT;
> + connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
>
> return 0;
> }
> @@ -1488,6 +1490,7 @@ static int ast_dp501_connector_helper_get_modes(struct drm_connector *connector)
>
> static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = {
> .get_modes = ast_dp501_connector_helper_get_modes,
> + .detect_ctx = drm_connector_helper_detect_ctx_from_edid,
> };
>
> static const struct drm_connector_funcs ast_dp501_connector_funcs = {
> @@ -1512,7 +1515,7 @@ static int ast_dp501_connector_init(struct drm_device *dev, struct drm_connector
> connector->interlace_allowed = 0;
> connector->doublescan_allowed = 0;
>
> - connector->polled = DRM_CONNECTOR_POLL_CONNECT;
> + connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
>
> return 0;
> }
> @@ -1575,6 +1578,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>
> static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs = {
> .get_modes = ast_astdp_connector_helper_get_modes,
> + .detect_ctx = drm_connector_helper_detect_ctx_from_edid,
> };
>
> static const struct drm_connector_funcs ast_astdp_connector_funcs = {
> @@ -1599,7 +1603,7 @@ static int ast_astdp_connector_init(struct drm_device *dev, struct drm_connector
> connector->interlace_allowed = 0;
> connector->doublescan_allowed = 0;
>
> - connector->polled = DRM_CONNECTOR_POLL_CONNECT;
> + connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
>
> return 0;
> }
> @@ -1709,5 +1713,7 @@ int ast_mode_config_init(struct ast_private *ast)
>
> drm_mode_config_reset(dev);
>
> + drm_kms_helper_poll_init(dev);
> +
> return 0;
> }
> diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
> index 425f56280d51..4440a7b6b240 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -1031,3 +1031,38 @@ int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector)
> return count;
> }
> EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc);
> +
> +/**
> + * drm_connector_helper_detect_ctx_from_edid -
> + * Updates the connector's status by reading EDID data
> + * @connector: The connector.
> + * @ctx: The lock-acquisition context.
> + * @force: True if the operation was requested by userspace, false otherwise.
> + *
> + * Returns:
> + * The connector's status as enum drm_connector_status.
> + *
> + * Updates the connector's EDID property by reading the display modes
> + * and returns the connector's status. If the EDID property is set, the
> + * connector is assumed to be connected; and disconnected otherwise.
> + * If the get_modes helper is missing, the default status is 'unknown'.
> + *
> + * See struct drm_connector_helper_funcs.detect_ctx.
> + */
> +int drm_connector_helper_detect_ctx_from_edid(struct drm_connector *connector,
> + struct drm_modeset_acquire_ctx *ctx,
> + bool force)
> +{
> + const struct drm_connector_helper_funcs *helper_funcs = connector->helper_private;
> +
> + if (!helper_funcs || !helper_funcs->get_modes)
> + return connector_status_unknown;
> +
> + helper_funcs->get_modes(connector);
> +
> + if (!connector->edid_blob_ptr)
> + return connector_status_disconnected;
> +
> + return connector_status_connected;
> +}
> +EXPORT_SYMBOL(drm_connector_helper_detect_ctx_from_edid);
> diff --git a/include/drm/drm_probe_helper.h b/include/drm/drm_probe_helper.h
> index c80cab7a53b7..7408cf010794 100644
> --- a/include/drm/drm_probe_helper.h
> +++ b/include/drm/drm_probe_helper.h
> @@ -27,5 +27,8 @@ void drm_kms_helper_poll_enable(struct drm_device *dev);
> bool drm_kms_helper_is_poll_worker(void);
>
> int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector);
> +int drm_connector_helper_detect_ctx_from_edid(struct drm_connector *connector,
> + struct drm_modeset_acquire_ctx *ctx,
> + bool force);
>
> #endif
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2022-06-07 10:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 11:14 [PATCH v2 0/5] drm/ast: Connector cleanups and polling Thomas Zimmermann
2022-05-31 11:14 ` [PATCH v2 1/5] drm/ast: Support multiple outputs Thomas Zimmermann
2022-06-02 7:24 ` Patrik Jakobsson
2022-06-02 11:01 ` Thomas Zimmermann
2022-05-31 11:14 ` [PATCH v2 2/5] drm/ast: Fix updating the connector's EDID property Thomas Zimmermann
2022-06-02 7:24 ` Patrik Jakobsson
2022-06-07 8:13 ` Thomas Zimmermann
2022-06-07 9:08 ` Patrik Jakobsson
2022-05-31 11:15 ` [PATCH v2 3/5] drm/ast: Support output polling Thomas Zimmermann
2022-06-02 7:25 ` Patrik Jakobsson
2022-06-02 11:00 ` Thomas Zimmermann
2022-06-07 10:03 ` Jani Nikula [this message]
2022-06-07 10:50 ` Thomas Zimmermann
2022-05-31 11:15 ` [PATCH v2 4/5] drm/ast: Fail probing if DCC channel could not be initialized Thomas Zimmermann
2022-06-02 7:25 ` Patrik Jakobsson
2022-06-02 7:42 ` Patrik Jakobsson
2022-06-02 9:32 ` Thomas Zimmermann
2022-06-02 10:34 ` Patrik Jakobsson
2022-05-31 11:15 ` [PATCH v2 5/5] drm/ast: Remove struct ast_{vga,sil164}_connector Thomas Zimmermann
2022-06-02 7:25 ` Patrik Jakobsson
2022-05-31 11:16 ` [PATCH v2 0/5] drm/ast: Connector cleanups and polling Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pmjkpz7n.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@linux.ie \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kuohsiang_chou@aspeedtech.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).