summaryrefslogtreecommitdiff
path: root/tests/kms_color_helper.h
diff options
context:
space:
mode:
authorKunal Joshi <kunal1.joshi@intel.com>2020-01-23 13:30:40 +0530
committerPetri Latvala <petri.latvala@intel.com>2020-01-27 11:10:09 +0200
commit62db2b8d9e957c6e383fb064941b216fcf4cf64e (patch)
tree0b9435aa419aa6100970d450324eaf82fb4ee55f /tests/kms_color_helper.h
parenta8c3f73c73b2c61b4461a83300e4c533a3fafdd1 (diff)
Moved common function in kms_color and kms_color_chamelium to kms_color_helper.c
kms_color and kms_color_chamelium shared common functions. Moved them to tests/kms_color_helper.c to avoid code duplication. (v4) Made a library kms_color_helper.c which is specific to kms_color and kms_color_chamelium. Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com> Signed-off-by: Swati Sharma <swati2.sharma@intel.com> Suggested-by: Uma Shankar <uma.shankar@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'tests/kms_color_helper.h')
-rw-r--r--tests/kms_color_helper.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
new file mode 100644
index 00000000..88890724
--- /dev/null
+++ b/tests/kms_color_helper.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#ifndef IGT_KMS_COLOR_HELPER_H
+#define IGT_KMS_COLOR_HELPER_H
+
+/*
+ * This header is for code that is shared between kms_color.c and
+ * kms_color_chamelium.c. Reusability elsewhere can be questionable.
+ */
+
+#include <math.h>
+#include <unistd.h>
+
+#include "drm.h"
+#include "drmtest.h"
+#include "igt.h"
+
+
+/* Internal */
+typedef struct {
+ double r, g, b;
+} color_t;
+
+typedef struct {
+ int drm_fd;
+ uint32_t devid;
+ igt_display_t display;
+ igt_pipe_crc_t *pipe_crc;
+
+ uint32_t color_depth;
+ uint64_t degamma_lut_size;
+ uint64_t gamma_lut_size;
+ #ifdef HAVE_CHAMELIUM
+ struct chamelium *chamelium;
+ struct chamelium_port **ports;
+ int port_count;
+ #endif
+} data_t;
+
+typedef struct {
+ int size;
+ double coeffs[];
+} gamma_lut_t;
+
+void paint_gradient_rectangles(data_t *data,
+ drmModeModeInfo *mode,
+ color_t *colors,
+ struct igt_fb *fb);
+void paint_rectangles(data_t *data,
+ drmModeModeInfo *mode,
+ color_t *colors,
+ struct igt_fb *fb);
+gamma_lut_t *alloc_lut(int lut_size);
+void free_lut(gamma_lut_t *gamma);
+gamma_lut_t *generate_table(int lut_size, double exp);
+gamma_lut_t *generate_table_max(int lut_size);
+gamma_lut_t *generate_table_zero(int lut_size);
+struct drm_color_lut *coeffs_to_lut(data_t *data,
+ const gamma_lut_t *gamma,
+ uint32_t color_depth,
+ int off);
+void set_degamma(data_t *data,
+ igt_pipe_t *pipe,
+ const gamma_lut_t *gamma);
+void set_gamma(data_t *data,
+ igt_pipe_t *pipe,
+ const gamma_lut_t *gamma);
+void set_ctm(igt_pipe_t *pipe, const double *coefficients);
+void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop);
+
+#define disable_degamma(pipe) disable_prop(pipe, IGT_CRTC_DEGAMMA_LUT)
+#define disable_gamma(pipe) disable_prop(pipe, IGT_CRTC_GAMMA_LUT)
+#define disable_ctm(pipe) disable_prop(pipe, IGT_CRTC_CTM)
+
+drmModePropertyBlobPtr get_blob(data_t *data, igt_pipe_t *pipe,
+ enum igt_atomic_crtc_properties prop);
+bool crc_equal(igt_crc_t *a, igt_crc_t *b);
+int pipe_set_property_blob_id(igt_pipe_t *pipe,
+ enum igt_atomic_crtc_properties prop,
+ uint32_t blob_id);
+int pipe_set_property_blob(igt_pipe_t *pipe,
+ enum igt_atomic_crtc_properties prop,
+ void *ptr, size_t length);
+void invalid_gamma_lut_sizes(data_t *data);
+void invalid_degamma_lut_sizes(data_t *data);
+void invalid_ctm_matrix_sizes(data_t *data);
+#endif
+