1 /*===================== begin_copyright_notice ==================================
2 
3 # Copyright (c) 2022, Intel Corporation
4 
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
11 
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 # OTHER DEALINGS IN THE SOFTWARE.
22 
23 ======================= end_copyright_notice ==================================*/
24 
25 
26 //!
27 //! \file     media_interfaces_dg2.h
28 //! \brief    All interfaces used for DG2 that require factory creation
29 //!
30 
31 #ifndef __MEDIA_INTERFACES_XE_HPM_H__
32 #define __MEDIA_INTERFACES_XE_HPM_H__
33 
34 #include "media_interfaces_mhw.h"
35 #include "media_interfaces_mhw_next.h"
36 #include "media_interfaces_codechal.h"
37 #include "media_interfaces_codechal_next.h"
38 #include "media_interfaces_mmd.h"
39 #include "media_interfaces_mcpy.h"
40 #include "media_interfaces_cmhal.h"
41 #include "media_interfaces_vphal.h"
42 #include "media_interfaces_renderhal.h"
43 #include "media_interfaces_nv12top010.h"
44 #include "media_interfaces_decode_histogram.h"
45 #include "media_interfaces_hwinfo_device.h"
46 
47 #include "mhw_cp_interface.h"
48 #include "mhw_mi_xe_xpm_base.h"
49 #include "mhw_render_xe_hpg.h"
50 #include "mhw_sfc_xe_xpm.h"
51 #include "mhw_state_heap_xe_xpm.h"
52 #include "mhw_vebox_xe_hpm.h"
53 #include "mhw_vdbox_mfx_xe_xpm.h"
54 #include "mhw_vdbox_hcp_xe_hpm.h"
55 #include "mhw_vdbox_avp_xe_hpm.h"
56 #include "mhw_vdbox_huc_xe_hpm.h"
57 #include "mhw_vdbox_avp_g12_X.h"
58 #ifdef IGFX_VDENC_INTERFACE_EXT_SUPPORT
59 #include "mhw_vdbox_vdenc_xe_hpm_ext.h"
60 #else
61 #include "mhw_vdbox_vdenc_xe_hpm.h"
62 #endif
63 #include "vphal_render_vebox_memdecomp_xe_xpm.h"
64 #include "media_copy_xe_hpm.h"
65 #include "mhw_blt_xe_hp_base.h"
66 
67 #include "codechal_hw_xe_hpm.h"
68 #include "codechal_hw_next_xe_hpm.h"
69 
70 #ifdef _AVC_DECODE_SUPPORTED
71 #include "decode_avc_pipeline_adapter_m12.h"
72 #endif
73 
74 #ifdef _HEVC_DECODE_SUPPORTED
75 #include "decode_hevc_pipeline_adapter_m12.h"
76 #endif
77 
78 #ifdef _JPEG_DECODE_SUPPORTED
79 #include "decode_jpeg_pipeline_adapter_m12.h"
80 #endif
81 
82 #ifdef _MPEG2_DECODE_SUPPORTED
83 #include "decode_mpeg2_pipeline_adapter_m12.h"
84 #endif
85 
86 #ifdef _VC1_DECODE_SUPPORTED
87 #include "codechal_decode_vc1_xe_hpm.h"
88 #endif
89 
90 #ifdef _VP8_DECODE_SUPPORTED
91 #include "codechal_decode_vp8_g12.h"
92 #endif
93 
94 #ifdef _VP9_DECODE_SUPPORTED
95 #include "decode_vp9_pipeline_adapter_m12.h"
96 #endif
97 
98 #ifdef _AV1_DECODE_SUPPORTED
99 #include "decode_av1_pipeline_adapter_g12.h"
100 #endif
101 
102 #ifdef _HEVC_ENCODE_VDENC_SUPPORTED
103 #include "encode_hevc_vdenc_pipeline_adapter_xe_hpm.h"
104 #endif
105 
106 #ifdef _AV1_ENCODE_VDENC_SUPPORTED
107 #include "encode_av1_vdenc_pipeline_adapter_xe_hpm.h"
108 #endif
109 
110 #ifdef _AVC_ENCODE_VDENC_SUPPORTED
111 #include "codechal_vdenc_avc_xe_hpm.h"
112 #endif
113 
114 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
115 #include "codechal_vdenc_vp9_g12.h"
116 #include "codechal_vdenc_vp9_xe_hpm.h"
117 #endif
118 
119 #ifdef _JPEG_ENCODE_SUPPORTED
120 #include "codechal_encode_jpeg_g12.h"
121 #endif
122 
123 #ifdef _MEDIA_RESERVED
124 #ifdef _AVC_ENCODE_VDENC_SUPPORTED
125 #include "codechal_vdenc_avc_xe_hpm_ext.h"
126 #endif
127 
128 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
129 #ifdef _APOGEIOS_SUPPORTED
130 #include "encode_vp9_vdenc_pipeline_adapter_xe_hpm.h"
131 #endif
132 #endif
133 
134 
135 #include "cm_hal_xe_xpm.h"
136 
137 #endif // _MEDIA_RESERVED
138 
139 #include "vphal_xe_xpm.h"
140 #include "vphal_xe_hpm.h"
141 #include "renderhal_xe_hpg.h"
142 
143 #include "codechal_decode_histogram.h"
144 #include "codechal_decode_histogram_g12.h"
145 #include "decode_scalability_singlepipe.h"
146 #include "decode_scalability_multipipe.h"
147 
148 class MhwInterfacesDg2_Next : public MhwInterfacesNext
149 {
150 public:
151     // Need to remove legacy mhw sub interfaces
152     using Mi        = MhwMiInterfaceXe_Xpm_Base;
153     using Cp        = MhwCpInterface;
154     using Render    = MhwRenderInterfaceXe_Hpg;
155     using Sfc       = MhwSfcInterfaceXe_Xpm;
156     using StateHeap = MHW_STATE_HEAP_INTERFACE_XE_XPM;
157     using Mfx       = MhwVdboxMfxInterfaceXe_Xpm;
158     using Hcp       = MhwVdboxHcpInterfaceXe_Hpm;
159     using Huc       = MhwVdboxHucInterfaceXe_Hpm;
160 #ifdef IGFX_VDENC_INTERFACE_EXT_SUPPORT
161     using Vdenc     = MhwVdboxVdencInterfaceXe_HpmExt;
162 #else
163     using Vdenc     = MhwVdboxVdencInterfaceXe_Hpm;
164 #endif
165     using Vebox     = MhwVeboxInterfaceXe_Hpm;
166     using Blt       = MhwBltInterfaceXe_Hp_Base;
167 
168     virtual MOS_STATUS Initialize(
169         CreateParams params,
170         PMOS_INTERFACE osInterface);
171 
172     //!
173     //! \brief    Destroys all created MHW interfaces
174     //! \details  If the HAL creation fails, this is used for cleanup
175     //!
176     virtual void Destroy();
177 
178     std::shared_ptr<MhwMiInterface> m_miInterface = nullptr;
179 
180     MhwRenderInterface *m_renderInterface = nullptr;
181 };
182 
183 class MhwInterfacesDg2 : public MhwInterfaces
184 {
185 public:
186     MhwVdboxAvpInterface *m_avpInterface = nullptr;
187 
188     using Mi        = MhwMiInterfaceXe_Xpm_Base;
189     using Cp        = MhwCpInterface;
190     using Render    = MhwRenderInterfaceXe_Hpg;
191     using Sfc       = MhwSfcInterfaceXe_Xpm;
192     using StateHeap = MHW_STATE_HEAP_INTERFACE_XE_XPM;
193     using Mfx       = MhwVdboxMfxInterfaceXe_Xpm;
194     using Hcp       = MhwVdboxHcpInterfaceXe_Hpm;
195     using Avp       = MhwVdboxAvpInterfaceXe_Hpm;
196     using Huc       = MhwVdboxHucInterfaceXe_Hpm;
197 #ifdef IGFX_VDENC_INTERFACE_EXT_SUPPORT
198     using Vdenc     = MhwVdboxVdencInterfaceXe_HpmExt;
199 #else
200     using Vdenc     = MhwVdboxVdencInterfaceXe_Hpm;
201 #endif
202     using Vebox     = MhwVeboxInterfaceXe_Hpm;
203     using Blt       = MhwBltInterfaceXe_Hp_Base;
204 
205     virtual MOS_STATUS Initialize(
206         CreateParams params,
207         PMOS_INTERFACE osInterface);
208 
209 };
210 
211 class MmdDeviceXe_Hpm : public MmdDevice
212 {
213 public:
214     using Mmd  = MediaVeboxDecompStateXe_Xpm;
215 
216     MOS_STATUS Initialize(
217         PMOS_INTERFACE osInterface,
218         MhwInterfaces *mhwInterfaces);
219 
220     MhwInterfaces* CreateMhwInterface(
221         PMOS_INTERFACE osInterface);
222 };
223 
224 class McpyDeviceXe_Hpm : public McpyDevice
225 {
226 public:
227     using Mcpy  = MediaCopyState_Xe_Hpm;
228 
229     MOS_STATUS Initialize(
230         PMOS_INTERFACE osInterface,
231         MhwInterfaces *mhwInterfaces);
232 
233     MhwInterfaces* CreateMhwInterface(
234         PMOS_INTERFACE osInterface);
235 };
236 
237 class Nv12ToP010DeviceXe_Hpm : public Nv12ToP010Device
238 {
239 public:
240 
241     MOS_STATUS Initialize(
242         PMOS_INTERFACE osInterface);
243 };
244 
245 class CodechalDecodeInterfacesXe_Hpm
246 {
247 public:
248 #ifdef _AVC_DECODE_SUPPORTED
249     using Avc = DecodeAvcPipelineAdapterM12;
250 #endif
251 #ifdef _HEVC_DECODE_SUPPORTED
252     using Hevc = DecodeHevcPipelineAdapterM12;
253 #endif
254 #ifdef _JPEG_DECODE_SUPPORTED
255     using Jpeg = DecodeJpegPipelineAdapterM12;
256 #endif
257 #ifdef _MPEG2_DECODE_SUPPORTED
258     using Mpeg2 = DecodeMpeg2PipelineAdapterM12;
259 #endif
260 #ifdef _VC1_DECODE_SUPPORTED
261     using Vc1 = CodechalDecodeVc1Xe_Hpm;
262 #endif
263 #ifdef _VP8_DECODE_SUPPORTED
264     using Vp8 = CodechalDecodeVp8G12;
265 #endif
266 #ifdef _VP9_DECODE_SUPPORTED
267     using Vp9 = DecodeVp9PipelineAdapterG12;
268 #endif
269 #ifdef _AV1_DECODE_SUPPORTED
270     using Av1 = DecodeAv1PipelineAdapterG12;
271 #endif
272 };
273 
274 class CodechalEncodeInterfacesXe_Hpm
275 {
276 public:
277 #ifdef _MEDIA_RESERVED
278 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
279     using Vp9 = CodechalVdencVp9StateXe_Xpm;
280 #endif
281 #ifdef _AVC_ENCODE_VDENC_SUPPORTED
282     using AvcVdenc = CodechalVdencAvcStateXe_HpmExt;
283 #endif
284 #else
285 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
286     using Vp9 = CodechalVdencVp9StateXe_Xpm;
287 #endif
288 #ifdef _AVC_ENCODE_VDENC_SUPPORTED
289     using AvcVdenc = CodechalVdencAvcStateXe_Hpm;
290 #endif
291 #endif
292 
293 #ifdef _JPEG_ENCODE_SUPPORTED
294     using Jpeg = CodechalEncodeJpegStateG12;
295 #endif
296 #ifdef _HEVC_ENCODE_VDENC_SUPPORTED
297     using HevcVdenc = EncodeHevcVdencPipelineAdapterXe_Hpm;
298 #endif
299 #ifdef _AV1_ENCODE_VDENC_SUPPORTED
300     using Av1Vdenc = EncodeAv1VdencPipelineAdapterXe_Hpm;
301 #endif
302 };
303 
304 class CodechalInterfacesXe_Hpm : public CodechalDevice
305 {
306 public:
307     using Decode = CodechalDecodeInterfacesXe_Hpm;
308     using Encode = CodechalEncodeInterfacesXe_Hpm;
309     using Hw = CodechalHwInterfaceXe_Hpm;
310 
311     virtual MOS_STATUS Initialize(
312         void *standardInfo,
313         void *settings,
314         MhwInterfaces *mhwInterfaces,
315         PMOS_INTERFACE osInterface) override;
316 
317 protected:
318     virtual MOS_STATUS CreateCodecHalInterface(MhwInterfaces  *mhwInterfaces,
319                                        CodechalHwInterface    *&pHwInterface,
320                                        CodechalDebugInterface *&pDebugInterface,
321                                        PMOS_INTERFACE         osInterface,
322                                        CODECHAL_FUNCTION      CodecFunction,
323                                        bool                   disableScalability);
324 
325     virtual MOS_STATUS CreateCodecHalInterface(MhwInterfaces *mhwInterfaces,
326         MhwInterfacesNext                                   *&pMhwInterfacesNext,
327         CodechalHwInterfaceNext                                 *&pHwInterface,
328         CodechalDebugInterface                              *&pDebugInterface,
329         PMOS_INTERFACE                                        osInterface,
330         CODECHAL_FUNCTION                                     CodecFunction,
331         bool                                                  disableScalability);
332 };
333 class CodechalInterfacesNextXe_Hpm : public CodechalDeviceNext
334 {
335 public:
336     using Decode = CodechalDecodeInterfacesXe_Hpm;
337     using Encode = CodechalEncodeInterfacesXe_Hpm;
338     using Hw     = CodechalHwInterfaceNextXe_Hpm;
339 
340     virtual MOS_STATUS Initialize(
341         void          *standardInfo,
342         void          *settings,
343         MhwInterfacesNext *mhwInterfaces,
344         PMOS_INTERFACE osInterface) override;
345 };
346 
347 #define DG2_L3_CONFIG_COUNT     6
348 // 4KB per Way for DG2, two Way per section
349 static const L3ConfigRegisterValues DG2_L3_PLANES[DG2_L3_CONFIG_COUNT] =
350 {                                    //  Rest  R/W  RO   UTC  CB  Sum (in KB)
351     {0x00000200, 0, 0, 0},           //  512   0    0    0    0   512
352     {0xC0000000, 0x40000000, 0, 0},  //  384   0    0    128  0   512
353     {0xF0000000, 0x00000080, 0, 0},  //  480   0    0    0    32  512
354     {0x80000000, 0x80000000, 0, 0},  //  256   0    0    256  0   512
355     {0x40000000, 0x00000080, 0, 0},  //  0     128  352  0    32  512
356     {0x80000000, 0x70000080, 0, 0},  //  256   0    0    224  32  512
357 };
358 
359 #ifdef _MEDIA_RESERVED
360 class CMHalInterfacesXe_Hpm : public CMHalDevice
361 {
362 protected:
363     using CMHal = CmHalXe_Xpm;
364     MOS_STATUS Initialize(
365         CM_HAL_STATE *pCmState);
366 };
367 #endif
368 
369 class VphalInterfacesXe_Hpm : public VphalDevice
370 {
371 public:
372     using VphalState = VphalStateXe_Hpm;
373 
374     MOS_STATUS Initialize(
375         PMOS_INTERFACE  osInterface,
376         bool            bInitVphalState,
377         MOS_STATUS      *eStatus,
378         bool            clearViewMode = false);
379 
380     MOS_STATUS CreateVpPlatformInterface(
381         PMOS_INTERFACE           osInterface,
382         MOS_STATUS *             eStatus);
383 
384 private:
385     void InitPlatformKernelBinary(
386         vp::VpPlatformInterface  *&vpPlatformInterface);
387 };
388 
389 class RenderHalInterfacesXe_Hpg : public RenderHalDevice
390 {
391 protected:
392     using XRenderHal = XRenderHal_Interface_Xe_Hpg;
393     MOS_STATUS Initialize();
394 };
395 
396 class DecodeHistogramDeviceXe_Hpm : public DecodeHistogramDevice
397 {
398 public:
399     using DecodeHistogramG12 = CodechalDecodeHistogramG12;
400 
401     MOS_STATUS Initialize(
402         CodechalHwInterface *hwInterface,
403         PMOS_INTERFACE osInterface);
404 };
405 
406 class MediaInterfacesHwInfoDeviceDg2 : public MediaInterfacesHwInfoDevice
407 {
408 public:
409     virtual MOS_STATUS RefreshRevId(PLATFORM &platform, MEDIA_WA_TABLE *waTable) override;
410     virtual MOS_STATUS Initialize(PLATFORM platform) override;
411 };
412 
413 #endif // __MEDIA_INTERFACES_XE_HPM_H__
414