1 /*
2 * Copyright (c) 2018, 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     codechal_encode_singlepipe_virtualengine.cpp
24 //! \brief    Implements the encode interface extension for single pipe virtual engine.
25 //! \details  Implements all functions required by CodecHal for single pipe encoding with virtual engine interface.
26 //!
27 #include "codechal_encode_singlepipe_virtualengine.h"
28 #include "mos_os_virtualengine_next.h"
29 
CodecHalEncodeSinglePipeVE_ConstructParmsForGpuCtxCreation(PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,PMOS_GPUCTX_CREATOPTIONS_ENHANCED gpuCtxCreatOpts)30 MOS_STATUS CodecHalEncodeSinglePipeVE_ConstructParmsForGpuCtxCreation(
31     PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,
32     PMOS_GPUCTX_CREATOPTIONS_ENHANCED               gpuCtxCreatOpts)
33 {
34     PMOS_VIRTUALENGINE_INTERFACE   pVEInterface;
35     MOS_STATUS                     eStatus = MOS_STATUS_SUCCESS;
36 
37     CODECHAL_ENCODE_FUNCTION_ENTER;
38 
39     CODECHAL_ENCODE_CHK_NULL_RETURN(pVEState);
40     CODECHAL_ENCODE_CHK_NULL_RETURN(pVEState->pVEInterface);
41 
42     pVEInterface = pVEState->pVEInterface;
43     auto pOsInterface = pVEInterface->pOsInterface;
44     CODECHAL_ENCODE_CHK_NULL_RETURN(pOsInterface);
45 
46     gpuCtxCreatOpts->UsingSFC  = false;
47     gpuCtxCreatOpts->LRCACount = 1;
48 
49 #if (_DEBUG || _RELEASE_INTERNAL)
50     if (pOsInterface->bEnableDbgOvrdInVE)
51     {
52         gpuCtxCreatOpts->DebugOverride      = true;
53         if (pOsInterface->apoMosEnabled)
54         {
55             CODECHAL_ENCODE_CHK_NULL_RETURN(pVEInterface->veInterface);
56             CODECHAL_ENCODE_ASSERT(pVEInterface->veInterface->GetEngineCount() == 1);
57             gpuCtxCreatOpts->EngineInstance[0] = pVEInterface->veInterface->GetEngineLogicId(0);
58         }
59         else
60         {
61             CODECHAL_ENCODE_ASSERT(pVEInterface->ucEngineCount == 1);
62             gpuCtxCreatOpts->EngineInstance[0] = pVEInterface->EngineLogicId[0];
63         }
64     }
65 #endif
66 
67     return eStatus;
68 }
69 
CodecHalEncodeSinglePipeVE_InitInterface(CodechalHwInterface * pHwInterface,PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState)70 MOS_STATUS CodecHalEncodeSinglePipeVE_InitInterface(
71     CodechalHwInterface                            *pHwInterface,
72     PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState)
73 {
74     PMOS_INTERFACE                 pOsInterface;
75     PMOS_VIRTUALENGINE_INTERFACE   pVEInterface;
76     MOS_VIRTUALENGINE_INIT_PARAMS  VEInitParams;
77     MOS_STATUS                     eStatus = MOS_STATUS_SUCCESS;
78 
79     CODECHAL_ENCODE_FUNCTION_ENTER;
80 
81     CODECHAL_ENCODE_CHK_NULL_RETURN(pHwInterface);
82     CODECHAL_ENCODE_CHK_NULL_RETURN(pHwInterface->GetOsInterface());
83     CODECHAL_ENCODE_CHK_NULL_RETURN(pVEState);
84     pOsInterface = pHwInterface->GetOsInterface();
85     CODECHAL_ENCODE_CHK_NULL_RETURN(pOsInterface);
86 
87     //virtual engine init with singlepipe
88     MOS_ZeroMemory(&VEInitParams, sizeof(VEInitParams));
89     VEInitParams.bScalabilitySupported = false;
90     CODECHAL_ENCODE_CHK_STATUS_RETURN(pOsInterface->pfnVirtualEngineInterfaceInitialize(pOsInterface, &VEInitParams));
91     pVEState->pVEInterface = pVEInterface = pOsInterface->pVEInterf;
92 
93     if(pVEInterface->pfnVEGetHintParams)
94     {
95         CODECHAL_ENCODE_CHK_STATUS_RETURN(pVEInterface->pfnVEGetHintParams(pVEInterface, false, &pVEState->pHintParms));
96     }
97     return eStatus;
98 }
99 
100