Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 3 | * Copyright © 2009-2014 VMware, Inc., Palo Alto, CA., USA |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 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 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 31 | #include <drm/drmP.h> |
| 32 | #include <drm/drm_crtc_helper.h> |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 33 | #include "vmwgfx_drv.h" |
| 34 | |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 35 | |
| 36 | |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 37 | #define VMWGFX_NUM_DISPLAY_UNITS 8 |
| 38 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 39 | |
| 40 | #define vmw_framebuffer_to_vfb(x) \ |
| 41 | container_of(x, struct vmw_framebuffer, base) |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 42 | #define vmw_framebuffer_to_vfbs(x) \ |
| 43 | container_of(x, struct vmw_framebuffer_surface, base.base) |
| 44 | #define vmw_framebuffer_to_vfbd(x) \ |
| 45 | container_of(x, struct vmw_framebuffer_dmabuf, base.base) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * Base class for framebuffers |
| 49 | * |
| 50 | * @pin is called the when ever a crtc uses this framebuffer |
| 51 | * @unpin is called |
| 52 | */ |
| 53 | struct vmw_framebuffer { |
| 54 | struct drm_framebuffer base; |
| 55 | int (*pin)(struct vmw_framebuffer *fb); |
| 56 | int (*unpin)(struct vmw_framebuffer *fb); |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 57 | bool dmabuf; |
Thomas Hellstrom | 90ff18b | 2011-10-04 20:13:32 +0200 | [diff] [blame] | 58 | struct ttm_base_object *user_obj; |
| 59 | uint32_t user_handle; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 62 | /* |
| 63 | * Clip rectangle |
| 64 | */ |
| 65 | struct vmw_clip_rect { |
| 66 | int x1, x2, y1, y2; |
| 67 | }; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 68 | |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 69 | struct vmw_framebuffer_surface { |
| 70 | struct vmw_framebuffer base; |
| 71 | struct vmw_surface *surface; |
| 72 | struct vmw_dma_buffer *buffer; |
| 73 | struct list_head head; |
| 74 | struct drm_master *master; |
Sinclair Yeh | f89c6c3 | 2015-06-26 01:54:28 -0700 | [diff] [blame^] | 75 | bool is_dmabuf_proxy; /* true if this is proxy surface for DMA buf */ |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | |
| 79 | struct vmw_framebuffer_dmabuf { |
| 80 | struct vmw_framebuffer base; |
| 81 | struct vmw_dma_buffer *buffer; |
| 82 | }; |
| 83 | |
| 84 | |
| 85 | /* |
| 86 | * Basic clip rect manipulation |
| 87 | */ |
| 88 | void vmw_clip_cliprects(struct drm_clip_rect *rects, |
| 89 | int num_rects, |
| 90 | struct vmw_clip_rect clip, |
| 91 | SVGASignedRect *out_rects, |
| 92 | int *out_num); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 93 | |
| 94 | /* |
| 95 | * Basic cursor manipulation |
| 96 | */ |
| 97 | int vmw_cursor_update_image(struct vmw_private *dev_priv, |
| 98 | u32 *image, u32 width, u32 height, |
| 99 | u32 hotspotX, u32 hotspotY); |
Jakob Bornecrantz | bfc2638 | 2011-11-28 13:19:14 +0100 | [diff] [blame] | 100 | int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv, |
| 101 | struct vmw_dma_buffer *dmabuf, |
| 102 | u32 width, u32 height, |
| 103 | u32 hotspotX, u32 hotspotY); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 104 | void vmw_cursor_update_position(struct vmw_private *dev_priv, |
| 105 | bool show, int x, int y); |
| 106 | |
Jakob Bornecrantz | bfc2638 | 2011-11-28 13:19:14 +0100 | [diff] [blame] | 107 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 108 | /** |
| 109 | * Base class display unit. |
| 110 | * |
| 111 | * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector |
| 112 | * so the display unit is all of them at the same time. This is true for both |
| 113 | * legacy multimon and screen objects. |
| 114 | */ |
| 115 | struct vmw_display_unit { |
| 116 | struct drm_crtc crtc; |
| 117 | struct drm_encoder encoder; |
| 118 | struct drm_connector connector; |
| 119 | |
| 120 | struct vmw_surface *cursor_surface; |
| 121 | struct vmw_dma_buffer *cursor_dmabuf; |
| 122 | size_t cursor_age; |
| 123 | |
| 124 | int cursor_x; |
| 125 | int cursor_y; |
| 126 | |
| 127 | int hotspot_x; |
| 128 | int hotspot_y; |
| 129 | |
| 130 | unsigned unit; |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 131 | |
| 132 | /* |
| 133 | * Prefered mode tracking. |
| 134 | */ |
| 135 | unsigned pref_width; |
| 136 | unsigned pref_height; |
| 137 | bool pref_active; |
| 138 | struct drm_display_mode *pref_mode; |
Thomas Hellstrom | cd2b89e | 2011-10-25 23:35:53 +0200 | [diff] [blame] | 139 | |
| 140 | /* |
| 141 | * Gui positioning |
| 142 | */ |
| 143 | int gui_x; |
| 144 | int gui_y; |
Thomas Hellstrom | 6987427 | 2011-11-02 09:43:11 +0100 | [diff] [blame] | 145 | bool is_implicit; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
Jakob Bornecrantz | 2fcd5a7 | 2011-10-04 20:13:26 +0200 | [diff] [blame] | 148 | #define vmw_crtc_to_du(x) \ |
| 149 | container_of(x, struct vmw_display_unit, crtc) |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 150 | #define vmw_connector_to_du(x) \ |
| 151 | container_of(x, struct vmw_display_unit, connector) |
| 152 | |
| 153 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 154 | /* |
| 155 | * Shared display unit functions - vmwgfx_kms.c |
| 156 | */ |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 157 | void vmw_du_cleanup(struct vmw_display_unit *du); |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 158 | void vmw_du_crtc_save(struct drm_crtc *crtc); |
| 159 | void vmw_du_crtc_restore(struct drm_crtc *crtc); |
| 160 | void vmw_du_crtc_gamma_set(struct drm_crtc *crtc, |
| 161 | u16 *r, u16 *g, u16 *b, |
| 162 | uint32_t start, uint32_t size); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 163 | int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 164 | uint32_t handle, uint32_t width, uint32_t height); |
| 165 | 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] | 166 | void vmw_du_connector_dpms(struct drm_connector *connector, int mode); |
| 167 | void vmw_du_connector_save(struct drm_connector *connector); |
| 168 | void vmw_du_connector_restore(struct drm_connector *connector); |
| 169 | enum drm_connector_status |
| 170 | vmw_du_connector_detect(struct drm_connector *connector, bool force); |
| 171 | int vmw_du_connector_fill_modes(struct drm_connector *connector, |
| 172 | uint32_t max_width, uint32_t max_height); |
| 173 | int vmw_du_connector_set_property(struct drm_connector *connector, |
| 174 | struct drm_property *property, |
| 175 | uint64_t val); |
Thomas Hellstrom | cd2b89e | 2011-10-25 23:35:53 +0200 | [diff] [blame] | 176 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 177 | |
| 178 | /* |
Jakob Bornecrantz | d8bd19d | 2010-06-01 11:54:20 +0200 | [diff] [blame] | 179 | * Legacy display unit functions - vmwgfx_ldu.c |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 180 | */ |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 181 | int vmw_kms_ldu_init_display(struct vmw_private *dev_priv); |
| 182 | int vmw_kms_ldu_close_display(struct vmw_private *dev_priv); |
| 183 | int vmw_kms_ldu_do_dmabuf_dirty(struct vmw_private *dev_priv, |
| 184 | struct vmw_framebuffer *framebuffer, |
| 185 | unsigned flags, unsigned color, |
| 186 | struct drm_clip_rect *clips, |
| 187 | unsigned num_clips, int increment); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 188 | |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 189 | /* |
| 190 | * Screen Objects display functions - vmwgfx_scrn.c |
| 191 | */ |
Sinclair Yeh | c8261a9 | 2015-06-26 01:23:42 -0700 | [diff] [blame] | 192 | int vmw_kms_sou_init_display(struct vmw_private *dev_priv); |
| 193 | int vmw_kms_sou_close_display(struct vmw_private *dev_priv); |
| 194 | int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv, |
| 195 | struct drm_file *file_priv, |
| 196 | struct vmw_framebuffer *framebuffer, |
| 197 | unsigned flags, unsigned color, |
| 198 | struct drm_clip_rect *clips, |
| 199 | unsigned num_clips, int inc, |
| 200 | struct vmw_fence_obj **out_fence); |
| 201 | int vmw_kms_sou_do_dmabuf_dirty(struct drm_file *file_priv, |
| 202 | struct vmw_private *dev_priv, |
| 203 | struct vmw_framebuffer *framebuffer, |
| 204 | unsigned flags, unsigned color, |
| 205 | struct drm_clip_rect *clips, |
| 206 | unsigned num_clips, int increment, |
| 207 | struct vmw_fence_obj **out_fence); |
Sinclair Yeh | 35c0512 | 2015-06-26 01:42:06 -0700 | [diff] [blame] | 208 | |
| 209 | |
| 210 | /* |
| 211 | * Screen Target Display Unit functions - vmwgfx_stdu.c |
| 212 | */ |
| 213 | int vmw_kms_stdu_init_display(struct vmw_private *dev_priv); |
| 214 | int vmw_kms_stdu_close_display(struct vmw_private *dev_priv); |
| 215 | int vmw_kms_stdu_do_surface_dirty(struct vmw_private *dev_priv, |
| 216 | struct drm_file *file_priv, |
| 217 | struct vmw_framebuffer *framebuffer, |
| 218 | struct drm_clip_rect *clips, |
| 219 | unsigned num_clips, int increment); |
| 220 | int vmw_kms_stdu_present(struct vmw_private *dev_priv, |
| 221 | struct drm_file *file_priv, |
| 222 | struct vmw_framebuffer *vfb, |
| 223 | uint32_t user_handle, |
| 224 | int32_t dest_x, int32_t dest_y, |
| 225 | struct drm_vmw_rect *clips, |
| 226 | uint32_t num_clips); |
| 227 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 228 | #endif |