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_rot_mir_filter.h
24 //! \brief    Defines the common interface for rotation/mirror
25 //!           this file is for the base interface which is shared by rotation/mirror in driver.
26 //!
27 
28 #ifndef __VP_ROT_MIR_FILTER_H__
29 #define __VP_ROT_MIR_FILTER_H__
30 
31 #include "vp_filter.h"
32 #include "sw_filter.h"
33 
34 namespace vp {
35 
36 class VpRotMirFilter : public VpFilter
37 {
38 public:
39 
40     VpRotMirFilter(
41         PVP_MHWINTERFACE vpMhwInterface);
42 
~VpRotMirFilter()43     ~VpRotMirFilter()
44     {
45         Destroy();
46     };
47 
48     virtual MOS_STATUS Init() override;
49 
50     virtual MOS_STATUS Prepare() override;
51 
52     virtual MOS_STATUS Destroy() override;
53 
54     virtual MOS_STATUS SetExecuteEngineCaps(
55         FeatureParamRotMir      &rotMirParams,
56         VP_EXECUTE_CAPS         vpExecuteCaps);
57 
58     MOS_STATUS CalculateEngineParams();
GetSfcParams()59     SFC_ROT_MIR_PARAMS *GetSfcParams()
60     {
61         return m_sfcRotMirParams;
62     }
63 protected:
64 
65     //!
66     //! \brief    Setup Rotation and Mirrow params
67     //! \details  Setup Rotation and Mirrow params
68     //! \param    [in] Rotation
69     //!           Pointer to surface rotation params
70     //! \return   MOS_STATUS
71     //!
72     MOS_STATUS SetRotationAndMirrowParams(
73         VPHAL_ROTATION     Rotation);
74 
75     //!
76     //! \brief    Setup Rotation and Mirrow params
77     //! \details  Setup Rotation and Mirrow params
78     //! \param    [in] Rotation
79     //!           surface rotation params
80     //! \return   VPHAL_ROTATION
81     //!
82     VPHAL_ROTATION GetRotationParam(
83         VPHAL_ROTATION Rotation);
84 
85 protected:
86     FeatureParamRotMir      m_rotMirParams = {};
87     PSFC_ROT_MIR_PARAMS     m_sfcRotMirParams = nullptr;
88 };
89 
90 struct HW_FILTER_ROT_MIR_PARAM
91 {
92     FeatureType             type;
93     PVP_MHWINTERFACE        pHwInterface;
94     VP_EXECUTE_CAPS         vpExecuteCaps;
95     PacketParamFactoryBase *pPacketParamFactory;
96     FeatureParamRotMir      rotMirParams;
97 };
98 
99 class HwFilterRotMirParameter : public HwFilterParameter
100 {
101 public:
102     static HwFilterParameter *Create(HW_FILTER_ROT_MIR_PARAM &param, FeatureType featureType);
103     HwFilterRotMirParameter(FeatureType featureType);
104     virtual ~HwFilterRotMirParameter();
105     virtual MOS_STATUS ConfigParams(HwFilter &hwFilter);
106     MOS_STATUS Initialize(HW_FILTER_ROT_MIR_PARAM &param);
107 
108 private:
109     HW_FILTER_ROT_MIR_PARAM m_Params = {};
110 };
111 
112 class VpSfcRotMirParameter : public VpPacketParameter
113 {
114 public:
115     static VpPacketParameter *Create(HW_FILTER_ROT_MIR_PARAM &param);
116     VpSfcRotMirParameter(PVP_MHWINTERFACE pHwInterface, PacketParamFactoryBase *packetParamFactory);
117     virtual ~VpSfcRotMirParameter();
118 
119     virtual bool SetPacketParam(VpCmdPacket *pPacket);
120 
121 private:
122     MOS_STATUS Initialize(HW_FILTER_ROT_MIR_PARAM & params);
123 
124     VpRotMirFilter m_RotMirFilter;
125 };
126 
127 class PolicySfcRotMirHandler : public PolicyFeatureHandler
128 {
129 public:
130     PolicySfcRotMirHandler();
131     virtual ~PolicySfcRotMirHandler();
132     virtual bool IsFeatureEnabled(VP_EXECUTE_CAPS vpExecuteCaps);
133     virtual HwFilterParameter *CreateHwFilterParam(VP_EXECUTE_CAPS vpExecuteCaps, SwFilterPipe &swFilterPipe, PVP_MHWINTERFACE pHwInterface);
134 private:
135     PacketParamFactory<VpSfcRotMirParameter> m_PacketParamFactory;
136 };
137 }
138 #endif//__VP_ROT_MIR_FILTER_H__