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

Configure Feed

Select the types of activity you want to include in your feed.

drm/vkms: Allow to configure connector status via configfs

When a connector is created, add a `status` file to allow to update the
connector status to:

- 1 connector_status_connected
- 2 connector_status_disconnected
- 3 connector_status_unknown

If the device is enabled, updating the status hot-plug or unplugs the
connector.

Tested-by: Mark Yacoub <markyacoub@google.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Link: https://lore.kernel.org/r/20251016175618.10051-17-jose.exposito89@gmail.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

authored by

José Expósito and committed by
Luca Ceresoli
f97180f0 466f4388

+66
+5
Documentation/gpu/vkms.rst
··· 108 108 109 109 sudo mkdir /config/vkms/my-vkms/connectors/connector0 110 110 111 + Connectors have 1 configurable attribute: 112 + 113 + - status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values 114 + as those exposed by the "status" property of a connector) 115 + 111 116 To finish the configuration, link the different pipeline items:: 112 117 113 118 sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/planes/plane0/possible_crtcs
+48
drivers/gpu/drm/vkms/vkms_configfs.c
··· 7 7 #include "vkms_drv.h" 8 8 #include "vkms_config.h" 9 9 #include "vkms_configfs.h" 10 + #include "vkms_connector.h" 10 11 11 12 /* To avoid registering configfs more than once or unregistering on error */ 12 13 static bool is_configfs_registered; ··· 513 512 .ct_owner = THIS_MODULE, 514 513 }; 515 514 515 + static ssize_t connector_status_show(struct config_item *item, char *page) 516 + { 517 + struct vkms_configfs_connector *connector; 518 + enum drm_connector_status status; 519 + 520 + connector = connector_item_to_vkms_configfs_connector(item); 521 + 522 + scoped_guard(mutex, &connector->dev->lock) 523 + status = vkms_config_connector_get_status(connector->config); 524 + 525 + return sprintf(page, "%u", status); 526 + } 527 + 528 + static ssize_t connector_status_store(struct config_item *item, 529 + const char *page, size_t count) 530 + { 531 + struct vkms_configfs_connector *connector; 532 + enum drm_connector_status status; 533 + 534 + connector = connector_item_to_vkms_configfs_connector(item); 535 + 536 + if (kstrtouint(page, 10, &status)) 537 + return -EINVAL; 538 + 539 + if (status != connector_status_connected && 540 + status != connector_status_disconnected && 541 + status != connector_status_unknown) 542 + return -EINVAL; 543 + 544 + scoped_guard(mutex, &connector->dev->lock) { 545 + vkms_config_connector_set_status(connector->config, status); 546 + 547 + if (connector->dev->enabled) 548 + vkms_trigger_connector_hotplug(connector->dev->config->dev); 549 + } 550 + 551 + return (ssize_t)count; 552 + } 553 + 554 + CONFIGFS_ATTR(connector_, status); 555 + 556 + static struct configfs_attribute *connector_item_attrs[] = { 557 + &connector_attr_status, 558 + NULL, 559 + }; 560 + 516 561 static void connector_release(struct config_item *item) 517 562 { 518 563 struct vkms_configfs_connector *connector; ··· 578 531 }; 579 532 580 533 static const struct config_item_type connector_item_type = { 534 + .ct_attrs = connector_item_attrs, 581 535 .ct_item_ops = &connector_item_operations, 582 536 .ct_owner = THIS_MODULE, 583 537 };
+7
drivers/gpu/drm/vkms/vkms_connector.c
··· 87 87 88 88 return connector; 89 89 } 90 + 91 + void vkms_trigger_connector_hotplug(struct vkms_device *vkmsdev) 92 + { 93 + struct drm_device *dev = &vkmsdev->drm; 94 + 95 + drm_kms_helper_hotplug_event(dev); 96 + }
+6
drivers/gpu/drm/vkms/vkms_connector.h
··· 26 26 */ 27 27 struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev); 28 28 29 + /** 30 + * vkms_trigger_connector_hotplug() - Update the device's connectors status 31 + * @vkmsdev: VKMS device to update 32 + */ 33 + void vkms_trigger_connector_hotplug(struct vkms_device *vkmsdev); 34 + 29 35 #endif /* _VKMS_CONNECTOR_H_ */