xref: /aosp_15_r20/external/mesa3d/src/amd/vpelib/inc/vpelib.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /* Copyright 2022 Advanced Micro Devices, Inc.
2*61046927SAndroid Build Coastguard Worker  *
3*61046927SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
4*61046927SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the "Software"),
5*61046927SAndroid Build Coastguard Worker  * to deal in the Software without restriction, including without limitation
6*61046927SAndroid Build Coastguard Worker  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7*61046927SAndroid Build Coastguard Worker  * and/or sell copies of the Software, and to permit persons to whom the
8*61046927SAndroid Build Coastguard Worker  * Software is furnished to do so, subject to the following conditions:
9*61046927SAndroid Build Coastguard Worker  *
10*61046927SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice shall be included in
11*61046927SAndroid Build Coastguard Worker  * all copies or substantial portions of the Software.
12*61046927SAndroid Build Coastguard Worker  *
13*61046927SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14*61046927SAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15*61046927SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16*61046927SAndroid Build Coastguard Worker  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
17*61046927SAndroid Build Coastguard Worker  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18*61046927SAndroid Build Coastguard Worker  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19*61046927SAndroid Build Coastguard Worker  * OTHER DEALINGS IN THE SOFTWARE.
20*61046927SAndroid Build Coastguard Worker  *
21*61046927SAndroid Build Coastguard Worker  * Authors: AMD
22*61046927SAndroid Build Coastguard Worker  *
23*61046927SAndroid Build Coastguard Worker  */
24*61046927SAndroid Build Coastguard Worker 
25*61046927SAndroid Build Coastguard Worker #pragma once
26*61046927SAndroid Build Coastguard Worker 
27*61046927SAndroid Build Coastguard Worker #include "vpe_types.h"
28*61046927SAndroid Build Coastguard Worker #include "vpe_version.h"
29*61046927SAndroid Build Coastguard Worker 
30*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
31*61046927SAndroid Build Coastguard Worker extern "C" {
32*61046927SAndroid Build Coastguard Worker #endif
33*61046927SAndroid Build Coastguard Worker 
34*61046927SAndroid Build Coastguard Worker /* @brief Create the VPE lib instance.
35*61046927SAndroid Build Coastguard Worker  *
36*61046927SAndroid Build Coastguard Worker  * Caler provides the current asic info,
37*61046927SAndroid Build Coastguard Worker  * logging and system memory APIs.
38*61046927SAndroid Build Coastguard Worker  * It initializes all the necessary resources for the asic
39*61046927SAndroid Build Coastguard Worker  * and returns the general capabilities of the engines.
40*61046927SAndroid Build Coastguard Worker  *
41*61046927SAndroid Build Coastguard Worker  * For capabilities based on conditions,
42*61046927SAndroid Build Coastguard Worker  * shall be done by vpe->cap_funcs.*
43*61046927SAndroid Build Coastguard Worker  *
44*61046927SAndroid Build Coastguard Worker  *
45*61046927SAndroid Build Coastguard Worker  * @param[in] params  provide the asic version, APIs for logging and memory
46*61046927SAndroid Build Coastguard Worker  * @return            vpe instance if supported. NULL otherwise
47*61046927SAndroid Build Coastguard Worker  */
48*61046927SAndroid Build Coastguard Worker struct vpe *vpe_create(const struct vpe_init_data *params);
49*61046927SAndroid Build Coastguard Worker 
50*61046927SAndroid Build Coastguard Worker /* @brief Destroy the VPE lib instance and resources
51*61046927SAndroid Build Coastguard Worker  *
52*61046927SAndroid Build Coastguard Worker  * @param[in] vpe   the vpe instance created by vpe_create
53*61046927SAndroid Build Coastguard Worker  */
54*61046927SAndroid Build Coastguard Worker void vpe_destroy(struct vpe **vpe);
55*61046927SAndroid Build Coastguard Worker 
56*61046927SAndroid Build Coastguard Worker /**
57*61046927SAndroid Build Coastguard Worker  * @brief Check if the VPE operation is supported.
58*61046927SAndroid Build Coastguard Worker  *
59*61046927SAndroid Build Coastguard Worker  * Caller must call this to check if the VPE supports
60*61046927SAndroid Build Coastguard Worker  * the requested operation before calling vpe_build_commands().
61*61046927SAndroid Build Coastguard Worker  * If operation is supported, it returns the memory requirement.
62*61046927SAndroid Build Coastguard Worker  *
63*61046927SAndroid Build Coastguard Worker  * The caller has to prepare those required memories
64*61046927SAndroid Build Coastguard Worker  *  and pass them to the vpe_build_commands().
65*61046927SAndroid Build Coastguard Worker  *
66*61046927SAndroid Build Coastguard Worker  * @param[in]  vpe      vpe instance returned by vpe_initialize()
67*61046927SAndroid Build Coastguard Worker  * @param[in]  param    build params
68*61046927SAndroid Build Coastguard Worker  * @param[out] req      memory required for the command buffer and
69*61046927SAndroid Build Coastguard Worker                         embedded data if return VPE_OK.
70*61046927SAndroid Build Coastguard Worker                         caller has to alloc them and provide it to build_vpbilts API.
71*61046927SAndroid Build Coastguard Worker  * @return VPE_OK if supported
72*61046927SAndroid Build Coastguard Worker  */
73*61046927SAndroid Build Coastguard Worker enum vpe_status vpe_check_support(
74*61046927SAndroid Build Coastguard Worker     struct vpe *vpe, const struct vpe_build_param *param, struct vpe_bufs_req *req);
75*61046927SAndroid Build Coastguard Worker 
76*61046927SAndroid Build Coastguard Worker /************************************
77*61046927SAndroid Build Coastguard Worker  * Command building functions
78*61046927SAndroid Build Coastguard Worker  ************************************/
79*61046927SAndroid Build Coastguard Worker /**
80*61046927SAndroid Build Coastguard Worker  * Build the command descriptors for No-Op operation
81*61046927SAndroid Build Coastguard Worker  * @param[in]      vpe             vpe instance created by vpe_create()
82*61046927SAndroid Build Coastguard Worker  * @param[in]      num_dwords      number of noops
83*61046927SAndroid Build Coastguard Worker  * @param[in,out]  ppcmd_space     in: dword aligned command buffer start address
84*61046927SAndroid Build Coastguard Worker  *                                 out: dword aligned next good write address
85*61046927SAndroid Build Coastguard Worker  * @return status
86*61046927SAndroid Build Coastguard Worker  */
87*61046927SAndroid Build Coastguard Worker enum vpe_status vpe_build_noops(struct vpe *vpe, uint32_t num_dwords, uint32_t **ppcmd_space);
88*61046927SAndroid Build Coastguard Worker 
89*61046927SAndroid Build Coastguard Worker /**
90*61046927SAndroid Build Coastguard Worker  * build the command descriptors for the given param.
91*61046927SAndroid Build Coastguard Worker  * caller must call vpe_check_support() before this function,
92*61046927SAndroid Build Coastguard Worker  * unexpected result otherwise.
93*61046927SAndroid Build Coastguard Worker  *
94*61046927SAndroid Build Coastguard Worker  * @param[in]  vpe      vpe instance created by vpe_create()
95*61046927SAndroid Build Coastguard Worker  * @param[in]  param    vpe build params
96*61046927SAndroid Build Coastguard Worker  * @param[in,out]  bufs  [in]  memory allocated for the command buffer, embedded buffer and 3dlut.
97*61046927SAndroid Build Coastguard Worker  *                             If size is 0, it reports the required size for this checked
98*61046927SAndroid Build Coastguard Worker  * operation. [out] the next write address and the filled sizes.
99*61046927SAndroid Build Coastguard Worker  * @return status
100*61046927SAndroid Build Coastguard Worker  */
101*61046927SAndroid Build Coastguard Worker enum vpe_status vpe_build_commands(
102*61046927SAndroid Build Coastguard Worker     struct vpe *vpe, const struct vpe_build_param *param, struct vpe_build_bufs *bufs);
103*61046927SAndroid Build Coastguard Worker 
104*61046927SAndroid Build Coastguard Worker /**
105*61046927SAndroid Build Coastguard Worker  * get the optimal number of taps based on the scaling ratio.
106*61046927SAndroid Build Coastguard Worker  * @param[in]  vpe      vpe instance created by vpe_create()
107*61046927SAndroid Build Coastguard Worker  * @param[in,out]  scaling_info  [in] source and destination rectangles [out] calculated taps.
108*61046927SAndroid Build Coastguard Worker  */
109*61046927SAndroid Build Coastguard Worker 
110*61046927SAndroid Build Coastguard Worker void vpe_get_optimal_num_of_taps(struct vpe *vpe, struct vpe_scaling_info *scaling_info);
111*61046927SAndroid Build Coastguard Worker 
112*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
113*61046927SAndroid Build Coastguard Worker }
114*61046927SAndroid Build Coastguard Worker #endif
115