1 /*
2 * Copyright (c) 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     encode_check_huc_load_packet.h
24 //! \brief    Defines the implementation of check HuC load status packet
25 //!
26 
27 #ifndef __ENCODE_CHECK_HUC_LOAD_PACKET_H__
28 #define __ENCODE_CHECK_HUC_LOAD_PACKET_H__
29 
30 #include "media_cmd_packet.h"
31 #include "encode_utils.h"
32 #include "encode_pipeline.h"
33 
34 namespace encode
35 {
36     class EncodeCheckHucLoadPkt : public CmdPacket,
37         public mhw::vdbox::huc::Itf::ParSetting,
38         public mhw::mi::Itf::ParSetting
39     {
40     public:
EncodeCheckHucLoadPkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)41         EncodeCheckHucLoadPkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext  *hwInterface) :
42             CmdPacket(task),
43             m_pipeline(dynamic_cast<EncodePipeline *>(pipeline))
44         {
45             ENCODE_CHK_NULL_NO_STATUS_RETURN(hwInterface);
46             ENCODE_CHK_NULL_NO_STATUS_RETURN(m_pipeline);
47 
48             m_hwInterface = hwInterface;
49             m_miItf  = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext());
50             m_hucItf = std::static_pointer_cast<mhw::vdbox::huc::Itf>(hwInterface->GetHucInterfaceNext());
51         }
52 
53         virtual ~EncodeCheckHucLoadPkt();
54 
55         //!
56         //! \brief  Initialize the packet, allocate required resources
57         //! \return MOS_STATUS
58         //!         MOS_STATUS_SUCCESS if success, else fail reason
59         //!
60         MOS_STATUS Init();
61 
62         MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase = otherPacket) override;
63 
Get2ndLevelBatchBuffer(uint32_t currRecycledBufIdx)64         PMHW_BATCH_BUFFER Get2ndLevelBatchBuffer(uint32_t currRecycledBufIdx)
65         {
66             return &m_2ndLevelBB[currRecycledBufIdx];
67         };
68 
69     protected:
70         MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER *cmdBuffer);
71         MOS_STATUS SendPrologCmds(MOS_COMMAND_BUFFER *cmdBuffer);
72 
73     private:
74         MOS_STATUS PackHucAuthCmds(MOS_COMMAND_BUFFER &cmdBuffer);
75 
76         static const uint32_t m_hucLoadInfoMask = 0x1;
77         MHW_VDBOX_NODE_IND    m_vdboxIndex      = MHW_VDBOX_NODE_1;
78 
79         CodechalHwInterfaceNext *m_hwInterface = nullptr;
80         EncodePipeline          *m_pipeline    = nullptr;
81         EncodeAllocator         *m_allocator   = nullptr;
82 
83         std::shared_ptr<mhw::vdbox::huc::Itf> m_hucItf = nullptr;
84 
85         //Resources
86         PMOS_RESOURCE      m_hucAuthBuf                                      = nullptr; //!< Pointer to Huc authentication buffer
87         MHW_BATCH_BUFFER   m_2ndLevelBB[CODECHAL_ENCODE_RECYCLED_BUFFER_NUM] = {};      //!< 2nd level batch buffer
88         PMHW_BATCH_BUFFER  m_batchBuf           = nullptr;
89 
90         enum COMPARE_OPERATION
91         {
92             COMPARE_OPERATION_MADGREATERTHANIDD        = 0, //!< If Indirect fetched data is greater than inline data then continue.
93             COMPARE_OPERATION_MADGREATERTHANOREQUALIDD = 1, //!< If Indirect fetched data is greater than or equal to inline data then continue.
94             COMPARE_OPERATION_MADLESSTHANIDD           = 2, //!< If Indirect fetched data is less than inline data then continue.
95             COMPARE_OPERATION_MADLESSTHANOREQUALIDD    = 3, //!< If Indirect fetched data is less than or equal to inline data then continue.
96             COMPARE_OPERATION_MADEQUALIDD              = 4, //!< If Indirect fetched data is equal to inline data then continue.
97             COMPARE_OPERATION_MADNOTEQUALIDD           = 5, //!< If Indirect fetched data is not equal to inline data then continue.
98         };
99 
100 MEDIA_CLASS_DEFINE_END(encode__CheckHucLoadPkt)
101     };
102 }  // namespace decode
103 #endif
104