Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / gallium / winsys / svga / drm / vmw_screen.h
1 /**********************************************************
2  * Copyright 2009 VMware, Inc.  All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  *
24  **********************************************************/
25
26 /**
27  * @file
28  * Common definitions for the VMware SVGA winsys.
29  *
30  * @author Jose Fonseca <jfonseca@vmware.com>
31  */
32
33
34 #ifndef VMW_SCREEN_H_
35 #define VMW_SCREEN_H_
36
37
38 #include "pipe/p_compiler.h"
39 #include "pipe/p_state.h"
40
41 #include "svga_winsys.h"
42
43
44 #define VMW_GMR_POOL_SIZE (16*1024*1024)
45
46
47 struct pb_manager;
48 struct vmw_region;
49
50
51 struct vmw_winsys_screen
52 {
53    struct svga_winsys_screen base;
54
55    boolean use_old_scanout_flag;
56    uint32_t default_throttle_us;
57
58    struct {
59       volatile uint32_t *fifo_map;
60       uint64_t last_fence;
61       int drm_fd;
62    } ioctl;
63
64    struct {
65       struct pb_manager *gmr;
66       struct pb_manager *gmr_mm;
67       struct pb_manager *gmr_fenced;
68    } pools;
69 };
70
71
72 static INLINE struct vmw_winsys_screen *
73 vmw_winsys_screen(struct svga_winsys_screen *base)
74 {
75    return (struct vmw_winsys_screen *)base;
76 }
77
78 /*  */
79 uint32
80 vmw_ioctl_context_create(struct vmw_winsys_screen *vws);
81
82 void
83 vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws,
84                           uint32 cid);
85
86 uint32
87 vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
88                               SVGA3dSurfaceFlags flags,
89                               SVGA3dSurfaceFormat format,
90                               SVGA3dSize size,
91                               uint32 numFaces,
92                               uint32 numMipLevels);
93
94 void
95 vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws,
96                           uint32 sid);
97
98 void
99 vmw_ioctl_command(struct vmw_winsys_screen *vws,
100                   int32_t cid,
101                   uint32_t throttle_us,
102                   void *commands,
103                   uint32_t size,
104                   uint32_t *fence);
105
106 struct vmw_region *
107 vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size);
108
109 void
110 vmw_ioctl_region_destroy(struct vmw_region *region);
111
112 struct SVGAGuestPtr
113 vmw_ioctl_region_ptr(struct vmw_region *region);
114
115 void *
116 vmw_ioctl_region_map(struct vmw_region *region);
117 void
118 vmw_ioctl_region_unmap(struct vmw_region *region);
119
120
121 int
122 vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
123                        uint32_t fence);
124
125 int
126 vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
127                           uint32_t fence);
128
129
130 /* Initialize parts of vmw_winsys_screen at startup:
131  */
132 boolean vmw_ioctl_init(struct vmw_winsys_screen *vws);
133 boolean vmw_pools_init(struct vmw_winsys_screen *vws);
134 boolean vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws);
135
136 void vmw_ioctl_cleanup(struct vmw_winsys_screen *vws);
137 void vmw_pools_cleanup(struct vmw_winsys_screen *vws);
138
139 struct vmw_winsys_screen *vmw_winsys_create(int fd, boolean use_old_scanout_flag);
140 void vmw_winsys_destroy(struct vmw_winsys_screen *sws);
141 void vmw_winsys_screen_set_throttling(struct pipe_screen *screen,
142                                       uint32_t throttle_us);
143
144 #endif /* VMW_SCREEN_H_ */