| 1 |
/* |
| 2 |
* Copyright (c) 2026, 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_common_impl.h |
| 24 |
//! \brief MHW VEBOX common implementation helper functions |
| 25 |
//! \details Common helper utilities for VEBOX_STATE command initialization |
| 26 |
//! across multiple platforms. These non-member helper functions |
| 27 |
//! extract duplicated logic to improve maintainability. |
| 28 |
//! |
| 29 |
|
| 30 |
#ifndef __MHW_VEBOX_COMMON_IMPL_H__ |
| 31 |
#define __MHW_VEBOX_COMMON_IMPL_H__ |
| 32 |
|
| 33 |
#include "mos_os.h" |
| 34 |
#include "mhw_vebox_itf.h" |
| 35 |
#include "mhw_utilities_next.h" |
| 36 |
#include "hal_oca_interface_next.h" |
| 37 |
|
| 38 |
namespace mhw { |
| 39 |
namespace vebox { |
| 40 |
namespace common { |
| 41 |
|
| 42 |
//! |
| 43 |
//! \brief Helper function for adding VEBOX resource to command |
| 44 |
//! \details Initializes MHW_RESOURCE_PARAMS and calls AddResourceToCmd, |
| 45 |
//! handles command buffer dump and OCA interface tracing |
| 46 |
//! \param [in] pOsInterface |
| 47 |
//! Pointer to OS interface |
| 48 |
//! \param [in] pCmdBuffer |
| 49 |
//! Pointer to command buffer |
| 50 |
//! \param [in] pResource |
| 51 |
//! Pointer to resource to add |
| 52 |
//! \param [in] dwOffset |
| 53 |
//! Offset in resource |
| 54 |
//! \param [in,out] pdwCmd |
| 55 |
//! Pointer to command DW to update |
| 56 |
//! \param [in] dwLocationInCmd |
| 57 |
//! Location in command |
| 58 |
//! \param [in] bUseSharedMocs |
| 59 |
//! Whether to use shared MOCS |
| 60 |
//! \param [in] dwSharedMocsOffset |
| 61 |
//! Shared MOCS offset (used when bUseSharedMocs is true) |
| 62 |
//! \param [in] pOsContext |
| 63 |
//! Pointer to OS context |
| 64 |
//! \param [in] pVeboxHeap |
| 65 |
//! Pointer to VEBOX heap |
| 66 |
//! \param [in] resourceName |
| 67 |
//! Resource name for command buffer dump |
| 68 |
//! \param [in] stateSize |
| 69 |
//! State size for OCA interface |
| 70 |
//! \param [in] AddResourceToCmd |
| 71 |
//! Function pointer to AddResourceToCmd |
| 72 |
//! \return MOS_STATUS |
| 73 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 74 |
//! |
| 75 |
template <typename cmd_t> |
| 76 |
inline MOS_STATUS AddVeboxResource( |
| 77 |
PMOS_INTERFACE pOsInterface, |
| 78 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 79 |
PMOS_RESOURCE pResource, |
| 80 |
uint32_t dwOffset, |
| 81 |
uint32_t* pdwCmd, |
| 82 |
uint32_t dwLocationInCmd, |
| 83 |
bool bUseSharedMocs, |
| 84 |
int32_t dwSharedMocsOffset, |
| 85 |
PMOS_CONTEXT pOsContext, |
| 86 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 87 |
const char* resourceName, |
| 88 |
uint32_t stateSize, |
| 89 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 90 |
{ |
| 91 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 92 |
uint32_t* pIndirectState = nullptr; |
| 93 |
|
| 94 |
MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 95 |
ResourceParams.presResource = pResource; |
| 96 |
ResourceParams.dwOffset = dwOffset; |
| 97 |
ResourceParams.pdwCmd = pdwCmd; |
| 98 |
ResourceParams.dwLocationInCmd = dwLocationInCmd; |
| 99 |
ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 100 |
|
| 101 |
if (bUseSharedMocs) |
| 102 |
{ |
| 103 |
ResourceParams.dwSharedMocsOffset = static_cast<uint32_t>(dwSharedMocsOffset); |
| 104 |
} |
| 105 |
|
| 106 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 107 |
pOsInterface, |
| 108 |
pCmdBuffer, |
| 109 |
&ResourceParams)); |
| 110 |
|
| 111 |
#if MOS_COMMAND_BUFFER_DUMP_SUPPORTED |
| 112 |
if (*ResourceParams.pdwCmd != 0 || *(ResourceParams.pdwCmd + 1) != 0) |
| 113 |
{ |
| 114 |
pIndirectState = (uint32_t*)(pVeboxHeap->pLockedDriverResourceMem + ResourceParams.dwOffset); |
| 115 |
pOsInterface->pfnAddIndirectState(pOsInterface, |
| 116 |
stateSize, |
| 117 |
pIndirectState, |
| 118 |
ResourceParams.pdwCmd, |
| 119 |
ResourceParams.pdwCmd + 1, |
| 120 |
resourceName); |
| 121 |
} |
| 122 |
#endif |
| 123 |
|
| 124 |
HalOcaInterfaceNext::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, ResourceParams.dwOffset, false, stateSize); |
| 125 |
|
| 126 |
return MOS_STATUS_SUCCESS; |
| 127 |
} |
| 128 |
|
| 129 |
//! |
| 130 |
//! \brief Helper function for DNDI state setup |
| 131 |
//! \param [in,out] cmd |
| 132 |
//! Reference to VEBOX_STATE command |
| 133 |
//! \param [in] pOsInterface |
| 134 |
//! Pointer to OS interface |
| 135 |
//! \param [in] pCmdBuffer |
| 136 |
//! Pointer to command buffer |
| 137 |
//! \param [in] pVeboxHeap |
| 138 |
//! Pointer to VEBOX heap |
| 139 |
//! \param [in] uiInstanceBaseAddr |
| 140 |
//! Instance base address |
| 141 |
//! \param [in] bCmBuffer |
| 142 |
//! Whether using CM buffer |
| 143 |
//! \param [in] pVeboxParamResource |
| 144 |
//! Pointer to VEBOX parameter resource |
| 145 |
//! \param [in] pOsContext |
| 146 |
//! Pointer to OS context |
| 147 |
//! \param [in] uiDndiStateSize |
| 148 |
//! DNDI state size |
| 149 |
//! \param [in] AddResourceToCmd |
| 150 |
//! Function pointer to AddResourceToCmd |
| 151 |
//! \return MOS_STATUS |
| 152 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 153 |
//! |
| 154 |
template <typename cmd_t> |
| 155 |
inline MOS_STATUS SetupVeboxDndiState( |
| 156 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 157 |
PMOS_INTERFACE pOsInterface, |
| 158 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 159 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 160 |
uint32_t uiInstanceBaseAddr, |
| 161 |
bool bCmBuffer, |
| 162 |
PMOS_RESOURCE pVeboxParamResource, |
| 163 |
PMOS_CONTEXT pOsContext, |
| 164 |
uint32_t uiDndiStateSize, |
| 165 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 166 |
{ |
| 167 |
PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 168 |
uint32_t dwOffset = 0; |
| 169 |
|
| 170 |
if (bCmBuffer) |
| 171 |
{ |
| 172 |
pVeboxHeapResource = pVeboxParamResource; |
| 173 |
dwOffset = pVeboxHeap->uiDndiStateOffset; |
| 174 |
} |
| 175 |
else |
| 176 |
{ |
| 177 |
pVeboxHeapResource = &pVeboxHeap->DriverResource; |
| 178 |
dwOffset = pVeboxHeap->uiDndiStateOffset + uiInstanceBaseAddr; |
| 179 |
} |
| 180 |
|
| 181 |
return AddVeboxResource<cmd_t>( |
| 182 |
pOsInterface, |
| 183 |
pCmdBuffer, |
| 184 |
pVeboxHeapResource, |
| 185 |
dwOffset, |
| 186 |
&(cmd.DW2.Value), |
| 187 |
2, |
| 188 |
false, |
| 189 |
0, |
| 190 |
pOsContext, |
| 191 |
pVeboxHeap, |
| 192 |
"VEBOX_DNDI_STATE_CMD", |
| 193 |
uiDndiStateSize, |
| 194 |
AddResourceToCmd); |
| 195 |
} |
| 196 |
|
| 197 |
//! |
| 198 |
//! \brief Helper function for IECP state setup |
| 199 |
//! \param [in,out] cmd |
| 200 |
//! Reference to VEBOX_STATE command |
| 201 |
//! \param [in] pOsInterface |
| 202 |
//! Pointer to OS interface |
| 203 |
//! \param [in] pCmdBuffer |
| 204 |
//! Pointer to command buffer |
| 205 |
//! \param [in] pVeboxHeap |
| 206 |
//! Pointer to VEBOX heap |
| 207 |
//! \param [in] uiInstanceBaseAddr |
| 208 |
//! Instance base address |
| 209 |
//! \param [in] bCmBuffer |
| 210 |
//! Whether using CM buffer |
| 211 |
//! \param [in] pVeboxParamResource |
| 212 |
//! Pointer to VEBOX parameter resource |
| 213 |
//! \param [in] pOsContext |
| 214 |
//! Pointer to OS context |
| 215 |
//! \param [in] uiIecpStateSize |
| 216 |
//! IECP state size |
| 217 |
//! \param [in] AddResourceToCmd |
| 218 |
//! Function pointer to AddResourceToCmd |
| 219 |
//! \return MOS_STATUS |
| 220 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 221 |
//! |
| 222 |
template <typename cmd_t> |
| 223 |
inline MOS_STATUS SetupVeboxIecpState( |
| 224 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 225 |
PMOS_INTERFACE pOsInterface, |
| 226 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 227 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 228 |
uint32_t uiInstanceBaseAddr, |
| 229 |
bool bCmBuffer, |
| 230 |
PMOS_RESOURCE pVeboxParamResource, |
| 231 |
PMOS_CONTEXT pOsContext, |
| 232 |
uint32_t uiIecpStateSize, |
| 233 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 234 |
{ |
| 235 |
PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 236 |
uint32_t dwOffset = 0; |
| 237 |
|
| 238 |
if (bCmBuffer) |
| 239 |
{ |
| 240 |
pVeboxHeapResource = pVeboxParamResource; |
| 241 |
dwOffset = pVeboxHeap->uiIecpStateOffset; |
| 242 |
} |
| 243 |
else |
| 244 |
{ |
| 245 |
pVeboxHeapResource = &pVeboxHeap->DriverResource; |
| 246 |
dwOffset = pVeboxHeap->uiIecpStateOffset + uiInstanceBaseAddr; |
| 247 |
} |
| 248 |
|
| 249 |
return AddVeboxResource<cmd_t>( |
| 250 |
pOsInterface, |
| 251 |
pCmdBuffer, |
| 252 |
pVeboxHeapResource, |
| 253 |
dwOffset, |
| 254 |
&(cmd.DW4.Value), |
| 255 |
4, |
| 256 |
true, |
| 257 |
1 - 4, |
| 258 |
pOsContext, |
| 259 |
pVeboxHeap, |
| 260 |
"VEBOX_IECP_STATE_CMD", |
| 261 |
uiIecpStateSize, |
| 262 |
AddResourceToCmd); |
| 263 |
} |
| 264 |
|
| 265 |
//! |
| 266 |
//! \brief Helper function for HDR/Gamut state setup |
| 267 |
//! \param [in,out] cmd |
| 268 |
//! Reference to VEBOX_STATE command |
| 269 |
//! \param [in] pOsInterface |
| 270 |
//! Pointer to OS interface |
| 271 |
//! \param [in] pCmdBuffer |
| 272 |
//! Pointer to command buffer |
| 273 |
//! \param [in] pVeboxHeap |
| 274 |
//! Pointer to VEBOX heap |
| 275 |
//! \param [in] uiInstanceBaseAddr |
| 276 |
//! Instance base address |
| 277 |
//! \param [in] bCmBuffer |
| 278 |
//! Whether using CM buffer |
| 279 |
//! \param [in] pVeboxParamResource |
| 280 |
//! Pointer to VEBOX parameter resource |
| 281 |
//! \param [in] bHdrEnabled |
| 282 |
//! Whether HDR is enabled |
| 283 |
//! \param [in] pOsContext |
| 284 |
//! Pointer to OS context |
| 285 |
//! \param [in] uiStateSize |
| 286 |
//! State size (HDR or Gamut) |
| 287 |
//! \param [in] AddResourceToCmd |
| 288 |
//! Function pointer to AddResourceToCmd |
| 289 |
//! \return MOS_STATUS |
| 290 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 291 |
//! |
| 292 |
template <typename cmd_t> |
| 293 |
inline MOS_STATUS SetupVeboxHdrGamutState( |
| 294 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 295 |
PMOS_INTERFACE pOsInterface, |
| 296 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 297 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 298 |
uint32_t uiInstanceBaseAddr, |
| 299 |
bool bCmBuffer, |
| 300 |
PMOS_RESOURCE pVeboxParamResource, |
| 301 |
bool bHdrEnabled, |
| 302 |
PMOS_CONTEXT pOsContext, |
| 303 |
uint32_t uiStateSize, |
| 304 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 305 |
{ |
| 306 |
PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 307 |
uint32_t dwOffset = 0; |
| 308 |
const char* resourceName = nullptr; |
| 309 |
|
| 310 |
if (bCmBuffer) |
| 311 |
{ |
| 312 |
pVeboxHeapResource = pVeboxParamResource; |
| 313 |
dwOffset = bHdrEnabled ? pVeboxHeap->uiHdrStateOffset : pVeboxHeap->uiGamutStateOffset; |
| 314 |
} |
| 315 |
else |
| 316 |
{ |
| 317 |
pVeboxHeapResource = &pVeboxHeap->DriverResource; |
| 318 |
dwOffset = (bHdrEnabled ? pVeboxHeap->uiHdrStateOffset : pVeboxHeap->uiGamutStateOffset) + uiInstanceBaseAddr; |
| 319 |
} |
| 320 |
|
| 321 |
resourceName = bHdrEnabled ? "VEBOX_HDR_STATE_CMD" : "Gamut_Expansion_Gamma_Correction_CMD"; |
| 322 |
|
| 323 |
return AddVeboxResource<cmd_t>( |
| 324 |
pOsInterface, |
| 325 |
pCmdBuffer, |
| 326 |
pVeboxHeapResource, |
| 327 |
dwOffset, |
| 328 |
&(cmd.DW6.Value), |
| 329 |
6, |
| 330 |
true, |
| 331 |
1 - 6, |
| 332 |
pOsContext, |
| 333 |
pVeboxHeap, |
| 334 |
resourceName, |
| 335 |
uiStateSize, |
| 336 |
AddResourceToCmd); |
| 337 |
} |
| 338 |
|
| 339 |
//! |
| 340 |
//! \brief Helper function for Vertex Table setup |
| 341 |
//! \param [in,out] cmd |
| 342 |
//! Reference to VEBOX_STATE command |
| 343 |
//! \param [in] pOsInterface |
| 344 |
//! Pointer to OS interface |
| 345 |
//! \param [in] pCmdBuffer |
| 346 |
//! Pointer to command buffer |
| 347 |
//! \param [in] pVeboxHeap |
| 348 |
//! Pointer to VEBOX heap |
| 349 |
//! \param [in] uiInstanceBaseAddr |
| 350 |
//! Instance base address |
| 351 |
//! \param [in] bCmBuffer |
| 352 |
//! Whether using CM buffer |
| 353 |
//! \param [in] pVeboxParamResource |
| 354 |
//! Pointer to VEBOX parameter resource |
| 355 |
//! \param [in] pOsContext |
| 356 |
//! Pointer to OS context |
| 357 |
//! \param [in] uiVertexTableSize |
| 358 |
//! Vertex table size |
| 359 |
//! \param [in] AddResourceToCmd |
| 360 |
//! Function pointer to AddResourceToCmd |
| 361 |
//! \return MOS_STATUS |
| 362 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 363 |
//! |
| 364 |
template <typename cmd_t> |
| 365 |
inline MOS_STATUS SetupVeboxVertexTable( |
| 366 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 367 |
PMOS_INTERFACE pOsInterface, |
| 368 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 369 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 370 |
uint32_t uiInstanceBaseAddr, |
| 371 |
bool bCmBuffer, |
| 372 |
PMOS_RESOURCE pVeboxParamResource, |
| 373 |
PMOS_CONTEXT pOsContext, |
| 374 |
uint32_t uiVertexTableSize, |
| 375 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 376 |
{ |
| 377 |
PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 378 |
uint32_t dwOffset = 0; |
| 379 |
|
| 380 |
if (bCmBuffer) |
| 381 |
{ |
| 382 |
pVeboxHeapResource = pVeboxParamResource; |
| 383 |
dwOffset = pVeboxHeap->uiVertexTableOffset; |
| 384 |
} |
| 385 |
else |
| 386 |
{ |
| 387 |
pVeboxHeapResource = &pVeboxHeap->DriverResource; |
| 388 |
dwOffset = pVeboxHeap->uiVertexTableOffset + uiInstanceBaseAddr; |
| 389 |
} |
| 390 |
|
| 391 |
return AddVeboxResource<cmd_t>( |
| 392 |
pOsInterface, |
| 393 |
pCmdBuffer, |
| 394 |
pVeboxHeapResource, |
| 395 |
dwOffset, |
| 396 |
&(cmd.DW8.Value), |
| 397 |
8, |
| 398 |
true, |
| 399 |
1 - 8, |
| 400 |
pOsContext, |
| 401 |
pVeboxHeap, |
| 402 |
"VEBOX_VERTEX_TABLE_CMD", |
| 403 |
uiVertexTableSize, |
| 404 |
AddResourceToCmd); |
| 405 |
} |
| 406 |
|
| 407 |
//! |
| 408 |
//! \brief Helper function for Capture Pipe setup |
| 409 |
//! \param [in,out] cmd |
| 410 |
//! Reference to VEBOX_STATE command |
| 411 |
//! \param [in] pOsInterface |
| 412 |
//! Pointer to OS interface |
| 413 |
//! \param [in] pCmdBuffer |
| 414 |
//! Pointer to command buffer |
| 415 |
//! \param [in] pVeboxHeap |
| 416 |
//! Pointer to VEBOX heap |
| 417 |
//! \param [in] uiInstanceBaseAddr |
| 418 |
//! Instance base address |
| 419 |
//! \param [in] bCmBuffer |
| 420 |
//! Whether using CM buffer |
| 421 |
//! \param [in] pVeboxParamResource |
| 422 |
//! Pointer to VEBOX parameter resource |
| 423 |
//! \param [in] pOsContext |
| 424 |
//! Pointer to OS context |
| 425 |
//! \param [in] uiCapturePipeStateSize |
| 426 |
//! Capture pipe state size |
| 427 |
//! \param [in] AddResourceToCmd |
| 428 |
//! Function pointer to AddResourceToCmd |
| 429 |
//! \return MOS_STATUS |
| 430 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 431 |
//! |
| 432 |
template <typename cmd_t> |
| 433 |
inline MOS_STATUS SetupVeboxCapturePipe( |
| 434 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 435 |
PMOS_INTERFACE pOsInterface, |
| 436 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 437 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 438 |
uint32_t uiInstanceBaseAddr, |
| 439 |
bool bCmBuffer, |
| 440 |
PMOS_RESOURCE pVeboxParamResource, |
| 441 |
PMOS_CONTEXT pOsContext, |
| 442 |
uint32_t uiCapturePipeStateSize, |
| 443 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 444 |
{ |
| 445 |
PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 446 |
uint32_t dwOffset = 0; |
| 447 |
|
| 448 |
if (bCmBuffer) |
| 449 |
{ |
| 450 |
pVeboxHeapResource = pVeboxParamResource; |
| 451 |
dwOffset = pVeboxHeap->uiCapturePipeStateOffset; |
| 452 |
} |
| 453 |
else |
| 454 |
{ |
| 455 |
pVeboxHeapResource = &pVeboxHeap->DriverResource; |
| 456 |
dwOffset = pVeboxHeap->uiCapturePipeStateOffset + uiInstanceBaseAddr; |
| 457 |
} |
| 458 |
|
| 459 |
return AddVeboxResource<cmd_t>( |
| 460 |
pOsInterface, |
| 461 |
pCmdBuffer, |
| 462 |
pVeboxHeapResource, |
| 463 |
dwOffset, |
| 464 |
&(cmd.DW10.Value), |
| 465 |
10, |
| 466 |
true, |
| 467 |
1 - 10, |
| 468 |
pOsContext, |
| 469 |
pVeboxHeap, |
| 470 |
"VEBOX_CAPTURE_PIPE_STATE_CMD", |
| 471 |
uiCapturePipeStateSize, |
| 472 |
AddResourceToCmd); |
| 473 |
} |
| 474 |
|
| 475 |
//! |
| 476 |
//! \brief Helper function for LACE LUT setup |
| 477 |
//! \param [in,out] cmd |
| 478 |
//! Reference to VEBOX_STATE command |
| 479 |
//! \param [in] pOsInterface |
| 480 |
//! Pointer to OS interface |
| 481 |
//! \param [in] pCmdBuffer |
| 482 |
//! Pointer to command buffer |
| 483 |
//! \param [in] pLaceLookUpTables |
| 484 |
//! Pointer to LACE lookup tables resource |
| 485 |
//! \param [in] AddResourceToCmd |
| 486 |
//! Function pointer to AddResourceToCmd |
| 487 |
//! \return MOS_STATUS |
| 488 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 489 |
//! |
| 490 |
template <typename cmd_t> |
| 491 |
inline MOS_STATUS SetupVeboxLaceLut( |
| 492 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 493 |
PMOS_INTERFACE pOsInterface, |
| 494 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 495 |
PMOS_RESOURCE pLaceLookUpTables, |
| 496 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 497 |
{ |
| 498 |
if (pLaceLookUpTables == nullptr) |
| 499 |
{ |
| 500 |
return MOS_STATUS_SUCCESS; |
| 501 |
} |
| 502 |
|
| 503 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 504 |
MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 505 |
ResourceParams.presResource = pLaceLookUpTables; |
| 506 |
ResourceParams.dwOffset = 0; |
| 507 |
ResourceParams.pdwCmd = &(cmd.DW12.Value); |
| 508 |
ResourceParams.dwLocationInCmd = 12; |
| 509 |
ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 510 |
ResourceParams.dwSharedMocsOffset = static_cast<uint32_t>(1 - 12); |
| 511 |
|
| 512 |
return AddResourceToCmd( |
| 513 |
pOsInterface, |
| 514 |
pCmdBuffer, |
| 515 |
&ResourceParams); |
| 516 |
} |
| 517 |
|
| 518 |
//! |
| 519 |
//! \brief Helper function for Gamma Correction setup |
| 520 |
//! \param [in,out] cmd |
| 521 |
//! Reference to VEBOX_STATE command |
| 522 |
//! \param [in] pOsInterface |
| 523 |
//! Pointer to OS interface |
| 524 |
//! \param [in] pCmdBuffer |
| 525 |
//! Pointer to command buffer |
| 526 |
//! \param [in] pVeboxHeap |
| 527 |
//! Pointer to VEBOX heap |
| 528 |
//! \param [in] uiInstanceBaseAddr |
| 529 |
//! Instance base address |
| 530 |
//! \param [in] bCmBuffer |
| 531 |
//! Whether using CM buffer |
| 532 |
//! \param [in] pVeboxParamResource |
| 533 |
//! Pointer to VEBOX parameter resource |
| 534 |
//! \param [in] pOsContext |
| 535 |
//! Pointer to OS context |
| 536 |
//! \param [in] uiGammaCorrectionStateSize |
| 537 |
//! Gamma correction state size |
| 538 |
//! \param [in] AddResourceToCmd |
| 539 |
//! Function pointer to AddResourceToCmd |
| 540 |
//! \return MOS_STATUS |
| 541 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 542 |
//! |
| 543 |
template <typename cmd_t> |
| 544 |
inline MOS_STATUS SetupVeboxGammaCorrection( |
| 545 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 546 |
PMOS_INTERFACE pOsInterface, |
| 547 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 548 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 549 |
uint32_t uiInstanceBaseAddr, |
| 550 |
bool bCmBuffer, |
| 551 |
PMOS_RESOURCE pVeboxParamResource, |
| 552 |
PMOS_CONTEXT pOsContext, |
| 553 |
uint32_t uiGammaCorrectionStateSize, |
| 554 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 555 |
{ |
| 556 |
PMOS_RESOURCE pVeboxHeapResource = nullptr; |
| 557 |
uint32_t dwOffset = 0; |
| 558 |
|
| 559 |
if (bCmBuffer) |
| 560 |
{ |
| 561 |
pVeboxHeapResource = pVeboxParamResource; |
| 562 |
dwOffset = pVeboxHeap->uiGammaCorrectionStateOffset; |
| 563 |
} |
| 564 |
else |
| 565 |
{ |
| 566 |
pVeboxHeapResource = &pVeboxHeap->DriverResource; |
| 567 |
dwOffset = pVeboxHeap->uiGammaCorrectionStateOffset + uiInstanceBaseAddr; |
| 568 |
} |
| 569 |
|
| 570 |
return AddVeboxResource<cmd_t>( |
| 571 |
pOsInterface, |
| 572 |
pCmdBuffer, |
| 573 |
pVeboxHeapResource, |
| 574 |
dwOffset, |
| 575 |
&(cmd.DW14_15.Value[0]), |
| 576 |
14, |
| 577 |
true, |
| 578 |
1 - 14, |
| 579 |
pOsContext, |
| 580 |
pVeboxHeap, |
| 581 |
"PMHW_FORWARD_GAMMA_SEG", |
| 582 |
uiGammaCorrectionStateSize, |
| 583 |
AddResourceToCmd); |
| 584 |
} |
| 585 |
|
| 586 |
//! |
| 587 |
//! \brief Helper function for 3D LUT setup |
| 588 |
//! \param [in,out] cmd |
| 589 |
//! Reference to VEBOX_STATE command |
| 590 |
//! \param [in] pOsInterface |
| 591 |
//! Pointer to OS interface |
| 592 |
//! \param [in] pCmdBuffer |
| 593 |
//! Pointer to command buffer |
| 594 |
//! \param [in] pVebox3DLookUpTables |
| 595 |
//! Pointer to 3D LUT resource |
| 596 |
//! \param [in] AddResourceToCmd |
| 597 |
//! Function pointer to AddResourceToCmd |
| 598 |
//! \return MOS_STATUS |
| 599 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 600 |
//! |
| 601 |
template <typename cmd_t> |
| 602 |
inline MOS_STATUS SetupVebox3DLut( |
| 603 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 604 |
PMOS_INTERFACE pOsInterface, |
| 605 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 606 |
PMOS_RESOURCE pVebox3DLookUpTables, |
| 607 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 608 |
{ |
| 609 |
if (pVebox3DLookUpTables == nullptr) |
| 610 |
{ |
| 611 |
return MOS_STATUS_SUCCESS; |
| 612 |
} |
| 613 |
|
| 614 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 615 |
MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 616 |
ResourceParams.presResource = pVebox3DLookUpTables; |
| 617 |
ResourceParams.dwOffset = 0; |
| 618 |
ResourceParams.pdwCmd = &(cmd.DW16.Value); |
| 619 |
ResourceParams.dwLocationInCmd = 16; |
| 620 |
ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 621 |
ResourceParams.dwSharedMocsOffset = static_cast<uint32_t>(1 - 16); |
| 622 |
|
| 623 |
return AddResourceToCmd( |
| 624 |
pOsInterface, |
| 625 |
pCmdBuffer, |
| 626 |
&ResourceParams); |
| 627 |
} |
| 628 |
|
| 629 |
//! |
| 630 |
//! \brief Helper function for 1D LUT setup |
| 631 |
//! \param [in,out] cmd |
| 632 |
//! Reference to VEBOX_STATE command |
| 633 |
//! \param [in] pOsInterface |
| 634 |
//! Pointer to OS interface |
| 635 |
//! \param [in] pCmdBuffer |
| 636 |
//! Pointer to command buffer |
| 637 |
//! \param [in] pVebox1DLookUpTables |
| 638 |
//! Pointer to 1D LUT resource |
| 639 |
//! \param [in] AddResourceToCmd |
| 640 |
//! Function pointer to AddResourceToCmd |
| 641 |
//! \return MOS_STATUS |
| 642 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 643 |
//! |
| 644 |
template <typename cmd_t> |
| 645 |
inline MOS_STATUS SetupVebox1DLut( |
| 646 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 647 |
PMOS_INTERFACE pOsInterface, |
| 648 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 649 |
PMOS_RESOURCE pVebox1DLookUpTables, |
| 650 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 651 |
{ |
| 652 |
if (pVebox1DLookUpTables == nullptr) |
| 653 |
{ |
| 654 |
return MOS_STATUS_SUCCESS; |
| 655 |
} |
| 656 |
|
| 657 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 658 |
MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 659 |
ResourceParams.presResource = pVebox1DLookUpTables; |
| 660 |
ResourceParams.dwOffset = 0; |
| 661 |
ResourceParams.pdwCmd = &(cmd.DW21.Value); |
| 662 |
ResourceParams.dwLocationInCmd = 21; |
| 663 |
ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 664 |
ResourceParams.dwSharedMocsOffset = static_cast<uint32_t>(1 - 21); |
| 665 |
|
| 666 |
return AddResourceToCmd( |
| 667 |
pOsInterface, |
| 668 |
pCmdBuffer, |
| 669 |
&ResourceParams); |
| 670 |
} |
| 671 |
|
| 672 |
//! |
| 673 |
//! \brief Helper function for HDR state surface redirect (LutCompound) |
| 674 |
//! \param [in,out] cmd |
| 675 |
//! Reference to VEBOX_STATE command |
| 676 |
//! \param [in] pOsInterface |
| 677 |
//! Pointer to OS interface |
| 678 |
//! \param [in] pCmdBuffer |
| 679 |
//! Pointer to command buffer |
| 680 |
//! \param [in] pVeboxHdrStateSurf |
| 681 |
//! Pointer to HDR state surface resource |
| 682 |
//! \param [in] AddResourceToCmd |
| 683 |
//! Function pointer to AddResourceToCmd |
| 684 |
//! \return MOS_STATUS |
| 685 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 686 |
//! |
| 687 |
template <typename cmd_t> |
| 688 |
inline MOS_STATUS SetupVeboxHdrStateSurf( |
| 689 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 690 |
PMOS_INTERFACE pOsInterface, |
| 691 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 692 |
PMOS_RESOURCE pVeboxHdrStateSurf, |
| 693 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 694 |
{ |
| 695 |
if (pVeboxHdrStateSurf == nullptr) |
| 696 |
{ |
| 697 |
return MOS_STATUS_SUCCESS; |
| 698 |
} |
| 699 |
|
| 700 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 701 |
MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 702 |
ResourceParams.presResource = pVeboxHdrStateSurf; |
| 703 |
ResourceParams.dwOffset = 0; |
| 704 |
ResourceParams.pdwCmd = &(cmd.DW6.Value); |
| 705 |
ResourceParams.dwLocationInCmd = 6; |
| 706 |
ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 707 |
ResourceParams.dwSharedMocsOffset = static_cast<uint32_t>(1 - 6); |
| 708 |
|
| 709 |
return AddResourceToCmd( |
| 710 |
pOsInterface, |
| 711 |
pCmdBuffer, |
| 712 |
&ResourceParams); |
| 713 |
} |
| 714 |
|
| 715 |
//! |
| 716 |
//! \brief Helper function for dummy IECP resource setup |
| 717 |
//! \param [in,out] cmd |
| 718 |
//! Reference to VEBOX_STATE command |
| 719 |
//! \param [in] pOsInterface |
| 720 |
//! Pointer to OS interface |
| 721 |
//! \param [in] pCmdBuffer |
| 722 |
//! Pointer to command buffer |
| 723 |
//! \param [in,out] pDummyIecpResource |
| 724 |
//! Pointer to dummy IECP resource |
| 725 |
//! \param [in] uiIecpStateSize |
| 726 |
//! IECP state size |
| 727 |
//! \param [in] pOsContext |
| 728 |
//! Pointer to OS context |
| 729 |
//! \param [in] AddResourceToCmd |
| 730 |
//! Function pointer to AddResourceToCmd |
| 731 |
//! \return MOS_STATUS |
| 732 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 733 |
//! |
| 734 |
template <typename cmd_t> |
| 735 |
inline MOS_STATUS SetupDummyIecpResource( |
| 736 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 737 |
PMOS_INTERFACE pOsInterface, |
| 738 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 739 |
PMOS_RESOURCE pDummyIecpResource, |
| 740 |
uint32_t uiIecpStateSize, |
| 741 |
PMOS_CONTEXT pOsContext, |
| 742 |
MOS_STATUS (*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 743 |
{ |
| 744 |
MOS_ALLOC_GFXRES_PARAMS AllocParamsForBufferLinear = {}; |
| 745 |
MHW_RESOURCE_PARAMS ResourceParams = {}; |
| 746 |
|
| 747 |
// Allocate Resource to avoid Page Fault issue since HW will access it |
| 748 |
if (Mos_ResourceIsNull(pDummyIecpResource)) |
| 749 |
{ |
| 750 |
AllocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER; |
| 751 |
AllocParamsForBufferLinear.TileType = MOS_TILE_LINEAR; |
| 752 |
AllocParamsForBufferLinear.Format = Format_Buffer; |
| 753 |
AllocParamsForBufferLinear.dwBytes = uiIecpStateSize; |
| 754 |
AllocParamsForBufferLinear.pBufName = "DummyIecpResource"; |
| 755 |
AllocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_FF; |
| 756 |
|
| 757 |
MHW_CHK_STATUS_RETURN(pOsInterface->pfnAllocateResource( |
| 758 |
pOsInterface, |
| 759 |
&AllocParamsForBufferLinear, |
| 760 |
pDummyIecpResource)); |
| 761 |
} |
| 762 |
|
| 763 |
MOS_ZeroMemory(&ResourceParams, sizeof(ResourceParams)); |
| 764 |
ResourceParams.presResource = pDummyIecpResource; |
| 765 |
ResourceParams.dwOffset = 0; |
| 766 |
ResourceParams.pdwCmd = &(cmd.DW4.Value); |
| 767 |
ResourceParams.dwLocationInCmd = 4; |
| 768 |
ResourceParams.HwCommandType = MOS_VEBOX_STATE; |
| 769 |
ResourceParams.dwSharedMocsOffset = static_cast<uint32_t>(1 - 4); |
| 770 |
|
| 771 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 772 |
pOsInterface, |
| 773 |
pCmdBuffer, |
| 774 |
&ResourceParams)); |
| 775 |
|
| 776 |
HalOcaInterfaceNext::OnIndirectState(*pCmdBuffer, (MOS_CONTEXT_HANDLE)pOsContext, ResourceParams.presResource, 0, true, 0); |
| 777 |
|
| 778 |
return MOS_STATUS_SUCCESS; |
| 779 |
} |
| 780 |
|
| 781 |
//! |
| 782 |
//! \brief Helper function for mode controls (DW1) setup |
| 783 |
//! \param [in,out] cmd |
| 784 |
//! Reference to VEBOX_STATE command |
| 785 |
//! \param [in] params |
| 786 |
//! Reference to VEBOX_STATE parameters |
| 787 |
//! \param [in] pOsInterface |
| 788 |
//! Pointer to OS interface |
| 789 |
//! \param [in] cacheUsage |
| 790 |
//! Cache usage policy (default: MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_FF) |
| 791 |
//! \return void |
| 792 |
//! |
| 793 |
template <typename cmd_t, typename ParamType> |
| 794 |
inline void SetupVeboxModeControls( |
| 795 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 796 |
const ParamType& params, |
| 797 |
PMOS_INTERFACE pOsInterface, |
| 798 |
MOS_HW_RESOURCE_DEF cacheUsage = MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_FF) |
| 799 |
{ |
| 800 |
cmd.DW1.ColorGamutExpansionEnable = params.VeboxMode.ColorGamutExpansionEnable; |
| 801 |
cmd.DW1.ColorGamutCompressionEnable = params.VeboxMode.ColorGamutCompressionEnable; |
| 802 |
cmd.DW1.GlobalIecpEnable = params.VeboxMode.GlobalIECPEnable; |
| 803 |
cmd.DW1.DnEnable = params.VeboxMode.DNEnable; |
| 804 |
cmd.DW1.DiEnable = params.VeboxMode.DIEnable; |
| 805 |
cmd.DW1.DnDiFirstFrame = params.VeboxMode.DNDIFirstFrame; |
| 806 |
cmd.DW1.DiOutputFrames = params.VeboxMode.DIOutputFrames; |
| 807 |
cmd.DW1.DemosaicEnable = params.VeboxMode.DemosaicEnable; |
| 808 |
cmd.DW1.VignetteEnable = params.VeboxMode.VignetteEnable; |
| 809 |
cmd.DW1.AlphaPlaneEnable = params.VeboxMode.AlphaPlaneEnable; |
| 810 |
cmd.DW1.HotPixelFilteringEnable = params.VeboxMode.HotPixelFilteringEnable; |
| 811 |
cmd.DW1.LaceCorrectionEnable = params.VeboxMode.LACECorrectionEnable; |
| 812 |
cmd.DW1.DisableEncoderStatistics = params.VeboxMode.DisableEncoderStatistics; |
| 813 |
cmd.DW1.DisableTemporalDenoiseFilter = params.VeboxMode.DisableTemporalDenoiseFilter; |
| 814 |
cmd.DW1.SinglePipeEnable = params.VeboxMode.SinglePipeIECPEnable; |
| 815 |
cmd.DW1.ScalarMode = params.VeboxMode.ScalarMode; |
| 816 |
cmd.DW1.ForwardGammaCorrectionEnable = params.VeboxMode.ForwardGammaCorrectionEnable; |
| 817 |
cmd.DW1.HdrEnable = params.VeboxMode.Hdr1DLutEnable; |
| 818 |
cmd.DW1.Fp16ModeEnable = params.VeboxMode.Fp16ModeEnable; |
| 819 |
cmd.DW1.StateSurfaceControlBits = (pOsInterface->pfnCachePolicyGetMemoryObject( |
| 820 |
cacheUsage, |
| 821 |
pOsInterface->pfnGetGmmClientContext(pOsInterface))).DwordValue; |
| 822 |
} |
| 823 |
|
| 824 |
//! |
| 825 |
//! \brief Helper function for chroma sampling (DW18) setup |
| 826 |
//! \param [in,out] cmd |
| 827 |
//! Reference to VEBOX_STATE command |
| 828 |
//! \param [in] params |
| 829 |
//! Reference to VEBOX_STATE parameters |
| 830 |
//! \return void |
| 831 |
//! |
| 832 |
template <typename cmd_t, typename ParamType> |
| 833 |
inline void SetupVeboxChromaSampling( |
| 834 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 835 |
const ParamType& params) |
| 836 |
{ |
| 837 |
cmd.DW18.ChromaUpsamplingCoSitedHorizontalOffset = params.ChromaSampling.ChromaUpsamplingCoSitedHorizontalOffset; |
| 838 |
cmd.DW18.ChromaUpsamplingCoSitedVerticalOffset = params.ChromaSampling.ChromaUpsamplingCoSitedVerticalOffset; |
| 839 |
cmd.DW18.ChromaDownsamplingCoSitedHorizontalOffset = params.ChromaSampling.ChromaDownsamplingCoSitedHorizontalOffset; |
| 840 |
cmd.DW18.ChromaDownsamplingCoSitedVerticalOffset = params.ChromaSampling.ChromaDownsamplingCoSitedVerticalOffset; |
| 841 |
cmd.DW18.BypassChromaUpsampling = params.ChromaSampling.BypassChromaUpsampling; |
| 842 |
cmd.DW18.BypassChromaDownsampling = params.ChromaSampling.BypassChromaDownsampling; |
| 843 |
} |
| 844 |
|
| 845 |
//! |
| 846 |
//! \brief Helper function for 3D LUT controls (DW17 for older platforms) |
| 847 |
//! \param [in,out] cmd |
| 848 |
//! Reference to VEBOX_STATE command |
| 849 |
//! \param [in] params |
| 850 |
//! Reference to VEBOX_STATE parameters |
| 851 |
//! \return void |
| 852 |
//! |
| 853 |
template <typename cmd_t, typename ParamType> |
| 854 |
inline void SetupVebox3DLutControlsLegacy( |
| 855 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 856 |
const ParamType& params) |
| 857 |
{ |
| 858 |
cmd.DW17.EncDataControlFor3DLUT = 0; |
| 859 |
cmd.DW17.Lut3DMemoryLayoutControl = 0; // Legacy layout |
| 860 |
cmd.DW17.ChannelMappingSwapForLut3D = params.LUT3D.ChannelMappingSwapForLut3D; |
| 861 |
cmd.DW17.ArbitrationPriorityControlForLut3D = params.LUT3D.ArbitrationPriorityControl; |
| 862 |
cmd.DW17.Lut3DMocsTable = params.Vebox3DLookUpTablesSurfCtrl.Gen9.Index; |
| 863 |
} |
| 864 |
|
| 865 |
//! |
| 866 |
//! \brief Helper function for 3D LUT controls (DW23 for newer platforms) |
| 867 |
//! \param [in,out] cmd |
| 868 |
//! Reference to VEBOX_STATE command |
| 869 |
//! \param [in] params |
| 870 |
//! Reference to VEBOX_STATE parameters |
| 871 |
//! \return void |
| 872 |
//! |
| 873 |
template <typename cmd_t, typename ParamType> |
| 874 |
inline void SetupVebox3DLutControlsNew( |
| 875 |
typename cmd_t::VEBOX_STATE_CMD& cmd, |
| 876 |
const ParamType& params) |
| 877 |
{ |
| 878 |
cmd.DW23.ChannelMappingSwapForLut3D = params.LUT3D.ChannelMappingSwapForLut3D; |
| 879 |
cmd.DW23.ArbitrationPriorityControlForLut3D = params.LUT3D.ArbitrationPriorityControl; |
| 880 |
cmd.DW23.Lut3DMocsTable = params.Vebox3DLookUpTablesSurfCtrl.Gen9.Index; |
| 881 |
} |
| 882 |
|
| 883 |
//! |
| 884 |
//! \brief Helper function for tracing indirect state information |
| 885 |
//! \param [in] cmdBuffer |
| 886 |
//! Reference to command buffer |
| 887 |
//! \param [in] osContext |
| 888 |
//! Reference to OS context |
| 889 |
//! \param [in] bCmBuffer |
| 890 |
//! Whether using CM buffer |
| 891 |
//! \param [in] bUseKernelResource |
| 892 |
//! Whether using kernel resource |
| 893 |
//! \return MOS_STATUS |
| 894 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 895 |
//! |
| 896 |
inline MOS_STATUS TraceIndirectStateInfo( |
| 897 |
MOS_COMMAND_BUFFER& cmdBuffer, |
| 898 |
MOS_CONTEXT& osContext, |
| 899 |
bool bCmBuffer, |
| 900 |
bool bUseKernelResource) |
| 901 |
{ |
| 902 |
if (bCmBuffer) |
| 903 |
{ |
| 904 |
char ocaLog[] = "Vebox indirect state use CmBuffer"; |
| 905 |
HalOcaInterfaceNext::TraceMessage(cmdBuffer, (MOS_CONTEXT_HANDLE)&osContext, ocaLog, sizeof(ocaLog)); |
| 906 |
} |
| 907 |
else |
| 908 |
{ |
| 909 |
if (bUseKernelResource) |
| 910 |
{ |
| 911 |
char ocaLog[] = "Vebox indirect state use KernelResource"; |
| 912 |
HalOcaInterfaceNext::TraceMessage(cmdBuffer, (MOS_CONTEXT_HANDLE)&osContext, ocaLog, sizeof(ocaLog)); |
| 913 |
} |
| 914 |
else |
| 915 |
{ |
| 916 |
char ocaLog[] = "Vebox indirect state use DriverResource"; |
| 917 |
HalOcaInterfaceNext::TraceMessage(cmdBuffer, (MOS_CONTEXT_HANDLE)&osContext, ocaLog, sizeof(ocaLog)); |
| 918 |
} |
| 919 |
} |
| 920 |
return MOS_STATUS_SUCCESS; |
| 921 |
} |
| 922 |
|
| 923 |
//! |
| 924 |
//! \brief Helper function for VEBOX surface format determination |
| 925 |
//! \details Extracts surface format determination logic shared across all platforms. |
| 926 |
//! This helper function encapsulates both the primary format switch (handling |
| 927 |
//! 25+ surface formats including YUV, RGB, Bayer patterns) and the secondary |
| 928 |
//! Bayer input alignment switch. Each platform's SetVeboxSurfaces can call |
| 929 |
//! this helper function and only handle platform-specific differences. |
| 930 |
//! \param [in] VeboxSurfaceState |
| 931 |
//! Reference to VEBOX_SURFACE_STATE command structure (used for format constants) |
| 932 |
//! \param [in] pSurfaceParam |
| 933 |
//! Pointer to surface parameters containing format and bit depth information |
| 934 |
//! \param [in] bIsOutputSurface |
| 935 |
//! Flag indicating whether this is an output surface |
| 936 |
//! \param [out] dwFormat |
| 937 |
//! Reference to format value to be set |
| 938 |
//! \param [out] bInterleaveChroma |
| 939 |
//! Reference to interleave chroma flag to be set |
| 940 |
//! \param [out] wUYOffset |
| 941 |
//! Reference to U/Y offset value to be set |
| 942 |
//! \param [out] bBayerOffset |
| 943 |
//! Reference to Bayer pattern offset to be set |
| 944 |
//! \param [out] bBayerStride |
| 945 |
//! Reference to Bayer pattern stride to be set |
| 946 |
//! \param [out] bBayerInputAlignment |
| 947 |
//! Reference to Bayer input alignment to be set |
| 948 |
//! \return MOS_STATUS |
| 949 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 950 |
//! |
| 951 |
template <typename cmd_t> |
| 952 |
inline MOS_STATUS SetVeboxSurfaceFormat( |
| 953 |
typename cmd_t::VEBOX_SURFACE_STATE_CMD& VeboxSurfaceState, |
| 954 |
PMHW_VEBOX_SURFACE_PARAMS pSurfaceParam, |
| 955 |
bool bIsOutputSurface, |
| 956 |
uint32_t& dwFormat, |
| 957 |
bool& bInterleaveChroma, |
| 958 |
uint16_t& wUYOffset, |
| 959 |
uint8_t& bBayerOffset, |
| 960 |
uint8_t& bBayerStride, |
| 961 |
uint8_t& bBayerInputAlignment) |
| 962 |
{ |
| 963 |
// Primary format switch - determine surface format based on input format |
| 964 |
switch (pSurfaceParam->Format) |
| 965 |
{ |
| 966 |
case Format_NV12: |
| 967 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR4208; |
| 968 |
bInterleaveChroma = true; |
| 969 |
wUYOffset = (uint16_t)pSurfaceParam->dwUYoffset; |
| 970 |
break; |
| 971 |
|
| 972 |
case Format_YUYV: |
| 973 |
case Format_YUY2: |
| 974 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBNORMAL; |
| 975 |
break; |
| 976 |
|
| 977 |
case Format_UYVY: |
| 978 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPY; |
| 979 |
break; |
| 980 |
|
| 981 |
case Format_AYUV: |
| 982 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED444A8; |
| 983 |
break; |
| 984 |
|
| 985 |
case Format_Y416: |
| 986 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED44416; |
| 987 |
break; |
| 988 |
|
| 989 |
case Format_Y410: |
| 990 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED44410; |
| 991 |
break; |
| 992 |
|
| 993 |
case Format_YVYU: |
| 994 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPUV; |
| 995 |
break; |
| 996 |
|
| 997 |
case Format_VYUY: |
| 998 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPUVY; |
| 999 |
break; |
| 1000 |
|
| 1001 |
case Format_A8B8G8R8: |
| 1002 |
case Format_X8B8G8R8: |
| 1003 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R8G8B8A8UNORMR8G8B8A8UNORMSRGB; |
| 1004 |
break; |
| 1005 |
|
| 1006 |
case Format_A16B16G16R16: |
| 1007 |
case Format_A16R16G16B16: |
| 1008 |
case Format_A16B16G16R16F: |
| 1009 |
case Format_A16R16G16B16F: |
| 1010 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R16G16B16A16; |
| 1011 |
break; |
| 1012 |
|
| 1013 |
case Format_L8: |
| 1014 |
case Format_P8: |
| 1015 |
case Format_Y8: |
| 1016 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_Y8UNORM; |
| 1017 |
break; |
| 1018 |
|
| 1019 |
case Format_IRW0: |
| 1020 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1021 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISBLUE; |
| 1022 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 1023 |
break; |
| 1024 |
|
| 1025 |
case Format_IRW1: |
| 1026 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1027 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISRED; |
| 1028 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 1029 |
break; |
| 1030 |
|
| 1031 |
case Format_IRW2: |
| 1032 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1033 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISRED; |
| 1034 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 1035 |
break; |
| 1036 |
|
| 1037 |
case Format_IRW3: |
| 1038 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1039 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISBLUE; |
| 1040 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_16_BITINPUTATA16_BITSTRIDE; |
| 1041 |
break; |
| 1042 |
|
| 1043 |
case Format_IRW4: |
| 1044 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1045 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISBLUE; |
| 1046 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 1047 |
break; |
| 1048 |
|
| 1049 |
case Format_IRW5: |
| 1050 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1051 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISRED; |
| 1052 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 1053 |
break; |
| 1054 |
|
| 1055 |
case Format_IRW6: |
| 1056 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1057 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISRED; |
| 1058 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 1059 |
break; |
| 1060 |
|
| 1061 |
case Format_IRW7: |
| 1062 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 1063 |
bBayerOffset = VeboxSurfaceState.BAYER_PATTERN_OFFSET_PIXELATX0_Y0ISGREEN_PIXELATX1_Y0ISBLUE; |
| 1064 |
bBayerStride = VeboxSurfaceState.BAYER_PATTERN_FORMAT_8_BITINPUTATA8_BITSTRIDE; |
| 1065 |
break; |
| 1066 |
|
| 1067 |
case Format_P010: |
| 1068 |
case Format_P016: |
| 1069 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR42016; |
| 1070 |
bInterleaveChroma = true; |
| 1071 |
wUYOffset = (uint16_t)pSurfaceParam->dwUYoffset; |
| 1072 |
break; |
| 1073 |
|
| 1074 |
case Format_A8R8G8B8: |
| 1075 |
case Format_X8R8G8B8: |
| 1076 |
// Platform-specific logic: output surface uses different format |
| 1077 |
if (bIsOutputSurface) |
| 1078 |
{ |
| 1079 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_B8G8R8A8UNORM; |
| 1080 |
} |
| 1081 |
else |
| 1082 |
{ |
| 1083 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R8G8B8A8UNORMR8G8B8A8UNORMSRGB; |
| 1084 |
} |
| 1085 |
break; |
| 1086 |
|
| 1087 |
case Format_R10G10B10A2: |
| 1088 |
case Format_B10G10R10A2: |
| 1089 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R10G10B10A2UNORMR10G10B10A2UNORMSRGB; |
| 1090 |
break; |
| 1091 |
|
| 1092 |
case Format_Y216: |
| 1093 |
case Format_Y210: |
| 1094 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED42216; |
| 1095 |
break; |
| 1096 |
|
| 1097 |
case Format_P216: |
| 1098 |
case Format_P210: |
| 1099 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR42216; |
| 1100 |
wUYOffset = (uint16_t)pSurfaceParam->dwUYoffset; |
| 1101 |
break; |
| 1102 |
|
| 1103 |
case Format_Y16S: |
| 1104 |
case Format_Y16U: |
| 1105 |
dwFormat = VeboxSurfaceState.SURFACE_FORMAT_Y16UNORM; |
| 1106 |
break; |
| 1107 |
|
| 1108 |
default: |
| 1109 |
MHW_ASSERTMESSAGE("Unsupported format."); |
| 1110 |
return MOS_STATUS_INVALID_PARAMETER; |
| 1111 |
} |
| 1112 |
|
| 1113 |
// Secondary Bayer input alignment switch - only for input surfaces |
| 1114 |
if (!bIsOutputSurface) |
| 1115 |
{ |
| 1116 |
// Camera pipe will use 10/12/14 for LSB, 0 for MSB. For other pipelines, |
| 1117 |
// dwBitDepth is inherited from pSrc->dwDepth which may not be among (0,10,12,14). |
| 1118 |
// For such cases should use MSB as default value. |
| 1119 |
switch (pSurfaceParam->dwBitDepth) |
| 1120 |
{ |
| 1121 |
case 10: |
| 1122 |
bBayerInputAlignment = VeboxSurfaceState.BAYER_INPUT_ALIGNMENT_10BITLSBALIGNEDDATA; |
| 1123 |
break; |
| 1124 |
|
| 1125 |
case 12: |
| 1126 |
bBayerInputAlignment = VeboxSurfaceState.BAYER_INPUT_ALIGNMENT_12BITLSBALIGNEDDATA; |
| 1127 |
break; |
| 1128 |
|
| 1129 |
case 14: |
| 1130 |
bBayerInputAlignment = VeboxSurfaceState.BAYER_INPUT_ALIGNMENT_14BITLSBALIGNEDDATA; |
| 1131 |
break; |
| 1132 |
|
| 1133 |
case 0: |
| 1134 |
default: |
| 1135 |
bBayerInputAlignment = VeboxSurfaceState.BAYER_INPUT_ALIGNMENT_MSBALIGNEDDATA; |
| 1136 |
break; |
| 1137 |
} |
| 1138 |
} |
| 1139 |
else |
| 1140 |
{ |
| 1141 |
bBayerInputAlignment = VeboxSurfaceState.BAYER_INPUT_ALIGNMENT_MSBALIGNEDDATA; |
| 1142 |
} |
| 1143 |
|
| 1144 |
return MOS_STATUS_SUCCESS; |
| 1145 |
} |
| 1146 |
|
| 1147 |
//! |
| 1148 |
//! \brief Helper function for setting up CSC coefficients for BT601 color space |
| 1149 |
//! \details Configures CSC transformation coefficients for BT601 color space. |
| 1150 |
//! Supports two modes: Color Balance (YUV to RGB with 16-bit precision) |
| 1151 |
//! and Gamut Expansion (YUV to RGB with 10-bit precision). |
| 1152 |
//! \param [in,out] pCscState |
| 1153 |
//! Pointer to CSC state structure to be configured |
| 1154 |
//! \param [in] isColorBalance |
| 1155 |
//! Mode selector: true for Color Balance mode, false for Gamut Expansion mode |
| 1156 |
//! \return void |
| 1157 |
//! |
| 1158 |
template <typename CSCStateType> |
| 1159 |
inline void SetupCSCCoefficients_BT601(CSCStateType* pCscState, bool isColorBalance) |
| 1160 |
{ |
| 1161 |
pCscState->DW0.TransformEnable = true; |
| 1162 |
|
| 1163 |
if (isColorBalance) |
| 1164 |
{ |
| 1165 |
// Color Balance mode: 16-bit precision coefficients |
| 1166 |
pCscState->DW0.C0 = 76309; |
| 1167 |
pCscState->DW1.C1 = 0; |
| 1168 |
pCscState->DW2.C2 = 104597; |
| 1169 |
pCscState->DW3.C3 = 76309; |
| 1170 |
pCscState->DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-25675, 19); |
| 1171 |
pCscState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-53279, 19); |
| 1172 |
pCscState->DW6.C6 = 76309; |
| 1173 |
pCscState->DW7.C7 = 132201; |
| 1174 |
pCscState->DW8.C8 = 0; |
| 1175 |
pCscState->DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 1176 |
pCscState->DW9.OffsetOut1 = 0; |
| 1177 |
pCscState->DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1178 |
pCscState->DW10.OffsetOut2 = 0; |
| 1179 |
pCscState->DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1180 |
pCscState->DW11.OffsetOut3 = 0; |
| 1181 |
} |
| 1182 |
else |
| 1183 |
{ |
| 1184 |
// Gamut Expansion mode: 10-bit precision coefficients |
| 1185 |
pCscState->DW0.C0 = 1192; |
| 1186 |
pCscState->DW1.C1 = MOS_BITFIELD_VALUE((uint32_t)-2, 19); |
| 1187 |
pCscState->DW2.C2 = 1634; |
| 1188 |
pCscState->DW3.C3 = 1192; |
| 1189 |
pCscState->DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-401, 19); |
| 1190 |
pCscState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-833, 19); |
| 1191 |
pCscState->DW6.C6 = 1192; |
| 1192 |
pCscState->DW7.C7 = 2066; |
| 1193 |
pCscState->DW8.C8 = MOS_BITFIELD_VALUE((uint32_t)-1, 19); |
| 1194 |
pCscState->DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-64, 16); |
| 1195 |
pCscState->DW9.OffsetOut1 = 0; |
| 1196 |
pCscState->DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-512, 16); |
| 1197 |
pCscState->DW10.OffsetOut2 = 0; |
| 1198 |
pCscState->DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-512, 16); |
| 1199 |
pCscState->DW11.OffsetOut3 = 0; |
| 1200 |
} |
| 1201 |
} |
| 1202 |
|
| 1203 |
//! |
| 1204 |
//! \brief Helper function for setting up CSC coefficients for BT709 color space |
| 1205 |
//! \details Configures CSC transformation coefficients for BT709 color space. |
| 1206 |
//! Supports two modes: Color Balance (YUV to RGB with 16-bit precision) |
| 1207 |
//! and Gamut Expansion (YUV to RGB with 10-bit precision). |
| 1208 |
//! \param [in,out] pCscState |
| 1209 |
//! Pointer to CSC state structure to be configured |
| 1210 |
//! \param [in] isColorBalance |
| 1211 |
//! Mode selector: true for Color Balance mode, false for Gamut Expansion mode |
| 1212 |
//! \return void |
| 1213 |
//! |
| 1214 |
template <typename CSCStateType> |
| 1215 |
inline void SetupCSCCoefficients_BT709(CSCStateType* pCscState, bool isColorBalance) |
| 1216 |
{ |
| 1217 |
pCscState->DW0.TransformEnable = true; |
| 1218 |
|
| 1219 |
if (isColorBalance) |
| 1220 |
{ |
| 1221 |
// Color Balance mode: 16-bit precision coefficients |
| 1222 |
pCscState->DW0.C0 = 76309; |
| 1223 |
pCscState->DW1.C1 = 0; |
| 1224 |
pCscState->DW2.C2 = 117489; |
| 1225 |
pCscState->DW3.C3 = 76309; |
| 1226 |
pCscState->DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-13975, 19); |
| 1227 |
pCscState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-34925, 19); |
| 1228 |
pCscState->DW6.C6 = 76309; |
| 1229 |
pCscState->DW7.C7 = 138438; |
| 1230 |
pCscState->DW8.C8 = 0; |
| 1231 |
pCscState->DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-2048, 16); |
| 1232 |
pCscState->DW9.OffsetOut1 = 0; |
| 1233 |
pCscState->DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1234 |
pCscState->DW10.OffsetOut2 = 0; |
| 1235 |
pCscState->DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-16384, 16); |
| 1236 |
pCscState->DW11.OffsetOut3 = 0; |
| 1237 |
} |
| 1238 |
else |
| 1239 |
{ |
| 1240 |
// Gamut Expansion mode: 10-bit precision coefficients |
| 1241 |
pCscState->DW0.C0 = 1192; |
| 1242 |
pCscState->DW1.C1 = MOS_BITFIELD_VALUE((uint32_t)-1, 19); |
| 1243 |
pCscState->DW2.C2 = 1835; |
| 1244 |
pCscState->DW3.C3 = 1192; |
| 1245 |
pCscState->DW4.C4 = MOS_BITFIELD_VALUE((uint32_t)-218, 19); |
| 1246 |
pCscState->DW5.C5 = MOS_BITFIELD_VALUE((uint32_t)-537, 19); |
| 1247 |
pCscState->DW6.C6 = 1192; |
| 1248 |
pCscState->DW7.C7 = 2164; |
| 1249 |
pCscState->DW8.C8 = 1; |
| 1250 |
pCscState->DW9.OffsetIn1 = MOS_BITFIELD_VALUE((uint32_t)-64, 16); |
| 1251 |
pCscState->DW9.OffsetOut1 = 0; |
| 1252 |
pCscState->DW10.OffsetIn2 = MOS_BITFIELD_VALUE((uint32_t)-512, 16); |
| 1253 |
pCscState->DW10.OffsetOut2 = 0; |
| 1254 |
pCscState->DW11.OffsetIn3 = MOS_BITFIELD_VALUE((uint32_t)-512, 16); |
| 1255 |
pCscState->DW11.OffsetOut3 = 0; |
| 1256 |
} |
| 1257 |
} |
| 1258 |
|
| 1259 |
//! |
| 1260 |
//! \brief Helper function for populating GE_Values array with identity mapping |
| 1261 |
//! \details Fills the GE_Values array with identity transformation (257*i for all channels). |
| 1262 |
//! This is used when no gamma correction is needed (both input and output gamma are 1.0). |
| 1263 |
//! \param [out] usGE_Values |
| 1264 |
//! 2D array [256][8] to be populated with identity values |
| 1265 |
//! \return void |
| 1266 |
//! |
| 1267 |
inline void PopulateGEValues_Identity(uint16_t usGE_Values[256][8]) |
| 1268 |
{ |
| 1269 |
for (uint32_t i = 0; i < 256; i++) |
| 1270 |
{ |
| 1271 |
usGE_Values[i][0] = 257 * i; |
| 1272 |
usGE_Values[i][1] = 257 * i; |
| 1273 |
usGE_Values[i][2] = 257 * i; |
| 1274 |
usGE_Values[i][3] = 257 * i; |
| 1275 |
usGE_Values[i][4] = 257 * i; |
| 1276 |
usGE_Values[i][5] = 257 * i; |
| 1277 |
usGE_Values[i][6] = 257 * i; |
| 1278 |
usGE_Values[i][7] = 257 * i; |
| 1279 |
} |
| 1280 |
} |
| 1281 |
|
| 1282 |
//! |
| 1283 |
//! \brief Helper function for populating GE_Values array with gamma correction |
| 1284 |
//! \details Fills the GE_Values array using power function-based gamma correction. |
| 1285 |
//! Applies inverse gamma to channels 1-3 and forward gamma to channels 5-7. |
| 1286 |
//! If both gamma values are 1.0 (identity), calls PopulateGEValues_Identity instead. |
| 1287 |
//! \param [out] usGE_Values |
| 1288 |
//! 2D array [256][8] to be populated with gamma-corrected values |
| 1289 |
//! \param [in] dInverseGamma |
| 1290 |
//! Inverse gamma value (typically 1.0, 2.2, or 2.6) |
| 1291 |
//! \param [in] dForwardGamma |
| 1292 |
//! Forward gamma value (typically 1.0, 2.2, or 2.6) |
| 1293 |
//! \param [in] isIdentity |
| 1294 |
//! Flag indicating if both gamma values are 1.0 (identity transformation) |
| 1295 |
//! \return void |
| 1296 |
//! |
| 1297 |
inline void PopulateGEValues_Gamma(uint16_t usGE_Values[256][8], double dInverseGamma, double dForwardGamma, bool isIdentity) |
| 1298 |
{ |
| 1299 |
if (isIdentity) |
| 1300 |
{ |
| 1301 |
PopulateGEValues_Identity(usGE_Values); |
| 1302 |
return; |
| 1303 |
} |
| 1304 |
|
| 1305 |
// Note: Loop only goes to 254, not 255 |
| 1306 |
for (uint32_t i = 0; i < 255; i++) |
| 1307 |
{ |
| 1308 |
usGE_Values[i][0] = 256 * i; |
| 1309 |
usGE_Values[i][1] = (uint16_t)MOS_F_ROUND(pow((double)((double)i / 256), dInverseGamma) * 65536); |
| 1310 |
usGE_Values[i][2] = usGE_Values[i][1]; |
| 1311 |
usGE_Values[i][3] = usGE_Values[i][1]; |
| 1312 |
|
| 1313 |
usGE_Values[i][4] = 256 * i; |
| 1314 |
usGE_Values[i][5] = (uint16_t)MOS_F_ROUND(pow((double)((double)i / 256), 1 / dForwardGamma) * 65536); |
| 1315 |
usGE_Values[i][6] = usGE_Values[i][5]; |
| 1316 |
usGE_Values[i][7] = usGE_Values[i][5]; |
| 1317 |
} |
| 1318 |
} |
| 1319 |
|
| 1320 |
//! |
| 1321 |
//! \brief Helper function for populating GE_Values array from BT2020 global LUTs |
| 1322 |
//! \details Fills the GE_Values array using pre-defined BT2020 inverse and forward |
| 1323 |
//! pixel value and gamma LUT arrays. Used for BT2020 color space conversion. |
| 1324 |
//! \param [out] usGE_Values |
| 1325 |
//! 2D array [256][8] to be populated with BT2020 LUT values |
| 1326 |
//! \return void |
| 1327 |
//! |
| 1328 |
inline void PopulateGEValues_BT2020(uint16_t usGE_Values[256][8]) |
| 1329 |
{ |
| 1330 |
for (uint32_t i = 0; i < 256; i++) |
| 1331 |
{ |
| 1332 |
usGE_Values[i][0] = (uint16_t)g_Vebox_BT2020_Inverse_Pixel_Value[i]; |
| 1333 |
usGE_Values[i][1] = (uint16_t)g_Vebox_BT2020_Inverse_Gamma_LUT[i]; |
| 1334 |
usGE_Values[i][2] = (uint16_t)g_Vebox_BT2020_Inverse_Gamma_LUT[i]; |
| 1335 |
usGE_Values[i][3] = (uint16_t)g_Vebox_BT2020_Inverse_Gamma_LUT[i]; |
| 1336 |
|
| 1337 |
usGE_Values[i][4] = (uint16_t)g_Vebox_BT2020_Forward_Pixel_Value[i]; |
| 1338 |
usGE_Values[i][5] = (uint16_t)g_Vebox_BT2020_Forward_Gamma_LUT[i]; |
| 1339 |
usGE_Values[i][6] = (uint16_t)g_Vebox_BT2020_Forward_Gamma_LUT[i]; |
| 1340 |
usGE_Values[i][7] = (uint16_t)g_Vebox_BT2020_Forward_Gamma_LUT[i]; |
| 1341 |
} |
| 1342 |
} |
| 1343 |
|
| 1344 |
//! |
| 1345 |
//! \brief Helper function for populating GE_Values array from 1DLUT with AYUV processing |
| 1346 |
//! \details Fills the GE_Values array using 1DLUT data for AYUV channel processing. |
| 1347 |
//! Channels 0-3 use identity mapping, channels 4-7 use 1DLUT values. |
| 1348 |
//! Special handling for boundary values (i==0 and i==255). |
| 1349 |
//! \param [out] usGE_Values |
| 1350 |
//! 2D array [256][8] to be populated with 1DLUT AYUV values |
| 1351 |
//! \param [in] pForwardGamma |
| 1352 |
//! Pointer to forward gamma LUT data (4 values per entry: in_val, Y, U, V) |
| 1353 |
//! \param [in] LUTSize |
| 1354 |
//! Size of the LUT (typically 256) |
| 1355 |
//! \return MOS_STATUS |
| 1356 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1357 |
//! |
| 1358 |
inline MOS_STATUS PopulateGEValues_1DLUT_AYUV(uint16_t usGE_Values[256][8], const uint16_t* pForwardGamma, uint32_t LUTSize) |
| 1359 |
{ |
| 1360 |
MHW_CHK_NULL_RETURN(pForwardGamma); |
| 1361 |
|
| 1362 |
for (uint32_t i = 0; i < LUTSize; i++) |
| 1363 |
{ |
| 1364 |
// Channels 0-3: Identity mapping |
| 1365 |
usGE_Values[i][0] = 257 * i; |
| 1366 |
usGE_Values[i][1] = 257 * i; |
| 1367 |
usGE_Values[i][2] = 257 * i; |
| 1368 |
usGE_Values[i][3] = 257 * i; |
| 1369 |
|
| 1370 |
// Channels 4-7: 1DLUT AYUV values |
| 1371 |
uint32_t nIndex = 4 * i; |
| 1372 |
uint16_t in_val = pForwardGamma[nIndex]; |
| 1373 |
uint16_t vchan1_y = pForwardGamma[nIndex + 1]; |
| 1374 |
uint16_t vchan2_u = pForwardGamma[nIndex + 2]; |
| 1375 |
uint16_t vchan3_v = pForwardGamma[nIndex + 3]; |
| 1376 |
|
| 1377 |
// Special handling for boundary values |
| 1378 |
usGE_Values[i][4] = (i == 0) ? 0 : ((i == 255) ? 0xffff : in_val); |
| 1379 |
usGE_Values[i][5] = vchan1_y; |
| 1380 |
usGE_Values[i][6] = vchan2_u; |
| 1381 |
usGE_Values[i][7] = vchan3_v; |
| 1382 |
} |
| 1383 |
|
| 1384 |
return MOS_STATUS_SUCCESS; |
| 1385 |
} |
| 1386 |
|
| 1387 |
//! |
| 1388 |
//! \brief Helper function for setting up Gamut Compression |
| 1389 |
//! \details Configures gamut compression settings based on compression mode (Basic or Advanced). |
| 1390 |
//! For Basic mode, sets up scaling factor if specified. For Advanced mode, sets up |
| 1391 |
//! full range mapping parameters (D1Out, DOutDefault, DInDefault, D1In). |
| 1392 |
//! Calls SetVertexTableCallback to set up vertex table for the specified color space. |
| 1393 |
//! \param [in,out] pGamutState |
| 1394 |
//! Pointer to VEBOX_GAMUT_CONTROL_STATE_CMD structure |
| 1395 |
//! \param [in] gamutCmd |
| 1396 |
//! Reference to VEBOX_GAMUT_CONTROL_STATE_CMD for constant values |
| 1397 |
//! \param [in] pVeboxGamutParams |
| 1398 |
//! Pointer to gamut parameters |
| 1399 |
//! \param [in] SetVertexTableCallback |
| 1400 |
//! Callback function to set vertex table for the color space |
| 1401 |
//! \return MOS_STATUS |
| 1402 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1403 |
//! |
| 1404 |
template <typename cmd_t> |
| 1405 |
inline MOS_STATUS SetGamutCompression( |
| 1406 |
typename cmd_t::VEBOX_GAMUT_CONTROL_STATE_CMD* pGamutState, |
| 1407 |
const typename cmd_t::VEBOX_GAMUT_CONTROL_STATE_CMD& gamutCmd, |
| 1408 |
PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams) |
| 1409 |
{ |
| 1410 |
MHW_CHK_NULL_RETURN(pGamutState); |
| 1411 |
MHW_CHK_NULL_RETURN(pVeboxGamutParams); |
| 1412 |
|
| 1413 |
if (pVeboxGamutParams->GCompMode == MHW_GAMUT_MODE_BASIC) |
| 1414 |
{ |
| 1415 |
pGamutState->DW15.Fullrangemappingenable = false; |
| 1416 |
|
| 1417 |
if (pVeboxGamutParams->GCompBasicMode == gamutCmd.GCC_BASICMODESELECTION_SCALINGFACTOR) |
| 1418 |
{ |
| 1419 |
pGamutState->DW17.GccBasicmodeselection = gamutCmd.GCC_BASICMODESELECTION_SCALINGFACTOR; |
| 1420 |
pGamutState->DW17.Basicmodescalingfactor = pVeboxGamutParams->iBasicModeScalingFactor; |
| 1421 |
} |
| 1422 |
} |
| 1423 |
else if (pVeboxGamutParams->GCompMode == MHW_GAMUT_MODE_ADVANCED) |
| 1424 |
{ |
| 1425 |
pGamutState->DW15.Fullrangemappingenable = true; |
| 1426 |
pGamutState->DW15.D1Out = pVeboxGamutParams->iDout; |
| 1427 |
pGamutState->DW15.DOutDefault = pVeboxGamutParams->iDoutDefault; |
| 1428 |
pGamutState->DW15.DInDefault = pVeboxGamutParams->iDinDefault; |
| 1429 |
pGamutState->DW16.D1In = pVeboxGamutParams->iDin; |
| 1430 |
} |
| 1431 |
else |
| 1432 |
{ |
| 1433 |
MHW_ASSERTMESSAGE("Invalid GAMUT MODE"); |
| 1434 |
} |
| 1435 |
|
| 1436 |
return MOS_STATUS_SUCCESS; |
| 1437 |
} |
| 1438 |
|
| 1439 |
//! |
| 1440 |
//! \brief Helper function for setting up Color Balance |
| 1441 |
//! \details Configures color balance by setting up CSC coefficients for YUV to RGB conversion |
| 1442 |
//! based on the color space (BT601 or BT709). Sets up gamut state with global mode |
| 1443 |
//! enabled and copies the color correction matrix. Populates GE_Values array with |
| 1444 |
//! identity mapping and copies to gamma correction structure. |
| 1445 |
//! \param [in,out] pIecpState |
| 1446 |
//! Pointer to VEBOX_IECP_STATE_CMD structure |
| 1447 |
//! \param [in] pVeboxGamutParams |
| 1448 |
//! Pointer to gamut parameters |
| 1449 |
//! \param [out] usGE_Values |
| 1450 |
//! 2D array [256][8] for GE values |
| 1451 |
//! \param [out] pVeboxGEGammaCorrection |
| 1452 |
//! Pointer to gamma correction structure |
| 1453 |
//! \return MOS_STATUS |
| 1454 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1455 |
//! |
| 1456 |
template <typename cmd_t> |
| 1457 |
inline MOS_STATUS SetColorBalance( |
| 1458 |
typename cmd_t::VEBOX_IECP_STATE_CMD* pIecpState, |
| 1459 |
PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams, |
| 1460 |
uint16_t usGE_Values[256][8], |
| 1461 |
void* pVeboxGEGammaCorrection) |
| 1462 |
{ |
| 1463 |
MHW_CHK_NULL_RETURN(pIecpState); |
| 1464 |
MHW_CHK_NULL_RETURN(pVeboxGamutParams); |
| 1465 |
MHW_CHK_NULL_RETURN(pVeboxGEGammaCorrection); |
| 1466 |
|
| 1467 |
// Setup CSC coefficients based on color space (Color Balance mode) |
| 1468 |
if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601 || |
| 1469 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC601 || |
| 1470 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601_FullRange) |
| 1471 |
{ |
| 1472 |
SetupCSCCoefficients_BT601(&pIecpState->CscState, true); |
| 1473 |
} |
| 1474 |
else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709 || |
| 1475 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC709 || |
| 1476 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709_FullRange) |
| 1477 |
{ |
| 1478 |
SetupCSCCoefficients_BT709(&pIecpState->CscState, true); |
| 1479 |
} |
| 1480 |
else |
| 1481 |
{ |
| 1482 |
MHW_ASSERTMESSAGE("Unknown primary"); |
| 1483 |
} |
| 1484 |
|
| 1485 |
// Setup gamut state - properly access from pIecpState |
| 1486 |
auto pGamutState = &pIecpState->GamutState; |
| 1487 |
MHW_CHK_NULL_RETURN(pGamutState); |
| 1488 |
pGamutState->DW0.GlobalModeEnable = true; |
| 1489 |
pGamutState->DW1.CmW = 1023; |
| 1490 |
|
| 1491 |
// Copy color correction matrix |
| 1492 |
pGamutState->DW1.C0 = pVeboxGamutParams->Matrix[0][0]; |
| 1493 |
pGamutState->DW0.C1 = pVeboxGamutParams->Matrix[0][1]; |
| 1494 |
pGamutState->DW3.C2 = pVeboxGamutParams->Matrix[0][2]; |
| 1495 |
pGamutState->DW2.C3 = pVeboxGamutParams->Matrix[1][0]; |
| 1496 |
pGamutState->DW5.C4 = pVeboxGamutParams->Matrix[1][1]; |
| 1497 |
pGamutState->DW4.C5 = pVeboxGamutParams->Matrix[1][2]; |
| 1498 |
pGamutState->DW7.C6 = pVeboxGamutParams->Matrix[2][0]; |
| 1499 |
pGamutState->DW6.C7 = pVeboxGamutParams->Matrix[2][1]; |
| 1500 |
pGamutState->DW8.C8 = pVeboxGamutParams->Matrix[2][2]; |
| 1501 |
|
| 1502 |
// Set all offsets to 0 |
| 1503 |
pGamutState->DW9.OffsetInR = 0; |
| 1504 |
pGamutState->DW10.OffsetInG = 0; |
| 1505 |
pGamutState->DW11.OffsetInB = 0; |
| 1506 |
pGamutState->DW12.OffsetOutR = 0; |
| 1507 |
pGamutState->DW13.OffsetOutG = 0; |
| 1508 |
pGamutState->DW14.OffsetOutB = 0; |
| 1509 |
|
| 1510 |
// Populate GE_Values with identity mapping |
| 1511 |
PopulateGEValues_Identity(usGE_Values); |
| 1512 |
|
| 1513 |
// Copy to gamma correction structure (1024 DWords = 256 entries * 8 uint16_t / 2) |
| 1514 |
MOS_SecureMemcpy(pVeboxGEGammaCorrection, sizeof(uint32_t) * 1024, usGE_Values, sizeof(uint16_t) * 8 * 256); |
| 1515 |
|
| 1516 |
return MOS_STATUS_SUCCESS; |
| 1517 |
} |
| 1518 |
|
| 1519 |
//! |
| 1520 |
//! \brief Helper function for setting up Gamut Expansion |
| 1521 |
//! \details Configures gamut expansion by setting up CSC coefficients for YUV to RGB conversion |
| 1522 |
//! based on the color space (BT601 or BT709). Handles both Basic and Advanced gamut |
| 1523 |
//! expansion modes. Copies the color correction matrix to gamut state. |
| 1524 |
//! \param [in,out] pIecpState |
| 1525 |
//! Pointer to VEBOX_IECP_STATE_CMD structure |
| 1526 |
//! \param [in] pVeboxGamutParams |
| 1527 |
//! Pointer to gamut parameters |
| 1528 |
//! \return MOS_STATUS |
| 1529 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1530 |
//! |
| 1531 |
template <typename cmd_t> |
| 1532 |
inline MOS_STATUS SetGamutExpansion( |
| 1533 |
typename cmd_t::VEBOX_IECP_STATE_CMD* pIecpState, |
| 1534 |
PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams) |
| 1535 |
{ |
| 1536 |
MHW_CHK_NULL_RETURN(pIecpState); |
| 1537 |
MHW_CHK_NULL_RETURN(pVeboxGamutParams); |
| 1538 |
|
| 1539 |
// Setup CSC coefficients based on color space (Gamut Expansion mode) |
| 1540 |
if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601 || |
| 1541 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC601 || |
| 1542 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601_FullRange) |
| 1543 |
{ |
| 1544 |
SetupCSCCoefficients_BT601(&pIecpState->CscState, false); |
| 1545 |
} |
| 1546 |
else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709 || |
| 1547 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC709 || |
| 1548 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709_FullRange) |
| 1549 |
{ |
| 1550 |
SetupCSCCoefficients_BT709(&pIecpState->CscState, false); |
| 1551 |
} |
| 1552 |
else |
| 1553 |
{ |
| 1554 |
MHW_ASSERTMESSAGE("Unknown primary"); |
| 1555 |
} |
| 1556 |
|
| 1557 |
// Setup gamut state based on expansion mode - properly access from pIecpState |
| 1558 |
auto pGamutState = &pIecpState->GamutState; |
| 1559 |
MHW_CHK_NULL_RETURN(pGamutState); |
| 1560 |
if (pVeboxGamutParams->GExpMode == MHW_GAMUT_MODE_BASIC) |
| 1561 |
{ |
| 1562 |
pGamutState->DW0.GlobalModeEnable = true; |
| 1563 |
pGamutState->DW1.CmW = 1023; |
| 1564 |
} |
| 1565 |
else if (pVeboxGamutParams->GExpMode == MHW_GAMUT_MODE_ADVANCED) |
| 1566 |
{ |
| 1567 |
pGamutState->DW0.GlobalModeEnable = false; |
| 1568 |
} |
| 1569 |
else |
| 1570 |
{ |
| 1571 |
MHW_ASSERTMESSAGE("Invalid GAMUT MODE"); |
| 1572 |
} |
| 1573 |
|
| 1574 |
// Copy color correction matrix |
| 1575 |
pGamutState->DW1.C0 = pVeboxGamutParams->Matrix[0][0]; |
| 1576 |
pGamutState->DW0.C1 = pVeboxGamutParams->Matrix[0][1]; |
| 1577 |
pGamutState->DW3.C2 = pVeboxGamutParams->Matrix[0][2]; |
| 1578 |
pGamutState->DW2.C3 = pVeboxGamutParams->Matrix[1][0]; |
| 1579 |
pGamutState->DW5.C4 = pVeboxGamutParams->Matrix[1][1]; |
| 1580 |
pGamutState->DW4.C5 = pVeboxGamutParams->Matrix[1][2]; |
| 1581 |
pGamutState->DW7.C6 = pVeboxGamutParams->Matrix[2][0]; |
| 1582 |
pGamutState->DW6.C7 = pVeboxGamutParams->Matrix[2][1]; |
| 1583 |
pGamutState->DW8.C8 = pVeboxGamutParams->Matrix[2][2]; |
| 1584 |
|
| 1585 |
return MOS_STATUS_SUCCESS; |
| 1586 |
} |
| 1587 |
|
| 1588 |
//! |
| 1589 |
//! \brief Helper function for setting up Gamma Correction |
| 1590 |
//! \details Configures gamma correction by setting up CSC coefficients for YUV to RGB conversion |
| 1591 |
//! based on the color space. For BT2020, calls BT2020YUVToRGBCallback. Sets up color |
| 1592 |
//! correction matrix (CCM) for BT2020->BT709/BT601 conversion if needed. Populates |
| 1593 |
//! GE_Values array using power function-based gamma correction or identity mapping. |
| 1594 |
//! \param [in,out] pIecpState |
| 1595 |
//! Pointer to VEBOX_IECP_STATE_CMD structure |
| 1596 |
//! \param [in] pVeboxGamutParams |
| 1597 |
//! Pointer to gamut parameters |
| 1598 |
//! \param [out] usGE_Values |
| 1599 |
//! 2D array [256][8] for GE values |
| 1600 |
//! \param [out] pVeboxGEGammaCorrection |
| 1601 |
//! Pointer to gamma correction structure |
| 1602 |
//! \param [in] pVeboxInterface |
| 1603 |
//! Pointer to VEBOX interface |
| 1604 |
//! \param [in] pVeboxHeap |
| 1605 |
//! Pointer to VEBOX heap |
| 1606 |
//! \param [in] pVeboxIecpParams |
| 1607 |
//! Pointer to IECP parameters |
| 1608 |
//! \return MOS_STATUS |
| 1609 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1610 |
//! |
| 1611 |
template <typename cmd_t, typename T> |
| 1612 |
inline MOS_STATUS SetGammaCorrection( |
| 1613 |
typename cmd_t::VEBOX_IECP_STATE_CMD* pIecpState, |
| 1614 |
PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams, |
| 1615 |
uint16_t usGE_Values[256][8], |
| 1616 |
void* pVeboxGEGammaCorrection, |
| 1617 |
T* pVeboxInterface, |
| 1618 |
MHW_VEBOX_HEAP* pVeboxHeap, |
| 1619 |
PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) |
| 1620 |
{ |
| 1621 |
MHW_CHK_NULL_RETURN(pIecpState); |
| 1622 |
MHW_CHK_NULL_RETURN(pVeboxGamutParams); |
| 1623 |
MHW_CHK_NULL_RETURN(pVeboxGEGammaCorrection); |
| 1624 |
MHW_CHK_NULL_RETURN(pVeboxInterface); |
| 1625 |
|
| 1626 |
// Setup CSC coefficients based on color space (Color Balance mode for gamma correction) |
| 1627 |
if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601 || |
| 1628 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC601 || |
| 1629 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT601_FullRange) |
| 1630 |
{ |
| 1631 |
SetupCSCCoefficients_BT601(&pIecpState->CscState, true); |
| 1632 |
} |
| 1633 |
else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709 || |
| 1634 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_xvYCC709 || |
| 1635 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT709_FullRange) |
| 1636 |
{ |
| 1637 |
SetupCSCCoefficients_BT709(&pIecpState->CscState, true); |
| 1638 |
} |
| 1639 |
else if (pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020 || |
| 1640 |
pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020_FullRange) |
| 1641 |
{ |
| 1642 |
pVeboxInterface->VeboxInterface_BT2020YUVToRGB(pVeboxHeap, pVeboxIecpParams, pVeboxGamutParams); |
| 1643 |
} |
| 1644 |
else |
| 1645 |
{ |
| 1646 |
MHW_ASSERTMESSAGE("Unknown primary"); |
| 1647 |
} |
| 1648 |
|
| 1649 |
// CCM is needed for CSC (BT2020->BT709/BT601 with different gamma) |
| 1650 |
bool bEnableCCM = (pVeboxGamutParams->InputGammaValue != pVeboxGamutParams->OutputGammaValue); |
| 1651 |
|
| 1652 |
// Setup gamut state - properly access from pIecpState |
| 1653 |
auto pGamutState = &pIecpState->GamutState; |
| 1654 |
MHW_CHK_NULL_RETURN(pGamutState); |
| 1655 |
pGamutState->DW0.GlobalModeEnable = true; |
| 1656 |
pGamutState->DW1.CmW = 1023; |
| 1657 |
|
| 1658 |
if ((pVeboxGamutParams->ColorSpace == MHW_CSpace_BT2020) && bEnableCCM) |
| 1659 |
{ |
| 1660 |
if (pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT709) |
| 1661 |
{ |
| 1662 |
// BT2020->BT709 CCM matrix |
| 1663 |
pGamutState->DW1.C0 = 108190; |
| 1664 |
pGamutState->DW0.C1 = MOS_BITFIELD_VALUE((uint32_t)-38288, 21); |
| 1665 |
pGamutState->DW3.C2 = MOS_BITFIELD_VALUE((uint32_t)-4747, 21); |
| 1666 |
pGamutState->DW2.C3 = MOS_BITFIELD_VALUE((uint32_t)-7967, 21); |
| 1667 |
pGamutState->DW5.C4 = 74174; |
| 1668 |
pGamutState->DW4.C5 = MOS_BITFIELD_VALUE((uint32_t)-557, 21); |
| 1669 |
pGamutState->DW7.C6 = MOS_BITFIELD_VALUE((uint32_t)-1198, 21); |
| 1670 |
pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-6587, 21); |
| 1671 |
pGamutState->DW8.C8 = 73321; |
| 1672 |
} |
| 1673 |
else |
| 1674 |
{ |
| 1675 |
// BT2020->BT601 CCM matrix |
| 1676 |
pGamutState->DW1.C0 = 116420; |
| 1677 |
pGamutState->DW0.C1 = MOS_BITFIELD_VALUE((uint32_t)-45094, 21); |
| 1678 |
pGamutState->DW3.C2 = MOS_BITFIELD_VALUE((uint32_t)-5785, 21); |
| 1679 |
pGamutState->DW2.C3 = MOS_BITFIELD_VALUE((uint32_t)-10586, 21); |
| 1680 |
pGamutState->DW5.C4 = 77814; |
| 1681 |
pGamutState->DW4.C5 = MOS_BITFIELD_VALUE((uint32_t)-1705, 21); |
| 1682 |
pGamutState->DW7.C6 = MOS_BITFIELD_VALUE((uint32_t)-1036, 21); |
| 1683 |
pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-6284, 21); |
| 1684 |
pGamutState->DW8.C8 = 72864; |
| 1685 |
} |
| 1686 |
} |
| 1687 |
else |
| 1688 |
{ |
| 1689 |
// Identity matrix |
| 1690 |
pGamutState->DW1.C0 = 65536; |
| 1691 |
pGamutState->DW0.C1 = 0; |
| 1692 |
pGamutState->DW3.C2 = 0; |
| 1693 |
pGamutState->DW2.C3 = 0; |
| 1694 |
pGamutState->DW5.C4 = 65536; |
| 1695 |
pGamutState->DW4.C5 = 0; |
| 1696 |
pGamutState->DW7.C6 = 0; |
| 1697 |
pGamutState->DW6.C7 = 0; |
| 1698 |
pGamutState->DW8.C8 = 65536; |
| 1699 |
pGamutState->DW9.OffsetInR = 0; |
| 1700 |
pGamutState->DW10.OffsetInG = 0; |
| 1701 |
pGamutState->DW11.OffsetInB = 0; |
| 1702 |
pGamutState->DW12.OffsetOutR = 0; |
| 1703 |
pGamutState->DW13.OffsetOutG = 0; |
| 1704 |
pGamutState->DW14.OffsetOutB = 0; |
| 1705 |
} |
| 1706 |
|
| 1707 |
// Map gamma values |
| 1708 |
double dInverseGamma = 1.0; |
| 1709 |
if (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_1P0) |
| 1710 |
{ |
| 1711 |
dInverseGamma = 1.0; |
| 1712 |
} |
| 1713 |
else if (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_2P2) |
| 1714 |
{ |
| 1715 |
dInverseGamma = 2.2; |
| 1716 |
} |
| 1717 |
else if (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_2P6) |
| 1718 |
{ |
| 1719 |
dInverseGamma = 2.6; |
| 1720 |
} |
| 1721 |
else |
| 1722 |
{ |
| 1723 |
MHW_ASSERTMESSAGE("Invalid InputGammaValue"); |
| 1724 |
} |
| 1725 |
|
| 1726 |
double dForwardGamma = 1.0; |
| 1727 |
if (pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_1P0) |
| 1728 |
{ |
| 1729 |
dForwardGamma = 1.0; |
| 1730 |
} |
| 1731 |
else if (pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_2P2) |
| 1732 |
{ |
| 1733 |
dForwardGamma = 2.2; |
| 1734 |
} |
| 1735 |
else if (pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_2P6) |
| 1736 |
{ |
| 1737 |
dForwardGamma = 2.6; |
| 1738 |
} |
| 1739 |
else |
| 1740 |
{ |
| 1741 |
MHW_ASSERTMESSAGE("Invalid OutputGammaValue"); |
| 1742 |
} |
| 1743 |
|
| 1744 |
// Populate GE_Values with gamma correction |
| 1745 |
bool isIdentity = (pVeboxGamutParams->InputGammaValue == MHW_GAMMA_1P0) && |
| 1746 |
(pVeboxGamutParams->OutputGammaValue == MHW_GAMMA_1P0); |
| 1747 |
PopulateGEValues_Gamma(usGE_Values, dInverseGamma, dForwardGamma, isIdentity); |
| 1748 |
|
| 1749 |
// Copy to gamma correction structure |
| 1750 |
if (isIdentity) |
| 1751 |
{ |
| 1752 |
MOS_SecureMemcpy(pVeboxGEGammaCorrection, sizeof(uint32_t) * 1024, usGE_Values, sizeof(uint16_t) * 8 * 256); |
| 1753 |
} |
| 1754 |
else |
| 1755 |
{ |
| 1756 |
MOS_SecureMemcpy(pVeboxGEGammaCorrection, sizeof(uint32_t) * 1020, usGE_Values, sizeof(uint16_t) * 8 * 255); |
| 1757 |
} |
| 1758 |
|
| 1759 |
return MOS_STATUS_SUCCESS; |
| 1760 |
} |
| 1761 |
|
| 1762 |
//! |
| 1763 |
//! \brief Helper function for setting up BT2020 CSC |
| 1764 |
//! \details Configures BT2020 color space conversion with global tone mapping LUTs. |
| 1765 |
//! If 1DLUT is active, sets up CCM from 1DLUT parameters and returns early. |
| 1766 |
//! Otherwise, sets up BT2020->BT709/BT601 CCM matrix, populates GE_Values |
| 1767 |
//! from BT2020 global LUTs, and calls BT2020YUVToRGBCallback. |
| 1768 |
//! \param [in,out] pIecpState |
| 1769 |
//! Pointer to VEBOX_IECP_STATE_CMD structure |
| 1770 |
//! \param [in] pVeboxIecpParams |
| 1771 |
//! Pointer to IECP parameters |
| 1772 |
//! \param [in] pVeboxGamutParams |
| 1773 |
//! Pointer to gamut parameters |
| 1774 |
//! \param [out] usGE_Values |
| 1775 |
//! 2D array [256][8] for GE values |
| 1776 |
//! \param [out] pVeboxGEGammaCorrection |
| 1777 |
//! Pointer to gamma correction structure |
| 1778 |
//! \param [in] pVeboxInterface |
| 1779 |
//! Pointer to VEBOX interface |
| 1780 |
//! \param [in] pVeboxHeap |
| 1781 |
//! Pointer to VEBOX heap |
| 1782 |
//! \return MOS_STATUS |
| 1783 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1784 |
//! |
| 1785 |
template <typename cmd_t, typename T> |
| 1786 |
inline MOS_STATUS SetBT2020CSC( |
| 1787 |
typename cmd_t::VEBOX_IECP_STATE_CMD* pIecpState, |
| 1788 |
PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, |
| 1789 |
PMHW_VEBOX_GAMUT_PARAMS pVeboxGamutParams, |
| 1790 |
uint16_t usGE_Values[256][8], |
| 1791 |
void* pVeboxGEGammaCorrection, |
| 1792 |
T* pVeboxInterface, |
| 1793 |
MHW_VEBOX_HEAP* pVeboxHeap) |
| 1794 |
{ |
| 1795 |
MHW_CHK_NULL_RETURN(pIecpState); |
| 1796 |
MHW_CHK_NULL_RETURN(pVeboxIecpParams); |
| 1797 |
MHW_CHK_NULL_RETURN(pVeboxGamutParams); |
| 1798 |
MHW_CHK_NULL_RETURN(pVeboxGEGammaCorrection); |
| 1799 |
MHW_CHK_NULL_RETURN(pVeboxInterface); |
| 1800 |
|
| 1801 |
// Check if 1DLUT is active |
| 1802 |
if (pVeboxIecpParams->s1DLutParams.bActive) |
| 1803 |
{ |
| 1804 |
// CCM setting if 1DLUT VEBOX HDR enabled |
| 1805 |
auto p1DLutParams = &pVeboxIecpParams->s1DLutParams; |
| 1806 |
|
| 1807 |
pIecpState->CcmState.DW1.C0 = p1DLutParams->pCCM[0]; |
| 1808 |
pIecpState->CcmState.DW0.C1 = MOS_BITFIELD_VALUE((uint32_t)p1DLutParams->pCCM[1], 27); |
| 1809 |
pIecpState->CcmState.DW3.C2 = MOS_BITFIELD_VALUE((uint32_t)p1DLutParams->pCCM[2], 27); |
| 1810 |
pIecpState->CcmState.DW2.C3 = MOS_BITFIELD_VALUE((uint32_t)p1DLutParams->pCCM[3], 27); |
| 1811 |
pIecpState->CcmState.DW5.C4 = p1DLutParams->pCCM[4]; |
| 1812 |
pIecpState->CcmState.DW4.C5 = MOS_BITFIELD_VALUE((uint32_t)p1DLutParams->pCCM[5], 27); |
| 1813 |
pIecpState->CcmState.DW7.C6 = MOS_BITFIELD_VALUE((uint32_t)p1DLutParams->pCCM[6], 27); |
| 1814 |
pIecpState->CcmState.DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)p1DLutParams->pCCM[7], 27); |
| 1815 |
pIecpState->CcmState.DW8.C8 = p1DLutParams->pCCM[8]; |
| 1816 |
pIecpState->CcmState.DW9.OffsetInR = p1DLutParams->pCCM[9]; |
| 1817 |
pIecpState->CcmState.DW10.OffsetInG = p1DLutParams->pCCM[10]; |
| 1818 |
pIecpState->CcmState.DW11.OffsetInB = p1DLutParams->pCCM[11]; |
| 1819 |
pIecpState->CcmState.DW12.OffsetOutR = p1DLutParams->pCCM[12]; |
| 1820 |
pIecpState->CcmState.DW13.OffsetOutG = p1DLutParams->pCCM[13]; |
| 1821 |
pIecpState->CcmState.DW14.OffsetOutB = p1DLutParams->pCCM[14]; |
| 1822 |
|
| 1823 |
auto pGamutState = &pIecpState->GamutState; |
| 1824 |
pGamutState->DW0.GlobalModeEnable = false; |
| 1825 |
|
| 1826 |
// Still need to set CSC params here |
| 1827 |
pVeboxInterface->VeboxInterface_BT2020YUVToRGB(pVeboxHeap, pVeboxIecpParams, pVeboxGamutParams); |
| 1828 |
|
| 1829 |
return MOS_STATUS_SUCCESS; |
| 1830 |
} |
| 1831 |
|
| 1832 |
// Setup gamut state for BT2020 CSC |
| 1833 |
auto pGamutState = &pIecpState->GamutState; |
| 1834 |
pGamutState->DW0.GlobalModeEnable = true; |
| 1835 |
pGamutState->DW1.CmW = 1023; // Colorimetric accurate image |
| 1836 |
|
| 1837 |
if (pVeboxGamutParams->dstColorSpace == MHW_CSpace_BT601) |
| 1838 |
{ |
| 1839 |
// BT2020->BT601 CCM matrix |
| 1840 |
pGamutState->DW1.C0 = 116420; |
| 1841 |
pGamutState->DW0.C1 = MOS_BITFIELD_VALUE((uint32_t)-45094, 21); |
| 1842 |
pGamutState->DW3.C2 = MOS_BITFIELD_VALUE((uint32_t)-5785, 21); |
| 1843 |
pGamutState->DW2.C3 = MOS_BITFIELD_VALUE((uint32_t)-10586, 21); |
| 1844 |
pGamutState->DW5.C4 = 77814; |
| 1845 |
pGamutState->DW4.C5 = MOS_BITFIELD_VALUE((uint32_t)-1705, 21); |
| 1846 |
pGamutState->DW7.C6 = MOS_BITFIELD_VALUE((uint32_t)-1036, 21); |
| 1847 |
pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-6284, 21); |
| 1848 |
pGamutState->DW8.C8 = 72864; |
| 1849 |
} |
| 1850 |
else // BT709, sRGB has same chromaticity CIE 1931 |
| 1851 |
{ |
| 1852 |
// BT2020->BT709 CCM matrix |
| 1853 |
pGamutState->DW1.C0 = 108190; |
| 1854 |
pGamutState->DW0.C1 = MOS_BITFIELD_VALUE((uint32_t)-38288, 21); |
| 1855 |
pGamutState->DW3.C2 = MOS_BITFIELD_VALUE((uint32_t)-4747, 21); |
| 1856 |
pGamutState->DW2.C3 = MOS_BITFIELD_VALUE((uint32_t)-7967, 21); |
| 1857 |
pGamutState->DW5.C4 = 74174; |
| 1858 |
pGamutState->DW4.C5 = MOS_BITFIELD_VALUE((uint32_t)-557, 21); |
| 1859 |
pGamutState->DW7.C6 = MOS_BITFIELD_VALUE((uint32_t)-1198, 21); |
| 1860 |
pGamutState->DW6.C7 = MOS_BITFIELD_VALUE((uint32_t)-6587, 21); |
| 1861 |
pGamutState->DW8.C8 = 73321; |
| 1862 |
} |
| 1863 |
|
| 1864 |
// Populate GE_Values from BT2020 global LUTs |
| 1865 |
PopulateGEValues_BT2020(usGE_Values); |
| 1866 |
|
| 1867 |
// Copy to gamma correction structure (1024 DWords) |
| 1868 |
MOS_SecureMemcpy(pVeboxGEGammaCorrection, sizeof(uint32_t) * 1024, usGE_Values, sizeof(uint16_t) * 8 * 256); |
| 1869 |
|
| 1870 |
// Back end CSC setting, need to convert BT2020 YUV input to RGB before GE |
| 1871 |
pVeboxInterface->VeboxInterface_BT2020YUVToRGB(pVeboxHeap, pVeboxIecpParams, pVeboxGamutParams); |
| 1872 |
|
| 1873 |
return MOS_STATUS_SUCCESS; |
| 1874 |
} |
| 1875 |
|
| 1876 |
//! |
| 1877 |
//! \brief Helper function for setting up 1DLUT Processing |
| 1878 |
//! \details Configures 1DLUT processing with AYUV channel processing for platforms that support it. |
| 1879 |
//! For platforms that don't support full processing, only |
| 1880 |
//! logs a message. For other platforms, sets up gamut state and populates GE_Values |
| 1881 |
//! from 1DLUT data with identity matrix. |
| 1882 |
//! \param [in,out] pGamutState |
| 1883 |
//! Pointer to VEBOX_GAMUT_CONTROL_STATE_CMD structure |
| 1884 |
//! \param [in] pVeboxIecpParams |
| 1885 |
//! Pointer to IECP parameters |
| 1886 |
//! \param [out] usGE_Values |
| 1887 |
//! 2D array [256][8] for GE values |
| 1888 |
//! \param [out] pVeboxGEGammaCorrection |
| 1889 |
//! Pointer to gamma correction structure |
| 1890 |
//! \param [in] enableFullProcessing |
| 1891 |
//! Flag to enable full AYUV processing |
| 1892 |
//! \return MOS_STATUS |
| 1893 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 1894 |
//! |
| 1895 |
template <typename cmd_t> |
| 1896 |
inline MOS_STATUS Set1DLUTProcessing( |
| 1897 |
typename cmd_t::VEBOX_GAMUT_CONTROL_STATE_CMD* pGamutState, |
| 1898 |
PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, |
| 1899 |
uint16_t usGE_Values[256][8], |
| 1900 |
void* pVeboxGEGammaCorrection, |
| 1901 |
bool enableFullProcessing) |
| 1902 |
{ |
| 1903 |
MHW_CHK_NULL_RETURN(pVeboxIecpParams); |
| 1904 |
|
| 1905 |
if (!enableFullProcessing) |
| 1906 |
{ |
| 1907 |
// Platforms that don't support full processing only log for 1DLUT |
| 1908 |
MHW_NORMALMESSAGE("Use VEBOX_SHAPER_1K_LOOKUP_STATE for 1DLUT (4x 1DLUT but Gamut State only has 1DLUT)!"); |
| 1909 |
return MOS_STATUS_SUCCESS; |
| 1910 |
} |
| 1911 |
|
| 1912 |
// Full AYUV processing for other platforms |
| 1913 |
MHW_CHK_NULL_RETURN(pGamutState); |
| 1914 |
MHW_CHK_NULL_RETURN(pVeboxIecpParams); |
| 1915 |
MHW_CHK_NULL_RETURN(pVeboxGEGammaCorrection); |
| 1916 |
|
| 1917 |
// Gamut Expansion setting |
| 1918 |
pGamutState->DW0.GlobalModeEnable = true; |
| 1919 |
pGamutState->DW1.CmW = 1023; |
| 1920 |
|
| 1921 |
// Populate GE_Values from 1DLUT AYUV data |
| 1922 |
MHW_CHK_STATUS_RETURN(PopulateGEValues_1DLUT_AYUV( |
| 1923 |
usGE_Values, |
| 1924 |
(uint16_t*)pVeboxIecpParams->s1DLutParams.p1DLUT, |
| 1925 |
pVeboxIecpParams->s1DLutParams.LUTSize)); |
| 1926 |
|
| 1927 |
// Set identity matrix |
| 1928 |
pGamutState->DW1.C0 = 65536; |
| 1929 |
pGamutState->DW0.C1 = 0; |
| 1930 |
pGamutState->DW3.C2 = 0; |
| 1931 |
pGamutState->DW2.C3 = 0; |
| 1932 |
pGamutState->DW5.C4 = 65536; |
| 1933 |
pGamutState->DW4.C5 = 0; |
| 1934 |
pGamutState->DW7.C6 = 0; |
| 1935 |
pGamutState->DW6.C7 = 0; |
| 1936 |
pGamutState->DW8.C8 = 65536; |
| 1937 |
pGamutState->DW9.OffsetInR = 0; |
| 1938 |
pGamutState->DW10.OffsetInG = 0; |
| 1939 |
pGamutState->DW11.OffsetInB = 0; |
| 1940 |
pGamutState->DW12.OffsetOutR = 0; |
| 1941 |
pGamutState->DW13.OffsetOutG = 0; |
| 1942 |
pGamutState->DW14.OffsetOutB = 0; |
| 1943 |
|
| 1944 |
// Copy to gamma correction structure (1024 DWords) |
| 1945 |
MOS_SecureMemcpy(pVeboxGEGammaCorrection, sizeof(uint32_t) * 1024, usGE_Values, sizeof(uint16_t) * 8 * 256); |
| 1946 |
|
| 1947 |
return MOS_STATUS_SUCCESS; |
| 1948 |
} |
| 1949 |
|
| 1950 |
//! |
| 1951 |
//! \brief Helper function for programming CCM as identity matrix |
| 1952 |
//! \details Sets the Color Correction Matrix to identity (diagonal 0x400000, off-diagonal 0) |
| 1953 |
//! with all offsets zeroed. Used when no color correction is needed. |
| 1954 |
//! \param [in,out] pIecpState |
| 1955 |
//! Pointer to IECP state structure containing CcmState |
| 1956 |
//! \param [in] ccmEnable |
| 1957 |
//! Value to set for ColorCorrectionMatrixEnable flag |
| 1958 |
//! \return void |
| 1959 |
//! |
| 1960 |
template <typename IecpState_t> |
| 1961 |
inline void SetCcmIdentityMatrix(IecpState_t* pIecpState, bool ccmEnable) |
| 1962 |
{ |
| 1963 |
pIecpState->CcmState.DW0.ColorCorrectionMatrixEnable = ccmEnable; |
| 1964 |
pIecpState->CcmState.DW1.C0 = 0x400000; |
| 1965 |
pIecpState->CcmState.DW0.C1 = 0; |
| 1966 |
pIecpState->CcmState.DW3.C2 = 0; |
| 1967 |
pIecpState->CcmState.DW2.C3 = 0; |
| 1968 |
pIecpState->CcmState.DW5.C4 = 0x400000; |
| 1969 |
pIecpState->CcmState.DW4.C5 = 0; |
| 1970 |
pIecpState->CcmState.DW7.C6 = 0; |
| 1971 |
pIecpState->CcmState.DW6.C7 = 0; |
| 1972 |
pIecpState->CcmState.DW8.C8 = 0x400000; |
| 1973 |
pIecpState->CcmState.DW9.OffsetInR = 0; |
| 1974 |
pIecpState->CcmState.DW10.OffsetInG = 0; |
| 1975 |
pIecpState->CcmState.DW11.OffsetInB = 0; |
| 1976 |
pIecpState->CcmState.DW12.OffsetOutR = 0; |
| 1977 |
pIecpState->CcmState.DW13.OffsetOutG = 0; |
| 1978 |
pIecpState->CcmState.DW14.OffsetOutB = 0; |
| 1979 |
} |
| 1980 |
|
| 1981 |
//! |
| 1982 |
//! \brief Helper function for programming CCM based on color space |
| 1983 |
//! \details Programs the Color Correction Matrix coefficients for BT709 or BT2020 |
| 1984 |
//! color spaces. For other color spaces, optionally programs identity matrix |
| 1985 |
//! and always asserts with an error message. |
| 1986 |
//! \param [in,out] pIecpState |
| 1987 |
//! Pointer to IECP state structure containing CcmState |
| 1988 |
//! \param [in] colorSpace |
| 1989 |
//! Input color space (MHW_CSpace_BT709, MHW_CSpace_BT709_FullRange, |
| 1990 |
//! MHW_CSpace_BT2020, MHW_CSpace_BT2020_FullRange, or other) |
| 1991 |
//! \param [in] programFallbackIdentity |
| 1992 |
//! If true, programs identity matrix for unsupported color spaces before asserting. |
| 1993 |
//! If false, only asserts without programming |
| 1994 |
//! \return void |
| 1995 |
//! |
| 1996 |
template <typename IecpState_t> |
| 1997 |
inline void SetCcmColorSpace(IecpState_t* pIecpState, MHW_CSPACE colorSpace, bool programFallbackIdentity = true) |
| 1998 |
{ |
| 1999 |
// Always disable CCM enable for color space programming |
| 2000 |
pIecpState->CcmState.DW0.ColorCorrectionMatrixEnable = false; |
| 2001 |
|
| 2002 |
if ((colorSpace == MHW_CSpace_BT709) || (colorSpace == MHW_CSpace_BT709_FullRange)) |
| 2003 |
{ |
| 2004 |
// BT709 CCM coefficients |
| 2005 |
pIecpState->CcmState.DW1.C0 = 0x00009937; |
| 2006 |
pIecpState->CcmState.DW0.C1 = 0x000115f6; |
| 2007 |
pIecpState->CcmState.DW3.C2 = 0; |
| 2008 |
pIecpState->CcmState.DW2.C3 = 0x00009937; |
| 2009 |
pIecpState->CcmState.DW5.C4 = 0x07ffe3f1; |
| 2010 |
pIecpState->CcmState.DW4.C5 = 0x07ffb9e0; |
| 2011 |
pIecpState->CcmState.DW7.C6 = 0x00009937; |
| 2012 |
pIecpState->CcmState.DW6.C7 = 0; |
| 2013 |
pIecpState->CcmState.DW8.C8 = 0x0000ebe6; |
| 2014 |
// Limited range BT709 has non-zero input offsets; full range has zero offsets |
| 2015 |
pIecpState->CcmState.DW9.OffsetInR = (colorSpace == MHW_CSpace_BT709) ? 0xf8000000 : 0; |
| 2016 |
pIecpState->CcmState.DW10.OffsetInG = (colorSpace == MHW_CSpace_BT709) ? 0xc0000000 : 0; |
| 2017 |
pIecpState->CcmState.DW11.OffsetInB = (colorSpace == MHW_CSpace_BT709) ? 0xc0000000 : 0; |
| 2018 |
pIecpState->CcmState.DW12.OffsetOutR = 0; |
| 2019 |
pIecpState->CcmState.DW13.OffsetOutG = 0; |
| 2020 |
pIecpState->CcmState.DW14.OffsetOutB = 0; |
| 2021 |
} |
| 2022 |
else if ((colorSpace == MHW_CSpace_BT2020) || (colorSpace == MHW_CSpace_BT2020_FullRange)) |
| 2023 |
{ |
| 2024 |
// BT2020 CCM coefficients |
| 2025 |
pIecpState->CcmState.DW1.C0 = 0x00009937; |
| 2026 |
pIecpState->CcmState.DW0.C1 = 0x000119d4; |
| 2027 |
pIecpState->CcmState.DW3.C2 = 0; |
| 2028 |
pIecpState->CcmState.DW2.C3 = 0x00009937; |
| 2029 |
pIecpState->CcmState.DW5.C4 = 0x07ffe75a; |
| 2030 |
pIecpState->CcmState.DW4.C5 = 0x07ffaa6a; |
| 2031 |
pIecpState->CcmState.DW7.C6 = 0x00009937; |
| 2032 |
pIecpState->CcmState.DW6.C7 = 0; |
| 2033 |
pIecpState->CcmState.DW8.C8 = 0x0000dce4; |
| 2034 |
// Limited range BT2020 has non-zero input offsets; full range has zero offsets |
| 2035 |
pIecpState->CcmState.DW9.OffsetInR = (colorSpace == MHW_CSpace_BT2020) ? 0xf8000000 : 0; |
| 2036 |
pIecpState->CcmState.DW10.OffsetInG = (colorSpace == MHW_CSpace_BT2020) ? 0xc0000000 : 0; |
| 2037 |
pIecpState->CcmState.DW11.OffsetInB = (colorSpace == MHW_CSpace_BT2020) ? 0xc0000000 : 0; |
| 2038 |
pIecpState->CcmState.DW12.OffsetOutR = 0; |
| 2039 |
pIecpState->CcmState.DW13.OffsetOutG = 0; |
| 2040 |
pIecpState->CcmState.DW14.OffsetOutB = 0; |
| 2041 |
} |
| 2042 |
else |
| 2043 |
{ |
| 2044 |
// Unsupported color space: optionally program identity matrix, then assert |
| 2045 |
if (programFallbackIdentity) |
| 2046 |
{ |
| 2047 |
SetCcmIdentityMatrix(pIecpState, false); |
| 2048 |
} |
| 2049 |
MHW_ASSERTMESSAGE("Unsupported Input Color Space!"); |
| 2050 |
} |
| 2051 |
} |
| 2052 |
|
| 2053 |
//! |
| 2054 |
//! \brief Helper function for programming identity forward gamma LUT |
| 2055 |
//! \details Programs the forward gamma LUT with identity mapping (256*i for each entry). |
| 2056 |
//! Handles two special-entry modes: dual (entries 254 and 255) or single (entry 255 only). |
| 2057 |
//! \param [in,out] pForwardGamma |
| 2058 |
//! Pointer to array of forward gamma correction state entries |
| 2059 |
//! \param [in] loopBound |
| 2060 |
//! Number of entries to fill with identity (254 for dual-special-entry mode, |
| 2061 |
//! 255 for single-special-entry mode) |
| 2062 |
//! \param [in] dualSpecialEntries |
| 2063 |
//! If true, entries 254 and 255 are both special. |
| 2064 |
//! If false, only entry 255 is special. |
| 2065 |
//! \return void |
| 2066 |
//! |
| 2067 |
template <typename FwdGamma_t> |
| 2068 |
inline void SetForwardGammaIdentity(FwdGamma_t* pForwardGamma, uint32_t loopBound, bool dualSpecialEntries) |
| 2069 |
{ |
| 2070 |
// Fill identity entries from 0 to loopBound (exclusive) |
| 2071 |
for (uint32_t i = 0; i < loopBound; i++) |
| 2072 |
{ |
| 2073 |
pForwardGamma[i].DW0.PointValueForForwardGammaLut = 256 * i; |
| 2074 |
pForwardGamma[i].DW1.ForwardRChannelGammaCorrectionValue = 256 * i; |
| 2075 |
pForwardGamma[i].DW2.ForwardGChannelGammaCorrectionValue = 256 * i; |
| 2076 |
pForwardGamma[i].DW3.ForwardBChannelGammaCorrectionValue = 256 * i; |
| 2077 |
} |
| 2078 |
|
| 2079 |
if (dualSpecialEntries) |
| 2080 |
{ |
| 2081 |
// Dual special entries: entry 254 is all 0xffff, entry 255 point is 0xffffffff |
| 2082 |
pForwardGamma[254].DW0.PointValueForForwardGammaLut = 0xffff; |
| 2083 |
pForwardGamma[254].DW1.ForwardRChannelGammaCorrectionValue = 0xffff; |
| 2084 |
pForwardGamma[254].DW2.ForwardGChannelGammaCorrectionValue = 0xffff; |
| 2085 |
pForwardGamma[254].DW3.ForwardBChannelGammaCorrectionValue = 0xffff; |
| 2086 |
|
| 2087 |
pForwardGamma[255].DW0.PointValueForForwardGammaLut = 0xffffffff; |
| 2088 |
} |
| 2089 |
else |
| 2090 |
{ |
| 2091 |
// Single special entry: entry 255 point is 0xffff |
| 2092 |
pForwardGamma[255].DW0.PointValueForForwardGammaLut = 0xffff; |
| 2093 |
} |
| 2094 |
|
| 2095 |
// Entry 255 channel values are always 0xffff |
| 2096 |
pForwardGamma[255].DW1.ForwardRChannelGammaCorrectionValue = 0xffff; |
| 2097 |
pForwardGamma[255].DW2.ForwardGChannelGammaCorrectionValue = 0xffff; |
| 2098 |
pForwardGamma[255].DW3.ForwardBChannelGammaCorrectionValue = 0xffff; |
| 2099 |
} |
| 2100 |
|
| 2101 |
//! |
| 2102 |
//! \brief Helper function for programming inverse gamma from API-provided 1D LUT |
| 2103 |
//! \details Programs the inverse gamma LUT entries from the API-provided 1D LUT data |
| 2104 |
//! for the active range, and zeros out the remaining entries up to fullSize. |
| 2105 |
//! \param [in,out] pInverseGamma |
| 2106 |
//! Pointer to array of inverse gamma correction state entries |
| 2107 |
//! \param [in] p1DLut |
| 2108 |
//! Pointer to 1D LUT data (4 uint16_t values per entry: index, R, G, B) |
| 2109 |
//! \param [in] lutSize |
| 2110 |
//! Number of active LUT entries to program from p1DLut |
| 2111 |
//! \param [in] fullSize |
| 2112 |
//! Total number of inverse gamma entries in hardware (4096 for older platforms, |
| 2113 |
//! 1024 for newer platforms) |
| 2114 |
//! \return void |
| 2115 |
//! |
| 2116 |
template <typename InvGamma_t> |
| 2117 |
inline void SetInverseGammaFromLut(InvGamma_t* pInverseGamma, uint16_t* p1DLut, uint32_t lutSize, uint32_t fullSize) |
| 2118 |
{ |
| 2119 |
// Program active LUT entries from API-provided data |
| 2120 |
for (uint32_t i = 0; i < lutSize; i++) |
| 2121 |
{ |
| 2122 |
pInverseGamma[i].DW0.Value = 0; |
| 2123 |
pInverseGamma[i].DW1.InverseRChannelGammaCorrectionValue = (uint32_t)(p1DLut[4 * i + 1]); // 32-bit precision |
| 2124 |
pInverseGamma[i].DW2.InverseGChannelGammaCorrectionValue = (uint32_t)(p1DLut[4 * i + 2]); // 32-bit precision |
| 2125 |
pInverseGamma[i].DW3.InverseBChannelGammaCorrectionValue = (uint32_t)(p1DLut[4 * i + 3]); // 32-bit precision |
| 2126 |
} |
| 2127 |
|
| 2128 |
// Zero out remaining entries beyond the active LUT range |
| 2129 |
for (uint32_t i = lutSize; i < fullSize; i++) |
| 2130 |
{ |
| 2131 |
pInverseGamma[i].DW0.Value = 0; |
| 2132 |
pInverseGamma[i].DW1.InverseRChannelGammaCorrectionValue = 0; |
| 2133 |
pInverseGamma[i].DW2.InverseGChannelGammaCorrectionValue = 0; |
| 2134 |
pInverseGamma[i].DW3.InverseBChannelGammaCorrectionValue = 0; |
| 2135 |
} |
| 2136 |
} |
| 2137 |
|
| 2138 |
//! |
| 2139 |
//! \brief Helper function for programming identity inverse gamma LUT |
| 2140 |
//! \details Programs the inverse gamma LUT with identity mapping using linear interpolation |
| 2141 |
//! from 0 to maxValLutOut. The last entry is always set to maxValLutOut exactly. |
| 2142 |
//! \param [in,out] pInverseGamma |
| 2143 |
//! Pointer to array of inverse gamma correction state entries |
| 2144 |
//! \param [in] nLutInBitDepth |
| 2145 |
//! Bit depth of the LUT input (e.g., 12 for 4096-entry LUT, 10 for 1024-entry LUT) |
| 2146 |
//! \param [in] totalEntries |
| 2147 |
//! Total number of entries to program (e.g., 4096 or 1024) |
| 2148 |
//! \return void |
| 2149 |
//! |
| 2150 |
template <typename InvGamma_t> |
| 2151 |
inline void SetInverseGammaIdentity(InvGamma_t* pInverseGamma, uint32_t nLutInBitDepth, uint32_t totalEntries) |
| 2152 |
{ |
| 2153 |
uint64_t maxValLutIn = (((uint64_t)1) << nLutInBitDepth) - 1; |
| 2154 |
uint64_t maxValLutOut = (((uint64_t)1) << 32) - 1; |
| 2155 |
uint32_t lastEntry = totalEntries - 1; |
| 2156 |
|
| 2157 |
for (uint32_t i = 0; i < totalEntries; i++) |
| 2158 |
{ |
| 2159 |
float x = (float)i / (float)maxValLutIn; |
| 2160 |
uint32_t nCorrectedValue = (i < lastEntry) ? (uint32_t)(x * (float)maxValLutOut + 0.5f) : (uint32_t)maxValLutOut; |
| 2161 |
|
| 2162 |
pInverseGamma[i].DW0.Value = 0; |
| 2163 |
pInverseGamma[i].DW1.InverseRChannelGammaCorrectionValue = nCorrectedValue; |
| 2164 |
pInverseGamma[i].DW2.InverseGChannelGammaCorrectionValue = nCorrectedValue; |
| 2165 |
pInverseGamma[i].DW3.InverseBChannelGammaCorrectionValue = nCorrectedValue; |
| 2166 |
} |
| 2167 |
} |
| 2168 |
|
| 2169 |
//! |
| 2170 |
//! \brief Helper function for VEBOX input format determination |
| 2171 |
//! \details Extracts input format determination logic shared across all platforms. |
| 2172 |
//! This helper function encapsulates the primary format switch (handling |
| 2173 |
//! 25+ surface formats including YUV, RGB, Bayer patterns) for VeboxInputFormat. |
| 2174 |
//! Each platform's VeboxInputFormat can call this helper and only handle |
| 2175 |
//! platform-specific differences. |
| 2176 |
//! \param [in] pCurrSurf |
| 2177 |
//! Pointer to current surface parameters containing format information |
| 2178 |
//! \param [out] dwFormat |
| 2179 |
//! Pointer to format value to be set |
| 2180 |
//! \param [in] VeboxSurfaceState |
| 2181 |
//! Reference to VEBOX_SURFACE_STATE command structure (used for format constants) |
| 2182 |
//! \return MOS_STATUS |
| 2183 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2184 |
//! |
| 2185 |
template <typename SurfaceStateType> |
| 2186 |
inline MOS_STATUS VeboxInputFormat( |
| 2187 |
PMHW_VEBOX_SURFACE_PARAMS pCurrSurf, |
| 2188 |
uint32_t *dwFormat, |
| 2189 |
SurfaceStateType &VeboxSurfaceState) |
| 2190 |
{ |
| 2191 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2192 |
|
| 2193 |
switch (pCurrSurf->Format) |
| 2194 |
{ |
| 2195 |
case Format_NV12: |
| 2196 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR4208; |
| 2197 |
break; |
| 2198 |
|
| 2199 |
case Format_YUYV: |
| 2200 |
case Format_YUY2: |
| 2201 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBNORMAL; |
| 2202 |
break; |
| 2203 |
|
| 2204 |
case Format_UYVY: |
| 2205 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPY; |
| 2206 |
break; |
| 2207 |
|
| 2208 |
case Format_AYUV: |
| 2209 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED444A8; |
| 2210 |
break; |
| 2211 |
|
| 2212 |
case Format_Y416: |
| 2213 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED44416; |
| 2214 |
break; |
| 2215 |
|
| 2216 |
case Format_Y410: |
| 2217 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED44410; |
| 2218 |
break; |
| 2219 |
|
| 2220 |
case Format_YVYU: |
| 2221 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPUV; |
| 2222 |
break; |
| 2223 |
|
| 2224 |
case Format_VYUY: |
| 2225 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_YCRCBSWAPUVY; |
| 2226 |
break; |
| 2227 |
|
| 2228 |
case Format_A8B8G8R8: |
| 2229 |
case Format_X8B8G8R8: |
| 2230 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R8G8B8A8UNORMR8G8B8A8UNORMSRGB; |
| 2231 |
break; |
| 2232 |
|
| 2233 |
case Format_A16B16G16R16: |
| 2234 |
case Format_A16R16G16B16: |
| 2235 |
case Format_A16B16G16R16F: |
| 2236 |
case Format_A16R16G16B16F: |
| 2237 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R16G16B16A16; |
| 2238 |
break; |
| 2239 |
|
| 2240 |
case Format_L8: |
| 2241 |
case Format_P8: |
| 2242 |
case Format_Y8: |
| 2243 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_Y8UNORM; |
| 2244 |
break; |
| 2245 |
|
| 2246 |
case Format_IRW0: |
| 2247 |
case Format_IRW1: |
| 2248 |
case Format_IRW2: |
| 2249 |
case Format_IRW3: |
| 2250 |
case Format_IRW4: |
| 2251 |
case Format_IRW5: |
| 2252 |
case Format_IRW6: |
| 2253 |
case Format_IRW7: |
| 2254 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_BAYERPATTERN; |
| 2255 |
break; |
| 2256 |
|
| 2257 |
case Format_P010: |
| 2258 |
case Format_P016: |
| 2259 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR42016; |
| 2260 |
break; |
| 2261 |
|
| 2262 |
case Format_A8R8G8B8: |
| 2263 |
case Format_X8R8G8B8: |
| 2264 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R8G8B8A8UNORMR8G8B8A8UNORMSRGB; |
| 2265 |
break; |
| 2266 |
|
| 2267 |
case Format_R10G10B10A2: |
| 2268 |
case Format_B10G10R10A2: |
| 2269 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_R10G10B10A2UNORMR10G10B10A2UNORMSRGB; |
| 2270 |
break; |
| 2271 |
|
| 2272 |
case Format_Y216: |
| 2273 |
case Format_Y210: |
| 2274 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PACKED42216; |
| 2275 |
break; |
| 2276 |
|
| 2277 |
case Format_P216: |
| 2278 |
case Format_P210: |
| 2279 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_PLANAR42216; |
| 2280 |
break; |
| 2281 |
|
| 2282 |
case Format_Y16S: |
| 2283 |
case Format_Y16U: |
| 2284 |
*dwFormat = VeboxSurfaceState.SURFACE_FORMAT_Y16UNORM; |
| 2285 |
break; |
| 2286 |
|
| 2287 |
default: |
| 2288 |
MHW_ASSERTMESSAGE("Unsupported format."); |
| 2289 |
break; |
| 2290 |
} |
| 2291 |
|
| 2292 |
return eStatus; |
| 2293 |
} |
| 2294 |
|
| 2295 |
//! |
| 2296 |
//! \brief Helper function for VEB_DI_IECP surface resource binding |
| 2297 |
//! \details Handles all 11 surface resource binding blocks (DW2 through DW22) |
| 2298 |
//! for the VEB_DI_IECP command. This is the common logic shared across |
| 2299 |
//! all platforms. Platform-specific MMC field assignments (e.g., |
| 2300 |
//! MemoryCompressionEnable, CompressionType) should be done before |
| 2301 |
//! calling this helper. |
| 2302 |
//! \param [in,out] cmd |
| 2303 |
//! Reference to VEB_DI_IECP command structure |
| 2304 |
//! \param [in] params |
| 2305 |
//! Reference to VEB_DI_IECP parameters |
| 2306 |
//! \param [in] pOsInterface |
| 2307 |
//! Pointer to OS interface |
| 2308 |
//! \param [in] pCmdBuffer |
| 2309 |
//! Pointer to command buffer |
| 2310 |
//! \param [in] AddResourceToCmd |
| 2311 |
//! Function pointer to AddResourceToCmd |
| 2312 |
//! \return MOS_STATUS |
| 2313 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2314 |
//! |
| 2315 |
template <typename cmd_t, typename ParamsT> |
| 2316 |
inline MOS_STATUS VebDiIecpSetResources( |
| 2317 |
typename cmd_t::VEB_DI_IECP_CMD &cmd, |
| 2318 |
const ParamsT ¶ms, |
| 2319 |
PMOS_INTERFACE pOsInterface, |
| 2320 |
PMOS_COMMAND_BUFFER pCmdBuffer, |
| 2321 |
MOS_STATUS (*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 2322 |
{ |
| 2323 |
MHW_RESOURCE_PARAMS resourceParams = {}; |
| 2324 |
|
| 2325 |
// Block 1 — pOsResCurrInput (DW2) |
| 2326 |
if (params.pOsResCurrInput) |
| 2327 |
{ |
| 2328 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2329 |
resourceParams.presResource = params.pOsResCurrInput; |
| 2330 |
resourceParams.dwOffset = params.dwCurrInputSurfOffset + params.CurrInputSurfCtrl.Value; |
| 2331 |
resourceParams.pdwCmd = &(cmd.DW2.Value); |
| 2332 |
resourceParams.dwLocationInCmd = 2; |
| 2333 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2334 |
|
| 2335 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2336 |
pOsInterface, |
| 2337 |
pCmdBuffer, |
| 2338 |
&resourceParams)); |
| 2339 |
} |
| 2340 |
|
| 2341 |
// Block 2 — pOsResPrevInput (DW4) |
| 2342 |
if (params.pOsResPrevInput) |
| 2343 |
{ |
| 2344 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2345 |
resourceParams.presResource = params.pOsResPrevInput; |
| 2346 |
resourceParams.dwOffset = params.PrevInputSurfCtrl.Value + params.dwPrevInputSurfOffset; |
| 2347 |
resourceParams.pdwCmd = &(cmd.DW4.Value); |
| 2348 |
resourceParams.dwLocationInCmd = 4; |
| 2349 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2350 |
|
| 2351 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2352 |
pOsInterface, |
| 2353 |
pCmdBuffer, |
| 2354 |
&resourceParams)); |
| 2355 |
} |
| 2356 |
|
| 2357 |
// Block 3 — pOsResStmmInput (DW6) |
| 2358 |
if (params.pOsResStmmInput) |
| 2359 |
{ |
| 2360 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2361 |
resourceParams.presResource = params.pOsResStmmInput; |
| 2362 |
resourceParams.dwOffset = params.StmmInputSurfCtrl.Value; |
| 2363 |
resourceParams.pdwCmd = &(cmd.DW6.Value); |
| 2364 |
resourceParams.dwLocationInCmd = 6; |
| 2365 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2366 |
|
| 2367 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2368 |
pOsInterface, |
| 2369 |
pCmdBuffer, |
| 2370 |
&resourceParams)); |
| 2371 |
} |
| 2372 |
|
| 2373 |
// Block 4 — pOsResStmmOutput (DW8) |
| 2374 |
if (params.pOsResStmmOutput) |
| 2375 |
{ |
| 2376 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2377 |
resourceParams.presResource = params.pOsResStmmOutput; |
| 2378 |
resourceParams.dwOffset = params.StmmOutputSurfCtrl.Value; |
| 2379 |
resourceParams.pdwCmd = &(cmd.DW8.Value); |
| 2380 |
resourceParams.dwLocationInCmd = 8; |
| 2381 |
resourceParams.bIsWritable = true; |
| 2382 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2383 |
|
| 2384 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2385 |
pOsInterface, |
| 2386 |
pCmdBuffer, |
| 2387 |
&resourceParams)); |
| 2388 |
} |
| 2389 |
|
| 2390 |
// Block 5 — pOsResDenoisedCurrOutput (DW10) |
| 2391 |
if (params.pOsResDenoisedCurrOutput) |
| 2392 |
{ |
| 2393 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2394 |
resourceParams.presResource = params.pOsResDenoisedCurrOutput; |
| 2395 |
resourceParams.dwOffset = params.DenoisedCurrOutputSurfCtrl.Value; |
| 2396 |
resourceParams.pdwCmd = &(cmd.DW10.Value); |
| 2397 |
resourceParams.dwLocationInCmd = 10; |
| 2398 |
resourceParams.bIsWritable = true; |
| 2399 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2400 |
|
| 2401 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2402 |
pOsInterface, |
| 2403 |
pCmdBuffer, |
| 2404 |
&resourceParams)); |
| 2405 |
} |
| 2406 |
|
| 2407 |
// Block 6 — pOsResCurrOutput (DW12) |
| 2408 |
if (params.pOsResCurrOutput) |
| 2409 |
{ |
| 2410 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2411 |
resourceParams.presResource = params.pOsResCurrOutput; |
| 2412 |
resourceParams.dwOffset = params.CurrOutputSurfCtrl.Value + params.dwCurrOutputSurfOffset; |
| 2413 |
resourceParams.pdwCmd = &(cmd.DW12.Value); |
| 2414 |
resourceParams.dwLocationInCmd = 12; |
| 2415 |
resourceParams.bIsWritable = true; |
| 2416 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2417 |
|
| 2418 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2419 |
pOsInterface, |
| 2420 |
pCmdBuffer, |
| 2421 |
&resourceParams)); |
| 2422 |
} |
| 2423 |
|
| 2424 |
// Block 7 — pOsResPrevOutput (DW14) |
| 2425 |
if (params.pOsResPrevOutput) |
| 2426 |
{ |
| 2427 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2428 |
resourceParams.presResource = params.pOsResPrevOutput; |
| 2429 |
resourceParams.dwOffset = params.PrevOutputSurfCtrl.Value; |
| 2430 |
resourceParams.pdwCmd = &(cmd.DW14.Value); |
| 2431 |
resourceParams.dwLocationInCmd = 14; |
| 2432 |
resourceParams.bIsWritable = true; |
| 2433 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2434 |
|
| 2435 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2436 |
pOsInterface, |
| 2437 |
pCmdBuffer, |
| 2438 |
&resourceParams)); |
| 2439 |
} |
| 2440 |
|
| 2441 |
// Block 8 — pOsResStatisticsOutput (DW16) |
| 2442 |
if (params.pOsResStatisticsOutput) |
| 2443 |
{ |
| 2444 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2445 |
resourceParams.presResource = params.pOsResStatisticsOutput; |
| 2446 |
resourceParams.dwOffset = params.StatisticsOutputSurfCtrl.Value; |
| 2447 |
resourceParams.pdwCmd = &(cmd.DW16.Value); |
| 2448 |
resourceParams.dwLocationInCmd = 16; |
| 2449 |
resourceParams.bIsWritable = true; |
| 2450 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2451 |
|
| 2452 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2453 |
pOsInterface, |
| 2454 |
pCmdBuffer, |
| 2455 |
&resourceParams)); |
| 2456 |
} |
| 2457 |
|
| 2458 |
// Block 9 — pOsResAlphaOrVignette (DW18) |
| 2459 |
if (params.pOsResAlphaOrVignette) |
| 2460 |
{ |
| 2461 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2462 |
resourceParams.presResource = params.pOsResAlphaOrVignette; |
| 2463 |
resourceParams.dwOffset = params.AlphaOrVignetteSurfCtrl.Value; |
| 2464 |
resourceParams.pdwCmd = &(cmd.DW18.Value); |
| 2465 |
resourceParams.dwLocationInCmd = 18; |
| 2466 |
resourceParams.bIsWritable = true; |
| 2467 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2468 |
|
| 2469 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2470 |
pOsInterface, |
| 2471 |
pCmdBuffer, |
| 2472 |
&resourceParams)); |
| 2473 |
} |
| 2474 |
|
| 2475 |
// Block 10 — pOsResLaceOrAceOrRgbHistogram (DW20) |
| 2476 |
if (params.pOsResLaceOrAceOrRgbHistogram) |
| 2477 |
{ |
| 2478 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2479 |
resourceParams.presResource = params.pOsResLaceOrAceOrRgbHistogram; |
| 2480 |
resourceParams.dwOffset = params.LaceOrAceOrRgbHistogramSurfCtrl.Value; |
| 2481 |
resourceParams.pdwCmd = &(cmd.DW20.Value); |
| 2482 |
resourceParams.dwLocationInCmd = 20; |
| 2483 |
resourceParams.bIsWritable = true; |
| 2484 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2485 |
|
| 2486 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2487 |
pOsInterface, |
| 2488 |
pCmdBuffer, |
| 2489 |
&resourceParams)); |
| 2490 |
} |
| 2491 |
|
| 2492 |
// Block 11 — pOsResSkinScoreSurface (DW22) |
| 2493 |
if (params.pOsResSkinScoreSurface) |
| 2494 |
{ |
| 2495 |
MOS_ZeroMemory(&resourceParams, sizeof(resourceParams)); |
| 2496 |
resourceParams.presResource = params.pOsResSkinScoreSurface; |
| 2497 |
resourceParams.dwOffset = params.SkinScoreSurfaceSurfCtrl.Value; |
| 2498 |
resourceParams.pdwCmd = &(cmd.DW22.Value); |
| 2499 |
resourceParams.dwLocationInCmd = 22; |
| 2500 |
resourceParams.bIsWritable = true; |
| 2501 |
resourceParams.HwCommandType = MOS_VEBOX_DI_IECP; |
| 2502 |
|
| 2503 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd( |
| 2504 |
pOsInterface, |
| 2505 |
pCmdBuffer, |
| 2506 |
&resourceParams)); |
| 2507 |
} |
| 2508 |
|
| 2509 |
return MOS_STATUS_SUCCESS; |
| 2510 |
} |
| 2511 |
|
| 2512 |
//! |
| 2513 |
//! \brief Helper function for VEB_DI_IECP scalability X coordinate calculation |
| 2514 |
//! \details Handles the vebox scalability X coordinate calculation block for the |
| 2515 |
//! VEB_DI_IECP command. This is the common logic shared across all platforms. |
| 2516 |
//! When scalability is disabled, simply sets EndingX and StartingX from params. |
| 2517 |
//! When scalability is enabled, computes the medium X split point and assigns |
| 2518 |
//! per-vebox start/end coordinates, with optional SFC overfetch adjustments. |
| 2519 |
//! \param [in,out] cmd |
| 2520 |
//! Reference to VEB_DI_IECP command structure |
| 2521 |
//! \param [in] params |
| 2522 |
//! Reference to VEB_DI_IECP parameters |
| 2523 |
//! \param [in] bVeboxScalabilityEnabled |
| 2524 |
//! Whether VEBOX scalability is enabled |
| 2525 |
//! \param [in] numVebox |
| 2526 |
//! Number of VEBOX |
| 2527 |
//! \param [in] indexofVebox |
| 2528 |
//! Index of current VEBOX |
| 2529 |
//! \param [in] bUsingSfc |
| 2530 |
//! Whether SFC is used |
| 2531 |
//! \return void |
| 2532 |
//! |
| 2533 |
template <typename cmd_t, typename ParamsT> |
| 2534 |
inline void VebDiIecpSetScalability( |
| 2535 |
typename cmd_t::VEB_DI_IECP_CMD &cmd, |
| 2536 |
const ParamsT ¶ms, |
| 2537 |
bool bVeboxScalabilityEnabled, |
| 2538 |
uint32_t numVebox, |
| 2539 |
uint32_t indexofVebox, |
| 2540 |
bool bUsingSfc) |
| 2541 |
{ |
| 2542 |
if (bVeboxScalabilityEnabled == false) |
| 2543 |
{ |
| 2544 |
cmd.DW1.EndingX = params.dwEndingX; |
| 2545 |
cmd.DW1.StartingX = params.dwStartingX; |
| 2546 |
} |
| 2547 |
else |
| 2548 |
{ |
| 2549 |
uint32_t iMediumX; |
| 2550 |
MHW_ASSERT(params.dwEndingX >= numVebox * 64 - 1); |
| 2551 |
|
| 2552 |
iMediumX = MOS_ALIGN_FLOOR(((params.dwEndingX + 1) / numVebox), 64); |
| 2553 |
iMediumX = MOS_CLAMP_MIN_MAX(iMediumX, 64, (params.dwEndingX - 63)); |
| 2554 |
|
| 2555 |
if (numVebox > 1) |
| 2556 |
{ |
| 2557 |
if (indexofVebox == MHW_VEBOX_STARTING_INDEX) |
| 2558 |
{ |
| 2559 |
cmd.DW1.EndingX = iMediumX - 1; |
| 2560 |
cmd.DW1.StartingX = params.dwStartingX; |
| 2561 |
} |
| 2562 |
else if (indexofVebox == numVebox - 1) |
| 2563 |
{ |
| 2564 |
cmd.DW1.EndingX = params.dwEndingX; |
| 2565 |
cmd.DW1.StartingX = indexofVebox * iMediumX; |
| 2566 |
} |
| 2567 |
else if (indexofVebox < numVebox - 1) |
| 2568 |
{ |
| 2569 |
cmd.DW1.EndingX = (indexofVebox + 1) * iMediumX - 1; |
| 2570 |
cmd.DW1.StartingX = indexofVebox * iMediumX; |
| 2571 |
} |
| 2572 |
else |
| 2573 |
{ |
| 2574 |
MHW_ASSERTMESSAGE("Unsupported Vebox Scalability Settings"); |
| 2575 |
} |
| 2576 |
} |
| 2577 |
|
| 2578 |
if (bUsingSfc) |
| 2579 |
{ |
| 2580 |
cmd.DW1.SplitWorkloadEnable = true; |
| 2581 |
|
| 2582 |
if ((params.dwEndingX + 1) != numVebox * iMediumX) |
| 2583 |
{ |
| 2584 |
if (indexofVebox < numVebox - 1) |
| 2585 |
{ |
| 2586 |
cmd.DW1.EndingX += 64; |
| 2587 |
} |
| 2588 |
|
| 2589 |
if (indexofVebox > MHW_VEBOX_STARTING_INDEX) |
| 2590 |
{ |
| 2591 |
cmd.DW1.StartingX += 64; |
| 2592 |
} |
| 2593 |
} |
| 2594 |
} |
| 2595 |
else |
| 2596 |
{ |
| 2597 |
cmd.DW1.SplitWorkloadEnable = false; |
| 2598 |
} |
| 2599 |
|
| 2600 |
cmd.DW24.OutputEndingX = cmd.DW1.EndingX; |
| 2601 |
cmd.DW24.OutputStartingX = cmd.DW1.StartingX; |
| 2602 |
|
| 2603 |
if (bUsingSfc) |
| 2604 |
{ |
| 2605 |
// Use left overfetch for sfc split |
| 2606 |
if (cmd.DW1.StartingX >= 64) |
| 2607 |
{ |
| 2608 |
cmd.DW1.StartingX -= 64; |
| 2609 |
} |
| 2610 |
} |
| 2611 |
|
| 2612 |
MT_LOG3(MT_VP_MHW_VE_SCALABILITY, MT_NORMAL, MT_VP_MHW_VE_SCALABILITY_EN, bVeboxScalabilityEnabled, |
| 2613 |
MT_VP_MHW_VE_SCALABILITY_USE_SFC, bUsingSfc, MT_VP_MHW_VE_SCALABILITY_IDX, indexofVebox); |
| 2614 |
|
| 2615 |
MHW_NORMALMESSAGE("VEBOX%d STATE: startx %d endx %d", indexofVebox, cmd.DW1.StartingX, cmd.DW1.EndingX); |
| 2616 |
MHW_NORMALMESSAGE("VEBOX%d STATE: output startx %d endx %d", indexofVebox, cmd.DW24.OutputStartingX, cmd.DW24.OutputEndingX); |
| 2617 |
} |
| 2618 |
} |
| 2619 |
|
| 2620 |
//! |
| 2621 |
//! \brief Common helper for VEBOX IECP state field initialization |
| 2622 |
//! \details Resets all fields to HW defaults by default-constructing a local |
| 2623 |
//! VEBOX_IECP_STATE_CMD and then assigns the common field values that |
| 2624 |
//! are identical across all supported platforms. This function is |
| 2625 |
//! intended to be called from each platform's IecpStateInitialization |
| 2626 |
//! member function after the default-construct/assign step. |
| 2627 |
//! \param [in,out] pVeboxIecpState |
| 2628 |
//! Pointer to VEBOX_IECP_STATE_CMD to initialize |
| 2629 |
//! \return void |
| 2630 |
//! |
| 2631 |
template <typename cmd_t> |
| 2632 |
inline void IecpStateInitialization(typename cmd_t::VEBOX_IECP_STATE_CMD *pVeboxIecpState) |
| 2633 |
{ |
| 2634 |
// Reset all fields to HW defaults via default construction |
| 2635 |
typename cmd_t::VEBOX_IECP_STATE_CMD IecpState; |
| 2636 |
*pVeboxIecpState = IecpState; |
| 2637 |
|
| 2638 |
// Re-set the common values identical across all platforms |
| 2639 |
pVeboxIecpState->StdSteState.DW5.InvMarginVyl = 3300; |
| 2640 |
pVeboxIecpState->StdSteState.DW5.InvSkinTypesMargin = 1638; |
| 2641 |
pVeboxIecpState->StdSteState.DW12.B3U = 140; |
| 2642 |
pVeboxIecpState->StdSteState.DW27.Hues0Dark = 256; |
| 2643 |
pVeboxIecpState->StdSteState.DW27.Hues1Dark = 0; |
| 2644 |
|
| 2645 |
pVeboxIecpState->AceState.DW0.LaceHistogramSize = 1; |
| 2646 |
|
| 2647 |
pVeboxIecpState->TccState.DW0.Satfactor1 = 160; |
| 2648 |
pVeboxIecpState->TccState.DW0.Satfactor2 = 160; |
| 2649 |
pVeboxIecpState->TccState.DW0.Satfactor3 = 160; |
| 2650 |
pVeboxIecpState->TccState.DW1.Satfactor4 = 160; |
| 2651 |
pVeboxIecpState->TccState.DW1.Satfactor5 = 160; |
| 2652 |
pVeboxIecpState->TccState.DW1.Satfactor6 = 160; |
| 2653 |
|
| 2654 |
pVeboxIecpState->GamutState.DW2.CmS = 640; |
| 2655 |
pVeboxIecpState->GamutState.DW3.AG = 26; |
| 2656 |
pVeboxIecpState->GamutState.DW4.AB = 26; |
| 2657 |
pVeboxIecpState->GamutState.DW5.RS = 768; |
| 2658 |
pVeboxIecpState->GamutState.DW6.CmI = 192; |
| 2659 |
pVeboxIecpState->GamutState.DW7.RI = 128; |
| 2660 |
} |
| 2661 |
|
| 2662 |
//! |
| 2663 |
//! \brief Common helper for SetVeboxIecpState shared control flow |
| 2664 |
//! \details Encapsulates the shared control flow of SetVeboxIecpState used |
| 2665 |
//! across all 6 platform-specific VEBOX implementations. Two |
| 2666 |
//! compile-time bool template parameters handle the two behavioral |
| 2667 |
//! differences across platforms: |
| 2668 |
//! - EnableLACEArg: if true, passes bEnableLACE from params to |
| 2669 |
//! SetVeboxIecpStateACELACE; if false, passes hardcoded false. |
| 2670 |
//! - HasFeCSCBlock: if true, includes the HDR Front End CSC block |
| 2671 |
//! that checks bFeCSCEnable. |
| 2672 |
//! \param [in] pImpl |
| 2673 |
//! Pointer to the platform-specific implementation object |
| 2674 |
//! \param [in] pVeboxHeap |
| 2675 |
//! Pointer to VEBOX heap |
| 2676 |
//! \param [in] pVeboxIecpParams |
| 2677 |
//! Pointer to VEBOX IECP parameters |
| 2678 |
//! \return MOS_STATUS |
| 2679 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2680 |
//! |
| 2681 |
template <typename cmd_t, typename ImplType, bool EnableLACEArg, bool HasFeCSCBlock> |
| 2682 |
inline MOS_STATUS SetVeboxIecpState( |
| 2683 |
ImplType *pImpl, |
| 2684 |
MHW_VEBOX_HEAP *pVeboxHeap, |
| 2685 |
PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) |
| 2686 |
{ |
| 2687 |
bool bEnableFECSC = false; |
| 2688 |
PMHW_FORWARD_GAMMA_SEG pFwdGammaSeg = nullptr; |
| 2689 |
uint32_t uiOffset = 0; |
| 2690 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 2691 |
typename cmd_t::VEBOX_IECP_STATE_CMD *pVeboxIecpState = nullptr; |
| 2692 |
|
| 2693 |
MHW_CHK_NULL_RETURN(pVeboxIecpParams); |
| 2694 |
MHW_CHK_NULL_RETURN(pVeboxHeap); |
| 2695 |
|
| 2696 |
uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 2697 |
pVeboxIecpState = (typename cmd_t::VEBOX_IECP_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 2698 |
pVeboxHeap->uiIecpStateOffset + |
| 2699 |
uiOffset); |
| 2700 |
|
| 2701 |
MHW_CHK_NULL_RETURN(pVeboxIecpState); |
| 2702 |
|
| 2703 |
// FDFB early-return block |
| 2704 |
if (pVeboxIecpParams->iecpstateforFDFB) |
| 2705 |
{ |
| 2706 |
pImpl->IecpStateInitializationforFDFB(pVeboxIecpState); |
| 2707 |
return MOS_STATUS_SUCCESS; |
| 2708 |
} |
| 2709 |
else |
| 2710 |
{ |
| 2711 |
pImpl->IecpStateInitialization(pVeboxIecpState); |
| 2712 |
} |
| 2713 |
|
| 2714 |
// ColorPipe block: STD/E and TCC |
| 2715 |
if (pVeboxIecpParams->ColorPipeParams.bActive) |
| 2716 |
{ |
| 2717 |
// Enable STD/E (Skin Tone Detection/Enhancement) |
| 2718 |
pImpl->SetVeboxIecpStateSTE( |
| 2719 |
&pVeboxIecpState->StdSteState, |
| 2720 |
&pVeboxIecpParams->ColorPipeParams); |
| 2721 |
|
| 2722 |
// Enable TCC (Total Color Control) |
| 2723 |
if (pVeboxIecpParams->ColorPipeParams.bEnableTCC) |
| 2724 |
{ |
| 2725 |
pImpl->SetVeboxIecpStateTCC( |
| 2726 |
&pVeboxIecpState->TccState, |
| 2727 |
&pVeboxIecpParams->ColorPipeParams); |
| 2728 |
} |
| 2729 |
} |
| 2730 |
|
| 2731 |
// ACE/LACE block: Enable ACE (Automatic Contrast Enhancement). |
| 2732 |
// EnableLACEArg controls whether bEnableLACE is passed or hardcoded false. |
| 2733 |
if (pVeboxIecpParams->bAce || |
| 2734 |
(pVeboxIecpParams->ColorPipeParams.bActive && |
| 2735 |
pVeboxIecpParams->ColorPipeParams.bEnableACE)) |
| 2736 |
{ |
| 2737 |
// Compile-time selection of lace argument |
| 2738 |
bool laceArg = EnableLACEArg ? (pVeboxIecpParams->ColorPipeParams.bEnableLACE == true) : false; |
| 2739 |
pImpl->SetVeboxIecpStateACELACE( |
| 2740 |
&pVeboxIecpState->AceState, |
| 2741 |
&pVeboxIecpState->AlphaAoiState, |
| 2742 |
laceArg); |
| 2743 |
} |
| 2744 |
|
| 2745 |
// CapPipe block: Front End CSC and Color Correction Matrix |
| 2746 |
if (pVeboxIecpParams->CapPipeParams.bActive) |
| 2747 |
{ |
| 2748 |
// IECP needs to operate in YUV space |
| 2749 |
if ((pVeboxIecpParams->srcFormat != Format_AYUV) && |
| 2750 |
(pVeboxIecpParams->dstFormat == Format_AYUV || |
| 2751 |
pVeboxIecpParams->dstFormat == Format_Y416 || |
| 2752 |
pVeboxIecpParams->ProcAmpParams.bActive || |
| 2753 |
pVeboxIecpParams->ColorPipeParams.bActive)) |
| 2754 |
{ |
| 2755 |
bEnableFECSC = true; |
| 2756 |
} |
| 2757 |
else if (pVeboxIecpParams->CapPipeParams.FECSCParams.bActive) |
| 2758 |
{ |
| 2759 |
bEnableFECSC = true; |
| 2760 |
} |
| 2761 |
else |
| 2762 |
{ |
| 2763 |
bEnableFECSC = false; |
| 2764 |
} |
| 2765 |
|
| 2766 |
// Enable Front End CSC so that input to IECP will be in YUV color space |
| 2767 |
if (bEnableFECSC) |
| 2768 |
{ |
| 2769 |
pImpl->SetVeboxIecpStateFecsc(&pVeboxIecpState->FrontEndCsc, pVeboxIecpParams); |
| 2770 |
} |
| 2771 |
|
| 2772 |
// Enable Color Correction Matrix |
| 2773 |
if (pVeboxIecpParams->CapPipeParams.ColorCorrectionParams.bActive) |
| 2774 |
{ |
| 2775 |
pImpl->SetVeboxIecpStateCcm( |
| 2776 |
pVeboxIecpState, |
| 2777 |
&pVeboxIecpParams->CapPipeParams, |
| 2778 |
65536); |
| 2779 |
} |
| 2780 |
} |
| 2781 |
|
| 2782 |
// HDR Front End CSC block (compile-time gated by HasFeCSCBlock). |
| 2783 |
if (HasFeCSCBlock && pVeboxIecpParams->bFeCSCEnable) |
| 2784 |
{ |
| 2785 |
pImpl->SetVeboxIecpStateFecsc(&pVeboxIecpState->FrontEndCsc, pVeboxIecpParams); |
| 2786 |
} |
| 2787 |
|
| 2788 |
// Back End CSC block: Enable Back End CSC for capture pipeline or Vebox output pipe |
| 2789 |
if (pVeboxIecpParams->CapPipeParams.bActive || |
| 2790 |
pVeboxIecpParams->bCSCEnable) |
| 2791 |
{ |
| 2792 |
pImpl->SetVeboxIecpStateBecsc( |
| 2793 |
pVeboxIecpState, |
| 2794 |
pVeboxIecpParams, |
| 2795 |
bEnableFECSC); |
| 2796 |
} |
| 2797 |
|
| 2798 |
// ProcAmp block: Enable ProcAmp |
| 2799 |
if (pVeboxIecpParams->ProcAmpParams.bActive && |
| 2800 |
pVeboxIecpParams->ProcAmpParams.bEnabled) |
| 2801 |
{ |
| 2802 |
pImpl->SetVeboxIecpStateProcAmp( |
| 2803 |
&pVeboxIecpState->ProcampState, |
| 2804 |
&pVeboxIecpParams->ProcAmpParams); |
| 2805 |
} |
| 2806 |
|
| 2807 |
// CapPipeState block |
| 2808 |
if (pVeboxIecpParams && pVeboxIecpParams->CapPipeParams.bActive) |
| 2809 |
{ |
| 2810 |
pImpl->SetVeboxCapPipeState( |
| 2811 |
&pVeboxIecpParams->CapPipeParams); |
| 2812 |
} |
| 2813 |
|
| 2814 |
// FwdGamma block |
| 2815 |
if (pVeboxIecpParams && |
| 2816 |
pVeboxIecpParams->CapPipeParams.bActive && |
| 2817 |
pVeboxIecpParams->CapPipeParams.FwdGammaParams.bActive) |
| 2818 |
{ |
| 2819 |
pFwdGammaSeg = |
| 2820 |
(PMHW_FORWARD_GAMMA_SEG)(pVeboxHeap->pLockedDriverResourceMem + |
| 2821 |
pVeboxHeap->uiGammaCorrectionStateOffset + |
| 2822 |
uiOffset); |
| 2823 |
|
| 2824 |
MHW_CHK_NULL_RETURN(pFwdGammaSeg); |
| 2825 |
MOS_SecureMemcpy( |
| 2826 |
pFwdGammaSeg, |
| 2827 |
sizeof(MHW_FORWARD_GAMMA_SEG) * MHW_FORWARD_GAMMA_SEGMENT_CONTROL_POINT, |
| 2828 |
&pVeboxIecpParams->CapPipeParams.FwdGammaParams.Segment[0], |
| 2829 |
sizeof(MHW_FORWARD_GAMMA_SEG) * MHW_FORWARD_GAMMA_SEGMENT_CONTROL_POINT); |
| 2830 |
} |
| 2831 |
|
| 2832 |
return eStatus; |
| 2833 |
} |
| 2834 |
|
| 2835 |
//! |
| 2836 |
//! \brief Helper function for direct copy of 1024-entry 1D LUT |
| 2837 |
//! \details Handles the LUTSize==1024 case by directly copying all 1024 source |
| 2838 |
//! LUT entries into the target hardware command array via the provided |
| 2839 |
//! R/G/B channel setter callables. Avoids any interpolation. |
| 2840 |
//! Setter signature: setter(LutArray& arr, uint32_t index, uint16_t value) |
| 2841 |
//! \param [in,out] lutArray |
| 2842 |
//! Reference to the target LUT array in the hardware command structure |
| 2843 |
//! \param [in] p1DLutParams |
| 2844 |
//! Pointer to 1D LUT parameters (must have LUTSize==1024 and valid p1DLUT) |
| 2845 |
//! \param [in] setR |
| 2846 |
//! Callable to set the R channel value at a given index |
| 2847 |
//! \param [in] setG |
| 2848 |
//! Callable to set the G channel value at a given index |
| 2849 |
//! \param [in] setB |
| 2850 |
//! Callable to set the B channel value at a given index |
| 2851 |
//! \return MOS_STATUS |
| 2852 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2853 |
//! |
| 2854 |
template <typename LutArray, typename SetterR, typename SetterG, typename SetterB> |
| 2855 |
MOS_STATUS Copy1DLut1024( |
| 2856 |
LutArray &lutArray, |
| 2857 |
const MHW_1DLUT_PARAMS *p1DLutParams, |
| 2858 |
SetterR setR, |
| 2859 |
SetterG setG, |
| 2860 |
SetterB setB) |
| 2861 |
{ |
| 2862 |
uint16_t *p1DLut = (uint16_t *)p1DLutParams->p1DLUT; |
| 2863 |
for (uint32_t i = 0; i < p1DLutParams->LUTSize; i++) |
| 2864 |
{ |
| 2865 |
setR(lutArray, i, (uint16_t)(p1DLut[4 * i + 1])); |
| 2866 |
setG(lutArray, i, (uint16_t)(p1DLut[4 * i + 2])); |
| 2867 |
setB(lutArray, i, (uint16_t)(p1DLut[4 * i + 3])); |
| 2868 |
} |
| 2869 |
return MOS_STATUS_SUCCESS; |
| 2870 |
} |
| 2871 |
|
| 2872 |
//! |
| 2873 |
//! \brief Helper function for interpolating 256-entry 1D LUT to 1024 entries |
| 2874 |
//! \details Handles the LUTSize==256 case by computing 1024 output entries via |
| 2875 |
//! linear interpolation between adjacent 256-entry source samples using |
| 2876 |
//! cur_index/pre_index/point arithmetic, writing results via the provided |
| 2877 |
//! R/G/B channel setter callables. |
| 2878 |
//! Setter signature: setter(LutArray& arr, uint32_t index, uint16_t value) |
| 2879 |
//! \param [in,out] lutArray |
| 2880 |
//! Reference to the target LUT array in the hardware command structure |
| 2881 |
//! \param [in] p1DLutParams |
| 2882 |
//! Pointer to 1D LUT parameters (must have LUTSize==256 and valid p1DLUT) |
| 2883 |
//! \param [in] setR |
| 2884 |
//! Callable to set the R channel value at a given index |
| 2885 |
//! \param [in] setG |
| 2886 |
//! Callable to set the G channel value at a given index |
| 2887 |
//! \param [in] setB |
| 2888 |
//! Callable to set the B channel value at a given index |
| 2889 |
//! \return MOS_STATUS |
| 2890 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2891 |
//! |
| 2892 |
template <typename LutArray, typename SetterR, typename SetterG, typename SetterB> |
| 2893 |
MOS_STATUS Interpolate1DLut256To1024( |
| 2894 |
LutArray &lutArray, |
| 2895 |
const MHW_1DLUT_PARAMS *p1DLutParams, |
| 2896 |
SetterR setR, |
| 2897 |
SetterG setG, |
| 2898 |
SetterB setB) |
| 2899 |
{ |
| 2900 |
uint32_t cur_index = 0, pre_index = 0, point = 1; |
| 2901 |
uint16_t *p1DLut = (uint16_t *)p1DLutParams->p1DLUT; |
| 2902 |
|
| 2903 |
// Set index 0 directly from first source entry |
| 2904 |
setR(lutArray, 0, (uint16_t)(p1DLut[1])); |
| 2905 |
setG(lutArray, 0, (uint16_t)(p1DLut[2])); |
| 2906 |
setB(lutArray, 0, (uint16_t)(p1DLut[3])); |
| 2907 |
|
| 2908 |
for (uint32_t i = 1; i < 1024; i++) |
| 2909 |
{ |
| 2910 |
for (uint32_t j = point; j <= 256; j++) |
| 2911 |
{ |
| 2912 |
cur_index = 4 * j; |
| 2913 |
pre_index = cur_index ? 4 * (j - 1) : 0; |
| 2914 |
if (p1DLut[cur_index] == i * 64) |
| 2915 |
{ |
| 2916 |
setR(lutArray, i, (uint16_t)(p1DLut[cur_index + 1])); |
| 2917 |
setG(lutArray, i, (uint16_t)(p1DLut[cur_index + 2])); |
| 2918 |
setB(lutArray, i, (uint16_t)(p1DLut[cur_index + 3])); |
| 2919 |
point = j; |
| 2920 |
break; |
| 2921 |
} |
| 2922 |
else if (p1DLut[cur_index] > i * 64) |
| 2923 |
{ |
| 2924 |
if (cur_index != pre_index) |
| 2925 |
{ |
| 2926 |
setR(lutArray, i, (uint16_t)(p1DLut[pre_index + 1] + (p1DLut[cur_index + 1] - p1DLut[pre_index + 1]) * (i * 64 - p1DLut[pre_index]) / (p1DLut[cur_index] - p1DLut[pre_index]))); |
| 2927 |
setG(lutArray, i, (uint16_t)(p1DLut[pre_index + 2] + (p1DLut[cur_index + 2] - p1DLut[pre_index + 2]) * (i * 64 - p1DLut[pre_index]) / (p1DLut[cur_index] - p1DLut[pre_index]))); |
| 2928 |
setB(lutArray, i, (uint16_t)(p1DLut[pre_index + 3] + (p1DLut[cur_index + 3] - p1DLut[pre_index + 3]) * (i * 64 - p1DLut[pre_index]) / (p1DLut[cur_index] - p1DLut[pre_index]))); |
| 2929 |
point = j; |
| 2930 |
break; |
| 2931 |
} |
| 2932 |
else |
| 2933 |
{ |
| 2934 |
MHW_ASSERTMESSAGE("Error in map 256 LUT to 1k LUT"); |
| 2935 |
} |
| 2936 |
} |
| 2937 |
} |
| 2938 |
} |
| 2939 |
return MOS_STATUS_SUCCESS; |
| 2940 |
} |
| 2941 |
|
| 2942 |
//! |
| 2943 |
//! \brief Helper function for writing identity 1D LUT (fallback) |
| 2944 |
//! \details Handles the identity/fallback case by writing i*64 for indices [0,1022] |
| 2945 |
//! and 0xFFFF for index 1023 into all three channels via the provided setter |
| 2946 |
//! callables. Used when p1DLutParams is null, LUT is disabled, or LUTSize |
| 2947 |
//! is not a recognized value. |
| 2948 |
//! Setter signature: setter(LutArray& arr, uint32_t index, uint16_t value) |
| 2949 |
//! \param [in,out] lutArray |
| 2950 |
//! Reference to the target LUT array in the hardware command structure |
| 2951 |
//! \param [in] setR |
| 2952 |
//! Callable to set the R channel value at a given index |
| 2953 |
//! \param [in] setG |
| 2954 |
//! Callable to set the G channel value at a given index |
| 2955 |
//! \param [in] setB |
| 2956 |
//! Callable to set the B channel value at a given index |
| 2957 |
//! \return MOS_STATUS |
| 2958 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2959 |
//! |
| 2960 |
template <typename LutArray, typename SetterR, typename SetterG, typename SetterB> |
| 2961 |
MOS_STATUS WriteIdentity1DLut( |
| 2962 |
LutArray &lutArray, |
| 2963 |
SetterR setR, |
| 2964 |
SetterG setG, |
| 2965 |
SetterB setB) |
| 2966 |
{ |
| 2967 |
MHW_NORMALMESSAGE("Fall back to the identity 1k 1dlut"); |
| 2968 |
for (uint32_t i = 0; i < 1023; i++) |
| 2969 |
{ |
| 2970 |
setR(lutArray, i, (uint16_t)(i * 64)); |
| 2971 |
setG(lutArray, i, (uint16_t)(i * 64)); |
| 2972 |
setB(lutArray, i, (uint16_t)(i * 64)); |
| 2973 |
} |
| 2974 |
setR(lutArray, 1023, (uint16_t)0xffff); |
| 2975 |
setG(lutArray, 1023, (uint16_t)0xffff); |
| 2976 |
setB(lutArray, 1023, (uint16_t)0xffff); |
| 2977 |
return MOS_STATUS_SUCCESS; |
| 2978 |
} |
| 2979 |
|
| 2980 |
//! |
| 2981 |
//! \brief Helper function to unify Add1DLutState logic across platforms |
| 2982 |
//! \details Dispatches to Copy1DLut1024, Interpolate1DLut256To1024, or WriteIdentity1DLut |
| 2983 |
//! based on p1DLutParams validation and LUTSize. |
| 2984 |
//! \param [in,out] lutArray |
| 2985 |
//! Reference to the target LUT array in the hardware command structure |
| 2986 |
//! \param [in] p1DLutParams |
| 2987 |
//! Pointer to 1D LUT parameters |
| 2988 |
//! \param [in] setR |
| 2989 |
//! Callable to set the R channel value at a given index |
| 2990 |
//! \param [in] setG |
| 2991 |
//! Callable to set the G channel value at a given index |
| 2992 |
//! \param [in] setB |
| 2993 |
//! Callable to set the B channel value at a given index |
| 2994 |
//! \return MOS_STATUS |
| 2995 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 2996 |
//! |
| 2997 |
template <typename LutArray, typename SetterR, typename SetterG, typename SetterB> |
| 2998 |
MOS_STATUS Add1DLutState( |
| 2999 |
LutArray &lutArray, |
| 3000 |
const MHW_1DLUT_PARAMS *p1DLutParams, |
| 3001 |
SetterR setR, |
| 3002 |
SetterG setG, |
| 3003 |
SetterB setB) |
| 3004 |
{ |
| 3005 |
if (p1DLutParams && p1DLutParams->bActive && (p1DLutParams->LUTSize == 1024)) |
| 3006 |
{ |
| 3007 |
return Copy1DLut1024(lutArray, p1DLutParams, setR, setG, setB); |
| 3008 |
} |
| 3009 |
else if (p1DLutParams && p1DLutParams->bActive && (p1DLutParams->LUTSize == 256)) |
| 3010 |
{ |
| 3011 |
return Interpolate1DLut256To1024(lutArray, p1DLutParams, setR, setG, setB); |
| 3012 |
} |
| 3013 |
else |
| 3014 |
{ |
| 3015 |
return WriteIdentity1DLut(lutArray, setR, setG, setB); |
| 3016 |
} |
| 3017 |
} |
| 3018 |
|
| 3019 |
//! |
| 3020 |
//! \brief Helper function for setting VEBOX DNDI state GNE fields (TGNE enabled path) |
| 3021 |
//! \details Sets the Global Noise Estimation (GNE) related fields in VEBOX_DNDI_STATE_CMD |
| 3022 |
//! for the Temporal GNE (TGNE) enabled path. Sets DW3/DW4/DW6/DW8/DW30/DW49/ |
| 3023 |
//! DW50/DW51/DW52 fields with non-zero uniformity thresholds. |
| 3024 |
//! \param [in,out] pVeboxDndiState |
| 3025 |
//! Pointer to VEBOX_DNDI_STATE_CMD structure to configure |
| 3026 |
//! \param [in] bTGNEEnable |
| 3027 |
//! Temporal GNE enable flag |
| 3028 |
//! \param [in] dwChromaStadTh |
| 3029 |
//! Chroma STAD threshold value |
| 3030 |
//! \param [in] dwLumaStadTh |
| 3031 |
//! Luma STAD threshold value |
| 3032 |
//! \param [in] dw4X4TGNEThCnt |
| 3033 |
//! 4x4 Temporal GNE threshold count value |
| 3034 |
//! \return void |
| 3035 |
//! |
| 3036 |
template <typename cmd_t> |
| 3037 |
inline void SetVeboxDndiStateTGNE( |
| 3038 |
typename cmd_t::VEBOX_DNDI_STATE_CMD *pVeboxDndiState, |
| 3039 |
bool bTGNEEnable, |
| 3040 |
uint32_t dwChromaStadTh, |
| 3041 |
uint32_t dwLumaStadTh, |
| 3042 |
uint32_t dw4X4TGNEThCnt) |
| 3043 |
{ |
| 3044 |
pVeboxDndiState->DW3.TemporalGneEnable = bTGNEEnable; |
| 3045 |
pVeboxDndiState->DW4.BlockNoiseEstimateNoiseThreshold = 720; |
| 3046 |
pVeboxDndiState->DW6.BlockNoiseEstimateEdgeThreshold = 200; |
| 3047 |
pVeboxDndiState->DW8.ChromaDenoiseMovingPixelThreshold = 2; |
| 3048 |
pVeboxDndiState->DW8.ChromaDenoiseAsdThreshold = 512; |
| 3049 |
pVeboxDndiState->DW8.ChromaDenoiseThresholdForSumOfComplexityMeasure = 512; |
| 3050 |
pVeboxDndiState->DW30.EightDirectionEdgeThreshold = 3200; |
| 3051 |
pVeboxDndiState->DW30.ValidPixelThreshold = 336; |
| 3052 |
pVeboxDndiState->DW49.ChromaStadTh = dwChromaStadTh; |
| 3053 |
pVeboxDndiState->DW49.LumaStadTh = dwLumaStadTh; |
| 3054 |
pVeboxDndiState->DW50.LumaUniformityHighTh2 = 50; |
| 3055 |
pVeboxDndiState->DW50.LumaUniformityHighTh1 = 15; |
| 3056 |
pVeboxDndiState->DW50.LumaUniformityLowTh2 = 2; |
| 3057 |
pVeboxDndiState->DW50.LumaUniformityLowTh1 = 2; |
| 3058 |
pVeboxDndiState->DW51.ChromaUniformityHighTh2 = 30; |
| 3059 |
pVeboxDndiState->DW51.ChromaUniformityHighTh1 = 15; |
| 3060 |
pVeboxDndiState->DW51.ChromaUniformityLowTh2 = 2; |
| 3061 |
pVeboxDndiState->DW51.ChromaUniformityLowTh1 = 1; |
| 3062 |
pVeboxDndiState->DW52._4X4TemporalGneThresholdCount = dw4X4TGNEThCnt; |
| 3063 |
} |
| 3064 |
|
| 3065 |
//! |
| 3066 |
//! \brief Helper function for setting VEBOX DNDI state GNE fields (SGNE/disabled path) |
| 3067 |
//! \details Sets the Global Noise Estimation (GNE) related fields in VEBOX_DNDI_STATE_CMD |
| 3068 |
//! for the Spatial GNE (SGNE) or TGNE-disabled path. Sets DW3/DW4/DW6/DW8/DW30/ |
| 3069 |
//! DW49/DW50/DW51/DW52 fields with uniformity thresholds zeroed out. |
| 3070 |
//! \param [in,out] pVeboxDndiState |
| 3071 |
//! Pointer to VEBOX_DNDI_STATE_CMD structure to configure |
| 3072 |
//! \return void |
| 3073 |
//! |
| 3074 |
template <typename cmd_t> |
| 3075 |
inline void SetVeboxDndiStateSGNE( |
| 3076 |
typename cmd_t::VEBOX_DNDI_STATE_CMD *pVeboxDndiState) |
| 3077 |
{ |
| 3078 |
pVeboxDndiState->DW3.TemporalGneEnable = 0; |
| 3079 |
pVeboxDndiState->DW4.BlockNoiseEstimateNoiseThreshold = 720; |
| 3080 |
pVeboxDndiState->DW6.BlockNoiseEstimateEdgeThreshold = 200; |
| 3081 |
pVeboxDndiState->DW8.ChromaDenoiseMovingPixelThreshold = 2; |
| 3082 |
pVeboxDndiState->DW8.ChromaDenoiseAsdThreshold = 512; |
| 3083 |
pVeboxDndiState->DW8.ChromaDenoiseThresholdForSumOfComplexityMeasure = 512; |
| 3084 |
pVeboxDndiState->DW30.EightDirectionEdgeThreshold = 3200; |
| 3085 |
pVeboxDndiState->DW30.ValidPixelThreshold = 336; |
| 3086 |
pVeboxDndiState->DW49.ChromaStadTh = 0; |
| 3087 |
pVeboxDndiState->DW49.LumaStadTh = 0; |
| 3088 |
pVeboxDndiState->DW50.LumaUniformityHighTh2 = 0; |
| 3089 |
pVeboxDndiState->DW50.LumaUniformityHighTh1 = 0; |
| 3090 |
pVeboxDndiState->DW50.LumaUniformityLowTh2 = 0; |
| 3091 |
pVeboxDndiState->DW50.LumaUniformityLowTh1 = 0; |
| 3092 |
pVeboxDndiState->DW51.ChromaUniformityHighTh2 = 0; |
| 3093 |
pVeboxDndiState->DW51.ChromaUniformityHighTh1 = 0; |
| 3094 |
pVeboxDndiState->DW51.ChromaUniformityLowTh2 = 0; |
| 3095 |
pVeboxDndiState->DW51.ChromaUniformityLowTh1 = 0; |
| 3096 |
pVeboxDndiState->DW52._4X4TemporalGneThresholdCount = 0; |
| 3097 |
} |
| 3098 |
|
| 3099 |
//! |
| 3100 |
//! \brief Common helper for SetVeboxDndiState shared body |
| 3101 |
//! \details Encapsulates the shared body of SetVeboxDndiState used across all |
| 3102 |
//! platform-specific VEBOX implementations. Contains all the common |
| 3103 |
//! field assignments from DW0 through DW52, including the SlimIPU |
| 3104 |
//! denoise block, SCD enable block, and GNE setting block. |
| 3105 |
//! This eliminates the ~270-line duplication across platform files. |
| 3106 |
//! \param [in,out] pVeboxDndiState |
| 3107 |
//! Pointer to VEBOX_DNDI_STATE_CMD structure to configure |
| 3108 |
//! \param [in] pVeboxDndiParams |
| 3109 |
//! Pointer to VEBOX DNDI parameters |
| 3110 |
//! \param [in] chromaParams |
| 3111 |
//! Reference to chroma parameters (MHW_VEBOX_CHROMA_PARAMS) |
| 3112 |
//! \param [in] bTGNEEnable |
| 3113 |
//! Temporal GNE enable flag |
| 3114 |
//! \param [in] dwChromaStadTh |
| 3115 |
//! Chroma STAD threshold value |
| 3116 |
//! \param [in] dwLumaStadTh |
| 3117 |
//! Luma STAD threshold value |
| 3118 |
//! \param [in] dw4X4TGNEThCnt |
| 3119 |
//! 4x4 Temporal GNE threshold count value |
| 3120 |
//! \return MOS_STATUS |
| 3121 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 3122 |
//! |
| 3123 |
template <typename cmd_t> |
| 3124 |
inline MOS_STATUS SetVeboxDndiStateBody( |
| 3125 |
typename cmd_t::VEBOX_DNDI_STATE_CMD *pVeboxDndiState, |
| 3126 |
PMHW_VEBOX_DNDI_PARAMS pVeboxDndiParams, |
| 3127 |
const MHW_VEBOX_CHROMA_PARAMS &chromaParams, |
| 3128 |
bool bTGNEEnable, |
| 3129 |
uint32_t dwChromaStadTh, |
| 3130 |
uint32_t dwLumaStadTh, |
| 3131 |
uint32_t dw4X4TGNEThCnt) |
| 3132 |
{ |
| 3133 |
MHW_CHK_NULL_RETURN(pVeboxDndiState); |
| 3134 |
MHW_CHK_NULL_RETURN(pVeboxDndiParams); |
| 3135 |
|
| 3136 |
pVeboxDndiState->DW0.DenoiseMaximumHistory = pVeboxDndiParams->dwDenoiseMaximumHistory; |
| 3137 |
pVeboxDndiState->DW0.DenoiseStadThreshold = pVeboxDndiParams->dwDenoiseSTADThreshold > 4095 ? 4095 : pVeboxDndiParams->dwDenoiseSTADThreshold; |
| 3138 |
pVeboxDndiState->DW1.DenoiseAsdThreshold = pVeboxDndiParams->dwDenoiseASDThreshold; |
| 3139 |
pVeboxDndiState->DW1.DenoiseHistoryIncrease = pVeboxDndiParams->dwDenoiseHistoryDelta; |
| 3140 |
pVeboxDndiState->DW1.DenoiseMovingPixelThreshold = pVeboxDndiParams->dwDenoiseMPThreshold; |
| 3141 |
pVeboxDndiState->DW2.TemporalDifferenceThreshold = pVeboxDndiParams->dwTDThreshold; |
| 3142 |
pVeboxDndiState->DW3.LowTemporalDifferenceThreshold = pVeboxDndiParams->dwLTDThreshold; |
| 3143 |
pVeboxDndiState->DW3.ProgressiveDn = pVeboxDndiParams->bProgressiveDN; |
| 3144 |
pVeboxDndiState->DW3.HotPixelCountLuma = pVeboxDndiParams->dwHotPixelCount; |
| 3145 |
pVeboxDndiState->DW4.DenoiseThresholdForSumOfComplexityMeasureLuma = pVeboxDndiParams->dwDenoiseSCMThreshold; |
| 3146 |
pVeboxDndiState->DW4.HotPixelThresholdLuma = pVeboxDndiParams->dwHotPixelThreshold; |
| 3147 |
pVeboxDndiState->DW5.ChromaDenoiseStadThreshold = pVeboxDndiParams->dwChromaSTADThreshold > 4095 ? 4095 : pVeboxDndiParams->dwChromaSTADThreshold; |
| 3148 |
pVeboxDndiState->DW5.HotPixelCountChromaU = chromaParams.dwHotPixelCountChromaU; |
| 3149 |
pVeboxDndiState->DW5.HotPixelThresholdChromaU = chromaParams.dwHotPixelThresholdChromaU; |
| 3150 |
pVeboxDndiState->DW6.ChromaDenoiseEnable = pVeboxDndiParams->bChromaDNEnable; |
| 3151 |
pVeboxDndiState->DW6.ChromaTemporalDifferenceThreshold = pVeboxDndiParams->dwChromaTDThreshold; |
| 3152 |
pVeboxDndiState->DW7.ChromaLowTemporalDifferenceThreshold = pVeboxDndiParams->dwChromaLTDThreshold; |
| 3153 |
pVeboxDndiState->DW7.HotPixelCountChromaV = chromaParams.dwHotPixelCountChromaV; |
| 3154 |
pVeboxDndiState->DW7.HotPixelThresholdChromaV = chromaParams.dwHotPixelThresholdChromaV; |
| 3155 |
pVeboxDndiState->DW8.ChromaDenoiseMovingPixelThreshold = chromaParams.dwHotPixelThresholdChromaV; |
| 3156 |
|
| 3157 |
pVeboxDndiState->DW9.DnyWr040 = pVeboxDndiParams->dwPixRangeWeight[0]; |
| 3158 |
pVeboxDndiState->DW9.DnyWr140 = pVeboxDndiParams->dwPixRangeWeight[1]; |
| 3159 |
pVeboxDndiState->DW9.DnyWr240 = pVeboxDndiParams->dwPixRangeWeight[2]; |
| 3160 |
pVeboxDndiState->DW9.DnyWr340 = pVeboxDndiParams->dwPixRangeWeight[3]; |
| 3161 |
pVeboxDndiState->DW9.DnyWr440 = pVeboxDndiParams->dwPixRangeWeight[4]; |
| 3162 |
pVeboxDndiState->DW9.DnyWr540 = pVeboxDndiParams->dwPixRangeWeight[5]; |
| 3163 |
|
| 3164 |
pVeboxDndiState->DW11.DnyPrt5120 = pVeboxDndiParams->dwPixRangeThreshold[5]; |
| 3165 |
pVeboxDndiState->DW12.DnyPrt4120 = pVeboxDndiParams->dwPixRangeThreshold[4]; |
| 3166 |
pVeboxDndiState->DW12.DnyPrt3120 = pVeboxDndiParams->dwPixRangeThreshold[3]; |
| 3167 |
pVeboxDndiState->DW13.DnyPrt2120 = pVeboxDndiParams->dwPixRangeThreshold[2]; |
| 3168 |
pVeboxDndiState->DW13.DnyPrt1120 = pVeboxDndiParams->dwPixRangeThreshold[1]; |
| 3169 |
pVeboxDndiState->DW14.DnyPrt0120 = pVeboxDndiParams->dwPixRangeThreshold[0]; |
| 3170 |
|
| 3171 |
pVeboxDndiState->DW16.DnuWr040 = chromaParams.dwPixRangeWeightChromaU[0]; |
| 3172 |
pVeboxDndiState->DW16.DnuWr140 = chromaParams.dwPixRangeWeightChromaU[1]; |
| 3173 |
pVeboxDndiState->DW16.DnuWr240 = chromaParams.dwPixRangeWeightChromaU[2]; |
| 3174 |
pVeboxDndiState->DW16.DnuWr340 = chromaParams.dwPixRangeWeightChromaU[3]; |
| 3175 |
pVeboxDndiState->DW16.DnuWr440 = chromaParams.dwPixRangeWeightChromaU[4]; |
| 3176 |
pVeboxDndiState->DW16.DnuWr540 = chromaParams.dwPixRangeWeightChromaU[5]; |
| 3177 |
|
| 3178 |
pVeboxDndiState->DW18.DnuPrt5120 = chromaParams.dwPixRangeThresholdChromaU[5]; |
| 3179 |
pVeboxDndiState->DW19.DnuPrt4120 = chromaParams.dwPixRangeThresholdChromaU[4]; |
| 3180 |
pVeboxDndiState->DW19.DnuPrt3120 = chromaParams.dwPixRangeThresholdChromaU[3]; |
| 3181 |
pVeboxDndiState->DW20.DnuPrt2120 = chromaParams.dwPixRangeThresholdChromaU[2]; |
| 3182 |
pVeboxDndiState->DW20.DnuPrt1120 = chromaParams.dwPixRangeThresholdChromaU[1]; |
| 3183 |
pVeboxDndiState->DW21.DnuPrt0120 = chromaParams.dwPixRangeThresholdChromaU[0]; |
| 3184 |
|
| 3185 |
pVeboxDndiState->DW23.DnvWr040 = chromaParams.dwPixRangeWeightChromaV[0]; |
| 3186 |
pVeboxDndiState->DW23.DnvWr5140 = chromaParams.dwPixRangeWeightChromaV[1]; |
| 3187 |
pVeboxDndiState->DW23.DnvWr240 = chromaParams.dwPixRangeWeightChromaV[2]; |
| 3188 |
pVeboxDndiState->DW23.DnvWr340 = chromaParams.dwPixRangeWeightChromaV[3]; |
| 3189 |
pVeboxDndiState->DW23.DnvWr440 = chromaParams.dwPixRangeWeightChromaV[4]; |
| 3190 |
pVeboxDndiState->DW23.DnvWr540 = chromaParams.dwPixRangeWeightChromaV[5]; |
| 3191 |
|
| 3192 |
pVeboxDndiState->DW25.DnvPrt5120 = chromaParams.dwPixRangeThresholdChromaV[5]; |
| 3193 |
pVeboxDndiState->DW26.DnvPrt4120 = chromaParams.dwPixRangeThresholdChromaV[4]; |
| 3194 |
pVeboxDndiState->DW26.DnvPrt3120 = chromaParams.dwPixRangeThresholdChromaV[3]; |
| 3195 |
pVeboxDndiState->DW27.DnvPrt2120 = chromaParams.dwPixRangeThresholdChromaV[2]; |
| 3196 |
pVeboxDndiState->DW27.DnvPrt1120 = chromaParams.dwPixRangeThresholdChromaV[1]; |
| 3197 |
pVeboxDndiState->DW28.DnvPrt0120 = chromaParams.dwPixRangeThresholdChromaV[0]; |
| 3198 |
|
| 3199 |
pVeboxDndiState->DW38.DnDiTopFirst = pVeboxDndiParams->bDNDITopFirst; |
| 3200 |
|
| 3201 |
pVeboxDndiState->DW39.ProgressiveCadenceReconstructionFor1StFieldOfCurrentFrame = pVeboxDndiParams->dwFMDFirstFieldCurrFrame; |
| 3202 |
pVeboxDndiState->DW39.ProgressiveCadenceReconstructionForSecondFieldOfPreviousFrame = pVeboxDndiParams->dwFMDSecondFieldPrevFrame; |
| 3203 |
|
| 3204 |
// Improved Deinterlacing |
| 3205 |
pVeboxDndiState->DW36.LumatdmWt = pVeboxDndiParams->dwLumaTDMWeight; |
| 3206 |
pVeboxDndiState->DW36.ChromatdmWt = pVeboxDndiParams->dwChromaTDMWeight; |
| 3207 |
|
| 3208 |
pVeboxDndiState->DW37.CoringThresholdForSvcm = pVeboxDndiParams->dwSVCMThreshold; |
| 3209 |
pVeboxDndiState->DW37.DeltabitValueForSvcm = pVeboxDndiParams->dwSVCMDelta; |
| 3210 |
pVeboxDndiState->DW37.CoringThresholdForShcm = pVeboxDndiParams->dwSHCMThreshold; |
| 3211 |
pVeboxDndiState->DW37.DeltabitValueForShcm = pVeboxDndiParams->dwSHCMDelta; |
| 3212 |
|
| 3213 |
pVeboxDndiState->DW39.ChromaSmallerWindowForTdm = pVeboxDndiParams->bTDMChromaSmallerWindow; |
| 3214 |
pVeboxDndiState->DW39.LumaSmallerWindowForTdm = pVeboxDndiParams->bTDMLumaSmallerWindow; |
| 3215 |
pVeboxDndiState->DW39.Fastercovergence = pVeboxDndiParams->bFasterConvergence; |
| 3216 |
|
| 3217 |
pVeboxDndiState->DW40.SadWt0 = pVeboxDndiParams->dwSADWT0; |
| 3218 |
pVeboxDndiState->DW40.SadWt1 = pVeboxDndiParams->dwSADWT1; |
| 3219 |
pVeboxDndiState->DW40.SadWt2 = pVeboxDndiParams->dwSADWT2; |
| 3220 |
pVeboxDndiState->DW40.SadWt3 = pVeboxDndiParams->dwSADWT3; |
| 3221 |
pVeboxDndiState->DW41.SadWt4 = pVeboxDndiParams->dwSADWT4; |
| 3222 |
pVeboxDndiState->DW41.SadWt6 = pVeboxDndiParams->dwSADWT6; |
| 3223 |
|
| 3224 |
pVeboxDndiState->DW41.CoringThresholdForLumaSadCalculation = pVeboxDndiParams->dwLumaTDMCoringThreshold; |
| 3225 |
pVeboxDndiState->DW41.CoringThresholdForChromaSadCalculation = pVeboxDndiParams->dwChromaTDMCoringThreshold; |
| 3226 |
|
| 3227 |
pVeboxDndiState->DW42.ParDiffcheckslackthreshold = pVeboxDndiParams->dwDiffCheckSlackThreshold; |
| 3228 |
pVeboxDndiState->DW42.ParTearinghighthreshold = pVeboxDndiParams->dwTearingHighThreshold; |
| 3229 |
pVeboxDndiState->DW42.ParTearinglowthreshold = pVeboxDndiParams->dwTearingLowThreshold; |
| 3230 |
pVeboxDndiState->DW42.ParDirectioncheckth = pVeboxDndiParams->dwDirectionCheckThreshold; |
| 3231 |
pVeboxDndiState->DW42.ParSyntheticcontentcheck = pVeboxDndiParams->bSyntheticContentCheck; |
| 3232 |
pVeboxDndiState->DW42.ParLocalcheck = pVeboxDndiParams->bLocalCheck; |
| 3233 |
pVeboxDndiState->DW42.ParUsesyntheticcontentmedian = pVeboxDndiParams->bUseSyntheticContentMedian; |
| 3234 |
pVeboxDndiState->DW42.BypassDeflicker = pVeboxDndiParams->bBypassDeflickerFilter; |
| 3235 |
|
| 3236 |
pVeboxDndiState->DW43.Lpfwtlut0 = pVeboxDndiParams->dwLPFWtLUT0; |
| 3237 |
pVeboxDndiState->DW43.Lpfwtlut1 = pVeboxDndiParams->dwLPFWtLUT1; |
| 3238 |
pVeboxDndiState->DW43.Lpfwtlut2 = pVeboxDndiParams->dwLPFWtLUT2; |
| 3239 |
pVeboxDndiState->DW43.Lpfwtlut3 = pVeboxDndiParams->dwLPFWtLUT3; |
| 3240 |
pVeboxDndiState->DW44.Lpfwtlut4 = pVeboxDndiParams->dwLPFWtLUT4; |
| 3241 |
pVeboxDndiState->DW44.Lpfwtlut5 = pVeboxDndiParams->dwLPFWtLUT5; |
| 3242 |
pVeboxDndiState->DW44.Lpfwtlut6 = pVeboxDndiParams->dwLPFWtLUT6; |
| 3243 |
pVeboxDndiState->DW44.Lpfwtlut7 = pVeboxDndiParams->dwLPFWtLUT7; |
| 3244 |
|
| 3245 |
pVeboxDndiState->DW10.DnyThmin120 = 512; |
| 3246 |
pVeboxDndiState->DW10.DnyThmax120 = 2048; |
| 3247 |
pVeboxDndiState->DW11.DnyDynThmin120 = 256; |
| 3248 |
|
| 3249 |
pVeboxDndiState->DW14.DnyWd2040 = 10; |
| 3250 |
pVeboxDndiState->DW14.DnyWd2140 = 10; |
| 3251 |
pVeboxDndiState->DW14.DnyWd2240 = 8; |
| 3252 |
pVeboxDndiState->DW15.DnyWd0040 = 12; |
| 3253 |
pVeboxDndiState->DW15.DnyWd0140 = 12; |
| 3254 |
pVeboxDndiState->DW15.DnyWd0240 = 10; |
| 3255 |
pVeboxDndiState->DW15.DnyWd1040 = 12; |
| 3256 |
pVeboxDndiState->DW15.DnyWd1140 = 11; |
| 3257 |
pVeboxDndiState->DW15.DnyWd1240 = 10; |
| 3258 |
|
| 3259 |
pVeboxDndiState->DW17.DnuThmin120 = 512; |
| 3260 |
pVeboxDndiState->DW17.DnuThmax120 = 2048; |
| 3261 |
pVeboxDndiState->DW18.DnuDynThmin120 = 256; |
| 3262 |
|
| 3263 |
pVeboxDndiState->DW21.DnuWd2040 = 10; |
| 3264 |
pVeboxDndiState->DW21.DnuWd2140 = 10; |
| 3265 |
pVeboxDndiState->DW21.DnuWd2240 = 8; |
| 3266 |
pVeboxDndiState->DW22.DnuWd0040 = 12; |
| 3267 |
pVeboxDndiState->DW22.DnuWd0140 = 12; |
| 3268 |
pVeboxDndiState->DW22.DnuWd0240 = 10; |
| 3269 |
pVeboxDndiState->DW22.DnuWd1040 = 12; |
| 3270 |
pVeboxDndiState->DW22.DnuWd1140 = 11; |
| 3271 |
pVeboxDndiState->DW22.DnuWd1240 = 10; |
| 3272 |
|
| 3273 |
pVeboxDndiState->DW24.DnvThmin120 = 512; |
| 3274 |
pVeboxDndiState->DW24.DnvThmax120 = 2048; |
| 3275 |
pVeboxDndiState->DW25.DnvDynThmin120 = 256; |
| 3276 |
|
| 3277 |
pVeboxDndiState->DW28.DnvWd2040 = 10; |
| 3278 |
pVeboxDndiState->DW28.DnvWd2140 = 10; |
| 3279 |
pVeboxDndiState->DW28.DnvWd2240 = 8; |
| 3280 |
pVeboxDndiState->DW29.DnvWd0040 = 12; |
| 3281 |
pVeboxDndiState->DW29.DnvWd0140 = 12; |
| 3282 |
pVeboxDndiState->DW29.DnvWd0240 = 10; |
| 3283 |
pVeboxDndiState->DW29.DnvWd1040 = 12; |
| 3284 |
pVeboxDndiState->DW29.DnvWd1140 = 11; |
| 3285 |
pVeboxDndiState->DW29.DnvWd1240 = 10; |
| 3286 |
|
| 3287 |
pVeboxDndiState->DW31.SmallSobelCountThreshold = 6; |
| 3288 |
pVeboxDndiState->DW32.LargeSobelCountThreshold = 6; |
| 3289 |
pVeboxDndiState->DW32.MedianSobelCountThreshold = 40; |
| 3290 |
|
| 3291 |
pVeboxDndiState->DW34.StmmC2 = 2; |
| 3292 |
pVeboxDndiState->DW35.MaximumStmm = 150; |
| 3293 |
pVeboxDndiState->DW35.MultiplierForVecm = 30; |
| 3294 |
pVeboxDndiState->DW35.BlendingConstantAcrossTimeForSmallValuesOfStmm = 125; |
| 3295 |
pVeboxDndiState->DW35.BlendingConstantAcrossTimeForLargeValuesOfStmm = 64; |
| 3296 |
|
| 3297 |
pVeboxDndiState->DW36.FmdTemporalDifferenceThreshold = 175; |
| 3298 |
pVeboxDndiState->DW36.StmmOutputShift = 5; |
| 3299 |
pVeboxDndiState->DW36.StmmShiftUp = 1; |
| 3300 |
pVeboxDndiState->DW36.MinimumStmm = 118; |
| 3301 |
|
| 3302 |
pVeboxDndiState->DW38.McdiEnable = 1; |
| 3303 |
pVeboxDndiState->DW38.FmdTearThreshold = 2; |
| 3304 |
pVeboxDndiState->DW38.Fmd2VerticalDifferenceThreshold = 100; |
| 3305 |
pVeboxDndiState->DW38.Fmd1VerticalDifferenceThreshold = 16; |
| 3306 |
|
| 3307 |
pVeboxDndiState->DW45.SynthticFrame = pVeboxDndiParams->bSyntheticFrame; |
| 3308 |
|
| 3309 |
// copy the DW0-DW33 SLIM_IPU_DN_PARAMS to VEBOX_DNDI_STATE, DW34-DW48 for DI according to DI DDI setting. |
| 3310 |
if (pVeboxDndiParams->bEnableSlimIPUDenoise) |
| 3311 |
{ |
| 3312 |
uint32_t slimIpuDnCmdSize = MHW_VEBOX_SLIM_IPU_DN_CMD_SIZE_INUSE * sizeof(pVeboxDndiState->DW0); //buffer size in use for SLIM IPU DN |
| 3313 |
|
| 3314 |
if (nullptr == pVeboxDndiParams->pSystemMem || pVeboxDndiParams->MemSizeInBytes != sizeof(*pVeboxDndiState) || pVeboxDndiParams->MemSizeInBytes < slimIpuDnCmdSize) |
| 3315 |
{ |
| 3316 |
MHW_ASSERTMESSAGE("SlimIPUDenoise size is invaild"); |
| 3317 |
return MOS_STATUS_INVALID_PARAMETER; |
| 3318 |
} |
| 3319 |
|
| 3320 |
MOS_SecureMemcpy(pVeboxDndiState, sizeof(*pVeboxDndiState), pVeboxDndiParams->pSystemMem, slimIpuDnCmdSize); // only copy dw0 - dw33 for DN |
| 3321 |
|
| 3322 |
pVeboxDndiState->DW3.ProgressiveDn = pVeboxDndiParams->bProgressiveDN; |
| 3323 |
} |
| 3324 |
|
| 3325 |
if (pVeboxDndiParams->bSCDEnable) |
| 3326 |
{ |
| 3327 |
pVeboxDndiState->DW34.SignBitForMinimumStmm = 1; |
| 3328 |
pVeboxDndiState->DW34.SignBitForMaximumStmm = 1; |
| 3329 |
pVeboxDndiState->DW34.SignBitForSmoothMvThreshold = 1; |
| 3330 |
} |
| 3331 |
else |
| 3332 |
{ |
| 3333 |
pVeboxDndiState->DW34.SignBitForMinimumStmm = 0; |
| 3334 |
pVeboxDndiState->DW34.SignBitForMaximumStmm = 0; |
| 3335 |
pVeboxDndiState->DW34.SignBitForSmoothMvThreshold = 0; |
| 3336 |
} |
| 3337 |
|
| 3338 |
// GNE setting |
| 3339 |
if (bTGNEEnable) |
| 3340 |
{ |
| 3341 |
SetVeboxDndiStateTGNE<cmd_t>( |
| 3342 |
pVeboxDndiState, bTGNEEnable, dwChromaStadTh, dwLumaStadTh, dw4X4TGNEThCnt); |
| 3343 |
} |
| 3344 |
else |
| 3345 |
{ |
| 3346 |
SetVeboxDndiStateSGNE<cmd_t>( |
| 3347 |
pVeboxDndiState); |
| 3348 |
} |
| 3349 |
|
| 3350 |
return MOS_STATUS_SUCCESS; |
| 3351 |
} |
| 3352 |
|
| 3353 |
//! |
| 3354 |
//! \brief Common helper for the full SetVeboxDndiState function |
| 3355 |
//! \details Encapsulates the entire SetVeboxDndiState function used across all |
| 3356 |
//! platform-specific VEBOX implementations. Handles heap access, |
| 3357 |
//! offset calculation, pointer casting, state initialization, |
| 3358 |
//! calling SetVeboxDndiStateBody, and DumpDNDIStates. |
| 3359 |
//! This eliminates the duplicated boilerplate platform files. |
| 3360 |
//! \param [in] pImpl |
| 3361 |
//! Pointer to the platform-specific implementation object |
| 3362 |
//! \param [in] pVeboxHeap |
| 3363 |
//! Pointer to VEBOX heap |
| 3364 |
//! \param [in] pVeboxDndiParams |
| 3365 |
//! Pointer to VEBOX DNDI parameters |
| 3366 |
//! \return MOS_STATUS |
| 3367 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 3368 |
//! |
| 3369 |
template <typename cmd_t, typename ImplType> |
| 3370 |
inline MOS_STATUS SetVeboxDndiState( |
| 3371 |
ImplType *pImpl, |
| 3372 |
MHW_VEBOX_HEAP *pVeboxHeap, |
| 3373 |
PMHW_VEBOX_DNDI_PARAMS pVeboxDndiParams) |
| 3374 |
{ |
| 3375 |
uint32_t uiOffset = 0; |
| 3376 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3377 |
|
| 3378 |
typename cmd_t::VEBOX_DNDI_STATE_CMD *pVeboxDndiState = nullptr; |
| 3379 |
typename cmd_t::VEBOX_DNDI_STATE_CMD mVeboxDndiState; |
| 3380 |
|
| 3381 |
MHW_CHK_NULL_RETURN(pVeboxDndiParams); |
| 3382 |
MHW_CHK_NULL_RETURN(pVeboxHeap); |
| 3383 |
|
| 3384 |
uiOffset = pVeboxHeap->uiCurState * pVeboxHeap->uiInstanceSize; |
| 3385 |
pVeboxDndiState = |
| 3386 |
(typename cmd_t::VEBOX_DNDI_STATE_CMD *)(pVeboxHeap->pLockedDriverResourceMem + |
| 3387 |
pVeboxHeap->uiDndiStateOffset + |
| 3388 |
uiOffset); |
| 3389 |
|
| 3390 |
MHW_CHK_NULL_RETURN(pVeboxDndiState); |
| 3391 |
|
| 3392 |
*pVeboxDndiState = mVeboxDndiState; |
| 3393 |
|
| 3394 |
// Delegate the shared body to the common helper function |
| 3395 |
MHW_CHK_STATUS_RETURN(SetVeboxDndiStateBody<cmd_t>( |
| 3396 |
pVeboxDndiState, pVeboxDndiParams, pImpl->GetChromaParams(), pImpl->GetTGNEEnable(), pImpl->GetChromaStadThreshold(), pImpl->GetLumaStadThreshold(), pImpl->Get4X4TGNEThresholdCount())); |
| 3397 |
|
| 3398 |
pImpl->DumpDNDIStates((uint8_t *)pVeboxDndiState); |
| 3399 |
return eStatus; |
| 3400 |
} |
| 3401 |
|
| 3402 |
//! |
| 3403 |
//! \brief Shared helper for SetVeboxIecpStateSTE across all platforms |
| 3404 |
//! \details Encapsulates the common implementation of SetVeboxIecpStateSTE. |
| 3405 |
//! The only behavioral difference between platforms is the StdScoreOutput |
| 3406 |
//! assignment at the end: |
| 3407 |
//! - Older platforms: |
| 3408 |
//! enableLaceStdScoreOutput = true -> |
| 3409 |
//! DW1.StdScoreOutput = (bEnableLACE && LaceParams.bSTD) || bEnableSTD |
| 3410 |
//! - Newer platforms: |
| 3411 |
//! enableLaceStdScoreOutput = false -> |
| 3412 |
//! DW1.StdScoreOutput = bEnableSTD |
| 3413 |
//! \param [in,out] pVeboxStdSteState |
| 3414 |
//! Pointer to platform-specific VEBOX_STD_STE_STATE_CMD structure |
| 3415 |
//! \param [in] pColorPipeParams |
| 3416 |
//! Pointer to COLOR PIPE Params |
| 3417 |
//! \param [in] enableLaceStdScoreOutput |
| 3418 |
//! If true, StdScoreOutput includes the LACE condition (older platforms). |
| 3419 |
//! If false, StdScoreOutput is just bEnableSTD (newer platforms). |
| 3420 |
//! \return MOS_STATUS |
| 3421 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 3422 |
//! |
| 3423 |
template <typename VEBOX_STD_STE_STATE_CMD> |
| 3424 |
inline MOS_STATUS SetVeboxIecpStateSTE( |
| 3425 |
VEBOX_STD_STE_STATE_CMD *pVeboxStdSteState, |
| 3426 |
PMHW_COLORPIPE_PARAMS pColorPipeParams, |
| 3427 |
bool enableLaceStdScoreOutput) |
| 3428 |
{ |
| 3429 |
MHW_FUNCTION_ENTER; |
| 3430 |
|
| 3431 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 3432 |
|
| 3433 |
MHW_CHK_NULL_RETURN(pVeboxStdSteState); |
| 3434 |
MHW_CHK_NULL_RETURN(pColorPipeParams); |
| 3435 |
|
| 3436 |
// STD detects the skin like colors and passes a grade of skin tone |
| 3437 |
// color to STE (Skin Tone Enhancement). STD operates in the YUV color |
| 3438 |
// space. The level of skin tone detection is determined through skin |
| 3439 |
// tone factors in UV plane. If skin tone detection in VY plane is also |
| 3440 |
// enabled, the final skin tone factor is given by the minimum of STD |
| 3441 |
// in the (U, V) plane and (V, Y) plane. |
| 3442 |
// |
| 3443 |
// The skin tone factor will also be passed to ACE and TCC to indicate |
| 3444 |
// the strength of skin tone likelihood. |
| 3445 |
pVeboxStdSteState->DW0.StdEnable = true; |
| 3446 |
|
| 3447 |
// Enable skin tone detection in VY plane |
| 3448 |
pVeboxStdSteState->DW3.VyStdEnable = true; |
| 3449 |
|
| 3450 |
// Enable STE (Skin Tone Enhancement) |
| 3451 |
// STE modify the saturation and hue of the pixels which were detected |
| 3452 |
// as the skin-tone pixels by STD |
| 3453 |
if (pColorPipeParams->bEnableSTE && |
| 3454 |
pColorPipeParams->SteParams.dwSTEFactor > 0) |
| 3455 |
{ |
| 3456 |
pVeboxStdSteState->DW0.SteEnable = true; |
| 3457 |
|
| 3458 |
if (pColorPipeParams->SteParams.dwSTEFactor <= MHW_STE_OPTIMAL) |
| 3459 |
{ |
| 3460 |
pVeboxStdSteState->DW15.Satb1 = MOS_BITFIELD_VALUE((uint32_t)-8, 10); |
| 3461 |
pVeboxStdSteState->DW15.Satp3 = 31; |
| 3462 |
pVeboxStdSteState->DW15.Satp2 = 6; |
| 3463 |
pVeboxStdSteState->DW15.Satp1 = pColorPipeParams->SteParams.satP1; |
| 3464 |
|
| 3465 |
pVeboxStdSteState->DW16.Sats0 = pColorPipeParams->SteParams.satS0; |
| 3466 |
pVeboxStdSteState->DW16.Satb3 = 124; |
| 3467 |
pVeboxStdSteState->DW16.Satb2 = 8; |
| 3468 |
|
| 3469 |
pVeboxStdSteState->DW17.Sats2 = 297; |
| 3470 |
pVeboxStdSteState->DW17.Sats1 = pColorPipeParams->SteParams.satS1; |
| 3471 |
|
| 3472 |
pVeboxStdSteState->DW18.Huep3 = 14; |
| 3473 |
pVeboxStdSteState->DW18.Huep2 = 6; |
| 3474 |
pVeboxStdSteState->DW18.Huep1 = MOS_BITFIELD_VALUE((uint32_t)-6, 7); |
| 3475 |
pVeboxStdSteState->DW18.Sats3 = 256; |
| 3476 |
|
| 3477 |
pVeboxStdSteState->DW19.Hueb3 = 56; |
| 3478 |
pVeboxStdSteState->DW19.Hueb2 = 8; |
| 3479 |
pVeboxStdSteState->DW19.Hueb1 = MOS_BITFIELD_VALUE((uint32_t)-8, 10); |
| 3480 |
|
| 3481 |
pVeboxStdSteState->DW20.Hues1 = 85; |
| 3482 |
pVeboxStdSteState->DW20.Hues0 = 384; |
| 3483 |
|
| 3484 |
pVeboxStdSteState->DW21.Hues3 = 256; |
| 3485 |
pVeboxStdSteState->DW21.Hues2 = 384; |
| 3486 |
} |
| 3487 |
else // if (pColorPipeParams->SteParams.dwSTEFactor > MHW_STE_OPTIMAL) |
| 3488 |
{ |
| 3489 |
pVeboxStdSteState->DW15.Satb1 = 0; |
| 3490 |
pVeboxStdSteState->DW15.Satp3 = 31; |
| 3491 |
pVeboxStdSteState->DW15.Satp2 = 31; |
| 3492 |
pVeboxStdSteState->DW15.Satp1 = pColorPipeParams->SteParams.satP1; |
| 3493 |
|
| 3494 |
pVeboxStdSteState->DW16.Sats0 = pColorPipeParams->SteParams.satS0; |
| 3495 |
pVeboxStdSteState->DW16.Satb3 = 124; |
| 3496 |
pVeboxStdSteState->DW16.Satb2 = 124; |
| 3497 |
|
| 3498 |
pVeboxStdSteState->DW17.Sats2 = 256; |
| 3499 |
pVeboxStdSteState->DW17.Sats1 = pColorPipeParams->SteParams.satS1; |
| 3500 |
|
| 3501 |
pVeboxStdSteState->DW18.Huep3 = 14; |
| 3502 |
pVeboxStdSteState->DW18.Huep2 = 14; |
| 3503 |
pVeboxStdSteState->DW18.Huep1 = 14; |
| 3504 |
pVeboxStdSteState->DW18.Sats3 = 256; |
| 3505 |
|
| 3506 |
pVeboxStdSteState->DW19.Hueb3 = 56; |
| 3507 |
pVeboxStdSteState->DW19.Hueb2 = 56; |
| 3508 |
pVeboxStdSteState->DW19.Hueb1 = 56; |
| 3509 |
|
| 3510 |
pVeboxStdSteState->DW20.Hues1 = 256; |
| 3511 |
pVeboxStdSteState->DW20.Hues0 = 256; |
| 3512 |
|
| 3513 |
pVeboxStdSteState->DW21.Hues3 = 256; |
| 3514 |
pVeboxStdSteState->DW21.Hues2 = 256; |
| 3515 |
} |
| 3516 |
} |
| 3517 |
else if (pColorPipeParams->bEnableSTD) |
| 3518 |
{ |
| 3519 |
if (nullptr == pColorPipeParams->StdParams.param || |
| 3520 |
pColorPipeParams->StdParams.paraSizeInBytes > pVeboxStdSteState->byteSize) |
| 3521 |
{ |
| 3522 |
MHW_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER); |
| 3523 |
} |
| 3524 |
|
| 3525 |
MOS_SecureMemcpy(pVeboxStdSteState, |
| 3526 |
pColorPipeParams->StdParams.paraSizeInBytes, |
| 3527 |
pColorPipeParams->StdParams.param, |
| 3528 |
pColorPipeParams->StdParams.paraSizeInBytes); |
| 3529 |
} |
| 3530 |
|
| 3531 |
// Enable Skin Score Output surface to be written by Vebox |
| 3532 |
if (enableLaceStdScoreOutput) |
| 3533 |
{ |
| 3534 |
// Older platforms: |
| 3535 |
// include LACE condition in StdScoreOutput |
| 3536 |
pVeboxStdSteState->DW1.StdScoreOutput = |
| 3537 |
(pColorPipeParams->bEnableLACE && pColorPipeParams->LaceParams.bSTD) || pColorPipeParams->bEnableSTD; |
| 3538 |
} |
| 3539 |
else |
| 3540 |
{ |
| 3541 |
// Newer platforms: |
| 3542 |
// StdScoreOutput is just bEnableSTD (LACE condition dropped) |
| 3543 |
pVeboxStdSteState->DW1.StdScoreOutput = pColorPipeParams->bEnableSTD; |
| 3544 |
} |
| 3545 |
|
| 3546 |
return eStatus; |
| 3547 |
} |
| 3548 |
|
| 3549 |
//! |
| 3550 |
//! \brief Common helper for SetVeboxIecpStateFecsc (Front-End CSC) |
| 3551 |
//! \details Encapsulates the shared implementation of SetVeboxIecpStateFecsc used |
| 3552 |
//! across all 6 platform-specific VEBOX implementations. Uses duck typing |
| 3553 |
//! on the FecscStateType template parameter so that all platforms can call |
| 3554 |
//! the same implementation regardless of their specific command namespace. |
| 3555 |
//! \param [in,out] pVeboxFecscState |
| 3556 |
//! Pointer to platform-specific VEBOX_FRONT_END_CSC_STATE_CMD structure |
| 3557 |
//! \param [in] pVeboxIecpParams |
| 3558 |
//! Pointer to VEBOX IECP State Params |
| 3559 |
//! \return void |
| 3560 |
//! |
| 3561 |
template <typename FecscStateType> |
| 3562 |
inline void SetVeboxIecpStateFecsc( |
| 3563 |
FecscStateType *pVeboxFecscState, |
| 3564 |
PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams) |
| 3565 |
{ |
| 3566 |
MHW_CAPPIPE_PARAMS *pCapPipeParams = nullptr; |
| 3567 |
|
| 3568 |
MHW_CHK_NULL_NO_STATUS_RETURN(pVeboxFecscState); |
| 3569 |
MHW_CHK_NULL_NO_STATUS_RETURN(pVeboxIecpParams); |
| 3570 |
|
| 3571 |
pCapPipeParams = &pVeboxIecpParams->CapPipeParams; |
| 3572 |
MHW_CHK_NULL_NO_STATUS_RETURN(pCapPipeParams); |
| 3573 |
MHW_ASSERT(pCapPipeParams->bActive); |
| 3574 |
|
| 3575 |
#define SET_COEFS(_c0, _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8) \ |
| 3576 |
{ \ |
| 3577 |
pVeboxFecscState->DW0.FecscC0TransformCoefficient = _c0; \ |
| 3578 |
pVeboxFecscState->DW1.FecscC1TransformCoefficient = _c1; \ |
| 3579 |
pVeboxFecscState->DW2.FecscC2TransformCoefficient = _c2; \ |
| 3580 |
pVeboxFecscState->DW3.FecscC3TransformCoefficient = _c3; \ |
| 3581 |
pVeboxFecscState->DW4.FecscC4TransformCoefficient = _c4; \ |
| 3582 |
pVeboxFecscState->DW5.FecscC5TransformCoefficient = _c5; \ |
| 3583 |
pVeboxFecscState->DW6.FecscC6TransformCoefficient = _c6; \ |
| 3584 |
pVeboxFecscState->DW7.FecscC7TransformCoefficient = _c7; \ |
| 3585 |
pVeboxFecscState->DW8.FecscC8TransformCoefficient = _c8; \ |
| 3586 |
} |
| 3587 |
|
| 3588 |
#define SET_INPUT_OFFSETS(_in1, _in2, _in3) \ |
| 3589 |
{ \ |
| 3590 |
pVeboxFecscState->DW9.FecScOffsetIn1OffsetInForYR = _in1; \ |
| 3591 |
pVeboxFecscState->DW10.FecScOffsetIn2OffsetOutForUG = _in2; \ |
| 3592 |
pVeboxFecscState->DW11.FecScOffsetIn3OffsetOutForVB = _in3; \ |
| 3593 |
} |
| 3594 |
|
| 3595 |
#define SET_OUTPUT_OFFSETS(_out1, _out2, _out3) \ |
| 3596 |
{ \ |
| 3597 |
pVeboxFecscState->DW9.FecScOffsetOut1OffsetOutForYR = _out1; \ |
| 3598 |
pVeboxFecscState->DW10.FecScOffsetOut2OffsetOutForUG = _out2; \ |
| 3599 |
pVeboxFecscState->DW11.FecScOffsetOut3OffsetOutForVB = _out3; \ |
| 3600 |
} |
| 3601 |
|
| 3602 |
pVeboxFecscState->DW0.FrontEndCscTransformEnable = true; |
| 3603 |
|
| 3604 |
if (pCapPipeParams->FECSCParams.bActive) |
| 3605 |
{ |
| 3606 |
// Coeff is S2.16, so multiply the floating value by 65536 |
| 3607 |
SET_COEFS( |
| 3608 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[0][0] * 65536)), |
| 3609 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[0][1] * 65536)), |
| 3610 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[0][2] * 65536)), |
| 3611 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[1][0] * 65536)), |
| 3612 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[1][1] * 65536)), |
| 3613 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[1][2] * 65536)), |
| 3614 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[2][0] * 65536)), |
| 3615 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[2][1] * 65536)), |
| 3616 |
((uint32_t)(pCapPipeParams->FECSCParams.Matrix[2][2] * 65536))); |
| 3617 |
SET_INPUT_OFFSETS( |
| 3618 |
((uint32_t)pCapPipeParams->FECSCParams.PreOffset[0]), |
| 3619 |
((uint32_t)pCapPipeParams->FECSCParams.PreOffset[1]), |
| 3620 |
((uint32_t)pCapPipeParams->FECSCParams.PreOffset[2])); |
| 3621 |
SET_OUTPUT_OFFSETS( |
| 3622 |
((uint32_t)pCapPipeParams->FECSCParams.PostOffset[0]), |
| 3623 |
((uint32_t)pCapPipeParams->FECSCParams.PostOffset[1]), |
| 3624 |
((uint32_t)pCapPipeParams->FECSCParams.PostOffset[2])); |
| 3625 |
} |
| 3626 |
else if (pVeboxIecpParams->bFeCSCEnable) |
| 3627 |
{ |
| 3628 |
// Coeff is S2.16, so multiply the floating value by 65536 |
| 3629 |
SET_COEFS( |
| 3630 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[0] * 65536)), |
| 3631 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[1] * 65536)), |
| 3632 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[2] * 65536)), |
| 3633 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[3] * 65536)), |
| 3634 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[4] * 65536)), |
| 3635 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[5] * 65536)), |
| 3636 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[6] * 65536)), |
| 3637 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[7] * 65536)), |
| 3638 |
((uint32_t)(pVeboxIecpParams->pfFeCscCoeff[8] * 65536))); |
| 3639 |
SET_INPUT_OFFSETS( |
| 3640 |
((uint32_t)(pVeboxIecpParams->pfFeCscInOffset[0] * 128.0F)), |
| 3641 |
((uint32_t)(pVeboxIecpParams->pfFeCscInOffset[1] * 128.0F)), |
| 3642 |
((uint32_t)(pVeboxIecpParams->pfFeCscInOffset[2] * 128.0F))); |
| 3643 |
SET_OUTPUT_OFFSETS( |
| 3644 |
((uint32_t)(pVeboxIecpParams->pfFeCscOutOffset[0] * 128.0F)), |
| 3645 |
((uint32_t)(pVeboxIecpParams->pfFeCscOutOffset[1] * 128.0F)), |
| 3646 |
((uint32_t)(pVeboxIecpParams->pfFeCscOutOffset[2] * 128.0F))); |
| 3647 |
} |
| 3648 |
else if (pVeboxIecpParams->ColorSpace == MHW_CSpace_BT601) |
| 3649 |
{ |
| 3650 |
SET_COEFS(16843, 33030, 6423, MOS_BITFIELD_VALUE((uint32_t)-9698, 19), MOS_BITFIELD_VALUE((uint32_t)-19070, 19), 28770, 28770, MOS_BITFIELD_VALUE((uint32_t)-24116, 19), MOS_BITFIELD_VALUE((uint32_t)-4652, 19)); |
| 3651 |
SET_INPUT_OFFSETS(0, 0, 0); |
| 3652 |
SET_OUTPUT_OFFSETS(2048, 16384, 16384); |
| 3653 |
} |
| 3654 |
else if (pVeboxIecpParams->ColorSpace == MHW_CSpace_BT709) |
| 3655 |
{ |
| 3656 |
SET_COEFS(11993, 40239, 4063, MOS_BITFIELD_VALUE((uint32_t)-6618, 19), MOS_BITFIELD_VALUE((uint32_t)-22216, 19), 28770, 28770, MOS_BITFIELD_VALUE((uint32_t)-26148, 19), MOS_BITFIELD_VALUE((uint32_t)-2620, 19)); |
| 3657 |
SET_INPUT_OFFSETS(0, 0, 0); |
| 3658 |
SET_OUTPUT_OFFSETS(2048, 16384, 16384); |
| 3659 |
} |
| 3660 |
else if (pVeboxIecpParams->ColorSpace == MHW_CSpace_sRGB) |
| 3661 |
{ |
| 3662 |
SET_COEFS(13932, 46871, 4731, MOS_BITFIELD_VALUE((uint32_t)-7508, 19), MOS_BITFIELD_VALUE((uint32_t)-25260, 19), 32768, 32768, MOS_BITFIELD_VALUE((uint32_t)-29764, 19), MOS_BITFIELD_VALUE((uint32_t)-3005, 19)); |
| 3663 |
SET_INPUT_OFFSETS(0, 0, 0); |
| 3664 |
SET_OUTPUT_OFFSETS(0, 16384, 16384); |
| 3665 |
} |
| 3666 |
else |
| 3667 |
{ |
| 3668 |
MHW_ASSERT(0); |
| 3669 |
} |
| 3670 |
|
| 3671 |
#undef SET_COEFS |
| 3672 |
#undef SET_INPUT_OFFSETS |
| 3673 |
#undef SET_OUTPUT_OFFSETS |
| 3674 |
} |
| 3675 |
|
| 3676 |
//! |
| 3677 |
//! \brief Common helper for SetVeboxIecpStateBecsc (Back-End CSC) |
| 3678 |
//! \details Encapsulates the shared implementation of SetVeboxIecpStateBecsc used |
| 3679 |
//! across all 6 platform-specific VEBOX implementations. Uses duck typing |
| 3680 |
//! on the IecpStateType template parameter so that all platforms can call |
| 3681 |
//! the same implementation regardless of their specific command namespace. |
| 3682 |
//! \param [in,out] pVeboxIecpState |
| 3683 |
//! Pointer to platform-specific VEBOX_IECP_STATE_CMD structure |
| 3684 |
//! \param [in] pVeboxIecpParams |
| 3685 |
//! Pointer to VEBOX IECP State Params |
| 3686 |
//! \param [in] bEnableFECSC |
| 3687 |
//! Whether Front-End CSC is enabled |
| 3688 |
//! \return MOS_STATUS |
| 3689 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 3690 |
//! |
| 3691 |
template <typename IecpStateType> |
| 3692 |
inline MOS_STATUS SetVeboxIecpStateBecsc( |
| 3693 |
IecpStateType *pVeboxIecpState, |
| 3694 |
PMHW_VEBOX_IECP_PARAMS pVeboxIecpParams, |
| 3695 |
bool bEnableFECSC) |
| 3696 |
{ |
| 3697 |
MHW_CAPPIPE_PARAMS *m_capPipeParams = nullptr; |
| 3698 |
MOS_FORMAT dstFormat; |
| 3699 |
|
| 3700 |
MHW_CHK_NULL_RETURN(pVeboxIecpState); |
| 3701 |
MHW_CHK_NULL_RETURN(pVeboxIecpParams); |
| 3702 |
|
| 3703 |
m_capPipeParams = &pVeboxIecpParams->CapPipeParams; |
| 3704 |
dstFormat = pVeboxIecpParams->dstFormat; |
| 3705 |
|
| 3706 |
#define SET_COEFS(_c0, _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8) \ |
| 3707 |
{ \ |
| 3708 |
pVeboxIecpState->CscState.DW0.C0 = _c0; \ |
| 3709 |
pVeboxIecpState->CscState.DW1.C1 = _c1; \ |
| 3710 |
pVeboxIecpState->CscState.DW2.C2 = _c2; \ |
| 3711 |
pVeboxIecpState->CscState.DW3.C3 = _c3; \ |
| 3712 |
pVeboxIecpState->CscState.DW4.C4 = _c4; \ |
| 3713 |
pVeboxIecpState->CscState.DW5.C5 = _c5; \ |
| 3714 |
pVeboxIecpState->CscState.DW6.C6 = _c6; \ |
| 3715 |
pVeboxIecpState->CscState.DW7.C7 = _c7; \ |
| 3716 |
pVeboxIecpState->CscState.DW8.C8 = _c8; \ |
| 3717 |
} |
| 3718 |
|
| 3719 |
#define SET_INPUT_OFFSETS(_in1, _in2, _in3) \ |
| 3720 |
{ \ |
| 3721 |
pVeboxIecpState->CscState.DW9.OffsetIn1 = _in1; \ |
| 3722 |
pVeboxIecpState->CscState.DW10.OffsetIn2 = _in2; \ |
| 3723 |
pVeboxIecpState->CscState.DW11.OffsetIn3 = _in3; \ |
| 3724 |
} |
| 3725 |
|
| 3726 |
#define SET_OUTPUT_OFFSETS(_out1, _out2, _out3) \ |
| 3727 |
{ \ |
| 3728 |
pVeboxIecpState->CscState.DW9.OffsetOut1 = _out1; \ |
| 3729 |
pVeboxIecpState->CscState.DW10.OffsetOut2 = _out2; \ |
| 3730 |
pVeboxIecpState->CscState.DW11.OffsetOut3 = _out3; \ |
| 3731 |
} |
| 3732 |
|
| 3733 |
MHW_CHK_NULL_RETURN(m_capPipeParams); |
| 3734 |
if (m_capPipeParams->bActive) |
| 3735 |
{ |
| 3736 |
// Application controlled CSC operation |
| 3737 |
if (m_capPipeParams->BECSCParams.bActive) |
| 3738 |
{ |
| 3739 |
pVeboxIecpState->CscState.DW0.TransformEnable = true; |
| 3740 |
|
| 3741 |
// Coeff is S2.16, so multiply the floating value by 65536 |
| 3742 |
SET_COEFS( |
| 3743 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[0][0] * 65536)), |
| 3744 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[0][1] * 65536)), |
| 3745 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[0][2] * 65536)), |
| 3746 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[1][0] * 65536)), |
| 3747 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[1][1] * 65536)), |
| 3748 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[1][2] * 65536)), |
| 3749 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[2][0] * 65536)), |
| 3750 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[2][1] * 65536)), |
| 3751 |
((uint32_t)(m_capPipeParams->BECSCParams.Matrix[2][2] * 65536))); |
| 3752 |
SET_INPUT_OFFSETS( |
| 3753 |
((uint32_t)m_capPipeParams->BECSCParams.PreOffset[0]), |
| 3754 |
((uint32_t)m_capPipeParams->BECSCParams.PreOffset[1]), |
| 3755 |
((uint32_t)m_capPipeParams->BECSCParams.PreOffset[2])); |
| 3756 |
SET_OUTPUT_OFFSETS( |
| 3757 |
((uint32_t)m_capPipeParams->BECSCParams.PostOffset[0]), |
| 3758 |
((uint32_t)m_capPipeParams->BECSCParams.PostOffset[1]), |
| 3759 |
((uint32_t)m_capPipeParams->BECSCParams.PostOffset[2])); |
| 3760 |
} |
| 3761 |
// YUV 4:4:4 CSC to xBGR or xRGB |
| 3762 |
else if ((bEnableFECSC || (pVeboxIecpParams->srcFormat == Format_AYUV)) && |
| 3763 |
(IS_RGB_FORMAT(dstFormat))) |
| 3764 |
{ |
| 3765 |
pVeboxIecpState->CscState.DW0.TransformEnable = true; |
| 3766 |
|
| 3767 |
// CSC matrix to convert YUV 4:4:4 to xBGR. e.g. Format_A8B8G8R8. In the |
| 3768 |
// event that dstFormat is xRGB, driver sets R & B channel swapping via |
| 3769 |
// CscState.DW0.YuvChannelSwap so a separate matrix is not needed. |
| 3770 |
|
| 3771 |
if (pVeboxIecpParams->ColorSpace == MHW_CSpace_BT601) |
| 3772 |
{ |
| 3773 |
SET_COEFS(76284, 0, 104595, 76284, MOS_BITFIELD_VALUE((uint32_t)-25689, 19), MOS_BITFIELD_VALUE((uint32_t)-53280, 19), 76284, 132186, 0); |
| 3774 |
|
| 3775 |
SET_INPUT_OFFSETS(MOS_BITFIELD_VALUE((uint32_t)-2048, 16), |
| 3776 |
MOS_BITFIELD_VALUE((uint32_t)-16384, 16), |
| 3777 |
MOS_BITFIELD_VALUE((uint32_t)-16384, 16)); |
| 3778 |
SET_OUTPUT_OFFSETS(0, 0, 0); |
| 3779 |
} |
| 3780 |
else if (pVeboxIecpParams->ColorSpace == MHW_CSpace_BT709) |
| 3781 |
{ |
| 3782 |
SET_COEFS(76284, 0, 117506, 76284, MOS_BITFIELD_VALUE((uint32_t)-13958, 19), MOS_BITFIELD_VALUE((uint32_t)-34930, 19), 76284, 138412, 0); |
| 3783 |
|
| 3784 |
SET_INPUT_OFFSETS(MOS_BITFIELD_VALUE((uint32_t)-2048, 16), |
| 3785 |
MOS_BITFIELD_VALUE((uint32_t)-16384, 16), |
| 3786 |
MOS_BITFIELD_VALUE((uint32_t)-16384, 16)); |
| 3787 |
SET_OUTPUT_OFFSETS(0, 0, 0); |
| 3788 |
} |
| 3789 |
else |
| 3790 |
{ |
| 3791 |
MHW_ASSERT(false); |
| 3792 |
} |
| 3793 |
} |
| 3794 |
} |
| 3795 |
else if (pVeboxIecpParams->bCSCEnable) |
| 3796 |
{ |
| 3797 |
pVeboxIecpState->CscState.DW0.TransformEnable = true; |
| 3798 |
|
| 3799 |
// Coeff is S2.16, so multiply the floating value by 65536 |
| 3800 |
SET_COEFS( |
| 3801 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[0] * 65536.0F)), |
| 3802 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[1] * 65536.0F)), |
| 3803 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[2] * 65536.0F)), |
| 3804 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[3] * 65536.0F)), |
| 3805 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[4] * 65536.0F)), |
| 3806 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[5] * 65536.0F)), |
| 3807 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[6] * 65536.0F)), |
| 3808 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[7] * 65536.0F)), |
| 3809 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscCoeff[8] * 65536.0F))); |
| 3810 |
|
| 3811 |
// Offset is S15, but the SW offsets are calculated as 8bits, |
| 3812 |
// so left shift them 7bits to be in the position of MSB |
| 3813 |
SET_INPUT_OFFSETS( |
| 3814 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscInOffset[0] * 128.0F)), |
| 3815 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscInOffset[1] * 128.0F)), |
| 3816 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscInOffset[2] * 128.0F))); |
| 3817 |
SET_OUTPUT_OFFSETS( |
| 3818 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscOutOffset[0] * 128.0F)), |
| 3819 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscOutOffset[1] * 128.0F)), |
| 3820 |
((uint32_t)MOS_F_ROUND(pVeboxIecpParams->pfCscOutOffset[2] * 128.0F))); |
| 3821 |
} |
| 3822 |
|
| 3823 |
pVeboxIecpState->AlphaAoiState.DW0.AlphaFromStateSelect = pVeboxIecpParams->bAlphaEnable; |
| 3824 |
|
| 3825 |
if (pVeboxIecpParams->dstFormat == Format_Y416) |
| 3826 |
{ |
| 3827 |
pVeboxIecpState->AlphaAoiState.DW0.ColorPipeAlpha = pVeboxIecpParams->wAlphaValue; |
| 3828 |
} |
| 3829 |
else |
| 3830 |
{ |
| 3831 |
// Alpha is U16, but the SW alpha is calculated as 8bits, |
| 3832 |
// so left shift it 8bits to be in the position of MSB |
| 3833 |
pVeboxIecpState->AlphaAoiState.DW0.ColorPipeAlpha = pVeboxIecpParams->wAlphaValue * 256; |
| 3834 |
} |
| 3835 |
|
| 3836 |
#undef SET_COEFS |
| 3837 |
#undef SET_INPUT_OFFSETS |
| 3838 |
#undef SET_OUTPUT_OFFSETS |
| 3839 |
|
| 3840 |
return MOS_STATUS_SUCCESS; |
| 3841 |
} |
| 3842 |
|
| 3843 |
//! |
| 3844 |
//! \brief Common helper for SetVeboxCapPipeState shared logic |
| 3845 |
//! \details Encapsulates the BlackLevelParams and WhiteBalanceParams logic |
| 3846 |
//! that is 100% identical across all 6 platform-specific VEBOX |
| 3847 |
//! implementations. Each platform's member function sets up the |
| 3848 |
//! heap pointer and fetches the typed state pointer, then delegates |
| 3849 |
//! all logic to this helper. |
| 3850 |
//! \param [in,out] pVeboxCapPipeState |
| 3851 |
//! Pointer to platform-specific VEBOX_CAPTURE_PIPE_STATE_CMD structure |
| 3852 |
//! \param [in] pCapPipeParams |
| 3853 |
//! Pointer to capture pipe parameters |
| 3854 |
//! \return void |
| 3855 |
//! |
| 3856 |
template <typename CapPipeStateCmdType> |
| 3857 |
inline void SetVeboxCapPipeStateCommon( |
| 3858 |
CapPipeStateCmdType *pVeboxCapPipeState, |
| 3859 |
PMHW_CAPPIPE_PARAMS pCapPipeParams) |
| 3860 |
{ |
| 3861 |
if (pCapPipeParams->BlackLevelParams.bActive) |
| 3862 |
{ |
| 3863 |
pVeboxCapPipeState->DW2.BlackPointCorrectionEnable = true; |
| 3864 |
// Red |
| 3865 |
pVeboxCapPipeState->DW2.BlackPointOffsetRedMsb = |
| 3866 |
(pCapPipeParams->BlackLevelParams.R & MOS_BITFIELD_BIT_N(16)) >> 16; |
| 3867 |
pVeboxCapPipeState->DW3.BlackPointOffsetRed = |
| 3868 |
pCapPipeParams->BlackLevelParams.R & MOS_MASK(0, 15); |
| 3869 |
// Green Top |
| 3870 |
pVeboxCapPipeState->DW2.BlackPointOffsetGreenTopMsb = |
| 3871 |
(pCapPipeParams->BlackLevelParams.G1 & MOS_BITFIELD_BIT_N(16)) >> 16; |
| 3872 |
pVeboxCapPipeState->DW3.BlackPointOffsetGreenTop = |
| 3873 |
pCapPipeParams->BlackLevelParams.G1 & MOS_MASK(0, 15); |
| 3874 |
// Green Bottom |
| 3875 |
pVeboxCapPipeState->DW2.BlackPointOffsetGreenBottomMsb = |
| 3876 |
(pCapPipeParams->BlackLevelParams.G0 & MOS_BITFIELD_BIT_N(16)) >> 16; |
| 3877 |
pVeboxCapPipeState->DW4.BlackPointOffsetGreenBottom = |
| 3878 |
pCapPipeParams->BlackLevelParams.G0 & MOS_MASK(0, 15); |
| 3879 |
// Blue |
| 3880 |
pVeboxCapPipeState->DW2.BlackPointOffsetBlueMsb = |
| 3881 |
(pCapPipeParams->BlackLevelParams.B & MOS_BITFIELD_BIT_N(16)) >> 16; |
| 3882 |
pVeboxCapPipeState->DW4.BlackPointOffsetBlue = |
| 3883 |
pCapPipeParams->BlackLevelParams.B & MOS_MASK(0, 15); |
| 3884 |
} |
| 3885 |
|
| 3886 |
if (pCapPipeParams->WhiteBalanceParams.bActive && |
| 3887 |
pCapPipeParams->WhiteBalanceParams.Mode == MHW_WB_MANUAL) |
| 3888 |
{ |
| 3889 |
pVeboxCapPipeState->DW2.WhiteBalanceCorrectionEnable = true; |
| 3890 |
|
| 3891 |
// Is U4.12, so multiply the floating value by 4096 |
| 3892 |
// Red |
| 3893 |
pVeboxCapPipeState->DW5.WhiteBalanceRedCorrection = |
| 3894 |
(uint32_t)(pCapPipeParams->WhiteBalanceParams.RedCorrection * 4096); |
| 3895 |
|
| 3896 |
// Green Top |
| 3897 |
pVeboxCapPipeState->DW5.WhiteBalanceGreenTopCorrection = |
| 3898 |
(uint32_t)(pCapPipeParams->WhiteBalanceParams.GreenTopCorrection * 4096); |
| 3899 |
|
| 3900 |
// Green Bottom |
| 3901 |
pVeboxCapPipeState->DW6.WhiteBalanceGreenBottomCorrection = |
| 3902 |
(uint32_t)(pCapPipeParams->WhiteBalanceParams.GreenBottomCorrection * 4096); |
| 3903 |
|
| 3904 |
// Blue |
| 3905 |
pVeboxCapPipeState->DW6.WhiteBalanceBlueCorrection = |
| 3906 |
(uint32_t)(pCapPipeParams->WhiteBalanceParams.BlueCorrection * 4096); |
| 3907 |
} |
| 3908 |
} |
| 3909 |
|
| 3910 |
//! |
| 3911 |
//! \brief Common helper for AddVeboxTilingConvert shared logic |
| 3912 |
//! \details Encapsulates the tiling mode switch logic, MOCS index assignment, |
| 3913 |
//! InitMocsParams/AddResourceToCmd calls for both input and output |
| 3914 |
//! surfaces, SurfaceControlBits assignment, and pfnAddCommand call. |
| 3915 |
//! This logic is common across all 6 platform-specific VEBOX |
| 3916 |
//! implementations. Platform-specific differences (e.g., compression |
| 3917 |
//! handling for, different MOCS usage) are |
| 3918 |
//! handled by the caller before invoking this helper. |
| 3919 |
//! \param [in,out] cmd |
| 3920 |
//! Reference to VEBOX_TILING_CONVERT_CMD structure |
| 3921 |
//! \param [in,out] veboxInputSurfCtrlBits |
| 3922 |
//! Reference to input surface control bits (may have compression bits |
| 3923 |
//! pre-set by caller) |
| 3924 |
//! \param [in,out] veboxOutputSurfCtrlBits |
| 3925 |
//! Reference to output surface control bits (may have compression bits |
| 3926 |
//! pre-set by caller) |
| 3927 |
//! \param [in] inputSurface |
| 3928 |
//! Pointer to input MOS resource |
| 3929 |
//! \param [in] outputSurface |
| 3930 |
//! Pointer to output MOS resource |
| 3931 |
//! \param [in] inSurParams |
| 3932 |
//! Pointer to input surface parameters |
| 3933 |
//! \param [in] outSurParams |
| 3934 |
//! Pointer to output surface parameters |
| 3935 |
//! \param [in] mocsIndex |
| 3936 |
//! MOCS index value already computed by the caller |
| 3937 |
//! \param [in] osItf |
| 3938 |
//! Pointer to OS interface |
| 3939 |
//! \param [in] cmdBuffer |
| 3940 |
//! Pointer to command buffer |
| 3941 |
//! \param [in] AddResourceToCmd |
| 3942 |
//! Function pointer to AddResourceToCmd |
| 3943 |
//! \return MOS_STATUS |
| 3944 |
//! MOS_STATUS_SUCCESS if success, else fail reason |
| 3945 |
//! |
| 3946 |
template <typename cmd_t> |
| 3947 |
inline MOS_STATUS SetupVeboxTilingConvertCommon( |
| 3948 |
typename cmd_t::VEBOX_TILING_CONVERT_CMD &cmd, |
| 3949 |
typename cmd_t::VEB_DI_IECP_COMMAND_SURFACE_CONTROL_BITS_CMD &veboxInputSurfCtrlBits, |
| 3950 |
typename cmd_t::VEB_DI_IECP_COMMAND_SURFACE_CONTROL_BITS_CMD &veboxOutputSurfCtrlBits, |
| 3951 |
PMOS_RESOURCE inputSurface, |
| 3952 |
PMOS_RESOURCE outputSurface, |
| 3953 |
PMHW_VEBOX_SURFACE_PARAMS inSurParams, |
| 3954 |
PMHW_VEBOX_SURFACE_PARAMS outSurParams, |
| 3955 |
uint32_t mocsIndex, |
| 3956 |
PMOS_INTERFACE osItf, |
| 3957 |
PMOS_COMMAND_BUFFER cmdBuffer, |
| 3958 |
MOS_STATUS(*AddResourceToCmd)(PMOS_INTERFACE, PMOS_COMMAND_BUFFER, PMHW_RESOURCE_PARAMS)) |
| 3959 |
{ |
| 3960 |
MHW_RESOURCE_PARAMS ResourceParams = {0}; |
| 3961 |
|
| 3962 |
// Set input tiling mode |
| 3963 |
switch (inputSurface->TileType) |
| 3964 |
{ |
| 3965 |
case MOS_TILE_YF: |
| 3966 |
veboxInputSurfCtrlBits.DW0.TiledResourceModeForOutputFrameSurfaceBaseAddress = TRMODE_TILEYF; |
| 3967 |
break; |
| 3968 |
case MOS_TILE_YS: |
| 3969 |
veboxInputSurfCtrlBits.DW0.TiledResourceModeForOutputFrameSurfaceBaseAddress = TRMODE_TILEYS; |
| 3970 |
break; |
| 3971 |
default: |
| 3972 |
veboxInputSurfCtrlBits.DW0.TiledResourceModeForOutputFrameSurfaceBaseAddress = TRMODE_NONE; |
| 3973 |
break; |
| 3974 |
} |
| 3975 |
|
| 3976 |
// Set output tiling mode |
| 3977 |
if (outputSurface) |
| 3978 |
{ |
| 3979 |
switch (outputSurface->TileType) |
| 3980 |
{ |
| 3981 |
case MOS_TILE_YF: |
| 3982 |
veboxOutputSurfCtrlBits.DW0.TiledResourceModeForOutputFrameSurfaceBaseAddress = TRMODE_TILEYF; |
| 3983 |
break; |
| 3984 |
case MOS_TILE_YS: |
| 3985 |
veboxOutputSurfCtrlBits.DW0.TiledResourceModeForOutputFrameSurfaceBaseAddress = TRMODE_TILEYS; |
| 3986 |
break; |
| 3987 |
default: |
| 3988 |
veboxOutputSurfCtrlBits.DW0.TiledResourceModeForOutputFrameSurfaceBaseAddress = TRMODE_NONE; |
| 3989 |
break; |
| 3990 |
} |
| 3991 |
} |
| 3992 |
|
| 3993 |
// Set MOCS index for both input and output |
| 3994 |
veboxInputSurfCtrlBits.DW0.IndexToMemoryObjectControlStateMocsTables = mocsIndex; |
| 3995 |
veboxOutputSurfCtrlBits.DW0.IndexToMemoryObjectControlStateMocsTables = mocsIndex; |
| 3996 |
|
| 3997 |
// Setup input resource params: set up DW[2:1], input graphics address |
| 3998 |
MOS_ZeroMemory(&ResourceParams, sizeof(MHW_RESOURCE_PARAMS)); |
| 3999 |
InitMocsParams(ResourceParams, &cmd.DW1_2.Value[0], 1, 6); |
| 4000 |
ResourceParams.presResource = inputSurface; |
| 4001 |
ResourceParams.HwCommandType = MOS_VEBOX_TILING_CONVERT; |
| 4002 |
ResourceParams.dwLocationInCmd = 1; |
| 4003 |
ResourceParams.pdwCmd = &(cmd.DW1_2.Value[0]); |
| 4004 |
ResourceParams.bIsWritable = false; |
| 4005 |
ResourceParams.dwOffset = inSurParams->dwOffset + veboxInputSurfCtrlBits.DW0.Value; |
| 4006 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd(osItf, cmdBuffer, &ResourceParams)); |
| 4007 |
cmd.DW1_2.InputSurfaceControlBits = veboxInputSurfCtrlBits.DW0.Value; |
| 4008 |
|
| 4009 |
// Setup output resource params: set up DW[4:3], output graphics address |
| 4010 |
MOS_ZeroMemory(&ResourceParams, sizeof(MHW_RESOURCE_PARAMS)); |
| 4011 |
InitMocsParams(ResourceParams, &cmd.DW3_4.Value[0], 1, 6); |
| 4012 |
ResourceParams.presResource = outputSurface; |
| 4013 |
ResourceParams.HwCommandType = MOS_VEBOX_TILING_CONVERT; |
| 4014 |
ResourceParams.dwLocationInCmd = 3; |
| 4015 |
ResourceParams.pdwCmd = &(cmd.DW3_4.Value[0]); |
| 4016 |
ResourceParams.bIsWritable = true; |
| 4017 |
ResourceParams.dwOffset = outSurParams->dwOffset + veboxOutputSurfCtrlBits.DW0.Value; |
| 4018 |
MHW_CHK_STATUS_RETURN(AddResourceToCmd(osItf, cmdBuffer, &ResourceParams)); |
| 4019 |
cmd.DW3_4.OutputSurfaceControlBits = veboxOutputSurfCtrlBits.DW0.Value; |
| 4020 |
|
| 4021 |
// Issue command |
| 4022 |
osItf->pfnAddCommand(cmdBuffer, &cmd, cmd.byteSize); |
| 4023 |
|
| 4024 |
return MOS_STATUS_SUCCESS; |
| 4025 |
} |
| 4026 |
|
| 4027 |
} // namespace common |
| 4028 |
} // namespace vebox |
| 4029 |
} // namespace mhw |
| 4030 |
|
| 4031 |
#endif // __MHW_VEBOX_COMMON_IMPL_H__ |