xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/common/renderhal/hal_oca_interface.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2019-2021, 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     hal_oca_interface.h
24 //! \brief    Implementation of functions for HAL OCA Interface
25 //!
26 
27 #ifndef __HAL_OCA_INTERFACE_H__
28 #define __HAL_OCA_INTERFACE_H__
29 
30 #include "mhw_mi.h"
31 #include "mos_os_hw.h"
32 #include "hal_oca_interface_next.h"
33 
34 /****************************************************************************************************/
35 /*                                      HalOcaInterface                                             */
36 /****************************************************************************************************/
37 
38 class HalOcaInterface: public HalOcaInterfaceNext
39 {
40 public:
41     //!
42     //! \brief  Oca operation which should be called at the beginning of 1st level batch buffer start.
43     //! \param  [in/out] cmdBuffer
44     //!         Command buffer for current BB. hOcaBuf in cmdBuffer will be updated.
45     //! \param  [in] mosContext
46     //!         Reference to MOS_CONTEXT.
47     //! \param  [in] gpuContextHandle
48     //!         Gpu context handle
49     //! \param  [in] mhwMiInterface
50     //!         Reference to MhwMiInterface.
51     //! \param  [in] mmioRegisters
52     //!         mmio registers for current engine.
53     //! \param  [in] offsetOf1stLevelBB
54     //!         Offset for current BB in cmdBuffer.
55     //! \param  [in] bUseSizeOfCmdBuf
56     //!         If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB.
57     //! \param  [in] sizeOf1stLevelBB
58     //!         Size of BB. Ignore if bUseSizeOfResource == true.
59     //! \return void
60     //!         No return value. Handle all exception inside the function.
61     //!
62     static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext,
63         uint32_t gpuContextHandle, MhwMiInterface &mhwMiInterface, MHW_MI_MMIOREGISTERS &mmioRegisters,
64         uint32_t offsetOf1stLevelBB = 0, bool bUseSizeOfCmdBuf = true, uint32_t sizeOf1stLevelBB = 0);
65 
66     //!
67     //! \brief  Oca operation which should be called at the beginning of 1st level batch buffer start.
68     //! \param  [in/out] cmdBuffer
69     //!         Command buffer for current BB. hOcaBuf in cmdBuffer will be updated.
70     //! \param  [in] mosContext
71     //!         Reference to MOS_CONTEXT.
72     //! \param  [in] gpuContextHandle
73     //!         Gpu context handle
74     //! \param  [in] mhwMiInterface
75     //!         Reference to MhwMiInterface.
76     //! \param  [in] mmioRegisters
77     //!         mmio registers for current engine.
78     //! \param  [in] offsetOf1stLevelBB
79     //!         Offset for current BB in cmdBuffer.
80     //! \param  [in] bUseSizeOfCmdBuf
81     //!         If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB.
82     //! \param  [in] sizeOf1stLevelBB
83     //!         Size of BB. Ignore if bUseSizeOfResource == true.
84     //! \return void
85     //!         No return value. Handle all exception inside the function.
86     //!
87     static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext,
88         uint32_t gpuContextHandle, MhwMiInterface &mhwMiInterface, MmioRegistersMfx &mmioRegisters,
89         uint32_t offsetOf1stLevelBB = 0, bool bUseSizeOfCmdBuf = true, uint32_t sizeOf1stLevelBB = 0);
90 
91     //!
92     //! \brief  Oca operation which should be called before adding dispatch states,
93     //!         e.g. VEB_DI_IECP_STATE and MEDIA_OBJECT_WALKER.
94     //! \param  [in] cmdBuffer
95     //!         Command buffer for current BB.
96     //! \param  [in] mosContext
97     //!         Reference to MOS_CONTEXT.
98     //! \param  [in] mhwMiInterface
99     //!         Reference to MhwMiInterface.
100     //! \param  [in] mmioRegisters
101     //!         mmio registers for current engine.
102     //! \return void
103     //!         No return value. Handle all exception inside the function.
104     //!
105     static void OnDispatch(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, MhwMiInterface &mhwMiInterface, MHW_MI_MMIOREGISTERS &mmioRegisters);
106 
107 protected:
108     static MOS_STATUS MhwMiLoadRegisterImmCmd(
109         MhwMiInterface                   *pMiInterface,
110         PMOS_COMMAND_BUFFER              pCmdBuffer,
111         MHW_MI_LOAD_REGISTER_IMM_PARAMS  *params);
112 
113     // Private functions to ensure class singleton.
114     HalOcaInterface();
115     HalOcaInterface(HalOcaInterface &);
116     HalOcaInterface& operator= (HalOcaInterface &);
117 
118 };
119 
120 
121 #endif // __RHAL_OCA_INTERFACE_H__
122