Commit ee5c2c7d authored by Louis Chauvet's avatar Louis Chauvet Committed by Luca Ceresoli
Browse files

drm/vkms: Allow to configure CRTC writeback support via configfs



When a CRTC is created, add a `writeback` file to allow to enable or
disable writeback connector support

Tested-by: default avatarMark Yacoub <markyacoub@google.com>
Reviewed-by: default avatarLouis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: default avatarLouis Chauvet <louis.chauvet@bootlin.com>
Co-developed-by: default avatarJosé Expósito <jose.exposito89@gmail.com>
Signed-off-by: default avatarJosé Expósito <jose.exposito89@gmail.com>
Link: https://lore.kernel.org/r/20251016175618.10051-7-jose.exposito89@gmail.com


Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
parent 3e4d5b30
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ Continue by creating one or more CRTCs::

  sudo mkdir /config/vkms/my-vkms/crtcs/crtc0

CRTCs have 1 configurable attribute:

- writeback: Enable or disable writeback connector support by writing 1 or 0

Once you are done configuring the VKMS instance, enable it::

  echo "1" | sudo tee /config/vkms/my-vkms/enabled
+42 −0
Original line number Diff line number Diff line
@@ -74,6 +74,47 @@ struct vkms_configfs_crtc {
#define crtc_item_to_vkms_configfs_crtc(item) \
	container_of(to_config_group((item)), struct vkms_configfs_crtc, group)

static ssize_t crtc_writeback_show(struct config_item *item, char *page)
{
	struct vkms_configfs_crtc *crtc;
	bool writeback;

	crtc = crtc_item_to_vkms_configfs_crtc(item);

	scoped_guard(mutex, &crtc->dev->lock)
		writeback = vkms_config_crtc_get_writeback(crtc->config);

	return sprintf(page, "%d\n", writeback);
}

static ssize_t crtc_writeback_store(struct config_item *item, const char *page,
				    size_t count)
{
	struct vkms_configfs_crtc *crtc;
	bool writeback;

	crtc = crtc_item_to_vkms_configfs_crtc(item);

	if (kstrtobool(page, &writeback))
		return -EINVAL;

	scoped_guard(mutex, &crtc->dev->lock) {
		if (crtc->dev->enabled)
			return -EBUSY;

		vkms_config_crtc_set_writeback(crtc->config, writeback);
	}

	return (ssize_t)count;
}

CONFIGFS_ATTR(crtc_, writeback);

static struct configfs_attribute *crtc_item_attrs[] = {
	&crtc_attr_writeback,
	NULL,
};

static void crtc_release(struct config_item *item)
{
	struct vkms_configfs_crtc *crtc;
@@ -93,6 +134,7 @@ static struct configfs_item_operations crtc_item_operations = {
};

static const struct config_item_type crtc_item_type = {
	.ct_attrs	= crtc_item_attrs,
	.ct_item_ops	= &crtc_item_operations,
	.ct_owner	= THIS_MODULE,
};