GNU Linux-libre 4.19.295-gnu1
[releases.git] / drivers / gpu / drm / amd / display / dc / dcn10 / dcn10_cm_common.h
1 /*
2  * Copyright 2016 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25
26 #ifndef __DAL_DCN10_CM_COMMON_H__
27 #define __DAL_DCN10_CM_COMMON_H__
28
29 #define TF_HELPER_REG_FIELD_LIST(type) \
30         type exp_region0_lut_offset; \
31         type exp_region0_num_segments; \
32         type exp_region1_lut_offset; \
33         type exp_region1_num_segments;\
34         type field_region_end;\
35         type field_region_end_slope;\
36         type field_region_end_base;\
37         type exp_region_start;\
38         type exp_resion_start_segment;\
39         type field_region_linear_slope
40
41 #define TF_CM_REG_FIELD_LIST(type) \
42         type csc_c11; \
43         type csc_c12
44
45 struct xfer_func_shift {
46         TF_HELPER_REG_FIELD_LIST(uint8_t);
47 };
48
49 struct xfer_func_mask {
50         TF_HELPER_REG_FIELD_LIST(uint32_t);
51 };
52
53 struct xfer_func_reg {
54         struct xfer_func_shift shifts;
55         struct xfer_func_mask masks;
56
57         uint32_t start_cntl_b;
58         uint32_t start_cntl_g;
59         uint32_t start_cntl_r;
60         uint32_t start_slope_cntl_b;
61         uint32_t start_slope_cntl_g;
62         uint32_t start_slope_cntl_r;
63         uint32_t start_end_cntl1_b;
64         uint32_t start_end_cntl2_b;
65         uint32_t start_end_cntl1_g;
66         uint32_t start_end_cntl2_g;
67         uint32_t start_end_cntl1_r;
68         uint32_t start_end_cntl2_r;
69         uint32_t region_start;
70         uint32_t region_end;
71 };
72
73 struct cm_color_matrix_shift {
74         TF_CM_REG_FIELD_LIST(uint8_t);
75 };
76
77 struct cm_color_matrix_mask {
78         TF_CM_REG_FIELD_LIST(uint32_t);
79 };
80
81 struct color_matrices_reg{
82         struct cm_color_matrix_shift shifts;
83         struct cm_color_matrix_mask masks;
84
85         uint32_t csc_c11_c12;
86         uint32_t csc_c33_c34;
87 };
88
89 void cm_helper_program_color_matrices(
90                 struct dc_context *ctx,
91                 const uint16_t *regval,
92                 const struct color_matrices_reg *reg);
93
94 void cm_helper_program_xfer_func(
95                 struct dc_context *ctx,
96                 const struct pwl_params *params,
97                 const struct xfer_func_reg *reg);
98
99 bool cm_helper_convert_to_custom_float(
100                 struct pwl_result_data *rgb_resulted,
101                 struct curve_points *arr_points,
102                 uint32_t hw_points_num,
103                 bool fixpoint);
104
105 bool cm_helper_translate_curve_to_hw_format(
106                 const struct dc_transfer_func *output_tf,
107                 struct pwl_params *lut_params, bool fixpoint);
108
109 bool cm_helper_translate_curve_to_degamma_hw_format(
110                                 const struct dc_transfer_func *output_tf,
111                                 struct pwl_params *lut_params);
112
113
114 #endif