aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_fb/ecore_fb.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/lib/ecore_fb/ecore_fb.c
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/ecore/src/lib/ecore_fb/ecore_fb.c')
-rw-r--r--libraries/ecore/src/lib/ecore_fb/ecore_fb.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_fb/ecore_fb.c b/libraries/ecore/src/lib/ecore_fb/ecore_fb.c
new file mode 100644
index 0000000..ca7d73d
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_fb/ecore_fb.c
@@ -0,0 +1,114 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Ecore_Fb.h"
6#include "ecore_fb_private.h"
7
8static void _ecore_fb_size_get(int *w, int *h);
9
10static int _ecore_fb_init_count = 0;
11static int _ecore_fb_console_w = 0;
12static int _ecore_fb_console_h = 0;
13
14/**
15 * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
16 *
17 * @{
18 */
19
20/**
21 * @brief Initialize the Ecore_Fb library.
22 *
23 * @param name Device target name.
24 * @return 1 or greater on success, 0 on error.
25 *
26 * This function sets up all the Ecore_Fb library. It returns 0 on
27 * failure, otherwise it returns the number of times it has already
28 * been called.
29 *
30 * When Ecore_Fb is not used anymore, call ecore_fb_shutdown() to shut down
31 * the Ecore_Fb library.
32 */
33EAPI int
34ecore_fb_init(const char *name __UNUSED__)
35{
36 if (++_ecore_fb_init_count != 1)
37 return _ecore_fb_init_count;
38
39 if (!ecore_fb_vt_init())
40 return --_ecore_fb_init_count;
41
42 _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
43
44 return _ecore_fb_init_count;
45}
46
47/**
48 * @brief Shut down the Ecore_Fb library.
49 *
50 * @return 0 when the library is completely shut down, 1 or
51 * greater otherwise.
52 *
53 * This function shuts down the Ecore_Fb library. It returns 0 when it has
54 * been called the same number of times than ecore_fb_init().
55 */
56EAPI int
57ecore_fb_shutdown(void)
58{
59 if (--_ecore_fb_init_count != 0)
60 return _ecore_fb_init_count;
61
62 ecore_fb_vt_shutdown();
63
64 return _ecore_fb_init_count;
65}
66
67
68/**
69 * @brief Retrieve the width and height of the current frame buffer in
70 * pixels.
71 *
72 * @param w Pointer to an integer in which to store the width.
73 * @param h Pointer to an interge in which to store the height.
74 *
75 * This function retrieves the size of the current frame buffer in
76 * pixels. @p w and @p h can be buffers that will be filled with the
77 * corresponding values. If one of them is @c NULL, nothing will be
78 * done for that parameter.
79 */
80EAPI void
81ecore_fb_size_get(int *w, int *h)
82{
83 if (w) *w = _ecore_fb_console_w;
84 if (h) *h = _ecore_fb_console_h;
85}
86
87static void
88_ecore_fb_size_get(int *w, int *h)
89{
90 struct fb_var_screeninfo fb_var;
91 int fb;
92
93 fb = open("/dev/fb0", O_RDWR);
94 if (fb < 0)
95 {
96 if (w) *w = 0;
97 if (h) *h = 0;
98 return;
99 }
100 if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
101 {
102 if (w) *w = 0;
103 if (h) *h = 0;
104 close(fb);
105 return;
106 }
107 close(fb);
108 if (w) *w = fb_var.xres;
109 if (h) *h = fb_var.yres;
110}
111
112/**
113 * @}
114 */