MVOID Ts_IT:: TS_Thread_Init(int count) { MY_LOGD("E"); Mutex::Autolock lock(mLock); MY_LOGD("mInitCount(%d)", mInitCount); if(mInitCount > 0) { android_atomic_inc(&mInitCount); } else { // Init semphore ::sem_init(&m_semTestEnDequethread, 0, 0); // Create main thread for preview and capture pthread_create(&m_TestEnDequethread, NULL, previewProc, (void *)count); android_atomic_inc(&mInitCount); pthread_join(m_TestEnDequethread, NULL); } MY_LOGD("X"); }
MBOOL IspDebug:: init() { char value[PROPERTY_VALUE_MAX] = {'\0'}; property_get("debug.isp_debug.enable", value, "1"); m_bDebugEnable = atoi(value); Mutex::Autolock lock(m_Lock); if (m_Users > 0) { MY_LOG("%d has created \n", m_Users); android_atomic_inc(&m_Users); return MTRUE; } m_pIspDrv = IspDrv::createInstance(); if (!m_pIspDrv) { MY_ERR("IspDrv::createInstance() fail \n"); return MFALSE; } m_pIspDrv->init(); m_pIspReg = (isp_reg_t*)m_pIspDrv->getRegAddr(); android_atomic_inc(&m_Users); return MTRUE; }
void RefBase::weakref_type::incWeak(const void* id) { weakref_impl* const impl = static_cast<weakref_impl*>(this); impl->addWeakRef(id); const int32_t c = android_atomic_inc(&impl->mWeak); ALOG_ASSERT(c >= 0, "incWeak called on %p after last weak ref", this); }
ssize_t SharedBufferServer::RetireUpdate::operator()() { int32_t head = stack.head; if (uint32_t(head) >= SharedBufferStack::NUM_BUFFER_MAX) return BAD_VALUE; // Decrement the number of queued buffers int32_t queued; do { queued = stack.queued; if (queued == 0) { return NOT_ENOUGH_DATA; } } while (android_atomic_cmpxchg(queued, queued-1, &stack.queued)); // lock the buffer before advancing head, which automatically unlocks // the buffer we preventively locked upon entering this function head = (head + 1) % numBuffers; const int8_t headBuf = stack.index[head]; stack.headBuf = headBuf; // head is only modified here, so we don't need to use cmpxchg android_atomic_write(head, &stack.head); // now that head has moved, we can increment the number of available buffers android_atomic_inc(&stack.available); return head; }
BufferedTextOutput::BufferedTextOutput(uint32_t flags) : mFlags(flags) , mSeq(android_atomic_inc(&gSequence)) , mIndex(allocBufferIndex()) { mGlobalState = new BufferState(mSeq); if (mGlobalState) mGlobalState->incStrong(this); }
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, const sp<Client>& client) : LayerBase(flinger), mHasSurface(false), mClientRef(client), mIdentity(uint32_t(android_atomic_inc(&sIdentity))) { }
Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags) : contentDirty(false), sequence(uint32_t(android_atomic_inc(&sSequence))), mFlinger(flinger), mTextureName(-1U), mPremultipliedAlpha(true), mName("unnamed"), mDebug(false), mFormat(PIXEL_FORMAT_NONE), mOpaqueLayer(true), mNeedsDithering(false), mTransactionFlags(0), mQueuedFrames(0), mCurrentTransform(0), mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), mCurrentOpacity(true), mRefreshPending(false), mFrameLatencyNeeded(false), mFiltering(false), mNeedsFiltering(false), mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2), mSecure(false), mProtectedByApp(false), mHasSurface(false), mClientRef(client) { mCurrentCrop.makeInvalid(); mFlinger->getRenderEngine().genTextures(1, &mTextureName); mTexture.init(Texture::TEXTURE_EXTERNAL, mTextureName); uint32_t layerFlags = 0; if (flags & ISurfaceComposerClient::eHidden) layerFlags = layer_state_t::eLayerHidden; if (flags & ISurfaceComposerClient::eNonPremultiplied) mPremultipliedAlpha = false; mName = name; mCurrentState.active.w = w; mCurrentState.active.h = h; mCurrentState.active.crop.makeInvalid(); mCurrentState.z = 0; mCurrentState.alpha = 0xFF; mCurrentState.layerStack = 0; mCurrentState.flags = layerFlags; mCurrentState.sequence = 0; mCurrentState.transform.set(0, 0); mCurrentState.requested = mCurrentState.active; // drawing state & current state are identical mDrawingState = mCurrentState; nsecs_t displayPeriod = flinger->getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY); mFrameTracker.setDisplayRefreshPeriod(displayPeriod); }
LayerBase::LayerBase(SurfaceFlinger* flinger) : contentDirty(false), sequence(uint32_t(android_atomic_inc(&sSequence))), mFlinger(flinger), mFiltering(false), mNeedsFiltering(false), mTransactionFlags(0), mPremultipliedAlpha(true), mName("unnamed"), mDebug(false) { }
jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val) { if (val == NULL) return NULL; if (val->checkSubclass(&gBinderOffsets)) { // One of our own! jobject object = static_cast<JavaBBinder*>(val.get())->object(); LOGDEATH("objectForBinder %p: it's our own %p!\n", val.get(), object); return object; } // For the rest of the function we will hold this lock, to serialize // looking/creation of Java proxies for native Binder proxies. AutoMutex _l(mProxyLock); // Someone else's... do we know about it? jobject object = (jobject)val->findObject(&gBinderProxyOffsets); if (object != NULL) { jobject res = jniGetReferent(env, object); if (res != NULL) { ALOGV("objectForBinder %p: found existing %p!\n", val.get(), res); return res; } LOGDEATH("Proxy object %p of IBinder %p no longer in working set!!!", object, val.get()); android_atomic_dec(&gNumProxyRefs); val->detachObject(&gBinderProxyOffsets); env->DeleteGlobalRef(object); } object = env->NewObject(gBinderProxyOffsets.mClass, gBinderProxyOffsets.mConstructor); if (object != NULL) { LOGDEATH("objectForBinder %p: created new proxy %p !\n", val.get(), object); // The proxy holds a reference to the native object. env->SetLongField(object, gBinderProxyOffsets.mObject, (jlong)val.get()); val->incStrong((void*)javaObjectForIBinder); // The native object needs to hold a weak reference back to the // proxy, so we can retrieve the same proxy if it is still active. jobject refObject = env->NewGlobalRef( env->GetObjectField(object, gBinderProxyOffsets.mSelf)); val->attachObject(&gBinderProxyOffsets, refObject, jnienv_to_javavm(env), proxy_cleanup); // Also remember the death recipients registered on this proxy sp<DeathRecipientList> drl = new DeathRecipientList; drl->incStrong((void*)javaObjectForIBinder); env->SetLongField(object, gBinderProxyOffsets.mOrgue, reinterpret_cast<jlong>(drl.get())); // Note that a new object reference has been created. android_atomic_inc(&gNumProxyRefs); incRefsCreated(env); } return object; }
void HeapCache::pin_heap(const sp<IBinder>& binder) { Mutex::Autolock _l(mHeapCacheLock); ssize_t i = mHeapCache.indexOfKey(binder); if (i>=0) { heap_info_t& info(mHeapCache.editValueAt(i)); android_atomic_inc(&info.count); binder->linkToDeath(this); } else { LOGE("pin_heap binder=%p not found!!!", binder.get()); } }
/* * Exercise several of the atomic ops. */ static void doAtomicTest(int num) { int addVal = (num & 0x01) + 1; int i; for (i = 0; i < ITERATION_COUNT; i++) { if (USE_ATOMIC) { android_atomic_inc(&incTest); android_atomic_dec(&decTest); android_atomic_add(addVal, &addTest); int val; do { val = casTest; } while (android_atomic_release_cas(val, val + 3, &casTest) != 0); do { val = casTest; } while (android_atomic_acquire_cas(val, val - 1, &casTest) != 0); int64_t wval; do { wval = dvmQuasiAtomicRead64(&wideCasTest); } while (dvmQuasiAtomicCas64(wval, wval + 0x0000002000000001LL, &wideCasTest) != 0); do { wval = dvmQuasiAtomicRead64(&wideCasTest); } while (dvmQuasiAtomicCas64(wval, wval - 0x0000002000000001LL, &wideCasTest) != 0); } else { incr(); decr(); add(addVal); int val; do { val = casTest; } while (compareAndSwap(val, val + 3, &casTest) != 0); do { val = casTest; } while (compareAndSwap(val, val - 1, &casTest) != 0); int64_t wval; do { wval = wideCasTest; } while (compareAndSwapWide(wval, wval + 0x0000002000000001LL, &wideCasTest) != 0); do { wval = wideCasTest; } while (compareAndSwapWide(wval, wval - 0x0000002000000001LL, &wideCasTest) != 0); } } }
LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display) : dpy(display), contentDirty(false), sequence(uint32_t(android_atomic_inc(&sSequence))), mFlinger(flinger), mFiltering(false), mNeedsFiltering(false), mOrientation(0), mPlaneOrientation(0), mTransactionFlags(0), mPremultipliedAlpha(true), mName("unnamed"), mDebug(false) { const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware()); mFlags = hw.getFlags(); }
LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display) : dpy(display), invalidate(false), mFlinger(flinger), mTransformed(false), mOrientation(0), mCanUseCopyBit(false), mTransactionFlags(0), mPremultipliedAlpha(true), mIdentity(uint32_t(android_atomic_inc(&sIdentity))) { const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware()); mFlags = hw.getFlags(); }
//---------------------------------------------------------------------------- MBOOL PipeMgrDrvImp::Init(void) { MBOOL Result = MTRUE; // Mutex::Autolock lock(mLock); // if(mUser == 0) { LOG_MSG("First user(%d)",mUser); } else { LOG_MSG("More user(%d)",mUser); android_atomic_inc(&mUser); goto EXIT; } // if(mFd < 0) { mFd = open(PIPE_MGR_DRV_DEVNAME, O_RDONLY, 0); if(mFd < 0) { LOG_ERR("CamPipeMgr kernel open fail, errno(%d):%s",errno,strerror(errno)); Result = MFALSE; goto EXIT; } } else { LOG_MSG("CamPipeMgr kernel is opened already"); } // android_atomic_inc(&mUser); // EXIT: return Result; }
LayerBase::LayerBase(SurfaceFlinger* flinger) : contentDirty(false), sequence(uint32_t(android_atomic_inc(&sSequence))), mFlinger(flinger), mFiltering(false), mNeedsFiltering(false), mTransactionFlags(0), mPremultipliedAlpha(true), mName("unnamed"), mDebug(false) { const sp<const DisplayDevice> hw(mFlinger->getDefaultDisplayDevice()); if(hw->setDispProp(DISPLAY_CMD_GETDISPLAYMODE,0,0,0) == DISPLAY_MODE_SINGLE_VAR_GPU) { mDispWidth = hw->setDispProp(DISPLAY_CMD_GETDISPPARA,0,DISPLAY_VALID_WIDTH,0); mDispHeight = hw->setDispProp(DISPLAY_CMD_GETDISPPARA,0,DISPLAY_VALID_HEIGHT,0); } }
int V4L2VideoNode::qbuf(struct v4l2_buffer_info *buf) { LOG2("@%s", __FUNCTION__); struct v4l2_buffer *v4l2_buf = &buf->vbuffer; int ret = 0; v4l2_buf->flags = buf->cache_flags; ret = pioctl(mFd, VIDIOC_QBUF, v4l2_buf); if (ret < 0) { LOGE("VIDIOC_QBUF on %s failed: %s", mName.string(), strerror(errno)); return ret; } android_atomic_inc(&mBuffersInDevice); return ret; }
sp<IMediaPlayer> MediaPlayerService::create(pid_t pid, const sp<IMediaPlayerClient>& client, const char* url) { int32_t connId = android_atomic_inc(&mNextConnId); sp<Client> c = new Client(this, pid, connId, client); LOGV("Create new client(%d) from pid %d, url=%s, connId=%d", connId, pid, url, connId); if (NO_ERROR != c->setDataSource(url)) { c.clear(); return c; } wp<Client> w = c; Mutex::Autolock lock(mLock); mClients.add(w); return c; }
MVOID Ts_UT:: TS_Thread_Init(int count) { printf("[TS_Thread_Init] E\n"); Mutex::Autolock lock(mLock); printf("[TS_Thread_Init] mInitCount(%d) \n", mInitCount); // if(mInitCount > 0) { android_atomic_inc(&mInitCount); } else { // Init semphore ::sem_init(&m_semTestEnDequethread, 0, 0); // Create main thread for preview and capture pthread_create(&m_TestEnDequethread, NULL, endeque_Thread, (void *)count); android_atomic_inc(&mInitCount); pthread_join(m_TestEnDequethread, NULL); } printf("[TS_Thread_Init] X\n"); }
int StrobeGlobalDriver::openkd_nolock() { if(mUsers==0) { mStrobeHandle = open(STROBE_DEV_NAME, O_RDWR); logI("open flash driver kd=%d", mStrobeHandle); } if (mStrobeHandle <= 0) { logE("error openkd_nolock %s: %s", STROBE_DEV_NAME, strerror(errno)); return StrobeDrv::STROBE_UNKNOWN_ERROR; } android_atomic_inc(&mUsers); return 0; }
sp<IMediaPlayer> MediaPlayerService::create(pid_t pid, const sp<IMediaPlayerClient>& client, int fd, int64_t offset, int64_t length) { int32_t connId = android_atomic_inc(&mNextConnId); sp<Client> c = new Client(this, pid, connId, client); LOGV("Create new client(%d) from pid %d, fd=%d, offset=%lld, length=%lld", connId, pid, fd, offset, length); if (NO_ERROR != c->setDataSource(fd, offset, length)) { c.clear(); } else { wp<Client> w = c; Mutex::Autolock lock(mLock); mClients.add(w); } ::close(fd); return c; }
void RefBase::incStrong(const void* id) const { weakref_impl* const refs = mRefs; refs->incWeak(id); refs->addStrongRef(id); const int32_t c = android_atomic_inc(&refs->mStrong); ALOG_ASSERT(c > 0, "incStrong() called on %p after last strong ref", refs); #if PRINT_REFS ALOGD("incStrong of %p from %p: cnt=%d\n", this, id, c); #endif if (c != INITIAL_STRONG_VALUE) { return; } android_atomic_add(-INITIAL_STRONG_VALUE, &refs->mStrong); refs->mBase->onFirstRef(); }
LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display) : dpy(display), contentDirty(false), sequence(uint32_t(android_atomic_inc(&sSequence))), mFlinger(flinger), mNeedsFiltering(false), mOrientation(0), mLeft(0), mTop(0), mTransactionFlags(0), mPremultipliedAlpha(true), mName("unnamed"), mDebug(false), mInvalidate(0) #ifdef AVOID_DRAW_TEXTURE ,mTransformed(false) #endif { const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware()); mFlags = hw.getFlags(); mBufferCrop.makeInvalid(); mBufferTransform = 0; }
MINT32 mHalCam::mHalCamVideoProc( ) { MINT32 err = MHAL_NO_ERROR; VideoFrame rVideoFrame; if (0 == getVideoFrame(rVideoFrame)) { mhalCamTimeStampBufCBInfo rCamTimeStampBufCB(rVideoFrame.hwIndex, rVideoFrame.timeStampS, rVideoFrame.timeStampUs); android_atomic_inc(&mVdoBusyFrmCnt); MCAM_DBG1("[mHalCamVideoProc] Video CB (index, stampS, stampUs, busyCnt) = (%d, %d, %d, %d)\n", rVideoFrame.hwIndex, rVideoFrame.timeStampS, rVideoFrame.timeStampUs, mVdoBusyFrmCnt); mHalCamCBHandle(MHAL_CAM_CB_VIDEO_RECORD, &rCamTimeStampBufCB); } return err; }
void RefBase::forceIncStrong(const void* id) const { weakref_impl* const refs = mRefs; refs->incWeak(id); refs->addStrongRef(id); const int32_t c = android_atomic_inc(&refs->mStrong); ALOG_ASSERT(c >= 0, "forceIncStrong called on %p after ref count underflow", refs); #if PRINT_REFS ALOGD("forceIncStrong of %p from %p: cnt=%d\n", this, id, c); #endif switch (c) { case INITIAL_STRONG_VALUE: android_atomic_add(-INITIAL_STRONG_VALUE, &refs->mStrong); // fall through... case 0: refs->mBase->onFirstRef(); } }
sp<IMemoryHeap> HeapCache::find_heap(const sp<IBinder>& binder) { Mutex::Autolock _l(mHeapCacheLock); ssize_t i = mHeapCache.indexOfKey(binder); if (i>=0) { heap_info_t& info = mHeapCache.editValueAt(i); ALOGD_IF(VERBOSE, "found binder=%p, heap=%p, size=%d, fd=%d, count=%d", binder.get(), info.heap.get(), static_cast<BpMemoryHeap*>(info.heap.get())->mSize, static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId, info.count); android_atomic_inc(&info.count); return info.heap; } else { heap_info_t info; info.heap = interface_cast<IMemoryHeap>(binder); info.count = 1; //ALOGD("adding binder=%p, heap=%p, count=%d", // binder.get(), info.heap.get(), info.count); mHeapCache.add(binder, info); return info.heap; } }
void LayerBase::forceVisibilityTransaction() { // this can be called without SurfaceFlinger.mStateLock, but if we // can atomically increment the sequence number, it doesn't matter. android_atomic_inc(&mCurrentState.sequence); requestTransaction(); }
// Get an ID that's unique within this process. static int32_t createProcessUniqueId() { static volatile int32_t globalCounter = 0; return android_atomic_inc(&globalCounter); }
MINT32 EisHal::init() { EIS_LOG("mUsers(%d)", mUsers); //====== Check Reference Count ====== Mutex::Autolock lock(mLock); if(mUsers > 0) { EIS_LOG("%d has created", mUsers); android_atomic_inc(&mUsers); return EIS_RETURN_NO_ERROR; } //====== Dynamic Debug ====== char value[PROPERTY_VALUE_MAX] = {'\0'}; property_get("debug.eis.dump", value, "0"); g_debugDump = atoi(value); //====== Create EIS Driver ====== m_pEisDrv = EisDrvBase::createInstance(); if(m_pEisDrv == NULL) { EIS_ERR("EisDrv::createInstance fail"); goto create_fail_exit; } //====== Create EIS Algorithm Object ====== m_pEisAlg = MTKEis::createInstance(); if(m_pEisAlg == NULL) { EIS_ERR("EisAlg::createInstance fail"); goto create_fail_exit; } if(g_debugDump >= 2) { //====== EisAlgo Debug Buffer ====== m_pIMemDrv = IMemDrv::createInstance(); if(m_pIMemDrv == NULL) { EIS_ERR("Null IMemDrv Obj"); return EIS_RETURN_NULL_OBJ; } MUINT32 eisMemSize = EIS_LOG_BUFFER_SIZE; createMemBuf(eisMemSize,1,&mEisAlgoIMemBuf); if(mEisAlgoIMemBuf.virtAddr == 0 && mEisAlgoIMemBuf.phyAddr == 0) { EIS_ERR("create IMem fail"); return EIS_RETURN_MEMORY_ERROR; } EIS_LOG("mEisAlgoIMemBuf : memID(%d),size(%u),virAdd(0x%x),phyAddr(0x%x)",mEisAlgoIMemBuf.memID, mEisAlgoIMemBuf.size, mEisAlgoIMemBuf.virtAddr, mEisAlgoIMemBuf.phyAddr); } android_atomic_inc(&mUsers); EIS_LOG("-"); return EIS_RETURN_NO_ERROR; create_fail_exit: if(m_pEisDrv != NULL) { m_pEisDrv->destroyInstance(); m_pEisDrv = NULL; } if(m_pEisAlg != NULL) { m_pEisAlg->destroyInstance(); m_pEisAlg = NULL; } EIS_LOG("-"); return EIS_RETURN_INVALID_DRIVER; }
MBOOL HdrHal::init(void *pInitInData) { HDR_LOGD("- E. mUsers: %d.", mUsers); HDR_PIPE_INIT_INFO* prHdrPipeInitInfo = (HDR_PIPE_INIT_INFO*)pInitInData; HDR_LOGV("ImgW/H: (%d, %d). FinalGainDiff[0/1]: (%d, %d). OutputFrameNum: %d. TargetTone: %d.", prHdrPipeInitInfo->u4ImgW, prHdrPipeInitInfo->u4ImgH, prHdrPipeInitInfo->u4FinalGainDiff0, prHdrPipeInitInfo->u4FinalGainDiff1, prHdrPipeInitInfo->u4OutputFrameNum, prHdrPipeInitInfo->u4TargetTone); HDR_LOGV("pSourceImgBufAddr[0/1/2]: (%p, %p, %p).", prHdrPipeInitInfo->pSourceImgBufAddr[0], prHdrPipeInitInfo->pSourceImgBufAddr[1], prHdrPipeInitInfo->pSourceImgBufAddr[2]); MBOOL ret = MFALSE; MINT32 err = 0; // 0: No error. other value: error. Mutex::Autolock lock(mLock); if (mUsers > 0) { HDR_LOGD("%d has created.", mUsers); android_atomic_inc(&mUsers); HDR_LOGD("- X. ret: %d.", MTRUE); return MTRUE; } // Create HdrDrv instance. m_pHdrDrv = MTKHdr::createInstance(); if (!m_pHdrDrv) { HDR_LOGD("MTKHdr::createInstance() fail."); goto create_fail_exit; } // Allocate working buffer needed by Drv (HdrDrv and MavDrv). // Init HdrDrv object. // Fill init data. HDR_SET_ENV_INFO_STRUCT rHdrInitInfo; rHdrInitInfo.image_num = prHdrPipeInitInfo->u4OutputFrameNum; GS_u4OutputFrameNum = prHdrPipeInitInfo->u4OutputFrameNum; // Record u4OutputFrameNum for HDR Pipe to use. rHdrInitInfo.ev_gain1 = (MUINT16)prHdrPipeInitInfo->u4FinalGainDiff0; rHdrInitInfo.ev_gain2 = 1024; // Fix at 1024. rHdrInitInfo.ev_gain3 = (MUINT16)prHdrPipeInitInfo->u4FinalGainDiff1; rHdrInitInfo.target_tone = prHdrPipeInitInfo->u4TargetTone; rHdrInitInfo.image_width = prHdrPipeInitInfo->u4ImgW; rHdrInitInfo.image_height = prHdrPipeInitInfo->u4ImgH; if(CustomHdrUseIspGamma()) { HDR_LOGD("Use ISP Gamma"); rHdrInitInfo.pIsp_gamma = prHdrPipeInitInfo->pIsp_gamma; } else { HDR_LOGD("Use Fixed Gamma"); rHdrInitInfo.pIsp_gamma = NULL; } rHdrInitInfo.hdr_tuning_data.BRatio = CustomHdrBRatioGet(); for (MUINT32 i = 0; i < 11; i++) { rHdrInitInfo.hdr_tuning_data.Gain[i] = CustomHdrGainArrayGet(i); } rHdrInitInfo.hdr_tuning_data.BottomFRatio = CustomHdrBottomFRatioGet(); rHdrInitInfo.hdr_tuning_data.TopFRatio = CustomHdrTopFRatioGet(); rHdrInitInfo.hdr_tuning_data.BottomFBound = CustomHdrBottomFBoundGet(); rHdrInitInfo.hdr_tuning_data.TopFBound = CustomHdrTopFBoundGet(); rHdrInitInfo.hdr_tuning_data.ThHigh = CustomHdrThHighGet(); rHdrInitInfo.hdr_tuning_data.ThLow = CustomHdrThLowGet(); rHdrInitInfo.hdr_tuning_data.TargetLevelSub = CustomHdrTargetLevelSubGet(); rHdrInitInfo.hdr_tuning_data.CoreNumber = CustomHdrCoreNumberGet(); rHdrInitInfo.hdr_tuning_data.HdrSpeed = HDR_PROCESS_NORMAL; //Never use HDR_PROCESS_FAST rHdrInitInfo.HdrSrcInfo = (prHdrPipeInitInfo->u4SensorType == NSCam::SENSOR_TYPE_YUV) ? HDR_INFO_SRC_YUV : HDR_INFO_SRC_RAW; HDR_LOGD("rHdrInitInfo:: ImgW/H: (%d, %d). FinalGainDiff[0/1]: (%d, %d). OutputFrameNum: %d. TargetTone: %d. RawSensor: %d." , rHdrInitInfo.image_width , rHdrInitInfo.image_height , rHdrInitInfo.ev_gain1 , rHdrInitInfo.ev_gain3 , rHdrInitInfo.image_num , rHdrInitInfo.target_tone , rHdrInitInfo.HdrSrcInfo); //HDR_LOGV("rHdrInitInfo:: pSourceImgBufAddr[0/1/2]: (0x%08X, 0x%08X, 0x%08X).", rHdrInitInfo.image_addr[0], rHdrInitInfo.image_addr[1], rHdrInitInfo.image_addr[2]); HDR_LOGV("rHdrInitInfo:: BRatio: %d. BottomFRatio: %f. TopFRatio: %f. BottomFBound: %d. TopFBound: %d.", rHdrInitInfo.hdr_tuning_data.BRatio, rHdrInitInfo.hdr_tuning_data.BottomFRatio, rHdrInitInfo.hdr_tuning_data.TopFRatio, rHdrInitInfo.hdr_tuning_data.BottomFBound, rHdrInitInfo.hdr_tuning_data.TopFBound ); HDR_LOGV("rHdrInitInfo:: ThHigh: %d. ThLow: %d. TargetLevelSub: %d.", rHdrInitInfo.hdr_tuning_data.ThHigh, rHdrInitInfo.hdr_tuning_data.ThLow, rHdrInitInfo.hdr_tuning_data.TargetLevelSub ); for (MUINT32 i = 0; i < 11; i++) HDR_LOGV("rHdrInitInfo:: u4Gain[%d]: %d.", i, rHdrInitInfo.hdr_tuning_data.Gain[i]); // Call HdrDrv init. err = m_pHdrDrv->HdrInit(&rHdrInitInfo, 0); if (err) // if ret != 0 means error happened. { HDR_LOGD("m_pHdrDrv->HdrInit() fail, err=%d", err); goto create_fail_exit; } if(1) { // set HDR default pthread attribute to avoid RT throttling pthread_attr_t attr = {0, NULL, 1024 * 1024, 4096, SCHED_OTHER, ANDROID_PRIORITY_FOREGROUND+1}; m_pHdrDrv->HdrFeatureCtrl(HDR_FEATURE_SET_PTHREAD_ATTR, &attr, NULL); } #if EARLY_MAV_INIT // Create MavDrv instance. m_pMavDrv = MTKMav::createInstance(DRV_MAV_OBJ_SWHDR); if (!m_pMavDrv) { HDR_LOGD("MTKMav::createInstance() fail."); goto create_fail_exit; } // Init MavDrv object. // Fill init data. MavInitInfo rMavInitInfo; rMavInitInfo.WorkingBuffAddr = (MUINT32)global_buffer_rectify; // FIXME: Allocate working buffer for MAV. rMavInitInfo.pTuningInfo = NULL; // Call MavDrv init. err = m_pMavDrv->MavInit(&rMavInitInfo, 0); if (err) // if ret != 0 means error happened. { HDR_LOGD("m_pMavDrv->MavInit() fail. err: %d.", err); goto create_fail_exit; } #endif // EARLY_MAV_INIT android_atomic_inc(&mUsers); ret = MTRUE; HDR_LOGD("- X. ret: %d.", ret); return ret; create_fail_exit: // HdrDrv Init failed, destroy HdrDrv instance. if (m_pHdrDrv) { m_pHdrDrv->destroyInstance(); m_pHdrDrv = NULL; } #if EARLY_MAV_INIT // MavDrv Init failed, destroy MavDrv instance. if (m_pMavDrv) { m_pMavDrv->MavReset(); m_pMavDrv->destroyInstance(); m_pMavDrv = NULL; } #endif // EARLY_MAV_INIT HDR_LOGD("- X. ret: %d.", ret); return ret; // 0: No error. other value: error. }
uint32_t CameraRecordService::nextUniqueId() { REPORT_FUNCTION(); return android_atomic_inc(&mNextUniqueId); }