| 1 |
/* |
| 2 |
* Copyright (c) 2017-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 mos_graphicsresource_specific.h |
| 24 |
//! \brief Container class for the linux/Android specfic graphic resource |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __GRAPHICS_RESOURCE_SPECIFIC_H__ |
| 28 |
#define __GRAPHICS_RESOURCE_SPECIFIC_H__ |
| 29 |
|
| 30 |
#include "mos_graphicsresource.h" |
| 31 |
|
| 32 |
class GraphicsResourceSpecific : public GraphicsResource |
| 33 |
{ |
| 34 |
public: |
| 35 |
//! |
| 36 |
//! \brief Constructor |
| 37 |
//! |
| 38 |
GraphicsResourceSpecific(); |
| 39 |
|
| 40 |
//! |
| 41 |
//! \brief Destructor |
| 42 |
//! |
| 43 |
~GraphicsResourceSpecific(); |
| 44 |
|
| 45 |
//! |
| 46 |
//! \brief to sync render target for multi-threading decoding mode |
| 47 |
//! |
| 48 |
struct HybridSem |
| 49 |
{ |
| 50 |
public: |
| 51 |
//! |
| 52 |
//! \brief Semaphore queue for hybrid decoding multi-threading case |
| 53 |
//! |
| 54 |
PMOS_SEMAPHORE* m_pCurrentFrameSemaphore = nullptr; |
| 55 |
|
| 56 |
//! |
| 57 |
//! \brief Semaphore queue for hybrid decoding multi-threading case; post when a |
| 58 |
//! surface is not used as reference frame |
| 59 |
//! |
| 60 |
PMOS_SEMAPHORE* m_pReferenceFrameSemaphore = nullptr; |
| 61 |
|
| 62 |
//! |
| 63 |
//! \brief Flag to mark whether the semaphore has been initialized |
| 64 |
//! |
| 65 |
bool m_semInitialized = false; |
| 66 |
|
| 67 |
}; |
| 68 |
|
| 69 |
//! |
| 70 |
//! \brief Add a sync tag to the graphic resource |
| 71 |
//! \param [in] osContextPtr |
| 72 |
//! Pointer to the osContext handle |
| 73 |
//! \param [in] params |
| 74 |
//! Parameters to do the synchronization |
| 75 |
//! \return MOS_SUCCESS on success case |
| 76 |
//! |
| 77 |
MOS_STATUS SetSyncTag(OsContext* osContextPtr, SyncParams& params, uint32_t streamIndex); |
| 78 |
|
| 79 |
//! |
| 80 |
//! \brief Check whether the resource is nullptr |
| 81 |
//! \return ture if the resource is nullptr, false on other cases |
| 82 |
//! |
| 83 |
bool ResourceIsNull(); |
| 84 |
|
| 85 |
//! |
| 86 |
//! \brief Allocate the graphic memory to back up the graphic resource |
| 87 |
//! \param [in] osContextPtr |
| 88 |
//! Pointer to the osContext handle |
| 89 |
//! \param [in] params |
| 90 |
//! Resource creation Params |
| 91 |
//! \return MOS_STATUS_SUCCESS on success case, MOS error status on fail cases |
| 92 |
//! |
| 93 |
MOS_STATUS Allocate(OsContext* osContextPtr, CreateParams& params); |
| 94 |
|
| 95 |
//! |
| 96 |
//! \brief Frees the specified resource with flag, if locked, unlocks it. |
| 97 |
//! \param [in] osContextPtr |
| 98 |
//! Pointer to the osContext handle |
| 99 |
//! \param [in] freeFlag |
| 100 |
//! flags for the free operation |
| 101 |
//! |
| 102 |
void Free(OsContext* osContextPtr, uint32_t freeFlag = 0); |
| 103 |
|
| 104 |
//! |
| 105 |
//! \brief Check whether the specific graphic resources is equal to the current one |
| 106 |
//! \param [in] toCompare |
| 107 |
//! ptr to the graphics resource to be compared with |
| 108 |
//! \return Returns true if the two resources are equal and false otherwise. |
| 109 |
//! |
| 110 |
bool IsEqual(GraphicsResource* toCompare); |
| 111 |
|
| 112 |
//! |
| 113 |
//! \brief Check whether the current graphic resource is valid |
| 114 |
//! \return Returns true if a resource is valid and false otherwise. |
| 115 |
//! |
| 116 |
bool IsValid(); |
| 117 |
|
| 118 |
//! |
| 119 |
//! \brief Locks a resource and returns a mapped system memory pointer. |
| 120 |
//! \param [in] osContextPtr |
| 121 |
//! Pointer to the osContext handle |
| 122 |
//! \param [in] params |
| 123 |
//! Resource lock Params |
| 124 |
//! \return CPU side lock address in success case, nullptr in fail cases |
| 125 |
//! |
| 126 |
void* Lock(OsContext* osContextPtr, LockParams& params); |
| 127 |
|
| 128 |
//! |
| 129 |
//! \brief Unlocks a resource that has already been locked, if no lock has |
| 130 |
//! occurred, this function does nothing |
| 131 |
//! \param [in] osContextPtr |
| 132 |
//! Pointer to the osContext handle |
| 133 |
//! \return MOS_SUCCESS in success case, MOS error status in fail cases |
| 134 |
//! |
| 135 |
MOS_STATUS Unlock(OsContext* osContextPtr); |
| 136 |
|
| 137 |
//! |
| 138 |
//! \brief Converts an OS specific resource to a MOS resource. |
| 139 |
//! \param [in] mosResourcePtr |
| 140 |
//! ptr to the MosResource to be filled w/ the conversion result |
| 141 |
//! \return MOS_SUCCESS on success case |
| 142 |
//! |
| 143 |
MOS_STATUS ConvertToMosResource(MOS_RESOURCE* mosResourcePtr); |
| 144 |
|
| 145 |
MOS_LINUX_BO* GetBufferObject(){return m_bo;}; |
| 146 |
|
| 147 |
protected: |
| 148 |
//! |
| 149 |
//! \brief Set tilemode by force to GMM info flag. |
| 150 |
//! \return MOS_SUCCESS on success case. |
| 151 |
//! |
| 152 |
MOS_STATUS SetTileModebyForce(GMM_RESCREATE_PARAMS &gmmParams, MOS_TILE_MODE_GMM tileMode); |
| 153 |
|
| 154 |
private: |
| 155 |
|
| 156 |
//! |
| 157 |
//! \brief Pointer to the GMM info structure |
| 158 |
//! |
| 159 |
GMM_RESOURCE_INFO* m_gmmResInfo = nullptr; |
| 160 |
|
| 161 |
//! |
| 162 |
//! \brief Whether the graphic resource is mapped at CPU side |
| 163 |
//! |
| 164 |
bool m_mapped = false; |
| 165 |
|
| 166 |
//! |
| 167 |
//! \brief The map operation type we use |
| 168 |
//! |
| 169 |
MOS_MMAP_OPERATION m_mmapOperation = MOS_MMAP_OPERATION_NONE; |
| 170 |
|
| 171 |
//! |
| 172 |
//! \brief the ptr to the buffer object of the graphic buffer |
| 173 |
//! |
| 174 |
MOS_LINUX_BO* m_bo = nullptr; |
| 175 |
|
| 176 |
//! |
| 177 |
//! \brief the semaphore used in hybrid decoder corresponding to the graphic buffer |
| 178 |
//! |
| 179 |
HybridSem m_hybridSem = {}; |
| 180 |
|
| 181 |
uint8_t* m_systemShadow = nullptr; //!< System shadow surface for s/w untiling |
| 182 |
}; |
| 183 |
#endif // #ifndef __GRAPHICS_RESOURCE_SPECIFIC_H__ |
| 184 |
|