| 1 |
/* |
| 2 |
* Copyright (c) 2009-2023, 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 vphal_ddi.c |
| 24 |
//! \brief VPHAL related utility functions that are needed in DDI layer |
| 25 |
//! \details Common utility functions for different DDI layers |
| 26 |
//! |
| 27 |
#include "vphal_ddi.h" |
| 28 |
#include "vphal.h" |
| 29 |
|
| 30 |
//! |
| 31 |
//! \brief Delete surface at DDI layer |
| 32 |
//! \details Free different parameter structures in surfaces and free surfaces |
| 33 |
//! at DDI layer, e.g. Sourc/Target/Bwd/Fwd surface |
| 34 |
//! \param [in,out] pSurf |
| 35 |
//! VPHAL surface pointer |
| 36 |
//! \return void |
| 37 |
//! |
| 38 |
void VpHal_DdiDeleteSurface(PVPHAL_SURFACE pSurf) |
| 39 |
{ |
| 40 |
if (pSurf) |
| 41 |
{ |
| 42 |
if (pSurf->pBwdRef) |
| 43 |
{ |
| 44 |
VpHal_DdiDeleteSurface(pSurf->pBwdRef); |
| 45 |
} |
| 46 |
|
| 47 |
if (pSurf->pFwdRef) |
| 48 |
{ |
| 49 |
VpHal_DdiDeleteSurface(pSurf->pFwdRef); |
| 50 |
} |
| 51 |
|
| 52 |
MOS_SafeFreeMemory(pSurf->Palette.pPalette8); |
| 53 |
|
| 54 |
MOS_SafeFreeMemory(pSurf->pBlendingParams); |
| 55 |
|
| 56 |
MOS_SafeFreeMemory(pSurf->pLumaKeyParams); |
| 57 |
|
| 58 |
if (pSurf->pIEFParams) |
| 59 |
{ |
| 60 |
MOS_SafeFreeMemory(pSurf->pIEFParams->pExtParam); |
| 61 |
MOS_SafeFreeMemory(pSurf->pIEFParams); |
| 62 |
} |
| 63 |
|
| 64 |
MOS_SafeFreeMemory(pSurf->pProcampParams); |
| 65 |
|
| 66 |
MOS_SafeFreeMemory(pSurf->pDeinterlaceParams); |
| 67 |
|
| 68 |
MOS_SafeFreeMemory(pSurf->pDenoiseParams); |
| 69 |
|
| 70 |
MOS_SafeFreeMemory(pSurf->pColorPipeParams); |
| 71 |
|
| 72 |
if (pSurf->p3DLutParams) |
| 73 |
{ |
| 74 |
MOS_SafeFreeMemory(pSurf->p3DLutParams->pExt3DLutSurface); |
| 75 |
MOS_SafeFreeMemory(pSurf->p3DLutParams); |
| 76 |
} |
| 77 |
|
| 78 |
MOS_SafeFreeMemory(pSurf); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
//! |
| 83 |
//! \brief Destroy VPHAL rendering parameters |
| 84 |
//! \details Free source/target surface and other parameters |
| 85 |
//! \param [in,out] pRenderParams |
| 86 |
//! Render parameter pointer |
| 87 |
//! \return void |
| 88 |
//! |
| 89 |
void VpHal_DdiReleaseRenderParams(PVPHAL_RENDER_PARAMS pRenderParams) |
| 90 |
{ |
| 91 |
int i; |
| 92 |
|
| 93 |
MOS_SafeFreeMemory(pRenderParams->pColorFillParams); |
| 94 |
|
| 95 |
MOS_SafeFreeMemory(pRenderParams->pCompAlpha); |
| 96 |
|
| 97 |
MOS_SafeFreeMemory(pRenderParams->pConstriction); |
| 98 |
|
| 99 |
for (i = 0; i < VPHAL_MAX_SOURCES; i++) |
| 100 |
{ |
| 101 |
if (pRenderParams->pSrc[i]) |
| 102 |
{ |
| 103 |
VpHal_DdiDeleteSurface(pRenderParams->pSrc[i]); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
for (i = 0; i < VPHAL_MAX_TARGETS; i++) |
| 108 |
{ |
| 109 |
if (pRenderParams->pTarget[i]) |
| 110 |
{ |
| 111 |
VpHal_DdiDeleteSurface(pRenderParams->pTarget[i]); |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
//! |
| 117 |
//! \brief Judge whether the input procamp value is default or not |
| 118 |
//! \details If the procamp values requested are outside one step of the |
| 119 |
//! default value(to handle precision errors), then return true |
| 120 |
//! \param [in] ProcAmpParameters |
| 121 |
//! ProcAmp Parameters |
| 122 |
//! \return bool |
| 123 |
//! - true The input procamp value is not default |
| 124 |
//! - false The input procamp value is default |
| 125 |
//! |
| 126 |
bool VpHal_DdiProcAmpValuesNotDefault(VPHAL_PROCAMP_PARAMS ProcAmpParameters) |
| 127 |
{ |
| 128 |
if (OUT_OF_BOUNDS( |
| 129 |
ProcAmpParameters.fBrightness, |
| 130 |
PROCAMP_BRIGHTNESS_DEFAULT - PROCAMP_BRIGHTNESS_STEP, |
| 131 |
PROCAMP_BRIGHTNESS_DEFAULT + PROCAMP_BRIGHTNESS_STEP) || |
| 132 |
OUT_OF_BOUNDS( |
| 133 |
ProcAmpParameters.fContrast, |
| 134 |
PROCAMP_CONTRAST_DEFAULT - PROCAMP_CONTRAST_STEP, |
| 135 |
PROCAMP_CONTRAST_DEFAULT + PROCAMP_CONTRAST_STEP) || |
| 136 |
OUT_OF_BOUNDS( |
| 137 |
ProcAmpParameters.fHue, |
| 138 |
PROCAMP_HUE_DEFAULT - PROCAMP_HUE_STEP, |
| 139 |
PROCAMP_HUE_DEFAULT + PROCAMP_HUE_STEP) || |
| 140 |
OUT_OF_BOUNDS( |
| 141 |
ProcAmpParameters.fSaturation, |
| 142 |
PROCAMP_SATURATION_DEFAULT - PROCAMP_SATURATION_STEP, |
| 143 |
PROCAMP_SATURATION_DEFAULT + PROCAMP_SATURATION_STEP)) |
| 144 |
{ |
| 145 |
return true; |
| 146 |
} |
| 147 |
return false; |
| 148 |
} |
| 149 |
|
| 150 |
//! |
| 151 |
//! \brief Report mode of different features |
| 152 |
//! \details Report DI/Scaling/OutputPipe/FRC mode |
| 153 |
//! \param [in] pVpHalState |
| 154 |
//! VPHAL state pointer |
| 155 |
//! \param [in,out] pConfigValues |
| 156 |
//! Porinter to configuration report value structure, |
| 157 |
//! feature modes will be store in this structure. |
| 158 |
//! \return void |
| 159 |
//! |
| 160 |
void VpHal_DdiReportFeatureMode( |
| 161 |
VpBase *pVpHalState, |
| 162 |
PVP_CONFIG pConfigValues) |
| 163 |
{ |
| 164 |
VphalFeatureReport* pReport; |
| 165 |
|
| 166 |
// Get VPHAL feature reporting |
| 167 |
pReport = pVpHalState->GetRenderFeatureReport(); |
| 168 |
VPHAL_PUBLIC_CHK_NULL_NO_STATUS_RETURN(pReport); |
| 169 |
|
| 170 |
// Report DI mode |
| 171 |
switch (pReport->GetFeatures().deinterlaceMode) |
| 172 |
{ |
| 173 |
case VPHAL_DI_REPORT_BOB : |
| 174 |
case VPHAL_DI_REPORT_ADI_BOB : |
| 175 |
pConfigValues->dwCurrentDeinterlaceMode = VPDDI_BOB; |
| 176 |
break; |
| 177 |
case VPHAL_DI_REPORT_ADI : |
| 178 |
case VPHAL_DI_REPORT_FMD : |
| 179 |
pConfigValues->dwCurrentDeinterlaceMode = VPDDI_ADI; |
| 180 |
break; |
| 181 |
case VPHAL_DI_REPORT_PROGRESSIVE : |
| 182 |
default: |
| 183 |
pConfigValues->dwCurrentDeinterlaceMode = VPDDI_PROGRESSIVE; |
| 184 |
break; |
| 185 |
} |
| 186 |
|
| 187 |
// Report Scaling mode |
| 188 |
pConfigValues->dwCurrentScalingMode = |
| 189 |
(pReport->GetFeatures().scalingMode == VPHAL_SCALING_AVS) ? VPDDI_ADVANCEDSCALING : |
| 190 |
(pReport->GetFeatures().scalingMode > VPHAL_SCALING_AVS) ? VPDDI_SUPERRESOLUTIONSCALING : VPDDI_SCALING; |
| 191 |
|
| 192 |
// Report Output Pipe |
| 193 |
pConfigValues->dwCurrentOutputPipeMode = pReport->GetFeatures().outputPipeMode; |
| 194 |
|
| 195 |
// Report HDR Mode |
| 196 |
pConfigValues->dwCurrentHdrMode = pReport->GetFeatures().hdrMode; |
| 197 |
|
| 198 |
// Report VE Feature In Use |
| 199 |
pConfigValues->dwCurrentVEFeatureInUse = pReport->GetFeatures().veFeatureInUse; |
| 200 |
|
| 201 |
// Report MMC status |
| 202 |
pConfigValues->dwVPMMCInUse = pReport->GetFeatures().vpMMCInUse; |
| 203 |
pConfigValues->dwRTCompressible = pReport->GetFeatures().rtCompressible; |
| 204 |
pConfigValues->dwRTCompressMode = pReport->GetFeatures().rtCompressMode; |
| 205 |
pConfigValues->dwFFDICompressible = pReport->GetFeatures().ffdiCompressible; |
| 206 |
pConfigValues->dwFFDICompressMode = pReport->GetFeatures().ffdiCompressMode; |
| 207 |
pConfigValues->dwFFDNCompressible = pReport->GetFeatures().ffdnCompressible; |
| 208 |
pConfigValues->dwFFDNCompressMode = pReport->GetFeatures().ffdnCompressMode; |
| 209 |
pConfigValues->dwSTMMCompressible = pReport->GetFeatures().stmmCompressible; |
| 210 |
pConfigValues->dwSTMMCompressMode = pReport->GetFeatures().stmmCompressMode; |
| 211 |
pConfigValues->dwScalerCompressible = pReport->GetFeatures().scalerCompressible; |
| 212 |
pConfigValues->dwScalerCompressMode = pReport->GetFeatures().scalerCompressMode; |
| 213 |
pConfigValues->dwPrimaryCompressible = pReport->GetFeatures().primaryCompressible; |
| 214 |
pConfigValues->dwPrimaryCompressMode = pReport->GetFeatures().primaryCompressMode; |
| 215 |
|
| 216 |
// Report In Place Compositon status |
| 217 |
pConfigValues->dwCurrentCompositionMode = pReport->GetFeatures().compositionMode; |
| 218 |
pConfigValues->dwCurrentScdMode = pReport->GetFeatures().diScdMode; |
| 219 |
|
| 220 |
// Report Vebox Scalability |
| 221 |
pConfigValues->dwCurrentVeboxScalability = pReport->GetFeatures().VeboxScalability; |
| 222 |
|
| 223 |
// Report VP Apogeios |
| 224 |
pConfigValues->dwCurrentVPApogeios = pReport->GetFeatures().VPApogeios; |
| 225 |
|
| 226 |
VP_DDI_NORMALMESSAGE("VP Feature Report: \ |
| 227 |
OutputPipeMode %d, \ |
| 228 |
HDRMode %d, \ |
| 229 |
VEFeatureInUse %d, \ |
| 230 |
ScalingMode %d, \ |
| 231 |
DeinterlaceMode %d, \ |
| 232 |
VPMMCInUse %d, \ |
| 233 |
RTCompressible %d, \ |
| 234 |
RTCompressMode %d, \ |
| 235 |
PrimaryCompressible %d, \ |
| 236 |
PrimaryCompressMode %d, \ |
| 237 |
CompositionMode %d", |
| 238 |
pReport->GetFeatures().outputPipeMode, |
| 239 |
pReport->GetFeatures().hdrMode, |
| 240 |
pReport->GetFeatures().veFeatureInUse, |
| 241 |
pReport->GetFeatures().scalingMode, |
| 242 |
pReport->GetFeatures().deinterlaceMode, |
| 243 |
pReport->GetFeatures().vpMMCInUse, |
| 244 |
pReport->GetFeatures().rtCompressible, |
| 245 |
pReport->GetFeatures().rtCompressMode, |
| 246 |
pReport->GetFeatures().primaryCompressible, |
| 247 |
pReport->GetFeatures().primaryCompressMode, |
| 248 |
pReport->GetFeatures().compositionMode |
| 249 |
); |
| 250 |
} |
| 251 |
|
| 252 |
//! |
| 253 |
//! \brief Set up split screen demo mode |
| 254 |
//! \details Allocate and initialize split-screen demo mode structure |
| 255 |
//! \param [in] splitDemoPosDdi |
| 256 |
//! The split demo position setting from DDI layer |
| 257 |
//! \param [in] splitDemoParaDdi |
| 258 |
//! The split demo parameters setting from DDI layer |
| 259 |
//! \param [in,out] splitScreenDemoModeParams |
| 260 |
//! Pointer to struct for split-screen demo mode parameters |
| 261 |
//! \param [in,out] disableDemoMode |
| 262 |
//! Return whether demo mode will be disable or not |
| 263 |
//! \param [in] disableDemoMode |
| 264 |
//! Pointer to MOS INTERFACE for OS interaction |
| 265 |
//! \return MOS_STATUS |
| 266 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 267 |
//! |
| 268 |
MOS_STATUS VpHal_DdiSetupSplitScreenDemoMode( |
| 269 |
uint32_t splitDemoPosDdi, |
| 270 |
uint32_t splitDemoParaDdi, |
| 271 |
PVPHAL_SPLIT_SCREEN_DEMO_MODE_PARAMS *splitScreenDemoModeParams, |
| 272 |
bool *disableDemoMode, |
| 273 |
PMOS_INTERFACE pOsInterface) |
| 274 |
{ |
| 275 |
MOS_STATUS eStatus; |
| 276 |
uint32_t splitScreenDemoPosition; |
| 277 |
uint32_t splitScreenDemoParameters; |
| 278 |
|
| 279 |
eStatus = MOS_STATUS_SUCCESS; |
| 280 |
splitScreenDemoPosition = splitDemoPosDdi; |
| 281 |
splitScreenDemoParameters = splitDemoParaDdi; |
| 282 |
|
| 283 |
//-------------------------- |
| 284 |
// Set Demo Mode Parameters |
| 285 |
//-------------------------- |
| 286 |
if (*splitScreenDemoModeParams == nullptr) |
| 287 |
{ |
| 288 |
*splitScreenDemoModeParams = (PVPHAL_SPLIT_SCREEN_DEMO_MODE_PARAMS)MOS_AllocAndZeroMemory(sizeof(VPHAL_SPLIT_SCREEN_DEMO_MODE_PARAMS)); |
| 289 |
VPHAL_PUBLIC_CHK_NULL(*splitScreenDemoModeParams); |
| 290 |
} |
| 291 |
|
| 292 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 293 |
// If it is not enabled from DDI params, check if internal user feature key have settings |
| 294 |
if (splitScreenDemoPosition == SPLIT_SCREEN_DEMO_DISABLED && |
| 295 |
splitScreenDemoParameters == 0) |
| 296 |
{ |
| 297 |
MOS_USER_FEATURE_VALUE_DATA UserFeatureData; |
| 298 |
|
| 299 |
MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData)); |
| 300 |
MOS_USER_FEATURE_INVALID_KEY_ASSERT(MOS_UserFeature_ReadValue_ID( |
| 301 |
nullptr, |
| 302 |
__MEDIA_USER_FEATURE_VALUE_SPLIT_SCREEN_DEMO_POSITION_ID, |
| 303 |
&UserFeatureData, |
| 304 |
pOsInterface ? pOsInterface->pOsContext : nullptr)); |
| 305 |
splitScreenDemoPosition = UserFeatureData.u32Data; |
| 306 |
|
| 307 |
MOS_ZeroMemory(&UserFeatureData, sizeof(UserFeatureData)); |
| 308 |
MOS_USER_FEATURE_INVALID_KEY_ASSERT(MOS_UserFeature_ReadValue_ID( |
| 309 |
nullptr, |
| 310 |
__MEDIA_USER_FEATURE_VALUE_SPLIT_SCREEN_DEMO_PARAMETERS_ID, |
| 311 |
&UserFeatureData, |
| 312 |
pOsInterface ? pOsInterface->pOsContext : nullptr)); |
| 313 |
splitScreenDemoParameters = UserFeatureData.u32Data; |
| 314 |
} |
| 315 |
#endif |
| 316 |
|
| 317 |
if ((splitScreenDemoPosition > SPLIT_SCREEN_DEMO_DISABLED) && (splitScreenDemoPosition < SPLIT_SCREEN_DEMO_END_POS_LIST)) |
| 318 |
{ |
| 319 |
(*splitScreenDemoModeParams)->Position = (VPHAL_SPLIT_SCREEN_DEMO_POSITION)(splitScreenDemoPosition); |
| 320 |
(*splitScreenDemoModeParams)->bDisableACE = (bool)((splitScreenDemoParameters & 0x0001) > 0); |
| 321 |
(*splitScreenDemoModeParams)->bDisableAVS = (bool)((splitScreenDemoParameters & 0x0002) > 0); |
| 322 |
(*splitScreenDemoModeParams)->bDisableDN = (bool)((splitScreenDemoParameters & 0x0004) > 0); |
| 323 |
(*splitScreenDemoModeParams)->bDisableFMD = (bool)((splitScreenDemoParameters & 0x0008) > 0); |
| 324 |
(*splitScreenDemoModeParams)->bDisableIEF = (bool)((splitScreenDemoParameters & 0x0010) > 0); |
| 325 |
(*splitScreenDemoModeParams)->bDisableProcamp = (bool)((splitScreenDemoParameters & 0x0020) > 0); |
| 326 |
(*splitScreenDemoModeParams)->bDisableSTE = (bool)((splitScreenDemoParameters & 0x0040) > 0); |
| 327 |
(*splitScreenDemoModeParams)->bDisableTCC = (bool)((splitScreenDemoParameters & 0x0080) > 0); |
| 328 |
(*splitScreenDemoModeParams)->bDisableIS = (bool)((splitScreenDemoParameters & 0x0100) > 0); |
| 329 |
(*splitScreenDemoModeParams)->bDisableDrDb = (bool)((splitScreenDemoParameters & 0x0200) > 0); |
| 330 |
(*splitScreenDemoModeParams)->bDisableDNUV = (bool)((splitScreenDemoParameters & 0x0400) > 0); |
| 331 |
(*splitScreenDemoModeParams)->bDisableFRC = (bool)((splitScreenDemoParameters & 0x0800) > 0); |
| 332 |
(*splitScreenDemoModeParams)->bDisableLACE = (bool)((splitScreenDemoParameters & 0x1000) > 0); |
| 333 |
*disableDemoMode = false; |
| 334 |
} |
| 335 |
else |
| 336 |
{ |
| 337 |
*disableDemoMode = true; |
| 338 |
} |
| 339 |
|
| 340 |
finish: |
| 341 |
return eStatus; |
| 342 |
} |
| 343 |
|
| 344 |
//! |
| 345 |
//! \brief Init IEF Params to their default value |
| 346 |
//! \param [out] pIEFParams |
| 347 |
//! The IEF Params struct to be initialized |
| 348 |
//! \return MOS_STATUS |
| 349 |
//! Return MOS_STATUS_SUCCESS if successful, otherwise failed |
| 350 |
//! |
| 351 |
MOS_STATUS VpHal_DdiInitIEFParams( |
| 352 |
PVPHAL_IEF_PARAMS pIEFParams) |
| 353 |
{ |
| 354 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 355 |
|
| 356 |
VPHAL_PUBLIC_CHK_NULL(pIEFParams); |
| 357 |
|
| 358 |
// Init default values for flows where user feature key is not available or used |
| 359 |
pIEFParams->bSkintoneTuned = true; |
| 360 |
pIEFParams->bEmphasizeSkinDetail = false; |
| 361 |
pIEFParams->bSmoothMode = false; |
| 362 |
pIEFParams->StrongEdgeWeight = IEF_STRONG_EDGE_WEIGHT; |
| 363 |
pIEFParams->RegularWeight = IEF_REGULAR_WEIGHT; |
| 364 |
pIEFParams->StrongEdgeThreshold = IEF_STRONG_EDGE_THRESHOLD; |
| 365 |
|
| 366 |
finish: |
| 367 |
return eStatus; |
| 368 |
} |