1 /*
2 * Copyright (c) 2013-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      codechal_secure_decode_interface.h
24 //! \brief     Stub file for CodecHal Secure Decode
25 //!
26 #ifndef __CODECHAL_SECURE_DECODE_INTERFACE_H__
27 #define __CODECHAL_SECURE_DECODE_INTERFACE_H__
28 
29 #include "codechal_hw.h"
30 
31 //!
32 //! \class  CodechalSecureDecode
33 //! \brief  Codechal secure decode
34 //!
35 class CodechalSecureDecodeInterface
36 {
37 public:
38 
39     //!
40     //! \brief  Allocate Resource
41     //!
42     virtual MOS_STATUS AllocateResource(void *state) = 0;
43 
44     //!
45     //! \brief  Execute Huc StreamOut
46     //!
47     virtual MOS_STATUS Execute(void *state) = 0;
48 
49     //!
50     //! \brief  Set Bitstream Buffer
51     //!
52     virtual MOS_STATUS SetBitstreamBuffer(MHW_VDBOX_IND_OBJ_BASE_ADDR_PARAMS *indObjBaseAddrParams) = 0;
53 
54     //!
55     //! \brief  Set HEVC Huc Dmem S2L Bss
56     //!
57     virtual MOS_STATUS SetHevcHucDmemS2LBss(
58         void          *state,
59         void          *hucPicBss,
60         void          *hucSliceBss) = 0;
61 
62     //!
63     //! \brief  Add Hevc Huc SecureState
64     //!
65     virtual MOS_STATUS AddHucSecureState(
66         void *              state,
67         void *              hevcSliceState,
68         PMOS_COMMAND_BUFFER cmdBuffer) = 0;
69 
70     //!
71     //! \brief  Set Huc StreamObject Params
72     //!
73     virtual MOS_STATUS SetHucStreamObj(
74         PMHW_VDBOX_HUC_STREAM_OBJ_PARAMS hucStreamObjParams) = 0;
75 
76     //!
77     //! \brief  Add Hevc Hcp SecureState
78     //!
79     virtual MOS_STATUS AddHcpSecureState(
80         PMOS_COMMAND_BUFFER             cmdBuffer,
81         void                            *sliceState) = 0;
82 
83     //!
84     //! \brief  Reset VP9 SegId Buffer With Huc
85     //!
86     virtual MOS_STATUS ResetVP9SegIdBufferWithHuc(
87         void                    *state,
88         PMOS_COMMAND_BUFFER     cmdBuffer) = 0;
89 
90     //!
91     //! \brief  Update VP9 ProbBuffer With Huc
92     //!
93     virtual MOS_STATUS UpdateVP9ProbBufferWithHuc(
94         bool                     isFullUpdate,
95         void                     *state,
96         PMOS_COMMAND_BUFFER      cmdBuffer) = 0;
97 
98     //!
99     //! \brief Encrypt default cdf table buffer through HuC copy
100     //! \return MOS_STATUS
101     //!         MOS_STATUS_SUCCESS if success, else fail reason
102     //!
103     virtual MOS_STATUS ProtectDefaultCdfTableBuffer(
104         void            *state,
105         uint32_t        bufIndex,
106         PMOS_COMMAND_BUFFER cmdBuffer) = 0;
107 
108     //!
109     //! \brief Return the temp cdf table buffer
110     //! \return PMOS_RESOURCE
111     //!
112     virtual PMOS_RESOURCE GetTempCdfTableBuffer() = 0;
113 
114     //!
115     //! \brief  Is aux data invalid
116     //!
117     virtual bool IsAuxDataInvalid(
118         PMOS_RESOURCE res) = 0;
119 
120     //!
121     //! \brief Encrypt aux buffer through partial copy
122     //! \return MOS_STATUS
123     //!         MOS_STATUS_SUCCESS if success, else fail reason
124     //!
125     virtual MOS_STATUS InitAuxSurface(
126         PMOS_RESOURCE res,
127         bool auxUV,
128         bool isMmcEnabled) = 0;
129 
130     //!
131     //! \brief  Is Dummy SteamOut Enabled
132     //!
133     virtual bool IsDummyStreamEnabled() = 0;
134 
135     //!
136     //! \brief  Destructor
137     //!
~CodechalSecureDecodeInterface()138     virtual ~CodechalSecureDecodeInterface(){}
139 
140     //!
141     //! \brief  Update huc streamout buffer index
142     //!
143     virtual MOS_STATUS UpdateHuCStreamoutBufferIndex() = 0;
144 
145     //!
146     //! \brief  Use same IV for each subsample
147     //!
148     virtual void EnableSampleGroupConstantIV() = 0;
149 };
150 
151 
152 //!
153 //! \brief    Create CodechalSecureDeocde Object
154 //!           Must use Delete_CodechalSecureDecodeInterface to delete created Object to avoid ULT Memory Leak errors
155 //!
156 //! \return   Return CP Wrapper Object
157 //!
158 CodechalSecureDecodeInterface *Create_SecureDecodeInterface(
159     CodechalSetting *      codechalSettings,
160     CodechalHwInterface *  hwInterfaceInput);
161 
162 //!
163 //! \brief    Delete the CodecHalSecureDecode Object
164 //!
165 //! \param    [in] *pMhwCpInterface
166 //!           MhwCpInterface
167 //!
168 void Delete_SecureDecodeInterface(CodechalSecureDecodeInterface* pCodechalSecureDecodeInterface);
169 
170 #endif // __CODECHAL_SECURE_DECODE_H__
171