1 #ifndef _ECORE_DRM2_H 2 # define _ECORE_DRM2_H 3 4 # include <Ecore.h> 5 6 # ifdef EAPI 7 # undef EAPI 8 # endif 9 10 # ifdef __GNUC__ 11 # if __GNUC__ >= 4 12 # define EAPI __attribute__ ((visibility("default"))) 13 # else // if __GNUC__ >= 4 14 # define EAPI 15 # endif // if __GNUC__ >= 4 16 # else // ifdef __GNUC__ 17 # define EAPI 18 # endif // ifdef __GNUC__ 19 20 # ifdef EFL_BETA_API_SUPPORT 21 22 typedef enum _Ecore_Drm2_Rotation 23 { 24 ECORE_DRM2_ROTATION_NORMAL = 1, 25 ECORE_DRM2_ROTATION_90 = 2, 26 ECORE_DRM2_ROTATION_180 = 4, 27 ECORE_DRM2_ROTATION_270 = 8, 28 ECORE_DRM2_ROTATION_REFLECT_X = 16, 29 ECORE_DRM2_ROTATION_REFLECT_Y = 32 30 } Ecore_Drm2_Rotation; 31 32 typedef enum _Ecore_Drm2_Fb_Status 33 { 34 ECORE_DRM2_FB_STATUS_SCANOUT_ON = 1, 35 ECORE_DRM2_FB_STATUS_SCANOUT_OFF = 2, 36 ECORE_DRM2_FB_STATUS_RELEASE = 4, 37 ECORE_DRM2_FB_STATUS_DELETED = 8, 38 ECORE_DRM2_FB_STATUS_PLANE_ASSIGN = 16, 39 ECORE_DRM2_FB_STATUS_PLANE_RELEASE = 32, 40 } Ecore_Drm2_Fb_Status; 41 42 typedef enum _Ecore_Drm2_Relative_Mode 43 { 44 ECORE_DRM2_RELATIVE_MODE_UNKNOWN, 45 ECORE_DRM2_RELATIVE_MODE_NONE, 46 ECORE_DRM2_RELATIVE_MODE_CLONE, 47 ECORE_DRM2_RELATIVE_MODE_TO_LEFT, 48 ECORE_DRM2_RELATIVE_MODE_TO_RIGHT, 49 ECORE_DRM2_RELATIVE_MODE_TO_ABOVE, 50 ECORE_DRM2_RELATIVE_MODE_TO_BELOW 51 } Ecore_Drm2_Relative_Mode; 52 53 /* opaque structure to represent a drm device */ 54 typedef struct _Ecore_Drm2_Device Ecore_Drm2_Device; 55 56 /* opaque structure to represent a framebuffer object */ 57 typedef struct _Ecore_Drm2_Fb Ecore_Drm2_Fb; 58 59 /* opaque structure to represent an output device */ 60 typedef struct _Ecore_Drm2_Output Ecore_Drm2_Output; 61 62 /* opaque structure to represent an output mode */ 63 typedef struct _Ecore_Drm2_Output_Mode Ecore_Drm2_Output_Mode; 64 65 /* opaque structure to represent a hardware plane */ 66 typedef struct _Ecore_Drm2_Plane Ecore_Drm2_Plane; 67 68 /* structure to represent event for output changes */ 69 typedef struct _Ecore_Drm2_Event_Output_Changed 70 { 71 unsigned int id; 72 int x, y, w, h; 73 int phys_width, phys_height; 74 unsigned int refresh, scale; 75 int subpixel, transform; 76 const char *make, *model, *name; 77 Eina_Bool connected : 1; 78 Eina_Bool enabled : 1; 79 } Ecore_Drm2_Event_Output_Changed; 80 81 /* structure to represent event for session state changes */ 82 typedef struct _Ecore_Drm2_Event_Activate 83 { 84 Eina_Bool active : 1; 85 } Ecore_Drm2_Event_Activate; 86 87 /* structure to represent a drm event context */ 88 typedef struct _Ecore_Drm2_Context 89 { 90 int version; 91 void (*vblank_handler)(int fd, unsigned int sequence, unsigned int tv_sec, 92 unsigned int tv_usec, void *user_data); 93 void (*page_flip_handler)(int fd, unsigned int sequence, unsigned int tv_sec, 94 unsigned int tv_usec, void *user_data); 95 void (*page_flip_handler2)(int fd, unsigned int sequence, unsigned int tv_sec, 96 unsigned int tv_usec, unsigned int crtc_id, void *user_data); 97 } Ecore_Drm2_Context; 98 99 EAPI extern int ECORE_DRM2_EVENT_OUTPUT_CHANGED; 100 EAPI extern int ECORE_DRM2_EVENT_ACTIVATE; 101 102 typedef void (*Ecore_Drm2_Release_Handler)(void *data, Ecore_Drm2_Fb *b); 103 typedef void (*Ecore_Drm2_Fb_Status_Handler)(Ecore_Drm2_Fb *b, Ecore_Drm2_Fb_Status status, void *data); 104 105 /** 106 * @file 107 * @brief Ecore functions for dealing with drm, virtual terminals 108 * 109 * @defgroup Ecore_Drm2_Group Ecore_Drm2 - Drm Integration 110 * @ingroup Ecore 111 * 112 * Ecore_Drm2 provides a wrapper and functions for using libdrm 113 * 114 * @li @ref Ecore_Drm2_Init_Group 115 * @li @ref Ecore_Drm2_Device_Group 116 * @li @ref Ecore_Drm2_Output_Group 117 * @li @ref Ecore_Drm2_Fb_Group 118 * @li @ref Ecore_Drm2_Plane_Group 119 */ 120 121 /** 122 * @defgroup Ecore_Drm2_Init_Group Drm library Init and Shutdown functions 123 * 124 * Functions that start and shutdown the Ecore_Drm2 library 125 */ 126 127 /** 128 * Initialize the Ecore_Drm2 library 129 * 130 * @return The number of times the library has been initialized without 131 * being shut down. 0 is returned if an error occurs. 132 * 133 * @ingroup Ecore_Drm2_Init_Group 134 * @since 1.18 135 */ 136 EAPI int ecore_drm2_init(void); 137 138 /** 139 * Shutdown the Ecore_Drm2 library 140 * 141 * @return The number of times the library has been initialized without 142 * being shutdown. 0 is returned if an error occurs. 143 * 144 * @ingroup Ecore_Drm2_Init_Group 145 * @since 1.18 146 */ 147 EAPI int ecore_drm2_shutdown(void); 148 149 /** 150 * Read and process pending Drm events 151 * 152 * @param dev drm device 153 * @param drmctx 154 * 155 * @return 0 on success, -1 otherwise 156 * 157 * @note: Do not ever use this function in applications !!! 158 * This is a special-purpose API function and should not be used by 159 * application developers. 160 * 161 * @ingroup Ecore_Drm_Init_Group 162 * @since 1.19 163 */ 164 EAPI int ecore_drm2_event_handle(Ecore_Drm2_Device *dev, Ecore_Drm2_Context *drmctx); 165 166 /** 167 * @defgroup Ecore_Drm2_Device_Group Drm device functions 168 * 169 * Functions that deal with finding, opening, closing, or obtaining various 170 * information about a drm device 171 */ 172 173 /** 174 * Try to open the Ecore_Drm2_Device for a given seat 175 * 176 * @param seat 177 * @param tty 178 * 179 * @return An Ecore_Drm2_Device or NULL on failure. 180 * 181 * @ingroup Ecore_Drm2_Device_Group 182 * @since 1.18 183 */ 184 EAPI Ecore_Drm2_Device *ecore_drm2_device_open(const char *seat, unsigned int tty); 185 186 /** 187 * Close an open Ecore_Drm2_Device 188 * 189 * @param device 190 * 191 * @ingroup Ecore_Drm2_Device_Group 192 * @since 1.18 193 */ 194 EAPI void ecore_drm2_device_close(Ecore_Drm2_Device *device); 195 196 /** 197 * Get the type of clock used by a given Ecore_Drm2_Device 198 * 199 * @param device 200 * 201 * @return The clockid_t used by this drm device 202 * 203 * @ingroup Ecore_Drm2_Device_Group 204 * @since 1.18 205 */ 206 EAPI int ecore_drm2_device_clock_id_get(Ecore_Drm2_Device *device); 207 208 /** 209 * Get the size of the cursor supported by a given Ecore_Drm2_Device 210 * 211 * @param device 212 * @param width 213 * @param height 214 * 215 * @ingroup Ecore_Drm2_Device_Group 216 * @since 1.18 217 */ 218 EAPI void ecore_drm2_device_cursor_size_get(Ecore_Drm2_Device *device, int *width, int *height); 219 220 /** 221 * Get the current pointer position 222 * 223 * @param device 224 * @param x 225 * @param y 226 * 227 * @ingroup Ecore_Drm2_Device_Group 228 * @since 1.18 229 */ 230 EAPI void ecore_drm2_device_pointer_xy_get(Ecore_Drm2_Device *device, int *x, int *y); 231 232 /** 233 * Warp the pointer position to given coordinates 234 * 235 * @param device 236 * @param x 237 * @param y 238 * 239 * @ingroup Ecore_Drm2_Device_Group 240 * @since 1.18 241 */ 242 EAPI void ecore_drm2_device_pointer_warp(Ecore_Drm2_Device *device, int x, int y); 243 244 /** 245 * Set a left handed mode for the given device 246 * 247 * @param device 248 * @param left 249 * 250 * @return EINA_TRUE on success, EINA_FALSE otherwise 251 * 252 * @ingroup Ecore_Drm2_Device_Group 253 * @since 1.18 254 */ 255 EAPI Eina_Bool ecore_drm2_device_pointer_left_handed_set(Ecore_Drm2_Device *device, Eina_Bool left); 256 257 /** 258 * Set which window is to be used for input events 259 * 260 * @param device 261 * @param window 262 * 263 * @ingroup Ecore_Drm2_Device_Group 264 * @since 1.18 265 */ 266 EAPI void ecore_drm2_device_window_set(Ecore_Drm2_Device *device, unsigned int window); 267 268 /** 269 * Set maximium position that pointer device is allowed to move 270 * 271 * @param device 272 * @param w 273 * @param h 274 * 275 * @ingroup Ecore_Drm2_Device_Group 276 * @since 1.18 277 */ 278 EAPI void ecore_drm2_device_pointer_max_set(Ecore_Drm2_Device *device, int w, int h); 279 280 /** 281 * Set pointer acceleration speed 282 * 283 * @param device 284 * @param speed 285 * 286 * @ingroup Ecore_Drm2_Device_Group 287 * @since 1.21 288 */ 289 EAPI void ecore_drm2_device_pointer_accel_speed_set(Ecore_Drm2_Device *device, double speed); 290 291 /** 292 * Set pointer acceleration profile 293 * 294 * @param device 295 * @param profile 296 * 297 * @ingroup Ecore_Drm2_Device_Group 298 * @since 1.21 299 */ 300 EAPI void ecore_drm2_device_pointer_accel_profile_set(Ecore_Drm2_Device *device, uint32_t profile); 301 302 /** 303 * Set pointer value rotation 304 * 305 * @param device 306 * @param rotation 307 * 308 * @return EINA_TRUE on success, EINA_FALSE otherwise 309 * 310 * @ingroup Ecore_Drm2_Device_Group 311 * @since 1.20 312 */ 313 EAPI Eina_Bool ecore_drm2_device_pointer_rotation_set(Ecore_Drm2_Device *device, int rotation); 314 315 /** 316 * Enable or disable pointer tap-to-click 317 * 318 * @param device 319 * @param enabled 320 * 321 * @ingroup Ecore_Drm2_Device_Group 322 * @since 1.22 323 */ 324 EAPI void ecore_drm2_device_touch_tap_to_click_enabled_set(Ecore_Drm2_Device *device, Eina_Bool enabled); 325 326 /** 327 * Set info to be used on keyboards 328 * 329 * @param device 330 * @param context 331 * @param keymap 332 * @param group 333 * 334 * @ingroup Ecore_Drm2_Device_Group 335 * @since 1.20 336 */ 337 EAPI void ecore_drm2_device_keyboard_info_set(Ecore_Drm2_Device *device, void *context, void *keymap, int group); 338 339 /** 340 * Set a group layout to be used on keyboards 341 * 342 * @param device 343 * @param group 344 * 345 * @ingroup Ecore_Drm2_Device_Group 346 * @since 1.20 347 */ 348 EAPI void ecore_drm2_device_keyboard_group_set(Ecore_Drm2_Device *device, int group); 349 350 /** 351 * Get the crtcs of a given device 352 * 353 * @param device 354 * @param num 355 * 356 * @return The crtcs of this given device or NULL on failure 357 * 358 * @ingroup Ecore_Drm2_Device_Group 359 * @since 1.18 360 */ 361 EAPI unsigned int *ecore_drm2_device_crtcs_get(Ecore_Drm2_Device *device, int *num); 362 363 /** 364 * Get the minimum and maximum screen size range 365 * 366 * @param device 367 * @param *minw 368 * @param *minh 369 * @param *maxw 370 * @param *maxh 371 * 372 * @ingroup Ecore_Drm2_Device_Group 373 * @since 1.18 374 */ 375 EAPI void ecore_drm2_device_screen_size_range_get(Ecore_Drm2_Device *device, int *minw, int *minh, int *maxw, int *maxh); 376 377 /** 378 * Calibrate any input devices for given screen size 379 * 380 * @param device 381 * @param w 382 * @param h 383 * 384 * @ingroup Ecore_Drm2_Device_Group 385 * @since 1.18 386 */ 387 EAPI void ecore_drm2_device_calibrate(Ecore_Drm2_Device *device, int w, int h); 388 389 /** 390 * Try to switch to a given virtual terminal 391 * 392 * @param device 393 * @param vt 394 * 395 * @return EINA_TRUE on success, EINA_FALSE otherwise 396 * 397 * @ingroup Ecore_Drm2_Device_Group 398 * @since 1.18 399 */ 400 EAPI Eina_Bool ecore_drm2_device_vt_set(Ecore_Drm2_Device *device, int vt); 401 402 /** 403 * Get if a given device prefers the use of shadow buffers 404 * 405 * @param device 406 * 407 * @return EINA_TRUE if preferred, EINA_FALSE otherwise 408 * 409 * @ingroup Ecore_Drm2_Device_Group 410 * @since 1.19 411 */ 412 EAPI Eina_Bool ecore_drm2_device_prefer_shadow(Ecore_Drm2_Device *device); 413 414 /** 415 * Get the default depth & bpp from a given device 416 * 417 * @param device 418 * @param depth 419 * @param bpp 420 * 421 * @ingroup Ecore_Drm2_Device_Group 422 * @since 1.25 423 */ 424 EAPI void ecore_drm2_device_preferred_depth_get(Ecore_Drm2_Device *device, int *depth, int *bpp); 425 426 /** 427 * @defgroup Ecore_Drm2_Output_Group Drm output functions 428 * 429 * Functions that deal with setup of outputs 430 */ 431 432 /** 433 * Iterate drm resources and create outputs 434 * 435 * @param device 436 * 437 * @return EINA_TRUE on success, EINA_FALSE otherwise 438 * 439 * @ingroup Ecore_Drm2_Output_Group 440 * @since 1.18 441 */ 442 EAPI Eina_Bool ecore_drm2_outputs_create(Ecore_Drm2_Device *device); 443 444 /** 445 * Destroy any created outputs 446 * 447 * @param device 448 * 449 * @ingroup Ecore_Drm2_Output_Group 450 * @since 1.18 451 */ 452 EAPI void ecore_drm2_outputs_destroy(Ecore_Drm2_Device *device); 453 454 /** 455 * Get the list of outputs from a drm device 456 * 457 * @param device 458 * 459 * @return 460 * 461 * @ingroup Ecore_Drm2_Output_Group 462 * @since 1.18 463 */ 464 EAPI const Eina_List *ecore_drm2_outputs_get(Ecore_Drm2_Device *device); 465 466 /** 467 * Get the dpms level of a given output 468 * 469 * @param output 470 * 471 * @return Integer value representing the state of DPMS on a given output 472 * or -1 on error 473 * 474 * @ingroup Ecore_Drm2_Output_Group 475 * @since 1.18 476 */ 477 EAPI int ecore_drm2_output_dpms_get(Ecore_Drm2_Output *output); 478 479 /** 480 * Set the dpms level of a given output 481 * 482 * @param output 483 * @param level 484 * 485 * @ingroup Ecore_Drm2_Output_Group 486 * @since 1.18 487 */ 488 EAPI void ecore_drm2_output_dpms_set(Ecore_Drm2_Output *output, int level); 489 490 /** 491 * Get the edid of a given output 492 * 493 * @param output 494 * 495 * @return A string representing the edid 496 * 497 * @ingroup Ecore_Drm2_Output_Group 498 * @since 1.18 499 */ 500 EAPI char *ecore_drm2_output_edid_get(Ecore_Drm2_Output *output); 501 502 /** 503 * Get if a given output has a backlight 504 * 505 * @param output 506 * 507 * @return EINA_TRUE if this output has a backlight, EINA_FALSE otherwise 508 * 509 * @ingroup Ecore_Drm2_Output_Group 510 * @since 1.18 511 */ 512 EAPI Eina_Bool ecore_drm2_output_backlight_get(Ecore_Drm2_Output *output); 513 514 /** 515 * Find an output at the given position 516 * 517 * @param device 518 * @param x 519 * @param y 520 * 521 * @return An Ecore_Drm2_Output which exists at the given coordinates, or NULL on failure 522 * 523 * @ingroup Ecore_Drm2_Output_Group 524 * @since 1.18 525 */ 526 EAPI Ecore_Drm2_Output *ecore_drm2_output_find(Ecore_Drm2_Device *device, int x, int y); 527 528 /** 529 * Get the dpi of a given output 530 * 531 * @param output 532 * @param xdpi 533 * @param ydpi 534 * 535 * @ingroup Ecore_Drm2_Output_Group 536 * @since 1.19 537 */ 538 EAPI void ecore_drm2_output_dpi_get(Ecore_Drm2_Output *output, int *xdpi, int *ydpi); 539 540 /** 541 * Get the id of the crtc that an output is using 542 * 543 * @param output 544 * 545 * @return A valid crtc id or 0 on failure 546 * 547 * @ingroup Ecore_Drm2_Output_Group 548 * @since 1.18 549 */ 550 EAPI unsigned int ecore_drm2_output_crtc_get(Ecore_Drm2_Output *output); 551 552 /** 553 * Return the most recently set Ecore_Drm2_Fb for a given output 554 * 555 * This may be the currently scanned out buffer, a buffer currently being 556 * flipped to scanout, or a buffer that has been submit but may not 557 * actually ever hit scanout at all. 558 * 559 * @param output 560 * 561 * @return The latest Ecore_Drm2_Fb submit for this output, or NULL otherwise 562 * 563 * @ingroup Ecore_Drm2_Output_Group 564 * @since 1.19 565 */ 566 EAPI Ecore_Drm2_Fb *ecore_drm2_output_latest_fb_get(Ecore_Drm2_Output *output); 567 568 /** 569 * Get if a given output is marked as the primary output 570 * 571 * @param output 572 * 573 * @return EINA_TRUE if output is primary, EINA_FALSE otherwise 574 * 575 * @ingroup Ecore_Drm2_Output_Group 576 * @since 1.18 577 */ 578 EAPI Eina_Bool ecore_drm2_output_primary_get(Ecore_Drm2_Output *output); 579 580 /** 581 * Set a given output to be primary 582 * 583 * @param output 584 * @param primary 585 * 586 * @ingroup Ecore_Drm2_Output_Group 587 * @since 1.18 588 */ 589 EAPI void ecore_drm2_output_primary_set(Ecore_Drm2_Output *output, Eina_Bool primary); 590 591 /** 592 * Get if a given output is enabled 593 * 594 * @param output 595 * 596 * @return EINA_TRUE if enabled, EINA_FALSE otherwise. 597 * 598 * @ingroup Ecore_Drm2_Output_Group 599 * @since 1.18 600 */ 601 EAPI Eina_Bool ecore_drm2_output_enabled_get(Ecore_Drm2_Output *output); 602 603 /** 604 * Set if a given output is enabled 605 * 606 * @param output 607 * @param enabled 608 * 609 * @ingroup Ecore_Drm2_Output_Group 610 * @since 1.18 611 */ 612 EAPI void ecore_drm2_output_enabled_set(Ecore_Drm2_Output *output, Eina_Bool enabled); 613 614 /** 615 * Get the physical size of a given output 616 * 617 * This function will give the physical size (in mm) of an output 618 * 619 * @param output 620 * @param *w 621 * @param *h 622 * 623 * @ingroup Ecore_Drm2_Output_Group 624 * @since 1.18 625 */ 626 EAPI void ecore_drm2_output_physical_size_get(Ecore_Drm2_Output *output, int *w, int *h); 627 628 /** 629 * Get a list of the modes supported on a given output 630 * 631 * @param output 632 * 633 * @return An Eina_List of the modes supported for this output 634 * 635 * @note The returned list should not be freed 636 * 637 * @ingroup Ecore_Drm2_Output_Group 638 * @since 1.18 639 */ 640 EAPI const Eina_List *ecore_drm2_output_modes_get(Ecore_Drm2_Output *output); 641 642 /** 643 * Get information from an existing output mode 644 * 645 * @param mode 646 * @param w 647 * @param h 648 * @param refresh 649 * @param flags 650 * 651 * @ingroup Ecore_Drm2_Output_Group 652 * @since 1.18 653 */ 654 EAPI void ecore_drm2_output_mode_info_get(Ecore_Drm2_Output_Mode *mode, int *w, int *h, unsigned int *refresh, unsigned int *flags); 655 656 /** 657 * Set a given mode to be used on a given output 658 * 659 * @param output 660 * @param mode 661 * @param x 662 * @param y 663 * 664 * @return EINA_TRUE on success, EINA_FALSE otherwise 665 * 666 * @ingroup Ecore_Drm2_Output_Group 667 * @since 1.18 668 */ 669 EAPI Eina_Bool ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mode, int x, int y); 670 671 /** 672 * Get the name of a given output 673 * 674 * @param output 675 * 676 * @return A string representing the output's name. Caller should free this return. 677 * 678 * @ingroup Ecore_Drm2_Output_Group 679 * @since 1.18 680 */ 681 EAPI char *ecore_drm2_output_name_get(Ecore_Drm2_Output *output); 682 683 /** 684 * Get the model of a given output 685 * 686 * @param output 687 * 688 * @return A string representing the output's model. Caller should free this return. 689 * 690 * @ingroup Ecore_Drm2_Output_Group 691 * @since 1.18 692 */ 693 EAPI char *ecore_drm2_output_model_get(Ecore_Drm2_Output *output); 694 695 /** 696 * Get if a given output is connected 697 * 698 * @param output 699 * 700 * @return EINA_TRUE if connected, EINA_FALSE otherwise 701 * 702 * @ingroup Ecore_Drm2_Output_Group 703 * @since 1.18 704 */ 705 EAPI Eina_Bool ecore_drm2_output_connected_get(Ecore_Drm2_Output *output); 706 707 /** 708 * Get if a given output is cloned 709 * 710 * @param output 711 * 712 * @return EINA_TRUE if cloned, EINA_FALSE otherwise. 713 * 714 * @ingroup Ecore_Drm2_Output_Group 715 * @since 1.18 716 */ 717 EAPI Eina_Bool ecore_drm2_output_cloned_get(Ecore_Drm2_Output *output); 718 719 /** 720 * Get the connector type of a given output 721 * 722 * @param output 723 * 724 * @return An unsigned integer representing the type of connector for this output 725 * 726 * @ingroup Ecore_Drm2_Output_Group 727 * @since 1.18 728 */ 729 EAPI unsigned int ecore_drm2_output_connector_type_get(Ecore_Drm2_Output *output); 730 731 /** 732 * Get the geometry and refresh rate for a given output 733 * 734 * @param output 735 * @param *x 736 * @param *y 737 * @param *w 738 * @param *h 739 * @param *refresh 740 * 741 * @ingroup Ecore_Drm2_Output_Group 742 * @since 1.21 743 */ 744 EAPI void ecore_drm2_output_info_get(Ecore_Drm2_Output *output, int *x, int *y, int *w, int *h, unsigned int *refresh); 745 746 /** 747 * Get if an output can be used on a given crtc 748 * 749 * This function will loop the possible crtcs of an encoder to determine if 750 * a given output can be assigned to a given crtc 751 * 752 * @param output 753 * @param crtc 754 * 755 * @return EINA_TRUE if the output can be assigned to given crtc, EINA_FALSE otherwise 756 * 757 * @ingroup Ecore_Drm2_Output_Group 758 * @since 1.18 759 */ 760 EAPI Eina_Bool ecore_drm2_output_possible_crtc_get(Ecore_Drm2_Output *output, unsigned int crtc); 761 762 /** 763 * Set the gamma level of an Ecore_Drm_Output 764 * 765 * This function will set the gamma of an Ecore_Drm2_Output 766 * 767 * @param output The Ecore_Drm2_Output to set the gamma level on 768 * @param size The gamma table size to set 769 * @param red The amount to scale the red channel 770 * @param green The amount to scale the green channel 771 * @param blue The amount to scale the blue channel 772 * 773 * @ingroup Ecore_Drm2_Output_Group 774 * @since 1.19 775 */ 776 EAPI void ecore_drm2_output_gamma_set(Ecore_Drm2_Output *output, uint16_t size, uint16_t *red, uint16_t *green, uint16_t *blue); 777 778 /** 779 * Get the supported rotations of a given output 780 * 781 * @param output 782 * 783 * @return An integer representing possible rotations, or -1 on failure 784 * 785 * @note This function will only return valid values if Atomic support 786 * is enabled as it requires hardware plane support. 787 * 788 * @ingroup Ecore_Drm2_Output_Group 789 * @since 1.19 790 */ 791 EAPI int ecore_drm2_output_supported_rotations_get(Ecore_Drm2_Output *output); 792 793 /** 794 * Set a rotation on a given output 795 * 796 * @param output 797 * @param rotation 798 * 799 * @return EINA_TRUE on success, EINA_FALSE otherwise 800 * 801 * @note This function will only work if Atomic support 802 * is enabled as it requires hardware plane support. 803 * 804 * @ingroup Ecore_Drm2_Output_Group 805 * @since 1.19 806 */ 807 EAPI Eina_Bool ecore_drm2_output_rotation_set(Ecore_Drm2_Output *output, int rotation); 808 809 /** 810 * Get current output rotation 811 * 812 * @param output 813 * 814 * @return An integer representing the output current rotation 815 * 816 * @ingroup Ecore_Drm2_Output_Group 817 * @since 1.22 818 */ 819 EAPI int ecore_drm2_output_rotation_get(Ecore_Drm2_Output *output); 820 821 /** 822 * Set the user data for the output's page flip handler 823 * 824 * @param o The output to update user data for 825 * @param data The new user data pointer 826 * 827 * @ingroup Ecore_Drm2_Output_Group 828 * @since 1.19 829 */ 830 EAPI void ecore_drm2_output_user_data_set(Ecore_Drm2_Output *o, void *data); 831 832 /** 833 * Get the user data for a given output 834 * 835 * @param output The output to get user data for 836 * 837 * @return The user data associated with given output 838 * 839 * @ingroup Ecore_Drm2_Output_Group 840 * @since 1.21 841 */ 842 EAPI void *ecore_drm2_output_user_data_get(Ecore_Drm2_Output *output); 843 844 /** 845 * Get the subpixel state of the output 846 * @param output the output 847 * @return The state value 848 * @ingroup Ecore_Drm2_Output_Group 849 * @since 1.20 850 */ 851 EAPI unsigned int ecore_drm2_output_subpixel_get(const Ecore_Drm2_Output *output); 852 853 /** 854 * Set the relative mode for an output 855 * 856 * @param output The output to set relative mode 857 * @param mode The relative mode to set 858 * 859 * @ingroup Ecore_Drm2_Output_Group 860 * @since 1.21 861 */ 862 EAPI void ecore_drm2_output_relative_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Relative_Mode mode); 863 864 /** 865 * Get the relative mode of an output 866 * 867 * @param output The output to retrieve relative mode for 868 * 869 * @return The relative mode of a given output 870 * 871 * @ingroup Ecore_Drm2_Output_Group 872 * @since 1.21 873 */ 874 EAPI Ecore_Drm2_Relative_Mode ecore_drm2_output_relative_mode_get(Ecore_Drm2_Output *output); 875 876 /** 877 * Set which output a given output is relative to 878 * 879 * @param output The output for which to set relative 880 * @param relative The output for which the first output is relative to 881 * 882 * @ingroup Ecore_Drm2_Output_Group 883 * @since 1.21 884 */ 885 EAPI void ecore_drm2_output_relative_to_set(Ecore_Drm2_Output *output, const char *relative); 886 887 /** 888 * Get which output is relative to a given output 889 * 890 * @param output The output for which to retrieve relative 891 * 892 * @return The name of the output which is relative to the given output or NULL 893 * 894 * @ingroup Ecore_Drm2_Output_Group 895 * @since 1.21 896 */ 897 EAPI const char *ecore_drm2_output_relative_to_get(Ecore_Drm2_Output *output); 898 899 /** 900 * @defgroup Ecore_Drm2_Fb_Group Drm framebuffer functions 901 * 902 * Functions that deal with setup of framebuffers 903 */ 904 905 /** 906 * Create a new framebuffer object 907 * 908 * @param dev 909 * @param width 910 * @param height 911 * @param depth 912 * @param bpp 913 * @param format 914 * 915 * @return A newly create framebuffer object, or NULL on failure 916 * 917 * @ingroup Ecore_Drm2_Fb_Group 918 * @since 1.18 919 */ 920 EAPI Ecore_Drm2_Fb *ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format); 921 922 EAPI Ecore_Drm2_Fb *ecore_drm2_fb_gbm_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride, void *bo); 923 924 /** 925 * Get a framebuffer's mmap'd data 926 * 927 * @param fb 928 * 929 * @return The mmap'd area of the framebuffer or NULL on failure 930 * 931 * @ingroup Ecore_Drm2_Fb_Group 932 * @since 1.18 933 */ 934 EAPI void *ecore_drm2_fb_data_get(Ecore_Drm2_Fb *fb); 935 936 /** 937 * Get a framebuffer's size 938 * 939 * @param fb 940 * 941 * @return size of the framebuffers' mmap'd data or 0 on failure 942 * 943 * @ingroup Ecore_Drm2_Fb_Group 944 * @since 1.18 945 */ 946 EAPI unsigned int ecore_drm2_fb_size_get(Ecore_Drm2_Fb *fb); 947 948 /** 949 * Get a framebuffer's stride 950 * 951 * @param fb 952 * 953 * @return stride of the framebuffer or 0 on failure 954 * 955 * @ingroup Ecore_Drm2_Fb_Group 956 * @since 1.18 957 */ 958 EAPI unsigned int ecore_drm2_fb_stride_get(Ecore_Drm2_Fb *fb); 959 960 /** 961 * Mark regions of a framebuffer as dirty 962 * 963 * @param fb 964 * @param rects 965 * @param count 966 * 967 * @ingroup Ecore_Drm2_Fb_Group 968 * @since 1.18 969 */ 970 EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, Eina_Rectangle *rects, unsigned int count); 971 972 /** 973 * Schedule a pageflip to the given Ecore_Drm2_Fb 974 * 975 * The caller is responsible for running a page flip handler 976 * and calling ecore_drm2_fb_flip_complete() when it completes. 977 * 978 * @param fb 979 * @param output 980 * 981 * @return The result of drmModePageFlip function call 982 * 983 * @ingroup Ecore_Drm2_Fb_Group 984 * @since 1.18 985 */ 986 EAPI int ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output); 987 988 /** 989 * Must be called by a page flip handler when the flip completes. 990 * 991 * @param output 992 * 993 * @return Whether there's an undisplayed buffer still in the queue. 994 * 995 * @ingroup Ecore_Drm2_Fb_Group 996 * @since 1.18 997 */ 998 EAPI Eina_Bool ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output); 999 1000 /** 1001 * Return the Ecore_Drm2_Fb's busy status 1002 * 1003 * @param fb 1004 * 1005 * @return The busy status 1006 * 1007 * @ingroup Ecore_Drm2_Fb_Group 1008 * @since 1.19 1009 */ 1010 EAPI Eina_Bool ecore_drm2_fb_busy_get(Ecore_Drm2_Fb *fb); 1011 1012 /** 1013 * Try to force a framebuffer release for an output 1014 * 1015 * This tries to release the next or optionally pending, or current 1016 * buffer from the output. If successful there will be a release callback 1017 * to the registered handler, and the fb will no longer be flagged busy. 1018 * 1019 * Releasing buffers committed to scanout will potentially cause flicker, 1020 * so this is only done when the panic flag is set. 1021 * 1022 * @param o The output to force release 1023 * @param panic Try to release even buffers committed to scanout 1024 * 1025 * @return EINA_TRUE if a buffer was released 1026 * 1027 * @ingroup Ecore_Drm2_Fb_Group 1028 * @since 1.19 1029 */ 1030 EAPI Eina_Bool ecore_drm2_fb_release(Ecore_Drm2_Output *o, Eina_Bool panic); 1031 1032 /** 1033 * Get the Framebuffer's gbm buffer object 1034 * 1035 * @param fb The framebuffer to query 1036 * 1037 * @return The gbm bo for the framebuffer 1038 * 1039 * @ingroup Ecore_Drm2_Output_Group 1040 * @since 1.19 1041 */ 1042 EAPI void *ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb); 1043 1044 /** 1045 * Import a dmabuf object as a Framebuffer 1046 * 1047 * @param dev 1048 * @param width 1049 * @param height 1050 * @param depth 1051 * @param bpp 1052 * @param format 1053 * @param strides 1054 * @param dmabuf_fd 1055 * @param dmabuf_fd_count 1056 * 1057 * @return A newly created framebuffer object, or NULL on failure 1058 * 1059 * @ingroup Ecore_Drm2_Fb_Group 1060 * @since 1.20 1061 * 1062 */ 1063 EAPI Ecore_Drm2_Fb *ecore_drm2_fb_dmabuf_import(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count); 1064 1065 /** 1066 * Discard a framebuffer object 1067 * 1068 * Decreases the refcount on a fb object. It will be destroyed when it's 1069 * no longer attached to scanout or otherwise in use. 1070 * 1071 * @param fb 1072 * 1073 * @ingroup Ecore_Drm2_Fb_Group 1074 * @since 1.20 1075 */ 1076 EAPI void ecore_drm2_fb_discard(Ecore_Drm2_Fb *fb); 1077 1078 /** 1079 * @defgroup Ecore_Drm2_Plane_Group Functions that deal with hardware planes 1080 * 1081 * Functions that deal with hardware plane manipulation 1082 */ 1083 1084 /** 1085 * Find a hardware plane where a given Ecore_Drm2_Fb can go based on format and size 1086 * 1087 * @param output 1088 * @param fb 1089 * 1090 * @return A newly allocated plane object, or NULL otherwise 1091 * 1092 * @ingroup Ecore_Drm2_Plane_Group 1093 * @since 1.20 1094 */ 1095 EAPI Ecore_Drm2_Plane *ecore_drm2_plane_assign(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb, int x, int y); 1096 1097 /** 1098 * Remove a hardware plane from display 1099 * 1100 * @param plane 1101 * 1102 * @ingroup Ecore_Drm2_Plane_Group 1103 * @since 1.20 1104 */ 1105 EAPI void ecore_drm2_plane_release(Ecore_Drm2_Plane *plane); 1106 1107 /** 1108 * Set plane destination values 1109 * 1110 * @param plane 1111 * @param x 1112 * @param y 1113 * @param w 1114 * @param h 1115 * 1116 * @ingroup Ecore_Drm2_Plane_Group 1117 * @since 1.20 1118 */ 1119 EAPI void ecore_drm2_plane_destination_set(Ecore_Drm2_Plane *plane, int x, int y, int w, int h); 1120 1121 /** 1122 * Set plane frame buffer 1123 * 1124 * @param plane 1125 * @param fb 1126 * 1127 * @return whether the plane state has been successfully changed or not 1128 * 1129 * @ingroup Ecore_Drm2_Plane_Group 1130 * @since 1.20 1131 */ 1132 EAPI Eina_Bool ecore_drm2_plane_fb_set(Ecore_Drm2_Plane *plane, Ecore_Drm2_Fb *fb); 1133 1134 /** 1135 * Register a callback for buffer status updates 1136 * 1137 * When a flip completes ecore_drm2 may release a buffer. Use this callback 1138 * if you need to do bookkeeping or locking on buffer release. 1139 * 1140 * Additionally, an fb may be placed on scanout or removed from scanout by 1141 * evas. When this happens a compositor needs to ensure the buffers aren't 1142 * released back to a client while they're on scanout. 1143 * 1144 * @param fb The fb to register the callback on 1145 * @param handler The function to handle the callback 1146 * @param data The user data to pass to the callback 1147 * @ingroup Ecore_Drm2_Fb_Group 1148 * @since 1.20 1149 */ 1150 EAPI void ecore_drm2_fb_status_handler_set(Ecore_Drm2_Fb *fb, Ecore_Drm2_Fb_Status_Handler handler, void *data); 1151 1152 /** 1153 * Get the time of the last vblank 1154 * 1155 * Query the display hardware for the time of a vblank, potentially blocking. 1156 * 1157 * If sequence is 0 the time of the last vblank will be immediately returned, 1158 * if it's above zero that number of vblanks will pass before the function 1159 * returns. 1160 * 1161 * @param output 1162 * @param sequence 1163 * @param sec 1164 * @param usec 1165 * 1166 * @ingroup Ecore_Drm2_Output_Group 1167 * @since 1.20 1168 */ 1169 EAPI Eina_Bool ecore_drm2_output_blanktime_get(Ecore_Drm2_Output *output, int sequence, long *sec, long *usec); 1170 1171 /** 1172 * Get the fd of an Ecore_Drm2_Device 1173 * 1174 * Query the fd of the device. 1175 * 1176 * @param device 1177 * 1178 * @ingroup Ecore_Drm2_Device_Group 1179 * @since 1.20 1180 */ 1181 EAPI int ecore_drm2_device_fd_get(Ecore_Drm2_Device *device); 1182 1183 /** 1184 * Check if there's a pageflip in progress for an output 1185 * 1186 * Checks whether an output has submit a flip but not yet had 1187 * a callback completion event for that flip yet. 1188 * 1189 * @param output 1190 * @return Whether there's a flip in progress or not 1191 * @ingroup Ecore_Drm2_Output_Group 1192 * @since 1.20 1193 */ 1194 EAPI Eina_Bool ecore_drm2_output_pending_get(Ecore_Drm2_Output *output); 1195 1196 /** 1197 * Set the background color of an output's crtc 1198 * 1199 * @param output 1200 * @param r 1201 * @param g 1202 * @param b 1203 * @param a 1204 * 1205 * @return EINA_TRUE on success, EINA_FALSE otherwise 1206 * 1207 * @note This requires support from the video driver in order to function 1208 * 1209 * @since 1.23 1210 */ 1211 EAPI Eina_Bool ecore_drm2_output_background_color_set(Ecore_Drm2_Output *output, uint64_t r, uint64_t g, uint64_t b, uint64_t a); 1212 1213 /** 1214 * Check if vblank is supported by the current video driver 1215 * 1216 * @param dev 1217 * 1218 * @return EINA_TRUE if vblank is supported, EINA_FALSE otherwise 1219 * 1220 * @ingroup Ecore_Drm2_Device_Group 1221 * @since 1.23 */ 1222 EAPI Eina_Bool ecore_drm2_vblank_supported(Ecore_Drm2_Device *dev); 1223 1224 # endif 1225 1226 #endif 1227