Debian Codegraph @

media_softlet/agnostic/common/shared/statusreport/media_status_report.h

raw
1 /*
2 * Copyright (c) 2018-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 media_status_report.h
24 //! \brief Defines the class for media status report
25 //! \details
26 //!
27 #ifndef __MEDIA_STATUS_REPORT_H__
28 #define __MEDIA_STATUS_REPORT_H__
29
30 #include "mos_os_specific.h"
31 #include "media_status_report_observer.h"
32
33 #define STATUS_REPORT_GLOBAL_COUNT 0
34
35 enum CsEngineIdDef
36 {
37 // Instance ID
38 csInstanceIdVdbox0 = 0,
39 csInstanceIdVdbox1 = 1,
40 csInstanceIdVdbox2 = 2,
41 csInstanceIdVdbox3 = 3,
42 csInstanceIdVdbox4 = 4,
43 csInstanceIdVdbox5 = 5,
44 csInstanceIdVdbox6 = 6,
45 csInstanceIdVdbox7 = 7,
46 csInstanceIdMax,
47 // Class ID
48 classIdVideoEngine = 1,
49 };
50
51 union CsEngineId
52 {
53 struct
54 {
55 uint32_t classId : 3; //[0...4]
56 uint32_t reservedFiled1 : 1; //[0]
57 uint32_t instanceId : 6; //[0...7]
58 uint32_t reservedField2 : 22; //[0]
59 } fields;
60 uint32_t value;
61 };
62
63 class MediaStatusReport
64 {
65 public:
66
67 typedef enum
68 {
69 querySkipped = 0x00,
70 queryStart = 0x01,
71 queryEnd = 0xFF
72 } ExecutingStatus;
73
74 struct StatusBufAddr
75 {
76 MOS_RESOURCE *osResource;
77 uint32_t offset;
78 uint32_t bufSize;
79 };
80
81 //!
82 //! \brief Constructor
83 //!
84 MediaStatusReport(PMOS_INTERFACE osInterface);
85 virtual ~MediaStatusReport() {};
86
87 //!
88 //! \brief Create resources for status report and do initialization
89 //! \return MOS_STATUS
90 //! MOS_STATUS_SUCCESS if success, else fail reason
91 //!
92 virtual MOS_STATUS Create() = 0;
93 //!
94 //! \brief Initialize the status in report for each item
95 //!
96 //! \details Called per frame for normal usages.
97 //! It can be called per tilerow if needed.
98 //!
99 //! \param [in] inputPar
100 //! Pointer to parameters pass to status report.
101 //! \return MOS_STATUS
102 //! MOS_STATUS_SUCCESS if success, else fail reason
103 //!
104 virtual MOS_STATUS Init(void *inputPar) = 0;
105 //!
106 //! \brief Reset Status
107 //!
108 //! \details Called per frame for normal usages.
109 //! It can be called per tilerow if needed.
110 //!
111 //! \return MOS_STATUS
112 //! MOS_STATUS_SUCCESS if success, else fail reason
113 //!
114 virtual MOS_STATUS Reset() = 0;
115 //!
116 //! \brief The entry to get status report.
117 //! \param [in] numStatus
118 //! The requested number of status reports
119 //! \param [out] status
120 //! The point to encode status
121 //! \return MOS_STATUS
122 //! MOS_STATUS_SUCCESS if success, else fail reason
123 //!
124 //!
125 MOS_STATUS GetReport(uint16_t numStatus, void *status);
126 //!
127 //! \brief Get address of status report.
128 //! \param [in] statusReportType
129 //! status report item type
130 //! \param [out] pOsResource
131 //! The point to PMOS_RESOURCE of each item
132 //! \param [out] offset
133 //! Offset of each item
134 //! \return MOS_STATUS
135 //! MOS_STATUS_SUCCESS if success, else fail reason
136 //!
137 //!
138 MOS_STATUS GetAddress(uint32_t statusReportType, PMOS_RESOURCE &osResource, uint32_t &offset);
139 //!
140 //! \brief Get submitted count of status report.
141 //! \return m_submittedCount
142 //!
143 uint32_t GetSubmittedCount() const { return m_submittedCount; }
144
145 #if (_DEBUG || _RELEASE_INTERNAL)
146 //!
147 //! \brief Is Vdbox physical id reporting enabled
148 //! \return m_enableVdboxIdReport
149 //!
150 uint32_t IsVdboxIdReportEnabled()
151 {
152 return m_enableVdboxIdReport;
153 }
154
155 //!
156 //! \brief Parse Vdbox Ids from CsEngineId status buffer
157 //! \return void
158 //!
159 void ParseVdboxIdsFromBuf(const uint32_t *csEngineIdRegBuf);
160
161 //!
162 //! \brief Report Used Vdbox Ids
163 //! \return MOS_STATUS
164 //! MOS_STATUS_SUCCESS if success, else fail reason
165 //!
166 virtual MOS_STATUS ReportUsedVdboxIds();
167 #endif
168 //!
169 //! \brief Get completed count of status report.
170 //! \return The content of m_completedCount
171 //!
172 uint32_t GetCompletedCount() const
173 {
174 if (m_completedCount == nullptr)
175 {
176 return 0;
177 }
178 return (*m_completedCount);
179 }
180
181 //!
182 //! \brief Get reported count of status report.
183 //! \return m_reportedCount
184 //!
185 uint32_t GetReportedCount() const { return m_reportedCount; }
186
187 uint32_t GetIndex(uint32_t count) { return CounterToIndex(count); }
188 //!
189 //! \brief Regist observer of complete event.
190 //! \param [in] observer
191 //! The point to StatusReportObserver who will observe the complete event
192 //! \return MOS_STATUS
193 //! MOS_STATUS_SUCCESS if success, else fail reason
194 //!
195 MOS_STATUS RegistObserver(MediaStatusReportObserver *observer);
196
197 //!
198 //! \brief Unregist observer of complete event.
199 //! \param [in] observer
200 //! The point to StatusReportObserver
201 //! \return MOS_STATUS
202 //! MOS_STATUS_SUCCESS if success, else fail reason
203 //!
204 MOS_STATUS UnregistObserver(MediaStatusReportObserver *observer);
205
206 protected:
207 //!
208 //! \brief Collect the status report information into report buffer.
209 //! \param [in] report
210 //! The report buffer address provided by DDI.
211 //! \param [in] index
212 //! The index of current requesting report.
213 //! \return MOS_STATUS
214 //! MOS_STATUS_SUCCESS if success, else fail reason
215 //!
216 virtual MOS_STATUS ParseStatus(void *report, uint32_t index) = 0;
217
218 //!
219 //! \brief Set unavailable status report information into report buffer.
220 //! \param [in] report
221 //! The report buffer address provided by DDI.
222 //! \return MOS_STATUS
223 //! MOS_STATUS_SUCCESS if success, else fail reason
224 //!
225 virtual MOS_STATUS SetStatus(void *report, uint32_t index, bool outOfRange = false) = 0;
226 //!
227 //! \brief Notify observers that the frame has been completed.
228 //! \param [in] statusBuffer
229 //! The point to status buffer
230 //! \param [in,out] statusReport
231 //! The point to status report
232 //! \return MOS_STATUS
233 //! MOS_STATUS_SUCCESS if success, else fail reason
234 //!
235 MOS_STATUS NotifyObservers(void *mfxStatus, void *rcsStatus, void *statusReport);
236
237 void Lock(){m_lock.lock();};
238 void UnLock(){m_lock.unlock();};
239
240 inline uint32_t CounterToIndex(uint32_t counter)
241 {
242 return counter & (m_statusNum - 1);
243 }
244
245 static const uint32_t m_statusNum = 512;
246
247 PMOS_RESOURCE m_completedCountBuf = nullptr;
248 uint32_t *m_completedCount = nullptr;
249 uint32_t m_submittedCount = 0;
250 uint32_t m_reportedCount = 0;
251 uint32_t m_sizeOfReport = 0;
252
253 StatusBufAddr *m_statusBufAddr = nullptr;
254
255 #if (_DEBUG || _RELEASE_INTERNAL)
256 bool m_enableVdboxIdReport = false;
257 uint32_t m_usedVdboxIds = 0; //!< Used Vdbox physical engine id. Default 0 is not used. Each Hex symbol represents one VDBOX, e.g. bits[3:0] means VD0, bits[7:4] means VD1.
258 #endif
259 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; //!< user setting instance
260 std::recursive_mutex m_lock;
261 std::vector<MediaStatusReportObserver *> m_completeObservers;
262 MEDIA_CLASS_DEFINE_END(MediaStatusReport)
263 };
264
265 #endif // !__MEDIA_STATUS_REPORT_H__