| 1 | /* |
| 2 | * Copyright (c) 2022-2025, 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_vebox_copy_next.h |
| 24 | //! \brief Common Copy interface and structure used in Vebox Engine |
| 25 | //! \details Common Copy interface and structure used in Vebox Engine |
| 26 | |
| 27 | #ifndef __MEDIA_VEBOX_COPY_NEXT_H__ |
| 28 | #define __MEDIA_VEBOX_COPY_NEXT_H__ |
| 29 | |
| 30 | #include "mos_interface.h" |
| 31 | #include "media_interfaces_mhw_next.h" |
| 32 | #include "mhw_vebox.h" |
| 33 | #include "mhw_vebox_itf.h" |
| 34 | |
| 35 | #define VEBOX_COPY_CHK_STATUS(_stmt) MOS_CHK_STATUS(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _stmt) |
| 36 | #define VEBOX_COPY_CHK_STATUS_RETURN(_stmt) MOS_CHK_STATUS_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _stmt) |
| 37 | #define VEBOX_COPY_CHK_NULL(_ptr) MOS_CHK_NULL(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _ptr) |
| 38 | #define VEBOX_COPY_CHK_NULL_RETURN(_ptr) MOS_CHK_NULL_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _ptr) |
| 39 | #define VEBOX_COPY_ASSERTMESSAGE(_message, ...) MOS_ASSERTMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _message, ##__VA_ARGS__) |
| 40 | #define VEBOX_COPY_WARNINGMESSAGE(_message, ...) MOS_WARNINGMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _message, ##__VA_ARGS__) |
| 41 | #define VEBOX_COPY_NORMALMESSAGE(_message, ...) MOS_NORMALMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _message, ##__VA_ARGS__) |
| 42 | |
| 43 | class VeboxCopyStateNext |
| 44 | { |
| 45 | public: |
| 46 | //! |
| 47 | //! \brief Vebox Copy State constructor |
| 48 | //! \details Initialize the VeboxCopyStateNext members. |
| 49 | //! \param osInterface |
| 50 | //! [in] Pointer to MOS_INTERFACE. |
| 51 | //! |
| 52 | VeboxCopyStateNext(PMOS_INTERFACE osInterface); |
| 53 | VeboxCopyStateNext(PMOS_INTERFACE osInterface, MhwInterfacesNext* mhwInterfaces); |
| 54 | |
| 55 | virtual ~VeboxCopyStateNext(); |
| 56 | //! |
| 57 | //! \brief Vebox Copy State initialize |
| 58 | //! \details Initialize the Vebox Copy State, create Vebox Copy State context. |
| 59 | //! \return MOS_STATUS |
| 60 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 61 | //! |
| 62 | virtual MOS_STATUS Initialize(); |
| 63 | |
| 64 | //! |
| 65 | //! \brief Copy main surface |
| 66 | //! \details Vebox Copy State engine will copy source surface to destination surface |
| 67 | //! \param src |
| 68 | //! [in] Pointer to source surface |
| 69 | //! \param dst |
| 70 | //! [in] Pointer to destination surface |
| 71 | //! \return MOS_STATUS |
| 72 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 73 | //! |
| 74 | virtual MOS_STATUS CopyMainSurface( |
| 75 | PMOS_SURFACE src, |
| 76 | PMOS_SURFACE dst); |
| 77 | |
| 78 | //! |
| 79 | //! \brief Copy main surface |
| 80 | //! \details Vebox Copy State engine will copy source surface to destination surface |
| 81 | //! \param src |
| 82 | //! [in] Pointer to source resource |
| 83 | //! \param dst |
| 84 | //! [in] Pointer to destination resource |
| 85 | //! \return MOS_STATUS |
| 86 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 87 | //! |
| 88 | virtual MOS_STATUS CopyMainSurface( |
| 89 | PMOS_RESOURCE src, |
| 90 | PMOS_RESOURCE dst); |
| 91 | |
| 92 | //! |
| 93 | //! Is ve copy supported surface |
| 94 | //! \param [in/out] surface |
| 95 | //! Pointer to Output Surface parameters |
| 96 | //! \return true if supported, else false. |
| 97 | //! |
| 98 | bool IsSurfaceSupported(PMOS_RESOURCE surface); |
| 99 | |
| 100 | //! |
| 101 | //! \brief Setup Vebox_Surface_State Command parameter |
| 102 | //! \param [in/out] mhwVeboxSurfaceStateCmdParams |
| 103 | //! Pointer to VEBOX_SURFACE_STATE command parameters |
| 104 | //! \param [in] surface |
| 105 | //! Input surface pointer |
| 106 | //! \param [in] surface |
| 107 | //! output surface pointer |
| 108 | //! \return MOS_STATUS_SUCCESS if succeeded, else error code. |
| 109 | //! |
| 110 | virtual MOS_STATUS SetupVeboxSurfaceState( |
| 111 | PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS mhwVeboxSurfaceStateCmdParams, |
| 112 | PMOS_SURFACE inputSurface, |
| 113 | PMOS_SURFACE outputSurface); |
| 114 | |
| 115 | protected: |
| 116 | |
| 117 | //! \brief Get resource information |
| 118 | //! \details Get resource information for the specifc surface |
| 119 | //! \param [in] pSurface |
| 120 | //! Surface pointer |
| 121 | //! \return MOS_STATUS_SUCCESS if succeeded, else error code. |
| 122 | //! |
| 123 | MOS_STATUS GetResourceInfo( |
| 124 | PMOS_SURFACE surface); |
| 125 | |
| 126 | //! |
| 127 | //! \brief Get resource information |
| 128 | //! \details Get resource information for the specifc surface |
| 129 | //! \param [in] cmdBuffer |
| 130 | //! CmdBuffer pointer |
| 131 | //! \return MOS_STATUS_SUCCESS if succeeded, else error code. |
| 132 | //! |
| 133 | MOS_STATUS InitCommandBuffer( |
| 134 | PMOS_COMMAND_BUFFER cmdBuffer); |
| 135 | |
| 136 | //! |
| 137 | //! Is ve copy supported format |
| 138 | //! \param [in/out] surface mos format |
| 139 | //! |
| 140 | //! \return true if supported, else false. |
| 141 | //! |
| 142 | virtual bool IsVeCopySupportedFormat(MOS_FORMAT format); |
| 143 | |
| 144 | //! |
| 145 | //! \brief change vebox surface format. |
| 146 | //! \details change vebox surface format |
| 147 | //! \param [in] surface |
| 148 | //! mos surface |
| 149 | //! \return void |
| 150 | virtual void AdjustSurfaceFormat(MOS_SURFACE &surface); |
| 151 | |
| 152 | //! |
| 153 | //! \brief Create Gpu Context for Vebox |
| 154 | //! \details Create Gpu Context for Vebox |
| 155 | //! \param [in] pOsInterface |
| 156 | //! OS interface |
| 157 | //! \param [in] VeboxGpuContext |
| 158 | //! Vebox Gpu Context |
| 159 | //! \param [in] VeboxGpuNode |
| 160 | //! Vebox Gpu Node |
| 161 | //! \return MOS_STATUS |
| 162 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 163 | //! |
| 164 | virtual MOS_STATUS CreateGpuContext( |
| 165 | PMOS_INTERFACE pOsInterface, |
| 166 | MOS_GPU_CONTEXT VeboxGpuContext, |
| 167 | MOS_GPU_NODE VeboxGpuNode); |
| 168 | |
| 169 | protected: |
| 170 | PMOS_INTERFACE m_osInterface = nullptr; |
| 171 | MhwInterfacesNext *m_mhwInterfaces = nullptr; |
| 172 | MhwCpInterface *m_cpInterface = nullptr; |
| 173 | MhwInterfacesNext::CreateParams params; |
| 174 | |
| 175 | std::shared_ptr<mhw::mi::Itf> m_miItf = nullptr; |
| 176 | std::shared_ptr<mhw::vebox::Itf> m_veboxItf = nullptr; |
| 177 | |
| 178 | MEDIA_CLASS_DEFINE_END(VeboxCopyStateNext) |
| 179 | }; |
| 180 | |
| 181 | #endif //__MEDIA_VEBOX_COPY_NEXT_H__ |