| 1 | /* |
| 2 | * Copyright (c) 2014-2019, 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 mhw_vebox_g9_X.cpp |
| 24 | //! \brief Constructs vebox commands on Gen9-based platforms |
| 25 | //! \details Each client facing function both creates a HW command and adds |
| 26 | //! that command to a command or batch buffer. |
| 27 | //! |
| 28 | |
| 29 | #include "mhw_vebox_g9_X.h" |
| 30 | #include "hal_oca_interface.h" |
| 31 | |
| 32 | MhwVeboxInterfaceG9::MhwVeboxInterfaceG9( |
| 33 | PMOS_INTERFACE pInputInterface) |
| 34 | : MhwVeboxInterfaceGeneric(pInputInterface) |
| 35 | { |
| 36 | MHW_FUNCTION_ENTER; |
| 37 | m_veboxSettings = g_Vebox_Settings_g9; |
| 38 | } |
| 39 | |
| 40 | void MhwVeboxInterfaceG9::SetVeboxIecpStateBecsc( |
| 41 | mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState, |
| 42 | PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, |
| 43 | bool bEnableFECSC) |
| 44 | { |
| 45 | PMHW_CAPPIPE_PARAMS pCapPipeParams; |
| 46 | MOS_FORMAT dstFormat; |
| 47 | |
| 48 | MHW_CHK_NULL_NO_STATUS_RETURN(pVeboxIecpState); |
| 49 | MHW_CHK_NULL_NO_STATUS_RETURN(pVeboxIecpParams); |
| 50 | |
| 51 | pCapPipeParams = &pVeboxIecpParams->CapPipeParams; |
| 52 | dstFormat = pVeboxIecpParams->dstFormat; |
| 53 | |
| 54 | #define SET_COEFS(_c0, _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8) \ |
| 55 | { \ |
| 56 | pVeboxIecpState->CscState.DW0.C0 = _c0; \ |
| 57 | pVeboxIecpState->CscState.DW1.C1 = _c1; \ |
| 58 | pVeboxIecpState->CscState.DW2.C2 = _c2; \ |
| 59 | pVeboxIecpState->CscState.DW3.C3 = _c3; \ |
| 60 | pVeboxIecpState->CscState.DW4.C4 = _c4; \ |
| 61 | pVeboxIecpState->CscState.DW5.C5 = _c5; \ |
| 62 | pVeboxIecpState->CscState.DW6.C6 = _c6; \ |
| 63 | pVeboxIecpState->CscState.DW7.C7 = _c7; \ |
| 64 | pVeboxIecpState->CscState.DW8.C8 = _c8; \ |
| 65 | } |
| 66 | |
| 67 | #define SET_INPUT_OFFSETS(_in1, _in2, _in3) \ |
| 68 | { \ |
| 69 | pVeboxIecpState->CscState.DW9.OffsetIn1 = _in1; \ |
| 70 | pVeboxIecpState->CscState.DW10.OffsetIn2 = _in2; \ |
| 71 | pVeboxIecpState->CscState.DW11.OffsetIn3 = _in3; \ |
| 72 | } |
| 73 | |
| 74 | #define SET_OUTPUT_OFFSETS(_out1, _out2, _out3) \ |
| 75 | { \ |
| 76 | pVeboxIecpState->CscState.DW9.OffsetOut1 = _out1; \ |
| 77 | pVeboxIecpState->CscState.DW10.OffsetOut2 = _out2; \ |
| 78 | pVeboxIecpState->CscState.DW11.OffsetOut3 = _out3; \ |
| 79 | } |
| 80 | |
| 81 | if (pCapPipeParams->bActive) |
| 82 | { |
| 83 | // Application controlled CSC operation |
| 84 | if (pCapPipeParams->BECSCParams.bActive) |
| 85 | { |
| 86 | pVeboxIecpState->CscState.DW0.TransformEnable = true; |
| 87 | |
| 88 | if (IS_RGB_SWAP(dstFormat)) |
| 89 | { |
| 90 | pVeboxIecpState->CscState.DW0.YuvChannelSwap = true; |
| 91 | } |
| 92 | |
| 93 | // Coeff is S2.16, so multiply the floating value by 65536 |
| 94 | SET_COEFS( |
| 95 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[0][0] * 65536)), |
| 96 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[0][1] * 65536)), |
| 97 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[0][2] * 65536)), |
| 98 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[1][0] * 65536)), |
| 99 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[1][1] * 65536)), |
| 100 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[1][2] * 65536)), |
| 101 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[2][0] * 65536)), |
| 102 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[2][1] * 65536)), |
| 103 | ((uint32_t)(pCapPipeParams->BECSCParams.Matrix[2][2] * 65536))); |
| 104 | SET_INPUT_OFFSETS( |
| 105 | ((uint32_t)pCapPipeParams->BECSCParams.PreOffset[0]), |
| 106 | ((uint32_t)pCapPipeParams->BECSCParams.PreOffset[1]), |
| 107 | ((uint32_t)pCapPipeParams->BECSCParams.PreOffset[2])); |
| 108 | SET_OUTPUT_OFFSETS( |
| 109 | ((uint32_t)pCapPipeParams->BECSCParams.PostOffset[0]), |
| 110 | ((uint32_t)pCapPipeParams->BECSCParams.PostOffset[1]), |
| 111 | ((uint32_t)pCapPipeParams->BECSCParams.PostOffset[2])); |
| 112 | } |
| 113 | // YUV 4:4:4 CSC to xBGR or xRGB |
| 114 | else if ((bEnableFECSC || (pVeboxIecpParams->srcFormat == Format_AYUV)) && |
| 115 | (IS_RGB_FORMAT(dstFormat))) |
| 116 | { |
| 117 | pVeboxIecpState->CscState.DW0.TransformEnable = true; |
| 118 | |
| 119 | if (IS_RGB_SWAP(dstFormat)) |
| 120 | { |
| 121 | pVeboxIecpState->CscState.DW0.YuvChannelSwap = true; |
| 122 | } |
| 123 | |
| 124 | // CSC matrix to convert YUV 4:4:4 to xBGR. e.g. Format_A8B8G8R8. In the |
| 125 | // event that dstFormat is xRGB, driver sets R & B channel swapping via |
| 126 | // CscState.DW0.YuvChannelSwap so a separate matrix is not needed. |
| 127 | |
| 128 | if (pVeboxIecpParams->ColorSpace == MHW_CSpace_BT601) |
| 129 | { |
| 130 | SET_COEFS(76284, 0, 104595, 76284, MOS_BITFIELD_VALUE((uint32_t)-25689, 19), MOS_BITFIELD_VALUE((uint32_t)-53280, 19), 76284, 132186, 0); |
| 131 | |
| 132 | SET_INPUT_OFFSETS(MOS_BITFIELD_VALUE((uint32_t)-2048, 16), |
| 133 | MOS_BITFIELD_VALUE((uint32_t)-16384, 16), |
| 134 | MOS_BITFIELD_VALUE((uint32_t)-16384, 16)); |
| 135 | SET_OUTPUT_OFFSETS(0, 0, 0); |
| 136 | } |
| 137 | else if (pVeboxIecpParams->ColorSpace == MHW_CSpace_BT709) |
| 138 | { |
| 139 | SET_COEFS(76284, 0, 117506, 76284, MOS_BITFIELD_VALUE((uint32_t)-13958, 19), MOS_BITFIELD_VALUE((uint32_t)-34930, 19), 76284, 138412, 0); |
| 140 | |
| 141 | SET_INPUT_OFFSETS(MOS_BITFIELD_VALUE((uint32_t)-2048, 16), |
| 142 | MOS_BITFIELD_VALUE((uint32_t)-16384, 16), |
| 143 | MOS_BITFIELD_VALUE((uint32_t)-16384, 16)); |
| 144 | SET_OUTPUT_OFFSETS(0, 0, 0); |
| 145 | } |
| 146 | else if (pVeboxIecpParams->ColorSpace == MHW_CSpace_sRGB) |
| 147 | { |
| 148 | SET_COEFS(65536, 0, 103206, 65536, MOS_BITFIELD_VALUE((uint32_t)-12277, 19), MOS_BITFIELD_VALUE((uint32_t)-30679, 19), 65536, 121608, 0); |
| 149 | |
| 150 | SET_INPUT_OFFSETS(0, |
| 151 | MOS_BITFIELD_VALUE((uint32_t)-16384, 16), |
| 152 | MOS_BITFIELD_VALUE((uint32_t)-16384, 16)); |
| 153 | SET_OUTPUT_OFFSETS(0, 0, 0); |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | MHW_ASSERT(false); |
| 158 | } |
| 159 | } |
| 160 | // xBGR to xRGB |
| 161 | else if ((dstFormat == Format_A8R8G8B8) || |
| 162 | (dstFormat == Format_X8R8G8B8) || |
| 163 | (dstFormat == Format_A16R16G16B16)) |
| 164 | { |
| 165 | pVeboxIecpState->CscState.DW0.YuvChannelSwap = true; |
| 166 | } |
| 167 | } |
| 168 | else if (pVeboxIecpParams->bCSCEnable) |
| 169 | { |
| 170 | pVeboxIecpState->CscState.DW0.TransformEnable = true; |
| 171 | |
| 172 | if (IS_RGB_SWAP(dstFormat)) |
| 173 | { |
| 174 | pVeboxIecpState->CscState.DW0.YuvChannelSwap = true; |
| 175 | } |
| 176 | |
| 177 | // Coeff is S2.16, so multiply the floating value by 65536 |
| 178 | SET_COEFS( |
| 179 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[0] * 65536.0F)), |
| 180 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[1] * 65536.0F)), |
| 181 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[2] * 65536.0F)), |
| 182 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[3] * 65536.0F)), |
| 183 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[4] * 65536.0F)), |
| 184 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[5] * 65536.0F)), |
| 185 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[6] * 65536.0F)), |
| 186 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[7] * 65536.0F)), |
| 187 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[8] * 65536.0F))); |
| 188 | |
| 189 | // Offset is S15, but the SW offsets are calculated as 8bits, |
| 190 | // so left shift them 7bits to be in the position of MSB |
| 191 | SET_INPUT_OFFSETS( |
| 192 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscInOffset[0] * 128.0F)), |
| 193 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscInOffset[1] * 128.0F)), |
| 194 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscInOffset[2] * 128.0F))); |
| 195 | SET_OUTPUT_OFFSETS( |
| 196 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscOutOffset[0] * 128.0F)), |
| 197 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscOutOffset[1] * 128.0F)), |
| 198 | ((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscOutOffset[2] * 128.0F))); |
| 199 | } |
| 200 | |
| 201 | pVeboxIecpState->AlphaAoiState.DW0.AlphaFromStateSelect = pVeboxIecpParams->bAlphaEnable; |
| 202 | |
| 203 | // Alpha is U16, but the SW alpha is calculated as 8bits, |
| 204 | // so left shift it 8bits to be in the position of MSB |
| 205 | pVeboxIecpState->AlphaAoiState.DW0.ColorPipeAlpha = pVeboxIecpParams->wAlphaValue * 256; |
| 206 | |
| 207 | #undef SET_COEFS |
| 208 | #undef SET_INPUT_OFFSETS |
| 209 | #undef SET_OUTPUT_OFFSETS |
| 210 | } |
| 211 | |
| 212 | void MhwVeboxInterfaceG9::SetVeboxSurfaces( |
| 213 | PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam, |
| 214 | PMHW_VEBOX_SURFACE_PARAMS pDerivedSurfaceParam, |
| 215 | PMHW_VEBOX_SURFACE_PARAMS pSkinScoreSurfaceParam, |
| 216 | mhw_vebox_g9_X::VEBOX_SURFACE_STATE_CMD *pVeboxSurfaceState, |
| 217 | bool bIsOutputSurface, |
| 218 | bool bDIEnable) |
| 219 | { |
| 220 | uint32_t dwFormat; |
| 221 | uint32_t dwSurfaceWidth; |
| 222 | uint32_t dwSurfaceHeight; |
| 223 | uint32_t dwSurfacePitch; |
| 224 | bool bHalfPitchForChroma; |
| 225 | bool bInterleaveChroma; |
| 226 | uint16_t wUXOffset; |
| 227 | uint16_t wUYOffset; |
| 228 | uint16_t wVXOffset; |
| 229 | uint16_t wVYOffset; |
| 230 | uint8_t bBayerOffset; |
| 231 | uint8_t bBayerStride; |
| 232 | mhw_vebox_g9_X::VEBOX_SURFACE_STATE_CMD VeboxSurfaceState; |
| 233 | |
| 234 | MHW_CHK_NULL_NO_STATUS_RETURN(pSurfaceParam); |
| 235 | MHW_CHK_NULL_NO_STATUS_RETURN(pVeboxSurfaceState); |
| 236 | |
| 237 | // Initialize |
| 238 | dwSurfaceWidth = 0; |
| 239 | dwSurfaceHeight = 0; |
| 240 | dwSurfacePitch = 0; |
| 241 | bHalfPitchForChroma = false; |
| 242 | bInterleaveChroma = false; |
| 243 | wUXOffset = 0; |
| 244 | wUYOffset = 0; |
| 245 | wVXOffset = 0; |
| 246 | wVYOffset = 0; |
| 247 | bBayerOffset = 0; |
| 248 | bBayerStride = 0; |
| 249 | |
| 250 | *pVeboxSurfaceState = VeboxSurfaceState; |
| 251 | |
| 252 | switch (pSurfaceParam->Format) |
| 253 | { |
| 254 | case Format_NV12: |
| 255 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR4208; |
| 256 | bInterleaveChroma = true; |
| 257 | wUYOffset = (uint16_t)pSurfaceParam->dwUYoffset; |
| 258 | break; |
| 259 | |
| 260 | case Format_YUYV: |
| 261 | case Format_YUY2: |
| 262 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBNORMAL; |
| 263 | break; |
| 264 | |
| 265 | case Format_UYVY: |
| 266 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPY; |
| 267 | break; |
| 268 | |
| 269 | case Format_AYUV: |
| 270 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED444A8; |
| 271 | break; |
| 272 | |
| 273 | case Format_Y416: |
| 274 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED44416; |
| 275 | break; |
| 276 | |
| 277 | case Format_YVYU: |
| 278 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPUV; |
| 279 | break; |
| 280 | |
| 281 | case Format_VYUY: |
| 282 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPUVY; |
| 283 | break; |
| 284 | |
| 285 | case Format_A8R8G8B8: |
| 286 | case Format_X8R8G8B8: |
| 287 | case Format_A8B8G8R8: |
| 288 | case Format_X8B8G8R8: |
| 289 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R8G8B8A8UNORMR8G8B8A8UNORMSRGB; |
| 290 | break; |
| 291 | |
| 292 | case Format_A16B16G16R16: |
| 293 | case Format_A16R16G16B16: |
| 294 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R16G16B16A16; |
| 295 | break; |
| 296 | |
| 297 | case Format_L8: |
| 298 | case Format_P8: |
| 299 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_Y8UNORM; |
| 300 | break; |
| 301 | |
| 302 | case Format_IRW0: |
| 303 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 304 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISBLUE; |
| 305 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 306 | break; |
| 307 | |
| 308 | case Format_IRW1: |
| 309 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 310 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISRED; |
| 311 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 312 | break; |
| 313 | |
| 314 | case Format_IRW2: |
| 315 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 316 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISRED; |
| 317 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 318 | break; |
| 319 | |
| 320 | case Format_IRW3: |
| 321 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 322 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISBLUE; |
| 323 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 324 | break; |
| 325 | |
| 326 | case Format_IRW4: |
| 327 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 328 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISBLUE; |
| 329 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 330 | break; |
| 331 | |
| 332 | case Format_IRW5: |
| 333 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 334 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISRED; |
| 335 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 336 | break; |
| 337 | |
| 338 | case Format_IRW6: |
| 339 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 340 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISRED; |
| 341 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 342 | break; |
| 343 | |
| 344 | case Format_IRW7: |
| 345 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 346 | bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISBLUE; |
| 347 | bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 348 | break; |
| 349 | |
| 350 | case Format_P010: |
| 351 | case Format_P016: |
| 352 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR42016; |
| 353 | bInterleaveChroma = true; |
| 354 | wUYOffset = (uint16_t)pSurfaceParam->dwUYoffset; |
| 355 | break; |
| 356 | |
| 357 | case Format_R10G10B10A2: |
| 358 | case Format_B10G10R10A2: |
| 359 | dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R10G10B10A2UNORMR10G10B10A2UNORMSRGB; |
| 360 | break; |
| 361 | |
| 362 | default: |
| 363 | MHW_ASSERTMESSAGE("Unsupported format."); |
| 364 | goto finish; |
| 365 | break; |
| 366 | } |
| 367 | |
| 368 | // adjust boundary for vebox |
| 369 | VeboxAdjustBoundary( |
| 370 | pSurfaceParam, |
| 371 | &dwSurfaceWidth, |
| 372 | &dwSurfaceHeight, |
| 373 | bDIEnable); |
| 374 | |
| 375 | dwSurfacePitch = (pSurfaceParam->TileType == MOS_TILE_LINEAR) ? MOS_ALIGN_CEIL(pSurfaceParam->dwPitch, MHW_VEBOX_LINEAR_PITCH) : pSurfaceParam->dwPitch; |
| 376 | |
| 377 | pVeboxSurfaceState->DW1.SurfaceIdentification = bIsOutputSurface; |
| 378 | pVeboxSurfaceState->DW2.Width = dwSurfaceWidth - 1; |
| 379 | pVeboxSurfaceState->DW2.Height = dwSurfaceHeight - 1; |
| 380 | pVeboxSurfaceState->DW3.HalfPitchForChroma = bHalfPitchForChroma; |
| 381 | pVeboxSurfaceState->DW3.InterleaveChroma = bInterleaveChroma; |
| 382 | pVeboxSurfaceState->DW3.SurfaceFormat = dwFormat; |
| 383 | pVeboxSurfaceState->DW3.BayerPatternOffset = bBayerOffset; |
| 384 | pVeboxSurfaceState->DW3.BayerPatternFormat = bBayerStride; |
| 385 | pVeboxSurfaceState->DW3.SurfacePitch = dwSurfacePitch - 1; |
| 386 | pVeboxSurfaceState->DW3.TiledSurface = (pSurfaceParam->TileType != MOS_TILE_LINEAR) ? true : false; |
| 387 | pVeboxSurfaceState->DW3.TileWalk = (pSurfaceParam->TileType == MOS_TILE_Y) |
| 388 | ? VeboxSurfaceState.TILE_WALK_TILEWALKYMAJOR |
| 389 | : VeboxSurfaceState.TILE_WALK_TILEWALKXMAJOR; |
| 390 | pVeboxSurfaceState->DW4.XOffsetForU = wUXOffset; |
| 391 | pVeboxSurfaceState->DW4.YOffsetForU = wUYOffset; |
| 392 | pVeboxSurfaceState->DW5.XOffsetForV = wVXOffset; |
| 393 | pVeboxSurfaceState->DW5.YOffsetForV = wVYOffset; |
| 394 | |
| 395 | // May fix this for stereo surfaces |
| 396 | pVeboxSurfaceState->DW6.YOffsetForFrame = pSurfaceParam->dwYoffset; |
| 397 | pVeboxSurfaceState->DW6.XOffsetForFrame = 0; |
| 398 | |
| 399 | pVeboxSurfaceState->DW7.DerivedSurfacePitch = pDerivedSurfaceParam->dwPitch - 1; |
| 400 | pVeboxSurfaceState->DW8.SurfacePitchForSkinScoreOutputSurfaces = (bIsOutputSurface && pSkinScoreSurfaceParam->bActive) ? (pSkinScoreSurfaceParam->dwPitch - 1) : 0; |
| 401 | |
| 402 | finish: |
| 403 | return; |
| 404 | } |
| 405 | |
| 406 | MOS_STATUS MhwVeboxInterfaceG9::GetVeboxAce_FullImageHistogram( |
| 407 | uint32_t *pFullImageHistogram) |
| 408 | { |
| 409 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 410 | PMHW_VEBOX_HEAP pVeboxHeap; |
| 411 | int32_t uiOffset; |
| 412 | mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState; |
| 413 | |
| 414 | MHW_CHK_NULL(pFullImageHistogram); |
| 415 | MHW_CHK_NULL(m_veboxHeap); |
| 416 | |
| 417 | pVeboxHeap = m_veboxHeap; |
| 418 | uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 419 | |
| 420 | pVeboxIecpState = (mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 421 | pVeboxHeap->uiIecpStateOffset + |
| 422 | uiOffset); |
| 423 | MHW_CHK_NULL(pVeboxIecpState); |
| 424 | *pFullImageHistogram = pVeboxIecpState->AlphaAoiState.DW0.FullImageHistogram; |
| 425 | |
| 426 | finish: |
| 427 | return eStatus; |
| 428 | } |
| 429 | |
| 430 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxState( |
| 431 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 432 | PMHW_VEBOX_STATE_CMD_PARAMS pVeboxStateCmdParams, |
| 433 | bool bUseCmBuffer) |
| 434 | { |
| 435 | MOS_STATUS eStatus; |
| 436 | PMOS_INTERFACE pOsInterface; |
| 437 | PMOS_CONTEXT pOsContext = nullptr; |
| 438 | PMOS_RESOURCE pVeboxParamResource = nullptr; |
| 439 | PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 440 | PMHW_VEBOX_MODE pVeboxMode; |
| 441 | uint32_t uiInstanceBaseAddr = 0; |
| 442 | MHW_RESOURCE_PARAMS ResourceParams; |
| 443 | PMHW_VEBOX_HEAP pVeboxHeap; |
| 444 | MOS_ALLOC_GFXRES_PARAMS AllocParamsForBufferLinear; |
| 445 | mhw_vebox_g9_X::VEBOX_STATE_CMD cmd; |
| 446 | |
| 447 | MHW_CHK_NULL(m_osInterface); |
| 448 | MHW_CHK_NULL(m_osInterface->pOsContext); |
| 449 | MHW_CHK_NULL(pCmdBuffer); |
| 450 | MHW_CHK_NULL(pVeboxStateCmdParams); |
| 451 | |
| 452 | // Initialize |
| 453 | eStatus = MOS_STATUS_SUCCESS; |
| 454 | pOsInterface = m_osInterface; |
| 455 | pOsContext = m_osInterface->pOsContext; |
| 456 | pVeboxMode = &pVeboxStateCmdParams->VeboxMode; |
| 457 | |
| 458 | cmd.DW1.DownsampleMethod422to420 = 1; |
| 459 | cmd.DW1.DownsampleMethod444to422 = 1; |
| 460 | |
| 461 | if (!pVeboxStateCmdParams->bNoUseVeboxHeap) |
| 462 | { |
| 463 | MHW_CHK_NULL(m_veboxHeap); |
| 464 | |
| 465 | pVeboxHeap = m_veboxHeap; |
| 466 | if (bUseCmBuffer) |
| 467 | pVeboxParamResource = pVeboxStateCmdParams->pVeboxParamSurf; |
| 468 | else |
| 469 | { |
| 470 | pVeboxHeap = m_veboxHeap; |
| 471 | pVeboxHeapResource = pVeboxStateCmdParams->bUseVeboxHeapKernelResource ? &pVeboxHeap->KernelResource : &pVeboxHeap->DriverResource; |
| 472 | // Calculate the instance base address |
| 473 | uiInstanceBaseAddr = pVeboxHeap->uiInstanceSize * pVeboxHeap->uiCurState; |
| 474 | } |
| 475 | |
| 476 | TraceIndirectStateInfo(*pCmdBuffer, *pOsContext, bUseCmBuffer, pVeboxStateCmdParams->bUseVeboxHeapKernelResource); |
| 477 | |
| 478 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 479 | if (bUseCmBuffer) |
| 480 | { |
| 481 | ResourceParams.presResource = pVeboxParamResource; |
| 482 | ResourceParams.dwOffset = pVeboxHeap->uiDndiStateOffset; |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | ResourceParams.presResource = pVeboxHeapResource; |
| 487 | ResourceParams.dwOffset = pVeboxHeap->uiDndiStateOffset + uiInstanceBaseAddr; |
| 488 | } |
| 489 | ResourceParams.pdwCmd = & (cmd.DW2.Value); |
| 490 | ResourceParams.dwLocationInCmd = 2; |
| 491 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 492 | |
| 493 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 494 | pOsInterface, |
| 495 | pCmdBuffer, |
| 496 | &ResourceParams)); |
| 497 | |
| 498 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, m_veboxSettings.uiDndiStateSize); |
| 499 | |
| 500 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 501 | if (bUseCmBuffer) |
| 502 | { |
| 503 | ResourceParams.presResource = pVeboxParamResource; |
| 504 | ResourceParams.dwOffset = pVeboxHeap->uiIecpStateOffset; |
| 505 | } |
| 506 | else |
| 507 | { |
| 508 | ResourceParams.presResource = pVeboxHeapResource; |
| 509 | ResourceParams.dwOffset = pVeboxHeap->uiIecpStateOffset + uiInstanceBaseAddr; |
| 510 | } |
| 511 | ResourceParams.pdwCmd = & (cmd.DW4.Value); |
| 512 | ResourceParams.dwLocationInCmd = 4; |
| 513 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 514 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 515 | |
| 516 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 517 | pOsInterface, |
| 518 | pCmdBuffer, |
| 519 | &ResourceParams)); |
| 520 | |
| 521 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, m_veboxSettings.uiIecpStateSize); |
| 522 | |
| 523 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 524 | |
| 525 | if (bUseCmBuffer) |
| 526 | { |
| 527 | ResourceParams.presResource = pVeboxParamResource; |
| 528 | ResourceParams.dwOffset = pVeboxHeap->uiGamutStateOffset; |
| 529 | } |
| 530 | else |
| 531 | { |
| 532 | ResourceParams.presResource = pVeboxHeapResource; |
| 533 | ResourceParams.dwOffset = pVeboxHeap->uiGamutStateOffset + uiInstanceBaseAddr; |
| 534 | } |
| 535 | ResourceParams.pdwCmd = & (cmd.DW6.Value); |
| 536 | ResourceParams.dwLocationInCmd = 6; |
| 537 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 538 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 539 | |
| 540 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 541 | pOsInterface, |
| 542 | pCmdBuffer, |
| 543 | &ResourceParams)); |
| 544 | |
| 545 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, m_veboxSettings.uiGamutStateSize); |
| 546 | |
| 547 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 548 | if (bUseCmBuffer) |
| 549 | { |
| 550 | ResourceParams.presResource = pVeboxParamResource; |
| 551 | ResourceParams.dwOffset = pVeboxHeap->uiVertexTableOffset; |
| 552 | } |
| 553 | else |
| 554 | { |
| 555 | ResourceParams.presResource = pVeboxHeapResource; |
| 556 | ResourceParams.dwOffset = pVeboxHeap->uiVertexTableOffset + uiInstanceBaseAddr; |
| 557 | } |
| 558 | ResourceParams.pdwCmd = & (cmd.DW8.Value); |
| 559 | ResourceParams.dwLocationInCmd = 8; |
| 560 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 561 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 562 | |
| 563 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 564 | pOsInterface, |
| 565 | pCmdBuffer, |
| 566 | &ResourceParams)); |
| 567 | |
| 568 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, m_veboxSettings.uiVertexTableSize); |
| 569 | |
| 570 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 571 | if (bUseCmBuffer) |
| 572 | { |
| 573 | ResourceParams.presResource = pVeboxParamResource; |
| 574 | ResourceParams.dwOffset = pVeboxHeap->uiCapturePipeStateOffset; |
| 575 | } |
| 576 | else |
| 577 | { |
| 578 | ResourceParams.presResource = pVeboxHeapResource; |
| 579 | ResourceParams.dwOffset = pVeboxHeap->uiCapturePipeStateOffset + uiInstanceBaseAddr; |
| 580 | } |
| 581 | ResourceParams.pdwCmd = & (cmd.DW10.Value); |
| 582 | ResourceParams.dwLocationInCmd = 10; |
| 583 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 584 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 585 | |
| 586 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 587 | pOsInterface, |
| 588 | pCmdBuffer, |
| 589 | &ResourceParams)); |
| 590 | |
| 591 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, m_veboxSettings.uiCapturePipeStateSize); |
| 592 | |
| 593 | if (pVeboxStateCmdParams->pLaceLookUpTables) |
| 594 | { |
| 595 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 596 | ResourceParams.presResource = pVeboxStateCmdParams->pLaceLookUpTables; |
| 597 | ResourceParams.dwOffset = 0; |
| 598 | ResourceParams.pdwCmd = & (cmd.DW12.Value); |
| 599 | ResourceParams.dwLocationInCmd = 12; |
| 600 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 601 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 602 | |
| 603 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 604 | pOsInterface, |
| 605 | pCmdBuffer, |
| 606 | &ResourceParams)); |
| 607 | } |
| 608 | |
| 609 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 610 | if (bUseCmBuffer) |
| 611 | { |
| 612 | ResourceParams.presResource = pVeboxParamResource; |
| 613 | ResourceParams.dwOffset = pVeboxHeap->uiGammaCorrectionStateOffset; |
| 614 | } |
| 615 | else |
| 616 | { |
| 617 | ResourceParams.presResource = pVeboxHeapResource; |
| 618 | ResourceParams.dwOffset = pVeboxHeap->uiGammaCorrectionStateOffset + uiInstanceBaseAddr; |
| 619 | } |
| 620 | ResourceParams.pdwCmd = & (cmd.DW14_15.Value[0]); |
| 621 | ResourceParams.dwLocationInCmd = 14; |
| 622 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 623 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 624 | |
| 625 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 626 | pOsInterface, |
| 627 | pCmdBuffer, |
| 628 | &ResourceParams)); |
| 629 | |
| 630 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, m_veboxSettings.uiGammaCorrectionStateSize); |
| 631 | } |
| 632 | else |
| 633 | { |
| 634 | // Allocate Resource to avoid Page Fault issue since HW will access it |
| 635 | if (Mos_ResourceIsNull(&pVeboxStateCmdParams->DummyIecpResource)) |
| 636 | { |
| 637 | MOS_ZeroMemory(&AllocParamsForBufferLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS)); |
| 638 | |
| 639 | AllocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER; |
| 640 | AllocParamsForBufferLinear.TileType = MOS_TILE_LINEAR; |
| 641 | AllocParamsForBufferLinear.Format = Format_Buffer; |
| 642 | AllocParamsForBufferLinear.dwBytes = m_veboxSettings.uiIecpStateSize; |
| 643 | AllocParamsForBufferLinear.pBufName = "DummyIecpResource"; |
| 644 | |
| 645 | MHW_CHK_STATUS(pOsInterface->pfnAllocateResource( |
| 646 | pOsInterface, |
| 647 | &AllocParamsForBufferLinear, |
| 648 | &pVeboxStateCmdParams->DummyIecpResource)); |
| 649 | } |
| 650 | |
| 651 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 652 | ResourceParams.presResource = &pVeboxStateCmdParams->DummyIecpResource; |
| 653 | ResourceParams.dwOffset = 0; |
| 654 | ResourceParams.pdwCmd = &(cmd.DW4.Value); |
| 655 | ResourceParams.dwLocationInCmd = 4; |
| 656 | ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 657 | ResourceParams.dwSharedMocsOffset = 1 - ResourceParams.dwLocationInCmd; |
| 658 | |
| 659 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 660 | pOsInterface, |
| 661 | pCmdBuffer, |
| 662 | &ResourceParams)); |
| 663 | |
| 664 | HalOcaInterface::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, 0, true, 0); |
| 665 | } |
| 666 | |
| 667 | cmd.DW1.ColorGamutExpansionEnable = pVeboxMode->ColorGamutExpansionEnable; |
| 668 | cmd.DW1.ColorGamutCompressionEnable = pVeboxMode->ColorGamutCompressionEnable; |
| 669 | cmd.DW1.GlobalIecpEnable = pVeboxMode->GlobalIECPEnable; |
| 670 | cmd.DW1.DnEnable = pVeboxMode->DNEnable; |
| 671 | cmd.DW1.DiEnable = pVeboxMode->DIEnable; |
| 672 | cmd.DW1.DnDiFirstFrame = pVeboxMode->DNDIFirstFrame; |
| 673 | cmd.DW1.DiOutputFrames = pVeboxMode->DIOutputFrames; |
| 674 | cmd.DW1.DemosaicEnable = pVeboxMode->DemosaicEnable; |
| 675 | cmd.DW1.VignetteEnable = pVeboxMode->VignetteEnable; |
| 676 | cmd.DW1.AlphaPlaneEnable = pVeboxMode->AlphaPlaneEnable; |
| 677 | cmd.DW1.HotPixelFilteringEnable = pVeboxMode->HotPixelFilteringEnable; |
| 678 | cmd.DW1.SingleSliceVeboxEnable = pVeboxMode->SingleSliceVeboxEnable; |
| 679 | cmd.DW1.LaceCorrectionEnable = pVeboxMode->LACECorrectionEnable; |
| 680 | cmd.DW1.DisableEncoderStatistics = pVeboxMode->DisableEncoderStatistics; |
| 681 | cmd.DW1.DisableTemporalDenoiseFilter = pVeboxMode->DisableTemporalDenoiseFilter; |
| 682 | cmd.DW1.SinglePipeEnable = pVeboxMode->SinglePipeIECPEnable; |
| 683 | cmd.DW1.ForwardGammaCorrectionEnable = pVeboxMode->ForwardGammaCorrectionEnable; |
| 684 | |
| 685 | pOsInterface->pfnAddCommand(pCmdBuffer, &cmd, cmd.byteSize); |
| 686 | |
| 687 | finish: |
| 688 | return eStatus; |
| 689 | } |
| 690 | |
| 691 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxGamutState( |
| 692 | PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, |
| 693 | PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams) |
| 694 | |
| 695 | { |
| 696 | PMHW_VEBOX_HEAP pVeboxHeap; |
| 697 | uint32_t uiOffset; |
| 698 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 699 | |
| 700 | mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *pIecpState, IecpStateCmd; |
| 701 | mhw_vebox_g9_X::VEBOX_GAMUT_STATE_CMD *pGamutState, gamutCmd; |
| 702 | MHW_CHK_NULL(pVeboxGamutParams); |
| 703 | MHW_CHK_NULL(m_veboxHeap); |
| 704 | |
| 705 | pVeboxHeap = m_veboxHeap; |
| 706 | uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 707 | |
| 708 | pIecpState = |
| 709 | (mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 710 | pVeboxHeap->uiIecpStateOffset + |
| 711 | uiOffset); |
| 712 | pGamutState = |
| 713 | (mhw_vebox_g9_X::VEBOX_GAMUT_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 714 | pVeboxHeap->uiGamutStateOffset + |
| 715 | uiOffset); |
| 716 | |
| 717 | MHW_CHK_NULL(pIecpState); |
| 718 | MHW_CHK_NULL(pGamutState); |
| 719 | |
| 720 | // Must initialize VeboxIecpState even if it is not used because GCE |
| 721 | // requires GlobalIECP enable bit to be turned on |
| 722 | if (!pVeboxIecpParams) |
| 723 | { |
| 724 | *pIecpState = IecpStateCmd; |
| 725 | } |
| 726 | // Initializte the GammatSate; |
| 727 | GamutStateInitialization(pGamutState); |
| 728 | |
| 729 | if (pVeboxGamutParams->GCompMode != MHW_GAMUT_MODE_NONE) |
| 730 | { |
| 731 | if (pVeboxGamutParams->GCompMode == MHW_GAMUT_MODE_BASIC) |
| 732 | { |
| 733 | pGamutState->DW35.Fullrangemappingenable = false; |
| 734 | |
| 735 | if (pVeboxGamutParams->GCompBasicMode == gamutCmd.GCC_BASICMODESELECTION_SCALINGFACTOR) |
| 736 | { |
| 737 | pGamutState->DW37.GccBasicmodeselection = gamutCmd.GCC_BASICMODESELECTION_SCALINGFACTOR; |
| 738 | pGamutState->DW37.Basicmodescalingfactor = |
| 739 | pVeboxGamutParams->iBasicModeScalingFactor; |
| 740 | } |
| 741 | } |
| 742 | else if (pVeboxGamutParams->GCompMode == MHW_GAMUT_MODE_ADVANCED) |
| 743 | { |
| 744 | pGamutState->DW35.Fullrangemappingenable = true; |
| 745 | pGamutState->DW35.D1Out = pVeboxGamutParams->iDout; |
| 746 | pGamutState->DW35.DOutDefault = pVeboxGamutParams->iDoutDefault; |
| 747 | pGamutState->DW35.DInDefault = pVeboxGamutParams->iDinDefault; |
| 748 | pGamutState->DW36.D1In = pVeboxGamutParams->iDin; |
| 749 | } |
| 750 | |
| 751 | // Set Vertex Table if Gamut Compression is enabled |
| 752 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::AddVeboxVertexTable(pVeboxGamutParams->ColorSpace); |
| 753 | } |
| 754 | |
| 755 | if (pVeboxGamutParams->GExpMode != MHW_GAMUT_MODE_NONE) |
| 756 | { |
| 757 | // Need to convert YUV input to RGB before GE |
| 758 | pIecpState->CscState.DW0.TransformEnable = true; |
| 759 | if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601 || |
| 760 | pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC601 || |
| 761 | pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601_FullRange) |
| 762 | { |
| 763 | pIecpState->CscState.DW0.C0 = 76309; |
| 764 | pIecpState->CscState.DW1.C1 = 0; |
| 765 | pIecpState->CscState.DW2.C2 = 104597; |
| 766 | pIecpState->CscState.DW3.C3 = 76309; |
| 767 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-25675, 19); |
| 768 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-53279, 19); |
| 769 | pIecpState->CscState.DW6.C6 = 76309; |
| 770 | pIecpState->CscState.DW7.C7 = 132201; |
| 771 | pIecpState->CscState.DW8.C8 = 0; |
| 772 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 773 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 774 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 775 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 776 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 777 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 778 | } |
| 779 | else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709 || |
| 780 | pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC709 || |
| 781 | pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709_FullRange) |
| 782 | { |
| 783 | pIecpState->CscState.DW0.C0 = 76309; |
| 784 | pIecpState->CscState.DW1.C1 = 0; |
| 785 | pIecpState->CscState.DW2.C2 = 117489; |
| 786 | pIecpState->CscState.DW3.C3 = 76309; |
| 787 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-13975, 19); |
| 788 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-34925, 19); |
| 789 | pIecpState->CscState.DW6.C6 = 76309; |
| 790 | pIecpState->CscState.DW7.C7 = 138438; |
| 791 | pIecpState->CscState.DW8.C8 = 0; |
| 792 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 793 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 794 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 795 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 796 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 797 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 798 | } |
| 799 | else |
| 800 | { |
| 801 | MHW_ASSERTMESSAGE("Unknown primary"); |
| 802 | } |
| 803 | |
| 804 | if (pVeboxGamutParams->GExpMode == MHW_GAMUT_MODE_BASIC) |
| 805 | { |
| 806 | pGamutState->DW0.GlobalModeEnable = true; |
| 807 | pGamutState->DW0.CmW = 1023; // Colorimetric accurate image |
| 808 | } |
| 809 | else if (pVeboxGamutParams->GExpMode == MHW_GAMUT_MODE_ADVANCED) |
| 810 | { |
| 811 | pGamutState->DW0.GlobalModeEnable = false; |
| 812 | } |
| 813 | |
| 814 | pGamutState->DW3.C0 = pVeboxGamutParams->Matrix[0][0]; |
| 815 | pGamutState->DW3.C1 = pVeboxGamutParams->Matrix[0][1]; |
| 816 | pGamutState->DW4.C2 = pVeboxGamutParams->Matrix[0][2]; |
| 817 | pGamutState->DW4.C3 = pVeboxGamutParams->Matrix[1][0]; |
| 818 | pGamutState->DW5.C4 = pVeboxGamutParams->Matrix[1][1]; |
| 819 | pGamutState->DW5.C5 = pVeboxGamutParams->Matrix[1][2]; |
| 820 | pGamutState->DW6.C6 = pVeboxGamutParams->Matrix[2][0]; |
| 821 | pGamutState->DW6.C7 = pVeboxGamutParams->Matrix[2][1]; |
| 822 | pGamutState->DW7.C8 = pVeboxGamutParams->Matrix[2][2]; |
| 823 | } |
| 824 | else if (pVeboxGamutParams->bGammaCorr) |
| 825 | { |
| 826 | // Need to convert YUV input to RGB before Gamma Correction |
| 827 | pIecpState->CscState.DW0.TransformEnable = true; |
| 828 | if (IS_RGB_SWAP(pVeboxGamutParams->dstFormat)) |
| 829 | { |
| 830 | pIecpState->CscState.DW0.YuvChannelSwap = true; |
| 831 | } |
| 832 | if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601 || |
| 833 | pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC601 || |
| 834 | pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601_FullRange) |
| 835 | { |
| 836 | pIecpState->CscState.DW0.C0 = 76309; |
| 837 | pIecpState->CscState.DW1.C1 = 0; |
| 838 | pIecpState->CscState.DW2.C2 = 104597; |
| 839 | pIecpState->CscState.DW3.C3 = 76309; |
| 840 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-25675, 19); |
| 841 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-53279, 19); |
| 842 | pIecpState->CscState.DW6.C6 = 76309; |
| 843 | pIecpState->CscState.DW7.C7 = 132201; |
| 844 | pIecpState->CscState.DW8.C8 = 0; |
| 845 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 846 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 847 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 848 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 849 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 850 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 851 | } |
| 852 | else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709 || |
| 853 | pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC709 || |
| 854 | pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709_FullRange) |
| 855 | { |
| 856 | pIecpState->CscState.DW0.C0 = 76309; |
| 857 | pIecpState->CscState.DW1.C1 = 0; |
| 858 | pIecpState->CscState.DW2.C2 = 117489; |
| 859 | pIecpState->CscState.DW3.C3 = 76309; |
| 860 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-13975, 19); |
| 861 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-34925, 19); |
| 862 | pIecpState->CscState.DW6.C6 = 76309; |
| 863 | pIecpState->CscState.DW7.C7 = 138438; |
| 864 | pIecpState->CscState.DW8.C8 = 0; |
| 865 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 866 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 867 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 868 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 869 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 870 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 871 | } |
| 872 | else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020) |
| 873 | { |
| 874 | pIecpState->CscState.DW0.C0 = 76309; |
| 875 | pIecpState->CscState.DW1.C1 = 0; |
| 876 | pIecpState->CscState.DW2.C2 = 110014; |
| 877 | pIecpState->CscState.DW3.C3 = 76309; |
| 878 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-12277, 19); |
| 879 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-42626, 19); |
| 880 | pIecpState->CscState.DW6.C6 = 76309; |
| 881 | pIecpState->CscState.DW7.C7 = 140363; |
| 882 | pIecpState->CscState.DW8.C8 = 0; |
| 883 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 884 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 885 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 886 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 887 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 888 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 889 | } |
| 890 | else |
| 891 | { |
| 892 | MHW_ASSERTMESSAGE("Unknown primary"); |
| 893 | } |
| 894 | |
| 895 | pGamutState->DW0.GlobalModeEnable = true; |
| 896 | pGamutState->DW0.CmW = 1023; |
| 897 | if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020) |
| 898 | { |
| 899 | if (pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT709) |
| 900 | { |
| 901 | pGamutState->DW3.C0 = 6762; |
| 902 | pGamutState->DW3.C1 = MOS_BITFIELD_VALUE((uint32_t)-2393, 15); |
| 903 | pGamutState->DW4.C2 = MOS_BITFIELD_VALUE((uint32_t)-297, 15); |
| 904 | pGamutState->DW4.C3 = MOS_BITFIELD_VALUE((uint32_t)-498, 15); |
| 905 | pGamutState->DW5.C4 = 4636; |
| 906 | pGamutState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-35, 15); |
| 907 | pGamutState->DW6.C6 = MOS_BITFIELD_VALUE((uint32_t)-75, 15); |
| 908 | pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-412, 15); |
| 909 | pGamutState->DW7.C8 = 4583; |
| 910 | } |
| 911 | else |
| 912 | { |
| 913 | pGamutState->DW3.C0 = 7276; |
| 914 | pGamutState->DW3.C1 = MOS_BITFIELD_VALUE((uint32_t)-2818, 15); |
| 915 | pGamutState->DW4.C2 = MOS_BITFIELD_VALUE((uint32_t)-362, 15); |
| 916 | pGamutState->DW4.C3 = MOS_BITFIELD_VALUE((uint32_t)-662, 15); |
| 917 | pGamutState->DW5.C4 = 4863; |
| 918 | pGamutState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-107, 15); |
| 919 | pGamutState->DW6.C6 = MOS_BITFIELD_VALUE((uint32_t)-65, 15); |
| 920 | pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-393, 15); |
| 921 | pGamutState->DW7.C8 = 4554; |
| 922 | } |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | pGamutState->DW3.C0 = 4096; |
| 927 | pGamutState->DW3.C1 = 0; |
| 928 | pGamutState->DW4.C2 = 0; |
| 929 | pGamutState->DW4.C3 = 0; |
| 930 | pGamutState->DW5.C4 = 4096; |
| 931 | pGamutState->DW5.C5 = 0; |
| 932 | pGamutState->DW6.C6 = 0; |
| 933 | pGamutState->DW6.C7 = 0; |
| 934 | pGamutState->DW7.C8 = 4096; |
| 935 | pGamutState->DW32.OffsetInR = 0; |
| 936 | pGamutState->DW32.OffsetInG = 0; |
| 937 | pGamutState->DW33.OffsetInB = 0; |
| 938 | pGamutState->DW33.OffsetOutB = 0; |
| 939 | pGamutState->DW34.OffsetOutR = 0; |
| 940 | pGamutState->DW34.OffsetOutG = 0; |
| 941 | } |
| 942 | |
| 943 | if (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_1P0) |
| 944 | { |
| 945 | pGamutState->DW20.PwlInvGammaPoint1 = 21; |
| 946 | pGamutState->DW20.PwlInvGammaPoint2 = 43; |
| 947 | pGamutState->DW20.PwlInvGammaPoint3 = 64; |
| 948 | pGamutState->DW20.PwlInvGammaPoint4 = 85; |
| 949 | pGamutState->DW21.PwlInvGammaPoint5 = 106; |
| 950 | pGamutState->DW21.PwlInvGammaPoint6 = 128; |
| 951 | pGamutState->DW21.PwlInvGammaPoint7 = 149; |
| 952 | pGamutState->DW21.PwlInvGammaPoint8 = 170; |
| 953 | pGamutState->DW22.PwlInvGammaPoint9 = 191; |
| 954 | pGamutState->DW22.PwlInvGammaPoint10 = 213; |
| 955 | pGamutState->DW22.PwlInvGammaPoint11 = 234; |
| 956 | pGamutState->DW23.PwlInvGammaBias1 = 21; |
| 957 | pGamutState->DW23.PwlInvGammaBias2 = 43; |
| 958 | pGamutState->DW23.PwlInvGammaBias3 = 64; |
| 959 | pGamutState->DW23.PwlInvGammaBias4 = 85; |
| 960 | pGamutState->DW24.PwlInvGammaBias5 = 106; |
| 961 | pGamutState->DW24.PwlInvGammaBias6 = 128; |
| 962 | pGamutState->DW24.PwlInvGammaBias7 = 149; |
| 963 | pGamutState->DW24.PwlInvGammaBias8 = 170; |
| 964 | pGamutState->DW25.PwlInvGammaBias9 = 191; |
| 965 | pGamutState->DW25.PwlInvGammaBias10 = 213; |
| 966 | pGamutState->DW25.PwlInvGammaBias11 = 234; |
| 967 | pGamutState->DW26.PwlInvGammaSlope0 = 256; |
| 968 | pGamutState->DW26.PwlInvGammaSlope1 = 256; |
| 969 | pGamutState->DW27.PwlInvGammaSlope2 = 256; |
| 970 | pGamutState->DW27.PwlInvGammaSlope3 = 256; |
| 971 | pGamutState->DW28.PwlInvGammaSlope4 = 256; |
| 972 | pGamutState->DW28.PwlInvGammaSlope5 = 256; |
| 973 | pGamutState->DW29.PwlInvGammaSlope6 = 256; |
| 974 | pGamutState->DW29.PwlInvGammaSlope7 = 256; |
| 975 | pGamutState->DW30.PwlInvGammaSlope8 = 256; |
| 976 | pGamutState->DW30.PwlInvGammaSlope9 = 256; |
| 977 | pGamutState->DW31.PwlInvGammaSlope10 = 256; |
| 978 | pGamutState->DW31.PwlInvGammaSlope11 = 256; |
| 979 | } |
| 980 | else if (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_2P2) |
| 981 | { |
| 982 | pGamutState->DW20.PwlInvGammaPoint1 = 40; |
| 983 | pGamutState->DW20.PwlInvGammaPoint2 = 56; |
| 984 | pGamutState->DW20.PwlInvGammaPoint3 = 80; |
| 985 | pGamutState->DW20.PwlInvGammaPoint4 = 104; |
| 986 | pGamutState->DW21.PwlInvGammaPoint5 = 128; |
| 987 | pGamutState->DW21.PwlInvGammaPoint6 = 149; |
| 988 | pGamutState->DW21.PwlInvGammaPoint7 = 170; |
| 989 | pGamutState->DW21.PwlInvGammaPoint8 = 191; |
| 990 | pGamutState->DW22.PwlInvGammaPoint9 = 207; |
| 991 | pGamutState->DW22.PwlInvGammaPoint10 = 223; |
| 992 | pGamutState->DW22.PwlInvGammaPoint11 = 239; |
| 993 | pGamutState->DW23.PwlInvGammaBias1 = 4; |
| 994 | pGamutState->DW23.PwlInvGammaBias2 = 9; |
| 995 | pGamutState->DW23.PwlInvGammaBias3 = 20; |
| 996 | pGamutState->DW23.PwlInvGammaBias4 = 35; |
| 997 | pGamutState->DW24.PwlInvGammaBias5 = 55; |
| 998 | pGamutState->DW24.PwlInvGammaBias6 = 78; |
| 999 | pGamutState->DW24.PwlInvGammaBias7 = 105; |
| 1000 | pGamutState->DW24.PwlInvGammaBias8 = 135; |
| 1001 | pGamutState->DW25.PwlInvGammaBias9 = 161; |
| 1002 | pGamutState->DW25.PwlInvGammaBias10 = 190; |
| 1003 | pGamutState->DW25.PwlInvGammaBias11 = 221; |
| 1004 | pGamutState->DW26.PwlInvGammaSlope0 = 28; |
| 1005 | pGamutState->DW26.PwlInvGammaSlope1 = 76; |
| 1006 | pGamutState->DW27.PwlInvGammaSlope2 = 115; |
| 1007 | pGamutState->DW27.PwlInvGammaSlope3 = 165; |
| 1008 | pGamutState->DW28.PwlInvGammaSlope4 = 218; |
| 1009 | pGamutState->DW28.PwlInvGammaSlope5 = 270; |
| 1010 | pGamutState->DW29.PwlInvGammaSlope6 = 320; |
| 1011 | pGamutState->DW29.PwlInvGammaSlope7 = 372; |
| 1012 | pGamutState->DW30.PwlInvGammaSlope8 = 419; |
| 1013 | pGamutState->DW30.PwlInvGammaSlope9 = 459; |
| 1014 | pGamutState->DW31.PwlInvGammaSlope10 = 500; |
| 1015 | pGamutState->DW31.PwlInvGammaSlope11 = 542; |
| 1016 | } |
| 1017 | else if (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_2P6) |
| 1018 | { |
| 1019 | pGamutState->DW20.PwlInvGammaPoint1 = 40; |
| 1020 | pGamutState->DW20.PwlInvGammaPoint2 = 56; |
| 1021 | pGamutState->DW20.PwlInvGammaPoint3 = 80; |
| 1022 | pGamutState->DW20.PwlInvGammaPoint4 = 104; |
| 1023 | pGamutState->DW21.PwlInvGammaPoint5 = 128; |
| 1024 | pGamutState->DW21.PwlInvGammaPoint6 = 149; |
| 1025 | pGamutState->DW21.PwlInvGammaPoint7 = 170; |
| 1026 | pGamutState->DW21.PwlInvGammaPoint8 = 191; |
| 1027 | pGamutState->DW22.PwlInvGammaPoint9 = 207; |
| 1028 | pGamutState->DW22.PwlInvGammaPoint10 = 223; |
| 1029 | pGamutState->DW22.PwlInvGammaPoint11 = 239; |
| 1030 | pGamutState->DW23.PwlInvGammaBias1 = 2; |
| 1031 | pGamutState->DW23.PwlInvGammaBias2 = 5; |
| 1032 | pGamutState->DW23.PwlInvGammaBias3 = 12; |
| 1033 | pGamutState->DW23.PwlInvGammaBias4 = 25; |
| 1034 | pGamutState->DW24.PwlInvGammaBias5 = 42; |
| 1035 | pGamutState->DW24.PwlInvGammaBias6 = 63; |
| 1036 | pGamutState->DW24.PwlInvGammaBias7 = 89; |
| 1037 | pGamutState->DW24.PwlInvGammaBias8 = 121; |
| 1038 | pGamutState->DW25.PwlInvGammaBias9 = 149; |
| 1039 | pGamutState->DW25.PwlInvGammaBias10 = 180; |
| 1040 | pGamutState->DW25.PwlInvGammaBias11 = 216; |
| 1041 | pGamutState->DW26.PwlInvGammaSlope0 = 13; |
| 1042 | pGamutState->DW26.PwlInvGammaSlope1 = 46; |
| 1043 | pGamutState->DW27.PwlInvGammaSlope2 = 80; |
| 1044 | pGamutState->DW27.PwlInvGammaSlope3 = 130; |
| 1045 | pGamutState->DW28.PwlInvGammaSlope4 = 188; |
| 1046 | pGamutState->DW28.PwlInvGammaSlope5 = 250; |
| 1047 | pGamutState->DW29.PwlInvGammaSlope6 = 314; |
| 1048 | pGamutState->DW29.PwlInvGammaSlope7 = 384; |
| 1049 | pGamutState->DW30.PwlInvGammaSlope8 = 449; |
| 1050 | pGamutState->DW30.PwlInvGammaSlope9 = 507; |
| 1051 | pGamutState->DW31.PwlInvGammaSlope10 = 569; |
| 1052 | pGamutState->DW31.PwlInvGammaSlope11 = 633; |
| 1053 | } |
| 1054 | else |
| 1055 | { |
| 1056 | MHW_ASSERTMESSAGE("Unknown InputGammaValue"); |
| 1057 | } |
| 1058 | |
| 1059 | if (pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_1P0) |
| 1060 | { |
| 1061 | pGamutState->DW8.PwlGammaPoint1 = 21; |
| 1062 | pGamutState->DW8.PwlGammaPoint2 = 43; |
| 1063 | pGamutState->DW8.PwlGammaPoint3 = 64; |
| 1064 | pGamutState->DW8.PwlGammaPoint4 = 85; |
| 1065 | pGamutState->DW9.PwlGammaPoint5 = 106; |
| 1066 | pGamutState->DW9.PwlGammaPoint6 = 128; |
| 1067 | pGamutState->DW9.PwlGammaPoint7 = 149; |
| 1068 | pGamutState->DW9.PwlGammaPoint8 = 170; |
| 1069 | pGamutState->DW10.PwlGammaPoint9 = 191; |
| 1070 | pGamutState->DW10.PwlGammaPoint10 = 213; |
| 1071 | pGamutState->DW10.PwlGammaPoint11 = 234; |
| 1072 | pGamutState->DW11.PwlGammaBias1 = 21; |
| 1073 | pGamutState->DW11.PwlGammaBias2 = 43; |
| 1074 | pGamutState->DW11.PwlGammaBias3 = 64; |
| 1075 | pGamutState->DW11.PwlGammaBias4 = 85; |
| 1076 | pGamutState->DW12.PwlGammaBias5 = 106; |
| 1077 | pGamutState->DW12.PwlGammaBias6 = 128; |
| 1078 | pGamutState->DW12.PwlGammaBias7 = 149; |
| 1079 | pGamutState->DW12.PwlGammaBias8 = 170; |
| 1080 | pGamutState->DW13.PwlGammaBias9 = 191; |
| 1081 | pGamutState->DW13.PwlGammaBias10 = 213; |
| 1082 | pGamutState->DW13.PwlGammaBias11 = 234; |
| 1083 | pGamutState->DW14.PwlGammaSlope0 = 256; |
| 1084 | pGamutState->DW14.PwlGammaSlope1 = 256; |
| 1085 | pGamutState->DW15.PwlGammaSlope2 = 256; |
| 1086 | pGamutState->DW15.PwlGammaSlope3 = 256; |
| 1087 | pGamutState->DW16.PwlGammaSlope4 = 256; |
| 1088 | pGamutState->DW16.PwlGammaSlope5 = 256; |
| 1089 | pGamutState->DW17.PwlGammaSlope6 = 256; |
| 1090 | pGamutState->DW17.PwlGammaSlope7 = 256; |
| 1091 | pGamutState->DW18.PwlGammaSlope8 = 256; |
| 1092 | pGamutState->DW18.PwlGammaSlope9 = 256; |
| 1093 | pGamutState->DW19.PwlGammaSlope10 = 256; |
| 1094 | pGamutState->DW19.PwlGammaSlope11 = 256; |
| 1095 | } |
| 1096 | else if (pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_2P2) |
| 1097 | { |
| 1098 | pGamutState->DW8.PwlGammaPoint1 = 4; |
| 1099 | pGamutState->DW8.PwlGammaPoint2 = 10; |
| 1100 | pGamutState->DW8.PwlGammaPoint3 = 16; |
| 1101 | pGamutState->DW8.PwlGammaPoint4 = 27; |
| 1102 | pGamutState->DW9.PwlGammaPoint5 = 44; |
| 1103 | pGamutState->DW9.PwlGammaPoint6 = 64; |
| 1104 | pGamutState->DW9.PwlGammaPoint7 = 96; |
| 1105 | pGamutState->DW9.PwlGammaPoint8 = 128; |
| 1106 | pGamutState->DW10.PwlGammaPoint9 = 159; |
| 1107 | pGamutState->DW10.PwlGammaPoint10 = 191; |
| 1108 | pGamutState->DW10.PwlGammaPoint11 = 223; |
| 1109 | pGamutState->DW11.PwlGammaBias1 = 39; |
| 1110 | pGamutState->DW11.PwlGammaBias2 = 58; |
| 1111 | pGamutState->DW11.PwlGammaBias3 = 72; |
| 1112 | pGamutState->DW11.PwlGammaBias4 = 91; |
| 1113 | pGamutState->DW12.PwlGammaBias5 = 115; |
| 1114 | pGamutState->DW12.PwlGammaBias6 = 136; |
| 1115 | pGamutState->DW12.PwlGammaBias7 = 163; |
| 1116 | pGamutState->DW12.PwlGammaBias8 = 186; |
| 1117 | pGamutState->DW13.PwlGammaBias9 = 206; |
| 1118 | pGamutState->DW13.PwlGammaBias10 = 224; |
| 1119 | pGamutState->DW13.PwlGammaBias11 = 240; |
| 1120 | pGamutState->DW14.PwlGammaSlope0 = 255; |
| 1121 | pGamutState->DW14.PwlGammaSlope1 = 2474; |
| 1122 | pGamutState->DW15.PwlGammaSlope2 = 852; |
| 1123 | pGamutState->DW15.PwlGammaSlope3 = 596; |
| 1124 | pGamutState->DW16.PwlGammaSlope4 = 455; |
| 1125 | pGamutState->DW16.PwlGammaSlope5 = 345; |
| 1126 | pGamutState->DW17.PwlGammaSlope6 = 273; |
| 1127 | pGamutState->DW17.PwlGammaSlope7 = 221; |
| 1128 | pGamutState->DW18.PwlGammaSlope8 = 183; |
| 1129 | pGamutState->DW18.PwlGammaSlope9 = 160; |
| 1130 | pGamutState->DW19.PwlGammaSlope10 = 143; |
| 1131 | pGamutState->DW19.PwlGammaSlope11 = 130; |
| 1132 | } |
| 1133 | else if (pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_2P6) |
| 1134 | { |
| 1135 | pGamutState->DW8.PwlGammaPoint1 = 4; |
| 1136 | pGamutState->DW8.PwlGammaPoint2 = 10; |
| 1137 | pGamutState->DW8.PwlGammaPoint3 = 16; |
| 1138 | pGamutState->DW8.PwlGammaPoint4 = 27; |
| 1139 | pGamutState->DW9.PwlGammaPoint5 = 44; |
| 1140 | pGamutState->DW9.PwlGammaPoint6 = 64; |
| 1141 | pGamutState->DW9.PwlGammaPoint7 = 96; |
| 1142 | pGamutState->DW9.PwlGammaPoint8 = 128; |
| 1143 | pGamutState->DW10.PwlGammaPoint9 = 159; |
| 1144 | pGamutState->DW10.PwlGammaPoint10 = 191; |
| 1145 | pGamutState->DW10.PwlGammaPoint11 = 223; |
| 1146 | pGamutState->DW11.PwlGammaBias1 = 52; |
| 1147 | pGamutState->DW11.PwlGammaBias2 = 73; |
| 1148 | pGamutState->DW11.PwlGammaBias3 = 88; |
| 1149 | pGamutState->DW11.PwlGammaBias4 = 107; |
| 1150 | pGamutState->DW12.PwlGammaBias5 = 130; |
| 1151 | pGamutState->DW12.PwlGammaBias6 = 150; |
| 1152 | pGamutState->DW12.PwlGammaBias7 = 175; |
| 1153 | pGamutState->DW12.PwlGammaBias8 = 195; |
| 1154 | pGamutState->DW13.PwlGammaBias9 = 213; |
| 1155 | pGamutState->DW13.PwlGammaBias10 = 228; |
| 1156 | pGamutState->DW13.PwlGammaBias11 = 242; |
| 1157 | pGamutState->DW14.PwlGammaSlope0 = 3309; |
| 1158 | pGamutState->DW14.PwlGammaSlope1 = 932; |
| 1159 | pGamutState->DW15.PwlGammaSlope2 = 622; |
| 1160 | pGamutState->DW15.PwlGammaSlope3 = 459; |
| 1161 | pGamutState->DW16.PwlGammaSlope4 = 335; |
| 1162 | pGamutState->DW16.PwlGammaSlope5 = 257; |
| 1163 | pGamutState->DW17.PwlGammaSlope6 = 203; |
| 1164 | pGamutState->DW17.PwlGammaSlope7 = 164; |
| 1165 | pGamutState->DW18.PwlGammaSlope8 = 141; |
| 1166 | pGamutState->DW18.PwlGammaSlope9 = 124; |
| 1167 | pGamutState->DW19.PwlGammaSlope10 = 112; |
| 1168 | pGamutState->DW19.PwlGammaSlope11 = 103; |
| 1169 | } |
| 1170 | else |
| 1171 | { |
| 1172 | MHW_ASSERTMESSAGE("Unknown OutputGammaValue"); |
| 1173 | } |
| 1174 | } |
| 1175 | else if ((pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020 || |
| 1176 | (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020_FullRange)) && // Need to refine |
| 1177 | pVeboxGamutParams->dstColorSpace != MHW_CSpace_BT2020_RGB && // BT2020 CSC case |
| 1178 | pVeboxGamutParams->dstColorSpace != MHW_CSpace_BT2020_stRGB) |
| 1179 | { |
| 1180 | // Gamut Expansion setting |
| 1181 | pGamutState->DW0.GlobalModeEnable = true; |
| 1182 | pGamutState->DW0.CmW = 1023; // Colorimetric accurate image |
| 1183 | |
| 1184 | if (pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT709) |
| 1185 | { |
| 1186 | pGamutState->DW3.C0 = 6762; |
| 1187 | pGamutState->DW3.C1 = MOS_BITFIELD_VALUE((uint32_t)-2393, 15); |
| 1188 | pGamutState->DW4.C2 = MOS_BITFIELD_VALUE((uint32_t)-297, 15); |
| 1189 | pGamutState->DW4.C3 = MOS_BITFIELD_VALUE((uint32_t)-498, 15); |
| 1190 | pGamutState->DW5.C4 = 4636; |
| 1191 | pGamutState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-35, 15); |
| 1192 | pGamutState->DW6.C6 = MOS_BITFIELD_VALUE((uint32_t)-75, 15); |
| 1193 | pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-412, 15); |
| 1194 | pGamutState->DW7.C8 = 4583; |
| 1195 | } |
| 1196 | else |
| 1197 | { |
| 1198 | pGamutState->DW3.C0 = 7276; |
| 1199 | pGamutState->DW3.C1 = MOS_BITFIELD_VALUE((uint32_t)-2818, 15); |
| 1200 | pGamutState->DW4.C2 = MOS_BITFIELD_VALUE((uint32_t)-362, 15); |
| 1201 | pGamutState->DW4.C3 = MOS_BITFIELD_VALUE((uint32_t)-662, 15); |
| 1202 | pGamutState->DW5.C4 = 4863; |
| 1203 | pGamutState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-107, 15); |
| 1204 | pGamutState->DW6.C6 = MOS_BITFIELD_VALUE((uint32_t)-65, 15); |
| 1205 | pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-393, 15); |
| 1206 | pGamutState->DW7.C8 = 4554; |
| 1207 | } |
| 1208 | |
| 1209 | pGamutState->DW8.PwlGammaPoint1 = 5; |
| 1210 | pGamutState->DW8.PwlGammaPoint2 = 27; |
| 1211 | pGamutState->DW8.PwlGammaPoint3 = 50; |
| 1212 | pGamutState->DW8.PwlGammaPoint4 = 73; |
| 1213 | pGamutState->DW9.PwlGammaPoint5 = 96; |
| 1214 | pGamutState->DW9.PwlGammaPoint6 = 118; |
| 1215 | pGamutState->DW9.PwlGammaPoint7 = 141; |
| 1216 | pGamutState->DW9.PwlGammaPoint8 = 164; |
| 1217 | pGamutState->DW10.PwlGammaPoint9 = 187; |
| 1218 | pGamutState->DW10.PwlGammaPoint10 = 209; |
| 1219 | pGamutState->DW10.PwlGammaPoint11 = 232; |
| 1220 | |
| 1221 | pGamutState->DW11.PwlGammaBias1 = 21; |
| 1222 | pGamutState->DW11.PwlGammaBias2 = 77; |
| 1223 | pGamutState->DW11.PwlGammaBias3 = 110; |
| 1224 | pGamutState->DW11.PwlGammaBias4 = 134; |
| 1225 | pGamutState->DW12.PwlGammaBias5 = 155; |
| 1226 | pGamutState->DW12.PwlGammaBias6 = 173; |
| 1227 | pGamutState->DW12.PwlGammaBias7 = 190; |
| 1228 | pGamutState->DW12.PwlGammaBias8 = 204; |
| 1229 | pGamutState->DW13.PwlGammaBias9 = 218; |
| 1230 | pGamutState->DW13.PwlGammaBias10 = 231; |
| 1231 | pGamutState->DW13.PwlGammaBias11 = 243; |
| 1232 | |
| 1233 | pGamutState->DW14.PwlGammaSlope0 = 1156; |
| 1234 | pGamutState->DW14.PwlGammaSlope1 = 637; |
| 1235 | pGamutState->DW15.PwlGammaSlope2 = 361; |
| 1236 | pGamutState->DW15.PwlGammaSlope3 = 278; |
| 1237 | pGamutState->DW16.PwlGammaSlope4 = 233; |
| 1238 | pGamutState->DW16.PwlGammaSlope5 = 204; |
| 1239 | pGamutState->DW17.PwlGammaSlope6 = 184; |
| 1240 | pGamutState->DW17.PwlGammaSlope7 = 168; |
| 1241 | pGamutState->DW18.PwlGammaSlope8 = 156; |
| 1242 | pGamutState->DW18.PwlGammaSlope9 = 146; |
| 1243 | pGamutState->DW19.PwlGammaSlope10 = 137; |
| 1244 | pGamutState->DW19.PwlGammaSlope11 = 130; |
| 1245 | |
| 1246 | pGamutState->DW20.PwlInvGammaPoint1 = 21; |
| 1247 | pGamutState->DW20.PwlInvGammaPoint2 = 42; |
| 1248 | pGamutState->DW20.PwlInvGammaPoint3 = 63; |
| 1249 | pGamutState->DW20.PwlInvGammaPoint4 = 85; |
| 1250 | pGamutState->DW21.PwlInvGammaPoint5 = 106; |
| 1251 | pGamutState->DW21.PwlInvGammaPoint6 = 127; |
| 1252 | pGamutState->DW21.PwlInvGammaPoint7 = 148; |
| 1253 | pGamutState->DW21.PwlInvGammaPoint8 = 170; |
| 1254 | pGamutState->DW22.PwlInvGammaPoint9 = 191; |
| 1255 | pGamutState->DW22.PwlInvGammaPoint10 = 212; |
| 1256 | pGamutState->DW22.PwlInvGammaPoint11 = 234; |
| 1257 | |
| 1258 | pGamutState->DW23.PwlInvGammaBias1 = 5; |
| 1259 | pGamutState->DW23.PwlInvGammaBias2 = 11; |
| 1260 | pGamutState->DW23.PwlInvGammaBias3 = 20; |
| 1261 | pGamutState->DW23.PwlInvGammaBias4 = 32; |
| 1262 | pGamutState->DW24.PwlInvGammaBias5 = 47; |
| 1263 | pGamutState->DW24.PwlInvGammaBias6 = 66; |
| 1264 | pGamutState->DW24.PwlInvGammaBias7 = 88; |
| 1265 | pGamutState->DW24.PwlInvGammaBias8 = 114; |
| 1266 | pGamutState->DW25.PwlInvGammaBias9 = 143; |
| 1267 | pGamutState->DW25.PwlInvGammaBias10 = 177; |
| 1268 | pGamutState->DW25.PwlInvGammaBias11 = 214; |
| 1269 | |
| 1270 | pGamutState->DW26.PwlInvGammaSlope0 = 57; |
| 1271 | pGamutState->DW26.PwlInvGammaSlope1 = 73; |
| 1272 | pGamutState->DW27.PwlInvGammaSlope2 = 108; |
| 1273 | pGamutState->DW27.PwlInvGammaSlope3 = 145; |
| 1274 | pGamutState->DW28.PwlInvGammaSlope4 = 185; |
| 1275 | pGamutState->DW28.PwlInvGammaSlope5 = 225; |
| 1276 | pGamutState->DW29.PwlInvGammaSlope6 = 267; |
| 1277 | pGamutState->DW29.PwlInvGammaSlope7 = 310; |
| 1278 | pGamutState->DW30.PwlInvGammaSlope8 = 355; |
| 1279 | pGamutState->DW30.PwlInvGammaSlope9 = 400; |
| 1280 | pGamutState->DW31.PwlInvGammaSlope10 = 446; |
| 1281 | pGamutState->DW31.PwlInvGammaSlope11 = 494; |
| 1282 | |
| 1283 | pGamutState->DW32.OffsetInR = 0; |
| 1284 | pGamutState->DW32.OffsetInG = 0; |
| 1285 | pGamutState->DW33.OffsetInB = 0; |
| 1286 | pGamutState->DW33.OffsetOutB = 0; |
| 1287 | pGamutState->DW34.OffsetOutG = 0; |
| 1288 | pGamutState->DW34.OffsetOutR = 0; |
| 1289 | |
| 1290 | // Back end CSC setting |
| 1291 | // Need to convert BT2020 YUV input to RGB before GE |
| 1292 | pIecpState->CscState.DW0.TransformEnable = true; |
| 1293 | |
| 1294 | if (IS_RGB_SWAP(pVeboxGamutParams->dstFormat)) |
| 1295 | { |
| 1296 | pIecpState->CscState.DW0.YuvChannelSwap = true; |
| 1297 | } |
| 1298 | |
| 1299 | pIecpState->CscState.DW0.C0 = 76309; |
| 1300 | pIecpState->CscState.DW1.C1 = 0; |
| 1301 | pIecpState->CscState.DW2.C2 = 110014; |
| 1302 | pIecpState->CscState.DW3.C3 = 76309; |
| 1303 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-12277, 19); |
| 1304 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-42626, 19); |
| 1305 | pIecpState->CscState.DW6.C6 = 76309; |
| 1306 | pIecpState->CscState.DW7.C7 = 140363; |
| 1307 | pIecpState->CscState.DW8.C8 = 0; |
| 1308 | |
| 1309 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 1310 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1311 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1312 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 1313 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 1314 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 1315 | } |
| 1316 | else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020 && |
| 1317 | (pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT2020_RGB || |
| 1318 | pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT2020_stRGB)) // BT2020 YUV to BT2020 RGB CSC |
| 1319 | { |
| 1320 | // Back end CSC setting |
| 1321 | // Convert BT2020 YUV input to BT2020 RGB |
| 1322 | pIecpState->CscState.DW0.TransformEnable = true; |
| 1323 | |
| 1324 | if (IS_RGB_SWAP(pVeboxGamutParams->dstFormat)) |
| 1325 | { |
| 1326 | pIecpState->CscState.DW0.YuvChannelSwap = true; |
| 1327 | } |
| 1328 | |
| 1329 | if (pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT2020_stRGB) |
| 1330 | { |
| 1331 | pIecpState->CscState.DW0.C0 = 65536; |
| 1332 | pIecpState->CscState.DW1.C1 = 0; |
| 1333 | pIecpState->CscState.DW2.C2 = 94482; |
| 1334 | pIecpState->CscState.DW3.C3 = 65536; |
| 1335 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-10543, 19); |
| 1336 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-36608, 19); |
| 1337 | pIecpState->CscState.DW6.C6 = 65536; |
| 1338 | pIecpState->CscState.DW7.C7 = 120547; |
| 1339 | pIecpState->CscState.DW8.C8 = 0; |
| 1340 | |
| 1341 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 1342 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1343 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1344 | |
| 1345 | pIecpState->CscState.DW9.OffsetOut1 = 2048; |
| 1346 | pIecpState->CscState.DW10.OffsetOut2 = 2048; |
| 1347 | pIecpState->CscState.DW11.OffsetOut3 = 2048; |
| 1348 | } |
| 1349 | else |
| 1350 | { |
| 1351 | pIecpState->CscState.DW0.C0 = 76309; |
| 1352 | pIecpState->CscState.DW1.C1 = 0; |
| 1353 | pIecpState->CscState.DW2.C2 = 110014; |
| 1354 | pIecpState->CscState.DW3.C3 = 76309; |
| 1355 | pIecpState->CscState.DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-12277, 19); |
| 1356 | pIecpState->CscState.DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-42626, 19); |
| 1357 | pIecpState->CscState.DW6.C6 = 76309; |
| 1358 | pIecpState->CscState.DW7.C7 = 140363; |
| 1359 | pIecpState->CscState.DW8.C8 = 0; |
| 1360 | |
| 1361 | pIecpState->CscState.DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 1362 | pIecpState->CscState.DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1363 | pIecpState->CscState.DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1364 | |
| 1365 | pIecpState->CscState.DW9.OffsetOut1 = 0; |
| 1366 | pIecpState->CscState.DW10.OffsetOut2 = 0; |
| 1367 | pIecpState->CscState.DW11.OffsetOut3 = 0; |
| 1368 | } |
| 1369 | } |
| 1370 | else |
| 1371 | { |
| 1372 | MHW_ASSERTMESSAGE("Unknown Handled ColorSpace"); |
| 1373 | } |
| 1374 | |
| 1375 | finish: |
| 1376 | return eStatus; |
| 1377 | } |
| 1378 | |
| 1379 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxIecpAceState( |
| 1380 | PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) |
| 1381 | { |
| 1382 | PMHW_ACE_PARAMS pAceParams; |
| 1383 | PMHW_LACE_PARAMS pLaceParams; |
| 1384 | PMHW_VEBOX_HEAP pVeboxHeap; |
| 1385 | int32_t uiOffset; |
| 1386 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1387 | |
| 1388 | mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState; |
| 1389 | |
| 1390 | MHW_CHK_NULL(pVeboxIecpParams); |
| 1391 | MHW_CHK_NULL(m_veboxHeap); |
| 1392 | |
| 1393 | pVeboxHeap = m_veboxHeap; |
| 1394 | uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 1395 | |
| 1396 | pVeboxIecpState = (mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 1397 | pVeboxHeap->uiIecpStateOffset + |
| 1398 | uiOffset); |
| 1399 | MHW_CHK_NULL(pVeboxIecpState); |
| 1400 | |
| 1401 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::SetVeboxAceLaceState(pVeboxIecpParams, pVeboxIecpState); |
| 1402 | |
| 1403 | if (pVeboxIecpParams->ColorPipeParams.bActive && |
| 1404 | pVeboxIecpParams->ColorPipeParams.bEnableLACE) |
| 1405 | { |
| 1406 | pLaceParams = &pVeboxIecpParams->ColorPipeParams.LaceParams; |
| 1407 | |
| 1408 | pVeboxIecpState->AceState.DW0.MinAceLuma = pLaceParams->wMinAceLuma; |
| 1409 | pVeboxIecpState->AceState.DW12.MaxAceLuma = pLaceParams->wMaxAceLuma; |
| 1410 | } |
| 1411 | |
| 1412 | finish: |
| 1413 | return eStatus; |
| 1414 | } |
| 1415 | |
| 1416 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxDiIecp( |
| 1417 | PMOS_COMMAND_BUFFER pCmdBuffer, |
| 1418 | PMHW_VEBOX_DI_IECP_CMD_PARAMS pVeboxDiIecpCmdParams) |
| 1419 | { |
| 1420 | MOS_STATUS eStatus; |
| 1421 | PMOS_INTERFACE pOsInterface; |
| 1422 | MHW_RESOURCE_PARAMS ResourceParams; |
| 1423 | mhw_vebox_g9_X::VEB_DI_IECP_CMD cmd; |
| 1424 | |
| 1425 | MHW_CHK_NULL(m_osInterface); |
| 1426 | MHW_CHK_NULL(pCmdBuffer); |
| 1427 | MHW_CHK_NULL(pVeboxDiIecpCmdParams); |
| 1428 | MHW_ASSERT(MOS_IS_ALIGNED(pVeboxDiIecpCmdParams->dwCurrInputSurfOffset, MHW_PAGE_SIZE)); // offset should be aligned with 4KB |
| 1429 | MHW_ASSERT(MOS_IS_ALIGNED(pVeboxDiIecpCmdParams->dwPrevInputSurfOffset, MHW_PAGE_SIZE)); // offset should be aligned with 4KB |
| 1430 | |
| 1431 | // Initialize |
| 1432 | eStatus = MOS_STATUS_SUCCESS; |
| 1433 | pOsInterface = m_osInterface; |
| 1434 | |
| 1435 | if (pVeboxDiIecpCmdParams->pOsResCurrInput) |
| 1436 | { |
| 1437 | cmd.DW2.CurrentFrameSurfaceControlBitsMemoryCompressionEnable = |
| 1438 | (pVeboxDiIecpCmdParams->CurInputSurfMMCState != MOS_MEMCOMP_DISABLED) ? 1 : 0; |
| 1439 | cmd.DW2.CurrentFrameSurfaceControlBitsMemoryCompressionMode = |
| 1440 | (pVeboxDiIecpCmdParams->CurInputSurfMMCState == MOS_MEMCOMP_HORIZONTAL) ? 0 : 1; |
| 1441 | |
| 1442 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1443 | ResourceParams.dwLsbNum = MHW_VEBOX_DI_IECP_SHIFT; |
| 1444 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResCurrInput; |
| 1445 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->dwCurrInputSurfOffset; |
| 1446 | ResourceParams.pdwCmd = & (cmd.DW2.Value); |
| 1447 | ResourceParams.dwLocationInCmd = 2; |
| 1448 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1449 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1450 | pOsInterface, |
| 1451 | pCmdBuffer, |
| 1452 | &ResourceParams)); |
| 1453 | } |
| 1454 | |
| 1455 | // Remove this after VPHAL moving to new cmd definition --- assign MOCS/MMC bits directly |
| 1456 | if (pVeboxDiIecpCmdParams->CurInputSurfMMCState == 0) |
| 1457 | { |
| 1458 | // bit 0 ~ 10 is MOCS/MMC bits |
| 1459 | cmd.DW2.Value = (cmd.DW2.Value & 0xFFFFF800) + pVeboxDiIecpCmdParams->CurrInputSurfCtrl.Value; |
| 1460 | } |
| 1461 | |
| 1462 | if (pVeboxDiIecpCmdParams->pOsResPrevInput) |
| 1463 | { |
| 1464 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1465 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResPrevInput; |
| 1466 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->PrevInputSurfCtrl.Value + pVeboxDiIecpCmdParams->dwPrevInputSurfOffset; |
| 1467 | ResourceParams.pdwCmd = & (cmd.DW4.Value); |
| 1468 | ResourceParams.dwLocationInCmd = 4; |
| 1469 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1470 | |
| 1471 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1472 | pOsInterface, |
| 1473 | pCmdBuffer, |
| 1474 | &ResourceParams)); |
| 1475 | } |
| 1476 | |
| 1477 | if (pVeboxDiIecpCmdParams->pOsResStmmInput) |
| 1478 | { |
| 1479 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1480 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResStmmInput; |
| 1481 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->StmmInputSurfCtrl.Value; |
| 1482 | ResourceParams.pdwCmd = & (cmd.DW6.Value); |
| 1483 | ResourceParams.dwLocationInCmd = 6; |
| 1484 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1485 | |
| 1486 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1487 | pOsInterface, |
| 1488 | pCmdBuffer, |
| 1489 | &ResourceParams)); |
| 1490 | } |
| 1491 | |
| 1492 | if (pVeboxDiIecpCmdParams->pOsResStmmOutput) |
| 1493 | { |
| 1494 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1495 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResStmmOutput; |
| 1496 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->StmmOutputSurfCtrl.Value; |
| 1497 | ResourceParams.pdwCmd = & (cmd.DW8.Value); |
| 1498 | ResourceParams.dwLocationInCmd = 8; |
| 1499 | ResourceParams.bIsWritable = true; |
| 1500 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1501 | |
| 1502 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1503 | pOsInterface, |
| 1504 | pCmdBuffer, |
| 1505 | &ResourceParams)); |
| 1506 | } |
| 1507 | |
| 1508 | if (pVeboxDiIecpCmdParams->pOsResDenoisedCurrOutput) |
| 1509 | { |
| 1510 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1511 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResDenoisedCurrOutput; |
| 1512 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->DenoisedCurrOutputSurfCtrl.Value; |
| 1513 | ResourceParams.pdwCmd = & (cmd.DW10.Value); |
| 1514 | ResourceParams.dwLocationInCmd = 10; |
| 1515 | ResourceParams.bIsWritable = true; |
| 1516 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1517 | |
| 1518 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1519 | pOsInterface, |
| 1520 | pCmdBuffer, |
| 1521 | &ResourceParams)); |
| 1522 | } |
| 1523 | |
| 1524 | if (pVeboxDiIecpCmdParams->pOsResCurrOutput) |
| 1525 | { |
| 1526 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1527 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResCurrOutput; |
| 1528 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->CurrOutputSurfCtrl.Value + pVeboxDiIecpCmdParams->dwCurrOutputSurfOffset; |
| 1529 | ResourceParams.pdwCmd = & (cmd.DW12.Value); |
| 1530 | ResourceParams.dwLocationInCmd = 12; |
| 1531 | ResourceParams.bIsWritable = true; |
| 1532 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1533 | |
| 1534 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1535 | pOsInterface, |
| 1536 | pCmdBuffer, |
| 1537 | &ResourceParams)); |
| 1538 | } |
| 1539 | |
| 1540 | if (pVeboxDiIecpCmdParams->pOsResPrevOutput) |
| 1541 | { |
| 1542 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1543 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResPrevOutput; |
| 1544 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->PrevOutputSurfCtrl.Value; |
| 1545 | ResourceParams.pdwCmd = & (cmd.DW14.Value); |
| 1546 | ResourceParams.dwLocationInCmd = 14; |
| 1547 | ResourceParams.bIsWritable = true; |
| 1548 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1549 | |
| 1550 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1551 | pOsInterface, |
| 1552 | pCmdBuffer, |
| 1553 | &ResourceParams)); |
| 1554 | } |
| 1555 | |
| 1556 | if (pVeboxDiIecpCmdParams->pOsResStatisticsOutput) |
| 1557 | { |
| 1558 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1559 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResStatisticsOutput; |
| 1560 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->StatisticsOutputSurfCtrl.Value; |
| 1561 | ResourceParams.pdwCmd = & (cmd.DW16.Value); |
| 1562 | ResourceParams.dwLocationInCmd = 16; |
| 1563 | ResourceParams.bIsWritable = true; |
| 1564 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1565 | |
| 1566 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1567 | pOsInterface, |
| 1568 | pCmdBuffer, |
| 1569 | &ResourceParams)); |
| 1570 | } |
| 1571 | |
| 1572 | if (pVeboxDiIecpCmdParams->pOsResAlphaOrVignette) |
| 1573 | { |
| 1574 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1575 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResAlphaOrVignette; |
| 1576 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->AlphaOrVignetteSurfCtrl.Value; |
| 1577 | ResourceParams.pdwCmd = & (cmd.DW18.Value); |
| 1578 | ResourceParams.dwLocationInCmd = 18; |
| 1579 | ResourceParams.bIsWritable = true; |
| 1580 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1581 | |
| 1582 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1583 | pOsInterface, |
| 1584 | pCmdBuffer, |
| 1585 | &ResourceParams)); |
| 1586 | } |
| 1587 | |
| 1588 | if (pVeboxDiIecpCmdParams->pOsResLaceOrAceOrRgbHistogram) |
| 1589 | { |
| 1590 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1591 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResLaceOrAceOrRgbHistogram; |
| 1592 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->LaceOrAceOrRgbHistogramSurfCtrl.Value; |
| 1593 | ResourceParams.pdwCmd = & (cmd.DW20.Value); |
| 1594 | ResourceParams.dwLocationInCmd = 20; |
| 1595 | ResourceParams.bIsWritable = true; |
| 1596 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1597 | |
| 1598 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1599 | pOsInterface, |
| 1600 | pCmdBuffer, |
| 1601 | &ResourceParams)); |
| 1602 | } |
| 1603 | |
| 1604 | if (pVeboxDiIecpCmdParams->pOsResSkinScoreSurface) |
| 1605 | { |
| 1606 | MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 1607 | ResourceParams.presResource = pVeboxDiIecpCmdParams->pOsResSkinScoreSurface; |
| 1608 | ResourceParams.dwOffset = pVeboxDiIecpCmdParams->SkinScoreSurfaceSurfCtrl.Value; |
| 1609 | ResourceParams.pdwCmd = & (cmd.DW22.Value); |
| 1610 | ResourceParams.dwLocationInCmd = 22; |
| 1611 | ResourceParams.bIsWritable = true; |
| 1612 | ResourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 1613 | |
| 1614 | MHW_CHK_STATUS(pfnAddResourceToCmd( |
| 1615 | pOsInterface, |
| 1616 | pCmdBuffer, |
| 1617 | &ResourceParams)); |
| 1618 | } |
| 1619 | |
| 1620 | cmd.DW1.EndingX = pVeboxDiIecpCmdParams->dwEndingX; |
| 1621 | cmd.DW1.StartingX = pVeboxDiIecpCmdParams->dwStartingX; |
| 1622 | |
| 1623 | pOsInterface->pfnAddCommand(pCmdBuffer, &cmd, cmd.byteSize); |
| 1624 | |
| 1625 | finish: |
| 1626 | return eStatus; |
| 1627 | } |
| 1628 | |
| 1629 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxDndiState( |
| 1630 | PMHW_VEBOX_DNDI_PARAMS pVeboxDndiParams) |
| 1631 | { |
| 1632 | PMHW_VEBOX_HEAP pVeboxHeap; |
| 1633 | uint32_t uiOffset; |
| 1634 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1635 | |
| 1636 | mhw_vebox_g9_X::VEBOX_DNDI_STATE_CMD *pVeboxDndiState, DndiStateCmd; |
| 1637 | |
| 1638 | MHW_CHK_NULL(pVeboxDndiParams); |
| 1639 | MHW_CHK_NULL(m_veboxHeap); |
| 1640 | |
| 1641 | pVeboxHeap = m_veboxHeap; |
| 1642 | uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 1643 | pVeboxDndiState = |
| 1644 | (mhw_vebox_g9_X::VEBOX_DNDI_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 1645 | pVeboxHeap->uiDndiStateOffset + |
| 1646 | uiOffset); |
| 1647 | MHW_CHK_NULL(pVeboxDndiState); |
| 1648 | *pVeboxDndiState = DndiStateCmd; |
| 1649 | |
| 1650 | pVeboxDndiState->DW0.DenoiseMovingPixelThreshold = |
| 1651 | pVeboxDndiParams->dwDenoiseMPThreshold; |
| 1652 | pVeboxDndiState->DW0.DenoiseHistoryIncrease = |
| 1653 | pVeboxDndiParams->dwDenoiseHistoryDelta; |
| 1654 | pVeboxDndiState->DW0.DenoiseMaximumHistory = |
| 1655 | pVeboxDndiParams->dwDenoiseMaximumHistory; |
| 1656 | pVeboxDndiState->DW0.DenoiseStadThreshold = |
| 1657 | pVeboxDndiParams->dwDenoiseSTADThreshold; |
| 1658 | pVeboxDndiState->DW1.DenoiseAsdThreshold = |
| 1659 | pVeboxDndiParams->dwDenoiseASDThreshold; |
| 1660 | pVeboxDndiState->DW1.LowTemporalDifferenceThreshold = |
| 1661 | pVeboxDndiParams->dwLTDThreshold; |
| 1662 | pVeboxDndiState->DW1.TemporalDifferenceThreshold = |
| 1663 | pVeboxDndiParams->dwTDThreshold; |
| 1664 | pVeboxDndiState->DW2.DenoiseThresholdForSumOfComplexityMeasure = |
| 1665 | pVeboxDndiParams->dwDenoiseSCMThreshold; |
| 1666 | pVeboxDndiState->DW2.ProgressiveDn = |
| 1667 | pVeboxDndiParams->bProgressiveDN; |
| 1668 | |
| 1669 | //DW5 to DW11 for new 5x5 spatial denoise filter on Gen9 |
| 1670 | pVeboxDndiState->DW5.DnWr0 = |
| 1671 | pVeboxDndiParams->dwPixRangeWeight[0]; |
| 1672 | pVeboxDndiState->DW5.DnWr1 = |
| 1673 | pVeboxDndiParams->dwPixRangeWeight[1]; |
| 1674 | pVeboxDndiState->DW5.DnWr2 = |
| 1675 | pVeboxDndiParams->dwPixRangeWeight[2]; |
| 1676 | pVeboxDndiState->DW5.DnWr3 = |
| 1677 | pVeboxDndiParams->dwPixRangeWeight[3]; |
| 1678 | pVeboxDndiState->DW5.DnWr4 = |
| 1679 | pVeboxDndiParams->dwPixRangeWeight[4]; |
| 1680 | pVeboxDndiState->DW5.DnWr5 = |
| 1681 | pVeboxDndiParams->dwPixRangeWeight[5]; |
| 1682 | |
| 1683 | pVeboxDndiState->DW7.DnPrt5 = |
| 1684 | pVeboxDndiParams->dwPixRangeThreshold[5]; |
| 1685 | pVeboxDndiState->DW8.DnPrt4 = |
| 1686 | pVeboxDndiParams->dwPixRangeThreshold[4]; |
| 1687 | pVeboxDndiState->DW8.DnPrt3 = |
| 1688 | pVeboxDndiParams->dwPixRangeThreshold[3]; |
| 1689 | pVeboxDndiState->DW9.DnPrt2 = |
| 1690 | pVeboxDndiParams->dwPixRangeThreshold[2]; |
| 1691 | pVeboxDndiState->DW9.DnPrt1 = |
| 1692 | pVeboxDndiParams->dwPixRangeThreshold[1]; |
| 1693 | pVeboxDndiState->DW10.DnPrt0 = |
| 1694 | pVeboxDndiParams->dwPixRangeThreshold[0]; |
| 1695 | |
| 1696 | pVeboxDndiState->DW16.DnDiTopFirst = |
| 1697 | pVeboxDndiParams->bDNDITopFirst; |
| 1698 | |
| 1699 | pVeboxDndiState->DW17.ProgressiveCadenceReconstructionFor1StFieldOfCurrentFrame = |
| 1700 | pVeboxDndiParams->dwFMDFirstFieldCurrFrame; |
| 1701 | pVeboxDndiState->DW17.ProgressiveCadenceReconstructionFor2NdFieldOfPreviousFrame = |
| 1702 | pVeboxDndiParams->dwFMDSecondFieldPrevFrame; |
| 1703 | |
| 1704 | // Chroma Denoise |
| 1705 | pVeboxDndiState->DW4.ChromaLowTemporalDifferenceThreshold = |
| 1706 | pVeboxDndiParams->dwChromaLTDThreshold; |
| 1707 | pVeboxDndiState->DW4.ChromaTemporalDifferenceThreshold = |
| 1708 | pVeboxDndiParams->dwChromaTDThreshold; |
| 1709 | pVeboxDndiState->DW4.ChromaDenoiseStadThreshold = |
| 1710 | pVeboxDndiParams->dwChromaSTADThreshold; |
| 1711 | pVeboxDndiState->DW4.ChromaDenoiseEnable = |
| 1712 | pVeboxDndiParams->bChromaDNEnable; |
| 1713 | |
| 1714 | // Hot Pixel |
| 1715 | pVeboxDndiState->DW3.HotPixelThreshold = |
| 1716 | pVeboxDndiParams->dwHotPixelThreshold; |
| 1717 | pVeboxDndiState->DW3.HotPixelCount = |
| 1718 | pVeboxDndiParams->dwHotPixelCount; |
| 1719 | |
| 1720 | pVeboxDndiState->DW3.BlockNoiseEstimateNoiseThreshold = ABSMAXABSMIN_THRESHOLD_DEFAULT_G9; |
| 1721 | |
| 1722 | pVeboxDndiState->DW6.DnThmin = 512; |
| 1723 | pVeboxDndiState->DW6.DnThmax = 2048; |
| 1724 | |
| 1725 | pVeboxDndiState->DW7.DnDynThmin = 256; |
| 1726 | |
| 1727 | pVeboxDndiState->DW10.DnWd20 = 10; |
| 1728 | pVeboxDndiState->DW10.DnWd21 = 10; |
| 1729 | pVeboxDndiState->DW10.DnWd22 = 8; |
| 1730 | pVeboxDndiState->DW11.DnWd00 = 12; |
| 1731 | pVeboxDndiState->DW11.DnWd01 = 12; |
| 1732 | pVeboxDndiState->DW11.DnWd02 = 10; |
| 1733 | pVeboxDndiState->DW11.DnWd10 = 12; |
| 1734 | pVeboxDndiState->DW11.DnWd11 = 11; |
| 1735 | pVeboxDndiState->DW11.DnWd12 = 10; |
| 1736 | |
| 1737 | pVeboxDndiState->DW12.StmmC2 = 2; |
| 1738 | |
| 1739 | pVeboxDndiState->DW13.MaximumStmm = 150; |
| 1740 | pVeboxDndiState->DW13.MultiplierForVecm = 30; |
| 1741 | pVeboxDndiState->DW13.BlendingConstantAcrossTimeForSmallValuesOfStmm = 125; |
| 1742 | pVeboxDndiState->DW13.BlendingConstantAcrossTimeForLargeValuesOfStmm = 64; |
| 1743 | |
| 1744 | pVeboxDndiState->DW14.SdiDelta = 5; |
| 1745 | pVeboxDndiState->DW14.SdiThreshold = 100; |
| 1746 | pVeboxDndiState->DW14.StmmOutputShift = 5; |
| 1747 | pVeboxDndiState->DW14.StmmShiftUp = 1; |
| 1748 | pVeboxDndiState->DW14.MinimumStmm = 118; |
| 1749 | |
| 1750 | pVeboxDndiState->DW15.FmdTemporalDifferenceThreshold = 175; |
| 1751 | pVeboxDndiState->DW15.SdiFallbackMode2ConstantAngle2X1 = 37; |
| 1752 | pVeboxDndiState->DW15.SdiFallbackMode1T2Constant = 100; |
| 1753 | pVeboxDndiState->DW15.SdiFallbackMode1T1Constant = 50; |
| 1754 | |
| 1755 | pVeboxDndiState->DW16.McdiEnable = 1; |
| 1756 | pVeboxDndiState->DW16.FmdTearThreshold = 2; |
| 1757 | pVeboxDndiState->DW16.Fmd2VerticalDifferenceThreshold = 100; |
| 1758 | pVeboxDndiState->DW16.Fmd1VerticalDifferenceThreshold = 16; |
| 1759 | |
| 1760 | finish: |
| 1761 | return eStatus; |
| 1762 | } |
| 1763 | |
| 1764 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxIecpState( |
| 1765 | PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) |
| 1766 | { |
| 1767 | bool bEnableFECSC = false; |
| 1768 | bool bEnableLACE = false; |
| 1769 | PMHW_FORWARD_GAMMA_SEG pFwdGammaSeg; |
| 1770 | PMHW_VEBOX_HEAP pVeboxHeap; |
| 1771 | uint32_t uiOffset; |
| 1772 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1773 | mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState, IecpState; |
| 1774 | |
| 1775 | MHW_CHK_NULL(pVeboxIecpParams); |
| 1776 | MHW_CHK_NULL(m_veboxHeap); |
| 1777 | |
| 1778 | pVeboxHeap = m_veboxHeap; |
| 1779 | uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 1780 | pVeboxIecpState = (mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 1781 | pVeboxHeap->uiIecpStateOffset + |
| 1782 | uiOffset); |
| 1783 | MHW_CHK_NULL(pVeboxIecpState); |
| 1784 | |
| 1785 | *pVeboxIecpState = IecpState; |
| 1786 | IecpStateInitialization(pVeboxIecpState); |
| 1787 | |
| 1788 | if (pVeboxIecpParams->ColorPipeParams.bActive) |
| 1789 | { |
| 1790 | // Enable STD/E (Skin Tone Detection/Enhancement) |
| 1791 | SetVeboxIecpStateSTE( |
| 1792 | &pVeboxIecpState->StdSteState, |
| 1793 | &pVeboxIecpParams->ColorPipeParams); |
| 1794 | |
| 1795 | // Enable ACE (Automatic Contrast Enhancement). Enable LACE if it's enabled. |
| 1796 | if (pVeboxIecpParams->ColorPipeParams.bEnableACE) |
| 1797 | { |
| 1798 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::SetVeboxIecpStateACELACE( |
| 1799 | &pVeboxIecpState->AceState, |
| 1800 | &pVeboxIecpState->AlphaAoiState, |
| 1801 | (pVeboxIecpParams->ColorPipeParams.bEnableLACE == true)? true : false); |
| 1802 | } |
| 1803 | |
| 1804 | // Enable TCC (Total Color Control) |
| 1805 | if (pVeboxIecpParams->ColorPipeParams.bEnableTCC) |
| 1806 | { |
| 1807 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::SetVeboxIecpStateTCC( |
| 1808 | &pVeboxIecpState->TccState, |
| 1809 | &pVeboxIecpParams->ColorPipeParams); |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | if (pVeboxIecpParams->CapPipeParams.bActive) |
| 1814 | { |
| 1815 | // IECP needs to operate in YUV space |
| 1816 | if ((pVeboxIecpParams->srcFormat != Format_AYUV) && |
| 1817 | (pVeboxIecpParams->dstFormat == Format_AYUV || |
| 1818 | pVeboxIecpParams->dstFormat == Format_Y416 || |
| 1819 | pVeboxIecpParams->ProcAmpParams.bActive || |
| 1820 | pVeboxIecpParams->ColorPipeParams.bActive)) |
| 1821 | { |
| 1822 | bEnableFECSC = true; |
| 1823 | } |
| 1824 | else if (pVeboxIecpParams->srcFormat == Format_A16B16G16R16 && |
| 1825 | (pVeboxIecpParams->ProcAmpParams.bActive || |
| 1826 | pVeboxIecpParams->ColorPipeParams.bActive)) |
| 1827 | { |
| 1828 | bEnableFECSC = true; |
| 1829 | } |
| 1830 | else if (pVeboxIecpParams->CapPipeParams.FECSCParams.bActive) |
| 1831 | { |
| 1832 | bEnableFECSC = true; |
| 1833 | } |
| 1834 | else |
| 1835 | { |
| 1836 | bEnableFECSC = false; |
| 1837 | } |
| 1838 | |
| 1839 | // Enable Front End CSC so that input to IECP will be in YUV color space |
| 1840 | if (bEnableFECSC) |
| 1841 | { |
| 1842 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::SetVeboxIecpStateFecsc(&pVeboxIecpState->FrontEndCsc, pVeboxIecpParams); |
| 1843 | } |
| 1844 | |
| 1845 | // Enable Color Correction Matrix |
| 1846 | if (pVeboxIecpParams->CapPipeParams.ColorCorrectionParams.bActive) |
| 1847 | { |
| 1848 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::SetVeboxIecpStateCcm( |
| 1849 | pVeboxIecpState, |
| 1850 | &pVeboxIecpParams->CapPipeParams, |
| 1851 | 4096); |
| 1852 | } |
| 1853 | } |
| 1854 | |
| 1855 | // Enable Back End CSC for capture pipeline or Vebox output pipe |
| 1856 | if (pVeboxIecpParams->CapPipeParams.bActive || |
| 1857 | pVeboxIecpParams->bCSCEnable) |
| 1858 | { |
| 1859 | SetVeboxIecpStateBecsc( |
| 1860 | pVeboxIecpState, |
| 1861 | pVeboxIecpParams, |
| 1862 | bEnableFECSC); |
| 1863 | } |
| 1864 | |
| 1865 | // Enable ProcAmp |
| 1866 | if (pVeboxIecpParams->ProcAmpParams.bActive && |
| 1867 | pVeboxIecpParams->ProcAmpParams.bEnabled) |
| 1868 | { |
| 1869 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::SetVeboxIecpStateProcAmp( |
| 1870 | &pVeboxIecpState->ProcampState, |
| 1871 | &pVeboxIecpParams->ProcAmpParams); |
| 1872 | } |
| 1873 | |
| 1874 | if (pVeboxIecpParams && pVeboxIecpParams->CapPipeParams.bActive) |
| 1875 | { |
| 1876 | MhwVeboxInterfaceGeneric<mhw_vebox_g9_X>::AddVeboxCapPipeState(&pVeboxIecpParams->CapPipeParams); |
| 1877 | } |
| 1878 | |
| 1879 | if (pVeboxIecpParams && |
| 1880 | pVeboxIecpParams->CapPipeParams.bActive && |
| 1881 | pVeboxIecpParams->CapPipeParams.FwdGammaParams.bActive) |
| 1882 | { |
| 1883 | pFwdGammaSeg = |
| 1884 | (PMHW_FORWARD_GAMMA_SEG)(pVeboxHeap->pLockedDriverResourceMem + |
| 1885 | pVeboxHeap->uiGammaCorrectionStateOffset + |
| 1886 | uiOffset); |
| 1887 | MHW_CHK_NULL(pFwdGammaSeg); |
| 1888 | MOS_SecureMemcpy( |
| 1889 | pFwdGammaSeg, |
| 1890 | sizeof(MHW_FORWARD_GAMMA_SEG) * MHW_FORWARD_GAMMA_SEGMENT_CONTROL_POINT_G9, |
| 1891 | &pVeboxIecpParams->CapPipeParams.FwdGammaParams.Segment[0], |
| 1892 | sizeof(MHW_FORWARD_GAMMA_SEG) * MHW_FORWARD_GAMMA_SEGMENT_CONTROL_POINT_G9); |
| 1893 | } |
| 1894 | |
| 1895 | finish: |
| 1896 | return eStatus; |
| 1897 | } |
| 1898 | |
| 1899 | MOS_STATUS MhwVeboxInterfaceG9::VeboxAdjustBoundary( |
| 1900 | PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam, |
| 1901 | uint32_t *pdwSurfaceWidth, |
| 1902 | uint32_t *pdwSurfaceHeight, |
| 1903 | bool bDIEnable) |
| 1904 | { |
| 1905 | uint16_t wWidthAlignUnit; |
| 1906 | uint16_t wHeightAlignUnit; |
| 1907 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 1908 | |
| 1909 | MHW_CHK_NULL(pSurfaceParam); |
| 1910 | MHW_CHK_NULL(pdwSurfaceWidth); |
| 1911 | MHW_CHK_NULL(pdwSurfaceHeight); |
| 1912 | |
| 1913 | // initialize |
| 1914 | wHeightAlignUnit = 1; |
| 1915 | wWidthAlignUnit = 1; |
| 1916 | |
| 1917 | switch (pSurfaceParam->Format) |
| 1918 | { |
| 1919 | case Format_NV12: |
| 1920 | wHeightAlignUnit = bDIEnable ? 4 : 2; |
| 1921 | wWidthAlignUnit = 2; |
| 1922 | break; |
| 1923 | |
| 1924 | case Format_YUYV: |
| 1925 | case Format_YUY2: |
| 1926 | case Format_UYVY: |
| 1927 | case Format_YVYU: |
| 1928 | case Format_VYUY: |
| 1929 | wHeightAlignUnit = bDIEnable ? 2 : 1; |
| 1930 | wWidthAlignUnit = 2; |
| 1931 | break; |
| 1932 | |
| 1933 | case Format_AYUV: |
| 1934 | case Format_Y416: |
| 1935 | wHeightAlignUnit = 1; |
| 1936 | wWidthAlignUnit = 2; |
| 1937 | break; |
| 1938 | |
| 1939 | // For other formats, we will not do any special alignment |
| 1940 | case Format_A8R8G8B8: |
| 1941 | case Format_X8R8G8B8: |
| 1942 | case Format_A8B8G8R8: |
| 1943 | case Format_X8B8G8R8: |
| 1944 | case Format_L8: |
| 1945 | default: |
| 1946 | break; |
| 1947 | } |
| 1948 | |
| 1949 | //When Crop being used in vebox, source surface height/width is updated in VeboxAdjustBoundary(), and the rcMaxSrc is used for crop rectangle. |
| 1950 | //But in dynamic Crop case, if the rcMaxSrc is larger than the rcSrc, the input pdwSurfaceHeight/pdwSurfaceWidth will be the input surface size. |
| 1951 | //And if the target surface size is smaller than input surface, it may lead to pagefault issue . So in Vebox Crop case, we set the pdwSurfaceHeight/pdwSurfaceWidth |
| 1952 | //with rcSrc to ensure Vebox input size is same with target Dstrec. |
| 1953 | if (pSurfaceParam->bVEBOXCroppingUsed) |
| 1954 | { |
| 1955 | *pdwSurfaceHeight = MOS_ALIGN_CEIL( |
| 1956 | MOS_MIN(pSurfaceParam->dwHeight, MOS_MAX((uint32_t)pSurfaceParam->rcSrc.bottom, MHW_VEBOX_MIN_HEIGHT)), |
| 1957 | wHeightAlignUnit); |
| 1958 | *pdwSurfaceWidth = MOS_ALIGN_CEIL( |
| 1959 | MOS_MIN(pSurfaceParam->dwWidth, MOS_MAX((uint32_t)pSurfaceParam->rcSrc.right, MHW_VEBOX_MIN_WIDTH)), |
| 1960 | wWidthAlignUnit); |
| 1961 | MHW_NORMALMESSAGE("bVEBOXCroppingUsed = true, pSurfaceParam->rcSrc.bottom: %d, pSurfaceParam->rcSrc.right: %d; pdwSurfaceHeight: %d, pdwSurfaceWidth: %d;", |
| 1962 | (uint32_t)pSurfaceParam->rcSrc.bottom, |
| 1963 | (uint32_t)pSurfaceParam->rcSrc.right, |
| 1964 | *pdwSurfaceHeight, |
| 1965 | *pdwSurfaceWidth); |
| 1966 | MT_LOG5(MT_VP_MHW_VE_ADJUST_SURFPARAM, MT_NORMAL, MT_VP_RENDER_VE_CROPPING, 1, MT_RECT_BOTTOM, pSurfaceParam->rcSrc.bottom, |
| 1967 | MT_RECT_RIGHT, pSurfaceParam->rcSrc.right, MT_SURF_HEIGHT, *pdwSurfaceHeight, MT_SURF_WIDTH, *pdwSurfaceWidth); |
| 1968 | } |
| 1969 | else |
| 1970 | { |
| 1971 | // Align width and height with max src renctange with consideration of |
| 1972 | // these conditions: |
| 1973 | // The minimum of width/height should equal to or larger than |
| 1974 | // MHW_VEBOX_MIN_WIDTH/HEIGHT. The maximum of width/heigh should equal |
| 1975 | // to or smaller than surface width/height |
| 1976 | *pdwSurfaceHeight = MOS_ALIGN_CEIL( |
| 1977 | MOS_MIN(pSurfaceParam->dwHeight, MOS_MAX((uint32_t)pSurfaceParam->rcMaxSrc.bottom, MHW_VEBOX_MIN_HEIGHT)), |
| 1978 | wHeightAlignUnit); |
| 1979 | *pdwSurfaceWidth = MOS_ALIGN_CEIL( |
| 1980 | MOS_MIN(pSurfaceParam->dwWidth, MOS_MAX((uint32_t)pSurfaceParam->rcMaxSrc.right, MHW_VEBOX_MIN_WIDTH)), |
| 1981 | wWidthAlignUnit); |
| 1982 | MHW_NORMALMESSAGE("bVEBOXCroppingUsed = false, pSurfaceParam->rcMaxSrc.bottom: %d, pSurfaceParam->rcMaxSrc.right: %d; pdwSurfaceHeight: %d, pdwSurfaceWidth: %d;", |
| 1983 | (uint32_t)pSurfaceParam->rcMaxSrc.bottom, |
| 1984 | (uint32_t)pSurfaceParam->rcMaxSrc.right, |
| 1985 | *pdwSurfaceHeight, |
| 1986 | *pdwSurfaceWidth); |
| 1987 | } |
| 1988 | |
| 1989 | |
| 1990 | finish: |
| 1991 | return eStatus; |
| 1992 | } |
| 1993 | |
| 1994 | void MhwVeboxInterfaceG9::IecpStateInitialization( |
| 1995 | mhw_vebox_g9_X::VEBOX_IECP_STATE_CMD *pVeboxIecpState) |
| 1996 | { |
| 1997 | MHW_CHK_NULL_NO_STATUS_RETURN(pVeboxIecpState); |
| 1998 | // Initialize the values to default for media driver. |
| 1999 | pVeboxIecpState->StdSteState.DW5.InvMarginVyl = 3300; |
| 2000 | pVeboxIecpState->StdSteState.DW5.InvSkinTypesMargin = 1638; |
| 2001 | |
| 2002 | pVeboxIecpState->StdSteState.DW12.B3U = 140; |
| 2003 | pVeboxIecpState->StdSteState.DW15.Satp1 = 122; |
| 2004 | pVeboxIecpState->StdSteState.DW15.Satb1 = 1016; |
| 2005 | pVeboxIecpState->StdSteState.DW19.Hueb1 = 1016; |
| 2006 | pVeboxIecpState->StdSteState.DW27.Hues0Dark = 256; |
| 2007 | pVeboxIecpState->StdSteState.DW27.Hues1Dark = 0; |
| 2008 | |
| 2009 | pVeboxIecpState->AceState.DW0.LaceHistogramSize = 1; |
| 2010 | |
| 2011 | pVeboxIecpState->TccState.DW0.Satfactor1 = 160; |
| 2012 | pVeboxIecpState->TccState.DW0.Satfactor2 = 160; |
| 2013 | pVeboxIecpState->TccState.DW0.Satfactor3 = 160; |
| 2014 | pVeboxIecpState->TccState.DW1.Satfactor4 = 160; |
| 2015 | pVeboxIecpState->TccState.DW1.Satfactor5 = 160; |
| 2016 | pVeboxIecpState->TccState.DW1.Satfactor6 = 160; |
| 2017 | |
| 2018 | pVeboxIecpState->AlphaAoiState.DW1.AoiMaxX = 0; |
| 2019 | pVeboxIecpState->AlphaAoiState.DW2.AoiMaxY = 0; |
| 2020 | |
| 2021 | return; |
| 2022 | } |
| 2023 | |
| 2024 | void MhwVeboxInterfaceG9::GamutStateInitialization( |
| 2025 | mhw_vebox_g9_X::VEBOX_GAMUT_STATE_CMD *pGamutState) |
| 2026 | { |
| 2027 | MHW_CHK_NULL_NO_STATUS_RETURN(pGamutState); |
| 2028 | |
| 2029 | mhw_vebox_g9_X::VEBOX_GAMUT_STATE_CMD cmd; |
| 2030 | *pGamutState = cmd; |
| 2031 | |
| 2032 | pGamutState->DW1.AB = 26; |
| 2033 | pGamutState->DW1.AG = 26; |
| 2034 | pGamutState->DW1.CmS = 640; |
| 2035 | |
| 2036 | pGamutState->DW2.RI = 128; |
| 2037 | pGamutState->DW2.CmI = 192; |
| 2038 | pGamutState->DW2.RS = 768; |
| 2039 | |
| 2040 | pGamutState->DW3.C0 = 2792; |
| 2041 | pGamutState->DW3.C1 = 1141; |
| 2042 | pGamutState->DW4.C2 = 34; |
| 2043 | pGamutState->DW4.C3 = 71; |
| 2044 | pGamutState->DW5.C4 = 3663; |
| 2045 | pGamutState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-52, 15); |
| 2046 | pGamutState->DW6.C6 = MOS_BITFIELD_VALUE((uint32_t)-12, 15); |
| 2047 | pGamutState->DW6.C7 = 168; |
| 2048 | pGamutState->DW7.C8 = 3434; |
| 2049 | |
| 2050 | pGamutState->DW14.PwlGammaSlope0 = 3328; |
| 2051 | pGamutState->DW14.PwlGammaSlope1 = 2560; |
| 2052 | pGamutState->DW15.PwlGammaSlope2 = 1280; |
| 2053 | pGamutState->DW15.PwlGammaSlope3 = 960; |
| 2054 | pGamutState->DW16.PwlGammaSlope4 = 658; |
| 2055 | pGamutState->DW16.PwlGammaSlope5 = 512; |
| 2056 | pGamutState->DW17.PwlGammaSlope6 = 368; |
| 2057 | pGamutState->DW17.PwlGammaSlope7 = 278; |
| 2058 | pGamutState->DW18.PwlGammaSlope8 = 215; |
| 2059 | pGamutState->DW18.PwlGammaSlope9 = 179; |
| 2060 | pGamutState->DW19.PwlGammaSlope10 = 151; |
| 2061 | pGamutState->DW19.PwlGammaSlope11 = 124; |
| 2062 | |
| 2063 | pGamutState->DW26.PwlInvGammaSlope0 = 26; |
| 2064 | pGamutState->DW26.PwlInvGammaSlope1 = 72; |
| 2065 | pGamutState->DW27.PwlInvGammaSlope2 = 107; |
| 2066 | pGamutState->DW27.PwlInvGammaSlope3 = 151; |
| 2067 | pGamutState->DW28.PwlInvGammaSlope4 = 195; |
| 2068 | pGamutState->DW28.PwlInvGammaSlope5 = 243; |
| 2069 | pGamutState->DW29.PwlInvGammaSlope6 = 305; |
| 2070 | pGamutState->DW29.PwlInvGammaSlope7 = 337; |
| 2071 | pGamutState->DW30.PwlInvGammaSlope8 = 404; |
| 2072 | pGamutState->DW30.PwlInvGammaSlope9 = 445; |
| 2073 | pGamutState->DW31.PwlInvGammaSlope10 = 498; |
| 2074 | pGamutState->DW31.PwlInvGammaSlope11 = 555; |
| 2075 | |
| 2076 | pGamutState->DW33.OffsetOutB = MOS_BITFIELD_VALUE((uint32_t)-1246, 15); |
| 2077 | pGamutState->DW34.OffsetOutR = MOS_BITFIELD_VALUE((uint32_t)-974, 15); |
| 2078 | pGamutState->DW34.OffsetOutG = MOS_BITFIELD_VALUE((uint32_t)-983, 15); |
| 2079 | } |
| 2080 | |
| 2081 | MOS_STATUS MhwVeboxInterfaceG9::AddVeboxSurfaceControlBits( |
| 2082 | PMHW_VEBOX_SURFACE_CNTL_PARAMS pVeboxSurfCntlParams, |
| 2083 | uint32_t *pSurfCtrlBits) |
| 2084 | { |
| 2085 | PLATFORM Platform = {}; |
| 2086 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2087 | |
| 2088 | mhw_vebox_g9_X::VEB_DI_IECP_COMMAND_SURFACE_CONTROL_BITS_CMD *pVeboxSurfCtrlBits; |
| 2089 | |
| 2090 | MHW_CHK_NULL(pVeboxSurfCntlParams); |
| 2091 | MHW_CHK_NULL(pSurfCtrlBits); |
| 2092 | MHW_CHK_NULL(m_osInterface); |
| 2093 | |
| 2094 | m_osInterface->pfnGetPlatform(m_osInterface, &Platform); |
| 2095 | |
| 2096 | pVeboxSurfCtrlBits = (mhw_vebox_g9_X::VEB_DI_IECP_COMMAND_SURFACE_CONTROL_BITS_CMD *)pSurfCtrlBits; |
| 2097 | |
| 2098 | if (pVeboxSurfCntlParams->bIsCompressed) |
| 2099 | { |
| 2100 | pVeboxSurfCtrlBits->DW0.MemoryCompressionEnable = 1; |
| 2101 | |
| 2102 | if (pVeboxSurfCntlParams->CompressionMode == MOS_MMC_VERTICAL) |
| 2103 | { |
| 2104 | pVeboxSurfCtrlBits->DW0.MemoryCompressionMode = 1; |
| 2105 | } |
| 2106 | } |
| 2107 | |
| 2108 | finish: |
| 2109 | return eStatus; |
| 2110 | } |