drm/ast: Add detect function support
Subsystems (3)
PATCH 1/1 drm/ast: Add detect function support
From: Ainux <[email protected]>
The existence of the connector cannot be detected, so add the detect function to support.
--- drivers/gpu/drm/ast/ast_drv.c | 2 ++ drivers/gpu/drm/ast/ast_mode.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_drv.c +2 -0
@@ -128,6 +128,8 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)drm_fbdev_generic_setup (dev,32 ); +drm_kms_helper_poll_init (dev); +return 0 ; }
drivers/gpu/drm/ast/ast_mode.c +18 -1
@@ -1293,6 +1293,21 @@ static enum drm_mode_status ast_mode_valid(struct drm_connector *connector,return flags; } +static enum drm_connector_status ast_connector_detect (struct drm_connector + *connector,bool force) +{ +int r; +enum drm_connector_status ret = connector_status_connected; + + r =ast_get_modes (connector); +if (r) + ret = connector_status_connected; +else + ret = connector_status_disconnected; + +return ret; +} +static void ast_connector_destroy (struct drm_connector *connector) {struct ast_connector *ast_connector =to_ast_connector (connector);
@@ -1307,6 +1322,7 @@ static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {static const struct drm_connector_funcs ast_connector_funcs = { .reset = drm_atomic_helper_connector_reset, + .detect = ast_connector_detect, .fill_modes = drm_helper_probe_single_connector_modes, .destroy = ast_connector_destroy, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
@@ -1334,7 +1350,8 @@ static int ast_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 ;drm_connector_attach_encoder (connector, encoder);
Signature · 1 line
2.18.1
Thomas Zimmermann
maintainerHi,
thanks for the patch.
Am 25.05.21 um 03:55 schrieb [email protected]:
Quoted 16 lines
From: Ainux <[email protected]>
The existence of the connector cannot be detected, so add the detect function to support.
Signed-off-by Ainux <[email protected]>--- drivers/gpu/drm/ast/ast_drv.c | 2 ++ drivers/gpu/drm/ast/ast_mode.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)drivers/gpu/drm/ast/ast_drv.c +0
-0
drivers/gpu/drm/ast/ast_drv.c static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 132
Quoted 5 lines
drivers/gpu/drm/ast/ast_drv.c +2
-0@@ -128,6 +128,8 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)drm_fbdev_generic_setup (dev,32 ); +drm_kms_helper_poll_init (dev); +
I think this is too late. Rather put it at the end of ast_mode_config_init(). [1]
Quoted 14 lines
drivers/gpu/drm/ast/ast_drv.c +0
-0return 0 ; }drivers/gpu/drm/ast/ast_mode.c +3
-0@@ -1293,6 +1293,21 @@ static enum drm_mode_status ast_mode_valid(struct drm_connector *connector,return flags; } +static enum drm_connector_status ast_connector_detect (struct drm_connector + *connector,bool force) +{
drivers/gpu/drm/ast/ast_mode.c static enum drm_mode_status ast_mode_valid(struct drm_connector *connector, · line 1308
Quoted 10 lines
drivers/gpu/drm/ast/ast_mode.c +10
-0+int r; +enum drm_connector_status ret = connector_status_connected; + + r =ast_get_modes (connector); +if (r) + ret = connector_status_connected; +else + ret = connector_status_disconnected; + +return ret;
As a side note: VGA is not hotplug-able, but expected to always be connected. Ideally we could detect this, but it's unreliable AFAIK.
Rather use:
r = ast_get_modes()
if (r < 0)
return connector_status_disconnected
return connector_status_connected
So it's disconnected if there was an error in ast_get_modes().
Best regards
Thomas
[1] https://elixir.bootlin.com/linux/v5.12/source/drivers/gpu/drm/ast/ast_mode.c#L1171
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer