summaryrefslogtreecommitdiff
path: root/src/lib/ecore_fb
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-03 12:41:07 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-03 12:44:54 -0200
commit806be7adc04ddfe9677e66116342762e093d80f9 (patch)
tree7345a890ed26e8efbdb42bf8a3224cfefde888db /src/lib/ecore_fb
parent3f84aac424ae275df120e181018702ad0b43ae26 (diff)
downloadefl-806be7adc04ddfe9677e66116342762e093d80f9.tar.gz
ecore_fb_init(): use 'name' parameter similar to ecore_evas_fb_new().
Instead of assuming /dev/fb/0 or /dev/fb0, use the given 'name' parameter in a similar way to ecore_evas_fb_new(): a number to be parsed with 'strtoul()'. Without this calling ecore_evas_fb_new() or ecore_evas_new() with 'display=1' will produce incorrect results. @fix
Diffstat (limited to 'src/lib/ecore_fb')
-rw-r--r--src/lib/ecore_fb/ecore_fb.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/lib/ecore_fb/ecore_fb.c b/src/lib/ecore_fb/ecore_fb.c
index 85ad087d33..eec3904f67 100644
--- a/src/lib/ecore_fb/ecore_fb.c
+++ b/src/lib/ecore_fb/ecore_fb.c
@@ -4,8 +4,9 @@
#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;
@@ -38,7 +39,7 @@ nosigint(int val EINA_UNUSED)
* 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;
@@ -51,7 +52,7 @@ ecore_fb_init(const char *name EINA_UNUSED)
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;
}
@@ -103,7 +104,7 @@ ecore_fb_size_get(int *w, int *h)
}
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;
@@ -113,18 +114,40 @@ _ecore_fb_size_get(int *w, int *h)
(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;