Debian Codegraph @

media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp

raw
1 /*===================== begin_copyright_notice ==================================
2
3 # Copyright (c) 2021-2024, Intel Corporation
4
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
11
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 # OTHER DEALINGS IN THE SOFTWARE.
22
23 ======================= end_copyright_notice ==================================*/
24 //!
25 //! \file media_interfaces_dg2.cpp
26
27 //! \brief Helps with DG2 factory creation.
28 //!
29
30 #include "media_interfaces_dg2.h"
31 #include "codechal.h"
32 #include "codechal_debug.h"
33 #if defined(ENABLE_KERNELS) && defined(_MEDIA_RESERVED)
34 #include "cm_gpucopy_kernel_xe_hpm.h"
35 #include "cm_gpuinit_kernel_xe_hpm.h"
36 #else
37 unsigned int iGPUCopy_kernel_isa_size_dg2 = 0;
38 unsigned int iGPUInit_kernel_isa_size_dg2 = 0;
39 unsigned char *pGPUCopy_kernel_isa_dg2 = nullptr;
40 unsigned char *pGPUInit_kernel_isa_dg2 = nullptr;
41 #endif
42 #include "vp_pipeline_adapter_xe_hpm.h"
43 #include "vp_platform_interface_xe_hpm.h"
44 #include "vp_kernel_config_g12_base.h"
45 #include "encode_av1_vdenc_pipeline_adapter_xe_hpm.h"
46
47 #if defined(ENABLE_KERNELS)
48 #include "igvpkrn_xe_hpg.h"
49 #include "igvpkrn_xe_hpg_cmfcpatch.h"
50 #if !defined(_FULL_OPEN_SOURCE)
51 #include "igvpkrn_isa_xe_hpg.h"
52 #endif
53 #endif
54 #include "codechal_hw_next_xe_hpm.h"
55
56 using namespace mhw::vdbox::avp::xe_hpm;
57 using namespace mhw::vdbox::vdenc::xe_hpm;
58 using namespace mhw::vdbox::huc::xe_hpm;
59
60 extern template class MediaFactory<uint32_t, MhwInterfaces>;
61 extern template class MediaFactory<uint32_t, MmdDevice>;
62 extern template class MediaFactory<uint32_t, McpyDevice>;
63 extern template class MediaFactory<uint32_t, CodechalDevice>;
64 extern template class MediaFactory<uint32_t, CodechalDeviceNext>;
65 extern template class MediaFactory<uint32_t, CMHalDevice>;
66 extern template class MediaFactory<uint32_t, VphalDevice>;
67 extern template class MediaFactory<uint32_t, RenderHalDevice>;
68 extern template class MediaFactory<uint32_t, Nv12ToP010Device>;
69 extern template class MediaFactory<uint32_t, DecodeHistogramDevice>;
70 extern template class MediaFactory<uint32_t, MediaInterfacesHwInfoDevice>;
71
72 // Swith to use new media factory template
73 extern template class MediaFactory<uint32_t, MhwInterfacesNext>;
74
75 static bool dg2RegisteredVphal =
76 MediaFactory<uint32_t, VphalDevice>::
77 Register<VphalInterfacesXe_Hpm>((uint32_t)IGFX_DG2);
78
79 MOS_STATUS VphalInterfacesXe_Hpm::Initialize(
80 PMOS_INTERFACE osInterface,
81 bool bInitVphalState,
82 MOS_STATUS *eStatus,
83 bool clearViewMode)
84 {
85 bool bApogeiosEnable = true;
86 MOS_USER_FEATURE_VALUE_DATA UserFeatureData;
87 MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData));
88
89 UserFeatureData.i32Data = bApogeiosEnable;
90 UserFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE;
91
92 MOS_UserFeature_ReadValue_ID(
93 nullptr,
94 __MEDIA_USER_FEATURE_VALUE_APOGEIOS_ENABLE_ID,
95 &UserFeatureData,
96 osInterface->pOsContext);
97 bApogeiosEnable = UserFeatureData.bData ? true : false;
98 if (bApogeiosEnable)
99 {
100 vp::VpPlatformInterface *vpPlatformInterface = MOS_New(vp::VpPlatformInterfaceXe_Hpm, osInterface);
101 if (nullptr == vpPlatformInterface)
102 {
103 *eStatus = MOS_STATUS_NULL_POINTER;
104 return *eStatus;
105 }
106
107 InitPlatformKernelBinary(vpPlatformInterface);
108
109 if (!bInitVphalState)
110 {
111 m_vpPipeline = MOS_New(vp::VpPipeline, osInterface);
112 if (nullptr == m_vpPipeline)
113 {
114 MOS_Delete(vpPlatformInterface);
115 MOS_OS_CHK_NULL_RETURN(m_vpPipeline);
116 }
117 m_vpPlatformInterface = vpPlatformInterface;
118 *eStatus = MOS_STATUS_SUCCESS;
119 return *eStatus;
120 }
121
122 m_vpBase = MOS_New(
123 VpPipelineAdapterXe_Hpm,
124 osInterface,
125 *vpPlatformInterface,
126 *eStatus);
127 if (nullptr == m_vpBase)
128 {
129 MOS_Delete(vpPlatformInterface);
130 *eStatus = MOS_STATUS_NULL_POINTER;
131 return *eStatus;
132 }
133 m_isNextEnabled = true;
134 }
135 else
136 {
137 m_vpBase = MOS_New(
138 VphalState,
139 osInterface,
140 eStatus);
141 }
142
143 return *eStatus;
144 }
145
146 MOS_STATUS VphalInterfacesXe_Hpm::CreateVpPlatformInterface(
147 PMOS_INTERFACE osInterface,
148 MOS_STATUS * eStatus)
149 {
150 vp::VpPlatformInterface *vpPlatformInterface = MOS_New(vp::VpPlatformInterfaceXe_Hpm, osInterface);
151 if (nullptr == vpPlatformInterface)
152 {
153 *eStatus = MOS_STATUS_NULL_POINTER;
154 }
155 else
156 {
157 InitPlatformKernelBinary(vpPlatformInterface);
158
159 m_vpPlatformInterface = vpPlatformInterface;
160 *eStatus = MOS_STATUS_SUCCESS;
161 }
162 return *eStatus;
163 }
164
165 void VphalInterfacesXe_Hpm::InitPlatformKernelBinary(
166 vp::VpPlatformInterface *&vpPlatformInterface)
167 {
168 static vp::VpKernelConfigG12_Base kernelConfig;
169 vpPlatformInterface->SetKernelConfig(&kernelConfig);
170 #if defined(ENABLE_KERNELS)
171 vpPlatformInterface->SetVpFCKernelBinary(
172 IGVPKRN_XE_HPG,
173 IGVPKRN_XE_HPG_SIZE,
174 IGVPKRN_XE_HPG_CMFCPATCH,
175 IGVPKRN_XE_HPG_CMFCPATCH_SIZE);
176 #if !defined(_FULL_OPEN_SOURCE)
177 vpPlatformInterface->AddVpIsaKernelEntryToList(IGVP3DLUT_GENERATION_XE_HPG, IGVP3DLUT_GENERATION_XE_HPG_SIZE);
178 vpPlatformInterface->AddVpIsaKernelEntryToList(IGVPHVS_DENOISE_XE_HPG, IGVPHVS_DENOISE_XE_HPG_SIZE);
179 #endif
180 #endif
181 }
182
183 static bool dg2RegisteredMhw =
184 MediaFactory<uint32_t, MhwInterfaces>::
185 Register<MhwInterfacesDg2>((uint32_t)IGFX_DG2);
186
187 #define PLATFORM_INTEL_DG2 22
188 #define GENX_XEHP 11
189 #define GENX_DG2 13
190
191 MOS_STATUS MhwInterfacesDg2::Initialize(
192 CreateParams params,
193 PMOS_INTERFACE osInterface)
194 {
195 if (osInterface == nullptr)
196 {
197 MHW_ASSERTMESSAGE("The OS interface is not valid!");
198 return MOS_STATUS_INVALID_PARAMETER;
199 }
200 m_osInterface = osInterface;
201
202 auto gtSystemInfo = osInterface->pfnGetGtSystemInfo(osInterface);
203 if (gtSystemInfo == nullptr)
204 {
205 MHW_ASSERTMESSAGE("The OS interface is not valid!");
206 return MOS_STATUS_INVALID_PARAMETER;
207 }
208
209 if ((params.m_isCp == false) && (params.Flags.m_value == 0))
210 {
211 MHW_ASSERTMESSAGE("No MHW interfaces were requested for creation.");
212 return MOS_STATUS_INVALID_PARAMETER;
213 }
214
215 // MHW_CP and MHW_MI must always be created
216 MOS_STATUS status;
217 m_cpInterface = osInterface->pfnCreateMhwCpInterface(osInterface);
218 MHW_MI_CHK_NULL(m_cpInterface);
219 m_miInterface = MOS_New(Mi, m_cpInterface, osInterface);
220
221 if (params.Flags.m_render)
222 {
223 m_renderInterface =
224 MOS_New(Render, m_miInterface, osInterface, gtSystemInfo, params.m_heapMode);
225 }
226 if (params.Flags.m_stateHeap)
227 {
228 m_stateHeapInterface =
229 MOS_New(StateHeap, osInterface, params.m_heapMode);
230 }
231 if (params.Flags.m_sfc)
232 {
233 m_sfcInterface = MOS_New(Sfc, osInterface);
234 }
235 if (params.Flags.m_vebox)
236 {
237 m_veboxInterface = MOS_New(Vebox, osInterface);
238 }
239
240 if (params.Flags.m_vdboxAll || params.Flags.m_mfx)
241 {
242 m_mfxInterface =
243 MOS_New(Mfx, osInterface, m_miInterface, m_cpInterface, params.m_isDecode);
244 }
245 if (params.Flags.m_vdboxAll || params.Flags.m_hcp)
246 {
247 m_hcpInterface =
248 MOS_New(Hcp, osInterface, m_miInterface, m_cpInterface, params.m_isDecode);
249 }
250 if (params.Flags.m_vdboxAll || params.Flags.m_avp)
251 {
252 m_avpInterface =
253 MOS_New(Avp, osInterface, m_miInterface, m_cpInterface, params.m_isDecode);
254 }
255 if (params.Flags.m_vdboxAll || params.Flags.m_huc)
256 {
257 m_hucInterface = MOS_New(Huc, osInterface, m_miInterface, m_cpInterface);
258 }
259 if (params.Flags.m_vdboxAll || params.Flags.m_vdenc)
260 {
261 m_vdencInterface = MOS_New(Vdenc, osInterface);
262 }
263 if (params.Flags.m_blt)
264 {
265 m_bltInterface = MOS_New(Blt, osInterface);
266 }
267
268 return MOS_STATUS_SUCCESS;
269 }
270
271 static bool dg2RegisteredMmd =
272 MediaFactory<uint32_t, MmdDevice>::
273 Register<MmdDeviceXe_Hpm>((uint32_t)IGFX_DG2);
274
275 MOS_STATUS MmdDeviceXe_Hpm::Initialize(
276 PMOS_INTERFACE osInterface,
277 MhwInterfaces *mhwInterfaces)
278 {
279 MHW_FUNCTION_ENTER;
280
281 if (mhwInterfaces->m_miInterface == nullptr || mhwInterfaces->m_veboxInterface == nullptr)
282 {
283 if (osInterface != nullptr)
284 {
285 if (osInterface->pfnDestroy)
286 {
287 osInterface->pfnDestroy(osInterface, false);
288 }
289 MOS_FreeMemory(osInterface);
290 }
291 return MOS_STATUS_NULL_POINTER;
292 }
293
294 Mmd *device = nullptr;
295 device = MOS_New(Mmd);
296
297 if (device == nullptr)
298 {
299 if (osInterface != nullptr)
300 {
301 if (osInterface->pfnDestroy)
302 {
303 osInterface->pfnDestroy(osInterface, false);
304 }
305 MOS_FreeMemory(osInterface);
306 }
307 return MOS_STATUS_NO_SPACE;
308 }
309
310 // transfer ownership of osinterface to device. device will have exclusive ownership of osinterface and free it.
311 if (device->Initialize(
312 osInterface,
313 mhwInterfaces->m_cpInterface,
314 mhwInterfaces->m_miInterface,
315 mhwInterfaces->m_veboxInterface) != MOS_STATUS_SUCCESS)
316 {
317 // Vebox/mi/cp interface will gove control to mmd device, will release will be in destructure func
318 // set as null to avoid double free in driver
319 mhwInterfaces->m_cpInterface = nullptr;
320 mhwInterfaces->m_miInterface = nullptr;
321 mhwInterfaces->m_veboxInterface = nullptr;
322 MOS_Delete(device);
323 return MOS_STATUS_UNKNOWN;
324 }
325
326 m_mmdDevice = device;
327
328 return MOS_STATUS_SUCCESS;
329 }
330
331 MhwInterfaces* MmdDeviceXe_Hpm::CreateMhwInterface(
332 PMOS_INTERFACE osInterface)
333 {
334 MhwInterfaces::CreateParams params;
335 params.Flags.m_vebox = true;
336
337 // the destroy of interfaces happens when the mmd deviced deconstructor funcs
338 MhwInterfaces *mhw = MhwInterfaces::CreateFactory(params, osInterface);
339
340 return mhw;
341 }
342
343 static bool dg2RegisteredMcpy =
344 MediaFactory<uint32_t, McpyDevice>::
345 Register<McpyDeviceXe_Hpm>((uint32_t)IGFX_DG2);
346
347 MOS_STATUS McpyDeviceXe_Hpm::Initialize(
348 PMOS_INTERFACE osInterface)
349 {
350 MHW_FUNCTION_ENTER;
351
352 Mcpy *device = nullptr;
353 MhwInterfaces* mhwInterfaces = nullptr;
354
355 auto deleterOnFailure = [&](bool deleteOsInterface, bool deleteMhwInterface){
356 if (deleteOsInterface && osInterface != nullptr)
357 {
358 if (osInterface->pfnDestroy)
359 {
360 osInterface->pfnDestroy(osInterface, false);
361 }
362 MOS_FreeMemory(osInterface);
363 }
364
365 if (deleteMhwInterface && mhwInterfaces != nullptr)
366 {
367 mhwInterfaces->Destroy();
368 MOS_Delete(mhwInterfaces);
369 }
370
371 MOS_Delete(device);
372 };
373
374 device = MOS_New(Mcpy);
375 if (device == nullptr)
376 {
377 deleterOnFailure(true, false);
378 return MOS_STATUS_NO_SPACE;
379 }
380
381 mhwInterfaces = CreateMhwInterface(osInterface);
382 if (mhwInterfaces->m_miInterface == nullptr ||
383 mhwInterfaces->m_veboxInterface == nullptr ||
384 mhwInterfaces->m_bltInterface == nullptr)
385 {
386 deleterOnFailure(true, true);
387 return MOS_STATUS_NO_SPACE;
388 }
389
390 if (device->Initialize(
391 osInterface, mhwInterfaces) != MOS_STATUS_SUCCESS)
392 {
393 deleterOnFailure(false, false);
394 MOS_OS_CHK_STATUS_RETURN(MOS_STATUS_UNINITIALIZED);
395 }
396
397 m_mcpyDevice = device;
398
399 return MOS_STATUS_SUCCESS;
400 }
401
402 MhwInterfaces* McpyDeviceXe_Hpm::CreateMhwInterface(
403 PMOS_INTERFACE osInterface)
404 {
405 MhwInterfaces::CreateParams params;
406 params.Flags.m_vebox = true;
407 params.Flags.m_blt = true;
408
409 // the destroy of interfaces happens when the mcpy deviced deconstructor funcs
410 MhwInterfaces *mhw = MhwInterfaces::CreateFactory(params, osInterface);
411
412 return mhw;
413 }
414
415 static bool dg2RegisteredNv12ToP010 =
416 MediaFactory<uint32_t, Nv12ToP010Device>::
417 Register<Nv12ToP010DeviceXe_Hpm>((uint32_t)IGFX_DG2);
418
419 MOS_STATUS Nv12ToP010DeviceXe_Hpm::Initialize(
420 PMOS_INTERFACE osInterface)
421 {
422 CODECHAL_PUBLIC_ASSERTMESSAGE("Not support Nv12 to P010 interfaces.")
423
424 return MOS_STATUS_INVALID_PARAMETER;
425 }
426
427 static bool dg2RegisteredCodecHal =
428 MediaFactory<uint32_t, CodechalDevice>::
429 Register<CodechalInterfacesXe_Hpm>((uint32_t)IGFX_DG2);
430
431 static bool dg2RegisteredCodecHalNext =
432 MediaFactory<uint32_t, CodechalDeviceNext>::
433 Register<CodechalInterfacesNextXe_Hpm>((uint32_t)IGFX_DG2);
434
435 static bool dg2RegisteredMhwNext =
436 MediaFactory<uint32_t, MhwInterfacesNext>::
437 Register<MhwInterfacesDg2_Next>((uint32_t)IGFX_DG2);
438
439 MOS_STATUS MhwInterfacesDg2_Next::Initialize(
440 CreateParams params,
441 PMOS_INTERFACE osInterface)
442 {
443 if (osInterface == nullptr)
444 {
445 MHW_ASSERTMESSAGE("The OS interface is not valid!");
446 return MOS_STATUS_INVALID_PARAMETER;
447 }
448 m_osInterface = osInterface;
449
450 auto gtSystemInfo = osInterface->pfnGetGtSystemInfo(osInterface);
451 if (gtSystemInfo == nullptr)
452 {
453 MHW_ASSERTMESSAGE("The OS interface is not valid!");
454 return MOS_STATUS_INVALID_PARAMETER;
455 }
456
457 if ((params.m_isCp == false) && (params.Flags.m_value == 0))
458 {
459 MHW_ASSERTMESSAGE("No MHW interfaces were requested for creation.");
460 return MOS_STATUS_INVALID_PARAMETER;
461 }
462
463 // MHW_CP and MHW_MI must always be created
464 MOS_STATUS status;
465 m_cpInterface = osInterface->pfnCreateMhwCpInterface(osInterface);
466 MHW_MI_CHK_NULL(m_cpInterface);
467 m_miInterface = std::make_shared<Mi>(m_cpInterface, osInterface);
468
469 auto ptr = std::make_shared<mhw::mi::xe_xpm_base::Impl>(osInterface);
470 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(ptr);
471 ptr->SetCpInterface(m_cpInterface, m_miItf);
472
473 if (params.Flags.m_render)
474 {
475 m_renderInterface =
476 MOS_New(Render, m_miInterface.get(), osInterface, gtSystemInfo, params.m_heapMode);
477 auto renderPtr = std::make_shared<mhw::render::xe_hpg::Impl>(osInterface);
478 m_renderItf = std::static_pointer_cast<mhw::render::Itf>(renderPtr);
479 }
480 if (params.Flags.m_stateHeap)
481 {
482 m_stateHeapInterface =
483 MOS_New(StateHeap, osInterface, params.m_heapMode);
484 }
485 if (params.Flags.m_sfc)
486 {
487 m_sfcInterface = MOS_New(Sfc, osInterface);
488 }
489 if (params.Flags.m_vebox)
490 {
491 m_veboxInterface = MOS_New(Vebox, osInterface);
492 }
493
494 if (params.Flags.m_vdboxAll || params.Flags.m_mfx)
495 {
496 m_mfxItf = nullptr;
497 }
498 if (params.Flags.m_vdboxAll || params.Flags.m_hcp)
499 {
500 m_hcpItf = std::make_shared<mhw::vdbox::hcp::xe_xpm_base::xe_hpm::Impl>(osInterface);
501 }
502 if (params.Flags.m_vdboxAll)
503 {
504 auto ptr = std::make_shared<mhw::vdbox::avp::xe_hpm::Impl>(osInterface);
505 m_avpItf = std::static_pointer_cast<mhw::vdbox::avp::Itf>(ptr);
506 }
507 if (params.Flags.m_vdboxAll || params.Flags.m_huc)
508 {
509 auto ptr = std::make_shared<mhw::vdbox::huc::xe_hpm::Impl>(osInterface, m_cpInterface);
510 m_hucItf = std::static_pointer_cast<mhw::vdbox::huc::Itf>(ptr);
511 }
512 if (params.Flags.m_vdboxAll || params.Flags.m_vdenc)
513 {
514 auto ptr = std::make_shared<mhw::vdbox::vdenc::xe_hpm::Impl>(osInterface);
515 m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(ptr);
516 }
517 if (params.Flags.m_blt)
518 {
519 m_bltInterface = MOS_New(Blt, osInterface);
520 }
521
522 return MOS_STATUS_SUCCESS;
523 }
524
525 //!
526 //! \brief Destroys all created MHW interfaces
527 //! \details If the HAL creation fails, this is used for cleanup
528 //!
529 void MhwInterfacesDg2_Next::Destroy()
530 {
531 MhwInterfacesNext::Destroy();
532 MOS_Delete(m_sfcInterface);
533 MOS_Delete(m_veboxInterface);
534 MOS_Delete(m_bltInterface);
535 if (m_renderInterface != nullptr)
536 {
537 MOS_Delete(m_renderInterface);
538 }
539 }
540
541 MOS_STATUS CodechalInterfacesXe_Hpm::Initialize(
542 void *standardInfo,
543 void *settings,
544 MhwInterfaces *mhwInterfaces,
545 PMOS_INTERFACE osInterface)
546 {
547 if (standardInfo == nullptr ||
548 mhwInterfaces == nullptr ||
549 osInterface == nullptr)
550 {
551 CODECHAL_PUBLIC_ASSERTMESSAGE("CodecHal device is not valid!");
552 return MOS_STATUS_INVALID_PARAMETER;
553 }
554
555 PCODECHAL_STANDARD_INFO info = ((PCODECHAL_STANDARD_INFO)standardInfo);
556 CODECHAL_FUNCTION CodecFunction = info->CodecFunction;
557
558 bool disableScalability = false;
559 PLATFORM platform = {};
560 osInterface->pfnGetPlatform(osInterface, &platform);
561 if((platform.usDeviceID >= 0x56C0)
562 && (platform.usDeviceID <= 0x56CF))
563 {
564 disableScalability = true;
565 }
566
567 CodechalHwInterface *hwInterface = nullptr;
568 CodechalDebugInterface *debugInterface = nullptr;
569 CodechalHwInterfaceNext *hwInterface_next = nullptr;
570
571 auto release_func = [&]()
572 {
573 MOS_Delete(hwInterface);
574 #if USE_CODECHAL_DEBUG_TOOL
575 MOS_Delete(debugInterface);
576 #endif // USE_CODECHAL_DEBUG_TOOL
577 };
578
579 if (CodecHalIsDecode(CodecFunction))
580 {
581 if(osInterface->bHcpDecScalabilityMode == MOS_SCALABILITY_ENABLE_MODE_USER_FORCE)
582 {
583 disableScalability = false;
584 }
585 CODECHAL_PUBLIC_CHK_STATUS_RETURN(CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability));
586
587 #ifdef _MPEG2_DECODE_SUPPORTED
588 if (info->Mode == CODECHAL_DECODE_MODE_MPEG2IDCT ||
589 info->Mode == CODECHAL_DECODE_MODE_MPEG2VLD)
590 {
591 m_codechalDevice = MOS_New(Decode::Mpeg2, hwInterface, debugInterface);
592 }
593 else
594 #endif
595 #ifdef _VC1_DECODE_SUPPORTED
596 if (info->Mode == CODECHAL_DECODE_MODE_VC1IT ||
597 info->Mode == CODECHAL_DECODE_MODE_VC1VLD)
598 {
599 m_codechalDevice = MOS_New(Decode::Vc1, hwInterface, debugInterface, info);
600 }
601 else
602 #endif
603 #ifdef _AVC_DECODE_SUPPORTED
604 if (info->Mode == CODECHAL_DECODE_MODE_AVCVLD)
605 {
606 m_codechalDevice = MOS_New(Decode::Avc, hwInterface, debugInterface);
607 }
608 else
609 #endif
610 #ifdef _JPEG_DECODE_SUPPORTED
611 if (info->Mode == CODECHAL_DECODE_MODE_JPEG)
612 {
613 m_codechalDevice = MOS_New(Decode::Jpeg, hwInterface, debugInterface);
614 }
615 else
616 #endif
617 #ifdef _VP8_DECODE_SUPPORTED
618 if (info->Mode == CODECHAL_DECODE_MODE_VP8VLD)
619 {
620 m_codechalDevice = MOS_New(Decode::Vp8, hwInterface, debugInterface, info);
621 }
622 else
623 #endif
624 #ifdef _HEVC_DECODE_SUPPORTED
625 if (info->Mode == CODECHAL_DECODE_MODE_HEVCVLD)
626 {
627 m_codechalDevice = MOS_New(Decode::Hevc, hwInterface, debugInterface);
628 }
629 else
630 #endif
631 #ifdef _VP9_DECODE_SUPPORTED
632 if (info->Mode == CODECHAL_DECODE_MODE_VP9VLD)
633 {
634 m_codechalDevice = MOS_New(Decode::Vp9, hwInterface, debugInterface);
635 }
636 else
637 #endif
638 #ifdef _AV1_DECODE_SUPPORTED
639 if (info->Mode == CODECHAL_DECODE_MODE_AV1VLD)
640 {
641 m_codechalDevice = MOS_New(Decode::Av1, hwInterface, debugInterface);
642 }
643 else
644 #endif
645 {
646 CODECHAL_PUBLIC_ASSERTMESSAGE("Decode mode requested invalid!");
647 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
648 }
649
650 if (m_codechalDevice == nullptr)
651 {
652 CODECHAL_PUBLIC_ASSERTMESSAGE("Decoder device creation failed!");
653 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_NO_SPACE, release_func);
654 }
655 }
656 else if (CodecHalIsEncode(CodecFunction))
657 {
658 MhwInterfacesNext *mhwInterfacesNext = nullptr;
659
660 #define RETURN_STATUS_WITH_DELETE(stmt) \
661 { \
662 MOS_Delete(mhwInterfacesNext); \
663 return stmt; \
664 }
665
666 auto release_func_next = [&]()
667 {
668 MOS_Delete(mhwInterfacesNext);
669 MOS_Delete(hwInterface_next);
670 #if USE_CODECHAL_DEBUG_TOOL
671 MOS_Delete(debugInterface);
672 #endif // USE_CODECHAL_DEBUG_TOOL
673 };
674
675 CodechalEncoderState *encoder = nullptr;
676
677 #if defined (_AVC_ENCODE_VDENC_SUPPORTED)
678 if (info->Mode == CODECHAL_ENCODE_MODE_AVC)
679 {
680 CODECHAL_PUBLIC_CHK_STATUS_RETURN(CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability));
681
682 if (CodecHalUsesVdencEngine(info->CodecFunction))
683 {
684 encoder = MOS_New(Encode::AvcVdenc, hwInterface, debugInterface, info);
685 }
686 else
687 {
688 CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, AVC VME Encoder is not supported, please use AVC LowPower Encoder instead!");
689 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
690 }
691 if (encoder == nullptr)
692 {
693 CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
694 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
695 }
696 else
697 {
698 m_codechalDevice = encoder;
699 }
700 }
701 else
702 #endif
703 #ifdef _JPEG_ENCODE_SUPPORTED
704 if (info->Mode == CODECHAL_ENCODE_MODE_JPEG)
705 {
706 CODECHAL_PUBLIC_CHK_STATUS_RETURN(CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability));
707
708 encoder = MOS_New(Encode::Jpeg, hwInterface, debugInterface, info);
709 if (encoder == nullptr)
710 {
711 CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
712 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
713 }
714 else
715 {
716 m_codechalDevice = encoder;
717 }
718 encoder->m_vdboxOneDefaultUsed = true;
719 }
720 else
721 #endif
722 if (info->Mode == CODECHAL_ENCODE_MODE_MPEG2)
723 {
724 CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, MPEG2 Encoder is not supported!");
725 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
726 }
727 else
728 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
729 if (info->Mode == CODECHAL_ENCODE_MODE_VP9)
730 {
731 CODECHAL_PUBLIC_CHK_STATUS_RETURN(CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability));
732
733 encoder = MOS_New(Encode::Vp9, hwInterface, debugInterface, info);
734
735 if (encoder == nullptr)
736 {
737 CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
738 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
739 }
740 else
741 {
742 m_codechalDevice = encoder;
743 }
744 }
745 else
746 #endif
747 #if defined (_AV1_ENCODE_VDENC_SUPPORTED)
748 if (info->Mode == codechalEncodeModeAv1)
749 {
750 CODECHAL_PUBLIC_CHK_STATUS_RETURN(CreateCodecHalInterface(mhwInterfaces, mhwInterfacesNext, hwInterface_next, debugInterface, osInterface, CodecFunction, disableScalability));
751
752 if (CodecHalUsesVdencEngine(info->CodecFunction))
753 {
754 m_codechalDevice = MOS_New(Encode::Av1Vdenc, hwInterface_next, debugInterface);
755 if (m_codechalDevice == nullptr)
756 {
757 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_NULL_POINTER, release_func_next);
758 }
759 else
760 {
761 RETURN_STATUS_WITH_DELETE(MOS_STATUS_SUCCESS);
762 }
763 }
764 else
765 {
766 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func_next);
767 }
768 }
769 else
770 #endif
771 #if defined (_HEVC_ENCODE_VDENC_SUPPORTED)
772 if (info->Mode == CODECHAL_ENCODE_MODE_HEVC)
773 {
774 CODECHAL_PUBLIC_CHK_STATUS_RETURN(CreateCodecHalInterface(mhwInterfaces, mhwInterfacesNext, hwInterface_next, debugInterface, osInterface, CodecFunction, disableScalability));
775
776 if (CodecHalUsesVdencEngine(info->CodecFunction))
777 {
778 m_codechalDevice = MOS_New(Encode::HevcVdenc, hwInterface_next, debugInterface);
779 if (m_codechalDevice == nullptr)
780 {
781 CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!");
782 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func_next);
783 }
784 RETURN_STATUS_WITH_DELETE(MOS_STATUS_SUCCESS);
785 }
786 }
787 else
788 #endif
789 {
790 CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested.");
791 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
792 }
793
794 if (mhwInterfacesNext != nullptr)
795 {
796 MOS_Delete(mhwInterfacesNext);
797 }
798 }
799 else
800 {
801 CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported codec function requested.");
802 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
803 }
804
805 return MOS_STATUS_SUCCESS;
806 }
807
808 MOS_STATUS CodechalInterfacesNextXe_Hpm::Initialize(
809 void *standardInfo,
810 void *settings,
811 MhwInterfacesNext *mhwInterfaces,
812 PMOS_INTERFACE osInterface)
813 {
814 bool mdfSupported = true;
815 #if (_DEBUG || _RELEASE_INTERNAL)
816 MOS_USER_FEATURE_VALUE_DATA UserFeatureData;
817 MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData));
818 MOS_UserFeature_ReadValue_ID(
819 nullptr,
820 __MEDIA_USER_FEATURE_VALUE_HEVC_ENCODE_MDF_DISABLE_ID,
821 &UserFeatureData,
822 osInterface->pOsContext);
823 mdfSupported = (UserFeatureData.i32Data == 1) ? false : true;
824 #endif // (_DEBUG || _RELEASE_INTERNAL)
825 if (standardInfo == nullptr ||
826 mhwInterfaces == nullptr ||
827 osInterface == nullptr)
828 {
829 CODECHAL_PUBLIC_ASSERTMESSAGE("CodecHal device is not valid!");
830 return MOS_STATUS_INVALID_PARAMETER;
831 }
832
833 // This part should be moved back to media_intefaces.cpp for softlet build
834 PCODECHAL_STANDARD_INFO info = ((PCODECHAL_STANDARD_INFO)standardInfo);
835 CODECHAL_FUNCTION CodecFunction = info->CodecFunction;
836
837 bool disableScalability = false;
838 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
839 if (info->Mode == CODECHAL_ENCODE_MODE_VP9)
840 disableScalability = true;
841 #endif
842 CodechalHwInterfaceNext *hwInterface = MOS_New(Hw, osInterface, CodecFunction, mhwInterfaces, disableScalability);
843
844 if (hwInterface == nullptr)
845 {
846 CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterface is not valid!");
847 return MOS_STATUS_NO_SPACE;
848 }
849
850 #if USE_CODECHAL_DEBUG_TOOL
851 CodechalDebugInterface *debugInterface = MOS_New(CodechalDebugInterface);
852 if (debugInterface == nullptr)
853 {
854 MOS_Delete(hwInterface);
855 CODECHAL_PUBLIC_ASSERTMESSAGE("debugInterface is not valid!");
856 return MOS_STATUS_NO_SPACE;
857 }
858 if (debugInterface->Initialize(hwInterface, CodecFunction) != MOS_STATUS_SUCCESS)
859 {
860 MOS_Delete(hwInterface);
861 MOS_Delete(debugInterface);
862 CODECHAL_PUBLIC_ASSERTMESSAGE("Debug interface creation failed!");
863 return MOS_STATUS_INVALID_PARAMETER;
864 }
865 #else
866 CodechalDebugInterface *debugInterface = nullptr;
867 #endif // USE_CODECHAL_DEBUG_TOOL
868
869 auto release_func = [&]()
870 {
871 MOS_Delete(hwInterface);
872 #if USE_CODECHAL_DEBUG_TOOL
873 MOS_Delete(debugInterface);
874 #endif // USE_CODECHAL_DEBUG_TOOL
875 };
876
877 if (CodecHalIsDecode(CodecFunction))
878 {
879 CODECHAL_PUBLIC_ASSERTMESSAGE("Decode allocation failed, Decoder with CodechalDeviceNext is not supported!");
880 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
881
882 }
883 else if (CodecHalIsEncode(CodecFunction))
884 {
885 CodechalEncoderState *encoder = nullptr;
886
887 #if defined (_AV1_ENCODE_VDENC_SUPPORTED)
888 if (info->Mode == codechalEncodeModeAv1)
889 {
890 //TODO, use create
891 if (CodecHalUsesVdencEngine(info->CodecFunction))
892 {
893 m_codechalDevice = MOS_New(Encode::Av1Vdenc, hwInterface, debugInterface);
894 if (m_codechalDevice == nullptr)
895 {
896 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_NULL_POINTER, release_func);
897 }
898 return MOS_STATUS_SUCCESS;
899 }
900 else
901 {
902 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
903 }
904 }
905 else
906 #endif
907 {
908 CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested.");
909 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
910 }
911
912 }
913 else
914 {
915 CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported codec function requested.");
916 CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func);
917 }
918
919 return MOS_STATUS_SUCCESS;
920 }
921
922 #ifdef _MEDIA_RESERVED
923 static bool dg2RegisteredCMHal =
924 MediaFactory<uint32_t, CMHalDevice>::
925 Register<CMHalInterfacesXe_Hpm>((uint32_t)IGFX_DG2);
926 MOS_STATUS CMHalInterfacesXe_Hpm::Initialize(CM_HAL_STATE *pCmState)
927 {
928 if (pCmState == nullptr)
929 {
930 MHW_ASSERTMESSAGE("pCmState is nullptr.")
931 return MOS_STATUS_INVALID_PARAMETER;
932 }
933 CMHal *device = MOS_New(CMHal, pCmState);
934 if (device == nullptr)
935 {
936 MHW_ASSERTMESSAGE("Create CM Hal interfaces failed.")
937 return MOS_STATUS_NO_SPACE;
938 }
939 device->SetCopyKernelIsa((void*)pGPUCopy_kernel_isa_dg2, iGPUCopy_kernel_isa_size_dg2);
940 device->SetInitKernelIsa((void*)pGPUInit_kernel_isa_dg2, iGPUInit_kernel_isa_size_dg2);
941
942 m_cmhalDevice = device;
943 m_cmhalDevice->SetGenPlatformInfo(PLATFORM_INTEL_DG2, PLATFORM_INTEL_GT2, "DG2");
944 uint32_t cisaIDs[] = { GENX_DG2 , GENX_XEHP };
945 m_cmhalDevice->AddSupportedCisaIDs(cisaIDs, sizeof(cisaIDs)/sizeof(uint32_t));
946
947 if (pCmState->skuTable && MEDIA_IS_SKU(pCmState->skuTable, FtrCCSNode))
948 {
949 m_cmhalDevice->SetRedirectRcsToCcs(true);
950 }
951
952 m_cmhalDevice->SetDefaultMOCS(MOS_CM_RESOURCE_USAGE_L1_Enabled_SurfaceState);
953 m_cmhalDevice->m_l3Plane = DG2_L3_PLANES;
954 m_cmhalDevice->m_l3ConfigCount = DG2_L3_CONFIG_COUNT;
955 return MOS_STATUS_SUCCESS;
956 }
957 #endif
958
959 static bool dg2RegisteredRenderHal =
960 MediaFactory<uint32_t, RenderHalDevice>::
961 Register<RenderHalInterfacesXe_Hpg>((uint32_t)IGFX_DG2);
962 MOS_STATUS RenderHalInterfacesXe_Hpg::Initialize()
963 {
964 m_renderhalDevice = MOS_New(XRenderHal);
965 if (m_renderhalDevice == nullptr)
966 {
967 MHW_ASSERTMESSAGE("Create Render Hal interfaces failed.")
968 return MOS_STATUS_NO_SPACE;
969 }
970 return MOS_STATUS_SUCCESS;
971 }
972 static bool dg2RegisteredDecodeHistogram =
973 MediaFactory<uint32_t, DecodeHistogramDevice>::
974 Register<DecodeHistogramDeviceXe_Hpm>((uint32_t)IGFX_DG2);
975 MOS_STATUS DecodeHistogramDeviceXe_Hpm::Initialize(
976 CodechalHwInterface *hwInterface,
977 PMOS_INTERFACE osInterface)
978 {
979 m_decodeHistogramDevice = MOS_New(DecodeHistogramG12, hwInterface, osInterface);
980 if (m_decodeHistogramDevice == nullptr)
981 {
982 MHW_ASSERTMESSAGE("Create decode histogram interfaces failed.")
983 return MOS_STATUS_NO_SPACE;
984 }
985
986 return MOS_STATUS_SUCCESS;
987 }
988
989 static bool dg2RegisteredHwInfo =
990 MediaFactory<uint32_t, MediaInterfacesHwInfoDevice>::Register<MediaInterfacesHwInfoDeviceDg2>((uint32_t)IGFX_DG2);
991
992 #define IP_VERSION_XE_HPM 0x1207
993
994 MOS_STATUS MediaInterfacesHwInfoDeviceDg2::RefreshRevId(PLATFORM &platform, MEDIA_WA_TABLE *waTable)
995 {
996 if (waTable == nullptr)
997 {
998 CODECHAL_PUBLIC_ASSERTMESSAGE("waTable is null!");
999 return MOS_STATUS_INVALID_PARAMETER;
1000 }
1001 if (!MEDIA_IS_WA(waTable, WaEnableOnlyASteppingFeatures) && (platform.usRevId == 0 || platform.usRevId == 1))
1002 {
1003 platform.usRevId = 4;
1004 }
1005
1006 return MOS_STATUS_SUCCESS;
1007 };
1008
1009 MOS_STATUS MediaInterfacesHwInfoDeviceDg2::Initialize(PLATFORM platform)
1010 {
1011 m_hwInfo.SetDeviceInfo(IP_VERSION_XE_HPM, platform.usRevId);
1012 return MOS_STATUS_SUCCESS;
1013 }
1014
1015 MOS_STATUS CodechalInterfacesXe_Hpm::CreateCodecHalInterface(MhwInterfaces *mhwInterfaces,
1016 CodechalHwInterface *&pHwInterface,
1017 CodechalDebugInterface *&pDebugInterface,
1018 PMOS_INTERFACE osInterface,
1019 CODECHAL_FUNCTION CodecFunction,
1020 bool disableScalability)
1021 {
1022 pHwInterface = MOS_New(Hw, osInterface, CodecFunction, mhwInterfaces, disableScalability);
1023 if (pHwInterface == nullptr)
1024 {
1025 CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterface is not valid!");
1026 return MOS_STATUS_NO_SPACE;
1027 }
1028 pHwInterface->m_hwInterfaceNext = MOS_New(CodechalHwInterfaceNext, osInterface, pHwInterface->IsDisableScalability());
1029 if (pHwInterface->m_hwInterfaceNext == nullptr)
1030 {
1031 MOS_Delete(pHwInterface);
1032 CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterfaceNext is not valid!");
1033 return MOS_STATUS_NO_SPACE;
1034 }
1035 pHwInterface->m_hwInterfaceNext->pfnCreateDecodeSinglePipe = decode::DecodeScalabilitySinglePipe::CreateDecodeSinglePipe;
1036 pHwInterface->m_hwInterfaceNext->pfnCreateDecodeMultiPipe = decode::DecodeScalabilityMultiPipe::CreateDecodeMultiPipe;
1037 pHwInterface->m_hwInterfaceNext->SetMediaSfcInterface(pHwInterface->GetMediaSfcInterface());
1038
1039 #if USE_CODECHAL_DEBUG_TOOL
1040 pDebugInterface = MOS_New(CodechalDebugInterface);
1041 if (pDebugInterface == nullptr)
1042 {
1043 MOS_Delete(pHwInterface);
1044 CODECHAL_PUBLIC_ASSERTMESSAGE("debugInterface is not valid!");
1045 return MOS_STATUS_NO_SPACE;
1046 }
1047 if ((pDebugInterface)->Initialize(pHwInterface, CodecFunction) != MOS_STATUS_SUCCESS)
1048 {
1049 MOS_Delete(pHwInterface);
1050 MOS_Delete(pDebugInterface);
1051 CODECHAL_PUBLIC_ASSERTMESSAGE("Debug interface creation failed!");
1052 return MOS_STATUS_INVALID_PARAMETER;
1053 }
1054 #endif // USE_CODECHAL_DEBUG_TOOL
1055 return MOS_STATUS_SUCCESS;
1056 }
1057
1058 MOS_STATUS CodechalInterfacesXe_Hpm::CreateCodecHalInterface(MhwInterfaces *mhwInterfaces,
1059 MhwInterfacesNext *&pMhwInterfacesNext,
1060 CodechalHwInterfaceNext *&pHwInterface,
1061 CodechalDebugInterface *&pDebugInterface,
1062 PMOS_INTERFACE osInterface,
1063 CODECHAL_FUNCTION CodecFunction,
1064 bool disableScalability)
1065 {
1066 if (mhwInterfaces != nullptr)
1067 {
1068 if (((MhwInterfacesDg2 *)mhwInterfaces)->m_avpInterface != nullptr)
1069 {
1070 MOS_Delete(((MhwInterfacesDg2 *)mhwInterfaces)->m_avpInterface);
1071 }
1072 mhwInterfaces->Destroy();
1073 }
1074
1075 pMhwInterfacesNext = nullptr;
1076 MhwInterfacesNext::CreateParams params;
1077 MOS_ZeroMemory(&params, sizeof(params));
1078 params.Flags.m_render = true;
1079 params.Flags.m_sfc = true;
1080 params.Flags.m_vdboxAll = true;
1081 params.Flags.m_vebox = true;
1082 params.m_heapMode = (uint8_t)2;
1083 params.m_isDecode = CodecHalIsDecode(CodecFunction);
1084 pMhwInterfacesNext = MhwInterfacesNext::CreateFactory(params, osInterface);
1085
1086 if (pMhwInterfacesNext == nullptr)
1087 {
1088 CODECHAL_PUBLIC_ASSERTMESSAGE("mhwInterfacesNext is not valid!");
1089 return MOS_STATUS_NO_SPACE;
1090 }
1091
1092 pHwInterface = MOS_New(CodechalHwInterfaceNextXe_Hpm, osInterface, CodecFunction, pMhwInterfacesNext, disableScalability);
1093
1094 if (pHwInterface == nullptr)
1095 {
1096 CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterface is not valid!");
1097 return MOS_STATUS_NO_SPACE;
1098 }
1099 #if USE_CODECHAL_DEBUG_TOOL
1100 pDebugInterface = MOS_New(CodechalDebugInterface);
1101 if (pDebugInterface == nullptr)
1102 {
1103 MOS_Delete(pHwInterface);
1104 CODECHAL_PUBLIC_ASSERTMESSAGE("debugInterface is not valid!");
1105 return MOS_STATUS_NO_SPACE;
1106 }
1107 if ((pDebugInterface)->Initialize(pHwInterface, CodecFunction) != MOS_STATUS_SUCCESS)
1108 {
1109 MOS_Delete(pHwInterface);
1110 MOS_Delete(pDebugInterface);
1111 CODECHAL_PUBLIC_ASSERTMESSAGE("Debug interface creation failed!");
1112 return MOS_STATUS_INVALID_PARAMETER;
1113 }
1114 #endif // USE_CODECHAL_DEBUG_TOOL
1115 return MOS_STATUS_SUCCESS;
1116 }