1 /* 2 * Copyright (c) 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 //! \file media_blt_copy.h 24 //! \brief Common interface and structure used in Blitter Engine 25 //! \details Common interface and structure used in Blitter Engine which are platform independent 26 //! 27 #ifndef __MEDIA_BLT_COPY_H__ 28 #define __MEDIA_BLT_COPY_H__ 29 30 #include "media_interfaces_mhw.h" 31 #include "mhw_blt.h" 32 #include "mhw_mi.h" 33 #include "mhw_cp_interface.h" 34 #include "mos_os.h" 35 36 #define BLT_CHK_STATUS(_stmt) MOS_CHK_STATUS(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _stmt) 37 #define BLT_CHK_STATUS_RETURN(_stmt) MOS_CHK_STATUS_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _stmt) 38 #define BLT_CHK_NULL(_ptr) MOS_CHK_NULL(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _ptr) 39 #define BLT_CHK_NULL_RETURN(_ptr) MOS_CHK_NULL_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _ptr) 40 #define BLT_ASSERTMESSAGE(_message, ...) MOS_ASSERTMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _message, ##__VA_ARGS__) 41 #define BLT_BITS_PER_BYTE 8 42 //! 43 //! \brief Structure for BLT parameter 44 //! 45 typedef struct _BLT_STATE_PARAM 46 { 47 bool bCopyMainSurface; 48 PMOS_RESOURCE pSrcSurface; 49 PMOS_RESOURCE pDstSurface; 50 }BLT_STATE_PARAM, *PBLT_STATE_PARAM; 51 52 53 class BltState 54 { 55 public: 56 //! 57 //! \brief BltState constructor 58 //! \details Initialize the BltState members. 59 //! \param osInterface 60 //! [in] Pointer to MOS_INTERFACE. 61 //! 62 BltState(PMOS_INTERFACE osInterface); 63 BltState(PMOS_INTERFACE osInterface, MhwInterfaces* mhwInterfaces); 64 65 virtual ~BltState(); 66 67 //! 68 //! \brief BltState initialize 69 //! \details Initialize the BltState, create BLT context. 70 //! \return MOS_STATUS 71 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 72 //! 73 virtual MOS_STATUS Initialize(); 74 75 //! 76 //! \brief Copy main surface 77 //! \details BLT engine will copy source surface to destination surface 78 //! \param src 79 //! [in] Pointer to source surface 80 //! \param dst 81 //! [in] Pointer to destination surface 82 //! \return MOS_STATUS 83 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 84 //! 85 virtual MOS_STATUS CopyMainSurface( 86 PMOS_SURFACE src, 87 PMOS_SURFACE dst); 88 89 //! 90 //! \brief Copy main surface 91 //! \details BLT engine will copy source surface to destination surface 92 //! \param src 93 //! [in] Pointer to source resource 94 //! \param dst 95 //! [in] Pointer to destination resource 96 //! \return MOS_STATUS 97 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 98 //! 99 virtual MOS_STATUS CopyMainSurface( 100 PMOS_RESOURCE src, 101 PMOS_RESOURCE dst); 102 //! 103 //! \brief Setup blt copy parameters 104 //! \details Setup blt copy parameters for BLT Engine 105 //! \param mhwParams 106 //! [in/out] Pointer to MHW_FAST_COPY_BLT_PARAM 107 //! \param inputSurface 108 //! [in] Pointer to input surface 109 //! \param outputSurface 110 //! [in] Pointer to output surface 111 //! \return MOS_STATUS 112 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 113 //! 114 virtual MOS_STATUS SetupBltCopyParam( 115 PMHW_FAST_COPY_BLT_PARAM mhwParams, 116 PMOS_RESOURCE inputSurface, 117 PMOS_RESOURCE outputSurface); 118 119 120 //! 121 //! \brief Setup fast copy parameters 122 //! \details Setup fast copy parameters for BLT Engine 123 //! \param mhwParams 124 //! [in/out] Pointer to MHW_FAST_COPY_BLT_PARAM 125 //! \param inputSurface 126 //! [in] Pointer to input surface 127 //! \param outputSurface 128 //! [in] Pointer to output surface 129 //! \return MOS_STATUS 130 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 131 //! 132 virtual MOS_STATUS SetupFastCopyBltParam( 133 PMHW_FAST_COPY_BLT_PARAM mhwParams, 134 PMOS_RESOURCE inputSurface, 135 PMOS_RESOURCE outputSurface); 136 137 //! 138 //! \brief Submit command 139 //! \details Submit BLT command 140 //! \param pBltStateParam 141 //! [in] Pointer to BLT_STATE_PARAM 142 //! \return MOS_STATUS 143 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 144 //! 145 virtual MOS_STATUS SubmitCMD( 146 PBLT_STATE_PARAM pBltStateParam); 147 148 149 //! 150 //! \brief Get color depth. 151 //! \details get different format's color depth. 152 //! \param surface 153 //! [in] input or output surface. 154 //! \return MOS_STATUS 155 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed 156 //! 157 uint32_t GetColorDepth( 158 GMM_RESOURCE_FORMAT dstFormat, 159 uint32_t BytesPerTexel); 160 161 public: 162 PMOS_INTERFACE m_osInterface = nullptr; 163 MhwInterfaces *m_mhwInterfaces = nullptr; 164 MhwMiInterface *m_miInterface = nullptr; 165 PMHW_BLT_INTERFACE m_bltInterface = nullptr; 166 MhwCpInterface *m_cpInterface = nullptr; 167 MhwInterfaces::CreateParams params; 168 }; 169 170 #endif // __MEDIA_BLT_COPY_H__ 171