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_dumper_specific.c
24 //!
25 //!
26
27 #if (_DEBUG || _RELEASE_INTERNAL)
28 #include <stdio.h>
29 #include "mhw_vebox.h"
30 #include "mos_os.h"
31 #include "vp_dumper.h"
32 #include "ctype.h"
33 #include "vp_utils.h"
34
SkuWa_DumpToXML(MEDIA_FEATURE_TABLE * skuTable,MEDIA_WA_TABLE * waTable)35 MOS_STATUS VpParameterDumper::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_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
54 VP_DEBUG_CHK_NULL(pParamsDumpSpec);
55
56 if (!enableSkuWaDump)
57 goto finish;
58
59 VP_DEBUG_CHK_NULL(skuTable);
60 VP_DEBUG_CHK_NULL(waTable);
61
62 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(true, &pcOutContents, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
63 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\n"));
64
65 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<ID>%d</ID>\n", MosUtilities::MosGetPid()));
66
67 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<!-- SkuTable infomation -->\n"));
68 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<SkuTable>\n"));
69
70 VP_DEBUG_CHK_NULL(mediaSkuMap);
71
72 for (iter = mediaSkuMap->begin(); iter != mediaSkuMap->end(); iter++)
73 {
74 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<%s> %d </%s>\n", iter->first.c_str(), unsigned(iter->second), iter->first.c_str()));
75 }
76 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t</SkuTable>\n"));
77
78 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<!-- WaTable information -->\n"));
79 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t<WaTable>\n"));
80
81 VP_DEBUG_CHK_NULL(mediaWaMap);
82
83 for (iter = mediaWaMap->begin(); iter != mediaWaMap->end(); iter++)
84 {
85 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t\t<%s> %d </%s>\n", iter->first.c_str(), unsigned(iter->second), iter->first.c_str()));
86 }
87 VP_DEBUG_CHK_STATUS(VpDumperTool::AppendString(false, &pcOutContents, "\t</WaTable>\n"));
88
89 MOS_SecureStringPrint(sPath, MAX_PATH, MAX_PATH, "%s%c%s.xml", pParamsDumpSpec->outFileLocation, MOS_DIR_SEPERATOR, SkuWatableFileName.c_str());
90 VpDumperTool::GetOsFilePath(sPath, sOsPath);
91 VP_DEBUG_CHK_STATUS(MosUtilities::MosWriteFileFromPtr(sOsPath, pcOutContents, strlen(pcOutContents)));
92
93 finish:
94 if (pcOutContents)
95 {
96 MOS_FreeMemory(pcOutContents);
97 pcOutContents = nullptr;
98 }
99
100 return eStatus;
101 }
102
103 #endif // (_DEBUG || _RELEASE_INTERNAL)