Merge branch 'devel/dri3' into devel/tizen
[platform/adaptation/samsung_exynos/xf86-video-exynos.git] / src / sec.h
1 /**************************************************************************
2
3 xserver-xorg-video-exynos
4
5 Copyright 2011 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact: SooChan Lim <sc1.lim@samsung.com>
8
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sub license, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial portions
19 of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 **************************************************************************/
30
31 #ifndef SEC_H
32 #define SEC_H
33
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
37
38 #include <stdint.h>
39 #include "xorg-server.h"
40 #include "xf86.h"
41 #include "xf86xv.h"
42 #include "xf86_OSproc.h"
43 #include "xf86drm.h"
44 #include "X11/Xatom.h"
45 #include "tbm_bufmgr.h"
46 #include "sec_display.h"
47 #include "sec_accel.h"
48 #include "sec_video.h"
49 #include "sec_wb.h"
50 #include "sec_util.h"
51 #if HAVE_UDEV
52 #include <libudev.h>
53 #endif
54
55 #define USE_XDBG 1
56
57 /* drm bo data type */
58 typedef enum
59 {
60     TBM_BO_DATA_FB = 1,
61 } TBM_BO_DATA;
62
63 /* framebuffer infomation */
64 typedef struct
65 {
66     ScrnInfoPtr pScrn;
67
68     int width;
69     int height;
70
71     int num_bo;
72     struct xorg_list list_bo;
73     void* tbl_bo;               /* bo hash table: key=(x,y)position */
74
75     tbm_bo default_bo;
76 } SECFbRec, *SECFbPtr;
77
78 /* framebuffer bo data */
79 typedef struct
80 {
81     SECFbPtr pFb;
82     BoxRec pos;
83     uint32_t gem_handle;
84     int fb_id;
85     int pitch;
86     int size;
87     PixmapPtr   pPixmap;
88     ScrnInfoPtr pScrn;
89 } SECFbBoDataRec, *SECFbBoDataPtr;
90
91 /* sec screen private information */
92 typedef struct
93 {
94     EntityInfoPtr pEnt;
95     Bool fake_root; /* screen rotation status */
96
97     /* driver options */
98     OptionInfoPtr Options;
99     Bool is_exa;
100     Bool is_dri2;
101     Bool is_present;
102     Bool is_dri3;
103     Bool is_sw_exa;
104     Bool is_accel_2d;
105     Bool is_wb_clone;
106     Bool is_tfb;        /* triple flip buffer */
107     Bool cachable;      /* if use cachable buffer */
108     Bool scanout;       /* if use scanout buffer */
109     int flip_bufs;      /* number of the flip buffers */
110     Rotation rotate;
111     Bool use_partial_update;
112     Bool is_fb_touched; /* whether framebuffer is touched or not */
113
114     /* drm */
115     int drm_fd;
116     char *drm_device_name;
117     tbm_bufmgr tbm_bufmgr;
118
119     /* main fb information */
120     SECFbPtr pFb;
121
122     /* mode setting info private */
123     SECModePtr pSecMode;
124
125     /* exa private */
126     SECExaPrivPtr pExaPriv;
127
128     /* video private */
129     SECVideoPrivPtr pVideoPriv;
130
131     Bool isLcdOff; /* lvds connector on/off status */
132 #ifdef NO_CRTC_MODE
133     Bool isCrtcOn; /* Global crtc status */
134 #endif
135     /* screen wrapper functions */
136     CloseScreenProcPtr CloseScreen;
137     CreateScreenResourcesProcPtr CreateScreenResources;
138
139 #if HAVE_UDEV
140     struct udev_monitor *uevent_monitor;
141     InputHandlerProc uevent_handler;
142 #endif
143
144     /* DRI2 */
145     Atom atom_use_dri2;
146     Bool useAsyncSwap;
147     DrawablePtr flipDrawable;
148
149     /* pending flip handler cause of lcd off */
150     Bool pending_flip_handler;
151     unsigned int frame;
152     unsigned int tv_sec;
153     unsigned int tv_usec;
154     void *event_data;
155
156     /* overlay drawable */
157     DamagePtr ovl_damage;
158     DrawablePtr ovl_drawable;
159
160     SECDisplaySetMode set_mode;
161     OsTimerPtr resume_timer;
162
163     SECWb *wb_clone;
164     Bool   wb_fps;
165     int    wb_hz;
166
167     /* Cursor */
168     Bool enableCursor;
169
170     /* dump */
171     int dump_mode;
172     long dump_xid;
173     void *dump_info;
174     char *dump_str;
175     char dump_type[16];
176     int   xvperf_mode;
177     char *xvperf;
178
179     int scale;
180     int cpu;
181     int flip_cnt;
182
183     /* mem debug
184        Normal pixmap
185        CREATE_PIXMAP_USAGE_BACKING_PIXMAP
186        CREATE_PIXMAP_USAGE_OVERLAY
187        CREATE_PIXMAP_USAGE_XVIDEO
188        CREATE_PIXMAP_USAGE_DRI2_FILP_BACK
189        CREATE_PIXMAP_USAGE_FB
190        CREATE_PIXMAP_USAGE_SUB_FB
191        CREATE_PIXMAP_USAGE_DRI2_BACK
192      */
193     int pix_normal;
194     int pix_backing_pixmap;
195     int pix_overlay;
196     int pix_dri2_flip_back;
197     int pix_fb;
198     int pix_sub_fb;
199     int pix_dri2_back;
200 } SECRec, *SECPtr;
201
202 /* get a private screen of ScrnInfo */
203 #define SECPTR(p) ((SECPtr)((p)->driverPrivate))
204
205 /* the version of the driver */
206 #define SEC_VERSION 1000
207
208 /* the name used to prefix messages */
209 #define SEC_NAME "exynos"
210
211 /* the driver name used in display.conf file. exynos_drv.so */
212 #define SEC_DRIVER_NAME "exynos"
213
214 #define ROOT_FB_ADDR (~0UL)
215
216 #define SEC_CURSOR_W 128
217 #define SEC_CURSOR_H 128
218
219 /* sec framebuffer */
220 SECFbPtr      secFbAllocate      (ScrnInfoPtr pScrn, int width, int height);
221 void          secFbFree          (SECFbPtr pFb);
222 void          secFbResize        (SECFbPtr pFb, int width, int height);
223 tbm_bo    secFbGetBo         (SECFbPtr pFb, int x, int y, int width, int height, Bool onlyIfExists);
224 int           secFbFindBo        (SECFbPtr pFb, int x, int y, int width, int height, int *num_bo, tbm_bo** bos);
225 tbm_bo    secFbFindBoByPoint (SECFbPtr pFb, int x, int y);
226 tbm_bo    secFbSwapBo        (SECFbPtr pFb, tbm_bo back_bo);
227
228 tbm_bo    secRenderBoCreate    (ScrnInfoPtr pScrn, int width, int height);
229 int       secSwapToRenderBo        (ScrnInfoPtr pScrn, int width, int height, tbm_bo carr_bo);
230 tbm_bo    secRenderBoRef       (tbm_bo bo);
231 void          secRenderBoUnref     (tbm_bo bo);
232 void          secRenderBoSetPos    (tbm_bo bo, int x, int y);
233 PixmapPtr     secRenderBoGetPixmap (SECFbPtr pFb, tbm_bo bo);
234
235 #endif /* SEC_H */