[Media Interface] Enable unified deissue dump interface

this deissue interface works for both codechal and vphal dump
diff --git a/media_driver/agnostic/common/codec/hal/codechal_debug.cpp b/media_driver/agnostic/common/codec/hal/codechal_debug.cpp
index f31604f..78ee794 100644
--- a/media_driver/agnostic/common/codec/hal/codechal_debug.cpp
+++ b/media_driver/agnostic/common/codec/hal/codechal_debug.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2019, Intel Corporation
+* Copyright (c) 2011-2020, Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -21,20 +21,12 @@
 */
 //!
 //! \file     codechal_debug.cpp
-//! \brief    Defines the debug interface shared by all of CodecHal.
-//! \details  The debug interface dumps output from CodecHal based on in input config file.
+//! \brief    Defines the debug interface shared by codec only.
+//! \details  The debug interface dumps output from Media based on in input config file.
 //!
 #include "codechal_debug.h"
 #if USE_CODECHAL_DEBUG_TOOL
 #include "codechal_debug_config_manager.h"
-#include "codechal_hw.h"
-#include <fstream>
-#include <sstream>
-#include <iomanip>
-
-#if !defined(LINUX) && !defined(ANDROID)
-#include "UmdStateSeparation.h"
-#endif
 
 CodechalDebugInterface::CodechalDebugInterface()
 {
@@ -42,971 +34,36 @@
     memset(m_fileName, 0, sizeof(m_fileName));
     memset(m_path, 0, sizeof(m_path));
 }
+
 CodechalDebugInterface::~CodechalDebugInterface()
 {
     if (nullptr != m_configMgr)
     {
         MOS_Delete(m_configMgr);
     }
-
-    if (!Mos_ResourceIsNull(&m_temp2DSurfForCopy.OsResource))
-    {
-        m_osInterface->pfnFreeResource(m_osInterface, &m_temp2DSurfForCopy.OsResource);
-    }
 }
 
 MOS_STATUS CodechalDebugInterface::Initialize(
     CodechalHwInterface *hwInterface,
-    CODECHAL_FUNCTION      codecFunction)
+    CODECHAL_FUNCTION    codecFunction)
 {
-    MOS_USER_FEATURE_VALUE_DATA       userFeatureData;
-    MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData;
-    char                              stringData[MOS_MAX_PATH_LENGTH + 1];
-    std::string                       codechalDumpFilePath;
-
     CODECHAL_DEBUG_FUNCTION_ENTER;
 
     CODECHAL_DEBUG_CHK_NULL(hwInterface);
-
-    m_hwInterface = hwInterface;
-    m_osInterface = m_hwInterface->GetOsInterface();
-    m_cpInterface = m_hwInterface->GetCpInterface();
-    m_miInterface = m_hwInterface->GetMiInterface();
-
-#ifdef LINUX
-    char* customizedOutputPath = getenv("MOS_DEBUG_OUTPUT_LOCATION");
-    if (customizedOutputPath != nullptr && strlen(customizedOutputPath) != 0)
-    {
-        m_outputFilePath = customizedOutputPath;
-        m_outputFilePath.erase(m_outputFilePath.find_last_not_of(" \n\r\t") + 1);
-        if (m_outputFilePath[m_outputFilePath.length() - 1] != MOS_DIRECTORY_DELIMITER)
-             m_outputFilePath += MOS_DIRECTORY_DELIMITER;
-    }
-    else
-#endif
-    {
-        MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
-        userFeatureData.StringData.pStringData = stringData;
-        MOS_UserFeature_ReadValue_ID(
-            NULL,
-            __MEDIA_USER_FEATURE_VALUE_CODECHAL_DEBUG_OUTPUT_DIRECTORY_ID,
-            &userFeatureData,
-            m_osInterface->pOsContext);
-
-        if (userFeatureData.StringData.uSize == MOS_MAX_PATH_LENGTH + 1)
-        {
-            userFeatureData.StringData.uSize = 0;
-        }
-
-        if (userFeatureData.StringData.uSize > 0)
-        {
-            if (userFeatureData.StringData.pStringData[userFeatureData.StringData.uSize - 2] != MOS_DIRECTORY_DELIMITER)
-            {
-                userFeatureData.StringData.pStringData[userFeatureData.StringData.uSize - 1] = MOS_DIRECTORY_DELIMITER;
-                userFeatureData.StringData.pStringData[userFeatureData.StringData.uSize]     = '\0';
-                userFeatureData.StringData.uSize++;
-            }
-            m_outputFilePath = userFeatureData.StringData.pStringData;
-        }
-        else
-        {
-#if defined(LINUX) || defined(ANDROID)
-            m_outputFilePath = MOS_DEBUG_DEFAULT_OUTPUT_LOCATION;
-#else
-            // Use state separation APIs to obtain appropriate storage location
-            if (SUCCEEDED(GetDriverPersistentStorageLocation(codechalDumpFilePath)))
-            {
-                m_outputFilePath = codechalDumpFilePath.c_str();
-                m_outputFilePath.append(MOS_CODECHAL_DUMP_OUTPUT_FOLDER);
-
-                MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData));
-                userFeatureWriteData.Value.StringData.pStringData = const_cast<char *>(m_outputFilePath.c_str());
-                userFeatureWriteData.Value.StringData.uSize       = m_outputFilePath.size();
-                userFeatureWriteData.ValueID                      = __MEDIA_USER_FEATURE_VALUE_CODECHAL_DUMP_OUTPUT_DIRECTORY_ID;
-                MOS_UserFeature_WriteValues_ID(NULL, &userFeatureWriteData, 1, m_osInterface->pOsContext);
-            }
-            else
-            {
-                return MOS_STATUS_UNKNOWN;
-            }
-#endif
-        }
-    }
-
+    m_hwInterface   = hwInterface;
     m_codecFunction = codecFunction;
-    m_configMgr = MOS_New(CodechalDebugConfigMgr, this, codecFunction, m_outputFilePath);
+    m_osInterface   = m_hwInterface->GetOsInterface();
+    m_cpInterface   = m_hwInterface->GetCpInterface();
+    m_miInterface   = m_hwInterface->GetMiInterface();
+
+    //dump loctaion is codechaldump
+    MediaDebugInterface::SetOutputFilePath();
+
+    m_configMgr = MOS_New(CodecDebugConfigMgr, this, m_codecFunction, m_outputFilePath);
     CODECHAL_DEBUG_CHK_NULL(m_configMgr);
     CODECHAL_DEBUG_CHK_STATUS(m_configMgr->ParseConfig(m_osInterface->pOsContext));
 
-    // Create thread specified sub folder as dump folder.
-    if (m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpToThreadFolder))
-    {
-        std::string  ThreadSubFolder = "T" + std::to_string(MOS_GetCurrentThreadId()) + MOS_DIRECTORY_DELIMITER;
-        m_outputFilePath = m_outputFilePath + ThreadSubFolder;
-        MOS_CreateDirectory(const_cast<char*>(m_outputFilePath.c_str()));
-    }
-
-    m_ddiFileName = m_outputFilePath + "ddi.par";
-    std::ofstream ofs(m_ddiFileName, std::ios::out);
-    ofs << "ParamFilePath"
-        << " = \"" << m_fileName << "\"" << std::endl;
-    ofs.close();
-
-    return MOS_STATUS_SUCCESS;
-}
-
-bool CodechalDebugInterface::DumpIsEnabled(
-    const char *attr,
-    CODECHAL_MEDIA_STATE_TYPE mediaState)
-{
-    if (nullptr == m_configMgr)
-    {
-        return false;
-    }
-
-    if (mediaState != CODECHAL_NUM_MEDIA_STATES)
-    {
-        return m_configMgr->AttrIsEnabled(mediaState, attr);
-    }
-    else
-    {
-        return m_configMgr->AttrIsEnabled(attr);
-    }
-}
-
-const char *CodechalDebugInterface::CreateFileName(
-    const char *funcName,
-    const char *bufType,
-    const char *extType)
-{
-    if (nullptr == funcName || nullptr == extType)
-    {
-        return nullptr;
-    }
-
-    char frameType = 'X';
-    // Sets the frameType label
-    if (m_frameType == I_TYPE)
-    {
-        frameType = 'I';
-    }
-    else if (m_frameType == P_TYPE)
-    {
-        frameType = 'P';
-    }
-    else if (m_frameType == B_TYPE)
-    {
-        frameType = 'B';
-    }
-    else if (m_frameType == MIXED_TYPE)
-    {
-        frameType = 'M';
-    }
-
-    const char *fieldOrder;
-    // Sets the Field Order label
-    if (CodecHal_PictureIsTopField(m_currPic))
-    {
-        fieldOrder = CodechalDbgFieldType::topField;
-    }
-    else if (CodecHal_PictureIsBottomField(m_currPic))
-    {
-        fieldOrder = CodechalDbgFieldType::botField;
-    }
-    else
-    {
-        fieldOrder = CodechalDbgFieldType::frame;
-    }
-
-    // Sets the Postfix label
-    if (m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary) &&
-        strcmp(extType, CodechalDbgExtType::txt) == 0)
-    {
-        extType = CodechalDbgExtType::dat;
-    }
-
-    if (bufType != nullptr &&
-        !strncmp(bufType, CodechalDbgBufferType::bufSlcParams, sizeof(CodechalDbgBufferType::bufSlcParams) - 1)
-        && !strncmp(funcName, "_DDIEnc", sizeof("_DDIEnc") - 1))
-    {
-        m_outputFileName = m_outputFilePath +
-                           std::to_string(m_bufferDumpFrameNum) + '-' +
-                           std::to_string(m_streamId) + '_' +
-                           std::to_string(m_sliceId + 1) +
-                           funcName + '_' + bufType + '_' + frameType + fieldOrder + extType;
-    }
-    else if (bufType != nullptr &&
-        !strncmp(bufType, CodechalDbgBufferType::bufEncodePar, sizeof(CodechalDbgBufferType::bufEncodePar) - 1))
-    {
-        if (!strncmp(funcName, "EncodeSequence", sizeof("EncodeSequence") - 1))
-        {
-            m_outputFileName = m_outputFilePath +
-                               std::to_string(m_streamId) + '_' +
-                               funcName + extType;
-        }
-        else
-        {
-            m_outputFileName = m_outputFilePath +
-                               std::to_string(m_bufferDumpFrameNum) + '-' +
-                               std::to_string(m_streamId) + '_' +
-                               funcName + frameType + fieldOrder + extType;
-        }
-    }
-    else
-    {
-        if (funcName[0]=='_')
-            funcName += 1;
-
-        if (bufType != nullptr)
-        {
-            m_outputFileName = m_outputFilePath +
-                               std::to_string(m_bufferDumpFrameNum) + '-' +
-                               std::to_string(m_streamId) + '_' +
-                               funcName + '_' + bufType + '_' + frameType + fieldOrder + extType;
-        }
-        else
-        {
-            m_outputFileName = m_outputFilePath +
-                               std::to_string(m_bufferDumpFrameNum) + '-' +
-                               std::to_string(m_streamId) + '_' +
-                               funcName + '_' + frameType + fieldOrder + extType;
-        }
-    }
-
-    return m_outputFileName.c_str();
-}
-
-MOS_STATUS CodechalDebugInterface::DumpCmdBuffer(
-    PMOS_COMMAND_BUFFER       cmdBuffer,
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    const char*    cmdName)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    bool attrEnabled = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrCmdBufferMfx);
-
-    if (!attrEnabled && mediaState != CODECHAL_NUM_MEDIA_STATES)
-    {
-        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attrCmdBuffer);
-    }
-
-    if (!attrEnabled)
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    bool binaryDumpEnabled = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpCmdBufInBinary);
-
-    std::string funcName = cmdName ? cmdName : m_configMgr->GetMediaStateStr(mediaState);
-    const char *fileName = CreateFileName(
-        funcName.c_str(),
-        CodechalDbgBufferType::bufCmd,
-        binaryDumpEnabled ? CodechalDbgExtType::dat : CodechalDbgExtType::txt);
-
-    if (binaryDumpEnabled)
-    {
-        DumpBufferInBinary((uint8_t *)cmdBuffer->pCmdBase, (uint32_t)cmdBuffer->iOffset);
-    }
-    else
-    {
-        DumpBufferInHexDwords((uint8_t *)cmdBuffer->pCmdBase, (uint32_t)cmdBuffer->iOffset);
-    }
-
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::Dump2ndLvlBatch(
-    PMHW_BATCH_BUFFER         batchBuffer,
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    const char*     batchName)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    bool attrEnabled = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attr2ndLvlBatchMfx);
-
-    if (!attrEnabled && mediaState != CODECHAL_NUM_MEDIA_STATES)
-    {
-        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attr2ndLvlBatch);
-    }
-
-    if (!attrEnabled)
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    CODECHAL_DEBUG_CHK_NULL(m_hwInterface);
-
-    bool        batchLockedForDebug = !batchBuffer->bLocked;
-    std::string funcName            = batchName ? batchName : m_configMgr->GetMediaStateStr(mediaState);
-
-    if (batchLockedForDebug)
-    {
-        (Mhw_LockBb(m_osInterface, batchBuffer));
-    }
-
-    const char *fileName = CreateFileName(
-        funcName.c_str(),
-        CodechalDbgBufferType::buf2ndLvl,
-        CodechalDbgExtType::txt);
-
-    batchBuffer->pData += batchBuffer->dwOffset;
-
-    DumpBufferInHexDwords(batchBuffer->pData,
-        (uint32_t)batchBuffer->iLastCurrent);
-
-    if (batchLockedForDebug)
-    {
-        (Mhw_UnlockBb(m_osInterface, batchBuffer, false));
-    }
-
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpCurbe(
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    PMHW_KERNEL_STATE         kernelState)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    if (mediaState >= CODECHAL_NUM_MEDIA_STATES ||
-        !m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attrCurbe))
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    std::string funcName = m_configMgr->GetMediaStateStr(mediaState);
-    bool binaryDump = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary);
-
-    const char *fileName = CreateFileName(
-        funcName.c_str(),
-        CodechalDbgBufferType::bufCurbe,
-        CodechalDbgExtType::txt);
-
-    return kernelState->m_dshRegion.Dump(
-        fileName,
-        kernelState->dwCurbeOffset,
-        kernelState->KernelParams.iCurbeLength,
-        binaryDump);
-}
-
-MOS_STATUS CodechalDebugInterface::DumpMDFCurbe(
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    uint8_t *                 curbeBuffer,
-    uint32_t                  curbeSize)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    uint8_t     *curbeAlignedData = nullptr;
-    uint32_t     curbeAlignedSize = 0;
-    MOS_STATUS   eStatus = MOS_STATUS_SUCCESS;
-
-    if (mediaState >= CODECHAL_NUM_MEDIA_STATES ||
-        !m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attrCurbe))
-    {
-        return eStatus;
-    }
-
-    std::string funcName = m_configMgr->GetMediaStateStr(mediaState);
-    bool binaryDump = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary);
-    const char* extType = binaryDump ? CodechalDbgExtType::dat : CodechalDbgExtType::txt;
-
-    const char *fileName = CreateFileName(
-        funcName.c_str(),
-        CodechalDbgBufferType::bufCurbe,
-        extType);
-
-    curbeAlignedSize = MOS_ALIGN_CEIL(curbeSize, 64);
-    curbeAlignedData = (uint8_t *)malloc(curbeAlignedSize * sizeof(uint8_t));
-    if (curbeAlignedData == nullptr)
-    {
-        eStatus = MOS_STATUS_NULL_POINTER;
-        return eStatus;
-    }
-
-    MOS_ZeroMemory(curbeAlignedData, curbeAlignedSize);
-    MOS_SecureMemcpy(curbeAlignedData, curbeSize, curbeBuffer, curbeSize);
-
-    if (binaryDump)
-    {
-        eStatus = DumpBufferInBinary(curbeAlignedData, curbeAlignedSize);
-    }
-    else
-    {
-        eStatus = DumpBufferInHexDwords(curbeAlignedData, curbeAlignedSize);
-    }
-
-    free(curbeAlignedData);
-
-    return eStatus;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpKernelRegion(
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    MHW_STATE_HEAP_TYPE       stateHeap,
-    PMHW_KERNEL_STATE         kernelState)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    uint8_t *sshData = nullptr;
-    uint32_t sshSize = 0;
-
-    MemoryBlock *regionBlock = nullptr;
-    bool         attrEnabled = false;
-    const char * bufferType;
-    if (stateHeap == MHW_ISH_TYPE)
-    {
-        regionBlock = &kernelState->m_ishRegion;
-        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attrIsh);
-        bufferType  = CodechalDbgBufferType::bufISH;
-    }
-    else if (stateHeap == MHW_DSH_TYPE)
-    {
-        regionBlock = &kernelState->m_dshRegion;
-        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attrDsh);
-        bufferType  = CodechalDbgBufferType::bufDSH;
-    }
-    else
-    {
-        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, CodechalDbgAttr::attrSsh);
-        bufferType  = CodechalDbgBufferType::bufSSH;
-
-        CODECHAL_DEBUG_CHK_NULL(m_osInterface);
-        CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnGetIndirectStatePointer(
-            m_osInterface,
-            &sshData));
-        sshData += kernelState->dwSshOffset;
-        sshSize = kernelState->dwSshSize;
-    }
-
-    if (!attrEnabled)
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    std::string funcName = m_configMgr->GetMediaStateStr(mediaState);
-
-    const char *fileName = CreateFileName(
-        funcName.c_str(),
-        bufferType,
-        CodechalDbgExtType::txt);
-
-    bool binaryDump = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary);
-
-    if (regionBlock)
-    {
-        return regionBlock->Dump(fileName, 0, 0, binaryDump);
-    }
-    else
-    {
-        return DumpBufferInHexDwords(sshData, sshSize);
-    }
-}
-
-MOS_STATUS CodechalDebugInterface::DumpYUVSurface(
-    PMOS_SURFACE              surface,
-    const char*               attrName,
-    const char*               surfName,
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    uint32_t                  width_in,
-    uint32_t                  height_in)
-{
-    if (!DumpIsEnabled(attrName, mediaState))
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    MOS_LOCK_PARAMS lockFlags;
-    MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
-    lockFlags.ReadOnly = 1;
-    lockFlags.TiledAsTiled = 1; // Bypass GMM CPU blit due to some issues in GMM CpuBlt function
-
-    uint8_t* lockedAddr = (uint8_t*)m_osInterface->pfnLockResource(m_osInterface, &surface->OsResource, &lockFlags);
-    if (lockedAddr == nullptr) // Failed to lock. Try to submit copy task and dump another surface
-    {
-        uint32_t        sizeToBeCopied = 0;
-        MOS_GFXRES_TYPE ResType;
-
-#if LINUX
-        // Linux does not have OsResource->ResType
-        ResType = surface->Type;
-#else
-        ResType = surface->OsResource.ResType;
-#endif
-
-        GMM_RESOURCE_FLAG gmmFlags = surface->OsResource.pGmmResInfo->GetResFlags();
-        bool allocated = false;
-
-        CODECHAL_DEBUG_CHK_STATUS(ReAllocateSurface(
-            &m_temp2DSurfForCopy,
-            surface,
-            "Temp2DSurfForSurfDumper",
-            ResType));
-
-        // Ensure allocated buffer size contains the source surface size
-        if (m_temp2DSurfForCopy.OsResource.pGmmResInfo->GetSizeMainSurface() >= surface->OsResource.pGmmResInfo->GetSizeMainSurface())
-        {
-            sizeToBeCopied = (uint32_t)surface->OsResource.pGmmResInfo->GetSizeMainSurface();
-        }
-
-        if (sizeToBeCopied == 0)
-        {
-            // Currently, MOS's pfnAllocateResource does not support allocate a surface reference to another surface.
-            // When the source surface is not created from Media, it is possible that we cannot allocate the same size as source.
-            // For example, on Gen9, Render target might have GMM set CCS=1 MMC=0, but MOS cannot allocate surface with such combination.
-            // When Gmm allocation parameter is different, the resulting surface size/padding/pitch will be differnt.
-            // Once if MOS can support allocate a surface by reference another surface, we can do a bit to bit copy without problem.
-            CODECHAL_DEBUG_ASSERTMESSAGE("Cannot allocate correct size, failed to copy nonlockable resource");
-            return MOS_STATUS_NULL_POINTER;
-        }
-
-        CODECHAL_DEBUG_VERBOSEMESSAGE("Temp2DSurfaceForCopy width %d, height %d, pitch %d, TileType %d, bIsCompressed %d, CompressionMode %d",
-            m_temp2DSurfForCopy.dwWidth,
-            m_temp2DSurfForCopy.dwHeight,
-            m_temp2DSurfForCopy.dwPitch,
-            m_temp2DSurfForCopy.TileType,
-            m_temp2DSurfForCopy.bIsCompressed,
-            m_temp2DSurfForCopy.CompressionMode);
-
-        if (CopySurfaceData_Vdbox(sizeToBeCopied, &surface->OsResource, &m_temp2DSurfForCopy.OsResource) != MOS_STATUS_SUCCESS)
-        {
-            CODECHAL_DEBUG_ASSERTMESSAGE("CopyDataSurface_Vdbox failed");
-            m_osInterface->pfnFreeResource(m_osInterface, &m_temp2DSurfForCopy.OsResource);
-            return MOS_STATUS_NULL_POINTER;
-        }
-        lockedAddr = (uint8_t*)m_osInterface->pfnLockResource(m_osInterface, &m_temp2DSurfForCopy.OsResource, &lockFlags);
-        CODECHAL_DEBUG_CHK_NULL(lockedAddr);
-
-        if (DumpIsEnabled(CodechalDbgAttr::attrDisableSwizzleForDumps))
-        {
-            if (CodecHal_PictureIsField(m_currPic))
-            {
-                return MOS_STATUS_INVALID_PARAMETER;
-            }
-            else
-            {
-                return DumpNotSwizzled(surfName, m_temp2DSurfForCopy, lockedAddr, sizeToBeCopied);
-            }
-        }
-    }
-
-    uint32_t sizeMain = (uint32_t)(surface->OsResource.pGmmResInfo->GetSizeMainSurface());
-    if (DumpIsEnabled(CodechalDbgAttr::attrDisableSwizzleForDumps))
-    {
-        if (CodecHal_PictureIsField(m_currPic))
-        {
-            return MOS_STATUS_INVALID_PARAMETER;
-        }
-        else
-        {
-            return DumpNotSwizzled(surfName, *surface, lockedAddr, sizeMain);
-        }
-    }
-
-    uint8_t* surfBaseAddr = (uint8_t*)MOS_AllocMemory(sizeMain);
-    CODECHAL_DEBUG_CHK_NULL(surfBaseAddr);
-
-    if (DumpIsEnabled(CodechalDbgAttr::attrForceYUVDumpWithMemcpy))
-    {
-        MOS_SecureMemcpy(surfBaseAddr, sizeMain, lockedAddr, sizeMain); // Firstly, copy to surfBaseAddr to faster unlock resource
-        m_osInterface->pfnUnlockResource(m_osInterface, &surface->OsResource);
-        lockedAddr = surfBaseAddr;
-        surfBaseAddr = (uint8_t*)MOS_AllocMemory(sizeMain);
-        CODECHAL_DEBUG_CHK_NULL(surfBaseAddr);
-    }
-
-    // Always use MOS swizzle instead of GMM Cpu blit
-    CODECHAL_DEBUG_CHK_NULL(surfBaseAddr);
-    Mos_SwizzleData(lockedAddr, surfBaseAddr, surface->TileType, MOS_TILE_LINEAR, sizeMain / surface->dwPitch, surface->dwPitch, 0);
-
-    uint8_t* data = surfBaseAddr;
-    data += surface->dwOffset + surface->YPlaneOffset.iYOffset * surface->dwPitch;
-
-    uint32_t width = width_in ? width_in : surface->dwWidth;
-    uint32_t height = height_in ? height_in : surface->dwHeight;
-
-    switch (surface->Format)
-    {
-    case Format_YUY2:
-    case Format_Y216V:
-    case Format_P010:
-    case Format_P016:
-        width = width << 1;
-        break;
-    case Format_Y216:
-    case Format_Y210:  //422 10bit -- Y0[15:0]:U[15:0]:Y1[15:0]:V[15:0] = 32bits per pixel = 4Bytes per pixel
-    case Format_Y410:  //444 10bit -- A[31:30]:V[29:20]:Y[19:10]:U[9:0] = 32bits per pixel = 4Bytes per pixel
-    case Format_R10G10B10A2:
-    case Format_AYUV:  //444 8bit  -- A[31:24]:Y[23:16]:U[15:8]:V[7:0] = 32bits per pixel = 4Bytes per pixel
-    case Format_A8R8G8B8:
-        width = width << 2;
-        break;
-    default:
-        break;
-    }
-
-    uint32_t pitch = surface->dwPitch;
-    if (surface->Format == Format_UYVY)
-        pitch = width;
-
-    if (CodecHal_PictureIsBottomField(m_currPic))
-    {
-        data += pitch;
-    }
-
-    if (CodecHal_PictureIsField(m_currPic))
-    {
-        pitch *= 2;
-        height /= 2;
-    }
-
-    const char* funcName = (m_codecFunction == CODECHAL_FUNCTION_DECODE) ? "_DEC" : (m_codecFunction == CODECHAL_FUNCTION_CENC_DECODE ? "_DEC" : "_ENC");
-    std::string bufName = std::string(surfName) + "_w[" + std::to_string(surface->dwWidth) + "]_h[" + std::to_string(surface->dwHeight) + "]_p[" + std::to_string(pitch) + "]";
-    const char* filePath = CreateFileName(funcName, bufName.c_str(), CodechalDbgExtType::yuv);
-
-    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
-    if (ofs.fail())
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    // write luma data to file
-    for (uint32_t h = 0; h < height; h++)
-    {
-        ofs.write((char*)data, width);
-        data += pitch;
-    }
-
-    if (surface->Format != Format_A8B8G8R8)
-    {
-        switch (surface->Format)
-        {
-        case Format_NV12:
-        case Format_P010:
-        case Format_P016:
-            height >>= 1;
-            break;
-        case  Format_Y416:
-        case  Format_AUYV:
-        case  Format_R10G10B10A2:
-            height *= 2;
-            break;
-        case  Format_YUY2:
-        case  Format_YUYV:
-        case  Format_YUY2V:
-        case  Format_Y216V:
-        case  Format_YVYU:
-        case  Format_UYVY:
-        case  Format_VYUY:
-        case  Format_Y216: //422 16bit
-        case  Format_Y210: //422 10bit
-        case  Format_P208: //422 8bit
-            break;
-        case Format_422V:
-        case Format_IMC3:
-            height = height / 2;
-            break;
-        case  Format_AYUV:
-        default:
-            height = 0;
-            break;
-        }
-
-        uint8_t* vPlaneData = surfBaseAddr;
-#ifdef LINUX
-        data = surfBaseAddr + surface->UPlaneOffset.iSurfaceOffset;
-        if (surface->Format == Format_422V
-            || surface->Format == Format_IMC3)
-        {
-            vPlaneData = surfBaseAddr + surface->VPlaneOffset.iSurfaceOffset;
-    }
-#else
-        data = surfBaseAddr + surface->UPlaneOffset.iLockSurfaceOffset;
-        if (surface->Format == Format_422V
-            || surface->Format == Format_IMC3)
-        {
-            vPlaneData = surfBaseAddr + surface->VPlaneOffset.iLockSurfaceOffset;
-        }
-
-#endif
-
-        // write chroma data to file
-        for (uint32_t h = 0; h < height; h++)
-        {
-            ofs.write((char*)data, width);
-            data += pitch;
-        }
-
-        // write v planar data to file
-        if (surface->Format == Format_422V
-            || surface->Format == Format_IMC3)
-        {
-            for (uint32_t h = 0; h < height; h++)
-            {
-                ofs.write((char*)vPlaneData, width);
-                vPlaneData += pitch;
-            }
-        }
-    }
-    ofs.close();
-
-    if (DumpIsEnabled(CodechalDbgAttr::attrForceYUVDumpWithMemcpy))
-    {
-        MOS_FreeMemory(lockedAddr);
-    }
-    else
-    {
-        m_osInterface->pfnUnlockResource(m_osInterface, &surface->OsResource);
-    }
-    MOS_FreeMemory(surfBaseAddr);
-
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpBuffer(
-    PMOS_RESOURCE             resource,
-    const char *              attrName,
-    const char *              bufferName,
-    uint32_t                  size,
-    uint32_t                  offset,
-    CODECHAL_MEDIA_STATE_TYPE mediaState)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    CODECHAL_DEBUG_CHK_NULL(resource);
-    CODECHAL_DEBUG_CHK_NULL(bufferName);
-
-    if (size == 0)
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    if (attrName)
-    {
-        bool attrEnabled = false;
-
-        if (mediaState == CODECHAL_NUM_MEDIA_STATES)
-        {
-            attrEnabled = m_configMgr->AttrIsEnabled(attrName);
-        }
-        else
-        {
-            attrEnabled = m_configMgr->AttrIsEnabled(mediaState, attrName);
-        }
-
-        if (!attrEnabled)
-        {
-            return MOS_STATUS_SUCCESS;
-        }
-    }
-
-    MOS_LOCK_PARAMS lockFlags;
-    MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
-    lockFlags.ReadOnly = 1;
-    uint8_t *data      = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, resource, &lockFlags);
-    CODECHAL_DEBUG_CHK_NULL(data);
-    data += offset;
-
-    const char *fileName;
-    bool binaryDump = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary);
-    const char* extType = binaryDump ? CodechalDbgExtType::dat : CodechalDbgExtType::txt;
-
-    if (mediaState == CODECHAL_NUM_MEDIA_STATES)
-    {
-        fileName = CreateFileName(bufferName, attrName, extType);
-    }
-    else
-    {
-        std::string kernelName = m_configMgr->GetMediaStateStr(mediaState);
-        fileName           = CreateFileName(kernelName.c_str(), bufferName, extType);
-    }
-
-    MOS_STATUS status;
-    if (binaryDump)
-    {
-        status = DumpBufferInBinary(data, size);
-    }
-    else
-    {
-        status = DumpBufferInHexDwords(data, size);
-    }
-
-    if (data)
-    {
-        m_osInterface->pfnUnlockResource(m_osInterface, resource);
-    }
-
-    return status;
-}
-
-#define FIELD_TO_OFS(type, name)   ofs << #name << ": " << (int64_t)*((type*)report) << std::endl; report += sizeof(type) / sizeof(uint8_t);
-#define POINTER_TO_OFS(type, name) ofs << #name << ": " << (void*)report << std::endl; report += sizeof(void*) / sizeof(uint8_t);
-MOS_STATUS CodechalDebugInterface::DumpEncodeStatusReport(uint8_t* report)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    CODECHAL_DEBUG_CHK_NULL(report);
-
-    const char* bufferName = "EncodeStatusReport_Parsed";
-    const char* attrName = CodechalDbgAttr::attrStatusReport;
-    if (!m_configMgr->AttrIsEnabled(attrName))
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    const char* filePath = CreateFileName(bufferName, attrName, CodechalDbgExtType::txt);
-    std::ofstream ofs(filePath);
-
-    if (ofs.fail())
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    FIELD_TO_OFS(CODECHAL_STATUS,    CodecStatus);
-    FIELD_TO_OFS(uint32_t,           StatusReportNumber);
-    FIELD_TO_OFS(uint32_t,           CurrOriginalPic.FrameIdx);
-    FIELD_TO_OFS(CODEC_PICTURE_FLAG, CurrOriginalPic.PicFlags);
-    FIELD_TO_OFS(uint32_t,           CurrOriginalPic.PicEntry);
-    FIELD_TO_OFS(uint32_t,           Func);
-    POINTER_TO_OFS(PCODEC_REF_LIST,  pCurrRefList);
-    ofs << std::endl;
-
-    FIELD_TO_OFS(bool,        bSequential);
-    FIELD_TO_OFS(uint32_t,    bitstreamSize);
-    FIELD_TO_OFS(int8_t,      QpY);
-    FIELD_TO_OFS(int8_t,      SuggestedQpYDelta);
-    FIELD_TO_OFS(uint8_t,     NumberPasses);
-    FIELD_TO_OFS(uint8_t,     AverageQp);
-    FIELD_TO_OFS(uint64_t,    HWCounterValue.IV);
-    FIELD_TO_OFS(uint64_t,    HWCounterValue.Count);
-    POINTER_TO_OFS(uint64_t*, hwctr);
-    FIELD_TO_OFS(uint32_t,    QueryStatusFlags);
-    ofs << std::endl;
-
-    FIELD_TO_OFS(uint32_t, MAD);
-    FIELD_TO_OFS(uint32_t, loopFilterLevel);
-    FIELD_TO_OFS(int8_t,   LongTermIndication);
-    FIELD_TO_OFS(uint16_t, NextFrameWidthMinus1);
-    FIELD_TO_OFS(uint16_t, NextFrameHeightMinus1);
-    FIELD_TO_OFS(uint8_t,  NumberSlices);
-
-    FIELD_TO_OFS(uint16_t, PSNRx100[0]);
-    FIELD_TO_OFS(uint16_t, PSNRx100[1]);
-    FIELD_TO_OFS(uint16_t, PSNRx100[2]);
-
-    FIELD_TO_OFS(uint32_t,    NumberTilesInFrame);
-    FIELD_TO_OFS(uint8_t,     UsedVdBoxNumber);
-    FIELD_TO_OFS(uint32_t,    SizeOfSliceSizesBuffer);
-    POINTER_TO_OFS(uint16_t*, pSliceSizes);
-    FIELD_TO_OFS(uint32_t,    SizeOfTileInfoBuffer);
-    POINTER_TO_OFS(void*,     pHEVCTileinfo);
-    FIELD_TO_OFS(uint32_t,    NumTileReported);
-    ofs << std::endl;
-
-    FIELD_TO_OFS(uint32_t, StreamId);
-    POINTER_TO_OFS(void*,  pLookaheadStatus);
-    ofs.close();
-
-    return MOS_STATUS_SUCCESS;
-}
-#undef FIELD_TO_OFS
-#undef POINTER_TO_OFS
-
-MOS_STATUS CodechalDebugInterface::DumpSurface(
-    PMOS_SURFACE              surface,
-    const char *              attrName,
-    const char *              surfaceName,
-    CODECHAL_MEDIA_STATE_TYPE mediaState)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    CODECHAL_DEBUG_CHK_NULL(surface);
-    CODECHAL_DEBUG_CHK_NULL(attrName);
-    CODECHAL_DEBUG_CHK_NULL(surfaceName);
-
-    bool attrEnabled = false;
-
-    if (mediaState == CODECHAL_NUM_MEDIA_STATES)
-    {
-        attrEnabled = m_configMgr->AttrIsEnabled(attrName);
-    }
-    else
-    {
-        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, attrName);
-    }
-
-    if (!attrEnabled)
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    bool binaryDump = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary);
-    const char* extType = binaryDump ? CodechalDbgExtType::dat : CodechalDbgExtType::txt;
-
-    MOS_LOCK_PARAMS lockFlags;
-    MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
-    lockFlags.ReadOnly = 1;
-    uint8_t *data      = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, &surface->OsResource, &lockFlags);
-    CODECHAL_DEBUG_CHK_NULL(data);
-    
-    std::string bufName  = std::string(surfaceName) + "_w[" + std::to_string(surface->dwWidth) + "]_h[" + std::to_string(surface->dwHeight) + "]_p[" + std::to_string(surface->dwPitch) + "]";
-    const char *fileName;
-    if (mediaState == CODECHAL_NUM_MEDIA_STATES)
-    {
-        fileName = CreateFileName(bufName.c_str(), nullptr, extType);
-    }
-    else
-    {
-        std::string kernelName = m_configMgr->GetMediaStateStr(mediaState);
-        fileName               = CreateFileName(kernelName.c_str(), bufName.c_str(), extType);
-    }
-
-    MOS_STATUS status;
-    if (binaryDump)
-    {
-        status = Dump2DBufferInBinary(data, surface->dwWidth, surface->dwHeight, surface->dwPitch);
-    }
-    else
-    {
-        status = DumpBufferInHexDwords(data, surface->dwHeight*surface->dwPitch);
-    }
-
-    if (data)
-    {
-        m_osInterface->pfnUnlockResource(m_osInterface, &surface->OsResource);
-    }
-
-    return status;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpData(
-    void *      data,
-    uint32_t    size,
-    const char *attrName,
-    const char *bufferName)
-{
-    CODECHAL_DEBUG_FUNCTION_ENTER;
-
-    CODECHAL_DEBUG_CHK_NULL(data);
-    CODECHAL_DEBUG_CHK_NULL(attrName);
-    CODECHAL_DEBUG_CHK_NULL(bufferName);
-
-    if (!m_configMgr->AttrIsEnabled(attrName))
-    {
-        return MOS_STATUS_SUCCESS;
-    }
-
-    bool binaryDump = m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrDumpBufferInBinary);
-    const char *fileName = CreateFileName(bufferName, nullptr,
-                                          binaryDump ? CodechalDbgExtType::dat : CodechalDbgExtType::txt);
-
-    if (binaryDump)
-    {
-        DumpBufferInBinary((uint8_t *)data, size);
-    }
-    else
-    {
-        DumpBufferInHexDwords((uint8_t *)data, size);
-    }
+    MediaDebugInterface::InitDumpLocation();
 
     return MOS_STATUS_SUCCESS;
 }
@@ -1019,7 +76,7 @@
 {
     CODECHAL_DEBUG_FUNCTION_ENTER;
 
-    if (!m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrHuCDmem))
+    if (!m_configMgr->AttrIsEnabled(MediaDbgAttr::attrHuCDmem))
     {
         return MOS_STATUS_SUCCESS;
     }
@@ -1044,7 +101,7 @@
         funcName = "ENC_";
     }
 
-    std::string dmemName = CodechalDbgBufferType::bufHucDmem;
+    std::string dmemName = MediaDbgBufferType::bufHucDmem;
     std::string passName = std::to_string(hucPassNum);
     switch (dumpType)
     {
@@ -1080,6 +137,17 @@
     return DumpBuffer(dmemResource, nullptr, funcName.c_str(), dmemSize);
 }
 
+MOS_USER_FEATURE_VALUE_ID CodechalDebugInterface::SetOutputPathKey()
+{
+    return __MEDIA_USER_FEATURE_VALUE_CODECHAL_DEBUG_OUTPUT_DIRECTORY_ID;
+}
+
+MOS_USER_FEATURE_VALUE_ID CodechalDebugInterface::InitDefaultOutput()
+{
+    m_outputFilePath.append(MEDIA_DEBUG_CODECHAL_DUMP_OUTPUT_FOLDER);
+    return SetOutputPathKey();
+}
+
 MOS_STATUS CodechalDebugInterface::DumpHucRegion(
     PMOS_RESOURCE             region,
     uint32_t                  regionOffset,
@@ -1092,7 +160,7 @@
 {
     CODECHAL_DEBUG_FUNCTION_ENTER;
 
-    if (!m_configMgr->AttrIsEnabled(CodechalDbgAttr::attrHucRegions))
+    if (!m_configMgr->AttrIsEnabled(MediaDbgAttr::attrHucRegions))
     {
         return MOS_STATUS_SUCCESS;
     }
@@ -1111,14 +179,14 @@
     }
     else if (m_codecFunction == CODECHAL_FUNCTION_CENC_DECODE)
     {
-        funcName = "DEC_Cenc_";
+        funcName = "DEC_CENC_";
     }
     else
     {
         funcName = "ENC_";
     }
 
-    std::string bufName       = CodechalDbgBufferType::bufHucRegion;
+    std::string bufName       = MediaDbgBufferType::bufHucRegion;
     std::string inputName     = (inputBuffer) ? "Input_" : "Output_";
     std::string regionNumName = std::to_string(regionNum);
     std::string passName      = std::to_string(hucPassNum);
@@ -1153,318 +221,26 @@
     return DumpBuffer(region, nullptr, funcName.c_str(), regionSize, regionOffset);
 }
 
-MOS_STATUS CodechalDebugInterface::DumpBltOutput(
-    PMOS_SURFACE              surface,
-    const char *              attrName)
+#define FIELD_TO_OFS(type, name)                                       \
+    ofs << #name << ": " << (int64_t) * ((type *)report) << std::endl; \
+    report += sizeof(type) / sizeof(uint8_t);
+#define POINTER_TO_OFS(type, name)                       \
+    ofs << #name << ": " << (void *)report << std::endl; \
+    report += sizeof(void *) / sizeof(uint8_t);
+MOS_STATUS CodechalDebugInterface::DumpEncodeStatusReport(uint8_t *report)
 {
-    return MOS_STATUS_SUCCESS;
-}
+    CODECHAL_DEBUG_FUNCTION_ENTER;
 
-MOS_STATUS CodechalDebugInterface::DeleteCfgLinkNode(uint32_t frameIdx)
-{
-   return m_configMgr->DeleteCfgNode(frameIdx);
-}
+    CODECHAL_DEBUG_CHK_NULL(report);
 
-
-MOS_STATUS CodechalDebugInterface::ReAllocateSurface(
-    PMOS_SURFACE    pSurface,
-    PMOS_SURFACE    pSrcSurf,
-    PCCHAR          pSurfaceName,
-    MOS_GFXRES_TYPE DefaultResType)
-{
-    MOS_ALLOC_GFXRES_PARAMS AllocParams;
-
-    CODECHAL_DEBUG_ASSERT(m_osInterface);
-    CODECHAL_DEBUG_ASSERT(&pSurface->OsResource);
-
-    // bCompressible should be compared with bCompressible since it is inited by bCompressible in previous call
-    // TileType of surface should be compared since we need to reallocate surface if TileType changes
-    if (!Mos_ResourceIsNull(&pSurface->OsResource)               &&
-        (pSurface->dwWidth         == pSrcSurf->dwWidth)         &&
-        (pSurface->dwHeight        == pSrcSurf->dwHeight)        &&
-        (pSurface->Format          == pSrcSurf->Format)          &&
-        (pSurface->bCompressible   == pSrcSurf->bCompressible)   &&
-        (pSurface->CompressionMode == pSrcSurf->CompressionMode) &&
-        (pSurface->TileType        == pSrcSurf->TileType))
+    const char *bufferName = "EncodeStatusReport_Parsed";
+    const char *attrName   = MediaDbgAttr::attrStatusReport;
+    if (!m_configMgr->AttrIsEnabled(attrName))
     {
         return MOS_STATUS_SUCCESS;
     }
-    MOS_ZeroMemory(&AllocParams, sizeof(MOS_ALLOC_GFXRES_PARAMS));
 
-#if !EMUL
-    //  Need to reallocate surface according to expected tiletype instead of tiletype of the surface what we have 
-    if ((pSurface->OsResource.pGmmResInfo != nullptr) &&
-        (pSurface->TileType               == pSrcSurf->TileType))
-    {
-        // Reallocate but use same tile type and resource type as current
-        AllocParams.TileType = pSurface->OsResource.TileType;
-        AllocParams.Type     = DefaultResType;
-    }
-    else
-#endif
-    {
-        // First time allocation. Caller must specify default params
-        AllocParams.TileType = pSrcSurf->TileType;
-        AllocParams.Type     = DefaultResType;
-    }
-
-    AllocParams.dwWidth         = pSrcSurf->dwWidth;
-    AllocParams.dwHeight        = pSrcSurf->dwHeight;
-    AllocParams.Format          = pSrcSurf->Format;
-    AllocParams.bIsCompressible = pSrcSurf->bCompressible;
-    AllocParams.CompressionMode = pSrcSurf->CompressionMode;
-    AllocParams.pBufName        = pSurfaceName;
-    AllocParams.dwArraySize     = 1;
-
-    // Delete resource if already allocated
-    m_osInterface->pfnFreeResource(m_osInterface, &(pSurface->OsResource));
-
-    // Allocate surface
-    CODECHAL_PUBLIC_CHK_STATUS_RETURN(m_osInterface->pfnAllocateResource(
-        m_osInterface,
-        &AllocParams,
-        &pSurface->OsResource));
-
-    pSurface->dwWidth         = pSrcSurf->dwWidth;
-    pSurface->dwHeight        = pSrcSurf->dwHeight;
-    pSurface->dwPitch         = pSrcSurf->dwPitch;
-    pSurface->dwDepth         = pSrcSurf->dwDepth;
-    pSurface->dwQPitch        = pSrcSurf->dwQPitch;
-    pSurface->bArraySpacing   = pSrcSurf->bArraySpacing;
-    pSurface->bCompressible   = pSrcSurf->bCompressible;
-    pSurface->CompressionMode = pSrcSurf->CompressionMode;
-    pSurface->bIsCompressed   = pSrcSurf->bIsCompressed;
-
-    MOS_SURFACE details;
-    MOS_ZeroMemory(&details, sizeof(details));
-    details.Format = Format_Invalid;
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnGetResourceInfo(m_osInterface, &pSurface->OsResource, &details));
-
-    pSurface->Format   = details.Format;
-    pSurface->TileType = details.TileType;
-    pSurface->dwOffset = details.RenderOffset.YUV.Y.BaseOffset;
-    pSurface->YPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.Y.BaseOffset;
-    pSurface->YPlaneOffset.iXOffset = details.RenderOffset.YUV.Y.XOffset;
-    pSurface->YPlaneOffset.iYOffset =
-        (pSurface->YPlaneOffset.iSurfaceOffset - pSurface->dwOffset) / pSurface->dwPitch +
-        details.RenderOffset.YUV.Y.YOffset;
-    pSurface->UPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.U.BaseOffset;
-    pSurface->UPlaneOffset.iXOffset = details.RenderOffset.YUV.U.XOffset;
-    pSurface->UPlaneOffset.iYOffset =
-        (pSurface->UPlaneOffset.iSurfaceOffset - pSurface->dwOffset) / pSurface->dwPitch +
-        details.RenderOffset.YUV.U.YOffset;
-    pSurface->UPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.U;
-    pSurface->VPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.V.BaseOffset;
-    pSurface->VPlaneOffset.iXOffset = details.RenderOffset.YUV.V.XOffset;
-    pSurface->VPlaneOffset.iYOffset =
-        (pSurface->VPlaneOffset.iSurfaceOffset - pSurface->dwOffset) / pSurface->dwPitch +
-        details.RenderOffset.YUV.V.YOffset;
-    pSurface->VPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.V;
-
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::CopySurfaceData_Vdbox(
-    uint32_t      dwDataSize,
-    PMOS_RESOURCE presSourceSurface,
-    PMOS_RESOURCE presCopiedSurface)
-{
-    MOS_COMMAND_BUFFER                      CmdBuffer;
-    MHW_MI_FLUSH_DW_PARAMS                  FlushDwParams;
-    MHW_GENERIC_PROLOG_PARAMS               genericPrologParams;
-    MHW_CP_COPY_PARAMS                      cpCopyParams;
-    MOS_NULL_RENDERING_FLAGS                NullRenderingFlags;
-    MOS_GPU_CONTEXT                         orgGpuContext;
-
-    if (!m_vdboxContextCreated)
-    {
-        MOS_GPUCTX_CREATOPTIONS createOption;
-
-        CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnCreateGpuContext(
-            m_osInterface,
-            MOS_GPU_CONTEXT_VIDEO,
-            MOS_GPU_NODE_VIDEO,
-            &createOption));
-
-        // Register VDbox GPU context with the Batch Buffer completion event
-        CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterBBCompleteNotifyEvent(
-            m_osInterface,
-            MOS_GPU_CONTEXT_VIDEO));
-
-        m_vdboxContextCreated = true;
-    }
-
-    CODECHAL_DEBUG_CHK_NULL(m_cpInterface);
-    CODECHAL_DEBUG_CHK_NULL(m_osInterface);
-    CODECHAL_DEBUG_CHK_NULL(m_miInterface);
-    CODECHAL_DEBUG_CHK_NULL(m_osInterface->pfnGetWaTable(m_osInterface));
-
-    orgGpuContext   = m_osInterface->CurrentGpuContextOrdinal;
-
-    // Due to VDBOX cryto copy limitation, the size must be Cache line aligned
-    if (!MOS_IS_ALIGNED(dwDataSize, MHW_CACHELINE_SIZE))
-    {
-        CODECHAL_DEBUG_ASSERTMESSAGE("Size is not CACHE line aligned, cannot use VDBOX to copy.");
-        return MOS_STATUS_INVALID_PARAMETER;
-    }
-
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnSetGpuContext(m_osInterface, MOS_GPU_CONTEXT_VIDEO));
-    m_osInterface->pfnResetOsStates(m_osInterface);
-
-    // Register the target resource
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterResource(
-        m_osInterface,
-        presCopiedSurface,
-        true,
-        true));
-
-    // Register the source resource
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterResource(
-        m_osInterface,
-        presSourceSurface,
-        false,
-        true));
-
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnGetCommandBuffer(m_osInterface, &CmdBuffer, 0));
-
-    MOS_ZeroMemory(&genericPrologParams, sizeof(genericPrologParams));
-    genericPrologParams.pOsInterface    = m_osInterface;
-    genericPrologParams.pvMiInterface   = m_miInterface;
-    genericPrologParams.bMmcEnabled     = false;
-    CODECHAL_DEBUG_CHK_STATUS(Mhw_SendGenericPrologCmd(&CmdBuffer, &genericPrologParams));
-
-    MOS_ZeroMemory(&cpCopyParams, sizeof(cpCopyParams));
-    cpCopyParams.size = dwDataSize;
-    cpCopyParams.presSrc = presSourceSurface;
-    cpCopyParams.presDst = presCopiedSurface;
-    cpCopyParams.isEncodeInUse = false;
-
-    CODECHAL_DEBUG_CHK_STATUS(m_cpInterface->SetCpCopy(m_osInterface, &CmdBuffer, &cpCopyParams));
-
-    // MI_FLUSH
-    MOS_ZeroMemory(&FlushDwParams, sizeof(FlushDwParams));
-    CODECHAL_DEBUG_CHK_STATUS(m_miInterface->AddMiFlushDwCmd(
-        &CmdBuffer,
-        &FlushDwParams));
-
-    CODECHAL_DEBUG_CHK_STATUS(m_miInterface->AddMiBatchBufferEnd(
-        &CmdBuffer,
-        nullptr));
-
-    m_osInterface->pfnReturnCommandBuffer(m_osInterface, &CmdBuffer, 0);
-
-    NullRenderingFlags = m_osInterface->pfnGetNullHWRenderFlags(m_osInterface);
-
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnSubmitCommandBuffer(
-        m_osInterface,
-        &CmdBuffer,
-        NullRenderingFlags.CtxVideo || NullRenderingFlags.CodecGlobal || NullRenderingFlags.CtxVideo || NullRenderingFlags.VPGobal));
-
-    CODECHAL_DEBUG_CHK_STATUS(m_osInterface->pfnSetGpuContext(m_osInterface, orgGpuContext));
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpNotSwizzled(
-    std::string  surfName,
-    MOS_SURFACE& surf,
-    uint8_t*     lockedAddr,
-    int32_t      size)
-{
-    const char* funcName = (m_codecFunction == CODECHAL_FUNCTION_DECODE) ? "_DEC" : (m_codecFunction == CODECHAL_FUNCTION_CENC_DECODE ? "_DEC" : "_ENC");
-    int YOffset = surf.dwOffset + surf.YPlaneOffset.iYOffset * surf.dwPitch;
-
-#ifdef LINUX
-    int UOffset = surf.UPlaneOffset.iSurfaceOffset;
-    int VOffset = surf.VPlaneOffset.iSurfaceOffset;
-#else
-    int UOffset = surf.UPlaneOffset.iLockSurfaceOffset;
-    int VOffset = surf.VPlaneOffset.iLockSurfaceOffset;
-#endif
-
-    std::string bufName = std::string(surfName) + "NotSwizzled_format[" + std::to_string((int)surf.Format) + "]_w[" + std::to_string(surf.dwWidth)
-        + "]_h[" + std::to_string(surf.dwHeight) + "]_p[" + std::to_string(surf.dwPitch) + "]_srcTiling[" + std::to_string((int)surf.TileType) 
-        + "]_sizeMain[" + std::to_string(size) + "]_YOffset[" + std::to_string(YOffset) 
-        + "]_UOffset[" + std::to_string(UOffset) + "]_VOffset[" + std::to_string(VOffset) + "]";
-
-    const char* filePath = CreateFileName(funcName, bufName.c_str(), CodechalDbgExtType::yuv);
-    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
-    if (ofs.fail())
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    uint8_t* data = lockedAddr;
-    ofs.write((char*)data, size);
-    ofs.close();
-
-    m_osInterface->pfnUnlockResource(m_osInterface, &surf.OsResource);    
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpBufferInBinary(uint8_t *data, uint32_t size)
-{
-    CODECHAL_DEBUG_CHK_NULL(data);
-
-    const char *filePath = m_outputFileName.c_str();
-
-    if (size == 0)
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
-    if (ofs.fail())
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    ofs.write((char*)data, size);
-    ofs.close();
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::Dump2DBufferInBinary(
-    uint8_t *   data,
-    uint32_t    width,
-    uint32_t    height,
-    uint32_t    pitch)
-{
-    CODECHAL_DEBUG_CHK_NULL(data);
-
-    const char *filePath = m_outputFileName.c_str();
-
-    if (width == 0 || height == 0 || pitch == 0)
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
-    if (ofs.fail())
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
-    for (uint32_t h = 0; h < height; h++)
-    {
-        ofs.write((char*)data, width);
-        data += pitch;
-    }
-
-    ofs.close();
-    return MOS_STATUS_SUCCESS;
-}
-
-MOS_STATUS CodechalDebugInterface::DumpBufferInHexDwords(uint8_t *data, uint32_t size)
-{
-    CODECHAL_DEBUG_CHK_NULL(data);
-
-    const char *filePath = m_outputFileName.c_str();
-
-    if (size == 0)
-    {
-        return MOS_STATUS_UNKNOWN;
-    }
-
+    const char *  filePath = CreateFileName(bufferName, attrName, MediaDbgExtType::txt);
     std::ofstream ofs(filePath);
 
     if (ofs.fail())
@@ -1472,29 +248,54 @@
         return MOS_STATUS_UNKNOWN;
     }
 
-    uint32_t dwordSize  = size / sizeof(uint32_t);
-    uint32_t remainSize = size % sizeof(uint32_t);
+    FIELD_TO_OFS(CODECHAL_STATUS, CodecStatus);
+    FIELD_TO_OFS(uint32_t, StatusReportNumber);
+    FIELD_TO_OFS(uint32_t, CurrOriginalPic.FrameIdx);
+    FIELD_TO_OFS(CODEC_PICTURE_FLAG, CurrOriginalPic.PicFlags);
+    FIELD_TO_OFS(uint32_t, CurrOriginalPic.PicEntry);
+    FIELD_TO_OFS(uint32_t, Func);
+    POINTER_TO_OFS(PCODEC_REF_LIST, pCurrRefList);
+    ofs << std::endl;
 
-    uint32_t *dwordData = (uint32_t *)data;
-    uint32_t  i;
-    for (i = 0; i < dwordSize; i++)
-    {
-        ofs << std::hex << std::setw(8) << std::setfill('0') << +dwordData[i] << " ";
-        if (i % 4 == 3)
-        {
-            ofs << std::endl;
-        }
-    }
+    FIELD_TO_OFS(bool, bSequential);
+    FIELD_TO_OFS(uint32_t, bitstreamSize);
+    FIELD_TO_OFS(int8_t, QpY);
+    FIELD_TO_OFS(int8_t, SuggestedQpYDelta);
+    FIELD_TO_OFS(uint8_t, NumberPasses);
+    FIELD_TO_OFS(uint8_t, AverageQp);
+    FIELD_TO_OFS(uint64_t, HWCounterValue.IV);
+    FIELD_TO_OFS(uint64_t, HWCounterValue.Count);
+    POINTER_TO_OFS(uint64_t *, hwctr);
+    FIELD_TO_OFS(uint32_t, QueryStatusFlags);
+    ofs << std::endl;
 
-    if (remainSize > 0)
-    {
-        uint32_t lastWord = dwordData[i] & (0xFFFFFFFF << ((8 - remainSize * 2) * 4));
-        ofs << std::hex << std::setw(8) << std::setfill('0') << +lastWord << std::endl;
-    }
+    FIELD_TO_OFS(uint32_t, MAD);
+    FIELD_TO_OFS(uint32_t, loopFilterLevel);
+    FIELD_TO_OFS(int8_t, LongTermIndication);
+    FIELD_TO_OFS(uint16_t, NextFrameWidthMinus1);
+    FIELD_TO_OFS(uint16_t, NextFrameHeightMinus1);
+    FIELD_TO_OFS(uint8_t, NumberSlices);
 
+    FIELD_TO_OFS(uint16_t, PSNRx100[0]);
+    FIELD_TO_OFS(uint16_t, PSNRx100[1]);
+    FIELD_TO_OFS(uint16_t, PSNRx100[2]);
+
+    FIELD_TO_OFS(uint32_t, NumberTilesInFrame);
+    FIELD_TO_OFS(uint8_t, UsedVdBoxNumber);
+    FIELD_TO_OFS(uint32_t, SizeOfSliceSizesBuffer);
+    POINTER_TO_OFS(uint16_t *, pSliceSizes);
+    FIELD_TO_OFS(uint32_t, SizeOfTileInfoBuffer);
+    POINTER_TO_OFS(void *, pHEVCTileinfo);
+    FIELD_TO_OFS(uint32_t, NumTileReported);
+    ofs << std::endl;
+
+    FIELD_TO_OFS(uint32_t, StreamId);
+    POINTER_TO_OFS(void *, pLookaheadStatus);
     ofs.close();
 
     return MOS_STATUS_SUCCESS;
 }
+#undef FIELD_TO_OFS
+#undef POINTER_TO_OFS
 
-#endif  // USE_CODECHAL_DEBUG_TOOL
+#endif // USE_CODECHAL_DEBUG_TOOL
diff --git a/media_driver/agnostic/common/codec/hal/codechal_debug.h b/media_driver/agnostic/common/codec/hal/codechal_debug.h
index b4d046d..5440ecb 100644
--- a/media_driver/agnostic/common/codec/hal/codechal_debug.h
+++ b/media_driver/agnostic/common/codec/hal/codechal_debug.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011-2018, Intel Corporation
+* Copyright (c) 2011-2020, Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -21,25 +21,26 @@
 */
 //!
 //! \file     codechal_debug.h
-//! \brief    Defines the debug interface shared by all of CodecHal.
-//! \details  The debug interface dumps output from CodecHal based on in input config file.
+//! \brief    Defines the debug interface shared by codec only.
+//! \details  The debug interface dumps output from Media based on in input config file.
 //!
-#ifndef __CODECHAL_DEBUG_H__
-#define __CODECHAL_DEBUG_H__
-#if (_DEBUG || _RELEASE_INTERNAL)
+#ifndef __CODEC_DEBUG_H__
+#define __CODEC_DEBUG_H__
+
+#include "media_debug_interface.h"
+#if USE_MEDIA_DEBUG_TOOL
 
 #define USE_CODECHAL_DEBUG_TOOL 1
-#define CODECHAL_DEBUG_TOOL(expr)   expr;
+#define CODECHAL_DEBUG_TOOL(expr) expr;
 
-#include "BRCIF.h"
-#include "mhw_utilities.h"
-#include "mhw_state_heap.h"
-#include "codec_def_common.h"
-#include "codechal_debug_config_manager.h"
-#include <sstream>
-#include <fstream>
+typedef struct _CODECHAL_DBG_CFG CODECHAL_DBG_CFG, *PCODECHAL_DBG_CFG;
 
-#define CODECHAL_DEBUG_TOOL(expr)   expr;
+namespace CodechalDbgFieldType   = MediaDbgFieldType;
+namespace CodechalDbgExtType     = MediaDbgExtType;
+namespace CodechalDbgSurfaceType = MediaDbgSurfaceType;
+namespace CodechalDbgBufferType  = MediaDbgBufferType;
+namespace CodechalDbgAttr        = MediaDbgAttr;
+namespace CodechalDbgKernel      = MediaDbgKernel;
 
 //------------------------------------------------------------------------------
 // Macros specific to MOS_CODEC_SUBCOMP_DEBUG sub-comp
@@ -71,75 +72,6 @@
 #define CODECHAL_DEBUG_CHK_NULL_NO_STATUS(_ptr) \
     MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _ptr)
 
-namespace CodechalDbgFieldType
-{
-static const char *topField = "_Top";
-static const char *botField = "_Bot";
-static const char *frame    = "_Frame";
-};
-
-namespace CodechalDbgExtType
-{
-static const char *dat  = ".dat";
-static const char *txt  = ".txt";
-static const char *par  = ".par";
-static const char *y    = ".Y";
-static const char *uv   = ".UV";
-static const char *yuv  = ".yuv";
-static const char *yuy2 = ".yuy2";
-static const char *uyvy = ".uyvy";
-};
-
-namespace CodechalDbgSurfaceType
-{
-static const char *yuv444    = "_yuv444";
-static const char *yuv411    = "_yuv411";
-static const char *yuv420    = "_yuv420";
-static const char *yuv400    = "_yuv400";
-static const char *yuv422h2y = "_yuv422h_2y";
-static const char *yuv422v2y = "_yuv422v_2y";
-static const char *yuv422h4y = "_yuv422h_4y";
-static const char *yuv422v4y = "_yuv422v_4y";
-static const char *yuy2422   = "_yuy2422";
-static const char *uyvy422   = "_uyvy422";
-};
-
-namespace CodechalDbgBufferType
-{
-static const char *bufCmd           = "CmdBuf";
-static const char *buf2ndLvl        = "2ndLvl";
-static const char *bufCurbe         = "Curbe";
-static const char *bufISH           = "ISH";
-static const char *bufDSH           = "DSH";
-static const char *bufSSH           = "SSH";
-static const char *bufSeqParams     = "SeqParams";
-static const char *bufPicParams     = "PicParams";
-static const char *bufSlcParams     = "SlcParams";
-static const char *bufSubsetsParams = "SubsetsParams";
-static const char *bufVuiParams     = "VuiParams";
-static const char *bufBitstream     = "Bitstream";
-static const char *bufFeiPicParams  = "FeiPicParams";
-static const char *bufMadRead       = "MADRead";
-static const char *bufMadWrite      = "MADWrite";
-static const char *bufSegmentParams = "SegmentParams";
-static const char *bufIqParams      = "IqParams";
-static const char *bufHuffmanTbl    = "HuffmanTbl";
-static const char *bufScanParams    = "ScanParams";
-static const char *bufMvcPicParams  = "MvcPicParams";
-static const char *bufMbParams      = "MbParams";
-static const char *bufDecProcParams = "DecProcParams";
-static const char *bufHucRegion     = "HucRegion";
-static const char *bufHucDmem       = "HucDmem";
-static const char *bufEncodePar     = "EncodePar";
-};
-
-namespace CodechalDbgAttr
-{
-static const char *attrInitSWScoreboard = "InitSWScoreboard";
-static const char *attrSfcHistogram = "SfcHistogram";
-static const char* attrFilmGrain = "FilmGrain";
-};
-
 enum CodechalHucRegionDumpType
 {
     hucRegionDumpDefault        = 0,
@@ -153,93 +85,27 @@
     hucRegionDumpHpuSuperFrame  = 8
 };
 
-struct _CODECHAL_DEBUG_INTERFACE;
-typedef struct _CODECHAL_DBG_CFG    CODECHAL_DBG_CFG, *PCODECHAL_DBG_CFG;
-
 typedef struct _CODECHAL_ME_OUTPUT_PARAMS
 {
-    PMOS_SURFACE                    psMeMvBuffer;
-    PMOS_SURFACE                    psMeBrcDistortionBuffer;
-    PMOS_SURFACE                    psMeDistortionBuffer;
-    PMOS_RESOURCE                   pResVdenStreamInBuffer;
-    bool                            b16xMeInUse;
-    bool                            b32xMeInUse;
-    bool                            bVdencStreamInInUse;
+    PMOS_SURFACE  psMeMvBuffer;
+    PMOS_SURFACE  psMeBrcDistortionBuffer;
+    PMOS_SURFACE  psMeDistortionBuffer;
+    PMOS_RESOURCE pResVdenStreamInBuffer;
+    bool          b16xMeInUse;
+    bool          b32xMeInUse;
+    bool          bVdencStreamInInUse;
 } CODECHAL_ME_OUTPUT_PARAMS, *PCODECHAL_ME_OUTPUT_PARAMS;
 
-class CodechalDebugInterface
+class MediaDebugInterface;
+class CodechalDebugInterface : public MediaDebugInterface
 {
 public:
     CodechalDebugInterface();
     virtual ~CodechalDebugInterface();
 
-    MOS_STATUS Initialize(
+    virtual MOS_STATUS Initialize(
         CodechalHwInterface *hwInterface,
-        CODECHAL_FUNCTION      codecFunction);
-
-    bool DumpIsEnabled(
-        const char *              attr,
-        CODECHAL_MEDIA_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES);
-
-    const char *CreateFileName(
-        const char *funcName,
-        const char *bufType,
-        const char *extType);
-
-    MOS_STATUS DumpCmdBuffer(
-        PMOS_COMMAND_BUFFER       cmdBuffer,
-        CODECHAL_MEDIA_STATE_TYPE mediaState,
-        const char *              cmdName = nullptr);
-
-    MOS_STATUS Dump2ndLvlBatch(
-        PMHW_BATCH_BUFFER         batchBuffer,
-        CODECHAL_MEDIA_STATE_TYPE mediaState,
-        const char *              batchName = nullptr);
-
-    MOS_STATUS DumpCurbe(
-        CODECHAL_MEDIA_STATE_TYPE mediaState,
-        PMHW_KERNEL_STATE         kernelState);
-
-    MOS_STATUS DumpMDFCurbe(
-        CODECHAL_MEDIA_STATE_TYPE mediaState,
-        uint8_t *                 curbeBuffer,
-        uint32_t                  curbeSize);
-
-    MOS_STATUS DumpKernelRegion(
-        CODECHAL_MEDIA_STATE_TYPE mediaState,
-        MHW_STATE_HEAP_TYPE       stateHeapType,
-        PMHW_KERNEL_STATE         kernelState);
-
-    virtual MOS_STATUS DumpYUVSurface(
-        PMOS_SURFACE              surface,
-        const char *              attrName,
-        const char *              surfName,
-        CODECHAL_MEDIA_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES,
-        uint32_t                  width_in = 0,
-        uint32_t                  height_in = 0);
-
-    MOS_STATUS DumpBuffer(
-        PMOS_RESOURCE             resource,
-        const char *              attrName,
-        const char *              bufferName,
-        uint32_t                  size,
-        uint32_t                  offset     = 0,
-        CODECHAL_MEDIA_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES);
-
-    MOS_STATUS DumpEncodeStatusReport(
-        uint8_t *                 report);
-
-    MOS_STATUS DumpSurface(
-        PMOS_SURFACE              surface,
-        const char *              attrName,
-        const char *              surfaceName,
-        CODECHAL_MEDIA_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES);
-
-    MOS_STATUS DumpData(
-        void *      data,
-        uint32_t    size,
-        const char *attrName,
-        const char *bufferName);
+        CODECHAL_FUNCTION    codecFunction);
 
     MOS_STATUS DumpHucDmem(
         PMOS_RESOURCE             dmemResource,
@@ -257,80 +123,20 @@
         uint32_t                  hucPassNum,
         CodechalHucRegionDumpType dumpType);
 
-    virtual MOS_STATUS DumpBltOutput(
-        PMOS_SURFACE              surface,
-        const char *              attrName);
+    MOS_STATUS DumpEncodeStatusReport(
+        uint8_t *report);
 
-    MOS_STATUS DeleteCfgLinkNode(uint32_t frameIdx);
-
-    std::string             m_ddiFileName;
-    std::string             m_outputFileName;
-
-    MOS_SURFACE          m_temp2DSurfForCopy      = {};
-    CodechalHwInterface *m_hwInterface            = nullptr;
-    PMOS_INTERFACE       m_osInterface            = nullptr;
-    MhwCpInterface      *m_cpInterface            = nullptr;
-    MhwMiInterface      *m_miInterface            = nullptr;
-    CODECHAL_FUNCTION    m_codecFunction          = CODECHAL_FUNCTION_INVALID;
-    bool                 m_enableBinaryDebugDumps = false;
-    bool                 m_enableEncodeDdiDump    = false;
-    PCODECHAL_DBG_CFG    m_dbgCfgHead             = nullptr;
-    CODEC_PICTURE        m_currPic;
-    uint32_t             m_scaledBottomFieldOffset = 0;
-    uint16_t             m_frameType               = 0;
-    uint32_t             m_sliceId                 = 0;  // used for constructing debug file name
-    char                 m_fileName[MOS_MAX_PATH_LENGTH + 1];
-    char                 m_path[MOS_MAX_PATH_LENGTH + 1];
-    bool                 m_secondField              = false;
-    bool                 m_hybridPakP1              = false;
-    bool                 m_hybridVp8EncodeBrcEnable = false;
-    bool                 m_hybridVp9EncodeEnable    = false;
-    bool                 m_vdboxContextCreated      = false;
-    uint16_t             m_preIndex                 = 0;
-    uint16_t             m_refIndex                 = 0;
-    uint32_t             m_bufferDumpFrameNum       = 0;
-    uint32_t             m_decodeSurfDumpFrameNum   = 0;
-
-    uint32_t             m_streamId = 0;
-
-    MOS_STATUS DumpBufferInHexDwords(
-        uint8_t *   data,
-        uint32_t    size);
+    CodechalHwInterface *m_hwInterface   = nullptr;
+    CODECHAL_FUNCTION    m_codecFunction = CODECHAL_FUNCTION_INVALID;
+    PCODECHAL_DBG_CFG    m_dbgCfgHead    = nullptr;
 
 protected:
-    MOS_STATUS ReAllocateSurface(
-        PMOS_SURFACE    pSurface,
-        PMOS_SURFACE    pSrcSurf,
-        PCCHAR          pSurfaceName,
-        MOS_GFXRES_TYPE DefaultResType);
-
-    MOS_STATUS CopySurfaceData_Vdbox(
-        uint32_t        dwDataSize,
-        PMOS_RESOURCE   presSourceSurface,
-        PMOS_RESOURCE   presCopiedSurface);
-
-    MOS_STATUS DumpNotSwizzled(
-        std::string  surfName,
-        MOS_SURFACE& surf,
-        uint8_t*     lockedAddr,
-        int32_t      size);
-
-    MOS_STATUS DumpBufferInBinary(
-        uint8_t *    data,
-        uint32_t     size);
-
-    MOS_STATUS Dump2DBufferInBinary(
-        uint8_t *    data,
-        uint32_t     width,
-        uint32_t     height,
-        uint32_t     pitch);
-
-    CodechalDebugConfigMgr *m_configMgr = nullptr;
-    std::string             m_outputFilePath;
+    MOS_USER_FEATURE_VALUE_ID SetOutputPathKey() override;
+    MOS_USER_FEATURE_VALUE_ID InitDefaultOutput() override;
 };
 #else
-#define USE_CODECHAL_DEBUG_TOOL     0
-#define CODECHAL_DEBUG_TOOL(expr)   ;
-#endif  // (_DEBUG || _RELEASE_INTERNAL)
+#define USE_CODECHAL_DEBUG_TOOL 0
+#define CODECHAL_DEBUG_TOOL(expr) ;
 
-#endif  /* __CODECHAL_DEBUG_H__ */
+#endif  // USE_MEDIA_DEBUG_TOOL
+#endif  /* __MEDIA_DEBUG_H__ */
diff --git a/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.cpp b/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.cpp
index 9ae600e..8c20aa5 100644
--- a/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.cpp
+++ b/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2019, Intel Corporation
+* Copyright (c) 2017-2020, Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -25,531 +25,61 @@
 //! \brief    Defines the dump configuration manager.
 //! \details  The debug interface dumps configuration manager file which parse attributes.
 //!
-#include "codechal_debug.h"
-#if USE_CODECHAL_DEBUG_TOOL
 #include "codechal_debug_config_manager.h"
-#include <fstream>
-#include <sstream>
+#if USE_CODECHAL_DEBUG_TOOL
 
-CodechalDebugConfigMgr::CodechalDebugConfigMgr(
+CodecDebugConfigMgr::CodecDebugConfigMgr(
     CodechalDebugInterface *debugInterface,
     CODECHAL_FUNCTION       codecFunction,
     std::string             outputFolderPath)
-    : m_debugInterface(debugInterface),
-    m_codecFunction(codecFunction),
-    m_outputFolderPath(outputFolderPath)
+    : MediaDebugConfigMgr(outputFolderPath),
+      m_debugInterface(debugInterface),
+      m_codecFunction(codecFunction)
 {
+    GetFunctionType();
 }
 
-CodechalDebugConfigMgr::~CodechalDebugConfigMgr()
+void CodecDebugConfigMgr::GetFunctionType()
 {
-    if (m_debugAllConfigs)
+    switch (m_codecFunction)
     {
-        MOS_Delete(m_debugAllConfigs);
+    case CODECHAL_FUNCTION_CENC_DECODE:
+        m_mediaFunction = MEDIA_FUNCTION_CENC_DECODE;
+        break;
+    case CODECHAL_FUNCTION_DECODE:
+        m_mediaFunction = MEDIA_FUNCTION_DECODE;
+        break;
+    case CODECHAL_FUNCTION_ENC:
+    case CODECHAL_FUNCTION_PAK:
+    case CODECHAL_FUNCTION_ENC_PAK:
+    case CODECHAL_FUNCTION_HYBRIDPAK:
+    case CODECHAL_FUNCTION_ENC_VDENC_PAK:
+    case CODECHAL_FUNCTION_DEMO_COPY:
+    case CODECHAL_FUNCTION_FEI_PRE_ENC:
+    case CODECHAL_FUNCTION_FEI_ENC:
+    case CODECHAL_FUNCTION_FEI_PAK:
+    case CODECHAL_FUNCTION_FEI_ENC_PAK:
+        m_mediaFunction = MEDIA_FUNCTION_ENCODE;
+        break;
+    default:
+        m_mediaFunction = MEDIA_FUNCTION_DEFAULT;
+        break;
     }
 }
 
-MOS_STATUS CodechalDebugConfigMgr::ParseConfig(MOS_CONTEXT_HANDLE mosCtx)
+std::string CodecDebugConfigMgr::InitFileName(MediaDbgFunction mediaFunction)
 {
-    std::string   configFilePath = m_outputFolderPath + "CodecDbgSetting.cfg";
-    std::ifstream configStream(configFilePath);
-
-    if (!configStream.good())
-    {
-        CODECHAL_DEBUG_VERBOSEMESSAGE("CodecDbgSetting.cfg is not valid, we generate a template for your reference");
-        MOS_USER_FEATURE_VALUE_DATA userFeatureData;
-        MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
-        MOS_UserFeature_ReadValue_ID(
-            nullptr,
-            __MEDIA_USER_FEATURE_VALUE_CODECHAL_DEBUG_CFG_GENERATION_ID,
-            &userFeatureData,
-            mosCtx);
-        if (userFeatureData.i32Data)
-        {
-            GenerateDefaultConfig();
-        }
-        return MOS_STATUS_SUCCESS;
-    }
-
-    std::string line;
-
-    bool    parseEnable = false;
-    int32_t minFrameNum = -1;
-    int32_t maxFrameNum = -1;
-
-    while (std::getline(configStream, line))
-    {
-        if (line.empty())
-        {
-            continue;
-        }
-        auto        pos = line.find_first_not_of("\t ");
-        std::string newline = line.substr(pos);
-        if (newline[0] == '\n' || newline[0] == '#')
-        {
-            continue;
-        }
-        else if (newline[0] == '@')  // parse keyword
-        {
-            if (!strncmp(newline.substr(1, 4).c_str(), "mode", 4))
-            {
-                auto pos1 = newline.find_first_not_of("\t ", 5);
-                if (pos1 == std::string::npos)
-                {
-                    continue;
-                }
-                if ((!strncmp(newline.substr(pos1, 3).c_str(), "ALL", 3)) ||
-                    (!strncmp(newline.substr(pos1, 6).c_str(), "encode", 6) &&
-                        m_codecFunction != CODECHAL_FUNCTION_DECODE) ||
-                    (!strncmp(newline.substr(pos1, 6).c_str(), "decode", 6) &&
-                    (m_codecFunction == CODECHAL_FUNCTION_DECODE || m_codecFunction == CODECHAL_FUNCTION_CENC_DECODE)))
-                {
-                    parseEnable = true;
-                }
-                else
-                {
-                    parseEnable = false;
-                }
-                continue;
-            }
-
-            if (!parseEnable)
-            {
-                continue;
-            }
-
-            if (!strncmp(newline.substr(1, 5).c_str(), "Frame", 5))
-            {
-                // start with new frame config
-                auto pos1 = newline.find_first_not_of("\t ", 6);
-                if (pos1 == std::string::npos)
-                    continue;
-
-                minFrameNum = maxFrameNum = -1;
-                if (!strncmp(newline.substr(pos1, 3).c_str(), "ALL", 3))
-                {
-                    // coonfig applid to all frames
-                    if (nullptr == m_debugAllConfigs)
-                    {
-                        m_debugAllConfigs = MOS_New(CodechalDbgCfg);
-                    }
-                }
-                else
-                {
-                    auto pos2 = newline.find_first_of("-", 6);
-                    if (pos2 != std::string::npos)  // handle frame range
-                    {
-                        minFrameNum = std::stoi(newline.substr(pos1, pos2 - pos1));
-                        maxFrameNum = std::stoi(newline.substr(pos2 + 1));
-                    }
-                    else
-                    {
-                        minFrameNum = maxFrameNum = std::stoi(newline.substr(pos1));
-                    }
-                }
-            }
-            else if (!strncmp(newline.substr(1, 5).c_str(), "Force", 5))
-            {
-
-            }
-            else if (!strncmp(newline.substr(1, 14).c_str(), "OverwriteCurbe", 14))
-            {
-
-            }
-            else
-            {
-                if (minFrameNum < 0)
-                {
-                    ParseKernelAttribs(newline, nullptr);
-                }
-                else
-                {
-                    for (int32_t i = minFrameNum; i <= maxFrameNum; i++)
-                    {
-                        ParseKernelAttribs(newline, &m_debugFrameConfigs.at(GetFrameConfig(i)));
-                    }
-                }
-            }
-        }
-        else if (parseEnable)
-        {
-            if (minFrameNum < 0)
-            {
-                StoreDebugAttribs(newline, nullptr);
-            }
-            else
-            {
-                for (int32_t i = minFrameNum; i <= maxFrameNum; i++)
-                {
-                    StoreDebugAttribs(newline, &m_debugFrameConfigs.at(GetFrameConfig(i)));
-                }
-            }
-        }
-    }
-
-    return MOS_STATUS_SUCCESS;
+    return "CodecDbgSetting.cfg";
 }
 
-void CodechalDebugConfigMgr::GenerateDefaultConfig()
+CodecDebugConfigMgr::~CodecDebugConfigMgr()
 {
-    std::string   configFilePath = m_outputFolderPath + "CodecDbgSetting.cfg";
-    std::ofstream ofs(configFilePath);
-    ofs << "###################################################################" << std::endl;
-    ofs << "## CodecDbgSettings.cfg" << std::endl;
-    ofs << "## - White space should be agnostic." << std::endl;
-    ofs << "## - '#' as first non-white space char denotes line as comment" << std::endl;
-    ofs << "## - '@frame ALL' MUST be present as the first directive, even if " << std::endl;
-    ofs << "##   nothing is dumped for every frame." << std::endl;
-    ofs << "###################################################################" << std::endl;
-    ofs << std::endl;
-
-    ofs << "###################################################################" << std::endl;
-    ofs << "## key words defined under @mode ALL works for both encode & decode" << std::endl;
-    ofs << "###################################################################" << std::endl;
-    ofs << std::endl;
-    ofs << "@mode ALL" << std::endl;
-    ofs << "@Frame ALL" << std::endl;
-    ofs << std::endl;
-
-    ofs << "#" << CodechalDbgAttr::attrPicParams <<":0"<< std::endl;
-    ofs << "#" << CodechalDbgAttr::attrSlcParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrSubsetsParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrIqParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrBitstream << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrHucRegions << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrHuCDmem << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrCmdBufferMfx << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attr2ndLvlBatchMfx << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrHuffmanTbl << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrScanParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDriverUltDump << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDumpBufferInBinary << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDumpToThreadFolder << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDumpCmdBufInBinary << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrStatusReport << ":0" << std::endl;
-    ofs << std::endl;
-
-    ofs << "##" << CodechalDbgAttr::attrStreamOut << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrStreamIn << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrResidualDifference << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrDeblocking << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrMvData << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrForceYUVDumpWithMemcpy << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrDisableSwizzleForDumps << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrSfcOutputSurface << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrSfcBuffers << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrReferenceSurfaces << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrEncodeRawInputSurface << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrReconstructedSurface << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrPakInput << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrPakOutput << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrUpsamlingInput << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrResidualSurface << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrStCoeff << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrCoeffPredCs << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrMbRecord << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrPakObjStreamout << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrTileBasedStats << ":0" << std::endl;    
-    ofs << "##" << CodechalDbgAttr::attrOverwriteCommands << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrForceCmdDumpLvl << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrForceCurbeDumpLvl << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrFrameState << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrBrcPakStats<< ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrCUStreamout<< ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrImageState << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrSliceSizeStreamout << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrCoeffProb << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrROISurface << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrHuCStitchDataBuf << ":0" << std::endl;
-    
-   // MD5 attributes
-    ofs << "##" << CodechalDbgAttr::attrMD5HashEnable << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrMD5FlushInterval << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrMD5PicWidth << ":0" << std::endl;
-    ofs << "##" << CodechalDbgAttr::attrMD5PicHeight << ":0" << std::endl;
-    ofs << std::endl;
-
-    ofs << "###################################################################" << std::endl;
-    ofs << "## key words defined under @mode decode works for decode only" << std::endl;
-    ofs << "###################################################################" << std::endl;
-    ofs << std::endl;
-    ofs << "#@mode decode" << std::endl;
-    ofs << "#@Frame ALL" << std::endl;
-    ofs << std::endl;
-
-    ofs << "#" << CodechalDbgAttr::attrSegmentParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrMbParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrVc1Bitplane << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrCoefProb << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrSegId << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDecodeOutputSurface << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDecodeAuxSurface << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDecodeBltOutput << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDecodeProcParams << ":0" << std::endl;
-    ofs << std::endl;
-
-    ofs << "###############################################################" << std::endl;
-    ofs << "## key words defined under @mode encode works for encode only" << std::endl;
-    ofs << "###############################################################" << std::endl;
-    ofs << std::endl;
-    ofs << "#@mode encode" << std::endl;
-    ofs << "#@Frame ALL" << std::endl;
-    ofs << std::endl;
-
-    ofs << "#" << CodechalDbgAttr::attrFeiPicParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrSeqParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrVuiParams << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrDumpEncodePar << ":0" << std::endl;
-    ofs << "#" << CodechalDbgAttr::attrVdencOutput << ":0" << std::endl;
-    ofs << std::endl;
-
-    ofs << "###############################################################" << std::endl;
-    ofs << "## key words defined for kernel" << std::endl;
-    ofs << "###############################################################" << std::endl;
-    // generate kernel related config
-    CodechalDbgKernel::KernelStateMap::kernelMapType &kernelMap = CodechalDbgKernel::KernelStateMap::GetKernelStateMap();
-    for (auto &it : kernelMap)
-    {
-        ofs << "#@" << it.second << " ALL" << std::endl;
-    }
-    ofs << std::endl;
-
-    ofs << "### Encode plug-in ###" << std::endl;
-    ofs << "#@force" << std::endl;
-    ofs << "#ForceCmpDumpLvl:3" << std::endl;
-    ofs << "#@OverwriteCurbe" << std::endl;
-    ofs << "#ForceCurbeDumpLvl:3" << std::endl;
-
-    ofs.close();
 }
 
-uint32_t CodechalDebugConfigMgr::GetFrameConfig(uint32_t frameIdx)
+uint32_t CodecDebugConfigMgr::GetDumpFrameNum()
 {
-    uint32_t pos;
-    for (pos = 0; pos < m_debugFrameConfigs.size(); pos++)
-    {
-        if (m_debugFrameConfigs[pos].frameIndex == frameIdx)
-        {
-            return pos;
-        }
-    }
-    CodechalDbgCfg frameConfig;
-    frameConfig.frameIndex = frameIdx;
-    m_debugFrameConfigs.push_back(frameConfig);
-    return pos;
-}
-
-void CodechalDebugConfigMgr::StoreDebugAttribs(std::string line, CodechalDbgCfg *dbgCfg)
-{
-    CodechalDbgCfg *config = dbgCfg != nullptr ? dbgCfg : m_debugAllConfigs;
-    if (config == nullptr)
-    {
-        return;
-    }
-
-    auto delimeterPos = line.find(':');
-    if (delimeterPos == std::string::npos)
-    {
-        return;
-    }
-
-    auto        attrEndPos = line.substr(0, delimeterPos).find_last_not_of("\t ");
-    std::string attrName   = line.substr(0, attrEndPos + 1);
-    int32_t     attrValue  = std::stoi(line.substr(delimeterPos + 1));
-
-    auto it = config->cmdAttribs.find(attrName);
-    if (it != config->cmdAttribs.end())
-    {
-        config->cmdAttribs.erase(it);
-    }
-
-    config->cmdAttribs[attrName] = attrValue;
-}
-
-void CodechalDebugConfigMgr::ParseKernelAttribs(std::string line, CodechalDbgCfg *dbgCfg)
-{
-    CodechalDbgCfg *config = dbgCfg != nullptr ? dbgCfg : m_debugAllConfigs;
-    if (config == nullptr)
-    {
-        return;
-    }
-
-    auto        kernelNameEndPos = line.find_first_of("\t ", 1);
-    std::string kernelName       = line.substr(1, kernelNameEndPos - 1);
-
-    std::istringstream iss(line.substr(kernelNameEndPos));
-    do
-    {
-        std::string attrName;
-        iss >> attrName;
-        if (attrName.empty())
-        {
-            continue;
-        }
-
-        if (!strncmp(attrName.c_str(), "ALL", 3))
-        {
-            config->kernelAttribs[kernelName].dumpDsh         = true;
-            config->kernelAttribs[kernelName].dumpSsh         = true;
-            config->kernelAttribs[kernelName].dumpIsh         = true;
-            config->kernelAttribs[kernelName].dumpCurbe       = true;
-            config->kernelAttribs[kernelName].dumpCmdBuffer   = true;
-            config->kernelAttribs[kernelName].dump2ndLvlBatch = true;
-            config->kernelAttribs[kernelName].dumpInput       = true;
-            config->kernelAttribs[kernelName].dumpOutput      = true;
-            break;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrDsh, sizeof(CodechalDbgAttr::attrDsh) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpDsh = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrSsh, sizeof(CodechalDbgAttr::attrSsh) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpSsh = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrIsh, sizeof(CodechalDbgAttr::attrIsh) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpIsh = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrCurbe, sizeof(CodechalDbgAttr::attrCurbe) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpCurbe = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrCmdBuffer, sizeof(CodechalDbgAttr::attrCmdBuffer) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpCmdBuffer = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attr2ndLvlBatch, sizeof(CodechalDbgAttr::attr2ndLvlBatch) - 1))
-        {
-            config->kernelAttribs[kernelName].dump2ndLvlBatch = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrInput, sizeof(CodechalDbgAttr::attrInput) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpInput = true;
-        }
-        else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrOutput, sizeof(CodechalDbgAttr::attrOutput) - 1))
-        {
-            config->kernelAttribs[kernelName].dumpOutput = true;
-        }
-
-    } while (iss);
-}
-
-MOS_STATUS CodechalDebugConfigMgr::DeleteCfgNode(uint32_t frameIdx)
-{
-    for (auto it = m_debugFrameConfigs.begin(); it != m_debugFrameConfigs.end(); it++)
-    {
-        if (it->frameIndex == frameIdx)
-        {
-            m_debugFrameConfigs.erase(it);
-            break;
-        }
-    }
-    return MOS_STATUS_SUCCESS;
-}
-
-std::string CodechalDebugConfigMgr::GetMediaStateStr(CODECHAL_MEDIA_STATE_TYPE mediaState)
-{
-    CodechalDbgKernel::KernelStateMap::kernelMapType &kernelMap = CodechalDbgKernel::KernelStateMap::GetKernelStateMap();
-    auto                                              it        = kernelMap.find(mediaState);
-    if (it != kernelMap.end())
-    {
-        return it->second;
-    }
-
-    return "";
-}
-
-bool CodechalDebugConfigMgr::AttrIsEnabled(std::string attrName)
-{
-    if (nullptr != m_debugAllConfigs)
-    {
-        int attrValue = m_debugAllConfigs->cmdAttribs[attrName];
-        if (attrValue > 0)
-        {
-            return true;
-        }
-    }
-
-    for (auto it : m_debugFrameConfigs)
-    {
-        if (it.frameIndex == m_debugInterface->m_bufferDumpFrameNum)
-        {
-            int attrValue = it.cmdAttribs[attrName];
-            return attrValue > 0;
-        }
-    }
-
-    return false;
-}
-
-bool CodechalDebugConfigMgr::AttrIsEnabled(
-    CODECHAL_MEDIA_STATE_TYPE mediaState,
-    std::string               attrName)
-{
-    std::string kernelName = GetMediaStateStr(mediaState);
-    if (kernelName.empty())
-    {
-        return false;
-    }
-
-    if (nullptr != m_debugAllConfigs)
-    {
-        KernelDumpConfig attrs   = m_debugAllConfigs->kernelAttribs[kernelName];
-        bool             enabled = KernelAttrEnabled(attrs, attrName);
-        if (enabled)
-        {
-            return enabled;
-        }
-    }
-
-    for (auto it : m_debugFrameConfigs)
-    {
-        if (it.frameIndex == m_debugInterface->m_bufferDumpFrameNum)
-        {
-            KernelDumpConfig attrs = it.kernelAttribs[kernelName];
-            return KernelAttrEnabled(attrs, attrName);
-        }
-    }
-    return false;
-}
-
-bool CodechalDebugConfigMgr::KernelAttrEnabled(KernelDumpConfig kernelConfig, std::string attrName)
-{
-    if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrDsh, sizeof(CodechalDbgAttr::attrDsh) - 1))
-    {
-        return kernelConfig.dumpDsh;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrSsh, sizeof(CodechalDbgAttr::attrSsh) - 1))
-    {
-        return kernelConfig.dumpSsh;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrIsh, sizeof(CodechalDbgAttr::attrIsh) - 1))
-    {
-        return kernelConfig.dumpIsh;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrCurbe, sizeof(CodechalDbgAttr::attrCurbe) - 1))
-    {
-        return kernelConfig.dumpCurbe;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrCmdBuffer, sizeof(CodechalDbgAttr::attrCmdBuffer) - 1))
-    {
-        return kernelConfig.dumpCmdBuffer;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attr2ndLvlBatch, sizeof(CodechalDbgAttr::attr2ndLvlBatch) - 1))
-    {
-        return kernelConfig.dump2ndLvlBatch;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrInput, sizeof(CodechalDbgAttr::attrInput) - 1))
-    {
-        return kernelConfig.dumpInput;
-    }
-    else if (!strncmp(attrName.c_str(), CodechalDbgAttr::attrOutput, sizeof(CodechalDbgAttr::attrOutput) - 1))
-    {
-        return kernelConfig.dumpOutput;
-    }
-    else
-        return false;
+    return (uint32_t)m_debugInterface->m_bufferDumpFrameNum;
 }
 
 #endif  // USE_CODECHAL_DEBUG_TOOL
+
diff --git a/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.h b/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.h
index 9ad0cc0..70f30ad 100644
--- a/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.h
+++ b/media_driver/agnostic/common/codec/hal/codechal_debug_config_manager.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017-2019, Intel Corporation
+* Copyright (c) 2017-2020, Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -26,270 +26,27 @@
 //!
 #ifndef __CODECHAL_DEBUG_CONFIG_MANAGER_H__
 #define __CODECHAL_DEBUG_CONFIG_MANAGER_H__
+
+#include "codechal_debug.h"
 #if USE_CODECHAL_DEBUG_TOOL
 
-#include <string>
-#include <map>
-#include <vector>
-#include "mos_defs.h"
-#include "codechal_hw.h"
-
-namespace CodechalDbgAttr
-{
-static const char *attrPicParams              = "PicParams";
-static const char *attrSubsetsParams          = "SubsetsParams";
-static const char *attrFeiPicParams           = "FeiPicParams";
-static const char *attrMvcExtPicParams        = "MvcExtPicParams";
-static const char *attrSegmentParams          = "SegmentParams";
-static const char *attrSlcParams              = "SlcParams";
-static const char *attrMbParams               = "MbParams";
-static const char *attrIqParams               = "IqParams";
-static const char *attrSeqParams              = "SeqParams";
-static const char *attrVuiParams              = "VuiParams";
-static const char *attrBitstream              = "Bitstream";
-static const char *attrStreamOut              = "StreamOut";
-static const char *attrStreamIn               = "StreamIn";
-static const char *attrResidualDifference     = "ResidualDifference";
-static const char *attrDeblocking             = "Deblocking";
-static const char *attrMvData                 = "MvData";
-static const char *attrVc1Bitplane            = "Vc1Bitplane";
-static const char *attrCoefProb               = "CoefProb";
-static const char *attrSegId                  = "SegId";
-static const char *attrHucRegions             = "HucRegions";
-static const char *attrHuCDmem                = "HucDmem";
-static const char *attrCmdBufferMfx           = "CmdBufferMfx";
-static const char *attr2ndLvlBatchMfx         = "2ndLvlBatchMfx";
-static const char *attrDecodeOutputSurface    = "DecodeOutputSurface";
-static const char *attrDecodeAuxSurface       = "DumpAuxsurface";
-static const char *attrDecodeBltOutput        = "DumpBltOutput";
-static const char *attrSfcOutputSurface       = "SfcOutputSurface";
-static const char *attrSfcBuffers             = "SfcBuffers";
-static const char *attrReferenceSurfaces      = "ReferenceSurfaces";
-static const char *attrEncodeRawInputSurface  = "EncodeRawInputSurface";
-static const char *attrReconstructedSurface   = "ReconstructedSurface";
-static const char *attrPakInput               = "PakInput";
-static const char *attrPakOutput              = "PakOutput";
-static const char *attrUpsamlingInput         = "UpsamplingInput";
-static const char *attrResidualSurface        = "ResidualSurface";
-static const char *attrStCoeff                = "StCoeff";
-static const char *attrCoeffPredCs            = "CoeffPredCs";
-static const char *attrMbRecord               = "MbRecord";
-static const char *attrOverwriteCommands      = "OverwriteCommands";
-static const char *attrHuffmanTbl             = "HuffmanTbl";
-static const char *attrScanParams             = "ScanParams";
-static const char *attrDriverUltDump          = "DriverUltDump";
-static const char *attrDumpBufferInBinary     = "DumpBufferInBinary";
-static const char *attrDumpToThreadFolder     = "DumpToThreadFolder";
-static const char *attrDumpCmdBufInBinary     = "DumpCmdBufInBinary";
-static const char *attrDumpEncodePar          = "DumpEncodePar";
-static const char *attrForceCmdDumpLvl        = "ForceCmdDumpLvl";
-static const char *attrForceCurbeDumpLvl      = "ForceCurbeDumpLvl";
-static const char *attrForceYUVDumpWithMemcpy = "ForceYUVDumpWithMemcpy";
-static const char *attrDisableSwizzleForDumps = "DisableSwizzleForDumps";
-static const char *attrVdencOutput            = "VdencOutput";
-static const char *attrDecodeProcParams       = "DecodeProcParams";
-static const char *attrFrameState             = "FrameState";
-static const char *attrCUStreamout            = "CUStreamout";
-static const char *attrBrcPakStats            = "BrcPakStats";
-static const char *attrImageState             = "ImageState";
-static const char *attrSliceSizeStreamout     = "SliceSizeStreamout";
-static const char *attrCoeffProb              = "PakHwCoeffProbs";
-static const char *attrStatusReport           = "StatusReport";
-static const char *attrPakObjStreamout        = "PakObjStreamOut";
-static const char *attrTileBasedStats         = "TileBasedStats";
-static const char *attrROISurface             = "ROIInput";
-static const char *attrHuCStitchDataBuf       = "HuCStitchDataBuffer";
-
-// MD5 attributes
-static const char *attrMD5HashEnable    = "MD5HasEnable";
-static const char *attrMD5FlushInterval = "MD5FlushInterval";
-static const char *attrMD5PicWidth      = "MD5PicWidth";
-static const char *attrMD5PicHeight     = "MD5PicHeight";
-// kernel attributes
-static const char *attrDsh         = "DSH";
-static const char *attrIsh         = "ISH";
-static const char *attrSsh         = "SSH";
-static const char *attrCurbe       = "Curbe";
-static const char *attrCmdBuffer   = "CmdBuffer";
-static const char *attr2ndLvlBatch = "2ndLvlBath";
-static const char *attrInput       = "Input";
-static const char *attrOutput      = "Output";
-};
-
-namespace CodechalDbgKernel
-{
-class KernelStateMap
+class CodecDebugConfigMgr : public MediaDebugConfigMgr
 {
 public:
-    using kernelMapType = std::map<CODECHAL_MEDIA_STATE_TYPE, std::string>;
-
-    static bool RegisterKernelStr(CODECHAL_MEDIA_STATE_TYPE mediaState, std::string kernelName)
-    {
-        kernelMapType &kernelMap = GetKernelStateMap();
-        auto           it        = kernelMap.find(mediaState);
-        if (it == kernelMap.end())
-        {
-            kernelMap.insert(std::make_pair(mediaState, kernelName));
-        }
-        return true;
-    }
-
-    static kernelMapType &GetKernelStateMap()
-    {
-        static kernelMapType m_kernelStateMap;
-        return m_kernelStateMap;
-    }
-};
-
-static const char *kernelOlp                          = "Vc1Olp";
-static const char *kernelEncNormal                    = "MbEncNorm";
-static const char *kernelEncPerf                      = "MbEncPerf";
-static const char *kernelEncQuality                   = "MbEncQlty";
-static const char *kernelEncIFrameDist                = "IFrameDist";
-static const char *kernel32xScaling                   = "32xScaling";
-static const char *kernel16xScaling                   = "16xScaling";
-static const char *kernel4xScaling                    = "4xScaling";
-static const char *kernel32xMe                        = "32xMe";
-static const char *kernel16xMe                        = "16xMe";
-static const char *kernel4xMe                         = "4xMe";
-static const char *kernelBrcInitReset                 = "BrcInitReset";
-static const char *kernelBrcUpdate                    = "BrcUpdate";
-static const char *kernel2xScaling                    = "2xScaling";
-static const char *kernelHevc32x32PuModeDecision      = "HEVC_32x32_PU_MD";
-static const char *kernelHevc16x16PuSad               = "HEVC_16x16_PU_SAD";
-static const char *kernelHevc16x16PuModeDecision      = "HEVC_16x16_PU_MD";
-static const char *kernelHevc8x8Pu                    = "HEVC_8x8_PU_MD";
-static const char *kernelHevc8x8PuFMode               = "HEVC_8x8_PU_FMODE";
-static const char *kernelHevc32x32BIntraCheck         = "HEVC_32x32_B_INTRA_CHECK";
-static const char *kernelHevcBMbenc                   = "HEVC_B_MBENC";
-static const char *kernelHevcBPak                     = "HEVC_B_PAK";
-static const char *kernelHevcBrcLcuUpdate             = "HEVC_LCU_BRCUpdate";
-static const char *kernelMeVdencStreamIn              = "MeVDEncStreamIn";
-static const char *kernelVP9EncI32x32                 = "VP9_I_32x32_MBENC";
-static const char *kernelVP9EncI16x16                 = "VP9_I_16x16_MBENC";
-static const char *kernelVP9EncP                      = "VP9_P_MBENC";
-static const char *kernelVP9EncTx                     = "VP9_TX_MBENC";
-static const char *kernelVP9Dys                       = "VP9_DYS";
-static const char *kernelVP9PakLumaRecon              = "VP9_I_MBPAK_LumaRecon";
-static const char *kernelVP9PakChromaRecon            = "VP9_I_MBPAK_ChromaRecon";
-static const char *kernelVP9PakDeblockMask            = "VP9_I_MBPAK_DeblockMask";
-static const char *kernelVP9PakLumaDeblock            = "VP9_I_MBPAK_LumaDeblock";
-static const char *kernelVP9PakChromaDeblock          = "VP9_I_MBPAK_ChromaDeblock";
-static const char *kernelVP9PakMcPred                 = "VP9_P_MbPak_McPred";
-static const char *kernelVP9PakPFrameLumaRecon        = "VP9_P_MbPak_LumaRecon";
-static const char *kernelVP9PakPFrameLumaRecon32x32   = "VP9_P_MbPak_LumaRecon";
-static const char *kernelVP9PakPFrameChromaRecon      = "VP9_P_MbPak_ChromaRecon";
-static const char *kernelVP9PakPFrameIntraLumaRecon   = "VP9_Intra_P_MbPak_LumaRecon";
-static const char *kernelVP9PakPFrameIntraChromaRecon = "VP9_Intra_P_MbPak_ChromaRecon";
-static const char *kernelPreProc                      = "PreProc";
-static const char *kernelEncWP                        = "WP";
-static const char *kernelHevcIMbenc                   = "HEVC_I_MBENC";
-static const char *kernelCscDsCopy                    = "CSCDsCopy";
-static const char *kernel2x4xScaling                  = "2x_4xScaling";
-static const char *kernelHevcLcu64BMbenc              = "HEVC_LCU64_B_MBENC";
-static const char *kernelMbBrcUpdate                  = "MbBrcUpdate";
-static const char *kernelStaticFrameDetection         = "StaticFrameDetection";
-static const char *kernelHevcRoi                      = "HEVC_ROI";
-
-static bool regOlp                          = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_OLP, kernelOlp);
-static bool regEncNormal                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_NORMAL, kernelEncNormal);
-static bool regEncQuality                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_PERFORMANCE, kernelEncPerf);
-static bool regEncPerf                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_QUALITY, kernelEncQuality);
-static bool regEncIFrameDist                = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_I_FRAME_DIST, kernelEncIFrameDist);
-static bool reg32xScaling                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32X_SCALING, kernel32xScaling);
-static bool reg16xScaling                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16X_SCALING, kernel16xScaling);
-static bool reg4xScaling                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_4X_SCALING, kernel4xScaling);
-static bool reg32xMe                        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32X_ME, kernel32xMe);
-static bool reg16xMe                        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16X_ME, kernel16xMe);
-static bool reg4xMe                         = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_4X_ME, kernel4xMe);
-static bool regBrcInit                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_BRC_INIT_RESET, kernelBrcInitReset);
-static bool regBrcUpdate                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_BRC_UPDATE, kernelBrcUpdate);
-static bool reg2xScale                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_2X_SCALING, kernel2xScaling);
-static bool regHevc32x32PuMode              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32x32_PU_MODE_DECISION, kernelHevc32x32PuModeDecision);
-static bool regHevc16x16PuSad               = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16x16_PU_SAD, kernelHevc16x16PuSad);
-static bool regHevc16x16PuMode              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16x16_PU_MODE_DECISION, kernelHevc16x16PuModeDecision);
-static bool regHevc8x8Pu                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_8x8_PU, kernelHevc8x8Pu);
-static bool regHevc8x8PuFMode               = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_8x8_PU_FMODE, kernelHevc8x8PuFMode);
-static bool regHevc32x32BIntraCheck         = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32x32_B_INTRA_CHECK, kernelHevc32x32BIntraCheck);
-static bool regHevcBMben                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_B_MBENC, kernelHevcBMbenc);
-static bool regHevcBPak                     = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_B_PAK, kernelHevcBPak);
-static bool regHevcBrcLcuUpdate             = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_BRC_LCU_UPDATE, kernelHevcBrcLcuUpdate);
-static bool regMeVdencStreamIn              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ME_VDENC_STREAMIN, kernelMeVdencStreamIn);
-static bool regVp9EncI32x32                 = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_I_32x32, kernelVP9EncI32x32);
-static bool regVp9EncI16x16                 = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_I_16x16, kernelVP9EncI16x16);
-static bool regVp9EncP                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_P, kernelVP9EncP);
-static bool regVp9EncTx                     = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_TX, kernelVP9EncTx);
-static bool regVp9Dys                       = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_DYS, kernelVP9Dys);
-static bool regVp9PakLumaRecon              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_LUMA_RECON, kernelVP9PakLumaRecon);
-static bool regVp9PakChromaRecon            = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_CHROMA_RECON, kernelVP9PakChromaRecon);
-static bool regVp9PakDeblockMask            = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_DEBLOCK_MASK, kernelVP9PakDeblockMask);
-static bool regVp9PakLumaDeblock            = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_LUMA_DEBLOCK, kernelVP9PakLumaDeblock);
-static bool regVp9PakChromaDeblock          = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_CHROMA_DEBLOCK, kernelVP9PakChromaDeblock);
-static bool regVp9PakMcPred                 = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_MC_PRED, kernelVP9PakMcPred);
-static bool regVp9PakPFrameLumaRecon        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_LUMA_RECON, kernelVP9PakPFrameLumaRecon);
-static bool regVp9PakPFrameLumaRecon32x32   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_LUMA_RECON_32x32, kernelVP9PakPFrameLumaRecon32x32);
-static bool regVp9PakPFrameChromaRecon      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_CHROMA_RECON, kernelVP9PakPFrameChromaRecon);
-static bool regVp9PakPFrameIntraLumaRecon   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_INTRA_LUMA_RECON, kernelVP9PakPFrameIntraLumaRecon);
-static bool regVp9PakPFrameIntraChromaRecon = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_INTRA_CHROMA_RECON, kernelVP9PakPFrameIntraChromaRecon);
-static bool regPreProc                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_PREPROC, kernelPreProc);
-static bool regEncWP                        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_WP, kernelEncWP);
-static bool regHevcIMbenc                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_I_MBENC, kernelHevcIMbenc);
-static bool regCscDsCopy                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_CSC_DS_COPY, kernelCscDsCopy);
-static bool reg2x4xScaling                  = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_2X_4X_SCALING, kernel2x4xScaling);
-static bool regHevcLcu64BMbenc              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_LCU64_B_MBENC, kernelHevcLcu64BMbenc);
-static bool regMbBrcUpdate                  = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_MB_BRC_UPDATE, kernelMbBrcUpdate);
-static bool regStaticFrameDetection         = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_STATIC_FRAME_DETECTION, kernelStaticFrameDetection);
-static bool regHevcRoi                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_ROI, kernelHevcRoi);
-};
-
-struct KernelDumpConfig
-{
-    bool dumpDsh         = false;
-    bool dumpSsh         = false;
-    bool dumpIsh         = false;
-    bool dumpCurbe       = false;
-    bool dumpCmdBuffer   = false;
-    bool dump2ndLvlBatch = false;
-    bool dumpInput       = false;
-    bool dumpOutput      = false;
-};
-struct CodechalDbgCfg
-{
-    int32_t frameIndex;
-    std::map<std::string, int32_t>          cmdAttribs;
-    std::map<std::string, KernelDumpConfig> kernelAttribs;
-    std::vector<std::string> forceCmds;
-};
-class CodechalDebugInterface;
-class CodechalDebugConfigMgr
-{
-public:
-    CodechalDebugConfigMgr(
+    CodecDebugConfigMgr(
         CodechalDebugInterface *debugInterface,
-        CODECHAL_FUNCTION       CodecFunction,
+        CODECHAL_FUNCTION       codecFunction,
         std::string             outputFolderPath);
-    ~CodechalDebugConfigMgr();
-    MOS_STATUS ParseConfig(MOS_CONTEXT_HANDLE mosCtx);
-    MOS_STATUS DeleteCfgNode(uint32_t frameIdx);
-
-    std::string GetMediaStateStr(CODECHAL_MEDIA_STATE_TYPE mediaState);
-
-    bool AttrIsEnabled(std::string attrib);
-    bool AttrIsEnabled(CODECHAL_MEDIA_STATE_TYPE mediaState, std::string attrib);
+    virtual ~CodecDebugConfigMgr();
 
 protected:
-    void GenerateDefaultConfig();
-    uint32_t GetFrameConfig(uint32_t frameIdx);
-    void StoreDebugAttribs(std::string line, CodechalDbgCfg *dbgCfg);
-    void ParseKernelAttribs(std::string line, CodechalDbgCfg *dbgCfg);
-    bool KernelAttrEnabled(KernelDumpConfig kernelConfig, std::string attrName);
+    void     GetFunctionType();
+    uint32_t GetDumpFrameNum() override;
+    std::string InitFileName(MediaDbgFunction mediaFunction) override;
 
 protected:
-    CodechalDebugInterface *    m_debugInterface = nullptr;
-    CODECHAL_FUNCTION           m_codecFunction;
-    std::string                 m_outputFolderPath;
-    std::vector<CodechalDbgCfg> m_debugFrameConfigs;
-    CodechalDbgCfg *            m_debugAllConfigs = nullptr;
+    CodechalDebugInterface *m_debugInterface = nullptr;
+    CODECHAL_FUNCTION       m_codecFunction;
 };
 
 #endif  //USE_CODECHAL_DEBUG_TOOL
diff --git a/media_driver/agnostic/common/os/mos_utilities.cpp b/media_driver/agnostic/common/os/mos_utilities.cpp
index c7ddb05..ce993bf 100644
--- a/media_driver/agnostic/common/os/mos_utilities.cpp
+++ b/media_driver/agnostic/common/os/mos_utilities.cpp
@@ -2321,15 +2321,15 @@
         MOS_USER_FEATURE_VALUE_TYPE_STRING,
         "",
         "CodecHal Dump Output Directory."),
-    MOS_DECLARE_UF_KEY_DBGONLY(__MEDIA_USER_FEATURE_VALUE_CODECHAL_DEBUG_CFG_GENERATION_ID,
-        "CodecHal Debug Cfg Generation",
+    MOS_DECLARE_UF_KEY_DBGONLY(__MEDIA_USER_FEATURE_VALUE_MEDIA_DEBUG_CFG_GENERATION_ID,
+        "Media Debug Cfg Generation",
         __MEDIA_USER_FEATURE_SUBKEY_INTERNAL,
         __MEDIA_USER_FEATURE_SUBKEY_REPORT,
         "Codec",
         MOS_USER_FEATURE_TYPE_USER,
         MOS_USER_FEATURE_VALUE_TYPE_INT32,
         "0",
-        "Enable the Generation of CodecHal Debug Cfg file."),
+        "Enable the Generation of Media Debug Cfg file."),
     MOS_DECLARE_UF_KEY_DBGONLY(__MEDIA_USER_FEATURE_VALUE_CODECHAL_RDOQ_INTRA_TU_OVERRIDE_ID,
         "RDOQ Intra TU Override",
         __MEDIA_USER_FEATURE_SUBKEY_INTERNAL,
diff --git a/media_driver/agnostic/common/os/mos_utilities_common.h b/media_driver/agnostic/common/os/mos_utilities_common.h
index bae4944..ebc0cf8 100644
--- a/media_driver/agnostic/common/os/mos_utilities_common.h
+++ b/media_driver/agnostic/common/os/mos_utilities_common.h
@@ -338,7 +338,7 @@
     __MEDIA_USER_FEATURE_VALUE_DECOMPRESS_DECODE_SFC_OUTPUT_ID,
     __MEDIA_USER_FEATURE_VALUE_CODECHAL_DEBUG_OUTPUT_DIRECTORY_ID,
     __MEDIA_USER_FEATURE_VALUE_CODECHAL_DUMP_OUTPUT_DIRECTORY_ID,
-    __MEDIA_USER_FEATURE_VALUE_CODECHAL_DEBUG_CFG_GENERATION_ID,
+    __MEDIA_USER_FEATURE_VALUE_MEDIA_DEBUG_CFG_GENERATION_ID,
     __MEDIA_USER_FEATURE_VALUE_CODECHAL_RDOQ_INTRA_TU_OVERRIDE_ID,
     __MEDIA_USER_FEATURE_VALUE_CODECHAL_RDOQ_INTRA_TU_DISABLE_ID,
     __MEDIA_USER_FEATURE_VALUE_CODECHAL_RDOQ_INTRA_TU_THRESHOLD_ID,
diff --git a/media_driver/agnostic/common/shared/media_debug_config_manager.cpp b/media_driver/agnostic/common/shared/media_debug_config_manager.cpp
new file mode 100644
index 0000000..ab1432a
--- /dev/null
+++ b/media_driver/agnostic/common/shared/media_debug_config_manager.cpp
@@ -0,0 +1,552 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//!
+//! \file     media_debug_config_manager.cpp
+//! \brief    Defines the dump configuration manager.
+//! \details  The debug interface dumps configuration manager file which parse attributes.
+//!
+#include "codechal_debug.h"
+#include "vp_debug_interface.h"
+#if USE_MEDIA_DEBUG_TOOL
+#include "media_debug_config_manager.h"
+#include <fstream>
+#include <sstream>
+
+MediaDebugConfigMgr::MediaDebugConfigMgr(
+    std::string outputFolderPath)
+    : m_outputFolderPath(outputFolderPath)
+{
+}
+
+MediaDebugConfigMgr::~MediaDebugConfigMgr()
+{
+}
+
+MOS_STATUS MediaDebugConfigMgr::ParseConfig(MOS_CONTEXT_HANDLE mosCtx)
+{
+    std::string               configFileName;
+    MOS_USER_FEATURE_VALUE_ID configGenerateKey = __MOS_USER_FEATURE_KEY_INVALID_ID;
+
+    configFileName = InitFileName(m_mediaFunction);
+
+    configGenerateKey = __MEDIA_USER_FEATURE_VALUE_MEDIA_DEBUG_CFG_GENERATION_ID;
+    configFileName    = m_outputFolderPath + configFileName;
+    std::ifstream configStream(configFileName);
+
+    if (!configStream.good())
+    {
+        MOS_USER_FEATURE_VALUE_DATA userFeatureData;
+        MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
+        MOS_UserFeature_ReadValue_ID(
+            nullptr,
+            configGenerateKey,
+            &userFeatureData,
+            mosCtx);
+        if (userFeatureData.i32Data)
+        {
+            GenerateDefaultConfig(configFileName);
+        }
+        return MOS_STATUS_SUCCESS;
+    }
+
+    std::string line;
+
+    bool    parseEnable = false;
+    int32_t minFrameNum = -1;
+    int32_t maxFrameNum = -1;
+
+    while (std::getline(configStream, line))
+    {
+        if (line.empty())
+        {
+            continue;
+        }
+        auto        pos     = line.find_first_not_of("\t ");
+        std::string newline = line.substr(pos);
+        if (newline[0] == '\n' || newline[0] == '#')
+        {
+            continue;
+        }
+        else if (newline[0] == '@')  // parse keyword
+        {
+            if (!strncmp(newline.substr(1, 4).c_str(), "mode", 4))
+            {
+                auto pos1 = newline.find_first_not_of("\t ", 5);
+                if (pos1 == std::string::npos)
+                {
+                    continue;
+                }
+                if ((!strncmp(newline.substr(pos1, 3).c_str(), "ALL", 3)) ||
+                    (!strncmp(newline.substr(pos1, 6).c_str(), "encode", 6) &&
+                        m_mediaFunction == MEDIA_FUNCTION_ENCODE) ||
+                    (!strncmp(newline.substr(pos1, 6).c_str(), "decode", 6) &&
+                        (m_mediaFunction == MEDIA_FUNCTION_DECODE ||
+                         m_mediaFunction == MEDIA_FUNCTION_CENC_DECODE)) ||
+                    (!strncmp(newline.substr(pos1, 2).c_str(), "vp", 2) &&
+                        (m_mediaFunction == MEDIA_FUNCTION_VP)))
+                {
+                    parseEnable = true;
+                }
+                else
+                {
+                    parseEnable = false;
+                }
+                continue;
+            }
+
+            if (!parseEnable)
+            {
+                continue;
+            }
+
+            if (!strncmp(newline.substr(1, 5).c_str(), "Frame", 5))
+            {
+                // start with new frame config
+                auto pos1 = newline.find_first_not_of("\t ", 6);
+                if (pos1 == std::string::npos)
+                    continue;
+
+                minFrameNum = maxFrameNum = -1;
+                if (!strncmp(newline.substr(pos1, 3).c_str(), "ALL", 3))
+                {
+                    // coonfig applid to all frames
+                    if (nullptr == m_debugAllConfigs)
+                    {
+                        m_debugAllConfigs = MOS_New(MediaDbgCfg);
+                    }
+                }
+                else
+                {
+                    auto pos2 = newline.find_first_of("-", 6);
+                    if (pos2 != std::string::npos)  // handle frame range
+                    {
+                        minFrameNum = std::stoi(newline.substr(pos1, pos2 - pos1));
+                        maxFrameNum = std::stoi(newline.substr(pos2 + 1));
+                    }
+                    else
+                    {
+                        minFrameNum = maxFrameNum = std::stoi(newline.substr(pos1));
+                    }
+                }
+            }
+            else if (!strncmp(newline.substr(1, 5).c_str(), "Force", 5))
+            {
+            }
+            else if (!strncmp(newline.substr(1, 14).c_str(), "OverwriteCurbe", 14))
+            {
+            }
+            else
+            {
+                if (minFrameNum < 0)
+                {
+                    ParseKernelAttribs(newline, nullptr);
+                }
+                else
+                {
+                    for (int32_t i = minFrameNum; i <= maxFrameNum; i++)
+                    {
+                        ParseKernelAttribs(newline, &m_debugFrameConfigs.at(GetFrameConfig(i)));
+                    }
+                }
+            }
+        }
+        else if (parseEnable)
+        {
+            if (minFrameNum < 0)
+            {
+                StoreDebugAttribs(newline, nullptr);
+            }
+            else
+            {
+                for (int32_t i = minFrameNum; i <= maxFrameNum; i++)
+                {
+                    StoreDebugAttribs(newline, &m_debugFrameConfigs.at(GetFrameConfig(i)));
+                }
+            }
+        }
+    }
+
+    return MOS_STATUS_SUCCESS;
+}
+
+uint32_t MediaDebugConfigMgr::GetFrameConfig(uint32_t frameIdx)
+{
+    uint32_t pos;
+    for (pos = 0; pos < m_debugFrameConfigs.size(); pos++)
+    {
+        if (m_debugFrameConfigs[pos].frameIndex == frameIdx)
+        {
+            return pos;
+        }
+    }
+    MediaDbgCfg frameConfig;
+    frameConfig.frameIndex = frameIdx;
+    m_debugFrameConfigs.push_back(frameConfig);
+    return pos;
+}
+
+void MediaDebugConfigMgr::StoreDebugAttribs(std::string line, MediaDbgCfg *dbgCfg)
+{
+    MediaDbgCfg *config = dbgCfg != nullptr ? dbgCfg : m_debugAllConfigs;
+    if (config == nullptr)
+    {
+        return;
+    }
+
+    auto delimeterPos = line.find(':');
+    if (delimeterPos == std::string::npos)
+    {
+        return;
+    }
+
+    auto        attrEndPos = line.substr(0, delimeterPos).find_last_not_of("\t ");
+    std::string attrName   = line.substr(0, attrEndPos + 1);
+    int32_t     attrValue  = std::stoi(line.substr(delimeterPos + 1));
+
+    auto it = config->cmdAttribs.find(attrName);
+    if (it != config->cmdAttribs.end())
+    {
+        config->cmdAttribs.erase(it);
+    }
+
+    config->cmdAttribs[attrName] = attrValue;
+}
+
+void MediaDebugConfigMgr::ParseKernelAttribs(std::string line, MediaDbgCfg *dbgCfg)
+{
+    MediaDbgCfg *config = dbgCfg != nullptr ? dbgCfg : m_debugAllConfigs;
+    if (config == nullptr)
+    {
+        return;
+    }
+
+    auto        kernelNameEndPos = line.find_first_of("\t ", 1);
+    std::string kernelName       = line.substr(1, kernelNameEndPos - 1);
+
+    std::istringstream iss(line.substr(kernelNameEndPos));
+    do
+    {
+        std::string attrName;
+        iss >> attrName;
+        if (attrName.empty())
+        {
+            continue;
+        }
+
+        if (!strncmp(attrName.c_str(), "ALL", 3))
+        {
+            config->kernelAttribs[kernelName].dumpDsh         = true;
+            config->kernelAttribs[kernelName].dumpSsh         = true;
+            config->kernelAttribs[kernelName].dumpIsh         = true;
+            config->kernelAttribs[kernelName].dumpCurbe       = true;
+            config->kernelAttribs[kernelName].dumpCmdBuffer   = true;
+            config->kernelAttribs[kernelName].dump2ndLvlBatch = true;
+            config->kernelAttribs[kernelName].dumpInput       = true;
+            config->kernelAttribs[kernelName].dumpOutput      = true;
+            break;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrDsh, sizeof(MediaDbgAttr::attrDsh) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpDsh = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrSsh, sizeof(MediaDbgAttr::attrSsh) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpSsh = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrIsh, sizeof(MediaDbgAttr::attrIsh) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpIsh = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrCurbe, sizeof(MediaDbgAttr::attrCurbe) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpCurbe = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrCmdBuffer, sizeof(MediaDbgAttr::attrCmdBuffer) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpCmdBuffer = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attr2ndLvlBatch, sizeof(MediaDbgAttr::attr2ndLvlBatch) - 1))
+        {
+            config->kernelAttribs[kernelName].dump2ndLvlBatch = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrInput, sizeof(MediaDbgAttr::attrInput) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpInput = true;
+        }
+        else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrOutput, sizeof(MediaDbgAttr::attrOutput) - 1))
+        {
+            config->kernelAttribs[kernelName].dumpOutput = true;
+        }
+
+    } while (iss);
+}
+
+MOS_STATUS MediaDebugConfigMgr::DeleteCfgNode(uint32_t frameIdx)
+{
+    for (auto it = m_debugFrameConfigs.begin(); it != m_debugFrameConfigs.end(); it++)
+    {
+        if (it->frameIndex == frameIdx)
+        {
+            m_debugFrameConfigs.erase(it);
+            break;
+        }
+    }
+    return MOS_STATUS_SUCCESS;
+}
+
+std::string MediaDebugConfigMgr::GetMediaStateStr(MEDIA_DEBUG_STATE_TYPE mediaState)
+{
+    MediaDbgKernel::KernelStateMap::kernelMapType &kernelMap = MediaDbgKernel::KernelStateMap::GetKernelStateMap();
+    auto                                              it        = kernelMap.find(mediaState);
+    if (it != kernelMap.end())
+    {
+        return it->second;
+    }
+
+    return "";
+}
+
+bool MediaDebugConfigMgr::AttrIsEnabled(std::string attrName)
+{
+    if (nullptr != m_debugAllConfigs)
+    {
+        int attrValue = m_debugAllConfigs->cmdAttribs[attrName];
+        if (attrValue > 0)
+        {
+            return true;
+        }
+    }
+
+    for (auto it : m_debugFrameConfigs)
+    {
+        if (it.frameIndex == GetDumpFrameNum())
+        {
+            int attrValue = it.cmdAttribs[attrName];
+            return attrValue > 0;
+        }
+    }
+
+    return false;
+}
+
+bool MediaDebugConfigMgr::AttrIsEnabled(
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    std::string            attrName)
+{
+    std::string kernelName = GetMediaStateStr(mediaState);
+    if (kernelName.empty())
+    {
+        return false;
+    }
+
+    if (nullptr != m_debugAllConfigs)
+    {
+        MediaKernelDumpConfig attrs   = m_debugAllConfigs->kernelAttribs[kernelName];
+        bool             enabled = KernelAttrEnabled(attrs, attrName);
+        if (enabled)
+        {
+            return enabled;
+        }
+    }
+
+    for (auto it : m_debugFrameConfigs)
+    {
+        if (it.frameIndex == GetDumpFrameNum())
+        {
+            MediaKernelDumpConfig attrs = it.kernelAttribs[kernelName];
+            return KernelAttrEnabled(attrs, attrName);
+        }
+    }
+    return false;
+}
+
+bool MediaDebugConfigMgr::KernelAttrEnabled(MediaKernelDumpConfig kernelConfig, std::string attrName)
+{
+    if (!strncmp(attrName.c_str(), MediaDbgAttr::attrDsh, sizeof(MediaDbgAttr::attrDsh) - 1))
+    {
+        return kernelConfig.dumpDsh;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrSsh, sizeof(MediaDbgAttr::attrSsh) - 1))
+    {
+        return kernelConfig.dumpSsh;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrIsh, sizeof(MediaDbgAttr::attrIsh) - 1))
+    {
+        return kernelConfig.dumpIsh;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrCurbe, sizeof(MediaDbgAttr::attrCurbe) - 1))
+    {
+        return kernelConfig.dumpCurbe;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrCmdBuffer, sizeof(MediaDbgAttr::attrCmdBuffer) - 1))
+    {
+        return kernelConfig.dumpCmdBuffer;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attr2ndLvlBatch, sizeof(MediaDbgAttr::attr2ndLvlBatch) - 1))
+    {
+        return kernelConfig.dump2ndLvlBatch;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrInput, sizeof(MediaDbgAttr::attrInput) - 1))
+    {
+        return kernelConfig.dumpInput;
+    }
+    else if (!strncmp(attrName.c_str(), MediaDbgAttr::attrOutput, sizeof(MediaDbgAttr::attrOutput) - 1))
+    {
+        return kernelConfig.dumpOutput;
+    }
+    else
+        return false;
+}
+
+void MediaDebugConfigMgr::GenerateDefaultConfig(std::string configFileName)
+{
+    std::ofstream ofs(configFileName);
+
+    ofs << "###################################################################" << std::endl;
+    ofs << "## - White space should be agnostic." << std::endl;
+    ofs << "## - '#' as first non-white space char denotes line as comment" << std::endl;
+    ofs << "## - '@frame ALL' MUST be present as the first directive, even if " << std::endl;
+    ofs << "##   nothing is dumped for every frame." << std::endl;
+    ofs << "###################################################################" << std::endl;
+    ofs << std::endl;
+
+    ofs << "###################################################################" << std::endl;
+    ofs << "## key words defined under @mode ALL works for encode decode vp" << std::endl;
+    ofs << "###################################################################" << std::endl;
+    ofs << std::endl;
+    ofs << "@mode ALL" << std::endl;
+    ofs << "@Frame ALL" << std::endl;
+    ofs << std::endl;
+
+    ofs << "#" << MediaDbgAttr::attrPicParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrSlcParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrSubsetsParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrIqParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrBitstream << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrHucRegions << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrHuCDmem << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrCmdBufferMfx << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attr2ndLvlBatchMfx << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrHuffmanTbl << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrScanParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDriverUltDump << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDumpBufferInBinary << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDumpToThreadFolder << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDumpCmdBufInBinary << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrStatusReport << ":0" << std::endl;
+    ofs << std::endl;
+
+    ofs << "##" << MediaDbgAttr::attrStreamOut << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrStreamIn << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrResidualDifference << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrDeblocking << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrMvData << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrForceYUVDumpWithMemcpy << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrDisableSwizzleForDumps << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrSfcOutputSurface << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrReferenceSurfaces << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrEncodeRawInputSurface << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrReconstructedSurface << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrPakInput << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrPakOutput << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrUpsamlingInput << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrResidualSurface << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrStCoeff << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrCoeffPredCs << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrMbRecord << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrPakObjStreamout << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrTileBasedStats << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrOverwriteCommands << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrForceCmdDumpLvl << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrForceCurbeDumpLvl << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrFrameState << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrBrcPakStats << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrCUStreamout << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrImageState << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrSliceSizeStreamout << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrCoeffProb << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrROISurface << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrHuCStitchDataBuf << ":0" << std::endl;
+
+    // MD5 attributes
+    ofs << "##" << MediaDbgAttr::attrMD5HashEnable << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrMD5FlushInterval << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrMD5PicWidth << ":0" << std::endl;
+    ofs << "##" << MediaDbgAttr::attrMD5PicHeight << ":0" << std::endl;
+    ofs << std::endl;
+
+    ofs << "###################################################################" << std::endl;
+    ofs << "## key words defined under @mode decode works for decode only" << std::endl;
+    ofs << "###################################################################" << std::endl;
+    ofs << std::endl;
+    ofs << "#@mode decode" << std::endl;
+    ofs << "#@Frame ALL" << std::endl;
+    ofs << std::endl;
+
+    ofs << "#" << MediaDbgAttr::attrSegmentParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrMbParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrVc1Bitplane << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrCoefProb << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrSegId << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDecodeOutputSurface << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDecodeAuxSurface << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDecodeBltOutput << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDecodeProcParams << ":0" << std::endl;
+    ofs << std::endl;
+
+    ofs << "###############################################################" << std::endl;
+    ofs << "## key words defined under @mode encode works for encode only" << std::endl;
+    ofs << "###############################################################" << std::endl;
+    ofs << std::endl;
+    ofs << "#@mode encode" << std::endl;
+    ofs << "#@Frame ALL" << std::endl;
+    ofs << std::endl;
+
+    ofs << "#" << MediaDbgAttr::attrFeiPicParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrSeqParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrVuiParams << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrDumpEncodePar << ":0" << std::endl;
+    ofs << "#" << MediaDbgAttr::attrVdencOutput << ":0" << std::endl;
+    ofs << std::endl;
+
+    ofs << "###############################################################" << std::endl;
+    ofs << "## key words defined for kernel" << std::endl;
+    ofs << "###############################################################" << std::endl;
+    // generate kernel related config
+    MediaDbgKernel::KernelStateMap::kernelMapType &kernelMap = MediaDbgKernel::KernelStateMap::GetKernelStateMap();
+    for (auto &it : kernelMap)
+    {
+        ofs << "#@" << it.second << " ALL" << std::endl;
+    }
+    ofs << std::endl;
+
+    ofs << "### Encode plug-in ###" << std::endl;
+    ofs << "#@force" << std::endl;
+    ofs << "#ForceCmpDumpLvl:3" << std::endl;
+    ofs << "#@OverwriteCurbe" << std::endl;
+    ofs << "#ForceCurbeDumpLvl:3" << std::endl;
+
+    ofs.close();
+}
+
+#endif  // USE_MEDIA_DEBUG_TOOL
diff --git a/media_driver/agnostic/common/shared/media_debug_config_manager.h b/media_driver/agnostic/common/shared/media_debug_config_manager.h
new file mode 100644
index 0000000..465ad3e
--- /dev/null
+++ b/media_driver/agnostic/common/shared/media_debug_config_manager.h
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     media_debug_config_manager.h
+//! \brief    Defines the dump configuration manager.
+//! \details  The debug interface dumps configuration manager file which parse attributes.
+#ifndef __MEDIA_DEBUG_CONFIG_MANAGER_H__
+#define __MEDIA_DEBUG_CONFIG_MANAGER_H__
+#if USE_MEDIA_DEBUG_TOOL
+#include "media_debug_utils.h"
+#include "media_common_defs.h"
+
+struct MediaKernelDumpConfig
+{
+    bool dumpDsh         = false;
+    bool dumpSsh         = false;
+    bool dumpIsh         = false;
+    bool dumpCurbe       = false;
+    bool dumpCmdBuffer   = false;
+    bool dump2ndLvlBatch = false;
+    bool dumpInput       = false;
+    bool dumpOutput      = false;
+};
+
+struct MediaDbgCfg
+{
+    int32_t                                      frameIndex;
+    std::map<std::string, int32_t>               cmdAttribs;
+    std::map<std::string, MediaKernelDumpConfig> kernelAttribs;
+    std::vector<std::string>                     forceCmds;
+};
+
+enum MediaDbgFunction
+{
+    MEDIA_FUNCTION_DEFAULT     = 0,
+    MEDIA_FUNCTION_ENCODE      = 1,
+    MEDIA_FUNCTION_DECODE      = 2,
+    MEDIA_FUNCTION_CENC_DECODE = 3,
+    MEDIA_FUNCTION_VP          = 4,
+};
+
+class MediaDebugInterface;
+class CodechalDebugInterface;
+class VpDebugInterface;
+class MediaDebugConfigMgr
+{
+public:
+    MediaDebugConfigMgr(std::string outputFolderPath);
+    virtual ~MediaDebugConfigMgr();
+
+    MOS_STATUS ParseConfig(MOS_CONTEXT_HANDLE mosCtx);
+    MOS_STATUS DeleteCfgNode(uint32_t frameIdx);
+
+    std::string GetMediaStateStr(MEDIA_DEBUG_STATE_TYPE mediaState);
+
+    bool AttrIsEnabled(std::string attrName);
+    bool AttrIsEnabled(MEDIA_DEBUG_STATE_TYPE mediaState, std::string attrName);
+
+ protected:
+    void     GenerateDefaultConfig(std::string configFileName);
+    void     StoreDebugAttribs(std::string line, MediaDbgCfg *dbgCfg);
+    void     ParseKernelAttribs(std::string line, MediaDbgCfg *dbgCfg);
+    bool     KernelAttrEnabled(MediaKernelDumpConfig kernelConfig, std::string attrName);
+    uint32_t GetFrameConfig(uint32_t frameIdx);
+
+    virtual uint32_t GetDumpFrameNum() = 0;
+    virtual std::string InitFileName(MediaDbgFunction mediaFunction) = 0;
+
+protected:
+    MediaDbgFunction         m_mediaFunction;
+    std::string              m_outputFolderPath;
+    std::vector<MediaDbgCfg> m_debugFrameConfigs;
+    MediaDbgCfg *            m_debugAllConfigs = nullptr;
+};
+
+#endif  //USE_MEDIA_DEBUG_TOOL
+#endif  /* __MEDIA_DEBUG_CONFIG_MANAGER_H__ */
diff --git a/media_driver/agnostic/common/shared/media_debug_interface.cpp b/media_driver/agnostic/common/shared/media_debug_interface.cpp
new file mode 100644
index 0000000..2089d39
--- /dev/null
+++ b/media_driver/agnostic/common/shared/media_debug_interface.cpp
@@ -0,0 +1,1274 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     media_debug_interface.cpp
+//! \brief    Defines the debug interface shared by all of Media.
+//! \details  The debug interface dumps output from Media based on input config file.
+//!
+#include "media_debug_interface.h"
+#if USE_MEDIA_DEBUG_TOOL
+#include "media_debug_config_manager.h"
+#include "codechal_hw.h"
+#include <fstream>
+#include <sstream>
+#include <iomanip>
+
+#if !defined(LINUX) && !defined(ANDROID)
+#include "UmdStateSeparation.h"
+#endif
+
+MediaDebugInterface::MediaDebugInterface()
+{
+    memset(&m_currPic, 0, sizeof(CODEC_PICTURE));
+    memset(m_fileName, 0, sizeof(m_fileName));
+    memset(m_path, 0, sizeof(m_path));
+}
+
+MediaDebugInterface::~MediaDebugInterface()
+{
+    if (nullptr != m_configMgr)
+    {
+        MOS_Delete(m_configMgr);
+    }
+
+    if (!Mos_ResourceIsNull(&m_temp2DSurfForCopy.OsResource))
+    {
+        m_osInterface->pfnFreeResource(m_osInterface, &m_temp2DSurfForCopy.OsResource);
+    }
+}
+
+MOS_STATUS MediaDebugInterface::InitDumpLocation()
+{
+    if (m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpToThreadFolder))
+    {
+        std::string ThreadSubFolder = "T" + std::to_string(MOS_GetCurrentThreadId()) + MOS_DIRECTORY_DELIMITER;
+        m_outputFilePath            = m_outputFilePath + ThreadSubFolder;
+        MOS_CreateDirectory(const_cast<char *>(m_outputFilePath.c_str()));
+    }
+
+    m_ddiFileName = m_outputFilePath + "ddi.par";
+    std::ofstream ofs(m_ddiFileName, std::ios::out);
+    ofs << "ParamFilePath"
+        << " = \"" << m_fileName << "\"" << std::endl;
+    ofs.close();
+
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::SetOutputFilePath()
+{
+    MOS_USER_FEATURE_VALUE_DATA       userFeatureData;
+    MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData;
+    MOS_USER_FEATURE_VALUE_ID         OutputPathKey = __MOS_USER_FEATURE_KEY_INVALID_ID;
+    char                              stringData[MOS_MAX_PATH_LENGTH + 1];
+    std::string                       DumpFilePath;
+
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+#ifdef LINUX
+    char *customizedOutputPath = getenv("MOS_DEBUG_OUTPUT_LOCATION");
+    if (customizedOutputPath != nullptr && strlen(customizedOutputPath) != 0)
+    {
+        m_outputFilePath = customizedOutputPath;
+        m_outputFilePath.erase(m_outputFilePath.find_last_not_of(" \n\r\t") + 1);
+        if (m_outputFilePath[m_outputFilePath.length() - 1] != MOS_DIRECTORY_DELIMITER)
+            m_outputFilePath += MOS_DIRECTORY_DELIMITER;
+    }
+    else
+#endif
+    {
+        OutputPathKey = SetOutputPathKey();
+        MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
+        userFeatureData.StringData.pStringData = stringData;
+        MOS_UserFeature_ReadValue_ID(
+            NULL,
+            OutputPathKey,
+            &userFeatureData,
+            m_osInterface->pOsContext);
+
+        if (userFeatureData.StringData.uSize == MOS_MAX_PATH_LENGTH + 1)
+        {
+            userFeatureData.StringData.uSize = 0;
+        }
+
+        if (userFeatureData.StringData.uSize > 0)
+        {
+            if (userFeatureData.StringData.pStringData[userFeatureData.StringData.uSize - 2] != MOS_DIRECTORY_DELIMITER)
+            {
+                userFeatureData.StringData.pStringData[userFeatureData.StringData.uSize - 1] = MOS_DIRECTORY_DELIMITER;
+                userFeatureData.StringData.pStringData[userFeatureData.StringData.uSize]     = '\0';
+                userFeatureData.StringData.uSize++;
+            }
+            m_outputFilePath = userFeatureData.StringData.pStringData;
+        }
+        else
+        {
+#if defined(LINUX) || defined(ANDROID)
+            m_outputFilePath = MOS_DEBUG_DEFAULT_OUTPUT_LOCATION;
+#else
+            // Use state separation APIs to obtain appropriate storage location
+            if (SUCCEEDED(GetDriverPersistentStorageLocation(DumpFilePath)))
+            {
+                m_outputFilePath = DumpFilePath.c_str();
+                OutputPathKey    = InitDefaultOutput();
+                MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData));
+                userFeatureWriteData.Value.StringData.pStringData = const_cast<char *>(m_outputFilePath.c_str());
+                userFeatureWriteData.Value.StringData.uSize       = m_outputFilePath.size();
+                userFeatureWriteData.ValueID                      = OutputPathKey;
+                MOS_UserFeature_WriteValues_ID(NULL, &userFeatureWriteData, 1, m_osInterface->pOsContext);
+            }
+            else
+            {
+                return MOS_STATUS_UNKNOWN;
+            }
+#endif
+        }
+    }
+    return MOS_STATUS_SUCCESS;
+}
+
+bool MediaDebugInterface::DumpIsEnabled(
+    const char *              attr,
+    MEDIA_DEBUG_STATE_TYPE mediaState)
+{
+    if (nullptr == m_configMgr)
+    {
+        return false;
+    }
+
+    if (mediaState != CODECHAL_NUM_MEDIA_STATES)
+    {
+        return m_configMgr->AttrIsEnabled(mediaState, attr);
+    }
+    else
+    {
+        return m_configMgr->AttrIsEnabled(attr);
+    }
+}
+
+const char *MediaDebugInterface::CreateFileName(
+    const char *funcName,
+    const char *bufType,
+    const char *extType)
+{
+    if (nullptr == funcName || nullptr == extType)
+    {
+        return nullptr;
+    }
+
+    char frameType = 'X';
+    // Sets the frameType label
+    if (m_frameType == I_TYPE)
+    {
+        frameType = 'I';
+    }
+    else if (m_frameType == P_TYPE)
+    {
+        frameType = 'P';
+    }
+    else if (m_frameType == B_TYPE)
+    {
+        frameType = 'B';
+    }
+    else if (m_frameType == MIXED_TYPE)
+    {
+        frameType = 'M';
+    }
+
+    const char *fieldOrder;
+    // Sets the Field Order label
+    if (CodecHal_PictureIsTopField(m_currPic))
+    {
+        fieldOrder = MediaDbgFieldType::topField;
+    }
+    else if (CodecHal_PictureIsBottomField(m_currPic))
+    {
+        fieldOrder = MediaDbgFieldType::botField;
+    }
+    else
+    {
+        fieldOrder = MediaDbgFieldType::frame;
+    }
+
+    // Sets the Postfix label
+    if (m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary) &&
+        strcmp(extType, MediaDbgExtType::txt) == 0)
+    {
+        extType = MediaDbgExtType::dat;
+    }
+
+    if (bufType != nullptr &&
+        !strncmp(bufType, MediaDbgBufferType::bufSlcParams, sizeof(MediaDbgBufferType::bufSlcParams) - 1) && !strncmp(funcName, "_DDIEnc", sizeof("_DDIEnc") - 1))
+    {
+        m_outputFileName = m_outputFilePath +
+                           std::to_string(m_bufferDumpFrameNum) + '-' +
+                           std::to_string(m_streamId) + '_' +
+                           std::to_string(m_sliceId + 1) +
+                           funcName + '_' + bufType + '_' + frameType + fieldOrder + extType;
+    }
+    else if (bufType != nullptr &&
+             !strncmp(bufType, MediaDbgBufferType::bufEncodePar, sizeof(MediaDbgBufferType::bufEncodePar) - 1))
+    {
+        if (!strncmp(funcName, "EncodeSequence", sizeof("EncodeSequence") - 1))
+        {
+            m_outputFileName = m_outputFilePath +
+                               std::to_string(m_streamId) + '_' +
+                               funcName + extType;
+        }
+        else
+        {
+            m_outputFileName = m_outputFilePath +
+                               std::to_string(m_bufferDumpFrameNum) + '-' +
+                               std::to_string(m_streamId) + '_' +
+                               funcName + frameType + fieldOrder + extType;
+        }
+    }
+    else
+    {
+        if (funcName[0] == '_')
+            funcName += 1;
+
+        if (bufType != nullptr)
+        {
+            m_outputFileName = m_outputFilePath +
+                               std::to_string(m_bufferDumpFrameNum) + '-' +
+                               std::to_string(m_streamId) + '_' +
+                               funcName + '_' + bufType + '_' + frameType + fieldOrder + extType;
+        }
+        else
+        {
+            m_outputFileName = m_outputFilePath +
+                               std::to_string(m_bufferDumpFrameNum) + '-' +
+                               std::to_string(m_streamId) + '_' +
+                               funcName + '_' + frameType + fieldOrder + extType;
+        }
+    }
+
+    return m_outputFileName.c_str();
+}
+
+MOS_STATUS MediaDebugInterface::DumpCmdBuffer(
+    PMOS_COMMAND_BUFFER    cmdBuffer,
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    const char *           cmdName)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    bool attrEnabled = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrCmdBufferMfx);
+
+    if (!attrEnabled && mediaState != CODECHAL_NUM_MEDIA_STATES)
+    {
+        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attrCmdBuffer);
+    }
+
+    if (!attrEnabled)
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    bool binaryDumpEnabled = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpCmdBufInBinary);
+
+    std::string funcName = cmdName ? cmdName : m_configMgr->GetMediaStateStr(mediaState);
+    const char *fileName = CreateFileName(
+        funcName.c_str(),
+        MediaDbgBufferType::bufCmd,
+        binaryDumpEnabled ? MediaDbgExtType::dat : MediaDbgExtType::txt);
+
+    if (binaryDumpEnabled)
+    {
+        DumpBufferInBinary((uint8_t *)cmdBuffer->pCmdBase, (uint32_t)cmdBuffer->iOffset);
+    }
+    else
+    {
+        DumpBufferInHexDwords((uint8_t *)cmdBuffer->pCmdBase, (uint32_t)cmdBuffer->iOffset);
+    }
+
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::Dump2ndLvlBatch(
+    PMHW_BATCH_BUFFER      batchBuffer,
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    const char *           batchName)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    bool attrEnabled = m_configMgr->AttrIsEnabled(MediaDbgAttr::attr2ndLvlBatchMfx);
+
+    if (!attrEnabled && mediaState != CODECHAL_NUM_MEDIA_STATES)
+    {
+        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attr2ndLvlBatch);
+    }
+
+    if (!attrEnabled)
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    bool        batchLockedForDebug = !batchBuffer->bLocked;
+    std::string funcName            = batchName ? batchName : m_configMgr->GetMediaStateStr(mediaState);
+
+    if (batchLockedForDebug)
+    {
+        (Mhw_LockBb(m_osInterface, batchBuffer));
+    }
+
+    const char *fileName = CreateFileName(
+        funcName.c_str(),
+        MediaDbgBufferType::buf2ndLvl,
+        MediaDbgExtType::txt);
+
+    batchBuffer->pData += batchBuffer->dwOffset;
+
+    DumpBufferInHexDwords(batchBuffer->pData,
+        (uint32_t)batchBuffer->iLastCurrent);
+
+    if (batchLockedForDebug)
+    {
+        (Mhw_UnlockBb(m_osInterface, batchBuffer, false));
+    }
+
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DumpCurbe(
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    PMHW_KERNEL_STATE      kernelState)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    if (mediaState >= CODECHAL_NUM_MEDIA_STATES ||
+        !m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attrCurbe))
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    std::string funcName   = m_configMgr->GetMediaStateStr(mediaState);
+    bool        binaryDump = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary);
+
+    const char *fileName = CreateFileName(
+        funcName.c_str(),
+        MediaDbgBufferType::bufCurbe,
+        MediaDbgExtType::txt);
+
+    return kernelState->m_dshRegion.Dump(
+        fileName,
+        kernelState->dwCurbeOffset,
+        kernelState->KernelParams.iCurbeLength,
+        binaryDump);
+}
+
+MOS_STATUS MediaDebugInterface::DumpMDFCurbe(
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    uint8_t *              curbeBuffer,
+    uint32_t               curbeSize)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    uint8_t *  curbeAlignedData = nullptr;
+    uint32_t   curbeAlignedSize = 0;
+    MOS_STATUS eStatus          = MOS_STATUS_SUCCESS;
+
+    if (mediaState >= CODECHAL_NUM_MEDIA_STATES ||
+        !m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attrCurbe))
+    {
+        return eStatus;
+    }
+
+    std::string funcName   = m_configMgr->GetMediaStateStr(mediaState);
+    bool        binaryDump = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary);
+    const char *extType    = binaryDump ? MediaDbgExtType::dat : MediaDbgExtType::txt;
+
+    const char *fileName = CreateFileName(
+        funcName.c_str(),
+        MediaDbgBufferType::bufCurbe,
+        extType);
+
+    curbeAlignedSize = MOS_ALIGN_CEIL(curbeSize, 64);
+    curbeAlignedData = (uint8_t *)malloc(curbeAlignedSize * sizeof(uint8_t));
+    if (curbeAlignedData == nullptr)
+    {
+        eStatus = MOS_STATUS_NULL_POINTER;
+        return eStatus;
+    }
+
+    MOS_ZeroMemory(curbeAlignedData, curbeAlignedSize);
+    MOS_SecureMemcpy(curbeAlignedData, curbeSize, curbeBuffer, curbeSize);
+
+    if (binaryDump)
+    {
+        eStatus = DumpBufferInBinary(curbeAlignedData, curbeAlignedSize);
+    }
+    else
+    {
+        eStatus = DumpBufferInHexDwords(curbeAlignedData, curbeAlignedSize);
+    }
+
+    free(curbeAlignedData);
+
+    return eStatus;
+}
+
+MOS_STATUS MediaDebugInterface::DumpKernelRegion(
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    MHW_STATE_HEAP_TYPE    stateHeap,
+    PMHW_KERNEL_STATE      kernelState)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    uint8_t *sshData = nullptr;
+    uint32_t sshSize = 0;
+
+    MemoryBlock *regionBlock = nullptr;
+    bool         attrEnabled = false;
+    const char * bufferType;
+    if (stateHeap == MHW_ISH_TYPE)
+    {
+        regionBlock = &kernelState->m_ishRegion;
+        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attrIsh);
+        bufferType  = MediaDbgBufferType::bufISH;
+    }
+    else if (stateHeap == MHW_DSH_TYPE)
+    {
+        regionBlock = &kernelState->m_dshRegion;
+        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attrDsh);
+        bufferType  = MediaDbgBufferType::bufDSH;
+    }
+    else
+    {
+        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, MediaDbgAttr::attrSsh);
+        bufferType  = MediaDbgBufferType::bufSSH;
+
+        MEDIA_DEBUG_CHK_NULL(m_osInterface);
+        MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnGetIndirectStatePointer(
+            m_osInterface,
+            &sshData));
+        sshData += kernelState->dwSshOffset;
+        sshSize = kernelState->dwSshSize;
+    }
+
+    if (!attrEnabled)
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    std::string funcName = m_configMgr->GetMediaStateStr(mediaState);
+
+    const char *fileName = CreateFileName(
+        funcName.c_str(),
+        bufferType,
+        MediaDbgExtType::txt);
+
+    bool binaryDump = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary);
+
+    if (regionBlock)
+    {
+        return regionBlock->Dump(fileName, 0, 0, binaryDump);
+    }
+    else
+    {
+        return DumpBufferInHexDwords(sshData, sshSize);
+    }
+}
+
+MOS_STATUS MediaDebugInterface::DumpYUVSurface(
+    PMOS_SURFACE           surface,
+    const char *           attrName,
+    const char *           surfName,
+    MEDIA_DEBUG_STATE_TYPE mediaState,
+    uint32_t               width_in,
+    uint32_t               height_in)
+{
+    if (!DumpIsEnabled(attrName, mediaState))
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    MOS_LOCK_PARAMS lockFlags;
+    MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
+    lockFlags.ReadOnly     = 1;
+    lockFlags.TiledAsTiled = 1;  // Bypass GMM CPU blit due to some issues in GMM CpuBlt function
+
+    uint8_t *lockedAddr = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, &surface->OsResource, &lockFlags);
+    if (lockedAddr == nullptr)  // Failed to lock. Try to submit copy task and dump another surface
+    {
+        uint32_t        sizeToBeCopied = 0;
+        MOS_GFXRES_TYPE ResType;
+
+#if LINUX
+        // Linux does not have OsResource->ResType
+        ResType = surface->Type;
+#else
+        ResType = surface->OsResource.ResType;
+#endif
+
+        GMM_RESOURCE_FLAG gmmFlags  = surface->OsResource.pGmmResInfo->GetResFlags();
+        bool              allocated = false;
+
+        MEDIA_DEBUG_CHK_STATUS(ReAllocateSurface(
+            &m_temp2DSurfForCopy,
+            surface,
+            "Temp2DSurfForSurfDumper",
+            ResType));
+
+        // Ensure allocated buffer size contains the source surface size
+        if (m_temp2DSurfForCopy.OsResource.pGmmResInfo->GetSizeMainSurface() >= surface->OsResource.pGmmResInfo->GetSizeMainSurface())
+        {
+            sizeToBeCopied = (uint32_t)surface->OsResource.pGmmResInfo->GetSizeMainSurface();
+        }
+
+        if (sizeToBeCopied == 0)
+        {
+            // Currently, MOS's pfnAllocateResource does not support allocate a surface reference to another surface.
+            // When the source surface is not created from Media, it is possible that we cannot allocate the same size as source.
+            // For example, on Gen9, Render target might have GMM set CCS=1 MMC=0, but MOS cannot allocate surface with such combination.
+            // When Gmm allocation parameter is different, the resulting surface size/padding/pitch will be differnt.
+            // Once if MOS can support allocate a surface by reference another surface, we can do a bit to bit copy without problem.
+            MEDIA_DEBUG_ASSERTMESSAGE("Cannot allocate correct size, failed to copy nonlockable resource");
+            return MOS_STATUS_NULL_POINTER;
+        }
+
+        MEDIA_DEBUG_VERBOSEMESSAGE("Temp2DSurfaceForCopy width %d, height %d, pitch %d, TileType %d, bIsCompressed %d, CompressionMode %d",
+            m_temp2DSurfForCopy.dwWidth,
+            m_temp2DSurfForCopy.dwHeight,
+            m_temp2DSurfForCopy.dwPitch,
+            m_temp2DSurfForCopy.TileType,
+            m_temp2DSurfForCopy.bIsCompressed,
+            m_temp2DSurfForCopy.CompressionMode);
+
+        if (CopySurfaceData_Vdbox(sizeToBeCopied, &surface->OsResource, &m_temp2DSurfForCopy.OsResource) != MOS_STATUS_SUCCESS)
+        {
+            MEDIA_DEBUG_ASSERTMESSAGE("CopyDataSurface_Vdbox failed");
+            m_osInterface->pfnFreeResource(m_osInterface, &m_temp2DSurfForCopy.OsResource);
+            return MOS_STATUS_NULL_POINTER;
+        }
+        lockedAddr = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, &m_temp2DSurfForCopy.OsResource, &lockFlags);
+        MEDIA_DEBUG_CHK_NULL(lockedAddr);
+
+        if (DumpIsEnabled(MediaDbgAttr::attrDisableSwizzleForDumps))
+        {
+            if (CodecHal_PictureIsField(m_currPic))
+            {
+                return MOS_STATUS_INVALID_PARAMETER;
+            }
+            else
+            {
+                return DumpNotSwizzled(surfName, m_temp2DSurfForCopy, lockedAddr, sizeToBeCopied);
+            }
+        }
+    }
+
+    uint32_t sizeMain = (uint32_t)(surface->OsResource.pGmmResInfo->GetSizeMainSurface());
+    if (DumpIsEnabled(MediaDbgAttr::attrDisableSwizzleForDumps))
+    {
+        if (CodecHal_PictureIsField(m_currPic))
+        {
+            return MOS_STATUS_INVALID_PARAMETER;
+        }
+        else
+        {
+            return DumpNotSwizzled(surfName, *surface, lockedAddr, sizeMain);
+        }
+    }
+
+    uint8_t *surfBaseAddr = (uint8_t *)MOS_AllocMemory(sizeMain);
+    MEDIA_DEBUG_CHK_NULL(surfBaseAddr);
+
+    if (DumpIsEnabled(MediaDbgAttr::attrForceYUVDumpWithMemcpy))
+    {
+        MOS_SecureMemcpy(surfBaseAddr, sizeMain, lockedAddr, sizeMain);  // Firstly, copy to surfBaseAddr to faster unlock resource
+        m_osInterface->pfnUnlockResource(m_osInterface, &surface->OsResource);
+        lockedAddr   = surfBaseAddr;
+        surfBaseAddr = (uint8_t *)MOS_AllocMemory(sizeMain);
+        MEDIA_DEBUG_CHK_NULL(surfBaseAddr);
+    }
+
+    // Always use MOS swizzle instead of GMM Cpu blit
+    MEDIA_DEBUG_CHK_NULL(surfBaseAddr);
+    Mos_SwizzleData(lockedAddr, surfBaseAddr, surface->TileType, MOS_TILE_LINEAR, sizeMain / surface->dwPitch, surface->dwPitch, 0);
+
+    uint8_t *data = surfBaseAddr;
+    data += surface->dwOffset + surface->YPlaneOffset.iYOffset * surface->dwPitch;
+
+    uint32_t width  = width_in ? width_in : surface->dwWidth;
+    uint32_t height = height_in ? height_in : surface->dwHeight;
+
+    switch (surface->Format)
+    {
+    case Format_YUY2:
+    case Format_Y216V:
+    case Format_P010:
+    case Format_P016:
+        width = width << 1;
+        break;
+    case Format_Y216:
+    case Format_Y210:  //422 10bit -- Y0[15:0]:U[15:0]:Y1[15:0]:V[15:0] = 32bits per pixel = 4Bytes per pixel
+    case Format_Y410:  //444 10bit -- A[31:30]:V[29:20]:Y[19:10]:U[9:0] = 32bits per pixel = 4Bytes per pixel
+    case Format_R10G10B10A2:
+    case Format_AYUV:  //444 8bit  -- A[31:24]:Y[23:16]:U[15:8]:V[7:0] = 32bits per pixel = 4Bytes per pixel
+    case Format_A8R8G8B8:
+        width = width << 2;
+        break;
+    default:
+        break;
+    }
+
+    uint32_t pitch = surface->dwPitch;
+    if (surface->Format == Format_UYVY)
+        pitch = width;
+
+    if (CodecHal_PictureIsBottomField(m_currPic))
+    {
+        data += pitch;
+    }
+
+    if (CodecHal_PictureIsField(m_currPic))
+    {
+        pitch *= 2;
+        height /= 2;
+    }
+
+    const char *funcName = (m_mediafunction == MEDIA_FUNCTION_VP) ? "_VP" : ((m_mediafunction == MEDIA_FUNCTION_ENCODE) ? "_ENC" : "_DEC");
+    std::string bufName  = std::string(surfName) + "_w[" + std::to_string(surface->dwWidth) + "]_h[" + std::to_string(surface->dwHeight) + "]_p[" + std::to_string(pitch) + "]";
+    const char *filePath = CreateFileName(funcName, bufName.c_str(), MediaDbgExtType::yuv);
+
+    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
+    if (ofs.fail())
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    // write luma data to file
+    for (uint32_t h = 0; h < height; h++)
+    {
+        ofs.write((char *)data, width);
+        data += pitch;
+    }
+
+    if (surface->Format != Format_A8B8G8R8)
+    {
+        switch (surface->Format)
+        {
+        case Format_NV12:
+        case Format_P010:
+        case Format_P016:
+            height >>= 1;
+            break;
+        case Format_Y416:
+        case Format_AUYV:
+        case Format_R10G10B10A2:
+            height *= 2;
+            break;
+        case Format_YUY2:
+        case Format_YUYV:
+        case Format_YUY2V:
+        case Format_Y216V:
+        case Format_YVYU:
+        case Format_UYVY:
+        case Format_VYUY:
+        case Format_Y216:  //422 16bit
+        case Format_Y210:  //422 10bit
+        case Format_P208:  //422 8bit
+            break;
+        case Format_422V:
+        case Format_IMC3:
+            height = height / 2;
+            break;
+        case Format_AYUV:
+        default:
+            height = 0;
+            break;
+        }
+
+        uint8_t *vPlaneData = surfBaseAddr;
+#ifdef LINUX
+        data = surfBaseAddr + surface->UPlaneOffset.iSurfaceOffset;
+        if (surface->Format == Format_422V || surface->Format == Format_IMC3)
+        {
+            vPlaneData = surfBaseAddr + surface->VPlaneOffset.iSurfaceOffset;
+        }
+#else
+        data = surfBaseAddr + surface->UPlaneOffset.iLockSurfaceOffset;
+        if (surface->Format == Format_422V || surface->Format == Format_IMC3)
+        {
+            vPlaneData = surfBaseAddr + surface->VPlaneOffset.iLockSurfaceOffset;
+        }
+
+#endif
+
+        // write chroma data to file
+        for (uint32_t h = 0; h < height; h++)
+        {
+            ofs.write((char *)data, width);
+            data += pitch;
+        }
+
+        // write v planar data to file
+        if (surface->Format == Format_422V || surface->Format == Format_IMC3)
+        {
+            for (uint32_t h = 0; h < height; h++)
+            {
+                ofs.write((char *)vPlaneData, width);
+                vPlaneData += pitch;
+            }
+        }
+    }
+    ofs.close();
+
+    if (DumpIsEnabled(MediaDbgAttr::attrForceYUVDumpWithMemcpy))
+    {
+        MOS_FreeMemory(lockedAddr);
+    }
+    else
+    {
+        m_osInterface->pfnUnlockResource(m_osInterface, &surface->OsResource);
+    }
+    MOS_FreeMemory(surfBaseAddr);
+
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DumpBuffer(
+    PMOS_RESOURCE          resource,
+    const char *           attrName,
+    const char *           bufferName,
+    uint32_t               size,
+    uint32_t               offset,
+    MEDIA_DEBUG_STATE_TYPE mediaState)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    MEDIA_DEBUG_CHK_NULL(resource);
+    MEDIA_DEBUG_CHK_NULL(bufferName);
+
+    if (size == 0)
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    if (attrName)
+    {
+        bool attrEnabled = false;
+
+        if (mediaState == CODECHAL_NUM_MEDIA_STATES)
+        {
+            attrEnabled = m_configMgr->AttrIsEnabled(attrName);
+        }
+        else
+        {
+            attrEnabled = m_configMgr->AttrIsEnabled(mediaState, attrName);
+        }
+
+        if (!attrEnabled)
+        {
+            return MOS_STATUS_SUCCESS;
+        }
+    }
+
+    MOS_LOCK_PARAMS lockFlags;
+    MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
+    lockFlags.ReadOnly = 1;
+    uint8_t *data      = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, resource, &lockFlags);
+    MEDIA_DEBUG_CHK_NULL(data);
+    data += offset;
+
+    const char *fileName;
+    bool        binaryDump = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary);
+    const char *extType    = binaryDump ? MediaDbgExtType::dat : MediaDbgExtType::txt;
+
+    if (mediaState == CODECHAL_NUM_MEDIA_STATES)
+    {
+        fileName = CreateFileName(bufferName, attrName, extType);
+    }
+    else
+    {
+        std::string kernelName = m_configMgr->GetMediaStateStr(mediaState);
+        fileName               = CreateFileName(kernelName.c_str(), bufferName, extType);
+    }
+
+    MOS_STATUS status;
+    if (binaryDump)
+    {
+        status = DumpBufferInBinary(data, size);
+    }
+    else
+    {
+        status = DumpBufferInHexDwords(data, size);
+    }
+
+    if (data)
+    {
+        m_osInterface->pfnUnlockResource(m_osInterface, resource);
+    }
+
+    return status;
+}
+
+MOS_STATUS MediaDebugInterface::DumpSurface(
+    PMOS_SURFACE              surface,
+    const char *              attrName,
+    const char *              surfaceName,
+    MEDIA_DEBUG_STATE_TYPE    mediaState)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    MEDIA_DEBUG_CHK_NULL(surface);
+    MEDIA_DEBUG_CHK_NULL(attrName);
+    MEDIA_DEBUG_CHK_NULL(surfaceName);
+
+    bool attrEnabled = false;
+
+    if (mediaState == CODECHAL_NUM_MEDIA_STATES)
+    {
+        attrEnabled = m_configMgr->AttrIsEnabled(attrName);
+    }
+    else
+    {
+        attrEnabled = m_configMgr->AttrIsEnabled(mediaState, attrName);
+    }
+
+    if (!attrEnabled)
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    bool        binaryDump = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary);
+    const char *extType    = binaryDump ? MediaDbgExtType::dat : MediaDbgExtType::txt;
+
+    MOS_LOCK_PARAMS lockFlags;
+    MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
+    lockFlags.ReadOnly = 1;
+    uint8_t *data      = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, &surface->OsResource, &lockFlags);
+    MEDIA_DEBUG_CHK_NULL(data);
+
+    std::string bufName = std::string(surfaceName) + "_w[" + std::to_string(surface->dwWidth) + "]_h[" + std::to_string(surface->dwHeight) + "]_p[" + std::to_string(surface->dwPitch) + "]";
+    const char *fileName;
+    if (mediaState == CODECHAL_NUM_MEDIA_STATES)
+    {
+        fileName = CreateFileName(bufName.c_str(), nullptr, extType);
+    }
+    else
+    {
+        std::string kernelName = m_configMgr->GetMediaStateStr(mediaState);
+        fileName               = CreateFileName(kernelName.c_str(), bufName.c_str(), extType);
+    }
+
+    MOS_STATUS status;
+    if (binaryDump)
+    {
+        status = Dump2DBufferInBinary(data, surface->dwWidth, surface->dwHeight, surface->dwPitch);
+    }
+    else
+    {
+        status = DumpBufferInHexDwords(data, surface->dwHeight * surface->dwPitch);
+    }
+
+    if (data)
+    {
+        m_osInterface->pfnUnlockResource(m_osInterface, &surface->OsResource);
+    }
+
+    return status;
+}
+
+MOS_STATUS MediaDebugInterface::DumpData(
+    void *      data,
+    uint32_t    size,
+    const char *attrName,
+    const char *bufferName)
+{
+    MEDIA_DEBUG_FUNCTION_ENTER;
+
+    MEDIA_DEBUG_CHK_NULL(data);
+    MEDIA_DEBUG_CHK_NULL(attrName);
+    MEDIA_DEBUG_CHK_NULL(bufferName);
+
+    if (!m_configMgr->AttrIsEnabled(attrName))
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+
+    bool        binaryDump = m_configMgr->AttrIsEnabled(MediaDbgAttr::attrDumpBufferInBinary);
+    const char *fileName   = CreateFileName(bufferName, nullptr, binaryDump ? MediaDbgExtType::dat : MediaDbgExtType::txt);
+
+    if (binaryDump)
+    {
+        DumpBufferInBinary((uint8_t *)data, size);
+    }
+    else
+    {
+        DumpBufferInHexDwords((uint8_t *)data, size);
+    }
+
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DumpBltOutput(
+    PMOS_SURFACE surface,
+    const char * attrName)
+{
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DeleteCfgLinkNode(uint32_t frameIdx)
+{
+    return m_configMgr->DeleteCfgNode(frameIdx);
+}
+
+MOS_STATUS MediaDebugInterface::ReAllocateSurface(
+    PMOS_SURFACE    pSurface,
+    PMOS_SURFACE    pSrcSurf,
+    PCCHAR          pSurfaceName,
+    MOS_GFXRES_TYPE DefaultResType)
+{
+    MOS_ALLOC_GFXRES_PARAMS AllocParams;
+
+    MEDIA_DEBUG_ASSERT(m_osInterface);
+    MEDIA_DEBUG_ASSERT(&pSurface->OsResource);
+
+    // bCompressible should be compared with bCompressible since it is inited by bCompressible in previous call
+    // TileType of surface should be compared since we need to reallocate surface if TileType changes
+    if (!Mos_ResourceIsNull(&pSurface->OsResource) &&
+        (pSurface->dwWidth == pSrcSurf->dwWidth) &&
+        (pSurface->dwHeight == pSrcSurf->dwHeight) &&
+        (pSurface->Format == pSrcSurf->Format) &&
+        (pSurface->bCompressible == pSrcSurf->bCompressible) &&
+        (pSurface->CompressionMode == pSrcSurf->CompressionMode) &&
+        (pSurface->TileType == pSrcSurf->TileType))
+    {
+        return MOS_STATUS_SUCCESS;
+    }
+    MOS_ZeroMemory(&AllocParams, sizeof(MOS_ALLOC_GFXRES_PARAMS));
+
+#if !EMUL
+    //  Need to reallocate surface according to expected tiletype instead of tiletype of the surface what we have
+    if ((pSurface->OsResource.pGmmResInfo != nullptr) &&
+        (pSurface->TileType == pSrcSurf->TileType))
+    {
+        // Reallocate but use same tile type and resource type as current
+        AllocParams.TileType = pSurface->OsResource.TileType;
+        AllocParams.Type     = DefaultResType;
+    }
+    else
+#endif
+    {
+        // First time allocation. Caller must specify default params
+        AllocParams.TileType = pSrcSurf->TileType;
+        AllocParams.Type     = DefaultResType;
+    }
+
+    AllocParams.dwWidth         = pSrcSurf->dwWidth;
+    AllocParams.dwHeight        = pSrcSurf->dwHeight;
+    AllocParams.Format          = pSrcSurf->Format;
+    AllocParams.bIsCompressible = pSrcSurf->bCompressible;
+    AllocParams.CompressionMode = pSrcSurf->CompressionMode;
+    AllocParams.pBufName        = pSurfaceName;
+    AllocParams.dwArraySize     = 1;
+
+    // Delete resource if already allocated
+    m_osInterface->pfnFreeResource(m_osInterface, &(pSurface->OsResource));
+
+    // Allocate surface
+    CODECHAL_PUBLIC_CHK_STATUS_RETURN(m_osInterface->pfnAllocateResource(
+        m_osInterface,
+        &AllocParams,
+        &pSurface->OsResource));
+
+    pSurface->dwWidth         = pSrcSurf->dwWidth;
+    pSurface->dwHeight        = pSrcSurf->dwHeight;
+    pSurface->dwPitch         = pSrcSurf->dwPitch;
+    pSurface->dwDepth         = pSrcSurf->dwDepth;
+    pSurface->dwQPitch        = pSrcSurf->dwQPitch;
+    pSurface->bArraySpacing   = pSrcSurf->bArraySpacing;
+    pSurface->bCompressible   = pSrcSurf->bCompressible;
+    pSurface->CompressionMode = pSrcSurf->CompressionMode;
+    pSurface->bIsCompressed   = pSrcSurf->bIsCompressed;
+
+    if (!m_osInterface->apoMosEnabled)
+    {
+        MOS_SURFACE details;
+        MOS_ZeroMemory(&details, sizeof(details));
+        details.Format = Format_Invalid;
+
+        MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnGetResourceInfo(m_osInterface, &pSurface->OsResource, &details));
+
+        pSurface->Format                      = details.Format;
+        pSurface->TileType                    = details.TileType;
+        pSurface->dwOffset                    = details.RenderOffset.YUV.Y.BaseOffset;
+        pSurface->YPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.Y.BaseOffset;
+        pSurface->YPlaneOffset.iXOffset       = details.RenderOffset.YUV.Y.XOffset;
+        pSurface->YPlaneOffset.iYOffset =
+            (pSurface->YPlaneOffset.iSurfaceOffset - pSurface->dwOffset) / pSurface->dwPitch +
+            details.RenderOffset.YUV.Y.YOffset;
+        pSurface->UPlaneOffset.iSurfaceOffset = details.RenderOffset.YUV.U.BaseOffset;
+        pSurface->UPlaneOffset.iXOffset       = details.RenderOffset.YUV.U.XOffset;
+        pSurface->UPlaneOffset.iYOffset =
+            (pSurface->UPlaneOffset.iSurfaceOffset - pSurface->dwOffset) / pSurface->dwPitch +
+            details.RenderOffset.YUV.U.YOffset;
+        pSurface->UPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.U;
+        pSurface->VPlaneOffset.iSurfaceOffset     = details.RenderOffset.YUV.V.BaseOffset;
+        pSurface->VPlaneOffset.iXOffset           = details.RenderOffset.YUV.V.XOffset;
+        pSurface->VPlaneOffset.iYOffset =
+            (pSurface->VPlaneOffset.iSurfaceOffset - pSurface->dwOffset) / pSurface->dwPitch +
+            details.RenderOffset.YUV.V.YOffset;
+        pSurface->VPlaneOffset.iLockSurfaceOffset = details.LockOffset.YUV.V;
+    }
+    else
+    {
+        pSurface->Format = Format_Invalid;
+        MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnGetResourceInfo(m_osInterface, &pSurface->OsResource, pSurface));
+    }
+
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::CopySurfaceData_Vdbox(
+    uint32_t      dwDataSize,
+    PMOS_RESOURCE presSourceSurface,
+    PMOS_RESOURCE presCopiedSurface)
+{
+    MOS_COMMAND_BUFFER        CmdBuffer;
+    MHW_MI_FLUSH_DW_PARAMS    FlushDwParams;
+    MHW_GENERIC_PROLOG_PARAMS genericPrologParams;
+    MHW_CP_COPY_PARAMS        cpCopyParams;
+    MOS_NULL_RENDERING_FLAGS  NullRenderingFlags;
+    MOS_GPU_CONTEXT           orgGpuContext;
+
+    if (!m_vdboxContextCreated)
+    {
+        MOS_GPUCTX_CREATOPTIONS createOption;
+
+        MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnCreateGpuContext(
+            m_osInterface,
+            MOS_GPU_CONTEXT_VIDEO,
+            MOS_GPU_NODE_VIDEO,
+            &createOption));
+
+        // Register VDbox GPU context with the Batch Buffer completion event
+        MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterBBCompleteNotifyEvent(
+            m_osInterface,
+            MOS_GPU_CONTEXT_VIDEO));
+
+        m_vdboxContextCreated = true;
+    }
+
+    MEDIA_DEBUG_CHK_NULL(m_cpInterface);
+    MEDIA_DEBUG_CHK_NULL(m_osInterface);
+    MEDIA_DEBUG_CHK_NULL(m_miInterface);
+    MEDIA_DEBUG_CHK_NULL(m_osInterface->pfnGetWaTable(m_osInterface));
+
+    orgGpuContext = m_osInterface->CurrentGpuContextOrdinal;
+
+    // Due to VDBOX cryto copy limitation, the size must be Cache line aligned
+    if (!MOS_IS_ALIGNED(dwDataSize, MHW_CACHELINE_SIZE))
+    {
+        MEDIA_DEBUG_ASSERTMESSAGE("Size is not CACHE line aligned, cannot use VDBOX to copy.");
+        return MOS_STATUS_INVALID_PARAMETER;
+    }
+
+    MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSetGpuContext(m_osInterface, MOS_GPU_CONTEXT_VIDEO));
+    m_osInterface->pfnResetOsStates(m_osInterface);
+
+    // Register the target resource
+    MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterResource(
+        m_osInterface,
+        presCopiedSurface,
+        true,
+        true));
+
+    // Register the source resource
+    MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnRegisterResource(
+        m_osInterface,
+        presSourceSurface,
+        false,
+        true));
+
+    MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnGetCommandBuffer(m_osInterface, &CmdBuffer, 0));
+
+    MOS_ZeroMemory(&genericPrologParams, sizeof(genericPrologParams));
+    genericPrologParams.pOsInterface  = m_osInterface;
+    genericPrologParams.pvMiInterface = m_miInterface;
+    genericPrologParams.bMmcEnabled   = false;
+    MEDIA_DEBUG_CHK_STATUS(Mhw_SendGenericPrologCmd(&CmdBuffer, &genericPrologParams));
+
+    MOS_ZeroMemory(&cpCopyParams, sizeof(cpCopyParams));
+    cpCopyParams.size          = dwDataSize;
+    cpCopyParams.presSrc       = presSourceSurface;
+    cpCopyParams.presDst       = presCopiedSurface;
+    cpCopyParams.isEncodeInUse = false;
+
+    MEDIA_DEBUG_CHK_STATUS(m_cpInterface->SetCpCopy(m_osInterface, &CmdBuffer, &cpCopyParams));
+
+    // MI_FLUSH
+    MOS_ZeroMemory(&FlushDwParams, sizeof(FlushDwParams));
+    MEDIA_DEBUG_CHK_STATUS(m_miInterface->AddMiFlushDwCmd(
+        &CmdBuffer,
+        &FlushDwParams));
+
+    MEDIA_DEBUG_CHK_STATUS(m_miInterface->AddMiBatchBufferEnd(
+        &CmdBuffer,
+        nullptr));
+
+    m_osInterface->pfnReturnCommandBuffer(m_osInterface, &CmdBuffer, 0);
+
+    NullRenderingFlags = m_osInterface->pfnGetNullHWRenderFlags(m_osInterface);
+
+    MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSubmitCommandBuffer(
+        m_osInterface,
+        &CmdBuffer,
+        NullRenderingFlags.CtxVideo || NullRenderingFlags.CodecGlobal || NullRenderingFlags.CtxVideo || NullRenderingFlags.VPGobal));
+
+    MEDIA_DEBUG_CHK_STATUS(m_osInterface->pfnSetGpuContext(m_osInterface, orgGpuContext));
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DumpNotSwizzled(
+    std::string  surfName,
+    MOS_SURFACE &surf,
+    uint8_t *    lockedAddr,
+    int32_t      size)
+{
+    const char *funcName = (m_mediafunction == MEDIA_FUNCTION_VP) ? "_VP" : ((m_mediafunction == MEDIA_FUNCTION_ENCODE) ? "_ENC" : "_DEC");
+    int         YOffset  = surf.dwOffset + surf.YPlaneOffset.iYOffset * surf.dwPitch;
+
+#ifdef LINUX
+    int UOffset = surf.UPlaneOffset.iSurfaceOffset;
+    int VOffset = surf.VPlaneOffset.iSurfaceOffset;
+#else
+    int UOffset = surf.UPlaneOffset.iLockSurfaceOffset;
+    int VOffset = surf.VPlaneOffset.iLockSurfaceOffset;
+#endif
+
+    std::string bufName = std::string(surfName) + "NotSwizzled_format[" + std::to_string((int)surf.Format) + "]_w[" + std::to_string(surf.dwWidth) + "]_h[" + std::to_string(surf.dwHeight) + "]_p[" + std::to_string(surf.dwPitch) + "]_srcTiling[" + std::to_string((int)surf.TileType) + "]_sizeMain[" + std::to_string(size) + "]_YOffset[" + std::to_string(YOffset) + "]_UOffset[" + std::to_string(UOffset) + "]_VOffset[" + std::to_string(VOffset) + "]";
+
+    const char *  filePath = CreateFileName(funcName, bufName.c_str(), MediaDbgExtType::yuv);
+    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
+    if (ofs.fail())
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    uint8_t *data = lockedAddr;
+    ofs.write((char *)data, size);
+    ofs.close();
+
+    m_osInterface->pfnUnlockResource(m_osInterface, &surf.OsResource);
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::Dump2DBufferInBinary(
+    uint8_t *data,
+    uint32_t width,
+    uint32_t height,
+    uint32_t pitch)
+{
+    MEDIA_DEBUG_CHK_NULL(data);
+
+    const char *filePath = m_outputFileName.c_str();
+
+    if (width == 0 || height == 0 || pitch == 0)
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
+    if (ofs.fail())
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    for (uint32_t h = 0; h < height; h++)
+    {
+        ofs.write((char *)data, width);
+        data += pitch;
+    }
+
+    ofs.close();
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DumpBufferInBinary(uint8_t *data, uint32_t size)
+{
+    MEDIA_DEBUG_CHK_NULL(data);
+
+    const char *filePath = m_outputFileName.c_str();
+
+    if (size == 0)
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    std::ofstream ofs(filePath, std::ios_base::out | std::ios_base::binary);
+    if (ofs.fail())
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    ofs.write((char *)data, size);
+    ofs.close();
+    return MOS_STATUS_SUCCESS;
+}
+
+MOS_STATUS MediaDebugInterface::DumpBufferInHexDwords(uint8_t *data, uint32_t size)
+{
+    MEDIA_DEBUG_CHK_NULL(data);
+
+    const char *filePath = m_outputFileName.c_str();
+
+    if (size == 0)
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    std::ofstream ofs(filePath);
+
+    if (ofs.fail())
+    {
+        return MOS_STATUS_UNKNOWN;
+    }
+
+    uint32_t dwordSize  = size / sizeof(uint32_t);
+    uint32_t remainSize = size % sizeof(uint32_t);
+
+    uint32_t *dwordData = (uint32_t *)data;
+    uint32_t  i;
+    for (i = 0; i < dwordSize; i++)
+    {
+        ofs << std::hex << std::setw(8) << std::setfill('0') << +dwordData[i] << " ";
+        if (i % 4 == 3)
+        {
+            ofs << std::endl;
+        }
+    }
+
+    if (remainSize > 0)
+    {
+        uint32_t lastWord = dwordData[i] & (0xFFFFFFFF << ((8 - remainSize * 2) * 4));
+        ofs << std::hex << std::setw(8) << std::setfill('0') << +lastWord << std::endl;
+    }
+
+    ofs.close();
+
+    return MOS_STATUS_SUCCESS;
+}
+
+#endif  // USE_MEDIA_DEBUG_TOOL
diff --git a/media_driver/agnostic/common/shared/media_debug_interface.h b/media_driver/agnostic/common/shared/media_debug_interface.h
new file mode 100644
index 0000000..12cbf4a
--- /dev/null
+++ b/media_driver/agnostic/common/shared/media_debug_interface.h
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     media_debug_interface.h
+//! \brief    Defines the debug interface shared by all of Media.
+//! \details  The debug interface dumps output from Media based on input config file.
+//!
+#ifndef __MEDIA_DEBUG_INTERFACE_H__
+#define __MEDIA_DEBUG_INTERFACE_H__
+
+#if (_DEBUG || _RELEASE_INTERNAL)
+#define USE_MEDIA_DEBUG_TOOL 1
+#define MEDIA_DEBUG_TOOL(expr) expr;
+
+#include "BRCIF.h"
+#include "mhw_utilities.h"
+#include "mhw_state_heap.h"
+#include "media_debug_config_manager.h"
+#include "media_debug_utils.h"
+#include <sstream>
+#include <fstream>
+
+class MediaDebugInterface
+{
+public:
+    MediaDebugInterface();
+    virtual ~MediaDebugInterface();
+
+    MOS_STATUS InitDumpLocation();
+
+    bool DumpIsEnabled(
+        const char *           attr,
+        MEDIA_DEBUG_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES);
+
+    const char *CreateFileName(
+        const char *funcName,
+        const char *bufType,
+        const char *extType);
+
+    MOS_STATUS SetOutputFilePath();
+
+    MOS_STATUS DumpCmdBuffer(
+        PMOS_COMMAND_BUFFER    cmdBuffer,
+        MEDIA_DEBUG_STATE_TYPE mediaState,
+        const char *           cmdName = nullptr);
+
+    MOS_STATUS Dump2ndLvlBatch(
+        PMHW_BATCH_BUFFER      batchBuffer,
+        MEDIA_DEBUG_STATE_TYPE mediaState,
+        const char *           batchName = nullptr);
+
+    MOS_STATUS DumpCurbe(
+        MEDIA_DEBUG_STATE_TYPE mediaState,
+        PMHW_KERNEL_STATE      kernelState);
+
+    MOS_STATUS DumpMDFCurbe(
+        MEDIA_DEBUG_STATE_TYPE mediaState,
+        uint8_t *              curbeBuffer,
+        uint32_t               curbeSize);
+
+    MOS_STATUS DumpKernelRegion(
+        MEDIA_DEBUG_STATE_TYPE mediaState,
+        MHW_STATE_HEAP_TYPE    stateHeapType,
+        PMHW_KERNEL_STATE      kernelState);
+
+    virtual MOS_STATUS DumpYUVSurface(
+        PMOS_SURFACE           surface,
+        const char *           attrName,
+        const char *           surfName,
+        MEDIA_DEBUG_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES,
+        uint32_t               width_in   = 0,
+        uint32_t               height_in  = 0);
+
+    MOS_STATUS DumpBuffer(
+        PMOS_RESOURCE          resource,
+        const char *           attrName,
+        const char *           bufferName,
+        uint32_t               size,
+        uint32_t               offset = 0,
+        MEDIA_DEBUG_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES);
+
+    MOS_STATUS DumpSurface(
+        PMOS_SURFACE           surface,
+        const char *           attrName,
+        const char *           surfaceName,
+        MEDIA_DEBUG_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES);
+
+    MOS_STATUS DumpData(
+        void       *data,
+        uint32_t   size,
+        const char *attrName,
+        const char *bufferName);
+
+    MOS_STATUS DumpBufferInHexDwords(
+        uint8_t *data,
+        uint32_t size);
+
+    virtual MOS_STATUS DumpBltOutput(
+        PMOS_SURFACE surface,
+        const char * attrName);
+
+    MOS_STATUS DeleteCfgLinkNode(uint32_t frameIdx);
+
+    std::string m_ddiFileName;
+    std::string m_outputFilePath;
+
+    MOS_SURFACE       m_temp2DSurfForCopy = {};
+    PMOS_INTERFACE    m_osInterface       = nullptr;
+    MhwCpInterface   *m_cpInterface       = nullptr;
+    MhwMiInterface   *m_miInterface       = nullptr;
+    MediaDbgFunction  m_mediafunction     = MEDIA_FUNCTION_DEFAULT;
+    CODEC_PICTURE     m_currPic;
+    uint32_t          m_scaledBottomFieldOffset = 0;
+    uint16_t          m_frameType               = 0;
+    uint32_t          m_sliceId                 = 0;  // used for constructing debug file name
+    char              m_fileName[MOS_MAX_PATH_LENGTH + 1];
+    char              m_path[MOS_MAX_PATH_LENGTH + 1];
+    bool              m_secondField              = false;
+    bool              m_hybridPakP1              = false;
+    bool              m_hybridVp8EncodeBrcEnable = false;
+    bool              m_hybridVp9EncodeEnable    = false;
+    bool              m_vdboxContextCreated      = false;
+    uint16_t          m_preIndex                 = 0;
+    uint16_t          m_refIndex                 = 0;
+    uint32_t          m_bufferDumpFrameNum       = 0;
+    uint32_t          m_decodeSurfDumpFrameNum   = 0;
+    uint32_t          m_streamId                 = 0;
+
+protected:
+    MOS_STATUS ReAllocateSurface(
+        PMOS_SURFACE    pSurface,
+        PMOS_SURFACE    pSrcSurf,
+        PCCHAR          pSurfaceName,
+        MOS_GFXRES_TYPE DefaultResType);
+
+    MOS_STATUS CopySurfaceData_Vdbox(
+        uint32_t      dwDataSize,
+        PMOS_RESOURCE presSourceSurface,
+        PMOS_RESOURCE presCopiedSurface);
+
+    MOS_STATUS DumpNotSwizzled(
+        std::string  surfName,
+        MOS_SURFACE &surf,
+        uint8_t *    lockedAddr,
+        int32_t      size);
+
+    MOS_STATUS DumpBufferInBinary(
+        uint8_t *data,
+        uint32_t size);
+
+    MOS_STATUS Dump2DBufferInBinary(
+        uint8_t *data,
+        uint32_t width,
+        uint32_t height,
+        uint32_t pitch);
+
+    virtual MOS_USER_FEATURE_VALUE_ID SetOutputPathKey()  = 0;
+    virtual MOS_USER_FEATURE_VALUE_ID InitDefaultOutput() = 0;
+
+    std::string          m_outputFileName;
+    MediaDebugConfigMgr *m_configMgr = nullptr;
+};
+
+#else
+#define USE_MEDIA_DEBUG_TOOL 0
+#define MEDIA_DEBUG_TOOL(expr) ;
+
+#endif  // (_DEBUG || _RELEASE_INTERNAL)
+#endif /* __MEDIA_DEBUG_INTERFACE_H__ */
\ No newline at end of file
diff --git a/media_driver/agnostic/common/shared/media_debug_utils.h b/media_driver/agnostic/common/shared/media_debug_utils.h
new file mode 100644
index 0000000..64df883
--- /dev/null
+++ b/media_driver/agnostic/common/shared/media_debug_utils.h
@@ -0,0 +1,351 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     media_debug_utils.h
+//! \brief    Defines the debug interface utilities shared by all of Media.
+//! \details  The debug interface dumps output from Media based on in input config file.
+//!
+#ifndef __MEDIA_DEBUG_UTILS_H__
+#define __MEDIA_DEBUG_UTILS_H__
+
+#if USE_MEDIA_DEBUG_TOOL
+#include <string>
+#include <map>
+#include <vector>
+#include "mos_defs.h"
+#include "codechal_hw.h"
+
+typedef CODECHAL_MEDIA_STATE_TYPE MEDIA_DEBUG_STATE_TYPE;
+
+namespace MediaDbgAttr
+{
+//Common Attr
+static const char *attrDumpBufferInBinary = "DumpBufferInBinary";
+static const char *attrDumpToThreadFolder = "DumpToThreadFolder";
+static const char *attrDumpCmdBufInBinary = "DumpCmdBufInBinary";
+
+//Codec Attr 
+static const char *attrPicParams              = "PicParams";
+static const char *attrSubsetsParams          = "SubsetsParams";
+static const char *attrFeiPicParams           = "FeiPicParams";
+static const char *attrMvcExtPicParams        = "MvcExtPicParams";
+static const char *attrSegmentParams          = "SegmentParams";
+static const char *attrSlcParams              = "SlcParams";
+static const char *attrMbParams               = "MbParams";
+static const char *attrIqParams               = "IqParams";
+static const char *attrSeqParams              = "SeqParams";
+static const char *attrVuiParams              = "VuiParams";
+static const char *attrBitstream              = "Bitstream";
+static const char *attrStreamOut              = "StreamOut";
+static const char *attrStreamIn               = "StreamIn";
+static const char *attrResidualDifference     = "ResidualDifference";
+static const char *attrDeblocking             = "Deblocking";
+static const char *attrMvData                 = "MvData";
+static const char *attrVc1Bitplane            = "Vc1Bitplane";
+static const char *attrCoefProb               = "CoefProb";
+static const char *attrSegId                  = "SegId";
+static const char *attrHucRegions             = "HucRegions";
+static const char *attrHuCDmem                = "HucDmem";
+static const char *attrCmdBufferMfx           = "CmdBufferMfx";
+static const char *attr2ndLvlBatchMfx         = "2ndLvlBatchMfx";
+static const char *attrDecodeOutputSurface    = "DecodeOutputSurface";
+static const char *attrDecodeAuxSurface       = "DumpAuxsurface";
+static const char *attrDecodeBltOutput        = "DumpBltOutput";
+static const char *attrSfcOutputSurface       = "SfcOutputSurface";
+static const char *attrSfcBuffers             = "SfcBuffers";
+static const char *attrReferenceSurfaces      = "ReferenceSurfaces";
+static const char *attrEncodeRawInputSurface  = "EncodeRawInputSurface";
+static const char *attrReconstructedSurface   = "ReconstructedSurface";
+static const char *attrPakInput               = "PakInput";
+static const char *attrPakOutput              = "PakOutput";
+static const char *attrUpsamlingInput         = "UpsamplingInput";
+static const char *attrResidualSurface        = "ResidualSurface";
+static const char *attrStCoeff                = "StCoeff";
+static const char *attrCoeffPredCs            = "CoeffPredCs";
+static const char *attrMbRecord               = "MbRecord";
+static const char *attrOverwriteCommands      = "OverwriteCommands";
+static const char *attrHuffmanTbl             = "HuffmanTbl";
+static const char *attrScanParams             = "ScanParams";
+static const char *attrDriverUltDump          = "DriverUltDump";
+
+static const char *attrDumpEncodePar          = "DumpEncodePar";
+static const char *attrForceCmdDumpLvl        = "ForceCmdDumpLvl";
+static const char *attrForceCurbeDumpLvl      = "ForceCurbeDumpLvl";
+static const char *attrForceYUVDumpWithMemcpy = "ForceYUVDumpWithMemcpy";
+static const char *attrDisableSwizzleForDumps = "DisableSwizzleForDumps";
+static const char *attrVdencOutput            = "VdencOutput";
+static const char *attrDecodeProcParams       = "DecodeProcParams";
+static const char *attrFrameState             = "FrameState";
+static const char *attrCUStreamout            = "CUStreamout";
+static const char *attrBrcPakStats            = "BrcPakStats";
+static const char *attrImageState             = "ImageState";
+static const char *attrSliceSizeStreamout     = "SliceSizeStreamout";
+static const char *attrCoeffProb              = "PakHwCoeffProbs";
+static const char *attrStatusReport           = "StatusReport";
+static const char *attrPakObjStreamout        = "PakObjStreamOut";
+static const char *attrTileBasedStats         = "TileBasedStats";
+static const char *attrROISurface             = "ROIInput";
+static const char *attrHuCStitchDataBuf       = "HuCStitchDataBuffer";
+static const char *attrInitSWScoreboard       = "InitSWScoreboard";
+static const char *attrSfcHistogram           = "SfcHistogram";
+static const char *attrFilmGrain              = "FilmGrain";
+
+// MD5 attributes
+static const char *attrMD5HashEnable    = "MD5HasEnable";
+static const char *attrMD5FlushInterval = "MD5FlushInterval";
+static const char *attrMD5PicWidth      = "MD5PicWidth";
+static const char *attrMD5PicHeight     = "MD5PicHeight";
+// kernel attributes
+static const char *attrDsh         = "DSH";
+static const char *attrIsh         = "ISH";
+static const char *attrSsh         = "SSH";
+static const char *attrCurbe       = "Curbe";
+static const char *attrCmdBuffer   = "CmdBuffer";
+static const char *attr2ndLvlBatch = "2ndLvlBath";
+static const char *attrInput       = "Input";
+static const char *attrOutput      = "Output";
+};
+
+namespace MediaDbgKernel
+{
+class KernelStateMap
+{
+public:
+    using kernelMapType = std::map<MEDIA_DEBUG_STATE_TYPE, std::string>;
+
+    static bool RegisterKernelStr(MEDIA_DEBUG_STATE_TYPE mediaState, std::string kernelName)
+    {
+        kernelMapType &kernelMap = GetKernelStateMap();
+        auto           it        = kernelMap.find(mediaState);
+        if (it == kernelMap.end())
+        {
+            kernelMap.insert(std::make_pair(mediaState, kernelName));
+        }
+        return true;
+    }
+
+    static kernelMapType &GetKernelStateMap()
+    {
+        static kernelMapType m_kernelStateMap;
+        return m_kernelStateMap;
+    }
+};
+
+//Codec Kernel
+static const char *kernelOlp                          = "Vc1Olp";
+static const char *kernelEncNormal                    = "MbEncNorm";
+static const char *kernelEncPerf                      = "MbEncPerf";
+static const char *kernelEncQuality                   = "MbEncQlty";
+static const char *kernelEncIFrameDist                = "IFrameDist";
+static const char *kernel32xScaling                   = "32xScaling";
+static const char *kernel16xScaling                   = "16xScaling";
+static const char *kernel4xScaling                    = "4xScaling";
+static const char *kernel32xMe                        = "32xMe";
+static const char *kernel16xMe                        = "16xMe";
+static const char *kernel4xMe                         = "4xMe";
+static const char *kernelBrcInitReset                 = "BrcInitReset";
+static const char *kernelBrcUpdate                    = "BrcUpdate";
+static const char *kernel2xScaling                    = "2xScaling";
+static const char *kernelHevc32x32PuModeDecision      = "HEVC_32x32_PU_MD";
+static const char *kernelHevc16x16PuSad               = "HEVC_16x16_PU_SAD";
+static const char *kernelHevc16x16PuModeDecision      = "HEVC_16x16_PU_MD";
+static const char *kernelHevc8x8Pu                    = "HEVC_8x8_PU_MD";
+static const char *kernelHevc8x8PuFMode               = "HEVC_8x8_PU_FMODE";
+static const char *kernelHevc32x32BIntraCheck         = "HEVC_32x32_B_INTRA_CHECK";
+static const char *kernelHevcBMbenc                   = "HEVC_B_MBENC";
+static const char *kernelHevcBPak                     = "HEVC_B_PAK";
+static const char *kernelHevcBrcLcuUpdate             = "HEVC_LCU_BRCUpdate";
+static const char *kernelMeVdencStreamIn              = "MeVDEncStreamIn";
+static const char *kernelVP9EncI32x32                 = "VP9_I_32x32_MBENC";
+static const char *kernelVP9EncI16x16                 = "VP9_I_16x16_MBENC";
+static const char *kernelVP9EncP                      = "VP9_P_MBENC";
+static const char *kernelVP9EncTx                     = "VP9_TX_MBENC";
+static const char *kernelVP9Dys                       = "VP9_DYS";
+static const char *kernelVP9PakLumaRecon              = "VP9_I_MBPAK_LumaRecon";
+static const char *kernelVP9PakChromaRecon            = "VP9_I_MBPAK_ChromaRecon";
+static const char *kernelVP9PakDeblockMask            = "VP9_I_MBPAK_DeblockMask";
+static const char *kernelVP9PakLumaDeblock            = "VP9_I_MBPAK_LumaDeblock";
+static const char *kernelVP9PakChromaDeblock          = "VP9_I_MBPAK_ChromaDeblock";
+static const char *kernelVP9PakMcPred                 = "VP9_P_MbPak_McPred";
+static const char *kernelVP9PakPFrameLumaRecon        = "VP9_P_MbPak_LumaRecon";
+static const char *kernelVP9PakPFrameLumaRecon32x32   = "VP9_P_MbPak_LumaRecon";
+static const char *kernelVP9PakPFrameChromaRecon      = "VP9_P_MbPak_ChromaRecon";
+static const char *kernelVP9PakPFrameIntraLumaRecon   = "VP9_Intra_P_MbPak_LumaRecon";
+static const char *kernelVP9PakPFrameIntraChromaRecon = "VP9_Intra_P_MbPak_ChromaRecon";
+static const char *kernelPreProc                      = "PreProc";
+static const char *kernelEncWP                        = "WP";
+static const char *kernelHevcIMbenc                   = "HEVC_I_MBENC";
+static const char *kernelCscDsCopy                    = "CSCDsCopy";
+static const char *kernel2x4xScaling                  = "2x_4xScaling";
+static const char *kernelHevcLcu64BMbenc              = "HEVC_LCU64_B_MBENC";
+static const char *kernelMbBrcUpdate                  = "MbBrcUpdate";
+static const char *kernelStaticFrameDetection         = "StaticFrameDetection";
+static const char *kernelHevcRoi                      = "HEVC_ROI";
+
+static bool regOlp                          = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_OLP, kernelOlp);
+static bool regEncNormal                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_NORMAL, kernelEncNormal);
+static bool regEncQuality                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_PERFORMANCE, kernelEncPerf);
+static bool regEncPerf                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_QUALITY, kernelEncQuality);
+static bool regEncIFrameDist                = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_I_FRAME_DIST, kernelEncIFrameDist);
+static bool reg32xScaling                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32X_SCALING, kernel32xScaling);
+static bool reg16xScaling                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16X_SCALING, kernel16xScaling);
+static bool reg4xScaling                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_4X_SCALING, kernel4xScaling);
+static bool reg32xMe                        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32X_ME, kernel32xMe);
+static bool reg16xMe                        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16X_ME, kernel16xMe);
+static bool reg4xMe                         = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_4X_ME, kernel4xMe);
+static bool regBrcInit                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_BRC_INIT_RESET, kernelBrcInitReset);
+static bool regBrcUpdate                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_BRC_UPDATE, kernelBrcUpdate);
+static bool reg2xScale                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_2X_SCALING, kernel2xScaling);
+static bool regHevc32x32PuMode              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32x32_PU_MODE_DECISION, kernelHevc32x32PuModeDecision);
+static bool regHevc16x16PuSad               = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16x16_PU_SAD, kernelHevc16x16PuSad);
+static bool regHevc16x16PuMode              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_16x16_PU_MODE_DECISION, kernelHevc16x16PuModeDecision);
+static bool regHevc8x8Pu                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_8x8_PU, kernelHevc8x8Pu);
+static bool regHevc8x8PuFMode               = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_8x8_PU_FMODE, kernelHevc8x8PuFMode);
+static bool regHevc32x32BIntraCheck         = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_32x32_B_INTRA_CHECK, kernelHevc32x32BIntraCheck);
+static bool regHevcBMben                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_B_MBENC, kernelHevcBMbenc);
+static bool regHevcBPak                     = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_B_PAK, kernelHevcBPak);
+static bool regHevcBrcLcuUpdate             = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_BRC_LCU_UPDATE, kernelHevcBrcLcuUpdate);
+static bool regMeVdencStreamIn              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ME_VDENC_STREAMIN, kernelMeVdencStreamIn);
+static bool regVp9EncI32x32                 = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_I_32x32, kernelVP9EncI32x32);
+static bool regVp9EncI16x16                 = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_I_16x16, kernelVP9EncI16x16);
+static bool regVp9EncP                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_P, kernelVP9EncP);
+static bool regVp9EncTx                     = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_ENC_TX, kernelVP9EncTx);
+static bool regVp9Dys                       = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_DYS, kernelVP9Dys);
+static bool regVp9PakLumaRecon              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_LUMA_RECON, kernelVP9PakLumaRecon);
+static bool regVp9PakChromaRecon            = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_CHROMA_RECON, kernelVP9PakChromaRecon);
+static bool regVp9PakDeblockMask            = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_DEBLOCK_MASK, kernelVP9PakDeblockMask);
+static bool regVp9PakLumaDeblock            = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_LUMA_DEBLOCK, kernelVP9PakLumaDeblock);
+static bool regVp9PakChromaDeblock          = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_CHROMA_DEBLOCK, kernelVP9PakChromaDeblock);
+static bool regVp9PakMcPred                 = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_MC_PRED, kernelVP9PakMcPred);
+static bool regVp9PakPFrameLumaRecon        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_LUMA_RECON, kernelVP9PakPFrameLumaRecon);
+static bool regVp9PakPFrameLumaRecon32x32   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_LUMA_RECON_32x32, kernelVP9PakPFrameLumaRecon32x32);
+static bool regVp9PakPFrameChromaRecon      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_CHROMA_RECON, kernelVP9PakPFrameChromaRecon);
+static bool regVp9PakPFrameIntraLumaRecon   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_INTRA_LUMA_RECON, kernelVP9PakPFrameIntraLumaRecon);
+static bool regVp9PakPFrameIntraChromaRecon = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_VP9_PAK_P_FRAME_INTRA_CHROMA_RECON, kernelVP9PakPFrameIntraChromaRecon);
+static bool regPreProc                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_PREPROC, kernelPreProc);
+static bool regEncWP                        = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_ENC_WP, kernelEncWP);
+static bool regHevcIMbenc                   = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_I_MBENC, kernelHevcIMbenc);
+static bool regCscDsCopy                    = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_CSC_DS_COPY, kernelCscDsCopy);
+static bool reg2x4xScaling                  = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_2X_4X_SCALING, kernel2x4xScaling);
+static bool regHevcLcu64BMbenc              = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_LCU64_B_MBENC, kernelHevcLcu64BMbenc);
+static bool regMbBrcUpdate                  = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_MB_BRC_UPDATE, kernelMbBrcUpdate);
+static bool regStaticFrameDetection         = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_STATIC_FRAME_DETECTION, kernelStaticFrameDetection);
+static bool regHevcRoi                      = KernelStateMap::RegisterKernelStr(CODECHAL_MEDIA_STATE_HEVC_ROI, kernelHevcRoi);
+}  // namespace MediaDbgKernel
+
+namespace MediaDbgFieldType
+{
+static const char *topField = "_Top";
+static const char *botField = "_Bot";
+static const char *frame    = "_Frame";
+};  // namespace MediaDbgFieldType
+
+namespace MediaDbgExtType
+{
+static const char *dat  = ".dat";
+static const char *txt  = ".txt";
+static const char *par  = ".par";
+static const char *y    = ".Y";
+static const char *uv   = ".UV";
+static const char *yuv  = ".yuv";
+static const char *yuy2 = ".yuy2";
+static const char *uyvy = ".uyvy";
+};  // namespace MediaDbgExtType
+
+namespace MediaDbgSurfaceType
+{
+static const char *yuv444    = "_yuv444";
+static const char *yuv411    = "_yuv411";
+static const char *yuv420    = "_yuv420";
+static const char *yuv400    = "_yuv400";
+static const char *yuv422h2y = "_yuv422h_2y";
+static const char *yuv422v2y = "_yuv422v_2y";
+static const char *yuv422h4y = "_yuv422h_4y";
+static const char *yuv422v4y = "_yuv422v_4y";
+static const char *yuy2422   = "_yuy2422";
+static const char *uyvy422   = "_uyvy422";
+};
+
+namespace MediaDbgBufferType
+{
+static const char *bufCmd           = "CmdBuf";
+static const char *buf2ndLvl        = "2ndLvl";
+static const char *bufCurbe         = "Curbe";
+static const char *bufISH           = "ISH";
+static const char *bufDSH           = "DSH";
+static const char *bufSSH           = "SSH";
+static const char *bufSeqParams     = "SeqParams";
+static const char *bufPicParams     = "PicParams";
+static const char *bufSlcParams     = "SlcParams";
+static const char *bufSubsetsParams = "SubsetsParams";
+static const char *bufVuiParams     = "VuiParams";
+static const char *bufBitstream     = "Bitstream";
+static const char *bufFeiPicParams  = "FeiPicParams";
+static const char *bufMadRead       = "MADRead";
+static const char *bufMadWrite      = "MADWrite";
+static const char *bufSegmentParams = "SegmentParams";
+static const char *bufIqParams      = "IqParams";
+static const char *bufHuffmanTbl    = "HuffmanTbl";
+static const char *bufScanParams    = "ScanParams";
+static const char *bufMvcPicParams  = "MvcPicParams";
+static const char *bufMbParams      = "MbParams";
+static const char *bufDecProcParams = "DecProcParams";
+static const char *bufHucRegion     = "HucRegion";
+static const char *bufHucDmem       = "HucDmem";
+static const char *bufEncodePar     = "EncodePar";
+};  // namespace MediaDbgBufferType
+
+//------------------------------------------------------------------------------
+// Macros specific to MOS_OS_SUBCOMP_DEBUG sub-comp
+//------------------------------------------------------------------------------
+#define MEDIA_DEBUG_ASSERT(_expr) \
+    MOS_ASSERT(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _expr)
+
+#define MEDIA_DEBUG_ASSERTMESSAGE(_message, ...) \
+    MOS_ASSERTMESSAGE(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _message, ##__VA_ARGS__)
+
+#define MEDIA_DEBUG_NORMALMESSAGE(_message, ...) \
+    MOS_NORMALMESSAGE(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _message, ##__VA_ARGS__)
+
+#define MEDIA_DEBUG_VERBOSEMESSAGE(_message, ...) \
+    MOS_VERBOSEMESSAGE(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _message, ##__VA_ARGS__)
+
+#define MEDIA_DEBUG_FUNCTION_ENTER \
+    MOS_FUNCTION_ENTER(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF)
+
+#define MEDIA_DEBUG_CHK_STATUS(_stmt) \
+    MOS_CHK_STATUS_RETURN(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _stmt)
+
+#define MEDIA_DEBUG_CHK_STATUS_MESSAGE(_stmt, _message, ...) \
+    MOS_CHK_STATUS_MESSAGE_RETURN(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _stmt, _message, ##__VA_ARGS__)
+
+#define MEDIA_DEBUG_CHK_NULL(_ptr) \
+    MOS_CHK_NULL_RETURN(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _ptr)
+
+#define MEDIA_DEBUG_CHK_NULL_NO_STATUS(_ptr) \
+    MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_OS, MOS_SUBCOMP_SELF, _ptr)
+
+#define MEDIA_DEBUG_CODECHAL_DUMP_OUTPUT_FOLDER "\\codechaldump\\"
+#define MEDIA_DEBUG_VPHAL_DUMP_OUTPUT_FOLDER "\\vphaldump\\"
+
+#endif  //USE_MEDIA_DEBUG_TOOL
+#endif  /* __MEDIA_DEBUG_UTILS_H__ */
diff --git a/media_driver/agnostic/common/shared/media_srcs.cmake b/media_driver/agnostic/common/shared/media_srcs.cmake
index de01ed5..c0e8377 100644
--- a/media_driver/agnostic/common/shared/media_srcs.cmake
+++ b/media_driver/agnostic/common/shared/media_srcs.cmake
@@ -24,6 +24,8 @@
     ${CMAKE_CURRENT_LIST_DIR}/media_user_settings_mgr.cpp
     ${CMAKE_CURRENT_LIST_DIR}/memory_policy_manager.cpp
     ${CMAKE_CURRENT_LIST_DIR}/null_hardware.cpp
+    ${CMAKE_CURRENT_LIST_DIR}/media_debug_interface.cpp
+    ${CMAKE_CURRENT_LIST_DIR}/media_debug_config_manager.cpp
 )
 
 set(TMP_HEADERS_
@@ -32,6 +34,9 @@
     ${CMAKE_CURRENT_LIST_DIR}/media_user_settings_mgr.h
     ${CMAKE_CURRENT_LIST_DIR}/memory_policy_manager.h
     ${CMAKE_CURRENT_LIST_DIR}/null_hardware.h
+    ${CMAKE_CURRENT_LIST_DIR}/media_debug_interface.h
+    ${CMAKE_CURRENT_LIST_DIR}/media_debug_config_manager.h
+    ${CMAKE_CURRENT_LIST_DIR}/media_debug_utils.h
 )
 
 set(SOURCES_
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.cpp b/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.cpp
index 9eafab8..56e38ff 100644
--- a/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.cpp
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.cpp
@@ -61,18 +61,13 @@
     MOS_Delete(m_statusReport);
     MOS_Delete(m_packetSharedContext);
     MOS_Delete(m_reporting);
+    VP_DEBUG_INTERFACE_DESTROY(m_debugInterface);
 
     if (m_mediaContext)
     {
         MOS_Delete(m_mediaContext);
         m_mediaContext = nullptr;
     }
-
-    // Destroy surface dumper
-    VPHAL_SURF_DUMP_DESTORY(m_surfaceDumper);
-
-    // Destroy vphal parameter dump
-    VPHAL_PARAMETERS_DUMPPER_DESTORY(m_parameterDumper);
 }
 
 MOS_STATUS VpPipeline::GetStatusReport(void *status, uint16_t numStatus)
@@ -172,15 +167,7 @@
     VP_PUBLIC_CHK_NULL_RETURN(m_featureManager);
 
 #if (_DEBUG || _RELEASE_INTERNAL)
-
-    // Initialize Surface Dumper
-    VPHAL_SURF_DUMP_CREATE()
-    VP_PUBLIC_CHK_NULL_RETURN(m_surfaceDumper);
-
-    // Initialize Parameter Dumper
-    VPHAL_PARAMETERS_DUMPPER_CREATE()
-    VP_PUBLIC_CHK_NULL_RETURN(m_parameterDumper);
-
+    VP_DEBUG_INTERFACE_CREATE(m_debugInterface)
 #endif
 
     m_pPacketFactory = MOS_New(PacketFactory, m_vpMhwInterface.m_vpPlatformInterface);
@@ -231,11 +218,13 @@
         // Set Pipeline status Table
         m_statusReport->SetPipeStatusReportParams(params, m_vpMhwInterface.m_statusTable);
 
-        VPHAL_PARAMETERS_DUMPPER_DUMP_XML(params);
+        VP_PARAMETERS_DUMPPER_DUMP_XML(m_debugInterface,
+            params,
+            m_frameCounter);
 
         for (uint32_t uiLayer = 0; uiLayer < params->uSrcCount && uiLayer < VPHAL_MAX_SOURCES; uiLayer++)
         {
-            VPHAL_SURFACE_DUMP(m_surfaceDumper,
+            VP_SURFACE_DUMP(m_debugInterface,
                 params->pSrc[uiLayer],
                 m_frameCounter,
                 uiLayer,
@@ -292,12 +281,13 @@
     {
         PVP_PIPELINE_PARAMS params = m_pvpParams.renderParams;
         VP_PUBLIC_CHK_NULL(params);
-        VPHAL_SURFACE_PTRS_DUMP(m_surfaceDumper,
+        VP_SURFACE_PTRS_DUMP(m_debugInterface,
             params->pTarget,
             VPHAL_MAX_TARGETS,
             params->uDstCount,
             m_frameCounter,
             VPHAL_DUMP_TYPE_POST_ALL);
+
 #if ((_DEBUG || _RELEASE_INTERNAL) && !EMUL)
         // Decompre output surface for debug
         MOS_USER_FEATURE_VALUE_DATA userFeatureData;
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.h b/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.h
index f12f46e..a9488de 100644
--- a/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.h
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/pipeline/vp_pipeline.h
@@ -37,6 +37,7 @@
 #include "vp_status_report.h"
 #include "vphal.h"
 #include "vp_dumper.h"
+#include "vp_debug_interface.h"
 #include "vp_feature_manager.h"
 #include "vp_packet_shared_context.h"
 #include "vp_kernelset.h"
@@ -266,8 +267,7 @@
     // Surface dumper fields (counter and specification)
     uint32_t               m_frameCounter           = 0;
 #if (_DEBUG || _RELEASE_INTERNAL)
-    VpSurfaceDumper       *m_surfaceDumper          = nullptr;
-    VpParameterDumper     *m_parameterDumper        = nullptr;
+    VpDebugInterface      *m_debugInterface         = nullptr;
 #endif
     bool                   m_currentFrameAPGEnabled = false;
     PacketFactory         *m_pPacketFactory         = nullptr;
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/media_srcs.cmake b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/media_srcs.cmake
index 0de6508..d7fc994 100644
--- a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/media_srcs.cmake
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/media_srcs.cmake
@@ -20,11 +20,15 @@
 
 set(TMP_SOURCES_
     ${CMAKE_CURRENT_LIST_DIR}/vp_dumper.cpp
+    ${CMAKE_CURRENT_LIST_DIR}/vp_debug_interface.cpp
+    ${CMAKE_CURRENT_LIST_DIR}/vp_debug_config_manager.cpp
 )
 
 set(TMP_HEADERS_
     ${CMAKE_CURRENT_LIST_DIR}/vp_dumper.h
     ${CMAKE_CURRENT_LIST_DIR}/vp_utils.h
+    ${CMAKE_CURRENT_LIST_DIR}/vp_debug_interface.h
+    ${CMAKE_CURRENT_LIST_DIR}/vp_debug_config_manager.h
 )
 
 set(SOURCES_NEW
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_config_manager.cpp b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_config_manager.cpp
new file mode 100644
index 0000000..7279bf1
--- /dev/null
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_config_manager.cpp
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2017-2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//!
+//! \file     vp_debug_config_manager.cpp
+//! \brief    Defines the dump configuration manager.
+//! \details  The debug interface dumps configuration manager file which parse attributes.
+//!
+#include "vp_debug_config_manager.h"
+#if USE_VP_DEBUG_TOOL
+
+VpDebugConfigMgr::VpDebugConfigMgr(
+    VpDebugInterface *debugInterface,
+    std::string       outputFolderPath)
+    : MediaDebugConfigMgr(outputFolderPath),
+      m_debugInterface(debugInterface)
+{
+    m_mediaFunction = MEDIA_FUNCTION_VP;
+}
+
+uint32_t VpDebugConfigMgr::GetDumpFrameNum()
+{
+    return (uint32_t)m_debugInterface->m_bufferDumpFrameNum;
+}
+
+std::string VpDebugConfigMgr::InitFileName(MediaDbgFunction mediaFunction)
+{
+    return "VpDbgSetting.cfg";
+}
+
+VpDebugConfigMgr::~VpDebugConfigMgr()
+{
+}
+
+#endif  // USE_VP_DEBUG_TOOL
+
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_config_manager.h b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_config_manager.h
new file mode 100644
index 0000000..d3b5e45
--- /dev/null
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_config_manager.h
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2017-2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     vp_debug_config.manager.h
+//! \brief    Defines the dump configuration manager.
+//! \details  The debug interface dumps configuration manager file which parse attributes.
+//!
+#ifndef __VP_DEBUG_CONFIG_MANAGER_H__
+#define __VP_DEBUG_CONFIG_MANAGER_H__
+
+#include "vp_debug_interface.h"
+#if USE_VP_DEBUG_TOOL
+
+class VpDebugConfigMgr : public MediaDebugConfigMgr
+{
+public:
+    VpDebugConfigMgr(
+        VpDebugInterface *debugInterface,
+        std::string       outputFolderPath);
+    virtual  ~VpDebugConfigMgr();
+
+protected:
+    uint32_t GetDumpFrameNum() override;
+
+protected:
+    VpDebugInterface *m_debugInterface = nullptr;
+    std::string       InitFileName(MediaDbgFunction mediaFunction) override;
+};
+
+#endif  //USE_VP_DEBUG_TOOL
+#endif  /* __VP_DEBUG_CONFIG_MANAGER_H__ */
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_interface.cpp b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_interface.cpp
new file mode 100644
index 0000000..ba2d0e7
--- /dev/null
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_interface.cpp
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     vp_debug_interface.cpp
+//! \brief    Defines the debug interface shared by vp only.
+//! \details  The debug interface dumps output from Media based on in input config file.
+//!
+
+#include "vp_debug_interface.h"
+#if USE_VP_DEBUG_TOOL
+#include "vp_debug_config_manager.h"
+#include "vphal.h"
+
+VpDebugInterface::VpDebugInterface()
+{
+    memset(&m_currPic, 0, sizeof(CODEC_PICTURE));
+    memset(m_fileName, 0, sizeof(m_fileName));
+    memset(m_path, 0, sizeof(m_path));
+}
+
+VpDebugInterface::~VpDebugInterface()
+{
+    // Destroy surface dumper
+    VP_SURF_DUMP_DESTORY(m_surfaceDumper);
+    // Destroy vphal parameter dump
+    VP_PARAMETERS_DUMPPER_DESTORY(m_parameterDumper);
+
+    if (nullptr != m_configMgr)
+    {
+        MOS_Delete(m_configMgr);
+    }
+}
+
+MOS_STATUS VpDebugInterface::Initialize(PMOS_INTERFACE pOsInterface)
+{
+    MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
+    VP_DEBUG_FUNCTION_ENTER;
+
+    VP_DEBUG_CHK_NULL_RETURN(pOsInterface);
+    m_osInterface = pOsInterface;
+
+    //dump loctaion is vpdump
+    MediaDebugInterface::SetOutputFilePath();
+
+    m_configMgr = MOS_New(VpDebugConfigMgr, this, m_outputFilePath);
+    VP_DEBUG_CHK_NULL_RETURN(m_configMgr);
+    m_configMgr->ParseConfig(m_osInterface->pOsContext);
+
+    MediaDebugInterface::InitDumpLocation();
+
+    // Initialize Surface Dumper
+    VP_SURF_DUMP_CREATE(m_surfaceDumper);
+    VP_DEBUG_CHK_NULL_RETURN(m_surfaceDumper);
+    // Initialize Parameter Dumper
+    VP_PARAMETERS_DUMPPER_CREATE(m_parameterDumper);
+    VP_DEBUG_CHK_NULL_RETURN(m_parameterDumper);
+
+    return eStatus;
+}
+
+void VpDebugInterface::DumpToXML(PVPHAL_RENDER_PARAMS pRenderParams, uint32_t framecounter)
+{
+    if (m_surfaceDumper && m_surfaceDumper)
+    {
+        m_parameterDumper->DumpToXML(
+            framecounter,
+            m_surfaceDumper->m_dumpSpec.pcOutputPath,
+            pRenderParams);
+    }
+}
+
+MOS_STATUS VpDebugInterface::DumpVpSurface(
+    PVPHAL_SURFACE pSurf,
+    uint32_t       uiFrameNumber,
+    uint32_t       uiCounter,
+    uint32_t       Location)
+{
+    VP_DEBUG_CHK_NULL_RETURN(m_surfaceDumper)
+    return m_surfaceDumper->DumpSurface(
+               pSurf,
+               uiFrameNumber,
+               uiCounter,
+               Location);
+}
+
+MOS_STATUS VpDebugInterface::DumpVpSurfaceArray(
+    PVPHAL_SURFACE                  *ppSurfaces,
+    uint32_t                        uiMaxSurfaces,
+    uint32_t                        uiNumSurfaces,
+    uint32_t                        uiFrameNumber,
+    uint32_t                        Location)
+{
+    VP_DEBUG_CHK_NULL_RETURN(m_surfaceDumper)
+    return m_surfaceDumper->DumpSurfaceArray(
+               ppSurfaces,
+               uiMaxSurfaces,
+               uiNumSurfaces,
+               uiFrameNumber,
+               Location);
+}
+
+MOS_USER_FEATURE_VALUE_ID VpDebugInterface::SetOutputPathKey()
+{
+    return __VPHAL_DBG_SURF_DUMP_OUTFILE_KEY_NAME_ID;
+}
+
+MOS_USER_FEATURE_VALUE_ID VpDebugInterface::InitDefaultOutput()
+{
+    m_outputFilePath.append(MEDIA_DEBUG_VPHAL_DUMP_OUTPUT_FOLDER);
+    return SetOutputPathKey();
+}
+
+#endif  // USE_VP_DEBUG_INTERFACE
+
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_interface.h b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_interface.h
new file mode 100644
index 0000000..99b5b9f
--- /dev/null
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_debug_interface.h
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2020, Intel Corporation
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+//!
+//! \file     vp_debug_interface.h
+//! \brief    Defines the debug interface shared by vp only.
+//! \details  The debug interface dumps output from Media based on in input config file.
+//!
+#ifndef __VP_DEBUG_INTERFACE_H__
+#define __VP_DEBUG_INTERFACE_H__
+
+#include "media_debug_interface.h"
+#include "media_debug_config_manager.h"
+#include "vp_dumper.h"
+#include "vp_utils.h"
+#if USE_MEDIA_DEBUG_TOOL
+#define USE_VP_DEBUG_TOOL 1
+#define VP_DEBUG_TOOL(expr) expr;
+
+class VpDebugInterface : public MediaDebugInterface
+{
+public:
+    VpDebugInterface();
+    virtual ~VpDebugInterface();
+
+    MOS_STATUS Initialize(PMOS_INTERFACE pOsInterface);
+
+    void DumpToXML(
+        PVPHAL_RENDER_PARAMS            pRenderParams,
+        uint32_t                        framecounter);
+
+    MOS_STATUS DumpVpSurfaceArray(
+        PVPHAL_SURFACE                 *ppSurfaces,
+        uint32_t                        uiMaxSurfaces,
+        uint32_t                        uiNumSurfaces,
+        uint32_t                        uiFrameNumber,
+        uint32_t                        Location);
+
+    MOS_STATUS DumpVpSurface(
+        PVPHAL_SURFACE pSurf,
+        uint32_t       uiFrameNumber,
+        uint32_t       uiCounter,
+        uint32_t       Location);
+
+protected:
+    MOS_USER_FEATURE_VALUE_ID SetOutputPathKey() override;
+    MOS_USER_FEATURE_VALUE_ID InitDefaultOutput() override;
+
+    VpSurfaceDumper *  m_surfaceDumper   = nullptr;
+    VpParameterDumper *m_parameterDumper = nullptr;
+
+};
+
+#else
+#define USE_VP_DEBUG_TOOL 0
+#define VP_DEBUG_TOOL(expr) ;
+#endif  // USE_MEDIA_DEBUG_TOOL
+#endif  /* __VP_DEBUG_INTERFACE_H__ */
\ No newline at end of file
diff --git a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_dumper.h b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_dumper.h
index 0754edc..4bd502b 100644
--- a/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_dumper.h
+++ b/media_driver/media_driver_next/agnostic/common/vp/hal/utils/vp_dumper.h
@@ -50,60 +50,77 @@
 #define VPHAL_SURF_DUMP_MANUAL_TRIGGER_STOPPED (0)
 
 //------------------------------------------------------------------------------
+// Dump macro for dumper.  Dump vphal parameters.
+//------------------------------------------------------------------------------
+#define VP_PARAMETERS_DUMPPER_DUMP_XML(              \
+    debuginterface, pRenderParams, frameCounter)     \
+    if (debuginterface)                                              \
+        debuginterface->DumpToXML(pRenderParams, frameCounter);      \
+
+//------------------------------------------------------------------------------
 // Dump macro.  Simply calls the dump function.  defined as null in production
 //------------------------------------------------------------------------------
-#define VPHAL_SURFACE_DUMP(dumper, surf, frameCntr, layerCntr, loc)         \
-    VPHAL_DEBUG_CHK_STATUS(dumper->DumpSurface(surf, frameCntr, layerCntr, loc));
+#define VP_SURFACE_DUMP(                                       \
+    debuginterface, surf, frameCntr, layerCntr, loc)           \
+    if (debuginterface)                                        \
+        VP_DEBUG_CHK_STATUS(debuginterface->DumpVpSurface(     \
+           surf, frameCntr, layerCntr, loc));
 
 //------------------------------------------------------------------------------
 // Dump array of surfaces
 //------------------------------------------------------------------------------
-#define VPHAL_SURFACE_PTRS_DUMP(                                            \
-    dumper, surfs, maxCntr, numCntr, frameCntr, loc)                            \
-    VPHAL_DEBUG_CHK_STATUS(dumper->DumpSurfaceArray(                            \
-        surfs, maxCntr, numCntr, frameCntr, loc));
-
+#define VP_SURFACE_PTRS_DUMP(                                    \
+    debuginterface, surfs, maxCntr, numCntr, frameCntr, loc)     \
+    if (debuginterface)                                          \
+        VP_DEBUG_CHK_STATUS(debuginterface->DumpVpSurfaceArray(  \
+            surfs, maxCntr, numCntr, frameCntr, loc));
 //------------------------------------------------------------------------------
 // Create macro for dumper.  Allocates and initializes.
 //    Potential leak if renderer not destroyed properly. However, cannot add a
 //    free here since renderer is not initialized to null (0)
 //------------------------------------------------------------------------------
-#define VPHAL_SURF_DUMP_CREATE()                                            \
-    m_surfaceDumper = MOS_New(VpSurfaceDumper, m_osInterface);              \
-    if (m_surfaceDumper)                                                        \
-        m_surfaceDumper->GetSurfaceDumpSpec();
+#define VP_SURF_DUMP_CREATE(surfaceDumper)                   \
+    surfaceDumper = MOS_New(VpSurfaceDumper, m_osInterface); \
+    if (surfaceDumper)                                       \
+        surfaceDumper->GetSurfaceDumpSpec();
 
 //------------------------------------------------------------------------------
 // Destroy macro for dumper.  Frees and sets to null.
 //------------------------------------------------------------------------------
-#define VPHAL_SURF_DUMP_DESTORY(surfaceDumper)                              \
-    MOS_Delete(surfaceDumper);                                                  \
+#define VP_SURF_DUMP_DESTORY(surfaceDumper)    \
+    MOS_Delete(surfaceDumper);                 \
     surfaceDumper = nullptr;
 
-
 //------------------------------------------------------------------------------
 // Create macro for vphal parameters dumper.  Allocates and initializes.
 //------------------------------------------------------------------------------
-#define VPHAL_PARAMETERS_DUMPPER_CREATE()                                   \
-    m_parameterDumper = MOS_New(VpParameterDumper, m_osInterface);          \
-    if (m_parameterDumper)                                                      \
-        m_parameterDumper->GetParametersDumpSpec();
+#define VP_PARAMETERS_DUMPPER_CREATE(parameterDumper)            \
+    parameterDumper = MOS_New(VpParameterDumper, m_osInterface); \
+    if (parameterDumper)                                         \
+        parameterDumper->GetParametersDumpSpec();
 
 //------------------------------------------------------------------------------
 // Destroy macro for dumper.  Frees and sets to null.
 //------------------------------------------------------------------------------
-#define VPHAL_PARAMETERS_DUMPPER_DESTORY(parameterDumper)                 \
-    MOS_Delete(parameterDumper);                                              \
+#define VP_PARAMETERS_DUMPPER_DESTORY(parameterDumper)    \
+    MOS_Delete(parameterDumper);                          \
     parameterDumper = nullptr;
 
 //------------------------------------------------------------------------------
-// Dump macro for dumper.  Dump vphal parameters.
+// Create macro for vp debug interface.  Allocates and initializes.
 //------------------------------------------------------------------------------
-#define VPHAL_PARAMETERS_DUMPPER_DUMP_XML(pRenderParams)                    \
-    m_parameterDumper->DumpToXML(                                               \
-        m_frameCounter,                                                         \
-        m_surfaceDumper->m_dumpSpec.pcOutputPath,                               \
-        pRenderParams);
+#define VP_DEBUG_INTERFACE_CREATE(debuginterface)       \
+    debuginterface = MOS_New(VpDebugInterface);         \
+    if (debuginterface)                                 \
+        VP_PUBLIC_CHK_STATUS_RETURN(                    \
+            debuginterface->Initialize(m_osInterface)); \
+
+//------------------------------------------------------------------------------
+// Destroy macro for vp debug interface.  Frees and sets to null.
+//------------------------------------------------------------------------------
+#define VP_DEBUG_INTERFACE_DESTROY(debuginterface)      \
+    MOS_Delete(debuginterface);                         \
+    debuginterface = nullptr;
 
 //! 
 //! Structure VPHAL_DBG_SURF_DUMP_SURFACE_DEF
@@ -152,7 +169,7 @@
 struct VPHAL_SURF_DUMP_SPEC
 {
     char                          pcOutputPath[MAX_PATH];                       //!< Path where dumps are written
-    VPHAL_SURF_DUMP_LOC       *pDumpLocations;                              //!< Locations in post-processing pipeline to dump at
+    VPHAL_SURF_DUMP_LOC          *pDumpLocations;                              //!< Locations in post-processing pipeline to dump at
     uint32_t                      uiStartFrame;                                 //!< Frame to start dumping at
     uint32_t                      uiEndFrame;                                   //!< Frame to stop dumping at
     int32_t                       iNumDumpLocs;                                 //!< Number of pipe stage dump locations
@@ -172,7 +189,7 @@
     uint32_t                 dwSize;
     uint32_t                 uiNumber;
     char                     pcStructName[MAX_NAME_LEN];
-    VPHAL_FIELD_LAYOUT   *pChildLayout;
+    VPHAL_FIELD_LAYOUT      *pChildLayout;
     uint32_t                 uiNumChildren;
 
 };
@@ -732,14 +749,16 @@
 
 #if (!(_DEBUG || _RELEASE_INTERNAL))
 
-#define VPHAL_SURFACE_DUMP(dumper, surf, frameCntr, layerCntr, loc)
-#define VPHAL_SURFACE_PTRS_DUMP(                                            \
-    dumper, surfs, maxCntr, numCntr, frameCntr, loc)
-#define VPHAL_SURF_DUMP_CREATE()
-#define VPHAL_SURF_DUMP_DESTORY(surfaceDumper)
-#define VPHAL_PARAMETERS_DUMPPER_CREATE()
-#define VPHAL_PARAMETERS_DUMPPER_DESTORY(pParametersDumpSpec)
-#define VPHAL_PARAMETERS_DUMPPER_DUMP_XML(pRenderParams)
+#define VP_PARAMETERS_DUMPPER_DUMP_XML(debuginterface, pRenderParams, frameCounter)
+#define VP_SURFACE_DUMP(debuginterface, surf, frameCntr, layerCntr, loc)
+#define VP_SURFACE_PTRS_DUMP(                                            \
+    debuginterface, surfs, maxCntr, numCntr, frameCntr, loc)
+#define VP_SURF_DUMP_CREATE(surfaceDumper)
+#define VP_SURF_DUMP_DESTORY(surfaceDumper)
+#define VP_PARAMETERS_DUMPPER_CREATE(pParametersDumpSpec)
+#define VP_PARAMETERS_DUMPPER_DESTORY(pParametersDumpSpec)
+#define VP_DEBUG_INTERFACE_CREATE(debuginterface)
+#define VP_DEBUG_INTERFACE_DESTROY(debuginterface)
 
 #endif // (!(_DEBUG || _RELEASE_INTERNAL) || EMUL)