diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-11-15 12:07:12 -0800 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-11-15 12:07:12 -0800 |
commit | 333a80cf9ffc975aee91d82bee2bb17cdfe458a7 (patch) | |
tree | 3e41affbdd064920ceced073bb39c1e12b36e2c3 /adb | |
parent | e25ff1c682ae5cc87af5e76de7e31a2702b620f3 (diff) | |
parent | 4b29fe640ae852c04d5d87d0f9527bdc32177ad1 (diff) | |
download | system_core-333a80cf9ffc975aee91d82bee2bb17cdfe458a7.zip system_core-333a80cf9ffc975aee91d82bee2bb17cdfe458a7.tar.gz system_core-333a80cf9ffc975aee91d82bee2bb17cdfe458a7.tar.bz2 |
merge from eclair
Diffstat (limited to 'adb')
-rw-r--r-- | adb/framebuffer_service.c | 70 | ||||
-rw-r--r-- | adb/usb_vendors.c | 3 |
2 files changed, 56 insertions, 17 deletions
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c index 65cb20a..2f45694 100644 --- a/adb/framebuffer_service.c +++ b/adb/framebuffer_service.c @@ -28,18 +28,35 @@ #include <sys/mman.h> /* TODO: -** - grab the current buffer, not the first buffer ** - sync with vsync to avoid tearing */ +/* This version number defines the format of the fbinfo struct. + It must match versioning in ddms where this data is consumed. */ +#define DDMS_RAWIMAGE_VERSION 1 +struct fbinfo { + unsigned int version; + unsigned int bpp; + unsigned int size; + unsigned int width; + unsigned int height; + unsigned int red_offset; + unsigned int red_length; + unsigned int blue_offset; + unsigned int blue_length; + unsigned int green_offset; + unsigned int green_length; + unsigned int alpha_offset; + unsigned int alpha_length; +} __attribute__((packed)); 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]; + struct fbinfo fbinfo; + unsigned i, bytespp; fb = open("/dev/graphics/fb0", O_RDONLY); if(fb < 0) goto done; @@ -47,24 +64,43 @@ 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; - fbinfo[2] = vinfo.xres; - fbinfo[3] = vinfo.yres; + bytespp = vinfo.bits_per_pixel / 8; - ptr = mmap(0, fbinfo[1], PROT_READ, MAP_SHARED, fb, 0); - if(ptr == MAP_FAILED) goto done; + fbinfo.version = DDMS_RAWIMAGE_VERSION; + fbinfo.bpp = vinfo.bits_per_pixel; + fbinfo.size = vinfo.xres * vinfo.yres * bytespp; + fbinfo.width = vinfo.xres; + fbinfo.height = vinfo.yres; + fbinfo.red_offset = vinfo.red.offset; + fbinfo.red_length = vinfo.red.length; + fbinfo.green_offset = vinfo.green.offset; + fbinfo.green_length = vinfo.green.length; + fbinfo.blue_offset = vinfo.blue.offset; + fbinfo.blue_length = vinfo.blue.length; + fbinfo.alpha_offset = vinfo.transp.offset; + fbinfo.alpha_length = vinfo.transp.length; - if(writex(fd, fbinfo, sizeof(unsigned) * 4)) 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; - for(;;) { - if(readx(fd, &x, 1)) goto done; - if(writex(fd, ptr, fbinfo[1])) goto done; + offset += vinfo.xres * vinfo.yoffset * bytespp; + + if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done; + + lseek(fb, offset, SEEK_SET); + for(i = 0; i < fbinfo.size; i += 256) { + if(readx(fb, &x, 256)) goto done; + if(writex(fd, &x, 256)) goto done; } + if(readx(fb, &x, fbinfo.size % 256)) goto done; + if(writex(fd, &x, fbinfo.size % 256)) goto done; + done: - if(ptr != MAP_FAILED) munmap(ptr, fbinfo[1]); if(fb >= 0) close(fb); close(fd); } - diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c index 5534fd9..064abc0 100644 --- a/adb/usb_vendors.c +++ b/adb/usb_vendors.c @@ -49,6 +49,8 @@ #define VENDOR_ID_HUAWEI 0x12D1 // Acer's USB Vendor ID #define VENDOR_ID_ACER 0x0502 +// Sony Ericsson's USB Vendor ID +#define VENDOR_ID_SONY_ERICSSON 0x0FCE /** built-in vendor list */ int builtInVendorIds[] = { @@ -59,6 +61,7 @@ int builtInVendorIds[] = { VENDOR_ID_LGE, VENDOR_ID_HUAWEI, VENDOR_ID_ACER, + VENDOR_ID_SONY_ERICSSON, }; #define BUILT_IN_VENDOR_COUNT (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0])) |