1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
|
/*
* Copyright (c) 2007-2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file cm_surface_2d.h
//! \brief Contains CmSurface2D declaration.
//!
#ifndef MEDIADRIVER_LINUX_COMMON_CM_CMSURFACE2D_H_
#define MEDIADRIVER_LINUX_COMMON_CM_CMSURFACE2D_H_
#include "cm_def.h"
#include "cm_queue.h"
namespace CMRT_UMD
{
class CmEvent;
class CmSurface2D
{
public:
//!
//! \brief Retrieves surface index of this CmSurface2D.
//! \param [out] index
//! Reference to the pointer to an SurfaceIndex.
//! It will point to the internal SurfaceIndex.
//! \retval CM_SUECCESS.
//!
CM_RT_API virtual int32_t GetIndex(SurfaceIndex* &index) = 0;
//!
//! \brief Copies data in this CmSurface2D to system memory.
//! \details Copied data size is the same as surface data size.
//! This is a blocking function, i.e. the function will not return
//! until the copy operation is completed.
//! Copying will not happen until the status of the dependent event
//! becomes CM_STATUS_FINISHED.
//! It's the application's responsibility to make sure no other
//! task enqueued between the task corresponding to the event and
//! this fuction call.
//! If sysMemSize is given, it will be checked against the size of
//! the surface data.
//! \param [out] sysMem
//! Pointer to the system memory receiving surface data.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \param [in] sysMemSize
//! Size of the system memory.
//! \retval CM_SUCCESS if this function succeeds.
//! \retval CM_INVALID_ARG_VALUE if sysMemSize is given but less than what
//! is needed.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
ReadSurface(unsigned char *sysMem,
CmEvent *event,
uint64_t sysMemSize = 0xFFFFFFFFFFFFFFFFULL) = 0;
//!
//! \brief Copies data in system memory to this CmSurface2D.
//! \details Copied data size is the same as the surface data size.
//! This is a blocking function, i.e. the function will not return
//! until the copy operation is completed.
//! Copying will not happen until the status of the dependent event
//! becomes CM_STATUS_FINISHED.
//! If sysMemSize is given, it will be checked against the size of
//! the surface data.
//! \param [in] sysMem
//! Pointer to the system memory storing surface data.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \param [in] sysMemSize
//! Size of the system memory.
//! \retval CM_SUCCESS if copy is successful.
//! \retval CM_INVALID_ARG_VALUE if sysMemSize is given but less than what
//! is needed.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
WriteSurface(const unsigned char *sysMem,
CmEvent *event,
uint64_t sysMemSize = 0xFFFFFFFFFFFFFFFFULL) = 0;
//!
//! \brief Copies data in this CmSurface2D to system memory with system
//! memory stride.
//! \details Copied data size is the same as surface data size.
//! This is a blocking function, i.e. the function will not return
//! until the copy operation is completed.
//! Copying will not happen until the status of the dependent event
//! becomes CM_STATUS_FINISHED.
//! It's the application's responsibility to make sure no other
//! task enqueued between the task corresponding to the event and
//! this fuction call.
//! If sysMemSize is given, it will be checked against the size of
//! the surface data.
//! \param [out] sysMem
//! Pointer to the system memory receiving surface data.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \param [in] stride
//! System memory stride in bytes.
//! It equals actual surface width in bytes plus extra padding bytes.
//! \param [in] sysMemSize
//! Size of the system memory.
//! \retval CM_SUCCESS if this function succeeds.
//! \retval CM_INVALID_ARG_VALUE if sysMemSize is given but less than what
//! is needed.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
ReadSurfaceStride(unsigned char *sysMem,
CmEvent *event,
const unsigned int stride,
uint64_t sysMemSize = 0xFFFFFFFFFFFFFFFFULL) = 0;
//!
//! \brief Copies data in system memory to this CmSurface2D with system
//! memory stride.
//! \details Copied data size is the same as the surface data size.
//! This is a blocking function, i.e. the function will not return
//! until the copy operation is completed.
//! Copying will not happen until the status of the dependent event
//! becomes CM_STATUS_FINISHED.
//! If sysMemSize is given, it will be checked against the size of
//! the surface data.
//! \param [in] sysMem
//! Pointer to the system memory storing surface data.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \param [in] stride
//! System memory stride in bytes.
//! It equals actual surface width in bytes plus extra padding bytes.
//! \param [in] sysMemSize
//! Size of the system memory.
//! \retval CM_SUCCESS if copy is successful.
//! \retval CM_INVALID_ARG_VALUE if sysMemSize is given but less than what
//! is needed.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
WriteSurfaceStride(const unsigned char *sysMem,
CmEvent *event,
const unsigned int stride,
uint64_t sysMemSize = 0xFFFFFFFFFFFFFFFFULL) = 0;
//!
//! \brief Sets surface data to a unified value.
//! \details This is a blocking function, i.e. the function will not return
//! until the operation is completed.
//! Initialization will not happen until the status of the
//! dependent event becomes CM_STATUS_FINISHED.
//! \param [in] initValue
//! The value for initialization.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \retval CM_SUCCESS if initialization is successful.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t InitSurface(const unsigned int initValue,
CmEvent *event,
unsigned int useGPU = 0) = 0;
//!
//! \brief Retrieves libva surface ID.
//! \note This function is a Linux-only API.
//! \param [out] vaSurface
//! Reference to a VASurfaceID receiving libva surface ID.
//! \retval CM_SUCCESS.
//!
CM_RT_API virtual int32_t GetVaSurfaceID(VASurfaceID &vaSurface) = 0;
//!
//! \brief Hybrid memory copy from this CmSurface2D to system memory with system
//! memory strides.
//! \details Copied data size is the same as surface data size.
//! This is a blocking function, i.e. the function will not return
//! until the copy operation is completed.
//! Copying will not happen until the status of the dependent event
//! becomes CM_STATUS_FINISHED.
//! If sysMemSize is given, it will be checked against the size of
//! the surface data.
//! \param [out] sysMem
//! Pointer to the system memory receiving surface data.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \param [in] horizontalStride
//! Horizontal stride of system memory in bytes.
//! \param [in] verticalStride
//! Vertical stride of system memory in rows.
//! \param [in] sysMemSize
//! Size of the system memory.
//! \param [in] option
//! Option to disable/enable hybrid memory copy.
//! \retval CM_SUCCESS if this function succeeds.
//! \retval CM_INVALID_ARG_VALUE if sysMemSize is given but less than what
//! is needed.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
ReadSurfaceHybridStrides(unsigned char *sysMem,
CmEvent *event,
const unsigned int horizontalStride,
const unsigned int verticalStride,
uint64_t sysMemSize = 0xFFFFFFFFFFFFFFFFULL,
unsigned int option = 0) = 0;
//!
//! \brief Hybrid memory copy from system memory to this CmSurface2D with
//! system memory stride.
//! \details Copied data size is the same as the surface data size.
//! This is a blocking function, i.e. the function will not return
//! until the copy
//! operation is completed.
//! Copying will not happen until the status of the dependent event
//! becomes CM_STATUS_FINISHED.
//! If sysMemSize is given, it will be checked against the size of
//! the surface data.
//! \param [in] sysMem
//! Pointer to the system memory storing surface data.
//! \param [in] event
//! Pointer to the dependent event used for sychronization.
//! \param [in] horizontalStride
//! Horizontal stride of system memory in bytes.
//! \param [in] verticalStride
//! Vertical stride of system memory in rows.
//! \param [in] sysMemSize
//! Size of the system memory.
//! \param [in] option
//! Option to disable/enable hybrid memory copy.
//! \retval CM_SUCCESS if copy is successful.
//! \retval CM_INVALID_ARG_VALUE if sysMemSize is given but less than what
//! is needed.
//! \retval CM_LOCK_SURFACE_FAIL if surface locking fails.
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
WriteSurfaceHybridStrides(const unsigned char *sysMem,
CmEvent *event,
const unsigned int horizontalStride,
const unsigned int verticalStride,
uint64_t sysMemSize = 0xFFFFFFFFFFFFFFFFULL,
unsigned int option = 0) = 0;
//!
//! \brief Selects one of the pre-defined memory object control settings for
//! this CmSurface2D.
//! \note This function only works on Gen9+ paltforms.
//! \param [in] memCtrl
//! The selected pre-defined memory object control setting.
//! \retval CM_SUCCESS if the given parameter is valid
//! \retval CM_FAILURE otherwise.
//!
CM_RT_API virtual int32_t
SelectMemoryObjectControlSetting(MEMORY_OBJECT_CONTROL memCtrl) = 0;
//!
//! \brief Sets frame type of this CmSurface2D.
//! \details By default this CmSurface2D is a whole frame.
//! \param [in] frameType
//! A value in enumeration CM_FRAME_TYPE, frame type of this
//! CmSurface2D. It should be a whole frame or a field in an
//! interlaced frame.
//! \retval CM_SUCCESS.
//!
CM_RT_API virtual int32_t SetProperty(CM_FRAME_TYPE frameType) = 0;
//!
//! \brief Sets surface state parameters for an alias of this CmSurface2D.
//! \details If surfIndex is nullptr, default state of this CmSurface2D
//! is changed.
//! \param [in] surfIndex
//! Pointer to the surface index of an alias of this CmSurface2D. A new
//! surface state is created for this alias or the existing state is updated.
//! \param [in] surfStateParam
//! Pointer to a new state parameter.
//! \retval CM_INVALID_ARG_VALUE if any parameter is invalid.
//! \retval CM_SUCCESS if successful.
//!
CM_RT_API virtual int32_t
SetSurfaceStateParam(SurfaceIndex *surfIndex,
const CM_SURFACE2D_STATE_PARAM *surfStateParam) = 0;
// Pay Attention: below APIs only used in UMD. If you add an API exposed to application, please add it BEFORE this line.
public:
//!
//! \brief Selects one of the pre-defined MOS resource usage settings for
//! this CmSurface2D.
//! \note This function works only on Gen9+ paltforms.
//! \param [in] mosUsage
//! The selected pre-defined MOS resource usage for memory object control setting.
//! \retval CM_SUCCESS if the given parameter is valid
//! \retval CM_FAILURE otherwise.
//!
CMRT_UMD_API virtual int32_t SetResourceUsage(MOS_HW_RESOURCE_DEF mosUsage) = 0;
//!
//! \brief Sets the surface's read sync flag for synchronization between engines.
//! \details If the surface is shared between render engine and another engine,
//! the read sync flag is to tell whether the next engine should wait till
//! the kernel execution ends in render engine. If the read sync flag is set,
//! then it means the render engine only read this surface and the next engine
//! can also access it simultaneously. If the read sync flag
//! is not set (or set to false), then the next engine should assume the
//! render engine is writing to this surface and wait till the kernel execution
//! ends.
//! \param [in] readSync
//! value of read sync flag to be set to the surface
//! \retval CM_INVALID_ARG_VALUE if any parameter is invalid.
//! \retval CM_SUCCESS if successful.
//!
CMRT_UMD_API virtual int32_t SetReadSyncFlag(bool readSync, CmQueue *pCmQueue) = 0;
//!
//! \brief Set the UMD Resource and MOS Resource in the CmSurface2D
//! \details A callback function which allows CM callers to change the UMD Resource and
//! MOS Resource embedded in the CmSurface2D.
//! \param [in] umdResource
//! the UMD Resource set to the CmSurface2D
//! \param [in] updateMosResource
//! a flag indicating whether MOS resource needs updating. 0 mean keeping it
//! unchanged. Otherwise, set the MOS resource to parameter mosResource. Default
//! is 0.
//! \param [in] mosResource
//! the MOS Resource set to the CmSurface2D
//! \retval CM_SUCCESS always.
//!
CMRT_UMD_API virtual int32_t
NotifyUmdResourceChanged(UMD_RESOURCE umdResource,
int updateMosResource = 0,
PMOS_RESOURCE mosResource = nullptr) = 0;
};
}; //namespace
#endif // #ifndef MEDIADRIVER_LINUX_COMMON_CM_CMSURFACE2D_H_
|