mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
drm/vkms: Set device name from vkms_config
In order to be able to create multiple devices, the device name needs to be unique. Allow to set it in the VKMS configuration. Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250218101214.5790-7-jose.exposito89@gmail.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
This commit is contained in:
parent
8b059b0c3f
commit
969a3a4e2b
|
|
@ -15,10 +15,15 @@ struct default_config_case {
|
|||
static void vkms_config_test_empty_config(struct kunit *test)
|
||||
{
|
||||
struct vkms_config *config;
|
||||
const char *dev_name = "test";
|
||||
|
||||
config = vkms_config_create();
|
||||
config = vkms_config_create(dev_name);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
|
||||
|
||||
/* The dev_name string and the config have different lifetimes */
|
||||
dev_name = NULL;
|
||||
KUNIT_EXPECT_STREQ(test, vkms_config_get_device_name(config), "test");
|
||||
|
||||
vkms_config_destroy(config);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "vkms_config.h"
|
||||
|
||||
struct vkms_config *vkms_config_create(void)
|
||||
struct vkms_config *vkms_config_create(const char *dev_name)
|
||||
{
|
||||
struct vkms_config *config;
|
||||
|
||||
|
|
@ -16,6 +16,12 @@ struct vkms_config *vkms_config_create(void)
|
|||
if (!config)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
config->dev_name = kstrdup_const(dev_name, GFP_KERNEL);
|
||||
if (!config->dev_name) {
|
||||
kfree(config);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
EXPORT_SYMBOL_IF_KUNIT(vkms_config_create);
|
||||
|
|
@ -26,7 +32,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
|
|||
{
|
||||
struct vkms_config *config;
|
||||
|
||||
config = vkms_config_create();
|
||||
config = vkms_config_create(DEFAULT_DEVICE_NAME);
|
||||
if (IS_ERR(config))
|
||||
return config;
|
||||
|
||||
|
|
@ -40,6 +46,7 @@ EXPORT_SYMBOL_IF_KUNIT(vkms_config_default_create);
|
|||
|
||||
void vkms_config_destroy(struct vkms_config *config)
|
||||
{
|
||||
kfree_const(config->dev_name);
|
||||
kfree(config);
|
||||
}
|
||||
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy);
|
||||
|
|
@ -49,7 +56,10 @@ static int vkms_config_show(struct seq_file *m, void *data)
|
|||
struct drm_debugfs_entry *entry = m->private;
|
||||
struct drm_device *dev = entry->dev;
|
||||
struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
|
||||
const char *dev_name;
|
||||
|
||||
dev_name = vkms_config_get_device_name((struct vkms_config *)vkmsdev->config);
|
||||
seq_printf(m, "dev_name=%s\n", dev_name);
|
||||
seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback);
|
||||
seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor);
|
||||
seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@
|
|||
/**
|
||||
* struct vkms_config - General configuration for VKMS driver
|
||||
*
|
||||
* @dev_name: Name of the device
|
||||
* @writeback: If true, a writeback buffer can be attached to the CRTC
|
||||
* @cursor: If true, a cursor plane is created in the VKMS device
|
||||
* @overlay: If true, NUM_OVERLAY_PLANES will be created for the VKMS device
|
||||
* @dev: Used to store the current VKMS device. Only set when the device is instantiated.
|
||||
*/
|
||||
struct vkms_config {
|
||||
const char *dev_name;
|
||||
bool writeback;
|
||||
bool cursor;
|
||||
bool overlay;
|
||||
|
|
@ -24,12 +26,13 @@ struct vkms_config {
|
|||
|
||||
/**
|
||||
* vkms_config_create() - Create a new VKMS configuration
|
||||
* @dev_name: Name of the device
|
||||
*
|
||||
* Returns:
|
||||
* The new vkms_config or an error. Call vkms_config_destroy() to free the
|
||||
* returned configuration.
|
||||
*/
|
||||
struct vkms_config *vkms_config_create(void);
|
||||
struct vkms_config *vkms_config_create(const char *dev_name);
|
||||
|
||||
/**
|
||||
* vkms_config_default_create() - Create the configuration for the default device
|
||||
|
|
@ -51,6 +54,19 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
|
|||
*/
|
||||
void vkms_config_destroy(struct vkms_config *config);
|
||||
|
||||
/**
|
||||
* vkms_config_get_device_name() - Return the name of the device
|
||||
* @config: Configuration to get the device name from
|
||||
*
|
||||
* Returns:
|
||||
* The device name. Only valid while @config is valid.
|
||||
*/
|
||||
static inline const char *
|
||||
vkms_config_get_device_name(struct vkms_config *config)
|
||||
{
|
||||
return config->dev_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* vkms_config_register_debugfs() - Register a debugfs file to show the device's
|
||||
* configuration
|
||||
|
|
|
|||
|
|
@ -151,8 +151,10 @@ static int vkms_create(struct vkms_config *config)
|
|||
int ret;
|
||||
struct platform_device *pdev;
|
||||
struct vkms_device *vkms_device;
|
||||
const char *dev_name;
|
||||
|
||||
pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
|
||||
dev_name = vkms_config_get_device_name(config);
|
||||
pdev = platform_device_register_simple(dev_name, -1, NULL, 0);
|
||||
if (IS_ERR(pdev))
|
||||
return PTR_ERR(pdev);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <drm/drm_encoder.h>
|
||||
#include <drm/drm_writeback.h>
|
||||
|
||||
#define DEFAULT_DEVICE_NAME "vkms"
|
||||
|
||||
#define XRES_MIN 10
|
||||
#define YRES_MIN 10
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user