Ejemplo n.º 1
0
//========================================================
//Function Name:msgQDelete
//Syntax:		void msgQDelete (MSG_Q_ID msgQId)
//Purpose:		delete a message queue
//Note:
//Parameters:   MSG_Q_ID msgQId		/* message queue to delete */
//Return:
//=======================================================
void msgQDelete (MSG_Q_ID msgQId)
{
	INT8U err;

	MSG_Q_LOCK();

	OSQDel(msgQId->pEvent, OS_DEL_ALWAYS, &err);
	gp_free((void *)msgQId);

	MSG_Q_UNLOCK();
}
Ejemplo n.º 2
0
static void shareinput_clean_lk_ctxt(ShareInput_Lk_Context *lk_ctxt)
{
	elog(DEBUG1, "shareinput_clean_lk_ctxt cleanup lk ctxt %p", lk_ctxt);

	if (!lk_ctxt)
		return;

	if (lk_ctxt->readyfd >= 0)
	{
		if (gp_retry_close(lk_ctxt->readyfd))
			ereport(WARNING,
				(errcode(ERRCODE_IO_ERROR),
				errmsg("shareinput_clean_lk_ctxt cannot close readyfd: %m")));
	}

	if (lk_ctxt->donefd >= 0)
	{
		if (gp_retry_close(lk_ctxt->donefd))
			ereport(WARNING,
				(errcode(ERRCODE_IO_ERROR),
				errmsg("shareinput_clean_lk_ctxt cannot close donefd: %m")));
	}

	if (lk_ctxt->del_ready && lk_ctxt->lkname_ready[0])
	{
		if (unlink(lk_ctxt->lkname_ready))
			ereport(WARNING,
				(errcode(ERRCODE_IO_ERROR),
				errmsg("shareinput_clean_lk_ctxt cannot unlink \"%s\": %m",
					lk_ctxt->lkname_ready)));
	}

	if (lk_ctxt->del_done && lk_ctxt->lkname_done[0])
	{
		if (unlink(lk_ctxt->lkname_done))
			ereport(WARNING,
				(errcode(ERRCODE_IO_ERROR),
				errmsg("shareinput_clean_lk_ctxt cannot unlink \"%s\": %m",
					lk_ctxt->lkname_done)));
	}

	gp_free(lk_ctxt);
}
Ejemplo n.º 3
0
//========================================================
//Function Name:msgQCreate
//Syntax:		MSG_Q_ID msgQCreate(INT32U maxQSize, INT32U maxMsgs, INT32U maxMsgLength)
//Purpose:		create and initialize a message queue
//Note:
//Parameters:   INT32U maxQSize			/* max queue can be creat */
//				INT32U	maxMsgs			/* max messages that can be queued */
//				INT32U	maxMsgLength	/* max bytes in a message */
//Return:		NULL if faile
//=======================================================
MSG_Q_ID msgQCreate(INT32U maxQSize, INT32U maxMsgs, INT32U maxMsgLength)
{
	MSG_Q_ID	msgQId;
	OS_EVENT*	pEvent;
	void*		pMsgQ;
	INT32U		msg_length = (maxMsgLength + 4 - 1) & (~(4 - 1));
	INT32U		size = sizeof(*msgQId) + 						/* MSG_Q_ID struct size */
					maxQSize * sizeof(void*) + 					/* OS Q size */
					maxMsgs * (msg_length + 4);				/* type + message size */



	msgQId = (MSG_Q_ID)gp_malloc(size);
	if(msgQId == NULL)
	{
	#if MSG_Q_DEBUG == 1
		DBG_PRINT("msg create err:memory allocate fail\r\n");
	#endif
		return NULL;
	}

	gp_memset((INT8S *)msgQId, 0, size);	/* clear out msg q structure */

	pMsgQ = (void*)(msgQId + 1);
	pEvent = OSQCreate(pMsgQ, maxQSize);
	if(pEvent == NULL)						/* creat q faile */
	{
		gp_free(msgQId);
	#if MSG_Q_DEBUG == 1
		DBG_PRINT("msg create err:queue create fail\r\n");
	#endif
		return NULL;
	}

	msgQId->pEvent = pEvent;
	msgQId->pMsgQ = pMsgQ;
	msgQId->maxMsgs = maxMsgs;
	msgQId->maxMsgLength = msg_length;
	msgQId->pMsgPool = (INT8U*)((INT32U*)pMsgQ + maxQSize);

	return ((MSG_Q_ID) msgQId);
}
Ejemplo n.º 4
0
void ap_startup_init(void)
{
	IMAGE_DECODE_STRUCT img_info;
	INT32U	size;
	INT16U	logo_fd;

#if C_LOGO == CUSTOM_ON
	ap_music_effect_resource_init();		//wwj add
	audio_vol_set(ap_state_config_volume_get());	//wwj add

	size = ((INT32U) gvarg.DisplayBufferWidth) * ((INT32U) gvarg.DisplayBufferHeight) * 2UL;
	startup_logo_decode_buff = (INT32U) gp_malloc_align(size, 64);
	if (!startup_logo_decode_buff) {
		DBG_PRINT("State startup allocate jpeg output buffer fail.\r\n");
		return;
	}

	logo_fd = nv_open((INT8U *) "POWER_ON_LOGO.JPG");
	if (logo_fd != 0xFFFF) {
		size = nv_rs_size_get(logo_fd);
		startup_logo_img_ptr = (INT32S) gp_malloc(size);
		if (!startup_logo_img_ptr) {
			DBG_PRINT("State startup allocate jpeg input buffer fail.[%d]\r\n", size);
			gp_free((void *) startup_logo_decode_buff);
			return;
		}
		if (nv_read(logo_fd, (INT32U) startup_logo_img_ptr, size)) {
			DBG_PRINT("Failed to read resource_header in ap_startup_init\r\n");
			gp_free((void *) startup_logo_img_ptr);
			gp_free((void *) startup_logo_decode_buff);
			return;
		}
		img_info.image_source		= (INT32S) startup_logo_img_ptr;
		img_info.source_size		= size;
		img_info.source_type		= TK_IMAGE_SOURCE_TYPE_BUFFER;
		img_info.output_format		= C_SCALER_CTRL_OUT_RGB565;
		img_info.output_ratio		= 0;
		img_info.out_of_boundary_color	= 0x008080;
		img_info.output_buffer_width	= gvarg.DisplayBufferWidth;
		img_info.output_buffer_height	= gvarg.DisplayBufferHeight;
		img_info.output_image_width	= gvarg.DisplayBufferWidth;
		img_info.output_image_height	= gvarg.DisplayBufferHeight;
		img_info.output_buffer_pointer	= startup_logo_decode_buff;
		if (jpeg_buffer_decode_and_scale(&img_info) == STATUS_FAIL) {
			gp_free((void *) startup_logo_img_ptr);
			gp_free((void *) startup_logo_decode_buff);
			DBG_PRINT("State startup decode jpeg file fail.\r\n");
			return;
		}
		OSQPost(DisplayTaskQ, (void *) (startup_logo_decode_buff|MSG_DISPLAY_TASK_JPEG_DRAW));
    #if MINI_DVR_BOARD_VERSION == GPL32680_MINI_DVR_CAR_RECORD_V2
		OSTimeDly(5);
		tft_backlight_en_set(TRUE);		
    #endif
		if (audio_effect_play(EFFECT_BEEP)) {
			audio_done++;
		}
		OSTimeDly(20);
		if (audio_effect_play(EFFECT_POWER_ON)) {
			audio_done++;
		}
		gp_free((void *) startup_logo_img_ptr);
		OSTimeDly(100);
	} else {
    #if MINI_DVR_BOARD_VERSION == GPL32680_MINI_DVR_CAR_RECORD_V2
		tft_backlight_en_set(TRUE);
    #endif
	}
	gp_free((void *) startup_logo_decode_buff);
#endif
	if (vid_dec_entry() < 0) {
		DBG_PRINT("Failed to init motion jpeg task\r\n");
	}
}
Ejemplo n.º 5
0
void state_handling_init(void)
{
	INT32S config_load_flag;

	StateHandlingQ = OSQCreate(state_handling_q_stack, STATE_HANDLING_QUEUE_MAX);
	ApQ = msgQCreate(AP_QUEUE_MAX, AP_QUEUE_MAX, AP_QUEUE_MSG_MAX_LEN);
	
	nvmemory_init();
	config_load_flag = ap_state_config_load();
	ap_state_resource_init();
	ap_state_config_initial(config_load_flag);
#if ENABLE_CHECK_RTC == 1
	if (config_load_flag != STATUS_FAIL)
	{
		ap_state_config_data_time_check();
	}
#endif
	ap_state_handling_calendar_init();

	ap_state_handling_storage_id_set(NO_STORAGE);
	
	{
		DISPLAY_ICONSHOW icon = {216, 144, TRANSPARENT_COLOR, 0, 0};
		INT32U i, *buff_ptr, color_data, cnt;
		INT32U display_frame0;

		display_battery_low_frame0 = (INT32U) gp_malloc_align(icon.icon_w * icon.icon_h * 2, 64);
		DBG_PRINT("batteryLow_display_buf_addr = 0x%x \r\n",display_frame0);
		buff_ptr = (INT32U *) display_battery_low_frame0;
		color_data = 0x8C71ul|(0x8C71ul<<16);
		cnt = (icon.icon_w * icon.icon_h * 2) >> 2;
		for (i=0 ; i<cnt ; i++) {
			*buff_ptr++ = color_data;
		}
		DBG_PRINT("batteryLowshow! \r\n");

		{
			INT32U size, read_buf;
			INT16U logo_fd;
			INT8U *zip_buf;
			INT32U icon_buffer;

			logo_fd = nv_open((INT8U*)"INSERTSDC.GPZP");
			if (logo_fd != 0xFFFF) {
				size = nv_rs_size_get(logo_fd);
				read_buf = (INT32S) gp_malloc(size);
				if (!read_buf) {
					DBG_PRINT("allocate BACKGROUND.GPZP read buffer fail.[%d]\r\n", size);
				}

				if (nv_read(logo_fd, (INT32U) read_buf, size)) {
					DBG_PRINT("Failed to read icon_buffer resource\r\n");
					gp_free((void *) read_buf);
				}

				zip_buf = (INT8U *)read_buf;
				if (gpzp_decode((INT8U *) &zip_buf[4], (INT8U *) display_battery_low_frame0) == STATUS_FAIL) {
					DBG_PRINT("Failed to unzip GPZP file\r\n");
					gp_free((void *) read_buf);
					gp_free((void *) icon_buffer);
					read_buf = 0;
					icon_buffer = 0;
				}

				gp_free((void *) read_buf);
			}
		}
	}
	
	DBG_PRINT("state_handling_init OK!\r\n"); 
}
Ejemplo n.º 6
0
void user_memory_free(void* buffer_addr)
{
	gp_free(buffer_addr);	
}
Ejemplo n.º 7
0
void FileSrv_AVIAudio_Read(STAVIAUDIOBufConfig *para)
{
	INT32S read_cnt;
	INT32S temp_len;
	STAVIAUDIOBufConfig *newptr;
	INT8U *ptr = NULL;

	newptr = avi_audio_buf_wi->next;
	if(avi_audio_buf_wi->status!=AUDIO_BUF_OVER)
	{
		switch(newptr->status)
		{
			case AUDIO_BUF_FIRST_FILL:
				avi_audio_flag = 1;
				if(avi_mov_switchflag == C_MOV_MODE_PLAY)
					audiolen = tk_mov_find_adpos(1);		
				else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
				audiolen = tk_avi_get_audio_data(1);		
			case AUDIO_BUF_FILL_ALL_AGAIN:
				avi_audio_flag = 0;
				while(1)
				{
					if(avi_audio_flag)
					{
						if(avi_mov_switchflag == C_MOV_MODE_PLAY)
							audiolen = tk_mov_find_adpos(1);		
						else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
						audiolen = tk_avi_get_audio_data(1);		
						avi_audio_flag = 0;
					}
					
					//added for the avi file size is small.
					if(audiolen < 0)
					{
						avi_audio_buf_wi->status = AUDIO_BUF_OVER;
						avi_audio_flag = 1;	
						break;			
					}
					if(audiolen <= avi_audio_buf_wi->length)
					{
						if(avi_audio_buf_wi->length>=(avi_audio_buf_wi->wi + (INT32U)audiolen))
						{
							if(avi_mov_switchflag == C_MOV_MODE_PLAY)
								read_cnt = tk_mov_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
							else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
							read_cnt = tk_avi_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
							avi_audio_buf_wi->wi += (INT32U)audiolen;
							avi_audio_flag = 1;
						}
						else
						{
							avi_audio_buf_wi->status = AUDIO_BUF_FILLING;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi = avi_audio_buf_wi->next;
							if(avi_audio_buf_wi->status != AUDIO_BUF_FIRST_FILL)
								break;
						}
					}
					//sunxw modify code for avi audio length
					else if(audiolen > avi_audio_buf_wi->length*2)
					{
						avi_audio_buf_wi->status = AUDIO_BUF_OVER;
						avi_audio_buf_wi->wi = 0;
						break;
					}
					else
					{
						if(ptr == NULL)
							ptr = (INT8U*)gp_malloc(audiolen);
							
						if(avi_mov_switchflag == C_MOV_MODE_PLAY)
							read_cnt = tk_mov_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
						else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
							read_cnt = tk_avi_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
						if(read_cnt != -1)
						{
							gp_memcpy((INT8S*)avi_audio_buf_wi->audiobufptr,(INT8S*)ptr,avi_audio_buf_wi->length);
							avi_audio_buf_wi->wi = avi_audio_buf_wi->length;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi->status = AUDIO_BUF_FILLING;
							avi_audio_buf_wi = avi_audio_buf_wi->next;
							
							avi_audio_buf_wi->wi = (INT32U)audiolen - avi_audio_buf_wi->length;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi->status = AUDIO_BUF_GETING;
							gp_memcpy((INT8S*)avi_audio_buf_wi->audiobufptr,(INT8S*)((INT32U)ptr+avi_audio_buf_wi->length),avi_audio_buf_wi->wi);
							avi_audio_flag = 1;
							
							avi_audio_buf_wi = avi_audio_buf_wi->next;							
							if(avi_audio_buf_wi->status != AUDIO_BUF_FIRST_FILL)
							{
								gp_free((void*)ptr);
								ptr = NULL;
								break;												
							}	
						}
					}			
				}
				if(audio_fs_result_q)
					OSQPost(audio_fs_result_q , (void *) read_cnt);					
				break;

			case AUDIO_BUF_GETING:
				// if audio len < 1000,or audio len > 1000;		
				temp_len = 0;
				while(1)
				{
					if(avi_audio_flag)
					{
						if(avi_mov_switchflag == C_MOV_MODE_PLAY)
							audiolen = tk_mov_find_adpos(1);		
						else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
						audiolen = tk_avi_get_audio_data(1);		
						if(audiolen == -1)
						{
							avi_audio_buf_wi->status = AUDIO_BUF_OVER;
							avi_audio_flag = 1;
							avi_audio_buf_wi->ri = 0;
							break;
						}
						else
							avi_audio_flag = 0;
					}
					
					if(audiolen <= avi_audio_buf_wi->length)
					{	
						if(avi_audio_buf_wi->length>=(avi_audio_buf_wi->wi + (INT32U)audiolen))
						{
							if(avi_mov_switchflag == C_MOV_MODE_PLAY)
								read_cnt = tk_mov_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
							else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
							read_cnt = tk_avi_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
							if(read_cnt != -1)
							{
								avi_audio_buf_wi->wi += (INT32U)audiolen;
								avi_audio_flag = 1;
								temp_len += audiolen;
							}
							else
							{
								avi_audio_buf_wi->status = AUDIO_BUF_OVER;
								avi_audio_flag = 1;
								avi_audio_buf_wi->ri = 0;
								break;
							}
						}
						else
						{
							avi_audio_buf_wi->status = AUDIO_BUF_FILLING;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi = avi_audio_buf_wi->next;
							break;
						}

						if(temp_len>AUDIO_AVI_RINGBUF_LEN)
							break;	
					}	
					else
						break;					
				}
					
				break;
				
			
			case AUDIO_BUF_EMPTY:
				//data len smaller than ring buffer len.		
				// if audio len < 1000,or audio len > 1000;		
				temp_len = 0;
				while(1)
				{
					if(avi_audio_flag)
					{
						if(avi_mov_switchflag == C_MOV_MODE_PLAY)
							audiolen = tk_mov_find_adpos(1);		
						else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
						audiolen = tk_avi_get_audio_data(1);		
						if(audiolen == -1)
						{
							avi_audio_buf_wi->status = AUDIO_BUF_OVER;
							avi_audio_flag = 1;
							avi_audio_buf_wi->ri = 0;
							break;
						}
						else
							avi_audio_flag = 0;
					}
						
					if(audiolen <= avi_audio_buf_wi->length)	
					{	
						if(avi_audio_buf_wi->length>=(avi_audio_buf_wi->wi + (INT32U)audiolen))
						{
							if(avi_mov_switchflag == C_MOV_MODE_PLAY)
								read_cnt = tk_mov_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
							else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
							read_cnt = tk_avi_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
							if(read_cnt != -1)
							{
								avi_audio_buf_wi->wi += (INT32U)audiolen;
								avi_audio_flag = 1;
								temp_len += audiolen;
							}
							else
							{
								avi_audio_buf_wi->status = AUDIO_BUF_OVER;
								avi_audio_flag = 1;
								avi_audio_buf_wi->ri = 0;
								break;
							}
						}
						else
						{
							avi_audio_buf_wi->status = AUDIO_BUF_FILLING;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi = avi_audio_buf_wi->next;
							break;
						}
					}
					//sunxw modify code for avi audio length
					else if(audiolen > avi_audio_buf_wi->length*2)
					{
						avi_audio_buf_wi->status = AUDIO_BUF_OVER;
						avi_audio_buf_wi->wi = 0;
						break;
					}
					else
					{
						if(ptr == NULL)
							ptr = (INT8U*)gp_malloc(audiolen);
							
						if(avi_mov_switchflag == C_MOV_MODE_PLAY)
							read_cnt = tk_mov_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
						else if(avi_mov_switchflag == C_AVI_MODE_PLAY)
							read_cnt = tk_avi_read_audio_data((CHAR *)((INT32U)avi_audio_buf_wi->audiobufptr+avi_audio_buf_wi->wi),(INT32U)audiolen);
						if(read_cnt != -1)
						{
							gp_memcpy((INT8S*)avi_audio_buf_wi->audiobufptr,(INT8S*)ptr,avi_audio_buf_wi->length);
							avi_audio_buf_wi->wi = avi_audio_buf_wi->length;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi->status = AUDIO_BUF_FILLING;
							avi_audio_buf_wi = avi_audio_buf_wi->next;
							
							avi_audio_buf_wi->wi = (INT32U)audiolen - avi_audio_buf_wi->length;
							avi_audio_buf_wi->ri = 0;
							avi_audio_buf_wi->status = AUDIO_BUF_GETING;
							gp_memcpy((INT8S*)avi_audio_buf_wi->audiobufptr,(INT8S*)((INT32U)ptr+avi_audio_buf_wi->length),avi_audio_buf_wi->wi);
							avi_audio_flag = 1;
							
							avi_audio_buf_wi = avi_audio_buf_wi->next;							
							gp_free((void*)ptr);
							ptr = NULL;
								break;												
						}	
						else
						{
							avi_audio_buf_wi->status = AUDIO_BUF_OVER;
							avi_audio_flag = 1;
							avi_audio_buf_wi->ri = 0;
							gp_free((void*)ptr);
							ptr = NULL;							
							break;						
						}			
					}
					
					if(audio_fs_result_q)
						OSQPost(audio_fs_result_q , (void *) read_cnt);
				}							
				break;
			
			case AUDIO_BUF_OVER:
				break;
			
			case AUDIO_BUF_FILLING:
				
				break;
			default:
				break;	
		}
	}
}
Ejemplo n.º 8
0
void usb_msdc_state_exit(void)
{
	if (BUF != NULL) {
		gp_free((void *) BUF);
	}
}