summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2019-09-06 15:25:54 +0200
committerJacopo Mondi <jacopo@jmondi.org>2019-09-06 15:28:41 +0200
commitfe178a43861da7c8e79618e2a13fa0f19dbcd03d (patch)
treec1f8700a76cfe6675bb31df2067cdcb9e1cdaffc
parent3c6af4db165e5b3dc8996f0a288746c35dbb1cb9 (diff)
kmstest: Reprogram CMM every 50 frames
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--utils/kmstest.cpp81
1 files changed, 52 insertions, 29 deletions
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index 87dacd8..b1477e5 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -825,9 +825,6 @@ 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.
@@ -861,25 +858,6 @@ 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) {
@@ -899,7 +877,6 @@ 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)
@@ -928,17 +905,13 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
r = req.test(true);
if (r) {
- delete[] gamma_table;
EXIT("Atomic test failed: %d\n", r);
}
r = req.commit_sync(true);
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)
@@ -957,6 +930,7 @@ public:
FlipState(Card& card, const string& name, vector<const OutputInfo*> outputs)
: m_card(card), m_name(name), m_outputs(outputs)
{
+
}
void start_flipping()
@@ -1016,7 +990,7 @@ private:
draw_text(*fb, fb->width() / 2, 0, to_string(frame_num), RGB(255, 255, 255));
}
- static void do_flip_output(AtomicReq& req, unsigned frame_num, const OutputInfo& o)
+ static void do_flip_output(Card &card, AtomicReq& req, unsigned frame_num, const OutputInfo& o)
{
unsigned cur = frame_num % s_num_buffers;
@@ -1029,6 +1003,50 @@ private:
{ "FB_ID", fb->id() },
});
}
+
+ if (frame_num == 0 || !(frame_num % 50)) {
+ auto conn = o.connector;
+ auto crtc = o.crtc;
+ Blob *lut_blob;
+
+#define DRM_GAMMA_MAX_VALUE 0xffff
+#define LUT_ENTRIES 256
+ if (!lut_active) {
+ /* Prepare a color inversion LUT table. */
+ for (unsigned int i = 0; i < LUT_ENTRIES; ++i) {
+ 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;
+ }
+
+ lut_active = true;
+ } else {
+ /* Program a linear color table. */
+ for (uint16_t i = 0; i < LUT_ENTRIES; ++i) {
+ uint32_t entry = i * DRM_GAMMA_MAX_VALUE;
+ entry /= LUT_ENTRIES;
+ gamma_table[i].red = (uint16_t)entry;
+ gamma_table[i].green = (uint16_t)entry;
+ gamma_table[i].blue = (uint16_t)entry;
+ }
+
+ lut_active = false;
+ }
+
+ req.add(conn, {
+ { "CRTC_ID", crtc->id() },
+ });
+
+ lut_blob = new Blob(card, &gamma_table,
+ sizeof(struct drm_color_lut) * LUT_ENTRIES);
+ req.add(crtc, {
+ { "ACTIVE", 1 },
+ { "GAMMA_LUT", lut_blob->id() },
+ });
+ }
}
void do_flip_output_legacy(unsigned frame_num, const OutputInfo& o)
@@ -1064,7 +1082,7 @@ private:
AtomicReq req(m_card);
for (auto o : m_outputs)
- do_flip_output(req, m_frame_num, *o);
+ do_flip_output(m_card, req, m_frame_num, *o);
int r = req.commit(this);
if (r)
@@ -1087,7 +1105,12 @@ private:
static const unsigned bar_width = 20;
static const unsigned bar_speed = 8;
+
+ static struct drm_color_lut gamma_table[LUT_ENTRIES];
+ static bool lut_active;
};
+bool FlipState::lut_active = false;
+struct drm_color_lut FlipState::gamma_table[LUT_ENTRIES];
static void main_flip(Card& card, const vector<OutputInfo>& outputs)
{