1 /**************************************************************************
3 xserver-xorg-video-emulfb
5 Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>
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:
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial portions
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.
29 **************************************************************************/
42 #include <X11/Xatom.h>
47 #include "fbdev_crtc_priv.h"
48 #include "fbdev_util.h"
51 #include "xf86Xinput.h"
54 /********************************************************************************************/
55 /* Implementation of Crtc entry points */
56 /********************************************************************************************/
58 * Turns the crtc on/off, or sets intermediate power levels if available.
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.
64 static void fbdev_crtc_dpms(xf86CrtcPtr crtc, int mode)
70 * Lock CRTC prior to mode setting, mostly for DRI.
71 * Returns whether unlock is needed
73 static Bool fbdev_crtc_lock(xf86CrtcPtr crtc)
76 /* check whether unlock is needed */
81 * Lock CRTC prior to mode setting, mostly for DRI.
82 * Returns whether unlock is needed
84 static void fbdev_crtc_unlock(xf86CrtcPtr crtc)
91 * Callback to adjust the mode to be set in the CRTC.
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.
97 static Bool fbdev_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
98 DisplayModePtr adjusted_mode)
104 * Prepare CRTC for an upcoming mode set.
106 static void fbdev_crtc_prepare(xf86CrtcPtr crtc)
112 * Callback for setting up a video mode after fixups have been made.
114 static void fbdev_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
115 DisplayModePtr adjusted_mode, int x, int y)
121 * Commit mode changes to a CRTC
123 static void fbdev_crtc_commit(xf86CrtcPtr crtc)
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)
138 void fbdev_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
144 * Set cursor position
146 void fbdev_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
155 void fbdev_crtc_show_cursor(xf86CrtcPtr crtc)
164 void fbdev_crtc_hide_cursor(xf86CrtcPtr crtc)
173 void fbdev_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
180 * Less fine-grained mode setting entry point for kernel modesetting
182 Bool fbdev_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
183 Rotation rotation, int x, int y)
190 * Callback for panning. Doesn't change the mode.
191 * Added in ABI version 2
193 static void fbdev_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
195 xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "set_origin: unimplemented");
196 return; /* XXX implement */
200 static const xf86CrtcFuncsRec fbdev_crtc_funcs =
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,
209 .prepare = fbdev_crtc_prepare,
210 .mode_set = fbdev_crtc_mode_set,
211 .commit = fbdev_crtc_commit,
212 .gamma_set = fbdev_crtc_gamma_set,
214 .shadow_create = NULL,
215 .shadow_allocate = NULL,
216 .shadow_destroy = NULL,
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,
230 void FBDevCrtcInit(ScrnInfoPtr pScrn, int num)
233 FBDevCrtcPrivPtr fbdev_crtc;
235 crtc = xf86CrtcCreate (pScrn, &fbdev_crtc_funcs);
239 fbdev_crtc = xnfcalloc (sizeof (FBDevCrtcPriv), 1);
242 xf86CrtcDestroy (crtc);
246 crtc->driver_private = fbdev_crtc;