1 /* Copyright 2022 Advanced Micro Devices, Inc. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a 4 * copy of this software and associated documentation files (the "Software"), 5 * to deal in the Software without restriction, including without limitation 6 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * and/or sell copies of the Software, and to permit persons to whom the 8 * Software is furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * OTHER DEALINGS IN THE SOFTWARE. 20 * 21 * Authors: AMD 22 * 23 */ 24 25 /** 26 * @file vpe_types.h 27 * @brief This is the file containing the API structures for the VPE library. 28 */ 29 #pragma once 30 31 #include <stdbool.h> 32 #include <stdint.h> 33 #include <stddef.h> 34 #include <limits.h> 35 #include "vpe_hw_types.h" 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 struct vpe; 42 43 /** @def MAX_NB_POLYPHASE_COEFFS 44 * 45 * @brief Maximum number of filter coefficients for polyphase scaling. 46 * VPE library supports up to 8 taps and 64 phases, only (32+1) phases needed 47 */ 48 #define MAX_NB_POLYPHASE_COEFFS (8 * 33) 49 50 /** @enum vpe_status 51 * @brief The status of VPE to indicate whether it supports the given job or not. 52 */ 53 enum vpe_status { 54 VPE_STATUS_OK = 1, /**< VPE supports the job. */ 55 VPE_STATUS_ERROR, /**< Unknown Error in VPE. */ 56 VPE_STATUS_NO_MEMORY, /**< VPE is out of memory. */ 57 VPE_STATUS_NOT_SUPPORTED, /**< VPE is out of memory. */ 58 VPE_STATUS_INPUT_DCC_NOT_SUPPORTED, /**< Input DCC is not supported. */ 59 VPE_STATUS_OUTPUT_DCC_NOT_SUPPORTED, /**< Output DCC is not supported. */ 60 VPE_STATUS_SWIZZLE_NOT_SUPPORTED, /**< Swizzle mode is not supported. */ 61 VPE_STATUS_NUM_STREAM_NOT_SUPPORTED, /**< Number of streams is not supported. Too many 62 streams. */ 63 VPE_STATUS_PIXEL_FORMAT_NOT_SUPPORTED, /**< Pixel format is not supported. */ 64 VPE_STATUS_COLOR_SPACE_VALUE_NOT_SUPPORTED, /**< Input DCC is not supported. */ 65 VPE_STATUS_SCALING_RATIO_NOT_SUPPORTED, /**< Given scaling is not supported. */ 66 VPE_STATUS_PITCH_ALIGNMENT_NOT_SUPPORTED, /**< Given pitch alignment is not supported. */ 67 VPE_STATUS_ROTATION_NOT_SUPPORTED, /**< Given rotation is not supported. */ 68 VPE_STATUS_MIRROR_NOT_SUPPORTED, /**< Given mirror is not supported. */ 69 VPE_STATUS_ALPHA_BLENDING_NOT_SUPPORTED, /**< Alpha blending is not supported. */ 70 VPE_STATUS_VIEWPORT_SIZE_NOT_SUPPORTED, /**< Given viewport size is not supported. */ 71 VPE_STATUS_LUMA_KEYING_NOT_SUPPORTED, /**< Luma keying is not supported. */ 72 VPE_STATUS_COLOR_KEYING_NOT_SUPPORTED, /**< Color keying is not supported. */ 73 VPE_STATUS_INVALID_KEYER_CONFIG, /**< Keying config is invalid. */ 74 VPE_STATUS_PLANE_ADDR_NOT_SUPPORTED, /**< Given plane address is not supported. */ 75 VPE_STATUS_ADJUSTMENT_NOT_SUPPORTED, /**< Color adjustment is not supported. */ 76 VPE_STATUS_CMD_OVERFLOW_ERROR, /**< More than 256 commands/jobs. */ 77 VPE_STATUS_SEGMENT_WIDTH_ERROR, /**< Calculated segment width is not supported. */ 78 VPE_STATUS_PARAM_CHECK_ERROR, /**< Given parametrs is not supported. */ 79 VPE_STATUS_TONE_MAP_NOT_SUPPORTED, /**< Tone mapping is not supported for the given 80 job. */ 81 VPE_STATUS_BAD_TONE_MAP_PARAMS, /**< Invalid tone mapping parameters. */ 82 VPE_STATUS_BAD_HDR_METADATA, /**< Ivalid HDR metadata. */ 83 VPE_STATUS_BUFFER_OVERFLOW, /**< Buffer overflow. */ 84 VPE_STATUS_BUFFER_UNDERRUN, /**< Buffer does not have enough capacity. */ 85 VPE_STATUS_BG_COLOR_OUT_OF_RANGE, /**< Given backgroud color does not lie in the 86 range of output color. */ 87 VPE_STATUS_REPEAT_ITEM, /**< Descriptor writer is on a repeated job. 88 Used internally */ 89 VPE_STATUS_PATCH_OVER_MAXSIZE, /**< Descriptor writer patch size is larger than 90 supported path size. */ 91 VPE_STATUS_INVALID_BUFFER_SIZE, /**< Provided buffer size is less than required 92 buffer size. */ 93 VPE_STATUS_SCALER_NOT_SET, /**< Scaler parameters are not set. */ 94 VPE_STATUS_GEOMETRICSCALING_ERROR, /**< Geometric scaling is not supported for the 95 given case. */ 96 }; 97 98 /***************************************************** 99 * Enum for emitting VPE System Events 100 *****************************************************/ 101 102 /** @enum vpe_event_id 103 * @brief Event IDs are VPE events that can be emitted through 104 * the EventLog callback. For each event ID, the number of params 105 * emitted must by synchronized with handler 106 */ 107 enum vpe_event_id { 108 VPE_EVENT_CHECK_SUPPORT, /**< Event emitted by vpe_check_support. 109 Params: 110 UInt32 num_streams, 111 UInt32 target_rect.width, 112 UInt32 target_rect.height, 113 UInt32 target_rect.height 114 */ 115 116 VPE_EVENT_MAX_ID /**< Max ID represents the number of event IDs supported */ 117 }; 118 119 /** @enum vpe_ip_level 120 * @brief HW IP level 121 */ 122 enum vpe_ip_level { 123 VPE_IP_LEVEL_UNKNOWN = (-1), 124 VPE_IP_LEVEL_1_0, /**< vpe 1.0 */ 125 VPE_IP_LEVEL_1_1, /**< vpe 1.1 */ 126 }; 127 128 /**************************************** 129 * Plane Caps 130 ****************************************/ 131 132 /** @struct vpe_pixel_format_support 133 * @brief Capability to support formats 134 */ 135 struct vpe_pixel_format_support { 136 uint32_t argb_packed_32b : 1; /**< Packed RGBA formats 32-bits per pixel */ 137 uint32_t nv12 : 1; /**< planar 4:2:0 8-bits */ 138 uint32_t fp16 : 1; /**< Floating point RGB 16-bits */ 139 uint32_t p010 : 1; /**< planar 4:2:0 10-bits */ 140 uint32_t p016 : 1; /**< planar 4:2:0 16-bits */ 141 uint32_t ayuv : 1; /**< packed 4:4:4 8-bits */ 142 uint32_t yuy2 : 1; /**< packed 4:2:2 8-bits */ 143 }; 144 145 /** @struct vpe_plane_caps 146 * @brief Capability to support given plane 147 */ 148 struct vpe_plane_caps { 149 uint32_t per_pixel_alpha : 1; /**< Per-pixel alpha */ 150 151 struct vpe_pixel_format_support 152 input_pixel_format_support; /**< Input pixel format capability */ 153 struct vpe_pixel_format_support 154 output_pixel_format_support; /**< Output pixel format capability */ 155 156 uint32_t max_upscale_factor; /**< Maximum upscaling factor (dst/src) x 1000. 157 E.g. 1080p -> 4k is 4000 */ 158 uint32_t max_downscale_factor; /**< Maximum downscaling factor (dst/src) x 1000. 159 E.g. 4k -> 1080p is 250 */ 160 161 uint32_t pitch_alignment; /**< Pitch alignment in bytes */ 162 uint32_t addr_alignment; /**< Plane address alignment in bytes */ 163 uint32_t max_viewport_width; /**< Maximum viewport size */ 164 }; 165 166 /************************* 167 * Color management caps 168 *************************/ 169 170 /** @struct vpe_rom_curve_caps 171 * @brief Capability to support given transfer function 172 */ 173 struct vpe_rom_curve_caps { 174 uint32_t srgb : 1; /**< SRGB Gamma */ 175 uint32_t bt2020 : 1; /**< BT 2020 */ 176 uint32_t gamma2_2 : 1; /**< Gamma 2.2 */ 177 uint32_t pq : 1; /**< Perceptual Quantizer */ 178 uint32_t hlg : 1; /**< Hybrid log-gamma */ 179 }; 180 181 /** @struct dpp_color_caps 182 * @brief Color management caps for dpp layer 183 */ 184 struct dpp_color_caps { 185 uint32_t pre_csc : 1; 186 uint32_t luma_key : 1; 187 uint32_t color_key : 1; 188 uint32_t dgam_ram : 1; 189 uint32_t post_csc : 1; /**< before gamut remap */ 190 uint32_t gamma_corr : 1; 191 uint32_t hw_3dlut : 1; 192 uint32_t ogam_ram : 1; 193 uint32_t ocsc : 1; 194 struct vpe_rom_curve_caps dgam_rom_caps; 195 }; 196 197 /** @struct mpc_color_caps 198 * @brief Color management caps for mpc layer 199 */ 200 struct mpc_color_caps { 201 uint32_t gamut_remap : 1; /**< Gamut remap */ 202 uint32_t ogam_ram : 1; /**< Ogam */ 203 uint32_t ocsc : 1; /**< OCSC */ 204 uint32_t shared_3d_lut : 1; /**< can be in either dpp or mpc, but single instance */ 205 uint32_t global_alpha : 1; /**< e.g. top plane 30 %. bottom 70 % */ 206 uint32_t top_bottom_blending : 1; /**< two-layer blending */ 207 }; 208 209 /** @struct vpe_color_caps 210 * @brief VPE color management caps 211 */ 212 struct vpe_color_caps { 213 struct dpp_color_caps dpp; /**< DPP color caps */ 214 struct mpc_color_caps mpc; /**< MPC color caps */ 215 }; 216 217 /************************************************** 218 * @struct vpe_caps 219 * @brief VPE Capabilities. 220 * 221 * Those depend on the condition like input format 222 * shall be queried by @ref vpe_cap_funcs 223 **************************************************/ 224 struct vpe_caps { 225 uint32_t max_downscale_ratio; /**< max downscaling ratio (src/dest) x 100. 226 E.g. 4k -> 1080p is 400 */ 227 uint64_t lut_size; /**< 3dlut size */ 228 229 uint32_t rotation_support : 1; 230 uint32_t h_mirror_support : 1; 231 uint32_t v_mirror_support : 1; 232 uint32_t is_apu : 1; 233 uint32_t bg_color_check_support : 1; 234 struct { 235 uint32_t num_dpp; 236 uint32_t num_opp; 237 uint32_t num_mpc_3dlut; 238 uint32_t num_cdc_be; 239 240 uint32_t num_queue; /**< num of hw queue */ 241 } resource_caps; 242 243 struct vpe_color_caps color_caps; 244 struct vpe_plane_caps plane_caps; 245 246 }; 247 248 /*********************************** 249 * Conditional Capabilities 250 ***********************************/ 251 /** @struct vpe_dcc_surface_param 252 * @brief DCC surface parameters 253 */ 254 struct vpe_dcc_surface_param { 255 struct vpe_size surface_size; 256 enum vpe_surface_pixel_format format; 257 enum vpe_swizzle_mode_values swizzle_mode; 258 enum vpe_scan_direction scan; 259 enum vpe_mirror mirror; 260 }; 261 262 /** @struct vpe_dcc_setting 263 * @brief DCC Settings 264 */ 265 struct vpe_dcc_setting { 266 unsigned int max_compressed_blk_size; 267 unsigned int max_uncompressed_blk_size; 268 bool independent_64b_blks; 269 270 struct { 271 uint32_t dcc_256_64_64 : 1; 272 uint32_t dcc_128_128_uncontrained : 1; 273 uint32_t dcc_256_128_128 : 1; 274 uint32_t dcc_256_256_unconstrained : 1; 275 } dcc_controls; 276 }; 277 278 /** @struct vpe_surface_dcc_cap 279 * @brief DCC Capabilities 280 */ 281 struct vpe_surface_dcc_cap { 282 union { 283 struct { 284 struct vpe_dcc_setting rgb; 285 } grph; 286 287 struct { 288 struct vpe_dcc_setting luma; 289 struct vpe_dcc_setting chroma; 290 } video; 291 }; 292 293 bool capable; 294 bool const_color_support; 295 296 }; 297 298 /** @struct vpe_cap_funcs 299 * @brief Conditional Capability functions 300 */ 301 struct vpe_cap_funcs { 302 /** @brief 303 * Get DCC support and setting according to the format, 304 * scan direction and swizzle mode for output. 305 * 306 * @param[in] vpe vpe instance 307 * @param[in] params surface properties 308 * @param[in/out] cap dcc capable result and related settings 309 * @return true if supported 310 */ 311 bool (*get_dcc_compression_output_cap)(const struct vpe *vpe, 312 const struct vpe_dcc_surface_param *params, struct vpe_surface_dcc_cap *cap); 313 314 /** @brief 315 * Get DCC support and setting according to the format, 316 * scan direction and swizzle mode for input. 317 * 318 * @param[in] vpe vpe instance 319 * @param[in] params surface properties 320 * @param[in/out] cap dcc capable result and related settings 321 * @return true if supported 322 */ 323 bool (*get_dcc_compression_input_cap)(const struct vpe *vpe, 324 const struct vpe_dcc_surface_param *params, struct vpe_surface_dcc_cap *cap); 325 }; 326 327 /**************************************** 328 * VPE Init Param 329 ****************************************/ 330 /** @brief Log function 331 * @param[in] log_ctx given in the struct @ref vpe_init_data 332 * @param[in] fmt format string 333 */ 334 typedef void (*vpe_log_func_t)(void *log_ctx, const char *fmt, ...); 335 336 /** @brief Sys Event function 337 * @param[in] event_id event to emit to system log 338 */ 339 typedef void (*vpe_sys_event_func_t)(enum vpe_event_id event_id, ...); 340 341 /** @brief system memory zalloc, allocated memory initailized with 0 342 * 343 * @param[in] mem_ctx given in the struct @ref vpe_init_data 344 * @param[in] size number of bytes 345 * @return allocated memory 346 */ 347 typedef void *(*vpe_zalloc_func_t)(void *mem_ctx, size_t size); 348 349 /** @brief system memory free 350 * @param[in] mem_ctx given in the struct @ref vpe_init_data 351 * @param[in] ptr number of bytes 352 */ 353 typedef void (*vpe_free_func_t)(void *mem_ctx, void *ptr); 354 355 /** @struct vpe_callback_funcs 356 * @brief Callback functions. 357 */ 358 struct vpe_callback_funcs { 359 void *log_ctx; /**< optional. provided by the caller and pass back to callback */ 360 vpe_log_func_t log; /**< Logging function */ 361 362 vpe_sys_event_func_t sys_event; /**< System event function */ 363 364 void *mem_ctx; /**< optional. provided by the caller and pass back to callback */ 365 vpe_zalloc_func_t zalloc; /**< Memory allocation */ 366 vpe_free_func_t free; /**< Free memory. In sync with @ref zalloc */ 367 }; 368 369 /** @struct vpe_mem_low_power_enable_options 370 * @brief Component activation on low power mode. Only used for debugging. 371 */ 372 struct vpe_mem_low_power_enable_options { 373 // override flags 374 struct { 375 uint32_t dscl : 1; 376 uint32_t cm : 1; 377 uint32_t mpc : 1; 378 } flags; 379 380 struct { 381 uint32_t dscl : 1; 382 uint32_t cm : 1; 383 uint32_t mpc : 1; 384 } bits; 385 }; 386 387 /** @enum vpe_expansion_mode 388 * @brief Color component expansion mode 389 */ 390 enum vpe_expansion_mode { 391 VPE_EXPANSION_MODE_DYNAMIC, /**< Dynamic expansion */ 392 VPE_EXPANSION_MODE_ZERO /**< Zero expansion */ 393 }; 394 395 /** @enum vpe_clamping_range 396 * @brief Color clamping 397 */ 398 enum vpe_clamping_range { 399 VPE_CLAMPING_FULL_RANGE = 0, /**< No Clamping */ 400 VPE_CLAMPING_LIMITED_RANGE_8BPC, /**< 8 bpc: Clamping 1 to FE */ 401 VPE_CLAMPING_LIMITED_RANGE_10BPC, /**< 10 bpc: Clamping 4 to 3FB */ 402 VPE_CLAMPING_LIMITED_RANGE_12BPC, /**< 12 bpc: Clamping 10 to FEF */ 403 VPE_CLAMPING_LIMITED_RANGE_PROGRAMMABLE, /**< Programmable. Use programmable clampping value on 404 FMT_CLAMP_COMPONENT_R/G/B. */ 405 }; 406 407 /** @struct vpe_clamping_params 408 * @brief Upper and lower bound of each color channel for clamping. 409 */ 410 struct vpe_clamping_params { 411 enum vpe_clamping_range clamping_range; 412 uint32_t r_clamp_component_upper; /**< Red channel upper bound */ 413 uint32_t b_clamp_component_upper; /**< Blue channel upper bound */ 414 uint32_t g_clamp_component_upper; /**< Green channel upper bound */ 415 uint32_t r_clamp_component_lower; /**< Red channel lower bound */ 416 uint32_t b_clamp_component_lower; /**< Blue channel lower bound */ 417 uint32_t g_clamp_component_lower; /**< Green channel lower bound */ 418 }; 419 420 /** @struct vpe_visual_confirm 421 * @brief Configurable parameters for visual confirm bar 422 */ 423 struct vpe_visual_confirm { 424 union { 425 struct { 426 uint32_t input_format : 1; 427 uint32_t output_format : 1; 428 uint32_t reserved : 30; 429 }; 430 uint32_t value; 431 }; 432 }; 433 434 /** @struct vpe_debug_options 435 * @brief Configurable parameters for debugging purpose 436 */ 437 struct vpe_debug_options { 438 // override flags 439 struct { 440 uint32_t cm_in_bypass : 1; 441 uint32_t vpcnvc_bypass : 1; 442 uint32_t mpc_bypass : 1; 443 uint32_t identity_3dlut : 1; 444 uint32_t sce_3dlut : 1; 445 uint32_t disable_reuse_bit : 1; 446 uint32_t bg_color_fill_only : 1; 447 uint32_t assert_when_not_support : 1; 448 uint32_t bypass_gamcor : 1; 449 uint32_t bypass_ogam : 1; 450 uint32_t bypass_dpp_gamut_remap : 1; 451 uint32_t bypass_post_csc : 1; 452 uint32_t bypass_blndgam : 1; 453 uint32_t clamping_setting : 1; 454 uint32_t expansion_mode : 1; 455 uint32_t bypass_per_pixel_alpha : 1; 456 uint32_t dpp_crc_ctrl : 1; 457 uint32_t opp_pipe_crc_ctrl : 1; 458 uint32_t mpc_crc_ctrl : 1; 459 uint32_t bg_bit_depth : 1; 460 uint32_t visual_confirm : 1; 461 uint32_t skip_optimal_tap_check : 1; 462 uint32_t disable_lut_caching : 1; 463 } flags; 464 465 // valid only if the corresponding flag is set 466 uint32_t cm_in_bypass : 1; 467 uint32_t vpcnvc_bypass : 1; 468 uint32_t mpc_bypass : 1; 469 uint32_t identity_3dlut : 1; 470 uint32_t sce_3dlut : 1; 471 uint32_t disable_reuse_bit : 1; 472 uint32_t bg_color_fill_only : 1; 473 uint32_t assert_when_not_support : 1; 474 uint32_t bypass_gamcor : 1; 475 uint32_t bypass_ogam : 1; 476 uint32_t bypass_dpp_gamut_remap : 1; 477 uint32_t bypass_post_csc : 1; 478 uint32_t bypass_blndgam : 1; 479 uint32_t clamping_setting : 1; 480 uint32_t bypass_per_pixel_alpha : 1; 481 uint32_t dpp_crc_ctrl : 1; 482 uint32_t opp_pipe_crc_ctrl : 1; 483 uint32_t mpc_crc_ctrl : 1; 484 uint32_t skip_optimal_tap_check : 1; 485 uint32_t disable_lut_caching : 1; /*< disable config caching for all luts */ 486 uint32_t bg_bit_depth; 487 488 struct vpe_mem_low_power_enable_options enable_mem_low_power; 489 enum vpe_expansion_mode expansion_mode; 490 struct vpe_clamping_params clamping_params; 491 struct vpe_visual_confirm visual_confirm_params; 492 }; 493 494 /** @struct vpe_init_data 495 * @brief VPE ip info and debug/callback functions 496 */ 497 struct vpe_init_data { 498 499 uint8_t ver_major; /**< vpe major version */ 500 uint8_t ver_minor; /**< vpe minor version */ 501 uint8_t ver_rev; /**< vpe revision version */ 502 struct vpe_callback_funcs funcs; /**< function callbacks */ 503 struct vpe_debug_options debug; /**< debug options */ 504 }; 505 506 /** @struct vpe 507 * @brief VPE instance created through vpelib entry function vpe_create() 508 */ 509 struct vpe { 510 uint32_t version; /**< API version */ 511 enum vpe_ip_level level; /**< HW IP level */ 512 513 struct vpe_caps *caps; /**< general static chip caps */ 514 struct vpe_cap_funcs *cap_funcs; /**< conditional caps */ 515 }; 516 517 /***************************************************** 518 * Structures for build VPE command 519 *****************************************************/ 520 521 /** @enum vpe_pixel_encoding 522 * @brief Color space format 523 */ 524 enum vpe_pixel_encoding { 525 VPE_PIXEL_ENCODING_YCbCr, /**< YCbCr Color space format */ 526 VPE_PIXEL_ENCODING_RGB, /**< RGB Color space format */ 527 VPE_PIXEL_ENCODING_COUNT 528 }; 529 530 /** @enum vpe_color_range 531 * @brief Color Range 532 */ 533 enum vpe_color_range { 534 VPE_COLOR_RANGE_FULL, /**< Full range */ 535 VPE_COLOR_RANGE_STUDIO, /**< Studio/limited range */ 536 VPE_COLOR_RANGE_COUNT 537 }; 538 539 /** @enum vpe_chroma_cositing 540 * @brief Chroma Cositing 541 * 542 * The position of the chroma for the chroma sub-sampled pixel formats. 543 */ 544 enum vpe_chroma_cositing { 545 VPE_CHROMA_COSITING_NONE, /**< No cositing */ 546 VPE_CHROMA_COSITING_LEFT, /**< Left cositing */ 547 VPE_CHROMA_COSITING_TOPLEFT, /**< Top-left cositing */ 548 VPE_CHROMA_COSITING_COUNT 549 }; 550 551 /** @enum vpe_color_primaries 552 * @brief Color Primaries 553 */ 554 enum vpe_color_primaries { 555 VPE_PRIMARIES_BT601, /**< BT. 601, Rec. 601 */ 556 VPE_PRIMARIES_BT709, /**< BT. 709, Rec. 709 */ 557 VPE_PRIMARIES_BT2020, /**< BT. 2020, Rec. 2020 */ 558 VPE_PRIMARIES_JFIF, /**< JPEG File Interchange Format */ 559 VPE_PRIMARIES_COUNT 560 }; 561 562 /** @enum vpe_transfer_function 563 * @brief Gamma Transfer function 564 */ 565 enum vpe_transfer_function { 566 VPE_TF_G22, /**< Gamma 2.2 */ 567 VPE_TF_G24, /**< Gamma 2.4 */ 568 VPE_TF_G10, /**< Linear */ 569 VPE_TF_PQ, /**< Perceptual Quantizer */ 570 VPE_TF_PQ_NORMALIZED, /**< Normalized Perceptual Quantizer */ 571 VPE_TF_HLG, /**< Hybrid Log-Gamma */ 572 VPE_TF_SRGB, /**< Standard RGB */ 573 VPE_TF_BT709, /**< BT 709 */ 574 VPE_TF_COUNT 575 }; 576 577 /** @enum vpe_alpha_mode 578 * @brief Alpha mode of the stream. 579 */ 580 enum vpe_alpha_mode { 581 VPE_ALPHA_OPAQUE, /**< Opaque. In this mode, If output has alpha channel, it is set to 582 * maximum value. For FP16 format it is set to 125.0f, 583 * and 2^(AlphaChannelBitDepth)-1 for other formats. 584 */ 585 VPE_ALPHA_BGCOLOR /**< If the output has alpha channel, sets the output alpha to be the 586 * alpha value of the user-provided background color. 587 */ 588 }; 589 590 /** @struct vpe_color_space 591 * @brief Color space parameters. 592 */ 593 struct vpe_color_space { 594 enum vpe_pixel_encoding encoding; /**< Color space format. RGBA vs. YCbCr */ 595 enum vpe_color_range range; /**< Color range. Full vs. Studio */ 596 enum vpe_transfer_function tf; /**< Transfer Function/Gamma */ 597 enum vpe_chroma_cositing cositing; /**< Chroma Cositing */ 598 enum vpe_color_primaries primaries; /**< Color primaries */ 599 }; 600 601 /** @struct vpe_color_rgba 602 * @brief Color value of each channel for RGBA color space formats. 603 * 604 * Component values are in the range: 0.0f - 1.0f 605 */ 606 struct vpe_color_rgba { 607 float r; /**< Red Channel*/ 608 float g; /**< Green Channel*/ 609 float b; /**< Blue Channel*/ 610 float a; /**< Alpha Channel*/ 611 }; 612 613 /** @struct vpe_color_ycbcra 614 * @brief Color value of each channel for YCbCr color space formats. 615 * 616 * Component values are in the range: 0.0f - 1.0f 617 */ 618 struct vpe_color_ycbcra { 619 float y; /**< Luminance/Luma Channel */ 620 float cb; /**< Blue-difference Chrominance/Chroma Channel */ 621 float cr; /**< Red-difference Chrominance/Chroma Channel */ 622 float a; /**< Alpha Channel */ 623 }; 624 625 /** @struct vpe_color 626 * @brief Color value of each pixel 627 */ 628 struct vpe_color { 629 bool is_ycbcr; /**< Set if the color space format is YCbCr. 630 If Ture, use @ref ycbcra. If False, use @ref rgba. */ 631 union { 632 struct vpe_color_rgba rgba; /**< RGBA value */ 633 struct vpe_color_ycbcra ycbcra; /**< YCbCr value */ 634 }; 635 }; 636 637 /** @struct vpe_color_adjust 638 * @brief Color adjustment values 639 * <pre> 640 * Adjustment Min Max default step 641 * 642 * Brightness -100.0f, 100.0f, 0.0f, 0.1f 643 * 644 * Contrast 0.0f, 2.0f, 1.0f, 0.01f 645 * 646 * Hue -180.0f, 180.0f, 0.0f, 1.0f 647 * 648 * Saturation 0.0f, 3.0f, 1.0f, 0.01f 649 * </pre> 650 */ 651 struct vpe_color_adjust { 652 float brightness; /**< Brightness */ 653 float contrast; /**< Contrast */ 654 float hue; /**< Hue */ 655 float saturation; /**< Saturation */ 656 }; 657 658 /** @struct vpe_surface_info 659 * @brief Surface address and properties 660 * 661 */ 662 struct vpe_surface_info { 663 664 struct vpe_plane_address address; /**< Address */ 665 enum vpe_swizzle_mode_values swizzle; /**< Swizzle mode */ 666 667 struct vpe_plane_size plane_size; /**< Pitch */ 668 struct vpe_plane_dcc_param dcc; 669 enum vpe_surface_pixel_format format; /**< Surface pixel format */ 670 671 struct vpe_color_space cs; /**< Surface color space */ 672 }; 673 674 struct vpe_blend_info { 675 bool blending; /**< Enable blending */ 676 bool pre_multiplied_alpha; /**< Is the pixel value pre-multiplied with alpha */ 677 bool global_alpha; /**< Enable global alpha */ 678 float global_alpha_value; /**< Global alpha value. In range of 0.0-1.0 */ 679 }; 680 681 /** @struct vpe_scaling_info 682 * @brief Data needs to calculate scaling data. 683 */ 684 struct vpe_scaling_info { 685 struct vpe_rect src_rect; /**< Input frame/stream rectangle*/ 686 struct vpe_rect dst_rect; /**< Output rectangle on the destination surface. */ 687 struct vpe_scaling_taps taps; /**< Number of taps to be used for scaler. 688 * If taps are set to 0, vpe internally calculates the 689 * required number of taps based on the scaling ratio. 690 */ 691 692 }; 693 694 /** @struct vpe_scaling_filter_coeffs 695 * @brief Filter coefficients for polyphase scaling 696 * 697 * If the number of taps are set to be 0, vpe internally calculates the number of taps and filter 698 * coefficients based on the scaling ratio. 699 */ 700 struct vpe_scaling_filter_coeffs { 701 702 struct vpe_scaling_taps taps; /**< Number of taps for polyphase 703 scaling */ 704 unsigned int nb_phases; /**< Number of phases for polyphase 705 scaling */ 706 uint16_t horiz_polyphase_coeffs[MAX_NB_POLYPHASE_COEFFS]; /**< Filter coefficients for 707 horizontal polyphase scaling */ 708 uint16_t vert_polyphase_coeffs[MAX_NB_POLYPHASE_COEFFS]; /**< Filter coefficients for 709 vertical polyphase scaling */ 710 }; 711 712 /** @struct vpe_hdr_metadata 713 * @brief HDR metadata 714 */ 715 struct vpe_hdr_metadata { 716 uint16_t redX; /**< Red point chromaticity X-value */ 717 uint16_t redY; /**< Red point chromaticity Y-value */ 718 uint16_t greenX; /**< Green point chromaticity X-value */ 719 uint16_t greenY; /**< Green point chromaticity Y-value */ 720 uint16_t blueX; /**< Blue point chromaticity X-value */ 721 uint16_t blueY; /**< Blue point chromaticity Y-value */ 722 uint16_t whiteX; /**< White point chromaticity X-value */ 723 uint16_t whiteY; /**< White point chromaticity Y-value */ 724 725 uint32_t min_mastering; /**< Minimum luminance for HDR frame/stream in 1/10000 nits */ 726 uint32_t max_mastering; /**< Maximum luminance for HDR frame/stream in nits */ 727 uint32_t max_content; /**< Maximum stream's content light level */ 728 uint32_t avg_content; /**< Frame's average light level */ 729 }; 730 731 struct vpe_reserved_param { 732 void *param; 733 uint32_t size; 734 }; 735 736 /** @struct vpe_tonemap_params 737 * @brief Tone mapping parameters 738 */ 739 struct vpe_tonemap_params { 740 uint64_t UID; /**< Unique ID for tonemap params provided by 741 * user. If tone mapping is not needed, set 742 * to 0, otherwise, each update to the 743 * tonemap parameter should use a new ID to 744 * signify a tonemap update. 745 */ 746 enum vpe_transfer_function shaper_tf; /**< Shaper LUT transfer function */ 747 enum vpe_transfer_function lut_out_tf; /**< Output transfer function */ 748 enum vpe_color_primaries lut_in_gamut; /**< Input color primary */ 749 enum vpe_color_primaries lut_out_gamut; /**< Output color primary */ 750 uint16_t input_pq_norm_factor; /**< Perceptual Quantizer normalization 751 factor. */ 752 uint16_t lut_dim; /**< Size of one dimension of the 3D-LUT */ 753 union { 754 uint16_t *lut_data; /**< Accessible to CPU */ 755 }; 756 bool is_dma_lut; 757 bool enable_3dlut; /**< Enable/Disable 3D-LUT */ 758 }; 759 760 /** @enum vpe_keyer_mode 761 * @brief Dictates the behavior of keyer's generated alpha 762 */ 763 enum vpe_keyer_mode { 764 VPE_KEYER_MODE_RANGE_00 = 0, /**< (Default) if in range -> generated alpha = 00 */ 765 VPE_KEYER_MODE_RANGE_FF, /**< if in_range -> generated alpha = FF */ 766 VPE_KEYER_MODE_FORCE_00, /**< ignore range setting, force generating alpha = 00 */ 767 VPE_KEYER_MODE_FORCE_FF, /**< ignore range setting, force generating alpha = FF */ 768 }; 769 770 /** @enum vpe_color_keyer 771 * @brief Input Parameters for Color keyer. 772 * bounds should be programmed to 0.0 <= 1.0, with lower < upper 773 * if format does not have alpha (RGBx) when using the color keyer, alpha should be programmed to 774 * lower=0.0, upper=1.0 775 */ 776 struct vpe_color_keyer { 777 bool enable_color_key; /**< Enable Color Key. Mutually Exclusive with Luma Key */ 778 float lower_g_bound; /**< Green Low Bound. */ 779 float upper_g_bound; /**< Green High Bound. */ 780 float lower_b_bound; /**< Blue Low Bound. */ 781 float upper_b_bound; /**< Blue High Bound. */ 782 float lower_r_bound; /**< Red Low Bound. */ 783 float upper_r_bound; /**< Red High Bound. */ 784 float lower_a_bound; /**< Alpha Low Bound. Program 0.0f if no alpha channel in input format.*/ 785 float upper_a_bound; /**< Alpha High Bound. Program 1.0f if no alpha channel in input format.*/ 786 }; 787 /** @struct vpe_stream 788 * @brief Input stream/frame properties to be passed to vpelib 789 */ 790 struct vpe_stream { 791 struct vpe_surface_info surface_info; /**< Stream plane information. */ 792 struct vpe_scaling_info scaling_info; /**< Scaling information. */ 793 struct vpe_blend_info blend_info; /**< Alpha blending */ 794 struct vpe_color_adjust color_adj; /**< Color adjustment. Brightness, 795 contrast, hue and saturation.*/ 796 struct vpe_tonemap_params tm_params; /**< Tone mapping parameters*/ 797 struct vpe_hdr_metadata hdr_metadata; /**< HDR metadata */ 798 struct vpe_scaling_filter_coeffs polyphase_scaling_coeffs; /**< Filter coefficients for 799 polyphase scaling. */ 800 enum vpe_rotation_angle rotation; /**< Rotation angle of the 801 stream/frame */ 802 bool horizontal_mirror; /**< Set if the stream is flipped 803 horizontally */ 804 bool vertical_mirror; /**< Set if the stream is flipped 805 vertically */ 806 bool use_external_scaling_coeffs; /**< Use provided polyphase scaling 807 * filter coefficients. 808 * See @ref vpe_scaling_filter_coeffs 809 */ 810 bool enable_luma_key; /**< Enable luma keying. Only 811 * works if vpe version supports 812 * luma keying. 813 */ 814 float lower_luma_bound; /**< Lowest range of the luma */ 815 float upper_luma_bound; /**< Highest range of the luma */ 816 struct vpe_color_keyer color_keyer; /**< Enable Luma Keying & Set Parameters. */ 817 enum vpe_keyer_mode keyer_mode; /**< Set Keyer Behavior. 818 * Used for both Luma & Color Keying. 819 */ 820 struct vpe_reserved_param reserved_param; 821 822 struct { 823 uint32_t hdr_metadata : 1; 824 uint32_t geometric_scaling : 1; /**< Enables geometric scaling. 825 * Support 1 input stream only. 826 * If set, gamut/gamma remapping will be disabled, 827 * as well as blending. 828 * Destination rect must equal to target rect. 829 */ 830 uint32_t reserved : 30; 831 } flags; 832 }; 833 834 /** @struct vpe_build_param 835 * @brief Build parametrs for vpelib. Must get populated before vpe_check_support() call. 836 */ 837 struct vpe_build_param { 838 839 uint32_t num_streams; /**< Number of source streams */ 840 struct vpe_stream *streams; /**< List of input streams */ 841 struct vpe_surface_info dst_surface; /**< Destination/Output surface */ 842 struct vpe_rect target_rect; /**< rectangle in target surface to be blt'd. 843 Ranges out of target_rect won't be touched */ 844 struct vpe_color bg_color; /**< Background Color */ 845 enum vpe_alpha_mode alpha_mode; /**< Alpha Mode. Output alpha in the output 846 surface */ 847 struct vpe_hdr_metadata hdr_metadata; /**< HDR Metadata */ 848 struct vpe_reserved_param dst_reserved_param; 849 850 // data flags 851 struct { 852 uint32_t hdr_metadata : 1; 853 uint32_t reserved : 31; 854 } flags; 855 856 uint16_t num_instances; /**< Number of instances for the collaboration mode */ 857 bool collaboration_mode; /**< Collaboration mode. If set, multiple instances of VPE being 858 used. */ 859 }; 860 861 /** @struct vpe_bufs_req 862 * @brief Command buffer and Embedded buffer required sizes reported through vpe_check_support() 863 * 864 * Once the operation is supported, 865 * it returns the required memory for storing 866 * 1. command buffer 867 * 2. embedded buffer 868 * - Pointed by the command buffer content. 869 * - Shall be free'ed together with command buffer once 870 * command is finished. 871 */ 872 struct vpe_bufs_req { 873 uint64_t cmd_buf_size; /**< total command buffer size for all vpe commands */ 874 uint64_t emb_buf_size; /**< total size for storing all embedded data */ 875 }; 876 877 /** @struct vpe_buf 878 * @brief Buffer information 879 */ 880 struct vpe_buf { 881 uint64_t gpu_va; /**< GPU start address of the buffer */ 882 uint64_t cpu_va; /**< CPU start address of the buffer */ 883 uint64_t size; /**< Size of the buffer */ 884 bool tmz; /**< allocated from tmz */ 885 }; 886 887 /** @struct vpe_build_bufs 888 * @brief Command buffer and Embedded buffer 889 */ 890 struct vpe_build_bufs { 891 struct vpe_buf cmd_buf; /**< Command buffer. gpu_va is optional */ 892 struct vpe_buf emb_buf; /**< Embedded buffer */ 893 }; 894 895 #ifdef __cplusplus 896 } 897 #endif 898