vmwgfx_kms.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /**************************************************************************
  2. *
  3. * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifndef VMWGFX_KMS_H_
  28. #define VMWGFX_KMS_H_
  29. #include "drmP.h"
  30. #include "drm_crtc_helper.h"
  31. #include "vmwgfx_drv.h"
  32. #define VMWGFX_NUM_DISPLAY_UNITS 8
  33. #define vmw_framebuffer_to_vfb(x) \
  34. container_of(x, struct vmw_framebuffer, base)
  35. /**
  36. * Base class for framebuffers
  37. *
  38. * @pin is called the when ever a crtc uses this framebuffer
  39. * @unpin is called
  40. */
  41. struct vmw_framebuffer {
  42. struct drm_framebuffer base;
  43. int (*pin)(struct vmw_framebuffer *fb);
  44. int (*unpin)(struct vmw_framebuffer *fb);
  45. bool dmabuf;
  46. struct ttm_base_object *user_obj;
  47. uint32_t user_handle;
  48. };
  49. #define vmw_crtc_to_du(x) \
  50. container_of(x, struct vmw_display_unit, crtc)
  51. /*
  52. * Basic cursor manipulation
  53. */
  54. int vmw_cursor_update_image(struct vmw_private *dev_priv,
  55. u32 *image, u32 width, u32 height,
  56. u32 hotspotX, u32 hotspotY);
  57. int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
  58. struct vmw_dma_buffer *dmabuf,
  59. u32 width, u32 height,
  60. u32 hotspotX, u32 hotspotY);
  61. void vmw_cursor_update_position(struct vmw_private *dev_priv,
  62. bool show, int x, int y);
  63. /**
  64. * Base class display unit.
  65. *
  66. * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
  67. * so the display unit is all of them at the same time. This is true for both
  68. * legacy multimon and screen objects.
  69. */
  70. struct vmw_display_unit {
  71. struct drm_crtc crtc;
  72. struct drm_encoder encoder;
  73. struct drm_connector connector;
  74. struct vmw_surface *cursor_surface;
  75. struct vmw_dma_buffer *cursor_dmabuf;
  76. size_t cursor_age;
  77. int cursor_x;
  78. int cursor_y;
  79. int hotspot_x;
  80. int hotspot_y;
  81. unsigned unit;
  82. /*
  83. * Prefered mode tracking.
  84. */
  85. unsigned pref_width;
  86. unsigned pref_height;
  87. bool pref_active;
  88. struct drm_display_mode *pref_mode;
  89. /*
  90. * Gui positioning
  91. */
  92. int gui_x;
  93. int gui_y;
  94. bool is_implicit;
  95. };
  96. #define vmw_crtc_to_du(x) \
  97. container_of(x, struct vmw_display_unit, crtc)
  98. #define vmw_connector_to_du(x) \
  99. container_of(x, struct vmw_display_unit, connector)
  100. /*
  101. * Shared display unit functions - vmwgfx_kms.c
  102. */
  103. void vmw_display_unit_cleanup(struct vmw_display_unit *du);
  104. int vmw_du_page_flip(struct drm_crtc *crtc,
  105. struct drm_framebuffer *fb,
  106. struct drm_pending_vblank_event *event);
  107. void vmw_du_crtc_save(struct drm_crtc *crtc);
  108. void vmw_du_crtc_restore(struct drm_crtc *crtc);
  109. void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
  110. u16 *r, u16 *g, u16 *b,
  111. uint32_t start, uint32_t size);
  112. int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
  113. uint32_t handle, uint32_t width, uint32_t height);
  114. int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
  115. void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
  116. void vmw_du_connector_save(struct drm_connector *connector);
  117. void vmw_du_connector_restore(struct drm_connector *connector);
  118. enum drm_connector_status
  119. vmw_du_connector_detect(struct drm_connector *connector, bool force);
  120. int vmw_du_connector_fill_modes(struct drm_connector *connector,
  121. uint32_t max_width, uint32_t max_height);
  122. int vmw_du_connector_set_property(struct drm_connector *connector,
  123. struct drm_property *property,
  124. uint64_t val);
  125. /*
  126. * Legacy display unit functions - vmwgfx_ldu.c
  127. */
  128. int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv);
  129. int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv);
  130. /*
  131. * Screen Objects display functions - vmwgfx_scrn.c
  132. */
  133. int vmw_kms_init_screen_object_display(struct vmw_private *dev_priv);
  134. int vmw_kms_close_screen_object_display(struct vmw_private *dev_priv);
  135. int vmw_kms_sou_update_layout(struct vmw_private *dev_priv, unsigned num,
  136. struct drm_vmw_rect *rects);
  137. bool vmw_kms_screen_object_flippable(struct vmw_private *dev_priv,
  138. struct drm_crtc *crtc);
  139. void vmw_kms_screen_object_update_implicit_fb(struct vmw_private *dev_priv,
  140. struct drm_crtc *crtc);
  141. #endif