diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-02-08 01:50:25 +0059 |
---|---|---|
committer | Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> | 2013-10-15 21:54:42 +0200 |
commit | b0e79c884a2bb5f4ea5c5f99174478d3823d0e35 (patch) | |
tree | 8f510cd6cd5c09f3eace809d19423b547127eafc | |
parent | f27dbad8634b43fb49d7ef62a743080355d2f0e6 (diff) | |
download | libhardware-b0e79c884a2bb5f4ea5c5f99174478d3823d0e35.tar.gz |
gralloc: Allow overriding the framebuffer device
On some devices, different outputs use different
framebuffer devices - e.g. on iMX6, /dev/fb0 is
the LVDS display, and /dev/fb1 is the HDMI
output.
Simply opening the first device that exists may
not be what we want - allow overrides on the
bootargs line
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | modules/gralloc/framebuffer.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp index a1ded497..48248e1d 100644 --- a/modules/gralloc/framebuffer.cpp +++ b/modules/gralloc/framebuffer.cpp @@ -144,10 +144,33 @@ int mapFrameBufferLocked(struct private_module_t* module) "/dev/fb%u", 0 }; - int fd = -1; + int fd; int i=0; char name[64]; + // Allow the user to specify the default framebuffer device + // on the kernel command line - e.g. on iMX6, /dev/fb1 is HDMI + // and /dev/fb0 is LVDS + fd = open("/proc/cmdline", O_RDONLY); + if(fd>0) { + char cmdline[2048]; + cmdline[2047]=0; + read(fd, &cmdline, 2047); + close(fd); + + char *dev=strstr(cmdline, " fbdev="); + if(!dev && !strncmp(cmdline, "fbdev=", 6)) + dev=cmdline; + if(dev) { + dev=strchr(dev, '=')+1; + if(strchr(dev, ' ')) + *strchr(dev, ' ')=0; + if(strchr(dev, '\n')) + *strchr(dev, '\n')=0; + } + fd = dev ? open(dev, O_RDWR, 0) : -1; + } + while ((fd==-1) && device_template[i]) { snprintf(name, 64, device_template[i], 0); fd = open(name, O_RDWR, 0); |