xref: /aosp_15_r20/external/mesa3d/src/amd/vpelib/src/core/inc/dpp.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /* Copyright 2022 Advanced Micro Devices, Inc.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a
4  * copy of this software and associated documentation files (the "Software"),
5  * to deal in the Software without restriction, including without limitation
6  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7  * and/or sell copies of the Software, and to permit persons to whom the
8  * Software is furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
17  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19  * OTHER DEALINGS IN THE SOFTWARE.
20  *
21  * Authors: AMD
22  *
23  */
24 
25 #pragma once
26 
27 #include "vpe_types.h"
28 #include "hw_shared.h"
29 #include "color.h"
30 #include "transform.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 struct dpp;
37 struct vpe_priv;
38 struct vpe_csc_matrix;
39 
40 struct cnv_alpha_2bit_lut {
41     int lut0;
42     int lut1;
43     int lut2;
44     int lut3;
45 };
46 
47 enum CNV_COLOR_KEYER_MODE {
48     CNV_COLOR_KEYER_MODE_FORCE_00 = 0,
49     CNV_COLOR_KEYER_MODE_FORCE_FF = 1,
50     CNV_COLOR_KEYER_MODE_RANGE_00 = 2,
51     CNV_COLOR_KEYER_MODE_RANGE_FF = 3
52 };
53 
54 struct cnv_color_keyer_params {
55     int color_keyer_en;
56     int color_keyer_mode;
57     int color_keyer_alpha_low;
58     int color_keyer_alpha_high;
59     int color_keyer_red_low;
60     int color_keyer_red_high;
61     int color_keyer_green_low;
62     int color_keyer_green_high;
63     int color_keyer_blue_low;
64     int color_keyer_blue_high;
65 };
66 
67 enum input_csc_select {
68     INPUT_CSC_SELECT_BYPASS = 0,
69     INPUT_CSC_SELECT_ICSC   = 1,
70 };
71 
72 struct dpp_funcs {
73 
74     bool (*get_optimal_number_of_taps)(
75         struct vpe_rect *src_rect, struct vpe_rect *dst_rect, struct vpe_scaling_taps *taps);
76 
77     void (*dscl_calc_lb_num_partitions)(const struct scaler_data *scl_data,
78         enum lb_memory_config lb_config, uint32_t *num_part_y, uint32_t *num_part_c);
79 
80     /** non segment specific */
81     void (*program_cnv)(
82         struct dpp *dpp, enum vpe_surface_pixel_format format, enum vpe_expansion_mode mode);
83 
84     void (*program_pre_dgam)(struct dpp *dpp, enum color_transfer_func tr);
85 
86     void (*program_cnv_bias_scale)(struct dpp *dpp, struct bias_and_scale *bias_and_scale);
87 
88     void (*program_alpha_keyer)(struct dpp *dpp, struct cnv_color_keyer_params *color_keyer);
89 
90     void (*program_input_transfer_func)(struct dpp *dpp, struct transfer_func *input_tf);
91 
92     void (*program_gamut_remap)(struct dpp *dpp, struct colorspace_transform *gamut_remap);
93 
94     /*program post scaler scs block in dpp CM*/
95     void (*program_post_csc)(struct dpp *dpp, enum color_space color_space,
96         enum input_csc_select input_select, struct vpe_csc_matrix *input_cs);
97 
98     void (*set_hdr_multiplier)(struct dpp *dpp, uint32_t multiplier);
99 
100     /** scaler */
101     void (*set_segment_scaler)(struct dpp *dpp, const struct scaler_data *scl_data);
102 
103     void (*set_frame_scaler)(struct dpp *dpp, const struct scaler_data *scl_data);
104 
105     uint32_t (*get_line_buffer_size)(void);
106 
107     bool (*validate_number_of_taps)(struct dpp *dpp, struct scaler_data *scl_data);
108 
109     void (*program_crc)(struct dpp *opp, bool enable);
110 };
111 
112 struct dpp {
113     struct vpe_priv  *vpe_priv;
114     struct dpp_funcs *funcs;
115 
116     struct pwl_params degamma_params;
117 };
118 
119 #ifdef __cplusplus
120 }
121 #endif
122