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.h
24 //! \brief Defines the encode interface extension for single pipe virtual engine.
25 //! \details Defines all types, macros, and functions required by CodecHal for single pipe virtual engine encoding. Definitions are not externally facing.
26 //!
27
28 #ifndef __CODECHAL_ENCODER_SINGLEPIPE_VIRTUALENGINE_H__
29 #define __CODECHAL_ENCODER_SINGLEPIPE_VIRTUALENGINE_H__
30
31 #include "codechal_encoder_base.h"
32 #include "mos_os_virtualengine_singlepipe.h"
33
34 typedef struct _CODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE
35 {
36 PMOS_VIRTUALENGINE_INTERFACE pVEInterface;
37 PMOS_VIRTUALENGINE_HINT_PARAMS pHintParms;
38 }CODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE, *PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE;
39
40 //!
41 //! \brief Set hint parameter for virtual engine interface in single pipe mode
42 //! \details Set hint prameter for virtual engine interface, shared by all single pipe codechal encode formats.
43 //! \param [in] pVEState
44 //! ponter to virtual engine state data structure
45 //! \param [in] pVESetParams
46 //! ponter to MOS_VIRTUALENGINE_SET_PARAMS data structure including parameters related to set hint parameters
47 //! \return MOS_STATUS
48 //! MOS_STATUS_SUCCESS if success, else fail reason
49 //!
CodecHalEncodeSinglePipeVE_SetHintParams(PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,PMOS_VIRTUALENGINE_SET_PARAMS pVESetParams)50 static __inline MOS_STATUS CodecHalEncodeSinglePipeVE_SetHintParams(
51 PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,
52 PMOS_VIRTUALENGINE_SET_PARAMS pVESetParams)
53 {
54 PMOS_VIRTUALENGINE_INTERFACE pVEInterface;
55 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
56
57 // this function can be removed after transiting to VE2.0
58 CODECHAL_ENCODE_CHK_NULL_RETURN(pVEState);
59 CODECHAL_ENCODE_CHK_NULL_RETURN(pVEState->pVEInterface);
60 pVEInterface = pVEState->pVEInterface;
61
62 if(!MOS_VE_CTXBASEDSCHEDULING_SUPPORTED(pVEInterface->pOsInterface))
63 {
64 if(pVEInterface->pfnVESetHintParams)
65 {
66 CODECHAL_ENCODE_CHK_STATUS_RETURN(pVEInterface->pfnVESetHintParams(pVEInterface, pVESetParams));
67 }
68 }
69
70 return eStatus;
71 }
72
73 //!
74 //! \brief Populate hint parameter for virtual engine interface in single pipe mode
75 //! \details Populate hint prameter to primary cmd buffer attributes, this is for virtual engine interface, shared by all single pipe codechal encode formats.
76 //! \param [in] pVEState
77 //! ponter to virtual engine state data structure
78 //! \param [in] pPrimCmdBuf
79 //! ponter to primary cmd buffer
80 //! \param [in] bUseVirtualEngineHint
81 //! true if CmdBuf need to use VE hint params, else false
82 //! \return PMOS_VIRTUALENGINE_HINT_PARAMS
83 //! return address of the single pipe hint parameter variable defined in MOS Virtual engine interface
84 //!
CodecHalEncodeSinglePipeVE_PopulateHintParams(PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,PMOS_COMMAND_BUFFER pPrimCmdBuf,bool bUseVirtualEngineHint)85 static __inline MOS_STATUS CodecHalEncodeSinglePipeVE_PopulateHintParams(
86 PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,
87 PMOS_COMMAND_BUFFER pPrimCmdBuf,
88 bool bUseVirtualEngineHint)
89 {
90 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
91 PMOS_CMD_BUF_ATTRI_VE pAttriVe;
92
93 CODECHAL_ENCODE_CHK_NULL_RETURN(pPrimCmdBuf);
94
95 if (pPrimCmdBuf->Attributes.pAttriVe)
96 {
97
98 pAttriVe = (PMOS_CMD_BUF_ATTRI_VE)(pPrimCmdBuf->Attributes.pAttriVe);
99
100 if (bUseVirtualEngineHint)
101 {
102 CODECHAL_ENCODE_CHK_NULL_RETURN(pVEState);
103 if(pVEState->pHintParms)
104 {
105 pAttriVe->VEngineHintParams = *(pVEState->pHintParms);
106 }
107 }
108
109 pAttriVe->bUseVirtualEngineHint = bUseVirtualEngineHint;
110 }
111
112 return eStatus;
113 }
114
115 //!
116 //! \brief construct gpu context creation params.
117 //! \param [in] pVEState
118 //! ponter to virtual engine state data structure
119 //! \param [in] gpucontxCreatOpts
120 //! ponter to gpu context creation option data structure
121 //! \return MOS_STATUS
122 //! MOS_STATUS_SUCCESS if success, else fail reason
123 //!
124 MOS_STATUS CodecHalEncodeSinglePipeVE_ConstructParmsForGpuCtxCreation(
125 PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState,
126 PMOS_GPUCTX_CREATOPTIONS_ENHANCED gpuCtxCreatOpts);
127
128 //!
129 //! \brief initialize virtual engine interface for single pipe encode
130 //! \details initialize virtual engine interface for single pipe encode shared by all codechal encode formats
131 //! \param [in] pHwInterface
132 //! poiner to vdbox interface
133 //! \param [in] pVEState
134 //! pointer to virtual engine state data structure
135 //! \return MOS_STATUS
136 //! MOS_STATUS_SUCCESS if success, else fail reason
137 //!
138 MOS_STATUS CodecHalEncodeSinglePipeVE_InitInterface(
139 CodechalHwInterface *pHwInterface,
140 PCODECHAL_ENCODE_SINGLEPIPE_VIRTUALENGINE_STATE pVEState);
141
142 #endif //__CODECHAL_ENCODER_SINGLEPIPE_VIRTUALENGINE_H__
143
144