aports/testing/mir/0001-Fix-the-signature-of-drmModeCrtcSetGamma.patch
Luca Weiss 7c77c03a24 testing/mir: rebuild against glog 0.7.1
Pick two patches from upstream that removes some files that cause
compilation errors with the newer glog.
2024-06-25 17:24:35 +00:00

70 lines
3 KiB
Diff

From a99d65d34e6b572d88c5fbade1efb809c3e9f0d9 Mon Sep 17 00:00:00 2001
From: Alan Griffiths <alan@octopull.co.uk>
Date: Thu, 31 Aug 2023 12:05:13 +0100
Subject: [PATCH 1/3] Fix the signature of drmModeCrtcSetGamma
---
tests/include/mir/test/doubles/mock_drm.h | 2 +-
tests/mir_test_doubles/mock_drm.cpp | 22 ++++++++++++++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/tests/include/mir/test/doubles/mock_drm.h b/tests/include/mir/test/doubles/mock_drm.h
index aeba8c7d05..d3c44f30c2 100644
--- a/tests/include/mir/test/doubles/mock_drm.h
+++ b/tests/include/mir/test/doubles/mock_drm.h
@@ -155,7 +155,7 @@ public:
MOCK_METHOD6(drmModeCrtcGetGamma, int(int fd, uint32_t crtc_id, uint32_t size,
uint16_t* red, uint16_t* green, uint16_t* blue));
MOCK_METHOD6(drmModeCrtcSetGamma, int(int fd, uint32_t crtc_id, uint32_t size,
- uint16_t* red, uint16_t* green, uint16_t* blue));
+ uint16_t const* red, uint16_t const* green, uint16_t const* blue));
MOCK_METHOD1(drmGetVersion, drmVersionPtr(int));
MOCK_METHOD1(drmFreeVersion, void(drmVersionPtr));
diff --git a/tests/mir_test_doubles/mock_drm.cpp b/tests/mir_test_doubles/mock_drm.cpp
index d3d5840b7a..bd51466cba 100644
--- a/tests/mir_test_doubles/mock_drm.cpp
+++ b/tests/mir_test_doubles/mock_drm.cpp
@@ -489,6 +489,24 @@ testing::Matcher<int> mtd::IsFdOfDevice(char const* device)
return ::testing::MakeMatcher(new mtd::MockDRM::IsFdOfDeviceMatcher(device));
}
+// The signature of drmModeCrtcSetGamma() changes from passing the gamma as `uint16_t*` to `uint16_t const*`
+// We need to provide a definition that matches
+namespace
+{
+template<typename Any>
+struct Decode_drmModeCrtcSetGamma_signature;
+
+template<typename Arg>
+struct Decode_drmModeCrtcSetGamma_signature<int(int fd, uint32_t crtc_id, uint32_t size, Arg red, Arg gree, Arg blue)>
+{
+ using gamma_t = Arg;
+};
+using gamma_t = Decode_drmModeCrtcSetGamma_signature<decltype(drmModeCrtcSetGamma)>::gamma_t;
+}
+
+// Ensure we get a compile error if the definition doesn't match the declaration (instead of providing an overload)
+extern "C"
+{
int drmOpen(const char *name, const char *busid)
{
return global_mock->drmOpen(name, busid);
@@ -548,8 +566,7 @@ int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
return global_mock->drmModeCrtcGetGamma(fd, crtc_id, size, red, green, blue);
}
-int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
- uint16_t* red, uint16_t* green, uint16_t* blue)
+int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, gamma_t red, gamma_t green, gamma_t blue)
{
return global_mock->drmModeCrtcSetGamma(fd, crtc_id, size, red, green, blue);
}
@@ -751,3 +768,4 @@ int drmCheckModesettingSupported(char const* busid)
{
return global_mock->drmCheckModesettingSupported(busid);
}
+}
--
2.45.2