Skip to content

Commit 6f00987

Browse files
JoseExpositolucaceresoli
authored andcommitted
drm/vkms: Allow to configure connector status
Allow to store the connector status in vkms_config_connector and add a getter and a setter functions as well a KUnit test. This change only adds the configuration, the connector status is not used yet. 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: José Expósito <jose.exposito89@gmail.com> Link: https://lore.kernel.org/r/20251016175618.10051-15-jose.exposito89@gmail.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
1 parent 085dadb commit 6f00987

3 files changed

Lines changed: 56 additions & 2 deletions

File tree

drivers/gpu/drm/vkms/tests/vkms_config_test.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,29 @@ static void vkms_config_test_connector_get_possible_encoders(struct kunit *test)
957957
vkms_config_destroy(config);
958958
}
959959

960+
static void vkms_config_test_connector_status(struct kunit *test)
961+
{
962+
struct vkms_config *config;
963+
struct vkms_config_connector *connector_cfg;
964+
enum drm_connector_status status;
965+
966+
config = vkms_config_create("test");
967+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
968+
969+
connector_cfg = vkms_config_create_connector(config);
970+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg);
971+
972+
status = vkms_config_connector_get_status(connector_cfg);
973+
KUNIT_EXPECT_EQ(test, status, connector_status_connected);
974+
975+
vkms_config_connector_set_status(connector_cfg,
976+
connector_status_disconnected);
977+
status = vkms_config_connector_get_status(connector_cfg);
978+
KUNIT_EXPECT_EQ(test, status, connector_status_disconnected);
979+
980+
vkms_config_destroy(config);
981+
}
982+
960983
static struct kunit_case vkms_config_test_cases[] = {
961984
KUNIT_CASE(vkms_config_test_empty_config),
962985
KUNIT_CASE_PARAM(vkms_config_test_default_config,
@@ -978,6 +1001,7 @@ static struct kunit_case vkms_config_test_cases[] = {
9781001
KUNIT_CASE(vkms_config_test_plane_get_possible_crtcs),
9791002
KUNIT_CASE(vkms_config_test_encoder_get_possible_crtcs),
9801003
KUNIT_CASE(vkms_config_test_connector_get_possible_encoders),
1004+
KUNIT_CASE(vkms_config_test_connector_status),
9811005
{}
9821006
};
9831007

drivers/gpu/drm/vkms/vkms_config.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,11 @@ static int vkms_config_show(struct seq_file *m, void *data)
361361
vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg)
362362
seq_puts(m, "encoder\n");
363363

364-
vkms_config_for_each_connector(vkmsdev->config, connector_cfg)
365-
seq_puts(m, "connector\n");
364+
vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
365+
seq_puts(m, "connector:\n");
366+
seq_printf(m, "\tstatus=%d\n",
367+
vkms_config_connector_get_status(connector_cfg));
368+
}
366369

367370
return 0;
368371
}
@@ -588,6 +591,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
588591
return ERR_PTR(-ENOMEM);
589592

590593
connector_cfg->config = config;
594+
connector_cfg->status = connector_status_connected;
591595
xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
592596

593597
list_add_tail(&connector_cfg->link, &config->connectors);

drivers/gpu/drm/vkms/vkms_config.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <linux/types.h>
88
#include <linux/xarray.h>
99

10+
#include <drm/drm_connector.h>
11+
1012
#include "vkms_drv.h"
1113

1214
/**
@@ -99,6 +101,7 @@ struct vkms_config_encoder {
99101
*
100102
* @link: Link to the others connector in vkms_config
101103
* @config: The vkms_config this connector belongs to
104+
* @status: Status (connected, disconnected...) of the connector
102105
* @possible_encoders: Array of encoders that can be used with this connector
103106
* @connector: Internal usage. This pointer should never be considered as valid.
104107
* It can be used to store a temporary reference to a VKMS connector
@@ -109,6 +112,7 @@ struct vkms_config_connector {
109112
struct list_head link;
110113
struct vkms_config *config;
111114

115+
enum drm_connector_status status;
112116
struct xarray possible_encoders;
113117

114118
/* Internal usage */
@@ -434,4 +438,26 @@ int __must_check vkms_config_connector_attach_encoder(struct vkms_config_connect
434438
void vkms_config_connector_detach_encoder(struct vkms_config_connector *connector_cfg,
435439
struct vkms_config_encoder *encoder_cfg);
436440

441+
/**
442+
* vkms_config_connector_get_status() - Return the status of the connector
443+
* @connector_cfg: Connector to get the status from
444+
*/
445+
static inline enum drm_connector_status
446+
vkms_config_connector_get_status(struct vkms_config_connector *connector_cfg)
447+
{
448+
return connector_cfg->status;
449+
}
450+
451+
/**
452+
* vkms_config_connector_set_status() - Set the status of the connector
453+
* @connector_cfg: Connector to set the status to
454+
* @status: New connector status
455+
*/
456+
static inline void
457+
vkms_config_connector_set_status(struct vkms_config_connector *connector_cfg,
458+
enum drm_connector_status status)
459+
{
460+
connector_cfg->status = status;
461+
}
462+
437463
#endif /* _VKMS_CONFIG_H_ */

0 commit comments

Comments
 (0)