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 File Name: vphal_render_sfc_xe_xpm.h
24 
25 Abstract:
26     Handles rendering operations for VE to SFC Pipe
27 
28 Notes:
29     This module contains rendering definitions for Adv processing - all
30     rendering parameters should be defined in this module, along with platform
31     capabilities and/or restrictions
32 
33 ======================= end_copyright_notice ==================================*/
34 //!
35 //! \file     vphal_render_sfc_xe_xpm.h
36 //! \brief    The header file of the VPHAL SFC Xe_XPM rendering component
37 //! \details  The SFC renderer supports Scaling, IEF, CSC/ColorFill and Rotation.
38 //!           It's responsible for setting up HW states and generating the SFC
39 //!           commands.
40 //!
41 #ifndef __VPHAL_RENDER_SFC_XE_XPM_H__
42 #define __VPHAL_RENDER_SFC_XE_XPM_H__
43 
44 #include "mhw_sfc_xe_xpm.h"
45 #include "vphal_render_sfc_g12_base.h"
46 
47 #if __VPHAL_SFC_SUPPORTED
48 class VphalSfcStateXe_Xpm :virtual public VphalSfcStateG12
49 {
50 public:
51     VphalSfcStateXe_Xpm(
52         PMOS_INTERFACE       osInterface,
53         PRENDERHAL_INTERFACE renderHal,
54         PMHW_SFC_INTERFACE   sfcInterface);
55 
~VphalSfcStateXe_Xpm()56     virtual ~VphalSfcStateXe_Xpm()
57     {
58 
59     }
60 
61     //!
62     //! \brief    Initialize sfc render data
63     //! \return   void
64     //!
InitRenderData()65     virtual void InitRenderData()
66     {
67         VphalSfcState::InitRenderData();
68         m_renderData.SfcStateParams = (MHW_SFC_STATE_PARAMS_XE_XPM*)MOS_AllocAndZeroMemory(sizeof(MHW_SFC_STATE_PARAMS_XE_XPM));
69     }
70 
71 protected:
72 
73     virtual bool IsOutputFormatSupported(
74         PVPHAL_SURFACE              outSurface);
75 
76     virtual MOS_STATUS SetSfcStateParams(
77         PVPHAL_VEBOX_RENDER_DATA    pRenderData,
78         PVPHAL_SURFACE              pSrcSurface,
79         PVPHAL_SURFACE              pOutSurface);
80 
81     VPHAL_OUTPUT_PIPE_MODE GetOutputPipe(
82         PVPHAL_SURFACE              pSrc,
83         PVPHAL_SURFACE              pRenderTarget,
84         PCVPHAL_RENDER_PARAMS       pcRenderParams);
85 
86     //!
87     //! \brief    Set Sfc index used by HW
88     //! \details  VPHAL set Sfc index used by HW
89     //! \param    [in] dwSfcIndex;
90     //!           set which Sfc can be used by HW
91     //! \param    [in] dwSfcCount;
92     //!           set Sfc Count
93     //! \return   MOS_STATUS
94     //!           MOS_STATUS_SUCCESS if success, else fail reason
95     virtual MOS_STATUS SetSfcIndex(
96         uint32_t                    dwSfcIndex,
97         uint32_t                    dwSfcCount);
98 
99     //!
100     //! \brief    Free resources used by SFC Pipe
101     //! \details  Free the AVS and IEF line buffer surfaces for SFC
102     //! \return   void
103     //!
104     virtual void FreeResources();
105 
106     //!
107     //! \brief    Allocate Resources for SFC Pipe
108     //! \details  Allocate the AVS and IEF line buffer surfaces for SFC
109     //! \return   Return MOS_STATUS_SUCCESS if successful, otherwise failed
110     //!
111     virtual MOS_STATUS AllocateResources();
112 
113     //!
114     //! \brief    Get width and height align unit of output format
115     //! \param    [in] outputFormat
116     //!           output format
117     //! \param    [out] widthAlignUnit
118     //!           width align unit
119     //! \param    [out] heightAlignUnit
120     //!           height align unit
121     //! \return   void
122     //!
123     virtual void GetOutputWidthHeightAlignUnit(
124         MOS_FORMAT outputFormat,
125         uint16_t & widthAlignUnit,
126         uint16_t & heightAlignUnit,
127         bool       isInterlacedScaling);
128 
129     //!
130     //! \brief    Get width and height align unit of input format
131     //! \param    [in] inputFormat
132     //!           input format
133     //! \param    [in] outputFormat
134     //!           output format
135     //! \param    [out] widthAlignUnit
136     //!           width align unit
137     //! \param    [out] heightAlignUnit
138     //!           height align unit
139     //! \return   void
140     //!
141     virtual void GetInputWidthHeightAlignUnit(
142         MOS_FORMAT              inputFormat,
143         MOS_FORMAT              outputFormat,
144         uint16_t                &widthAlignUnit,
145         uint16_t                &heightAlignUnit,
146         bool                    isInterlacedScaling = false);
147 
IsOutputCapable(bool isColorFill,PVPHAL_SURFACE src,PVPHAL_SURFACE renderTarget)148     virtual bool IsOutputCapable(
149         bool            isColorFill,
150         PVPHAL_SURFACE  src,
151         PVPHAL_SURFACE  renderTarget)
152     {
153         bool isOutputCapable = false;
154 
155         VPHAL_RENDER_CHK_NULL_NO_STATUS(src);
156         VPHAL_RENDER_CHK_NULL_NO_STATUS(renderTarget);
157 
158         isOutputCapable = VphalSfcStateG12::IsOutputCapable(
159             isColorFill,
160             src,
161             renderTarget);
162 
163         if (isColorFill &&
164             (renderTarget->rcDst.top != 0 ||
165              renderTarget->rcDst.left != 0))
166         {
167             isOutputCapable = false;
168         }
169 
170 finish:
171         return isOutputCapable;
172     }
173 
174     //!
175     //! \brief    Check whether dithering Needed
176     //! \details  Check whether dithering Needed
177     //! \param    [in] formatInput
178     //!           The input format
179     //!           [in] formatOutput
180     //!           The output format
181     //! \return   bool
182     //!
183     bool IsDitheringNeeded(MOS_FORMAT formatInput, MOS_FORMAT formatOutput);
184 
185     VPHAL_SURFACE m_AVSLineBufferSurfaceSplit[MHW_SFC_MAX_PIPE_NUM_XE_XPM] = {}; //!< AVS Line Buffer Surface for SFC
186     VPHAL_SURFACE m_IEFLineBufferSurfaceSplit[MHW_SFC_MAX_PIPE_NUM_XE_XPM] = {}; //!< IEF Line Buffer Surface for SFC
187 
188     bool m_disableSfcDithering = false;             //!< flag for dithering enable or disable, for debug purpose.
189 };
190 
191 #endif // __VPHAL_SFC_SUPPORTED
192 #endif // __VPHAL_RENDER_SFC_XE_XPM_H__
193