diff options
author | Dima Zavin <dima@android.com> | 2009-04-30 18:45:16 -0700 |
---|---|---|
committer | Dima Zavin <dima@android.com> | 2009-04-30 18:45:16 -0700 |
commit | acbb5bc99bccf7e625cc73fb1aaa90355bedb733 (patch) | |
tree | 7bc733d3a5d79843bb8aa4f9a29569f6e25aef12 | |
parent | d15831a05ceab8e4a84290d2cd31a74b98821f2c (diff) | |
download | extras-acbb5bc99bccf7e625cc73fb1aaa90355bedb733.tar.gz |
fb_test: Look for fbdev in several possible locations.
Also, only try to set console graphics mode if we have an fbcon.
This should make this utility a little more robust, and a hopefully
more useful for bringup.
Signed-off-by: Dima Zavin <dima@android.com>
-rw-r--r-- | tests/framebuffer/fb_test.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/tests/framebuffer/fb_test.c b/tests/framebuffer/fb_test.c index 6fdbf3b3..3bd7e8e5 100644 --- a/tests/framebuffer/fb_test.c +++ b/tests/framebuffer/fb_test.c @@ -59,9 +59,12 @@ static int get_framebuffer(GGLSurface *fb) void *bits; fd = open("/dev/graphics/fb0", O_RDWR); - if(fd < 0) { - perror("cannot open fb0"); - return -1; + if (fd < 0) { + printf("cannot open /dev/graphics/fb0, retrying with /dev/fb0\n"); + if ((fd = open("/dev/fb0", O_RDWR)) < 0) { + perror("cannot open /dev/fb0"); + return -1; + } } if(ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) { @@ -127,22 +130,26 @@ static void dumpinfo(struct fb_fix_screeninfo *fi, struct fb_var_screeninfo *vi) int gr_init(void) { - int fd; - + int fd = -1; - fd = open("/dev/tty0", O_RDWR | O_SYNC); - if(fd < 0) return -1; + if (!access("/dev/tty0", F_OK)) { + fd = open("/dev/tty0", O_RDWR | O_SYNC); + if(fd < 0) + return -1; - if(ioctl(fd, KDSETMODE, (void*) KD_GRAPHICS)) { - close(fd); - return -1; + if(ioctl(fd, KDSETMODE, (void*) KD_GRAPHICS)) { + close(fd); + return -1; + } } gr_fb_fd = get_framebuffer(gr_framebuffer); if(gr_fb_fd < 0) { - ioctl(fd, KDSETMODE, (void*) KD_TEXT); - close(fd); + if (fd >= 0) { + ioctl(fd, KDSETMODE, (void*) KD_TEXT); + close(fd); + } return -1; } @@ -160,9 +167,11 @@ void gr_exit(void) close(gr_fb_fd); gr_fb_fd = -1; - ioctl(gr_vt_fd, KDSETMODE, (void*) KD_TEXT); - close(gr_vt_fd); - gr_vt_fd = -1; + if (gr_vt_fd >= 0) { + ioctl(gr_vt_fd, KDSETMODE, (void*) KD_TEXT); + close(gr_vt_fd); + gr_vt_fd = -1; + } } int gr_fb_width(void) |