summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-02-08 01:50:25 +0059
committerBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-11-14 00:50:28 +0100
commitf77aa96387e9fbe40632c01f482e5bb87562328c (patch)
tree917f4ffc533b13380e6055ea0e5e534e3cd044f8
parent54e5f507553354f647df0754a034baf5b29fad61 (diff)
downloadlibhardware-f77aa96387e9fbe40632c01f482e5bb87562328c.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.cpp25
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);