summaryrefslogtreecommitdiff
path: root/tests/kms_color_helper.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2020-11-30 18:13:09 +0200
committerVille Syrjälä <ville.syrjala@linux.intel.com>2021-09-16 17:27:21 +0300
commit36ab5380d94f55a37508c42b96ed01b8269aa35a (patch)
treea6f3e49c721eb3cdce3d901f0eef9c6c70750148 /tests/kms_color_helper.c
parent096d8c36c455255c166437a22da855458a489cf6 (diff)
tests/kms_color: Store r/g/b separately for LUT color tests
Store the r/g/b values separately for each LUT. A lot of hw has a separate 1D LUT for each channel, so with this we can potentially do more interesting tests. Also needed for 3D LUTs (if we should ever support them). Reviewed-by: Bhanuprakash Modem <Bhanuprakash.modem@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'tests/kms_color_helper.c')
-rw-r--r--tests/kms_color_helper.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 68fa5f0e..8b08cdae 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -103,14 +103,19 @@ void free_lut(gamma_lut_t *gamma)
free(gamma);
}
+static void set_rgb(color_t *coeff, double value)
+{
+ coeff->r = coeff->g = coeff->b = value;
+}
+
gamma_lut_t *generate_table(int lut_size, double exp)
{
gamma_lut_t *gamma = alloc_lut(lut_size);
int i;
- gamma->coeffs[0] = 0.0;
+ set_rgb(&gamma->coeffs[0], 0.0);
for (i = 1; i < lut_size; i++)
- gamma->coeffs[i] = pow(i * 1.0 / (lut_size - 1), exp);
+ set_rgb(&gamma->coeffs[i], pow(i * 1.0 / (lut_size - 1), exp));
return gamma;
}
@@ -120,9 +125,9 @@ gamma_lut_t *generate_table_max(int lut_size)
gamma_lut_t *gamma = alloc_lut(lut_size);
int i;
- gamma->coeffs[0] = 0.0;
+ set_rgb(&gamma->coeffs[0], 0.0);
for (i = 1; i < lut_size; i++)
- gamma->coeffs[i] = 1.0;
+ set_rgb(&gamma->coeffs[i], 1.0);
return gamma;
}
@@ -133,7 +138,7 @@ gamma_lut_t *generate_table_zero(int lut_size)
int i;
for (i = 0; i < lut_size; i++)
- gamma->coeffs[i] = 0.0;
+ set_rgb(&gamma->coeffs[i], 0.0);
return gamma;
}
@@ -158,7 +163,9 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
if (IS_CHERRYVIEW(data->devid))
lut_size -= 1;
for (i = 0; i < lut_size; i++) {
- uint32_t v = (gamma->coeffs[i] * max_value);
+ uint32_t r = gamma->coeffs[i].r * max_value;
+ uint32_t g = gamma->coeffs[i].g * max_value;
+ uint32_t b = gamma->coeffs[i].b * max_value;
/*
* Hardware might encode colors on a different number of bits
@@ -166,11 +173,13 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
* Mask the lower bits not provided by the framebuffer so we
* can do CRC comparisons.
*/
- v &= mask;
+ r &= mask;
+ g &= mask;
+ b &= mask;
- lut[i].red = v;
- lut[i].green = v;
- lut[i].blue = v;
+ lut[i].red = r;
+ lut[i].green = g;
+ lut[i].blue = b;
}
if (IS_CHERRYVIEW(data->devid))