1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2016 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev * Authors: AMD 23*b843c749SSergey Zigachev * 24*b843c749SSergey Zigachev */ 25*b843c749SSergey Zigachev 26*b843c749SSergey Zigachev #ifndef COLOR_MOD_COLOR_GAMMA_H_ 27*b843c749SSergey Zigachev #define COLOR_MOD_COLOR_GAMMA_H_ 28*b843c749SSergey Zigachev 29*b843c749SSergey Zigachev struct dc_transfer_func; 30*b843c749SSergey Zigachev struct dc_gamma; 31*b843c749SSergey Zigachev struct dc_transfer_func_distributed_points; 32*b843c749SSergey Zigachev struct dc_rgb_fixed; 33*b843c749SSergey Zigachev enum dc_transfer_func_predefined; 34*b843c749SSergey Zigachev 35*b843c749SSergey Zigachev /* For SetRegamma ADL interface support 36*b843c749SSergey Zigachev * Must match escape type 37*b843c749SSergey Zigachev */ 38*b843c749SSergey Zigachev union regamma_flags { 39*b843c749SSergey Zigachev unsigned int raw; 40*b843c749SSergey Zigachev struct { 41*b843c749SSergey Zigachev unsigned int gammaRampArray :1; // RegammaRamp is in use 42*b843c749SSergey Zigachev unsigned int gammaFromEdid :1; //gamma from edid is in use 43*b843c749SSergey Zigachev unsigned int gammaFromEdidEx :1; //gamma from edid is in use , but only for Display Id 1.2 44*b843c749SSergey Zigachev unsigned int gammaFromUser :1; //user custom gamma is used 45*b843c749SSergey Zigachev unsigned int coeffFromUser :1; //coeff. A0-A3 from user is in use 46*b843c749SSergey Zigachev unsigned int coeffFromEdid :1; //coeff. A0-A3 from edid is in use 47*b843c749SSergey Zigachev unsigned int applyDegamma :1; //flag for additional degamma correction in driver 48*b843c749SSergey Zigachev unsigned int gammaPredefinedSRGB :1; //flag for SRGB gamma 49*b843c749SSergey Zigachev unsigned int gammaPredefinedPQ :1; //flag for PQ gamma 50*b843c749SSergey Zigachev unsigned int gammaPredefinedPQ2084Interim :1; //flag for PQ gamma, lower max nits 51*b843c749SSergey Zigachev unsigned int gammaPredefined36 :1; //flag for 3.6 gamma 52*b843c749SSergey Zigachev unsigned int gammaPredefinedReset :1; //flag to return to previous gamma 53*b843c749SSergey Zigachev } bits; 54*b843c749SSergey Zigachev }; 55*b843c749SSergey Zigachev 56*b843c749SSergey Zigachev struct regamma_ramp { 57*b843c749SSergey Zigachev unsigned short gamma[256*3]; // gamma ramp packed in same way as OS windows ,r , g & b 58*b843c749SSergey Zigachev }; 59*b843c749SSergey Zigachev 60*b843c749SSergey Zigachev struct regamma_coeff { 61*b843c749SSergey Zigachev int gamma[3]; 62*b843c749SSergey Zigachev int A0[3]; 63*b843c749SSergey Zigachev int A1[3]; 64*b843c749SSergey Zigachev int A2[3]; 65*b843c749SSergey Zigachev int A3[3]; 66*b843c749SSergey Zigachev }; 67*b843c749SSergey Zigachev 68*b843c749SSergey Zigachev struct regamma_lut { 69*b843c749SSergey Zigachev union regamma_flags flags; 70*b843c749SSergey Zigachev union { 71*b843c749SSergey Zigachev struct regamma_ramp ramp; 72*b843c749SSergey Zigachev struct regamma_coeff coeff; 73*b843c749SSergey Zigachev }; 74*b843c749SSergey Zigachev }; 75*b843c749SSergey Zigachev 76*b843c749SSergey Zigachev void setup_x_points_distribution(void); 77*b843c749SSergey Zigachev void precompute_pq(void); 78*b843c749SSergey Zigachev void precompute_de_pq(void); 79*b843c749SSergey Zigachev 80*b843c749SSergey Zigachev bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, 81*b843c749SSergey Zigachev const struct dc_gamma *ramp, bool mapUserRamp); 82*b843c749SSergey Zigachev 83*b843c749SSergey Zigachev bool mod_color_calculate_degamma_params(struct dc_transfer_func *output_tf, 84*b843c749SSergey Zigachev const struct dc_gamma *ramp, bool mapUserRamp); 85*b843c749SSergey Zigachev 86*b843c749SSergey Zigachev bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, 87*b843c749SSergey Zigachev struct dc_transfer_func_distributed_points *points); 88*b843c749SSergey Zigachev 89*b843c749SSergey Zigachev bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, 90*b843c749SSergey Zigachev struct dc_transfer_func_distributed_points *points); 91*b843c749SSergey Zigachev 92*b843c749SSergey Zigachev bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, 93*b843c749SSergey Zigachev const struct regamma_lut *regamma); 94*b843c749SSergey Zigachev 95*b843c749SSergey Zigachev bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, 96*b843c749SSergey Zigachev const struct regamma_lut *regamma); 97*b843c749SSergey Zigachev 98*b843c749SSergey Zigachev 99*b843c749SSergey Zigachev #endif /* COLOR_MOD_COLOR_GAMMA_H_ */ 100