1 /*
2 * Copyright (c) 2020-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     meida_sfc_interface.cpp
24 //! \brief    Common interface for sfc
25 //! \details  Common interface for sfc
26 //!
27 #include "media_sfc_interface.h"
28 #include "media_sfc_render.h"
29 #include "mos_utilities.h"
30 #include "vp_utils.h"
31 
MediaSfcInterface(PMOS_INTERFACE osInterface,MediaMemComp * mmc)32 MediaSfcInterface::MediaSfcInterface(PMOS_INTERFACE osInterface, MediaMemComp *mmc) : m_osInterface(osInterface), m_mmc(mmc)
33 {
34 }
35 
~MediaSfcInterface()36 MediaSfcInterface::~MediaSfcInterface()
37 {
38     Destroy();
39 }
40 
Destroy()41 void MediaSfcInterface::Destroy()
42 {
43     MOS_Delete(m_sfcRender);
44 }
45 
IsParameterSupported(VDBOX_SFC_PARAMS & sfcParam)46 MOS_STATUS MediaSfcInterface::IsParameterSupported(
47     VDBOX_SFC_PARAMS                    &sfcParam)
48 {
49     VP_PUBLIC_CHK_NULL_RETURN(m_sfcRender);
50     return m_sfcRender->IsParameterSupported(sfcParam);
51 }
52 
IsParameterSupported(VEBOX_SFC_PARAMS & sfcParam)53 MOS_STATUS MediaSfcInterface::IsParameterSupported(
54     VEBOX_SFC_PARAMS                    &sfcParam)
55 {
56     VP_PUBLIC_CHK_NULL_RETURN(m_sfcRender);
57     return m_sfcRender->IsParameterSupported(sfcParam);
58 }
59 
Render(VEBOX_SFC_PARAMS & param)60 MOS_STATUS MediaSfcInterface::Render(VEBOX_SFC_PARAMS &param)
61 {
62     VP_PUBLIC_CHK_NULL_RETURN(m_sfcRender);
63     return m_sfcRender->Render(param);
64 }
65 
Render(MOS_COMMAND_BUFFER * cmdBuffer,VDBOX_SFC_PARAMS & param)66 MOS_STATUS MediaSfcInterface::Render(MOS_COMMAND_BUFFER *cmdBuffer, VDBOX_SFC_PARAMS &param)
67 {
68     VP_PUBLIC_CHK_NULL_RETURN(cmdBuffer);
69     VP_PUBLIC_CHK_NULL_RETURN(m_sfcRender);
70     return m_sfcRender->Render(cmdBuffer, param);
71 }
72 
73 //!
74 //! \brief    MediaSfcInterface initialize
75 //! \details  Initialize the BltState, create BLT context.
76 //! \return   MOS_STATUS
77 //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
78 //!
Initialize(MEDIA_SFC_INTERFACE_MODE mode)79 MOS_STATUS MediaSfcInterface::Initialize(MEDIA_SFC_INTERFACE_MODE mode)
80 {
81     VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
82     if (m_sfcRender)
83     {
84         Destroy();
85     }
86 
87     m_sfcRender = MOS_New(MediaSfcRender, m_osInterface, mode, m_mmc);
88     VP_PUBLIC_CHK_NULL_RETURN(m_sfcRender);
89     VP_PUBLIC_CHK_STATUS_RETURN(m_sfcRender->Initialize());
90 
91     return MOS_STATUS_SUCCESS;
92 }
93 
IsRenderInitialized()94 bool MediaSfcInterface::IsRenderInitialized()
95 {
96     if (m_sfcRender)
97     {
98         return m_sfcRender->IsInitialized();
99     }
100     return false;
101 }