summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2019-06-06 15:58:17 +0200
committerJacopo Mondi <jacopo@jmondi.org>2019-08-27 17:00:00 +0200
commit3c6af4db165e5b3dc8996f0a288746c35dbb1cb9 (patch)
treea06dfdf3a5fe07159d5bcc9a23c32aa0f5ae0f48
parent626edbe2fc845803ffdd25936e21202e4f123b63 (diff)
kmstest: Inject color inversion gamma table
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--utils/kmstest.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index 8144117..87dacd8 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -9,6 +9,9 @@
#include <sys/select.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
#include <kms++/kms++.h>
#include <kms++/modedb.h>
#include <kms++/mode_cvt.h>
@@ -822,6 +825,9 @@ static void set_crtcs_n_planes_legacy(Card& card, const vector<OutputInfo>& outp
static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outputs)
{
+
+#define LUT_ENTRIES 256
+ unsigned int i;
int r;
// XXX DRM framework doesn't allow moving an active plane from one crtc to another.
@@ -855,6 +861,25 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
// Keep blobs here so that we keep ref to them until we have committed the req
vector<unique_ptr<Blob>> blobs;
+ struct drm_color_lut *gamma_table = static_cast<struct drm_color_lut *>
+ (calloc(LUT_ENTRIES,
+ sizeof(struct drm_color_lut)));
+ if (!gamma_table)
+ return;
+
+ for (i = 0; i < LUT_ENTRIES; ++i) {
+#define DRM_GAMMA_MAX_VALUE 0xffff
+ uint32_t entry = i * DRM_GAMMA_MAX_VALUE;
+ entry /= LUT_ENTRIES;
+ entry = DRM_GAMMA_MAX_VALUE - entry;
+ gamma_table[i].red = (uint16_t)entry;
+ gamma_table[i].green = (uint16_t)entry;
+ gamma_table[i].blue = (uint16_t)entry;
+ }
+
+ Blob* lut_blob = new Blob(card, gamma_table,
+ sizeof(struct drm_color_lut) * LUT_ENTRIES);
+
AtomicReq req(card);
for (const OutputInfo& o : outputs) {
@@ -874,6 +899,7 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
req.add(crtc, {
{ "ACTIVE", 1 },
{ "MODE_ID", mode_blob->id() },
+ { "GAMMA_LUT", lut_blob->id() },
});
for (const PropInfo &prop: o.crtc_props)
@@ -901,12 +927,18 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
}
r = req.test(true);
- if (r)
+ if (r) {
+ delete[] gamma_table;
EXIT("Atomic test failed: %d\n", r);
+ }
r = req.commit_sync(true);
- if (r)
+ if (r) {
+ delete[] gamma_table;
EXIT("Atomic commit failed: %d\n", r);
+ }
+
+ delete[] gamma_table;
}
static void set_crtcs_n_planes(Card& card, const vector<OutputInfo>& outputs)