Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+39 -1
+35
drivers/gpu/drm/drm_sysfs.c
··· 27 27 #include <drm/drm_sysfs.h> 28 28 29 29 #include "drm_internal.h" 30 + #include "drm_crtc_internal.h" 30 31 31 32 #define to_drm_minor(d) dev_get_drvdata(d) 32 33 #define to_drm_connector(d) dev_get_drvdata(d) ··· 334 333 * Send a uevent for the DRM device specified by @dev. Currently we only 335 334 * set HOTPLUG=1 in the uevent environment, but this could be expanded to 336 335 * deal with other types of events. 336 + * 337 + * Any new uapi should be using the drm_sysfs_connector_status_event() 338 + * for uevents on connector status change. 337 339 */ 338 340 void drm_sysfs_hotplug_event(struct drm_device *dev) 339 341 { ··· 348 344 kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp); 349 345 } 350 346 EXPORT_SYMBOL(drm_sysfs_hotplug_event); 347 + 348 + /** 349 + * drm_sysfs_connector_status_event - generate a DRM uevent for connector 350 + * property status change 351 + * @connector: connector on which property status changed 352 + * @property: connector property whose status changed. 353 + * 354 + * Send a uevent for the DRM device specified by @dev. Currently we 355 + * set HOTPLUG=1 and connector id along with the attached property id 356 + * related to the status change. 357 + */ 358 + void drm_sysfs_connector_status_event(struct drm_connector *connector, 359 + struct drm_property *property) 360 + { 361 + struct drm_device *dev = connector->dev; 362 + char hotplug_str[] = "HOTPLUG=1", conn_id[21], prop_id[21]; 363 + char *envp[4] = { hotplug_str, conn_id, prop_id, NULL }; 364 + 365 + WARN_ON(!drm_mode_obj_find_prop_id(&connector->base, 366 + property->base.id)); 367 + 368 + snprintf(conn_id, ARRAY_SIZE(conn_id), 369 + "CONNECTOR=%u", connector->base.id); 370 + snprintf(prop_id, ARRAY_SIZE(prop_id), 371 + "PROPERTY=%u", property->base.id); 372 + 373 + DRM_DEBUG("generating connector status event\n"); 374 + 375 + kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp); 376 + } 377 + EXPORT_SYMBOL(drm_sysfs_connector_status_event); 351 378 352 379 static void drm_sysfs_release(struct device *dev) 353 380 {
+4 -1
include/drm/drm_sysfs.h
··· 4 4 5 5 struct drm_device; 6 6 struct device; 7 + struct drm_connector; 8 + struct drm_property; 7 9 8 10 int drm_class_device_register(struct device *dev); 9 11 void drm_class_device_unregister(struct device *dev); 10 12 11 13 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); 13 16 #endif