1 /*
2 * Copyright (c) 2014-2017, 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 mhw_cp_interface.h
24 //! \brief MHW interface for content protection
25 //! \details Impelements the functionalities across all platforms for content protection
26 //!
27
28 #ifndef __MHW_CP_INTERFACE_H__
29 #define __MHW_CP_INTERFACE_H__
30
31 #include "mhw_mi.h"
32 #include "mos_os.h"
33 #include "mos_util_debug.h"
34
35 class MhwMiInterface;
36 namespace mhw
37 {
38 namespace mi
39 {
40 class Itf;
41 }
42 } // namespace mhw
43
44 typedef int32_t CP_MODE;
45 #define CP_TYPE_NONE 0
46
47 enum _CP_SECURITY_TYPE: int32_t;
48
49 typedef enum _CP_SECURITY_TYPE CP_SECURITY_TYPE;
50
51 typedef struct _MHW_CP_SLICE_INFO_PARAMS
52 {
53 PMOS_RESOURCE presDataBuffer = nullptr;
54 uint32_t dwDataLength[2] = {0}; // 1 is for DECE mode, 0 is for others
55 uint32_t dwDataStartOffset[2] = {0}; // 1 is for DECE mode, 0 is for others
56 uint32_t dwSliceIndex = 0;
57 bool bLastPass = false;
58 uint32_t dwTotalBytesConsumed = 0;
59 } MHW_CP_SLICE_INFO_PARAMS, *PMHW_CP_SLICE_INFO_PARAMS;
60
61 typedef struct _MHW_CP_COPY_PARAMS
62 {
63 PMOS_RESOURCE presSrc;
64 PMOS_RESOURCE presDst;
65 uint32_t size;
66 uint16_t lengthOfTable;
67 bool isEncodeInUse;
68 } MHW_CP_COPY_PARAMS, *PMHW_CP_COPY_PARAMS;
69
70 typedef struct _MHW_ADD_CP_COPY_PARAMS
71 {
72 PMOS_RESOURCE presSrc;
73 PMOS_RESOURCE presDst;
74 uint32_t size;
75 uint64_t offset;
76 bool bypass;
77 } MHW_ADD_CP_COPY_PARAMS, *PMHW_ADD_CP_COPY_PARAMS;
78
MhwStubMessage()79 static void MhwStubMessage()
80 {
81 MOS_NORMALMESSAGE(MOS_COMPONENT_CP, MOS_CP_SUBCOMP_MHW, "This function is stubbed as it is not implemented.");
82 }
83
84 class MhwCpInterface
85 {
86 public:
~MhwCpInterface()87 virtual ~MhwCpInterface() {}
88
AddProlog(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer)89 virtual MOS_STATUS AddProlog(
90 PMOS_INTERFACE osInterface,
91 PMOS_COMMAND_BUFFER cmdBuffer)
92 {
93 MOS_UNUSED(osInterface);
94 MOS_UNUSED(cmdBuffer);
95
96 MhwStubMessage();
97 return MOS_STATUS_SUCCESS;
98 }
99
RefreshCounter(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer)100 virtual MOS_STATUS RefreshCounter(
101 PMOS_INTERFACE osInterface,
102 PMOS_COMMAND_BUFFER cmdBuffer)
103 {
104 MOS_UNUSED(osInterface);
105 MOS_UNUSED(cmdBuffer);
106 return MOS_STATUS_SUCCESS;
107 }
108
IsHwCounterIncrement(PMOS_INTERFACE osInterface)109 virtual bool IsHwCounterIncrement(
110 PMOS_INTERFACE osInterface)
111 {
112 MOS_UNUSED(osInterface);
113
114 MhwStubMessage();
115 return false;
116 }
117
AddEpilog(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer)118 virtual MOS_STATUS AddEpilog(
119 PMOS_INTERFACE osInterface,
120 PMOS_COMMAND_BUFFER cmdBuffer)
121 {
122 MOS_UNUSED(osInterface);
123 MOS_UNUSED(cmdBuffer);
124
125 MhwStubMessage();
126 return MOS_STATUS_SUCCESS;
127 }
128
AddCheckForEarlyExit(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer)129 virtual MOS_STATUS AddCheckForEarlyExit(
130 PMOS_INTERFACE osInterface,
131 PMOS_COMMAND_BUFFER cmdBuffer)
132 {
133 MOS_UNUSED(osInterface);
134 MOS_UNUSED(cmdBuffer);
135
136 MhwStubMessage();
137 return MOS_STATUS_SUCCESS;
138 }
139
CheckStatusReportNum(void * mfxRegisters,uint32_t cencBufIndex,PMOS_RESOURCE resource,PMOS_COMMAND_BUFFER cmdBuffer)140 virtual MOS_STATUS CheckStatusReportNum(
141 void * mfxRegisters,
142 uint32_t cencBufIndex,
143 PMOS_RESOURCE resource,
144 PMOS_COMMAND_BUFFER cmdBuffer)
145 {
146 MOS_UNUSED(mfxRegisters);
147 MOS_UNUSED(cencBufIndex);
148 MOS_UNUSED(resource);
149 MOS_UNUSED(cmdBuffer);
150
151 MhwStubMessage();
152 return MOS_STATUS_SUCCESS;
153 }
154
SetCpCopy(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer,PMHW_CP_COPY_PARAMS params)155 virtual MOS_STATUS SetCpCopy(
156 PMOS_INTERFACE osInterface,
157 PMOS_COMMAND_BUFFER cmdBuffer,
158 PMHW_CP_COPY_PARAMS params)
159 {
160 MOS_UNUSED(osInterface);
161 MOS_UNUSED(cmdBuffer);
162 MOS_UNUSED(params);
163
164 MhwStubMessage();
165 return MOS_STATUS_SUCCESS;
166 }
167
AddCpCopy(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer,PMHW_ADD_CP_COPY_PARAMS params)168 virtual MOS_STATUS AddCpCopy(
169 PMOS_INTERFACE osInterface,
170 PMOS_COMMAND_BUFFER cmdBuffer,
171 PMHW_ADD_CP_COPY_PARAMS params)
172 {
173 MOS_UNUSED(osInterface);
174 MOS_UNUSED(cmdBuffer);
175 MOS_UNUSED(params);
176
177 MhwStubMessage();
178 return MOS_STATUS_SUCCESS;
179 }
180
ReadEncodeCounterFromHW(PMOS_INTERFACE osInterface,PMOS_COMMAND_BUFFER cmdBuffer,PMOS_RESOURCE resource,uint16_t currentIndex)181 virtual MOS_STATUS ReadEncodeCounterFromHW(
182 PMOS_INTERFACE osInterface,
183 PMOS_COMMAND_BUFFER cmdBuffer,
184 PMOS_RESOURCE resource,
185 uint16_t currentIndex)
186 {
187 MOS_UNUSED(osInterface);
188 MOS_UNUSED(cmdBuffer);
189 MOS_UNUSED(resource);
190 MOS_UNUSED(currentIndex);
191
192 MhwStubMessage();
193 return MOS_STATUS_SUCCESS;
194 }
195
SetProtectionSettingsForMiFlushDw(PMOS_INTERFACE osInterface,void * cmd)196 virtual MOS_STATUS SetProtectionSettingsForMiFlushDw(
197 PMOS_INTERFACE osInterface,
198 void * cmd)
199 {
200 MOS_UNUSED(osInterface);
201 MOS_UNUSED(cmd);
202
203 MhwStubMessage();
204 return MOS_STATUS_SUCCESS;
205 }
206
SetProtectionSettingsForMfxWait(PMOS_INTERFACE osInterface,void * cmd)207 virtual MOS_STATUS SetProtectionSettingsForMfxWait(
208 PMOS_INTERFACE osInterface,
209 void * cmd)
210 {
211 MOS_UNUSED(osInterface);
212 MOS_UNUSED(cmd);
213
214 MhwStubMessage();
215 return MOS_STATUS_SUCCESS;
216 }
217
SetProtectionSettingsForMfxPipeModeSelect(uint32_t * data)218 virtual MOS_STATUS SetProtectionSettingsForMfxPipeModeSelect(uint32_t *data)
219 {
220 MOS_UNUSED(data);
221
222 MhwStubMessage();
223 return MOS_STATUS_SUCCESS;
224 }
225
226 virtual MOS_STATUS SetProtectionSettingsForHcpPipeModeSelect(
227 uint32_t *data,
228 bool scalableEncode = false)
229 {
230 MOS_UNUSED(data);
231
232 MhwStubMessage();
233 return MOS_STATUS_SUCCESS;
234 }
235
SetProtectionSettingsForHucPipeModeSelect(uint32_t * data)236 virtual MOS_STATUS SetProtectionSettingsForHucPipeModeSelect(uint32_t *data)
237 {
238 MOS_UNUSED(data);
239
240 MhwStubMessage();
241 return MOS_STATUS_SUCCESS;
242 }
243
SetProtectionSettingsForReservedPipeModeSelect(uint32_t * data)244 virtual MOS_STATUS SetProtectionSettingsForReservedPipeModeSelect(uint32_t *data)
245 {
246 MOS_UNUSED(data);
247
248 MhwStubMessage();
249 return MOS_STATUS_SUCCESS;
250 }
251
SetMfxProtectionState(bool isDecodeInUse,PMOS_COMMAND_BUFFER cmdBuffer,PMHW_BATCH_BUFFER batchBuffer,PMHW_CP_SLICE_INFO_PARAMS sliceInfoParam)252 virtual MOS_STATUS SetMfxProtectionState(
253 bool isDecodeInUse,
254 PMOS_COMMAND_BUFFER cmdBuffer,
255 PMHW_BATCH_BUFFER batchBuffer,
256 PMHW_CP_SLICE_INFO_PARAMS sliceInfoParam)
257 {
258 MOS_UNUSED(isDecodeInUse);
259 MOS_UNUSED(cmdBuffer);
260 MOS_UNUSED(batchBuffer);
261 MOS_UNUSED(sliceInfoParam);
262
263 MhwStubMessage();
264 return MOS_STATUS_SUCCESS;
265 }
266
SetHcpProtectionState(bool isDecodeInUse,PMOS_COMMAND_BUFFER cmdBuffer,PMHW_BATCH_BUFFER batchBuffer,PMHW_CP_SLICE_INFO_PARAMS sliceInfoParam)267 virtual MOS_STATUS SetHcpProtectionState(
268 bool isDecodeInUse,
269 PMOS_COMMAND_BUFFER cmdBuffer,
270 PMHW_BATCH_BUFFER batchBuffer,
271 PMHW_CP_SLICE_INFO_PARAMS sliceInfoParam)
272 {
273 MOS_UNUSED(isDecodeInUse);
274 MOS_UNUSED(cmdBuffer);
275 MOS_UNUSED(batchBuffer);
276 MOS_UNUSED(sliceInfoParam);
277
278 MhwStubMessage();
279 return MOS_STATUS_SUCCESS;
280 }
281
RegisterMiInterface(MhwMiInterface * miInterface)282 virtual MOS_STATUS RegisterMiInterface(
283 MhwMiInterface *miInterface)
284 {
285 MOS_UNUSED(miInterface);
286
287 MhwStubMessage();
288 return MOS_STATUS_SUCCESS;
289 }
290
RegisterMiInterfaceNext(std::shared_ptr<mhw::mi::Itf> m_miItf)291 virtual MOS_STATUS RegisterMiInterfaceNext(
292 std::shared_ptr<mhw::mi::Itf> m_miItf)
293 {
294 MOS_UNUSED(m_miItf);
295
296 MhwStubMessage();
297 return MOS_STATUS_SUCCESS;
298 }
299
GetCpStateLevelCmdSize(uint32_t & cmdSize,uint32_t & patchListSize)300 virtual void GetCpStateLevelCmdSize(
301 uint32_t &cmdSize,
302 uint32_t &patchListSize)
303 {
304 cmdSize = 0;
305 patchListSize = 0;
306
307 MhwStubMessage();
308 return;
309 }
310
GetCpSliceLevelCmdSize(uint32_t & cmdSize,uint32_t & patchListSize)311 virtual void GetCpSliceLevelCmdSize(
312 uint32_t &cmdSize,
313 uint32_t &patchListSize)
314 {
315 cmdSize = 0;
316 patchListSize = 0;
317
318 MhwStubMessage();
319 return;
320 }
321
RegisterParams(void * params)322 virtual void RegisterParams(void *params)
323 {
324 MOS_UNUSED(params);
325 MhwStubMessage();
326 }
327
UpdateParams(bool isInput)328 virtual MOS_STATUS UpdateParams(bool isInput)
329 {
330 MOS_UNUSED(isInput);
331 MhwStubMessage();
332 return MOS_STATUS_SUCCESS;
333 }
334
335 virtual void SetCpSecurityType(
336 CP_SECURITY_TYPE type = static_cast<CP_SECURITY_TYPE>(1))
337 {
338 MOS_UNUSED(type);
339 MhwStubMessage();
340 }
341
GetCounterValue(uint32_t * ctr)342 virtual MOS_STATUS GetCounterValue(uint32_t *ctr)
343 {
344 MhwStubMessage();
345 return MOS_STATUS_SUCCESS;
346 }
347
348 MEDIA_CLASS_DEFINE_END(MhwCpInterface)
349 };
350
351 //!
352 //! \brief Create MhwCpInterface Object
353 //! Must use Delete_MhwCpInterface to delete created Object to avoid ULT Memory Leak errors
354 //!
355 //! \return Return CP Wrapper Object if CPLIB not loaded
356 //!
357 MhwCpInterface* Create_MhwCpInterface(PMOS_INTERFACE osInterface);
358
359 //!
360 //! \brief Delete the MhwCpInterface Object
361 //!
362 //! \param [in] *pMhwCpInterface
363 //! MhwCpInterface
364 //!
365 void Delete_MhwCpInterface(MhwCpInterface* pMhwCpInterface);
366 #endif
367