Tizen 2.1 base
[adaptation/xorg/driver/xserver-xorg-video-emulfb.git] / src / crtcconfig / fbdev_crtc.c
1 /**************************************************************************
2
3 xserver-xorg-video-emulfb
4
5 Copyright 2010 - 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 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34
35 #include <unistd.h>
36 #include <sys/mman.h>
37 #include <errno.h>
38 #include <math.h>
39
40 #include "xace.h"
41 #include "xacestr.h"
42 #include <X11/Xatom.h>
43
44 #include "fbdev.h"
45 #include "fbdevhw.h"
46 #include "fbdev_hw.h"
47 #include "fbdev_crtc_priv.h"
48 #include "fbdev_util.h"
49
50 #include "xf86Crtc.h"
51 #include "xf86Xinput.h"
52 #include "exevents.h"
53
54 /********************************************************************************************/
55 /* Implementation of Crtc entry points */
56 /********************************************************************************************/
57 /**
58   * Turns the crtc on/off, or sets intermediate power levels if available.
59   *
60   * Unsupported intermediate modes drop to the lower power setting.  If the
61   * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
62   * be safe to call mode_set.
63   */
64 static void fbdev_crtc_dpms(xf86CrtcPtr crtc, int mode)
65 {
66         return;
67 }
68
69 /**
70   * Lock CRTC prior to mode setting, mostly for DRI.
71   * Returns whether unlock is needed
72   */
73 static Bool fbdev_crtc_lock(xf86CrtcPtr crtc)
74 {
75
76         /* check whether unlock is needed */
77         return TRUE;
78 }
79
80 /**
81   * Lock CRTC prior to mode setting, mostly for DRI.
82   * Returns whether unlock is needed
83   */
84 static void fbdev_crtc_unlock(xf86CrtcPtr crtc)
85 {
86         return;
87 }
88
89
90 /**
91   * Callback to adjust the mode to be set in the CRTC.
92   *
93   * This allows a CRTC to adjust the clock or even the entire set of
94   * timings, which is used for panels with fixed timings or for
95   * buses with clock limitations.
96   */
97 static Bool fbdev_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
98                                  DisplayModePtr adjusted_mode)
99 {
100         return TRUE;
101 }
102
103 /**
104   * Prepare CRTC for an upcoming mode set.
105   */
106 static void fbdev_crtc_prepare(xf86CrtcPtr crtc)
107 {
108
109 }
110
111 /**
112   * Callback for setting up a video mode after fixups have been made.
113   */
114 static void fbdev_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
115                                DisplayModePtr adjusted_mode, int x, int y)
116 {
117
118 }
119
120 /**
121   * Commit mode changes to a CRTC
122   */
123 static void fbdev_crtc_commit(xf86CrtcPtr crtc)
124 {
125
126 }
127
128 /* Set the color ramps for the CRTC to the given values. */
129 static void fbdev_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green,
130                                 CARD16 * blue, int size)
131 {
132
133 }
134
135 /**
136   * Set cursor colors
137   */
138 void fbdev_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
139 {
140         return;
141 }
142
143 /**
144   * Set cursor position
145   */
146 void fbdev_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
147 {
148
149         return;
150 }
151
152 /**
153   * Show cursor
154   */
155 void fbdev_crtc_show_cursor(xf86CrtcPtr crtc)
156 {
157
158         return;
159 }
160
161 /**
162   * Hide cursor
163   */
164 void fbdev_crtc_hide_cursor(xf86CrtcPtr crtc)
165 {
166
167         return;
168 }
169
170 /**
171   * Load ARGB image
172   */
173 void fbdev_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
174 {
175
176         return;
177 }
178
179 /**
180   * Less fine-grained mode setting entry point for kernel modesetting
181   */
182 Bool fbdev_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
183                               Rotation rotation, int x, int y)
184 {
185         return TRUE;
186 }
187
188
189 /**
190   * Callback for panning. Doesn't change the mode.
191   * Added in ABI version 2
192   */
193 static void fbdev_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
194 {
195         xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "set_origin: unimplemented");
196         return;                 /* XXX implement */
197 }
198
199 /* crtc funcs */
200 static const xf86CrtcFuncsRec fbdev_crtc_funcs =
201 {
202         .dpms = fbdev_crtc_dpms,
203         .save = NULL, /* XXX */
204         .restore = NULL, /* XXX */
205         .lock = fbdev_crtc_lock,
206         .unlock = fbdev_crtc_unlock,
207         .mode_fixup = fbdev_crtc_mode_fixup,
208
209         .prepare = fbdev_crtc_prepare,
210         .mode_set = fbdev_crtc_mode_set,
211         .commit = fbdev_crtc_commit,
212         .gamma_set = fbdev_crtc_gamma_set,
213
214         .shadow_create = NULL,
215         .shadow_allocate = NULL,
216         .shadow_destroy = NULL,
217
218         .set_cursor_colors = fbdev_crtc_set_cursor_colors,
219         .set_cursor_position = fbdev_crtc_set_cursor_position,
220         .show_cursor = fbdev_crtc_show_cursor,
221         .hide_cursor = fbdev_crtc_hide_cursor,
222         .load_cursor_argb = fbdev_crtc_load_cursor_argb,
223         .destroy = NULL, /* XXX */
224         .set_mode_major = NULL, /*???*/
225 #if RANDR_13_INTERFACE
226         .set_origin = fbdev_crtc_set_origin,
227 #endif
228 };
229
230 void FBDevCrtcInit(ScrnInfoPtr pScrn, int num)
231 {
232         xf86CrtcPtr crtc;
233         FBDevCrtcPrivPtr fbdev_crtc;
234
235         crtc = xf86CrtcCreate (pScrn, &fbdev_crtc_funcs);
236         if (crtc == NULL)
237                 return;
238
239         fbdev_crtc = xnfcalloc (sizeof (FBDevCrtcPriv), 1);
240         if (!fbdev_crtc)
241         {
242                 xf86CrtcDestroy (crtc);
243                 return;
244         }
245
246         crtc->driver_private = fbdev_crtc;
247
248 }
249
250