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