1 /*
2 * Copyright (c) 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     encode_huc_la_update_packet.h
24 //! \brief    Defines the interface of Huc Lookahead update packet
25 
26 #ifndef __CODECHAL_HUC_LA_UPDATE_PACKET_H__
27 #define __CODECHAL_HUC_LA_UPDATE_PACKET_H__
28 
29 #include "media_cmd_packet.h"
30 #include "encode_huc.h"
31 #include "encode_hevc_vdenc_pipeline.h"
32 
33 namespace encode
34 {
35 class HucLaUpdatePkt : public EncodeHucPkt
36 {
37 public:
HucLaUpdatePkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)38     HucLaUpdatePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) : EncodeHucPkt(pipeline, task, hwInterface)
39     {
40         m_miItf = m_hwInterface->GetMiInterfaceNext();
41     }
42 
~HucLaUpdatePkt()43     virtual ~HucLaUpdatePkt() {}
44 
45     //!
46     //! \brief  Initialize the media packet, allocate required resources
47     //! \return MOS_STATUS
48     //!         MOS_STATUS_SUCCESS if success, else fail reason
49     //!
50     virtual MOS_STATUS Init() override;
51 
52     //!
53     //! \brief  Add the command sequence into the commandBuffer and
54     //!         and return to the caller task
55     //! \param  [in] commandBuffer
56     //!         Pointer to the command buffer which is allocated by caller
57     //! \param  [in] packetPhase
58     //!         Indicate packet phase stage
59     //! \return MOS_STATUS
60     //!         MOS_STATUS_SUCCESS if success, else fail reason
61     //!
62     virtual MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase = otherPacket) override;
63 
64     //!
65     //! \brief  One frame is completed
66     //! \param  [in] mfxStatus
67     //!         pointer to status buffer which for MFX
68     //! \param  [in] rcsStatus
69     //!         pointer to status buffer which for RCS
70     //! \param  [in, out] statusReport
71     //!         pointer of EncoderStatusReport
72     //! \return MOS_STATUS
73     //!         MOS_STATUS_SUCCESS if success, else fail reason
74     //!
75     virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override;
76 
77     virtual MOS_STATUS DumpOutput() override;
78 
79 #if USE_CODECHAL_DEBUG_TOOL
80     virtual MOS_STATUS DumpInput() override;
81 #endif
82 
83     //!
84     //! \brief  Calculate Command Size
85     //!
86     //! \param  [in, out] commandBufferSize
87     //!         requested size
88     //! \param  [in, out] requestedPatchListSize
89     //!         requested size
90     //! \return MOS_STATUS
91     //!         status
92     //!
93     MOS_STATUS CalculateCommandSize(
94         uint32_t &commandBufferSize,
95         uint32_t &requestedPatchListSize) override;
96 
97     //!
98     //! \brief  Get Packet Name
99     //! \return std::string
100     //!
GetPacketName()101     virtual std::string GetPacketName() override
102     {
103         return "LAUPDATE";
104     }
105 
106 protected:
107     virtual MOS_STATUS AllocateResources() override;
108 
109     MHW_SETPAR_DECL_HDR(HUC_IMEM_STATE);
110     MHW_SETPAR_DECL_HDR(HUC_DMEM_STATE);
111     MHW_SETPAR_DECL_HDR(HUC_VIRTUAL_ADDR_STATE);
112 
113     virtual MOS_STATUS ReadLPLAData(MOS_COMMAND_BUFFER *commandBuffer);
114 
115     HevcBasicFeature              *m_basicFeature = nullptr;  //!< Hevc Basic Feature used in each frame
116     std::shared_ptr<mhw::mi::Itf> m_miItf         = nullptr;
117 
118 MEDIA_CLASS_DEFINE_END(encode__HucLaUpdatePkt)
119 };
120 }  // namespace encode
121 
122 #endif
123