| 1 |
/* |
| 2 |
* Copyright (c) 2017, 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 |
#ifndef CMRTLIB_LINUX_HARDWARE_CM_DEVICE_H_ |
| 23 |
#define CMRTLIB_LINUX_HARDWARE_CM_DEVICE_H_ |
| 24 |
|
| 25 |
#include "cm_device_base.h" |
| 26 |
#include "cm_def_hw.h" |
| 27 |
#include "cm_kernel_debugger.h" |
| 28 |
#include <vector> |
| 29 |
|
| 30 |
class CmQueue_RT; |
| 31 |
class CmSurfaceManager; |
| 32 |
|
| 33 |
class CmDevice_RT : public CmDevice |
| 34 |
{ |
| 35 |
public: |
| 36 |
static int32_t GetSupportedAdapters(uint32_t& count); |
| 37 |
static int32_t CreateCmDeviceFromAdapter(CmDevice_RT*& pCmDev, int32_t adapterIndex, uint32_t createOption = 0); |
| 38 |
static int32_t GetPlatformInfo(uint32_t adapterIndex); |
| 39 |
static int32_t QueryAdapterInfo(uint32_t adapterIndex, AdapterInfoType infoName, void* info, uint32_t infoSize, uint32_t* outInfoSize); |
| 40 |
|
| 41 |
static int32_t Create( CmDevice_RT* &device, uint32_t createOption ); |
| 42 |
static int32_t Destroy( CmDevice_RT* &device ); |
| 43 |
static int32_t Create(VADisplay &vaDisplay, CmDevice_RT* &device,uint32_t createOption ); |
| 44 |
|
| 45 |
CM_RT_API int32_t CreateBuffer(uint32_t size, CmBuffer* &buffer); |
| 46 |
|
| 47 |
CM_RT_API int32_t CreateSurface2D(uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, CmSurface2D* &surface ); |
| 48 |
CM_RT_API int32_t CreateSurface3D(uint32_t width, uint32_t height, uint32_t depth, CM_SURFACE_FORMAT format, CmSurface3D* &surface ); |
| 49 |
|
| 50 |
CM_RT_API int32_t CreateSurface2D( VASurfaceID vaSurface, CmSurface2D* &surface ); |
| 51 |
CM_RT_API int32_t CreateSurface2D( VASurfaceID* vaSurfaceArray, const uint32_t surfaceCount, CmSurface2D **surfaceArray); |
| 52 |
|
| 53 |
CM_RT_API int32_t DestroySurface( CmBuffer* &buffer); |
| 54 |
CM_RT_API int32_t DestroySurface( CmSurface2D* &surface2d); |
| 55 |
CM_RT_API int32_t DestroySurface( CmSurface3D* &surface3d); |
| 56 |
|
| 57 |
CM_RT_API int32_t CreateQueue( CmQueue* & queue); |
| 58 |
|
| 59 |
CM_RT_API int32_t LoadProgram( void* commonISACode, const uint32_t size, CmProgram*& program, const char* options = nullptr ); |
| 60 |
|
| 61 |
CM_RT_API int32_t CreateKernel( CmProgram* program, const char* kernelName, CmKernel* & kernel, const char* options = nullptr); |
| 62 |
CM_RT_API int32_t CreateKernel( CmProgram* program, const char* kernelName, const void * fncPnt, CmKernel* & kernel, const char* options = nullptr) {return CM_FAILURE;} |
| 63 |
CM_RT_API int32_t CreateSampler( const CM_SAMPLER_STATE & sampleState, CmSampler* &sampler ); |
| 64 |
|
| 65 |
CM_RT_API int32_t CreateTask(CmTask *& task); |
| 66 |
CM_RT_API int32_t GetCaps(CM_DEVICE_CAP_NAME capName, size_t& capValueSize, void* capValue ); |
| 67 |
CM_RT_API int32_t CreateThreadSpace( uint32_t width, uint32_t height, CmThreadSpace* &threadSpace); |
| 68 |
|
| 69 |
CM_RT_API int32_t DestroyKernel( CmKernel*& kernel); |
| 70 |
CM_RT_API int32_t DestroySampler( CmSampler*& sampler ); |
| 71 |
CM_RT_API int32_t DestroyProgram( CmProgram*& program ); |
| 72 |
CM_RT_API int32_t DestroySampler8x8( CmSampler8x8 *& sampler ); |
| 73 |
CM_RT_API int32_t DestroyThreadSpace( CmThreadSpace* &threadSpace); |
| 74 |
CM_RT_API int32_t DestroyTask(CmTask *& task); |
| 75 |
|
| 76 |
CM_RT_API int32_t CreateVmeSurfaceG7_5 (CmSurface2D* currentSurface, CmSurface2D** forwardSurfaceArray, CmSurface2D** backwardSurfaceArray, const uint32_t surfaceCountForward, const uint32_t surfaceCountBackward, SurfaceIndex* & vmeSurfaceIndex ); |
| 77 |
CM_RT_API int32_t DestroyVmeSurfaceG7_5(SurfaceIndex* & vmeSurfaceIndex); |
| 78 |
CM_RT_API int32_t SetVmeSurfaceStateParam(SurfaceIndex* vmeSurfaceIndex, CM_VME_SURFACE_STATE_PARAM *newState); |
| 79 |
|
| 80 |
CM_RT_API int32_t CreateBufferUP(uint32_t size, void *sysMem, CmBufferUP* &buffer); |
| 81 |
CM_RT_API int32_t DestroyBufferUP( CmBufferUP* &buffer); |
| 82 |
|
| 83 |
CM_RT_API int32_t GetSurface2DInfo(uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, uint32_t & pitch, uint32_t & physicalSize ); |
| 84 |
CM_RT_API int32_t CreateSurface2DUP( uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, void* sysMem, CmSurface2DUP* &surface ); |
| 85 |
CM_RT_API int32_t DestroySurface2DUP( CmSurface2DUP* &surface) ; |
| 86 |
|
| 87 |
CM_RT_API int32_t CreateSampler8x8(const CM_SAMPLER_8X8_DESCR &samplerDescriptor, CmSampler8x8* &sampler); |
| 88 |
CM_RT_API int32_t CreateSampler8x8Surface(CmSurface2D* surface2d, SurfaceIndex* &sampler8x8SurfaceIndex, CM_SAMPLER8x8_SURFACE surfaceType, CM_SURFACE_ADDRESS_CONTROL_MODE addressControl = CM_SURFACE_CLAMP); |
| 89 |
CM_RT_API int32_t DestroySampler8x8Surface(SurfaceIndex* &sampler8x8SurfaceIndex); |
| 90 |
|
| 91 |
CM_RT_API int32_t CreateThreadGroupSpace( uint32_t threadSpaceWidth, uint32_t threadSpaceHeight, uint32_t groupSpaceWidth, uint32_t groupSpaceHeight, CmThreadGroupSpace* &threadGroupSpace); |
| 92 |
CM_RT_API int32_t DestroyThreadGroupSpace(CmThreadGroupSpace* &threadGroupSpace); |
| 93 |
|
| 94 |
CM_RT_API int32_t SetL3Config(const L3ConfigRegisterValues *registerValues); |
| 95 |
CM_RT_API int32_t SetSuggestedL3Config( L3_SUGGEST_CONFIG configIndex); |
| 96 |
|
| 97 |
CM_RT_API int32_t SetCaps(CM_DEVICE_CAP_NAME capName, size_t capValueSize, void* capValue ); |
| 98 |
|
| 99 |
CM_RT_API int32_t CreateSamplerSurface2D(CmSurface2D* surface2d, SurfaceIndex* & samplerSurface2dIndex); |
| 100 |
CM_RT_API int32_t CreateSamplerSurface3D(CmSurface3D* surface3d, SurfaceIndex* & samplerSurface3dIndex); |
| 101 |
CM_RT_API int32_t DestroySamplerSurface(SurfaceIndex* & samplerSurfaceIndex); |
| 102 |
|
| 103 |
CM_RT_API int32_t InitPrintBuffer(size_t size = CM_DEFAULT_PRINT_BUFFER_SIZE); |
| 104 |
|
| 105 |
CM_RT_API int32_t FlushPrintBuffer(); |
| 106 |
|
| 107 |
CM_RT_API int32_t CreateVebox( CmVebox* & vebox ); |
| 108 |
CM_RT_API int32_t DestroyVebox(CmVebox* & vebox); |
| 109 |
|
| 110 |
CM_RT_API int32_t CreateBufferSVM(uint32_t size, void* & sysMem, uint32_t accessFlag, CmBufferSVM* &buffer ); |
| 111 |
CM_RT_API int32_t DestroyBufferSVM( CmBufferSVM* & buffer); |
| 112 |
|
| 113 |
CM_RT_API int32_t CloneKernel( CmKernel * &destKernel, CmKernel *srcKernel ); |
| 114 |
|
| 115 |
CM_RT_API int32_t GetVaDpy(VADisplay* &vaDisplay); |
| 116 |
CM_RT_API int32_t CreateVaSurface2D( uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, VASurfaceID & vaSurface, CmSurface2D* & surface); |
| 117 |
|
| 118 |
CM_RT_API int32_t CreateSamplerSurface2DUP(CmSurface2DUP* surface2dUP, SurfaceIndex* & samplerSurface2dUPIndex); |
| 119 |
|
| 120 |
CM_RT_API int32_t CreateSurface2DAlias(CmSurface2D* originalSurface, SurfaceIndex* &aliasIndex); |
| 121 |
|
| 122 |
CM_RT_API int32_t CreateHevcVmeSurfaceG10(CmSurface2D* currentSurface, CmSurface2D** forwardSurfaceArray, CmSurface2D** backwardSurfaceArray, const uint32_t surfaceCountForward, const uint32_t surfaceCountBackward, SurfaceIndex* & vmeSurfaceIndex); |
| 123 |
CM_RT_API int32_t DestroyHevcVmeSurfaceG10(SurfaceIndex* & vmeSurfaceIndex); |
| 124 |
CM_RT_API int32_t CreateSamplerEx( const CM_SAMPLER_STATE_EX & samplerState, CmSampler* & sampler ) ; |
| 125 |
|
| 126 |
CM_RT_API int32_t FlushPrintBufferIntoFile(const char *filename); |
| 127 |
CM_RT_API int32_t CreateThreadGroupSpaceEx(uint32_t threadSpaceWidth, uint32_t threadSpaceHeight, uint32_t threadSpaceDepth, uint32_t groupSpaceWidth, uint32_t groupSpaceHeight, uint32_t groupSpaceDepth, CmThreadGroupSpace* &threadGroupSpace); |
| 128 |
CM_RT_API int32_t CreateSampler8x8SurfaceEx(CmSurface2D* surface2d, SurfaceIndex* &sampler8x8SurfaceIndex, CM_SAMPLER8x8_SURFACE surfaceType, CM_SURFACE_ADDRESS_CONTROL_MODE addressControl = CM_SURFACE_CLAMP, CM_FLAG* flag = nullptr); |
| 129 |
CM_RT_API int32_t CreateSamplerSurface2DEx(CmSurface2D* surface2d, SurfaceIndex* & samplerSurface2dIndex, CM_FLAG* flag); |
| 130 |
CM_RT_API int32_t CreateBufferAlias(CmBuffer *originalBuffer, SurfaceIndex* &aliasIndex); |
| 131 |
|
| 132 |
CM_RT_API int32_t GetVISAVersion(uint32_t& majorVersion, uint32_t& minorVersion); |
| 133 |
CM_RT_API int32_t CreateQueueEx(CmQueue *&queue, CM_QUEUE_CREATE_OPTION queueCreateOption = CM_DEFAULT_QUEUE_CREATE_OPTION); |
| 134 |
|
| 135 |
CM_RT_API int32_t CreateBufferStateless(size_t size, |
| 136 |
uint32_t option, |
| 137 |
void *sysMem, |
| 138 |
CmBufferStateless *&pBufferStateless); |
| 139 |
CM_RT_API int32_t DestroyBufferStateless(CmBufferStateless *&buffer); |
| 140 |
|
| 141 |
CM_RT_API int32_t DispatchTask() { return CM_SUCCESS; } |
| 142 |
|
| 143 |
CM_RT_API int32_t CreateSurface2DStateless(uint32_t width, |
| 144 |
uint32_t height, |
| 145 |
uint32_t &pitch, |
| 146 |
CmSurface2DStateless *&pSurface); |
| 147 |
|
| 148 |
CM_RT_API int32_t DestroySurface2DStateless(CmSurface2DStateless *&pSurface); |
| 149 |
|
| 150 |
int32_t CheckDdiVersionSupported(const uint32_t ddiVersion); |
| 151 |
|
| 152 |
int32_t OSALExtensionExecute(uint32_t functionId, |
| 153 |
void *inputData, |
| 154 |
uint32_t inputDataLength, |
| 155 |
void **resourceList = nullptr, |
| 156 |
uint32_t resourceCount = 0); |
| 157 |
|
| 158 |
protected: |
| 159 |
CmDevice_RT( |
| 160 |
VADisplay vaDisplay, |
| 161 |
uint32_t createOption |
| 162 |
); |
| 163 |
|
| 164 |
~CmDevice_RT( void ); |
| 165 |
|
| 166 |
int32_t SetCapsInternal(CM_DEVICE_CAP_NAME capName, size_t capValueSize, void* capValue); |
| 167 |
|
| 168 |
int32_t CreateProgram(void* commonISACode, |
| 169 |
const uint32_t size, |
| 170 |
CmProgram*& program, |
| 171 |
const char* options ); |
| 172 |
|
| 173 |
int32_t CreateDeviceInUmd(); |
| 174 |
|
| 175 |
int32_t FlushPrintBufferInternal(const char *filename); |
| 176 |
|
| 177 |
CmSurfaceManager * m_surfaceManager; |
| 178 |
|
| 179 |
uint32_t m_cmVersion; |
| 180 |
void *m_deviceInUmd; //CmDevice pointer in UMD |
| 181 |
bool m_cmCreated; |
| 182 |
|
| 183 |
int32_t Initialize(bool isCmCreated, uint32_t Index = 0); |
| 184 |
int32_t FreeResources(); |
| 185 |
#if USE_EXTENSION_CODE |
| 186 |
int32_t EnableGtpin( void ); |
| 187 |
int32_t RegisterGtpinMarkerFunctions(); |
| 188 |
#endif |
| 189 |
int32_t CreateVmeSurface( CmSurface2D* currentSurface, CmSurface2D** forwardSurfaceArray, CmSurface2D** backwardSurfaceArray, const uint32_t surfaceCountForward, const uint32_t surfaceCountBackward, SurfaceIndex* & vmeSurfaceIndex, CM_FUNCTION_ID functionName); |
| 190 |
int32_t DestroyVmeSurface( SurfaceIndex* & vmeSurfaceIndex ); |
| 191 |
|
| 192 |
#ifndef ANDROID |
| 193 |
int32_t FreeLibvaDrm(); |
| 194 |
int32_t GetLibvaDisplayDrm(VADisplay & vaDisplay); |
| 195 |
#endif |
| 196 |
|
| 197 |
int32_t InitializeLibvaDisplay(uint32_t Index = 0); |
| 198 |
VADisplay m_vaDisplay; |
| 199 |
uint32_t m_drmIndex; |
| 200 |
pvaCmExtSendReqMsg m_fvaCmExtSendReqMsg; |
| 201 |
|
| 202 |
#if !defined(ANDROID) |
| 203 |
static uint32_t m_vaReferenceCount; |
| 204 |
static CSync m_vaReferenceCountCriticalSection; |
| 205 |
int32_t m_driFileDescriptor; |
| 206 |
static void *m_vaDrm; |
| 207 |
static pfVAGetDisplayDRM m_vaGetDisplayDrm; |
| 208 |
#else |
| 209 |
Display* m_display; |
| 210 |
#endif |
| 211 |
|
| 212 |
L3ConfigRegisterValues m_l3Config; |
| 213 |
|
| 214 |
// Variables used in GTPIN |
| 215 |
bool m_gtpinEnabled; |
| 216 |
CmBufferUP* m_gtpinBufferUP0; |
| 217 |
CmBufferUP* m_gtpinBufferUP1; |
| 218 |
CmBufferUP* m_gtpinBufferUP2; |
| 219 |
|
| 220 |
uint32_t m_createOption; |
| 221 |
uint32_t m_driverStoreEnabled; |
| 222 |
|
| 223 |
// Kernel debugger |
| 224 |
CmKernelDebugger *m_kernelDebugger; |
| 225 |
|
| 226 |
// Queue list and Queue critical section |
| 227 |
CSync m_criticalSectionQueue; |
| 228 |
std::vector<CmQueue_RT *> m_queue; |
| 229 |
|
| 230 |
private: |
| 231 |
CmDevice_RT(const CmDevice_RT &other); |
| 232 |
CmDevice_RT &operator=(const CmDevice_RT &other); |
| 233 |
}; |
| 234 |
|
| 235 |
#endif // #ifndef CMRTLIB_LINUX_HARDWARE_CM_DEVICE_H_ |