#include "Ecore_Fb.h"
#include "ecore_fb_private.h"
+#include <limits.h>
-static void _ecore_fb_size_get(int *w, int *h);
+static void _ecore_fb_size_get(const char *name, int *w, int *h);
static int _ecore_fb_init_count = 0;
static int _ecore_fb_console_w = 0;
* the Ecore_Fb library.
*/
EAPI int
-ecore_fb_init(const char *name EINA_UNUSED)
+ecore_fb_init(const char *name)
{
if (++_ecore_fb_init_count != 1)
return _ecore_fb_init_count;
oldhand = signal(SIGINT, nosigint);
}
- _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
+ _ecore_fb_size_get(name, &_ecore_fb_console_w, &_ecore_fb_console_h);
return _ecore_fb_init_count;
}
}
static void
-_ecore_fb_size_get(int *w, int *h)
+_ecore_fb_size_get(const char *name, int *w, int *h)
{
struct fb_var_screeninfo fb_var;
int fb;
(getuid() == geteuid()) &&
#endif
(getenv("EVAS_FB_DEV")))
- fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
+ {
+ fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
+ if (fb < 0)
+ fprintf(stderr, "[ecore_fb] error opening $EVAS_FB_DEV=%s: %s\n", getenv("EVAS_FB_DEV"), strerror(errno));
+ }
else
{
- fb = open("/dev/fb/0", O_RDWR);
+ char dev[PATH_MAX];
+ int device;
+
+ /* consistent with ecore_evas_default_display in ecore_evas_fb.c */
+ if (!name) name = "0";
+
+ /* consistent with ecore_evas_fb.c -> evas_fb_main.c */
+ device = strtol(name, NULL, 10);
+
+ snprintf(dev, sizeof(dev), "/dev/fb/%i", device);
+ fb = open(dev, O_RDWR);
if (fb == -1)
- fb = open("/dev/fb0", O_RDWR);
+ {
+ snprintf(dev, sizeof(dev), "/dev/fb%i", device);
+ fb = open(dev, O_RDWR);
+ if (fb < 0)
+ fprintf(stderr, "[ecore_fb] error opening /dev/fb/%i and /dev/fb%i: %s\n", device, device, strerror(errno));
+ }
}
if (fb < 0)
goto exit;
if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
- goto err_ioctl;
+ {
+ perror("[ecore_fb] ioctl FBIOGET_VSCREENINFO");
+ goto err_ioctl;
+ }
*w = fb_var.xres;
*h = fb_var.yres;