* [PATCH 1/4] drm/sysfs: introduce drm_sysfs_connector_hotplug_event
@ 2021-06-09 10:39 ` Simon Ser
0 siblings, 0 replies; 4+ messages in thread
From: Simon Ser @ 2021-06-09 10:39 UTC (permalink / raw)
To: dri-devel, amd-gfx
Cc: pekka.paalanen, michel, daniel, daniel, alexander.deucher,
harry.wentland
This function sends a hotplug uevent with a CONNECTOR property.
Signed-off-by: Simon Ser <contact@emersion.fr>
---
drivers/gpu/drm/drm_sysfs.c | 25 +++++++++++++++++++++++++
include/drm/drm_sysfs.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 968a9560b4aa..6b52a53c0c3e 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -343,6 +343,31 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
}
EXPORT_SYMBOL(drm_sysfs_hotplug_event);
+/**
+ * drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
+ * change
+ * @connector: connector which has changed
+ *
+ * Send a uevent for the DRM connector specified by @connector. This will send
+ * a uevent with the properties HOTPLUG=1 and CONNECTOR.
+ */
+void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)
+{
+ struct drm_device *dev = connector->dev;
+ char hotplug_str[] = "HOTPLUG=1", conn_id[21];
+ char *envp[] = { hotplug_str, conn_id, NULL };
+
+ snprintf(conn_id, ARRAY_SIZE(conn_id),
+ "CONNECTOR=%u", connector->base.id);
+
+ drm_dbg(connector->dev,
+ "generating hotplug event for [CONNECTOR:%d:%s]\n",
+ connector->base.id, connector->name);
+
+ kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_connector_hotplug_event);
+
/**
* drm_sysfs_connector_status_event - generate a DRM uevent for connector
* property status change
diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
index d454ef617b2c..6273cac44e47 100644
--- a/include/drm/drm_sysfs.h
+++ b/include/drm/drm_sysfs.h
@@ -11,6 +11,7 @@ int drm_class_device_register(struct device *dev);
void drm_class_device_unregister(struct device *dev);
void drm_sysfs_hotplug_event(struct drm_device *dev);
+void drm_sysfs_connector_hotplug_event(struct drm_connector *connector);
void drm_sysfs_connector_status_event(struct drm_connector *connector,
struct drm_property *property);
#endif
--
2.31.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/4] drm/sysfs: introduce drm_sysfs_connector_hotplug_event
@ 2021-06-09 10:39 ` Simon Ser
0 siblings, 0 replies; 4+ messages in thread
From: Simon Ser @ 2021-06-09 10:39 UTC (permalink / raw)
To: dri-devel, amd-gfx; +Cc: pekka.paalanen, michel, alexander.deucher
This function sends a hotplug uevent with a CONNECTOR property.
Signed-off-by: Simon Ser <contact@emersion.fr>
---
drivers/gpu/drm/drm_sysfs.c | 25 +++++++++++++++++++++++++
include/drm/drm_sysfs.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 968a9560b4aa..6b52a53c0c3e 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -343,6 +343,31 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
}
EXPORT_SYMBOL(drm_sysfs_hotplug_event);
+/**
+ * drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
+ * change
+ * @connector: connector which has changed
+ *
+ * Send a uevent for the DRM connector specified by @connector. This will send
+ * a uevent with the properties HOTPLUG=1 and CONNECTOR.
+ */
+void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)
+{
+ struct drm_device *dev = connector->dev;
+ char hotplug_str[] = "HOTPLUG=1", conn_id[21];
+ char *envp[] = { hotplug_str, conn_id, NULL };
+
+ snprintf(conn_id, ARRAY_SIZE(conn_id),
+ "CONNECTOR=%u", connector->base.id);
+
+ drm_dbg(connector->dev,
+ "generating hotplug event for [CONNECTOR:%d:%s]\n",
+ connector->base.id, connector->name);
+
+ kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_connector_hotplug_event);
+
/**
* drm_sysfs_connector_status_event - generate a DRM uevent for connector
* property status change
diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
index d454ef617b2c..6273cac44e47 100644
--- a/include/drm/drm_sysfs.h
+++ b/include/drm/drm_sysfs.h
@@ -11,6 +11,7 @@ int drm_class_device_register(struct device *dev);
void drm_class_device_unregister(struct device *dev);
void drm_sysfs_hotplug_event(struct drm_device *dev);
+void drm_sysfs_connector_hotplug_event(struct drm_connector *connector);
void drm_sysfs_connector_status_event(struct drm_connector *connector,
struct drm_property *property);
#endif
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] drm/sysfs: introduce drm_sysfs_connector_hotplug_event
2021-06-09 10:39 ` Simon Ser
@ 2021-06-09 11:16 ` Jani Nikula
-1 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2021-06-09 11:16 UTC (permalink / raw)
To: Simon Ser, dri-devel, amd-gfx; +Cc: alexander.deucher, michel, pekka.paalanen
On Wed, 09 Jun 2021, Simon Ser <contact@emersion.fr> wrote:
> This function sends a hotplug uevent with a CONNECTOR property.
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> ---
> drivers/gpu/drm/drm_sysfs.c | 25 +++++++++++++++++++++++++
> include/drm/drm_sysfs.h | 1 +
> 2 files changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 968a9560b4aa..6b52a53c0c3e 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -343,6 +343,31 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
> }
> EXPORT_SYMBOL(drm_sysfs_hotplug_event);
>
> +/**
> + * drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
> + * change
> + * @connector: connector which has changed
> + *
> + * Send a uevent for the DRM connector specified by @connector. This will send
> + * a uevent with the properties HOTPLUG=1 and CONNECTOR.
> + */
> +void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)
> +{
> + struct drm_device *dev = connector->dev;
> + char hotplug_str[] = "HOTPLUG=1", conn_id[21];
> + char *envp[] = { hotplug_str, conn_id, NULL };
> +
> + snprintf(conn_id, ARRAY_SIZE(conn_id),
Semantically should be sizeof(conn_id) though the result is the same. (I
guess this is copy-paste from drm_sysfs_connector_status_event().)
> + "CONNECTOR=%u", connector->base.id);
> +
> + drm_dbg(connector->dev,
drm_dbg_kms?
> + "generating hotplug event for [CONNECTOR:%d:%s]\n",
> + connector->base.id, connector->name);
A matter of taste, but seems like in a lot of places we tend to stick
the [CONNECTOR:%d:%s] at the beginning of the string. So if you have
back-to-back messages related to the same connector, they get aligned
and are easy to spot.
BR,
Jani.
> +
> + kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
> +}
> +EXPORT_SYMBOL(drm_sysfs_connector_hotplug_event);
> +
> /**
> * drm_sysfs_connector_status_event - generate a DRM uevent for connector
> * property status change
> diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
> index d454ef617b2c..6273cac44e47 100644
> --- a/include/drm/drm_sysfs.h
> +++ b/include/drm/drm_sysfs.h
> @@ -11,6 +11,7 @@ int drm_class_device_register(struct device *dev);
> void drm_class_device_unregister(struct device *dev);
>
> void drm_sysfs_hotplug_event(struct drm_device *dev);
> +void drm_sysfs_connector_hotplug_event(struct drm_connector *connector);
> void drm_sysfs_connector_status_event(struct drm_connector *connector,
> struct drm_property *property);
> #endif
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/4] drm/sysfs: introduce drm_sysfs_connector_hotplug_event
@ 2021-06-09 11:16 ` Jani Nikula
0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2021-06-09 11:16 UTC (permalink / raw)
To: Simon Ser, dri-devel, amd-gfx; +Cc: alexander.deucher, michel, pekka.paalanen
On Wed, 09 Jun 2021, Simon Ser <contact@emersion.fr> wrote:
> This function sends a hotplug uevent with a CONNECTOR property.
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> ---
> drivers/gpu/drm/drm_sysfs.c | 25 +++++++++++++++++++++++++
> include/drm/drm_sysfs.h | 1 +
> 2 files changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 968a9560b4aa..6b52a53c0c3e 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -343,6 +343,31 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
> }
> EXPORT_SYMBOL(drm_sysfs_hotplug_event);
>
> +/**
> + * drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
> + * change
> + * @connector: connector which has changed
> + *
> + * Send a uevent for the DRM connector specified by @connector. This will send
> + * a uevent with the properties HOTPLUG=1 and CONNECTOR.
> + */
> +void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)
> +{
> + struct drm_device *dev = connector->dev;
> + char hotplug_str[] = "HOTPLUG=1", conn_id[21];
> + char *envp[] = { hotplug_str, conn_id, NULL };
> +
> + snprintf(conn_id, ARRAY_SIZE(conn_id),
Semantically should be sizeof(conn_id) though the result is the same. (I
guess this is copy-paste from drm_sysfs_connector_status_event().)
> + "CONNECTOR=%u", connector->base.id);
> +
> + drm_dbg(connector->dev,
drm_dbg_kms?
> + "generating hotplug event for [CONNECTOR:%d:%s]\n",
> + connector->base.id, connector->name);
A matter of taste, but seems like in a lot of places we tend to stick
the [CONNECTOR:%d:%s] at the beginning of the string. So if you have
back-to-back messages related to the same connector, they get aligned
and are easy to spot.
BR,
Jani.
> +
> + kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
> +}
> +EXPORT_SYMBOL(drm_sysfs_connector_hotplug_event);
> +
> /**
> * drm_sysfs_connector_status_event - generate a DRM uevent for connector
> * property status change
> diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
> index d454ef617b2c..6273cac44e47 100644
> --- a/include/drm/drm_sysfs.h
> +++ b/include/drm/drm_sysfs.h
> @@ -11,6 +11,7 @@ int drm_class_device_register(struct device *dev);
> void drm_class_device_unregister(struct device *dev);
>
> void drm_sysfs_hotplug_event(struct drm_device *dev);
> +void drm_sysfs_connector_hotplug_event(struct drm_connector *connector);
> void drm_sysfs_connector_status_event(struct drm_connector *connector,
> struct drm_property *property);
> #endif
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-09 11:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-09 10:39 [PATCH 1/4] drm/sysfs: introduce drm_sysfs_connector_hotplug_event Simon Ser
2021-06-09 10:39 ` Simon Ser
2021-06-09 11:16 ` Jani Nikula
2021-06-09 11:16 ` Jani Nikula
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.