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     decode_scalability_singlepipe.h
25 //! \brief    Defines the common interface for decode scalability singlepipe mode.
26 //! \details  The decode scalability singlepipe 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 __DECODE_SCALABILITY_SINGLEPIPE_H__
31 #define __DECODE_SCALABILITY_SINGLEPIPE_H__
32 #include "mos_defs.h"
33 #include "mos_os.h"
34 #include "codechal_hw.h"
35 #include "decode_scalability_singlepipe_next.h"
36 #include "decode_scalability_option.h"
37 
38 namespace decode
39 {
40 
41 class DecodeScalabilitySinglePipe: public DecodeScalabilitySinglePipeNext
42 {
43 public:
44     //!
45     //! \brief  decode scalability singlepipe constructor
46     //! \param  [in] hwInterface
47     //!         Pointer to HwInterface
48     //! \param  [in] mediaContext
49     //!         Pointer to MediaContext
50     //! \param  [in] componentType
51     //!         Component type
52     //!
53     DecodeScalabilitySinglePipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType);
54 
55     //!
56     //! \brief  decode scalability singlepipe destructor
57     //!
~DecodeScalabilitySinglePipe()58     virtual ~DecodeScalabilitySinglePipe() {};
59 
60     //!
61     //! \brief    Copy constructor
62     //!
63     DecodeScalabilitySinglePipe(const DecodeScalabilitySinglePipe&) = delete;
64 
65     //!
66     //! \brief    Copy assignment operator
67     //!
68     DecodeScalabilitySinglePipe& operator=(const DecodeScalabilitySinglePipe&) = delete;
69 
70     //!
71     //! \brief   Initialize the decode single scalability
72     //! \details It will prepare the resources needed in scalability
73     //!          and initialize the state of scalability
74     //! \param   [in] option
75     //!          Input scalability option
76     //! \return  MOS_STATUS
77     //!          MOS_STATUS_SUCCESS if success, else fail reason
78     //!
79     virtual MOS_STATUS Initialize(const MediaScalabilityOption &option) override;
80 
81     //!
82     //! \brief  Update the media scalability singlepipe mode state
83     //! \param  [in] statePars
84     //!         parameters to update the state
85     //! \return MOS_STATUS
86     //!         MOS_STATUS_SUCCESS if success, else fail reason
87     //!
88     virtual MOS_STATUS UpdateState(void *statePars) override;
89 
90     //!
91     //! \brief  Verify command buffer
92     //! \param  [in] requestedSize
93     //!         requested size for command buffer
94     //! \param  [in] requestedPatchListSize
95     //!         requested size for patched list
96     //! \param  [out] singleTaskPhaseSupportedInPak
97     //!         Inidcate if to use single task phase in pak.
98     //! \return MOS_STATUS
99     //!         MOS_STATUS_SUCCESS if success, else fail reason
100     //!
101     virtual MOS_STATUS VerifyCmdBuffer(uint32_t requestedSize,
102                 uint32_t requestedPatchListSize,
103                 bool &singleTaskPhaseSupportedInPak)  override;
104     //!
105     //! \brief  Submit command buffer
106     //! \param  [in, out] cmdBuffer
107     //!         Pointer to command buffer
108     //! \return MOS_STATUS
109     //!         MOS_STATUS_SUCCESS if success, else fail reason
110     //!
111     virtual MOS_STATUS SubmitCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffer) override;
112     //!
113     //! \brief  Create decode single pipe
114     //! \param  [in] hwInterface
115     //!         void type hw interface
116     //! \param  [in] mediaContext
117     //!         required media context to create single pipe
118     //! \param  [in] componentType
119     //!         Inidcate component.
120     //! \return MOS_STATUS
121     //!         MOS_STATUS_SUCCESS if success, else fail reason
122     //!
123     static MOS_STATUS CreateDecodeSinglePipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType);
124 
125 protected:
126     //!
127     //! \brief  Verify command buffer size and patch list size, reallocate if required
128     //! \return MOS_STATUS
129     //!         MOS_STATUS_SUCCESS if success, else fail reason
130     //!
131     virtual MOS_STATUS VerifySpaceAvailable(uint32_t requestedSize,
132                 uint32_t requestedPatchListSize,
133                 bool &singleTaskPhaseSupportedInPak) override;
134 
135     //!
136     //! \brief    Resizes the cmd buffer and patch list with cmd buffer header
137     //!
138     //! \param    [in] requestedCommandBufferSize
139     //!           Requested resize command buffer size
140     //! \param    [in] requestedPatchListSize
141     //!           Requested resize patchlist size
142     //!
143     //! \return   MOS_STATUS
144     //!           MOS_STATUS_SUCCESS if success, else fail reason
145     //!
146     virtual MOS_STATUS ResizeCommandBufferAndPatchList(
147         uint32_t                    requestedCommandBufferSize,
148         uint32_t                    requestedPatchListSize) override;
149 
150     virtual MOS_STATUS SendAttrWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested) override;
151 
152 private:
153     CodechalHwInterface *m_hwInterface = nullptr;
154 
155 MEDIA_CLASS_DEFINE_END(decode__DecodeScalabilitySinglePipe)
156 };
157 
158 }
159 #endif // !__MEDIA_SCALABILITY_SINGLEPIPE_H__
160 
161