1 /*
2 * Copyright (c) 2019 - 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 //!
24 //! \file     hw_filter_pipe.cpp
25 //! \brief    Defines the common interface for vp features manager
26 //! \details  The vp manager is further sub-divided by vp type
27 //!           this file is for the base interface which is shared by all components.
28 //!
29 #include "hw_filter_pipe.h"
30 #include "vp_resource_manager.h"
31 #include "vp_obj_factories.h"
32 #include "vp_pipeline.h"
33 using namespace vp;
34 
35 /****************************************************************************************************/
36 /*                                      HwFilterPipe                                                */
37 /****************************************************************************************************/
HwFilterPipe(VpInterface & vpInterface)38 HwFilterPipe::HwFilterPipe(VpInterface &vpInterface) : m_vpInterface(vpInterface)
39 {
40 }
41 
~HwFilterPipe()42 HwFilterPipe::~HwFilterPipe()
43 {
44     Clean();
45 }
46 
Initialize(SwFilterPipe & swFilterPipe,Policy & policy)47 MOS_STATUS HwFilterPipe::Initialize(SwFilterPipe &swFilterPipe, Policy &policy)
48 {
49     VP_FUNC_CALL();
50 
51     MOS_STATUS status = MOS_STATUS_SUCCESS;
52     SwFilterPipe &subSwFilterPipe = swFilterPipe;
53     HwFilter *pHwFilter = nullptr;
54 
55     Clean();
56 
57     status = policy.CreateHwFilter(subSwFilterPipe, pHwFilter);
58 
59     if (MOS_FAILED(status))
60     {
61         return status;
62     }
63 
64     while (pHwFilter)
65     {
66         status = AddHwFilter(*pHwFilter);
67 
68         if (MOS_FAILED(status))
69         {
70             return status;
71         }
72 
73         status = policy.CreateHwFilter(subSwFilterPipe, pHwFilter);
74 
75         if (MOS_FAILED(status))
76         {
77             return status;
78         }
79     }
80     return status;
81 }
82 
Clean()83 void HwFilterPipe::Clean()
84 {
85     VP_FUNC_CALL();
86 
87     while (!m_Pipe.empty())
88     {
89         HwFilter *p = m_Pipe.back();
90         m_Pipe.pop_back();
91         m_vpInterface.GetHwFilterFactory().Destory(p);
92     }
93 }
94 
AddHwFilter(HwFilter & hwFilter)95 MOS_STATUS HwFilterPipe::AddHwFilter(HwFilter &hwFilter)
96 {
97     VP_FUNC_CALL();
98 
99     m_Pipe.push_back(&hwFilter);
100     return MOS_STATUS_SUCCESS;
101 }
102 
InitPacketPipe(PacketPipe & packetPipe)103 MOS_STATUS HwFilterPipe::InitPacketPipe(PacketPipe &packetPipe)
104 {
105     VP_FUNC_CALL();
106 
107     for (std::vector<HwFilter*>::iterator it = m_Pipe.begin(); it!= m_Pipe.end(); ++it)
108     {
109         if (nullptr == *it)
110         {
111             return MOS_STATUS_NULL_POINTER;
112         }
113         VP_PUBLIC_CHK_STATUS_RETURN(packetPipe.AddPacket(**it));
114     }
115     return MOS_STATUS_SUCCESS;
116 }
117 
UpdateResources()118 MOS_STATUS HwFilterPipe::UpdateResources()
119 {
120     VP_FUNC_CALL();
121 
122     return MOS_STATUS_SUCCESS;
123 }
124 
HwFilterCount()125 uint32_t HwFilterPipe::HwFilterCount()
126 {
127     VP_FUNC_CALL();
128 
129     return m_Pipe.size();
130 }
131 
GetEngineType(uint32_t index)132 EngineType HwFilterPipe::GetEngineType(uint32_t index)
133 {
134     VP_FUNC_CALL();
135 
136     if (index >= m_Pipe.size() || nullptr == m_Pipe[index])
137     {
138         return EngineTypeInvalid;
139     }
140 
141     return m_Pipe[index]->GetEngineType();
142 }