| 1 |
/* |
| 2 |
* Copyright (c) 2021, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file skuwa_dump_specific.c |
| 24 |
//! |
| 25 |
//! |
| 26 |
|
| 27 |
#if (_DEBUG || _RELEASE_INTERNAL) && (!WDDM_LINUX) |
| 28 |
#include <stdio.h> |
| 29 |
#include "vphal.h" |
| 30 |
#include "mhw_vebox.h" |
| 31 |
#include "mos_os.h" |
| 32 |
#include "vphal_debug.h" |
| 33 |
#include "ctype.h" |
| 34 |
|
| 35 |
MOS_STATUS VphalParameterDumper::SkuWa_DumpToXML( |
| 36 |
MEDIA_FEATURE_TABLE *skuTable, |
| 37 |
MEDIA_WA_TABLE *waTable) |
| 38 |
{ |
| 39 |
char sPath[MAX_PATH] = {0}, sOsPath[MAX_PATH] = {0}; |
| 40 |
MOS_STATUS eStatus; |
| 41 |
char* pcOutContents; |
| 42 |
std::string SkuWatableFileName = "skuwatable_dump"; |
| 43 |
VPHAL_DBG_PARAMS_DUMP_SPEC* pParamsDumpSpec = &m_dumpSpec; |
| 44 |
bool enableSkuWaDump = false; |
| 45 |
|
| 46 |
eStatus = MOS_STATUS_SUCCESS; |
| 47 |
pcOutContents = nullptr; |
| 48 |
enableSkuWaDump = m_dumpSpec.enableSkuWaDump; |
| 49 |
|
| 50 |
std::map<std::string, uint8_t>::iterator iter; |
| 51 |
MediaFeatureTable::MediaMap * mediaSkuMap = skuTable->GetMediaSku(); |
| 52 |
MediaWaTable::MediaMap * mediaWaMap = waTable->GetMediaWa(); |
| 53 |
VPHAL_DEBUG_CHK_NULL(pParamsDumpSpec); |
| 54 |
|
| 55 |
if (!enableSkuWaDump) |
| 56 |
goto finish; |
| 57 |
|
| 58 |
VPHAL_DEBUG_CHK_NULL(skuTable); |
| 59 |
VPHAL_DEBUG_CHK_NULL(waTable); |
| 60 |
|
| 61 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(true, &pcOutContents, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); |
| 62 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\n")); |
| 63 |
|
| 64 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t<ID>%d</ID>\n", MosUtilities::MosGetPid())); |
| 65 |
|
| 66 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t<!-- SkuTable infomation -->\n")); |
| 67 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t<SkuTable>\n")); |
| 68 |
|
| 69 |
VPHAL_DEBUG_CHK_NULL(mediaSkuMap); |
| 70 |
|
| 71 |
for (iter = mediaSkuMap->begin(); iter != mediaSkuMap->end(); iter++) |
| 72 |
{ |
| 73 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t\t<%s> %d </%s>\n", iter->first.c_str(), unsigned(iter->second), iter->first.c_str())); |
| 74 |
} |
| 75 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t</SkuTable>\n")); |
| 76 |
|
| 77 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t<!-- WaTable information -->\n")); |
| 78 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t<WaTable>\n")); |
| 79 |
|
| 80 |
VPHAL_DEBUG_CHK_NULL(mediaWaMap); |
| 81 |
|
| 82 |
for (iter = mediaWaMap->begin(); iter != mediaWaMap->end(); iter++) |
| 83 |
{ |
| 84 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t\t<%s> %d </%s>\n", iter->first.c_str(), unsigned(iter->second), iter->first.c_str())); |
| 85 |
} |
| 86 |
VPHAL_DEBUG_CHK_STATUS(VphalDumperTool::AppendString(false, &pcOutContents, "\t</WaTable>\n")); |
| 87 |
|
| 88 |
MOS_SecureStringPrint(sPath, MAX_PATH, MAX_PATH, "%s%c%s.xml", pParamsDumpSpec->outFileLocation, MOS_DIR_SEPERATOR, SkuWatableFileName.c_str()); |
| 89 |
VphalDumperTool::GetOsFilePath(sPath, sOsPath); |
| 90 |
VPHAL_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pcOutContents, strlen(pcOutContents))); |
| 91 |
|
| 92 |
finish: |
| 93 |
if (pcOutContents) |
| 94 |
{ |
| 95 |
MOS_FreeMemory(pcOutContents); |
| 96 |
pcOutContents = nullptr; |
| 97 |
} |
| 98 |
|
| 99 |
return eStatus; |
| 100 |
} |
| 101 |
|
| 102 |
#endif // (_DEBUG || _RELEASE_INTERNAL) |