xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/shared/null_hardware_next.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
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     null_hardware_next.cpp
24 //! \brief    Defines interfaces for null hardware
25 #include "null_hardware.h"
26 #include "mhw_mi.h"
27 #include "mhw_mi_itf.h"
28 
StartPredicateNext(PMOS_INTERFACE pOsInterface,std::shared_ptr<void> pMiItf,PMOS_COMMAND_BUFFER cmdBuffer)29 MOS_STATUS NullHW::StartPredicateNext(PMOS_INTERFACE pOsInterface, std::shared_ptr<void> pMiItf, PMOS_COMMAND_BUFFER cmdBuffer)
30 {
31     MOS_OS_CHK_NULL_RETURN(pOsInterface);
32     if (!pOsInterface->bNullHwIsEnabled)
33     {
34         return MOS_STATUS_SUCCESS;
35     }
36 
37     std::shared_ptr<mhw::mi::Itf> miItf = std::static_pointer_cast<mhw::mi::Itf>(pMiItf);
38     MOS_OS_CHK_NULL_RETURN(miItf);
39     MOS_OS_CHK_NULL_RETURN(cmdBuffer);
40 
41     auto &par           = miItf->MHW_GETPAR_F(MI_SET_PREDICATE)();
42     par                 = {};
43     par.PredicateEnable = MHW_MI_SET_PREDICATE_ENABLE_ALWAYS;
44     return miItf->MHW_ADDCMD_F(MI_SET_PREDICATE)(cmdBuffer);
45 }
46 
StopPredicateNext(PMOS_INTERFACE pOsInterface,std::shared_ptr<void> pMiItf,PMOS_COMMAND_BUFFER cmdBuffer)47 MOS_STATUS NullHW::StopPredicateNext(PMOS_INTERFACE pOsInterface, std::shared_ptr<void> pMiItf, PMOS_COMMAND_BUFFER cmdBuffer)
48 {
49     MOS_OS_CHK_NULL_RETURN(pOsInterface);
50     if (!pOsInterface->bNullHwIsEnabled)
51     {
52         return MOS_STATUS_SUCCESS;
53     }
54 
55     std::shared_ptr<mhw::mi::Itf> miItf = std::static_pointer_cast<mhw::mi::Itf>(pMiItf);
56     MOS_OS_CHK_NULL_RETURN(miItf);
57     MOS_OS_CHK_NULL_RETURN(cmdBuffer);
58 
59     auto &par           = miItf->MHW_GETPAR_F(MI_SET_PREDICATE)();
60     par                 = {};
61     par.PredicateEnable = MHW_MI_SET_PREDICATE_DISABLE;
62     return miItf->MHW_ADDCMD_F(MI_SET_PREDICATE)(cmdBuffer);
63 }
64 
StatusReport(PMOS_INTERFACE pOsInterface,uint32_t & status,uint32_t & streamSize)65 void NullHW::StatusReport(PMOS_INTERFACE pOsInterface, uint32_t &status, uint32_t &streamSize)
66 {
67     if (!pOsInterface || !pOsInterface->bNullHwIsEnabled)
68     {
69         return;
70     }
71 
72     status = 0;
73     streamSize = 1024;
74 }