Skip to content

Commit

Permalink
[Media Common] [Codec] Add physical Vdbox id report for codec
Browse files Browse the repository at this point in the history
1. Add physical Vdbox id report for some encode legacy features.
2. Unify store and report engine id logic for encode and decode.
3. Fix decode report engine id  issues when there are only one frame.
  • Loading branch information
LhGu authored and intel-mediadev committed Feb 19, 2025
1 parent 645bc98 commit 4b0db78
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
#define __MEDIA_USER_FEATURE_VALUE_FORCE_VDBOX "Force VDBOX"
#define __MEDIA_USER_FEATURE_VALUE_FORCE_VEBOX "Force VEBOX"
#define __MEDIA_USER_FEATURE_VALUE_FORCE_YFYS "Force to allocate YfYs"
#define __MEDIA_USER_FEATURE_VALUE_USED_VDBOX_ID "Used VDBOX ID"

#define __MEDIA_USER_FEATURE_VALUE_NULL_HW_ACCELERATION_ENABLE "NullHWAccelerationEnable"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,12 @@ namespace decode {

DecodeStatusReport::DecodeStatusReport(
DecodeAllocator* allocator, bool enableRcs, PMOS_INTERFACE osInterface):
MediaStatusReport(osInterface),
m_enableRcs(enableRcs),
m_allocator(allocator),
m_osInterface(osInterface)
{
m_sizeOfReport = sizeof(DecodeStatusReportData);
#if (_DEBUG || _RELEASE_INTERNAL)
if (osInterface && osInterface->pfnGetUserSettingInstance)
{
auto userSetting = osInterface->pfnGetUserSettingInstance(osInterface);
ReadUserSettingForDebug(
userSetting,
m_enableVdboxIdReport,
__MEDIA_USER_FEATURE_VALUE_ENABLE_VDBOX_ID_REPORT,
MediaUserSetting::Group::Device);
}
#endif
}

DecodeStatusReport::~DecodeStatusReport()
Expand Down Expand Up @@ -213,6 +203,13 @@ namespace decode {
// The frame is completed, notify the observers
if (statusReportData->codecStatus == CODECHAL_STATUS_SUCCESSFUL)
{
#if (_DEBUG || _RELEASE_INTERNAL)
if (m_enableVdboxIdReport)
{
DECODE_CHK_NULL(decodeStatusMfx);
ParseVdboxIdsFromBuf(decodeStatusMfx->m_mmioCsEngineIdReg);
}
#endif
NotifyObservers(decodeStatusMfx, decodeStatusRcs, statusReportData);
}

Expand Down Expand Up @@ -303,10 +300,31 @@ namespace decode {
return m_statusReportData[index];
}

#if (_DEBUG || _RELEASE_INTERNAL)
MOS_STATUS DecodeStatusReport::ReportUsedVdboxIds()
{
if (m_enableVdboxIdReport)
{
DECODE_CHK_NULL(m_dataStatusMfx);
DECODE_CHK_NULL(m_completedCount);
uint32_t completedCount = *m_completedCount;
for (uint32_t num = m_reportedCount; num < completedCount; num++)
{
const DecodeStatusMfx& status = GetMfxStatus(num);
ParseVdboxIdsFromBuf(status.m_mmioCsEngineIdReg);
}
MediaStatusReport::ReportUsedVdboxIds();
}
return MOS_STATUS_SUCCESS;
}
#endif

MOS_STATUS DecodeStatusReport::Destroy()
{
DECODE_FUNC_CALL();

#if (_DEBUG || _RELEASE_INTERNAL)
ReportUsedVdboxIds();
#endif
if (m_allocator != nullptr && m_statusBufMfx != nullptr)
{
m_allocator->UnLock(m_statusBufMfx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ namespace decode {
//!
const DecodeStatusReportData& GetReportData(uint32_t counter);

#if (_DEBUG || _RELEASE_INTERNAL)
//!
//! \brief Report Used Vdbox Ids
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
virtual MOS_STATUS ReportUsedVdboxIds() override;
#endif
protected:
//!
//! \brief Collect the status report information into report buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,6 @@

namespace decode
{

enum CsEngineIdDef
{
// Instance ID
csInstanceIdVdbox0 = 0,
csInstanceIdVdbox1 = 1,
csInstanceIdVdbox2 = 2,
csInstanceIdVdbox3 = 3,
csInstanceIdVdbox4 = 4,
csInstanceIdVdbox5 = 5,
csInstanceIdVdbox6 = 6,
csInstanceIdVdbox7 = 7,
csInstanceIdMax,
// Class ID
classIdVideoEngine = 1,
};

union CsEngineId
{
struct
{
uint32_t classId : 3; //[0...4]
uint32_t reservedFiled1 : 1; //[0]
uint32_t instanceId : 6; //[0...7]
uint32_t reservedField2 : 22; //[0]
} fields;
uint32_t value;
};

enum DecodeStatusReportType
{
statusReportGlobalCount = STATUS_REPORT_GLOBAL_COUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ namespace encode{
ENCODE_CHK_NULL_RETURN(perfProfiler);
ENCODE_CHK_STATUS_RETURN(perfProfiler->AddPerfCollectStartCmd(
(void *)m_pipeline, m_osInterface, m_miItf, cmdBuffer));

#if (_DEBUG || _RELEASE_INTERNAL)
if (m_statusReport && m_statusReport->IsVdboxIdReportEnabled())
{
ENCODE_CHK_NULL_RETURN(m_pipeline);
StoreEngineId(cmdBuffer, encode::EncodeStatusReportType::statusReportCsEngineIdRegs, m_pipeline->GetCurrentPipe());
}
#endif
return MOS_STATUS_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,12 @@ namespace encode {
ENCODE_CHK_NULL_RETURN(perfProfiler);
ENCODE_CHK_STATUS_RETURN(perfProfiler->AddPerfCollectStartCmd(
(void *)m_pipeline, m_osInterface, m_miItf, cmdBuffer));

#if (_DEBUG || _RELEASE_INTERNAL)
if (m_statusReport && m_statusReport->IsVdboxIdReportEnabled())
{
StoreEngineId(cmdBuffer, encode::EncodeStatusReportType::statusReportCsEngineIdRegs);
}
#endif
return MOS_STATUS_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,13 @@ namespace encode
ENCODE_CHK_NULL_RETURN(perfProfiler);
ENCODE_CHK_STATUS_RETURN(perfProfiler->AddPerfCollectStartCmd(
(void *)m_pipeline, m_osInterface, m_miItf, &cmdBuffer));

#if (_DEBUG || _RELEASE_INTERNAL)
if (m_statusReport && m_statusReport->IsVdboxIdReportEnabled())
{
ENCODE_CHK_NULL_RETURN(m_pipeline);
StoreEngineId(&cmdBuffer, encode::EncodeStatusReportType::statusReportCsEngineIdRegs, m_pipeline->GetCurrentPipe());
}
#endif
ENCODE_CHK_STATUS_RETURN(AddPictureHcpCommands(cmdBuffer));

ENCODE_CHK_STATUS_RETURN(AddPictureVdencCommands(cmdBuffer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace encode {

EncoderStatusReport::EncoderStatusReport(
EncodeAllocator *allocator, PMOS_INTERFACE pOsInterface, bool enableMfx, bool enableRcs, bool enablecp):
MediaStatusReport(pOsInterface),
m_osInterface(pOsInterface),
m_enableMfx(enableMfx),
m_enableRcs(enableRcs),
Expand Down Expand Up @@ -175,6 +176,7 @@ namespace encode {
m_statusBufAddr[statusReportNumSkip8x8Block].offset = CODECHAL_OFFSETOF(EncodeStatusMfx, numSkip8x8Block);
m_statusBufAddr[statusReportSliceReport].offset = CODECHAL_OFFSETOF(EncodeStatusMfx, sliceReport);
m_statusBufAddr[statusReportLpla].offset = CODECHAL_OFFSETOF(EncodeStatusMfx, lookaheadStatus);
m_statusBufAddr[statusReportCsEngineIdRegs].offset = CODECHAL_OFFSETOF(EncodeStatusMfx, csEngineIdRegs[0]);
}

MOS_STATUS EncoderStatusReport::Init(void *inputPar)
Expand Down Expand Up @@ -389,6 +391,12 @@ namespace encode {
// The frame is completed, notify the observers
if (statusReportData->codecStatus == CODECHAL_STATUS_SUCCESSFUL)
{
#if (_DEBUG || _RELEASE_INTERNAL)
if (m_enableVdboxIdReport && encodeStatusMfx)
{
ParseVdboxIdsFromBuf(encodeStatusMfx->csEngineIdRegs);
}
#endif
eStatus = NotifyObservers(encodeStatusMfx, encodeStatusRcs, statusReportData);
}

Expand All @@ -411,10 +419,32 @@ namespace encode {
return MOS_STATUS_SUCCESS;
}

#if (_DEBUG || _RELEASE_INTERNAL)
MOS_STATUS EncoderStatusReport::ReportUsedVdboxIds()
{
if (m_enableVdboxIdReport && m_dataStatusMfx)
{
ENCODE_CHK_NULL_RETURN(m_completedCount);
uint32_t completedCount = *m_completedCount;
for (uint32_t num = m_reportedCount; num < completedCount; num++)
{
uint32_t index = CounterToIndex(num);
EncodeStatusMfx* encodeStatusMfx = (EncodeStatusMfx*)(m_dataStatusMfx + index * m_statusBufSizeMfx);
ParseVdboxIdsFromBuf(encodeStatusMfx->csEngineIdRegs);
}
MediaStatusReport::ReportUsedVdboxIds();
}
return MOS_STATUS_SUCCESS;
}
#endif

MOS_STATUS EncoderStatusReport::Destroy()
{
ENCODE_FUNC_CALL();

#if (_DEBUG || _RELEASE_INTERNAL)
ReportUsedVdboxIds();
#endif
if (m_completedCountBuf != nullptr)
{
m_allocator->UnLock(m_completedCountBuf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ namespace encode {

virtual PMOS_RESOURCE GetHwCtrBuf();

#if (_DEBUG || _RELEASE_INTERNAL)
//!
//! \brief Report Used Vdbox Ids
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
virtual MOS_STATUS ReportUsedVdboxIds() override;
#endif
protected:
//!
//! \brief Collect the status report information into report buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ enum EncodeStatusReportType
statusReportSliceReport,
statusReportLpla,
statusReportHucStatus2Reg,
statusReportCsEngineIdRegs,
statusReportMfxMaxNum,

statusReportMaxNum
Expand Down Expand Up @@ -401,6 +402,7 @@ struct EncodeStatusMfx
uint32_t numSkip8x8Block; //!< Number of skipped 8x8 blocks
EncodeStatusSliceReport sliceReport;
uint32_t hucStatus2Reg; //!< Register value saving HuC Status2
uint32_t csEngineIdRegs[csInstanceIdMax]; //!< Saving csEngineID register value.
};

struct EncodeStatusRcs
Expand Down
7 changes: 7 additions & 0 deletions media_softlet/agnostic/common/os/mos_user_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,13 @@ MOS_STATUS MosUserSetting::InitUserSettingForDebug(MediaUserSettingSharedPtr use
0,
true); //"Force the VEBox to be used. (Default 0: FORCE_VEBOX_NONE )"

DeclareUserSettingKeyForDebug(
userSettingPtr,
__MEDIA_USER_FEATURE_VALUE_USED_VDBOX_ID,
MediaUserSetting::Group::Device,
0,
true); //"Used Vdbox physical id. (Default 0: Not used, Each Hex symbol represents one VDBOX, e.g. bits[3:0] means VD0, bits[7:4] means VD1)"

DeclareUserSettingKeyForDebug(
userSettingPtr,
__MEDIA_USER_FEATURE_VALUE_FORCE_YFYS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@
//!
#include <algorithm>
#include "media_status_report.h"
#include "mos_os.h"

MediaStatusReport::MediaStatusReport(PMOS_INTERFACE osInterface)
{
if (osInterface && osInterface->pfnGetUserSettingInstance)
{
m_userSettingPtr = osInterface->pfnGetUserSettingInstance(osInterface);
}
#if (_DEBUG || _RELEASE_INTERNAL)
ReadUserSettingForDebug(
m_userSettingPtr,
m_enableVdboxIdReport,
__MEDIA_USER_FEATURE_VALUE_ENABLE_VDBOX_ID_REPORT,
MediaUserSetting::Group::Device);
#endif
}

MOS_STATUS MediaStatusReport::GetAddress(uint32_t statusReportType, PMOS_RESOURCE &osResource, uint32_t &offset)
{
Expand Down Expand Up @@ -146,5 +162,39 @@ MOS_STATUS MediaStatusReport::NotifyObservers(void *mfxStatus, void *rcsStatus,
return eStatus;
}

#if (_DEBUG || _RELEASE_INTERNAL)
void MediaStatusReport::ParseVdboxIdsFromBuf(const uint32_t *csEngineIdRegBuf)
{
for (auto i = 0; i < csInstanceIdMax; i++)
{
CsEngineId csEngineId;
csEngineId.value = csEngineIdRegBuf[i];
if (csEngineId.fields.classId == classIdVideoEngine)
{
m_usedVdboxIds |= 1 << ((csEngineId.fields.instanceId) << 2);
}
}
}


MOS_STATUS MediaStatusReport::ReportUsedVdboxIds()
{
if (m_enableVdboxIdReport)
{
uint32_t reportedUsedID = 0;
ReadUserSettingForDebug(
m_userSettingPtr,
reportedUsedID,
__MEDIA_USER_FEATURE_VALUE_USED_VDBOX_ID,
MediaUserSetting::Group::Device,
0,
false,
MEDIA_USER_SETTING_INTERNAL_REPORT);
ReportUserSettingForDebug(
m_userSettingPtr,
__MEDIA_USER_FEATURE_VALUE_USED_VDBOX_ID,
reportedUsedID | m_usedVdboxIds,
MediaUserSetting::Group::Device);
}
return MOS_STATUS_SUCCESS;
}
#endif
Loading

0 comments on commit 4b0db78

Please sign in to comment.