| 1 |
/* |
| 2 |
* Copyright (c) 2009-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 |
//! |
| 23 |
//! \file media_libva_cm.c |
| 24 |
//! \brief LibVA CM(C for Metal) extensions interface implementaion |
| 25 |
//! |
| 26 |
#include <va/va.h> |
| 27 |
#include <va/va_vpp.h> |
| 28 |
#include <va/va_backend.h> |
| 29 |
|
| 30 |
#include <dlfcn.h> |
| 31 |
|
| 32 |
#include "vphal.h" |
| 33 |
|
| 34 |
#include "media_libva_cm.h" |
| 35 |
#include "media_libva_util.h" |
| 36 |
#include "cm_debug.h" |
| 37 |
#include "cm_wrapper_os.h" |
| 38 |
|
| 39 |
///////////////////////////////////////////////////////////////////////////// |
| 40 |
//! \purpose: Free CM context |
| 41 |
//! \params |
| 42 |
//! [in] |
| 43 |
//! [out] None |
| 44 |
//! \returns VA_STATUS_SUCCESS if call succeeds |
| 45 |
///////////////////////////////////////////////////////////////////////////// |
| 46 |
VAStatus DdiDestroyContextCM ( |
| 47 |
VADriverContextP vaDriverCtx, |
| 48 |
VAContextID vaCtxID) |
| 49 |
{ |
| 50 |
DDI_UNUSED(vaDriverCtx); |
| 51 |
DDI_UNUSED(vaCtxID); |
| 52 |
return VA_STATUS_SUCCESS; |
| 53 |
} |
| 54 |
|
| 55 |
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) |
| 56 |
///////////////////////////////////////////////////////////////////////////// |
| 57 |
//! \purpose: communcation functions between CM Runtime and CM context in VA |
| 58 |
//! \this function will be dynamical opened as a library by vaGetLibFunc() called by CMRT |
| 59 |
//! \params |
| 60 |
//! [in] VADisplay |
| 61 |
//! [in] CM module type |
| 62 |
//! [in] input function ID |
| 63 |
//! [in] input parameter data |
| 64 |
//! [in] input parameter size |
| 65 |
//! [in] Size of the private data |
| 66 |
//! [out] output function ID |
| 67 |
//! [out] output parameter data |
| 68 |
//! [out] output parameter size |
| 69 |
//! returns VA_STATUS_SUCCESS if call succeeds |
| 70 |
///////////////////////////////////////////////////////////////////////////// |
| 71 |
VAStatus vaCmExtSendReqMsg( |
| 72 |
VADisplay display, |
| 73 |
void *moduleType, |
| 74 |
uint32_t *inputFunId, |
| 75 |
void *inputData, |
| 76 |
uint32_t *inputDataLen, |
| 77 |
uint32_t *outputFunId, |
| 78 |
void *outputData, |
| 79 |
uint32_t *outputDataLen) |
| 80 |
{ |
| 81 |
VADriverContextP vaDriverCtx; |
| 82 |
VAStatus hr; |
| 83 |
int32_t funcID; |
| 84 |
VAContextID vaCtxID; |
| 85 |
void * deviceHandle; |
| 86 |
DDI_UNUSED(outputFunId); |
| 87 |
DDI_UNUSED(outputDataLen); |
| 88 |
|
| 89 |
CM_FUNCTION_ENTER_DDI; |
| 90 |
|
| 91 |
hr = VA_STATUS_ERROR_UNKNOWN; |
| 92 |
CM_CHK_NULL_RETURN_WITH_MSG(display, VA_STATUS_ERROR_INVALID_PARAMETER, "Null VADisplay!"); |
| 93 |
vaDriverCtx = CTX(display); |
| 94 |
CM_CHK_NULL_RETURN_WITH_MSG(vaDriverCtx, VA_STATUS_ERROR_INVALID_PARAMETER, "Null vaDriverCtx!"); |
| 95 |
funcID = *(int *)inputFunId; |
| 96 |
|
| 97 |
deviceHandle = outputData; |
| 98 |
if ( *(int *)moduleType != VAExtModuleCMRT) |
| 99 |
{ |
| 100 |
return VA_STATUS_ERROR_UNKNOWN; |
| 101 |
} |
| 102 |
|
| 103 |
hr = CmThinExecute(vaDriverCtx, deviceHandle, *inputFunId, inputData, *inputDataLen); |
| 104 |
if(hr != VA_STATUS_SUCCESS) |
| 105 |
{ |
| 106 |
CM_ASSERTMESSAGE_DDI("CmThinExecute Failed FunctionID %x, ret %d \n", *inputFunId, hr); |
| 107 |
} |
| 108 |
|
| 109 |
return hr; |
| 110 |
} |