blob: 055b844bd80f718cc09962afea0e645ce23ccd15 [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"
Jesse Barnes308e5bc2011-11-14 14:51:28 -080032#include "drm_crtc_helper.h"
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000033#include "vmwgfx_drv.h"
34
Jakob Bornecrantz56d1c782011-10-04 20:13:22 +020035#define VMWGFX_NUM_DISPLAY_UNITS 8
36
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000037
38#define vmw_framebuffer_to_vfb(x) \
39 container_of(x, struct vmw_framebuffer, base)
40
41/**
42 * Base class for framebuffers
43 *
44 * @pin is called the when ever a crtc uses this framebuffer
45 * @unpin is called
46 */
47struct vmw_framebuffer {
48 struct drm_framebuffer base;
49 int (*pin)(struct vmw_framebuffer *fb);
50 int (*unpin)(struct vmw_framebuffer *fb);
Jakob Bornecrantz2fcd5a72011-10-04 20:13:26 +020051 bool dmabuf;
Thomas Hellstrom90ff18b2011-10-04 20:13:32 +020052 struct ttm_base_object *user_obj;
53 uint32_t user_handle;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +000054};
55
56
57#define vmw_crtc_to_du(x) \
58 container_of(x, struct vmw_display_unit, crtc)
59
60/*
61 * Basic cursor manipulation
62 */
63int vmw_cursor_update_image(struct vmw_private *dev_priv,
64 u32 *image, u32 width, u32 height,
65 u32 hotspotX, u32 hotspotY);
66void vmw_cursor_update_position(struct vmw_private *dev_priv,
67 bool show, int x, int y);
68
69/**
70 * Base class display unit.
71 *
72 * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
73 * so the display unit is all of them at the same time. This is true for both
74 * legacy multimon and screen objects.
75 */
76struct vmw_display_unit {
77 struct drm_crtc crtc;
78 struct drm_encoder encoder;
79 struct drm_connector connector;
80
81 struct vmw_surface *cursor_surface;
82 struct vmw_dma_buffer *cursor_dmabuf;
83 size_t cursor_age;
84
85 int cursor_x;
86 int cursor_y;
87
88 int hotspot_x;
89 int hotspot_y;
90
91 unsigned unit;
Jakob Bornecrantz626ab772011-10-04 20:13:20 +020092
93 /*
94 * Prefered mode tracking.
95 */
96 unsigned pref_width;
97 unsigned pref_height;
98 bool pref_active;
99 struct drm_display_mode *pref_mode;
Thomas Hellstromcd2b89e2011-10-25 23:35:53 +0200100
101 /*
102 * Gui positioning
103 */
104 int gui_x;
105 int gui_y;
Thomas Hellstrom69874272011-11-02 09:43:11 +0100106 bool is_implicit;
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000107};
108
Jakob Bornecrantz2fcd5a72011-10-04 20:13:26 +0200109#define vmw_crtc_to_du(x) \
110 container_of(x, struct vmw_display_unit, crtc)
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200111#define vmw_connector_to_du(x) \
112 container_of(x, struct vmw_display_unit, connector)
113
114
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000115/*
116 * Shared display unit functions - vmwgfx_kms.c
117 */
118void vmw_display_unit_cleanup(struct vmw_display_unit *du);
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200119void vmw_du_crtc_save(struct drm_crtc *crtc);
120void vmw_du_crtc_restore(struct drm_crtc *crtc);
121void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
122 u16 *r, u16 *g, u16 *b,
123 uint32_t start, uint32_t size);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000124int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
125 uint32_t handle, uint32_t width, uint32_t height);
126int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
Jakob Bornecrantz626ab772011-10-04 20:13:20 +0200127void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
128void vmw_du_connector_save(struct drm_connector *connector);
129void vmw_du_connector_restore(struct drm_connector *connector);
130enum drm_connector_status
131vmw_du_connector_detect(struct drm_connector *connector, bool force);
132int vmw_du_connector_fill_modes(struct drm_connector *connector,
133 uint32_t max_width, uint32_t max_height);
134int vmw_du_connector_set_property(struct drm_connector *connector,
135 struct drm_property *property,
136 uint64_t val);
Thomas Hellstromcd2b89e2011-10-25 23:35:53 +0200137
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000138
139/*
Jakob Bornecrantzd8bd19d2010-06-01 11:54:20 +0200140 * Legacy display unit functions - vmwgfx_ldu.c
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000141 */
142int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv);
143int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv);
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000144
Jakob Bornecrantz56d1c782011-10-04 20:13:22 +0200145/*
146 * Screen Objects display functions - vmwgfx_scrn.c
147 */
148int vmw_kms_init_screen_object_display(struct vmw_private *dev_priv);
149int vmw_kms_close_screen_object_display(struct vmw_private *dev_priv);
150int vmw_kms_sou_update_layout(struct vmw_private *dev_priv, unsigned num,
151 struct drm_vmw_rect *rects);
152
Jakob Bornecrantzfb1d9732009-12-10 00:19:58 +0000153#endif