xref: /aosp_15_r20/external/mesa3d/src/amd/vpelib/src/core/inc/transform.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 <stdint.h>
28 #include <stddef.h>
29 #include <stdbool.h>
30 #include "vpe_hw_types.h"
31 #include "fixed31_32.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define VPE_GAMUT_REMAP_MATRIX_SIZE 12
38 
39 enum gamut_adjust_type {
40     GAMUT_ADJUST_TYPE_BYPASS = 0,
41     GAMUT_ADJUST_TYPE_SW /* use adjustments */
42 };
43 
44 struct gamut_remap_matrix {
45     struct fixed31_32      matrix[VPE_GAMUT_REMAP_MATRIX_SIZE];
46     enum gamut_adjust_type adjust_type;
47 };
48 
49 enum lb_memory_config {
50     /* Enable all 3 pieces of memory */
51     LB_MEMORY_CONFIG_0 = 0,
52 
53     /* Enable only the first piece of memory */
54     LB_MEMORY_CONFIG_1 = 1,
55 
56     /* Enable only the second piece of memory */
57     LB_MEMORY_CONFIG_2 = 2,
58 
59     /* Only applicable in 4:2:0 mode, enable all 3 pieces of memory and the
60      * last piece of chroma memory used for the luma storage
61      */
62     LB_MEMORY_CONFIG_3 = 3
63 };
64 
65 struct scaling_ratios {
66     struct fixed31_32 horz;
67     struct fixed31_32 vert;
68     struct fixed31_32 horz_c;
69     struct fixed31_32 vert_c;
70 };
71 
72 struct sharpness_adj {
73     int horz;
74     int vert;
75 };
76 
77 struct line_buffer_params {
78     bool alpha_en;
79 };
80 
81 struct scl_inits {
82     struct fixed31_32 h;
83     struct fixed31_32 h_c;
84     struct fixed31_32 v;
85     struct fixed31_32 v_c;
86 };
87 
88 struct scaler_data {
89     uint32_t                          h_active;
90     uint32_t                          v_active;
91     struct vpe_scaling_taps           taps;
92     struct vpe_rect                   viewport;
93     struct vpe_rect                   viewport_c;
94     struct vpe_rect                   dst_viewport;
95     struct vpe_rect                   dst_viewport_c;
96     struct vpe_rect                   recout;
97     struct scaling_ratios             ratios;
98     struct scl_inits                  inits;
99     struct sharpness_adj              sharpness;
100     enum vpe_surface_pixel_format     format;
101     struct line_buffer_params         lb_params;
102     struct vpe_scaling_filter_coeffs *polyphase_filter_coeffs;
103 };
104 
105 const uint16_t *vpe_get_filter_2tap_64p(void);
106 const uint16_t *vpe_get_2tap_bilinear_64p(void);
107 const uint16_t *vpe_get_filter_4tap_64p(struct fixed31_32 ratio);
108 const uint16_t *vpe_get_filter_6tap_64p(struct fixed31_32 ratio);
109 const uint16_t *vpe_get_filter_8tap_64p(struct fixed31_32 ratio);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114