[PATCH RFC v2 10/18] drm/vkms: Introduce config for encoder name

Jani Nikula jani.nikula at linux.intel.com
Mon Nov 25 09:28:44 UTC 2024


On Fri, 22 Nov 2024, Louis Chauvet <louis.chauvet at bootlin.com> wrote:
> As an encoder will be a directory in ConfigFS, add the configuration for
> encoder name so we will be able to reflect the configfs directory name in
> the drm name.
>
> Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
> ---
>  drivers/gpu/drm/vkms/vkms_config.c | 6 ++++++
>  drivers/gpu/drm/vkms/vkms_config.h | 2 ++
>  drivers/gpu/drm/vkms/vkms_output.c | 2 +-
>  3 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index e44ed904cefb97b8b6ab8fc27623e315397e0106..a2539fb56b602569b75748fdf9c4784f104b0bff 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
> @@ -41,6 +41,10 @@ struct vkms_config *vkms_config_alloc_default(bool enable_writeback, bool enable
>  	encoder = vkms_config_create_encoder(vkms_config);
>  	if (!encoder)
>  		goto err_alloc;
> +	encoder->name = kzalloc(sizeof("Main Encoder"), GFP_KERNEL);
> +	if (!encoder->name)
> +		goto err_alloc;
> +	sprintf(encoder->name, "Main Encoder");

Drive-by comment, maybe kstrdup()?

>  
>  	if (vkms_config_encoder_attach_crtc(encoder, crtc))
>  		goto err_alloc;
> @@ -238,6 +242,7 @@ void vkms_config_delete_encoder(struct vkms_config_encoder *vkms_config_encoder,
>  		}
>  	}
>  
> +	kfree(vkms_config_encoder->name);
>  	kfree(vkms_config_encoder);
>  }
>  
> @@ -403,6 +408,7 @@ static int vkms_config_show(struct seq_file *m, void *data)
>  
>  	list_for_each_entry(config_encoder, &vkmsdev->config->encoders, link) {
>  		seq_puts(m, "encoder:\n");
> +		seq_printf(m, "\tname: %s\n", config_encoder->name);
>  	}
>  
>  	list_for_each_entry(config_crtc, &vkmsdev->config->crtcs, link) {
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 8f247fc09373fb2c8145e83be05c6afec1ffac1c..4223edd94ec270915dd658c0b5efd489554d33a5 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
> @@ -50,6 +50,7 @@ struct vkms_config_crtc {
>   * struct vkms_config_encoder
>   *
>   * @link: Link to the others encoders
> + * @name: Name of the encoder
>   * @possible_crtcs: List of CRTC that can be used with this encoder
>   * @encoder: Internal usage. This pointer should never be considered as valid. It can be used to
>   *         store a temporary reference to a vkms encoder during device creation. This pointer is
> @@ -58,6 +59,7 @@ struct vkms_config_crtc {
>  struct vkms_config_encoder {
>  	struct list_head link;
>  
> +	char *name;
>  	struct xarray possible_crtcs;
>  
>  	/* Internal usage */
> diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
> index 03498a20d78dd8a66f9fc66b360c5ea57fc48d88..6277ad72fdd476d1eff52ad037389bdb1a254f5e 100644
> --- a/drivers/gpu/drm/vkms/vkms_output.c
> +++ b/drivers/gpu/drm/vkms/vkms_output.c
> @@ -92,7 +92,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
>  		if (!config_encoder->encoder)
>  			return -ENOMEM;
>  		ret = drmm_encoder_init(dev, config_encoder->encoder, NULL,
> -					DRM_MODE_ENCODER_VIRTUAL, NULL);
> +					DRM_MODE_ENCODER_VIRTUAL, config_encoder->name);
>  		if (ret) {
>  			DRM_ERROR("Failed to init encoder\n");
>  			return ret;

-- 
Jani Nikula, Intel


More information about the dri-devel mailing list