1 /*
2 * Copyright (c) 2020-2022, 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      codec_hw_xe_lpm_plus_base.h
24 //! \brief     This modules implements HW interface layer to be used on Xe_LPM_plus+ platforms on all operating systems/DDIs, across CODECHAL components.
25 //!
26 #ifndef __CODECHAL_HW_XE_LPM_PLUS_BASE_H__
27 #define __CODECHAL_HW_XE_LPM_PLUS_BASE_H__
28 
29 #include "codec_hw_next.h"
30 
31 #define CODECHAL_NUM_MEDIA_STATES_XE_LPM_PLUS_BASE (CODECHAL_NUM_MEDIA_STATES + 4)
32 
33 //!  Codechal hw interface Xe_LPM_plus base
34 /*!
35 This class defines the interfaces for hardware dependent settings and functions used in Codechal for Gen12 platforms
36 */
37 class CodechalHwInterfaceXe_Lpm_Plus_Base : public CodechalHwInterfaceNext
38 {
39 protected:
40     static const CODECHAL_SSEU_SETTING m_defaultSsEuLutXeLpmPlus[CODECHAL_NUM_MEDIA_STATES_XE_LPM_PLUS_BASE];
41 
42 public:
43     CodechalHwInterfaceXe_Lpm_Plus_Base(
44         PMOS_INTERFACE    osInterface,
45         CODECHAL_FUNCTION codecFunction,
46         MhwInterfacesNext *mhwInterfacesNext,
47         bool              disableScalability = false);
48 
49     //!
50     //! \brief    Copy constructor
51     //!
52     CodechalHwInterfaceXe_Lpm_Plus_Base(const CodechalHwInterfaceXe_Lpm_Plus_Base&) = delete;
53 
54     //!
55     //! \brief    Copy assignment operator
56     //!
57     CodechalHwInterfaceXe_Lpm_Plus_Base& operator=(const CodechalHwInterfaceXe_Lpm_Plus_Base&) = delete;
58 
59     //!
60     //! \brief    Destructor
61     //!
62     virtual ~CodechalHwInterfaceXe_Lpm_Plus_Base();
63 
64     //!
65     //! \brief    Calculates the maximum size for AVP picture level commands
66     //! \details  Client facing function to calculate the maximum size for AVP picture level commands
67     //! \param    [in] mode
68     //!           Indicate the codec mode
69     //! \param    [out] commandsSize
70     //!           The maximum command buffer size
71     //! \param    [out] patchListSize
72     //!           The maximum command patch list size
73     //! \param    [in] params
74     //!           Indicate the command size parameters
75     //! \return   MOS_STATUS
76     //!           MOS_STATUS_SUCCESS if success, else fail reason
77     //!
78     MOS_STATUS GetAvpStateCommandSize(
79         uint32_t                        mode,
80         uint32_t                        *commandsSize,
81         uint32_t                        *patchListSize,
82         PMHW_VDBOX_STATE_CMDSIZE_PARAMS params) override;
83 
84     //!
85     //! \brief    Calculates maximum size for AVP tile level commands
86     //! \details  Client facing function to calculate maximum size for AVP tile level commands
87     //! \param    [in] mode
88     //!           Indicate the codec mode
89     //! \param    [out] commandsSize
90     //!            The maximum command buffer size
91     //! \param    [out] patchListSize
92     //!           The maximum command patch list size
93     //! \return   MOS_STATUS
94     //!           MOS_STATUS_SUCCESS if success, else fail reason
95     //!
96     MOS_STATUS GetAvpPrimitiveCommandSize(
97         uint32_t                        mode,
98         uint32_t                        *commandsSize,
99         uint32_t                        *patchListSize) override;
100 
101     //!
102     //! \brief    Set Rowstore Cache offsets for Gen12 specific interfaces
103     //! \details  Set Rowstore Cache offsets in sub interfaces in codechal hw G12 interface
104     //!
105     //! \param    [in] rowstoreParams
106     //!           parameters to set rowstore cache offsets
107     //!
108     //! \return   MOS_STATUS
109     //!           MOS_STATUS_SUCCESS if success, else fail reason
110     //!
111     MOS_STATUS SetRowstoreCachingOffsets(
112         PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams) override;
113 
114     //!
115     //! \brief    Send conditional batch buffer end cmd
116     //! \details  Send conditional batch buffer end cmd
117     //!
118     //! \param    [in] resource
119     //!           Reource used in conditional batch buffer end cmd
120     //! \param    [in] offset
121     //!           Reource offset used in mi atomic dword cmd
122     //! \param    [in] compData
123     //!           Compare data
124     //! \param    [in] disableCompMask
125     //!           Indicate disabling compare mask
126     //! \param    [in] enableEndCurrentBatchBuffLevel
127     //!           End Current Batch Buffer Level
128     //! \param    [in] compareOperation
129     //!           Compare operation
130     //! \param    [in,out] cmdBuffer
131     //!           command buffer
132     //!
133     //! \return   MOS_STATUS
134     //!           MOS_STATUS_SUCCESS if success, else fail reason
135     //!
136     MOS_STATUS SendCondBbEndCmd(
137         PMOS_RESOURCE              resource,
138         uint32_t                   offset,
139         uint32_t                   compData,
140         bool                       disableCompMask,
141         bool                       enableEndCurrentBatchBuffLevel,
142         uint32_t                   compareOperation,
143         PMOS_COMMAND_BUFFER        cmdBuffer);
144 
145     //!
146     //! \brief    Initialize the codechal hw interface
147     //! \details  Initialize the interface before using
148     //!
149     //! \param    [in] settings
150     //!           Settings for initialization
151     //!
152     //! \return   MOS_STATUS
153     //!           MOS_STATUS_SUCCESS if success, else fail reason
154     //!
155     MOS_STATUS Initialize(
156         CodechalSetting *settings) override;
157 
158         //!
159     //! \brief    Calculates the maximum size for HCP picture level commands
160     //! \details  Client facing function to calculate the maximum size for HCP picture level commands
161     //! \param    [in] mode
162     //!           Indicate the codec mode
163     //! \param    [out] commandsSize
164     //!           The maximum command buffer size
165     //! \param    [out] patchListSize
166     //!           The maximum command patch list size
167     //! \param    [in] params
168     //!           Indicate the command size parameters
169     //! \return   MOS_STATUS
170     //!           MOS_STATUS_SUCCESS if success, else fail reason
171     //!
172     MOS_STATUS GetHcpStateCommandSize(
173         uint32_t                        mode,
174         uint32_t *                      commandsSize,
175         uint32_t *                      patchListSize,
176         PMHW_VDBOX_STATE_CMDSIZE_PARAMS params);
177 
178     //!
179     //! \brief    Calculates maximum size for HCP slice/MB level commands
180     //! \details  Client facing function to calculate maximum size for HCP slice/MB level commands
181     //! \param    [in] mode
182     //!           Indicate the codec mode
183     //! \param    [out] commandsSize
184     //!            The maximum command buffer size
185     //! \param    [out] patchListSize
186     //!           The maximum command patch list size
187     //! \param    [in] modeSpecific
188     //!           Indicate the long or short format
189     //! \return   MOS_STATUS
190     //!           MOS_STATUS_SUCCESS if success, else fail reason
191     //!
192     MOS_STATUS GetHcpPrimitiveCommandSize(
193         uint32_t  mode,
194         uint32_t *commandsSize,
195         uint32_t *patchListSize,
196         bool      modeSpecific) override;
197 
198 
199 MEDIA_CLASS_DEFINE_END(CodechalHwInterfaceXe_Lpm_Plus_Base)
200 };
201 #endif // __CODECHAL_HW_XE_LPM_PLUS_BASE_H__
202