Debian Codegraph @

media_common/agnostic/common/hw/mhw_mi.h

raw
1 /*
2 * Copyright (c) 2015-2024, 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 mhw_mi.h
24 //! \brief MHW interface for MI and generic flush commands across all engines
25 //! \details Impelements the functionalities common across all platforms for MHW_MI
26 //!
27
28 #ifndef __MHW_MI_H__
29 #define __MHW_MI_H__
30
31 #include <memory>
32 #include "mos_defs.h"
33 #include "mos_os.h"
34 #include "mhw_mmio.h"
35 #include "mhw_utilities_next.h"
36 #include "mos_os_specific.h"
37
38 class MhwCpInterface;
39
40 #define MHW_MI_WATCHDOG_ENABLE_COUNTER 0x0
41 #define MHW_MI_WATCHDOG_DISABLE_COUNTER 0x1
42 #define MHW_MI_DEFAULT_WATCHDOG_THRESHOLD_IN_MS 60
43 #define MHW_MI_ENCODER_16K_WATCHDOG_THRESHOLD_IN_MS 2000
44 #define MHW_MI_ENCODER_8K_WATCHDOG_THRESHOLD_IN_MS 500
45 #define MHW_MI_ENCODER_4K_WATCHDOG_THRESHOLD_IN_MS 100
46 #define MHW_MI_ENCODER_FHD_WATCHDOG_THRESHOLD_IN_MS 50
47 #define MHW_MI_DECODER_720P_WATCHDOG_THRESHOLD_IN_MS 10
48 #define MHW_MI_DECODER_4K_WATCHDOG_THRESHOLD_IN_MS 20
49 #define MHW_MI_DECODER_8K_WATCHDOG_THRESHOLD_IN_MS 60
50 #define MHW_MI_DECODER_AV1_WATCHDOG_THRESHOLD_IN_MS 80
51 #define MHW_MI_DECODER_16K_WATCHDOG_THRESHOLD_IN_MS 180
52 #define MHW_MI_DECODER_16Kx16K_WATCHDOG_THRESHOLD_IN_MS 256
53 #define MHW_MI_DECODER_FHD_WATCHDOG_THRESHOLD_IN_MS_PLUS 30
54 #define MHW_MI_DECODER_4K_WATCHDOG_THRESHOLD_IN_MS_PLUS 60
55 #define MHW_MI_DECODER_8K_WATCHDOG_THRESHOLD_IN_MS_PLUS 120
56 #define MHW_MI_DECODER_16K_WATCHDOG_THRESHOLD_IN_MS_PLUS 200
57 #define MHW_MI_WATCHDOG_COUNTS_PER_MILLISECOND (19200123 / 1000) // Time stamp counts per millisecond
58
59 typedef enum _MHW_COMMON_MI_ADDRESS_SHIFT
60 {
61 MHW_COMMON_MI_GENERAL_SHIFT = 2,
62 MHW_COMMON_MI_PIPE_CONTROL_SHIFT = 3,
63 MHW_COMMON_MI_FLUSH_DW_SHIFT = 3,
64 MHW_COMMON_MI_STORE_DATA_DW_SHIFT = 2, //when write DW to memory, algin with 4 bytes.
65 MHW_COMMON_MI_STORE_DATA_QW_SHIFT = 3, //when write QW to memory, algin with 8 bytes
66 MHW_COMMON_MI_CONDITIONAL_BATCH_BUFFER_END_SHIFT = 3,
67 } MHW_COMMON_MI_ADDRESS_SHIFT;
68
69 typedef enum _MHW_MI_SET_PREDICATE_ENABLE
70 {
71 MHW_MI_SET_PREDICATE_DISABLE = 0x0, // Predication is Disabled and CS will process commands as usual.
72 MHW_MI_SET_PREDICATE_ENABLE_ON_CLEAR, // Following Commands will be NOOPED by CS only if the MI_PREDICATE_RESULT_2 is clear.
73 MHW_MI_SET_PREDICATE_ENABLE_ON_SET, // Following Commands will be NOOPED by CS only if the MI_PREDICATE_RESULT_2 is set.
74 MHW_MI_SET_PREDICATE_ENABLE_ALWAYS = 0xF,
75 } MHW_MI_SET_PREDICATE_ENABLE;
76
77 typedef enum _MHW_MI_POST_SYNC_OPERATION
78 {
79 MHW_FLUSH_NOWRITE = 0,
80 MHW_FLUSH_WRITE_IMMEDIATE_DATA = 1,
81 MHW_FLUSH_WRITE_TIMESTAMP_REG = 3
82 } MHW_MI_POST_SYNC_OPERATION;
83
84 typedef enum _MHW_COMMON_MI_ATOMIC_OPCODE
85 {
86 MHW_MI_ATOMIC_NONE = 0,
87 MHW_MI_ATOMIC_AND = 1,
88 MHW_MI_ATOMIC_OR = 2,
89 MHW_MI_ATOMIC_XOR = 3,
90 MHW_MI_ATOMIC_MOVE = 4,
91 MHW_MI_ATOMIC_INC = 5,
92 MHW_MI_ATOMIC_DEC = 6,
93 MHW_MI_ATOMIC_ADD = 7,
94 MHW_MI_ATOMIC_SUB = 8,
95 MHW_MI_ATOMIC_RSUB = 9,
96 MHW_MI_ATOMIC_IMAX = 10,
97 MHW_MI_ATOMIC_IMIN = 11,
98 MHW_MI_ATOMIC_UMAX = 12,
99 MHW_MI_ATOMIC_UMIN = 13,
100 MHW_MI_ATOMIC_CMP = 14,
101 MHW_MI_ATOMIC_MAX = 15
102 } MHW_COMMON_MI_ATOMIC_OPCODE;
103
104 typedef enum _MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION
105 {
106 MHW_MI_SAD_GREATER_THAN_SDD = 0,
107 MHW_MI_SAD_GREATER_THAN_OR_EQUAL_SDD = 1,
108 MHW_MI_SAD_LESS_THAN_SDD = 2,
109 MHW_MI_SAD_LESS_THAN_OR_EQUAL_SDD = 3,
110 MHW_MI_SAD_EQUAL_SDD = 4,
111 MHW_MI_SAD_NOT_EQUAL_SDD = 5,
112 } MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION;
113
114 typedef enum _MHW_MI_ALU_OPCODE
115 {
116 MHW_MI_ALU_NOOP = 0x0,
117 MHW_MI_ALU_LOAD = 0x80,
118 MHW_MI_ALU_LOADINV = 0x480,
119 MHW_MI_ALU_LOAD0 = 0x81,
120 MHW_MI_ALU_LOAD1 = 0x481,
121 MHW_MI_ALU_ADD = 0x100,
122 MHW_MI_ALU_SUB = 0x101,
123 MHW_MI_ALU_AND = 0x102,
124 MHW_MI_ALU_OR = 0x103,
125 MHW_MI_ALU_XOR = 0x104,
126 MHW_MI_ALU_SHR = 0x106,
127 MHW_MI_ALU_STORE = 0x180,
128 MHW_MI_ALU_STOREINV = 0x580
129 } MHW_MI_ALU_OPCODE;
130
131 typedef enum _MHW_MI_ALU_REG
132 {
133 MHW_MI_ALU_GPREG0 = 0,
134 MHW_MI_ALU_GPREG1,
135 MHW_MI_ALU_GPREG2,
136 MHW_MI_ALU_GPREG3,
137 MHW_MI_ALU_GPREG4,
138 MHW_MI_ALU_GPREG5,
139 MHW_MI_ALU_GPREG6,
140 MHW_MI_ALU_GPREG7,
141 MHW_MI_ALU_GPREG8,
142 MHW_MI_ALU_GPREG9,
143 MHW_MI_ALU_GPREG10,
144 MHW_MI_ALU_GPREG11,
145 MHW_MI_ALU_GPREG12,
146 MHW_MI_ALU_GPREG13,
147 MHW_MI_ALU_GPREG14,
148 MHW_MI_ALU_GPREG15,
149 MHW_MI_ALU_SRCA = 0x20,
150 MHW_MI_ALU_SRCB = 0x21,
151 MHW_MI_ALU_ACCU = 0x31,
152 MHW_MI_ALU_ZF = 0x32,
153 MHW_MI_ALU_CF = 0x33
154 } MHW_MI_ALU_REG;
155
156 typedef enum _MHW_FLUSH_OPERATION
157 {
158 MHW_FLUSH_NONE = 0, // No flush
159 MHW_FLUSH_WRITE_CACHE, // Flush write cache
160 MHW_FLUSH_READ_CACHE, // Flush read cache
161 MHW_FLUSH_CUSTOM // Flush with custom parameters
162 } MHW_FLUSH_OPERATION;
163
164 typedef enum _MMIO_REMAP_OPERATION
165 {
166 MMIO_REMAP_OPERATION_NONE = 0, // default operation
167 CCS_HW_FRONT_END_MMIO_REMAP // Remap CCS mmio base offset
168 }MMIO_REMAP_OPERATION;
169
170 typedef struct _MHW_PIPE_CONTROL_PARAMS
171 {
172 PMOS_RESOURCE presDest;
173 uint32_t dwResourceOffset;
174 uint32_t dwDataDW1;
175 uint32_t dwDataDW2;
176 uint32_t dwFlushMode;
177 uint32_t dwPostSyncOp;
178 uint32_t bDisableCSStall : 1;
179 uint32_t bInvalidateStateCache : 1;
180 uint32_t bInvalidateConstantCache : 1;
181 uint32_t bInvalidateVFECache : 1;
182 uint32_t bInvalidateInstructionCache : 1;
183 uint32_t bFlushRenderTargetCache : 1;
184 uint32_t bTlbInvalidate : 1;
185 uint32_t bInvalidateTextureCache : 1;
186 uint32_t bGenericMediaStateClear : 1;
187 uint32_t bIndirectStatePointersDisable : 1;
188 uint32_t bUnTypedDataPortCacheFlush : 1;
189 uint32_t bHdcPipelineFlush : 1;
190 uint32_t bKernelFenceEnabled : 1;
191 uint32_t bPPCFlush : 1;
192 } MHW_PIPE_CONTROL_PARAMS, *PMHW_PIPE_CONTROL_PARAMS;
193
194 typedef struct _MHW_MI_COPY_MEM_MEM_PARAMS
195 {
196 PMOS_RESOURCE presSrc;
197 uint32_t dwSrcOffset;
198 PMOS_RESOURCE presDst;
199 uint32_t dwDstOffset;
200 } MHW_MI_COPY_MEM_MEM_PARAMS, *PMHW_MI_COPY_MEM_MEM_PARAMS;
201
202 typedef struct _MHW_MI_STORE_REGISTER_MEM_PARAMS
203 {
204 PMOS_RESOURCE presStoreBuffer;
205 uint32_t dwOffset;
206 uint32_t dwRegister;
207 uint32_t dwOption;
208 } MHW_MI_STORE_REGISTER_MEM_PARAMS, *PMHW_MI_STORE_REGISTER_MEM_PARAMS;
209
210 typedef MHW_MI_STORE_REGISTER_MEM_PARAMS MHW_MI_LOAD_REGISTER_MEM_PARAMS, *PMHW_MI_LOAD_REGISTER_MEM_PARAMS;
211
212 typedef struct _MHW_MI_LOAD_REGISTER_REG_PARAMS
213 {
214 uint32_t dwSrcRegister;
215 uint32_t dwDstRegister;
216 } MHW_MI_LOAD_REGISTER_REG_PARAMS, *PMHW_MI_LOAD_REGISTER_REG_PARAMS;
217
218 typedef struct _MHW_MI_ALU_PARAMS
219 {
220 // DW 0
221 union
222 {
223 struct
224 {
225 uint32_t Operand2 : MOS_BITFIELD_RANGE(0, 9); // Operand-2
226 uint32_t Operand1 : MOS_BITFIELD_RANGE(10, 19); // Operand-1
227 uint32_t AluOpcode : MOS_BITFIELD_RANGE(20, 31); // ALU OPCODE
228 };
229 uint32_t Value;
230 };
231 } MHW_MI_ALU_PARAMS, *PMHW_MI_ALU_PARAMS;
232
233 typedef struct _MHW_MI_MATH_PARAMS
234 {
235 PMHW_MI_ALU_PARAMS pAluPayload;
236 uint32_t dwNumAluParams;
237 } MHW_MI_MATH_PARAMS, *PMHW_MI_MATH_PARAMS;
238
239 typedef struct _MHW_MI_LOAD_REGISTER_IMM_PARAMS
240 {
241 uint32_t dwRegister;
242 uint32_t dwData;
243 } MHW_MI_LOAD_REGISTER_IMM_PARAMS, *PMHW_MI_LOAD_REGISTER_IMM_PARAMS;
244
245 typedef struct _MHW_MI_CONDITIONAL_BATCH_BUFFER_END_PARAMS
246 {
247 PMOS_RESOURCE presSemaphoreBuffer;
248 uint32_t dwOffset;
249 uint32_t dwValue;
250 bool bDisableCompareMask;
251 uint32_t dwParamsType; //reserved
252 } MHW_MI_CONDITIONAL_BATCH_BUFFER_END_PARAMS, *PMHW_MI_CONDITIONAL_BATCH_BUFFER_END_PARAMS;
253
254 typedef struct _MHW_MI_STORE_DATA_PARAMS
255 {
256 PMOS_RESOURCE pOsResource; // Target OS Resource
257 uint32_t dwResourceOffset;
258 uint32_t dwValue; // Value to Write
259 } MHW_MI_STORE_DATA_PARAMS, *PMHW_MI_STORE_DATA_PARAMS;
260
261 typedef struct _MHW_MI_FLUSH_DW_PARAMS
262 {
263 PMOS_RESOURCE pOsResource; // Target OS Resource
264 uint32_t dwResourceOffset;
265 uint32_t dwDataDW1; // Value to Write
266 uint32_t dwDataDW2;
267 bool bVideoPipelineCacheInvalidate;
268 uint32_t postSyncOperation;
269 uint32_t bQWordEnable;
270 bool bEnablePPCFlush;
271 } MHW_MI_FLUSH_DW_PARAMS, *PMHW_MI_FLUSH_DW_PARAMS;
272
273 typedef struct _MHW_MI_ATOMIC_PARAMS
274 {
275 PMOS_RESOURCE pOsResource; // Target OS Resource
276 uint32_t dwResourceOffset;
277 bool bReturnData;
278 bool bInlineData;
279 uint32_t dwOperand1Data[4]; // Values to Write
280 uint32_t dwOperand2Data[4]; // Values to Write
281 uint32_t dwDataSize;
282 MHW_COMMON_MI_ATOMIC_OPCODE Operation;
283 } MHW_MI_ATOMIC_PARAMS, *PMHW_MI_ATOMIC_PARAMS;
284
285 typedef struct _MHW_MI_SEMAPHORE_WAIT_PARAMS
286 {
287 PMOS_RESOURCE presSemaphoreMem; // Semaphore memory Resource
288 uint64_t gpuVirtualAddress; // Semaphore memory Resource
289 uint32_t dwResourceOffset;
290 bool bRegisterPollMode;
291 bool bPollingWaitMode;
292 uint32_t dwCompareOperation;
293 uint32_t dwSemaphoreData;
294 bool b64bComparEnableWithGPR;
295 MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION CompareOperation;
296 }MHW_MI_SEMAPHORE_WAIT_PARAMS, *PMHW_MI_SEMAPHORE_WAIT_PARAMS;
297
298 typedef struct _MHW_MEDIA_STATE_FLUSH_PARAM
299 {
300 bool bFlushToGo;
301 uint8_t ui8InterfaceDescriptorOffset;
302 } MHW_MEDIA_STATE_FLUSH_PARAM, *PMHW_MEDIA_STATE_FLUSH_PARAM;
303
304 typedef struct _MHW_MI_FORCE_WAKEUP_PARAMS
305 {
306 uint32_t bForceMediaSlice0Awake : 1; //!< Force Media-Slice0 Awake
307 uint32_t bForceRenderAwake : 1; //!< Force Render Awake
308 uint32_t bForceMediaSlice1Awake : 1; //!< Force Media-Slice1 Awake
309 uint32_t bForceMediaSlice2Awake : 1; //!< Force Media-Slice2 Awake
310 uint32_t bForceMediaSlice3Awake : 1; //!< Force Media-Slice3 Awake
311 uint32_t Reserved5 : 3; //!< Reserved
312 uint32_t bHEVCPowerWellControl : 1; //!< HEVC Power Well Control
313 uint32_t bMFXPowerWellControl : 1; //!< MFX Power Well Control
314 uint32_t Reserved10 : 6; //!< Reserved
315 uint32_t bForceMediaSlice0AwakeMask : 1; //!< Force Media-Slice0 Awake Mask
316 uint32_t bForceRenderAwakeMask : 1; //!< Force Render Awake Mask
317 uint32_t bForceMediaSlice1AwakeMask : 1; //!< Force Media-Slice1 Awake Mask
318 uint32_t bForceMediaSlice2AwakeMask : 1; //!< Force Media-Slice2 Awake Mask
319 uint32_t bForceMediaSlice3AwakeMask : 1; //!< Force Media-Slice3 Awake Mask
320 uint32_t ReservedMask23_21 : 3; //!< Reserved Mask
321 uint32_t bHEVCPowerWellControlMask : 1; //!< HEVC Power Well Control Mask
322 uint32_t bMFXPowerWellControlMask : 1; //!< MFX Power Well Control Mask
323 uint32_t Reserved31_26 : 6; //!< Reserved Mask
324 } MHW_MI_FORCE_WAKEUP_PARAMS, *PMHW_MI_FORCE_WAKEUP_PARAMS;
325
326 typedef struct _MHW_MI_VD_CONTROL_STATE_PARAMS
327 {
328 bool vdencEnabled;
329 bool avpEnabled;
330 bool initialization;
331 bool vdencInitialization;
332 bool scalableModePipeLock;
333 bool scalableModePipeUnlock;
334 bool memoryImplicitFlush;
335 } MHW_MI_VD_CONTROL_STATE_PARAMS, *PMHW_MI_VD_CONTROL_STATE_PARAMS;
336
337 class MhwMiInterface
338 {
339 public:
340 virtual ~MhwMiInterface() { MHW_FUNCTION_ENTER; }
341
342 //!
343 //! \brief Adds MI_NOOP_CMD to the buffer provided
344 //! \details Either the command or batch buffer must be valid
345 //! \param [in] cmdBuffer
346 //! If valid, command buffer to which HW command is added
347 //! \param [in] batchBuffer
348 //! If valid, batch buffer to which HW command is added
349 //! \return MOS_STATUS
350 //! MOS_STATUS_SUCCESS if success, else fail reason
351 //!
352 virtual MOS_STATUS AddMiNoop(
353 PMOS_COMMAND_BUFFER cmdBuffer,
354 PMHW_BATCH_BUFFER batchBuffer) = 0;
355
356 //!
357 //! \brief Adds MI_BATCH_BUFFER_END to the buffer provided
358 //! \details Either the command or batch buffer must be valid
359 //! \param [in] cmdBuffer
360 //! If valid, command buffer to which HW command is added
361 //! \param [in] batchBuffer
362 //! If valid, batch buffer to which HW command is added
363 //! \return MOS_STATUS
364 //! MOS_STATUS_SUCCESS if success, else fail reason
365 //!
366 virtual MOS_STATUS AddMiBatchBufferEnd(
367 PMOS_COMMAND_BUFFER cmdBuffer,
368 PMHW_BATCH_BUFFER batchBuffer) = 0;
369
370 //!
371 //! \brief Add batch buffer end insertion flag
372 //!
373 //! \param [in/out] constructedCmdBuf
374 //! Constructed cmd buffer
375 //!
376 //! \return MOS_STATUS
377 //! MOS_STATUS_SUCCESS if success, else fail reason
378 //!
379 virtual MOS_STATUS AddBatchBufferEndInsertionFlag(
380 MOS_COMMAND_BUFFER &constructedCmdBuf) = 0;
381
382 //!
383 //! \brief Adds MI_BATCH_BUFFER_END to the buffer provided without any WA
384 //! \details Either the command or batch buffer must be valid
385 //! \param [in] cmdBuffer
386 //! If valid, command buffer to which HW command is added
387 //! \param [in] batchBuffer
388 //! If valid, batch buffer to which HW command is added
389 //! \return MOS_STATUS
390 //! MOS_STATUS_SUCCESS if success, else fail reason
391 //!
392 virtual MOS_STATUS AddMiBatchBufferEndOnly(
393 PMOS_COMMAND_BUFFER cmdBuffer,
394 PMHW_BATCH_BUFFER batchBuffer) = 0;
395
396 //!
397 //! \brief Adds MI_CONDITIONAL_BATCH_BUFFER_END to the command buffer
398 //! \param [in] cmdBuffer
399 //! Command buffer to which requested command is added
400 //! \param [in] params
401 //! Parameters used to populate the requested command
402 //! \return MOS_STATUS
403 //! MOS_STATUS_SUCCESS if success, else fail reason
404 //!
405 virtual MOS_STATUS AddMiConditionalBatchBufferEndCmd(
406 PMOS_COMMAND_BUFFER cmdBuffer,
407 PMHW_MI_CONDITIONAL_BATCH_BUFFER_END_PARAMS params) = 0;
408
409 //!
410 //! \brief Adds MI_BATCH_BUFFER_START to the command buffer
411 //! \param [in] cmdBuffer
412 //! Command buffer to which requested command is added
413 //! \param [in] batchBuffer
414 //! Batch buffer to refer to in MI_BATCH_BUFFER_START
415 //! \return MOS_STATUS
416 //! MOS_STATUS_SUCCESS if success, else fail reason
417 //!
418 virtual MOS_STATUS AddMiBatchBufferStartCmd(
419 PMOS_COMMAND_BUFFER cmdBuffer,
420 PMHW_BATCH_BUFFER batchBuffer) = 0;
421
422 //!
423 //! \brief Adds MI_STORE_DATA_IMM to the command buffer
424 //! \param [in] cmdBuffer
425 //! Command buffer to which requested command is added
426 //! \param [in] params
427 //! Parameters used to populate the requested command
428 //! \return MOS_STATUS
429 //! MOS_STATUS_SUCCESS if success, else fail reason
430 //!
431 virtual MOS_STATUS AddMiStoreDataImmCmd(
432 PMOS_COMMAND_BUFFER cmdBuffer,
433 PMHW_MI_STORE_DATA_PARAMS params) = 0;
434
435 //!
436 //! \brief Adds MI_FLUSH_DW to the command buffer
437 //! \param [in] cmdBuffer
438 //! Command buffer to which requested command is added
439 //! \param [in] params
440 //! Parameters used to populate the requested command
441 //! \return MOS_STATUS
442 //! MOS_STATUS_SUCCESS if success, else fail reason
443 //!
444 virtual MOS_STATUS AddMiFlushDwCmd(
445 PMOS_COMMAND_BUFFER cmdBuffer,
446 PMHW_MI_FLUSH_DW_PARAMS params) = 0;
447
448 //!
449 //! \brief Adds MI_FORCE_WAKEUP to the command buffer
450 //! \param [in] cmdBuffer
451 //! Command buffer to which requested command is added
452 //! \param [in] params
453 //! Parameters used to populate the requested command
454 //! \return MOS_STATUS
455 //! MOS_STATUS_SUCCESS if success, else fail reason
456 //!
457 virtual MOS_STATUS AddMiForceWakeupCmd(
458 PMOS_COMMAND_BUFFER cmdBuffer,
459 PMHW_MI_FORCE_WAKEUP_PARAMS params)
460 {
461 return MOS_STATUS_SUCCESS;
462 };
463
464 //!
465 //! \brief Adds MI_COPY_MEM_MEM to the command buffer
466 //! \param [in] cmdBuffer
467 //! Command buffer to which requested command is added
468 //! \param [in] params
469 //! Parameters used to populate the requested command
470 //! \return MOS_STATUS
471 //! MOS_STATUS_SUCCESS if success, else fail reason
472 //!
473 virtual MOS_STATUS AddMiCopyMemMemCmd(
474 PMOS_COMMAND_BUFFER cmdBuffer,
475 PMHW_MI_COPY_MEM_MEM_PARAMS params) = 0;
476
477 //!
478 //! \brief Adds MI_STORE_REGISTER_MEM to the command buffer
479 //! \param [in] cmdBuffer
480 //! Command buffer to which requested command is added
481 //! \param [in] params
482 //! Parameters used to populate the requested command
483 //! \return MOS_STATUS
484 //! MOS_STATUS_SUCCESS if success, else fail reason
485 //!
486 virtual MOS_STATUS AddMiStoreRegisterMemCmd(
487 PMOS_COMMAND_BUFFER cmdBuffer,
488 PMHW_MI_STORE_REGISTER_MEM_PARAMS params) = 0;
489
490 //!
491 //! \brief Adds MI_LOAD_REGISTER_MEM to the command buffer
492 //! \param [in] cmdBuffer
493 //! Command buffer to which requested command is added
494 //! \param [in] params
495 //! Parameters used to populate the requested command
496 //! \return MOS_STATUS
497 //! MOS_STATUS_SUCCESS if success, else fail reason
498 //!
499 virtual MOS_STATUS AddMiLoadRegisterMemCmd(
500 PMOS_COMMAND_BUFFER cmdBuffer,
501 PMHW_MI_STORE_REGISTER_MEM_PARAMS params) = 0;
502
503 //!
504 //! \brief Adds MI_LOAD_REGISTER_IMM to the command buffer
505 //! \param [in] cmdBuffer
506 //! Command buffer to which requested command is added
507 //! \param [in] params
508 //! Parameters used to populate the requested command
509 //! \return MOS_STATUS
510 //! MOS_STATUS_SUCCESS if success, else fail reason
511 //!
512 virtual MOS_STATUS AddMiLoadRegisterImmCmd(
513 PMOS_COMMAND_BUFFER cmdBuffer,
514 PMHW_MI_LOAD_REGISTER_IMM_PARAMS params) = 0;
515
516 //!
517 //! \brief Adds MI_LOAD_REGISTER_REG to the command buffer
518 //! \param [in] cmdBuffer
519 //! Command buffer to which requested command is added
520 //! \param [in] params
521 //! Parameters used to populate the requested command
522 //! \return MOS_STATUS
523 //! MOS_STATUS_SUCCESS if success, else fail reason
524 //!
525 virtual MOS_STATUS AddMiLoadRegisterRegCmd(
526 PMOS_COMMAND_BUFFER cmdBuffer,
527 PMHW_MI_LOAD_REGISTER_REG_PARAMS params) = 0;
528
529 //!
530 //! \brief Adds MI_MATH to the command buffer
531 //! \details MI_MATH is a variable length command requiring the ALU payload
532 //! for completion.
533 //! \param [in] cmdBuffer
534 //! Command buffer to which requested command is added
535 //! \param [in] params
536 //! Parameters used to populate the requested command
537 //! \return MOS_STATUS
538 //! MOS_STATUS_SUCCESS if success, else fail reason
539 //!
540 virtual MOS_STATUS AddMiMathCmd(
541 PMOS_COMMAND_BUFFER cmdBuffer,
542 PMHW_MI_MATH_PARAMS params) = 0;
543
544 //!
545 //! \brief Adds MI_SET_PREDICATE to the command buffer
546 //! for completion.
547 //! \param [in] cmdBuffer
548 //! Command buffer to which requested command is added
549 //! \param [in] params
550 //! Parameters used to populate the requested command
551 //! \return MOS_STATUS
552 //! MOS_STATUS_SUCCESS if success, else fail reason
553 //!
554 virtual MOS_STATUS AddMiSetPredicateCmd(
555 PMOS_COMMAND_BUFFER cmdBuffer,
556 MHW_MI_SET_PREDICATE_ENABLE enableFlag) = 0;
557
558 //!
559 //! \brief Adds MI_ATOMIC to the command buffer
560 //! \param [in] cmdBuffer
561 //! Command buffer to which requested command is added
562 //! \param [in] params
563 //! Parameters used to populate the requested command
564 //! \return MOS_STATUS
565 //! MOS_STATUS_SUCCESS if success, else fail reason
566 //!
567 virtual MOS_STATUS AddMiAtomicCmd(
568 PMOS_COMMAND_BUFFER cmdBuffer,
569 PMHW_MI_ATOMIC_PARAMS params) = 0;
570
571 //!
572 //! \brief Adds MI_SEMAPHORE_WAIT to the command buffer
573 //! \param [in] cmdBuffer
574 //! Command buffer to which requested command is added
575 //! \param [in] params
576 //! Parameters used to populate the requested command
577 //! \return MOS_STATUS
578 //! MOS_STATUS_SUCCESS if success, else fail reason
579 //!
580 virtual MOS_STATUS AddMiSemaphoreWaitCmd(
581 PMOS_COMMAND_BUFFER cmdBuffer,
582 PMHW_MI_SEMAPHORE_WAIT_PARAMS params) = 0;
583
584 //!
585 //! \brief Adds MI_ARB_CHECK to the command buffer
586 //! \param [in] cmdBuffer
587 //! Command buffer to which requested command is added
588 //! \return MOS_STATUS
589 //! MOS_STATUS_SUCCESS if success, else fail reason
590 //!
591 virtual MOS_STATUS AddMiArbCheckCmd(
592 PMOS_COMMAND_BUFFER cmdBuffer) = 0;
593
594 //!
595 //! \brief Adds PIPE_CONTROL to the command buffer
596 //! \details Although this function is not an MI function, all flushses are part of
597 //! the common MI interface, either the command or batch buffer must be valid
598 //! \param [in] cmdBuffer
599 //! Command buffer to which HW command is added, if valid batchBuffer should be null
600 //! \param [in] batchBuffer
601 //! Batch buffer to which HW command is added, if valid cmdBuffer should be null
602 //! \param [in] params
603 //! Parameters used to populate the requested command
604 //! \return MOS_STATUS
605 //! MOS_STATUS_SUCCESS if success, else fail reason
606 //!
607 virtual MOS_STATUS AddPipeControl(
608 PMOS_COMMAND_BUFFER cmdBuffer,
609 PMHW_BATCH_BUFFER batchBuffer,
610 PMHW_PIPE_CONTROL_PARAMS params) = 0;
611
612 //!
613 //! \brief Adds MFX_WAIT_CMD to the buffer provided
614 //! \details Either the command or batch buffer must be valid
615 //! \param [in] cmdBuffer
616 //! If valid, command buffer to which command are added
617 //! \param [in] batchBuffer
618 //! If valid, batch buffer to which the command is added
619 //! \param [in] stallVdboxPipeline
620 //! Indicates whether or not the MFX_WAIT will wait on VDBOX pipelines (HuC/HCP/MFX)
621 //! \return MOS_STATUS
622 //! MOS_STATUS_SUCCESS if success, else fail reason
623 //!
624 virtual MOS_STATUS AddMfxWaitCmd(
625 PMOS_COMMAND_BUFFER cmdBuffer,
626 PMHW_BATCH_BUFFER batchBuffer,
627 bool stallVdboxPipeline) = 0;
628
629 //!
630 //! \brief Adds MEDIA_STATE_FLUSH to valid buffer provided
631 //! \details Client facing function to add MEDIA_STATE_FLUSH to either the
632 //! command buffer or batch buffer (whichever is valid)
633 //! \param [in] cmdBuffer
634 //! If valid, command buffer to which HW command is added
635 //! \param [in] batchBuffer
636 //! If valid, Batch buffer to which HW command is added
637 //! \param [in] params
638 //! Parameters used to populate the requested command, may be nullptr if not needed
639 //! \return MOS_STATUS
640 //! MOS_STATUS_SUCCESS if success, else fail reason
641 //!
642 virtual MOS_STATUS AddMediaStateFlush(
643 PMOS_COMMAND_BUFFER cmdBuffer,
644 PMHW_BATCH_BUFFER batchBuffer,
645 PMHW_MEDIA_STATE_FLUSH_PARAM params = nullptr) = 0;
646
647 //!
648 //! \brief Skips batch buffer end command in a batch buffer
649 //! \details Inserts the space equivalent to what would have been inserted during
650 //! AddBatchBufferEnd to the batch buffer provided.
651 //! \param [in] batchBuffer
652 //! Batch buffer which HW command is skipped
653 //! \return MOS_STATUS
654 //! MOS_STATUS_SUCCESS if success, else fail reason
655 //!
656 virtual MOS_STATUS SkipMiBatchBufferEndBb(
657 PMHW_BATCH_BUFFER batchBuffer) = 0;
658
659 //!
660 //! \brief Adds prolog for protected content
661 //! \param [in] cmdBuffer
662 //! Command buffer into which prolog is inserted
663 //! \return MOS_STATUS
664 //! MOS_STATUS_SUCCESS if success, else fail reason
665 //!
666 MOS_STATUS AddProtectedProlog(MOS_COMMAND_BUFFER *cmdBuffer);
667
668 //!
669 //! \brief Get mmio registers address
670 //! \details Get mmio registers address
671 //! \return [out] PMHW_MI_MMIOREGISTERS*
672 //! mmio registers got.
673 //!
674 inline PMHW_MI_MMIOREGISTERS GetMmioRegisters()
675 {
676 return &m_mmioRegisters;
677 }
678
679 //!
680 //! \brief Get Os interface
681 //! \details Get Os interface in codechal hw interface
682 //!
683 //! \return [out] PMOS_INTERFACE
684 //! Interface got.
685 //!
686 inline PMOS_INTERFACE GetOsInterface()
687 {
688 return m_osInterface;
689 }
690
691 //!
692 //! \brief get the size of hw command
693 //! \details Internal function to get the size of MI_FLUSH_DW_CMD
694 //! \return commandSize
695 //! The command size
696 //!
697 virtual uint32_t GetMiFlushDwCmdSize() = 0;
698
699 //!
700 //! \brief get the size of hw command
701 //! \details Internal function to get the size of MI_BATCH_BUFFER_START_CMD
702 //! \return commandSize
703 //! The command size
704 //!
705 virtual uint32_t GetMiBatchBufferStartCmdSize() = 0;
706
707 //!
708 //! \brief get the size of hw command
709 //! \details Internal function to get the size of MI_BATCH_BUFFER_END_CMD
710 //! \return commandSize
711 //! The command size
712 //!
713 virtual uint32_t GetMiBatchBufferEndCmdSize() = 0;
714
715 //!
716 //! \brief Set Watchdog Timer Threshold
717 //! \details Set Watchdog Timer Threshold
718 //! \return MOS_STATUS
719 //! MOS_STATUS_SUCCESS if success, else fail reason
720 //!
721 virtual MOS_STATUS SetWatchdogTimerThreshold(uint32_t frameWidth, uint32_t frameHeight, bool isEncoder = true) = 0;
722
723 //!
724 //! \brief Set Watchdog Timer Register Offset
725 //! \details Set Watchdog Timer Register Offset
726 //! \return MOS_STATUS
727 //! MOS_STATUS_SUCCESS if success, else fail reason
728 //!
729 virtual MOS_STATUS SetWatchdogTimerRegisterOffset(MOS_GPU_CONTEXT gpuContext) = 0;
730
731 //!
732 //! \brief Add Watchdog Timer Start Cmd
733 //! \details Add Watchdog Timer Start Cmd
734 //! \return MOS_STATUS
735 //! MOS_STATUS_SUCCESS if success, else fail reason
736 //!
737 virtual MOS_STATUS AddWatchdogTimerStartCmd(PMOS_COMMAND_BUFFER cmdBuffer) = 0;
738
739 //!
740 //! \brief Add Watchdog Timer Stop Cmd
741 //! \details Add Watchdog Timer Stop Cmd
742 //! \return MOS_STATUS
743 //! MOS_STATUS_SUCCESS if success, else fail reason
744 //!
745 virtual MOS_STATUS AddWatchdogTimerStopCmd(PMOS_COMMAND_BUFFER cmdBuffer) = 0;
746
747 //!
748 //! \brief Adds Mi Vd control state cmd in command buffer
749 //!
750 //! \param [in] cmdBuffer
751 //! Command buffer to which HW command is added
752 //! \param [in] params
753 //! Params structure used to populate the HW command
754 //!
755 //! \return MOS_STATUS
756 //! MOS_STATUS_SUCCESS if success, else fail reason
757 //!
758 virtual MOS_STATUS AddMiVdControlStateCmd(
759 PMOS_COMMAND_BUFFER cmdBuffer,
760 PMHW_MI_VD_CONTROL_STATE_PARAMS params)
761 {
762 return MOS_STATUS_SUCCESS;
763 };
764
765 //!
766 //! \brief Get new render interface, temporal solution before switching from
767 //! old interface to new one
768 //!
769 //! \return pointer to new render interface
770 //!
771 virtual std::shared_ptr<void> GetNewMiInterface() { return nullptr; }
772
773 protected:
774 //!
775 //! \brief Initializes the MI interface
776 //! \details Internal MHW function to initialize all function pointers and some parameters
777 //! Assumes that the caller has checked pointer validity and whether or not an
778 //! addressing method has been selected in the OS interface (bUsesGfxAddress or
779 //! bUsesPatchList).
780 //! \param [in] pCpInterface
781 //! CP interface, must be valid
782 //! \param [in] pOsInterface
783 //! OS interface, must be valid
784 //!
785 MhwMiInterface(
786 MhwCpInterface *cpInterface,
787 PMOS_INTERFACE osInterface);
788
789 //!
790 //! \brief Adds a resource to the command buffer or indirect state (SSH)
791 //! \details Internal MHW function to add either a graphics address of a resource or
792 //! add the resource to the patch list for the requested buffer or state
793 //! \param [in] pOsInterface
794 //! OS interface
795 //! \param [in] cmdBuffer
796 //! If adding a resource to the command buffer, the buffer to which the resource
797 //! is added
798 //! \param [in] params
799 //! Parameters necessary to add the graphics address
800 //! \return MOS_STATUS
801 //! MOS_STATUS_SUCCESS if success, else fail reason
802 //!
803 MOS_STATUS (*AddResourceToCmd) (
804 PMOS_INTERFACE pOsInterface,
805 PMOS_COMMAND_BUFFER cmdBuffer,
806 PMHW_RESOURCE_PARAMS params) = nullptr;
807
808 //!
809 //! \brief Helper function to get GTT type (PGTT or GGTT)
810 //! \return bool
811 //! true for GGTT, false for PPGTT
812 //!
813 bool IsGlobalGttInUse();
814
815 void GetWatchdogThreshold(PMOS_INTERFACE osInterface);
816
817 MhwCpInterface *m_cpInterface = nullptr; //!< Responsible for CP functionality
818 PMOS_INTERFACE m_osInterface = nullptr; //!< Responsible for interaction with OS
819
820 //! \brief Indicates the global GTT setting on each engine.
821 struct
822 {
823 uint8_t m_cs : 1; //!< GGTT in use for the render engine.
824 uint8_t m_vcs : 1; //!< GGTT in use for VDBOX.
825 uint8_t m_vecs : 1; //!< GGTT in use for VEBOX.
826 } UseGlobalGtt;
827
828 //! \brief Indicates the MediaReset Parameter.
829 struct
830 {
831 uint32_t watchdogCountThreshold;
832 uint32_t watchdogCountCtrlOffset;
833 uint32_t watchdogCountThresholdOffset;
834 } MediaResetParam;
835
836 //! \brief Mmio registers address
837 MHW_MI_MMIOREGISTERS m_mmioRegisters = {}; //!< mfx mmio registers
838
839 std::shared_ptr<void> m_miItfNew = nullptr;
840 };
841
842 #endif // __MHW_MI_H__