Tizen 2.1 base
[adaptation/xorg/driver/xserver-xorg-video-emulfb.git] / src / util / fbdev_util.h
1 /**************************************************************************
2
3 xserver-xorg-video-emulfb
4
5 Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact: YoungHoon Jung <yhoon.jung@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 __FBDEV_UTIL_H__
32 #define __FBDEV_UTIL_H__
33
34 #include "property.h"
35
36 #ifndef CLEAR
37 #define CLEAR(x) memset(&(x), 0, sizeof (x))
38 #endif
39
40 #ifndef MAX
41 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
42 #endif
43 #ifndef MIN
44 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
45 #endif
46
47 #ifndef SWAP
48 #define SWAP(a, b)  ({int t; t = a; a = b; b = t;})
49 #endif
50
51 #ifndef FALSE
52 #define FALSE 0
53 #endif
54
55 #ifndef TRUE
56 #define TRUE 1
57 #endif
58
59 void drvlog (const char * f, ...);
60
61 //#define ENABLE_DEBUG 1
62
63 #if ENABLE_DEBUG
64 #define DRVLOG(fmt, arg...)      drvlog(fmt, ##arg)
65 #else
66 #define DRVLOG(fmt, arg...)      {;}
67 #endif
68
69 #define return_if_fail(cond)          {if (!(cond)) { ErrorF ("%s : '%s' failed.\n", __FUNCTION__, #cond); return; }}
70 #define return_val_if_fail(cond, val) {if (!(cond)) { ErrorF ("%s : '%s' failed.\n", __FUNCTION__, #cond); return val; }}
71 #define goto_if_fail(cond, dst)       {if (!(cond)) { ErrorF ("%s : '%s' failed.\n", __FUNCTION__, #cond); goto dst; }}
72
73 int fbdev_util_degree_to_rotate(int degree);
74 int fbdev_util_rotate_to_degree(int rotate);
75 int fbdev_util_rotate_add(int rot_a, int rot_b);
76
77 void fbdev_util_rotate_rect (int xres, int yres, int src_rot, int dst_rot, xRectangle *src);
78
79 const PropertyPtr fbdev_util_get_window_property(WindowPtr pWin, const char* prop_name);
80 void fbdev_util_align_rect (int src_w, int src_h, int dst_w, int dst_h, xRectangle *fit, Bool hw);
81
82 #endif  /* __FBDEV_UTIL_H__ */