Exemplo n.º 1
0
int openSocket(const int port, const char * peer) {
    int fd,res,opt;
    struct sockaddr_in addr;
    socklen_t addrlen;
#ifndef DONT_USE_GETHOSTBYNAME    
    char hBuf[10000];
    struct hostent hostbuf, *he;
    //struct hostent *he;
#endif    
    if (daveDebug & daveDebugOpen) {
	LOG1(ThisModule "enter OpenSocket");
	FLUSH;
    }
    addr.sin_family = AF_INET;
    addr.sin_port =htons(port);
//	(((port) & 0xff) << 8) | (((port) & 0xff00) >> 8);
#ifndef DONT_USE_GETHOSTBYNAME
    int herr;
    gethostbyname_r(peer, &hostbuf, hBuf, sizeof(hBuf), &he, &herr);
    //he = gethostbyname(peer);
    if (!he) return 0;  // bug reported by Nick Hibma
    memcpy(&addr.sin_addr, he->h_addr_list[0], sizeof(addr.sin_addr));
#else
    inet_aton(peer, &addr.sin_addr);
#endif

    fd = socket(AF_INET, SOCK_STREAM, 0);
    if (daveDebug & daveDebugOpen) {
	LOG2(ThisModule "OpenSocket: socket is %d\n", fd);
    }	
    
    addrlen = sizeof(addr);
    if (connect(fd, (struct sockaddr *) & addr, addrlen)) {
	LOG2(ThisModule "Socket error: %s \n", strerror(errno));
	close(fd);
	fd = 0;
    } else {
	if (daveDebug & daveDebugOpen) {
	    LOG2(ThisModule "Connected to host: %s \n", peer);
	}    
/*
	Need this, so we can read a packet with a single read call and make
	read return if there are too few bytes.
*/	
	errno=0;
//	res=fcntl(fd, F_SETFL, O_NONBLOCK);
//	if (daveDebug & daveDebugOpen) 
//	    LOG3(ThisModule "Set mode to O_NONBLOCK %s %d\n", strerror(errno),res);
/*
	I thought this might solve Marc's problem with the CP closing
	a connection after 30 seconds or so, but the Standrad keepalive time
	on my box is 7200 seconds.	    
*/	
	errno=0;
	opt=1;
	res=setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &opt, 4);
	if (daveDebug & daveDebugOpen) {	
	    LOG3(ThisModule "setsockopt %s %d\n", strerror(errno),res);	
	}    
    }	
    FLUSH;
    return fd;
}
Exemplo n.º 2
0
void CMMADisplay::Construct(MMAFunctionServer* eventSource ,JNIEnv* aJni, jobject javadisplayref)
{
    iEventSource = eventSource;
    iJavadisplayref = javadisplayref;
    LOG1(EJavaMMAPI,EInfo,"CMMADisplay::Construct=%d",iIseSWT);
    if (iIseSWT)
    {
        iJni = aJni;
    }
    else
    {
        iJni = iEventSource->getValidJniEnv();
    }
    iJavaDisplayObject = iJni->NewGlobalRef(javadisplayref);
    iJavaDisplayClass = iJni->GetObjectClass(iJavaDisplayObject);

    setRectID = iJni->GetMethodID(iJavaDisplayClass,
                                  "setRect",
                                  "()V");
    iRectDimensionField = iJni->GetFieldID(iJavaDisplayClass, "rectDimension", "[I");

    redrawControlID = iJni->GetMethodID(
                          iJavaDisplayClass,
                          "redrawControl",
                          "()V");

    removeContentBoundID = iJni->GetMethodID(
                               iJavaDisplayClass,
                               "removeContentBound",
                               "()V");

    setContentBoundID = iJni->GetMethodID(
                            iJavaDisplayClass,
                            "setContentBound",
                            "()V");

    getCallBackMethodID = iJni->GetMethodID(
                              iJavaDisplayClass,
                              "GetCallbackInUiThread",
                              "(I)V");

    getBoundRectID = iJni->GetMethodID(
                         iJavaDisplayClass,
                         "getBoundRect",
                         "()V");

    iDisplayboundarrField = iJni->GetFieldID(iJavaDisplayClass, "displayboundarr", "[I");

    // Components must have direct content.
    /* __ASSERT_LOG(EJavaMMAPI,EInfo,"aDirectContainer, User::Invariant());

     // Not owned
     iDirectContainer = aDirectContainer;

     // Get component visibility. Later visibility changes will
     // be informed through MDirectContent observer.
     iContainerVisible = iDirectContainer->MdcContainerVisibility();
     LOG1(EJavaMMAPI,EInfo,"CMMADisplay::Construct iContainerVisible = %d", iContainerVisible);
     LOG1(EJavaMMAPI,EInfo,"CMMADisplay::Construct iVisible = %d", iVisible);

     // Add this MDirectContent to the MDirectContainer. Cannot fail.
     iDirectContainer->MdcAddContent(this);
     */
}
Exemplo n.º 3
0
/* Compute the set of prefetched data.
   Notes:
   1. Even if caching is off, we will
       still prefetch the small variables.
   2. All prefetches are whole variable fetches.
   3. If the data set is unconstrainable, we
      will prefetch the whole thing
*/
NCerror
prefetchdata3(NCDAPCOMMON* nccomm)
{
    int i,j;
    NCerror ncstat = NC_NOERR;
    NClist* allvars = nccomm->cdf.varnodes;
    DCEconstraint* urlconstraint = nccomm->oc.dapconstraint;
    NClist* vars = nclistnew();
    NCcachenode* cache = NULL;
    DCEconstraint* newconstraint = NULL;
    int isnc4 = FLAGSET(nccomm->controls,NCF_NC4);


    if(FLAGSET(nccomm->controls,NCF_UNCONSTRAINABLE)) {
        /* If we cannot constrain and caching is enabled,
           then pull in everything */
        if(FLAGSET(nccomm->controls,NCF_CACHE)) {
	    for(i=0;i<nclistlength(allvars);i++) {
	        nclistpush(vars,nclistget(allvars,i));
	    }
	} else { /* do no prefetching */
    	    nccomm->cdf.cache->prefetch = NULL;
	    goto done;
	}
    } else { /* can do constraints */
	/* pull in those variables of sufficiently small size */
        for(i=0;i<nclistlength(allvars);i++) {
            CDFnode* var = (CDFnode*)nclistget(allvars,i);
            size_t nelems = 1;

            if(!isnc4) {
	        /* If netcdf 3 and var is a sequence or under a sequence, then never prefetch */
	        if(var->nctype == NC_Sequence || dapinsequence(var)) continue;
	    }

            /* Compute the # of elements in the variable */
            for(j=0;j<nclistlength(var->array.dimset0);j++) {
                CDFnode* dim = (CDFnode*)nclistget(var->array.dimset0,j);
                nelems *= dim->dim.declsize;
	    }
if(SHOWFETCH) {
nclog(NCLOGDBG,"prefetch: %s=%lu",var->ncfullname,(unsigned long)nelems);
}
	    if(nelems <= nccomm->cdf.smallsizelimit) {
	        nclistpush(vars,(ncelem)var);
if(SHOWFETCH) {
nclog(NCLOGDBG,"prefetch: %s",var->ncfullname);
}
	    }
	}
    }

    /* If there are no vars, then do nothing */
    if(nclistlength(vars) == 0) {
	nccomm->cdf.cache->prefetch = NULL;
	goto done;
    }

    /* Create a single constraint consisting of the projections for the variables;
       each projection is whole variable. The selections are passed on as is.
    */

    newconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT);
    newconstraint->projections = nclistnew();
    newconstraint->selections = dceclonelist(urlconstraint->selections);

    for(i=0;i<nclistlength(vars);i++) {
	CDFnode* var = (CDFnode*)nclistget(vars,i);
	DCEprojection* varprojection;
	/* convert var to a projection */
	ncstat = dapvar2projection(var,&varprojection);
	if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
	nclistpush(newconstraint->projections,(ncelem)varprojection);
    }
if(SHOWFETCH) {
char* s = dumpprojections(newconstraint->projections);
LOG1(NCLOGNOTE,"prefetch.final: %s",s);
nullfree(s);
}
    ncstat = buildcachenode34(nccomm,newconstraint,vars,&cache,!isnc4);
    newconstraint = NULL; /* buildcachenode34 takes control of newconstraint */
    if(ncstat) goto done;
    cache->wholevariable = 1; /* All prefetches are whole variable */
    /* Make cache node be the prefetch node */
    nccomm->cdf.cache->prefetch = cache;
if(SHOWFETCH) {
LOG0(NCLOGNOTE,"prefetch.complete");
}

if(SHOWFETCH) {
char* s = NULL;
/* Log the set of prefetch variables */
NCbytes* buf = ncbytesnew();
ncbytescat(buf,"prefetch.vars: ");
for(i=0;i<nclistlength(vars);i++) {
CDFnode* var = (CDFnode*)nclistget(vars,i);
ncbytescat(buf," ");
s = makecdfpathstring3(var,".");
ncbytescat(buf,s);
nullfree(s);
}
ncbytescat(buf,"\n");
nclog(NCLOGNOTE,"%s",ncbytescontents(buf));
ncbytesfree(buf);
}

done:
    nclistfree(vars);
    dcefree((DCEnode*)newconstraint);    
    if(ncstat) freenccachenode(nccomm,cache);
    return THROW(ncstat);
}
// ---------------------------------------------------------------------------
// CLbtAppChangeHandler::RunL
// ---------------------------------------------------------------------------
//
void CLbtAppChangeHandler::RunL()
	{
	FUNC_ENTER("CLbtAppChangeHandler::RunL");
	switch(iOperation)
		{
		case EOpRegiseteredForInitialListPoplulation:
			{
			// First get the set of installed applications in the system
			iAppArcSession.GetAllApps();
			
			TApaAppInfo appInfo;
			TInt error = iAppArcSession.GetNextApp(appInfo);
			
			while(KErrNone == error)
				{
		        TLbtAppInfo lbtAppInfo;
		        lbtAppInfo.iUid = appInfo.iUid;
		        lbtAppInfo.iFullName.Zero();
		        lbtAppInfo.iFullName.Copy( appInfo.iFullName );

				iCurrentInstalledApps.AppendL(lbtAppInfo);
				error = iAppArcSession.GetNextApp(appInfo);
				}
			iOperation = EOpNone;
			break;
			}
		case EOpRegiseteredForListPoplulation:
			{
			HandleAppListEvent(KErrNone);
			break;
			}
		case EOpRemovalTriggerDeletion:
			{
			// Here the observer is set to the get the information pertaining
            // triggers that were deleted.
            TLbtTriggerEventMask eventMask = 0;
            eventMask|= CLbtContainer::ELbtConTriggerDeleted;
            iContainer.SetChangeObserver( this,eventMask );
            
			// Delete triggers for which the un-installed application is the 
			// startup process
			iOperation = EOpDeletionStartupProcessTriggers;
			DeleteTriggersOfStartupProcessL();
			break;
			}
		case EOpRemovalListingStartupProcessTriggers:
			{
			// Here the observer is set to the get the information pertaining
            // triggers that were deleted.
            TLbtTriggerEventMask eventMask = 0;
            eventMask|= CLbtContainer::ELbtConTriggerDeleted;
            iContainer.SetChangeObserver( this,eventMask );
            
			CLbtContainerFilter* containerFilter = CLbtContainerFilter::NewL();
			CleanupStack::PushL(containerFilter);
			
			for(TInt i=0;i<iAppList.Count();++i)
				{
				containerFilter->AddOwnerSidInFilterL(iAppList[i].iUid);
				}
			
			CLbtTriggerFilterByAttribute* filterByAttribute = 
						CLbtTriggerFilterByAttribute::NewL();
			CleanupStack::PushL(filterByAttribute);
			filterByAttribute->AddTriggerTypeL(CLbtTriggerEntry::ETypeStartup);
			
			CLbtContainerUpdateFilter* updateFilter = CLbtContainerUpdateFilter::NewL(filterByAttribute ,containerFilter);
			
			iContainer.DeleteTriggers(updateFilter, iOpId, iStatus);
			SetActive();
			iOperation = EOpRemovalDeletingStartupProcessTriggers;
			break;
			}
		case EOpRemovalDeletingStartupProcessTriggers:
		    {
		    // Here the observer is set to the get the information pertaining
            // triggers that were deleted.
            TLbtTriggerEventMask eventMask = 0;
            eventMask|= CLbtContainer::ELbtConTriggerDeleted;
            iContainer.SetChangeObserver( this,eventMask );
		    break;
		    }
			
		case EOpMMCInsertionListingTriggers:			
		case EOpMMCRemovalListingTriggers:
			{
			// Listing Triggers of startup process
			LOG("Listing Triggers Over");
			
			if( iOperation == EOpMMCInsertionListingTriggers )
				{
				iOperation = EOpMMCInsertionListingTriggerForStartupProcess;
				}
			else
				{
				iOperation = EOpMMCRemovalListingTriggerForStartupProcess;
				}
		
			ListTriggersOfStartupProcessL();
			iAppList.Close();
			LOG("Listing Triggers for startup Process");
			break;
			}
		case EOpMMCRemovalListingTriggerForStartupProcess:
		case EOpMMCInsertionListingTriggerForStartupProcess:
			{
			LOG("Listing Trigger For startup Process Done");
			LOG1("iStatus = %d", iStatus.Int());
			LOG1("Triggers Count = %d", iTriggerEntries.Count());
			if(KErrNone == iStatus.Int())
				{
				// The list operation is a success. Hence invalidate the triggers now
				RArray<TLbtTriggerId> triggerIds;
				
				for(TInt i=0;i<iTriggerEntries.Count();++i)
					{
					triggerIds.AppendL(iTriggerEntries[i]->TriggerEntry()->Id());
					}
				
				TLbtTriggerDynamicInfo::TLbtTriggerValidity validity;
				
				if(iOperation == EOpMMCRemovalListingTriggerForStartupProcess)
					{
					validity = TLbtTriggerDynamicInfo::EInvalid;
					iCleanupHandler.AddTriggersForCleanupL( triggerIds );
					}
				else
					{
					validity = TLbtTriggerDynamicInfo::EValid;
					iCleanupHandler.RemoveTriggersFromCleanupL( triggerIds );
					}
			    
				// update validity of the triggers
				iContainer.UpdateTriggersValidity( validity,
												   triggerIds,
												   iOpId,
												   iStatus );
				SetActive();				
				iOperation = EOpRequestValidityChange;
				triggerIds.Close();
				iTriggerEntries.ResetAndDestroy();
				}
			else
				{
				// Listing is not successful. Hence dont do anything
				iOperation = EOpNone;
				iTriggerEntries.ResetAndDestroy();
				iAppList.Reset();
				}
			break;
			}
		case EOpRequestValidityChange:
		    {
		    // Here the observer is set to the get the information pertaining
            // triggers that were changed to invalid
            TLbtTriggerEventMask eventMask = 0;
            eventMask|= CLbtContainer::ELbtConTriggerValidityFieldChanged;
            iContainer.SetChangeObserver( this,eventMask );
            break;
		    }
		default:
			{
			// Operation complete
			iTriggerEntries.ResetAndDestroy();
			iAppList.Close();
			iOperation = EOpNone;
			break;			
			}
		}
	}
int IonDmaMemManager::createIonBuffer(struct bufferinfo_s* ionbuf)
{
	int ret =0,i = 0;
	int numBufs;
	int frame_size;
	camera_ionbuf_t* tmpalloc = NULL;
	struct bufferinfo_s* tmp_buf = NULL;
	#ifdef ROCKCHIP_ION_VERSION
    ion_user_handle_t handle = 0;
	#else
	struct ion_handle* handle = NULL;
	#endif
    int map_fd;
	long temp_handle = 0;
    unsigned long vir_addr = 0;

    
	if (!ionbuf) {
		LOGE("ion_alloc malloc buffer failed");
		return -1;
	}
    
	numBufs = ionbuf->mNumBffers;
	frame_size = ionbuf->mPerBuffersize;
	ionbuf->mBufferSizes = numBufs*PAGE_ALIGN(frame_size);
	switch(ionbuf->mBufType)
	{
		case PREVIEWBUFFER:
            tmpalloc = mPreviewData ;
			if((tmp_buf  = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL){
                mPreviewBufferInfo = tmp_buf;
            }else{
        		LOGE("ion_alloc malloc buffer failed");
        		return -1;
            }
			break;
		case RAWBUFFER:
            tmpalloc =  mRawData;
               
			if((tmp_buf = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL){
                mRawBufferInfo = tmp_buf;
            }else{
        		LOGE("ion_alloc malloc buffer failed");
        		return -1;
            }
			break;
		case JPEGBUFFER:
            tmpalloc = mJpegData;
            
			if((tmp_buf  = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL ){
                mJpegBufferInfo = tmp_buf;
            }else{
        		LOGE("ion_alloc malloc buffer failed");
        		return -1;
            }
			break;
		case VIDEOENCBUFFER:
            tmpalloc =  mVideoEncData ;

            if((tmp_buf = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL){
                mVideoEncBufferInfo = tmp_buf;
            }else{
        		LOGE("ion_alloc malloc buffer failed");
        		return -1;
            }
			break;
        default:
            return -1;
    }

    for(i = 0;i < numBufs;i++){
    	memset(tmpalloc,0,sizeof(struct camera_ionbuf_s));

        if((!mIommuEnabled) || (!ionbuf->mIsForceIommuBuf))
            ret = ion_alloc(client_fd, ionbuf->mPerBuffersize, PAGE_SIZE, ION_HEAP(ION_CMA_HEAP_ID), 0, &handle);
        else
            ret = ion_alloc(client_fd, ionbuf->mPerBuffersize, PAGE_SIZE, ION_HEAP(ION_VMALLOC_HEAP_ID), 0, &handle);
        if (ret) {
            LOGE("ion alloc failed\n");
            break;
        }

        LOG1("handle %d\n", handle);

        ret = ion_share(client_fd,handle,&map_fd);
        if (ret) {
            LOGE("ion map failed\n");
            ion_free(client_fd,handle);
            break;
        }

        vir_addr = (unsigned long )mmap(NULL, ionbuf->mPerBuffersize, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0);
        if (vir_addr == 0) {
            LOGE("ion mmap failed\n");
            ret = -1;
            ion_free(client_fd,handle);
            break;
        }
        
        if((!mIommuEnabled) || (!ionbuf->mIsForceIommuBuf))
            ion_get_phys(client_fd,handle,&(tmpalloc->phy_addr));
        else
            tmpalloc->phy_addr = map_fd;
        tmpalloc->size = ionbuf->mPerBuffersize;
        tmpalloc->vir_addr = vir_addr;
		temp_handle = handle;
        tmpalloc->ion_hdl = (void*)temp_handle;
        tmpalloc->map_fd    =   map_fd;

        
    	ionbuf->mPhyBaseAddr = (unsigned long)tmpalloc->phy_addr;
    	ionbuf->mVirBaseAddr = (unsigned long)tmpalloc->vir_addr;
    	ionbuf->mPerBuffersize = PAGE_ALIGN(frame_size);
    	ionbuf->mShareFd     = (unsigned int)tmpalloc->map_fd;
		*tmp_buf = *ionbuf;
		tmp_buf++;
        tmpalloc++;
        
    }
    if(ret < 0){
        LOGE(" failed !");
        while(--i >= 0){
            --tmpalloc;
            --tmp_buf;
            munmap((void *)tmpalloc->vir_addr, tmpalloc->size);
            ion_free(client_fd, tmpalloc->ion_hdl);
        }
        free(tmpalloc);
        free(tmp_buf);
    }
    return ret;
}
sp<ICamera> CameraService::connect(
        const sp<ICameraClient>& cameraClient, int cameraId) {
    int callingPid = getCallingPid();
    sp<CameraHardwareInterface> hardware = NULL;

    LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId);

    if (!mModule) {
        ALOGE("Camera HAL module not loaded");
        return NULL;
    }

    sp<Client> client;
    if (cameraId < 0 || cameraId >= mNumberOfCameras) {
        ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).",
            callingPid, cameraId);
        return NULL;
    }

    char value[PROPERTY_VALUE_MAX];
    property_get("sys.secpolicy.camera.disabled", value, "0");
    if (strcmp(value, "1") == 0) {
        // Camera is disabled by DevicePolicyManager.
        ALOGI("Camera is disabled. connect X (pid %d) rejected", callingPid);
        return NULL;
    }

    Mutex::Autolock lock(mServiceLock);
    if (mClient[cameraId] != 0) {
        client = mClient[cameraId].promote();
        if (client != 0) {
            if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
                LOG1("CameraService::connect X (pid %d) (the same client)",
                    callingPid);
                return client;
            } else {
                ALOGW("CameraService::connect X (pid %d) rejected (existing client).",
                    callingPid);
                return NULL;
            }
        }
        mClient[cameraId].clear();
    }

    if (mBusy[cameraId]) {
        ALOGW("CameraService::connect X (pid %d) rejected"
             " (camera %d is still busy).", callingPid, cameraId);
        return NULL;
    }

    struct camera_info info;
    if (mModule->get_camera_info(cameraId, &info) != OK) {
        ALOGE("Invalid camera id %d", cameraId);
        return NULL;
    }

    char camera_device_name[10];
    snprintf(camera_device_name, sizeof(camera_device_name), "%d", cameraId);

    hardware = new CameraHardwareInterface(camera_device_name);
    if (hardware->initialize(&mModule->common) != OK) {
        hardware.clear();
        return NULL;
    }

    client = new Client(this, cameraClient, hardware, cameraId, info.facing, callingPid);
    mClient[cameraId] = client;
    LOG1("CameraService::connect X");
    return client;
}
Exemplo n.º 7
0
Arquivo: emul.c Projeto: sfsy1989/j2me
void reallocQueue() {
    emul_data.req_size += DEFAULT_QUEUE_SIZE;
    LOG1("EMUL QUEUE reallocated to %d", emul_data.req_size);
    emul_data.request = midpRealloc(emul_data.request, emul_data.req_size);
}
Exemplo n.º 8
0
//---------------------------------------------------------------------------
//
//	割り込みチェック
//
//---------------------------------------------------------------------------
void FASTCALL IOSC::IntChk()
{
	int v;

	ASSERT(this);

	// 割り込み無し
	v = -1;

	// プリンタ割り込み
	if (iosc.prt_int && iosc.prt_en) {
		v = iosc.vbase + 3;
	}

	// HDC割り込み
	if (iosc.hdc_int && iosc.hdc_en) {
		v = iosc.vbase + 2;
	}

	// FDD割り込み
	if (iosc.fdd_int && iosc.fdd_en) {
		v = iosc.vbase + 1;
	}

	// FDC割り込み
	if (iosc.fdc_int && iosc.fdc_en) {
		v = iosc.vbase;
	}

	// 要求したい割り込みがない場合
	if (v < 0) {
		// 割り込み要求中でなければ、OK
		if (iosc.vector < 0) {
			return;
		}

		// 何らかの割り込みを要求しているので、割り込みキャンセル
#if defined(IOSC_LOG)
		LOG1(Log::Normal, "割り込みキャンセル ベクタ$%02X", iosc.vector);
#endif	// IOSC_LOG
		cpu->IntCancel(1);
		iosc.vector = -1;
		return;
	}

	// 既に要求しているベクタと同じであれば、OK
	if (iosc.vector == v) {
		return;
	}

	// 違うので、要求中なら一度キャンセル
	if (iosc.vector >= 0) {
#if defined(IOSC_LOG)
		LOG1(Log::Normal, "割り込みキャンセル ベクタ$%02X", iosc.vector);
#endif	// IOSC_LOG
		cpu->IntCancel(1);
		iosc.vector = -1;
	}

	// 割り込み要求
#if defined(IOSC_LOG)
	LOG1(Log::Normal, "割り込み要求 ベクタ$%02X", v);
#endif	// IOSC_LOG
	cpu->Interrupt(1, (uint8_t)v);

	// 記憶
	iosc.vector = v;
}
int
ActiveMemoryMonitorCalibration(void) {

#if MEMORY_SUPPORT
  unsigned int i, page_size, used, max_used, stop_count, base_start;
  struct bulk *start, *current;
  int connection[2];
  pid_t childPid;
 
  if(pipe(connection) != 0) {
      FAIL("ActiveMemoryMonitorCalibration: pipe() failed\n");
    }

  childPid = fork();

  if(childPid < 0) {
      FAIL("ActiveMemoryMonitorCalibration: fork() failed\n");
  }
  else if(childPid > 0) {
    /* Parent process. */
    close(connection[WRITE_END]);
    read(connection[READ_END], &BaseMem, sizeof(int));
    close(connection[READ_END]);
    wait(NULL);
    return 1;
  }

  /* Child comes here. */
  BaseMem = 0;
  close(connection[READ_END]);
  nice(19);
  LOG("ActiveMemoryMonitorCalibration: start calibration\n");
  page_size = getpagesize();
  base_start = ActiveMemoryGetRoughlyFree()*CALIBRATION_SPEEDUP_RATIO; 
  if (debug > 0) {
        DDEBUG1("Calibration speedup : start from %d KB of base memory\n", base_start);
  }

  start = (struct bulk *)malloc(sizeof(struct bulk));
  if (start == NULL) {
    write(connection[WRITE_END], &BaseMem, sizeof(int));
    close(connection[WRITE_END]);
    exit(0);
  }
  start->ptr = calloc(base_start*1024,sizeof(char));
  if (start->ptr == NULL) {
    free(start);
    write(connection[WRITE_END], &BaseMem, sizeof(int));
    close(connection[WRITE_END]);
    exit(0);
  } 
  start->length = base_start*1024*sizeof(char);
  start->next = NULL;

  used = 99;
  for (i=0; i<start->length; i+=page_size)
    start->ptr[i] = (int)used;
  start->ptr[start->length-1] = (int)used;
  
  current = start;
  max_used = 0;
  stop_count = 0;
  used = 1;
  while (stop_count <ITERATIONS_STALLED) {
    current->next = (struct bulk *)malloc(sizeof(struct bulk));
    if (current->next == NULL)
      break;
    current = current->next;
    current->ptr = malloc(CALIBRATION_BULK_SIZE*sizeof(char));
    if (current->ptr == NULL) {
      stop_count++;
      continue;
    }
    current->length = CALIBRATION_BULK_SIZE*sizeof(char);
    current->next = NULL;
    
    for (i=0; i<current->length; i+=page_size)
      current->ptr[i] = (int)used;
    current->ptr[current->length-1] = (int)used;
    
    used = ActiveMemoryGetUsed();
    if (used > max_used)
      max_used = used;
    else
      stop_count++;
  }
  
  BaseMem = max_used;
  if (debug > 0) {
	DDEBUG1("Calibration done : %d KB of base memory\n", BaseMem);
  }

  current = start;
  while (current != NULL) {
     free(current->ptr);
    current = current->next;
  }
  LOG1("ActiveMemoryMonitorCalibration: end of calibration (%d KB)\n",
       BaseMem);
  write(connection[WRITE_END], &BaseMem, sizeof(int));
  close(connection[WRITE_END]);
  exit(0); 
#else
  return 0;
#endif

}
Exemplo n.º 10
0
//---------------------------------------------------------------------------
//
//	バイト読み込み
//
//---------------------------------------------------------------------------
uint32_t FASTCALL IOSC::ReadByte(uint32_t addr)
{
	uint32_t data;

	ASSERT(this);
	ASSERT((addr >= memdev.first) && (addr <= memdev.last));

	// 16バイト単位でループ
	addr &= 0x0f;

	// 奇数アドレスのみデコードされている
	if ((addr & 1) != 0) {

		// ウェイト
		scheduler->Wait(2);

		// $E9C001 割り込みステータス
		if (addr == 1) {
			data = 0;
			if (iosc.fdc_int) {
				data |= 0x80;
			}
			if (iosc.fdd_int) {
				data |= 0x40;
			}
			if (iosc.hdc_int) {
				data |= 0x10;
			}
			if (iosc.hdc_en) {
				data |= 0x08;
			}
			if (iosc.fdc_en) {
				data |= 0x04;
			}
			if (iosc.fdd_en) {
				data |= 0x02;
			}
			if (iosc.prt_en) {
				data |= 0x01;
			}

			// プリンタはREADYの表示
			if (printer->IsReady()) {
				data |= 0x20;
			}

			// プリンタ割り込みはこの時点で降ろす
			if (iosc.prt_int) {
				iosc.prt_int = FALSE;
				IntChk();
			}
			return data;
		}

		// $E9C003 割り込みベクタ
		if (addr == 3) {
			return 0xff;
		}

		LOG1(Log::Warning, "未実装レジスタ読み込み $%06X", memdev.first + addr);
		return 0xff;
	}

	// バスエラーは発生しない
	return 0xff;
}
Exemplo n.º 11
0
//---------------------------------------------------------------------------
//
//	バイト書き込み
//
//---------------------------------------------------------------------------
void FASTCALL IOSC::WriteByte(uint32_t addr, uint32_t data)
{
	ASSERT(this);
	ASSERT((addr >= memdev.first) && (addr <= memdev.last));
	ASSERT(data < 0x100);

	// 16バイト単位でループ
	addr &= 0x0f;

	// 奇数アドレスのみデコードされている
	if ((addr & 1) != 0) {

		// ウェイト
		scheduler->Wait(2);

		// $E9C001 割り込みマスク
		if (addr == 1) {
			if (data & 0x01) {
				iosc.prt_en = TRUE;
			}
			else {
				iosc.prt_en = FALSE;
			}
			if (data & 0x02) {
				iosc.fdd_en = TRUE;
			}
			else {
				iosc.fdd_en = FALSE;
			}
			if (data & 0x04) {
				iosc.fdc_en = TRUE;
			}
			else {
				iosc.fdc_en = FALSE;
			}
			if (data & 0x08) {
				iosc.hdc_en = TRUE;
			}
			else {
				iosc.hdc_en = FALSE;
			}

			// 割り込みチェック(FORMULA 68K)
			IntChk();
			return;
		}

		// $E9C003 割り込みベクタ
		if (addr == 3) {
			data &= 0xfc;
			iosc.vbase &= 0x03;
			iosc.vbase |= data;

			LOG1(Log::Detail, "割り込みベクタベース $%02X", iosc.vbase);
			return;
		}

		// 未定義
		LOG2(Log::Warning, "未実装レジスタ書き込み $%06X <- $%02X",
										memdev.first + addr, data);
		return;
	}
}
Exemplo n.º 12
0
void threecom3c505_device::write_control_port( UINT8 data)
{
	// if (m_device->machine->firstcpu->safe_pcbase() == 0x3C4BAD48) verbose = 3;
	// if (m_device->machine->firstcpu->safe_pcbase() == 0x010464DC) verbose = 3;

	if (verbose <= 2 && (data & (DMAE | TCEN /*| CMDE*/)) != 0)
	{
		// dma or interrupts enabled
		LOG1(("writing 3C505 Control Register at offset %02x = %02x", PORT_CONTROL, data));
	}

	m_status = (m_status & ~DIR_) | (data & DIR_);

	switch (data & HSF_PCB_MASK)
	{
	case HSF_PCB_ACK: // HSF1
		if (m_wait_for_ack)
		{
			set_command_pending(0);
		}
		break;
	case HSF_PCB_NAK: // HSF2
		if (m_microcode_running)
		{
			m_status = (m_status & ~ASF_PCB_MASK) | ASF_PCB_ACK;
		}
		break;
	case HSF_PCB_END: // (HSF2|HSF1)
		m_status &= ~(ATTN | DMAE | ASF_PCB_MASK);
		if (m_microcode_running)
		{
			m_status = (m_status & ~ASF_PCB_MASK) | ASF_PCB_ACK;
		}
		break;
	default: // 0
		m_command_index = 0;
		m_status |= HCRE; /* command register empty */

		if (m_command_buffer[0] == CMD_MC_F9)
		{
			m_mc_f9_pending = 1;
//-         verbose = 2;
		}

		if (data == 0x00)
		{
			// hardware reset
			m_status |= HRDY; /* data register ready */
			// flush data register (reset tx data fifo)
			m_tx_data_length = 0;
			// FIXME: Don't do this (but why?)
			// m_tx_data_buffer.reset();
		}
		else if (data == DIR_)
		{
			// why?? dex ether 20 expects HRDY
			// m_status &= ~HRDY; /* data register not ready */
			m_status |= HRDY; /* data register ready */
		}
		else if (data & FLSH)
		{
			if (data & DIR_)
			{
				m_status &= ~HRDY; /* data register not ready */
			}
			else
			{
				// flush data register (reset tx data fifo)
//              m_tx_data_length = 0;
				m_tx_data_buffer.reset();
				m_status |= HRDY; /* data register ready */
			}
		}
		break;
	}

	if ((m_control & (ATTN | FLSH)) == (ATTN | FLSH) && (data & (ATTN | FLSH)) == 0)
	{
		m_status |= ASF_PCB_END;
	}

	if (m_mc_f9_pending == 2)
	{
		m_mc_f9_pending = 0;
		set_command_pending(0);
	}

	m_control = data;
}
	// set the ISurface that the preview will use
	status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface) {
		LOG1("setPreviewDisplay(%p) (pid %d)", surface.get(), getCallingPid());
		Mutex::Autolock lock(mLock);
		status_t result = checkPidAndHardware();
		if (result != NO_ERROR) return result;
		
		result = NO_ERROR;
		
		// return if no change in surface.
		// asBinder() is safe on NULL (returns NULL)
		if (surface->asBinder() == mSurface->asBinder()) {
			return result;
		}
		
		if (mSurface != 0) {
			LOG1("clearing old preview surface %p", mSurface.get());
			if (mUseOverlay) {
				// Force the destruction of any previous overlay
				sp<Overlay> dummy;
				mHardware->setOverlay(dummy);
				mOverlayRef = 0;
			} else {
				mSurface->unregisterBuffers();
			}
		}
		mSurface = surface;
		mOverlayRef = 0;
		// If preview has been already started, set overlay or register preview
		// buffers now.
#ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP
		if (mHardware->previewEnabled() || mUseOverlay) {
#else
			if (mHardware->previewEnabled()) {
#endif
				if (mUseOverlay) {
#ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP
					if (mSurface != NULL) {
#endif
						result = setOverlay();
#ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP
					}
#endif
				} else if (mSurface != 0) {
					result = registerPreviewBuffers();
				}
			}
			
			return result;
		}
		
		status_t CameraService::Client::registerPreviewBuffers() {
			int w, h;
			CameraParameters params(mHardware->getParameters());
			params.getPreviewSize(&w, &h);
			
			//for 720p recording , preview can be 800X448
			if(w ==  preview_sizes[0].width && h== preview_sizes[0].height){
				LOGD("registerpreviewbufs :changing dimensions to 768X432 for 720p recording.");
				w = preview_sizes[1].width;
				h = preview_sizes[1].height;
			}
			
			// FIXME: don't use a hardcoded format here.
			ISurface::BufferHeap buffers(w, h, w, h,
										 HAL_PIXEL_FORMAT_YCrCb_420_SP,
										 mOrientation,
										 0,
										 mHardware->getPreviewHeap());
			
			status_t result = mSurface->registerBuffers(buffers);
			if (result != NO_ERROR) {
				LOGE("registerBuffers failed with status %d", result);
			}
			return result;
		}
		
		status_t CameraService::Client::setOverlay() {
			int w, h;
			CameraParameters params(mHardware->getParameters());
			params.getPreviewSize(&w, &h);
			
			//for 720p recording , preview can be 800X448
			if(w == preview_sizes[0].width && h==preview_sizes[0].height){
				LOGD("Changing overlay dimensions to 768X432 for 720p recording.");
				w = preview_sizes[1].width;
				h = preview_sizes[1].height;
			}
			
			if (w != mOverlayW || h != mOverlayH || mOrientationChanged) {
				// Force the destruction of any previous overlay
				sp<Overlay> dummy;
				mHardware->setOverlay(dummy);
				mOverlayRef = 0;
#ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP
				if (mOverlay != NULL) {
					mOverlay->destroy();
				}
#endif
				mOrientationChanged = false;
			}
			
			status_t result = NO_ERROR;
			if (mSurface == 0) {
				result = mHardware->setOverlay(NULL);
			} else {
				if (mOverlayRef == 0) {
					// FIXME:
					// Surfaceflinger may hold onto the previous overlay reference for some
					// time after we try to destroy it. retry a few times. In the future, we
					// should make the destroy call block, or possibly specify that we can
					// wait in the createOverlay call if the previous overlay is in the
					// process of being destroyed.
					for (int retry = 0; retry < 50; ++retry) {
						mOverlayRef = mSurface->createOverlay(w, h,
#ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP
															  HAL_PIXEL_FORMAT_YCbCr_420_SP,
#else
															  OVERLAY_FORMAT_DEFAULT,
#endif
															  mOrientation);
						if (mOverlayRef != 0) break;
						LOGW("Overlay create failed - retrying");
						usleep(20000);
					}
					if (mOverlayRef == 0) {
						LOGE("Overlay Creation Failed!");
						return -EINVAL;
					}
#ifdef USE_OVERLAY_FORMAT_YCbCr_420_SP
					mOverlay = new Overlay(mOverlayRef);
					result = mHardware->setOverlay(mOverlay);
#else
					result = mHardware->setOverlay(new Overlay(mOverlayRef));
#endif
				}
			}
			if (result != NO_ERROR) {
				LOGE("mHardware->setOverlay() failed with status %d\n", result);
				return result;
			}
			
			mOverlayW = w;
			mOverlayH = h;
			
			return result;
		}
		
		// set the preview callback flag to affect how the received frames from
		// preview are handled.
		void CameraService::Client::setPreviewCallbackFlag(int callback_flag) {
			LOG1("setPreviewCallbackFlag(%d) (pid %d)", callback_flag, getCallingPid());
			Mutex::Autolock lock(mLock);
			if (checkPidAndHardware() != NO_ERROR) return;
			
			mPreviewCallbackFlag = callback_flag;
			
			// If we don't use overlay, we always need the preview frame for display.
			// If we do use overlay, we only need the preview frame if the user
			// wants the data.
			if (mUseOverlay) {
				if(mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ENABLE_MASK) {
					enableMsgType(CAMERA_MSG_PREVIEW_FRAME);
				} else {
					disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
				}
			}
		}
Exemplo n.º 14
0
/* Provide a wrapper for oc_fetch so we can log what it does */
NCerror
dap_fetch(NCDAPCOMMON* nccomm, OClink conn, const char* ce,
             OCdxd dxd, OCddsnode* rootp)
{
    NCerror ncstat = NC_NOERR;
    OCerror ocstat = OC_NOERR;
    char* ext = NULL;
    OCflags flags = 0;
    int httpcode = 0;

    if(dxd == OCDDS) ext = ".dds";
    else if(dxd == OCDAS) ext = ".das";
    else ext = ".dods";

    if(ce != NULL && strlen(ce) == 0)
	ce = NULL;

    if(FLAGSET(nccomm->controls,NCF_UNCONSTRAINABLE)) {
	ce = NULL;
    }

    if(FLAGSET(nccomm->controls,NCF_ONDISK)) {
	flags |= OCONDISK;
    }

    if(SHOWFETCH) {
	/* Build uri string minus the constraint and #tag */
	char* baseurl = ncuribuild(nccomm->oc.url,NULL,ext,NCURIBASE);
	if(ce == NULL)
            LOG1(NCLOGNOTE,"fetch: %s",baseurl);
	else
            LOG2(NCLOGNOTE,"fetch: %s?%s",baseurl,ce);
	nullfree(baseurl);
#ifdef HAVE_GETTIMEOFDAY
	gettimeofday(&time0,NULL);
#endif
    }
    ocstat = oc_fetch(conn,ce,dxd,flags,rootp);
    if(FLAGSET(nccomm->controls,NCF_SHOWFETCH)) {
#ifdef HAVE_GETTIMEOFDAY
        double secs;
	gettimeofday(&time1,NULL);
	secs = deltatime();
	nclog(NCLOGNOTE,"fetch complete: %0.3f secs",secs);
#else
	nclog(NCLOGNOTE,"fetch complete.");
#endif
    }
#ifdef DEBUG2
fprintf(stderr,"fetch: dds:\n");
oc_dumpnode(conn,*rootp);
#endif

    /* Look at the HTTP return code */
    httpcode = oc_httpcode(conn);
    if(httpcode < 400) {
        ncstat = ocerrtoncerr(ocstat);
    } else if(httpcode >= 500) {
        ncstat = NC_EDAPSVC;
    } else if(httpcode == 401) {
	ncstat = NC_EAUTH;
    } else if(httpcode == 404) {
	ncstat = NC_ENOTFOUND;
    } else {
	ncstat = NC_EACCESS;
    }
    return ncstat;
}
Exemplo n.º 15
0
Arquivo: sps.c Projeto: 4j1th/libde265
void dump_sps(seq_parameter_set* sps, ref_pic_set* sets, int fd)
{
  //#if (_MSC_VER >= 1500)
  //#define LOG0(t) loginfo(LogHeaders, t)
  //#define LOG1(t,d) loginfo(LogHeaders, t,d)
  //#define LOG2(t,d1,d2) loginfo(LogHeaders, t,d1,d2)
  //#define LOG3(t,d1,d2,d3) loginfo(LogHeaders, t,d1,d2,d3)

  FILE* fh;
  if (fd==1) fh=stdout;
  else if (fd==2) fh=stderr;
  else { return; }

#define LOG0(t) log2fh(fh, t)
#define LOG1(t,d) log2fh(fh, t,d)
#define LOG2(t,d1,d2) log2fh(fh, t,d1,d2)
#define LOG3(t,d1,d2,d3) log2fh(fh, t,d1,d2,d3)
  

  LOG0("----------------- SPS -----------------\n");
  LOG1("video_parameter_set_id  : %d\n", sps->video_parameter_set_id);
  LOG1("sps_max_sub_layers      : %d\n", sps->sps_max_sub_layers);
  LOG1("sps_temporal_id_nesting_flag : %d\n", sps->sps_temporal_id_nesting_flag);

  dump_profile_tier_level(&sps->profile_tier_level, sps->sps_max_sub_layers, fh);

  LOG1("seq_parameter_set_id    : %d\n", sps->seq_parameter_set_id);
  LOG2("chroma_format_idc       : %d (%s)\n", sps->chroma_format_idc,
       sps->chroma_format_idc == 1 ? "4:2:0" :
       sps->chroma_format_idc == 2 ? "4:2:2" :
       sps->chroma_format_idc == 3 ? "4:4:4" : "unknown");

  if (sps->chroma_format_idc == 3) {
    LOG1("separate_colour_plane_flag : %d\n", sps->separate_colour_plane_flag);
  }

  LOG1("pic_width_in_luma_samples  : %d\n", sps->pic_width_in_luma_samples);
  LOG1("pic_height_in_luma_samples : %d\n", sps->pic_height_in_luma_samples);
  LOG1("conformance_window_flag    : %d\n", sps->conformance_window_flag);

  if (sps->conformance_window_flag) {
    LOG1("conf_win_left_offset  : %d\n", sps->conf_win_left_offset);
    LOG1("conf_win_right_offset : %d\n", sps->conf_win_right_offset);
    LOG1("conf_win_top_offset   : %d\n", sps->conf_win_top_offset);
    LOG1("conf_win_bottom_offset: %d\n", sps->conf_win_bottom_offset);
  }

  LOG1("bit_depth_luma   : %d\n", sps->bit_depth_luma);
  LOG1("bit_depth_chroma : %d\n", sps->bit_depth_chroma);

  LOG1("log2_max_pic_order_cnt_lsb : %d\n", sps->log2_max_pic_order_cnt_lsb);
  LOG1("sps_sub_layer_ordering_info_present_flag : %d\n", sps->sps_sub_layer_ordering_info_present_flag);

  int firstLayer = (sps->sps_sub_layer_ordering_info_present_flag ?
                    0 : sps->sps_max_sub_layers-1 );

  for (int i=firstLayer ; i <= sps->sps_max_sub_layers-1; i++ ) {
    LOG1("Layer %d\n",i);
    LOG1("  sps_max_dec_pic_buffering : %d\n", sps->sps_max_dec_pic_buffering[i]);
    LOG1("  sps_max_num_reorder_pics  : %d\n", sps->sps_max_num_reorder_pics[i]);
    LOG1("  sps_max_latency_increase  : %d\n", sps->sps_max_latency_increase[i]);
  }

  LOG1("log2_min_luma_coding_block_size : %d\n", sps->log2_min_luma_coding_block_size);
  LOG1("log2_diff_max_min_luma_coding_block_size : %d\n",sps->log2_diff_max_min_luma_coding_block_size);
  LOG1("log2_min_transform_block_size   : %d\n", sps->log2_min_transform_block_size);
  LOG1("log2_diff_max_min_transform_block_size : %d\n", sps->log2_diff_max_min_transform_block_size);
  LOG1("max_transform_hierarchy_depth_inter : %d\n", sps->max_transform_hierarchy_depth_inter);
  LOG1("max_transform_hierarchy_depth_intra : %d\n", sps->max_transform_hierarchy_depth_intra);
  LOG1("scaling_list_enable_flag : %d\n", sps->scaling_list_enable_flag);

  if (sps->scaling_list_enable_flag) {

    //sps->sps_scaling_list_data_present_flag = get_bits(br,1);
    if (sps->sps_scaling_list_data_present_flag) {

      LOG0("NOT IMPLEMENTED");
      //assert(0);
      //scaling_list_data()
    }
  }

  LOG1("amp_enabled_flag                    : %d\n", sps->amp_enabled_flag);
  LOG1("sample_adaptive_offset_enabled_flag : %d\n", sps->sample_adaptive_offset_enabled_flag);
  LOG1("pcm_enabled_flag                    : %d\n", sps->pcm_enabled_flag);

  if (sps->pcm_enabled_flag) {
    LOG1("pcm_sample_bit_depth_luma     : %d\n", sps->pcm_sample_bit_depth_luma);
    LOG1("pcm_sample_bit_depth_chroma   : %d\n", sps->pcm_sample_bit_depth_chroma);
    LOG1("log2_min_pcm_luma_coding_block_size : %d\n", sps->log2_min_pcm_luma_coding_block_size);
    LOG1("log2_diff_max_min_pcm_luma_coding_block_size : %d\n", sps->log2_diff_max_min_pcm_luma_coding_block_size);
    LOG1("pcm_loop_filter_disable_flag  : %d\n", sps->pcm_loop_filter_disable_flag);
  }

  LOG1("num_short_term_ref_pic_sets : %d\n", sps->num_short_term_ref_pic_sets);

  for (int i = 0; i < sps->num_short_term_ref_pic_sets; i++) {
    LOG1("ref_pic_set[ %2d ]: ",i);
    dump_compact_short_term_ref_pic_set(&sets[i], 16, fh);
  }

  LOG1("long_term_ref_pics_present_flag : %d\n", sps->long_term_ref_pics_present_flag);

  if (sps->long_term_ref_pics_present_flag) {

    LOG1("num_long_term_ref_pics_sps : %d\n", sps->num_long_term_ref_pics_sps);

    for (int i = 0; i < sps->num_long_term_ref_pics_sps; i++ ) {
      LOG3("lt_ref_pic_poc_lsb_sps[%d] : %d   (used_by_curr_pic_lt_sps_flag=%d)\n",
           i, sps->lt_ref_pic_poc_lsb_sps[i], sps->used_by_curr_pic_lt_sps_flag[i]);
    }
  }

  LOG1("sps_temporal_mvp_enabled_flag      : %d\n", sps->sps_temporal_mvp_enabled_flag);
  LOG1("strong_intra_smoothing_enable_flag : %d\n", sps->strong_intra_smoothing_enable_flag);
  LOG1("vui_parameters_present_flag        : %d\n", sps->vui_parameters_present_flag);

  LOG1("CtbSizeY     : %d\n", sps->CtbSizeY);
  LOG1("MinCbSizeY   : %d\n", sps->MinCbSizeY);
  LOG1("MaxCbSizeY   : %d\n", 1<<(sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
  LOG1("MinTBSizeY   : %d\n", 1<<sps->log2_min_transform_block_size);
  LOG1("MaxTBSizeY   : %d\n", 1<<(sps->log2_min_transform_block_size + sps->log2_diff_max_min_transform_block_size));

  return;

  if (sps->vui_parameters_present_flag) {
    assert(false);
    /*
      vui_parameters()

        sps_extension_flag
        u(1)
        if( sps_extension_flag )

          while( more_rbsp_data() )

            sps_extension_data_flag
              u(1)
              rbsp_trailing_bits()
    */
  }
#undef LOG0
#undef LOG1
#undef LOG2
#undef LOG3
  //#endif
}
/*
 * encodeToJpeg: encodes the given buffer and creates the final JPEG file
 * Input:  mainBuf  - buffer containing the main picture image
 *         thumbBuf - buffer containing the thumbnail image (optional, can be NULL)
 * Output: destBuf  - buffer containing the final JPEG image including EXIF header
 *         Note that, if present, thumbBuf will be included in EXIF header
 */
status_t PictureThread::encodeToJpeg(CameraBuffer *mainBuf, CameraBuffer *thumbBuf, CameraBuffer *destBuf)
{
    LOG1("@%s", __FUNCTION__);
    status_t status = NO_ERROR;

    nsecs_t startTime = systemTime();
    nsecs_t endTime;

    // Convert and encode the thumbnail, if present and EXIF maker is initialized

    if (mConfig.exif.enableThumb) {

        LOG1("Encoding thumbnail");

        // setup the JpegCompressor input and output buffers
        mEncoderInBuf.clear();
        mEncoderInBuf.buf = (unsigned char*)thumbBuf->getData();
        mEncoderInBuf.width = mConfig.thumbnail.width;
        mEncoderInBuf.height = mConfig.thumbnail.height;
        mEncoderInBuf.format = mConfig.thumbnail.format;
        mEncoderInBuf.size = frameSize(mConfig.thumbnail.format,
                mConfig.thumbnail.width,
                mConfig.thumbnail.height);
        mEncoderOutBuf.clear();
        mEncoderOutBuf.buf = mOutData;
        mEncoderOutBuf.width = mConfig.thumbnail.width;
        mEncoderOutBuf.height = mConfig.thumbnail.height;
        mEncoderOutBuf.quality = mConfig.thumbnail.quality;
        mEncoderOutBuf.size = mMaxOutDataSize;
        endTime = systemTime();
        int size = compressor.encode(mEncoderInBuf, mEncoderOutBuf);
        LOG1("Thumbnail JPEG size: %d (time to encode: %ums)", size, (unsigned)((systemTime() - endTime) / 1000000));
        if (size > 0) {
            encoder.setThumbData(mEncoderOutBuf.buf, size);
        } else {
            // This is not critical, we can continue with main picture image
            ALOGE("Could not encode thumbnail stream!");
        }
    } else {
        LOG1("Skipping thumbnail");
    }
    int totalSize = 0;
    unsigned int exifSize = 0;
    // Copy the SOI marker
    unsigned char* currentPtr = mExifBuf;
    memcpy(currentPtr, JPEG_MARKER_SOI, sizeof(JPEG_MARKER_SOI));
    totalSize += sizeof(JPEG_MARKER_SOI);
    currentPtr += sizeof(JPEG_MARKER_SOI);
    if (encoder.makeExif(currentPtr, &mConfig.exif, &exifSize, false) != JPG_SUCCESS)
        ALOGE("Error making EXIF");
    currentPtr += exifSize;
    totalSize += exifSize;
    // Copy the EOI marker
    memcpy(currentPtr, (void*)JPEG_MARKER_EOI, sizeof(JPEG_MARKER_EOI));
    totalSize += sizeof(JPEG_MARKER_EOI);
    currentPtr += sizeof(JPEG_MARKER_EOI);
    exifSize = totalSize;

    // Convert and encode the main picture image
    // setup the JpegCompressor input and output buffers
    mEncoderInBuf.clear();
    mEncoderInBuf.buf = (unsigned char *) mainBuf->getData();

    mEncoderInBuf.width = mConfig.picture.width;
    mEncoderInBuf.height = mConfig.picture.height;
    mEncoderInBuf.format = mConfig.picture.format;
    mEncoderInBuf.size = frameSize(mConfig.picture.format,
            mConfig.picture.width,
            mConfig.picture.height);
    mEncoderOutBuf.clear();
    mEncoderOutBuf.buf = (unsigned char*)mOutData;
    mEncoderOutBuf.width = mConfig.picture.width;
    mEncoderOutBuf.height = mConfig.picture.height;
    mEncoderOutBuf.quality = mConfig.picture.quality;
    mEncoderOutBuf.size = mMaxOutDataSize;
    endTime = systemTime();
    int mainSize = compressor.encode(mEncoderInBuf, mEncoderOutBuf);
    LOG1("Picture JPEG size: %d (time to encode: %ums)", mainSize, (unsigned)((systemTime() - endTime) / 1000000));
    if (mainSize > 0) {
        // We will skip SOI marker from final file
        totalSize += (mainSize - sizeof(JPEG_MARKER_SOI));
    } else {
        ALOGE("Could not encode picture stream!");
        status = UNKNOWN_ERROR;
    }

    if (status == NO_ERROR) {
        mCallbacks->allocateMemory(destBuf, totalSize);
        if (destBuf->getData() == NULL) {
            ALOGE("No memory for final JPEG file!");
            status = NO_MEMORY;
        }
    }
    if (status == NO_ERROR) {
        // Copy EXIF (it will also have the SOI and EOI markers
        memcpy(destBuf->getData(), mExifBuf, exifSize);
        // Copy the final JPEG stream into the final destination buffer, but exclude the SOI marker
        char *copyTo = (char*)destBuf->getData() + exifSize;
        char *copyFrom = (char*)mOutData + sizeof(JPEG_MARKER_SOI);
        memcpy(copyTo, copyFrom, mainSize - sizeof(JPEG_MARKER_SOI));
    }
    LOG1("Total JPEG size: %d (time to encode: %ums)", totalSize, (unsigned)((systemTime() - startTime) / 1000000));
    return status;
}
Exemplo n.º 17
0
AtomCP::~AtomCP()
{
    LOG1("@%s", __FUNCTION__);
    ia_cp_hdr_uninit();
    ia_cp_uninit();
}
Exemplo n.º 18
0
KineticStatus KineticPDU_ReceiveMain(KineticPDU* const response)
{
    assert(response != NULL);
    assert(response->connection != NULL);
    const int fd = response->connection->socket;
    assert(fd >= 0);
    LOGF1("\nReceiving PDU via fd=%d", fd);

    KineticStatus status;
    KineticMessage* msg = &response->protoData.message;

    // Receive the PDU header
    ByteBuffer rawHeader =
        ByteBuffer_Create(&response->headerNBO, sizeof(KineticPDUHeader), 0);
    status = KineticSocket_Read(fd, &rawHeader, rawHeader.array.len);
    if (status != KINETIC_STATUS_SUCCESS) {
        LOG0("Failed to receive PDU header!");
        return status;
    }
    else {
        LOG3("PDU header received successfully");
        KineticPDUHeader* headerNBO = &response->headerNBO;
        response->header = (KineticPDUHeader) {
            .versionPrefix = headerNBO->versionPrefix,
            .protobufLength = KineticNBO_ToHostU32(headerNBO->protobufLength),
            .valueLength = KineticNBO_ToHostU32(headerNBO->valueLength),
        };
        KineticLogger_LogHeader(1, &response->header);
    }

    // Receive the protobuf message
    status = KineticSocket_ReadProtobuf(fd, response);
    if (status != KINETIC_STATUS_SUCCESS) {
        LOG0("Failed to receive PDU protobuf message!");
        return status;
    }
    else {
        LOG3("Received PDU protobuf");
        KineticLogger_LogProtobuf(2, response->proto);
    }

    // Validate the HMAC for the recevied protobuf message
    if (response->proto->authType == KINETIC_PROTO_MESSAGE_AUTH_TYPE_HMACAUTH) {
        if(!KineticHMAC_Validate(
          response->proto, response->connection->session.hmacKey)) {
            LOG0("Received PDU protobuf message has invalid HMAC!");
            msg->has_command = true;
            msg->command.status = &msg->status;
            msg->status.code = KINETIC_PROTO_COMMAND_STATUS_STATUS_CODE_DATA_ERROR;
            return KINETIC_STATUS_DATA_ERROR;
        }
        else {
            LOG3("Received protobuf HMAC validation succeeded");
        }
    }
    else if (response->proto->authType == KINETIC_PROTO_MESSAGE_AUTH_TYPE_PINAUTH) {
        LOG0("PIN-based authentication not yet supported!");
        return KINETIC_STATUS_DATA_ERROR;
    }
    else if (response->proto->authType == KINETIC_PROTO_MESSAGE_AUTH_TYPE_UNSOLICITEDSTATUS) {
        LOG3("Unsolicited status message is not authenticated");
    }

    // Extract embedded command, if supplied
    KineticProto_Message* pMsg = response->proto;
    if (pMsg->has_commandBytes &&
      pMsg->commandBytes.data != NULL &&
      pMsg->commandBytes.len > 0) {
        response->command = KineticProto_command__unpack(
            NULL,
            pMsg->commandBytes.len,
            pMsg->commandBytes.data);
    }

    status = KineticPDU_GetStatus(response);
    if (status == KINETIC_STATUS_SUCCESS) {
        LOG2("PDU received successfully!");
    }
    return status;
}

KineticStatus KineticPDU_ReceiveValue(int socket_desc, ByteBuffer* value, size_t value_length)
{
    assert(socket_desc >= 0);
    assert(value != NULL);
    assert(value->array.data != NULL);

    // Receive value payload
    LOGF1("Receiving value payload (%lld bytes)...", value_length);
    ByteBuffer_Reset(value);
    KineticStatus status = KineticSocket_Read(socket_desc, value, value_length);
    if (status != KINETIC_STATUS_SUCCESS) {
        LOG0("Failed to receive PDU value payload!");
        return status;
    }
    LOG1("Received value payload successfully");
    KineticLogger_LogByteBuffer(3, "Value Buffer", *value);
    return status;
}
Exemplo n.º 19
0
// start recording mode
status_t CameraService::Client::startRecording() {
    LOG1("startRecording (pid %d)", getCallingPid());
    return startCameraMode(CAMERA_RECORDING_MODE);
}
Exemplo n.º 20
0
DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old)
{
	static int retry = 0;
	static int owidth, oheight;

	BaseWinFB *fb;
	PalEntry flashColor;
	int flashAmount;

	LOG4 ("CreateFB %d %d %d %p\n", width, height, fullscreen, old);

	if (old != NULL)
	{ // Reuse the old framebuffer if its attributes are the same
		BaseWinFB *fb = static_cast<BaseWinFB *> (old);
		if (fb->Width == width &&
			fb->Height == height &&
			fb->Windowed == !fullscreen)
		{
			return old;
		}
		old->GetFlash (flashColor, flashAmount);
		old->ObjectFlags |= OF_YesReallyDelete;
		if (old == screen) screen = NULL;
		delete old;
	}
	else
	{
		flashColor = 0;
		flashAmount = 0;
	}

	if (D3D != NULL)
	{
		fb = new D3DFB (width, height, fullscreen);
	}
	else
	{
		fb = new DDrawFB (width, height, fullscreen);
	}
	LOG1 ("New fb created @ %p\n", fb);

	// If we could not create the framebuffer, try again with slightly
	// different parameters in this order:
	// 1. Try with the closest size
	// 2. Try in the opposite screen mode with the original size
	// 3. Try in the opposite screen mode with the closest size
	// This is a somewhat confusing mass of recursion here.

	while (fb == NULL || !fb->IsValid ())
	{
		static HRESULT hr;

		if (fb != NULL)
		{
			if (retry == 0)
			{
				hr = fb->GetHR ();
			}
			delete fb;

			LOG1 ("fb is bad: %08lx\n", hr);
		}
		else
		{
			LOG ("Could not create fb at all\n");
		}
		screen = NULL;

		LOG1 ("Retry number %d\n", retry);

		switch (retry)
		{
		case 0:
			owidth = width;
			oheight = height;
		case 2:
			// Try a different resolution. Hopefully that will work.
			I_ClosestResolution (&width, &height, 8);
			LOG2 ("Retry with size %d,%d\n", width, height);
			break;

		case 1:
			// Try changing fullscreen mode. Maybe that will work.
			width = owidth;
			height = oheight;
			fullscreen = !fullscreen;
			LOG1 ("Retry with fullscreen %d\n", fullscreen);
			break;

		default:
			// I give up!
			LOG3 ("Could not create new screen (%d x %d): %08lx", owidth, oheight, hr);
			I_FatalError ("Could not create new screen (%d x %d): %08lx", owidth, oheight, hr);
		}

		++retry;
		fb = static_cast<DDrawFB *>(CreateFrameBuffer (width, height, fullscreen, NULL));
	}
	retry = 0;

	fb->SetFlash (flashColor, flashAmount);

	return fb;
}
sp<ICamera> CameraService::connect(
        const sp<ICameraClient>& cameraClient, int cameraId) {
    int callingPid = getCallingPid();

    LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId);

    if (!mModule) {
        ALOGE("Camera HAL module not loaded");
        return NULL;
    }

    sp<Client> client;
    if (cameraId < 0 || cameraId >= mNumberOfCameras) {
        ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).",
            callingPid, cameraId);
        return NULL;
    }

    char value[PROPERTY_VALUE_MAX];
    property_get("sys.secpolicy.camera.disabled", value, "0");
    if (strcmp(value, "1") == 0) {
        // Camera is disabled by DevicePolicyManager.
        ALOGI("Camera is disabled. connect X (pid %d) rejected", callingPid);
        return NULL;
    }

#if defined(BOARD_HAVE_HTC_FFC)
    htcCameraSwitch(cameraId);
#endif

    Mutex::Autolock lock(mServiceLock);
    if (mClient[cameraId] != 0) {
        client = mClient[cameraId].promote();
        if (client != 0) {
            if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
                LOG1("CameraService::connect X (pid %d) (the same client)",
                     callingPid);
                return client;
            } else {
                ALOGW("CameraService::connect X (pid %d) rejected (existing client).",
                      callingPid);
                return NULL;
            }
        }
        mClient[cameraId].clear();
    }

    if (mBusy[cameraId]) {
        ALOGW("CameraService::connect X (pid %d) rejected"
                " (camera %d is still busy).", callingPid, cameraId);
        return NULL;
    }

    struct camera_info info;
    if (mModule->get_camera_info(cameraId, &info) != OK) {
        ALOGE("Invalid camera id %d", cameraId);
        return NULL;
    }

    int deviceVersion;
    if (mModule->common.module_api_version == CAMERA_MODULE_API_VERSION_2_0) {
        deviceVersion = info.device_version;
    } else {
        deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
    }

    switch(deviceVersion) {
      case CAMERA_DEVICE_API_VERSION_1_0:
        client = new CameraClient(this, cameraClient, cameraId,
                info.facing, callingPid, getpid());
        break;
      case CAMERA_DEVICE_API_VERSION_2_0:
        client = new Camera2Client(this, cameraClient, cameraId,
                info.facing, callingPid, getpid());
        break;
      default:
        ALOGE("Unknown camera device HAL version: %d", deviceVersion);
        return NULL;
    }

    if (client->initialize(mModule) != OK) {
        return NULL;
    }

    cameraClient->asBinder()->linkToDeath(this);

    mClient[cameraId] = client;
    LOG1("CameraService::connect X (id %d, this pid is %d)", cameraId, getpid());
    return client;
}
Exemplo n.º 22
0
sp<ICamera> CameraService::connect(
        const sp<ICameraClient>& cameraClient, int cameraId) {
#ifdef  MTK_CAMERAPROFILE_SUPPORT
    initCameraProfile(); 
    AutoCPTLog cptlog(Event_CS_connect);
#endif
    int callingPid = getCallingPid();

#ifdef VENDOR_EDIT
//LiChen@CameraApp, 2013/03/07, Add for IntelligentSleep
#ifdef OPPO_INTELLIGENT_SLEEP
    LOG1("CameraService::connect Intelligent Sleep (pid %d, id %d)", callingPid, cameraId);
    LOG1("CameraService::connect Intelligent mIntelSleepId %d", mIntelSleepId);
    switch (cameraId) {
        case CAMERA_INTELLIGENT_SLEEP:
        
            for(int i = 0 ; i < mNumberOfCameras; i ++) {
                if (mBusy[i]) {
                    return NULL;
                }
            }

            cameraId = 1;
            mIntelSleepId = CAMERA_INTELLIGENT_SLEEP;
            
            break;
        default:
            if (mIntelSleepId == CAMERA_INTELLIGENT_SLEEP) {
				int cnt = 0;
                while (mClient[1].promote() == NULL && cnt < 10) {
                    usleep(50000);
					cnt++;
                }
                
                if (mClient[1].promote() != NULL) {
                    mClient[1].promote()->disconnect();
                }
            }
            mIntelSleepId = -1;
            break;
    }
#endif
#endif /* VENDOR_EDIT */


    LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId);

    if (!mModule) {
        ALOGE("Camera HAL module not loaded");
        return NULL;
    }

    sp<Client> client;
//!++
#if defined(ATVCHIP_MTK_ENABLE)
    if (cameraId == 0xFF) {
        // It's atv, the last cameraId is atv
        cameraId = mNumberOfCameras - 1;
        status_t status = setProperty(
            String8(MtkCameraParameters::PROPERTY_KEY_CLIENT_APPMODE), 
            String8(MtkCameraParameters::APP_MODE_NAME_MTK_ATV)
        );
        ALOGD("connected from atv - cameraId(%d) status(%d) \n", cameraId, status);
    }
    else if (cameraId < 0 || cameraId >= (mNumberOfCameras - 1)) {
        ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d), (mNumberOfCameras-1=%d).",
        callingPid, cameraId, (mNumberOfCameras-1));
        return NULL;
    }
#else
    if (cameraId < 0 || cameraId >= mNumberOfCameras) {
        ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).",
            callingPid, cameraId);
        return NULL;
    }
#endif
//!--

    char value[PROPERTY_VALUE_MAX];
    property_get("sys.secpolicy.camera.disabled", value, "0");
    if (strcmp(value, "1") == 0) {
        // Camera is disabled by DevicePolicyManager.
        ALOGI("Camera is disabled. connect X (pid %d) rejected", callingPid);
        return NULL;
    }

    Mutex::Autolock lock(mServiceLock);
    if (mClient[cameraId] != 0) {
        client = mClient[cameraId].promote();
        if (client != 0) {
            if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
                LOG1("CameraService::connect X (pid %d) (the same client)",
                     callingPid);
                return client;
            } else {
                ALOGW("CameraService::connect X (pid %d) rejected (existing client).",
                      callingPid);
                return NULL;
            }
        }
        mClient[cameraId].clear();
    }

    if (mBusy[cameraId]) {
        ALOGW("CameraService::connect X (pid %d) rejected"
                " (camera %d is still busy).", callingPid, cameraId);
        return NULL;
    }

    struct camera_info info;
    if (mModule->get_camera_info(cameraId, &info) != OK) {
        ALOGE("Invalid camera id %d", cameraId);
        return NULL;
    }

    int deviceVersion;
    if (mModule->common.module_api_version == CAMERA_MODULE_API_VERSION_2_0) {
        deviceVersion = info.device_version;
    } else {
        deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
    }

    switch(deviceVersion) {
      case CAMERA_DEVICE_API_VERSION_1_0:
        client = new CameraClient(this, cameraClient, cameraId,
                info.facing, callingPid, getpid());
        break;
      case CAMERA_DEVICE_API_VERSION_2_0:
        client = new Camera2Client(this, cameraClient, cameraId,
                info.facing, callingPid, getpid());
        break;
      default:
        ALOGE("Unknown camera device HAL version: %d", deviceVersion);
        return NULL;
    }

#ifdef  MTK_CAMERA_BSP_SUPPORT
    // To avoid release/new MediaPlayer when switching between main/sub sensor, and it will reduce the switch time.
#ifdef VENDOR_EDIT
//LiChen@CameraApp, 2013/04/08, Remove for speeding up the opening camera
    loadSound();
#endif /* VENDOR_EDIT */

#endif  
 
#ifdef  MTK_CAMERAPROFILE_SUPPORT
    CPTLog(Event_CS_newCamHwIF, CPTFlagStart);
#endif

    if (client->initialize(mModule) != OK) {
#ifdef  MTK_CAMERAPROFILE_SUPPORT
        CPTLogStr(Event_CS_newCamHwIF, CPTFlagEnd,  "new CameraHardwareInterface failed");
#endif  
#ifdef  MTK_CAMERA_BSP_SUPPORT
        // To avoid release/new MediaPlayer when switching between main/sub sensor, and it will reduce the switch time.
        releaseSound();
#endif
        return NULL;
    }

#ifdef  MTK_CAMERAPROFILE_SUPPORT
    CPTLog(Event_CS_newCamHwIF, CPTFlagEnd);
#endif

    cameraClient->asBinder()->linkToDeath(this);

    mClient[cameraId] = client;
    LOG1("CameraService::connect X (id %d, this pid is %d)", cameraId, getpid());
    return client;
}
void IonMemManager::destroyIonBuffer(buffer_type_enum buftype)
{
	struct ion_buffer_t* tmpalloc = NULL;
    
	switch(buftype)
	{
		case PREVIEWBUFFER:
			tmpalloc = mPreviewData;
			if(tmpalloc && tmpalloc->virt) {
				LOG1("free preview buffer success!");
				mIonMemMgr->free(*tmpalloc);
				memset(tmpalloc,0,sizeof(ion_buffer_t));
 			} else {
 			    if (mPreviewData == NULL) {
				  //  LOGE("%s(%d): mPreviewData is NULL",__FUNCTION__,__LINE__);
                } else {
				    LOGE("mPreviewData->virt:0x%x mPreviewBufferInfo.mVirBaseAddr:0x%x",(long)mPreviewData->virt,mPreviewBufferInfo->mVirBaseAddr);
                }
			}
			memset(&mPreviewBufferInfo,0,sizeof(mPreviewBufferInfo));
			break;
		case RAWBUFFER:
			tmpalloc = mRawData;
			if(tmpalloc && tmpalloc->virt) {
				LOG1("free RAWBUFFER buffer success!");
				mIonMemMgr->free(*tmpalloc);
				memset(tmpalloc,0,sizeof(ion_buffer_t));
			} else {
				if (mRawData == NULL) {
				 //   LOGE("%s(%d): mRawData is NULL",__FUNCTION__,__LINE__);
                } else {
				    LOGE("mRawData->virt:0x%x mRawBufferInfo.mVirBaseAddr:0x%x",(long)mRawData->virt,mRawBufferInfo->mVirBaseAddr);
                }
			}
			memset(&mRawBufferInfo,0,sizeof(mRawBufferInfo));
			break;
		case JPEGBUFFER:
			tmpalloc = mJpegData;
			if(tmpalloc && tmpalloc->virt) {
				LOG1("free RAWBUFFER buffer success!");
				mIonMemMgr->free(*tmpalloc);
				memset(tmpalloc,0,sizeof(ion_buffer_t));
            } else {
				if (mJpegData == NULL) {
				//    LOGE("%s(%d): mJpegData is NULL",__FUNCTION__,__LINE__);
                } else {
				    LOGE("mJpegData->virt:0x%x mRawBufferInfo.mVirBaseAddr:0x%x",(long)mJpegData->virt,mJpegBufferInfo->mVirBaseAddr);
                }
			}
			memset(&mJpegBufferInfo,0,sizeof(mJpegBufferInfo));
			break;
		case VIDEOENCBUFFER:
			tmpalloc = mVideoEncData;
			if(tmpalloc && tmpalloc->virt) {
				LOG1("free VIDEOENCBUFFER buffer success!");
				mIonMemMgr->free(*tmpalloc);
				memset(tmpalloc,0,sizeof(ion_buffer_t));
			} else {
				if (mVideoEncData == NULL) {
				//	LOGE("%s(%d): mVideoEncData is NULL",__FUNCTION__,__LINE__);
				} else {
					LOGE("mVideoEncData->virt:0x%x mVideoEncBufferInfo.mVirBaseAddr:0x%x",(long)mVideoEncData->virt,mVideoEncBufferInfo->mVirBaseAddr);
				}
			}
			memset(&mVideoEncBufferInfo,0,sizeof(mVideoEncBufferInfo));
			break;

        default:
		   	LOGE("buffer type is wrong !");
            break;
	}
}
Exemplo n.º 24
0
EXIFMaker::~EXIFMaker()
{
    LOG1("@%s", __FUNCTION__);
}
Exemplo n.º 25
0
/* Compute the set of prefetched data.
   Notes:
   1. All prefetches are whole variable fetches.
   2. If the data set is unconstrainable, we
      will prefetch the whole thing
*/
NCerror
prefetchdata(NCDAPCOMMON* nccomm)
{
    int i;
    NCFLAGS flags;
    NCerror ncstat = NC_NOERR;
    NClist* allvars = nccomm->cdf.ddsroot->tree->varnodes;
    DCEconstraint* urlconstraint = nccomm->oc.dapconstraint;
    NClist* vars = nclistnew();
    NCcachenode* cache = NULL;
    DCEconstraint* newconstraint = NULL;

    if(FLAGSET(nccomm->controls,NCF_UNCONSTRAINABLE)) {
        /* If we cannot constrain and caching is enabled,
           then pull in everything */
        if(FLAGSET(nccomm->controls,NCF_CACHE)) {
	    for(i=0;i<nclistlength(allvars);i++) {
	        nclistpush(vars,nclistget(allvars,i));
	    }
	} else { /* do no prefetching */
    	    nccomm->cdf.cache->prefetch = NULL;
	    goto done;
	}
    } else {
	/* pull in those variables previously marked as prefetchable */
        for(i=0;i<nclistlength(allvars);i++) {
            CDFnode* var = (CDFnode*)nclistget(allvars,i);

	    /* Most of the important testing was already done */
	    if(!var->basenode->prefetchable)
		continue;

	    /* Do not attempt to prefetch any variables in the
               nc_open url's projection list
	    */
	    if(nclistcontains(nccomm->cdf.projectedvars,(void*)var))
		continue;

	    /* Should be prefetchable */
	    nclistpush(vars,(void*)var);
if(SHOWFETCH) {
nclog(NCLOGDBG,"prefetch: %s",var->ncfullname);
}
	}
    }

    /* If there are no vars, then do nothing */
    if(nclistlength(vars) == 0) {
	nccomm->cdf.cache->prefetch = NULL;
	goto done;
    }

    /* Create a single constraint consisting of the projections for the variables;
       each projection is whole variable. The selections are passed on as is.
       Conditionally, The exception is if we are prefetching everything.
    */

    newconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT);
    newconstraint->projections = nclistnew();
    newconstraint->selections = dceclonelist(urlconstraint->selections);

    for(i=0;i<nclistlength(vars);i++) {
        CDFnode* var = (CDFnode*)nclistget(vars,i);
	DCEprojection* varprojection;
	/* convert var to a projection */
	ncstat = dapvar2projection(var,&varprojection);
	if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
	nclistpush(newconstraint->projections,(void*)varprojection);
    }
if(SHOWFETCH) {
char* s = dumpprojections(newconstraint->projections);
LOG1(NCLOGNOTE,"prefetch.final: %s",s);
nullfree(s);
}

    flags = NCF_PREFETCH;
#ifndef GRADS_PREFETCH
    if(nclistlength(allvars) == nclistlength(vars)) flags |= NCF_PREFETCH_ALL;
#endif
    ncstat = buildcachenode(nccomm,newconstraint,vars,&cache,flags);
    newconstraint = NULL; /* buildcachenodetakes control of newconstraint */
    if(ncstat != OC_NOERR) goto done;
    else if(cache == NULL) goto done;
    else
      cache->wholevariable = 1; /* All prefetches are whole variable */
    /* Make cache node be the prefetch node */
    nccomm->cdf.cache->prefetch = cache;
if(SHOWFETCH) {
LOG0(NCLOGNOTE,"prefetch.complete");
}

if(SHOWFETCH) {
char* s = NULL;
/* Log the set of prefetch variables */
NCbytes* buf = ncbytesnew();
ncbytescat(buf,"prefetch.vars: ");
for(i=0;i<nclistlength(vars);i++) {
CDFnode* var = (CDFnode*)nclistget(vars,i);
ncbytescat(buf," ");
s = makecdfpathstring(var,".");
ncbytescat(buf,s);
nullfree(s);
 }
ncbytescat(buf,"\n");
nclog(NCLOGNOTE,"%s",ncbytescontents(buf));
ncbytesfree(buf);
 }

done:
    nclistfree(vars);
    dcefree((DCEnode*)newconstraint);
    if(ncstat && cache != NULL) freenccachenode(nccomm,cache);
    return THROW(ncstat);
}
Exemplo n.º 26
0
void apollo_kbd_device::putchar(const UINT8 data)
{
	LOG1(("putchar(%d) -> %02x", m_mode, data));
	m_tx_fifo.putchar(data);
}
Exemplo n.º 27
0
void CMMADisplay::SourceSizeChanged(const TSize& aSourceSize)
{
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SourceSizeChanged");

#ifdef RD_JAVA_NGA_ENABLED
    if (iWindow)
    {
        iWindow->SetVideoCropRegion(TRect(iUserRect.iTl, aSourceSize));
    }
#endif

    iSourceSize = aSourceSize;
    LOG1(EJavaMMAPI,EInfo,"MMA::CMMADisplay::SourceSizeChanged %d",
         aSourceSize.iWidth);
    LOG1(EJavaMMAPI,EInfo,"MMA::CMMADisplay::SourceSizeChanged %d",
         aSourceSize.iHeight);
    jmethodID getDisplayWidthID = iJni->GetMethodID(
                                      iJavaDisplayClass,
                                      "getDisplayWidth",
                                      "()I");

    jmethodID getDisplayHeightID = iJni->GetMethodID(
                                       iJavaDisplayClass,
                                       "getDisplayHeight",
                                       "()I");


    TInt x =  iJni->CallIntMethod(iJavaDisplayObject,getDisplayWidthID);
    TInt y = iJni->CallIntMethod(iJavaDisplayObject,getDisplayHeightID);
    LOG2(EJavaMMAPI,EInfo,"CMMADisplay.cpp : SourceSizeChanged () iFullScreenSize is x = %d ,y = %d ",x,y);
    // get the ScreenSize from canvas in java
    TSize canvasSize(x, y);
    iFullScreenSize = canvasSize;
    TBool sourceIsBigger = (aSourceSize.iWidth > iFullScreenSize.iWidth ||
                            aSourceSize.iHeight > iFullScreenSize.iHeight);

    if (sourceIsBigger)
    {
        // Source is larger than display area.
        // Shrink draw are to fit in display.
        iWindow->SetDrawRect(ScaleToFullScreen(iFullScreenSize, iSourceSize));
    }
    else
    {
        // source is smaller than display area
        iWindow->SetDrawRect(TRect(iUserRect.iTl, iSourceSize));
    }

    SetClippingRegion();

    if (iUserRect.IsEmpty())
    {
        // Java side hasn't set size.
        iUserRect = iWindow->DrawRect();

        if (!sourceIsBigger)
        {
            // Addjusting rect to top left corner.
            iUserRect = TRect(iUserRect.Size());
        }
    }
}
Exemplo n.º 28
0
void apollo_kbd_device::getchar(UINT8 data)
{
	static const UINT8 ff1116_data[] = { 0x00, 0xff, 0x00 };

	LOG1(("getchar <- %02x", data));

	if (m_keyboard_tty.isConnected())
	{
		m_keyboard_tty.putchar(data);
	}

	if (data == 0xff)
	{
		m_rx_message = data;
		putdata(&data, 1);
		m_loopback_mode = 1;
	}
	else if (data == 0x00)
	{
		if (m_loopback_mode)
		{
			set_mode(KBD_MODE_0_COMPATIBILITY);
			m_loopback_mode = 0;
		}
	}
	else
	{
		m_rx_message = m_rx_message << 8 | data;

		switch (m_rx_message)
		{
		case 0xff00:
			putdata(&data, 1);
			m_mode = KBD_MODE_0_COMPATIBILITY;
			m_loopback_mode = 0;
			m_rx_message = 0;
		case 0xff01:
			putdata(&data, 1);
			m_mode = KBD_MODE_1_KEYSTATE;
			m_rx_message = 0;
			break;
		case 0xff11:
			putdata(&data, 1);
			break;
		case 0xff1116:
			putdata(ff1116_data, sizeof(ff1116_data));
			m_loopback_mode = 0;
			m_rx_message = 0;
			break;
		case 0xff1117:
			m_rx_message = 0;
			break;
		case 0xff12:
			putdata(&data, 1);
			break;
		case 0xff1221: // receive ID message
			m_loopback_mode = 0;
			putdata(&data, 1);
			if (keyboard_is_german())
			{
				putstring("3-A\r2-0\rSD-03863-MS\r");
			}
			else
			{
				putstring("3-@\r2-0\rSD-03863-MS\r");
			}

			if (m_mode == KBD_MODE_0_COMPATIBILITY)
			{
				set_mode(KBD_MODE_0_COMPATIBILITY);
			}
			else
			{
				set_mode(KBD_MODE_1_KEYSTATE);
			}
			m_rx_message = 0;
			break;
		case 0xff2181: // beeper on (for 300 ms)
			putdata(&data, 1);
			m_rx_message = 0;
			m_beeper.on();
			break;
		case 0xff2182: // beeper off
			putdata(&data, 1);
			m_rx_message = 0;
			m_beeper.off();
			break;
		default:
			if (m_loopback_mode && data != 0)
			{
				putdata(&data, 1);
			}
			break;
		}
	}
}
// start preview mode
status_t CameraClient::startPreview() {
    LOG1("startPreview (pid %d)", getCallingPid());
    return startCameraMode(CAMERA_PREVIEW_MODE);
}
// ---------------------------------------------------------
// CDpDte2Tx::RunL
// This method handles write operation after signalling.
// ---------------------------------------------------------
//
void CDpDte2Tx::RunL()
    {
    OstTrace0( TRACE_NORMAL, CDPDTE2TX_RUNL, "CDpDte2Tx::RunL" );
    OstTrace1( TRACE_NORMAL, DUP1_CDPDTE2TX_RUNL, "CDpDte2Tx::RunL %x", &iDataPort );
    OstTrace1( TRACE_NORMAL, DUP2_CDPDTE2TX_RUNL, "CDpDte2Tx:: Port: %u", iDataPort.PortUnit() );

    LOGM1("CDpDte2Tx::RunL %x", &iDataPort);
    LOGM1("CDpDte2Tx::RunL - Port %d", iDataPort.PortUnit() );

    if ( iWritePending && iStatus != KErrCancel )
        {
        // check linefail
        TCommRole role;
        iDataPort.GetRole( role );
        if ( iDataConfig.IsLineFail( role ) )
            {
            LOG(" ERROR, Dte2Tx::RunL, Dte write completed with LINE FAIL.");
            OstTrace0( TRACE_NORMAL, DUP3_CDPDTE2TX_RUNL, "ERROR, Dte2Tx::RunL, Dte write completed with LINE FAIL." );

            iDataPort.WriteCompleted( KErrCommsLineFail );
            iWritePending = EFalse;
            iPendingClientBuffer = 0;
            iPendingLength = 0;
            }
        else if ( iDataConfig.IsEchoDte() &&
            ( iPendingLength - iIPCReadOffset ) > iRx2Dte.EchoBytesFreeSpace() )
            {
            if ( !IsActive() )
                {
                iRequestActive = ETrue;
                iStatus = KRequestPending;
                SetActive();
                }
            //no else
            }
        else
            {
            // first take minimum of three elements
            TInt clientLength( iPendingLength - iIPCReadOffset );
            TInt freeBytes( iBufferTx.FreeBytes() );
            TInt len( 0 );

            if ( clientLength >= iBufferTx.MaxReservationSize() )
                {
                len = iBufferTx.MaxReservationSize();
                }
            else
                {
                len = clientLength;
                }

            if ( freeBytes > 0 )
                {
                if (len >= freeBytes)
                    {
                    len = freeBytes;
                    }
                //no else
                }
            //no else

            TPtr8 nullPtr( 0, 0 );
            CDpDataElement& elem = iBufferTx.WriteElement();

            TInt ret( elem.Reserve( len, iTx, nullPtr ) );

            if ( ret != KErrNone)
                {
                if ( ret == KErrNotReady )
                    {
                    if ( !IsActive() )
                        {
                        iRequestActive = ETrue;
                        iStatus = KRequestPending;
                        SetActive();
                        }
                    //no else
                    }
                else
                    {
                    LOG1(" ErrorDte2Tx Tx element reservation failure! Id: %d",
                        ret );
                    OstTrace1( TRACE_NORMAL, DUP4_CDPDTE2TX_RUNL, "CDpDte2Tx:: ErrorDte2Tx Tx element reservation failure! Id: %d", ret );

                    User::Leave( ret );
                    }
                }
            else
                {
                // we suppose it's always either KErrNone or KErrNotReady ...
                User::LeaveIfError( iDataPort.IPCRead(
                    iPendingClientBuffer, iTx, iIPCReadOffset ) );

                if ( iDataConfig.IsEchoDte() && 0 < iTx.Length() )
                    {
                    // configured to echo tx bytes
                    iRx2Dte.EchoTx( iTx );
                    }
                //no else

                iEscDetect.Scan( iTx );

                // WasReaderWaiting is used to check if the reader was waiting
                // for more data until it is being able to read. Otherwise it
                // should signal to reader (Tx2Pn) that it can then read
                TBool WasReaderWaiting = iBufferTx.IsReaderWaiting();

                User::LeaveIfError( elem.Release( iTx.Length() ) );

                iIPCReadOffset += iTx.Length();

                // If reader was waiting for more data and got the enough,
                // DPElement from Release will notify Reader using ReleaseNotify().
                // WasReaderWaiting checks if Reader was waiting, if it is not,
                // it should signal the reader to read the buffer.
                if ( !WasReaderWaiting )
                    {
                    iDataPort.SignalTx2Pn();
                    }
                //no else

                if ( iIPCReadOffset >= iPendingLength )
                    {
                    LOG(" Dte2Tx::RunL, Dte write completed.");
                    OstTrace0( TRACE_NORMAL, DUP5_CDPDTE2TX_RUNL, "CDpDte2Tx:: Dte write completed" );

                    iIPCReadOffset = 0;
                    iDataPort.WriteCompleted( KErrNone );
                    iWritePending = EFalse;
                    iPendingClientBuffer = 0;
                    iPendingLength = 0;
                    }
                else
                    {
                    if ( !IsActive() )
                        {
                        iRequestActive = ETrue;
                        iStatus = KRequestPending;
                        SetActive();
                        }
                    //no else
                    iDataPort.SignalDte2Tx();
                    }
                }
            }
        }
        //no else
    }