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     decode_jpeg_packet_m12.cpp
24 //! \brief    Defines the interface for jpeg decode packet of Gen12
25 //!
26 #include "decode_jpeg_packet_m12.h"
27 #include "decode_utils.h"
28 #include "decode_jpeg_pipeline.h"
29 #include "decode_jpeg_basic_feature.h"
30 #include "decode_status_report_defs.h"
31 #include "mos_solo_generic.h"
32 #include "decode_status_report_defs.h"
33 #include "decode_resource_auto_lock.h"
34 #include "hal_oca_interface.h"
35 
36 namespace decode{
37 
Submit(MOS_COMMAND_BUFFER * cmdBuffer,uint8_t packetPhase)38 MOS_STATUS JpegDecodePktM12::Submit(
39     MOS_COMMAND_BUFFER* cmdBuffer,
40     uint8_t packetPhase)
41 {
42     DECODE_FUNC_CALL();
43 
44     PERF_UTILITY_AUTO(__FUNCTION__, PERF_DECODE, PERF_LEVEL_HAL);
45 
46     DECODE_CHK_NULL(cmdBuffer);
47     DECODE_CHK_NULL(m_hwInterface);
48 
49     DECODE_CHK_STATUS(m_miInterface->SetWatchdogTimerThreshold(
50         m_jpegBasicFeature->m_width, m_jpegBasicFeature->m_height, false));
51 
52     DECODE_CHK_STATUS(Mos_Solo_PreProcessDecode(m_osInterface, &m_jpegBasicFeature->m_destSurface));
53     SetPerfTag(m_jpegBasicFeature->m_mode, m_jpegBasicFeature->m_pictureCodingType);
54 
55     if (IsPrologRequired())
56     {
57         DECODE_CHK_STATUS(AddForceWakeup(*cmdBuffer));
58         DECODE_CHK_STATUS(SendPrologWithFrameTracking(*cmdBuffer, true));
59     }
60 
61     auto mmioRegisters = m_hwInterface->GetMfxInterface()->GetMmioRegisters(MHW_VDBOX_NODE_1);
62     HalOcaInterface::On1stLevelBBStart(*cmdBuffer, *m_osInterface->pOsContext,
63         m_osInterface->CurrentGpuContextHandle, *m_miInterface, *mmioRegisters);
64 
65     DECODE_CHK_STATUS(PackPictureLevelCmds(*cmdBuffer));
66 
67     HalOcaInterface::On1stLevelBBEnd(*cmdBuffer, *m_osInterface);
68     DECODE_CHK_STATUS(m_allocator->SyncOnResource(&m_jpegBasicFeature->m_resDataBuffer, false));
69     DECODE_CHK_STATUS(Mos_Solo_PostProcessDecode(m_osInterface, &m_jpegBasicFeature->m_destSurface));
70 
71     return MOS_STATUS_SUCCESS;
72 }
73 
PackPictureLevelCmds(MOS_COMMAND_BUFFER & cmdBuffer)74 MOS_STATUS JpegDecodePktM12::PackPictureLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer)
75 {
76     DECODE_FUNC_CALL();
77 
78     PERF_UTILITY_AUTO(__FUNCTION__, PERF_DECODE, PERF_LEVEL_HAL);
79 
80     DECODE_CHK_STATUS(StartStatusReport(statusReportMfx, &cmdBuffer));
81     DECODE_CHK_STATUS(m_picturePkt->Execute(cmdBuffer));
82 
83     DECODE_CHK_STATUS(EnsureAllCommandsExecuted(cmdBuffer));
84     DECODE_CHK_STATUS(EndStatusReport(statusReportMfx, &cmdBuffer));
85     DECODE_CHK_STATUS(UpdateStatusReport(statusReportGlobalCount, &cmdBuffer));
86 
87     DECODE_CHK_STATUS(m_miInterface->AddMiBatchBufferEnd(&cmdBuffer, nullptr));
88 
89     return MOS_STATUS_SUCCESS;
90 }
91 
EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER & cmdBuffer)92 MOS_STATUS JpegDecodePktM12::EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER &cmdBuffer)
93 {
94     DECODE_FUNC_CALL();
95 
96     // Send MI_FLUSH command
97     MHW_MI_FLUSH_DW_PARAMS flushDwParams;
98     MOS_ZeroMemory(&flushDwParams, sizeof(flushDwParams));
99     DECODE_CHK_STATUS(m_miInterface->AddMiFlushDwCmd(&cmdBuffer, &flushDwParams));
100 
101     return MOS_STATUS_SUCCESS;
102 }
103 
104 }
105 
106