Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 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 | |
| 28 | #ifndef VMWGFX_KMS_H_ |
| 29 | #define VMWGFX_KMS_H_ |
| 30 | |
| 31 | #include "drmP.h" |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 32 | #include "drm_crtc_helper.h" |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 33 | #include "vmwgfx_drv.h" |
| 34 | |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 35 | #define VMWGFX_NUM_DISPLAY_UNITS 8 |
| 36 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 37 | |
| 38 | #define vmw_framebuffer_to_vfb(x) \ |
| 39 | container_of(x, struct vmw_framebuffer, base) |
| 40 | |
| 41 | /** |
| 42 | * Base class for framebuffers |
| 43 | * |
| 44 | * @pin is called the when ever a crtc uses this framebuffer |
| 45 | * @unpin is called |
| 46 | */ |
| 47 | struct vmw_framebuffer { |
| 48 | struct drm_framebuffer base; |
| 49 | int (*pin)(struct vmw_framebuffer *fb); |
| 50 | int (*unpin)(struct vmw_framebuffer *fb); |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 51 | bool dmabuf; |
Thomas Hellstrom | 90ff18b | 2011-10-04 20:13:32 +0200 | [diff] [blame] | 52 | struct ttm_base_object *user_obj; |
| 53 | uint32_t user_handle; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | |
| 57 | #define vmw_crtc_to_du(x) \ |
| 58 | container_of(x, struct vmw_display_unit, crtc) |
| 59 | |
| 60 | /* |
| 61 | * Basic cursor manipulation |
| 62 | */ |
| 63 | int vmw_cursor_update_image(struct vmw_private *dev_priv, |
| 64 | u32 *image, u32 width, u32 height, |
| 65 | u32 hotspotX, u32 hotspotY); |
Jakob Bornecrantz | bfc2638 | 2011-11-28 13:19:14 +0100 | [diff] [blame] | 66 | int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv, |
| 67 | struct vmw_dma_buffer *dmabuf, |
| 68 | u32 width, u32 height, |
| 69 | u32 hotspotX, u32 hotspotY); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 70 | void vmw_cursor_update_position(struct vmw_private *dev_priv, |
| 71 | bool show, int x, int y); |
| 72 | |
Jakob Bornecrantz | bfc2638 | 2011-11-28 13:19:14 +0100 | [diff] [blame] | 73 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 74 | /** |
| 75 | * Base class display unit. |
| 76 | * |
| 77 | * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector |
| 78 | * so the display unit is all of them at the same time. This is true for both |
| 79 | * legacy multimon and screen objects. |
| 80 | */ |
| 81 | struct vmw_display_unit { |
| 82 | struct drm_crtc crtc; |
| 83 | struct drm_encoder encoder; |
| 84 | struct drm_connector connector; |
| 85 | |
| 86 | struct vmw_surface *cursor_surface; |
| 87 | struct vmw_dma_buffer *cursor_dmabuf; |
| 88 | size_t cursor_age; |
| 89 | |
| 90 | int cursor_x; |
| 91 | int cursor_y; |
| 92 | |
| 93 | int hotspot_x; |
| 94 | int hotspot_y; |
| 95 | |
| 96 | unsigned unit; |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 97 | |
| 98 | /* |
| 99 | * Prefered mode tracking. |
| 100 | */ |
| 101 | unsigned pref_width; |
| 102 | unsigned pref_height; |
| 103 | bool pref_active; |
| 104 | struct drm_display_mode *pref_mode; |
Thomas Hellstrom | cd2b89e | 2011-10-25 23:35:53 +0200 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * Gui positioning |
| 108 | */ |
| 109 | int gui_x; |
| 110 | int gui_y; |
Thomas Hellstrom | 6987427 | 2011-11-02 09:43:11 +0100 | [diff] [blame] | 111 | bool is_implicit; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 114 | #define vmw_crtc_to_du(x) \ |
| 115 | container_of(x, struct vmw_display_unit, crtc) |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 116 | #define vmw_connector_to_du(x) \ |
| 117 | container_of(x, struct vmw_display_unit, connector) |
| 118 | |
| 119 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 120 | /* |
| 121 | * Shared display unit functions - vmwgfx_kms.c |
| 122 | */ |
| 123 | void vmw_display_unit_cleanup(struct vmw_display_unit *du); |
Jakob Bornecrantz | b5ec427 | 2012-02-09 16:56:45 +0100 | [diff] [blame^] | 124 | int vmw_du_page_flip(struct drm_crtc *crtc, |
| 125 | struct drm_framebuffer *fb, |
| 126 | struct drm_pending_vblank_event *event); |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 127 | void vmw_du_crtc_save(struct drm_crtc *crtc); |
| 128 | void vmw_du_crtc_restore(struct drm_crtc *crtc); |
| 129 | void vmw_du_crtc_gamma_set(struct drm_crtc *crtc, |
| 130 | u16 *r, u16 *g, u16 *b, |
| 131 | uint32_t start, uint32_t size); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 132 | int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 133 | uint32_t handle, uint32_t width, uint32_t height); |
| 134 | int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y); |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 135 | void vmw_du_connector_dpms(struct drm_connector *connector, int mode); |
| 136 | void vmw_du_connector_save(struct drm_connector *connector); |
| 137 | void vmw_du_connector_restore(struct drm_connector *connector); |
| 138 | enum drm_connector_status |
| 139 | vmw_du_connector_detect(struct drm_connector *connector, bool force); |
| 140 | int vmw_du_connector_fill_modes(struct drm_connector *connector, |
| 141 | uint32_t max_width, uint32_t max_height); |
| 142 | int vmw_du_connector_set_property(struct drm_connector *connector, |
| 143 | struct drm_property *property, |
| 144 | uint64_t val); |
Thomas Hellstrom | cd2b89e | 2011-10-25 23:35:53 +0200 | [diff] [blame] | 145 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 146 | |
| 147 | /* |
Jakob Bornecrantz | d8bd19d | 2010-06-01 11:54:20 +0200 | [diff] [blame] | 148 | * Legacy display unit functions - vmwgfx_ldu.c |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 149 | */ |
| 150 | int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv); |
| 151 | int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 152 | |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 153 | /* |
| 154 | * Screen Objects display functions - vmwgfx_scrn.c |
| 155 | */ |
| 156 | int vmw_kms_init_screen_object_display(struct vmw_private *dev_priv); |
| 157 | int vmw_kms_close_screen_object_display(struct vmw_private *dev_priv); |
| 158 | int vmw_kms_sou_update_layout(struct vmw_private *dev_priv, unsigned num, |
| 159 | struct drm_vmw_rect *rects); |
Jakob Bornecrantz | b5ec427 | 2012-02-09 16:56:45 +0100 | [diff] [blame^] | 160 | bool vmw_kms_screen_object_flippable(struct vmw_private *dev_priv, |
| 161 | struct drm_crtc *crtc); |
| 162 | void vmw_kms_screen_object_update_implicit_fb(struct vmw_private *dev_priv, |
| 163 | struct drm_crtc *crtc); |
| 164 | |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 165 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 166 | #endif |