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