1 /*===================== begin_copyright_notice ==================================
2
3 # Copyright (c) 2020-2021, Intel Corporation
4
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
11
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 # OTHER DEALINGS IN THE SOFTWARE.
22
23 ======================= end_copyright_notice ==================================*/
24 //!
25 //! \file vphal_render_composite_xe_xpm.cpp
26 //! \brief Composite related VPHAL functions
27 //! \details Unified VP HAL Composite module including render initialization,
28 //! resource allocation/free and rendering
29 //!
30 #include "vphal_render_composite_xe_xpm.h"
31
32 #define VPHAL_SAMPLER_Y1 4
33 #define VPHAL_SAMPLER_U1 5
34 #define VPHAL_SAMPLER_V1 6
35 #define VPHAL_COMP_SOURCE_DEPTH 16
36 #define VPHAL_COMP_P010_DEPTH 0
37
38 const int32_t Samplerindex[2][3] = { {VPHAL_SAMPLER_Y, VPHAL_SAMPLER_U, VPHAL_SAMPLER_V },
39 {VPHAL_SAMPLER_Y1, VPHAL_SAMPLER_U1, VPHAL_SAMPLER_V1}};
40 const uint8_t SamplerSelectionArray[2][8] = { {0, 0, 0, 0, 0, 0, 0, 0},
41 {1, 1, 1, 1, 1, 1, 1, 1}};
42
GetSamplerIndex(PVPHAL_SURFACE pSurface,PRENDERHAL_SURFACE_STATE_ENTRY pEntry,int32_t * pSamplerIndex,PMHW_SAMPLER_TYPE pSamplerType)43 MOS_STATUS CompositeStateXe_Xpm ::GetSamplerIndex(
44 PVPHAL_SURFACE pSurface,
45 PRENDERHAL_SURFACE_STATE_ENTRY pEntry,
46 int32_t* pSamplerIndex,
47 PMHW_SAMPLER_TYPE pSamplerType)
48 {
49 if (pSurface == nullptr || pSamplerIndex == nullptr || pSamplerType == nullptr || pEntry == nullptr)
50 {
51 VPHAL_RENDER_ASSERTMESSAGE("Invalid parameter.");
52 return MOS_STATUS_NULL_POINTER;
53 }
54
55 // reset Scaling mode to NEAREST due to XeHP don't have AVS
56 if (pSurface->ScalingMode == VPHAL_SCALING_AVS)
57 {
58 pSurface->ScalingMode = VPHAL_SCALING_BILINEAR;
59 }
60
61 // if Scalingmode is BILINEAR, use the 4,5,6. if NEAREST, use 1,2,3
62 pEntry->bAVS = false;
63 *pSamplerType = MHW_SAMPLER_TYPE_3D;
64
65 *pSamplerIndex = Samplerindex[pSurface->ScalingMode][pEntry->YUVPlane];
66
67 return MOS_STATUS_SUCCESS;
68 }
69
IsSamplerIDForY(int32_t SamplerID)70 bool CompositeStateXe_Xpm ::IsSamplerIDForY(int32_t SamplerID)
71 {
72 return ((SamplerID == VPHAL_SAMPLER_Y) || (SamplerID == VPHAL_SAMPLER_Y1)) ? true : false;
73 }
74
Set3DSamplerStatus(PVPHAL_SURFACE pSurface,uint8_t Layer,MEDIA_OBJECT_KA2_STATIC_DATA * pStatic)75 MOS_STATUS CompositeStateXe_Xpm ::Set3DSamplerStatus(
76 PVPHAL_SURFACE pSurface,
77 uint8_t Layer,
78 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic)
79 {
80 if (pStatic == nullptr || pSurface == nullptr || Layer > 7)
81 {
82 VPHAL_RENDER_ASSERTMESSAGE("Invalid parameter.");
83 return MOS_STATUS_INVALID_PARAMETER;
84 }
85 // reset Scaling mode to NEAREST due to XeHP don't have AVS
86 if (pSurface->ScalingMode == VPHAL_SCALING_AVS)
87 {
88 pSurface->ScalingMode = VPHAL_SCALING_BILINEAR;
89 }
90
91 // Set which layer's Sampler status' selection: MEDIA_OBJECT_KA2_STATIC_DATA's DW14's bit 24 to 31.
92 pStatic->DW14.Value |= (SamplerSelectionArray[pSurface->ScalingMode][Layer] << (Layer+24));
93
94 return MOS_STATUS_SUCCESS;
95 }
96
UpdateInlineDataStatus(PVPHAL_SURFACE pSurface,MEDIA_OBJECT_KA2_STATIC_DATA * pStatic)97 MOS_STATUS CompositeStateXe_Xpm ::UpdateInlineDataStatus(
98 PVPHAL_SURFACE pSurface,
99 MEDIA_OBJECT_KA2_STATIC_DATA *pStatic)
100 {
101 uint32_t uiBitDepth = 0;
102
103 if (pStatic == nullptr || pSurface == nullptr)
104 {
105 VPHAL_RENDER_ASSERTMESSAGE("Invalid parameter.");
106 return MOS_STATUS_INVALID_PARAMETER;
107 }
108
109 uiBitDepth = VpHal_GetSurfaceBitDepth(pSurface->Format);
110 pStatic->DW07.OutputDepth = VPHAL_COMP_P010_DEPTH;
111 if (uiBitDepth && !(pSurface->Format == Format_P010 || pSurface->Format == Format_Y210))
112 {
113 pStatic->DW07.OutputDepth = VPHAL_COMP_SOURCE_DEPTH - uiBitDepth;
114 }
115
116 return MOS_STATUS_SUCCESS;
117 }
118
119 //!
120 //! \brief Get intermediate surface output
121 //! \param pOutput
122 //! [in] Pointer to Intermediate Output Surface
123 //! \return PVPHAL_SURFACE
124 //! Return the chose output
125 //!
GetIntermediateOutput(PVPHAL_SURFACE & output)126 MOS_STATUS CompositeStateXe_Xpm::GetIntermediateOutput(PVPHAL_SURFACE &output)
127 {
128 if (output == &m_Intermediate)
129 {
130 output = &m_Intermediate1;
131 }
132 else
133 {
134 output = &m_Intermediate;
135 }
136 return MOS_STATUS_SUCCESS;
137 }
138