Example #1
0
File: test.c Project: CPFL/AutoICT
int main(int argc, char *argv[])
{
    Display *dpy;

    disp_init(argc, argv);
    disp_ctrl(dpy, OFF);
    sleep(1);
    disp_ctrl(dpy, ON);
    disp_close(dpy);

    return 0;
}
Example #2
0
int main(){
    init();
	disp_init();
    printint(0, 50, 0);
    disp_home();
	while(1)
		{
		printfloat(touch_wait(), 50, 0);
		disp_home();
		}
	
    

return 0;
}
Example #3
0
int
main ()
{
	pl2303_init ();
	led_init ();
	disp_init ();

	serial_init (9600);

	while (1)
	{
		int c;
		switch ((c = serial_getchar ()))
		{
		case '!':
			led_all_off ();
			break;
		case '&':
			switch (serial_getchar ())
			{
			case 'R': led_on  (LED_R); break;
			case 'G': led_on  (LED_G); break;
			case 'B': led_on  (LED_B); break;
			case 'r': led_off (LED_R); break;
			case 'g': led_off (LED_G); break;
			case 'b': led_off (LED_B); break;

			case 'i':
				serial_puts ("Pripravek PIC24f Starter Kit;");
				break;
			case 's':
				disp_clear ();
				disp_at (1, 1);
				while ((c = serial_getchar ()) != ';')
					disp_char (c);
				break;
			default:
				disp_clear ();
				disp_at (1, 1);
				disp_str ("unrecognized '");
				disp_char (c);
				disp_char ('\'');
			}
		}
	}

	return 0;
}
Example #4
0
int main(void)
{
    int i;
    int line_count;

    hw_init();
    uart_init();
    
    uart_puts("Exstina-50 - Display Unit Test\r\n");
    uart_crlf();
    
    disp_init();
    
    /* Show line 1 */
    disp_puts(3, "   Exstina 50   ");
    /* Wait a short time */
    for (i = 0; i < 0x10000; i++)
        ;
    /* Show line 4 */
    disp_puts(0, "Display test 0.2");
    
    line_count = 0;

    while(1)
    {
        while (but_value() == 0)
            ;
        if (but_value() & 2)
        {
            disp_puts(line_count & 0x03, "Button 0        ");
            line_count ++;
        }
        if (but_value() & 8)
        {
            disp_puts(line_count & 0x03, "Button 1        ");
            line_count ++;
        }
        while (but_value() != 0)
            ;
    }
}
Example #5
0
static int32_t __init
gp_fb_init(
	void
)
{
	int32_t ret = 0;
	struct gp_fb_info *info;

#if 0
	/* Init display device */
	if (disp_open(0, 0) < 0)
		return -EIO;

	if (disp_init() < 0)
		return -EIO;
#endif

	fbinfo = framebuffer_alloc(sizeof(struct gp_fb_info), NULL);
	if (!fbinfo)
		return -ENOMEM;

	info = fbinfo->par;
	info->first_open = 0;

	/*Get panel resolution */
	disp_get_panel_res(&info->panelRes);

	/* Color */
	ret = gp_fb_setColorType(fbinfo);
	if (ret < 0) {
		printk("[%s:%d], set color type error\n", __FUNCTION__, __LINE__);
		goto dealloc_fb;
	}

	/* Get buffer width, height, and size */
	gp_fb_getBufInfo(fbinfo);

	/* Get panel rect */
	gp_fb_getPanelRect(fbinfo);

	info->fbmem = disp_allocate_buffer(info->bufinfo);
	if (info->fbmem == NULL) {
		ret = -ENXIO;
		goto dealloc_fb;
	}

	memset(info->fbmem, 0x00, info->bufinfo.size);

	fbinfo->fbops = &gp_fb_ops;
	fbinfo->flags = FBINFO_FLAG_DEFAULT;
	fbinfo->pseudo_palette = NULL;
	fbinfo->screen_base = info->fbmem;
	fbinfo->screen_size = 0;

	/* Resolution */
	fbinfo->var.xres = info->bufinfo.width;
	fbinfo->var.yres = info->bufinfo.height;
	fbinfo->var.xres_virtual = fbinfo->var.xres;
	fbinfo->var.yres_virtual = fbinfo->var.yres * 2;

	/* Timing */
	fbinfo->var.left_margin = 0;
	fbinfo->var.right_margin = 0;
	fbinfo->var.upper_margin = 0;
	fbinfo->var.lower_margin = 0;
	fbinfo->var.hsync_len = 0;
	fbinfo->var.vsync_len = 0;

	fbinfo->var.activate = FB_ACTIVATE_FORCE;
	fbinfo->var.accel_flags = 0;
	fbinfo->var.vmode = FB_VMODE_NONINTERLACED;

	/* fixed info */
	memset(&fbinfo->fix.id, 0, sizeof(fbinfo->fix.id));
	strncpy(fbinfo->fix.id, driver_name, sizeof(driver_name));
	fbinfo->fix.mmio_start  = 0x93000000;
	fbinfo->fix.mmio_len    = 0x1000;
	fbinfo->fix.type        = FB_TYPE_PACKED_PIXELS;
	fbinfo->fix.type_aux	= 0;
	fbinfo->fix.visual      = FB_VISUAL_TRUECOLOR;
	fbinfo->fix.xpanstep	= 0;
	fbinfo->fix.ypanstep	= 1;
	fbinfo->fix.ywrapstep	= 0;
	fbinfo->fix.accel	    = FB_ACCEL_NONE;
	fbinfo->fix.smem_start  = gp_chunk_pa(info->fbmem);
	fbinfo->fix.smem_len    = info->bufinfo.size;
	fbinfo->fix.line_length = (fbinfo->var.xres_virtual * fbinfo->var.bits_per_pixel) / 8;

	gp_fb_activate(fbinfo);

	ret = register_framebuffer(fbinfo);
	if (ret < 0) {
		printk(KERN_ERR "Failed to register framebuffer device: %d\n", ret);
		goto release_fbmem;
	}
	printk(KERN_INFO "fb%d: %s frame buffer device\n",
		fbinfo->node, fbinfo->fix.id);

	return 0;

release_fbmem:
	disp_free_buffer(FB_BUFFER_ID);

dealloc_fb:
	framebuffer_release(fbinfo);

	return ret;
}
Example #6
0
/*
 * The main function.
 */
int
main(int argc, char *argv[])
{
	int ret = 1, debug_level = 0;
	FILE *log = NULL, *dump = NULL;
	char c;

	/*
	 * The numatop requires some authorities to setup perf and increase the hard limit of
	 * fd. So either the user runs as root or following condtions need to be satisfied.
	 *
	 * 1. Set "-1" in /proc/sys/kernel/perf_event_paranoid to let the non-root be able to
	 *    setup perf. e.g.
	 *    echo -1 > /proc/sys/kernel/perf_event_paranoid
	 *
	 * 2. The CAP_SYS_RESOURCE capability is required to user for increasing the hard
	 *    limit of fd.
	 */

	g_sortkey = SORT_KEY_CPU;
	g_precise = PRECISE_NORMAL;
	g_numatop_pid = getpid();
	g_run_secs = TIME_NSEC_MAX;
	optind = 1;
	opterr = 0;

	/*
	 * Parse command line arguments.
	 */
	while ((c = getopt(argc, argv, "d:l:o:f:t:hf:s:")) != EOF) {
		switch (c) {
		case 'h':
			print_usage(argv[0]);
			ret = 0;
			goto L_EXIT0;

		case 'l':
			debug_level = atoi(optarg);
			if ((debug_level < 0) || (debug_level > 2)) {
				stderr_print("Invalid log_level %d.\n",
				    debug_level);
				print_usage(argv[0]);
				goto L_EXIT0;
			}
			break;

		case 'f':
			if (optarg == NULL) {
				stderr_print("Invalid output file.\n");
				goto L_EXIT0;
			}

			if ((log = fopen(optarg, "w")) == NULL) {
				stderr_print("Cannot open '%s' for writing.\n",
				    optarg);
				goto L_EXIT0;
			}
			break;

		case 's':
			if (optarg == NULL) {
				print_usage(argv[0]);
				goto L_EXIT0;
			}

			if (strcasecmp(optarg, "high") == 0) {
				g_precise = PRECISE_HIGH;
				break;
			}

			if (strcasecmp(optarg, "low") == 0) {
				g_precise = PRECISE_LOW;
				break;
			}

			if (strcasecmp(optarg, "normal") == 0) {
				g_precise = PRECISE_NORMAL;
				break;
			}

			stderr_print("Invalid sampling_precision '%s'.\n",
			    optarg);
			print_usage(argv[0]);
			goto L_EXIT0;

		case 'd':
			if (optarg == NULL) {
				stderr_print("Invalid dump file.\n");
				goto L_EXIT0;
			}

			if ((dump = fopen(optarg, "w")) == NULL) {
				stderr_print("Cannot open '%s' for dump.\n",
				    optarg);
				goto L_EXIT0;
			}
			break;

		case 't':
			g_run_secs = atoi(optarg);
			if (g_run_secs <= 0) {
				stderr_print("Invalid run time %d.\n",
				    g_run_secs);
				print_usage(argv[0]);
				goto L_EXIT0;
			}
			break;

		case ':':
			stderr_print("Missed argument for option %c.\n",
			    optopt);
			print_usage(argv[0]);
			goto L_EXIT0;

		case '?':
			stderr_print("Unrecognized option %c.\n", optopt);
			print_usage(argv[0]);
			goto L_EXIT0;
		}
	}

	if (plat_detect() != 0) {
		stderr_print("CPU is not supported!\n");
		ret = 2;
		goto L_EXIT0;
	}

	/*
	 * It could be failed if user doesn't have authority.
	 */
	(void) ulimit_expand(PERF_FD_NUM);

	/*
	 * Get the number of online cores in system.
	 */
	if ((g_ncpus = sysfs_online_ncpus()) == -1) {
		stderr_print("Platform is not supported "
		    "(numatop supports up to %d CPUs)\n", NCPUS_MAX);
		goto L_EXIT0;
	}

	pagesize_init();
	gettimeofday(&g_tvbase, 0);

	if (debug_init(debug_level, log) != 0) {
		goto L_EXIT1;
	}

	debug_print(NULL, 2, "Detected %d online CPU.\n", g_ncpus);
	log = NULL;
	sym_init();

	if (dump_init(dump) != 0) {
		goto L_EXIT2;
	}

	dump = NULL;

	/*
	 * Calculate how many nanoseconds for a TSC cycle.
	 */
	calibrate();

	/*
	 * Initialize for the "window-switching" table.
	 */
	switch_table_init();

	if (proc_group_init() != 0) {
		goto L_EXIT3;
	}

	if (node_group_init() != 0) {
		stderr_print("The node/cpu number is out of range, \n"
			"numatop supports up to %d nodes and %d CPUs\n",
			NNODES_MAX, NCPUS_MAX);
		goto L_EXIT4;
	}

	if (disp_cons_ctl_init() != 0) {
		goto L_EXIT5;
	}

	/*
	 * Catch signals from terminal.
	 */
	if ((signal(SIGINT, sigint_handler) == SIG_ERR) ||
	    (signal(SIGHUP, sigint_handler) == SIG_ERR) ||
	    (signal(SIGQUIT, sigint_handler) == SIG_ERR) ||
	    (signal(SIGTERM, sigint_handler) == SIG_ERR) ||
	    (signal(SIGPIPE, sigint_handler) == SIG_ERR)) {
		goto L_EXIT6;
	}

	/*
	 * Initialize the perf sampling facility.
	 */
	if (perf_init() != 0) {
		debug_print(NULL, 2, "perf_init() is failed\n");
		goto L_EXIT6;
	}

	/*
	 * Initialize for display and create console thread & display thread.
	 */
	if (disp_init() != 0) {
		perf_fini();
		goto L_EXIT6;
	}

	/*
	 * Wait the disp thread to exit. The disp thread would
	 * exit when user hits the hotkey 'Q' or press "CTRL+C".
	 */
	disp_dispthr_quit_wait();

	/*
	 * Notify cons thread to exit.
	 */
	disp_consthr_quit();
	
	disp_fini();
	stderr_print("NumaTOP is exiting ...\n");
	(void) fflush(stdout);
	ret = 0;

L_EXIT6:
	disp_cons_ctl_fini();

L_EXIT5:
	node_group_fini();

L_EXIT4:
	proc_group_fini();

L_EXIT3:
	dump_fini();

L_EXIT2:
	sym_fini();
	debug_fini();

L_EXIT1:
	exit_msg_print();

L_EXIT0:
	if (dump != NULL) {
		(void) fclose(dump);
	}

	if (log != NULL) {
		(void) fclose(log);
	}

	return (ret);
}
Example #7
0
int main(int argc, char* argv[])
{
	int i;
    int key_fd = -1;
	struct input_event data;
	struct sigaction sigact;

	memset(&sigact, 0, sizeof(sigact)); 

	sigact.sa_handler = handle_int;
	
	//format=V4L2_PIX_FMT_NV12; //V4L2_PIX_FMT_NV16
	format = V4L2_PIX_FMT_NV12;
	disp_format=DISP_FORMAT_YUV420; //DISP_FORMAT_YUV422
	disp_seq=DISP_SEQ_UVUV;
	struct v4l2_format fmt;
	struct v4l2_format fmt_priv;
	
    printf("*********************\n");
    printf("TVD demo start!\n");
    printf("Press KEY_ESC for exit\n");
    printf("*********************\n");


	/*if((key_fd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK)) < 0){//key: linux=event0, android=event2
    	printf("open event fail!\n");
		return -1;
	}*/
		
	fd = open ("/dev/video1", O_RDWR /* required */ | O_NONBLOCK, 0);
	
	
	int ret = -1;

	CLEAR (fmt_priv);
	fmt_priv.type                = V4L2_BUF_TYPE_PRIVATE;
	fmt_priv.fmt.raw_data[0] =0;//interface
	fmt_priv.fmt.raw_data[1] =0;//system
	fmt_priv.fmt.raw_data[2] =0;//format 1=mb, for test only
		
	fmt_priv.fmt.raw_data[8] =2;//row
	fmt_priv.fmt.raw_data[9] =2;//column
	
	fmt_priv.fmt.raw_data[10] =1;//channel_index
	fmt_priv.fmt.raw_data[11] =2;//channel_index
	fmt_priv.fmt.raw_data[12] =3;//channel_index
	fmt_priv.fmt.raw_data[13] =4;//channel_index
	if (-1 == ioctl (fd, VIDIOC_S_FMT, &fmt_priv)) //设置自定义
	{
		printf("VIDIOC_S_FMT error!  a\n");
		ret = -1;
		return ret; 
	}
	
//	CLEAR (fmt);
//	fmt.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
//	fmt.fmt.pix.width       = 720*fmt_priv.fmt.raw_data[8];//720; 
//	fmt.fmt.pix.height      = 480*fmt_priv.fmt.raw_data[9];//576;//480;
//	fmt.fmt.pix.pixelformat = format;//V4L2_PIX_FMT_YUV422P;//V4L2_PIX_FMT_NV12;//V4L2_PIX_FMT_YUYV;
//	fmt.fmt.pix.field       = V4L2_FIELD_NONE;
//	if (-1 == ioctl (fd, VIDIOC_S_FMT, &fmt)) //设置图像格式
//	{
//		printf("VIDIOC_S_FMT error! b\n");
//		ret = -1;
//		return ret;
//	}
	
	disp_mode=fmt_priv.fmt.raw_data[2]?DISP_MOD_MB_UV_COMBINED:DISP_MOD_NON_MB_UV_COMBINED;//DISP_MOD_NON_MB_UV_COMBINED DISP_MOD_MB_UV_COMBINED
	disp_size.width = fmt_priv.fmt.raw_data[8]*(fmt_priv.fmt.raw_data[2]?704:720);//width
	disp_size.height = fmt_priv.fmt.raw_data[9]*(fmt_priv.fmt.raw_data[1]?576:480);//height
	printf("disp_size.width=%d\n", disp_size.width);
	printf("disp_size.height=%d\n", disp_size.height);
	
	usleep(100000);//delay 100ms if you want to check the status after set fmt
	
	CLEAR (fmt_priv);
	fmt_priv.type                = V4L2_BUF_TYPE_PRIVATE;
	if (-1 == ioctl (fd, VIDIOC_G_FMT, &fmt_priv)) //设置自定义
	{
		printf("VIDIOC_G_FMT error!  a\n");
		ret = -1;
		return ret; 
	}
	printf("interface=%d\n", fmt_priv.fmt.raw_data[0]);
	printf("system=%d\n", fmt_priv.fmt.raw_data[1]);
	printf("format=%d\n", fmt_priv.fmt.raw_data[2]);
	printf("row=%d\n", fmt_priv.fmt.raw_data[8]);
	printf("column=%d\n", fmt_priv.fmt.raw_data[9]);
	printf("channel_index[0]=%d\n", fmt_priv.fmt.raw_data[10]);
	printf("channel_index[1]=%d\n", fmt_priv.fmt.raw_data[11]);
	printf("channel_index[2]=%d\n", fmt_priv.fmt.raw_data[12]);
	printf("channel_index[3]=%d\n", fmt_priv.fmt.raw_data[13]);
	printf("status[0]=%d\n", fmt_priv.fmt.raw_data[16]);
	printf("status[1]=%d\n", fmt_priv.fmt.raw_data[17]);
	printf("status[2]=%d\n", fmt_priv.fmt.raw_data[18]);
	printf("status[3]=%d\n", fmt_priv.fmt.raw_data[19]);

	struct v4l2_requestbuffers req;
	CLEAR (req);
	req.count               = 5;
	req.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	req.memory              = V4L2_MEMORY_MMAP;
		
	ioctl (fd, VIDIOC_REQBUFS, &req); //申请缓冲,count是申请的数量,注意,释放缓冲实际在VIDIOC_STREAMOFF内完成了。

	buffers = calloc (req.count, sizeof (*buffers));//内存中建立对应空间

	for (n_buffers = 0; n_buffers < req.count; ++n_buffers) 
	{
	   struct v4l2_buffer buf;   //驱动中的一帧
	   CLEAR (buf);
	   buf.type        = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	   buf.memory      = V4L2_MEMORY_MMAP;
	   buf.index       = n_buffers;

	   if (-1 == ioctl (fd, VIDIOC_QUERYBUF, &buf)) //映射用户空间
			printf ("VIDIOC_QUERYBUF error\n");

	   buffers[n_buffers].length = buf.length;
	   buffers[n_buffers].start  = mmap (NULL /* start anywhere */,    //通过mmap建立映射关系
								         buf.length,
								         PROT_READ | PROT_WRITE /* required */,
								         MAP_SHARED /* recommended */,
								         fd, buf.m.offset);
	   printf("MMAP: %p OFF: %p\n", buffers[n_buffers].start, buf.m.offset);

	   if (MAP_FAILED == buffers[n_buffers].start)
			printf ("mmap failed\n");
	}
	
	for (i = 0; i < n_buffers; ++i) 
	{
		struct v4l2_buffer buf;
		
		CLEAR (buf);		
		buf.type        = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		buf.memory      = V4L2_MEMORY_MMAP;
		buf.index       = i;

		if (-1 == ioctl (fd, VIDIOC_QBUF, &buf))//申请到的缓冲进入列队
			printf ("VIDIOC_QBUF failed\n");
	}
					
#ifdef DISPLAY				
	disp_init(disp_size.width,disp_size.height);
	disp_start();
	disp_on();                  
#endif	
	
	enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	
	if (-1 == ioctl (fd, VIDIOC_STREAMON, &type)) //开始捕捉图像数据
		printf ("VIDIOC_STREAMON failed\n");

	sigaction(SIGINT, &sigact, NULL);

	while(!quit)
	{	    
		read(key_fd, &data, sizeof(data));
		if( (data.type == EV_KEY)&&
			(data.code == KEY_ESC)&&
			(data.value == 1) ){
			quit = 1;
		}


		CLEAR (fmt_priv);
		fmt_priv.type                = V4L2_BUF_TYPE_PRIVATE;
		if (-1 == ioctl (fd, VIDIOC_G_FMT, &fmt_priv)) //监视状态
		{
			printf("VIDIOC_G_FMT error!  a\n");
			ret = -1;
			return ret;
		}
		//printf("status=0x%02x\n", fmt_priv.fmt.raw_data[16]);
	
		for (;;) //这一段涉及到异步IO
		{
			fd_set fds;
			struct timeval tv;
			int r;
			
			FD_ZERO (&fds);//将指定的文件描述符集清空
			FD_SET (fd, &fds);//在文件描述符集合中增加一个新的文件描述符
			
			/* Timeout. */
			tv.tv_sec = 2;
			tv.tv_usec = 0;

			r = select (fd + 1, &fds, NULL, NULL, &tv);//判断是否可读(即摄像头是否准备好),tv是定时
			
			if (-1 == r) {
				if (EINTR == errno)
					continue;
				printf ("select err\n");
			}
			if (0 == r) {
				fprintf (stderr, "select timeout\n");
				//exit (EXIT_FAILURE);
				//goto close;
			}
								
			if (read_frame ())//如果可读,执行read_frame ()函数,并跳出循环
				break;
		} 
	}

close:	
	if (-1 == ioctl (fd, VIDIOC_STREAMOFF, &type)) //停止捕捉图像数据,注意,此动作同时会释放VIDIOC_REQBUFS申请的缓冲
		printf ("VIDIOC_STREAMOFF failed\n");
unmap:
	for (i = 0; i < n_buffers; ++i) {
		if (-1 == munmap (buffers[i].start, buffers[i].length)) {
			printf ("munmap error");
		}
	}
	
	disp_stop();
	disp_exit();	
	close (fd);
	
	printf("TVD demo bye!\n");
	return 0;						
}
Example #8
0
/*
 *  ======== api_init ========
 *  Purpose:
 *      Module initialization used by Bridge API.
 */
bool api_init(void)
{
	bool ret = true;
	bool fdrv, fdev, fcod, fchnl, fmsg, fio;
	bool fmgr, fproc, fnode, fdisp, fstrm, frmm;

	if (api_c_refs == 0) {
		/* initialize driver and other modules */
		fdrv = drv_init();
		fmgr = mgr_init();
		fproc = proc_init();
		fnode = node_init();
		fdisp = disp_init();
		fstrm = strm_init();
		frmm = rmm_init();
		fchnl = chnl_init();
		fmsg = msg_mod_init();
		fio = io_init();
		fdev = dev_init();
		fcod = cod_init();
		ret = fdrv && fdev && fchnl && fcod && fmsg && fio;
		ret = ret && fmgr && fproc && frmm;
		if (!ret) {
			if (fdrv)
				drv_exit();

			if (fmgr)
				mgr_exit();

			if (fstrm)
				strm_exit();

			if (fproc)
				proc_exit();

			if (fnode)
				node_exit();

			if (fdisp)
				disp_exit();

			if (fchnl)
				chnl_exit();

			if (fmsg)
				msg_exit();

			if (fio)
				io_exit();

			if (fdev)
				dev_exit();

			if (fcod)
				cod_exit();

			if (frmm)
				rmm_exit();

		}
	}
	if (ret)
		api_c_refs++;

	return ret;
}
Example #9
0
/* display piu isr handler */
void disp_handler(void *ctx, piu_msg_p msg)
{
	uint16_t cmd_id;

	memcpy(&disp_rx, msg, sizeof(piu_msg_t));
		
	cmd_id = DISP_U8_TO_U16(disp_rx.p);
	dbg("V %x\n", cmd_id);
	
	if ((cmd_id & 0xFF) == DISP_GET)
	{
		switch (cmd_id&0xFF00)
		{
			case DISP_IMAGE_PROPERTY:
			{
				disp_tx.len = 6;
				DISP_U8_TO_U16(disp_tx.p) = cmd_id;
				DISP_U8_TO_U16(disp_tx.p+2) = cfg.output.size.w;
				DISP_U8_TO_U16(disp_tx.p+4) = cfg.output.size.h;
dbg("DISP: rx DISP_GET_IMAGE_PROPERTY ->tx [%d,%d] \n", cfg.output.size.w, cfg.output.size.h);
				break;
			}
			case DISP_IMAGE_START:
			{
				disp_tx.len = 6;
				DISP_U8_TO_U16(disp_tx.p) = cmd_id;
				DISP_U8_TO_U16(disp_tx.p+2) = 0;	//offset[0];
				DISP_U8_TO_U16(disp_tx.p+4) = 0;	//offset[1];
dbg("DISP: rx DISP_GET_IMAGE_START -> tx [%d,%d] \n", 0,0);             //offset[0], offset[1]);
				break;
			}
			default:
			{
				printf("rx Unkwown DISP_GET\n");
				return;
			}
			piu_tx(PIU_DISP_QID, &disp_tx);
		}
	}
	else if (cmd_id == (DISP_CFG | DISP_CFG_BUF))
	{
		// DO NOT send back response because ceva can't receive it due to nested interrupt
		uint32_t *addr = (uint32_t *)(disp_rx.p+4);
		
        	cfg.input.ybuf[0] = addr[0];
        	cfg.input.cbbuf[0] = addr[1];
        	cfg.input.crbuf[0] = addr[2];
		// check if there is partial display mode or not
		if((g_disp_mode == DISP_IMAGE_MODE) &&(g_partial_disp_mode == 1))
		{
			//update VPP output buffer pointor           
			cfg.output.ybuf[0] = vpp_output[0] + g_jpg_slices_index;
			cfg.output.cbbuf[0] = 0;
			cfg.output.crbuf[0] = 0;
			g_jpg_slices_index += g_jpg_slices_height*g_rgb_elem_size*cfg.output.size.w;
			dbg("DISP: output ybuf: %x, buf index: %x\n", cfg.output.ybuf[0], g_jpg_slices_index);
		}

		cfg.flag = VPP_F_ADDR;
dbg("DISP: rx DISP_CFG_BUF: (%x, %x, %x)\n", addr[0], addr[1], addr[2]);
		if (vpp_cfg(&vpp, &cfg, DISP_VPP_CH))
		{
			printf("DISP: VPP_CFG failed\n");
			return;
		}
dbg("DISP: DISP_START\n");
		if (vpp_start(&vpp, DISP_VPP_CH))
		{
			printf("DISP: VPP_START failed\n");
			return;
		}
dbg("DISP: DISP_START done\n");
	}
	else
	{
	 	if ((cmd_id & 0xFF) == DISP_CFG)
		{
			if (piu_vpp_cfg(cmd_id&0xFF00, (char *)disp_rx.p + 4))
			{
				printf("DISP: VPP_CFG failed\n");
			}
		}
		else if ((cmd_id & 0xFF) == DISP_SET)
		{
			switch (cmd_id&0xFF00)
			{
				case DISP_IMAGE_PROPERTY:
				{
					uint16_t *p = (uint16_t *)(disp_rx.p+2);
					cfg.input.size.w = p[0];
					cfg.input.size.h = p[1];
					cfg.input.stride_y = p[2];
					cfg.input.stride_cb = p[3];
					cfg.input.stride_cr = p[3];
					
					// check for partial image display mode
					if((g_disp_mode == DISP_IMAGE_MODE) && (cfg.input.size.h < g_jpg_height))
					{
						g_partial_disp_mode = 1;
						g_jpg_slices_height = (fbp[1]*cfg.input.size.h)/g_jpg_height;
                        dbg("DISP: partial input height = %d, output height = %d, orig image height = %d\n",cfg.input.size.h,g_jpg_slices_height,g_jpg_height);						
					}	

					//clean 080104

					if (disp_rx.len >= 12)  //added 2 bytes for yuv format
					{	
						switch (p[4])
						{
							case 0: cfg.input.format = VPP_PIC_YUV444P;break;
							case 1: cfg.input.format = VPP_PIC_YUV422P;break;
							case 2: cfg.input.format = VPP_PIC_YUV420P;break;
							case 3: cfg.input.format = VPP_PIC_YUV411P;break;
							case 4: cfg.input.format = VPP_PIC_YUV400P;break;
							default:printf("error yuv format\n");
						}
						dbg("DISP: output format = %d\n", cfg.input.format);
					}
					if (disp_rx.len == 16)  
					{						
						cfg.input.pixel.w = p[5];
						cfg.input.pixel.h = p[6];
						if (p[5] == 0 || p[6] == 0)
						{
							cfg.input.pixel.w = 1;
							cfg.input.pixel.h = 1;
						}
					}

					//endclean

					cfg.flag |= VPP_F_IN;
dbg("DISP: rx DISP_SET_IMAGE_PROPERTY: size=[%d,%d], stride=[%d %d]\n", p[0], p[1], p[2], p[3]);
#ifdef TV_UNDERRUN_BUG
{
	void *stat = mapm(0x8009008, 36);
	uint32_t val= 0;
	if (stat == (void *)-1)
	{
                printf("mapm fail\n");
		return;
	}
	val = *((uint32_t *)stat + 8);
	printf("image un=%x\n", val);
	if (val == 3)
 	{	
		int i= 500;
		
		*(uint32_t *)stat = 3;
		while (i--);
		*((uint32_t *)stat + 1) = 0x38004F;
		*((uint32_t *)stat + 5) = 0x93e00000;
		*((uint32_t *)stat + 6) = 0x93e54600;
		*((uint32_t *)stat + 7) = 0x93e7e900;
		*(uint32_t *)stat = 5;
		printf("image un=%x\n", *((uint32_t *)stat + 8) );
	}
	unmapm(stat, 36);
}
#endif
					break;
				}
				default:
				{
					printf("DISP: rx Unknown DISP_SET\n");
					return;
				}
			}
		}	
		else
		{
			switch (cmd_id)
			{
				case DISP_INIT:
				{
dbg("DISP: rx DISP_INIT\n");
#if 0
					if (disp_init())
					{
						printf("DISP_INIT failed\n");
						return;
					}
#endif
					if (piu_vpp_init())
					{
						printf("DISP: VPP_INIT failed\n");
						return;
					}
dbg("DISP: VPP OPEN\n");

					disp_tx.len = 6;
					DISP_U8_TO_U16(disp_tx.p) = cmd_id;
					DISP_U8_TO_U16(disp_tx.p+2) = cfg.output.size.w;
					DISP_U8_TO_U16(disp_tx.p+4) = cfg.output.size.h;
					piu_tx(PIU_DISP_QID, &disp_tx);
					return;

				}
				case DISP_START:
				{
dbg("DISP: rx DISP_START\n");
					if (vpp_start(&vpp, DISP_VPP_CH))
					{
						printf("DISP: VPP_START failed\n");
						return;
					}
					break;
				}			
				case DISP_CLOSE:
				{
					g_disp_mode = DISP_VIDEO_MODE;
					g_partial_disp_mode = 0;
					g_jpg_slices_index = 0;
					//vpp_exit(&vpp);
					disp_done = 1;
#ifdef TV_UNDERRUN_BUG
{
	void *stat = mapm(0x8009028, 4);
	uint32_t val= 0;
	if (stat == (void *)-1)
	{
                printf("mapm fail\n");
		return;
	}
	val = *(uint32_t *)stat;
	printf("close un=%x\n", val);
	if (val == 3)
	{
		*(uint32_t *)stat = 3;
	}
	unmapm(stat, 4);
}
#endif
printf("DISP: VPP CLOSE\n");
#if 0
					disp_exit();
printf("???disp_exit() done???\n");
#endif
					break;
				}
				default:
				{
					printf("Unkwown DISP command 0x%x\n", cmd_id);
					return;
				}
			}
		}
#ifdef NEED_RESP
printf("\n%x\n", cmd_id);
		disp_tx.len = 2;
		DISP_U8_TO_U16(disp_tx.p) = cmd_id;
		piu_tx(PIU_DISP_QID, &disp_tx);
#endif
	}
}