/******************************************************************************* ** ** Function: NfcAdaptation::InitializeHalDeviceContext ** ** Description: Ask the generic Android HAL to find the Broadcom-specific HAL. ** ** Returns: None. ** *******************************************************************************/ void NfcAdaptation::InitializeHalDeviceContext () { const char* func = "NfcAdaptation::InitializeHalDeviceContext"; ALOGD ("%s: enter", func); int ret = 0; //0 means success const hw_module_t* hw_module = NULL; mHalEntryFuncs.initialize = HalInitialize; mHalEntryFuncs.terminate = HalTerminate; mHalEntryFuncs.open = HalOpen; mHalEntryFuncs.close = HalClose; mHalEntryFuncs.core_initialized = HalCoreInitialized; mHalEntryFuncs.write = HalWrite; mHalEntryFuncs.prediscover = HalPrediscover; mHalEntryFuncs.control_granted = HalControlGranted; mHalEntryFuncs.power_cycle = HalPowerCycle; mHalEntryFuncs.get_max_ee = HalGetMaxNfcee; #if (NFC_NXP_NOT_OPEN_INCLUDED == TRUE) ret = hw_get_module ("nfc_nci_pn547", &hw_module); #else ret = hw_get_module (NFC_NCI_HARDWARE_MODULE_ID, &hw_module); #endif if (ret == 0) { ret = nfc_nci_open (hw_module, &mHalDeviceContext); if (ret != 0) ALOGE ("%s: nfc_nci_open fail", func); } else ALOGE ("%s: fail hw_get_module", func); ALOGD ("%s: exit", func); }
AudioHardwareALSA::AudioHardwareALSA() : mALSADevice(0), mAcousticDevice(0) { snd_lib_error_set_handler(&ALSAErrorHandler); mMixer = new ALSAMixer; hw_module_t *module; int err = hw_get_module(ALSA_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { hw_device_t* device; err = module->methods->open(module, ALSA_HARDWARE_NAME, &device); if (err == 0) { mALSADevice = (alsa_device_t *)device; mALSADevice->init(mALSADevice, mDeviceList); } else LOGE("ALSA Module could not be opened!!!"); } else LOGE("ALSA Module not found!!!"); err = hw_get_module(ACOUSTICS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { hw_device_t* device; err = module->methods->open(module, ACOUSTICS_HARDWARE_NAME, &device); if (err == 0) mAcousticDevice = (acoustic_device_t *)device; else LOGE("Acoustics Module not found."); } }
std::tuple<std::shared_ptr<mga::HwcWrapper>, mga::HwcVersion> mga::ResourceFactory::create_hwc_wrapper(std::shared_ptr<mga::HwcReport> const& hwc_report) const { //TODO: could probably be collapsed further into HwcWrapper's constructor hwc_composer_device_1* hwc_device_raw = nullptr; hw_module_t const *module; int rc = hw_get_module(HWC_HARDWARE_MODULE_ID, &module); if ((rc != 0) || (module == nullptr) || (!module->methods) || !(module->methods->open) || module->methods->open(module, HWC_HARDWARE_COMPOSER, reinterpret_cast<hw_device_t**>(&hwc_device_raw)) || (hwc_device_raw == nullptr)) { BOOST_THROW_EXCEPTION(std::runtime_error("error opening hwc hal")); } auto hwc_native = std::shared_ptr<hwc_composer_device_1>(hwc_device_raw, [](hwc_composer_device_1* device) { device->common.close((hw_device_t*) device); }); auto version = mga::HwcVersion::hwc10; switch(hwc_native->common.version) { case HWC_DEVICE_API_VERSION_1_0: version = mga::HwcVersion::hwc10; break; case HWC_DEVICE_API_VERSION_1_1: version = mga::HwcVersion::hwc11; break; case HWC_DEVICE_API_VERSION_1_2: version = mga::HwcVersion::hwc12; break; case HWC_DEVICE_API_VERSION_1_3: version = mga::HwcVersion::hwc13; break; case HWC_DEVICE_API_VERSION_1_4: version = mga::HwcVersion::hwc14; break; default: version = mga::HwcVersion::unknown; break; } return std::make_tuple( std::make_shared<mga::RealHwcWrapper>(hwc_native, hwc_report), version); }
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); }
extern "C" int fbdevws_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); } err = framebuffer_open((hw_module_t *) gralloc, &framebuffer); if (err) { fprintf(stderr, "ERROR: failed to open framebuffer: (%s)\n",strerror(-err)); assert(0); } 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)); eglplatformcommon_init(gralloc); } return display == EGL_DEFAULT_DISPLAY; }
void InitLights() { // assume that if backlight is NULL, nothing has been set yet // if this is not true, the initialization will occur everytime a light is read or set! if (!sLights[hal::eHalLightID_Backlight]) { int err; hw_module_t* module; err = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { sLights[hal::eHalLightID_Backlight] = GetDevice(module, LIGHT_ID_BACKLIGHT); sLights[hal::eHalLightID_Keyboard] = GetDevice(module, LIGHT_ID_KEYBOARD); sLights[hal::eHalLightID_Buttons] = GetDevice(module, LIGHT_ID_BUTTONS); sLights[hal::eHalLightID_Battery] = GetDevice(module, LIGHT_ID_BATTERY); sLights[hal::eHalLightID_Notifications] = GetDevice(module, LIGHT_ID_NOTIFICATIONS); sLights[hal::eHalLightID_Attention] = GetDevice(module, LIGHT_ID_ATTENTION); sLights[hal::eHalLightID_Bluetooth] = GetDevice(module, LIGHT_ID_BLUETOOTH); sLights[hal::eHalLightID_Wifi] = GetDevice(module, LIGHT_ID_WIFI); } } }
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) return; mUpdateOnDemand = (fbDev->setUpdateRect != 0); // initialize the buffer FIFO mNumBuffers = 2; mNumFreeBuffers = 2; mBufferHead = mNumBuffers-1; buffers[0] = new NativeBuffer( fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); buffers[1] = 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[0]->handle, &buffers[0]->stride); LOGE_IF(err, "fb buffer 0 allocation failed w=%d, h=%d, err=%s", fbDev->width, fbDev->height, strerror(-err)); err = grDev->alloc(grDev, fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB, &buffers[1]->handle, &buffers[1]->stride); LOGE_IF(err, "fb buffer 1 allocation failed w=%d, h=%d, err=%s", fbDev->width, fbDev->height, strerror(-err)); const_cast<uint32_t&>(android_native_window_t::flags) = fbDev->flags; const_cast<float&>(android_native_window_t::xdpi) = fbDev->xdpi; const_cast<float&>(android_native_window_t::ydpi) = fbDev->ydpi; const_cast<int&>(android_native_window_t::minSwapInterval) = fbDev->minSwapInterval; const_cast<int&>(android_native_window_t::maxSwapInterval) = fbDev->maxSwapInterval; } else { LOGE("Couldn't get gralloc module"); } android_native_window_t::setSwapInterval = setSwapInterval; android_native_window_t::dequeueBuffer = dequeueBuffer; android_native_window_t::lockBuffer = lockBuffer; android_native_window_t::queueBuffer = queueBuffer; android_native_window_t::query = query; android_native_window_t::perform = perform; }
GstGralloc * gst_gralloc_new () { hw_module_t *hwmod = NULL; gralloc_module_t *gralloc_module = NULL; alloc_device_t *alloc_device = NULL; GstGralloc *gralloc = NULL; int err = hw_get_module (GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &hwmod); if (err != 0) { g_warning ("Failed to load gralloc"); goto out; } gralloc_module = (gralloc_module_t *) hwmod; err = gralloc_open ((const hw_module_t *) gralloc_module, &alloc_device); if (err != 0) { g_warning ("Failed to open gralloc"); goto out; } gralloc = (GstGralloc *) gst_mini_object_new (GST_TYPE_GRALLOC); gralloc->gralloc = gralloc_module; gralloc->allocator = alloc_device; out: return gralloc; }
int main(void) { int status; unsigned int output; hw_module_t* module; status = hw_get_module(BALAMATOR_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (!status) { struct balamator_device_t *balamatordev; status = module->methods->open(module, 0, (struct hw_device_t **) &balamatordev); if (!status) { output = balamatordev->balamator_on(balamatordev); fprintf(stdout, "Balamator Library Interface Value: %u\n", output); balamatordev->common.close((struct hw_device_t *)balamatordev); } else { fprintf(stderr, "Failed to open Device! Id %d\n", status); return 2; } } else { fprintf(stderr, "Failed to get module %s", BALAMATOR_HARDWARE_MODULE_ID); return 1; } return 0; }
static jlong nativeInit(JNIEnv* env, jclass clazz, jobject callbacksObj, jobject messageQueueObj) { int err; hw_module_t* module; err = hw_get_module(HDMI_CEC_HARDWARE_MODULE_ID, const_cast<const hw_module_t **>(&module)); if (err != 0) { ALOGE("Error acquiring hardware module: %d", err); return 0; } hw_device_t* device; err = module->methods->open(module, HDMI_CEC_HARDWARE_INTERFACE, &device); if (err != 0) { ALOGE("Error opening hardware module: %d", err); return 0; } sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj); HdmiCecController* controller = new HdmiCecController( reinterpret_cast<hdmi_cec_device*>(device), env->NewGlobalRef(callbacksObj), messageQueue->getLooper()); controller->init(); GET_METHOD_ID(gHdmiCecControllerClassInfo.handleIncomingCecCommand, clazz, "handleIncomingCecCommand", "(II[B)V"); GET_METHOD_ID(gHdmiCecControllerClassInfo.handleHotplug, clazz, "handleHotplug", "(IZ)V"); return reinterpret_cast<jlong>(controller); }
static boolean android_display_init_drm(struct native_display *ndpy) { struct android_display *adpy = android_display(ndpy); const hw_module_t *mod; int fd, err; #ifndef ANDROID_BACKEND_NO_DRM /* get the authorized fd from gralloc */ err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod); if (!err) { const gralloc_module_t *gr = (gralloc_module_t *) mod; err = -EINVAL; if (gr->perform) err = gr->perform(gr, GRALLOC_MODULE_PERFORM_GET_DRM_FD, &fd); } if (!err && fd >= 0) { adpy->base.screen = adpy->event_handler->new_drm_screen(&adpy->base, NULL, fd); } #endif if (adpy->base.screen) { LOGI("using DRM screen"); return TRUE; } else { LOGW("failed to create DRM screen"); LOGW("will fall back to other EGL drivers if any"); return FALSE; } }
static jint init_native(JNIEnv *env, jobject clazz) { int err; hw_module_t* module; Devices* devices; devices = (Devices*)malloc(sizeof(Devices)); err = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { devices->lights[LIGHT_INDEX_BACKLIGHT] = get_device(module, LIGHT_ID_BACKLIGHT); devices->lights[LIGHT_INDEX_KEYBOARD] = get_device(module, LIGHT_ID_KEYBOARD); devices->lights[LIGHT_INDEX_BUTTONS] = get_device(module, LIGHT_ID_BUTTONS); devices->lights[LIGHT_INDEX_BATTERY] = get_device(module, LIGHT_ID_BATTERY); devices->lights[LIGHT_INDEX_NOTIFICATIONS] = get_device(module, LIGHT_ID_NOTIFICATIONS); devices->lights[LIGHT_INDEX_ATTENTION] = get_device(module, LIGHT_ID_ATTENTION); devices->lights[LIGHT_INDEX_BLUETOOTH] = get_device(module, LIGHT_ID_BLUETOOTH); devices->lights[LIGHT_INDEX_WIFI] = get_device(module, LIGHT_ID_WIFI); } else { memset(devices, 0, sizeof(Devices)); } return (jint)devices; }
static void init_p(int argc, const char **argv) { int err; const hw_module_t *module; hw_device_t *device; err = hw_get_module(BT_HARDWARE_MODULE_ID, &module); if (err) { haltest_error("he_get_module returned %d\n", err); return; } err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device); if (err) { haltest_error("module->methods->open returned %d\n", err); return; } if_bluetooth = ((bluetooth_device_t *) device)->get_bluetooth_interface(); if (!if_bluetooth) { haltest_error("get_bluetooth_interface returned NULL\n"); return; } EXEC(if_bluetooth->init, &bt_callbacks); }
static int loadbltsville(void) { void *hndl = dlopen(BLTSVILLELIB, RTLD_LOCAL | RTLD_LAZY); if (!hndl) { OUTE("Loading bltsville failed"); return -1; } bv_map = (BVFN_MAP)dlsym(hndl, "bv_map"); bv_blt = (BVFN_BLT)dlsym(hndl, "bv_blt"); bv_unmap = (BVFN_UNMAP)dlsym(hndl, "bv_unmap"); if(!bv_blt || !bv_map || !bv_unmap) { OUTE("Missing bltsville fn %p %p %p", bv_map, bv_blt, bv_unmap); return -1; } OUTP("Loaded %s", BLTSVILLELIB); #ifndef RGZ_TEST_INTEGRATION hw_module_t const* module; int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); if (err != 0) { OUTE("Loading gralloc failed"); return -1; } gralloc = (gralloc_module_t const *)module; #endif return 0; }
static const GpsInterface* get_gps_interface() { int error; hw_module_t* module; const GpsInterface* interface = NULL; struct gps_device_t *device; error = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (!error) { error = module->methods->open(module, GPS_HARDWARE_MODULE_ID, (struct hw_device_t **) &device); fprintf(stdout, "*** device info\n id = %s\n name = %s\n author = %s\n", module->id, module->name, module->author); if (!error) { interface = device->get_gps_interface(device); } } else { fprintf(stdout, "*** GPS interface not found :\(\n Bye! \n"); exit(1); } return interface; }
SensorDevice::SensorDevice() : mSensorDevice(0), mSensorModule(0) { status_t err = hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&mSensorModule); ALOGE_IF(err, "couldn't load %s module (%s)", SENSORS_HARDWARE_MODULE_ID, strerror(-err)); if (mSensorModule) { err = sensors_open_1(&mSensorModule->common, &mSensorDevice); ALOGE_IF(err, "couldn't open device for module %s (%s)", SENSORS_HARDWARE_MODULE_ID, strerror(-err)); if (mSensorDevice) { if (mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_1 || mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_2) { ALOGE(">>>> WARNING <<< Upgrade sensor HAL to version 1_3"); } sensor_t const* list; ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list); mActivationCount.setCapacity(count); Info model; for (size_t i=0 ; i<size_t(count) ; i++) { mActivationCount.add(list[i].handle, model); mSensorDevice->activate( reinterpret_cast<struct sensors_poll_device_t *>(mSensorDevice), list[i].handle, 0); } } } }
/** * Initializes the ActivityRecognitionHardware class from the native side. */ static void class_init(JNIEnv* env, jclass clazz) { // open the hardware module int error = hw_get_module( ACTIVITY_RECOGNITION_HARDWARE_MODULE_ID, (const hw_module_t**) &sModule); if (error != 0) { ALOGE("Error hw_get_module: %d", error); return; } error = activity_recognition_open(&sModule->common, &sDevice); if (error != 0) { ALOGE("Error opening device: %d", error); return; } // get references to the Java provided methods sOnActivityChanged = env->GetMethodID( clazz, "onActivityChanged", "([Landroid/hardware/location/ActivityRecognitionHardware$Event;)V"); if (sOnActivityChanged == NULL) { ALOGE("Error obtaining ActivityChanged callback."); return; } // register callbacks sDevice->register_activity_callback(sDevice, &sCallbacks); }
DisplayDispatcher::DisplayDispatcher() { int err; hw_module_t* module; status_t result; err = hw_get_module(DISPLAY_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { //LOGD("DisplayDispatcher createing1 err = %d!\n",err); err = display_open(module, &mDevice); if (err == 0) { LOGE("Open Display Device Failed!\n"); } } else { LOGD("hw_get display module Failed!\n"); } //LOGD("DisplayDispatcher createing err2 = %d!\n",err); mThread = new DisplayDispatcherThread(mDevice); result = mThread->run("DisplayDispatcheR", PRIORITY_HIGHEST); if (result) { LOGE("Could not start DisplayDispatcheR thread due to error %d.", result); mThread->requestExit(); } }
// Opens Framebuffer device static void openFramebufferDevice(hwc_context_t *ctx) { hw_module_t const *module; if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { framebuffer_open(module, &(ctx->mFbDev)); } }
GraphicBufferMapper::GraphicBufferMapper() : mAllocMod(0) { hw_module_t const* module; int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); if (err == 0) { mAllocMod = (gralloc_module_t const *)module; } // [MTK] {{{ // 20120918: gralloc extra device for internal purpose mExtraDev = NULL; if (err == 0) { gralloc_extra_open(module, &mExtraDev); } char value[PROPERTY_VALUE_MAX]; property_get("debug.gbuf.callstack", value, "0"); mIsDumpCallStack = atoi(value); if (true == mIsDumpCallStack) { XLOGI("!!! dump GraphicBufferMapper callstack for pid:%d !!!", getpid()); } // [MTK] }}} }
static void classInitNative(JNIEnv* env, jclass clazz) { int err; hw_module_t* module; jclass jniCallbackClass = env->FindClass("com/android/bluetooth/btservice/JniCallbacks"); sJniCallbacksField = env->GetFieldID(clazz, "mJniCallbacks", "Lcom/android/bluetooth/btservice/JniCallbacks;"); method_stateChangeCallback = env->GetMethodID(jniCallbackClass, "stateChangeCallback", "(I)V"); method_adapterPropertyChangedCallback = env->GetMethodID(jniCallbackClass, "adapterPropertyChangedCallback", "([I[[B)V"); method_discoveryStateChangeCallback = env->GetMethodID(jniCallbackClass, "discoveryStateChangeCallback", "(I)V"); method_devicePropertyChangedCallback = env->GetMethodID(jniCallbackClass, "devicePropertyChangedCallback", "([B[I[[B)V"); method_deviceFoundCallback = env->GetMethodID(jniCallbackClass, "deviceFoundCallback", "([B)V"); method_pinRequestCallback = env->GetMethodID(jniCallbackClass, "pinRequestCallback", "([B[BIZ)V"); method_sspRequestCallback = env->GetMethodID(jniCallbackClass, "sspRequestCallback", "([B[BIII)V"); method_bondStateChangeCallback = env->GetMethodID(jniCallbackClass, "bondStateChangeCallback", "(I[BI)V"); method_aclStateChangeCallback = env->GetMethodID(jniCallbackClass, "aclStateChangeCallback", "(I[BI)V"); method_setWakeAlarm = env->GetMethodID(clazz, "setWakeAlarm", "(JZ)Z"); method_acquireWakeLock = env->GetMethodID(clazz, "acquireWakeLock", "(Ljava/lang/String;)Z"); method_releaseWakeLock = env->GetMethodID(clazz, "releaseWakeLock", "(Ljava/lang/String;)Z"); method_deviceMasInstancesFoundCallback = env->GetMethodID(jniCallbackClass, "deviceMasInstancesFoundCallback", "(I[B[Ljava/lang/String;[I[I[I)V"); method_energyInfo = env->GetMethodID(clazz, "energyInfoCallback", "(IIJJJJ)V"); char value[PROPERTY_VALUE_MAX]; property_get("bluetooth.mock_stack", value, ""); const char *id = (strcmp(value, "1")? BT_STACK_MODULE_ID : BT_STACK_TEST_MODULE_ID); err = hw_get_module(id, (hw_module_t const**)&module); if (err == 0) { hw_device_t* abstraction; err = module->methods->open(module, id, &abstraction); if (err == 0) { bluetooth_module_t* btStack = (bluetooth_module_t *)abstraction; sBluetoothInterface = btStack->get_bluetooth_interface(); } else { ALOGE("Error while opening Bluetooth library"); } } else { ALOGE("No Bluetooth Library found"); } }
SensorDevice::SensorDevice() : mSensorDevice(0), mSensorModule(0) { status_t err = hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&mSensorModule); ALOGE_IF(err, "couldn't load %s module (%s)", SENSORS_HARDWARE_MODULE_ID, strerror(-err)); if (mSensorModule) { err = sensors_open_1(&mSensorModule->common, &mSensorDevice); ALOGE_IF(err, "couldn't open device for module %s (%s)", SENSORS_HARDWARE_MODULE_ID, strerror(-err)); if (mSensorDevice) { sensor_t const* list; ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list); #ifdef SYSFS_LIGHT_SENSOR count = addDummyLightSensor(&list, count); #endif mActivationCount.setCapacity(count); Info model; for (size_t i=0 ; i<size_t(count) ; i++) { mActivationCount.add(list[i].handle, model); mSensorDevice->activate( reinterpret_cast<struct sensors_poll_device_t *>(mSensorDevice), list[i].handle, 0); } } } }
int main(int argc, char** argv) { hw_module_t* module; hdmi_device_t* hdmi; int ret; ret = hw_get_module(HDMI_HARDWARE_MODULE_ID, (const hw_module_t**)&module); if(ret) { LOGE("%s:: Hdmi device not presented", __func__); goto fail; } ret = module->methods->open(module, "hdmi-test", (hw_device_t **)&hdmi); if(ret < 0) { LOGE("%s:: Can't open hdmi device", __func__); goto fail; } ret = hdmi->connect(hdmi); if(ret < 0) { LOGE("%s:: Can't connect hdmi device", __func__); goto close; } #if 1 dump_fbs(5); #endif for(int i = 0; i < 5; i++) { LOGI("Blit cycle: %d", i); ret = hdmi->blit(hdmi, 600, /* default lcd width */ 1024, /* default lcd height */ HAL_PIXEL_FORMAT_BGRA_8888, /* our default pixel format */ 0, 0, 0, /* use default frame buffer */ 0, 0, HDMI_MODE_UI, 0); if(ret < 0) { LOGE("%s:: Can't blit to hdmi device", __func__); break; } } disconnect: if(hdmi->disconnect(hdmi) < 0) { LOGE("%s:: Can't disconnect hdmi device", __func__); } close: if(hdmi->common.close(&hdmi->common) < 0) { LOGE("%s:: Can't close hdmi device", __func__); } fail: LOGI("HDMI result: %d", ret); return ret; }
extern "C" void waylandws_init_module(struct ws_egl_interface *egl_iface) { int err; hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc); err = gralloc_open((const hw_module_t *) gralloc, &alloc); TRACE("++ %lu wayland: got gralloc %p err:%s", pthread_self(), gralloc, strerror(-err)); eglplatformcommon_init(egl_iface, gralloc, alloc); }
FbDevice::FbDevice(){ hw_module_t const *module; if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { framebuffer_open(module, &sFb); } else { ALOGE("FATAL ERROR: framebuffer open failed."); } }
/* * Initializes the Fused Location Provider in the native side. It ensures that * the Flp interfaces are initialized properly. */ static void Init(JNIEnv* env, jobject obj) { if(sHardwareDevice != NULL) { ALOGD("Hardware Device already opened."); return; } const hw_module_t* module = NULL; int err = hw_get_module(FUSED_LOCATION_HARDWARE_MODULE_ID, &module); if(err != 0) { ALOGE("Error hw_get_module '%s': %d", FUSED_LOCATION_HARDWARE_MODULE_ID, err); return; } err = module->methods->open( module, FUSED_LOCATION_HARDWARE_MODULE_ID, &sHardwareDevice); if(err != 0) { ALOGE("Error opening device '%s': %d", FUSED_LOCATION_HARDWARE_MODULE_ID, err); return; } sFlpInterface = NULL; flp_device_t* flp_device = reinterpret_cast<flp_device_t*>(sHardwareDevice); sFlpInterface = flp_device->get_flp_interface(flp_device); if(sFlpInterface != NULL) { sFlpDiagnosticInterface = reinterpret_cast<const FlpDiagnosticInterface*>( sFlpInterface->get_extension(FLP_DIAGNOSTIC_INTERFACE) ); sFlpGeofencingInterface = reinterpret_cast<const FlpGeofencingInterface*>( sFlpInterface->get_extension(FLP_GEOFENCING_INTERFACE) ); sFlpDeviceContextInterface = reinterpret_cast<const FlpDeviceContextInterface*>( sFlpInterface->get_extension(FLP_DEVICE_CONTEXT_INTERFACE) ); } if(sCallbacksObj == NULL) { sCallbacksObj = env->NewGlobalRef(obj); } // initialize the Flp interfaces if(sFlpInterface == NULL || sFlpInterface->init(&sFlpCallbacks) != 0) { ThrowOnError(env, FLP_RESULT_ERROR, __FUNCTION__); } if(sFlpDiagnosticInterface != NULL) { sFlpDiagnosticInterface->init(&sFlpDiagnosticCallbacks); } if(sFlpGeofencingInterface != NULL) { sFlpGeofencingInterface->init(&sFlpGeofenceCallbacks); } // TODO: inject any device context if when needed }
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; }
mg::PlatformPriority probe_graphics_platform(mo::ProgramOption const& /*options*/) { mir::assert_entry_point_signature<mg::PlatformProbe>(&probe_graphics_platform); int err; hw_module_t const* hw_module; err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hw_module); return err < 0 ? mg::PlatformPriority::unsupported : mg::PlatformPriority::best; }
GraphicBufferMapper::GraphicBufferMapper() : mAllocMod(0) { hw_module_t const* module; int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); LOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); if (err == 0) { mAllocMod = (gralloc_module_t const *)module; } }
HWComposer::HWComposer( const sp<SurfaceFlinger>& flinger, EventHandler& handler, nsecs_t refreshPeriod) : mFlinger(flinger), mModule(0), mHwc(0), mList(0), mCapacity(0), mNumOVLayers(0), mNumFBLayers(0), mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE), mEventHandler(handler), mRefreshPeriod(refreshPeriod), mVSyncCount(0), mDebugForceFakeVSync(false) { #ifdef OMAP_ENHANCEMENT mListExt = NULL; #endif char value[PROPERTY_VALUE_MAX]; property_get("debug.sf.no_hw_vsync", value, "0"); mDebugForceFakeVSync = atoi(value); bool needVSyncThread = false; int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule); ALOGW_IF(err, "%s module not found", HWC_HARDWARE_MODULE_ID); if (err == 0) { err = hwc_open(mModule, &mHwc); ALOGE_IF(err, "%s device failed to initialize (%s)", HWC_HARDWARE_COMPOSER, strerror(-err)); if (err == 0) { if (mHwc->registerProcs) { mCBContext.hwc = this; mCBContext.procs.invalidate = &hook_invalidate; mCBContext.procs.vsync = &hook_vsync; #ifdef OMAP_ENHANCEMENT mCBContext.procs.extension_cb = &hook_extension_cb; #endif mHwc->registerProcs(mHwc, &mCBContext.procs); memset(mCBContext.procs.zero, 0, sizeof(mCBContext.procs.zero)); } if (mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) { if (mDebugForceFakeVSync) { // make sure to turn h/w vsync off in "fake vsync" mode mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0); } } else { needVSyncThread = true; } } } else { needVSyncThread = true; } if (needVSyncThread) { // we don't have VSYNC support, we need to fake it mVSyncThread = new VSyncThread(*this); } }