Skip to content

Commit 6fe2ce0

Browse files
committed
drm: uevent for connector status change
DRM API for generating uevent for a status changes of connector's property. This uevent will have following details related to the status change: HOTPLUG=1, CONNECTOR=<connector_id> and PROPERTY=<property_id> Pekka have completed the Weston DRM-backend review in https://gitlab.freedesktop.org/wayland/weston/merge_requests/48 and the UAPI for HDCP 2.2 looks good. The userspace is accepted in Weston. v2: Minor fixes at KDoc comments [Daniel] v3: Check the property is really attached with connector [Daniel] v4: Typos and string length suggestions are addressed [Sean] Signed-off-by: Ramalingam C <ramalingam.c@intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Sean Paul <sean@poorly.run> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/320961/?series=57232&rev=14
1 parent d456512 commit 6fe2ce0

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎drivers/gpu/drm/drm_sysfs.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <drm/drm_sysfs.h>
2828

2929
#include "drm_internal.h"
30+
#include "drm_crtc_internal.h"
3031

3132
#define to_drm_minor(d) dev_get_drvdata(d)
3233
#define to_drm_connector(d) dev_get_drvdata(d)
@@ -333,6 +334,9 @@ void drm_sysfs_lease_event(struct drm_device *dev)
333334
* Send a uevent for the DRM device specified by @dev. Currently we only
334335
* set HOTPLUG=1 in the uevent environment, but this could be expanded to
335336
* deal with other types of events.
337+
*
338+
* Any new uapi should be using the drm_sysfs_connector_status_event()
339+
* for uevents on connector status change.
336340
*/
337341
void drm_sysfs_hotplug_event(struct drm_device *dev)
338342
{
@@ -345,6 +349,37 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
345349
}
346350
EXPORT_SYMBOL(drm_sysfs_hotplug_event);
347351

352+
/**
353+
* drm_sysfs_connector_status_event - generate a DRM uevent for connector
354+
* property status change
355+
* @connector: connector on which property status changed
356+
* @property: connector property whose status changed.
357+
*
358+
* Send a uevent for the DRM device specified by @dev. Currently we
359+
* set HOTPLUG=1 and connector id along with the attached property id
360+
* related to the status change.
361+
*/
362+
void drm_sysfs_connector_status_event(struct drm_connector *connector,
363+
struct drm_property *property)
364+
{
365+
struct drm_device *dev = connector->dev;
366+
char hotplug_str[] = "HOTPLUG=1", conn_id[21], prop_id[21];
367+
char *envp[4] = { hotplug_str, conn_id, prop_id, NULL };
368+
369+
WARN_ON(!drm_mode_obj_find_prop_id(&connector->base,
370+
property->base.id));
371+
372+
snprintf(conn_id, ARRAY_SIZE(conn_id),
373+
"CONNECTOR=%u", connector->base.id);
374+
snprintf(prop_id, ARRAY_SIZE(prop_id),
375+
"PROPERTY=%u", property->base.id);
376+
377+
DRM_DEBUG("generating connector status event\n");
378+
379+
kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
380+
}
381+
EXPORT_SYMBOL(drm_sysfs_connector_status_event);
382+
348383
static void drm_sysfs_release(struct device *dev)
349384
{
350385
kfree(dev);

‎include/drm/drm_sysfs.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
struct drm_device;
66
struct device;
7+
struct drm_connector;
8+
struct drm_property;
79

810
int drm_class_device_register(struct device *dev);
911
void drm_class_device_unregister(struct device *dev);
1012

1113
void drm_sysfs_hotplug_event(struct drm_device *dev);
12-
14+
void drm_sysfs_connector_status_event(struct drm_connector *connector,
15+
struct drm_property *property);
1316
#endif

0 commit comments

Comments
 (0)