1 #ifndef _MSM_MDP_EXT_H_ 2 #define _MSM_MDP_EXT_H_ 3 4 #include <linux/msm_mdp.h> 5 6 #define MDP_IOCTL_MAGIC 'S' 7 /* atomic commit ioctl used for validate and commit request */ 8 #define MSMFB_ATOMIC_COMMIT _IOWR(MDP_IOCTL_MAGIC, 128, void *) 9 10 /* 11 * Ioctl for updating the layer position asynchronously. Initially, pipes 12 * should be configured with MDP_LAYER_ASYNC flag set during the atomic commit, 13 * after which any number of position update calls can be made. This would 14 * enable multiple position updates within a single vsync. However, the screen 15 * update would happen only after vsync, which would pick the latest update. 16 * 17 * Limitations: 18 * - Currently supported only for video mode panels with single LM or dual LM 19 * with source_split enabled. 20 * - Only position update is supported with no scaling/cropping. 21 * - Async layers should have unique z_order. 22 */ 23 #define MSMFB_ASYNC_POSITION_UPDATE _IOWR(MDP_IOCTL_MAGIC, 129, \ 24 struct mdp_position_update) 25 26 /* 27 * Ioctl for sending the config information. 28 * QSEED3 coefficeint LUT tables is passed by the user space using this IOCTL. 29 */ 30 #define MSMFB_MDP_SET_CFG _IOW(MDP_IOCTL_MAGIC, 130, \ 31 struct mdp_set_cfg) 32 33 /* 34 * To allow proper structure padding for 64bit/32bit target 35 */ 36 #ifdef __LP64 37 #define MDP_LAYER_COMMIT_V1_PAD 1 38 #else 39 #define MDP_LAYER_COMMIT_V1_PAD 3 40 #endif 41 42 /********************************************************************** 43 LAYER FLAG CONFIGURATION 44 **********************************************************************/ 45 /* left-right layer flip flag */ 46 #define MDP_LAYER_FLIP_LR 0x1 47 48 /* up-down layer flip flag */ 49 #define MDP_LAYER_FLIP_UD 0x2 50 51 /* 52 * This flag enables pixel extension for the current layer. Validate/commit 53 * call uses scale parameters when this flag is enabled. 54 */ 55 #define MDP_LAYER_ENABLE_PIXEL_EXT 0x4 56 57 /* Flag indicates that layer is foreground layer */ 58 #define MDP_LAYER_FORGROUND 0x8 59 60 /* Flag indicates that layer is associated with secure session */ 61 #define MDP_LAYER_SECURE_SESSION 0x10 62 63 /* 64 * Flag indicates that layer is drawing solid fill. Validate/commit call 65 * does not expect buffer when this flag is enabled. 66 */ 67 #define MDP_LAYER_SOLID_FILL 0x20 68 69 /* Layer format is deinterlace */ 70 #define MDP_LAYER_DEINTERLACE 0x40 71 72 /* layer contains bandwidth compressed format data */ 73 #define MDP_LAYER_BWC 0x80 74 75 /* layer is async position updatable */ 76 #define MDP_LAYER_ASYNC 0x100 77 78 /* layer contains postprocessing configuration data */ 79 #define MDP_LAYER_PP 0x200 80 81 /* Flag indicates that layer is associated with secure display session */ 82 #define MDP_LAYER_SECURE_DISPLAY_SESSION 0x400 83 84 /* Flag enabled qseed3 scaling for the current layer */ 85 #define MDP_LAYER_ENABLE_QSEED3_SCALE 0x800 86 87 /********************************************************************** 88 DESTINATION SCALER FLAG CONFIGURATION 89 **********************************************************************/ 90 91 /* Enable/disable Destination scaler */ 92 #define MDP_DESTSCALER_ENABLE 0x1 93 94 /* 95 * Indicating mdp_destination_scaler_data contains 96 * Scaling parameter update. Can be set anytime. 97 */ 98 #define MDP_DESTSCALER_SCALE_UPDATE 0x2 99 100 /* 101 * Indicating mdp_destination_scaler_data contains 102 * Detail enhancement setting update. Can be set anytime. 103 */ 104 #define MDP_DESTSCALER_ENHANCER_UPDATE 0x4 105 106 /* 107 * layer will work in multirect mode, where single hardware should 108 * fetch multiple rectangles with a single hardware 109 */ 110 #define MDP_LAYER_MULTIRECT_ENABLE 0x1000 111 112 /* 113 * if flag present and multirect is enabled, multirect will work in parallel 114 * fetch mode, otherwise it will default to serial fetch mode. 115 */ 116 #define MDP_LAYER_MULTIRECT_PARALLEL_MODE 0x2000 117 118 /********************************************************************** 119 VALIDATE/COMMIT FLAG CONFIGURATION 120 **********************************************************************/ 121 122 /* 123 * Client enables it to inform that call is to validate layers before commit. 124 * If this flag is not set then driver will use MSMFB_ATOMIC_COMMIT for commit. 125 */ 126 #define MDP_VALIDATE_LAYER 0x01 127 128 /* 129 * This flag is only valid for commit call. Commit behavior is synchronous 130 * when this flag is defined. It blocks current call till processing is 131 * complete. Behavior is asynchronous otherwise. 132 */ 133 #define MDP_COMMIT_WAIT_FOR_FINISH 0x02 134 135 /* 136 * This flag is only valid for commit call and used for debugging purpose. It 137 * forces the to wait for sync fences. 138 */ 139 #define MDP_COMMIT_SYNC_FENCE_WAIT 0x04 140 141 #define MDP_COMMIT_VERSION_1_0 0x00010000 142 143 #define OUT_LAYER_COLOR_SPACE 144 145 /********************************************************************** 146 Configuration structures 147 All parameters are input to driver unless mentioned output parameter 148 explicitly. 149 **********************************************************************/ 150 struct mdp_layer_plane { 151 /* DMA buffer file descriptor information. */ 152 int fd; 153 154 /* Pixel offset in the dma buffer. */ 155 uint32_t offset; 156 157 /* Number of bytes in one scan line including padding bytes. */ 158 uint32_t stride; 159 }; 160 161 struct mdp_layer_buffer { 162 /* layer width in pixels. */ 163 uint32_t width; 164 165 /* layer height in pixels. */ 166 uint32_t height; 167 168 /* 169 * layer format in DRM-style fourcc, refer drm_fourcc.h for 170 * standard formats 171 */ 172 uint32_t format; 173 174 /* plane to hold the fd, offset, etc for all color components */ 175 struct mdp_layer_plane planes[MAX_PLANES]; 176 177 /* valid planes count in layer planes list */ 178 uint32_t plane_count; 179 180 /* compression ratio factor, value depends on the pixel format */ 181 struct mult_factor comp_ratio; 182 183 /* 184 * SyncFence associated with this buffer. It is used in two ways. 185 * 186 * 1. Driver waits to consume the buffer till producer signals in case 187 * of primary and external display. 188 * 189 * 2. Writeback device uses buffer structure for output buffer where 190 * driver is producer. However, client sends the fence with buffer to 191 * indicate that consumer is still using the buffer and it is not ready 192 * for new content. 193 */ 194 int fence; 195 196 /* 32bits reserved value for future usage. */ 197 uint32_t reserved; 198 }; 199 200 /* 201 * One layer holds configuration for one pipe. If client wants to stage single 202 * layer on two pipes then it should send two different layers with relative 203 * (x,y) information. Client must send same information during validate and 204 * commit call. Commit call may fail if client sends different layer information 205 * attached to same pipe during validate and commit. Device invalidate the pipe 206 * once it receives the vsync for that commit. 207 */ 208 struct mdp_input_layer { 209 /* 210 * Flag to enable/disable properties for layer configuration. Refer 211 * layer flag configuration section for all possible flags. 212 */ 213 uint32_t flags; 214 215 /* 216 * Pipe selection for this layer by client. Client provides the index 217 * in validate and commit call. Device reserves the pipe once validate 218 * is successful. Device only uses validated pipe during commit call. 219 * If client sends different layer/pipe configuration in validate & 220 * commit then commit may fail. 221 */ 222 uint32_t pipe_ndx; 223 224 /* 225 * Horizontal decimation value, this indicates the amount of pixels 226 * dropped for each pixel that is fetched from a line. It does not 227 * result in bandwidth reduction because pixels are still fetched from 228 * memory but dropped internally by hardware. 229 * The decimation value given should be power of two of decimation 230 * amount. 231 * 0: no decimation 232 * 1: decimate by 2 (drop 1 pixel for each pixel fetched) 233 * 2: decimate by 4 (drop 3 pixels for each pixel fetched) 234 * 3: decimate by 8 (drop 7 pixels for each pixel fetched) 235 * 4: decimate by 16 (drop 15 pixels for each pixel fetched) 236 */ 237 uint8_t horz_deci; 238 239 /* 240 * Vertical decimation value, this indicates the amount of lines 241 * dropped for each line that is fetched from overlay. It saves 242 * bandwidth because decimated pixels are not fetched. 243 * The decimation value given should be power of two of decimation 244 * amount. 245 * 0: no decimation 246 * 1: decimation by 2 (drop 1 line for each line fetched) 247 * 2: decimation by 4 (drop 3 lines for each line fetched) 248 * 3: decimation by 8 (drop 7 lines for each line fetched) 249 * 4: decimation by 16 (drop 15 lines for each line fetched) 250 */ 251 uint8_t vert_deci; 252 253 /* 254 * Used to set plane opacity. The range can be from 0-255, where 255 * 0 means completely transparent and 255 means fully opaque. 256 */ 257 uint8_t alpha; 258 259 /* 260 * Blending stage to occupy in display, if multiple layers are present, 261 * highest z_order usually means the top most visible layer. The range 262 * acceptable is from 0-7 to support blending up to 8 layers. 263 */ 264 uint16_t z_order; 265 266 /* 267 * Color used as color key for transparency. Any pixel in fetched 268 * image matching this color will be transparent when blending. 269 * The color should be in same format as the source image format. 270 */ 271 uint32_t transp_mask; 272 273 /* 274 * Solid color used to fill the overlay surface when no source 275 * buffer is provided. 276 */ 277 uint32_t bg_color; 278 279 /* blend operation defined in "mdss_mdp_blend_op" enum. */ 280 enum mdss_mdp_blend_op blend_op; 281 282 /* color space of the source */ 283 enum mdp_color_space color_space; 284 285 /* 286 * Source crop rectangle, portion of image that will be fetched. This 287 * should always be within boundaries of source image. 288 */ 289 struct mdp_rect src_rect; 290 291 /* 292 * Destination rectangle, the position and size of image on screen. 293 * This should always be within panel boundaries. 294 */ 295 struct mdp_rect dst_rect; 296 297 /* Scaling parameters. */ 298 void __user *scale; 299 300 /* Buffer attached with each layer. Device uses it for commit call. */ 301 struct mdp_layer_buffer buffer; 302 303 /* 304 * Source side post processing configuration information for each 305 * layer. 306 */ 307 void __user *pp_info; 308 309 /* 310 * This is an output parameter. 311 * 312 * Only for validate call. Frame buffer device sets error code 313 * based on validate call failure scenario. 314 */ 315 int error_code; 316 317 /* 32bits reserved value for future usage. */ 318 uint32_t reserved[6]; 319 }; 320 321 struct mdp_output_layer { 322 /* 323 * Flag to enable/disable properties for layer configuration. Refer 324 * layer flag config section for all possible flags. 325 */ 326 uint32_t flags; 327 328 /* 329 * Writeback destination selection for output. Client provides the index 330 * in validate and commit call. 331 */ 332 uint32_t writeback_ndx; 333 334 /* Buffer attached with output layer. Device uses it for commit call */ 335 struct mdp_layer_buffer buffer; 336 337 /* color space of the destination */ 338 enum mdp_color_space color_space; 339 340 /* 32bits reserved value for future usage. */ 341 uint32_t reserved[5]; 342 }; 343 344 /* 345 * Destination scaling info structure holds setup paramaters for upscaling 346 * setting in the destination scaling block. 347 */ 348 struct mdp_destination_scaler_data { 349 /* 350 * Flag to switch between mode for destination scaler. Please Refer to 351 * destination scaler flag config for all possible setting. 352 */ 353 uint32_t flags; 354 355 /* 356 * Destination scaler selection index. Client provides the index in 357 * validate and commit call. 358 */ 359 uint32_t dest_scaler_ndx; 360 361 /* 362 * LM width configuration per Destination scaling updates 363 */ 364 uint32_t lm_width; 365 366 /* 367 * LM height configuration per Destination scaling updates 368 */ 369 uint32_t lm_height; 370 371 /* 372 * The scaling parameters for all the mode except disable. For 373 * disabling the scaler, there is no need to provide the scale. 374 * A userspace pointer points to struct mdp_scale_data_v2. 375 */ 376 uint64_t __user scale; 377 }; 378 379 /* Enable Deterministic Frame Rate Control (FRC) */ 380 #define MDP_VIDEO_FRC_ENABLE (1 << 0) 381 382 struct mdp_frc_info { 383 /* flags to control FRC feature */ 384 uint32_t flags; 385 /* video frame count per frame */ 386 uint32_t frame_cnt; 387 /* video timestamp per frame in millisecond unit */ 388 int64_t timestamp; 389 }; 390 391 /* 392 * Commit structure holds layer stack send by client for validate and commit 393 * call. If layers are different between validate and commit call then commit 394 * call will also do validation. In such case, commit may fail. 395 */ 396 struct mdp_layer_commit_v1 { 397 /* 398 * Flag to enable/disable properties for commit/validate call. Refer 399 * validate/commit flag config section for all possible flags. 400 */ 401 uint32_t flags; 402 403 /* 404 * This is an output parameter. 405 * 406 * Frame buffer device provides release fence handle to client. It 407 * triggers release fence when display hardware has consumed all the 408 * buffers attached to this commit call and buffer is ready for reuse 409 * for primary and external. For writeback case, it triggers it when 410 * output buffer is ready for consumer. 411 */ 412 int release_fence; 413 414 /* 415 * Left_roi is optional configuration. Client configures it only when 416 * partial update is enabled. It defines the "region of interest" on 417 * left part of panel when it is split display. For non-split display, 418 * it defines the "region of interest" on the panel. 419 */ 420 struct mdp_rect left_roi; 421 422 /* 423 * Right_roi is optional configuration. Client configures it only when 424 * partial update is enabled. It defines the "region of interest" on 425 * right part of panel for split display configuration. It is not 426 * required for non-split display. 427 */ 428 struct mdp_rect right_roi; 429 430 /* Pointer to a list of input layers for composition. */ 431 struct mdp_input_layer __user *input_layers; 432 433 /* Input layer count present in input list */ 434 uint32_t input_layer_cnt; 435 436 /* 437 * Output layer for writeback display. It supports only one 438 * layer as output layer. This is not required for primary 439 * and external displays 440 */ 441 struct mdp_output_layer __user *output_layer; 442 443 /* 444 * This is an output parameter. 445 * 446 * Frame buffer device provides retire fence handle if 447 * COMMIT_RETIRE_FENCE flag is set in commit call. It triggers 448 * retire fence when current layers are swapped with new layers 449 * on display hardware. For video mode panel and writeback, 450 * retire fence and release fences are triggered at the same 451 * time while command mode panel triggers release fence first 452 * (on pingpong done) and retire fence (on rdptr done) 453 * after that. 454 */ 455 int retire_fence; 456 457 /* 458 * Scaler data and control for setting up destination scaler. 459 * A userspace pointer that points to a list of 460 * struct mdp_destination_scaler_data. 461 */ 462 void __user *dest_scaler; 463 464 /* 465 * Represents number of Destination scaler data provied by userspace. 466 */ 467 uint32_t dest_scaler_cnt; 468 469 /* FRC info per device which contains frame count and timestamp */ 470 struct mdp_frc_info __user *frc_info; 471 472 /* 32-bits reserved value for future usage. */ 473 uint32_t reserved[MDP_LAYER_COMMIT_V1_PAD]; 474 }; 475 476 /* 477 * mdp_overlay_list - argument for ioctl MSMFB_ATOMIC_COMMIT 478 */ 479 struct mdp_layer_commit { 480 /* 481 * 32bit version indicates the commit structure selection 482 * from union. Lower 16bits indicates the minor version while 483 * higher 16bits indicates the major version. It selects the 484 * commit structure based on major version selection. Minor version 485 * indicates that reserved fields are in use. 486 * 487 * Current supported version is 1.0 (Major:1 Minor:0) 488 */ 489 uint32_t version; 490 union { 491 /* Layer commit/validate definition for V1 */ 492 struct mdp_layer_commit_v1 commit_v1; 493 }; 494 }; 495 496 struct mdp_point { 497 uint32_t x; 498 uint32_t y; 499 }; 500 501 /* 502 * Async updatable layers. One layer holds configuration for one pipe. 503 */ 504 struct mdp_async_layer { 505 /* 506 * Flag to enable/disable properties for layer configuration. Refer 507 * layer flag config section for all possible flags. 508 */ 509 uint32_t flags; 510 511 /* 512 * Pipe selection for this layer by client. Client provides the 513 * pipe index that the device reserved during ATOMIC_COMMIT. 514 */ 515 uint32_t pipe_ndx; 516 517 /* Source start x,y. */ 518 struct mdp_point src; 519 520 /* Destination start x,y. */ 521 struct mdp_point dst; 522 523 /* 524 * This is an output parameter. 525 * 526 * Frame buffer device sets error code based on the failure. 527 */ 528 int error_code; 529 530 uint32_t reserved[3]; 531 }; 532 533 /* 534 * mdp_position_update - argument for ioctl MSMFB_ASYNC_POSITION_UPDATE 535 */ 536 struct mdp_position_update { 537 /* Pointer to a list of async updatable input layers */ 538 struct mdp_async_layer __user *input_layers; 539 540 /* Input layer count present in input list */ 541 uint32_t input_layer_cnt; 542 }; 543 544 #define MAX_DET_CURVES 3 545 struct mdp_det_enhance_data { 546 uint32_t enable; 547 int16_t sharpen_level1; 548 int16_t sharpen_level2; 549 uint16_t clip; 550 uint16_t limit; 551 uint16_t thr_quiet; 552 uint16_t thr_dieout; 553 uint16_t thr_low; 554 uint16_t thr_high; 555 uint16_t prec_shift; 556 int16_t adjust_a[MAX_DET_CURVES]; 557 int16_t adjust_b[MAX_DET_CURVES]; 558 int16_t adjust_c[MAX_DET_CURVES]; 559 }; 560 561 /* Flags to enable Scaler and its sub components */ 562 #define ENABLE_SCALE 0x1 563 #define ENABLE_DETAIL_ENHANCE 0x2 564 #define ENABLE_DIRECTION_DETECTION 0x4 565 566 /* LUT configuration flags */ 567 #define SCALER_LUT_SWAP 0x1 568 #define SCALER_LUT_DIR_WR 0x2 569 #define SCALER_LUT_Y_CIR_WR 0x4 570 #define SCALER_LUT_UV_CIR_WR 0x8 571 #define SCALER_LUT_Y_SEP_WR 0x10 572 #define SCALER_LUT_UV_SEP_WR 0x20 573 574 /* Y/RGB and UV filter configuration */ 575 #define FILTER_EDGE_DIRECTED_2D 0x0 576 #define FILTER_CIRCULAR_2D 0x1 577 #define FILTER_SEPARABLE_1D 0x2 578 #define FILTER_BILINEAR 0x3 579 580 /* Alpha filters */ 581 #define FILTER_ALPHA_DROP_REPEAT 0x0 582 #define FILTER_ALPHA_BILINEAR 0x1 583 584 /** 585 * struct mdp_scale_data_v2 586 * Driver uses this new Data structure for storing all scaling params 587 * This structure contains all pixel extension data and QSEED3 filter 588 * configuration and coefficient table indices 589 */ 590 struct mdp_scale_data_v2 { 591 uint32_t enable; 592 593 /* Init phase values */ 594 int32_t init_phase_x[MAX_PLANES]; 595 int32_t phase_step_x[MAX_PLANES]; 596 int32_t init_phase_y[MAX_PLANES]; 597 int32_t phase_step_y[MAX_PLANES]; 598 599 /* This should be set to toal horizontal pixels 600 * left + right + width */ 601 uint32_t num_ext_pxls_left[MAX_PLANES]; 602 603 /* Unused param for backward compatibility */ 604 uint32_t num_ext_pxls_right[MAX_PLANES]; 605 606 /* This should be set to vertical pixels 607 * top + bottom + height */ 608 uint32_t num_ext_pxls_top[MAX_PLANES]; 609 610 /* Unused param for backward compatibility */ 611 uint32_t num_ext_pxls_btm[MAX_PLANES]; 612 613 /* over fetch pixels */ 614 int32_t left_ftch[MAX_PLANES]; 615 int32_t left_rpt[MAX_PLANES]; 616 int32_t right_ftch[MAX_PLANES]; 617 int32_t right_rpt[MAX_PLANES]; 618 619 /* Repeat pixels */ 620 uint32_t top_rpt[MAX_PLANES]; 621 uint32_t btm_rpt[MAX_PLANES]; 622 uint32_t top_ftch[MAX_PLANES]; 623 uint32_t btm_ftch[MAX_PLANES]; 624 625 uint32_t roi_w[MAX_PLANES]; 626 627 /* alpha plane can only be scaled using bilinear or pixel 628 * repeat/drop, specify these for Y and UV planes only */ 629 uint32_t preload_x[MAX_PLANES]; 630 uint32_t preload_y[MAX_PLANES]; 631 uint32_t src_width[MAX_PLANES]; 632 uint32_t src_height[MAX_PLANES]; 633 634 uint32_t dst_width; 635 uint32_t dst_height; 636 637 uint32_t y_rgb_filter_cfg; 638 uint32_t uv_filter_cfg; 639 uint32_t alpha_filter_cfg; 640 uint32_t blend_cfg; 641 642 uint32_t lut_flag; 643 uint32_t dir_lut_idx; 644 645 /* for Y(RGB) and UV planes*/ 646 uint32_t y_rgb_cir_lut_idx; 647 uint32_t uv_cir_lut_idx; 648 uint32_t y_rgb_sep_lut_idx; 649 uint32_t uv_sep_lut_idx; 650 651 struct mdp_det_enhance_data detail_enhance; 652 653 /* reserved value for future usage. */ 654 uint64_t reserved[8]; 655 }; 656 657 /** 658 * struct mdp_scale_luts_info 659 * This struct pointer is received as payload in SET_CFG_IOCTL when the flags 660 * is set to MDP_QSEED3_LUT_CFG 661 * @dir_lut: Direction detection coefficients table 662 * @cir_lut: Circular coefficeints table 663 * @sep_lut: Separable coefficeints table 664 * @dir_lut_size: Size of direction coefficients table 665 * @cir_lut_size: Size of circular coefficients table 666 * @sep_lut_size: Size of separable coefficients table 667 */ 668 struct mdp_scale_luts_info { 669 uint64_t __user dir_lut; 670 uint64_t __user cir_lut; 671 uint64_t __user sep_lut; 672 uint32_t dir_lut_size; 673 uint32_t cir_lut_size; 674 uint32_t sep_lut_size; 675 }; 676 677 #define MDP_QSEED3_LUT_CFG 0x1 678 679 struct mdp_set_cfg { 680 uint64_t flags; 681 uint32_t len; 682 uint64_t __user payload; 683 }; 684 #endif 685