1 /*
2 * Copyright (c) 2021-2022, 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     media_interfaces_mhw_next.h
24 //! \brief    Gen-specific factory creation of the mhw interfaces
25 //!
26 
27 #ifndef __MEDIA_INTERFACES_MHW_NEXT_H__
28 #define __MEDIA_INTERFACES_MHW_NEXT_H__
29 
30 #include "media_factory.h"
31 #include "igfxfmid.h"
32 #include "mos_utilities.h"
33 #include "mos_os.h"
34 #include "mhw_vdbox_avp_itf.h"
35 #include "mhw_vdbox_vdenc_itf.h"
36 #include "mhw_vdbox_huc_itf.h"
37 #include "mhw_mi_itf.h"
38 #include "mhw_blt_itf.h"
39 #include "mhw_vdbox_hcp_itf.h"
40 #include "mhw_vdbox_mfx_itf.h"
41 #include "mhw_vebox_itf.h"
42 #include "mhw_sfc_itf.h"
43 #include "mhw_render_itf.h"
44 #include "mhw_vdbox_vvcp_itf.h"
45 
46 // forward declarations
47 class MhwCpInterface;
48 class MhwSfcInterface;
49 class XMHW_STATE_HEAP_INTERFACE;
50 class MhwVeboxInterface;
51 class MhwVdboxMfxInterface;
52 class MhwVdboxHcpInterface;
53 class MhwVdboxHucInterface;
54 class MhwVdboxVdencInterface;
55 class MhwBltInterface;
56 class MhwVdboxAvpInterface;
57 
58 //!
59 //! \class    MhwInterfacesNext
60 //! \brief    MHW interfacesNext
61 //!
62 class MhwInterfacesNext
63 {
64 public:
~MhwInterfacesNext()65     virtual ~MhwInterfacesNext() {}
66 
67     //! \brief Determines which interfaces are created
68     struct CreateParams
69     {
CreateParamsCreateParams70         CreateParams()
71         {
72             Flags.m_value = 0;
73         }
74 
75         union
76         {
77             struct
78             {
79                 uint32_t m_render : 1;
80                 uint32_t m_sfc : 1;
81                 uint32_t m_stateHeap : 1;
82                 uint32_t m_vebox : 1;
83                 uint32_t m_vdboxAll : 1;
84                 uint32_t m_mfx : 1;
85                 uint32_t m_hcp : 1;
86                 uint32_t m_huc : 1;
87                 uint32_t m_vdenc : 1;
88                 uint32_t m_blt : 1;
89                 uint32_t m_avp : 1;
90                 uint32_t m_reserved : 21;
91             };
92             uint32_t m_value;
93         } Flags;
94 
95         uint8_t m_heapMode = 0; //!< To be deprecated when heap management unified
96         bool m_isDecode = false; //!< Whether or not decode is in use, only valid for VDBOX creation
97         bool m_isCp     = false; //!< Whether or not CP is in use, CP only need mi and cp interface.
98     };
99 
100     /* Below legacy interfaces are kept temporarily for backward compatibility */
101 
102     //! \brief These interfaces are responsible for constructing instructions,
103      //!           structures, and registers for hardware.
104     MhwCpInterface            *m_cpInterface        = nullptr;
105     MhwSfcInterface           *m_sfcInterface       = nullptr;
106     XMHW_STATE_HEAP_INTERFACE *m_stateHeapInterface = nullptr;
107     MhwVeboxInterface         *m_veboxInterface     = nullptr;
108     MhwBltInterface           *m_bltInterface       = nullptr;
109     PMOS_INTERFACE            m_osInterface         = nullptr;
110     /* New mhw sub interfaces*/
111     std::shared_ptr<mhw::vdbox::avp::Itf>   m_avpItf    = nullptr;
112     std::shared_ptr<mhw::vdbox::vdenc::Itf> m_vdencItf  = nullptr;
113     std::shared_ptr<mhw::vdbox::huc::Itf>   m_hucItf    = nullptr;
114     std::shared_ptr<mhw::mi::Itf>           m_miItf     = nullptr;
115     std::shared_ptr<mhw::vdbox::hcp::Itf>   m_hcpItf    = nullptr;
116     std::shared_ptr<mhw::vdbox::mfx::Itf>   m_mfxItf    = nullptr;
117     std::shared_ptr<mhw::vebox::Itf>        m_veboxItf  = nullptr;
118     std::shared_ptr<mhw::sfc::Itf>          m_sfcItf    = nullptr;
119     std::shared_ptr<mhw::blt::Itf>          m_bltItf    = nullptr;
120     std::shared_ptr<mhw::render::Itf>       m_renderItf = nullptr;
121     std::shared_ptr<mhw::vdbox::vvcp::Itf>  m_vvcpItf   = nullptr;
122 
123     //!
124     //! \brief    Calls the factory function to initialize all requested interfaces.
125     //! \param    [in] params
126     //!           Configuration flags for the creation of MHW interfaces.
127     //! \param    [in] osInterface
128     //!           OS interface
129     //! \return   MhwInterfaces*
130     //!           returns a valid pointer if successful and nullptr if failed.
131     //!
132     static MhwInterfacesNext* CreateFactory(
133         CreateParams params,
134         PMOS_INTERFACE osInterface);
135 
136     //!
137     //! \brief    Creates requested MHW interfaces.
138     //! \param    [in] params
139     //!           Configuration flags for the creation of MHW interfaces.
140     //! \param    [in] osInterface
141     //!           OS interface
142     //! \return   MOS_STATUS_SUCCESS if succeeded, else error code.
143     //!
144     virtual MOS_STATUS Initialize(
145         CreateParams params,
146         PMOS_INTERFACE osInterface) = 0;
147 
148     //!
149     //! \brief    Destroys all created MHW interfaces
150     //! \details  If the HAL creation fails, this is used for cleanup
151     //!
152     virtual void Destroy();
153 
154     //!
155     //! \brief    Set Interfaces Destroy State
156     //! \details  If the interfaces has destroyed, set this state value on
157     //!
SetDestroyState(bool destorystate)158     void SetDestroyState(bool destorystate) { m_isDestroyed = destorystate; };
GetDestroyState()159     bool GetDestroyState() { return m_isDestroyed; };
160 
161 private:
162     bool m_isDestroyed = false;
163 MEDIA_CLASS_DEFINE_END(MhwInterfacesNext)
164 };
165 
166 extern template class MediaFactory<uint32_t, MhwInterfacesNext>;
167 
168 #endif // __MEDIA_INTERFACES_MHW_NEXT_H__
169