Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroYY committed Nov 23, 2024
1 parent ab45550 commit 4955535
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ class McpyDevice
//! \return MOS_STATUS_SUCCESS if succeeded, else error code.
//!
virtual MOS_STATUS Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces) = 0;

PMOS_INTERFACE osInterface) = 0;
protected:
//!
//! \brief Creat platform specific MMD (media memory decompression) HW interface
//! \param [in] osInterface
Expand Down
55 changes: 24 additions & 31 deletions media_driver/linux/common/media_interfaces/media_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,36 +409,30 @@ MhwInterfaces* MmdDevice::CreateMhwInterface(PMOS_INTERFACE osInterface)
void* McpyDevice::CreateFactory(
PMOS_CONTEXT osDriverContext)
{
#define MCPY_FAILURE() \
{ \
if (mhwInterfaces != nullptr) \
{ \
mhwInterfaces->Destroy(); \
} \
MOS_Delete(mhwInterfaces); \
if (osInterface != nullptr) \
{ \
if (osInterface->pfnDestroy) \
{ \
osInterface->pfnDestroy(osInterface, false); \
} \
MOS_FreeMemory(osInterface); \
} \
MOS_Delete(device); \
return nullptr; \
}
MHW_FUNCTION_ENTER;

PMOS_INTERFACE osInterface = nullptr;
MhwInterfaces *mhwInterfaces = nullptr;
McpyDevice *device = nullptr;

auto deleterOnFailure = [&](bool deleteOsInterface){
if (deleteOsInterface && osInterface != nullptr)
{
if (osInterface->pfnDestroy)
{
osInterface->pfnDestroy(osInterface, false);
}
MOS_FreeMemory(osInterface);
}
MOS_Delete(device);
};

if (osDriverContext == nullptr)
{
MHW_ASSERTMESSAGE("Invalid(null) pOsDriverContext!");
return nullptr;
}

PMOS_INTERFACE osInterface = nullptr;
MhwInterfaces *mhwInterfaces = nullptr;
McpyDevice *device = nullptr;

osInterface = (PMOS_INTERFACE)MOS_AllocAndZeroMemory(sizeof(MOS_INTERFACE));
if (osInterface == nullptr)
{
Expand All @@ -449,26 +443,25 @@ void* McpyDevice::CreateFactory(
osDriverContext,
COMPONENT_MCPY) != MOS_STATUS_SUCCESS)
{
MCPY_FAILURE();
deleterOnFailure(true);
return nullptr;
}

PLATFORM platform = {};
osInterface->pfnGetPlatform(osInterface, &platform);
device = McpyFactory::Create(platform.eProductFamily);
if (device == nullptr)
{
MCPY_FAILURE();
deleterOnFailure(true);
return nullptr;
}

mhwInterfaces = device->CreateMhwInterface(osInterface);
if (mhwInterfaces == nullptr)
{
MCPY_FAILURE();
}
device->Initialize(osInterface, mhwInterfaces);
// transfer ownership of osInterface. No need to delete it if init fails
device->Initialize(osInterface);
if (device->m_mcpyDevice == nullptr)
{
MCPY_FAILURE();
deleterOnFailure(false);
return nullptr;
}

void *mcpyDevice = device->m_mcpyDevice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,47 +347,52 @@ static bool dg2RegisteredMcpy =
Register<McpyDeviceXe_Hpm>((uint32_t)IGFX_DG2);

MOS_STATUS McpyDeviceXe_Hpm::Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces)
PMOS_INTERFACE osInterface)
{
#define MCPY_FAILURE() \
{ \
if (device != nullptr) \
{ \
MOS_Delete(device); \
} \
return MOS_STATUS_NO_SPACE; \
}
MHW_FUNCTION_ENTER;

Mcpy *device = nullptr;
MhwInterfaces* mhwInterfaces = nullptr;

if (mhwInterfaces->m_miInterface == nullptr)
{
MCPY_FAILURE();
}
auto deleterOnFailure = [&](bool deleteOsInterface, bool deleteMhwInterface){
if (deleteOsInterface && osInterface != nullptr)
{
if (osInterface->pfnDestroy)
{
osInterface->pfnDestroy(osInterface, false);
}
MOS_FreeMemory(osInterface);
}

if (mhwInterfaces->m_veboxInterface == nullptr)
{
MCPY_FAILURE();
}
if (deleteMhwInterface && mhwInterfaces != nullptr)
{
mhwInterfaces->Destroy();
MOS_Delete(mhwInterfaces);
}

if (mhwInterfaces->m_bltInterface == nullptr)
{
MCPY_FAILURE();
}
MOS_Delete(device);
};

device = MOS_New(Mcpy);

if (device == nullptr)
{
MCPY_FAILURE();
deleterOnFailure(true, false);
return MOS_STATUS_NO_SPACE;
}

mhwInterfaces = CreateMhwInterface(osInterface);
if (mhwInterfaces->m_miInterface == nullptr ||
mhwInterfaces->m_veboxInterface == nullptr ||
mhwInterfaces->m_bltInterface == nullptr)
{
deleterOnFailure(true, true);
return MOS_STATUS_NO_SPACE;
}

if (device->Initialize(
osInterface, mhwInterfaces) != MOS_STATUS_SUCCESS)
{
MOS_Delete(device);
deleterOnFailure(false, false);
MOS_OS_CHK_STATUS_RETURN(MOS_STATUS_UNINITIALIZED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ class McpyDeviceXe_Hpm : public McpyDevice
using Mcpy = MediaCopyState_Xe_Hpm;

MOS_STATUS Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces);

PMOS_INTERFACE osInterface);
protected:
MhwInterfaces* CreateMhwInterface(
PMOS_INTERFACE osInterface);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,48 +409,52 @@ static bool tgllpRegisteredMcpy =
Register<McpyDeviceG12Tgllp>((uint32_t)IGFX_TIGERLAKE_LP);

MOS_STATUS McpyDeviceG12Tgllp::Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces)
PMOS_INTERFACE osInterface)
{
#define MCPY_FAILURE() \
{ \
if (device != nullptr) \
{ \
MOS_Delete(device); \
} \
return MOS_STATUS_NO_SPACE; \
}

MHW_FUNCTION_ENTER;

Mcpy *device = nullptr;
MhwInterfaces* mhwInterfaces = nullptr;

if (mhwInterfaces->m_miInterface == nullptr)
{
MCPY_FAILURE();
}
auto deleterOnFailure = [&](bool deleteOsInterface, bool deleteMhwInterface){
if (deleteOsInterface && osInterface != nullptr)
{
if (osInterface->pfnDestroy)
{
osInterface->pfnDestroy(osInterface, false);
}
MOS_FreeMemory(osInterface);
}

if (mhwInterfaces->m_veboxInterface == nullptr)
{
MCPY_FAILURE();
}
if (deleteMhwInterface && mhwInterfaces != nullptr)
{
mhwInterfaces->Destroy();
MOS_Delete(mhwInterfaces);
}

if (mhwInterfaces->m_bltInterface == nullptr)
{
MCPY_FAILURE();
}
MOS_Delete(device);
};

device = MOS_New(Mcpy);

if (device == nullptr)
{
MCPY_FAILURE();
deleterOnFailure(true, false);
return MOS_STATUS_NO_SPACE;
}

mhwInterfaces = CreateMhwInterface(osInterface);
if (mhwInterfaces->m_miInterface == nullptr ||
mhwInterfaces->m_veboxInterface == nullptr ||
mhwInterfaces->m_bltInterface == nullptr)
{
deleterOnFailure(true, true);
return MOS_STATUS_NO_SPACE;
}

if (device->Initialize(
osInterface, mhwInterfaces) != MOS_STATUS_SUCCESS)
{
MOS_Delete(device);
deleterOnFailure(false, false);
MOS_OS_CHK_STATUS_RETURN(MOS_STATUS_UNINITIALIZED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ public :
using Mcpy = MediaCopyStateM12_0;

MOS_STATUS Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces);

PMOS_INTERFACE osInterface);
protected:
MhwInterfaces* CreateMhwInterface(
PMOS_INTERFACE osInterface);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,43 +327,52 @@ static bool pvcRegisteredMcpy =
Register<McpyDeviceXe_Xpm_Plus>((uint32_t)IGFX_PVC);

MOS_STATUS McpyDeviceXe_Xpm_Plus::Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces)
PMOS_INTERFACE osInterface)
{
#define MCPY_FAILURE() \
{ \
if (device != nullptr) \
{ \
MOS_Delete(device); \
} \
return MOS_STATUS_NO_SPACE; \
}

MHW_FUNCTION_ENTER;

Mcpy *device = nullptr;
MhwInterfaces* mhwInterfaces = nullptr;

if (mhwInterfaces->m_miInterface == nullptr)
{
MCPY_FAILURE();
}
auto deleterOnFailure = [&](bool deleteOsInterface, bool deleteMhwInterface){
if (deleteOsInterface && osInterface != nullptr)
{
if (osInterface->pfnDestroy)
{
osInterface->pfnDestroy(osInterface, false);
}
MOS_FreeMemory(osInterface);
}

if (mhwInterfaces->m_renderInterface == nullptr)
{
MCPY_FAILURE();
}
if (deleteMhwInterface && mhwInterfaces != nullptr)
{
mhwInterfaces->Destroy();
MOS_Delete(mhwInterfaces);
}

device = MOS_New(Mcpy);
MOS_Delete(device);
};

device = MOS_New(Mcpy);
if (device == nullptr)
{
MCPY_FAILURE();
deleterOnFailure(true, false);
return MOS_STATUS_NO_SPACE;
}

mhwInterfaces = CreateMhwInterface(osInterface);
if (mhwInterfaces->m_miInterface == nullptr ||
mhwInterfaces->m_veboxInterface == nullptr ||
mhwInterfaces->m_bltInterface == nullptr)
{
deleterOnFailure(true, true);
return MOS_STATUS_NO_SPACE;
}

if (device->Initialize(
osInterface, mhwInterfaces) != MOS_STATUS_SUCCESS)
{
MOS_Delete(device);
deleterOnFailure(false, false);
MOS_OS_CHK_STATUS_RETURN(MOS_STATUS_UNINITIALIZED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@ class McpyDeviceXe_Xpm_Plus : public McpyDevice
public:
using Mcpy = MediaCopyStateXe_Xpm_Plus;
MOS_STATUS Initialize(
PMOS_INTERFACE osInterface,
MhwInterfaces *mhwInterfaces);

PMOS_INTERFACE osInterface);
protected:
MhwInterfaces* CreateMhwInterface(
PMOS_INTERFACE osInterface);
};
Expand Down
Loading

0 comments on commit 4955535

Please sign in to comment.