1 /*===================== begin_copyright_notice ==================================
2 
3 # Copyright (c) 2021, 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 //! \file     media_interfaces_dg2.h
26 //! \brief    All interfaces used for DG2 that require factory creation
27 //!
28 
29 #ifndef __MEDIA_INTERFACES_XE_HPM_H__
30 #define __MEDIA_INTERFACES_XE_HPM_H__
31 
32 #include "media_interfaces_mhw.h"
33 #include "media_interfaces_mhw_next.h"
34 #include "media_interfaces_codechal.h"
35 #include "media_interfaces_mmd.h"
36 #include "media_interfaces_mcpy.h"
37 #include "media_interfaces_cmhal.h"
38 #include "media_interfaces_mosutil.h"
39 #include "media_interfaces_vphal.h"
40 #include "media_interfaces_renderhal.h"
41 #include "media_interfaces_nv12top010.h"
42 #include "media_interfaces_decode_histogram.h"
43 #include "media_interfaces_hwinfo_device.h"
44 
45 #include "mhw_cp_interface.h"
46 #include "mhw_mi_xe_xpm_base.h"
47 #include "mhw_render_xe_hpg.h"
48 #include "mhw_sfc_xe_xpm.h"
49 #include "mhw_state_heap_xe_xpm.h"
50 #include "mhw_vebox_xe_hpm.h"
51 #include "mhw_vdbox_mfx_xe_xpm.h"
52 #include "mhw_vdbox_hcp_impl_legacy_xe_hpm.h"
53 #include "mhw_vdbox_avp_xe_hpm.h"
54 #include "mhw_vdbox_huc_xe_hpm.h"
55 #include "mhw_vdbox_avp_g12_X.h"
56 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
57 #include "mhw_vdbox_vdenc_xe_hpm.h"
58 #include "mhw_vdbox_vdenc_xe_hpm_ext.h"
59 #else
60 #include "mhw_vdbox_vdenc_g12_X.h"
61 #endif
62 #include "vphal_render_vebox_memdecomp_xe_xpm.h"
63 #include "media_copy_xe_xpm_base.h"
64 #include "mhw_blt_xe_hp_base.h"
65 
66 #include "codechal_hw_xe_hpm.h"
67 
68 #ifdef _AVC_DECODE_SUPPORTED
69 #include "decode_avc_pipeline_adapter_m12.h"
70 #endif
71 
72 #ifdef _HEVC_DECODE_SUPPORTED
73 #include "decode_hevc_pipeline_adapter_m12.h"
74 #endif
75 
76 #ifdef _JPEG_DECODE_SUPPORTED
77 #include "decode_jpeg_pipeline_adapter_m12.h"
78 #endif
79 
80 #ifdef _MPEG2_DECODE_SUPPORTED
81 #include "decode_mpeg2_pipeline_adapter_m12.h"
82 #endif
83 
84 #ifdef _VC1_DECODE_SUPPORTED
85 #include "codechal_decode_vc1_xe_hpm.h"
86 #endif
87 
88 #ifdef _VP8_DECODE_SUPPORTED
89 #include "codechal_decode_vp8_g12.h"
90 #endif
91 
92 #ifdef _VP9_DECODE_SUPPORTED
93 #include "decode_vp9_pipeline_adapter_m12.h"
94 #endif
95 
96 #ifdef _AV1_DECODE_SUPPORTED
97 #include "decode_av1_pipeline_adapter_g12.h"
98 #endif
99 
100 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
101 #ifdef _JPEG_ENCODE_SUPPORTED
102 #include "codechal_encode_jpeg_g12.h"
103 #endif
104 
105 #include "codechal_encode_csc_ds_xe_xpm.h"
106 #include "codechal_encode_csc_ds_mdf_xe_xpm.h"
107 
108 #ifdef _HEVC_ENCODE_VME_SUPPORTED
109 #include "codechal_encode_hevc_g12.h"
110 #include "codechal_encode_hevc_mbenc_xe_xpm.h"
111 #include "codechal_encode_csc_ds_mdf_g12.h"
112 #endif
113 #ifdef _HEVC_ENCODE_VDENC_SUPPORTED
114 #include "encode_hevc_vdenc_pipeline_adapter_xe_hpm.h"
115 #ifdef _APOGEIOS_SUPPORTED
116 #endif
117 #endif
118 
119 #ifdef _AV1_ENCODE_VDENC_SUPPORTED
120 #include "encode_av1_vdenc_pipeline_adapter_xe_hpm.h"
121 #endif
122 
123 #ifdef _AVC_ENCODE_VDENC_SUPPORTED
124 #include "codechal_vdenc_avc_xe_hpm.h"
125 #endif
126 
127 #include "codechal_memdecomp_g11_icl.h"
128 
129 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
130 #include "codechal_vdenc_vp9_g12.h"
131 #include "codechal_vdenc_vp9_xe_hpm.h"
132 #ifdef _APOGEIOS_SUPPORTED
133 #include "encode_vp9_vdenc_pipeline_adapter_xe_hpm.h"
134 #endif
135 #endif
136 
137 #include "codechal_encoder_unsupported.h"
138 #endif
139 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
140 #include "cm_hal_xe_xpm.h"
141 #endif
142 #include "vphal_xe_xpm.h"
143 #include "vphal_xe_hpm.h"
144 #include "renderhal_xe_hpg.h"
145 #include "media_user_settings_mgr_g12_plus.h"
146 
147 #include "codechal_decode_histogram.h"
148 #include "codechal_decode_histogram_g12.h"
149 
150 class MhwInterfacesDg2_Next : public MhwInterfacesNext
151 {
152 public:
153     // Need to remove legacy mhw sub interfaces
154     using Mi        = MhwMiInterfaceXe_Xpm_Base;
155     using Cp        = MhwCpInterface;
156     using Render    = MhwRenderInterfaceXe_Hpg;
157     using Sfc       = MhwSfcInterfaceXe_Xpm;
158     using StateHeap = MHW_STATE_HEAP_INTERFACE_XE_XPM;
159     using Mfx       = MhwVdboxMfxInterfaceXe_Xpm;
160     using Hcp       = MhwVdboxHcpInterfaceXe_Hpm;
161     using Huc       = MhwVdboxHucInterfaceXe_Hpm;
162 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
163     using Vdenc     = MhwVdboxVdencInterfaceXe_HpmExt;
164 #else
165     using Vdenc     = MhwVdboxVdencInterfaceG12X;
166 #endif
167     using Vebox     = MhwVeboxInterfaceXe_Hpm;
168     using Blt       = MhwBltInterfaceXe_Hp_Base;
169 
170     virtual MOS_STATUS Initialize(
171         CreateParams params,
172         PMOS_INTERFACE osInterface);
173 
174     //!
175     //! \brief    Destroys all created MHW interfaces
176     //! \details  If the HAL creation fails, this is used for cleanup
177     //!
178     virtual void Destroy();
179 };
180 
181 class MhwInterfacesDg2 : public MhwInterfaces
182 {
183 public:
184     MhwVdboxAvpInterface *m_avpInterface = nullptr;
185 
186     using Mi        = MhwMiInterfaceXe_Xpm_Base;
187     using Cp        = MhwCpInterface;
188     using Render    = MhwRenderInterfaceXe_Hpg;
189     using Sfc       = MhwSfcInterfaceXe_Xpm;
190     using StateHeap = MHW_STATE_HEAP_INTERFACE_XE_XPM;
191     using Mfx       = MhwVdboxMfxInterfaceXe_Xpm;
192     using Hcp       = MhwVdboxHcpInterfaceXe_Hpm;
193     using Avp       = MhwVdboxAvpInterfaceXe_Hpm;
194     using Huc       = MhwVdboxHucInterfaceXe_Hpm;
195 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
196     using Vdenc     = MhwVdboxVdencInterfaceXe_HpmExt;
197 #else
198     using Vdenc     = MhwVdboxVdencInterfaceG12X;
199 #endif
200     using Vebox     = MhwVeboxInterfaceXe_Hpm;
201     using Blt       = MhwBltInterfaceXe_Hp_Base;
202 
203     virtual MOS_STATUS Initialize(
204         CreateParams params,
205         PMOS_INTERFACE osInterface);
206 
207 };
208 
209 class MmdDeviceXe_Hpm : public MmdDevice
210 {
211 public:
212     using Mmd  = MediaVeboxDecompStateXe_Xpm;
213 
214     MOS_STATUS Initialize(
215         PMOS_INTERFACE osInterface,
216         MhwInterfaces *mhwInterfaces);
217 
218     MhwInterfaces* CreateMhwInterface(
219         PMOS_INTERFACE osInterface);
220 };
221 
222 class McpyDeviceXe_Hpm : public McpyDevice
223 {
224 public:
225     using Mcpy  = MediaCopyStateXe_Xpm_Base;
226 
227     MOS_STATUS Initialize(
228         PMOS_INTERFACE osInterface,
229         MhwInterfaces *mhwInterfaces);
230 
231     MhwInterfaces* CreateMhwInterface(
232         PMOS_INTERFACE osInterface);
233 };
234 
235 class Nv12ToP010DeviceXe_Hpm : public Nv12ToP010Device
236 {
237 public:
238 
239     MOS_STATUS Initialize(
240         PMOS_INTERFACE osInterface);
241 };
242 
243 class CodechalDecodeInterfacesXe_Hpm
244 {
245 public:
246 #ifdef _AVC_DECODE_SUPPORTED
247     using Avc = DecodeAvcPipelineAdapterM12;
248 #endif
249 #ifdef _HEVC_DECODE_SUPPORTED
250     using Hevc = DecodeHevcPipelineAdapterM12;
251 #endif
252 #ifdef _JPEG_DECODE_SUPPORTED
253     using Jpeg = DecodeJpegPipelineAdapterM12;
254 #endif
255 #ifdef _MPEG2_DECODE_SUPPORTED
256     using Mpeg2 = DecodeMpeg2PipelineAdapterM12;
257 #endif
258 #ifdef _VC1_DECODE_SUPPORTED
259     using Vc1 = CodechalDecodeVc1Xe_Hpm;
260 #endif
261 #ifdef _VP8_DECODE_SUPPORTED
262     using Vp8 = CodechalDecodeVp8G12;
263 #endif
264 #ifdef _VP9_DECODE_SUPPORTED
265     using Vp9 = DecodeVp9PipelineAdapterG12;
266 #endif
267 #ifdef _AV1_DECODE_SUPPORTED
268     using Av1 = DecodeAv1PipelineAdapterG12;
269 #endif
270 };
271 
272 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
273 class CodechalEncodeInterfacesXe_Hpm
274 {
275 public:
276     using CscDs = CodechalEncodeCscDsXe_Xpm;
277     using CscDsMdf = CodechalEncodeCscDsMdfXe_Xpm;
278 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
279     using Vp9 = CodechalVdencVp9StateXe_Xpm;
280 #endif
281 #ifdef _JPEG_ENCODE_SUPPORTED
282     using Jpeg = CodechalEncodeJpegStateG12;
283 #endif
284 #ifdef _MPEG2_ENCODE_VME_SUPPORTED
285     using Mpeg2 = CodechalEncoderStateUnsupported;
286 #endif
287 #ifdef _HEVC_ENCODE_VME_SUPPORTED
288     using HevcEnc = CodechalEncHevcStateG12;
289     using HevcMbenc = CodecHalHevcMbencXe_Xpm;
290 #endif
291 #ifdef _HEVC_ENCODE_VDENC_SUPPORTED
292     using HevcVdenc = EncodeHevcVdencPipelineAdapterXe_Hpm;
293 #endif
294 #ifdef _AVC_ENCODE_VME_SUPPORTED
295     using AvcEnc = CodechalEncoderStateUnsupported;
296 #endif
297 #ifdef _AVC_ENCODE_VDENC_SUPPORTED
298     using AvcVdenc = CodechalVdencAvcStateXe_Hpm;
299 #endif
300 #ifdef _AV1_ENCODE_VDENC_SUPPORTED
301     using Av1Vdenc = EncodeAv1VdencPipelineAdapterXe_Hpm;
302 #endif
303 };
304 #endif
305 
306 class CodechalInterfacesXe_Hpm : public CodechalDevice
307 {
308 public:
309     using Decode = CodechalDecodeInterfacesXe_Hpm;
310 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
311     using Encode = CodechalEncodeInterfacesXe_Hpm;
312 #endif
313     using Hw = CodechalHwInterfaceXe_Hpm;
314 
315     MOS_STATUS Initialize(
316         void *standardInfo,
317         void *settings,
318         MhwInterfaces *mhwInterfaces,
319         PMOS_INTERFACE osInterface) override;
320 
321 private:
322     MOS_STATUS CreateCodecHalInterface(MhwInterfaces          *mhwInterfaces,
323                                        CodechalHwInterface    *&pHwInterface,
324                                        CodechalDebugInterface *&pDebugInterface,
325                                        PMOS_INTERFACE         osInterface,
326                                        CODECHAL_FUNCTION      CodecFunction,
327                                        bool                   disableScalability);
328 
329     MOS_STATUS CreateCodecHalInterface(MhwInterfaces          *mhwInterfaces,
330                                        MhwInterfacesNext      *&pMhwInterfacesNext,
331                                        CodechalHwInterface    *&pHwInterface,
332                                        CodechalDebugInterface *&pDebugInterface,
333                                        PMOS_INTERFACE         osInterface,
334                                        CODECHAL_FUNCTION      CodecFunction,
335                                        bool                   disableScalability);
336 };
337 
338 #define DG2_L3_CONFIG_COUNT     6
339 // 4KB per Way for DG2, two Way per section
340 static const L3ConfigRegisterValues DG2_L3_PLANES[DG2_L3_CONFIG_COUNT] =
341 {                                    //  Rest  R/W  RO   UTC  CB  Sum (in KB)
342     {0x00000200, 0, 0, 0},           //  512   0    0    0    0   512
343     {0xC0000000, 0x40000000, 0, 0},  //  384   0    0    128  0   512
344     {0xF0000000, 0x00000080, 0, 0},  //  480   0    0    0    32  512
345     {0x80000000, 0x80000000, 0, 0},  //  256   0    0    256  0   512
346     {0x40000000, 0x00000080, 0, 0},  //  0     128  352  0    32  512
347     {0x80000000, 0x70000080, 0, 0},  //  256   0    0    224  32  512
348 };
349 
350 #ifdef IGFX_DG2_ENABLE_NON_UPSTREAM
351 class CMHalInterfacesXe_Hpm : public CMHalDevice
352 {
353 protected:
354     using CMHal = CmHalXe_Xpm;
355     MOS_STATUS Initialize(
356         CM_HAL_STATE *pCmState);
357 };
358 #endif
359 
360 class MosUtilDeviceXe_Hpm : public MosUtilDevice
361 {
362 public:
363     using MosUtil = MediaUserSettingsMgr_g12;
364 
365     MOS_STATUS Initialize();
366 };
367 
368 class VphalInterfacesXe_Hpm : public VphalDevice
369 {
370 public:
371     using VphalState = VphalStateXe_Hpm;
372 
373     MOS_STATUS Initialize(
374         PMOS_INTERFACE  osInterface,
375         PMOS_CONTEXT    osDriverContext,
376         bool            bInitVphalState,
377         MOS_STATUS      *eStatus);
378 
379     MOS_STATUS CreateVpPlatformInterface(
380         PMOS_INTERFACE           osInterface,
381         MOS_STATUS *             eStatus);
382 };
383 
384 class RenderHalInterfacesXe_Hpg : public RenderHalDevice
385 {
386 protected:
387     using XRenderHal = XRenderHal_Interface_Xe_Hpg;
388     MOS_STATUS Initialize();
389 };
390 
391 class DecodeHistogramDeviceXe_Hpm : public DecodeHistogramDevice
392 {
393 public:
394     using DecodeHistogramG12 = CodechalDecodeHistogramG12;
395 
396     MOS_STATUS Initialize(
397         CodechalHwInterface *hwInterface,
398         PMOS_INTERFACE osInterface);
399 };
400 
401 class MediaInterfacesHwInfoDeviceDg2 : public MediaInterfacesHwInfoDevice
402 {
403 public:
404     virtual MOS_STATUS RefreshRevId(PLATFORM &platform, MEDIA_WA_TABLE *waTable) override;
405     virtual MOS_STATUS Initialize(PLATFORM platform) override;
406 };
407 
408 #endif // __MEDIA_INTERFACES_XE_HPM_H__
409