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
29#include "color_table.h"
30
31struct dc_transfer_func;
32struct dc_gamma;
33struct dc_transfer_func_distributed_points;
34struct dc_rgb_fixed;
35struct dc_color_caps;
36enum dc_transfer_func_predefined;
37
38
39
40
41union regamma_flags {
42 unsigned int raw;
43 struct {
44 unsigned int gammaRampArray :1;
45 unsigned int gammaFromEdid :1;
46 unsigned int gammaFromEdidEx :1;
47 unsigned int gammaFromUser :1;
48 unsigned int coeffFromUser :1;
49 unsigned int coeffFromEdid :1;
50 unsigned int applyDegamma :1;
51 unsigned int gammaPredefinedSRGB :1;
52 unsigned int gammaPredefinedPQ :1;
53 unsigned int gammaPredefinedPQ2084Interim :1;
54 unsigned int gammaPredefined36 :1;
55 unsigned int gammaPredefinedReset :1;
56 } bits;
57};
58
59struct regamma_ramp {
60 unsigned short gamma[256*3];
61};
62
63struct regamma_coeff {
64 int gamma[3];
65 int A0[3];
66 int A1[3];
67 int A2[3];
68 int A3[3];
69};
70
71struct regamma_lut {
72 union regamma_flags flags;
73 union {
74 struct regamma_ramp ramp;
75 struct regamma_coeff coeff;
76 };
77};
78
79struct freesync_hdr_tf_params {
80 unsigned int sdr_white_level;
81 unsigned int min_content;
82 unsigned int max_content;
83 unsigned int min_display;
84 unsigned int max_display;
85 unsigned int skip_tm;
86};
87
88struct calculate_buffer {
89 int buffer_index;
90 struct fixed31_32 buffer[NUM_PTS_IN_REGION];
91 struct fixed31_32 gamma_of_2;
92};
93
94struct translate_from_linear_space_args {
95 struct fixed31_32 arg;
96 struct fixed31_32 a0;
97 struct fixed31_32 a1;
98 struct fixed31_32 a2;
99 struct fixed31_32 a3;
100 struct fixed31_32 gamma;
101 struct calculate_buffer *cal_buffer;
102};
103
104void setup_x_points_distribution(void);
105void log_x_points_distribution(struct dal_logger *logger);
106void precompute_pq(void);
107void precompute_de_pq(void);
108
109bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
110 const struct dc_gamma *ramp, bool mapUserRamp, bool canRomBeUsed,
111 const struct freesync_hdr_tf_params *fs_params,
112 struct calculate_buffer *cal_buffer);
113
114bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps,
115 struct dc_transfer_func *output_tf,
116 const struct dc_gamma *ramp, bool mapUserRamp);
117
118bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
119 struct dc_transfer_func_distributed_points *points);
120
121bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
122 const struct regamma_lut *regamma,
123 struct calculate_buffer *cal_buffer,
124 const struct dc_gamma *ramp);
125
126bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
127 const struct regamma_lut *regamma,
128 struct calculate_buffer *cal_buffer,
129 const struct dc_gamma *ramp);
130
131
132#endif
133