xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/vp/hal/packet/vp_cmd_packet.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
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 #include "vp_cmd_packet.h"
23 #include "vp_utils.h"
24 
25 namespace vp {
26 
VpCmdPacket(MediaTask * task,PVP_MHWINTERFACE hwInterface,PVpAllocator & allocator,VPMediaMemComp * mmc,PacketType packetId)27 VpCmdPacket::VpCmdPacket(
28     MediaTask *task,
29     PVP_MHWINTERFACE hwInterface,
30     PVpAllocator &allocator,
31     VPMediaMemComp *mmc,
32     PacketType packetId)
33     :CmdPacket(task),
34     m_allocator(allocator),
35     m_mmc(mmc),
36     m_PacketId(packetId)
37 {
38     m_surfSetting.Clean();
39     m_hwInterface = hwInterface;
40     VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(m_hwInterface);
41     VP_PUBLIC_CHK_NULL_NO_STATUS_RETURN(m_hwInterface->m_osInterface);
42 
43     m_osInterface    = m_hwInterface->m_osInterface;
44     m_userSettingPtr = m_hwInterface->m_osInterface->pfnGetUserSettingInstance(m_hwInterface->m_osInterface);
45     m_report         = hwInterface->m_reporting;
46 }
47 
VpCmdPacketInit()48 MOS_STATUS VpCmdPacket::VpCmdPacketInit()
49 {
50     VP_FUNC_CALL();
51 
52     return MOS_STATUS_SUCCESS;
53 }
54 
SetMediaFrameTracking(RENDERHAL_GENERIC_PROLOG_PARAMS & genericPrologParams)55 MOS_STATUS VpCmdPacket::SetMediaFrameTracking(RENDERHAL_GENERIC_PROLOG_PARAMS &genericPrologParams)
56 {
57     PMOS_INTERFACE  osInterface = nullptr;
58     PMOS_RESOURCE   gpuStatusBuffer = nullptr;
59 
60     VP_PUBLIC_CHK_NULL_RETURN(m_hwInterface);
61     VP_PUBLIC_CHK_NULL_RETURN(m_hwInterface->m_osInterface);
62 
63     osInterface = m_hwInterface->m_osInterface;
64 
65 #ifndef EMUL
66     if(m_PacketCaps.lastSubmission && osInterface->bEnableKmdMediaFrameTracking)
67     {
68         // Get GPU Status buffer
69         VP_PUBLIC_CHK_STATUS_RETURN(osInterface->pfnGetGpuStatusBufferResource(osInterface, gpuStatusBuffer));
70         VP_PUBLIC_CHK_NULL_RETURN(gpuStatusBuffer);
71         // Register the buffer
72         VP_PUBLIC_CHK_STATUS_RETURN(osInterface->pfnRegisterResource(osInterface, gpuStatusBuffer, true, true));
73 
74         genericPrologParams.bEnableMediaFrameTracking = true;
75         genericPrologParams.presMediaFrameTrackingSurface = gpuStatusBuffer;
76         genericPrologParams.dwMediaFrameTrackingTag = osInterface->pfnGetGpuStatusTag(osInterface, osInterface->CurrentGpuContextOrdinal);
77         genericPrologParams.dwMediaFrameTrackingAddrOffset = osInterface->pfnGetGpuStatusTagOffset(osInterface, osInterface->CurrentGpuContextOrdinal);
78 
79         VP_PUBLIC_CHK_NULL_RETURN(osInterface->pfnIncrementGpuStatusTag);
80         // Increment GPU Status Tag
81         osInterface->pfnIncrementGpuStatusTag(osInterface, osInterface->CurrentGpuContextOrdinal);
82     }
83 #endif
84 
85     return MOS_STATUS_SUCCESS;
86 }
87 
88 }