| 1 |
/* |
| 2 |
* Copyright (c) 2021-2026, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file media_interfaces_next.cpp |
| 24 |
//! \brief Helps with gen-specific factory creation. |
| 25 |
//! |
| 26 |
|
| 27 |
#include <stdint.h> |
| 28 |
#include "igfxfmid.h" |
| 29 |
#include "media_factory.h" |
| 30 |
#include "mhw_utilities_next.h" |
| 31 |
#include "mos_defs.h" |
| 32 |
#include "mos_os.h" |
| 33 |
#include "mos_os_specific.h" |
| 34 |
#include "mos_utilities.h" |
| 35 |
#include "mhw_cp_interface.h" |
| 36 |
|
| 37 |
#include "media_interfaces_vphal.h" |
| 38 |
#include "media_interfaces_renderhal.h" |
| 39 |
#include "media_interfaces_mcpy_next.h" |
| 40 |
#include "media_interfaces_mmd_next.h" |
| 41 |
#include "media_interfaces_mhw_next.h" |
| 42 |
#include "media_interfaces_codechal_next.h" |
| 43 |
#include "media_interfaces_huc_kernel_source.h" |
| 44 |
|
| 45 |
template class MediaFactory<uint32_t, VphalDevice>; |
| 46 |
template class MediaFactory<uint32_t, RenderHalDevice>; |
| 47 |
template class MediaFactory<uint32_t, CodechalDeviceNext>; |
| 48 |
template class MediaFactory<uint32_t, MhwInterfacesNext>; |
| 49 |
template class MediaFactory<uint32_t, McpyDeviceNext>; |
| 50 |
template class MediaFactory<uint32_t, MmdDeviceNext>; |
| 51 |
template class MediaFactory<uint32_t, HucKernelSourceDevice>; |
| 52 |
|
| 53 |
typedef MediaFactory<uint32_t, VphalDevice> VphalFactory; |
| 54 |
typedef MediaFactory<uint32_t, RenderHalDevice> RenderHalFactory; |
| 55 |
typedef MediaFactory<uint32_t, CodechalDeviceNext> CodechalFactoryNext; |
| 56 |
typedef MediaFactory<uint32_t, MhwInterfacesNext> MhwFactoryNext; |
| 57 |
typedef MediaFactory<uint32_t, McpyDeviceNext> McpyFactoryNext; |
| 58 |
typedef MediaFactory<uint32_t, MmdDeviceNext> MmdFactoryNext; |
| 59 |
typedef MediaFactory<uint32_t, HucKernelSourceDevice> HucKernelSourceFactory; |
| 60 |
|
| 61 |
VpBase *VphalDevice::CreateFactoryNext( |
| 62 |
PMOS_INTERFACE osInterface, |
| 63 |
MOS_CONTEXT_HANDLE osDriverContext, |
| 64 |
MOS_STATUS *eStatus, |
| 65 |
bool clearViewMode) |
| 66 |
{ |
| 67 |
VpBase *vpBase = nullptr; |
| 68 |
VphalDevice *vphalDevice = nullptr; |
| 69 |
PLATFORM platform; |
| 70 |
|
| 71 |
if (eStatus == nullptr) |
| 72 |
{ |
| 73 |
VP_DEBUG_ASSERTMESSAGE("Invalid null pointer."); |
| 74 |
return nullptr; |
| 75 |
} |
| 76 |
|
| 77 |
// pOsInterface not provided - use default for the current OS |
| 78 |
if (osInterface == nullptr) |
| 79 |
{ |
| 80 |
osInterface = (PMOS_INTERFACE)MOS_AllocAndZeroMemory(sizeof(MOS_INTERFACE)); |
| 81 |
|
| 82 |
if (osInterface == nullptr) |
| 83 |
{ |
| 84 |
VP_DEBUG_ASSERTMESSAGE("Allocate OS interface failed"); |
| 85 |
*eStatus = MOS_STATUS_NO_SPACE; |
| 86 |
return nullptr; |
| 87 |
} |
| 88 |
|
| 89 |
if (MOS_STATUS_SUCCESS != Mos_InitInterface(osInterface, osDriverContext, COMPONENT_VPCommon)) |
| 90 |
{ |
| 91 |
VP_DEBUG_ASSERTMESSAGE("Initailze OS interface failed"); |
| 92 |
MOS_FreeMemAndSetNull(osInterface); |
| 93 |
*eStatus = MOS_STATUS_NO_SPACE; |
| 94 |
return nullptr; |
| 95 |
} |
| 96 |
|
| 97 |
osInterface->bDeallocateOnExit = true; |
| 98 |
} |
| 99 |
else |
| 100 |
// pOsInterface provided - use OS interface functions provided by DDI (OS emulation) |
| 101 |
{ |
| 102 |
// Copy OS interface structure, save context |
| 103 |
osInterface->pOsContext = (PMOS_CONTEXT)osDriverContext; |
| 104 |
osInterface->bDeallocateOnExit = false; |
| 105 |
} |
| 106 |
|
| 107 |
// Initialize platform |
| 108 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 109 |
|
| 110 |
vphalDevice = VphalFactory::Create(platform.eProductFamily); |
| 111 |
|
| 112 |
if (vphalDevice == nullptr) |
| 113 |
{ |
| 114 |
VP_DEBUG_ASSERTMESSAGE("Failed to create MediaInterface on the given platform!"); |
| 115 |
if (osInterface->bDeallocateOnExit) |
| 116 |
{ |
| 117 |
MOS_FreeMemAndSetNull(osInterface); |
| 118 |
} |
| 119 |
*eStatus = MOS_STATUS_NO_SPACE; |
| 120 |
return nullptr; |
| 121 |
} |
| 122 |
|
| 123 |
if (vphalDevice->Initialize(osInterface, true, eStatus) != MOS_STATUS_SUCCESS) |
| 124 |
{ |
| 125 |
VP_DEBUG_ASSERTMESSAGE("VPHal interfaces were not successfully allocated!"); |
| 126 |
|
| 127 |
// If m_vpBase has been created, osInterface should be released in VphalState::~VphalState. |
| 128 |
if (osInterface->bDeallocateOnExit && nullptr == vphalDevice->m_vpBase) |
| 129 |
{ |
| 130 |
// Deallocate OS interface structure (except if externally provided) |
| 131 |
if (osInterface->pfnDestroy) |
| 132 |
{ |
| 133 |
osInterface->pfnDestroy(osInterface, true); |
| 134 |
} |
| 135 |
MOS_FreeMemAndSetNull(osInterface); |
| 136 |
} |
| 137 |
|
| 138 |
vphalDevice->Destroy(); |
| 139 |
MOS_Delete(vphalDevice); |
| 140 |
|
| 141 |
*eStatus = MOS_STATUS_NO_SPACE; |
| 142 |
return nullptr; |
| 143 |
} |
| 144 |
|
| 145 |
vpBase = vphalDevice->m_vpBase; |
| 146 |
|
| 147 |
MOS_Delete(vphalDevice); |
| 148 |
return vpBase; |
| 149 |
} |
| 150 |
|
| 151 |
MOS_STATUS VphalDevice::CreateVPMhwInterfaces( |
| 152 |
bool sfcNeeded, |
| 153 |
bool veboxNeeded, |
| 154 |
std::shared_ptr<mhw::vebox::Itf> &veboxItf, |
| 155 |
std::shared_ptr<mhw::sfc::Itf> &sfcItf, |
| 156 |
std::shared_ptr<mhw::mi::Itf> &miItf, |
| 157 |
PMOS_INTERFACE osInterface) |
| 158 |
{ |
| 159 |
MhwInterfacesNext *mhwInterfaces = nullptr; |
| 160 |
MhwInterfacesNext::CreateParams params = {}; |
| 161 |
params.Flags.m_sfc = sfcNeeded; |
| 162 |
params.Flags.m_vebox = veboxNeeded; |
| 163 |
|
| 164 |
mhwInterfaces = MhwInterfacesNext::CreateFactory(params, osInterface); |
| 165 |
if (mhwInterfaces) |
| 166 |
{ |
| 167 |
veboxItf = mhwInterfaces->m_veboxItf; |
| 168 |
sfcItf = mhwInterfaces->m_sfcItf; |
| 169 |
miItf = mhwInterfaces->m_miItf; |
| 170 |
|
| 171 |
// MhwInterfaces always create CP and MI interfaces, so we have to delete those we don't need. |
| 172 |
Delete_MhwCpInterface(mhwInterfaces->m_cpInterface); |
| 173 |
mhwInterfaces->m_cpInterface = nullptr; |
| 174 |
MOS_Delete(mhwInterfaces); |
| 175 |
return MOS_STATUS_SUCCESS; |
| 176 |
} |
| 177 |
|
| 178 |
VP_PUBLIC_ASSERTMESSAGE("Allocate MhwInterfaces failed"); |
| 179 |
return MOS_STATUS_NO_SPACE; |
| 180 |
} |
| 181 |
|
| 182 |
void VphalDevice::Destroy() |
| 183 |
{ |
| 184 |
MOS_Delete(m_vpBase); |
| 185 |
MOS_Delete(m_vpPipeline); |
| 186 |
MOS_Delete(m_vpPlatformInterface); |
| 187 |
} |
| 188 |
|
| 189 |
XRenderHal_Platform_Interface* RenderHalDevice::CreateFactory( |
| 190 |
PMOS_INTERFACE osInterface) |
| 191 |
{ |
| 192 |
RenderHalDevice *device = nullptr; |
| 193 |
PLATFORM platform = {}; |
| 194 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 195 |
device = RenderHalFactory::Create(platform.eProductFamily); |
| 196 |
if (device == nullptr) |
| 197 |
{ |
| 198 |
return nullptr; |
| 199 |
} |
| 200 |
device->m_osInterface = osInterface; |
| 201 |
device->Initialize(); |
| 202 |
if (device->m_renderhalDevice == nullptr) |
| 203 |
{ |
| 204 |
MHW_ASSERTMESSAGE("RenderHal device creation failed!"); |
| 205 |
MOS_Delete(device); |
| 206 |
return nullptr; |
| 207 |
} |
| 208 |
|
| 209 |
XRenderHal_Platform_Interface *pRet = device->m_renderhalDevice; |
| 210 |
MOS_Delete(device); |
| 211 |
return pRet; |
| 212 |
} |
| 213 |
|
| 214 |
Codechal* CodechalDeviceNext::CreateFactory( |
| 215 |
PMOS_INTERFACE osInterface, |
| 216 |
PMOS_CONTEXT osDriverContext, |
| 217 |
void *standardInfo, |
| 218 |
void *settings) |
| 219 |
{ |
| 220 |
#define FAIL_DESTROY(msg) \ |
| 221 |
{ \ |
| 222 |
CODECHAL_PUBLIC_ASSERTMESSAGE((msg)); \ |
| 223 |
if (mhwInterfaces != nullptr) \ |
| 224 |
{ \ |
| 225 |
mhwInterfaces->Destroy(); \ |
| 226 |
} \ |
| 227 |
if (osInterface != nullptr && osInterface->bDeallocateOnExit) \ |
| 228 |
{ \ |
| 229 |
if (osInterface->pfnDestroy != nullptr) \ |
| 230 |
{ \ |
| 231 |
osInterface->pfnDestroy(osInterface, false); \ |
| 232 |
} \ |
| 233 |
MOS_FreeMemory(osInterface); \ |
| 234 |
} \ |
| 235 |
MOS_Delete(mhwInterfaces); \ |
| 236 |
MOS_Delete(device); \ |
| 237 |
return nullptr; \ |
| 238 |
} |
| 239 |
|
| 240 |
#define FAIL_CHK_STATUS(stmt) \ |
| 241 |
{ \ |
| 242 |
if ((stmt) != MOS_STATUS_SUCCESS) \ |
| 243 |
{ \ |
| 244 |
FAIL_DESTROY("Status check failed, CodecHal creation failed!"); \ |
| 245 |
} \ |
| 246 |
} |
| 247 |
|
| 248 |
#define FAIL_CHK_NULL(ptr) \ |
| 249 |
{ \ |
| 250 |
if ((ptr) == nullptr) \ |
| 251 |
{ \ |
| 252 |
FAIL_DESTROY("nullptr check failed, CodecHal creation failed!"); \ |
| 253 |
} \ |
| 254 |
} |
| 255 |
|
| 256 |
if (osDriverContext == nullptr || |
| 257 |
standardInfo == nullptr) |
| 258 |
{ |
| 259 |
return nullptr; |
| 260 |
} |
| 261 |
|
| 262 |
MhwInterfacesNext *mhwInterfaces = nullptr; |
| 263 |
CodechalDeviceNext *device = nullptr; |
| 264 |
|
| 265 |
CODECHAL_FUNCTION CodecFunction = ((PCODECHAL_STANDARD_INFO)standardInfo)->CodecFunction; |
| 266 |
|
| 267 |
// pOsInterface not provided - use default for the current OS |
| 268 |
if (osInterface == nullptr) |
| 269 |
{ |
| 270 |
osInterface = |
| 271 |
(PMOS_INTERFACE)MOS_AllocAndZeroMemory(sizeof(MOS_INTERFACE)); |
| 272 |
FAIL_CHK_NULL(osInterface); |
| 273 |
|
| 274 |
MOS_COMPONENT component = CodecHalIsDecode(CodecFunction) ? COMPONENT_Decode : COMPONENT_Encode; |
| 275 |
|
| 276 |
osInterface->bDeallocateOnExit = true; |
| 277 |
FAIL_CHK_STATUS(Mos_InitInterface(osInterface, osDriverContext, component)); |
| 278 |
} |
| 279 |
// pOsInterface provided - use OS interface functions provided by DDI (OS emulation) |
| 280 |
else |
| 281 |
{ |
| 282 |
osInterface->bDeallocateOnExit = false; |
| 283 |
} |
| 284 |
|
| 285 |
MhwInterfacesNext::CreateParams params; |
| 286 |
MOS_ZeroMemory(¶ms, sizeof(params)); |
| 287 |
params.Flags.m_render = true; |
| 288 |
params.Flags.m_sfc = true; |
| 289 |
params.Flags.m_vdboxAll = true; |
| 290 |
params.Flags.m_vebox = true; |
| 291 |
params.m_heapMode = (uint8_t)2; |
| 292 |
params.m_isDecode = CodecHalIsDecode(CodecFunction); |
| 293 |
mhwInterfaces = MhwInterfacesNext::CreateFactory(params, osInterface); |
| 294 |
FAIL_CHK_NULL(mhwInterfaces); |
| 295 |
|
| 296 |
PLATFORM platform = {}; |
| 297 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 298 |
device = CodechalFactoryNext::Create(platform.eProductFamily + MEDIA_EXT_FLAG); |
| 299 |
if(device == nullptr) |
| 300 |
{ |
| 301 |
device = CodechalFactoryNext::Create(platform.eProductFamily); |
| 302 |
} |
| 303 |
FAIL_CHK_NULL(device); |
| 304 |
FAIL_CHK_STATUS(device->Initialize(standardInfo, settings, mhwInterfaces, osInterface)); |
| 305 |
FAIL_CHK_NULL(device->m_codechalDevice); |
| 306 |
|
| 307 |
Codechal *codechalDevice = device->m_codechalDevice; |
| 308 |
|
| 309 |
MOS_Delete(mhwInterfaces); |
| 310 |
MOS_Delete(device); |
| 311 |
|
| 312 |
return codechalDevice; |
| 313 |
} |
| 314 |
|
| 315 |
MhwInterfacesNext* MhwInterfacesNext::CreateFactory( |
| 316 |
CreateParams params, |
| 317 |
PMOS_INTERFACE osInterface) |
| 318 |
{ |
| 319 |
if (osInterface == nullptr) |
| 320 |
{ |
| 321 |
return nullptr; |
| 322 |
} |
| 323 |
PLATFORM platform = {}; |
| 324 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 325 |
|
| 326 |
MhwInterfacesNext *mhwNext = nullptr; |
| 327 |
|
| 328 |
mhwNext = MhwFactoryNext::Create(platform.eProductFamily + MEDIA_EXT_FLAG); |
| 329 |
if(mhwNext == nullptr) |
| 330 |
{ |
| 331 |
mhwNext = MhwFactoryNext::Create(platform.eProductFamily); |
| 332 |
} |
| 333 |
|
| 334 |
if (mhwNext == nullptr) |
| 335 |
{ |
| 336 |
MHW_ASSERTMESSAGE("Failed to create MediaInterface on the given platform!"); |
| 337 |
return nullptr; |
| 338 |
} |
| 339 |
|
| 340 |
if (mhwNext->Initialize(params, osInterface) != MOS_STATUS_SUCCESS) |
| 341 |
{ |
| 342 |
MHW_ASSERTMESSAGE("MHW interfaces were not successfully allocated!"); |
| 343 |
MOS_Delete(mhwNext); |
| 344 |
return nullptr; |
| 345 |
} |
| 346 |
|
| 347 |
return mhwNext; |
| 348 |
} |
| 349 |
|
| 350 |
void MhwInterfacesNext::Destroy() |
| 351 |
{ |
| 352 |
if(m_isDestroyed) |
| 353 |
{ |
| 354 |
return; |
| 355 |
} |
| 356 |
|
| 357 |
if(m_osInterface) |
| 358 |
{ |
| 359 |
m_osInterface->pfnDeleteMhwCpInterface(m_cpInterface); |
| 360 |
m_cpInterface = nullptr; |
| 361 |
} |
| 362 |
else |
| 363 |
{ |
| 364 |
MHW_ASSERTMESSAGE("Failed to destroy cpInterface."); |
| 365 |
} |
| 366 |
MOS_Delete(m_stateHeapInterface); |
| 367 |
} |
| 368 |
|
| 369 |
void* McpyDeviceNext::CreateFactory( |
| 370 |
MOS_CONTEXT_HANDLE osDriverContext) |
| 371 |
{ |
| 372 |
PMOS_INTERFACE osInterface = nullptr; |
| 373 |
McpyDeviceNext *device = nullptr; |
| 374 |
|
| 375 |
auto deleterOnFailure = [&](bool deleteOsInterface) { |
| 376 |
if (deleteOsInterface && osInterface != nullptr) |
| 377 |
{ |
| 378 |
if (osInterface->pfnDestroy) |
| 379 |
{ |
| 380 |
osInterface->pfnDestroy(osInterface, false); |
| 381 |
} |
| 382 |
MOS_FreeMemory(osInterface); |
| 383 |
} |
| 384 |
MOS_Delete(device); |
| 385 |
}; |
| 386 |
|
| 387 |
if (osDriverContext == nullptr) |
| 388 |
{ |
| 389 |
MHW_ASSERTMESSAGE("Invalid(null) pOsDriverContext!"); |
| 390 |
return nullptr; |
| 391 |
} |
| 392 |
|
| 393 |
osInterface = (PMOS_INTERFACE)MOS_AllocAndZeroMemory(sizeof(MOS_INTERFACE)); |
| 394 |
if (osInterface == nullptr) |
| 395 |
{ |
| 396 |
return nullptr; |
| 397 |
} |
| 398 |
if (Mos_InitInterface( |
| 399 |
osInterface, |
| 400 |
osDriverContext, |
| 401 |
COMPONENT_MCPY) != MOS_STATUS_SUCCESS) |
| 402 |
{ |
| 403 |
deleterOnFailure(true); |
| 404 |
return nullptr; |
| 405 |
} |
| 406 |
|
| 407 |
PLATFORM platform = {}; |
| 408 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 409 |
device = McpyFactoryNext::Create(platform.eProductFamily); |
| 410 |
if (device == nullptr) |
| 411 |
{ |
| 412 |
deleterOnFailure(true); |
| 413 |
return nullptr; |
| 414 |
} |
| 415 |
|
| 416 |
// transfer ownership of osInterface. No need to delete it if init fails |
| 417 |
device->Initialize(osInterface); |
| 418 |
if (device->m_mcpyDevice == nullptr) |
| 419 |
{ |
| 420 |
deleterOnFailure(false); |
| 421 |
return nullptr; |
| 422 |
} |
| 423 |
|
| 424 |
void *mcpyDevice = device->m_mcpyDevice; |
| 425 |
MOS_Delete(device); |
| 426 |
return mcpyDevice; |
| 427 |
} |
| 428 |
|
| 429 |
MhwInterfacesNext* McpyDeviceNext::CreateMhwInterface(PMOS_INTERFACE osInterface) |
| 430 |
{ |
| 431 |
MhwInterfacesNext::CreateParams params; |
| 432 |
MOS_ZeroMemory(¶ms, sizeof(params)); |
| 433 |
params.Flags.m_render = true; |
| 434 |
params.Flags.m_vebox = true; |
| 435 |
params.Flags.m_blt = true; |
| 436 |
|
| 437 |
// the destroy of interfaces happens when the mcpy deviced deconstructor funcs |
| 438 |
MhwInterfacesNext *mhw = MhwInterfacesNext::CreateFactory(params, osInterface); |
| 439 |
|
| 440 |
return mhw; |
| 441 |
} |
| 442 |
|
| 443 |
void* MmdDeviceNext::CreateFactory(PMOS_CONTEXT osDriverContext) |
| 444 |
{ |
| 445 |
#define MMD_FAILURE() \ |
| 446 |
{ \ |
| 447 |
if (mhwInterfaces != nullptr) \ |
| 448 |
{ \ |
| 449 |
mhwInterfaces->Destroy(); \ |
| 450 |
} \ |
| 451 |
MOS_Delete(mhwInterfaces); \ |
| 452 |
if (osInterface != nullptr) \ |
| 453 |
{ \ |
| 454 |
if (osInterface->pfnDestroy) \ |
| 455 |
{ \ |
| 456 |
osInterface->pfnDestroy(osInterface, false); \ |
| 457 |
} \ |
| 458 |
MOS_FreeMemory(osInterface); \ |
| 459 |
} \ |
| 460 |
MOS_Delete(device); \ |
| 461 |
return nullptr; \ |
| 462 |
} |
| 463 |
MHW_FUNCTION_ENTER; |
| 464 |
|
| 465 |
if (osDriverContext == nullptr) |
| 466 |
{ |
| 467 |
MHW_ASSERTMESSAGE("Invalid(null) pOsDriverContext!"); |
| 468 |
return nullptr; |
| 469 |
} |
| 470 |
|
| 471 |
PMOS_INTERFACE osInterface = nullptr; |
| 472 |
MhwInterfacesNext* mhwInterfaces = nullptr; |
| 473 |
MmdDeviceNext* device = nullptr; |
| 474 |
|
| 475 |
osInterface = (PMOS_INTERFACE)MOS_AllocAndZeroMemory(sizeof(MOS_INTERFACE)); |
| 476 |
if (osInterface == nullptr) |
| 477 |
{ |
| 478 |
return nullptr; |
| 479 |
} |
| 480 |
if (Mos_InitInterface( |
| 481 |
osInterface, |
| 482 |
osDriverContext, |
| 483 |
COMPONENT_MEMDECOMP) != MOS_STATUS_SUCCESS) |
| 484 |
{ |
| 485 |
MMD_FAILURE(); |
| 486 |
} |
| 487 |
|
| 488 |
PLATFORM platform = {}; |
| 489 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 490 |
device = MmdFactoryNext::Create(platform.eProductFamily); |
| 491 |
if (device == nullptr) |
| 492 |
{ |
| 493 |
MMD_FAILURE(); |
| 494 |
} |
| 495 |
|
| 496 |
mhwInterfaces = device->CreateMhwInterface(osInterface); |
| 497 |
if (mhwInterfaces == nullptr) |
| 498 |
{ |
| 499 |
MMD_FAILURE(); |
| 500 |
} |
| 501 |
MOS_STATUS status = device->Initialize(osInterface, mhwInterfaces); |
| 502 |
if (device->m_mmdDevice == nullptr) |
| 503 |
{ |
| 504 |
if (MOS_STATUS_UNINITIALIZED == status) |
| 505 |
{ |
| 506 |
MMD_FAILURE(); |
| 507 |
} |
| 508 |
else |
| 509 |
{ |
| 510 |
MOS_Delete(mhwInterfaces); |
| 511 |
MOS_Delete(device); |
| 512 |
return nullptr; |
| 513 |
} |
| 514 |
} |
| 515 |
|
| 516 |
void* mmdDevice = device->m_mmdDevice; |
| 517 |
MOS_Delete(mhwInterfaces); |
| 518 |
MOS_Delete(device); |
| 519 |
|
| 520 |
return mmdDevice; |
| 521 |
} |
| 522 |
|
| 523 |
MhwInterfacesNext* MmdDeviceNext::CreateMhwInterface(PMOS_INTERFACE osInterface) |
| 524 |
{ |
| 525 |
MhwInterfacesNext::CreateParams params; |
| 526 |
MOS_ZeroMemory(¶ms, sizeof(params)); |
| 527 |
params.Flags.m_vebox = true; |
| 528 |
MhwInterfacesNext* mhw = MhwInterfacesNext::CreateFactory(params, osInterface); |
| 529 |
|
| 530 |
if (mhw) |
| 531 |
{ |
| 532 |
MOS_Delete(mhw->m_veboxInterface); |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
return mhw; |
| 537 |
} |
| 538 |
|
| 539 |
HucKernelSource *HucKernelSourceDevice::CreateFactory( |
| 540 |
PMOS_INTERFACE osInterface) |
| 541 |
{ |
| 542 |
if (osInterface == nullptr) |
| 543 |
{ |
| 544 |
CODECHAL_PUBLIC_ASSERTMESSAGE("Invalid(null) osInterface!"); |
| 545 |
return nullptr; |
| 546 |
} |
| 547 |
|
| 548 |
PLATFORM platform = {}; |
| 549 |
osInterface->pfnGetPlatform(osInterface, &platform); |
| 550 |
HucKernelSourceDevice *device = HucKernelSourceFactory::Create(platform.eProductFamily); |
| 551 |
if (device == nullptr) |
| 552 |
{ |
| 553 |
CODECHAL_PUBLIC_ASSERTMESSAGE("HucKernelSource device creation failed!"); |
| 554 |
return nullptr; |
| 555 |
} |
| 556 |
|
| 557 |
device->Initialize(); |
| 558 |
if (device->m_hucKernelSource == nullptr) |
| 559 |
{ |
| 560 |
CODECHAL_PUBLIC_ASSERTMESSAGE("HucKernelSource creation failed!"); |
| 561 |
MOS_Delete(device); |
| 562 |
return nullptr; |
| 563 |
} |
| 564 |
|
| 565 |
HucKernelSource *hucKrnelSrc = device->m_hucKernelSource; |
| 566 |
MOS_Delete(device); |
| 567 |
return hucKrnelSrc; |
| 568 |
} |