Merge branch 'devel/dri3' into devel/tizen
[platform/adaptation/samsung_exynos/xf86-video-exynos.git] / src / crtcconfig / sec_display.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_DISPLAY_H__
32 #define __SEC_DISPLAY_H__
33
34 #include <xf86drmMode.h>
35 #include <xf86Crtc.h>
36 #include <tbm_bufmgr.h>
37 #include <list.h>
38
39 #define DBG_DRM_EVENT 1
40
41 typedef enum
42 {
43     DISPLAY_SET_MODE_OFF,
44     DISPLAY_SET_MODE_CLONE,
45     DISPLAY_SET_MODE_EXT,
46 } SECDisplaySetMode;
47
48 typedef enum
49 {
50     DISPLAY_CONN_MODE_NONE,
51     DISPLAY_CONN_MODE_LVDS,
52     DISPLAY_CONN_MODE_HDMI,
53     DISPLAY_CONN_MODE_VIRTUAL,
54     DISPLAY_CONN_MODE_DUMMY,
55     DISPLAY_CONN_MODE_MAX,
56 } SECDisplayConnMode;
57
58 typedef enum
59 {
60     VBLNAK_INFO_NONE,
61     VBLANK_INFO_SWAP,
62     VBLANK_INFO_PLANE,
63     VBLANK_INFO_PRESENT,
64     VBLANK_INFO_MAX
65 } SECVBlankInfoType;
66
67 typedef struct _secDrmEventContext {
68     void (*vblank_handler) (int fd,
69                             unsigned int sequence,
70                             unsigned int tv_sec,
71                             unsigned int tv_usec,
72                             void *user_data);
73
74     void (*page_flip_handler) (int fd,
75                                unsigned int sequence,
76                                unsigned int tv_sec,
77                                unsigned int tv_usec,
78                                void *user_data);
79
80     void (*g2d_handler) (int fd,
81                          unsigned int cmdlist_no,
82                          unsigned int tv_sec,
83                          unsigned int tv_usec,
84                          void *user_data);
85
86     void (*ipp_handler) (int fd,
87                          unsigned int  prop_id,
88                          unsigned int *buf_idx,
89                          unsigned int  tv_sec,
90                          unsigned int  tv_usec,
91                          void *user_data);
92 } secDrmEventContext, *secDrmEventContextPtr;
93
94 typedef struct _secDrmMode
95 {
96     int type;
97     int fd;
98     drmModeResPtr mode_res;
99     drmModePlaneResPtr plane_res;
100     int cpp;
101     drmModeModeInfo main_lcd_mode;
102     drmModeModeInfo ext_connector_mode;
103
104     secDrmEventContext event_context;
105
106     struct xorg_list outputs;
107     struct xorg_list crtcs;
108     struct xorg_list planes;
109 #ifdef NO_CRTC_MODE
110     int num_dummy_output;
111     int num_real_output;
112     int num_real_crtc;
113     int num_dummy_crtc;
114 #endif
115     SECDisplaySetMode  set_mode;
116     SECDisplayConnMode conn_mode;
117     int                rotate;
118
119     int unset_connector_type;
120 } SECModeRec, *SECModePtr;
121
122 typedef void (*SECFlipEventHandler) (unsigned int frame, unsigned int tv_exynos,
123                                  unsigned int tv_uexynos, void *event_data, Bool flip_failed);
124
125 typedef struct _secPageFlip
126 {
127     xf86CrtcPtr pCrtc;
128     Bool dispatch_me;
129     Bool clone;
130     Bool flip_failed;
131
132     tbm_bo back_bo;
133     tbm_bo accessibility_back_bo;
134
135     void *data;
136     CARD32 time;
137
138     SECFlipEventHandler handler;
139
140 #if DBG_DRM_EVENT
141     void *xdbg_log_pageflip;
142 #endif
143 } SECPageFlipRec, *SECPageFlipPtr;
144
145 typedef struct _secVBlankInfo
146 {
147     SECVBlankInfoType type;
148     void *data; /* request data pointer */
149     CARD32 time;
150
151 #if DBG_DRM_EVENT
152     void *xdbg_log_vblank;
153 #endif
154 } SECVBlankInfoRec, *SECVBlankInfoPtr;
155
156 typedef struct _secProperty
157 {
158     drmModePropertyPtr mode_prop;
159     uint64_t value;
160     int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
161     Atom *atoms;
162 } SECPropertyRec, *SECPropertyPtr;
163
164 Bool        secModePreInit (ScrnInfoPtr pScrn, int drm_fd);
165 void        secModeInit (ScrnInfoPtr pScrn);
166 void        secModeDeinit (ScrnInfoPtr pScrn);
167 xf86CrtcPtr secModeCoveringCrtc (ScrnInfoPtr pScrn, BoxPtr pBox, xf86CrtcPtr pDesiredCrtc, BoxPtr pBoxCrtc);
168 int         secModeGetCrtcPipe (xf86CrtcPtr pCrtc);
169 Bool        secModePageFlip (ScrnInfoPtr pScrn, xf86CrtcPtr pCrtc, void* flip_info, int pipe, tbm_bo back_bo, RegionPtr pFlipRegion, unsigned int client_idx, XID drawable_id, SECFlipEventHandler handler);
170 void        secModeLoadPalette (ScrnInfoPtr pScrn, int numColors, int* indices, LOCO* colors, VisualPtr pVisual);
171
172 void        secDisplaySwapModeFromKmode(ScrnInfoPtr pScrn, drmModeModeInfoPtr kmode, DisplayModePtr     pMode);
173 void        secDisplayModeFromKmode(ScrnInfoPtr pScrn, drmModeModeInfoPtr kmode, DisplayModePtr pMode);
174 void        secDisplaySwapModeToKmode(ScrnInfoPtr pScrn, drmModeModeInfoPtr kmode, DisplayModePtr pMode);
175 void        secDisplayModeToKmode(ScrnInfoPtr pScrn, drmModeModeInfoPtr kmode, DisplayModePtr pMode);
176
177 Bool               secDisplaySetDispSetMode  (ScrnInfoPtr pScrn, SECDisplaySetMode disp_mode);
178 SECDisplaySetMode  secDisplayGetDispSetMode  (ScrnInfoPtr pScrn);
179 Bool               secDisplaySetDispRotate   (ScrnInfoPtr pScrn, int disp_rotate);
180 int                secDisplayGetDispRotate   (ScrnInfoPtr pScrn);
181 Bool               secDisplaySetDispConnMode (ScrnInfoPtr pScrn, SECDisplayConnMode disp_conn);
182 SECDisplayConnMode secDisplayGetDispConnMode (ScrnInfoPtr pScrn);
183
184 Bool secDisplayInitDispMode (ScrnInfoPtr pScrn, SECDisplayConnMode conn_mode);
185 void secDisplayDeinitDispMode (ScrnInfoPtr pScrn);
186
187 Bool secDisplayGetCurMSC (ScrnInfoPtr pScrn, int pipe, CARD64 *ust, CARD64 *msc);
188 Bool secDisplayVBlank (ScrnInfoPtr pScrn, int pipe, CARD64 *target_msc, int flip, SECVBlankInfoType type, void *vblank_info);
189 int secDisplayDrawablePipe (DrawablePtr pDraw);
190
191 int secDisplayCrtcPipe (ScrnInfoPtr pScrn, int crtc_id);
192
193 Bool secDisplayUpdateRequest(ScrnInfoPtr pScrn);
194 #ifdef NO_CRTC_MODE
195 Bool secDisplayChangeMode (ScrnInfoPtr pScrn);
196 #endif
197 #endif /* __SEC_DISPLAY_H__ */
198