FramebufferNativeWindow::~FramebufferNativeWindow() 
{
#ifdef OMAP_ENHANCEMENT
    int i;

   if (grDev){
        for (i = 0; i < mNumBuffers; i++){
            if (buffers[i] != NULL)
                grDev->free(grDev, buffers[i]->handle);
        }
        gralloc_close(grDev);
    }
#else
    if (grDev) {
        if (buffers[0] != NULL)
            grDev->free(grDev, buffers[0]->handle);
        if (buffers[1] != NULL)
            grDev->free(grDev, buffers[1]->handle);
        gralloc_close(grDev);
    }
#endif
    if (fbDev) {
        framebuffer_close(fbDev);
    }
}
Exemplo n.º 2
0
static void initAllocDev()
{
	if(allocDev)
		return;
	if(!libhardware_dl())
	{
		LOG(LOG_ERROR,"Incompatible libhardware.so");
		return;
	}
	if(hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (hw_module_t const**)&grallocMod) != 0)
	{
		LOG(LOG_ERROR,"Can't load gralloc module");
		return;
	}
	gralloc_open((const hw_module_t*)grallocMod, &allocDev);
	if(!allocDev)
	{
		LOG(LOG_ERROR,"Can't load allocator device");
		return;
	}
	if(!allocDev->alloc || !allocDev->free)
	{
		LOG(LOG_ERROR,"Missing alloc/free functions");
		if(allocDev->common.close)
			gralloc_close(allocDev);
		else
			LOG(LOG_WARNING,"Missing device close function");
		allocDev = {};
		return;
	}
	LOG(LOG_MINIMAL,"alloc device:%p", allocDev);
}
Exemplo n.º 3
0
static void
gst_gralloc_finalize (GstGralloc * gralloc)
{
  int err = gralloc_close (gralloc->allocator);
  if (err != 0) {
    g_warning ("Failed to close gralloc");
  }

  gralloc->gralloc = NULL;
  gralloc->allocator = NULL;
}
Exemplo n.º 4
0
FramebufferNativeWindow::~FramebufferNativeWindow() 
{
    if (grDev) {
        if (buffers[0] != NULL)
            grDev->free(grDev, buffers[0]->handle);
        if (buffers[1] != NULL)
            grDev->free(grDev, buffers[1]->handle);
        gralloc_close(grDev);
    }

    if (fbDev) {
        framebuffer_close(fbDev);
    }
}
Exemplo n.º 5
0
FramebufferNativeWindow::~FramebufferNativeWindow() 
{
    if (grDev) {
        for(int i = 0; i < mNumBuffers; i++) {
            if (buffers[i] != NULL) {
                grDev->free(grDev, buffers[i]->handle);
            }
        }
        gralloc_close(grDev);
    }

    if (fbDev) {
        framebuffer_close(fbDev);
    }
}
Exemplo n.º 6
0
bool_e gfx_display_free(gfx_display_t *gfxd)
{
    bool_e freed = false_e;
    if (gfxd)
    {
        uint32_t i = 0;
        for (i = 0; i < gfxd->numBuffers; i++)
        {
            gfxd->allocator->free(gfxd->allocator, (buffer_handle_t)gfxd->handles[i]);
        }
        free(gfxd->handles);
        gfxd->numBuffers = 0;
        bitfield_deinit(&gfxd->used);
        queue_destroy(gfxd->returnq);
        gralloc_close(gfxd->allocator);
        freed = true_e;
    }
    return freed;
}
Exemplo n.º 7
0
void hybris_gralloc_deinitialize(void)
{
    if (framebuffer_device) framebuffer_close(framebuffer_device);
    framebuffer_device = NULL;

    if (gralloc0_alloc) gralloc_close(gralloc0_alloc);
    gralloc0_alloc = NULL;

#if HAS_GRALLOC1_HEADER
    if (gralloc1_device) gralloc1_close(gralloc1_device);
    gralloc1_device = NULL;
#endif

#ifdef ANDROID_BUILD
    if (gralloc_hardware_module) dlclose(gralloc_hardware_module->dso);
#else
    if (gralloc_hardware_module) android_dlclose(gralloc_hardware_module->dso);
#endif
    gralloc_hardware_module = NULL;
}
Exemplo n.º 8
0
FramebufferNativeWindow::~FramebufferNativeWindow() 
{
    LOGE_IF(!grDev, "~FramebufferNativeWindow [grDev==NULL]");

    Mutex::Autolock _l(mutex);

    if (grDev) {
        for(int i = 0; i < mNumBuffers; i++) {
            if (buffers[i] != NULL) {
                grDev->free(grDev, buffers[i]->handle);
            }
        }
        gralloc_close(grDev);
        grDev = 0;
    }

    if (fbDev) {
        framebuffer_close(fbDev);
        fbDev = 0;
    }
}
Exemplo n.º 9
0
FramebufferNativeWindow::FramebufferNativeWindow() 
    : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
{
    hw_module_t const* module;
    if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
        int stride;
        int err;
        err = framebuffer_open(module, &fbDev);
        LOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
        
        err = gralloc_open(module, &grDev);
        LOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));

        // bail out if we can't initialize the modules
        if (!fbDev || !grDev) {
            if (grDev) {
                gralloc_close(grDev);
                grDev = 0;
            }
            if (fbDev) {
                framebuffer_close(fbDev);
                fbDev = 0;
            }
            return;
        }
        
        mUpdateOnDemand = (fbDev->setUpdateRect != 0);
        
        // initialize the buffer FIFO
        mNumBuffers = fbDev->numFramebuffers;
        mNumFreeBuffers = mNumBuffers;
        mBufferHead = 0;
        LOGD("mNumBuffers = %d", mNumBuffers);
        for(int i = 0; i < mNumBuffers; i++) {
            buffers[i] = new NativeBuffer(
                fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);

            err = grDev->alloc(grDev,
                fbDev->width, fbDev->height, fbDev->format, 
                GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride);

            LOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
                i, fbDev->width, fbDev->height, strerror(-err));
        }

        const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; 
        const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
        const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
        const_cast<int&>(ANativeWindow::minSwapInterval) = 
            fbDev->minSwapInterval;
        const_cast<int&>(ANativeWindow::maxSwapInterval) = 
            fbDev->maxSwapInterval;
    } else {
        LOGE("Couldn't get gralloc module");
    }

    ANativeWindow::setSwapInterval = setSwapInterval;
    ANativeWindow::dequeueBuffer = dequeueBuffer;
    ANativeWindow::lockBuffer = lockBuffer;
    ANativeWindow::queueBuffer = queueBuffer;
    ANativeWindow::cancelBuffer = NULL;
    ANativeWindow::query = query;
    ANativeWindow::perform = perform;
}