1 /*
2 * Copyright (c) 2019, 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 decode_marker_packet.cpp
24 //! \brief Defines the interface for decode marker sub packet
25 //!
26 #include "decode_marker_packet.h"
27 #include "decode_common_feature_defs.h"
28
29 namespace decode
30 {
31
DecodeMarkerPkt(DecodePipeline * pipeline,CodechalHwInterfaceNext * hwInterface)32 DecodeMarkerPkt::DecodeMarkerPkt(DecodePipeline *pipeline, CodechalHwInterfaceNext *hwInterface)
33 : DecodeSubPacket(pipeline, hwInterface)
34 {
35 m_hwInterface = hwInterface;
36 }
37
Init()38 MOS_STATUS DecodeMarkerPkt::Init()
39 {
40 DECODE_CHK_NULL(m_pipeline);
41 DECODE_CHK_NULL(m_hwInterface);
42
43 m_miItf = m_hwInterface->GetMiInterfaceNext();
44 DECODE_CHK_NULL(m_miItf);
45
46 MediaFeatureManager *featureManager = m_pipeline->GetFeatureManager();
47 DECODE_CHK_NULL(featureManager);
48
49 m_marker = dynamic_cast<DecodeMarker *>(
50 featureManager->GetFeature(DecodeFeatureIDs::decodeMarker));
51 DECODE_CHK_NULL(m_marker);
52
53 return MOS_STATUS_SUCCESS;
54 }
55
Prepare()56 MOS_STATUS DecodeMarkerPkt::Prepare()
57 {
58 return MOS_STATUS_SUCCESS;
59 }
60
Execute(MOS_COMMAND_BUFFER & cmdBuffer)61 MOS_STATUS DecodeMarkerPkt::Execute(MOS_COMMAND_BUFFER& cmdBuffer)
62 {
63 if (!m_marker->m_setMarkerEnabled)
64 {
65 return MOS_STATUS_SUCCESS;
66 }
67
68 if (m_pipeline->GetMediaContext()->IsRenderEngineUsed())
69 {
70 // Send pipe_control to get the timestamp
71 auto &miPipeControlParams = m_miItf->MHW_GETPAR_F(PIPE_CONTROL)();
72 miPipeControlParams = {};
73 miPipeControlParams.presDest = &m_marker->m_markerBuffer->OsResource;
74 miPipeControlParams.dwResourceOffset = 0;
75 miPipeControlParams.dwPostSyncOp = MHW_FLUSH_WRITE_TIMESTAMP_REG;
76 miPipeControlParams.dwFlushMode = MHW_FLUSH_WRITE_CACHE;
77 DECODE_CHK_STATUS(m_miItf->MHW_ADDCMD_F(PIPE_CONTROL)(&cmdBuffer, NULL));
78 }
79 else
80 {
81 // Send flush_dw to get the timestamp
82 auto &miFlushDwParams = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)();
83 miFlushDwParams = {};
84 miFlushDwParams.pOsResource = &m_marker->m_markerBuffer->OsResource;
85 miFlushDwParams.dwResourceOffset = 0;
86 miFlushDwParams.postSyncOperation = MHW_FLUSH_WRITE_TIMESTAMP_REG;
87 miFlushDwParams.bQWordEnable = 1;
88 DECODE_CHK_STATUS(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(&cmdBuffer, NULL));
89 }
90
91 return MOS_STATUS_SUCCESS;
92 }
93
CalculateCommandSize(uint32_t & commandBufferSize,uint32_t & requestedPatchListSize)94 MOS_STATUS DecodeMarkerPkt::CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize)
95 {
96 commandBufferSize = 0;
97 requestedPatchListSize = 0;
98 return MOS_STATUS_SUCCESS;
99 }
100
101 } // namespace decode
102