Exemplo n.º 1
0
void closeContext(hwc_context_t *ctx)
{
    for(uint32_t i = 0; i < HWC_NUM_DISPLAY_TYPES; i++) {
        if(ctx->mOverlay[i]) {
            delete ctx->mOverlay[i];
            ctx->mOverlay[i] = NULL;
        }
    }

    if(ctx->mFbDev) {
        framebuffer_close(ctx->mFbDev);
        ctx->mFbDev = NULL;
        close(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd);
        ctx->dpyAttr[HWC_DISPLAY_PRIMARY].fd = -1;
    }

    if(ctx->mExtDisplay) {
        delete ctx->mExtDisplay;
        ctx->mExtDisplay = NULL;
    }

    pthread_mutex_destroy(&(ctx->vstate.lock));
    pthread_cond_destroy(&(ctx->vstate.cond));

}
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.º 3
0
extern "C" int hwcomposerws_IsValidDisplay(EGLNativeDisplayType display)
{
	if (__sync_fetch_and_add(&inited,1)==0)
	{
		int err;
		err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc);
		if (gralloc==NULL) {
			fprintf(stderr, "failed to get gralloc module: (%s)\n",strerror(-err));
			assert(0);
		}

		/* Not fatal on HW composer >= 1.1 */
		err = framebuffer_open((hw_module_t *) gralloc, &framebuffer);
		if (err) {
			fprintf(stderr, "WARNING: failed to open framebuffer: (%s)\n",strerror(-err));
		}
		printf("** framebuffer_open: status=(%s) format=x%x", strerror(-err), framebuffer->format);
	

		err = gralloc_open((const hw_module_t *) gralloc, &alloc);
		if (err) {
			fprintf(stderr, "ERROR: failed to open gralloc: (%s)\n",strerror(-err));
			assert(0);
		}
		printf("** gralloc_open %p status=%s\n", gralloc, strerror(-err));

		framebuffer_close(framebuffer);
		eglplatformcommon_init(gralloc, alloc);
	}

	return display == EGL_DEFAULT_DISPLAY;
}
Exemplo n.º 4
0
void closeContext(hwc_context_t *ctx)
{
    if(ctx->mOverlay) {
        delete ctx->mOverlay;
        ctx->mOverlay = NULL;
    }

    if(ctx->mCopybitEngine) {
        delete ctx->mCopybitEngine;
        ctx->mCopybitEngine = NULL;
    }

    if(ctx->mFbDev) {
        framebuffer_close(ctx->mFbDev);
        ctx->mFbDev = NULL;
    }

    if(ctx->qbuf) {
        delete ctx->qbuf;
        ctx->qbuf = NULL;
    }

    if(ctx->mExtDisplay) {
        delete ctx->mExtDisplay;
        ctx->mExtDisplay = NULL;
    }


    free(const_cast<hwc_methods_t *>(ctx->device.methods));

}
Exemplo n.º 5
0
FbDevice::~FbDevice()
{
    if(sFb)
    {
       framebuffer_close(sFb);
       sFb = NULL;
    }
}
Exemplo n.º 6
0
bool Hwcomposer::initialize()
{
    int err;
    log.d("initialize");

    // open frame buffer device
    hw_module_t const* module;
    err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
    if (err) {
        log.e("Hwcomposer::initialize: failed to load gralloc module, %d", err);
        return false;
    }

    IMG_gralloc_module_public_t *imgGrallocModule;
    imgGrallocModule = (IMG_gralloc_module_public_t*)module;

    // open frame buffer device
    err = framebuffer_open(module, (framebuffer_device_t**)&mFBDev);
    if (err) {
        log.e("Hwcomposer::initialize: failed to open frame buffer device, %d",
              err);
        return false;
    }

    mFBDev->bBypassPost = 1;

    // create display plane manager
    mPlaneManager = createDisplayPlaneManager();
    if (!mPlaneManager || !mPlaneManager->initialize()) {
        log.e("initialize: failed to create display plane manager");
        goto dpm_create_err;
    }

    // create display device
    for (int i = 0; i < IDisplayDevice::DEVICE_COUNT; i++) {
        IDisplayDevice *device = createDisplayDevice(i, *mPlaneManager);
        if (!device || !device->initialize()) {
            log.e("initialize: failed to create device %d", i);
            continue;
        }
        // add this device
        mDisplayDevices.insertAt(device, i, 1);
    }

    mInitialized = true;
    return true;
device_create_err:
    for (size_t i = 0; i < mDisplayDevices.size(); i++) {
        IDisplayDevice *device = mDisplayDevices.itemAt(i);
        delete device;
    }
dpm_create_err:
    framebuffer_close((framebuffer_device_t*)mFBDev);
    mInitialized = false;
    return false;
}
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
0
int 
main (int argc, char **argv)
{
  int i;

  for (i = 1; i < argc; i++) {
    if (!strcmp ("--verbose", argv[i]) || !strcmp ("-v", argv[i])) {
      Verbose = 1;
      continue;
    }
    if (!strcmp ("--multiblit", argv[i])) {
      WantMultiBlit = 1;
      continue;
    }

    if (!strcmp ("--cycles", argv[i])) {
      if (++i>=argc) usage ();
      TotalCycles = atoi(argv[i]);
      if (TotalCycles < 1) usage();
      continue;
    }

    usage();
  }

  if (framebuffer_open(NULL, NULL) == -1)
    {
      perror("framebuffer_open failed.");
      exit(0);
    }


  framebuffer_blit();

  framebuffer_close();

  return 0;
}
Exemplo n.º 12
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;
}