xref: /aosp_15_r20/external/mesa3d/src/amd/vpelib/src/core/inc/vpe_desc_writer.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 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct vpe_desc_writer {
34     struct vpe_buf *buf; /**< store the current buf pointer */
35 
36     /* store the base addr of the currnet config
37      * i.e. config header
38      * it is always constructed in emb_buf
39      */
40     uint64_t        base_gpu_va;
41     uint64_t        base_cpu_va;
42 
43     uint32_t        num_config_desc;
44     bool            plane_desc_added;
45     enum vpe_status status;
46 
47     /* public function hooks for vpe desc writer */
48 
49     /** initialize the vpe descriptor writer with buffer
50      * Calls right before building any vpe descriptor
51      *
52      * @param   writer      writer instance
53      * @param   buf         points to the current buf,
54      *                      each config_writer_fill will update the address
55      * @param   cd          count down of slice in a frame
56      */
57     enum vpe_status (*init)(struct vpe_desc_writer *writer, struct vpe_buf *buf, int cd);
58 
59     /** add the plane descriptor address to the vpe descriptor
60      *
61      * @param   writer              writer instance
62      * @param   plane_desc_addr     plane descriptor address
63      * @param   tmz
64      */
65     void (*add_plane_desc)(struct vpe_desc_writer *writer, uint64_t plane_desc_addr, uint8_t tmz);
66 
67     /** add the plane descriptor address to the vpe descriptor
68      *
69      * @param   writer              writer instance
70      * @param   plane_desc_addr     plane descriptor address
71      * @param   tmz
72      */
73     void (*add_config_desc)(
74         struct vpe_desc_writer *writer, uint64_t config_desc_addr, bool reuse, uint8_t tmz);
75 
76     /** finalize the config descriptor header
77      * @param   writer              writer instance
78      */
79     void (*complete)(struct vpe_desc_writer *writer);
80 };
81 
82 #ifdef __cplusplus
83 }
84 #endif
85