hw_get_moduleと、GRALLOC_HARDWARE_MODULE_IDがある場所は?
どうして3箇所、あるんだろ?
38 GraphicBufferMapper::GraphicBufferMapper() 39 : mAllocMod(0) 40 { 41 hw_module_t const* module; 42 int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); <=ここ 43 ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); 44 if (err == 0) { 45 mAllocMod = (gralloc_module_t const *)module; 46 } 47 }
38 GraphicBufferAllocator::GraphicBufferAllocator() 39 : mAllocDev(0) 40 { 41 hw_module_t const* module; 42 int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); <=ここ 43 ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); 44 if (err == 0) { 45 gralloc_open(module, &mAllocDev); 46 } 47 }
75 FramebufferNativeWindow::FramebufferNativeWindow() 76 : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false) 77 { 78 hw_module_t const* module; 79 if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { <=ここ 80 int stride; 81 int err; 82 int i; 83 err = framebuffer_open(module, &fbDev); 84 ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err)); 85 86 err = gralloc_open(module, &grDev); 87 ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err)); 88 89 // bail out if we can't initialize the modules 90 if (!fbDev || !grDev) 91 return; 92 93 mUpdateOnDemand = (fbDev->setUpdateRect != 0); 94 95 // initialize the buffer FIFO 96 if(fbDev->numFramebuffers >= MIN_NUM_FRAME_BUFFERS && 97 fbDev->numFramebuffers <= MAX_NUM_FRAME_BUFFERS){ 98 mNumBuffers = fbDev->numFramebuffers; 99 } else { 100 mNumBuffers = MIN_NUM_FRAME_BUFFERS; 101 } 102 mNumFreeBuffers = mNumBuffers; 103 mBufferHead = mNumBuffers-1; 104 105 /* 106 * This does not actually change the framebuffer format. It merely 107 * fakes this format to surfaceflinger so that when it creates 108 * framebuffer surfaces it will use this format. It's really a giant 109 * HACK to allow interworking with buggy gralloc+GPU driver 110 * implementations. You should *NEVER* need to set this for shipping 111 * devices. 112 */ 113 #ifdef FRAMEBUFFER_FORCE_FORMAT 114 *((uint32_t *)&fbDev->format) = FRAMEBUFFER_FORCE_FORMAT; 115 #endif 116 117 for (i = 0; i < mNumBuffers; i++) 118 { 119 buffers[i] = new NativeBuffer( 120 fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); 121 } 122 123 for (i = 0; i < mNumBuffers; i++) 124 { 125 err = grDev->alloc(grDev, 126 fbDev->width, fbDev->height, fbDev->format, 127 GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride); 128 129 ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s", 130 i, fbDev->width, fbDev->height, strerror(-err)); 131 132 if (err) 133 { 134 mNumBuffers = i; 135 mNumFreeBuffers = i; 136 mBufferHead = mNumBuffers-1; 137 break; 138 } 139 } 140 141 const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; 142 const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi; 143 const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi; 144 const_cast<int&>(ANativeWindow::minSwapInterval) = 145 fbDev->minSwapInterval; 146 const_cast<int&>(ANativeWindow::maxSwapInterval) = 147 fbDev->maxSwapInterval; 148 } else { 149 ALOGE("Couldn't get gralloc module"); 150 } 151 152 ANativeWindow::setSwapInterval = setSwapInterval; 153 ANativeWindow::dequeueBuffer = dequeueBuffer; 154 ANativeWindow::queueBuffer = queueBuffer; 155 ANativeWindow::query = query; 156 ANativeWindow::perform = perform; 157 158 ANativeWindow::dequeueBuffer_DEPRECATED = dequeueBuffer_DEPRECATED; 159 ANativeWindow::lockBuffer_DEPRECATED = lockBuffer_DEPRECATED; 160 ANativeWindow::queueBuffer_DEPRECATED = queueBuffer_DEPRECATED; 161 }
247 // Load and prepare the FB HAL, which uses the gralloc module. Sets mFbDev. 248 void HWComposer::loadFbHalModule() 249 { 250 hw_module_t const* module; 251 252 if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) != 0) { 253 ALOGE("%s module not found", GRALLOC_HARDWARE_MODULE_ID); 254 return; 255 } 256 257 int err = framebuffer_open(module, &mFbDev); 258 if (err) { 259 ALOGE("framebuffer_open failed (%s)", strerror(-err)); 260 return; 261 } 262 }
1699 static int omap4_hwc_open_fb_hal(IMG_framebuffer_device_public_t **fb_dev) 1700 { 1701 const struct hw_module_t *psModule; 1702 IMG_gralloc_module_public_t *psGrallocModule; 1703 int err; 1704 1705 err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &psModule); 1706 psGrallocModule = (IMG_gralloc_module_public_t *) psModule; 1707 1708 if(err) 1709 goto err_out; 1710 1711 if (strcmp(psGrallocModule->base.common.author, "Imagination Technologies")) { 1712 err = -EINVAL; 1713 goto err_out; 1714 } 1715 1716 *fb_dev = psGrallocModule->psFrameBufferDevice; 1717 1718 return 0; 1719 1720 err_out: 1721 ALOGE("Composer HAL failed to load compatible Graphics HAL"); 1722 return err; 1723 }