vmwgfx: Refactor common display unit functions to shared file
[deliverable/linux.git] / drivers / gpu / drm / vmwgfx / vmwgfx_kms.h
1 /**************************************************************************
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
34
35 #define vmw_framebuffer_to_vfb(x) \
36 container_of(x, struct vmw_framebuffer, base)
37
38 /**
39 * Base class for framebuffers
40 *
41 * @pin is called the when ever a crtc uses this framebuffer
42 * @unpin is called
43 */
44 struct vmw_framebuffer {
45 struct drm_framebuffer base;
46 int (*pin)(struct vmw_framebuffer *fb);
47 int (*unpin)(struct vmw_framebuffer *fb);
48 };
49
50
51 #define vmw_crtc_to_du(x) \
52 container_of(x, struct vmw_display_unit, crtc)
53
54 /*
55 * Basic cursor manipulation
56 */
57 int vmw_cursor_update_image(struct vmw_private *dev_priv,
58 u32 *image, u32 width, u32 height,
59 u32 hotspotX, u32 hotspotY);
60 void vmw_cursor_update_position(struct vmw_private *dev_priv,
61 bool show, int x, int y);
62
63 /**
64 * Base class display unit.
65 *
66 * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
67 * so the display unit is all of them at the same time. This is true for both
68 * legacy multimon and screen objects.
69 */
70 struct vmw_display_unit {
71 struct drm_crtc crtc;
72 struct drm_encoder encoder;
73 struct drm_connector connector;
74
75 struct vmw_surface *cursor_surface;
76 struct vmw_dma_buffer *cursor_dmabuf;
77 size_t cursor_age;
78
79 int cursor_x;
80 int cursor_y;
81
82 int hotspot_x;
83 int hotspot_y;
84
85 unsigned unit;
86
87 /*
88 * Prefered mode tracking.
89 */
90 unsigned pref_width;
91 unsigned pref_height;
92 bool pref_active;
93 struct drm_display_mode *pref_mode;
94 };
95
96 #define vmw_connector_to_du(x) \
97 container_of(x, struct vmw_display_unit, connector)
98
99
100 /*
101 * Shared display unit functions - vmwgfx_kms.c
102 */
103 void vmw_display_unit_cleanup(struct vmw_display_unit *du);
104 void vmw_du_crtc_save(struct drm_crtc *crtc);
105 void vmw_du_crtc_restore(struct drm_crtc *crtc);
106 void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
107 u16 *r, u16 *g, u16 *b,
108 uint32_t start, uint32_t size);
109 int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
110 uint32_t handle, uint32_t width, uint32_t height);
111 int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
112 void vmw_du_connector_dpms(struct drm_connector *connector, int mode);
113 void vmw_du_connector_save(struct drm_connector *connector);
114 void vmw_du_connector_restore(struct drm_connector *connector);
115 enum drm_connector_status
116 vmw_du_connector_detect(struct drm_connector *connector, bool force);
117 int vmw_du_connector_fill_modes(struct drm_connector *connector,
118 uint32_t max_width, uint32_t max_height);
119 int vmw_du_connector_set_property(struct drm_connector *connector,
120 struct drm_property *property,
121 uint64_t val);
122 int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
123 struct drm_vmw_rect *rects);
124
125 /*
126 * Legacy display unit functions - vmwgfx_ldu.c
127 */
128 int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv);
129 int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv);
130
131 #endif
This page took 0.038049 seconds and 5 git commands to generate.