android-2.1_r1 snapshot
This commit is contained in:
		@@ -20,6 +20,7 @@
 | 
			
		||||
 | 
			
		||||
#include <cutils/ashmem.h>
 | 
			
		||||
#include <cutils/log.h>
 | 
			
		||||
#include <cutils/properties.h>
 | 
			
		||||
 | 
			
		||||
#include <hardware/hardware.h>
 | 
			
		||||
#include <hardware/gralloc.h>
 | 
			
		||||
@@ -59,7 +60,8 @@ struct fb_context_t {
 | 
			
		||||
/*****************************************************************************/
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
msm_copy_buffer(buffer_handle_t handle, int fd, int width, int height,
 | 
			
		||||
msm_copy_buffer(buffer_handle_t handle, int fd,
 | 
			
		||||
                int width, int height, int format,
 | 
			
		||||
                int x, int y, int w, int h);
 | 
			
		||||
 | 
			
		||||
static int fb_setSwapInterval(struct framebuffer_device_t* dev,
 | 
			
		||||
@@ -120,9 +122,6 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
 | 
			
		||||
        m->currentBuffer = buffer;
 | 
			
		||||
        
 | 
			
		||||
    } else {
 | 
			
		||||
        // If we can't do the page_flip, just copy the buffer to the front 
 | 
			
		||||
        // FIXME: use copybit HAL instead of memcpy
 | 
			
		||||
        
 | 
			
		||||
        void* fb_vaddr;
 | 
			
		||||
        void* buffer_vaddr;
 | 
			
		||||
        
 | 
			
		||||
@@ -138,8 +137,9 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
 | 
			
		||||
 | 
			
		||||
        //memcpy(fb_vaddr, buffer_vaddr, m->finfo.line_length * m->info.yres);
 | 
			
		||||
 | 
			
		||||
        msm_copy_buffer(m->framebuffer, m->framebuffer->fd,
 | 
			
		||||
                m->info.xres, m->info.yres,
 | 
			
		||||
        msm_copy_buffer(
 | 
			
		||||
                m->framebuffer, m->framebuffer->fd,
 | 
			
		||||
                m->info.xres, m->info.yres, m->fbFormat,
 | 
			
		||||
                m->info.xoffset, m->info.yoffset,
 | 
			
		||||
                m->info.width, m->info.height);
 | 
			
		||||
 | 
			
		||||
@@ -152,7 +152,7 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
 | 
			
		||||
 | 
			
		||||
static int fb_compositionComplete(struct framebuffer_device_t* dev)
 | 
			
		||||
{
 | 
			
		||||
    // STOPSHIP: Properly implement composition complete callback
 | 
			
		||||
    // TODO: Properly implement composition complete callback
 | 
			
		||||
    glFinish();
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -199,19 +199,35 @@ int mapFrameBufferLocked(struct private_module_t* module)
 | 
			
		||||
    info.yoffset = 0;
 | 
			
		||||
    info.activate = FB_ACTIVATE_NOW;
 | 
			
		||||
 | 
			
		||||
    /* Interpretation of offset for color fields: All offsets are from the right,
 | 
			
		||||
    * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you
 | 
			
		||||
    * can use the offset as right argument to <<). A pixel afterwards is a bit
 | 
			
		||||
    * stream and is written to video memory as that unmodified. This implies
 | 
			
		||||
    * big-endian byte order if bits_per_pixel is greater than 8.
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Explicitly request 5/6/5
 | 
			
		||||
     * Explicitly request RGBA_8888
 | 
			
		||||
     */
 | 
			
		||||
    info.bits_per_pixel = 16;
 | 
			
		||||
    info.red.offset     = 11;
 | 
			
		||||
    info.red.length     = 5;
 | 
			
		||||
    info.green.offset   = 5;
 | 
			
		||||
    info.green.length   = 6;
 | 
			
		||||
    info.blue.offset    = 0;
 | 
			
		||||
    info.blue.length    = 5;
 | 
			
		||||
    info.bits_per_pixel = 32;
 | 
			
		||||
    info.red.offset     = 24;
 | 
			
		||||
    info.red.length     = 8;
 | 
			
		||||
    info.green.offset   = 16;
 | 
			
		||||
    info.green.length   = 8;
 | 
			
		||||
    info.blue.offset    = 8;
 | 
			
		||||
    info.blue.length    = 8;
 | 
			
		||||
    info.transp.offset  = 0;
 | 
			
		||||
    info.transp.length  = 0;
 | 
			
		||||
 | 
			
		||||
    /* Note: the GL driver does not have a r=8 g=8 b=8 a=0 config, so if we do
 | 
			
		||||
     * not use the MDP for composition (i.e. hw composition == 0), ask for
 | 
			
		||||
     * RGBA instead of RGBX. */
 | 
			
		||||
    char property[PROPERTY_VALUE_MAX];
 | 
			
		||||
    if (property_get("debug.sf.hw", property, NULL) > 0 && atoi(property) == 0)
 | 
			
		||||
        module->fbFormat = HAL_PIXEL_FORMAT_RGBX_8888;
 | 
			
		||||
    else
 | 
			
		||||
        module->fbFormat = HAL_PIXEL_FORMAT_RGBA_8888;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Request NUM_BUFFERS screens (at lest 2 for page flipping)
 | 
			
		||||
     */
 | 
			
		||||
@@ -322,7 +338,6 @@ int mapFrameBufferLocked(struct private_module_t* module)
 | 
			
		||||
        return -errno;
 | 
			
		||||
    }
 | 
			
		||||
    module->framebuffer->base = intptr_t(vaddr);
 | 
			
		||||
    module->framebuffer->phys = intptr_t(finfo.smem_start);
 | 
			
		||||
    memset(vaddr, 0, fbSize);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -378,7 +393,7 @@ int fb_device_open(hw_module_t const* module, const char* name,
 | 
			
		||||
            const_cast<uint32_t&>(dev->device.width) = m->info.xres;
 | 
			
		||||
            const_cast<uint32_t&>(dev->device.height) = m->info.yres;
 | 
			
		||||
            const_cast<int&>(dev->device.stride) = stride;
 | 
			
		||||
            const_cast<int&>(dev->device.format) = HAL_PIXEL_FORMAT_RGB_565;
 | 
			
		||||
            const_cast<int&>(dev->device.format) = m->fbFormat;
 | 
			
		||||
            const_cast<float&>(dev->device.xdpi) = m->xdpi;
 | 
			
		||||
            const_cast<float&>(dev->device.ydpi) = m->ydpi;
 | 
			
		||||
            const_cast<float&>(dev->device.fps) = m->fps;
 | 
			
		||||
@@ -400,7 +415,8 @@ int fb_device_open(hw_module_t const* module, const char* name,
 | 
			
		||||
/* Copy a pmem buffer to the framebuffer */
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
msm_copy_buffer(buffer_handle_t handle, int fd, int width, int height,
 | 
			
		||||
msm_copy_buffer(buffer_handle_t handle, int fd,
 | 
			
		||||
                int width, int height, int format,
 | 
			
		||||
                int x, int y, int w, int h)
 | 
			
		||||
{
 | 
			
		||||
    struct {
 | 
			
		||||
@@ -425,7 +441,7 @@ msm_copy_buffer(buffer_handle_t handle, int fd, int width, int height,
 | 
			
		||||
    blit.req.dst.height = height;
 | 
			
		||||
    blit.req.dst.offset = 0;
 | 
			
		||||
    blit.req.dst.memory_id = fd; 
 | 
			
		||||
    blit.req.dst.format = MDP_RGB_565;
 | 
			
		||||
    blit.req.dst.format = format;
 | 
			
		||||
 | 
			
		||||
    blit.req.src_rect.x = blit.req.dst_rect.x = x;
 | 
			
		||||
    blit.req.src_rect.y = blit.req.dst_rect.y = y;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								gralloc.cpp
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								gralloc.cpp
									
									
									
									
									
								
							@@ -104,6 +104,7 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
 | 
			
		||||
        perform: gralloc_perform,
 | 
			
		||||
    },
 | 
			
		||||
    framebuffer: 0,
 | 
			
		||||
    fbFormat: 0,
 | 
			
		||||
    flags: 0,
 | 
			
		||||
    numBuffers: 0,
 | 
			
		||||
    bufferMask: 0,
 | 
			
		||||
@@ -111,7 +112,6 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
 | 
			
		||||
    currentBuffer: 0,
 | 
			
		||||
    pmem_master: -1,
 | 
			
		||||
    pmem_master_base: 0,
 | 
			
		||||
    master_phys: 0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*****************************************************************************/
 | 
			
		||||
@@ -165,7 +165,6 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
 | 
			
		||||
    
 | 
			
		||||
    hnd->base = vaddr;
 | 
			
		||||
    hnd->offset = vaddr - intptr_t(m->framebuffer->base);
 | 
			
		||||
    hnd->phys = intptr_t(m->framebuffer->phys) + hnd->offset;
 | 
			
		||||
    *pHandle = hnd;
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -205,15 +204,6 @@ static int init_pmem_area_locked(private_module_t* m)
 | 
			
		||||
            base = 0;
 | 
			
		||||
            close(master_fd);
 | 
			
		||||
            master_fd = -1;
 | 
			
		||||
        } else {
 | 
			
		||||
            // FIXME: get physical address, eventually this will have to go away
 | 
			
		||||
            pmem_region region;
 | 
			
		||||
            err = ioctl(master_fd, PMEM_GET_PHYS, ®ion);
 | 
			
		||||
            if (err < 0) {
 | 
			
		||||
                LOGE("PMEM_GET_PHYS failed (%s)", strerror(-errno));
 | 
			
		||||
            } else {
 | 
			
		||||
                m->master_phys = (unsigned long)region.offset;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        m->pmem_master = master_fd;
 | 
			
		||||
        m->pmem_master_base = base;
 | 
			
		||||
@@ -289,9 +279,16 @@ try_ashmem:
 | 
			
		||||
                err = -ENOMEM;
 | 
			
		||||
            } else {
 | 
			
		||||
                struct pmem_region sub = { offset, size };
 | 
			
		||||
                
 | 
			
		||||
                int openFlags = O_RDWR | O_SYNC;
 | 
			
		||||
                uint32_t uread = usage & GRALLOC_USAGE_SW_READ_MASK;
 | 
			
		||||
                uint32_t uwrite = usage & GRALLOC_USAGE_SW_WRITE_MASK;
 | 
			
		||||
                if (uread == GRALLOC_USAGE_SW_READ_OFTEN ||
 | 
			
		||||
                    uwrite == GRALLOC_USAGE_SW_WRITE_OFTEN) {
 | 
			
		||||
                    openFlags &= ~O_SYNC;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // now create the "sub-heap"
 | 
			
		||||
                fd = open("/dev/pmem", O_RDWR, 0);
 | 
			
		||||
                fd = open("/dev/pmem", openFlags, 0);
 | 
			
		||||
                err = fd < 0 ? fd : 0;
 | 
			
		||||
                
 | 
			
		||||
                // and connect to it
 | 
			
		||||
@@ -307,8 +304,11 @@ try_ashmem:
 | 
			
		||||
                    close(fd);
 | 
			
		||||
                    sAllocator.deallocate(offset);
 | 
			
		||||
                    fd = -1;
 | 
			
		||||
                } else {
 | 
			
		||||
                    memset((char*)base + offset, 0, size);
 | 
			
		||||
                    // clean and invalidate the new allocation
 | 
			
		||||
                    cacheflush(intptr_t(base) + offset, size, 0);
 | 
			
		||||
                }
 | 
			
		||||
                memset((char*)base + offset, 0, size);
 | 
			
		||||
                //LOGD_IF(!err, "allocating pmem size=%d, offset=%d", size, offset);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -328,11 +328,6 @@ try_ashmem:
 | 
			
		||||
        hnd->offset = offset;
 | 
			
		||||
        hnd->base = int(base)+offset;
 | 
			
		||||
        hnd->lockState = lockState;
 | 
			
		||||
        if (flags & private_handle_t::PRIV_FLAGS_USES_PMEM) {
 | 
			
		||||
            private_module_t* m = reinterpret_cast<private_module_t*>(
 | 
			
		||||
                    dev->common.module);
 | 
			
		||||
            hnd->phys = m->master_phys + offset;
 | 
			
		||||
        }
 | 
			
		||||
        *pHandle = hnd;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@@ -391,6 +386,9 @@ static int gralloc_alloc(alloc_device_t* dev,
 | 
			
		||||
        size = alignedw * alignedh * bpp;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((ssize_t)size <= 0)
 | 
			
		||||
        return -EINVAL;
 | 
			
		||||
 | 
			
		||||
    int err;
 | 
			
		||||
    if (usage & GRALLOC_USAGE_HW_FB) {
 | 
			
		||||
        err = gralloc_alloc_framebuffer(dev, size, usage, pHandle);
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,7 @@ struct private_module_t {
 | 
			
		||||
    gralloc_module_t base;
 | 
			
		||||
 | 
			
		||||
    struct private_handle_t* framebuffer;
 | 
			
		||||
    uint32_t fbFormat;
 | 
			
		||||
    uint32_t flags;
 | 
			
		||||
    uint32_t numBuffers;
 | 
			
		||||
    uint32_t bufferMask;
 | 
			
		||||
@@ -45,7 +46,6 @@ struct private_module_t {
 | 
			
		||||
    buffer_handle_t currentBuffer;
 | 
			
		||||
    int pmem_master;
 | 
			
		||||
    void* pmem_master_base;
 | 
			
		||||
    unsigned long master_phys;
 | 
			
		||||
 | 
			
		||||
    struct fb_var_screeninfo info;
 | 
			
		||||
    struct fb_fix_screeninfo finfo;
 | 
			
		||||
@@ -92,7 +92,7 @@ struct private_handle_t {
 | 
			
		||||
    int     base;
 | 
			
		||||
    int     lockState;
 | 
			
		||||
    int     writeOwner;
 | 
			
		||||
    int     phys; // The physical address of that chunk of memory. If using ashmem, set to 0 They don't care
 | 
			
		||||
    int     gpuaddr; // The gpu address mapped into the mmu. If using ashmem, set to 0 They don't care
 | 
			
		||||
    int     pid;
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
@@ -102,7 +102,7 @@ struct private_handle_t {
 | 
			
		||||
 | 
			
		||||
    private_handle_t(int fd, int size, int flags) :
 | 
			
		||||
        fd(fd), magic(sMagic), flags(flags), size(size), offset(0), gpu_fd(-1),
 | 
			
		||||
        base(0), lockState(0), writeOwner(0), phys(0), pid(getpid())
 | 
			
		||||
        base(0), lockState(0), writeOwner(0), gpuaddr(0), pid(getpid())
 | 
			
		||||
    {
 | 
			
		||||
        version = sizeof(native_handle);
 | 
			
		||||
        numInts = sNumInts;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user