6 #include "ecore_fb_private.h"
8 static void _ecore_fb_size_get(int *w, int *h);
10 static int _ecore_fb_init_count = 0;
11 static int _ecore_fb_console_w = 0;
12 static int _ecore_fb_console_h = 0;
15 * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
20 static sighandler_t oldhand = NULL;
23 nosigint(int val __UNUSED__)
28 * @brief Initialize the Ecore_Fb library.
30 * @param name Device target name.
31 * @return 1 or greater on success, 0 on error.
33 * This function sets up all the Ecore_Fb library. It returns 0 on
34 * failure, otherwise it returns the number of times it has already
37 * When Ecore_Fb is not used anymore, call ecore_fb_shutdown() to shut down
38 * the Ecore_Fb library.
41 ecore_fb_init(const char *name __UNUSED__)
43 if (++_ecore_fb_init_count != 1)
44 return _ecore_fb_init_count;
46 if (!ecore_fb_vt_init())
47 return --_ecore_fb_init_count;
51 oldhand = signal(SIGINT, nosigint);
54 _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
56 return _ecore_fb_init_count;
60 * @brief Shut down the Ecore_Fb library.
62 * @return 0 when the library is completely shut down, 1 or
65 * This function shuts down the Ecore_Fb library. It returns 0 when it has
66 * been called the same number of times than ecore_fb_init().
69 ecore_fb_shutdown(void)
71 if (--_ecore_fb_init_count != 0)
72 return _ecore_fb_init_count;
76 signal(SIGINT, oldhand);
80 ecore_fb_vt_shutdown();
82 return _ecore_fb_init_count;
87 * @brief Retrieve the width and height of the current frame buffer in
90 * @param w Pointer to an integer in which to store the width.
91 * @param h Pointer to an interge in which to store the height.
93 * This function retrieves the size of the current frame buffer in
94 * pixels. @p w and @p h can be buffers that will be filled with the
95 * corresponding values. If one of them is @c NULL, nothing will be
96 * done for that parameter.
99 ecore_fb_size_get(int *w, int *h)
101 if (w) *w = _ecore_fb_console_w;
102 if (h) *h = _ecore_fb_console_h;
106 _ecore_fb_size_get(int *w, int *h)
108 struct fb_var_screeninfo fb_var;
111 fb = open("/dev/fb0", O_RDWR);
115 if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)