Ejemplo n.º 1
0
//structured monte carlo
//maintains correct blockstructure doesnt work very good
void oku_mcblksol(oku_sod* sod, double temp){
	int i,j,k,val;
	int fit1, fit2, num,blk,idx1,idx2,tmp;
	int size = sod->size;
	int blkunk[size],cnt[size];
	int blkunkidx[size][size];

	for(i=0;i<size;i++){
		blkunk[i] = 0;
		for(j=0;j<size;j++)
			cnt[j] = 0;

		//find unknowns for every block
		for(j=0;j<size;j++){
			val = get_blk(sod,i,j);
			if(val == 0){
				blkunkidx[i][blkunk[i]++] = j;
			} else {
				if(cnt[val-1] == 0){
					cnt[val-1] = 1;
				} else printf("Fehler in oku_mcblocksol: Invalid hint: %d\n",val);
			}
		}

		//fill them
		k=0;
		for(j=0;j<size;j++)
			if(cnt[j] == 0)
				set_blk(sod,i,blkunkidx[i][k++],j+1);
	}

	oku_sod_print(sod);

	fit1 = fitness(sod);
	num = 0;
	while(fit1){
		//choose block and two indizes inside
		blk = rndi() % size;
		idx1 = rndi() % blkunk[blk];
		idx2 = rndi() % blkunk[blk];

		//swap
		tmp = get_blk(sod,blk,idx1);
		set_blk(sod,blk,idx1,get_blk(sod,blk,idx2));
		set_blk(sod,blk,idx2,tmp);

		fit2 = fitness(sod); 

		if(fit2 > fit1 && exp((fit1 - fit2)/temp) < rndf()){
			//swap back
			tmp = get_blk(sod,blk,idx1);
			set_blk(sod,blk,idx1,get_blk(sod,blk,idx2));
			set_blk(sod,blk,idx2,tmp);
		} else fit1 = fit2;
		num++;
		if(num % 2000 == 0)
			printf("Step:%d Fitness: %d\n",num,fit1);
	}

}
Ejemplo n.º 2
0
//ethan_20110801_readAllCalibrationData,for Systeminit only
ER Cal_ReadCalData(void)
{
    ER ercode;
    UINT tmpDataArea,ECSDataArea;
    ercode = get_blk((void *)&(tmpDataArea), POOL_ID_DEFECT_PIXEL);
    if(ercode != E_OK)
    {
        debug_err(("Get dpfect pixel buffer error!!\r\n"));
    }
    else
    {
        rel_blk(POOL_ID_DEFECT_PIXEL, (VP)tmpDataArea);
        memset((void *)tmpDataArea,0,POOL_SIZE_DEFECT_PIXEL);
    }

    ercode = get_blk((void *)&(ECSDataArea), POOL_ID_ECS);
    if(ercode != E_OK)
    {
        debug_err(("Get ECS buffer error!!\r\n"));
    }
    else
    {
        rel_blk(POOL_ID_ECS, (VP)ECSDataArea);
        memset((void *)ECSDataArea,0,POOL_SIZE_ECS);
    }

    ercode = Cal_ReadData(NULL);
#if (_CALIBRATION_MODE_ == ENABLE)
    Cal_PassAdjustData();
#endif
    return ercode;
}
Ejemplo n.º 3
0
// returns 0 if solved > 0 otherwise
int unsolved(oku_sod* sod){
	int i,j,size = sod->size, score=0;
	//occurance counters
	int row[size+1][size+1],col[size+1][size+1],blk[size+1][size+1];
	//initialize counters
	for(i=0;i<size+1;i++)
		for(j=1;j<size+1;j++){
			row[i][j] = 0;
			col[i][j] = 0;
			blk[i][j] = 0;
		}
	// count occurances
	for(i=0;i<size;i++)
		for(j=0;j<size;j++){
			row[i][get_row(sod,i,j)]++;
			col[i][get_col(sod,i,j)]++;
			blk[i][get_blk(sod,i,j)]++;
		}
	for(i=0;i<size;i++)
		for(j=1;j<size+1;j++){
			score += row[i][j] > 1 ? 1 : 0;
			score += col[i][j] > 1 ? 1 : 0;
			score += blk[i][j] > 1 ? 1 : 0;
		 }
	return score;
}
Ejemplo n.º 4
0
/**
  Open Calibration task

  Open Calibration task

  @param PCAL_APPOBJ pCalObj: Calibration task object, specify memory available in calibration task.
  @return ER
    E_SYS: Task is already opened
    E_PAR: Parameter error (memory address or size is invalid)
    E_OK : Task opened correctly
*/
ER Cal_Open(void)
{
#if 0
    UINT32 uiPoolAddr;
    CAL_APPOBJ CalAppObj;

    if (g_bCalbirationOpened == TRUE)
    {
        return E_SYS;
    }

    g_bCalbirationOpened = TRUE;

    //Get memory for calibartion task
    get_blk((VP *)&uiPoolAddr, POOL_ID_FB);
    rel_blk(POOL_ID_FB, (VP)uiPoolAddr);

    CalAppObj.uiMemoryAddr = uiPoolAddr;
    CalAppObj.uiMemorySize = END_MEM - uiPoolAddr - POOL_SIZE_RAM_DISK;
    CalAppObj.pCalApi = Cal_GetCalApi();

    Cal_Init(&CalAppObj);
#endif

    return E_OK;
}
Ejemplo n.º 5
0
Archivo: mtree.c Proyecto: taysom/tau
void append_mtree(struct mtree *mt, u64 key, struct lump val)
{
	struct block *parent = NULL;
	struct block *child;
	struct branch *branch;
	struct leaf *leaf;
	struct twig *twig;
	int i;

eaver(val.size < 20);
	/* Find level that is not full */
	for (i = 0; ; i++) {
		if (i == MAX_LEVELS)
			fatal("out of levels");
		if (!mt->level[i]) {	/* Grow tree */
			if (i == 0) {
				child = new_leaf(mt);
			} else {
				u64 oldroot = mt->level[i - 1];
				child = new_branch(mt, oldroot);
				branch = child->buf;
				twig = branch->twig;
				twig->key = 0;
				twig->blknum = oldroot;
				branch->num_twigs = 1;
			}
			mt->level[i] = child->blknum;
			break;
		}
		child = get_blk(mt->dev, mt->level[i]);
		if (!isFull(child, val.size))
			break;
		put_blk(child);
	}
	/* Work our way back down the tree expanding it as we go */
	for (;;) {
		if (isLeaf(child))
			break;
		parent = child;
		branch = parent->buf;
		--i;
		if (i == 0) {
			child = new_leaf(mt);
		} else {
			child = new_branch(mt, mt->level[i - 1]);
		}
		twig = &branch->twig[branch->num_twigs++];
		twig->key = key;
		twig->blknum = child->blknum;
		mt->level[i] = child->blknum;
		put_blk(parent);
	}
	leaf = child->buf;
	append_leaf(leaf, key, val);
	put_blk(child);
	return;
}
Ejemplo n.º 6
0
/*写文件函数*/
int file_write(char* name)
{
	int 	inode;
	int		num, blk_num;
	FILE* 	fp = fopen(BUFF, "rb");
	Inode	temp;
	char	buff[BlkSize];

	inode = check_name(inode_num, name);

	fseek(Disk, InodeBeg + sizeof(Inode)*inode, SEEK_SET);
	fread(&temp, sizeof(Inode), 1, Disk);

	if (temp.access[1][user_num] == 0) { //文件不可写
		printf("%d\n", temp.access[1][user_num]);
		return -1;
	}

	//将原文件内容对应地磁盘块释放,文件大小设为0,
	//然后重新申请磁盘块存放修改后的文件内容,更新文件的大小和修改时间,属性改变时间
	temp.blk_num = 0;
	temp.file_size = 0;
	
	while (num = fread(buff, sizeof(char), BlkSize, fp)) {
		printf("num:%d\n", num);
		if ((blk_num = get_blk()) == -1) {
			printf("error:	block has been used up\n");
			break;
		}
		/*改变Inode结构的相应状态*/
		temp.blk_identifier[temp.blk_num++] = blk_num;
		temp.file_size += num;	
		printf("file_size:%d\n blocks: %d\n", temp.file_size, temp.blk_num);
		/*将数据写回磁盘块*/
		fseek(Disk, BlockBeg + BlkSize*blk_num, SEEK_SET);
		fwrite(buff, sizeof(char), num, Disk);
	}
	temp.i_mtime = time(NULL);
	temp.i_ctime = time(NULL);


	/*将修改后的Inode写回*/
	fseek(Disk, InodeBeg + sizeof(Inode)*inode, SEEK_SET);
	fwrite(&temp, sizeof(Inode), 1, Disk);

	/*
	Inode temp2;
	fseek(Disk, InodeBeg + sizeof(Inode)*inode, SEEK_SET);
	fread(&temp2, sizeof(Inode), 1, Disk);*/

//	printf("file_size:%d\n blocks: %d\n", temp2.file_size, temp2.blk_num);

	fclose(fp);
	return 1;
}
Ejemplo n.º 7
0
UINT8* UserPS_InitUniFontData(void)
{
    PPSTORE_SECTION_HANDLE  pSection;
    UINT32                  uiReadSize;
    UINT8                   *pMemPool;

    get_blk((void *)&pMemPool,  POOL_ID_CAPTURE);
    rel_blk(POOL_ID_CAPTURE, pMemPool);

    // Read Unicode font data from PStore to this memory pool
    pMemPool = (pMemPool + POOL_SIZE_CAPTURE - POOL_SIZE_UNIFONT);

    //PStore_EnablePS();

    if((pSection = PStore_OpenSection(PS_UNIFONT_DATA, PS_RDONLY)) != E_PS_SECHDLER)
    {
        // Get Unicode font data size first (leading 4 bytes)
        if(PStore_ReadSection(pMemPool, 0, 4, pSection) != E_PS_OK)
        {
            debug_err(("UserPS: PStore read Unicode font data size fail\r\n"));
            return NULL;
        }

        uiReadSize = MAKE_LONG(MAKE_WORD(pMemPool[0], pMemPool[1]), MAKE_WORD(pMemPool[2], pMemPool[3]));
        debug_err(("UserPS: Gotta read Unicode font data size = %ld\r\n", uiReadSize));
        if(uiReadSize > POOL_SIZE_UNIFONT)
        {
            debug_err(("UserPS: Font data size too large!\r\n"));
            return NULL;
        }

        // Get Unicode font data
        if(PStore_ReadSection(pMemPool, 4, uiReadSize, pSection) != E_PS_OK)
        {
            debug_err(("UserPS: PStore read Unicode font data fail\r\n"));
            return NULL;
        }

        PStore_CloseSection(pSection);
        //PStore_DisablePS();

#if 0   //Just verify the data integrity
        FilesysReadWriteByName2(FST_CMD_WRITE_BY_NAME, "A:\\VFONT.BIN", (UINT8 *)(pMemPool),
                                &uiReadSize, 0, FST_TIME_INFINITE);
#endif
    }
    else
    {
        debug_err(("UserPS: PStore open section fail\r\n"));
        //PStore_DisablePS();
        return NULL;
    }

    return pMemPool;
}
Ejemplo n.º 8
0
Archivo: mtree.c Proyecto: taysom/tau
static void pr_block(struct mtree *mt, u64 blknum, int indent)
{
	struct block *b;

	eaver(blknum);
	b = get_blk(mt->dev, blknum);
	if (isLeaf(b))
		pr_leaf(b->buf, indent+1);
	else
		pr_branch(mt, b->buf, indent+1);
	put_blk(b);
}
Ejemplo n.º 9
0
odp_buffer_t buffer_alloc(void *pool, size_t size)
{
	struct pool_entry_s *pool_s = &((pool_entry_t *)pool)->s;
	uintmax_t totsize = size + pool_s->room_size;
	odp_buffer_hdr_t *buf;

	/* Reject oversized allocation requests */
	if (odp_unlikely(size > pool_s->max_size))
		return ODP_BUFFER_INVALID;

	/* Try to satisfy request from the local cache */
	buf = get_local_buf(&pool_s->local_cache[local_id], pool_s, totsize);

	/* If cache is empty, satisfy request from the pool */
	if (odp_unlikely(buf == NULL)) {
		buf = get_buf(pool_s);

		if (odp_unlikely(buf == NULL))
			return ODP_BUFFER_INVALID;

		/* Get blocks for this buffer, if pool uses application data */
		if (buf->size < totsize) {
			intmax_t needed = totsize - buf->size;

			do {
				uint8_t *blk = get_blk(pool_s);

				if (blk == NULL) {
					ret_buf(pool_s, buf);
					return ODP_BUFFER_INVALID;
				}
				buf->addr[buf->segcount++] = blk;
				needed -= pool_s->seg_size;
			} while (needed > 0);
			buf->size = buf->segcount * pool_s->seg_size;

			/* Record the hdr before the buffer head */
			*(unsigned long *)(buf->addr[0] -
			      ODP_HDR_BACK_PTR_SIZE) = (unsigned long)buf;
		}
	}

	/* Mark buffer as allocated */
	buf->allocator = local_id;

	/* By default, buffers inherit their pool's zeroization setting */
	buf->flags.zeroized = pool_s->flags.zeroized;

	/* By default, buffers are not associated with an ordered queue */
	buf->origin_qe = NULL;

	return (odp_buffer_t)buf;
}
Ejemplo n.º 10
0
SYSCALL ER _tk_get_mpl_u( ID mplid, INT blksz, void **p_blk, TMO_U tmout )
{
	MPLCB	*mplcb;
	void	*blk = NULL;
	ER	ercd = E_OK;

	CHECK_MPLID(mplid);
	CHECK_PAR(blksz > 0 && blksz <= MAX_ALLOCATE);
	CHECK_TMOUT(tmout);
	CHECK_DISPATCH();

	mplcb = get_mplcb(mplid);
	blksz = roundSize(blksz);

	BEGIN_CRITICAL_SECTION;
	if ( mplcb->mplid == 0 ) {
		ercd = E_NOEXS;
		goto error_exit;
	}

#if CHK_PAR
	if ( blksz > mplcb->mplsz ) {
		ercd = E_PAR;
		goto error_exit;
	}
#endif

	/* Check wait disable */
	if ( is_diswai((GCB*)mplcb, ctxtsk, TTW_MPL) ) {
		ercd = E_DISWAI;
		goto error_exit;
	}

	if ( gcb_top_of_wait_queue((GCB*)mplcb, ctxtsk) == ctxtsk
	  && (blk = get_blk(mplcb, blksz)) != NULL ) {
		/* Get memory block */
		*p_blk = blk;
	} else {
		/* Ready for wait */
		ctxtsk->wspec = ( (mplcb->mplatr & TA_TPRI) != 0 )?
					&wspec_mpl_tpri: &wspec_mpl_tfifo;
		ctxtsk->wercd = &ercd;
		ctxtsk->winfo.mpl.blksz = blksz;
		ctxtsk->winfo.mpl.p_blk = p_blk;
		gcb_make_wait_with_diswai((GCB*)mplcb, tmout);
	}

    error_exit:
	END_CRITICAL_SECTION;

	return ercd;
}
Ejemplo n.º 11
0
void MsdcNvtCb_LcdGetFreeMem(void* pData)
{
    tMSDCEXT_LCD_DRV_MEM_POOL_GET* pDesc = BEGIN_MSDC_NVT_CB(tMSDCEXT_LCD_DRV_MEM_POOL_GET,pData);
    if(pDesc==NULL)
    {
        debug_err(("MsdcNvtCb_LcdGetFreeMem(): is failed!\r\n"));
        return;
    }
    get_blk((void *)&pDesc->PoolAddr,  POOL_ID_CAPTURE);
    rel_blk(POOL_ID_CAPTURE, (VP)pDesc->PoolAddr);
    pDesc->PoolSize = POOL_SIZE_CAPTURE;

    pDesc->tParent.bOK = TRUE;
}
Ejemplo n.º 12
0
odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size)
{
	uint32_t pool_id = pool_handle_to_index(pool_hdl);
	pool_entry_t *pool = get_pool_entry(pool_id);
	uintmax_t totsize = pool->s.headroom + size + pool->s.tailroom;
	odp_anybuf_t *buf;

	/* Reject oversized allocation requests */
	if ((pool->s.flags.unsegmented && totsize > pool->s.seg_size) ||
	    (!pool->s.flags.unsegmented &&
	     totsize > pool->s.seg_size * ODP_BUFFER_MAX_SEG))
		return ODP_BUFFER_INVALID;

	/* Try to satisfy request from the local cache */
	buf = (odp_anybuf_t *)(void *)get_local_buf(&local_cache[pool_id],
						    &pool->s, totsize);

	/* If cache is empty, satisfy request from the pool */
	if (odp_unlikely(buf == NULL)) {
		buf = (odp_anybuf_t *)(void *)get_buf(&pool->s);

		if (odp_unlikely(buf == NULL))
			return ODP_BUFFER_INVALID;

		/* Get blocks for this buffer, if pool uses application data */
		if (buf->buf.size < totsize) {
			intmax_t needed = totsize - buf->buf.size;
			do {
				uint8_t *blk = get_blk(&pool->s);
				if (blk == NULL) {
					ret_buf(&pool->s, &buf->buf);
					return ODP_BUFFER_INVALID;
				}
				buf->buf.addr[buf->buf.segcount++] = blk;
				needed -= pool->s.seg_size;
			} while (needed > 0);
			buf->buf.size = buf->buf.segcount * pool->s.seg_size;
		}
	}

	/* By default, buffers inherit their pool's zeroization setting */
	buf->buf.flags.zeroized = pool->s.flags.zeroized;

	if (buf->buf.type == ODP_EVENT_PACKET)
		packet_init(pool, &buf->pkt, size);

	return odp_hdr_to_buf(&buf->buf);
}
Ejemplo n.º 13
0
Archivo: mtree.c Proyecto: taysom/tau
static int next_key(struct iterator_mtree *imt, u64 blknum)
{
	struct block *b;
	u64 key = imt->key;
	int i;
	int rc;

	if (!blknum)
		return DONE;
	b = get_blk(imt->mt->dev, blknum);

	if (isLeaf(b)) {
		struct leaf *leaf = b->buf;
		struct record *rec = (struct record *)leaf->data;

		for (i = 0; i < leaf->num_recs; i++, rec++) {
			if (key < rec->key) {
				imt->key = rec->key;
				imt->val.size = rec->size;
				memcpy(imt->data,
					&leaf->data[rec->offset],
					rec->size);
				put_blk(b);
				return 0;
			}
		}
		put_blk(b);
		return NEXT;
	} else {
		struct branch *branch = b->buf;
		struct twig *twig = branch->twig;
		
		for (i = 0; i < branch->num_twigs - 1; i++, twig++) {
			if (key < twig[1].key)
				break;
		}
		for (; i < branch->num_twigs; i++, twig++) {
			rc = next_key(imt, twig->blknum);
			if (rc == 0) {
				put_blk(b);
				return 0;
			}
		}
		put_blk(b);
		return NEXT;
	}
}
Ejemplo n.º 14
0
/*
 * Allocate memory and release wait task,
 * as long as there are enough free memory.
 */
LOCAL void mpl_wakeup( MPLCB *mplcb )
{
	TCB	*top;
	void	*blk;
	INT	blksz;

	while ( !isQueEmpty(&mplcb->wait_queue) ) {
		top = (TCB*)mplcb->wait_queue.next;
		blksz = top->winfo.mpl.blksz;

		/* Check free space */
		if ( blksz > MaxFreeSize(mplcb) ) {
			break;
		}

		/* Get memory block */
		blk = get_blk(mplcb, blksz);
		*top->winfo.mpl.p_blk = blk;

		/* Release wait task */
		wait_release_ok(top);
	}
}
Ejemplo n.º 15
0
void task1( unsigned int arg )
{
    ER ercd;
    int i;
    T_RSYS rsys;

    CYG_TEST_INFO( "Task 1 running" );

    // check initial state
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" );
    // disable intrs and check state
    ercd = loc_cpu();
    CYG_TEST_CHECK( E_OK == ercd, "loc_cpu bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_LOC == rsys.sysstat, "system state not TSS_LOC" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // try an illegal op
    ercd = dly_tsk( 10 );
    CYG_TEST_CHECK( E_CTX == ercd, "dly_tsk bad ercd !E_CTX" );
#endif // CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // enable intrs and check state and a legal sleep
    ercd = unl_cpu();
    CYG_TEST_CHECK( E_OK == ercd, "unl_cpu bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" );
    ercd = dly_tsk( 1 );
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );
    // disable intrs and try scheduler illegal ops
    ercd = loc_cpu();
    CYG_TEST_CHECK( E_OK == ercd, "loc_cpu bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_LOC == rsys.sysstat, "system state not TSS_LOC" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = dis_dsp();
    CYG_TEST_CHECK( E_CTX == ercd, "dis_dsp bad ercd !E_CTX" );
    ercd = ena_dsp();
    CYG_TEST_CHECK( E_CTX == ercd, "ena_dsp bad ercd !E_CTX" );
#endif // CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // enable again and check state
    ercd = unl_cpu();
    CYG_TEST_CHECK( E_OK == ercd, "unl_cpu bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" );
    // disable the scheduler and check state
    ercd = dis_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_DDSP == rsys.sysstat, "system state not TSS_DDSP" );
    // disable intrs and check state
    ercd = loc_cpu();
    CYG_TEST_CHECK( E_OK == ercd, "loc_cpu bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_LOC == rsys.sysstat, "system state not TSS_LOC" );
    // then unlock and check state
    ercd = unl_cpu();
    CYG_TEST_CHECK( E_OK == ercd, "unl_cpu bad ercd" );
    ercd = ref_sys( &rsys );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" );
    CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" );

    CYG_TEST_PASS( "Interrupt dis/enabling and interactions" );

    // and now we can do the rest of the test

#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = rel_wai( 2 );
    CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai bad ercd !E_OBJ" );
    ercd = rel_wai( 1 );
    CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai(me) bad ercd !E_OBJ" );
    ercd = rel_wai( -6 );
    CYG_TEST_CHECK( E_ID == ercd, "rel_wai bad ercd !E_ID" );
    ercd = rel_wai( 99 );
    CYG_TEST_CHECK( E_ID == ercd, "rel_wai bad ercd !E_ID" );
#endif // we can test bad param error returns

    ercd = dis_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
    ercd = sta_tsk( 2, 22222 );
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
    ercd = chg_pri( 2, 5 );
    CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
    ercd = ena_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );

#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = rel_wai( 2 );
    CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai bad ercd !E_OBJ" );
    ercd = rel_wai( 1 );
    CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai(me) bad ercd !E_OBJ" );
#endif // we can test bad param error returns

    ercd = wai_sem( 1 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "wai_sem bad ercd !E_RLWAI" );

    ercd = twai_sem( 1, 20 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "twai_sem bad ercd !E_RLWAI" );

    ercd = wai_flg( &scratch, 1, 9999, 0 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "wai_flg bad ercd !E_RLWAI" );

    ercd = twai_flg( &scratch, 1, 9999, 0, 10 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "twai_flg bad ercd !E_RLWAI" );

    ercd = rcv_msg( &t_msg, 1 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "rcv_msg bad ercd !E_RLWAI" );

    ercd = trcv_msg( &t_msg, 1, 10 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "trcv_msg bad ercd !E_RLWAI" );

    // these are loops so as to consume the whole of the mempool
    // in order to wait at the end
    for ( i = 0; i < 10; i++ )
        if ( E_OK != (ercd = get_blf( &vp, 3 ) ) )
            break;
    CYG_TEST_CHECK( E_RLWAI == ercd, "get_blf bad ercd !E_RLWAI" );

    for ( i = 0; i < 10; i++ )
        if ( E_OK != (ercd = tget_blf( &vp, 3, 10 ) ) )
            break;
    CYG_TEST_CHECK( E_RLWAI == ercd, "tget_blf bad ercd !E_RLWAI" );

    for ( i = 0; i < 10; i++ )
        if ( E_OK != (ercd = get_blk( &vp, 1, 1000 ) ) )
            break;
    CYG_TEST_CHECK( E_RLWAI == ercd, "get_blk bad ercd !E_RLWAI" );

    for ( i = 0; i < 10; i++ )
        if ( E_OK != (ercd = tget_blk( &vp, 1, 1000, 10 ) ) )
            break;
    CYG_TEST_CHECK( E_RLWAI == ercd, "tget_blk bad ercd !E_RLWAI" );

    ercd = dly_tsk( 10 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "dly_tsk bad ercd !E_RLWAI" );

    ercd = tslp_tsk( 10 );
    CYG_TEST_CHECK( E_RLWAI == ercd, "tslp_tsk bad ercd !E_RLWAI" );

    ercd = slp_tsk();
    CYG_TEST_CHECK( E_RLWAI == ercd, "slp_tsk bad ercd !E_RLWAI" );

    ercd = ter_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
    ercd = dly_tsk( 10 );
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );

    CYG_TEST_PASS("release wait: various waiting calls");

    // all done
    CYG_TEST_EXIT( "All done" );
    ext_tsk();
}
Ejemplo n.º 16
0
UINT32 UserPS_WriteUniFontFile(CHAR *pFilename)
{
    PPSTORE_SECTION_HANDLE  pSection;
    HNVT_FILE               *pFile;
    UINT32                  uiFileSize, uiWriteSize;
    UINT8                   *pMemPool;

    FilesysWaitInitFinish(FST_TIME_INFINITE);
    FilesysWaitCmdFinish(FST_TIME_INFINITE);

    pFile = Filesys_fopen((char *)pFilename, "R");
    if(pFile == NULL)
    {
        debug_err(("UserPS: Error opening %s\r\n", pFilename));
        return E_USERPS_FILE;
    }

    uiFileSize = pFile->fileSize;
    uiWriteSize = uiFileSize;
    debug_err(("UserPS: File size = %ld\r\n", uiFileSize));
    FilesysCloseActFile();

    if(uiFileSize > POOL_SIZE_UNIFONT)
    {
        debug_err(("UserPS: File size too large!\r\n"));
        return E_USERPS_FILE;
    }

    get_blk((void *)&pMemPool, POOL_ID_CAPTURE);
    rel_blk(POOL_ID_CAPTURE, pMemPool);

    pMemPool = (pMemPool + POOL_SIZE_CAPTURE - POOL_SIZE_UNIFONT);
    FilesysReadWriteByName2(FST_CMD_READ_BY_NAME, pFilename, (UINT8 *)(pMemPool+4),
                            &uiWriteSize, 0, FST_TIME_INFINITE);
    FilesysWaitCmdFinish(FST_TIME_INFINITE);
    debug_err(("UserPS: Gotta write file size = %ld\r\n", uiWriteSize));

    *pMemPool = LO_BYTE(LO_WORD(uiWriteSize));
    *(pMemPool+1) = HI_BYTE(LO_WORD(uiWriteSize));
    *(pMemPool+2) = LO_BYTE(HI_WORD(uiWriteSize));
    *(pMemPool+3) = HI_BYTE(HI_WORD(uiWriteSize));

    //PStore_EnablePS();

    if((pSection = PStore_OpenSection(PS_UNIFONT_DATA, PS_RDWR | PS_CREATE)) != E_PS_SECHDLER)
    {
        if(PStore_WriteSection(pMemPool, 0, (uiWriteSize+4), pSection) != E_PS_OK)
        {
            debug_err(("UserPS: PStore write Unicode font data fail\r\n"));
        }
        PStore_CloseSection(pSection);
        //PStore_DisablePS();
    }
    else
    {
        debug_err(("UserPS: PStore open section fail\r\n"));
        //PStore_DisablePS();
        return E_USERPS_PSECTION;
    }

    return E_USERPS_OK;
}
Ejemplo n.º 17
0
/**
  Initialize application for Photo mode

  Initialize application for Photo mode.

  @param void
  @return void
*/
void AppInit_ModePhoto(void)
{
    UINT32              uiPoolAddr;
    PHOTO_APPOBJ        PhotoObj;
    CAPTURE_APPOBJ      CaptureObj;
    PHOTODISPLAY_APPOBJ PhotoDisplayObj;
    //#NT#2010/10/27#Connie Yu -begin
    //#NT#movie DIS update
    PHOTODIS_APPOBJ     PhotoDisObj = {0};
    //#NT#2010/10/27#Connie Yu -end
#if(_WAVSTUDIO_MODE_ == ENABLE)
    WAVSTUDIO_APPOBJ    WavObj;
    WAVSTUDIO_FMT       WavFormat;
#endif

    // Get memory for Capture task
    get_blk((VP *)&uiPoolAddr, POOL_ID_CAPTURE);
    rel_blk(POOL_ID_CAPTURE, (VP)uiPoolAddr);

    CaptureObj.uiMemoryAddr         = uiPoolAddr;
    CaptureObj.uiMemorySize         = POOL_SIZE_CAPTURE - POOL_SIZE_WAV;
    CaptureObj.CallBackFunc         = (FPALGCALLBACK)FlowPhoto_ImageCB;
    //#NT#2009/07/30#Niven Cho -begin
    //#NT#Added., for MSDCExt with NVT
    #if (_MSDCVENDOR_== _MSDCVENDOR_NVT_)
    CaptureObj.CallBackFunc         = MsdcNvt_HookImageCb(CaptureObj.CallBackFunc);
    #endif
    //#NT#2009/07/30#Niven Cho -end

    // Open Capture task
    if (ImgCapture_Open(&CaptureObj) == E_NOMEM)
    {
        debug_err(("Not enough memory for capture task\r\n"));
    }

#if(_WAVSTUDIO_MODE_ == ENABLE)
    //#NT#2008/04/28#Chris Hsu -begin
    //#NT#Add sample code for bits per sample and user data
    WavFormat.AudioChannel      = AUDIO_CH_RIGHT;
    WavFormat.AudioSamplingRate = AUDIO_SR_11025;
#if (_VM_FORMAT_ == _VM_FORMAT_PCM8_)
    // PCM 8 bits
    WavFormat.AudioCodec        = AUDIOCODEC_PCM;
    WavFormat.uiBitsPerSample   = WAV_BITS_PER_SAM_PCM_8;
#elif (_VM_FORMAT_ == _VM_FORMAT_PCM16_)
    // PCM 16 bits
    WavFormat.AudioCodec        = AUDIOCODEC_PCM;
    WavFormat.uiBitsPerSample   = WAV_BITS_PER_SAM_PCM_16;
#elif (_VM_FORMAT_ == _VM_FORMAT_ADPCM_)
    // ADPCM
    WavFormat.AudioCodec        = AUDIOCODEC_IMA_ADPCM;
    WavFormat.uiBitsPerSample   = WAV_BITS_PER_SAM_ADPCM;
#elif (_VM_FORMAT_ == _VM_FORMAT_ASFPCM_)
    // ASF PCM
    #if (WAVFILE_ASF_ENABLE == ENABLE)
    WavFormat.AudioCodec        = AUDIOCODEC_PCM;
    WavFormat.FileFormat        = WAVFILE_ASF;
    #endif
#endif
    WavStudio_SetFormat(&WavFormat);

    // Set maximum recording time
    WavStudio_SetMaxRecTime(10);

    // Set user data
#if (_WAV_SINGLE_USERDATA_ == ENABLE)
    WavStudio_SetUserData((UINT32)&g_uiWAVHeaderUserData, (UINT32)sizeof(g_uiWAVHeaderUserData));
#else
    WavStudio_SetUserData(0, 0);
#endif

    // Set WAV application object
    WavObj.uiMemoryAddr         = uiPoolAddr + POOL_SIZE_CAPTURE - POOL_SIZE_WAV;
    WavObj.uiMemorySize         = POOL_SIZE_WAV;
    WavObj.WavStudioCB          = (WAVSTUDIO_CB)FlowCommon_WAVStudioCB;
    //#NT#2008/04/28#Chris Hsu -end

    // Open Wav studio task
    if (WavStudio_Open(&WavObj) == E_NOMEM)
    {
        debug_err(("Not enough memory for wav studio task\r\n"));
    }
#endif

    // Get memory for Photo task
    get_blk((VP *)&uiPoolAddr, POOL_ID_IQ);
    rel_blk(POOL_ID_IQ, (VP)uiPoolAddr);

    memset(&PhotoObj,0x00,sizeof(PhotoObj));

    PhotoObj.uiMemoryAddr           = uiPoolAddr;
    PhotoObj.uiMemorySize           = POOL_SIZE_IQ;

    PhotoObj.uiDisplayFBWidth       = g_LCDSize.uiWidth;
    PhotoObj.uiDisplayFBHeight      = g_LCDSize.uiHeight;

    PhotoObj.CallBackFunc           = (FPALGCALLBACK)FlowPhoto_ImageCB;
    //#NT#2009/07/30#Niven Cho -begin
    //#NT#Added., for MSDCExt with NVT
    #if (_MSDCVENDOR_== _MSDCVENDOR_NVT_)
    PhotoObj.CallBackFunc           = MsdcNvt_HookImageCb(PhotoObj.CallBackFunc);
    #endif
    //#NT#2009/07/30#Niven Cho -end

    /*
    if (KeyScan_IsTVPlugIn() == TRUE)
    {
        PhotoObj.uiDisplayFBWidth   = g_LCDSize.uiWidth >> 1;
        PhotoObj.uiDisplayFBHeight  = g_LCDSize.uiHeight >> 1;
    }
    else
    {
        PhotoObj.uiDisplayFBWidth   = g_LCDSize.uiWidth;
        PhotoObj.uiDisplayFBHeight  = g_LCDSize.uiHeight;
    }
    */

    // Open Photo task
    if (Photo_Open(&PhotoObj) == E_NOMEM)
    {
        debug_err(("Not enough memory for photo task\r\n"));
    }

    PhotoDisplayObj.uiDisplayFBWidth    = g_LCDSize.uiWidth;
    PhotoDisplayObj.uiDisplayFBHeight   = g_LCDSize.uiHeight;
    PhotoDisplayObj.uiDisplayOutWidth   = g_LCDSize.uiWinWidth;
    PhotoDisplayObj.uiDisplayOutHeight  = g_LCDSize.uiWinHeight;

    // Open PhotoDisplay task
    if (PhotoDisplay_Open(&PhotoDisplayObj) == E_NOMEM)
    {
        debug_err(("Not enough memory for photo display task\r\n"));
    }

    // Register AE/AWB/FD/SD function pointer
    Photo_RegisterAE((FPPHOTOAE)aaa_AEprocess);
    Photo_RegisterAWB((FPPHOTOAWB)aaa_AWBprocess);
    #if (_FD_FUNCTION_ == ENABLE)
    Photo_RegisterFD((FPPHOTOFD)fd_FDprocess);
    #endif
    #if (_SD_FUNCTION_ == ENABLE)
    Photo_RegisterSD((FPPHOTOSD)sd_SmileDetectionProcess);
    #endif

    // Open Photo DIS task
    //#NT#2010/10/27#Connie Yu -begin
    //#NT#movie DIS update
    PhotoDisObj.uiDisplayFBWidth   = g_LCDSize.uiWidth;
    PhotoDisObj.uiDisplayFBHeight  = g_LCDSize.uiHeight;
    PhotoDisObj.uiDisplayOutWidth      = g_LCDSize.uiWinWidth;
    PhotoDisObj.uiDisplayOutHeight     = g_LCDSize.uiWinHeight;
    if (PhotoDis_Open(&PhotoDisObj) == E_NOMEM)
    {
        debug_err(("Not enough memory for photo DIS task\r\n"));
    }
    //#NT#2010/10/27#Connie Yu -end
    PhotoDis_registerDIS((FPPHOTODIS)dis_accumUpdateProcess);
}
Ejemplo n.º 18
0
UINT32 ECS_Adjust(void)
{
    CAL_ECS_PARAM ECSParam;
    UINT32 BufAddr;
    UINT32 ErrorCode = CAL_ERR_NULL;
    ER Error_check;
    UINT32 PrvMode = SENSOR_MODE_1280X960;
    CAL_AE_INFO AeSetting;
    UINT32 i;
    FLGPTN  uiFlag = 0;

    Error_check = get_blk((void *)&(BufAddr), POOL_ID_ECS);
    if(Error_check != E_OK)
    {
        ;
    }
    else
    {
        rel_blk(POOL_ID_ECS, (VP)BufAddr);
    }

    debug_err(("POOL_ID_ECS Addr=0x%x\r\n",BufAddr));
    //memset((void *)BufAddr, 0x10040100, POOL_SIZE_ECS);
    for(i=0;i<ECS_MAX;i++)
        *(UINT32 *)(BufAddr + i*4) = 0x10040100;

    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    Cal_ShowStringWithColor("Face Light and Press SHUTTER",20, 80, 3);

    clr_flg(FLG_ID_KEY, FLGKEY_SHUTTER2);
    wai_flg(&uiFlag, FLG_ID_KEY, FLGKEY_SHUTTER2, TWF_ORW | TWF_CLR);
    Cal_ClearOSD(_OSD_INDEX_TRANSPART);

    AAA_Adjust.ECS_Status = 0;
    Cal_SetCalData(CAL_DATANUM_STATUS_ECS, (UINT*)&AAA_Adjust.ECS_Status);

    Cal_SetMode(IPL_MODE_OFF, 0);

    // Set IPP to preview
    Cal_SetMode(IPL_MODE_PREVIEW, PrvMode);

    // Lock 3A, FD and SD
    Cal_Lock3A(1);
    Photo_WaitPhotoIdle(TRUE, (PHOTO_1ST|PHOTO_2ND|PHOTO_3RD|PHOTO_AE|PHOTO_AWB));

    // AE setting
    AeSetting.uiTarget = 150;
    AeSetting.uiLum = 0;
    AeSetting.uiAEType = AE_FIX_TIME;
    AeSetting.uiCAType = CAL_CASOURCE_SUBOUT;
    AeSetting.uiExpT = 4167;
    AeSetting.uiISO = 100;
    AeSetting.uiAdjStep = 1;
    AeSetting.uiTimeout = 300;
    AeSetting.uiResult = 0;

    Cal_WaitAeStable(&AeSetting);
    //AWBParam.uiBayAddr = Buffer;
    ECSParam.uiCalibMode = SENSOR_MODE_FULL;
    ECSParam.uiOBofs = 0x28;
    ECSParam.uiMsht = 31500;
    ECSParam.uiCmpRatio= 100; // don't over than 100(%)
    ECSParam.bSaveRaw = FALSE;
    ECSParam.uiTableAddr= BufAddr;
    ECSParam.uiExpT = (AeSetting.uiExpT * 2); //Preview binning 2x
    ECSParam.uiISO = AeSetting.uiISO;

    Cal_ECSAdjust(&ECSParam);

    AAA_Adjust.ECS_Status = _ECS_Status;
    AAA_Adjust.ECS_Addr[ECS_FOV1] = ECSParam.uiTableAddr;

    Cal_SetCalData(CAL_DATANUM_STATUS_ECS, (UINT*)&AAA_Adjust.ECS_Status);
    Cal_SetCalData(CAL_DATANUM_ECS_Addr, (UINT*)&AAA_Adjust.ECS_Addr[ECS_FOV1]);
    // Set IPP to preview
    Cal_SetMode(IPL_MODE_PREVIEW, PrvMode);

    ErrorCode = CAL_ERR_OK;

    if(ErrorCode == CAL_ERR_OK)
    {
        Cal_WriteCalData(PSTORE_SEC_SENSOR);
        Cal_WriteCalData(PSTORE_SEC_ECS);
    }
    sprintf(CalStringBuffer,"ECS ErrorCode %d",(UINT)ErrorCode);
    Cal_ShowStringWithColor(CalStringBuffer,20, 120, 4);

    sprintf(CalStringBuffer,"Press SHUTTER to return");
    Cal_ShowStringWithColor(CalStringBuffer,20, 160, 4);

    clr_flg(FLG_ID_KEY, FLGKEY_SHUTTER2);
    wai_flg(&uiFlag, FLG_ID_KEY, FLGKEY_SHUTTER2, TWF_ORW | TWF_CLR);

    return ErrorCode;
}
Ejemplo n.º 19
0
UINT32 DP_Adjust(void)
{
    UINT8 ErrorCode;
    UINT32 BufAddr;
    ER Error_check;
    FLGPTN  uiFlag = 0;

    Cal_SetCalData(CAL_DATANUM_STATUS_PrvDP_W, 0);
    Cal_SetCalData(CAL_DATANUM_STATUS_PrvDP_B, 0);
    Cal_SetCalData(CAL_DATANUM_STATUS_CapDP_W, 0);
    Cal_SetCalData(CAL_DATANUM_STATUS_CapDP_B, 0);

    //get DP address & clear status
    Error_check = get_blk((void *)&(BufAddr), POOL_ID_DEFECT_PIXEL);
    if(Error_check != E_OK)
    {
        ;
    }
    else
    {
        rel_blk(POOL_ID_DEFECT_PIXEL, (VP)BufAddr);
    }

    memset((void *)BufAddr, 0x0, POOL_SIZE_DEFECT_PIXEL);
    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    Cal_ShowStringWithColor("Face Light and Press SHUTTER",20, 80, 3);

    clr_flg(FLG_ID_KEY, FLGKEY_SHUTTER2);
    wai_flg(&uiFlag, FLG_ID_KEY, FLGKEY_SHUTTER2, TWF_ORW | TWF_CLR);

    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    Cal_ShowStringWithColor("Process...",20, 80, 3);

    AAA_Adjust.DPC_Addr[DPC_PRV] = BufAddr;
    AAA_Adjust.DPC_Addr[DPC_CAP] = BufAddr + (DP_Prv_MAX<<2);
    AAA_Adjust.DPC_Num[DPC_PRV] = 0;
    AAA_Adjust.DPC_Num[DPC_CAP] = 0;
    AAA_Adjust.DP_Status.Prv_White = AAA_Adjust.DP_Status.Prv_Black = 0;
    AAA_Adjust.DP_Status.Cap_White = AAA_Adjust.DP_Status.Cap_Black = 0;

    ErrorCode = DP_Adjust_White();
    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    sprintf(CalStringBuffer,"Prv Dark pixel %d",(UINT)AAA_Adjust.DPC_Num[DPC_PRV]);
    Cal_ShowStringWithColor(CalStringBuffer,20, 20, 4);
    sprintf(CalStringBuffer,"Cap Dark pixel %d",(UINT)AAA_Adjust.DPC_Num[DPC_CAP]);
    Cal_ShowStringWithColor(CalStringBuffer,20, 60, 4);
    TimerDelayMs(1500);

    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    Cal_ShowStringWithColor("Cover Lens and Press SHUTTER",20, 80, 3);

    clr_flg(FLG_ID_KEY, FLGKEY_SHUTTER2);
    wai_flg(&uiFlag, FLG_ID_KEY, FLGKEY_SHUTTER2, TWF_ORW | TWF_CLR);
    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    Cal_ShowStringWithColor("Process...",20, 80, 3);

    ErrorCode = DP_Adjust_Dark();
    Cal_ClearOSD(_OSD_INDEX_TRANSPART);
    sprintf(CalStringBuffer,"Prv Total pixel %d",(UINT)AAA_Adjust.DPC_Num[DPC_PRV]);
    Cal_ShowStringWithColor(CalStringBuffer,20, 80, 4);
    sprintf(CalStringBuffer,"Cap Total pixel %d",(UINT)AAA_Adjust.DPC_Num[DPC_CAP]);
    Cal_ShowStringWithColor(CalStringBuffer,20, 100, 4);

    sprintf(CalStringBuffer,"DP ErrorCode %d",ErrorCode);
    Cal_ShowStringWithColor(CalStringBuffer,20, 120, 4);

    if(ErrorCode == CAL_ERR_OK)
    {
        Cal_WriteCalData(PSTORE_SEC_SENSOR);
        Cal_WriteCalData(PSTORE_SEC_DP);
        //Cal_ReadCalData();
    }

    sprintf(CalStringBuffer,"Press SHUTTER to return");
    Cal_ShowStringWithColor(CalStringBuffer,20, 160, 4);

    clr_flg(FLG_ID_KEY, FLGKEY_SHUTTER2);
    wai_flg(&uiFlag, FLG_ID_KEY, FLGKEY_SHUTTER2, TWF_ORW | TWF_CLR);
    return ErrorCode;
}
Ejemplo n.º 20
0
//ethan_20110801_chg to read only specific section
ER Cal_ReadData(UINT32 uisection)
{
    UINT tmpDataArea,ECSDataArea;
    PPSTORE_SECTION_HANDLE  pSectionHdl;
    ER Error_check;

    CPUCleanInvalidateDCacheBlock((UINT32)&AAA_Adjust, (UINT32)&AAA_Adjust + sizeof(AAA_Adjust));
    CPUDrainWriteBuffer();

    Error_check = get_blk((void *)&(tmpDataArea), POOL_ID_DEFECT_PIXEL);
    if(Error_check != E_OK)
    {
        debug_err(("Get dpfect pixel buffer error!!\r\n"));
    }
    else
        rel_blk(POOL_ID_DEFECT_PIXEL, (VP)tmpDataArea);

    //memset((void *)tmpDataArea,0,POOL_SIZE_DEFECT_PIXEL);//ethan_20110804_avoid to reset dp coordinate

    Error_check = get_blk((void *)&(ECSDataArea), POOL_ID_ECS);
    if(Error_check != E_OK)
    {
        debug_err(("Get ECS buffer error!!\r\n"));
    }
    else
        rel_blk(POOL_ID_ECS, (VP)ECSDataArea);

    //memset((void *)ECSDataArea,0,POOL_SIZE_ECS);

    // Enable PStore
    //PStore_EnablePS();
    switch(uisection)
    {
        case PSTORE_SEC_SENSOR:
            if ((pSectionHdl = PStore_OpenSection(PS_CAL_HEAD, PS_RDWR)) != E_PS_SECHDLER)
            {
                PStore_ReadSection((UINT8 *)&AAA_Adjust, 0, sizeof(AAA_Adjust), pSectionHdl);
                PStore_CloseSection(pSectionHdl);
            }
            else
                debug_err(("Pstore open to read FAIL\r\n"));
            break;

        case PSTORE_SEC_DP:
            if ((pSectionHdl = PStore_OpenSection(PS_CAL_DATA, PS_RDWR)) != E_PS_SECHDLER)
            {
                AAA_Adjust.DPC_Addr[DPC_PRV] = tmpDataArea;

                PStore_ReadSection((UINT8 *)AAA_Adjust.DPC_Addr[DPC_PRV], sizeof(AAA_Adjust),
                                (sizeof(UW)*(DP_Prv_MAX+DP_Cap_MAX)),
                                pSectionHdl);

                PStore_CloseSection(pSectionHdl);
            }
            else
                debug_err(("Pstore open to read FAIL\r\n"));
        break;
        case PSTORE_SEC_ECS:
            if ((pSectionHdl = PStore_OpenSection(PS_CAL_DATA2, PS_RDWR)) != E_PS_SECHDLER)
            {
                AAA_Adjust.ECS_Addr[ECS_FOV1] = ECSDataArea;
                PStore_ReadSection((UINT8 *)AAA_Adjust.ECS_Addr[ECS_FOV1], sizeof(AAA_Adjust)+(sizeof(UW)*(DP_Prv_MAX+DP_Cap_MAX)),
                                (sizeof(UW)*(ECS_MAX)),
                                pSectionHdl);
                PStore_CloseSection(pSectionHdl);
            }
            else
                debug_err(("Pstore open to read FAIL\r\n"));
        break;
        default://read all section
            Cal_ReadData(PSTORE_SEC_SENSOR);
            Cal_ReadData(PSTORE_SEC_DP);
            Cal_ReadData(PSTORE_SEC_ECS);
            break;
    }
    // disable PStore
   // PStore_DisablePS();

#if (_CALIBRATION_MODE_ == ENABLE)
    Cal_PassAdjustData();
#endif
    return E_OK;
}
Ejemplo n.º 21
0
/*创建新的目录项*/
int make_file(int inode, char* name, int type)
{
	char original_name_path[30];
	int original_inode = inode_num;//记录当前的inode

	strcpy(original_name_path, name);
	if (eat_path(name) == -1) {
		if (type == File)
			printf("touch: cannot touch‘%s’: No such file or directory\n", original_name_path);
		if (type == Directory)
			printf("mkdir: cannot create directory ‘%s’: No such file or directory\n", original_name_path);
		return -1;
	}

	int new_node;
	int blk_need = 1;//本目录需要增加磁盘块则blk_need=2
	int t;
	Inode temp;

	/*读取当前目录的Inode*/
	fseek(Disk, InodeBeg + sizeof(Inode)*inode, SEEK_SET);
	fread(&temp, sizeof(Inode), 1, Disk);

	if (temp.access[1] == 0) { //当前目录不允许写
		if (type == Directory)
			printf("mkdir: cannot create directory ‘%s’: Permission denied\n", original_name_path);
		if (type == File)
			printf("touch: cannot touch ‘%s’: Permission denied\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}
	if (dir_num>MaxDirNum) {//超过了目录文件能包含的最大目录项
		if (type == Directory)
			printf("mkdir: cannot create directory '%s' : Directory full\n", original_name_path);
		if (type == File)
			printf("touch: cannot create file '%s' : Directory full\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	if (check_name(inode, name) != -1) {//防止重命名
		if (type == Directory)
			printf("mkdir: cannnot create directory '%s' : Directory exist\n", original_name_path);
		if (type == File)
			printf("touch: cannot create file '%s' : File exist\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	if (dir_num / DirPerBlk != (dir_num + 1) / DirPerBlk) {//本目录也要增加磁盘块
		blk_need = 2;
	}

	//	printf("blk_used:%d\n",super_blk.blk_used);
	if (super_blk.blk_used + blk_need>BlkNum) {
		if (type == Directory)
			printf("mkdir: cannot create directory '%s' :Block used up\n", original_name_path);
		if (type == File)
			printf("touch: cannot create file '%s' : Block used up\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	if (blk_need == 2) {//本目录需要增加磁盘块
		t = curr_inode.blk_num++;
		curr_inode.blk_identifier[t] = get_blk();
	}

	/*申请inode*/
	new_node = apply_inode();

	if (new_node == -1) {
		if (type == Directory)
			printf("mkdir: cannot create directory '%s' :Inode used up\n", original_name_path);
		if (type == File)
			printf("touch: cannot create file '%s' : Inode used up\n", original_name_path);
		close_dir(inode_num);
		inode_num = original_inode;
		open_dir(inode_num);
		return -1;
	}

	if (type == Directory) {
		/*初始化新建目录的inode*/
		init_dir_inode(new_node, inode);
	}
	else if (type == File) {
		/*初始化新建文件的inode*/
		init_file_inode(new_node);
	}

	strcpy(dir_table[dir_num].name, name);
	dir_table[dir_num++].inode_num = new_node;

	close_dir(inode_num);
	inode_num = original_inode;
	open_dir(inode_num);
	return 0;
}
Ejemplo n.º 22
0
void task1( unsigned int arg )
{
    ER ercd;
    int tests = 0;

    CYG_TEST_INFO( "Task 1 running" );

    ercd = dis_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
    ercd = sta_tsk( 2, 22222 );
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
    ercd = chg_pri( 2, 5 );
    CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
    ercd = ena_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
    ercd = dly_tsk( 10 );
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );

#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
    tests++;
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = del_mpf( -6 );
    CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" );
    ercd = del_mpf( 99 );
    CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" );
    ercd = cre_mpf( -6, &t_cmpf );
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" );
    ercd = cre_mpf( 99, &t_cmpf );
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" );
#endif // we can test bad param error returns
    // try a pre-existing object
    // [first get a valid block from it for the freeing test later]
    ercd = pget_blf( &vp, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
    ercd = cre_mpf( 3, &t_cmpf );
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpf bad ercd !E_OBJ" );
    // delete it so we can play
    ercd = del_mpf( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" );
    // check it is deleted
    ercd = rel_blf( 3, vp );            // vp did come from this pool
    CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blf bad ercd !E_NOEXS" );
    ercd = pget_blf( &vp, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );
    ercd = tget_blf( &vp, 3, 10 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blf bad ercd !E_NOEXS" );
    ercd = get_blf( &vp, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
    ercd = ref_mpf( &t_rmpf, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpf bad ercd !E_NOEXS" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // now try creating it (badly)
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
    ercd = cre_mpf( 3, NULL );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mpf bad ercd !E_PAR" );
#endif
    ercd = cre_mpf( 3, NADR );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mpf bad ercd !E_PAR" );
    t_cmpf.mpfatr = 0xfff;
    ercd = cre_mpf( 3, &t_cmpf );
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpf bad ercd !E_RSATR" );
#endif // we can test bad param error returns
    t_cmpf.mpfatr = 0;
    t_cmpf.mpfcnt = 10000;
    t_cmpf.blfsz = 100;
    ercd = cre_mpf( 3, &t_cmpf );
    CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" );
    t_cmpf.mpfcnt = 100;
    t_cmpf.blfsz = 100000;
    ercd = cre_mpf( 3, &t_cmpf );
    CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" );
    // now create it well
    t_cmpf.mpfatr = 0;
    t_cmpf.mpfcnt = 10;
    t_cmpf.blfsz = 100;
    ercd = cre_mpf( 3, &t_cmpf );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
    // and check we can use it
    ercd = pget_blf( &vp, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" );
    ercd = tget_blf( &vp, 3, 10 );
    CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" );
    ercd = get_blf( &vp, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "get_blf bad ercd" );
    ercd = rel_blf( 3, vp );            // vp did come from new pool
    CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" );
    ercd = rel_blf( 3, vp );            // vp already freed
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" );
    ercd = ref_mpf( &t_rmpf, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" );

    // In order to wait on the pools, we must first consume all they have:
    while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
    while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = get_blf( &vp, 1 );
    CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = tget_blf( &vp, 2, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" );
    // check they are deleted
    ercd = get_blf( &vp, 1 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
    ercd = pget_blf( &vp, 2 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );

    // re-create and do it again
    t_cmpf.mpfcnt = 90;
    t_cmpf.blfsz = 20;
    ercd = cre_mpf( 1, &t_cmpf );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );
    t_cmpf.mpfcnt = 5;
    t_cmpf.blfsz = 200;
    ercd = cre_mpf( 2, &t_cmpf );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" );

    // In order to wait on the pools, we must first consume all they have:
    while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" );
    while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" );
    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = get_blf( &vp, 1 );
    CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = tget_blf( &vp, 2, 10 );
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" );
    // check they are deleted
    ercd = tget_blf( &vp, 1, 1 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" );
    ercd = get_blf( &vp, 2 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" );

    CYG_TEST_PASS("create/delete fixed mempools");
#endif // CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE

#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
    tests++;
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = del_mpl( -6 );
    CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" );
    ercd = del_mpl( 99 );
    CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" );
    ercd = cre_mpl( -6, &t_cmpl );
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" );
    ercd = cre_mpl( 99, &t_cmpl );
    CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" );
#endif // we can test bad param error returns
    // try a pre-existing object
    // [first get a valid block from it for the freeing test later]
    ercd = pget_blk( &vp, 3, 100 );
    CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
    ercd = cre_mpl( 3, &t_cmpl );
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpl bad ercd !E_OBJ" );
    // delete it so we can play
    ercd = del_mpl( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" );
    // check it is deleted
    ercd = rel_blk( 3, vp );            // vp did come from this pool
    CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blk bad ercd !E_NOEXS" );
    ercd = pget_blk( &vp, 3, 100 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );
    ercd = tget_blk( &vp, 3, 100, 10 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blk bad ercd !E_NOEXS" );
    ercd = get_blk( &vp, 3, 100 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
    ercd = ref_mpl( &t_rmpl, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpl bad ercd !E_NOEXS" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // now try creating it (badly)
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
    ercd = cre_mpl( 3, NULL );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mpl bad ercd !E_PAR" );
#endif
    ercd = cre_mpl( 3, NADR );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mpl bad ercd !E_PAR" );
    t_cmpl.mplatr = 0xfff;
    ercd = cre_mpl( 3, &t_cmpl );
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpl bad ercd !E_RSATR" );
#endif // we can test bad param error returns
    t_cmpl.mplatr = 0;
    t_cmpl.mplsz = 100000000;
    ercd = cre_mpl( 3, &t_cmpl );
    CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpl bad ercd" );
    // now create it well
    t_cmpl.mplatr = 0;
    t_cmpl.mplsz = 1000;
    ercd = cre_mpl( 3, &t_cmpl );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
    // and check we can use it
    ercd = pget_blk( &vp, 3, 100 );
    CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" );
    ercd = pget_blk( &vp, 3, 100000000 ); // way too large
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
    ercd = tget_blk( &vp, 3, 100, 10 );
    CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" );
    ercd = get_blk( &vp, 3, 100 );
    CYG_TEST_CHECK( E_OK == ercd, "get_blk bad ercd" );
    ercd = rel_blk( 3, vp );            // vp did come from new pool
    CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" );
    ercd = rel_blk( 3, vp );            // vp already freed
    CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" );
    ercd = ref_mpl( &t_rmpl, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" );

    // In order to wait on the pools, we must first consume all they have:
    while ( E_OK == (ercd = pget_blk( &vp, 1, 100 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
    while ( E_OK == (ercd = tget_blk( &vp, 2, 100, 1 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = get_blk( &vp, 1, 200 );
    CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = tget_blk( &vp, 2, 100, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" );
    // check they are deleted
    ercd = get_blk( &vp, 1, 200 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
    ercd = pget_blk( &vp, 2, 20 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );

    // re-create and do it again
    ercd = cre_mpl( 1, &t_cmpl );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );
    ercd = cre_mpl( 2, &t_cmpl );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" );

    // In order to wait on the pools, we must first consume all they have:
    while ( E_OK == (ercd = pget_blk( &vp, 1, 20 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" );
    while ( E_OK == (ercd = tget_blk( &vp, 2, 400, 1 )) ) /* nothing */;
    CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" );
    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = get_blk( &vp, 1, 200 );
    CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = tget_blk( &vp, 2, 500, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" );
    // check they are deleted
    ercd = tget_blk( &vp, 1, 200, 1 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" );
    ercd = get_blk( &vp, 2, 20 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" );

    CYG_TEST_PASS("create/delete variable mempools");
#endif // CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE

    ercd = ter_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
    ercd = dly_tsk( 5 );
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );

    // all done
    if ( 0 == tests ) {
        CYG_TEST_NA( "No objects have create/delete enabled" );
    }
    else {
        CYG_TEST_EXIT( "All done" );
    }
    ext_tsk();
}
Ejemplo n.º 23
0
/**
  Initialize application for USB PCC mode

  Initialize application for USB PCC mode.

  @param void
  @return void
*/
void AppInit_ModeUSBPCC(void)
{
    USB_PCC_INFO    PCCInfo = {0};
    UINT32          uiPoolAddr;
    PHOTO_APPOBJ    PhotoObj = {0};

    //memset((void*)&PCCInfo, 0, sizeof(USB_PCC_INFO));

    // Get memory for Photo task
    get_blk((VP *)&uiPoolAddr, POOL_ID_FB);
    rel_blk(POOL_ID_FB, (VP)uiPoolAddr);

    PhotoObj.uiMemoryAddr       = uiPoolAddr;
#if (_PCC_720P_FUNC_ == ENABLE)
    //                            SIE*2          IME(YUV422)*3    CA
    PhotoObj.uiMemorySize       = (1280*960*2) + (1280*960*2*3) + 1280*960/4;
    PhotoObj.uiDisplayFBWidth   = 1280;
    PhotoObj.uiDisplayFBHeight  = 960;
#else
    PhotoObj.uiMemorySize       = POOL_SIZE_FB;
    PhotoObj.uiDisplayFBWidth   = 640;
    PhotoObj.uiDisplayFBHeight  = 480;
#endif
    PhotoObj.CallBackFunc       = (FPALGCALLBACK)FlowPhoto_ImageCB;

    // Register AE & AWB function pointer
    Photo_RegisterAE((FPPHOTOAE)AE_Process);
    Photo_RegisterAWB((FPPHOTOAWB)AWB_Process);

    // Register (disable) FD/SD function pointer
    Photo_RegisterFD(NULL);
    Photo_RegisterSD(NULL);

    // Open Photo task for AE & AWB
    if (Photo_Open(&PhotoObj) == E_NOMEM)
    {
        debug_err(("Not enough memory for photo task\r\n"));
    }

    //#NT#20100126#ethanlau -begin
    //add for Image pipeline from pcc 2 capture
    {
        CAPTURE_APPOBJ      CaptureObj;
        // Get memory for Capture task
        get_blk((VP *)&uiPoolAddr, POOL_ID_CAPTURE);
        rel_blk(POOL_ID_CAPTURE, (VP)uiPoolAddr);

        CaptureObj.uiMemoryAddr         = uiPoolAddr;
        CaptureObj.uiMemorySize         = POOL_SIZE_CAPTURE - POOL_SIZE_WAV+POOL_SIZE_FB;
        CaptureObj.CallBackFunc         = (FPALGCALLBACK)FlowPhoto_ImageCB;

        // Open Capture task
        if (ImgCapture_Open(&CaptureObj) == E_NOMEM)
        {
            debug_err(("Not enough memory for capture task\r\n"));
        }
    }

    //#NT#20100126#ethanlau -end
    //#NT#20100126#ethanlau -begin
    //remove this , agc is not setted by imgslicetsk anymore
    /*
    // Open ImgSliceTsk for set AGC, Modify by Iyen 20070702
    ImgSliceOpen();
    */
    //#NT#20100126#ethanlau -end

    // Reserved capture buffer for image capturing and PCC use SICD buffer
    // Get memory for PCC task
#if (_PCC_720P_FUNC_ == ENABLE)
    PCCInfo.UsbPccMemAdr    = END_MEM - POOL_SIZE_PCC_HD;
    PCCInfo.UsbPccMemSize   = POOL_SIZE_PCC_HD;
    PCCInfo.PccMaxSize      = PCC_MAX_SIZE_HD;
#else
    PCCInfo.UsbPccMemAdr    = END_MEM - POOL_SIZE_PCC_VGA;
    PCCInfo.UsbPccMemSize   = POOL_SIZE_PCC_VGA;
    PCCInfo.PccMaxSize      = PCC_MAX_SIZE_VGA;
#endif
    PCCInfo.BurnIn          = NULL;
    PCCInfo.FlashRead       = NULL;
    PCCInfo.IsFinish        = NULL;
    //#NT#2009/07/13#Chris Chung -begin
    //#NT#add to control PCC vendor function
    PCCInfo.bEnableVendorFunc = g_bAppInitUSBPCCVendorFunc;
    //#NT#2009/07/13#Chris Chung -end
    //PCCInfo.VendorProcess   = NULL;
    PCCInfo.VendorProcess   = UsbCustomVerdorCmdCB;

    USBMakerInit_UPCC(&PCCInfo);

    if(UPccRegisterVendorCmd(0x80, 0xFF) != E_OK)
    {
        debug_err(("Register vendor command failed ! \r\n"));
    }

    if (UPccOpen(&PCCInfo) != E_OK)
    {
        debug_err(("Error open USB PCC task\r\n"));
    }
}
Ejemplo n.º 24
0
void UI_BeginDisplay(UINT8 iDD, BOOL bClear)
{
    RESULT r;
    LAYER_INIT LayerInit;
    UINT32 w = OSD_W;//g_LCDSize.uiWinWidth;
    UINT32 h = OSD_H;//g_LCDSize.uiWinHeight;
    UINT32 uiBufBlk;
    UINT32 uiBufAddr;

    switch(iDD)
    {
    case DD_OSD:

    uiBufBlk = POOL_ID_OSD1;
    get_blk((void *)&uiBufAddr, uiBufBlk);
    rel_blk((ID)uiBufBlk, (VP)uiBufAddr);

    LayerInit.uiType = TYPE_FB;
#if (_OSD_COLOR_ == _OSD_COLOR_INDEX8_)
    LayerInit.uiPxlfmt = PXLFMT_INDEX8;
#else
    LayerInit.uiPxlfmt = PXLFMT_INDEX4;
#endif
    if (FWRotate_GetStatus()==TRUE)
    {
        LayerInit.uiWidth = h;//w;
        LayerInit.uiHeight = w;//h;
    } else {
        LayerInit.uiWidth = w;
        LayerInit.uiHeight = h;
    }
    if (FWRotate_GetStatus()==TRUE)
    {
        LayerInit.uiBufCount = 0;
        LayerInit.uiSwapEffect = SWAPEFFECT_DISCARD;
    } else {
#ifdef OSD_USE_DOUBLE_BUFFER
    LayerInit.uiBufCount = 1;
    LayerInit.uiSwapEffect = SWAPEFFECT_COPY;
#else
    LayerInit.uiBufCount = 0;
    LayerInit.uiSwapEffect = SWAPEFFECT_DISCARD;
#endif
    }
    switch(LayerInit.uiPxlfmt)
    {
    case PXLFMT_INDEX1: LayerInit.uiBufSize = (w*h)>>3;break;
    case PXLFMT_INDEX2: LayerInit.uiBufSize = (w*h)>>2;break;
    case PXLFMT_INDEX4: LayerInit.uiBufSize = (w*h)>>1;break;
    case PXLFMT_INDEX8: LayerInit.uiBufSize = (w*h)>>0;break;
    }
    LayerInit.pBufAddr[0] = uiBufAddr;
    if (FWRotate_GetStatus()==TRUE)
    {
        LayerInit.pBufAddr[1] = 0;
    } else {
#ifdef OSD_USE_DOUBLE_BUFFER
    LayerInit.pBufAddr[1] = uiBufAddr + LayerInit.uiBufSize;
#else
    LayerInit.pBufAddr[1] = 0;
#endif
    }

    if (FWRotate_GetStatus()==TRUE)
        LayerInit.pBufAddr[2] = uiBufAddr + (LayerInit.uiBufSize);
    else
        LayerInit.pBufAddr[2] = 0;
    LayerInit.win.x= 0;
    LayerInit.win.y = 0;
    if (FWRotate_GetStatus()==TRUE)
    {
        LayerInit.win.w = g_LCDSize.uiWinHeight;//g_LCDSize.uiWinWidth;
        LayerInit.win.h = g_LCDSize.uiWinWidth;//g_LCDSize.uiWinHeight;
    } else {
        LayerInit.win.w = g_LCDSize.uiWinWidth;
        LayerInit.win.h = g_LCDSize.uiWinHeight;
    }
    LayerInit.uiWinAttr = 0;

    //GxDisplay_InitScale(g_LCDSize.uiWinWidth, g_LCDSize.uiWinHeight);

    r = GxDisplay_InitLayer(LAYER_OSD1, &LayerInit, bClear);

    GxDisplay_WaitVD();

    memset(&LocalDC, 0, sizeof(DC));
    GxGfx_AttachDC(&LocalDC, TYPE_FB, PXLFMT_INDEX8, w, h, w, (UINT8*)(LayerInit.pBufAddr[2]), 0, 0);

    //initial DC palette
#if (_OSD_COLOR_ == _OSD_COLOR_INDEX8_)
    //GxDisplay_SetPalette(LAYER_OSD1,0,256,gDemo_Palette_Palette);
    GxDisplay_SetPalette(LAYER_OSD1,0,256,gDemoKit_Palette_Palette);
#else
    //GxDisplay_SetPalette(LAYER_OSD1,0,16,gDemo_Palette_Palette);
    GxDisplay_SetPalette(LAYER_OSD1,0,16,gDemoKit_Palette_Palette);
#endif
    GxDisplay_Set(LAYER_OSD1, LAYER_STATE_ENABLE, 1);
    GxDisplay_Flush(LAYER_OSD1);
    break;

    case DD_VDO:

    uiBufBlk = POOL_ID_FB;
    get_blk((void *)&uiBufAddr, uiBufBlk);
    rel_blk((ID)uiBufBlk, (VP)uiBufAddr);

    LayerInit.uiType = TYPE_FB;
    LayerInit.uiPxlfmt = PXLFMT_YUV422;
    LayerInit.uiWidth = w;
    LayerInit.uiHeight = h;
#ifdef VDO_USE_DOUBLE_BUFFER
    LayerInit.uiBufCount = 1;
    LayerInit.uiSwapEffect = SWAPEFFECT_COPY;
#else
    LayerInit.uiBufCount = 0;
    LayerInit.uiSwapEffect = SWAPEFFECT_DISCARD;
#endif
    switch(LayerInit.uiPxlfmt)
    {
    case PXLFMT_YUV422: LayerInit.uiBufSize = (w*h)*2;break;
    }
    LayerInit.pBufAddr[0] = uiBufAddr;
#ifdef VDO_USE_DOUBLE_BUFFER
    LayerInit.pBufAddr[1] = uiBufAddr + LayerInit.uiBufSize;
#else
    LayerInit.pBufAddr[1] = 0;
#endif
    LayerInit.pBufAddr[2] = 0;
    LayerInit.win.x= 0;
    LayerInit.win.y = 0;
    LayerInit.win.w = w;
    LayerInit.win.h = h;

    r = GxDisplay_InitLayer(LAYER_VDO1, &LayerInit, FALSE);

    GxDisplay_WaitVD();
    GxDisplay_Set(LAYER_VDO1, LAYER_STATE_ENABLE, 1);
    GxDisplay_Flush(LAYER_VDO1);

#if 0
    //initial DC temp buffer for JPEG decode
    uiBufBlk = POOL_ID_CAPTURE;
    get_blk((void *)&uiBufAddr, uiBufBlk);
    rel_blk((ID)uiBufBlk, (VP)uiBufAddr);
    GxGfx_AssignTempPool((UINT8*)uiBufAddr, POOL_SIZE_CAPTURE);
#endif
    break;

    }

    //set default Pen ,text, image Strok,Pen Color
    GxGfx_SetAllDefault();
    GxGfx_SetTextColor(CLRID_IDX_BLACK, CLRID_IDX_WHITE, TEXTFORECOLOR3_DEFAULT);
    GxGfx_SetImageStroke(ROP_KEY,IMAGEPARAM_DEFAULT);
    GxGfx_SetImageColor(CLRID_IDX_TRANSPART,IMAGEPARAM_DEFAULT);

    //initial general BR state
    GxGfx_SetImageTable((const IMAGE_TABLE*)&gDemoKit_Image);

    GxGfx_SetTextStroke((const FONT*)&gDemoKit_Font, FONTSTYLE_NORMAL, SCALE_1X);
    UIFontTable[FONT_TABLE_0] = (FONT*)(&gDemoKit_Font);
    UIFontTable[FONT_TABLE_1]= NULL;   //mp3 font size is very large, only assigned whenever entering mp3 mode
    Ux_SetFontTable(UIFontTable);

    colorTable[0]=IMAGEMAPPING_DEFAULT;
    colorTable[1]=ColorMap1;
    colorTable[2]=ColorMap2;
    colorTable[3]=ColorMap3;
    colorTable[4]=ColorMap4;
    Ux_SetColorMapTable(colorTable);

    GxGfx_SetStringTable((const STRING_TABLE*)Get_LanguageValue(SysGetFlag(FL_LANGUAGE)));
}