1 /*
2 * Copyright (c) 2017-2022, 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 codechal_mmc_decode_vc1_g12_ext.cpp
24 //! \brief Implements VC1 Gen12 media memory compression extra interface
25 //!
26
27 #include "codechal_mmc_decode_vc1_g12_ext.h"
28 #include "mos_interface.h"
29
CodechalMmcDecodeVc1G12Ext(CodechalHwInterface * hwInterface,CodecHalMmcState * mmcState)30 CodechalMmcDecodeVc1G12Ext::CodechalMmcDecodeVc1G12Ext(
31 CodechalHwInterface* hwInterface,
32 CodecHalMmcState* mmcState) :
33 m_hwInterface(hwInterface),
34 m_mmcState(mmcState)
35 {
36 CODECHAL_DECODE_FUNCTION_ENTER;
37
38 CODECHAL_HW_ASSERT(m_hwInterface);
39 CODECHAL_HW_ASSERT(m_mmcState);
40 }
41
CopyAuxSurfForSkip(PMOS_COMMAND_BUFFER cmdBuffer,PMOS_RESOURCE srcResource,PMOS_RESOURCE destResource)42 MOS_STATUS CodechalMmcDecodeVc1G12Ext::CopyAuxSurfForSkip(
43 PMOS_COMMAND_BUFFER cmdBuffer,
44 PMOS_RESOURCE srcResource,
45 PMOS_RESOURCE destResource)
46 {
47 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
48
49 CODECHAL_DECODE_FUNCTION_ENTER;
50
51 CODECHAL_DECODE_CHK_NULL_RETURN(cmdBuffer);
52 CODECHAL_DECODE_CHK_NULL_RETURN(srcResource);
53 CODECHAL_DECODE_CHK_NULL_RETURN(srcResource->pGmmResInfo);
54 CODECHAL_DECODE_CHK_NULL_RETURN(destResource);
55 CODECHAL_DECODE_CHK_NULL_RETURN(destResource->pGmmResInfo);
56 CODECHAL_DECODE_CHK_NULL_RETURN(m_hwInterface);
57
58 GMM_RESOURCE_FLAG srcFlags = srcResource->pGmmResInfo->GetResFlags();
59 GMM_RESOURCE_FLAG destFlags = destResource->pGmmResInfo->GetResFlags();
60 uint32_t srcArrayIndex = 0;
61 uint32_t destArrayIndex = 0;
62 PMOS_INTERFACE osInterface = m_hwInterface->GetOsInterface();
63
64 CODECHAL_DECODE_CHK_NULL_RETURN(osInterface);
65
66 srcArrayIndex = osInterface->pfnGetResourceArrayIndex(srcResource);
67 destArrayIndex = osInterface->pfnGetResourceArrayIndex(destResource);
68
69 if (m_mmcState->IsMmcEnabled() && srcFlags.Gpu.UnifiedAuxSurface && destFlags.Gpu.UnifiedAuxSurface)
70 {
71 CodechalHucStreamoutParams HucStreamOutParams;
72 MOS_ZeroMemory(&HucStreamOutParams, sizeof(HucStreamOutParams));
73
74 // params calculation for aux data
75 uint64_t srcGfxAddr = m_hwInterface->GetOsInterface()->pfnGetResourceGfxAddress(m_hwInterface->GetOsInterface(), srcResource);
76 uint64_t srcAuxYOffset = srcResource->pGmmResInfo->GetPlanarAuxOffset(srcArrayIndex, GMM_AUX_Y_CCS);
77 uint32_t srcAuxSurfSize = (uint32_t)srcResource->pGmmResInfo->GetAuxQPitch();
78
79 uint64_t destGfxAddr = m_hwInterface->GetOsInterface()->pfnGetResourceGfxAddress(m_hwInterface->GetOsInterface(), destResource);
80 uint64_t destAuxYOffset = destResource->pGmmResInfo->GetPlanarAuxOffset(destArrayIndex, GMM_AUX_Y_CCS);
81 uint32_t destAuxSurfSize = (uint32_t)destResource->pGmmResInfo->GetAuxQPitch();
82
83 // Ind Obj Addr command
84 HucStreamOutParams.dataBuffer = srcResource;
85 HucStreamOutParams.dataSize = srcAuxSurfSize;
86 HucStreamOutParams.dataOffset = MOS_ALIGN_FLOOR(srcAuxYOffset, MHW_PAGE_SIZE);
87 HucStreamOutParams.streamOutObjectBuffer = destResource;
88 HucStreamOutParams.streamOutObjectSize = destAuxSurfSize;
89 HucStreamOutParams.streamOutObjectOffset = MOS_ALIGN_FLOOR(destAuxYOffset, MHW_PAGE_SIZE);
90
91 // Stream object params
92 HucStreamOutParams.indStreamInLength = srcAuxSurfSize;
93 HucStreamOutParams.inputRelativeOffset = 0;
94 HucStreamOutParams.outputRelativeOffset = 0;
95
96 CODECHAL_DECODE_CHK_STATUS_RETURN(m_hwInterface->PerformHucStreamOut(
97 &HucStreamOutParams,
98 cmdBuffer));
99 }
100
101 return eStatus;
102 }
103