| 1 | /* |
| 2 | * Copyright (c) 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_vebox_copy.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_H__ |
| 28 | #define __MEDIA_VEBOX_COPY_H__ |
| 29 | |
| 30 | #include <memory> |
| 31 | #include "mos_defs.h" |
| 32 | #include "mos_os.h" |
| 33 | #include "mos_os_specific.h" |
| 34 | #include "mos_util_debug.h" |
| 35 | #include "media_interfaces_mhw.h" |
| 36 | #include "mhw_vebox.h" |
| 37 | #include "media_copy_common.h" |
| 38 | class MhwCpInterface; |
| 39 | class MhwMiInterface; |
| 40 | namespace mhw { namespace vebox { class Itf; } } |
| 41 | |
| 42 | #define VEBOX_COPY_CHK_STATUS(_stmt) MOS_CHK_STATUS(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _stmt) |
| 43 | #define VEBOX_COPY_CHK_STATUS_RETURN(_stmt) MOS_CHK_STATUS_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _stmt) |
| 44 | #define VEBOX_COPY_CHK_NULL(_ptr) MOS_CHK_NULL(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _ptr) |
| 45 | #define VEBOX_COPY_CHK_NULL_RETURN(_ptr) MOS_CHK_NULL_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _ptr) |
| 46 | #define VEBOX_COPY_ASSERTMESSAGE(_message, ...) MOS_ASSERTMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _message, ##__VA_ARGS__) |
| 47 | #define VEBOX_COPY_NORMALMESSAGE(_message, ...) MOS_NORMALMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_VEBOX, _message, ##__VA_ARGS__) |
| 48 | |
| 49 | class VeboxCopyState |
| 50 | { |
| 51 | public: |
| 52 | //! |
| 53 | //! \brief Vebox Copy State constructor |
| 54 | //! \details Initialize the VeboxCopyState members. |
| 55 | //! \param osInterface |
| 56 | //! [in] Pointer to MOS_INTERFACE. |
| 57 | //! |
| 58 | VeboxCopyState(PMOS_INTERFACE osInterface, MhwInterfaces* mhwInterfaces); |
| 59 | |
| 60 | virtual ~VeboxCopyState(); |
| 61 | //! |
| 62 | //! \brief Vebox Copy State initialize |
| 63 | //! \details Initialize the Vebox Copy State, create Vebox Copy State context. |
| 64 | //! \return MOS_STATUS |
| 65 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 66 | //! |
| 67 | virtual MOS_STATUS Initialize(); |
| 68 | |
| 69 | //! |
| 70 | //! \brief Copy main surface |
| 71 | //! \details Vebox Copy State engine will copy source surface to destination surface |
| 72 | //! \param src |
| 73 | //! [in] Pointer to source surface |
| 74 | //! \param dst |
| 75 | //! [in] Pointer to destination surface |
| 76 | //! \return MOS_STATUS |
| 77 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 78 | //! |
| 79 | virtual MOS_STATUS CopyMainSurface( |
| 80 | PMOS_SURFACE src, |
| 81 | PMOS_SURFACE dst); |
| 82 | |
| 83 | //! |
| 84 | //! \brief Copy main surface |
| 85 | //! \details Vebox Copy State engine will copy source surface to destination surface |
| 86 | //! \param src |
| 87 | //! [in] Pointer to source resource |
| 88 | //! \param dst |
| 89 | //! [in] Pointer to destination resource |
| 90 | //! \return MOS_STATUS |
| 91 | //! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 92 | //! |
| 93 | virtual MOS_STATUS CopyMainSurface( |
| 94 | PMOS_RESOURCE src, |
| 95 | PMOS_RESOURCE dst); |
| 96 | |
| 97 | //! |
| 98 | //! Is ve copy supported surface |
| 99 | //! \param [in] surface |
| 100 | //! Pointer to surface parameters |
| 101 | //! \return true if supported, else false. |
| 102 | //! |
| 103 | bool IsSurfaceSupported(PMOS_RESOURCE surface); |
| 104 | |
| 105 | //! |
| 106 | //! \brief Setup Vebox_Surface_State Command parameter |
| 107 | //! \param [in/out] mhwVeboxSurfaceStateCmdParams |
| 108 | //! Pointer to VEBOX_SURFACE_STATE command parameters |
| 109 | //! \param [in] surface |
| 110 | //! Input surface pointer |
| 111 | //! \param [in] surface |
| 112 | //! output surface pointer |
| 113 | //! \return MOS_STATUS_SUCCESS if succeeded, else error code. |
| 114 | //! |
| 115 | virtual MOS_STATUS SetupVeboxSurfaceState( |
| 116 | PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS mhwVeboxSurfaceStateCmdParams, |
| 117 | PMOS_SURFACE inputSurface, |
| 118 | PMOS_SURFACE outputSurface); |
| 119 | |
| 120 | protected: |
| 121 | |
| 122 | //! \brief Get resource information |
| 123 | //! \details Get resource information for the specifc surface |
| 124 | //! \param [in] pSurface |
| 125 | //! Surface pointer |
| 126 | //! \return MOS_STATUS_SUCCESS if succeeded, else error code. |
| 127 | //! |
| 128 | MOS_STATUS GetResourceInfo( |
| 129 | PMOS_SURFACE surface); |
| 130 | |
| 131 | //! |
| 132 | //! \brief Get resource information |
| 133 | //! \details Get resource information for the specifc surface |
| 134 | //! \param [in] cmdBuffer |
| 135 | //! CmdBuffer pointer |
| 136 | //! \return MOS_STATUS_SUCCESS if succeeded, else error code. |
| 137 | //! |
| 138 | MOS_STATUS InitCommandBuffer( |
| 139 | PMOS_COMMAND_BUFFER cmdBuffer); |
| 140 | |
| 141 | //! |
| 142 | //! Is ve copy supported format |
| 143 | //! \param [in/out] surface mos format |
| 144 | //! Pointer to Output Surface parameters |
| 145 | //! \return true if supported, else false. |
| 146 | //! |
| 147 | virtual bool IsVeCopySupportedFormat(MOS_FORMAT format); |
| 148 | |
| 149 | virtual void AdjustSurfaceFormat(MOS_SURFACE &surface); |
| 150 | |
| 151 | protected: |
| 152 | PMOS_INTERFACE m_osInterface = nullptr; |
| 153 | MhwInterfaces *m_mhwInterfaces = nullptr; |
| 154 | MhwMiInterface *m_miInterface = nullptr; |
| 155 | MhwVeboxInterface *m_veboxInterface = nullptr; |
| 156 | MhwCpInterface *m_cpInterface = nullptr; |
| 157 | MhwInterfaces::CreateParams params; |
| 158 | MEDIA_CLASS_DEFINE_END(VeboxCopyState) |
| 159 | }; |
| 160 | |
| 161 | #endif //__MEDIA_VEBOX_COPY_H__ |