1 /*
2 * Copyright (c) 2022-2023, 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_mem_decompress_xe_lpm_plus_base.h
24 //! \brief    Common interface and structure used in media decompress
25 //! \details  Common interface and structure used in media decompresswhich are platform independent
26 //!
27 #ifndef __MEDIA_MEM_DECOMPRESS_XE_LPM_PLUS_BASE_H__
28 #define __MEDIA_MEM_DECOMPRESS_XE_LPM_PLUS_BASE_H__
29 
30 #include "media_mem_decompression_next.h"
31 #include "media_perf_profiler.h"
32 
33 class MediaMemDeCompNext_Xe_Lpm_Plus_Base: virtual public MediaMemDeCompNext
34 {
35 public:
36 
37 public:
38     //!
39     //! \brief    Constructor, initiallize
40     //!
41     MediaMemDeCompNext_Xe_Lpm_Plus_Base();
42 
43     //!
44     //! \brief    Deconstructor
45     //!
~MediaMemDeCompNext_Xe_Lpm_Plus_Base()46     virtual ~MediaMemDeCompNext_Xe_Lpm_Plus_Base()
47     {
48         m_osInterface->pfnFreeResource(m_osInterface, &m_tempLinearSurface.OsResource);
49 
50         MediaPerfProfiler *perfProfiler = MediaPerfProfiler::Instance();
51 
52         if (!perfProfiler)
53         {
54             MOS_OS_ASSERTMESSAGE("Destroy MediaPerfProfiler failed!");
55         }
56         else
57         {
58             MediaPerfProfiler::Destroy(perfProfiler, (void *)this, m_osInterface);
59         }
60     }
61 
62     //!
63     //! \brief    Creat platform specific MMD (media memory decompression) HW interface
64     //! \param    [in] surface
65     //!           Pointers to surface
66     //! \return   MOS_STATUS_SUCCESS if succeeded, else error code.
67     //!
68     virtual MOS_STATUS RenderDecompCMD(
69         PMOS_SURFACE surface);
70 
71     //!
72     //! \brief    Media memory decompression Enabled or not
73     //! \details  Media memory decompression Enabled or not
74     //!
75     //! \return   true if MMC decompression enabled, else false.
76     //!
77     virtual MOS_STATUS IsVeboxDecompressionEnabled();
78 
79     //!
80     //! \brief    Media memory double buffer decompression render
81     //! \details  Entry point to decompress media memory
82     //! \param    [in] surface
83     //!           Input surface to be copyed and decompressed
84     //! \param    [out] surface
85     //!           Output surface for clear data
86     //!
87     //! \return   MOS_STATUS_SUCCESS if succeeded, else error code.
88     //!
89     virtual MOS_STATUS RenderDoubleBufferDecompCMD(
90         PMOS_SURFACE inputSurface,
91         PMOS_SURFACE outputSurface);
92 
93     MOS_STATUS LinearCopyWith64Aligned(
94         PMOS_SURFACE inputSurface,
95         PMOS_SURFACE outputSurface);
96 
97     MOS_STATUS ReAllocateLinearSurface(
98         PMOS_SURFACE            pSurface,
99         PCCHAR                  pSurfaceName,
100         MOS_FORMAT              Format,
101         MOS_GFXRES_TYPE         DefaultResType,
102         uint32_t                dwWidth,
103         uint32_t                dwHeight,
104         bool* pbAllocated);
105 
106     //!
107     //! Vebox Send Vebox_Tile_Convert command
108     //! \param    [in,out] cmdBuffer
109     //!           Pointer to PMOS_COMMAND_BUFFER command parameters
110     //! \param    [in]     surface
111     //!           Pointer to Input Surface parameters
112     //! \param    [in]     surface
113     //!           Pointer to Output Surface parameters
114     //! \param    [in]    streamID
115     //!            Stream ID for current surface
116     //! \return   MOS_STATUS_SUCCESS if succeeded, else error code.
117     //!
118     virtual MOS_STATUS VeboxSendVeboxTileConvertCMD(
119         PMOS_COMMAND_BUFFER cmdBuffer,
120         PMOS_SURFACE        inputSurface,
121         PMOS_SURFACE        outputSurface,
122         uint32_t            streamID);
123 
124 protected:
125     MOS_SURFACE m_tempLinearSurface = {};
126     int32_t     m_multiprocesssinglebin = 0;   //!< multi process single binary flag
127 MEDIA_CLASS_DEFINE_END(MediaMemDeCompNext_Xe_Lpm_Plus_Base)
128 };
129 
130 #endif // __MEDIA_MEM_DECOMPRESS_XE_LPM_PLUS_BASE_H__
131 
132