On Sat, Oct 18, 2025 at 04:01:20AM +0200, Louis Chauvet wrote:
> In order to prepare for dynamic connector configuration, we need to store
> if a connector is dynamic and if it is enabled.
> 
> The two new vkms_config_connector fields will helps for that.
> 
> Co-developed-by: José Expósito <[email protected]>
> Signed-off-by: José Expósito <[email protected]>
> Signed-off-by: Louis Chauvet <[email protected]>
> ---
>  drivers/gpu/drm/vkms/tests/vkms_config_test.c |  4 ++
>  drivers/gpu/drm/vkms/vkms_config.c            |  2 +
>  drivers/gpu/drm/vkms/vkms_config.h            | 66 
> +++++++++++++++++++++++++++
>  3 files changed, 72 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c 
> b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
> index d1e380da31ff..f4b5f8f59fab 100644
> --- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
> +++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
> @@ -192,6 +192,10 @@ static void vkms_config_test_default_config(struct kunit 
> *test)
>                               0);
>               KUNIT_EXPECT_EQ(test, 
> vkms_config_connector_get_edid_enabled(connector_cfg),
>                               false);
> +             KUNIT_EXPECT_EQ(test, 
> vkms_config_connector_is_enabled(connector_cfg),
> +                             true);
> +             KUNIT_EXPECT_EQ(test, 
> vkms_config_connector_is_dynamic(connector_cfg),
> +                             false);

I missed this in other reviews, but you can use KUNIT_EXPECT_TRUE/FALSE instead.

>       }
>  
>       KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c 
> b/drivers/gpu/drm/vkms/vkms_config.c
> index 56e2082b91c9..fd724ae2ebc9 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
> @@ -773,6 +773,8 @@ struct vkms_config_connector 
> *vkms_config_create_connector(struct vkms_config *c
>       connector_cfg->status = connector_status_connected;
>       vkms_config_connector_set_type(connector_cfg, 
> DRM_MODE_CONNECTOR_VIRTUAL);
>       vkms_config_connector_set_supported_colorspaces(connector_cfg, 0);
> +     vkms_config_connector_set_dynamic(connector_cfg, false);
> +     vkms_config_connector_set_enabled(connector_cfg, true);
>       xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
>  
>       list_add_tail(&connector_cfg->link, &config->connectors);
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h 
> b/drivers/gpu/drm/vkms/vkms_config.h
> index eaf76a58aab6..6716b5a85f0d 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
> @@ -128,6 +128,8 @@ struct vkms_config_encoder {
>   * @link: Link to the others connector in vkms_config
>   * @type: Store the type of connector using DRM_MODE_CONNECTOR_* values
>   * @config: The vkms_config this connector belongs to
> + * @dynamic: Store if a connector should be created with 
> drm_connector_dynamic_init
> + * @enabled: If @dynamic, this means that the correct is currently 
> registered in drm
>   * @status: Status (connected, disconnected...) of the connector
>   * @edid: Stores the current EDID
>   * @edid_len: Current EDID length
> @@ -142,6 +144,8 @@ struct vkms_config_connector {
>       struct vkms_config *config;
>  
>       int type;
> +     bool enabled;
> +     bool dynamic;

In this patch we could also log this in vkms_config_show().

>       enum drm_connector_status status;
>       u32 supported_colorspaces;
>       bool edid_enabled;
> @@ -185,6 +189,24 @@ struct vkms_config_connector {
>  #define vkms_config_for_each_connector(config, connector_cfg) \
>       list_for_each_entry((connector_cfg), &(config)->connectors, link)
>  
> +/**
> + * vkms_config_for_each_connector_static - Iterate over the static 
> vkms_config connectors
> + * @config: &struct vkms_config pointer
> + * @connector_cfg: &struct vkms_config_connector pointer used as cursor
> + */
> +#define vkms_config_for_each_connector_static(config, connector_cfg) \
> +     vkms_config_for_each_connector((config), (connector_cfg)) \
> +             if (!(connector_cfg)->dynamic)
> +
> +/**
> + * vkms_config_for_each_connector_dynamic - Iterate over the dynamic 
> vkms_config connectors
> + * @config: &struct vkms_config pointer
> + * @connector_cfg: &struct vkms_config_connector pointer used as cursor
> + */
> +#define vkms_config_for_each_connector_dynamic(config, connector_cfg) \
> +     vkms_config_for_each_connector((config), (connector_cfg)) \
> +             if ((connector_cfg)->dynamic)
> +
>  /**
>   * vkms_config_plane_for_each_possible_crtc - Iterate over the 
> vkms_config_plane
>   * possible CRTCs
> @@ -441,6 +463,50 @@ vkms_config_connector_set_type(struct 
> vkms_config_connector *connector_cfg,
>       connector_cfg->type = type;
>  }
>  
> +/**
> + * vkms_config_connector_set_enabled() - If the connector is part of the 
> device
> + * @crtc_cfg: Target connector
> + * @enabled: Add or remove the connector
> + */
> +static inline void
> +vkms_config_connector_set_enabled(struct vkms_config_connector 
> *connector_cfg,
> +                               bool enabled)
> +{
> +     connector_cfg->enabled = enabled;
> +}
> +
> +/**
> + * vkms_config_connector_is_enabled() - If the connector is part of the 
> device
> + * @connector_cfg: The connector
> + */
> +static inline bool
> +vkms_config_connector_is_enabled(struct vkms_config_connector *connector_cfg)
> +{
> +     return connector_cfg->enabled;
> +}
> +
> +/**
> + * vkms_config_connector_set_dynamic() - If the connector is dynamic
> + * @crtc_cfg: Target connector
> + * @enabled: Enable or disable the dynamic status
> + */
> +static inline void
> +vkms_config_connector_set_dynamic(struct vkms_config_connector 
> *connector_cfg,
> +                               bool dynamic)
> +{
> +     connector_cfg->dynamic = dynamic;
> +}
> +
> +/**
> + * vkms_config_connector_is_enabled() - If the connector is dynamic
> + * @connector_cfg: The connector
> + */
> +static inline bool
> +vkms_config_connector_is_dynamic(struct vkms_config_connector *connector_cfg)
> +{
> +     return connector_cfg->dynamic;
> +}
> +
>  /*
>   * vkms_config_plane_get_default_rotation() - Get the default rotation for a 
> plane
>   * @plane_cfg: Plane to get the default rotation from
> 
> -- 
> 2.51.0
> 

Reply via email to