xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/cp/decodecp_interface.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2019-2021, Intel Corporation
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
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS 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 //!
23 //! \file     decodecp_interface.h
24 //! \brief    Impelements the public interface for CodecHal Secure Decode
25 //!
26 #ifndef __DECODE_CP_INTERFACE_H__
27 #define __DECODE_CP_INTERFACE_H__
28 
29 #include "mos_util_debug.h"
30 #include "codechal_setting.h"
31 #include "mos_os_specific.h"
32 #include "codec_hw_next.h"
33 #include "mos_utilities.h"
34 
35 #define DECODE_CP_ASSERT(_ptr) \
36     MOS_ASSERT(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _ptr)
37 
38 #define DECODE_CP_ASSERTMESSAGE(_message, ...) \
39     MOS_ASSERTMESSAGE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _message, ##__VA_ARGS__)
40 
41 #define DECODE_CP_NORMALMESSAGE(_message, ...) \
42     MOS_NORMALMESSAGE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _message, ##__VA_ARGS__)
43 
44 #define DECODE_CP_VERBOSEMESSAGE(_message, ...) \
45     MOS_VERBOSEMESSAGE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _message, ##__VA_ARGS__)
46 
47 #define DECODE_CP_CHK_STATUS(_stmt) \
48     MOS_CHK_STATUS_RETURN(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _stmt)
49 
50 #define DECODE_CP_CHK_STATUS_MESSAGE(_stmt, _message, ...) \
51     MOS_CHK_STATUS_MESSAGE_RETURN(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _stmt, _message, ##__VA_ARGS__)
52 
53 #define DECODE_CP_CHK_NULL_RETURN(_ptr) \
54     MOS_CHK_NULL_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _ptr)
55 
56 #define DECODE_CP_CHK_NULL_NO_STATUS_RETURN(_ptr) \
57     MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _ptr)
58 
59 #define DECODE_CP_CHK_COND(_condition, retVal, _message, ...) \
60     MOS_CHK_COND_RETURN_VALUE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, (_condition), (retVal), (_message), ##__VA_ARGS__)
61 #define DECODE_CP_CHK_COND_RETURN(_expr, _message, ...) \
62     MOS_CHK_COND_RETURN(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, _expr, _message, ##__VA_ARGS__)
63 #define DECODE_CP_FUNCTION_ENTER \
64     MOS_FUNCTION_ENTER(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC)
65 
66 #define DECODE_CP_FUNCTION_EXIT(eStatus) \
67     MOS_FUNCTION_EXIT(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, eStatus)
68 
69 namespace decode
70 {
71     class DecodePipeline;
72     class DecodeSubPacket;
73 }
74 
75 class DecodeCpInterface
76 {
77 public:
~DecodeCpInterface()78     virtual ~DecodeCpInterface(){};
79     //!
80     //! \brief  Add Hcp SecureState
81     //! \return MOS_STATUS
82     //!         MOS_STATUS_SUCCESS if success, else fail reason
83     //!
84 
85     virtual MOS_STATUS AddHcpState(
86         PMOS_COMMAND_BUFFER cmdBuffer,
87         PMOS_RESOURCE       presDataBuffer,
88         uint32_t            length,
89         uint32_t            startoffset,
90         uint32_t            dwsliceIndex) = 0;
91 
92     //!
93     //! \brief  Add Huc State
94     //! \return MOS_STATUS
95     //!         MOS_STATUS_SUCCESS if success, else fail reason
96     //!
97     virtual MOS_STATUS AddHucState(
98         PMOS_COMMAND_BUFFER cmdBuffer,
99         PMOS_RESOURCE       presDataBuffer,
100         uint32_t            length,
101         uint32_t            startoffset,
102         uint32_t            dwsliceIndex) = 0;
103 
104     virtual MOS_STATUS AddHucIndState(
105         PMOS_COMMAND_BUFFER cmdBuffer,
106         PMOS_RESOURCE       presIndState) = 0;
107 
108     virtual MOS_STATUS SetHucDmemS2LPicBss(
109         void *        hucS2LPicBss,
110         PMOS_RESOURCE presDataBuffer) = 0;
111 
112     virtual MOS_STATUS SetHucDmemS2LSliceBss(
113         void *   hucS2LSliceBss,
114         uint32_t index,
115         uint32_t dataSize,
116         uint32_t dataOffset) = 0;
117 
118     virtual MOS_STATUS RegisterParams(void *settings)                    = 0;
119     virtual MOS_STATUS UpdateParams(bool input)                          = 0;
120     virtual MOS_STATUS SetHucPipeModeSelectParameter(bool& param)        = 0;
121     virtual bool       IsStreamOutNeeded()                               = 0;
122     virtual bool       IsStreamOutEnabled()                              = 0;
123     virtual bool       IsCpEnabled()                                     = 0;
124     virtual void       SetCpEnabled(bool isCpInUse)                      = 0;
125 
126     //!
127     //! \brief  CreateDecodeCpIndSubPkt
128     //! \return DecodeSubPacket pointer, return nullptr if failed.
129     //!
130     //!
CreateDecodeCpIndSubPkt(decode::DecodePipeline * pipeline,CODECHAL_MODE mode,CodechalHwInterfaceNext * hwInterface)131     virtual decode::DecodeSubPacket*  CreateDecodeCpIndSubPkt(
132         decode::DecodePipeline *pipeline,
133         CODECHAL_MODE           mode,
134         CodechalHwInterfaceNext    *hwInterface)
135     {
136         MOS_UNUSED(pipeline);
137         MOS_UNUSED(mode);
138         MOS_UNUSED(hwInterface);
139         MOS_ASSERTMESSAGE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, "This function is not implemented.");
140         return nullptr;
141     };
142 
143     //!
144     //! \brief  ExecuteDecodeCpIndSubPkt
145     //! \return MOS_STATUS_SUCCESS if success, else fail reason
146     //!
147     //!
ExecuteDecodeCpIndSubPkt(decode::DecodeSubPacket * packet,CODECHAL_MODE mode,MOS_COMMAND_BUFFER & cmdBuffer,uint32_t sliceIndex)148     virtual MOS_STATUS ExecuteDecodeCpIndSubPkt(
149         decode::DecodeSubPacket *packet,
150         CODECHAL_MODE            mode,
151         MOS_COMMAND_BUFFER      &cmdBuffer,
152         uint32_t                sliceIndex)
153     {
154         MOS_UNUSED(packet);
155         MOS_UNUSED(mode);
156         MOS_UNUSED(cmdBuffer);
157         MOS_UNUSED(sliceIndex);
158         MOS_ASSERTMESSAGE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_CODEC, "This function is not implemented.");
159         return MOS_STATUS_UNIMPLEMENTED;
160     };
161 
162 MEDIA_CLASS_DEFINE_END(DecodeCpInterface)
163 };
164 
165 //!
166 //! \brief    Create DecodeCpInterface Object
167 //!           Must use Delete_DecodeCpInterface to delete created Object to avoid ULT Memory Leak errors
168 //!
169 //! \return   Return CP Wrapper Object if CPLIB not loaded
170 //
171 DecodeCpInterface *Create_DecodeCpInterface(
172     CodechalSetting *    codechalSettings,
173     MhwCpInterface  *    cpInterface,
174     PMOS_INTERFACE       osInterface);
175 
176 //!
177 //! \brief    Delete the DecodeCpInterface Object
178 //!
179 //! \param    [in] *pMhwCpInterface
180 //!           MhwCpInterface
181 //!
182 void Delete_DecodeCpInterface(DecodeCpInterface *pDecodeCpInterface);
183 
184 #endif  // __DECODE_CP_INTERFACE_H__