mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/vkms: Allow to configure multiple encoders via configfs
Create a default subgroup at /config/vkms/encoders to allow to create as many encoders as required. 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: Louis Chauvet <louis.chauvet@bootlin.com> Co-developed-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Link: https://lore.kernel.org/r/20251016175618.10051-9-jose.exposito89@gmail.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
This commit is contained in:
committed by
Luca Ceresoli
parent
95fa73787a
commit
67d8cf92e1
@@ -76,6 +76,7 @@ And directories are created for each configurable item of the display pipeline::
|
|||||||
tree /config/vkms/my-vkms
|
tree /config/vkms/my-vkms
|
||||||
├── crtcs
|
├── crtcs
|
||||||
├── enabled
|
├── enabled
|
||||||
|
├── encoders
|
||||||
└── planes
|
└── planes
|
||||||
|
|
||||||
To add items to the display pipeline, create one or more directories under the
|
To add items to the display pipeline, create one or more directories under the
|
||||||
@@ -98,6 +99,10 @@ CRTCs have 1 configurable attribute:
|
|||||||
|
|
||||||
- writeback: Enable or disable writeback connector support by writing 1 or 0
|
- writeback: Enable or disable writeback connector support by writing 1 or 0
|
||||||
|
|
||||||
|
Next, create one or more encoders::
|
||||||
|
|
||||||
|
sudo mkdir /config/vkms/my-vkms/encoders/encoder0
|
||||||
|
|
||||||
To finish the configuration, link the different pipeline items::
|
To finish the configuration, link the different pipeline items::
|
||||||
|
|
||||||
sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/planes/plane0/possible_crtcs
|
sudo ln -s /config/vkms/my-vkms/crtcs/crtc0 /config/vkms/my-vkms/planes/plane0/possible_crtcs
|
||||||
@@ -119,6 +124,7 @@ And removing the top level directory and its subdirectories::
|
|||||||
sudo rm /config/vkms/my-vkms/planes/*/possible_crtcs/*
|
sudo rm /config/vkms/my-vkms/planes/*/possible_crtcs/*
|
||||||
sudo rmdir /config/vkms/my-vkms/planes/*
|
sudo rmdir /config/vkms/my-vkms/planes/*
|
||||||
sudo rmdir /config/vkms/my-vkms/crtcs/*
|
sudo rmdir /config/vkms/my-vkms/crtcs/*
|
||||||
|
sudo rmdir /config/vkms/my-vkms/encoders/*
|
||||||
sudo rmdir /config/vkms/my-vkms
|
sudo rmdir /config/vkms/my-vkms
|
||||||
|
|
||||||
Testing With IGT
|
Testing With IGT
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ static bool is_configfs_registered;
|
|||||||
* Initialized when a new directory is created under "/config/vkms/"
|
* Initialized when a new directory is created under "/config/vkms/"
|
||||||
* @planes_group: Default subgroup of @group at "/config/vkms/planes"
|
* @planes_group: Default subgroup of @group at "/config/vkms/planes"
|
||||||
* @crtcs_group: Default subgroup of @group at "/config/vkms/crtcs"
|
* @crtcs_group: Default subgroup of @group at "/config/vkms/crtcs"
|
||||||
|
* @encoders_group: Default subgroup of @group at "/config/vkms/encoders"
|
||||||
* @lock: Lock used to project concurrent access to the configuration attributes
|
* @lock: Lock used to project concurrent access to the configuration attributes
|
||||||
* @config: Protected by @lock. Configuration of the VKMS device
|
* @config: Protected by @lock. Configuration of the VKMS device
|
||||||
* @enabled: Protected by @lock. The device is created or destroyed when this
|
* @enabled: Protected by @lock. The device is created or destroyed when this
|
||||||
@@ -27,6 +28,7 @@ struct vkms_configfs_device {
|
|||||||
struct config_group group;
|
struct config_group group;
|
||||||
struct config_group planes_group;
|
struct config_group planes_group;
|
||||||
struct config_group crtcs_group;
|
struct config_group crtcs_group;
|
||||||
|
struct config_group encoders_group;
|
||||||
|
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
struct vkms_config *config;
|
struct vkms_config *config;
|
||||||
@@ -63,6 +65,20 @@ struct vkms_configfs_crtc {
|
|||||||
struct vkms_config_crtc *config;
|
struct vkms_config_crtc *config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct vkms_configfs_encoder - Configfs representation of a encoder
|
||||||
|
*
|
||||||
|
* @group: Top level configuration group that represents a encoder.
|
||||||
|
* Initialized when a new directory is created under "/config/vkms/encoders"
|
||||||
|
* @dev: The vkms_configfs_device this encoder belongs to
|
||||||
|
* @config: Configuration of the VKMS encoder
|
||||||
|
*/
|
||||||
|
struct vkms_configfs_encoder {
|
||||||
|
struct config_group group;
|
||||||
|
struct vkms_configfs_device *dev;
|
||||||
|
struct vkms_config_encoder *config;
|
||||||
|
};
|
||||||
|
|
||||||
#define device_item_to_vkms_configfs_device(item) \
|
#define device_item_to_vkms_configfs_device(item) \
|
||||||
container_of(to_config_group((item)), struct vkms_configfs_device, \
|
container_of(to_config_group((item)), struct vkms_configfs_device, \
|
||||||
group)
|
group)
|
||||||
@@ -80,6 +96,10 @@ struct vkms_configfs_crtc {
|
|||||||
#define crtc_item_to_vkms_configfs_crtc(item) \
|
#define crtc_item_to_vkms_configfs_crtc(item) \
|
||||||
container_of(to_config_group((item)), struct vkms_configfs_crtc, group)
|
container_of(to_config_group((item)), struct vkms_configfs_crtc, group)
|
||||||
|
|
||||||
|
#define encoder_item_to_vkms_configfs_encoder(item) \
|
||||||
|
container_of(to_config_group((item)), struct vkms_configfs_encoder, \
|
||||||
|
group)
|
||||||
|
|
||||||
static ssize_t crtc_writeback_show(struct config_item *item, char *page)
|
static ssize_t crtc_writeback_show(struct config_item *item, char *page)
|
||||||
{
|
{
|
||||||
struct vkms_configfs_crtc *crtc;
|
struct vkms_configfs_crtc *crtc;
|
||||||
@@ -344,6 +364,69 @@ static const struct config_item_type plane_group_type = {
|
|||||||
.ct_owner = THIS_MODULE,
|
.ct_owner = THIS_MODULE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void encoder_release(struct config_item *item)
|
||||||
|
{
|
||||||
|
struct vkms_configfs_encoder *encoder;
|
||||||
|
struct mutex *lock;
|
||||||
|
|
||||||
|
encoder = encoder_item_to_vkms_configfs_encoder(item);
|
||||||
|
lock = &encoder->dev->lock;
|
||||||
|
|
||||||
|
scoped_guard(mutex, lock) {
|
||||||
|
vkms_config_destroy_encoder(encoder->dev->config, encoder->config);
|
||||||
|
kfree(encoder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct configfs_item_operations encoder_item_operations = {
|
||||||
|
.release = &encoder_release,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct config_item_type encoder_item_type = {
|
||||||
|
.ct_item_ops = &encoder_item_operations,
|
||||||
|
.ct_owner = THIS_MODULE,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct config_group *make_encoder_group(struct config_group *group,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
struct vkms_configfs_device *dev;
|
||||||
|
struct vkms_configfs_encoder *encoder;
|
||||||
|
|
||||||
|
dev = child_group_to_vkms_configfs_device(group);
|
||||||
|
|
||||||
|
scoped_guard(mutex, &dev->lock) {
|
||||||
|
if (dev->enabled)
|
||||||
|
return ERR_PTR(-EBUSY);
|
||||||
|
|
||||||
|
encoder = kzalloc(sizeof(*encoder), GFP_KERNEL);
|
||||||
|
if (!encoder)
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
encoder->dev = dev;
|
||||||
|
|
||||||
|
encoder->config = vkms_config_create_encoder(dev->config);
|
||||||
|
if (IS_ERR(encoder->config)) {
|
||||||
|
kfree(encoder);
|
||||||
|
return ERR_CAST(encoder->config);
|
||||||
|
}
|
||||||
|
|
||||||
|
config_group_init_type_name(&encoder->group, name,
|
||||||
|
&encoder_item_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return &encoder->group;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct configfs_group_operations encoders_group_operations = {
|
||||||
|
.make_group = &make_encoder_group,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct config_item_type encoder_group_type = {
|
||||||
|
.ct_group_ops = &encoders_group_operations,
|
||||||
|
.ct_owner = THIS_MODULE,
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t device_enabled_show(struct config_item *item, char *page)
|
static ssize_t device_enabled_show(struct config_item *item, char *page)
|
||||||
{
|
{
|
||||||
struct vkms_configfs_device *dev;
|
struct vkms_configfs_device *dev;
|
||||||
@@ -447,6 +530,10 @@ static struct config_group *make_device_group(struct config_group *group,
|
|||||||
&crtc_group_type);
|
&crtc_group_type);
|
||||||
configfs_add_default_group(&dev->crtcs_group, &dev->group);
|
configfs_add_default_group(&dev->crtcs_group, &dev->group);
|
||||||
|
|
||||||
|
config_group_init_type_name(&dev->encoders_group, "encoders",
|
||||||
|
&encoder_group_type);
|
||||||
|
configfs_add_default_group(&dev->encoders_group, &dev->group);
|
||||||
|
|
||||||
return &dev->group;
|
return &dev->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user