1 /*
2 * Copyright (c) 2020-2023, 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     vp_scalability_multipipe.h
25 //! \brief    Defines the common interface for vp scalability mulitpipe mode.
26 //! \details  The vp scalability mulitpipe interface is further sub-divided by codecs,
27 //!           this file is for the base interface which is shared by all codecs.
28 //!
29 
30 #ifndef __VP_SCALABILITY_MULTIPIPE_H__
31 #define __VP_SCALABILITY_MULTIPIPE_H__
32 #include "vp_scalability_multipipe_next.h"
33 
34 namespace vp
35 {
36 class VpScalabilityMultiPipe : public VpScalabilityMultiPipeNext
37 {
38 public:
39     //!
40     //! \brief  Vp scalability mulitipipe constructor
41     //! \param  [in] hwInterface
42     //!         Pointer to HwInterface
43     //! \param  [in] mediaContext
44     //!         Pointer to MediaContext
45     //! \param  [in] componentType
46     //!         Component type
47     //!
48     VpScalabilityMultiPipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType);
49 
50     //!
51     //! \brief  Vp scalability mulitipipe destructor
52     //!
53     ~VpScalabilityMultiPipe();
54 
55     //!
56     //! \brief    Copy constructor
57     //!
58     VpScalabilityMultiPipe(const VpScalabilityMultiPipe &) = delete;
59 
60     //!
61     //! \brief    Copy assignment operator
62     //!
63     VpScalabilityMultiPipe &operator=(const VpScalabilityMultiPipe &) = delete;
64 
65     //!
66     //! \brief  Sync pipes with first pipe wait for others
67     //! \detials Only support to use this sync once per frame.
68     //! \param  [in] cmdBuffer
69     //!         Pointer to command buffer
70     //! \param  [in] pipeIdx
71     //!         The index of pipeline which wait for others
72     //! \return MOS_STATUS
73     //!         MOS_STATUS_SUCCESS if success, else fail reason
74     //!
75     //virtual MOS_STATUS SyncOnePipeWaitOthers(PMOS_COMMAND_BUFFER cmdBuffer, uint32_t pipeIdx);
76 
77     //!
78     //! \brief    Send hw semphore wait cmd
79     //! \details  Send hw semphore wait cmd for sync perpose
80     //!
81     //! \param    [in] semaMem
82     //!           Reource of Hw semphore
83     //! \param    [in] offset
84     //!           offset of semMem
85     //! \param    [in] semaData
86     //!           Data of Hw semphore
87     //! \param    [in] opCode
88     //!           Operation code
89     //! \param    [in,out] cmdBuffer
90     //!           command buffer
91     //!
92     //! \return   MOS_STATUS
93     //!           MOS_STATUS_SUCCESS if success, else fail reason
94     //!
95     virtual MOS_STATUS SendHwSemaphoreWaitCmd(
96         PMOS_RESOURCE                             semaMem,
97         uint32_t                                  offset,
98         uint32_t                                  semaData,
99         MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION opCode,
100         PMOS_COMMAND_BUFFER                       cmdBuffer) override;
101 
102     //!
103     //! \brief    Send mi atomic dword cmd
104     //! \details  Send mi atomic dword cmd for sync perpose
105     //!
106     //! \param    [in] resource
107     //!           Reource used in mi atomic dword cmd
108     //! \param    [in] offset
109     //!           offset of resource
110     //! \param    [in] immData
111     //!           Immediate data
112     //! \param    [in] opCode
113     //!           Operation code
114     //! \param    [in,out] cmdBuffer
115     //!           command buffer
116     //!
117     //! \return   MOS_STATUS
118     //!           MOS_STATUS_SUCCESS if success, else fail reason
119     //!
120     virtual MOS_STATUS SendMiAtomicDwordCmd(
121         PMOS_RESOURCE               resource,
122         uint32_t                    offset,
123         uint32_t                    immData,
124         MHW_COMMON_MI_ATOMIC_OPCODE opCode,
125         PMOS_COMMAND_BUFFER         cmdBuffer) override;
126 
127     //!
128     //! \brief    Send mi flush dword cmd
129     //! \details  Send mi flush dword cmd for sync perpose
130     //!
131     //! \param    [in] semMem
132     //!           Reource used in mi flush dword cmd
133     //! \param    [in] semaData
134     //!           Immediate data
135     //! \param    [in,out] cmdBuffer
136     //!           command buffer
137     //!
138     //! \return   MOS_STATUS
139     //!           MOS_STATUS_SUCCESS if success, else fail reason
140     //!
141     virtual MOS_STATUS AddMiFlushDwCmd(
142         PMOS_RESOURCE                             semaMem,
143         uint32_t                                  semaData,
144         PMOS_COMMAND_BUFFER                       cmdBuffer) override;
145 
146     //!
147     //! \brief    Send mi store data dword cmd
148     //! \details  Send mi store dat dword cmd for sync perpose
149     //!
150     //! \param    [in] resource
151     //!           Reource used in mi store dat dword cmd
152     //! \param    [in] offset
153     //!           offset of resource
154     //! \param    [in,out] cmdBuffer
155     //!           command buffer
156     //!
157     //! \return   MOS_STATUS
158     //!           MOS_STATUS_SUCCESS if success, else fail reason
159     //!
160     virtual MOS_STATUS AddMiStoreDataImmCmd(
161         PMOS_RESOURCE               resource,
162         uint32_t                    offset,
163         PMOS_COMMAND_BUFFER         cmdBuffer) override;
164 
165     //!
166     //! \brief   Initialize the media scalability
167     //! \details It will prepare the resources needed in scalability
168     //!          and initialize the state of scalability
169     //! \param   [in] option
170     //!          Input scalability option
171     //! \return  MOS_STATUS
172     //!          MOS_STATUS_SUCCESS if success, else fail reason
173     //!
174     MOS_STATUS Initialize(const MediaScalabilityOption &option) override;
175 
176     //!
177     //! \brief  Get command buffer
178     //! \param  [in, out] cmdBuffer
179     //!         Pointer to command buffer
180     //! \return MOS_STATUS
181     //!         MOS_STATUS_SUCCESS if success, else fail reason
182     //!
183     MOS_STATUS GetCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer, bool frameTrackingRequested = true) override;
184 
185     //!
186     //! \brief  Set hint parameters
187     //! \return MOS_STATUS
188     //!         MOS_STATUS_SUCCESS if success, else fail reason
189     //!
190     virtual MOS_STATUS SetHintParams() override;
191 
192     //!
193     //! \brief  Destroy the media scalability
194     //! \return MOS_STATUS
195     //!         MOS_STATUS_SUCCESS if success, else fail reason
196     //!
197     virtual MOS_STATUS Destroy() override;
198 
199     //!
200     //! \brief  Submit command buffer
201     //! \param  [in, out] cmdBuffer
202     //!         Pointer to command buffer
203     //! \return MOS_STATUS
204     //!         MOS_STATUS_SUCCESS if success, else fail reason
205     //!
206     MOS_STATUS SubmitCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer) override;
207 
208     static MOS_STATUS CreateMultiPipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType);
209 
210     VpPhase                               *m_phase = nullptr;
211 
212 MEDIA_CLASS_DEFINE_END(vp__VpScalabilityMultiPipe)
213 };
214 }  // namespace vp
215 #endif  // __VP_SCALABILITY_MULTIPIPE_H__
216