| 1 |
/*===================== begin_copyright_notice ================================== |
| 2 |
|
| 3 |
# Copyright (c) 2021, 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_pvc.cpp |
| 26 |
|
| 27 |
//! \brief Helps with PVC factory creation. |
| 28 |
//! |
| 29 |
|
| 30 |
#include "media_interfaces_pvc.h" |
| 31 |
#include "codechal.h" |
| 32 |
#include "codechal_debug.h" |
| 33 |
#if defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE) |
| 34 |
#include "igcodeckrn_g12.h" |
| 35 |
#endif |
| 36 |
#include "codechal_hw_next_xe_xpm_plus.h" |
| 37 |
#include "mhw_render_xe_hpg_impl.h" |
| 38 |
|
| 39 |
extern template class MediaFactory<uint32_t, MhwInterfaces>; |
| 40 |
extern template class MediaFactory<uint32_t, MmdDevice>; |
| 41 |
extern template class MediaFactory<uint32_t, McpyDevice>; |
| 42 |
extern template class MediaFactory<uint32_t, CodechalDevice>; |
| 43 |
extern template class MediaFactory<uint32_t, CMHalDevice>; |
| 44 |
extern template class MediaFactory<uint32_t, VphalDevice>; |
| 45 |
extern template class MediaFactory<uint32_t, RenderHalDevice>; |
| 46 |
extern template class MediaFactory<uint32_t, Nv12ToP010Device>; |
| 47 |
extern template class MediaFactory<uint32_t, DecodeHistogramDevice>; |
| 48 |
|
| 49 |
// Swith to use new media factory template |
| 50 |
extern template class MediaFactory<uint32_t, MhwInterfacesNext>; |
| 51 |
|
| 52 |
static bool pvcRegisteredVphal = |
| 53 |
MediaFactory<uint32_t, VphalDevice>:: |
| 54 |
Register<VphalInterfacesXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 55 |
|
| 56 |
MOS_STATUS VphalInterfacesXe_Xpm_Plus::Initialize( |
| 57 |
PMOS_INTERFACE osInterface, |
| 58 |
bool bInitVphalState, |
| 59 |
MOS_STATUS *eStatus, |
| 60 |
bool clearViewMode) |
| 61 |
{ |
| 62 |
m_vpBase = MOS_New( |
| 63 |
VphalState, |
| 64 |
osInterface, |
| 65 |
eStatus); |
| 66 |
return *eStatus; |
| 67 |
} |
| 68 |
|
| 69 |
static bool pvcRegisteredMhw = |
| 70 |
MediaFactory<uint32_t, MhwInterfaces>:: |
| 71 |
Register<MhwInterfacesPvc>((uint32_t)IGFX_PVC); |
| 72 |
|
| 73 |
#define PLATFORM_INTEL_PVC 18 |
| 74 |
#define GENX_XEHP 11 |
| 75 |
#define GENX_PVC 15 |
| 76 |
|
| 77 |
MOS_STATUS MhwInterfacesPvc::Initialize( |
| 78 |
CreateParams params, |
| 79 |
PMOS_INTERFACE osInterface) |
| 80 |
{ |
| 81 |
if (osInterface == nullptr) |
| 82 |
{ |
| 83 |
MHW_ASSERTMESSAGE("The OS interface is not valid!"); |
| 84 |
return MOS_STATUS_INVALID_PARAMETER; |
| 85 |
} |
| 86 |
m_osInterface = osInterface; |
| 87 |
|
| 88 |
auto gtSystemInfo = osInterface->pfnGetGtSystemInfo(osInterface); |
| 89 |
if (gtSystemInfo == nullptr) |
| 90 |
{ |
| 91 |
MHW_ASSERTMESSAGE("The OS interface is not valid!"); |
| 92 |
return MOS_STATUS_INVALID_PARAMETER; |
| 93 |
} |
| 94 |
|
| 95 |
if ((params.m_isCp == false) && (params.Flags.m_value == 0)) |
| 96 |
{ |
| 97 |
MHW_ASSERTMESSAGE("No MHW interfaces were requested for creation."); |
| 98 |
return MOS_STATUS_INVALID_PARAMETER; |
| 99 |
} |
| 100 |
|
| 101 |
// MHW_CP and MHW_MI must always be created |
| 102 |
MOS_STATUS status; |
| 103 |
m_cpInterface = osInterface->pfnCreateMhwCpInterface(osInterface); |
| 104 |
MHW_MI_CHK_NULL(m_cpInterface); |
| 105 |
m_miInterface = MOS_New(Mi, m_cpInterface, osInterface); |
| 106 |
|
| 107 |
if (params.Flags.m_render) |
| 108 |
{ |
| 109 |
m_renderInterface = |
| 110 |
MOS_New(Render, m_miInterface, osInterface, gtSystemInfo, params.m_heapMode); |
| 111 |
} |
| 112 |
if (params.Flags.m_stateHeap) |
| 113 |
{ |
| 114 |
m_stateHeapInterface = |
| 115 |
MOS_New(StateHeap, osInterface, params.m_heapMode); |
| 116 |
} |
| 117 |
if (params.Flags.m_sfc) |
| 118 |
{ |
| 119 |
m_sfcInterface = MOS_New(Sfc, osInterface); |
| 120 |
} |
| 121 |
if (params.Flags.m_vebox) |
| 122 |
{ |
| 123 |
m_veboxInterface = MOS_New(Vebox, osInterface); |
| 124 |
} |
| 125 |
|
| 126 |
if (params.Flags.m_vdboxAll || params.Flags.m_mfx) |
| 127 |
{ |
| 128 |
m_mfxInterface = |
| 129 |
MOS_New(Mfx, osInterface, m_miInterface, m_cpInterface, params.m_isDecode); |
| 130 |
} |
| 131 |
if (params.Flags.m_vdboxAll || params.Flags.m_hcp) |
| 132 |
{ |
| 133 |
m_hcpInterface = |
| 134 |
MOS_New(Hcp, osInterface, m_miInterface, m_cpInterface, params.m_isDecode); |
| 135 |
} |
| 136 |
if (params.Flags.m_vdboxAll) |
| 137 |
{ |
| 138 |
m_avpInterface = |
| 139 |
MOS_New(Avp, osInterface, m_miInterface, m_cpInterface, params.m_isDecode); |
| 140 |
} |
| 141 |
if (params.Flags.m_vdboxAll || params.Flags.m_huc) |
| 142 |
{ |
| 143 |
m_hucInterface = MOS_New(Huc, osInterface, m_miInterface, m_cpInterface); |
| 144 |
} |
| 145 |
if (params.Flags.m_vdboxAll || params.Flags.m_vdenc) |
| 146 |
{ |
| 147 |
m_vdencInterface = MOS_New(Vdenc, osInterface); |
| 148 |
} |
| 149 |
if (params.Flags.m_blt) |
| 150 |
{ |
| 151 |
m_bltInterface = MOS_New(Blt, osInterface); |
| 152 |
} |
| 153 |
|
| 154 |
return MOS_STATUS_SUCCESS; |
| 155 |
} |
| 156 |
|
| 157 |
static bool pvcRegisteredMhwNext = |
| 158 |
MediaFactory<uint32_t, MhwInterfacesNext>:: |
| 159 |
Register<MhwInterfacesPvc_Next>((uint32_t)IGFX_PVC); |
| 160 |
|
| 161 |
MOS_STATUS MhwInterfacesPvc_Next::Initialize( |
| 162 |
CreateParams params, |
| 163 |
PMOS_INTERFACE osInterface) |
| 164 |
{ |
| 165 |
if (osInterface == nullptr) |
| 166 |
{ |
| 167 |
MHW_ASSERTMESSAGE("The OS interface is not valid!"); |
| 168 |
return MOS_STATUS_INVALID_PARAMETER; |
| 169 |
} |
| 170 |
m_osInterface = osInterface; |
| 171 |
|
| 172 |
auto gtSystemInfo = osInterface->pfnGetGtSystemInfo(osInterface); |
| 173 |
if (gtSystemInfo == nullptr) |
| 174 |
{ |
| 175 |
MHW_ASSERTMESSAGE("The OS interface is not valid!"); |
| 176 |
return MOS_STATUS_INVALID_PARAMETER; |
| 177 |
} |
| 178 |
|
| 179 |
if ((params.m_isCp == false) && (params.Flags.m_value == 0)) |
| 180 |
{ |
| 181 |
MHW_ASSERTMESSAGE("No MHW interfaces were requested for creation."); |
| 182 |
return MOS_STATUS_INVALID_PARAMETER; |
| 183 |
} |
| 184 |
|
| 185 |
// MHW_CP and MHW_MI must always be created |
| 186 |
MOS_STATUS status; |
| 187 |
m_cpInterface = osInterface->pfnCreateMhwCpInterface(osInterface); |
| 188 |
MHW_MI_CHK_NULL(m_cpInterface); |
| 189 |
m_miInterface = std::make_shared<Mi>(m_cpInterface, osInterface); |
| 190 |
|
| 191 |
auto ptr = std::make_shared<mhw::mi::xe_xpm_base::Impl>(osInterface); |
| 192 |
m_miItf = std::static_pointer_cast<mhw::mi::Itf>(ptr); |
| 193 |
ptr->SetCpInterface(m_cpInterface, m_miItf); |
| 194 |
|
| 195 |
if (params.Flags.m_render) |
| 196 |
{ |
| 197 |
m_renderInterface = |
| 198 |
MOS_New(Render, m_miInterface.get(), osInterface, gtSystemInfo, params.m_heapMode); |
| 199 |
auto renderPtr = std::make_shared<mhw::render::xe_hpg::Impl>(osInterface); |
| 200 |
m_renderItf = std::static_pointer_cast<mhw::render::Itf>(renderPtr); |
| 201 |
} |
| 202 |
if (params.Flags.m_stateHeap) |
| 203 |
{ |
| 204 |
m_stateHeapInterface = |
| 205 |
MOS_New(StateHeap, osInterface, params.m_heapMode); |
| 206 |
} |
| 207 |
if (params.Flags.m_sfc) |
| 208 |
{ |
| 209 |
m_sfcInterface = MOS_New(Sfc, osInterface); |
| 210 |
} |
| 211 |
if (params.Flags.m_vebox) |
| 212 |
{ |
| 213 |
m_veboxInterface = MOS_New(Vebox, osInterface); |
| 214 |
} |
| 215 |
|
| 216 |
if (params.Flags.m_vdboxAll || params.Flags.m_mfx) |
| 217 |
{ |
| 218 |
m_mfxItf = nullptr; |
| 219 |
} |
| 220 |
if (params.Flags.m_vdboxAll || params.Flags.m_hcp) |
| 221 |
{ |
| 222 |
m_hcpItf = std::make_shared<mhw::vdbox::hcp::xe_xpm_base::xe_xpm_plus::Impl>(osInterface); |
| 223 |
} |
| 224 |
if (params.Flags.m_vdboxAll || params.Flags.m_huc) |
| 225 |
{ |
| 226 |
m_hucItf = std::make_shared<mhw::vdbox::huc::xe_xpm_plus::Impl>(osInterface, m_cpInterface); |
| 227 |
} |
| 228 |
if (params.Flags.m_vdboxAll || params.Flags.m_vdenc) |
| 229 |
{ |
| 230 |
#ifdef IGFX_PVC_ENABLE_NON_UPSTREAM |
| 231 |
m_vdencItf = std::make_shared<mhw::vdbox::vdenc::xe_xpm_plus::Impl>(osInterface); |
| 232 |
#endif |
| 233 |
} |
| 234 |
if (params.Flags.m_blt) |
| 235 |
{ |
| 236 |
m_bltInterface = MOS_New(Blt, osInterface); |
| 237 |
} |
| 238 |
|
| 239 |
return MOS_STATUS_SUCCESS; |
| 240 |
} |
| 241 |
|
| 242 |
//! |
| 243 |
//! \brief Destroys all created MHW interfaces |
| 244 |
//! \details If the HAL creation fails, this is used for cleanup |
| 245 |
//! |
| 246 |
void MhwInterfacesPvc_Next::Destroy() |
| 247 |
{ |
| 248 |
MhwInterfacesNext::Destroy(); |
| 249 |
MOS_Delete(m_sfcInterface); |
| 250 |
MOS_Delete(m_veboxInterface); |
| 251 |
MOS_Delete(m_bltInterface); |
| 252 |
if (m_renderInterface != nullptr) |
| 253 |
{ |
| 254 |
MOS_Delete(m_renderInterface); |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
static bool pvcRegisteredMmd = |
| 259 |
MediaFactory<uint32_t, MmdDevice>:: |
| 260 |
Register<MmdDeviceXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 261 |
|
| 262 |
MOS_STATUS MmdDeviceXe_Xpm_Plus::Initialize( |
| 263 |
PMOS_INTERFACE osInterface, |
| 264 |
MhwInterfaces *mhwInterfaces) |
| 265 |
{ |
| 266 |
#define MMD_FAILURE() \ |
| 267 |
{ \ |
| 268 |
if (device != nullptr) \ |
| 269 |
{ \ |
| 270 |
MOS_Delete(device); \ |
| 271 |
} \ |
| 272 |
return MOS_STATUS_NO_SPACE; \ |
| 273 |
} |
| 274 |
MHW_FUNCTION_ENTER; |
| 275 |
Mmd *device = nullptr; |
| 276 |
|
| 277 |
if (mhwInterfaces->m_miInterface == nullptr) |
| 278 |
{ |
| 279 |
MMD_FAILURE(); |
| 280 |
} |
| 281 |
if (mhwInterfaces->m_renderInterface == nullptr) |
| 282 |
{ |
| 283 |
MMD_FAILURE(); |
| 284 |
} |
| 285 |
device = MOS_New(Mmd); |
| 286 |
|
| 287 |
if (device == nullptr) |
| 288 |
{ |
| 289 |
MMD_FAILURE(); |
| 290 |
} |
| 291 |
|
| 292 |
if (device->Initialize( |
| 293 |
osInterface, |
| 294 |
mhwInterfaces->m_cpInterface, |
| 295 |
mhwInterfaces->m_miInterface, |
| 296 |
mhwInterfaces->m_renderInterface) != MOS_STATUS_SUCCESS) |
| 297 |
{ |
| 298 |
// Vebox/mi/cp interface will gove control to mmd device, will release will be in destructure func |
| 299 |
// set as null to avoid double free in driver |
| 300 |
mhwInterfaces->m_cpInterface = nullptr; |
| 301 |
mhwInterfaces->m_miInterface = nullptr; |
| 302 |
mhwInterfaces->m_veboxInterface = nullptr; |
| 303 |
MMD_FAILURE(); |
| 304 |
} |
| 305 |
|
| 306 |
m_mmdDevice = device; |
| 307 |
|
| 308 |
return MOS_STATUS_SUCCESS; |
| 309 |
} |
| 310 |
|
| 311 |
MhwInterfaces* MmdDeviceXe_Xpm_Plus::CreateMhwInterface( |
| 312 |
PMOS_INTERFACE osInterface) |
| 313 |
{ |
| 314 |
MhwInterfaces::CreateParams params; |
| 315 |
params.Flags.m_render = true; |
| 316 |
|
| 317 |
// the destroy of interfaces happens when the mmd deviced deconstructor funcs |
| 318 |
MhwInterfaces *mhw = MhwInterfaces::CreateFactory(params, osInterface); |
| 319 |
|
| 320 |
return mhw; |
| 321 |
} |
| 322 |
|
| 323 |
static bool pvcRegisteredMcpy = |
| 324 |
MediaFactory<uint32_t, McpyDevice>:: |
| 325 |
Register<McpyDeviceXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 326 |
|
| 327 |
MOS_STATUS McpyDeviceXe_Xpm_Plus::Initialize( |
| 328 |
PMOS_INTERFACE osInterface) |
| 329 |
{ |
| 330 |
MHW_FUNCTION_ENTER; |
| 331 |
|
| 332 |
Mcpy *device = nullptr; |
| 333 |
MhwInterfaces* mhwInterfaces = nullptr; |
| 334 |
|
| 335 |
auto deleterOnFailure = [&](bool deleteOsInterface, bool deleteMhwInterface){ |
| 336 |
if (deleteOsInterface && osInterface != nullptr) |
| 337 |
{ |
| 338 |
if (osInterface->pfnDestroy) |
| 339 |
{ |
| 340 |
osInterface->pfnDestroy(osInterface, false); |
| 341 |
} |
| 342 |
MOS_FreeMemory(osInterface); |
| 343 |
} |
| 344 |
|
| 345 |
if (deleteMhwInterface && mhwInterfaces != nullptr) |
| 346 |
{ |
| 347 |
mhwInterfaces->Destroy(); |
| 348 |
MOS_Delete(mhwInterfaces); |
| 349 |
} |
| 350 |
|
| 351 |
MOS_Delete(device); |
| 352 |
}; |
| 353 |
|
| 354 |
device = MOS_New(Mcpy); |
| 355 |
if (device == nullptr) |
| 356 |
{ |
| 357 |
deleterOnFailure(true, false); |
| 358 |
return MOS_STATUS_NO_SPACE; |
| 359 |
} |
| 360 |
|
| 361 |
mhwInterfaces = CreateMhwInterface(osInterface); |
| 362 |
if (mhwInterfaces->m_miInterface == nullptr || |
| 363 |
mhwInterfaces->m_veboxInterface == nullptr || |
| 364 |
mhwInterfaces->m_bltInterface == nullptr) |
| 365 |
{ |
| 366 |
deleterOnFailure(true, true); |
| 367 |
return MOS_STATUS_NO_SPACE; |
| 368 |
} |
| 369 |
|
| 370 |
if (device->Initialize( |
| 371 |
osInterface, mhwInterfaces) != MOS_STATUS_SUCCESS) |
| 372 |
{ |
| 373 |
deleterOnFailure(false, false); |
| 374 |
MOS_OS_CHK_STATUS_RETURN(MOS_STATUS_UNINITIALIZED); |
| 375 |
} |
| 376 |
|
| 377 |
m_mcpyDevice = device; |
| 378 |
|
| 379 |
return MOS_STATUS_SUCCESS; |
| 380 |
} |
| 381 |
|
| 382 |
MhwInterfaces* McpyDeviceXe_Xpm_Plus::CreateMhwInterface( |
| 383 |
PMOS_INTERFACE osInterface) |
| 384 |
{ |
| 385 |
MhwInterfaces::CreateParams params; |
| 386 |
params.Flags.m_blt = true; |
| 387 |
params.Flags.m_render = true; |
| 388 |
params.Flags.m_vebox = false; |
| 389 |
params.Flags.m_sfc = false; |
| 390 |
// the destroy of interfaces happens when the mcpy deviced deconstructor funcs |
| 391 |
MhwInterfaces *mhw = MhwInterfaces::CreateFactory(params, osInterface); |
| 392 |
|
| 393 |
return mhw; |
| 394 |
} |
| 395 |
|
| 396 |
static bool pvcRegisteredNv12ToP010 = |
| 397 |
MediaFactory<uint32_t, Nv12ToP010Device>:: |
| 398 |
Register<Nv12ToP010DeviceXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 399 |
|
| 400 |
MOS_STATUS Nv12ToP010DeviceXe_Xpm_Plus::Initialize( |
| 401 |
PMOS_INTERFACE osInterface) |
| 402 |
{ |
| 403 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Not support Nv12 to P010 interfaces.") |
| 404 |
|
| 405 |
return MOS_STATUS_INVALID_PARAMETER; |
| 406 |
} |
| 407 |
|
| 408 |
static bool pvcRegisteredCodecHal = |
| 409 |
MediaFactory<uint32_t, CodechalDevice>:: |
| 410 |
Register<CodechalInterfacesXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 411 |
|
| 412 |
MOS_STATUS CodechalInterfacesXe_Xpm_Plus::Initialize( |
| 413 |
void *standardInfo, |
| 414 |
void *settings, |
| 415 |
MhwInterfaces *mhwInterfaces, |
| 416 |
PMOS_INTERFACE osInterface) |
| 417 |
{ |
| 418 |
|
| 419 |
if (standardInfo == nullptr || |
| 420 |
mhwInterfaces == nullptr || |
| 421 |
osInterface == nullptr) |
| 422 |
{ |
| 423 |
CODECHAL_PUBLIC_ASSERTMESSAGE("CodecHal device is not valid!"); |
| 424 |
return MOS_STATUS_INVALID_PARAMETER; |
| 425 |
} |
| 426 |
|
| 427 |
bool mdfSupported = true; |
| 428 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 429 |
MOS_USER_FEATURE_VALUE_DATA UserFeatureData; |
| 430 |
MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData)); |
| 431 |
MOS_UserFeature_ReadValue_ID( |
| 432 |
nullptr, |
| 433 |
__MEDIA_USER_FEATURE_VALUE_HEVC_ENCODE_MDF_DISABLE_ID, |
| 434 |
&UserFeatureData, |
| 435 |
osInterface->pOsContext); |
| 436 |
mdfSupported = (UserFeatureData.i32Data == 1) ? false : true; |
| 437 |
#endif // (_DEBUG || _RELEASE_INTERNAL) |
| 438 |
|
| 439 |
PCODECHAL_STANDARD_INFO info = ((PCODECHAL_STANDARD_INFO)standardInfo); |
| 440 |
CODECHAL_FUNCTION CodecFunction = info->CodecFunction; |
| 441 |
|
| 442 |
bool disableScalability = true; |
| 443 |
CodechalHwInterface *hwInterface = nullptr; |
| 444 |
CodechalDebugInterface *debugInterface = nullptr; |
| 445 |
CodechalHwInterfaceNext *hwInterface_next = nullptr; |
| 446 |
|
| 447 |
if (CodecHalIsDecode(CodecFunction)) |
| 448 |
{ |
| 449 |
CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability); |
| 450 |
|
| 451 |
#ifdef _MPEG2_DECODE_SUPPORTED |
| 452 |
if (info->Mode == CODECHAL_DECODE_MODE_MPEG2IDCT || |
| 453 |
info->Mode == CODECHAL_DECODE_MODE_MPEG2VLD) |
| 454 |
{ |
| 455 |
m_codechalDevice = MOS_New(Decode::Mpeg2, hwInterface, debugInterface); |
| 456 |
} |
| 457 |
else |
| 458 |
#endif |
| 459 |
#ifdef _VC1_DECODE_SUPPORTED |
| 460 |
if (info->Mode == CODECHAL_DECODE_MODE_VC1IT || |
| 461 |
info->Mode == CODECHAL_DECODE_MODE_VC1VLD) |
| 462 |
{ |
| 463 |
m_codechalDevice = MOS_New(Decode::Vc1, hwInterface, debugInterface, info); |
| 464 |
} |
| 465 |
else |
| 466 |
#endif |
| 467 |
#ifdef _AVC_DECODE_SUPPORTED |
| 468 |
if (info->Mode == CODECHAL_DECODE_MODE_AVCVLD) |
| 469 |
{ |
| 470 |
m_codechalDevice = MOS_New(Decode::Avc, hwInterface, debugInterface); |
| 471 |
} |
| 472 |
else |
| 473 |
#endif |
| 474 |
#ifdef _JPEG_DECODE_SUPPORTED |
| 475 |
if (info->Mode == CODECHAL_DECODE_MODE_JPEG) |
| 476 |
{ |
| 477 |
m_codechalDevice = MOS_New(Decode::Jpeg, hwInterface, debugInterface); |
| 478 |
} |
| 479 |
else |
| 480 |
#endif |
| 481 |
#ifdef _VP8_DECODE_SUPPORTED |
| 482 |
if (info->Mode == CODECHAL_DECODE_MODE_VP8VLD) |
| 483 |
{ |
| 484 |
m_codechalDevice = MOS_New(Decode::Vp8, hwInterface, debugInterface, info); |
| 485 |
} |
| 486 |
else |
| 487 |
#endif |
| 488 |
#ifdef _HEVC_DECODE_SUPPORTED |
| 489 |
if (info->Mode == CODECHAL_DECODE_MODE_HEVCVLD) |
| 490 |
{ |
| 491 |
m_codechalDevice = MOS_New(Decode::Hevc, hwInterface, debugInterface); |
| 492 |
} |
| 493 |
else |
| 494 |
#endif |
| 495 |
#ifdef _VP9_DECODE_SUPPORTED |
| 496 |
if (info->Mode == CODECHAL_DECODE_MODE_VP9VLD) |
| 497 |
{ |
| 498 |
m_codechalDevice = MOS_New(Decode::Vp9, hwInterface, debugInterface); |
| 499 |
} |
| 500 |
else |
| 501 |
#endif |
| 502 |
#ifdef _AV1_DECODE_SUPPORTED |
| 503 |
if (info->Mode == CODECHAL_DECODE_MODE_AV1VLD) |
| 504 |
{ |
| 505 |
m_codechalDevice = MOS_New(Decode::Av1, hwInterface, debugInterface); |
| 506 |
} |
| 507 |
else |
| 508 |
#endif |
| 509 |
{ |
| 510 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Decode mode requested invalid!"); |
| 511 |
return MOS_STATUS_INVALID_PARAMETER; |
| 512 |
} |
| 513 |
|
| 514 |
if (m_codechalDevice == nullptr) |
| 515 |
{ |
| 516 |
MOS_Delete(hwInterface); |
| 517 |
mhwInterfaces->SetDestroyState(true); |
| 518 |
#if USE_CODECHAL_DEBUG_TOOL |
| 519 |
MOS_Delete(debugInterface); |
| 520 |
#endif |
| 521 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Decoder device creation failed!"); |
| 522 |
return MOS_STATUS_NO_SPACE; |
| 523 |
} |
| 524 |
} |
| 525 |
#ifdef IGFX_PVC_ENABLE_NON_UPSTREAM |
| 526 |
else if (CodecHalIsEncode(CodecFunction)) |
| 527 |
{ |
| 528 |
MhwInterfacesNext *mhwInterfacesNext = nullptr; |
| 529 |
|
| 530 |
#define RETRUN_STATUS_WITH_DELETE(stmt) \ |
| 531 |
{ \ |
| 532 |
MOS_Delete(mhwInterfacesNext); \ |
| 533 |
return stmt; \ |
| 534 |
} |
| 535 |
|
| 536 |
CodechalEncoderState *encoder = nullptr; |
| 537 |
#if defined (_AVC_ENCODE_VDENC_SUPPORTED) |
| 538 |
if (info->Mode == CODECHAL_ENCODE_MODE_AVC) |
| 539 |
{ |
| 540 |
CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability); |
| 541 |
if (CodecHalUsesVdencEngine(info->CodecFunction)) |
| 542 |
{ |
| 543 |
encoder = MOS_New(Encode::AvcVdenc, hwInterface, debugInterface, info); |
| 544 |
} |
| 545 |
else |
| 546 |
{ |
| 547 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, AVC VME Encoder is not supported, please use AVC LowPower Encoder instead!"); |
| 548 |
return MOS_STATUS_INVALID_PARAMETER; |
| 549 |
} |
| 550 |
if (encoder == nullptr) |
| 551 |
{ |
| 552 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); |
| 553 |
return MOS_STATUS_INVALID_PARAMETER; |
| 554 |
} |
| 555 |
else |
| 556 |
{ |
| 557 |
m_codechalDevice = encoder; |
| 558 |
} |
| 559 |
} |
| 560 |
else |
| 561 |
#endif |
| 562 |
#ifdef _VP9_ENCODE_VDENC_SUPPORTED |
| 563 |
if (info->Mode == CODECHAL_ENCODE_MODE_VP9) |
| 564 |
{ |
| 565 |
CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability); |
| 566 |
encoder = MOS_New(Encode::Vp9, hwInterface, debugInterface, info); |
| 567 |
if (encoder == nullptr) |
| 568 |
{ |
| 569 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); |
| 570 |
return MOS_STATUS_INVALID_PARAMETER; |
| 571 |
} |
| 572 |
else |
| 573 |
{ |
| 574 |
m_codechalDevice = encoder; |
| 575 |
} |
| 576 |
} |
| 577 |
else |
| 578 |
#endif |
| 579 |
if (info->Mode == CODECHAL_ENCODE_MODE_MPEG2) |
| 580 |
{ |
| 581 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode allocation failed, MPEG2 Encoder is not supported!"); |
| 582 |
return MOS_STATUS_INVALID_PARAMETER; |
| 583 |
} |
| 584 |
else |
| 585 |
#ifdef _JPEG_ENCODE_SUPPORTED |
| 586 |
if (info->Mode == CODECHAL_ENCODE_MODE_JPEG) |
| 587 |
{ |
| 588 |
CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability); |
| 589 |
encoder = MOS_New(Encode::Jpeg, hwInterface, debugInterface, info); |
| 590 |
if (encoder == nullptr) |
| 591 |
{ |
| 592 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); |
| 593 |
return MOS_STATUS_INVALID_PARAMETER; |
| 594 |
} |
| 595 |
else |
| 596 |
{ |
| 597 |
m_codechalDevice = encoder; |
| 598 |
} |
| 599 |
encoder->m_vdboxOneDefaultUsed = true; |
| 600 |
} |
| 601 |
else |
| 602 |
#endif |
| 603 |
#if defined (_HEVC_ENCODE_VME_SUPPORTED) || defined (_HEVC_ENCODE_VDENC_SUPPORTED) |
| 604 |
if (info->Mode == CODECHAL_ENCODE_MODE_HEVC) |
| 605 |
{ |
| 606 |
if (CodecHalUsesVdencEngine(info->CodecFunction)) |
| 607 |
{ |
| 608 |
#ifdef _HEVC_ENCODE_VDENC_SUPPORTED |
| 609 |
#ifdef _MEDIA_RESERVED |
| 610 |
bool apogeiosEnable = true; |
| 611 |
MOS_USER_FEATURE_VALUE_DATA userFeatureData; |
| 612 |
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData)); |
| 613 |
|
| 614 |
userFeatureData.i32Data = apogeiosEnable; |
| 615 |
userFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE; |
| 616 |
MOS_UserFeature_ReadValue_ID( |
| 617 |
nullptr, |
| 618 |
__MEDIA_USER_FEATURE_VALUE_APOGEIOS_ENABLE_ID, |
| 619 |
&userFeatureData, |
| 620 |
osInterface->pOsContext); |
| 621 |
apogeiosEnable = (userFeatureData.i32Data) ? true : false; |
| 622 |
|
| 623 |
if (apogeiosEnable) |
| 624 |
{ |
| 625 |
CreateCodecHalInterface(mhwInterfaces, mhwInterfacesNext, hwInterface_next, debugInterface, osInterface, CodecFunction, disableScalability); |
| 626 |
m_codechalDevice = MOS_New(EncodeHevcVdencPipelineAdapterXe_Xpm_Plus, hwInterface_next, debugInterface); |
| 627 |
if (m_codechalDevice == nullptr) |
| 628 |
{ |
| 629 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); |
| 630 |
RETRUN_STATUS_WITH_DELETE(MOS_STATUS_INVALID_PARAMETER); |
| 631 |
} |
| 632 |
RETRUN_STATUS_WITH_DELETE(MOS_STATUS_SUCCESS); |
| 633 |
} |
| 634 |
else |
| 635 |
#endif |
| 636 |
{ |
| 637 |
CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability); |
| 638 |
encoder = MOS_New(Encode::HevcVdenc, hwInterface, debugInterface, info); |
| 639 |
} |
| 640 |
#endif |
| 641 |
} |
| 642 |
else |
| 643 |
{ |
| 644 |
|
| 645 |
// disable HEVC encode MDF path. |
| 646 |
CreateCodecHalInterface(mhwInterfaces, hwInterface, debugInterface, osInterface, CodecFunction, disableScalability); |
| 647 |
#ifdef _HEVC_ENCODE_VME_SUPPORTED |
| 648 |
if (!mdfSupported) |
| 649 |
{ |
| 650 |
encoder = MOS_New(Encode::HevcEnc, hwInterface, debugInterface, info); |
| 651 |
} |
| 652 |
else |
| 653 |
{ |
| 654 |
encoder = MOS_New(Encode::HevcMbenc, hwInterface, debugInterface, info); |
| 655 |
} |
| 656 |
#endif |
| 657 |
} |
| 658 |
|
| 659 |
if (encoder == nullptr) |
| 660 |
{ |
| 661 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); |
| 662 |
return MOS_STATUS_INVALID_PARAMETER; |
| 663 |
} |
| 664 |
else |
| 665 |
{ |
| 666 |
m_codechalDevice = encoder; |
| 667 |
} |
| 668 |
|
| 669 |
encoder->m_kernelBase = (uint8_t*)IGCODECKRN_G12; |
| 670 |
} |
| 671 |
else |
| 672 |
#endif |
| 673 |
{ |
| 674 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested."); |
| 675 |
return MOS_STATUS_INVALID_PARAMETER; |
| 676 |
} |
| 677 |
|
| 678 |
if (info->Mode != CODECHAL_ENCODE_MODE_JPEG) |
| 679 |
{ |
| 680 |
if (mdfSupported && info->Mode == CODECHAL_ENCODE_MODE_HEVC && !CodecHalUsesVdencEngine(info->CodecFunction)) |
| 681 |
{ |
| 682 |
if ((encoder->m_cscDsState = MOS_New(Encode::CscDsMdf, encoder)) == nullptr) |
| 683 |
{ |
| 684 |
return MOS_STATUS_INVALID_PARAMETER; |
| 685 |
} |
| 686 |
} |
| 687 |
else |
| 688 |
{ |
| 689 |
// Create CSC and Downscaling interface |
| 690 |
if ((encoder->m_cscDsState = MOS_New(Encode::CscDs, encoder)) == nullptr) |
| 691 |
{ |
| 692 |
return MOS_STATUS_INVALID_PARAMETER; |
| 693 |
} |
| 694 |
} |
| 695 |
} |
| 696 |
|
| 697 |
if (mhwInterfacesNext != nullptr) |
| 698 |
{ |
| 699 |
MOS_Delete(mhwInterfacesNext); |
| 700 |
} |
| 701 |
} |
| 702 |
#endif |
| 703 |
else |
| 704 |
{ |
| 705 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported codec function requested."); |
| 706 |
return MOS_STATUS_INVALID_PARAMETER; |
| 707 |
} |
| 708 |
|
| 709 |
return MOS_STATUS_SUCCESS; |
| 710 |
} |
| 711 |
|
| 712 |
#ifdef IGFX_PVC_ENABLE_NON_UPSTREAM |
| 713 |
static bool pvcRegisteredCMHal = |
| 714 |
MediaFactory<uint32_t, CMHalDevice>:: |
| 715 |
Register<CMHalInterfacesXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 716 |
MOS_STATUS CMHalInterfacesXe_Xpm_Plus::Initialize(CM_HAL_STATE *pCmState) |
| 717 |
{ |
| 718 |
if (pCmState == nullptr) |
| 719 |
{ |
| 720 |
MHW_ASSERTMESSAGE("pCmState is nullptr.") |
| 721 |
return MOS_STATUS_INVALID_PARAMETER; |
| 722 |
} |
| 723 |
m_cmhalDevice = MOS_New(CMHal, pCmState); |
| 724 |
if (m_cmhalDevice == nullptr) |
| 725 |
{ |
| 726 |
MHW_ASSERTMESSAGE("Create CM Hal interfaces failed.") |
| 727 |
return MOS_STATUS_NO_SPACE; |
| 728 |
} |
| 729 |
m_cmhalDevice->SetGenPlatformInfo(PLATFORM_INTEL_PVC, PLATFORM_INTEL_GT2, "PVC"); |
| 730 |
uint32_t cisaIDs[] = { GENX_PVC , GENX_XEHP }; |
| 731 |
m_cmhalDevice->AddSupportedCisaIDs(cisaIDs, sizeof(cisaIDs)/sizeof(uint32_t)); |
| 732 |
m_cmhalDevice->SetRedirectRcsToCcs(true); |
| 733 |
m_cmhalDevice->SetDefaultMOCS(MOS_CM_RESOURCE_USAGE_L1_Enabled_SurfaceState); |
| 734 |
m_cmhalDevice->m_l3Plane = PVC_L3_PLANES; |
| 735 |
m_cmhalDevice->m_l3ConfigCount = PVC_L3_CONFIG_COUNT; |
| 736 |
return MOS_STATUS_SUCCESS; |
| 737 |
} |
| 738 |
#endif |
| 739 |
|
| 740 |
static bool pvcRegisteredRenderHal = |
| 741 |
MediaFactory<uint32_t, RenderHalDevice>:: |
| 742 |
Register<RenderHalInterfacesXe_Hpc>((uint32_t)IGFX_PVC); |
| 743 |
MOS_STATUS RenderHalInterfacesXe_Hpc::Initialize() |
| 744 |
{ |
| 745 |
m_renderhalDevice = MOS_New(XRenderHal); |
| 746 |
if (m_renderhalDevice == nullptr) |
| 747 |
{ |
| 748 |
MHW_ASSERTMESSAGE("Create Render Hal interfaces failed.") |
| 749 |
return MOS_STATUS_NO_SPACE; |
| 750 |
} |
| 751 |
return MOS_STATUS_SUCCESS; |
| 752 |
} |
| 753 |
static bool pvcRegisteredDecodeHistogram = |
| 754 |
MediaFactory<uint32_t, DecodeHistogramDevice>:: |
| 755 |
Register<DecodeHistogramDeviceXe_Xpm_Plus>((uint32_t)IGFX_PVC); |
| 756 |
MOS_STATUS DecodeHistogramDeviceXe_Xpm_Plus::Initialize( |
| 757 |
CodechalHwInterface *hwInterface, |
| 758 |
PMOS_INTERFACE osInterface) |
| 759 |
{ |
| 760 |
m_decodeHistogramDevice = MOS_New(DecodeHistogramG12, hwInterface, osInterface); |
| 761 |
if (m_decodeHistogramDevice == nullptr) |
| 762 |
{ |
| 763 |
MHW_ASSERTMESSAGE("Create decode histogram interfaces failed.") |
| 764 |
return MOS_STATUS_NO_SPACE; |
| 765 |
} |
| 766 |
|
| 767 |
return MOS_STATUS_SUCCESS; |
| 768 |
} |
| 769 |
|
| 770 |
MOS_STATUS CodechalInterfacesXe_Xpm_Plus::CreateCodecHalInterface(MhwInterfaces *mhwInterfaces, |
| 771 |
CodechalHwInterface *&pHwInterface, |
| 772 |
CodechalDebugInterface *&pDebugInterface, |
| 773 |
PMOS_INTERFACE osInterface, |
| 774 |
CODECHAL_FUNCTION CodecFunction, |
| 775 |
bool disableScalability) |
| 776 |
{ |
| 777 |
pHwInterface = MOS_New(Hw, osInterface, CodecFunction, mhwInterfaces, disableScalability); |
| 778 |
if (pHwInterface == nullptr) |
| 779 |
{ |
| 780 |
CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterface is not valid!"); |
| 781 |
return MOS_STATUS_NO_SPACE; |
| 782 |
} |
| 783 |
pHwInterface->m_hwInterfaceNext = MOS_New(CodechalHwInterfaceNext, osInterface); |
| 784 |
if (pHwInterface->m_hwInterfaceNext == nullptr) |
| 785 |
{ |
| 786 |
MOS_Delete(pHwInterface); |
| 787 |
mhwInterfaces->SetDestroyState(true); |
| 788 |
CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterfaceNext is not valid!"); |
| 789 |
return MOS_STATUS_NO_SPACE; |
| 790 |
} |
| 791 |
pHwInterface->m_hwInterfaceNext->pfnCreateDecodeSinglePipe = decode::DecodeScalabilitySinglePipe::CreateDecodeSinglePipe; |
| 792 |
pHwInterface->m_hwInterfaceNext->pfnCreateDecodeMultiPipe = decode::DecodeScalabilityMultiPipe::CreateDecodeMultiPipe; |
| 793 |
pHwInterface->m_hwInterfaceNext->SetMediaSfcInterface(pHwInterface->GetMediaSfcInterface()); |
| 794 |
|
| 795 |
#if USE_CODECHAL_DEBUG_TOOL |
| 796 |
pDebugInterface = MOS_New(CodechalDebugInterface); |
| 797 |
if (pDebugInterface == nullptr) |
| 798 |
{ |
| 799 |
MOS_Delete(pHwInterface); |
| 800 |
mhwInterfaces->SetDestroyState(true); |
| 801 |
CODECHAL_PUBLIC_ASSERTMESSAGE("debugInterface is not valid!"); |
| 802 |
return MOS_STATUS_NO_SPACE; |
| 803 |
} |
| 804 |
if (pDebugInterface->Initialize(pHwInterface, CodecFunction) != MOS_STATUS_SUCCESS) |
| 805 |
{ |
| 806 |
MOS_Delete(pHwInterface); |
| 807 |
mhwInterfaces->SetDestroyState(true); |
| 808 |
MOS_Delete(pDebugInterface); |
| 809 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Debug interface creation failed!"); |
| 810 |
return MOS_STATUS_INVALID_PARAMETER; |
| 811 |
} |
| 812 |
#endif // USE_CODECHAL_DEBUG_TOOL |
| 813 |
return MOS_STATUS_SUCCESS; |
| 814 |
} |
| 815 |
|
| 816 |
MOS_STATUS CodechalInterfacesXe_Xpm_Plus::CreateCodecHalInterface(MhwInterfaces *mhwInterfaces, |
| 817 |
MhwInterfacesNext *&pMhwInterfacesNext, |
| 818 |
CodechalHwInterfaceNext *&pHwInterface, |
| 819 |
CodechalDebugInterface *&pDebugInterface, |
| 820 |
PMOS_INTERFACE osInterface, |
| 821 |
CODECHAL_FUNCTION CodecFunction, |
| 822 |
bool disableScalability) |
| 823 |
{ |
| 824 |
if (mhwInterfaces != nullptr) |
| 825 |
{ |
| 826 |
if (((MhwInterfacesPvc *)mhwInterfaces)->m_avpInterface != nullptr) |
| 827 |
{ |
| 828 |
MOS_Delete(((MhwInterfacesPvc *)mhwInterfaces)->m_avpInterface); |
| 829 |
} |
| 830 |
mhwInterfaces->Destroy(); |
| 831 |
} |
| 832 |
|
| 833 |
pMhwInterfacesNext = nullptr; |
| 834 |
MhwInterfacesNext::CreateParams params; |
| 835 |
MOS_ZeroMemory(¶ms, sizeof(params)); |
| 836 |
params.Flags.m_render = true; |
| 837 |
params.Flags.m_sfc = true; |
| 838 |
params.Flags.m_vdboxAll = true; |
| 839 |
params.Flags.m_vebox = true; |
| 840 |
params.m_heapMode = (uint8_t)2; |
| 841 |
params.m_isDecode = CodecHalIsDecode(CodecFunction); |
| 842 |
pMhwInterfacesNext = MhwInterfacesNext::CreateFactory(params, osInterface); |
| 843 |
|
| 844 |
if (pMhwInterfacesNext == nullptr) |
| 845 |
{ |
| 846 |
CODECHAL_PUBLIC_ASSERTMESSAGE("mhwInterfacesNext is not valid!"); |
| 847 |
return MOS_STATUS_NO_SPACE; |
| 848 |
} |
| 849 |
|
| 850 |
pHwInterface = MOS_New(CodechalHwInterfaceNextXe_Xpm_Plus, osInterface, CodecFunction, pMhwInterfacesNext, disableScalability); |
| 851 |
|
| 852 |
if (pHwInterface == nullptr) |
| 853 |
{ |
| 854 |
CODECHAL_PUBLIC_ASSERTMESSAGE("hwInterface is not valid!"); |
| 855 |
return MOS_STATUS_NO_SPACE; |
| 856 |
} |
| 857 |
#if USE_CODECHAL_DEBUG_TOOL |
| 858 |
pDebugInterface = MOS_New(CodechalDebugInterface); |
| 859 |
if (pDebugInterface == nullptr) |
| 860 |
{ |
| 861 |
MOS_Delete(pHwInterface); |
| 862 |
(pMhwInterfacesNext)->SetDestroyState(true); |
| 863 |
CODECHAL_PUBLIC_ASSERTMESSAGE("debugInterface is not valid!"); |
| 864 |
return MOS_STATUS_NO_SPACE; |
| 865 |
} |
| 866 |
if ((pDebugInterface)->Initialize(pHwInterface, CodecFunction) != MOS_STATUS_SUCCESS) |
| 867 |
{ |
| 868 |
MOS_Delete(pHwInterface); |
| 869 |
(pMhwInterfacesNext)->SetDestroyState(true); |
| 870 |
MOS_Delete(pDebugInterface); |
| 871 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Debug interface creation failed!"); |
| 872 |
return MOS_STATUS_INVALID_PARAMETER; |
| 873 |
} |
| 874 |
#endif // USE_CODECHAL_DEBUG_TOOL |
| 875 |
return MOS_STATUS_SUCCESS; |
| 876 |
} |