/** ***************************************************************************** * Function: dal_transform_wide_gamut_set_gamut_remap * * @param [in] const struct xfm_grph_csc_adjustment *adjust * * @return * void * * @note calculate and apply color temperature adjustment to in Rgb color space * * @see * ***************************************************************************** */ static void dce_transform_set_gamut_remap( struct transform *xfm, const struct xfm_grph_csc_adjustment *adjust) { struct dce_transform *xfm_dce = TO_DCE_TRANSFORM(xfm); int i = 0; if (adjust->gamut_adjust_type != GRAPHICS_GAMUT_ADJUST_TYPE_SW) /* Bypass if type is bypass or hw */ program_gamut_remap(xfm_dce, NULL); else { struct fixed31_32 arr_matrix[GAMUT_MATRIX_SIZE]; uint16_t arr_reg_val[GAMUT_MATRIX_SIZE]; for (i = 0; i < GAMUT_MATRIX_SIZE; i++) arr_matrix[i] = adjust->temperature_matrix[i]; convert_float_matrix( arr_reg_val, arr_matrix, GAMUT_MATRIX_SIZE); program_gamut_remap(xfm_dce, arr_reg_val); } }
/** ***************************************************************************** * Function: dal_transform_wide_gamut_set_gamut_remap * * @param [in] const struct xfm_grph_csc_adjustment *adjust * * @return * void * * @note calculate and apply color temperature adjustment to in Rgb color space * * @see * ***************************************************************************** */ void dce80_transform_set_gamut_remap( struct transform *xfm, const struct xfm_grph_csc_adjustment *adjust) { struct dce80_transform *xfm80 = TO_DCE80_TRANSFORM(xfm); if (adjust->gamut_adjust_type != GRAPHICS_GAMUT_ADJUST_TYPE_SW || adjust->temperature_divider == 0) program_gamut_remap(xfm80, NULL); else { struct fixed31_32 arr_matrix[GAMUT_MATRIX_SIZE]; uint16_t arr_reg_val[GAMUT_MATRIX_SIZE]; arr_matrix[0] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[0], adjust->temperature_divider); arr_matrix[1] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[1], adjust->temperature_divider); arr_matrix[2] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[2], adjust->temperature_divider); arr_matrix[3] = dal_fixed31_32_zero; arr_matrix[4] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[3], adjust->temperature_divider); arr_matrix[5] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[4], adjust->temperature_divider); arr_matrix[6] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[5], adjust->temperature_divider); arr_matrix[7] = dal_fixed31_32_zero; arr_matrix[8] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[6], adjust->temperature_divider); arr_matrix[9] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[7], adjust->temperature_divider); arr_matrix[10] = dal_fixed31_32_from_fraction( adjust->temperature_matrix[8], adjust->temperature_divider); arr_matrix[11] = dal_fixed31_32_zero; convert_float_matrix( arr_reg_val, arr_matrix, GAMUT_MATRIX_SIZE); program_gamut_remap(xfm80, arr_reg_val); } }
/** ***************************************************************************** * Function: dal_transform_wide_gamut_set_rgb_adjustment_legacy * * @param [in] const struct opp_grph_csc_adjustment *adjust * * @return * void * * @note calculate and program color adjustments for sRGB color space * * @see * ***************************************************************************** */ static void set_rgb_adjustment_legacy( struct dce110_opp *opp110, const struct opp_grph_csc_adjustment *adjust) { const struct fixed31_32 k1 = dal_fixed31_32_from_fraction(701000, 1000000); const struct fixed31_32 k2 = dal_fixed31_32_from_fraction(236568, 1000000); const struct fixed31_32 k3 = dal_fixed31_32_from_fraction(-587000, 1000000); const struct fixed31_32 k4 = dal_fixed31_32_from_fraction(464432, 1000000); const struct fixed31_32 k5 = dal_fixed31_32_from_fraction(-114000, 1000000); const struct fixed31_32 k6 = dal_fixed31_32_from_fraction(-701000, 1000000); const struct fixed31_32 k7 = dal_fixed31_32_from_fraction(-299000, 1000000); const struct fixed31_32 k8 = dal_fixed31_32_from_fraction(-292569, 1000000); const struct fixed31_32 k9 = dal_fixed31_32_from_fraction(413000, 1000000); const struct fixed31_32 k10 = dal_fixed31_32_from_fraction(-92482, 1000000); const struct fixed31_32 k11 = dal_fixed31_32_from_fraction(-114000, 1000000); const struct fixed31_32 k12 = dal_fixed31_32_from_fraction(385051, 1000000); const struct fixed31_32 k13 = dal_fixed31_32_from_fraction(-299000, 1000000); const struct fixed31_32 k14 = dal_fixed31_32_from_fraction(886000, 1000000); const struct fixed31_32 k15 = dal_fixed31_32_from_fraction(-587000, 1000000); const struct fixed31_32 k16 = dal_fixed31_32_from_fraction(-741914, 1000000); const struct fixed31_32 k17 = dal_fixed31_32_from_fraction(886000, 1000000); const struct fixed31_32 k18 = dal_fixed31_32_from_fraction(-144086, 1000000); const struct fixed31_32 luma_r = dal_fixed31_32_from_fraction(299, 1000); const struct fixed31_32 luma_g = dal_fixed31_32_from_fraction(587, 1000); const struct fixed31_32 luma_b = dal_fixed31_32_from_fraction(114, 1000); struct out_csc_color_matrix tbl_entry; struct fixed31_32 matrix[OUTPUT_CSC_MATRIX_SIZE]; struct fixed31_32 grph_cont; struct fixed31_32 grph_sat; struct fixed31_32 grph_bright; struct fixed31_32 sin_grph_hue; struct fixed31_32 cos_grph_hue; initialize_color_float_adj_reference_values( adjust, &grph_cont, &grph_sat, &grph_bright, &sin_grph_hue, &cos_grph_hue); /* COEF_1_1 = GrphCont * (LumaR + GrphSat * (Cos(GrphHue) * K1 + * Sin(GrphHue) * K2)) */ /* (Cos(GrphHue) * K1 + Sin(GrphHue) * K2) */ matrix[0] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k1), dal_fixed31_32_mul(sin_grph_hue, k2)); /* GrphSat * (Cos(GrphHue) * K1 + Sin(GrphHue) * K2 */ matrix[0] = dal_fixed31_32_mul(grph_sat, matrix[0]); /* (LumaR + GrphSat * (Cos(GrphHue) * K1 + Sin(GrphHue) * K2)) */ matrix[0] = dal_fixed31_32_add(luma_r, matrix[0]); /* GrphCont * (LumaR + GrphSat * (Cos(GrphHue) * K1 + Sin(GrphHue) * * K2)) */ matrix[0] = dal_fixed31_32_mul(grph_cont, matrix[0]); /* COEF_1_2 = GrphCont * (LumaG + GrphSat * (Cos(GrphHue) * K3 + * Sin(GrphHue) * K4)) */ /* (Cos(GrphHue) * K3 + Sin(GrphHue) * K4) */ matrix[1] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k3), dal_fixed31_32_mul(sin_grph_hue, k4)); /* GrphSat * (Cos(GrphHue) * K3 + Sin(GrphHue) * K4) */ matrix[1] = dal_fixed31_32_mul(grph_sat, matrix[1]); /* (LumaG + GrphSat * (Cos(GrphHue) * K3 + Sin(GrphHue) * K4)) */ matrix[1] = dal_fixed31_32_add(luma_g, matrix[1]); /* GrphCont * (LumaG + GrphSat * (Cos(GrphHue) * K3 + Sin(GrphHue) * * K4)) */ matrix[1] = dal_fixed31_32_mul(grph_cont, matrix[1]); /* COEF_1_3 = GrphCont * (LumaB + GrphSat * (Cos(GrphHue) * K5 + * Sin(GrphHue) * K6)) */ /* (Cos(GrphHue) * K5 + Sin(GrphHue) * K6) */ matrix[2] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k5), dal_fixed31_32_mul(sin_grph_hue, k6)); /* GrphSat * (Cos(GrphHue) * K5 + Sin(GrphHue) * K6) */ matrix[2] = dal_fixed31_32_mul(grph_sat, matrix[2]); /* LumaB + GrphSat * (Cos(GrphHue) * K5 + Sin(GrphHue) * K6) */ matrix[2] = dal_fixed31_32_add(luma_b, matrix[2]); /* GrphCont * (LumaB + GrphSat * (Cos(GrphHue) * K5 + Sin(GrphHue) * * K6)) */ matrix[2] = dal_fixed31_32_mul(grph_cont, matrix[2]); /* COEF_1_4 = GrphBright */ matrix[3] = grph_bright; /* COEF_2_1 = GrphCont * (LumaR + GrphSat * (Cos(GrphHue) * K7 + * Sin(GrphHue) * K8)) */ /* (Cos(GrphHue) * K7 + Sin(GrphHue) * K8) */ matrix[4] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k7), dal_fixed31_32_mul(sin_grph_hue, k8)); /* GrphSat * (Cos(GrphHue) * K7 + Sin(GrphHue) * K8) */ matrix[4] = dal_fixed31_32_mul(grph_sat, matrix[4]); /* (LumaR + GrphSat * (Cos(GrphHue) * K7 + Sin(GrphHue) * K8)) */ matrix[4] = dal_fixed31_32_add(luma_r, matrix[4]); /* GrphCont * (LumaR + GrphSat * (Cos(GrphHue) * K7 + Sin(GrphHue) * * K8)) */ matrix[4] = dal_fixed31_32_mul(grph_cont, matrix[4]); /* COEF_2_2 = GrphCont * (LumaG + GrphSat * (Cos(GrphHue) * K9 + * Sin(GrphHue) * K10)) */ /* (Cos(GrphHue) * K9 + Sin(GrphHue) * K10)) */ matrix[5] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k9), dal_fixed31_32_mul(sin_grph_hue, k10)); /* GrphSat * (Cos(GrphHue) * K9 + Sin(GrphHue) * K10)) */ matrix[5] = dal_fixed31_32_mul(grph_sat, matrix[5]); /* (LumaG + GrphSat * (Cos(GrphHue) * K9 + Sin(GrphHue) * K10)) */ matrix[5] = dal_fixed31_32_add(luma_g, matrix[5]); /* GrphCont * (LumaG + GrphSat * (Cos(GrphHue) * K9 + Sin(GrphHue) * * K10)) */ matrix[5] = dal_fixed31_32_mul(grph_cont, matrix[5]); /* COEF_2_3 = GrphCont * (LumaB + GrphSat * (Cos(GrphHue) * K11 + * Sin(GrphHue) * K12)) */ /* (Cos(GrphHue) * K11 + Sin(GrphHue) * K12)) */ matrix[6] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k11), dal_fixed31_32_mul(sin_grph_hue, k12)); /* GrphSat * (Cos(GrphHue) * K11 + Sin(GrphHue) * K12)) */ matrix[6] = dal_fixed31_32_mul(grph_sat, matrix[6]); /* (LumaB + GrphSat * (Cos(GrphHue) * K11 + Sin(GrphHue) * K12)) */ matrix[6] = dal_fixed31_32_add(luma_b, matrix[6]); /* GrphCont * (LumaB + GrphSat * (Cos(GrphHue) * K11 + Sin(GrphHue) * * K12)) */ matrix[6] = dal_fixed31_32_mul(grph_cont, matrix[6]); /* COEF_2_4 = GrphBright */ matrix[7] = grph_bright; /* COEF_3_1 = GrphCont * (LumaR + GrphSat * (Cos(GrphHue) * K13 + * Sin(GrphHue) * K14)) */ /* (Cos(GrphHue) * K13 + Sin(GrphHue) * K14)) */ matrix[8] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k13), dal_fixed31_32_mul(sin_grph_hue, k14)); /* GrphSat * (Cos(GrphHue) * K13 + Sin(GrphHue) * K14)) */ matrix[8] = dal_fixed31_32_mul(grph_sat, matrix[8]); /* (LumaR + GrphSat * (Cos(GrphHue) * K13 + Sin(GrphHue) * K14)) */ matrix[8] = dal_fixed31_32_add(luma_r, matrix[8]); /* GrphCont * (LumaR + GrphSat * (Cos(GrphHue) * K13 + Sin(GrphHue) * * K14)) */ matrix[8] = dal_fixed31_32_mul(grph_cont, matrix[8]); /* COEF_3_2 = GrphCont * (LumaG + GrphSat * (Cos(GrphHue) * K15 + * Sin(GrphHue) * K16)) */ /* GrphSat * (Cos(GrphHue) * K15 + Sin(GrphHue) * K16) */ matrix[9] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k15), dal_fixed31_32_mul(sin_grph_hue, k16)); /* (LumaG + GrphSat * (Cos(GrphHue) * K15 + Sin(GrphHue) * K16)) */ matrix[9] = dal_fixed31_32_mul(grph_sat, matrix[9]); /* (LumaG + GrphSat * (Cos(GrphHue) * K15 + Sin(GrphHue) * K16)) */ matrix[9] = dal_fixed31_32_add(luma_g, matrix[9]); /* GrphCont * (LumaG + GrphSat * (Cos(GrphHue) * K15 + Sin(GrphHue) * * K16)) */ matrix[9] = dal_fixed31_32_mul(grph_cont, matrix[9]); /* COEF_3_3 = GrphCont * (LumaB + GrphSat * (Cos(GrphHue) * K17 + * Sin(GrphHue) * K18)) */ /* (Cos(GrphHue) * K17 + Sin(GrphHue) * K18)) */ matrix[10] = dal_fixed31_32_add( dal_fixed31_32_mul(cos_grph_hue, k17), dal_fixed31_32_mul(sin_grph_hue, k18)); /* GrphSat * (Cos(GrphHue) * K17 + Sin(GrphHue) * K18)) */ matrix[10] = dal_fixed31_32_mul(grph_sat, matrix[10]); /* (LumaB + GrphSat * (Cos(GrphHue) * K17 + Sin(GrphHue) * K18)) */ matrix[10] = dal_fixed31_32_add(luma_b, matrix[10]); /* GrphCont * (LumaB + GrphSat * (Cos(GrphHue) * K17 + Sin(GrphHue) * * K18)) */ matrix[10] = dal_fixed31_32_mul(grph_cont, matrix[10]); /* COEF_3_4 = GrphBright */ matrix[11] = grph_bright; tbl_entry.color_space = adjust->c_space; convert_float_matrix(tbl_entry.regval, matrix, OUTPUT_CSC_MATRIX_SIZE); program_color_matrix( opp110, &tbl_entry, adjust->color_adjust_option); }