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)
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 @@
4 4
5#include "Ecore_Fb.h" 5#include "Ecore_Fb.h"
6#include "ecore_fb_private.h" 6#include "ecore_fb_private.h"
7#include <limits.h>
7 8
8static void _ecore_fb_size_get(int *w, int *h); 9static void _ecore_fb_size_get(const char *name, int *w, int *h);
9 10
10static int _ecore_fb_init_count = 0; 11static int _ecore_fb_init_count = 0;
11static int _ecore_fb_console_w = 0; 12static int _ecore_fb_console_w = 0;
@@ -38,7 +39,7 @@ nosigint(int val EINA_UNUSED)
38 * the Ecore_Fb library. 39 * the Ecore_Fb library.
39 */ 40 */
40EAPI int 41EAPI int
41ecore_fb_init(const char *name EINA_UNUSED) 42ecore_fb_init(const char *name)
42{ 43{
43 if (++_ecore_fb_init_count != 1) 44 if (++_ecore_fb_init_count != 1)
44 return _ecore_fb_init_count; 45 return _ecore_fb_init_count;
@@ -51,7 +52,7 @@ ecore_fb_init(const char *name EINA_UNUSED)
51 oldhand = signal(SIGINT, nosigint); 52 oldhand = signal(SIGINT, nosigint);
52 } 53 }
53 54
54 _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h); 55 _ecore_fb_size_get(name, &_ecore_fb_console_w, &_ecore_fb_console_h);
55 56
56 return _ecore_fb_init_count; 57 return _ecore_fb_init_count;
57} 58}
@@ -103,7 +104,7 @@ ecore_fb_size_get(int *w, int *h)
103} 104}
104 105
105static void 106static void
106_ecore_fb_size_get(int *w, int *h) 107_ecore_fb_size_get(const char *name, int *w, int *h)
107{ 108{
108 struct fb_var_screeninfo fb_var; 109 struct fb_var_screeninfo fb_var;
109 int fb; 110 int fb;
@@ -113,18 +114,40 @@ _ecore_fb_size_get(int *w, int *h)
113 (getuid() == geteuid()) && 114 (getuid() == geteuid()) &&
114#endif 115#endif
115 (getenv("EVAS_FB_DEV"))) 116 (getenv("EVAS_FB_DEV")))
116 fb = open(getenv("EVAS_FB_DEV"), O_RDWR); 117 {
118 fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
119 if (fb < 0)
120 fprintf(stderr, "[ecore_fb] error opening $EVAS_FB_DEV=%s: %s\n", getenv("EVAS_FB_DEV"), strerror(errno));
121 }
117 else 122 else
118 { 123 {
119 fb = open("/dev/fb/0", O_RDWR); 124 char dev[PATH_MAX];
125 int device;
126
127 /* consistent with ecore_evas_default_display in ecore_evas_fb.c */
128 if (!name) name = "0";
129
130 /* consistent with ecore_evas_fb.c -> evas_fb_main.c */
131 device = strtol(name, NULL, 10);
132
133 snprintf(dev, sizeof(dev), "/dev/fb/%i", device);
134 fb = open(dev, O_RDWR);
120 if (fb == -1) 135 if (fb == -1)
121 fb = open("/dev/fb0", O_RDWR); 136 {
137 snprintf(dev, sizeof(dev), "/dev/fb%i", device);
138 fb = open(dev, O_RDWR);
139 if (fb < 0)
140 fprintf(stderr, "[ecore_fb] error opening /dev/fb/%i and /dev/fb%i: %s\n", device, device, strerror(errno));
141 }
122 } 142 }
123 if (fb < 0) 143 if (fb < 0)
124 goto exit; 144 goto exit;
125 145
126 if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1) 146 if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
127 goto err_ioctl; 147 {
148 perror("[ecore_fb] ioctl FBIOGET_VSCREENINFO");
149 goto err_ioctl;
150 }
128 151
129 *w = fb_var.xres; 152 *w = fb_var.xres;
130 *h = fb_var.yres; 153 *h = fb_var.yres;