1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef COLOR_MOD_COLOR_GAMMA_H_
27#define COLOR_MOD_COLOR_GAMMA_H_
28
29struct dc_transfer_func;
30struct dc_gamma;
31struct dc_transfer_func_distributed_points;
32struct dc_rgb_fixed;
33struct dc_color_caps;
34enum dc_transfer_func_predefined;
35
36
37
38
39union regamma_flags {
40 unsigned int raw;
41 struct {
42 unsigned int gammaRampArray :1;
43 unsigned int gammaFromEdid :1;
44 unsigned int gammaFromEdidEx :1;
45 unsigned int gammaFromUser :1;
46 unsigned int coeffFromUser :1;
47 unsigned int coeffFromEdid :1;
48 unsigned int applyDegamma :1;
49 unsigned int gammaPredefinedSRGB :1;
50 unsigned int gammaPredefinedPQ :1;
51 unsigned int gammaPredefinedPQ2084Interim :1;
52 unsigned int gammaPredefined36 :1;
53 unsigned int gammaPredefinedReset :1;
54 } bits;
55};
56
57struct regamma_ramp {
58 unsigned short gamma[256*3];
59};
60
61struct regamma_coeff {
62 int gamma[3];
63 int A0[3];
64 int A1[3];
65 int A2[3];
66 int A3[3];
67};
68
69struct regamma_lut {
70 union regamma_flags flags;
71 union {
72 struct regamma_ramp ramp;
73 struct regamma_coeff coeff;
74 };
75};
76
77struct freesync_hdr_tf_params {
78 unsigned int sdr_white_level;
79 unsigned int min_content;
80 unsigned int max_content;
81 unsigned int min_display;
82 unsigned int max_display;
83 unsigned int skip_tm;
84};
85
86struct translate_from_linear_space_args {
87 struct fixed31_32 arg;
88 struct fixed31_32 a0;
89 struct fixed31_32 a1;
90 struct fixed31_32 a2;
91 struct fixed31_32 a3;
92 struct fixed31_32 gamma;
93};
94
95void setup_x_points_distribution(void);
96void log_x_points_distribution(struct dal_logger *logger);
97void precompute_pq(void);
98void precompute_de_pq(void);
99
100bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
101 const struct dc_gamma *ramp, bool mapUserRamp, bool canRomBeUsed,
102 const struct freesync_hdr_tf_params *fs_params);
103
104bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps,
105 struct dc_transfer_func *output_tf,
106 const struct dc_gamma *ramp, bool mapUserRamp);
107
108bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
109 struct dc_transfer_func_distributed_points *points);
110
111bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
112 const struct regamma_lut *regamma);
113
114bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
115 const struct regamma_lut *regamma);
116
117
118#endif
119