Debian Codegraph @

media_driver/agnostic/common/codec/hal/codechal_memdecomp.h

raw
1 /*
2 * Copyright (c) 2013-2017, 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 //! \file codechal_memdecomp.h
23 //! \brief Defines data structures and interfaces for media memory decompression.
24 //! \details
25 //!
26
27 #ifndef __CODECHAL_MEDIAMEMCOMP_H__
28 #define __CODECHAL_MEDIAMEMCOMP_H__
29
30 #include "mhw_render_legacy.h"
31 #include "mos_os.h"
32 #include "mediamemdecomp.h"
33
34 //!
35 //! \class MediaMemDecompState
36 //! \brief Media memory decompression state. This class defines the member fields
37 //! functions etc used by memory decompression.
38 //!
39 class MediaMemDecompState : public MediaMemDecompBaseState
40 {
41 public:
42 //!
43 //! \brief Constructor
44 //!
45 MediaMemDecompState();
46
47 //!
48 //! \brief Copy constructor
49 //!
50 MediaMemDecompState(const MediaMemDecompState&) = delete;
51
52 //!
53 //! \brief Copy assignment operator
54 //!
55 MediaMemDecompState& operator=(const MediaMemDecompState&) = delete;
56
57 //!
58 //! \brief Destructor
59 //!
60 virtual ~MediaMemDecompState();
61
62 //!
63 //! \brief Media memory decompression
64 //! \details Entry point to decompress media memory
65 //! \param targetResource
66 //! [in] The surface will be decompressed
67 //!
68 //! \return MOS_STATUS
69 //! MOS_STATUS_SUCCESS if success, else fail reason
70 //!
71 MOS_STATUS MemoryDecompress(
72 PMOS_RESOURCE targetResource);
73
74 //!
75 //! \brief Initialize memory decompress state
76 //! \details Initialize memory decompress state
77 //! \return MOS_STATUS
78 //! MOS_STATUS_SUCCESS if success, else fail reason
79 //!
80 MOS_STATUS Initialize(
81 PMOS_INTERFACE osInterface,
82 MhwCpInterface *cpInterface,
83 MhwMiInterface *miInterface,
84 MhwRenderInterface *renderInterface);
85
86 virtual PMOS_INTERFACE GetDecompStateMosInterface()
87 {
88 return m_osInterface;
89 }
90
91 protected:
92
93 //!
94 //! \enum DecompKernelStateIdx
95 //! \brief Decompress kernel state index
96 //!
97 enum DecompKernelStateIdx
98 {
99 decompKernelStatePa = 0,
100 decompKernelStatePl2,
101 decompKernelStateMax
102 };
103
104 //!
105 //! \enum CopyBindingTableOffset
106 //! \brief Decompress copy kernel binding table offset
107 //!
108 enum CopyBindingTableOffset
109 {
110 copySurfaceSrcY = 0,
111 copySurfaceSrcU = 1,
112 copySurfaceSrcV = 2,
113 copySurfaceDstY = 3,
114 copySurfaceDstU = 4,
115 copySurfaceDstV = 5,
116 copySurfaceNum = 6
117 };
118
119 //!
120 //! \brief Initialize kernel state
121 //! \details Initialize kernel state
122 //! \param kernelStateIdx
123 //! [in] Kernel state index
124 //!
125 //! \return MOS_STATUS
126 //! MOS_STATUS_SUCCESS if success, else fail reason
127 //!
128 virtual MOS_STATUS InitKernelState(uint32_t kernelStateIdx);
129
130 //!
131 //! \brief Gets a kernel information for a specific unique kernel identifier
132 //! \details Gets a kernel information for a specific unique kernel identifier
133 //! from the combined kernel
134 //! \param kernelBase
135 //! [in] The combined kernel
136 //! \param krnUniId
137 //! [in] The unique kernel identifier in the combined kernel
138 //! \param kernelBinary
139 //! [in,out] The binary of the kernel specified by krnUniId
140 //! \param kernelSize
141 //! [in,out] The size of the kernel specified by krnUniId
142 //! \return MOS_STATUS
143 //! MOS_STATUS_SUCCESS if success, else fail reason
144 //!
145 MOS_STATUS GetKernelBinaryAndSize(
146 uint8_t *kernelBase,
147 uint32_t krnUniId,
148 uint8_t **kernelBinary,
149 uint32_t *kernelSize);
150
151 //!
152 //! \brief Sets up the CURBE data for MMC and loads it into the DSH
153 //! \details Calculates the kernel binary location and size and saves this information to either the
154 //! state heap interface or the provided kernel state
155 //! \param kernelStateIdx
156 //! [in] The type of copy kernel (PA or PL2)
157 //! \return MOS_STATUS
158 //! MOS_STATUS_SUCCESS if success, else fail reason
159 //!
160 MOS_STATUS SetMediaObjectCopyCurbe(
161 DecompKernelStateIdx kernelStateIdx);
162
163 //!
164 //! \brief Set copy kernel states parameters
165 //! \details Set copy kernel states parameters for MMC
166 //! \return MOS_STATUS
167 //! MOS_STATUS_SUCCESS if success, else fail reason
168 //!
169 MOS_STATUS SetKernelStateParams();
170
171 //!
172 //! \brief Get resource information
173 //! \details Get resource information for the specifc surface
174 //! \param surface
175 //! [in] Surface pointer
176 //! \return MOS_STATUS
177 //! MOS_STATUS_SUCCESS if success, else fail reason
178 //!
179 MOS_STATUS GetResourceInfo(PMOS_SURFACE surface);
180
181 //!
182 //! \brief Get the surface width in bytes
183 //! \details Get the suface width in bytes
184 //! \param surface
185 //! [in] Surface pointer
186 //! \return uint32_t
187 //! Output the surface width
188 //!
189 uint32_t GetSurfaceWidthInBytes(PMOS_SURFACE surface);
190
191 //!
192 //! \brief Updates GPU Sync Tag (H/W Tag) using MI_STORE_DATA_IMM command.
193 //! \details Updates GPU Sync Tag (H/W Tag) using MI_STORE_DATA_IMM command.
194 //! \param cmdBuffer
195 //! [in] Resource to decompress
196 //! \return MOS_STATUS
197 //! MOS_STATUS_SUCCESS if success, else fail reason
198 //!
199 MOS_STATUS WriteSyncTagToResourceCmd(
200 PMOS_COMMAND_BUFFER cmdBuffer);
201
202 static constexpr uint32_t m_numMemDecompSyncTags = 8; //!< Number of memory decompress sync tags
203
204 PMOS_INTERFACE m_osInterface = nullptr; //!< Pointer to Os Inteface
205 MhwCpInterface *m_cpInterface = nullptr; //!< Pointer to Cp Interface
206 MhwMiInterface *m_miInterface = nullptr; //!< Pointer to MhwMiInterface
207 MhwRenderInterface *m_renderInterface = nullptr; //!< Pointer to MhwRenderInterface
208 PMHW_STATE_HEAP_INTERFACE m_stateHeapInterface = nullptr; //!< Pointer to PMHW_STATE_HEAP_INTERFACE
209 uint8_t *m_kernelBase = nullptr; //!< Pointer to kernel base address
210 MHW_STATE_HEAP_SETTINGS m_stateHeapSettings; //!< State heap setting
211 uint32_t m_krnUniId[decompKernelStateMax]; //!< Kernel unique ID
212 uint8_t *m_kernelBinary[decompKernelStateMax]; //!< Kernel binary
213 uint32_t m_kernelSize[decompKernelStateMax]; //!< Kernel size
214 MHW_KERNEL_STATE m_kernelStates[decompKernelStateMax]; //!< Kernel state
215 MOS_GPU_CONTEXT m_renderContext; //!< Render GPU context
216 bool m_renderContextUsesNullHw = false; //!< Indicate if render context use null hw or not
217 bool m_disableDecodeSyncLock = false; //!< Indicate if decode sync lock disabled or not
218 bool m_disableLockForTranscode = false; //!< Indicate if lock is disabled for transcode or not
219 uint32_t *m_cmdBufIdGlobal = nullptr; //!< Pointer to command buffer global Id
220 MOS_RESOURCE m_resCmdBufIdGlobal; //!< Resource for command buffer global Id
221 uint32_t m_currCmdBufId; //!< Current command buffer Id
222 };
223
224 #endif //__CODECHAL_MEDIAMEMCOMP_H__