From 33beb28b5fe378e22f1e1732b4b580e591e13767 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmeister Date: Mon, 18 Dec 2023 22:57:58 +0100 Subject: [PATCH] autotests/drm: Fix connector_type_id usage --- autotests/drm/mock_drm.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/autotests/drm/mock_drm.cpp b/autotests/drm/mock_drm.cpp index 462f3c189b..eb41eec57c 100644 --- a/autotests/drm/mock_drm.cpp +++ b/autotests/drm/mock_drm.cpp @@ -14,6 +14,8 @@ extern "C" { } #include +#include + #include #include @@ -609,6 +611,14 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id) } } +// Instance ID of (some) specific connector type, incremented +// for each new connector (of any type) being created. +// There are no particular guarantees on the _stability_ of +// connector type "instance IDs" issued by the kernel, +// so simply giving each (new) connector a fresh ID is +// acceptable. +static std::atomic autoIncrementedConnectorId{}; + drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connectorId) { GPU(fd, nullptr); @@ -616,7 +626,10 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connectorId) drmModeConnectorPtr c = new drmModeConnector{}; c->connector_id = conn->id; c->connection = conn->connection; + c->connector_type = conn->type; + c->connector_type_id = autoIncrementedConnectorId++; + c->encoder_id = conn->encoder ? conn->encoder->id : 0; c->count_encoders = conn->encoder ? 1 : 0; c->encoders = c->count_encoders ? new uint32_t[1] : nullptr; @@ -632,8 +645,6 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connectorId) c->mmWidth = 1600; c->subpixel = DRM_MODE_SUBPIXEL_HORIZONTAL_RGB; - c->connector_type_id = DRM_MODE_CONNECTOR_DisplayPort;// ? - // these are not used nor will they be c->count_props = -1; c->props = nullptr;