Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

José Expósito and committed by
Luca Ceresoli
6f00987f 085dadb3

+56 -2
+24
drivers/gpu/drm/vkms/tests/vkms_config_test.c
··· 957 957 vkms_config_destroy(config); 958 958 } 959 959 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 + 960 983 static struct kunit_case vkms_config_test_cases[] = { 961 984 KUNIT_CASE(vkms_config_test_empty_config), 962 985 KUNIT_CASE_PARAM(vkms_config_test_default_config, ··· 1001 978 KUNIT_CASE(vkms_config_test_plane_get_possible_crtcs), 1002 979 KUNIT_CASE(vkms_config_test_encoder_get_possible_crtcs), 1003 980 KUNIT_CASE(vkms_config_test_connector_get_possible_encoders), 981 + KUNIT_CASE(vkms_config_test_connector_status), 1004 982 {} 1005 983 }; 1006 984
+6 -2
drivers/gpu/drm/vkms/vkms_config.c
··· 361 361 vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg) 362 362 seq_puts(m, "encoder\n"); 363 363 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 + } 366 369 367 370 return 0; 368 371 } ··· 591 588 return ERR_PTR(-ENOMEM); 592 589 593 590 connector_cfg->config = config; 591 + connector_cfg->status = connector_status_connected; 594 592 xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC); 595 593 596 594 list_add_tail(&connector_cfg->link, &config->connectors);
+26
drivers/gpu/drm/vkms/vkms_config.h
··· 7 7 #include <linux/types.h> 8 8 #include <linux/xarray.h> 9 9 10 + #include <drm/drm_connector.h> 11 + 10 12 #include "vkms_drv.h" 11 13 12 14 /** ··· 101 99 * 102 100 * @link: Link to the others connector in vkms_config 103 101 * @config: The vkms_config this connector belongs to 102 + * @status: Status (connected, disconnected...) of the connector 104 103 * @possible_encoders: Array of encoders that can be used with this connector 105 104 * @connector: Internal usage. This pointer should never be considered as valid. 106 105 * It can be used to store a temporary reference to a VKMS connector ··· 112 109 struct list_head link; 113 110 struct vkms_config *config; 114 111 112 + enum drm_connector_status status; 115 113 struct xarray possible_encoders; 116 114 117 115 /* Internal usage */ ··· 437 433 */ 438 434 void vkms_config_connector_detach_encoder(struct vkms_config_connector *connector_cfg, 439 435 struct vkms_config_encoder *encoder_cfg); 436 + 437 + /** 438 + * vkms_config_connector_get_status() - Return the status of the connector 439 + * @connector_cfg: Connector to get the status from 440 + */ 441 + static inline enum drm_connector_status 442 + vkms_config_connector_get_status(struct vkms_config_connector *connector_cfg) 443 + { 444 + return connector_cfg->status; 445 + } 446 + 447 + /** 448 + * vkms_config_connector_set_status() - Set the status of the connector 449 + * @connector_cfg: Connector to set the status to 450 + * @status: New connector status 451 + */ 452 + static inline void 453 + vkms_config_connector_set_status(struct vkms_config_connector *connector_cfg, 454 + enum drm_connector_status status) 455 + { 456 + connector_cfg->status = status; 457 + } 440 458 441 459 #endif /* _VKMS_CONFIG_H_ */