xref: /linux/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h (revision 6987427a3953c5038dc14d2a090b5a6c93669428)
1fb1d9738SJakob Bornecrantz /**************************************************************************
2fb1d9738SJakob Bornecrantz  *
3fb1d9738SJakob Bornecrantz  * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
4fb1d9738SJakob Bornecrantz  * All Rights Reserved.
5fb1d9738SJakob Bornecrantz  *
6fb1d9738SJakob Bornecrantz  * Permission is hereby granted, free of charge, to any person obtaining a
7fb1d9738SJakob Bornecrantz  * copy of this software and associated documentation files (the
8fb1d9738SJakob Bornecrantz  * "Software"), to deal in the Software without restriction, including
9fb1d9738SJakob Bornecrantz  * without limitation the rights to use, copy, modify, merge, publish,
10fb1d9738SJakob Bornecrantz  * distribute, sub license, and/or sell copies of the Software, and to
11fb1d9738SJakob Bornecrantz  * permit persons to whom the Software is furnished to do so, subject to
12fb1d9738SJakob Bornecrantz  * the following conditions:
13fb1d9738SJakob Bornecrantz  *
14fb1d9738SJakob Bornecrantz  * The above copyright notice and this permission notice (including the
15fb1d9738SJakob Bornecrantz  * next paragraph) shall be included in all copies or substantial portions
16fb1d9738SJakob Bornecrantz  * of the Software.
17fb1d9738SJakob Bornecrantz  *
18fb1d9738SJakob Bornecrantz  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19fb1d9738SJakob Bornecrantz  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20fb1d9738SJakob Bornecrantz  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21fb1d9738SJakob Bornecrantz  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22fb1d9738SJakob Bornecrantz  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23fb1d9738SJakob Bornecrantz  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24fb1d9738SJakob Bornecrantz  * USE OR OTHER DEALINGS IN THE SOFTWARE.
25fb1d9738SJakob Bornecrantz  *
26fb1d9738SJakob Bornecrantz  **************************************************************************/
27fb1d9738SJakob Bornecrantz 
28fb1d9738SJakob Bornecrantz #ifndef VMWGFX_KMS_H_
29fb1d9738SJakob Bornecrantz #define VMWGFX_KMS_H_
30fb1d9738SJakob Bornecrantz 
31fb1d9738SJakob Bornecrantz #include "drmP.h"
32fb1d9738SJakob Bornecrantz #include "vmwgfx_drv.h"
33fb1d9738SJakob Bornecrantz 
3456d1c78dSJakob Bornecrantz #define VMWGFX_NUM_DISPLAY_UNITS 8
3556d1c78dSJakob Bornecrantz 
36fb1d9738SJakob Bornecrantz 
37fb1d9738SJakob Bornecrantz #define vmw_framebuffer_to_vfb(x) \
38fb1d9738SJakob Bornecrantz 	container_of(x, struct vmw_framebuffer, base)
39fb1d9738SJakob Bornecrantz 
40fb1d9738SJakob Bornecrantz /**
41fb1d9738SJakob Bornecrantz  * Base class for framebuffers
42fb1d9738SJakob Bornecrantz  *
43fb1d9738SJakob Bornecrantz  * @pin is called the when ever a crtc uses this framebuffer
44fb1d9738SJakob Bornecrantz  * @unpin is called
45fb1d9738SJakob Bornecrantz  */
46fb1d9738SJakob Bornecrantz struct vmw_framebuffer {
47fb1d9738SJakob Bornecrantz 	struct drm_framebuffer base;
48fb1d9738SJakob Bornecrantz 	int (*pin)(struct vmw_framebuffer *fb);
49fb1d9738SJakob Bornecrantz 	int (*unpin)(struct vmw_framebuffer *fb);
502fcd5a73SJakob Bornecrantz 	bool dmabuf;
5190ff18bcSThomas Hellstrom 	struct ttm_base_object *user_obj;
5290ff18bcSThomas Hellstrom 	uint32_t user_handle;
53fb1d9738SJakob Bornecrantz };
54fb1d9738SJakob Bornecrantz 
55fb1d9738SJakob Bornecrantz 
56fb1d9738SJakob Bornecrantz #define vmw_crtc_to_du(x) \
57fb1d9738SJakob Bornecrantz 	container_of(x, struct vmw_display_unit, crtc)
58fb1d9738SJakob Bornecrantz 
59fb1d9738SJakob Bornecrantz /*
60fb1d9738SJakob Bornecrantz  * Basic cursor manipulation
61fb1d9738SJakob Bornecrantz  */
62fb1d9738SJakob Bornecrantz int vmw_cursor_update_image(struct vmw_private *dev_priv,
63fb1d9738SJakob Bornecrantz 			    u32 *image, u32 width, u32 height,
64fb1d9738SJakob Bornecrantz 			    u32 hotspotX, u32 hotspotY);
65fb1d9738SJakob Bornecrantz void vmw_cursor_update_position(struct vmw_private *dev_priv,
66fb1d9738SJakob Bornecrantz 				bool show, int x, int y);
67fb1d9738SJakob Bornecrantz 
68fb1d9738SJakob Bornecrantz /**
69fb1d9738SJakob Bornecrantz  * Base class display unit.
70fb1d9738SJakob Bornecrantz  *
71fb1d9738SJakob Bornecrantz  * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
72fb1d9738SJakob Bornecrantz  * so the display unit is all of them at the same time. This is true for both
73fb1d9738SJakob Bornecrantz  * legacy multimon and screen objects.
74fb1d9738SJakob Bornecrantz  */
75fb1d9738SJakob Bornecrantz struct vmw_display_unit {
76fb1d9738SJakob Bornecrantz 	struct drm_crtc crtc;
77fb1d9738SJakob Bornecrantz 	struct drm_encoder encoder;
78fb1d9738SJakob Bornecrantz 	struct drm_connector connector;
79fb1d9738SJakob Bornecrantz 
80fb1d9738SJakob Bornecrantz 	struct vmw_surface *cursor_surface;
81fb1d9738SJakob Bornecrantz 	struct vmw_dma_buffer *cursor_dmabuf;
82fb1d9738SJakob Bornecrantz 	size_t cursor_age;
83fb1d9738SJakob Bornecrantz 
84fb1d9738SJakob Bornecrantz 	int cursor_x;
85fb1d9738SJakob Bornecrantz 	int cursor_y;
86fb1d9738SJakob Bornecrantz 
87fb1d9738SJakob Bornecrantz 	int hotspot_x;
88fb1d9738SJakob Bornecrantz 	int hotspot_y;
89fb1d9738SJakob Bornecrantz 
90fb1d9738SJakob Bornecrantz 	unsigned unit;
91626ab771SJakob Bornecrantz 
92626ab771SJakob Bornecrantz 	/*
93626ab771SJakob Bornecrantz 	 * Prefered mode tracking.
94626ab771SJakob Bornecrantz 	 */
95626ab771SJakob Bornecrantz 	unsigned pref_width;
96626ab771SJakob Bornecrantz 	unsigned pref_height;
97626ab771SJakob Bornecrantz 	bool pref_active;
98626ab771SJakob Bornecrantz 	struct drm_display_mode *pref_mode;
99cd2b89e7SThomas Hellstrom 
100cd2b89e7SThomas Hellstrom 	/*
101cd2b89e7SThomas Hellstrom 	 * Gui positioning
102cd2b89e7SThomas Hellstrom 	 */
103cd2b89e7SThomas Hellstrom 	int gui_x;
104cd2b89e7SThomas Hellstrom 	int gui_y;
105*6987427aSThomas Hellstrom 	bool is_implicit;
106fb1d9738SJakob Bornecrantz };
107fb1d9738SJakob Bornecrantz 
1082fcd5a73SJakob Bornecrantz #define vmw_crtc_to_du(x) \
1092fcd5a73SJakob Bornecrantz 	container_of(x, struct vmw_display_unit, crtc)
110626ab771SJakob Bornecrantz #define vmw_connector_to_du(x) \
111626ab771SJakob Bornecrantz 	container_of(x, struct vmw_display_unit, connector)
112626ab771SJakob Bornecrantz 
113626ab771SJakob Bornecrantz 
114fb1d9738SJakob Bornecrantz /*
115fb1d9738SJakob Bornecrantz  * Shared display unit functions - vmwgfx_kms.c
116fb1d9738SJakob Bornecrantz  */
117fb1d9738SJakob Bornecrantz void vmw_display_unit_cleanup(struct vmw_display_unit *du);
118626ab771SJakob Bornecrantz void vmw_du_crtc_save(struct drm_crtc *crtc);
119626ab771SJakob Bornecrantz void vmw_du_crtc_restore(struct drm_crtc *crtc);
120626ab771SJakob Bornecrantz void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
121626ab771SJakob Bornecrantz 			   u16 *r, u16 *g, u16 *b,
122626ab771SJakob Bornecrantz 			   uint32_t start, uint32_t size);
123fb1d9738SJakob Bornecrantz int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
124fb1d9738SJakob Bornecrantz 			   uint32_t handle, uint32_t width, uint32_t height);
125fb1d9738SJakob Bornecrantz int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
126626ab771SJakob Bornecrantz void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
127626ab771SJakob Bornecrantz void vmw_du_connector_save(struct drm_connector *connector);
128626ab771SJakob Bornecrantz void vmw_du_connector_restore(struct drm_connector *connector);
129626ab771SJakob Bornecrantz enum drm_connector_status
130626ab771SJakob Bornecrantz vmw_du_connector_detect(struct drm_connector *connector, bool force);
131626ab771SJakob Bornecrantz int vmw_du_connector_fill_modes(struct drm_connector *connector,
132626ab771SJakob Bornecrantz 				uint32_t max_width, uint32_t max_height);
133626ab771SJakob Bornecrantz int vmw_du_connector_set_property(struct drm_connector *connector,
134626ab771SJakob Bornecrantz 				  struct drm_property *property,
135626ab771SJakob Bornecrantz 				  uint64_t val);
136cd2b89e7SThomas Hellstrom 
137fb1d9738SJakob Bornecrantz 
138fb1d9738SJakob Bornecrantz /*
139d8bd19d2SJakob Bornecrantz  * Legacy display unit functions - vmwgfx_ldu.c
140fb1d9738SJakob Bornecrantz  */
141fb1d9738SJakob Bornecrantz int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv);
142fb1d9738SJakob Bornecrantz int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv);
143fb1d9738SJakob Bornecrantz 
14456d1c78dSJakob Bornecrantz /*
14556d1c78dSJakob Bornecrantz  * Screen Objects display functions - vmwgfx_scrn.c
14656d1c78dSJakob Bornecrantz  */
14756d1c78dSJakob Bornecrantz int vmw_kms_init_screen_object_display(struct vmw_private *dev_priv);
14856d1c78dSJakob Bornecrantz int vmw_kms_close_screen_object_display(struct vmw_private *dev_priv);
14956d1c78dSJakob Bornecrantz int vmw_kms_sou_update_layout(struct vmw_private *dev_priv, unsigned num,
15056d1c78dSJakob Bornecrantz 			      struct drm_vmw_rect *rects);
15156d1c78dSJakob Bornecrantz 
152fb1d9738SJakob Bornecrantz #endif
153