Debian Codegraph @

media_softlet/agnostic/common/shared/packet/media_packet.h

raw
1 /*
2 * Copyright (c) 2018, 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 //!
24 //! \file media_packet.h
25 //! \brief Defines the common interface for media packet
26 //! \details The media packet is further sub-divided into mdf and cmd type
27 //! this file is for the base interface which is shared by all packet.
28 //!
29
30 #ifndef __MEDIA_PACKET_H__
31 #define __MEDIA_PACKET_H__
32 #include <stdint.h>
33 #include <memory>
34 #include <string>
35 #include "media_user_setting.h"
36 #include "mhw_itf.h"
37 #include "mhw_utilities_next.h"
38 #include "mos_defs.h"
39 #include "mos_os_specific.h"
40 #include "mos_os.h"
41 #include "mhw_cmdpar.h"
42 #include "mhw_mi_itf.h"
43 class MediaStatusReport;
44 class MhwMiInterface;
45 namespace mhw{namespace mi{class Itf;}} // namespace mhw
46
47 #define __SETPAR(CMD, itf) \
48 \
49 auto &par = itf->MHW_GETPAR_F(CMD)(); \
50 par = {}; \
51 using setting_t = typename std::remove_reference<decltype(*itf)>::type::ParSetting; \
52 auto p = dynamic_cast<const setting_t *>(this); \
53 if (p) \
54 { \
55 MHW_CHK_STATUS_RETURN(p->MHW_SETPAR_F(CMD)(par)); \
56 } \
57 if (m_featureManager) \
58 { \
59 for (auto feature : *m_featureManager) \
60 { \
61 p = dynamic_cast<const setting_t *>(feature); \
62 if (p) \
63 { \
64 MHW_CHK_STATUS_RETURN(p->MHW_SETPAR_F(CMD)(par)); \
65 } \
66 } \
67 }
68
69 #define SETPAR(CMD, itf) \
70 { \
71 __SETPAR(CMD, itf) \
72 }
73
74 #define SETPAR_AND_ADDCMD(CMD, itf, ...) \
75 { \
76 __SETPAR(CMD, itf) \
77 MHW_CHK_STATUS_RETURN(itf->MHW_ADDCMD_F(CMD)(__VA_ARGS__)); \
78 }
79
80 namespace CMRT_UMD
81 {
82 class CmTask;
83 }
84 class MediaTask;
85 class MediaPacket
86 {
87 public:
88 enum PacketPhaseFlag
89 {
90 firstPacket = 0x01,
91 lastPacket = 0x02,
92 otherPacket = 0x04
93 };
94
95 virtual ~MediaPacket() { }
96 //!
97 //! \brief MediaPacket constructor
98 //! \param [in] task
99 //! Pointer to MediaTask, it's assigned when create the packet,
100 //! the task is associated with current packet for future submit
101 //!
102 MediaPacket(MediaTask* task) : m_task(task) { }
103
104 //!
105 //! \brief Initialize the media packet, allocate required resources
106 //! \return MOS_STATUS
107 //! MOS_STATUS_SUCCESS if success, else fail reason
108 //!
109 virtual MOS_STATUS Init() = 0;
110
111 //!
112 //! \brief Destroy the media packet and release the resources
113 //! \return MOS_STATUS
114 //! MOS_STATUS_SUCCESS if success, else fail reason
115 //!
116 virtual MOS_STATUS Destroy() = 0;
117
118 //!
119 //! \brief Prepare the parameters for command submission
120 //! \return MOS_STATUS
121 //! MOS_STATUS_SUCCESS if success, else fail reason
122 //!
123 virtual MOS_STATUS Prepare() = 0;
124
125 //!
126 //! \brief Add the command sequence into the commandBuffer and
127 //! and return to the caller task
128 //! \param [in] commandBuffer
129 //! Pointer to the command buffer which is allocated by caller
130 //! \return MOS_STATUS
131 //! MOS_STATUS_SUCCESS if success, else fail reason
132 //!
133 virtual MOS_STATUS Submit(MOS_COMMAND_BUFFER* commandBuffer, uint8_t packetPhase = otherPacket)
134 {
135 return MOS_STATUS_SUCCESS;
136 }
137
138 //!
139 //! \brief Add CmKernel into CmTask and return to the caller task
140 //! \param [in] cmTask
141 //! Pointer to the CmTask which is created by caller
142 //! \return MOS_STATUS
143 //! MOS_STATUS_SUCCESS if success, else fail reason
144 //!
145 virtual MOS_STATUS Submit(CMRT_UMD::CmTask* cmTask)
146 {
147 return MOS_STATUS_SUCCESS;
148 }
149
150 //! \brief Calculate Command Size
151 //!
152 //! \param [in, out] commandBufferSize
153 //! requested size
154 //! \param [in, out] requestedPatchListSize
155 //! requested size
156 //! \return uint32_t
157 //! Command size calculated
158 //!
159 virtual MOS_STATUS CalculateCommandSize(
160 uint32_t &commandBufferSize,
161 uint32_t &requestedPatchListSize)
162 {
163 return MOS_STATUS_SUCCESS;
164 }
165
166 //!
167 //! \brief Get current associated media task
168 //! \return MediaTask*
169 //! return the media task pointer
170 //!
171 MediaTask* GetActiveTask()
172 {
173 return m_task;
174 }
175
176
177 //!
178 //! \brief Dump output resources or infomation after submit
179 //! \return MOS_STATUS
180 //! MOS_STATUS_SUCCESS if success, else fail reason
181 //!
182 virtual MOS_STATUS DumpOutput()
183 {
184 return MOS_STATUS_SUCCESS;
185 }
186
187 //!
188 //! \brief Get Packet Name
189 //! \return std::string
190 //!
191 virtual std::string GetPacketName()
192 {
193 return "";
194 }
195
196 #if (_DEBUG || _RELEASE_INTERNAL)
197 //!
198 //! \brief Store engine id data
199 //! \return MOS_STATUS
200 //! MOS_STATUS_SUCCESS if success, else fail
201 //!
202 MOS_STATUS StoreEngineId(MOS_COMMAND_BUFFER *cmdBuffer, uint32_t statusReportType, uint8_t curPipe = 0, uint32_t csEngineIdReg = CS_ENGINE_ID_OFFSET);
203 #endif
204
205 protected:
206
207 //!
208 //! \brief Start Status Report
209 //! \param [in] srType
210 //! status report type for send cmds
211 //! \param [in, out] cmdBuffer
212 //! cmdbuffer to send cmds
213 //! \return MOS_STATUS
214 //! MOS_STATUS_SUCCESS if success, else fail reason
215 //!
216 virtual MOS_STATUS StartStatusReport(
217 uint32_t srType,
218 MOS_COMMAND_BUFFER *cmdBuffer);
219
220 //!
221 //! \brief Start Status Report - Refactor Version
222 //! \param [in] srType
223 //! status report type for send cmds
224 //! \param [in, out] cmdBuffer
225 //! cmdbuffer to send cmds
226 //! \return MOS_STATUS
227 //! MOS_STATUS_SUCCESS if success, else fail reason
228 //!
229 virtual MOS_STATUS StartStatusReportNext(
230 uint32_t srType,
231 MOS_COMMAND_BUFFER *cmdBuffer);
232
233 virtual MOS_STATUS UpdateStatusReport(
234 uint32_t srType,
235 MOS_COMMAND_BUFFER *cmdBuffer);
236
237 //!
238 //! \brief Update Status Report - Refactor Version
239 //! \param [in] srType
240 //! status report type for send cmds
241 //! \param [in, out] cmdBuffer
242 //! cmdbuffer to send cmds
243 //! \return MOS_STATUS
244 //! MOS_STATUS_SUCCESS if success, else fail reason
245 //!
246 virtual MOS_STATUS UpdateStatusReportNext(
247 uint32_t srType,
248 MOS_COMMAND_BUFFER *cmdBuffer);
249
250 //!
251 //! \brief End Status Report
252 //! \param [in] srType
253 //! status report type for send cmds
254 //! \param [in, out] cmdBuffer
255 //! cmdbuffer to send cmds
256 //! \return MOS_STATUS
257 //! MOS_STATUS_SUCCESS if success, else fail reason
258 //!
259 virtual MOS_STATUS EndStatusReport(
260 uint32_t srType,
261 MOS_COMMAND_BUFFER *cmdBuffer);
262
263 //!
264 //! \brief End Status Report - Refactor Version
265 //! \param [in] srType
266 //! status report type for send cmds
267 //! \param [in, out] cmdBuffer
268 //! cmdbuffer to send cmds
269 //! \return MOS_STATUS
270 //! MOS_STATUS_SUCCESS if success, else fail reason
271 //!
272 virtual MOS_STATUS EndStatusReportNext(
273 uint32_t srType,
274 MOS_COMMAND_BUFFER *cmdBuffer);
275
276 //!
277 //! \brief Set the start tag in the command buffer
278 //! \param [in] osResource
279 //! reource used in the cmd
280 //! \param [in] offset
281 //! reource offset used the cmd
282 //! \param [in] srType
283 //! status report type
284 //! \param [in, out] cmdBuffer
285 //! cmdbuffer to send cmds
286 //! \return MOS_STATUS
287 //! MOS_STATUS_SUCCESS if success, else fail reason
288 //!
289 virtual MOS_STATUS SetStartTag(
290 MOS_RESOURCE *osResource,
291 uint32_t offset,
292 uint32_t srType,
293 MOS_COMMAND_BUFFER *cmdBuffer);
294
295 //!
296 //! \brief Set the start tag in the command buffer - Refactor Version
297 //! \param [in] osResource
298 //! reource used in the cmd
299 //! \param [in] offset
300 //! reource offset used the cmd
301 //! \param [in] srType
302 //! status report type
303 //! \param [in, out] cmdBuffer
304 //! cmdbuffer to send cmds
305 //! \return MOS_STATUS
306 //! MOS_STATUS_SUCCESS if success, else fail reason
307 //!
308 virtual MOS_STATUS SetStartTagNext(
309 MOS_RESOURCE *osResource,
310 uint32_t offset,
311 uint32_t srType,
312 MOS_COMMAND_BUFFER *cmdBuffer);
313
314 //!
315 //! \brief Set the end tag in the command buffer
316 //! \param [in] osResource
317 //! reource used in the cmd
318 //! \param [in] offset
319 //! reource offset used the cmd
320 //! \param [in] srType
321 //! status report type
322 //! \param [in, out] cmdBuffer
323 //! cmdbuffer to send cmds
324 //! \return MOS_STATUS
325 //! MOS_STATUS_SUCCESS if success, else fail reason
326 //!
327 virtual MOS_STATUS SetEndTag(
328 MOS_RESOURCE *osResource,
329 uint32_t offset,
330 uint32_t srType,
331 MOS_COMMAND_BUFFER *cmdBuffer);
332
333 //!
334 //! \brief Set the end tag in the command buffer - Refactor Version
335 //! \param [in] osResource
336 //! reource used in the cmd
337 //! \param [in] offset
338 //! reource offset used the cmd
339 //! \param [in] srType
340 //! status report type
341 //! \param [in, out] cmdBuffer
342 //! cmdbuffer to send cmds
343 //! \return MOS_STATUS
344 //! MOS_STATUS_SUCCESS if success, else fail reason
345 //!
346 virtual MOS_STATUS SetEndTagNext(
347 MOS_RESOURCE *osResource,
348 uint32_t offset,
349 uint32_t srType,
350 MOS_COMMAND_BUFFER *cmdBuffer);
351
352 protected:
353 MediaTask *m_task = nullptr; //!< MediaTask associated with current packet
354 PMOS_INTERFACE m_osInterface = nullptr;
355 MhwMiInterface *m_miInterface = nullptr;
356 MediaStatusReport *m_statusReport = nullptr;
357 std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr;
358 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; //!< usersettingInstance
359
360 //!
361 //! \brief Add native fence sync BB start command before force wakeup and prolog
362 //! \param [in, out] cmdBuffer
363 //! Reference to command buffer
364 //! \return MOS_STATUS
365 //! MOS_STATUS_SUCCESS if success, else fail reason
366 //!
367 MOS_STATUS AddNativeFenceSyncBBStartCmd(MOS_COMMAND_BUFFER &cmdBuffer)
368 {
369 return Mhw_SendNativeFenceSyncBBStartCmd(&cmdBuffer, m_osInterface, m_miItf);
370 }
371
372 MEDIA_CLASS_DEFINE_END(MediaPacket)
373 };
374
375 #endif // !__MEDIA_PACKET_H__