1 /*
2 * Copyright (c) 2018-2020, 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     vp_csc_filter.h
24 //! \brief    Defines the common interface for CSC
25 //!           this file is for the base interface which is shared by all CSC in driver.
26 //!
27 #ifndef __VP_CSC_FILTER_H__
28 #define __VP_CSC_FILTER_H__
29 
30 #include "vp_filter.h"
31 #include "sw_filter.h"
32 
33 namespace vp {
34 class VpCscFilter : public VpFilter
35 {
36 public:
37 
38     VpCscFilter(
39         PVP_MHWINTERFACE vpMhwInterface);
40 
~VpCscFilter()41     ~VpCscFilter()
42     {
43         Destroy();
44     };
45 
46     virtual MOS_STATUS Init() override;
47 
48     virtual MOS_STATUS Prepare() override;
49 
50     virtual MOS_STATUS Destroy() override;
51 
52     virtual MOS_STATUS SetExecuteEngineCaps(
53         FeatureParamCsc         &cscParams,
54         VP_EXECUTE_CAPS         vpExecuteCaps);
55 
56     MOS_STATUS CalculateEngineParams();
57 
58     MOS_STATUS CalculateSfcEngineParams();
59 
60     MOS_STATUS CalculateVeboxEngineParams();
61 
GetSfcParams()62     SFC_CSC_PARAMS *GetSfcParams()
63     {
64         return m_sfcCSCParams;
65     }
66 
GetVeboxParams()67     VEBOX_CSC_PARAMS* GetVeboxParams()
68     {
69         return m_veboxCSCParams;
70     }
71 
72 protected:
73 
74     //!
75     //! \brief    Setup Chroma sitting parameters
76     //! \details  Setup Chroma sitting parameters
77     //! \param    [in] vpExecuteCaps
78     //!           Pointer to Vebox Render Execution Caps
79     //! \return   MOS_STATUS
80     //!
81     MOS_STATUS SetChromaParams(
82         VP_EXECUTE_CAPS         vpExecuteCaps);
83 
84     //!
85     //! \brief    Setup Vebox Chroma up sampling parameters
86     //! \details  Setup Chroma sitting parameters
87     //! \param    [in] vpExecuteCaps
88     //!           Pointer to Vebox Render Execution Caps
89     //! \return   MOS_STATUS
90     //!
91     MOS_STATUS SetVeboxCUSChromaParams(
92         VP_EXECUTE_CAPS         vpExecuteCaps);
93 
94     //!
95 //! \brief    Setup Vebox Chroma down sampling parameters
96 //! \details  Setup Chroma sitting parameters
97 //! \param    [in] vpExecuteCaps
98 //!           Pointer to Vebox Render Execution Caps
99 //! \return   MOS_STATUS
100 //!
101     MOS_STATUS SetVeboxCDSChromaParams(
102         VP_EXECUTE_CAPS         vpExecuteCaps);
103 
104     //!
105     //! \brief    Setup Chroma sitting parameters
106     //! \details  Setup Chroma sitting parameters
107     //! \return   MOS_STATUS
108     //!
109     MOS_STATUS SetSubSampling();
110 
111     //!
112     //! \brief    Check whether Chroma Up Sampling Needed
113     //! \details  Check whether Chroma Up Sampling Needed
114     //! \return   bool
115     //!
116     bool IsChromaUpSamplingNeeded();
117 
118 protected:
119     FeatureParamCsc     m_cscParams = {};
120     PSFC_CSC_PARAMS     m_sfcCSCParams   = nullptr;
121     PVEBOX_CSC_PARAMS   m_veboxCSCParams = nullptr;
122 };
123 
124 
125 struct HW_FILTER_CSC_PARAM
126 {
127     FeatureType             type;
128     PVP_MHWINTERFACE        pHwInterface;
129     VP_EXECUTE_CAPS         vpExecuteCaps;
130     PacketParamFactoryBase *pPacketParamFactory;
131     FeatureParamCsc         cscParams;
132 };
133 
134 class HwFilterCscParameter : public HwFilterParameter
135 {
136 public:
137     static HwFilterParameter *Create(HW_FILTER_CSC_PARAM &param, FeatureType featureType);
138     HwFilterCscParameter(FeatureType featureType);
139     virtual ~HwFilterCscParameter();
140     virtual MOS_STATUS ConfigParams(HwFilter &hwFilter);
141 
142     MOS_STATUS Initialize(HW_FILTER_CSC_PARAM &param);
143 
144 private:
145     HW_FILTER_CSC_PARAM m_Params = {};
146 };
147 
148 class VpSfcCscParameter : public VpPacketParameter
149 {
150 public:
151     static VpPacketParameter *Create(HW_FILTER_CSC_PARAM &param);
152     VpSfcCscParameter(PVP_MHWINTERFACE pHwInterface, PacketParamFactoryBase *packetParamFactory);
153     virtual ~VpSfcCscParameter();
154 
155     virtual bool SetPacketParam(VpCmdPacket *pPacket);
156 
157 private:
158     MOS_STATUS Initialize(HW_FILTER_CSC_PARAM &params);
159 
160     VpCscFilter m_CscFilter;
161 };
162 
163 class PolicySfcCscHandler : public PolicyFeatureHandler
164 {
165 public:
166     PolicySfcCscHandler();
167     virtual ~PolicySfcCscHandler();
168     virtual bool IsFeatureEnabled(VP_EXECUTE_CAPS vpExecuteCaps);
169     virtual HwFilterParameter *CreateHwFilterParam(VP_EXECUTE_CAPS vpExecuteCaps, SwFilterPipe &swFilterPipe, PVP_MHWINTERFACE pHwInterface);
170 
171 private:
172     PacketParamFactory<VpSfcCscParameter> m_PacketParamFactory;
173 };
174 
175 }
176 #endif // !__VP_CSC_FILTER_H__