diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-09-10 19:31:27 -0400 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-09-10 19:31:27 -0400 |
| commit | 8880093fe386ab0dcefec9ce41f8ce6f4e068b0e (patch) | |
| tree | 3ba462c2bea26fc6048c53b07aea574983c8cb02 | |
| parent | e67eff1c615c98bf9ad51be9e474ef9ee82b6565 (diff) | |
| parent | 04bee29ad979ca770677338e343869a0d5662cfb (diff) | |
| download | system_core-8880093fe386ab0dcefec9ce41f8ce6f4e068b0e.zip system_core-8880093fe386ab0dcefec9ce41f8ce6f4e068b0e.tar.gz system_core-8880093fe386ab0dcefec9ce41f8ce6f4e068b0e.tar.bz2 | |
Merge change 24493 into eclair
* changes:
Fix several issues in framebuffer_service
| -rw-r--r-- | adb/framebuffer_service.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c index 65cb20a..cb48d41 100644 --- a/adb/framebuffer_service.c +++ b/adb/framebuffer_service.c @@ -28,18 +28,17 @@ #include <sys/mman.h> /* TODO: -** - grab the current buffer, not the first buffer ** - sync with vsync to avoid tearing */ void framebuffer_service(int fd, void *cookie) { struct fb_var_screeninfo vinfo; - int fb; - void *ptr = MAP_FAILED; - char x; + int fb, offset; + char x[256]; unsigned fbinfo[4]; + unsigned i, bytespp; fb = open("/dev/graphics/fb0", O_RDONLY); if(fb < 0) goto done; @@ -47,24 +46,34 @@ void framebuffer_service(int fd, void *cookie) if(ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) < 0) goto done; fcntl(fb, F_SETFD, FD_CLOEXEC); - fbinfo[0] = 16; - fbinfo[1] = vinfo.xres * vinfo.yres * 2; + bytespp = vinfo.bits_per_pixel / 8; + + fbinfo[0] = vinfo.bits_per_pixel; + fbinfo[1] = vinfo.xres * vinfo.yres * bytespp; fbinfo[2] = vinfo.xres; fbinfo[3] = vinfo.yres; - ptr = mmap(0, fbinfo[1], PROT_READ, MAP_SHARED, fb, 0); - if(ptr == MAP_FAILED) goto done; + /* HACK: for several of our 3d cores a specific alignment + * is required so the start of the fb may not be an integer number of lines + * from the base. As a result we are storing the additional offset in + * xoffset. This is not the correct usage for xoffset, it should be added + * to each line, not just once at the beginning */ + offset = vinfo.xoffset * bytespp; + + offset += vinfo.xres * vinfo.yoffset * bytespp; - if(writex(fd, fbinfo, sizeof(unsigned) * 4)) goto done; + if(writex(fd, fbinfo, sizeof(fbinfo))) goto done; - for(;;) { - if(readx(fd, &x, 1)) goto done; - if(writex(fd, ptr, fbinfo[1])) goto done; + lseek(fb, offset, SEEK_SET); + for(i = 0; i < fbinfo[1]; i += 256) { + if(readx(fb, &x, 256)) goto done; + if(writex(fd, &x, 256)) goto done; } + if(readx(fb, &x, fbinfo[1] % 256)) goto done; + if(writex(fd, &x, fbinfo[1] % 256)) goto done; + done: - if(ptr != MAP_FAILED) munmap(ptr, fbinfo[1]); if(fb >= 0) close(fb); close(fd); } - |
