* just multiply with 2^gamma which can be computed once, and save the result so we
* recursively compute all the values.
*/
- /*sRGB 709 2.2 2.4 P3*/
-static const int32_t gamma_numerator01[] = { 31308, 180000, 0, 0, 0};
-static const int32_t gamma_numerator02[] = { 12920, 4500, 0, 0, 0};
-static const int32_t gamma_numerator03[] = { 55, 99, 0, 0, 0};
-static const int32_t gamma_numerator04[] = { 55, 99, 0, 0, 0};
-static const int32_t gamma_numerator05[] = { 2400, 2200, 2200, 2400, 2600};
+ /*sRGB 709 2.2 2.4 P3*/
+static const int32_t regamma_numerator01[] = { 31308, 180000, 0, 0, 0};
+static const int32_t regamma_numerator02[] = { 12920, 4500, 0, 0, 0};
+static const int32_t regamma_numerator03[] = { 55, 99, 0, 0, 0};
+static const int32_t regamma_numerator04[] = { 55, 99, 0, 0, 0};
+static const int32_t regamma_numerator05[] = { 2400, 2200, 2200, 2400, 2600};
+
+static const int32_t degamma_numerator01[] = { 40450, 810000, 0, 0, 0};
+static const int32_t degamma_numerator02[] = { 12920, 4500, 0, 0, 0};
+static const int32_t degamma_numerator03[] = { 55, 99, 0, 0, 0};
+static const int32_t degamma_numerator04[] = { 55, 99, 0, 0, 0};
+static const int32_t degamma_numerator05[] = { 2400, 2200, 2200, 2400, 2600};
/* one-time setup of X points */
void setup_x_points_distribution(void)
};
-static bool build_coefficients(struct gamma_coefficients *coefficients, enum dc_transfer_func_predefined type)
+static bool build_coefficients(struct gamma_coefficients *coefficients,
+ enum dc_transfer_func_predefined type, bool isRegamma)
{
uint32_t i = 0;
}
do {
- coefficients->a0[i] = dc_fixpt_from_fraction(
- gamma_numerator01[index], 10000000);
- coefficients->a1[i] = dc_fixpt_from_fraction(
- gamma_numerator02[index], 1000);
- coefficients->a2[i] = dc_fixpt_from_fraction(
- gamma_numerator03[index], 1000);
- coefficients->a3[i] = dc_fixpt_from_fraction(
- gamma_numerator04[index], 1000);
- coefficients->user_gamma[i] = dc_fixpt_from_fraction(
- gamma_numerator05[index], 1000);
+ if (isRegamma) {
+ coefficients->a0[i] = dc_fixpt_from_fraction(
+ regamma_numerator01[index], 10000000);
+ coefficients->a1[i] = dc_fixpt_from_fraction(
+ regamma_numerator02[index], 1000);
+ coefficients->a2[i] = dc_fixpt_from_fraction(
+ regamma_numerator03[index], 1000);
+ coefficients->a3[i] = dc_fixpt_from_fraction(
+ regamma_numerator04[index], 1000);
+ coefficients->user_gamma[i] = dc_fixpt_from_fraction(
+ regamma_numerator05[index], 1000);
+ } else {
+ coefficients->a0[i] = dc_fixpt_from_fraction(
+ degamma_numerator01[index], 10000000);
+ coefficients->a1[i] = dc_fixpt_from_fraction(
+ degamma_numerator02[index], 1000);
+ coefficients->a2[i] = dc_fixpt_from_fraction(
+ degamma_numerator03[index], 1000);
+ coefficients->a3[i] = dc_fixpt_from_fraction(
+ degamma_numerator04[index], 1000);
+ coefficients->user_gamma[i] = dc_fixpt_from_fraction(
+ degamma_numerator05[index], 1000);
+ }
++i;
} while (i != ARRAY_SIZE(coefficients->a0));
if (!coeff)
goto release;
- if (!build_coefficients(coeff, type))
+ if (!build_coefficients(coeff, type, true))
goto release;
memset(cal_buffer->buffer, 0, NUM_PTS_IN_REGION * sizeof(struct fixed31_32));
uint32_t begin_index, end_index;
bool ret = false;
- if (!build_coefficients(&coeff, type))
+ if (!build_coefficients(&coeff, type, false))
goto release;
i = 0;
struct pwl_float_data_ex *rgb = rgb_regamma;
const struct hw_x_point *coord_x = coordinates_x;
- build_coefficients(&coeff, TRANSFER_FUNCTION_SRGB);
+ build_coefficients(&coeff, TRANSFER_FUNCTION_SRGB, true);
i = 0;
while (i != hw_points_num + 1) {