blob: db8ae94c403c6f2e4987037fc05689df6f8dfc18 [file] [log] [blame]
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +00001/**************************************************************************
2 *
Sinclair Yehc8261a92015-06-26 01:23:42 -07003 * Copyright © 2009-2014 VMware, Inc., Palo Alto, CA., USA
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +00004 * 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 Howells760285e2012-10-02 18:01:07 +010031#include <drm/drmP.h>
32#include <drm/drm_crtc_helper.h>
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000033#include "vmwgfx_drv.h"
34
Sinclair Yehc8261a92015-06-26 01:23:42 -070035
36
Jakob Bornecrantz56d1c782011-10-04 20:13:22 +020037#define VMWGFX_NUM_DISPLAY_UNITS 8
38
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000039
40#define vmw_framebuffer_to_vfb(x) \
41 container_of(x, struct vmw_framebuffer, base)
Sinclair Yehc8261a92015-06-26 01:23:42 -070042#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 Bornecrantzfb1d9732009-12-10 00:19:58 +000046
47/**
48 * Base class for framebuffers
49 *
50 * @pin is called the when ever a crtc uses this framebuffer
51 * @unpin is called
52 */
53struct vmw_framebuffer {
54 struct drm_framebuffer base;
55 int (*pin)(struct vmw_framebuffer *fb);
56 int (*unpin)(struct vmw_framebuffer *fb);
Jakob Bornecrantz2fcd5a72011-10-04 20:13:26 +020057 bool dmabuf;
Thomas Hellstrom90ff18b2011-10-04 20:13:32 +020058 struct ttm_base_object *user_obj;
59 uint32_t user_handle;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000060};
61
Sinclair Yehc8261a92015-06-26 01:23:42 -070062/*
63 * Clip rectangle
64 */
65struct vmw_clip_rect {
66 int x1, x2, y1, y2;
67};
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000068
Sinclair Yehc8261a92015-06-26 01:23:42 -070069struct 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 Yehf89c6c32015-06-26 01:54:28 -070075 bool is_dmabuf_proxy; /* true if this is proxy surface for DMA buf */
Sinclair Yehc8261a92015-06-26 01:23:42 -070076};
77
78
79struct vmw_framebuffer_dmabuf {
80 struct vmw_framebuffer base;
81 struct vmw_dma_buffer *buffer;
82};
83
84
85/*
86 * Basic clip rect manipulation
87 */
88void 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 Bornecrantzfb1d9732009-12-10 00:19:58 +000093
94/*
95 * Basic cursor manipulation
96 */
97int vmw_cursor_update_image(struct vmw_private *dev_priv,
98 u32 *image, u32 width, u32 height,
99 u32 hotspotX, u32 hotspotY);
Jakob Bornecrantzbfc26382011-11-28 13:19:14 +0100100int 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 Bornecrantzfb1d9732009-12-10 00:19:58 +0000104void vmw_cursor_update_position(struct vmw_private *dev_priv,
105 bool show, int x, int y);
106
Jakob Bornecrantzbfc26382011-11-28 13:19:14 +0100107
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000108/**
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 */
115struct 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 Bornecrantz626ab772011-10-04 20:13:20 +0200131
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 Hellstromcd2b89e2011-10-25 23:35:53 +0200139
140 /*
141 * Gui positioning
142 */
143 int gui_x;
144 int gui_y;
Thomas Hellstrom69874272011-11-02 09:43:11 +0100145 bool is_implicit;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000146};
147
Jakob Bornecrantz2fcd5a72011-10-04 20:13:26 +0200148#define vmw_crtc_to_du(x) \
149 container_of(x, struct vmw_display_unit, crtc)
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200150#define vmw_connector_to_du(x) \
151 container_of(x, struct vmw_display_unit, connector)
152
153
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000154/*
155 * Shared display unit functions - vmwgfx_kms.c
156 */
Sinclair Yehc8261a92015-06-26 01:23:42 -0700157void vmw_du_cleanup(struct vmw_display_unit *du);
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200158void vmw_du_crtc_save(struct drm_crtc *crtc);
159void vmw_du_crtc_restore(struct drm_crtc *crtc);
160void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
161 u16 *r, u16 *g, u16 *b,
162 uint32_t start, uint32_t size);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000163int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
164 uint32_t handle, uint32_t width, uint32_t height);
165int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200166void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
167void vmw_du_connector_save(struct drm_connector *connector);
168void vmw_du_connector_restore(struct drm_connector *connector);
169enum drm_connector_status
170vmw_du_connector_detect(struct drm_connector *connector, bool force);
171int vmw_du_connector_fill_modes(struct drm_connector *connector,
172 uint32_t max_width, uint32_t max_height);
173int vmw_du_connector_set_property(struct drm_connector *connector,
174 struct drm_property *property,
175 uint64_t val);
Thomas Hellstromcd2b89e2011-10-25 23:35:53 +0200176
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000177
178/*
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200179 * Legacy display unit functions - vmwgfx_ldu.c
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000180 */
Sinclair Yehc8261a92015-06-26 01:23:42 -0700181int vmw_kms_ldu_init_display(struct vmw_private *dev_priv);
182int vmw_kms_ldu_close_display(struct vmw_private *dev_priv);
183int 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 Bornecrantzfb1d9732009-12-10 00:19:58 +0000188
Jakob Bornecrantz56d1c782011-10-04 20:13:22 +0200189/*
190 * Screen Objects display functions - vmwgfx_scrn.c
191 */
Sinclair Yehc8261a92015-06-26 01:23:42 -0700192int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
193int vmw_kms_sou_close_display(struct vmw_private *dev_priv);
194int 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);
201int 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 Yeh35c05122015-06-26 01:42:06 -0700208
209
210/*
211 * Screen Target Display Unit functions - vmwgfx_stdu.c
212 */
213int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
214int vmw_kms_stdu_close_display(struct vmw_private *dev_priv);
215int 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);
220int 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 Bornecrantzfb1d9732009-12-10 00:19:58 +0000228#endif