1 /*
2 * Copyright (c) 2020-2021, 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_procamp_filter.h
24 //! \brief    Defines the common interface for Procamp
25 //!           this file is for the base interface which is shared by all Procamp in driver.
26 //!
27 #ifndef __VP_PROCAMP_FILTER_H__
28 #define __VP_PROCAMP_FILTER_H__
29 #include "vp_filter.h"
30 #include "sw_filter.h"
31 
32 namespace vp {
33 class VpProcampFilter : public VpFilter
34 {
35 public:
36 
37     VpProcampFilter(
38         PVP_MHWINTERFACE vpMhwInterface);
39 
~VpProcampFilter()40     ~VpProcampFilter()
41     {
42         Destroy();
43     };
44 
45     virtual MOS_STATUS Init() override;
46 
47     virtual MOS_STATUS Prepare() override;
48 
49     virtual MOS_STATUS Destroy() override;
50 
51     virtual MOS_STATUS SetExecuteEngineCaps(
52         FeatureParamProcamp     &procampParams,
53         VP_EXECUTE_CAPS         vpExecuteCaps);
54 
55     MOS_STATUS CalculateEngineParams();
GetVeboxParams()56     PVEBOX_PROCAMP_PARAMS GetVeboxParams()
57     {
58         return m_pVeboxProcampParams;
59     }
60 
61 protected:
62     FeatureParamProcamp     m_procampParams = {};
63     PVEBOX_PROCAMP_PARAMS   m_pVeboxProcampParams = nullptr;
64 
65 MEDIA_CLASS_DEFINE_END(vp__VpProcampFilter)
66 };
67 
68 struct HW_FILTER_PROCAMP_PARAM : public HW_FILTER_PARAM
69 {
70     FeatureParamProcamp         procampParams;
71 };
72 
73 class HwFilterProcampParameter : public HwFilterParameter
74 {
75 public:
76     static HwFilterParameter *Create(HW_FILTER_PROCAMP_PARAM &param, FeatureType featureType);
77     HwFilterProcampParameter(FeatureType featureType);
78     virtual ~HwFilterProcampParameter();
79     virtual MOS_STATUS ConfigParams(HwFilter &hwFilter);
80 
81     MOS_STATUS Initialize(HW_FILTER_PROCAMP_PARAM&param);
82 
83 private:
84     HW_FILTER_PROCAMP_PARAM m_Params = {};
85 
86 MEDIA_CLASS_DEFINE_END(vp__HwFilterProcampParameter)
87 };
88 
89 class VpVeboxProcampParameter : public VpPacketParameter
90 {
91 public:
92     static VpPacketParameter *Create(HW_FILTER_PROCAMP_PARAM &param);
93     VpVeboxProcampParameter(PVP_MHWINTERFACE pHwInterface, PacketParamFactoryBase *packetParamFactory);
94     virtual ~VpVeboxProcampParameter();
95 
96     virtual bool SetPacketParam(VpCmdPacket *pPacket);
97 
98 private:
99     MOS_STATUS Initialize(HW_FILTER_PROCAMP_PARAM&params);
100 
101     VpProcampFilter m_procampFilter;
102 
103 MEDIA_CLASS_DEFINE_END(vp__VpVeboxProcampParameter)
104 };
105 
106 class PolicyVeboxProcampHandler : public PolicyFeatureHandler
107 {
108 public:
109     PolicyVeboxProcampHandler(VP_HW_CAPS &hwCaps);
110     virtual ~PolicyVeboxProcampHandler();
111     virtual bool IsFeatureEnabled(VP_EXECUTE_CAPS vpExecuteCaps);
112     virtual HwFilterParameter *CreateHwFilterParam(VP_EXECUTE_CAPS vpExecuteCaps, SwFilterPipe &swFilterPipe, PVP_MHWINTERFACE pHwInterface);
113 
CreatePacketParam(HW_FILTER_PARAM & param)114     static VpPacketParameter* CreatePacketParam(HW_FILTER_PARAM& param)
115     {
116         if (param.type != FeatureTypeProcampOnVebox)
117         {
118             VP_PUBLIC_ASSERTMESSAGE("Invalid parameter for Vebox Procamp!");
119             return nullptr;
120         }
121 
122         HW_FILTER_PROCAMP_PARAM* procampParam = (HW_FILTER_PROCAMP_PARAM*)(&param);
123         return VpVeboxProcampParameter::Create(*procampParam);
124     }
125 
126 private:
127     PacketParamFactory<VpVeboxProcampParameter> m_PacketParamFactory;
128 
129 MEDIA_CLASS_DEFINE_END(vp__PolicyVeboxProcampHandler)
130 };
131 }
132 #endif
133