drm/vmwgfx: Implement screen targets
[deliverable/linux.git] / drivers / gpu / drm / vmwgfx / vmwgfx_kms.h
CommitLineData
fb1d9738
JB
1/**************************************************************************
2 *
c8261a96 3 * Copyright © 2009-2014 VMware, Inc., Palo Alto, CA., USA
fb1d9738
JB
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
760285e7
DH
31#include <drm/drmP.h>
32#include <drm/drm_crtc_helper.h>
fb1d9738
JB
33#include "vmwgfx_drv.h"
34
c8261a96
SY
35
36
56d1c78d
JB
37#define VMWGFX_NUM_DISPLAY_UNITS 8
38
fb1d9738
JB
39
40#define vmw_framebuffer_to_vfb(x) \
41 container_of(x, struct vmw_framebuffer, base)
c8261a96
SY
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)
fb1d9738
JB
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 */
53struct vmw_framebuffer {
54 struct drm_framebuffer base;
55 int (*pin)(struct vmw_framebuffer *fb);
56 int (*unpin)(struct vmw_framebuffer *fb);
2fcd5a73 57 bool dmabuf;
90ff18bc
TH
58 struct ttm_base_object *user_obj;
59 uint32_t user_handle;
fb1d9738
JB
60};
61
c8261a96
SY
62/*
63 * Clip rectangle
64 */
65struct vmw_clip_rect {
66 int x1, x2, y1, y2;
67};
68
69struct 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;
75};
fb1d9738 76
c8261a96
SY
77
78struct vmw_framebuffer_dmabuf {
79 struct vmw_framebuffer base;
80 struct vmw_dma_buffer *buffer;
81};
82
83
84/*
85 * Basic clip rect manipulation
86 */
87void vmw_clip_cliprects(struct drm_clip_rect *rects,
88 int num_rects,
89 struct vmw_clip_rect clip,
90 SVGASignedRect *out_rects,
91 int *out_num);
fb1d9738
JB
92
93/*
94 * Basic cursor manipulation
95 */
96int vmw_cursor_update_image(struct vmw_private *dev_priv,
97 u32 *image, u32 width, u32 height,
98 u32 hotspotX, u32 hotspotY);
bfc2638d
JB
99int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
100 struct vmw_dma_buffer *dmabuf,
101 u32 width, u32 height,
102 u32 hotspotX, u32 hotspotY);
fb1d9738
JB
103void vmw_cursor_update_position(struct vmw_private *dev_priv,
104 bool show, int x, int y);
105
bfc2638d 106
fb1d9738
JB
107/**
108 * Base class display unit.
109 *
110 * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
111 * so the display unit is all of them at the same time. This is true for both
112 * legacy multimon and screen objects.
113 */
114struct vmw_display_unit {
115 struct drm_crtc crtc;
116 struct drm_encoder encoder;
117 struct drm_connector connector;
118
119 struct vmw_surface *cursor_surface;
120 struct vmw_dma_buffer *cursor_dmabuf;
121 size_t cursor_age;
122
123 int cursor_x;
124 int cursor_y;
125
126 int hotspot_x;
127 int hotspot_y;
128
129 unsigned unit;
626ab771
JB
130
131 /*
132 * Prefered mode tracking.
133 */
134 unsigned pref_width;
135 unsigned pref_height;
136 bool pref_active;
137 struct drm_display_mode *pref_mode;
cd2b89e7
TH
138
139 /*
140 * Gui positioning
141 */
142 int gui_x;
143 int gui_y;
6987427a 144 bool is_implicit;
fb1d9738
JB
145};
146
2fcd5a73
JB
147#define vmw_crtc_to_du(x) \
148 container_of(x, struct vmw_display_unit, crtc)
626ab771
JB
149#define vmw_connector_to_du(x) \
150 container_of(x, struct vmw_display_unit, connector)
151
152
fb1d9738
JB
153/*
154 * Shared display unit functions - vmwgfx_kms.c
155 */
c8261a96 156void vmw_du_cleanup(struct vmw_display_unit *du);
626ab771
JB
157void vmw_du_crtc_save(struct drm_crtc *crtc);
158void vmw_du_crtc_restore(struct drm_crtc *crtc);
159void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
160 u16 *r, u16 *g, u16 *b,
161 uint32_t start, uint32_t size);
fb1d9738
JB
162int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
163 uint32_t handle, uint32_t width, uint32_t height);
164int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
626ab771
JB
165void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
166void vmw_du_connector_save(struct drm_connector *connector);
167void vmw_du_connector_restore(struct drm_connector *connector);
168enum drm_connector_status
169vmw_du_connector_detect(struct drm_connector *connector, bool force);
170int vmw_du_connector_fill_modes(struct drm_connector *connector,
171 uint32_t max_width, uint32_t max_height);
172int vmw_du_connector_set_property(struct drm_connector *connector,
173 struct drm_property *property,
174 uint64_t val);
cd2b89e7 175
fb1d9738
JB
176
177/*
d8bd19d2 178 * Legacy display unit functions - vmwgfx_ldu.c
fb1d9738 179 */
c8261a96
SY
180int vmw_kms_ldu_init_display(struct vmw_private *dev_priv);
181int vmw_kms_ldu_close_display(struct vmw_private *dev_priv);
182int vmw_kms_ldu_do_dmabuf_dirty(struct vmw_private *dev_priv,
183 struct vmw_framebuffer *framebuffer,
184 unsigned flags, unsigned color,
185 struct drm_clip_rect *clips,
186 unsigned num_clips, int increment);
fb1d9738 187
56d1c78d
JB
188/*
189 * Screen Objects display functions - vmwgfx_scrn.c
190 */
c8261a96
SY
191int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
192int vmw_kms_sou_close_display(struct vmw_private *dev_priv);
193int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
194 struct drm_file *file_priv,
195 struct vmw_framebuffer *framebuffer,
196 unsigned flags, unsigned color,
197 struct drm_clip_rect *clips,
198 unsigned num_clips, int inc,
199 struct vmw_fence_obj **out_fence);
200int vmw_kms_sou_do_dmabuf_dirty(struct drm_file *file_priv,
201 struct vmw_private *dev_priv,
202 struct vmw_framebuffer *framebuffer,
203 unsigned flags, unsigned color,
204 struct drm_clip_rect *clips,
205 unsigned num_clips, int increment,
206 struct vmw_fence_obj **out_fence);
35c05125
SY
207
208
209/*
210 * Screen Target Display Unit functions - vmwgfx_stdu.c
211 */
212int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
213int vmw_kms_stdu_close_display(struct vmw_private *dev_priv);
214int vmw_kms_stdu_do_surface_dirty(struct vmw_private *dev_priv,
215 struct drm_file *file_priv,
216 struct vmw_framebuffer *framebuffer,
217 struct drm_clip_rect *clips,
218 unsigned num_clips, int increment);
219int vmw_kms_stdu_present(struct vmw_private *dev_priv,
220 struct drm_file *file_priv,
221 struct vmw_framebuffer *vfb,
222 uint32_t user_handle,
223 int32_t dest_x, int32_t dest_y,
224 struct drm_vmw_rect *clips,
225 uint32_t num_clips);
226
fb1d9738 227#endif
This page took 0.696892 seconds and 5 git commands to generate.