blob: e1cb8556355fc625946783c30286ba3fb9388762 [file] [log] [blame]
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +00001/**************************************************************************
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"
32#include "vmwgfx_drv.h"
33
Jakob Bornecrantz56d1c782011-10-04 20:13:22 +020034#define VMWGFX_NUM_DISPLAY_UNITS 8
35
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000036
37#define vmw_framebuffer_to_vfb(x) \
38 container_of(x, struct vmw_framebuffer, base)
39
40/**
41 * Base class for framebuffers
42 *
43 * @pin is called the when ever a crtc uses this framebuffer
44 * @unpin is called
45 */
46struct vmw_framebuffer {
47 struct drm_framebuffer base;
48 int (*pin)(struct vmw_framebuffer *fb);
49 int (*unpin)(struct vmw_framebuffer *fb);
Jakob Bornecrantz2fcd5a72011-10-04 20:13:26 +020050 bool dmabuf;
Thomas Hellstrom90ff18b2011-10-04 20:13:32 +020051 struct ttm_base_object *user_obj;
52 uint32_t user_handle;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000053};
54
55
56#define vmw_crtc_to_du(x) \
57 container_of(x, struct vmw_display_unit, crtc)
58
59/*
60 * Basic cursor manipulation
61 */
62int vmw_cursor_update_image(struct vmw_private *dev_priv,
63 u32 *image, u32 width, u32 height,
64 u32 hotspotX, u32 hotspotY);
Jakob Bornecrantzbfc26382011-11-28 13:19:14 +010065int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
66 struct vmw_dma_buffer *dmabuf,
67 u32 width, u32 height,
68 u32 hotspotX, u32 hotspotY);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000069void vmw_cursor_update_position(struct vmw_private *dev_priv,
70 bool show, int x, int y);
71
Jakob Bornecrantzbfc26382011-11-28 13:19:14 +010072
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000073/**
74 * Base class display unit.
75 *
76 * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
77 * so the display unit is all of them at the same time. This is true for both
78 * legacy multimon and screen objects.
79 */
80struct vmw_display_unit {
81 struct drm_crtc crtc;
82 struct drm_encoder encoder;
83 struct drm_connector connector;
84
85 struct vmw_surface *cursor_surface;
86 struct vmw_dma_buffer *cursor_dmabuf;
87 size_t cursor_age;
88
89 int cursor_x;
90 int cursor_y;
91
92 int hotspot_x;
93 int hotspot_y;
94
95 unsigned unit;
Jakob Bornecrantz626ab772011-10-04 20:13:20 +020096
97 /*
98 * Prefered mode tracking.
99 */
100 unsigned pref_width;
101 unsigned pref_height;
102 bool pref_active;
103 struct drm_display_mode *pref_mode;
Thomas Hellstromcd2b89e2011-10-25 23:35:53 +0200104
105 /*
106 * Gui positioning
107 */
108 int gui_x;
109 int gui_y;
Thomas Hellstrom69874272011-11-02 09:43:11 +0100110 bool is_implicit;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000111};
112
Jakob Bornecrantz2fcd5a72011-10-04 20:13:26 +0200113#define vmw_crtc_to_du(x) \
114 container_of(x, struct vmw_display_unit, crtc)
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200115#define vmw_connector_to_du(x) \
116 container_of(x, struct vmw_display_unit, connector)
117
118
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000119/*
120 * Shared display unit functions - vmwgfx_kms.c
121 */
122void vmw_display_unit_cleanup(struct vmw_display_unit *du);
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200123void vmw_du_crtc_save(struct drm_crtc *crtc);
124void vmw_du_crtc_restore(struct drm_crtc *crtc);
125void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
126 u16 *r, u16 *g, u16 *b,
127 uint32_t start, uint32_t size);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000128int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
129 uint32_t handle, uint32_t width, uint32_t height);
130int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200131void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
132void vmw_du_connector_save(struct drm_connector *connector);
133void vmw_du_connector_restore(struct drm_connector *connector);
134enum drm_connector_status
135vmw_du_connector_detect(struct drm_connector *connector, bool force);
136int vmw_du_connector_fill_modes(struct drm_connector *connector,
137 uint32_t max_width, uint32_t max_height);
138int vmw_du_connector_set_property(struct drm_connector *connector,
139 struct drm_property *property,
140 uint64_t val);
Thomas Hellstromcd2b89e2011-10-25 23:35:53 +0200141
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000142
143/*
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200144 * Legacy display unit functions - vmwgfx_ldu.c
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000145 */
146int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv);
147int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000148
Jakob Bornecrantz56d1c782011-10-04 20:13:22 +0200149/*
150 * Screen Objects display functions - vmwgfx_scrn.c
151 */
152int vmw_kms_init_screen_object_display(struct vmw_private *dev_priv);
153int vmw_kms_close_screen_object_display(struct vmw_private *dev_priv);
154int vmw_kms_sou_update_layout(struct vmw_private *dev_priv, unsigned num,
155 struct drm_vmw_rect *rects);
156
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000157#endif