Esempio n. 1
0
long disp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	struct dev_disp_data *filp_data = filp->private_data;
	unsigned long karg[4];
	unsigned long ubuffer[4] = { 0 };
	__s32 ret = 0;

	if (copy_from_user
	    ((void *)karg, (void __user *)arg, 4 * sizeof(unsigned long))) {
		__wrn("copy_from_user fail\n");
		return -EFAULT;
	}

	ubuffer[0] = *(unsigned long *)karg;
	ubuffer[1] = (*(unsigned long *)(karg + 1));
	ubuffer[2] = (*(unsigned long *)(karg + 2));
	ubuffer[3] = (*(unsigned long *)(karg + 3));

	/* Verify version handshake first. */
	if (filp_data->version == SUNXI_DISP_VERSION_PENDING) {
		if (cmd == DISP_CMD_VERSION) {
			int version = *((int *) karg);

			if (version < 0) {
				pr_err("disp: process %d (%s) provided an "
				       "invalid version.\n",
				       current->pid, current->comm);
				filp_data->version = SUNXI_DISP_VERSION_SKIPPED;
				return -EINVAL;
			}

			if (version != SUNXI_DISP_VERSION)
				pr_warn("disp: process %d (%s) has a different "
				       "version: %d.%d (vs. %d.%d)\n",
					current->pid, current->comm,
					SUNXI_DISP_VERSION_MAJOR_GET(version),
					SUNXI_DISP_VERSION_MINOR_GET(version),
					SUNXI_DISP_VERSION_MAJOR,
					SUNXI_DISP_VERSION_MINOR);

			/* Add compatibility checks here */

			filp_data->version = version;
			return SUNXI_DISP_VERSION;
		} else {
			pr_err("disp: process %d (%s) has skipped the version "
			       "handshake.\n", current->pid, current->comm);
			filp_data->version = SUNXI_DISP_VERSION_SKIPPED;
		}
	}

	if (cmd < DISP_CMD_FB_REQUEST) {
		if ((ubuffer[0] != 0) && (ubuffer[0] != 1)) {
			__wrn("para err in disp_ioctl, cmd = 0x%x,"
			      "screen id = %d\n", cmd, (int)ubuffer[0]);
			return -1;
		}
	}
	if (suspend_status & 2) {
		__wrn("ioctl:%x fail when in suspend!\n", cmd);
		return -1;
	}
#if 0
	if (cmd != DISP_CMD_TV_GET_INTERFACE &&
	    cmd != DISP_CMD_HDMI_GET_HPD_STATUS &&
	    cmd != DISP_CMD_GET_OUTPUT_TYPE && cmd != DISP_CMD_SCN_GET_WIDTH &&
	    cmd != DISP_CMD_SCN_GET_HEIGHT && cmd != DISP_CMD_VIDEO_SET_FB &&
	    cmd != DISP_CMD_VIDEO_GET_FRAME_ID)
		DE_WRN("cmd:0x%x,%ld,%ld\n", cmd, ubuffer[0], ubuffer[1]);
#endif

	switch (cmd) {
	/* ----disp global---- */
	case DISP_CMD_SET_BKCOLOR:
		{
			__disp_color_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_color_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_set_bk_color(ubuffer[0], &para);
			break;
		}

	case DISP_CMD_SET_COLORKEY:
		{
			__disp_colorkey_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_colorkey_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_set_color_key(ubuffer[0], &para);
			break;
		}

	case DISP_CMD_SET_PALETTE_TBL:
		if ((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0)) {
			__wrn("para invalid in disp ioctrl "
			      "DISP_CMD_SET_PALETTE_TBL,buffer:0x%x, "
			      "size:0x%x\n", (unsigned int) ubuffer[1],
			     (unsigned int) ubuffer[3]);
			return -1;
		}
		if (copy_from_user(gbuffer, (void __user *) ubuffer[1],
				   ubuffer[3])) {
			__wrn("copy_from_user fail\n");
			return -EFAULT;
		}
		ret = BSP_disp_set_palette_table(ubuffer[0], (__u32 *) gbuffer,
						 ubuffer[2], ubuffer[3]);
		break;

	case DISP_CMD_GET_PALETTE_TBL:
		if ((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0)) {
			__wrn("para invalid in disp ioctrl "
			      "DISP_CMD_GET_PALETTE_TBL,buffer:0x%x, "
			      "size:0x%x\n", (unsigned int) ubuffer[1],
			     (unsigned int) ubuffer[3]);
			return -1;
		}
		ret =
		    BSP_disp_get_palette_table(ubuffer[0], (__u32 *) gbuffer,
					       ubuffer[2], ubuffer[3]);
		if (copy_to_user((void __user *) ubuffer[1], gbuffer,
				 ubuffer[3])) {
			__wrn("copy_to_user fail\n");
			return -EFAULT;
		}
		break;

	case DISP_CMD_START_CMD_CACHE:
		ret = BSP_disp_cmd_cache(ubuffer[0]);
		break;

	case DISP_CMD_EXECUTE_CMD_AND_STOP_CACHE:
		ret = BSP_disp_cmd_submit(ubuffer[0]);
		break;

	case DISP_CMD_GET_OUTPUT_TYPE:
		ret = BSP_disp_get_output_type(ubuffer[0]);
		break;

	case DISP_CMD_SCN_GET_WIDTH:
		ret = BSP_disp_get_screen_width(ubuffer[0]);
		break;

	case DISP_CMD_SCN_GET_HEIGHT:
		ret = BSP_disp_get_screen_height(ubuffer[0]);
		break;

	case DISP_CMD_SET_GAMMA_TABLE:
		if ((ubuffer[1] == 0) || ((int)ubuffer[2] <= 0)) {
			__wrn("para invalid in disp ioctrl "
			      "DISP_CMD_SET_GAMMA_TABLE,buffer:0x%x, "
			      "size:0x%x\n", (unsigned int) ubuffer[1],
			     (unsigned int) ubuffer[2]);
			return -1;
		}
		if (copy_from_user(gbuffer, (void __user *) ubuffer[1],
				   ubuffer[2])) {
			__wrn("copy_from_user fail\n");
			return -EFAULT;
		}
		ret = BSP_disp_set_gamma_table(ubuffer[0], (__u32 *) gbuffer,
					     ubuffer[2]);
		break;

	case DISP_CMD_GAMMA_CORRECTION_ON:
		ret = BSP_disp_gamma_correction_enable(ubuffer[0]);
		break;

	case DISP_CMD_GAMMA_CORRECTION_OFF:
		ret = BSP_disp_gamma_correction_disable(ubuffer[0]);
		break;

	case DISP_CMD_SET_BRIGHT:
		ret = BSP_disp_set_bright(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_BRIGHT:
		ret = BSP_disp_get_bright(ubuffer[0]);
		break;

	case DISP_CMD_SET_CONTRAST:
		ret = BSP_disp_set_contrast(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_CONTRAST:
		ret = BSP_disp_get_contrast(ubuffer[0]);
		break;

	case DISP_CMD_SET_SATURATION:
		ret = BSP_disp_set_saturation(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_SATURATION:
		ret = BSP_disp_get_saturation(ubuffer[0]);
		break;

	case DISP_CMD_SET_HUE:
		ret = BSP_disp_set_hue(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_HUE:
		ret = BSP_disp_get_hue(ubuffer[0]);
		break;
#ifdef CONFIG_ARCH_SUN4I
	case DISP_CMD_ENHANCE_ON:
		ret = BSP_disp_enhance_enable(ubuffer[0], 1);
		break;

	case DISP_CMD_ENHANCE_OFF:
		ret = BSP_disp_enhance_enable(ubuffer[0], 0);
		break;

	case DISP_CMD_GET_ENHANCE_EN:
		ret = BSP_disp_get_enhance_enable(ubuffer[0]);
		break;
#endif

	case DISP_CMD_CAPTURE_SCREEN:
		ret = BSP_disp_capture_screen(ubuffer[0],
					      (__disp_capture_screen_para_t *)
					      ubuffer[1]);
		break;

	case DISP_CMD_SET_SCREEN_SIZE:
		ret = BSP_disp_set_screen_size(ubuffer[0],
					       (__disp_rectsz_t *) ubuffer[1]);
		break;

	/* ----iep---- */
	case DISP_CMD_DE_FLICKER_ON:
#ifdef CONFIG_ARCH_SUN4I
		ret = BSP_disp_de_flicker_enable(ubuffer[0], 1);
#else
		ret = BSP_disp_iep_deflicker_enable(ubuffer[0], 1);
#endif
		break;

	case DISP_CMD_DE_FLICKER_OFF:
#ifdef CONFIG_ARCH_SUN4I
		ret = BSP_disp_de_flicker_enable(ubuffer[0], 0);
#else
		ret = BSP_disp_iep_deflicker_enable(ubuffer[0], 0);
#endif
		break;

#ifdef CONFIG_ARCH_SUN5I
	case DISP_CMD_GET_DE_FLICKER_EN:
		ret = BSP_disp_iep_get_deflicker_enable(ubuffer[0]);
		break;

	case DISP_CMD_DRC_ON:
		ret = BSP_disp_iep_drc_enable(ubuffer[0], 1);
		break;

	case DISP_CMD_DRC_OFF:
		ret = BSP_disp_iep_drc_enable(ubuffer[0], 0);
		break;

	case DISP_CMD_GET_DRC_EN:
		ret = BSP_disp_iep_get_drc_enable(ubuffer[0]);
		break;

	case DISP_CMD_DE_FLICKER_SET_WINDOW:
		{
			__disp_rect_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_rect_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}

			ret = BSP_disp_iep_set_demo_win(ubuffer[0], 1, &para);
			break;
		}

	case DISP_CMD_DRC_SET_WINDOW:
		{
			__disp_rect_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_rect_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}

			ret = BSP_disp_iep_set_demo_win(ubuffer[0], 2, &para);
			break;
		}
#endif
	/* ----layer---- */
	case DISP_CMD_LAYER_REQUEST:
		ret = BSP_disp_layer_request(ubuffer[0],
					     (__disp_layer_work_mode_t)
					     ubuffer[1]);
		break;

	case DISP_CMD_LAYER_RELEASE:
		ret = BSP_disp_layer_release(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_OPEN:
		ret = BSP_disp_layer_open(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_CLOSE:
		ret = BSP_disp_layer_close(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_FB:
		{
			__disp_fb_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_fb_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_layer_set_framebuffer(ubuffer[0],
							     ubuffer[1], &para);
			//DRV_disp_wait_cmd_finish(ubuffer[0]);
			break;
		}

	case DISP_CMD_LAYER_GET_FB:
		{
			__disp_fb_t para;

			ret = BSP_disp_layer_get_framebuffer(ubuffer[0],
							     ubuffer[1], &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_fb_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_LAYER_SET_SRC_WINDOW:
		{
			__disp_rect_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_rect_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_layer_set_src_window(ubuffer[0],
							    ubuffer[1], &para);
			//DRV_disp_wait_cmd_finish(ubuffer[0]);
			break;
		}

	case DISP_CMD_LAYER_GET_SRC_WINDOW:
		{
			__disp_rect_t para;

			ret = BSP_disp_layer_get_src_window(ubuffer[0],
							    ubuffer[1], &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_rect_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_LAYER_SET_SCN_WINDOW:
		{
			__disp_rect_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_rect_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_layer_set_screen_window(ubuffer[0],
							       ubuffer[1],
							       &para);
			//DRV_disp_wait_cmd_finish(ubuffer[0]);
			break;
		}

	case DISP_CMD_LAYER_GET_SCN_WINDOW:
		{
			__disp_rect_t para;

			ret = BSP_disp_layer_get_screen_window(ubuffer[0],
							       ubuffer[1],
							       &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_rect_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_LAYER_SET_PARA:
		{
			__disp_layer_info_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_layer_info_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_layer_set_para(ubuffer[0], ubuffer[1],
						      &para);
			//DRV_disp_wait_cmd_finish(ubuffer[0]);
			break;
		}

	case DISP_CMD_LAYER_GET_PARA:
		{
			__disp_layer_info_t para;

			ret = BSP_disp_layer_get_para(ubuffer[0], ubuffer[1],
						      &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_layer_info_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_LAYER_TOP:
		ret = BSP_disp_layer_set_top(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_BOTTOM:
		ret = BSP_disp_layer_set_bottom(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_ALPHA_ON:
		ret = BSP_disp_layer_alpha_enable(ubuffer[0], ubuffer[1], 1);
		break;

	case DISP_CMD_LAYER_ALPHA_OFF:
		ret = BSP_disp_layer_alpha_enable(ubuffer[0], ubuffer[1], 0);
		break;

	case DISP_CMD_LAYER_SET_ALPHA_VALUE:
		ret = BSP_disp_layer_set_alpha_value(ubuffer[0], ubuffer[1],
						     ubuffer[2]);
		//DRV_disp_wait_cmd_finish(ubuffer[0]);
		break;

	case DISP_CMD_LAYER_CK_ON:
		ret = BSP_disp_layer_colorkey_enable(ubuffer[0], ubuffer[1], 1);
		break;

	case DISP_CMD_LAYER_CK_OFF:
		ret = BSP_disp_layer_colorkey_enable(ubuffer[0], ubuffer[1], 0);
		break;

	case DISP_CMD_LAYER_SET_PIPE:
		ret = BSP_disp_layer_set_pipe(ubuffer[0], ubuffer[1],
					      ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_ALPHA_VALUE:
		ret = BSP_disp_layer_get_alpha_value(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_GET_ALPHA_EN:
		ret = BSP_disp_layer_get_alpha_enable(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_GET_CK_EN:
		ret = BSP_disp_layer_get_colorkey_enable(ubuffer[0],
							 ubuffer[1]);
		break;

	case DISP_CMD_LAYER_GET_PRIO:
		ret = BSP_disp_layer_get_piro(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_GET_PIPE:
		ret = BSP_disp_layer_get_pipe(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_SMOOTH:
		ret = BSP_disp_layer_set_smooth(ubuffer[0], ubuffer[1],
						(__disp_video_smooth_t)
						ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_SMOOTH:
		ret = BSP_disp_layer_get_smooth(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_BRIGHT:
		ret = BSP_disp_layer_set_bright(ubuffer[0], ubuffer[1],
						ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_BRIGHT:
		ret = BSP_disp_layer_get_bright(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_CONTRAST:
		ret = BSP_disp_layer_set_contrast(ubuffer[0], ubuffer[1],
						  ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_CONTRAST:
		ret = BSP_disp_layer_get_contrast(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_SATURATION:
		ret = BSP_disp_layer_set_saturation(ubuffer[0], ubuffer[1],
						    ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_SATURATION:
		ret = BSP_disp_layer_get_saturation(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_HUE:
		ret = BSP_disp_layer_set_hue(ubuffer[0], ubuffer[1],
					     ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_HUE:
		ret = BSP_disp_layer_get_hue(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_ENHANCE_ON:
		ret = BSP_disp_layer_enhance_enable(ubuffer[0], ubuffer[1], 1);
		break;

	case DISP_CMD_LAYER_ENHANCE_OFF:
		ret = BSP_disp_layer_enhance_enable(ubuffer[0], ubuffer[1], 0);
		break;

	case DISP_CMD_LAYER_GET_ENHANCE_EN:
		ret = BSP_disp_layer_get_enhance_enable(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_VPP_ON:
		ret = BSP_disp_layer_vpp_enable(ubuffer[0], ubuffer[1], 1);
		break;

	case DISP_CMD_LAYER_VPP_OFF:
		ret = BSP_disp_layer_vpp_enable(ubuffer[0], ubuffer[1], 0);
		break;

	case DISP_CMD_LAYER_GET_VPP_EN:
		ret = BSP_disp_layer_get_vpp_enable(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_LUMA_SHARP_LEVEL:
		ret = BSP_disp_layer_set_luma_sharp_level(ubuffer[0],
							  ubuffer[1],
							  ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_LUMA_SHARP_LEVEL:
		ret =
		    BSP_disp_layer_get_luma_sharp_level(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_CHROMA_SHARP_LEVEL:
		ret = BSP_disp_layer_set_chroma_sharp_level(ubuffer[0],
							    ubuffer[1],
							    ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_CHROMA_SHARP_LEVEL:
		ret = BSP_disp_layer_get_chroma_sharp_level(ubuffer[0],
							    ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_WHITE_EXTEN_LEVEL:
		ret = BSP_disp_layer_set_white_exten_level(ubuffer[0],
							   ubuffer[1],
							   ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_WHITE_EXTEN_LEVEL:
		ret = BSP_disp_layer_get_white_exten_level(ubuffer[0],
							   ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_BLACK_EXTEN_LEVEL:
		ret = BSP_disp_layer_set_black_exten_level(ubuffer[0],
							   ubuffer[1],
							   ubuffer[2]);
		break;

	case DISP_CMD_LAYER_GET_BLACK_EXTEN_LEVEL:
		ret = BSP_disp_layer_get_black_exten_level(ubuffer[0],
							   ubuffer[1]);
		break;

	/* ----scaler---- */
	case DISP_CMD_SCALER_REQUEST:
		ret = BSP_disp_scaler_request();
		break;

	case DISP_CMD_SCALER_RELEASE:
		ret = BSP_disp_scaler_release(ubuffer[1]);
		break;

	case DISP_CMD_SCALER_EXECUTE:
		{
			__disp_scaler_para_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_scaler_para_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_scaler_start(ubuffer[1], &para);
			break;
		}

	/* ----hwc---- */
	case DISP_CMD_HWC_OPEN:
		ret = BSP_disp_hwc_enable(ubuffer[0], 1);
		break;

	case DISP_CMD_HWC_CLOSE:
		ret = BSP_disp_hwc_enable(ubuffer[0], 0);
		break;

	case DISP_CMD_HWC_SET_POS:
		{
			__disp_pos_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_pos_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_hwc_set_pos(ubuffer[0], &para);
			break;
		}

	case DISP_CMD_HWC_GET_POS:
		{
			__disp_pos_t para;

			ret = BSP_disp_hwc_get_pos(ubuffer[0], &para);
			if (copy_to_user((void __user *)ubuffer[1], &para,
					 sizeof(__disp_pos_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_HWC_SET_FB:
		{
			__disp_hwc_pattern_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_hwc_pattern_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_hwc_set_framebuffer(ubuffer[0], &para);
			break;
		}

	case DISP_CMD_HWC_SET_PALETTE_TABLE:
		if ((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0)) {
			__wrn("para invalid in display ioctrl "
			      "DISP_CMD_HWC_SET_PALETTE_TABLE,buffer:0x%x, "
			      "size:0x%x\n", (unsigned int)ubuffer[1],
			     (unsigned int)ubuffer[3]);
			return -1;
		}
		if (copy_from_user(gbuffer, (void __user *)ubuffer[1],
				   ubuffer[3])) {
			__wrn("copy_from_user fail\n");
			return -EFAULT;
		}
		ret = BSP_disp_hwc_set_palette(ubuffer[0], (void *)gbuffer,
					       ubuffer[2], ubuffer[3]);
		break;

	/* ----video---- */
	case DISP_CMD_VIDEO_START:
		ret = BSP_disp_video_start(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_VIDEO_STOP:
		ret = BSP_disp_video_stop(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_VIDEO_SET_FB:
		{
			__disp_video_fb_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_video_fb_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_video_set_fb(ubuffer[0], ubuffer[1],
						    &para);
			break;
		}

	case DISP_CMD_VIDEO_GET_FRAME_ID:
		ret = BSP_disp_video_get_frame_id(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_VIDEO_GET_DIT_INFO:
		{
			__disp_dit_info_t para;

			ret = BSP_disp_video_get_dit_info(ubuffer[0],
							  ubuffer[1],
							  &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_dit_info_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	/* ----lcd---- */
	case DISP_CMD_LCD_ON:
		ret = DRV_lcd_open(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_LCD;
		break;

	case DISP_CMD_LCD_OFF:
		ret = DRV_lcd_close(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
		break;

	case DISP_CMD_LCD_SET_BRIGHTNESS:
#ifdef CONFIG_ARCH_SUN4I
		ret = BSP_disp_lcd_set_bright(ubuffer[0], ubuffer[1]);
#else
		ret = BSP_disp_lcd_set_bright(ubuffer[0], ubuffer[1], 0);
#endif
		break;

	case DISP_CMD_LCD_GET_BRIGHTNESS:
		ret = BSP_disp_lcd_get_bright(ubuffer[0]);
		break;

	case DISP_CMD_LCD_CPUIF_XY_SWITCH:
		ret = BSP_disp_lcd_xy_switch(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LCD_SET_SRC:
		ret = BSP_disp_lcd_set_src(ubuffer[0],
					   (__disp_lcdc_src_t) ubuffer[1]);
		break;

	case DISP_CMD_LCD_USER_DEFINED_FUNC:
		ret =  BSP_disp_lcd_user_defined_func(ubuffer[0], ubuffer[1],
						      ubuffer[2], ubuffer[3]);
		break;

	/* ----pwm---- */
	case DISP_CMD_PWM_SET_PARA:
		ret = pwm_set_para(ubuffer[0], (__pwm_info_t *) ubuffer[1]);
		break;

	case DISP_CMD_PWM_GET_PARA:
		ret = pwm_get_para(ubuffer[0], (__pwm_info_t *) ubuffer[1]);
		break;

	/* ----tv---- */
	case DISP_CMD_TV_ON:
		ret = BSP_disp_tv_open(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_TV;
		break;

	case DISP_CMD_TV_OFF:
		ret = BSP_disp_tv_close(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
		break;

	case DISP_CMD_TV_SET_MODE:
		ret = BSP_disp_tv_set_mode(ubuffer[0],
					   (__disp_tv_mode_t) ubuffer[1]);
		break;

	case DISP_CMD_TV_GET_MODE:
		ret = BSP_disp_tv_get_mode(ubuffer[0]);
		break;

	case DISP_CMD_TV_AUTOCHECK_ON:
		ret = BSP_disp_tv_auto_check_enable(ubuffer[0]);
		break;

	case DISP_CMD_TV_AUTOCHECK_OFF:
		ret = BSP_disp_tv_auto_check_disable(ubuffer[0]);
		break;

	case DISP_CMD_TV_GET_INTERFACE:
		if (suspend_status != 0)
			ret = DISP_TV_NONE;
		else
			ret = BSP_disp_tv_get_interface(ubuffer[0]);
		break;

	case DISP_CMD_TV_SET_SRC:
		ret = BSP_disp_tv_set_src(ubuffer[0],
					  (__disp_lcdc_src_t) ubuffer[1]);
		break;

	case DISP_CMD_TV_GET_DAC_STATUS:
		if (suspend_status != 0)
			ret = 0;
		else
			ret = BSP_disp_tv_get_dac_status(ubuffer[0],
							 ubuffer[1]);
		break;

	case DISP_CMD_TV_SET_DAC_SOURCE:
		ret = BSP_disp_tv_set_dac_source(ubuffer[0], ubuffer[1],
						 (__disp_tv_dac_source)
						 ubuffer[2]);
		break;

	case DISP_CMD_TV_GET_DAC_SOURCE:
		ret = BSP_disp_tv_get_dac_source(ubuffer[0], ubuffer[1]);
		break;

	/* ----hdmi---- */
	case DISP_CMD_HDMI_ON:
		ret = BSP_disp_hdmi_open(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_HDMI;
		break;

	case DISP_CMD_HDMI_OFF:
		ret = BSP_disp_hdmi_close(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
		break;

	case DISP_CMD_HDMI_SET_MODE:
		ret = BSP_disp_hdmi_set_mode(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_HDMI_GET_MODE:
		ret = BSP_disp_hdmi_get_mode(ubuffer[0]);
		break;

	case DISP_CMD_HDMI_GET_HPD_STATUS:
		if (suspend_status != 0)
			ret = 0;
		else
			ret = BSP_disp_hdmi_get_hpd_status(ubuffer[0]);
		break;

	case DISP_CMD_HDMI_SUPPORT_MODE:
		ret = BSP_disp_hdmi_check_support_mode(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_HDMI_SET_SRC:
		ret = BSP_disp_hdmi_set_src(ubuffer[0],
					    (__disp_lcdc_src_t) ubuffer[1]);
		break;

	/* ----vga---- */
	case DISP_CMD_VGA_ON:
		ret = BSP_disp_vga_open(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_VGA;

		break;

	case DISP_CMD_VGA_OFF:
		ret = BSP_disp_vga_close(ubuffer[0]);
		if (suspend_status != 0)
			suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;

		break;

	case DISP_CMD_VGA_SET_MODE:
		ret = BSP_disp_vga_set_mode(ubuffer[0],
					    (__disp_vga_mode_t) ubuffer[1]);
		break;

	case DISP_CMD_VGA_GET_MODE:
		ret = BSP_disp_vga_get_mode(ubuffer[0]);
		break;

	case DISP_CMD_VGA_SET_SRC:
		ret = BSP_disp_vga_set_src(ubuffer[0],
					   (__disp_lcdc_src_t) ubuffer[1]);
		break;

	/* ----sprite---- */
	case DISP_CMD_SPRITE_OPEN:
		ret = BSP_disp_sprite_open(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_CLOSE:
		ret = BSP_disp_sprite_close(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_SET_FORMAT:
		ret =
		    BSP_disp_sprite_set_format(ubuffer[0],
					       (__disp_pixel_fmt_t) ubuffer[1],
					       (__disp_pixel_seq_t) ubuffer[2]);
		break;

	case DISP_CMD_SPRITE_GLOBAL_ALPHA_ENABLE:
		ret = BSP_disp_sprite_alpha_enable(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_GLOBAL_ALPHA_DISABLE:
		ret = BSP_disp_sprite_alpha_disable(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_ENABLE:
		ret = BSP_disp_sprite_get_alpha_enable(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_SET_GLOBAL_ALPHA_VALUE:
		ret = BSP_disp_sprite_set_alpha_vale(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_VALUE:
		ret = BSP_disp_sprite_get_alpha_value(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_SET_ORDER:
		ret = BSP_disp_sprite_set_order(ubuffer[0], ubuffer[1],
						ubuffer[2]);
		break;

	case DISP_CMD_SPRITE_GET_TOP_BLOCK:
		ret = BSP_disp_sprite_get_top_block(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_GET_BOTTOM_BLOCK:
		ret = BSP_disp_sprite_get_bottom_block(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_SET_PALETTE_TBL:
		if ((ubuffer[1] == 0) || ((int) ubuffer[3] <= 0)) {
			__wrn("para invalid in display ioctrl "
			      "DISP_CMD_SPRITE_SET_PALETTE_TBL,buffer:0x%x,"
			      " size:0x%x\n", (unsigned int) ubuffer[1],
			     (unsigned int) ubuffer[3]);
			return -1;
		}
		if (copy_from_user(gbuffer, (void __user *)ubuffer[1],
				   ubuffer[3])) {
			__wrn("copy_from_user fail\n");
			return -EFAULT;
		}
		ret = BSP_disp_sprite_set_palette_table(ubuffer[0],
							(__u32 *) gbuffer,
							ubuffer[2], ubuffer[3]);
		break;

	case DISP_CMD_SPRITE_GET_BLOCK_NUM:
		ret = BSP_disp_sprite_get_block_number(ubuffer[0]);
		break;

	case DISP_CMD_SPRITE_BLOCK_REQUEST:
		{
			__disp_sprite_block_para_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_sprite_block_para_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_sprite_block_request(ubuffer[0], &para);
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_RELEASE:
		ret = BSP_disp_sprite_block_release(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_SET_SCREEN_WINDOW:
		{
			__disp_rect_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_rect_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_sprite_block_set_screen_win(ubuffer[0],
								   ubuffer[1],
								   &para);
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_GET_SCREEN_WINDOW:
		{
			__disp_rect_t para;

			ret = BSP_disp_sprite_block_get_srceen_win(ubuffer[0],
								   ubuffer[1],
								   &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_rect_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_SET_SOURCE_WINDOW:
		{
			__disp_rect_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_rect_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_sprite_block_set_src_win(ubuffer[0],
								ubuffer[1],
								&para);
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_GET_SOURCE_WINDOW:
		{
			__disp_rect_t para;

			ret = BSP_disp_sprite_block_get_src_win(ubuffer[0],
								ubuffer[1],
								&para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_rect_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_SET_FB:
		{
			__disp_fb_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_fb_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_sprite_block_set_framebuffer(ubuffer[0],
								    ubuffer[1],
								    &para);
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_GET_FB:
		{
			__disp_fb_t para;

			ret = BSP_disp_sprite_block_get_framebufer(ubuffer[0],
								   ubuffer[1],
								   &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_fb_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_SET_TOP:
		ret = BSP_disp_sprite_block_set_top(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_SET_BOTTOM:
		ret = BSP_disp_sprite_block_set_bottom(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_GET_PREV_BLOCK:
		ret = BSP_disp_sprite_block_get_pre_block(ubuffer[0],
							  ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_GET_NEXT_BLOCK:
		ret = BSP_disp_sprite_block_get_next_block(ubuffer[0],
							   ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_GET_PRIO:
		ret = BSP_disp_sprite_block_get_prio(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_OPEN:
		ret = BSP_disp_sprite_block_open(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_CLOSE:
		ret = BSP_disp_sprite_block_close(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_SPRITE_BLOCK_SET_PARA:
		{
			__disp_sprite_block_para_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[2],
					   sizeof(__disp_sprite_block_para_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = BSP_disp_sprite_block_set_para(ubuffer[0],
							     ubuffer[1], &para);
			break;
		}

	case DISP_CMD_SPRITE_BLOCK_GET_PARA:
		{
			__disp_sprite_block_para_t para;

			ret = BSP_disp_sprite_block_get_para(ubuffer[0],
							     ubuffer[1], &para);
			if (copy_to_user((void __user *)ubuffer[2], &para,
					 sizeof(__disp_sprite_block_para_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	/* ----framebuffer---- */
	case DISP_CMD_FB_REQUEST:
		{
			__disp_fb_create_para_t para;

			if (copy_from_user(&para, (void __user *)ubuffer[1],
					   sizeof(__disp_fb_create_para_t))) {
				__wrn("copy_from_user fail\n");
				return -EFAULT;
			}
			ret = Display_Fb_Request(ubuffer[0], &para);
			break;
		}

	case DISP_CMD_FB_RELEASE:
		ret = Display_Fb_Release(ubuffer[0]);
		break;

	case DISP_CMD_FB_GET_PARA:
		{
			__disp_fb_create_para_t para;

			ret = Display_Fb_get_para(ubuffer[0], &para);
			if (copy_to_user((void __user *)ubuffer[1], &para,
					 sizeof(__disp_fb_create_para_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_GET_DISP_INIT_PARA:
		{
			__disp_init_t para;

			ret = Display_get_disp_init_para(&para);
			if (copy_to_user((void __user *)ubuffer[0], &para,
					 sizeof(__disp_init_t))) {
				__wrn("copy_to_user fail\n");
				return -EFAULT;
			}
			break;
		}

	case DISP_CMD_MEM_REQUEST:
		ret = disp_mem_request(ubuffer[0], ubuffer[1]);
		break;

	/* ----for test---- */
	case DISP_CMD_MEM_RELASE:
		ret = disp_mem_release(ubuffer[0]);
		break;

	case DISP_CMD_MEM_SELIDX:
		g_disp_mm_sel = ubuffer[0];
		break;

	case DISP_CMD_MEM_GETADR:
		ret = g_disp_mm[ubuffer[0]].mem_start;
		break;

	case DISP_CMD_SUSPEND:
		{
			pm_message_t state = { };

			ret = disp_suspend(NULL, state);
			break;
		}

	case DISP_CMD_RESUME:
		ret = disp_resume(NULL);
		break;

	case DISP_CMD_PRINT_REG:
		ret = BSP_disp_print_reg(1, ubuffer[0]);
		break;

	default:
		break;
	}

	return ret;
}
long disp_ioctl(void *hd, unsigned int cmd, void *arg)
{
	unsigned long karg[4];
	unsigned long ubuffer[4] = {0};
	__s32 ret = 0;

	if(!display_opens)
	{
		printf("de not open\n");
		return -1;
	}
	if (copy_from_user((void*)karg,(void __user*)arg,4*sizeof(unsigned long)))
	{
		__wrn("copy_from_user fail %d \n",__LINE__);
		return -EFAULT;
	}

	ubuffer[0] = *(unsigned long*)karg;
	ubuffer[1] = (*(unsigned long*)(karg+1));
	ubuffer[2] = (*(unsigned long*)(karg+2));
	ubuffer[3] = (*(unsigned long*)(karg+3));

    if(cmd < DISP_CMD_FB_REQUEST)
    {
        if((ubuffer[0] != 0) && (ubuffer[0] != 1))
        {
            __wrn("para err in disp_ioctl, cmd = 0x%x,screen id = %d\n", cmd, (int)ubuffer[0]);
            return -1;
        }
    }
    if(suspend_status & 2)
    {
        __wrn("ioctl:%x fail when in suspend!\n", cmd);
        return -1;
    }

#if 0
    if(cmd!=DISP_CMD_TV_GET_INTERFACE && cmd!=DISP_CMD_HDMI_GET_HPD_STATUS && cmd!=DISP_CMD_GET_OUTPUT_TYPE
    	&& cmd!=DISP_CMD_SCN_GET_WIDTH && cmd!=DISP_CMD_SCN_GET_HEIGHT
    	&& cmd!=DISP_CMD_VIDEO_SET_FB && cmd!=DISP_CMD_VIDEO_GET_FRAME_ID)
    {
        OSAL_PRINTF("cmd:0x%x,%ld,%ld\n",cmd, ubuffer[0], ubuffer[1]);
    }
#endif

    switch(cmd)
    {
    //----disp global----
    	case DISP_CMD_SET_BKCOLOR:
	    {
	        __disp_color_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_color_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
		    ret = bsp_disp_set_bk_color(ubuffer[0], &para);
		    break;
	    }

    	case DISP_CMD_SET_COLORKEY:
    	{
    	    __disp_colorkey_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_colorkey_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_set_color_key(ubuffer[0], &para);
		    break;
		}

    	case DISP_CMD_SET_PALETTE_TBL:
    	    if((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0))
    	    {
    	        __wrn("para invalid in disp ioctrl DISP_CMD_SET_PALETTE_TBL,buffer:0x%x, size:0x%x\n", (unsigned int)ubuffer[1], (unsigned int)ubuffer[3]);
    	        return -1;
    	    }
    		if(copy_from_user(gbuffer, (void __user *)ubuffer[1],ubuffer[3]))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_set_palette_table(ubuffer[0], (__u32 *)gbuffer, ubuffer[2], ubuffer[3]);
    		break;

    	case DISP_CMD_GET_PALETTE_TBL:
    	    if((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0))
    	    {
    	        __wrn("para invalid in disp ioctrl DISP_CMD_GET_PALETTE_TBL,buffer:0x%x, size:0x%x\n", (unsigned int)ubuffer[1], (unsigned int)ubuffer[3]);
    	        return -1;
    	    }
    		ret = bsp_disp_get_palette_table(ubuffer[0], (__u32 *)gbuffer, ubuffer[2], ubuffer[3]);
    		if(copy_to_user((void __user *)ubuffer[1], gbuffer,ubuffer[3]))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;

    	case DISP_CMD_START_CMD_CACHE:
    		ret = bsp_disp_cmd_cache(ubuffer[0]);
    		break;

    	case DISP_CMD_EXECUTE_CMD_AND_STOP_CACHE:
    		ret = bsp_disp_cmd_submit(ubuffer[0]);
    		break;

    	case DISP_CMD_GET_OUTPUT_TYPE:
    		ret =  bsp_disp_get_output_type(ubuffer[0]);
    		break;

    	case DISP_CMD_SCN_GET_WIDTH:
    		ret = bsp_disp_get_screen_width(ubuffer[0]);
    		break;

    	case DISP_CMD_SCN_GET_HEIGHT:
    		ret = bsp_disp_get_screen_height(ubuffer[0]);
    		break;

    	case DISP_CMD_SET_GAMMA_TABLE:
    	    if((ubuffer[1] == 0) || ((int)ubuffer[2] <= 0))
    	    {
    	        __wrn("para invalid in disp ioctrl DISP_CMD_SET_GAMMA_TABLE,buffer:0x%x, size:0x%x\n", (unsigned int)ubuffer[1], (unsigned int)ubuffer[2]);
    	        return -1;
    	    }
    		if(copy_from_user(gbuffer, (void __user *)ubuffer[1],ubuffer[2]))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_set_gamma_table(ubuffer[0], (__u32 *)gbuffer, ubuffer[2]);
    		break;

    	case DISP_CMD_GAMMA_CORRECTION_ON:
    		ret = bsp_disp_gamma_correction_enable(ubuffer[0]);
    		break;

    	case DISP_CMD_GAMMA_CORRECTION_OFF:
    		ret = bsp_disp_gamma_correction_disable(ubuffer[0]);
    		break;

        case DISP_CMD_SET_BRIGHT:
            ret = bsp_disp_cmu_set_bright(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_GET_BRIGHT:
            ret = bsp_disp_cmu_get_bright(ubuffer[0]);
    		break;

        case DISP_CMD_SET_CONTRAST:
            ret = bsp_disp_cmu_set_contrast(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_GET_CONTRAST:
            ret = bsp_disp_cmu_get_contrast(ubuffer[0]);
    		break;

        case DISP_CMD_SET_SATURATION:
            ret = bsp_disp_cmu_set_saturation(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_GET_SATURATION:
            ret = bsp_disp_cmu_get_saturation(ubuffer[0]);
    		break;

        case DISP_CMD_SET_HUE:
            ret = bsp_disp_cmu_set_hue(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_GET_HUE:
            ret = bsp_disp_cmu_get_hue(ubuffer[0]);
    		break;

        case DISP_CMD_ENHANCE_ON:
            ret = bsp_disp_cmu_enable(ubuffer[0], 1);
    		break;

        case DISP_CMD_ENHANCE_OFF:
            ret = bsp_disp_cmu_enable(ubuffer[0], 0);
    		break;

        case DISP_CMD_GET_ENHANCE_EN:
            ret = bsp_disp_cmu_get_enable(ubuffer[0]);
    		break;

        case DISP_CMD_SET_ENHANCE_MODE:
            ret = bsp_disp_cmu_set_mode(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_GET_ENHANCE_MODE:
            ret = bsp_disp_cmu_get_mode(ubuffer[0]);
    		break;

        case DISP_CMD_SET_ENHANCE_WINDOW:
        {
            __disp_rect_t para;

            if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
            ret = bsp_disp_cmu_set_window(ubuffer[0], &para);
    		break;
        }

        case DISP_CMD_GET_ENHANCE_WINDOW:
        {
            __disp_rect_t para;

            ret = bsp_disp_cmu_get_window(ubuffer[0], &para);
            if(copy_to_user((void __user *)ubuffer[1],&para, sizeof(__disp_layer_info_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_CAPTURE_SCREEN:
    	    ret = bsp_disp_capture_screen(ubuffer[0], (__disp_capture_screen_para_t *)ubuffer[1]);
    	    break;

        case DISP_CMD_SET_SCREEN_SIZE:
            ret = bsp_disp_set_screen_size(ubuffer[0], (__disp_rectsz_t*)ubuffer[1]);
            break;

        case DISP_CMD_DE_FLICKER_ON:
            ret = bsp_disp_de_flicker_enable(ubuffer[0], 1);
            break;

        case DISP_CMD_DE_FLICKER_OFF:
            ret = bsp_disp_de_flicker_enable(ubuffer[0], 0);
            break;

        case DISP_CMD_DRC_ON:
            ret = bsp_disp_drc_enable(ubuffer[0], 1);
            break;

        case DISP_CMD_DRC_OFF:
            ret = bsp_disp_drc_enable(ubuffer[0], 0);
            break;

        case DISP_CMD_GET_DRC_EN:
            ret = bsp_disp_drc_get_enable(ubuffer[0]);
            break;

        case DISP_CMD_DRC_SET_WINDOW:
        {
            __disp_rect_t para;

            if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_rect_t)))
            {
                __wrn("copy_from_user fail\n");
                return  -EFAULT;
            }

            ret = bsp_disp_drc_set_window(ubuffer[0], &para);
            break;
       }

       case DISP_CMD_DRC_GET_WINDOW:
        {
            __disp_rect_t para;

            ret = bsp_disp_drc_get_window(ubuffer[0], &para);
            if(copy_to_user((void __user *)ubuffer[1], &para,sizeof(__disp_rect_t)))
            {
                __wrn("copy_to_user fail\n");
                return  -EFAULT;
            }

            return ret;
            break;
       }
    //----layer----
    	case DISP_CMD_LAYER_REQUEST:
    		ret = bsp_disp_layer_request(ubuffer[0], (__disp_layer_work_mode_t)ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_RELEASE:
    		ret = bsp_disp_layer_release(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_OPEN:
    		ret = bsp_disp_layer_open(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_CLOSE:
    		ret = bsp_disp_layer_close(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_SET_FB:
    	{
    	    __disp_fb_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_fb_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_layer_set_framebuffer(ubuffer[0], ubuffer[1], &para);
    		//DRV_disp_wait_cmd_finish(ubuffer[0]);
    		break;
    	}

    	case DISP_CMD_LAYER_GET_FB:
    	{
    	    __disp_fb_t para;

    		ret = bsp_disp_layer_get_framebuffer(ubuffer[0], ubuffer[1], &para);
    		if(copy_to_user((void __user *)ubuffer[2], &para,sizeof(__disp_fb_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_LAYER_SET_SRC_WINDOW:
    	{
    	    __disp_rect_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_layer_set_src_window(ubuffer[0],ubuffer[1], &para);
    		//DRV_disp_wait_cmd_finish(ubuffer[0]);
    		break;
        }

    	case DISP_CMD_LAYER_GET_SRC_WINDOW:
    	{
    	    __disp_rect_t para;

    		ret = bsp_disp_layer_get_src_window(ubuffer[0],ubuffer[1], &para);
    		if(copy_to_user((void __user *)ubuffer[2], &para, sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_LAYER_SET_SCN_WINDOW:
    	{
    	    __disp_rect_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_layer_set_screen_window(ubuffer[0],ubuffer[1], &para);
    		//DRV_disp_wait_cmd_finish(ubuffer[0]);
    		break;
        }

    	case DISP_CMD_LAYER_GET_SCN_WINDOW:
    	{
    	    __disp_rect_t para;

    		ret = bsp_disp_layer_get_screen_window(ubuffer[0],ubuffer[1], &para);
    		if(copy_to_user((void __user *)ubuffer[2], &para, sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_LAYER_SET_PARA:
    	{
    	    __disp_layer_info_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_layer_info_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_layer_set_para(ubuffer[0], ubuffer[1], &para);
    		//DRV_disp_wait_cmd_finish(ubuffer[0]);
    		break;
        }

    	case DISP_CMD_LAYER_GET_PARA:
    	{
    	    __disp_layer_info_t para;

    		ret = bsp_disp_layer_get_para(ubuffer[0], ubuffer[1], &para);
    		if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_layer_info_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_LAYER_TOP:
    		ret = bsp_disp_layer_set_top(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_BOTTOM:
    		ret = bsp_disp_layer_set_bottom(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_ALPHA_ON:
    		ret = bsp_disp_layer_alpha_enable(ubuffer[0], ubuffer[1], 1);
    		break;

    	case DISP_CMD_LAYER_ALPHA_OFF:
    		ret = bsp_disp_layer_alpha_enable(ubuffer[0], ubuffer[1], 0);
    		break;

    	case DISP_CMD_LAYER_SET_ALPHA_VALUE:
    		ret = bsp_disp_layer_set_alpha_value(ubuffer[0], ubuffer[1], ubuffer[2]);
    		//DRV_disp_wait_cmd_finish(ubuffer[0]);
    		break;

    	case DISP_CMD_LAYER_CK_ON:
    		ret = bsp_disp_layer_colorkey_enable(ubuffer[0], ubuffer[1], 1);
    		break;

    	case DISP_CMD_LAYER_CK_OFF:
    		ret = bsp_disp_layer_colorkey_enable(ubuffer[0], ubuffer[1], 0);
    		break;

    	case DISP_CMD_LAYER_SET_PIPE:
    		ret = bsp_disp_layer_set_pipe(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

    	case DISP_CMD_LAYER_GET_ALPHA_VALUE:
    		ret = bsp_disp_layer_get_alpha_value(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_GET_ALPHA_EN:
    		ret = bsp_disp_layer_get_alpha_enable(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_GET_CK_EN:
    		ret = bsp_disp_layer_get_colorkey_enable(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_GET_PRIO:
    		ret = bsp_disp_layer_get_piro(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_LAYER_GET_PIPE:
    		ret = bsp_disp_layer_get_pipe(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_SMOOTH:
            ret = bsp_disp_layer_set_smooth(ubuffer[0], ubuffer[1],(__disp_video_smooth_t) ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_SMOOTH:
            ret = bsp_disp_layer_get_smooth(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_BRIGHT:
            ret = bsp_disp_cmu_layer_set_bright(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_BRIGHT:
            ret = bsp_disp_cmu_layer_get_bright(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_CONTRAST:
            ret = bsp_disp_cmu_layer_set_contrast(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_CONTRAST:
            ret = bsp_disp_cmu_layer_get_contrast(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_SATURATION:
            ret = bsp_disp_cmu_layer_set_saturation(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_SATURATION:
            ret = bsp_disp_cmu_layer_get_saturation(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_HUE:
            ret = bsp_disp_cmu_layer_set_hue(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_HUE:
            ret = bsp_disp_cmu_layer_get_hue(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_ENHANCE_ON:
            ret = bsp_disp_cmu_layer_enable(ubuffer[0], ubuffer[1], 1);
    		break;

        case DISP_CMD_LAYER_ENHANCE_OFF:
            ret = bsp_disp_cmu_layer_enable(ubuffer[0], ubuffer[1], 0);
    		break;

        case DISP_CMD_LAYER_GET_ENHANCE_EN:
            ret = bsp_disp_cmu_layer_get_enable(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_ENHANCE_MODE:
            ret = bsp_disp_cmu_layer_set_mode(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_ENHANCE_MODE:
            ret = bsp_disp_cmu_layer_get_mode(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_ENHANCE_WINDOW:
        {
            __disp_rect_t para;
            if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
            ret = bsp_disp_cmu_layer_set_window(ubuffer[0], ubuffer[1], &para);
    		break;
       }

        case DISP_CMD_LAYER_GET_ENHANCE_WINDOW:
        {
            __disp_rect_t para;
            ret = bsp_disp_cmu_layer_get_window(ubuffer[0], ubuffer[1], &para);
            if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_layer_info_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
       }
        case DISP_CMD_LAYER_VPP_ON:
            ret = bsp_disp_deu_enable(ubuffer[0], ubuffer[1], 1);
    		break;

        case DISP_CMD_LAYER_VPP_OFF:
            ret = bsp_disp_deu_enable(ubuffer[0], ubuffer[1], 0);
    		break;

        case DISP_CMD_LAYER_GET_VPP_EN:
            ret = bsp_disp_deu_get_enable(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_LUMA_SHARP_LEVEL:
            ret = bsp_disp_deu_set_luma_sharp_level(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_LUMA_SHARP_LEVEL:
            ret = bsp_disp_deu_get_luma_sharp_level(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_CHROMA_SHARP_LEVEL:
            ret = bsp_disp_deu_set_chroma_sharp_level(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_CHROMA_SHARP_LEVEL:
            ret = bsp_disp_deu_get_chroma_sharp_level(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_WHITE_EXTEN_LEVEL:
            ret = bsp_disp_deu_set_white_exten_level(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_WHITE_EXTEN_LEVEL:
            ret = bsp_disp_deu_get_white_exten_level(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_LAYER_SET_BLACK_EXTEN_LEVEL:
            ret = bsp_disp_deu_set_black_exten_level(ubuffer[0], ubuffer[1], ubuffer[2]);
    		break;

        case DISP_CMD_LAYER_GET_BLACK_EXTEN_LEVEL:
            ret = bsp_disp_deu_get_black_exten_level(ubuffer[0], ubuffer[1]);
    		break;
        case DISP_CMD_LAYER_VPP_SET_WINDOW:
        {
            __disp_rect_t para;

            if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_rect_t)))
            {
                __wrn("copy_from_user fail\n");
                return  -EFAULT;
            }

            ret = bsp_disp_deu_set_window(ubuffer[0], ubuffer[1], &para);
            break;
       }

       case DISP_CMD_LAYER_VPP_GET_WINDOW:
        {
            __disp_rect_t para;

            ret = bsp_disp_deu_get_window(ubuffer[0], ubuffer[1], &para);
            if(copy_to_user((void __user *)ubuffer[2], &para,sizeof(__disp_rect_t)))
            {
                __wrn("copy_to_user fail\n");
                return  -EFAULT;
            }

            return ret;
            break;
       }

    //----scaler----
    	case DISP_CMD_SCALER_REQUEST:
    		ret = bsp_disp_scaler_request();
    		break;

    	case DISP_CMD_SCALER_RELEASE:
    		ret = bsp_disp_scaler_release(ubuffer[1]);
    		break;

    	case DISP_CMD_SCALER_EXECUTE:
    	{
    	    __disp_scaler_para_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_scaler_para_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_scaler_start(ubuffer[1],&para);
    		break;
        }

        case DISP_CMD_SCALER_EXECUTE_EX:
    	{
    	    __disp_scaler_para_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_scaler_para_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_scaler_start_ex(ubuffer[1],&para);
    		break;
        }

    //----hwc----
    	case DISP_CMD_HWC_OPEN:
    		ret =  bsp_disp_hwc_enable(ubuffer[0], 1);
    		break;

    	case DISP_CMD_HWC_CLOSE:
    		ret =  bsp_disp_hwc_enable(ubuffer[0], 0);
    		break;

    	case DISP_CMD_HWC_SET_POS:
    	{
    	    __disp_pos_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_pos_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_hwc_set_pos(ubuffer[0], &para);
    		break;
        }

    	case DISP_CMD_HWC_GET_POS:
    	{
    	    __disp_pos_t para;

    		ret = bsp_disp_hwc_get_pos(ubuffer[0], &para);
    		if(copy_to_user((void __user *)ubuffer[1],&para, sizeof(__disp_pos_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_HWC_SET_FB:
    	{
    	    __disp_hwc_pattern_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_hwc_pattern_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_hwc_set_framebuffer(ubuffer[0], &para);
    		break;
        }

    	case DISP_CMD_HWC_SET_PALETTE_TABLE:
			if((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0))
            {
                __wrn("para invalid in display ioctrl DISP_CMD_HWC_SET_PALETTE_TABLE,buffer:0x%x, size:0x%x\n", (unsigned int)ubuffer[1], (unsigned int)ubuffer[3]);
                return -1;
            }
    		if(copy_from_user(gbuffer, (void __user *)ubuffer[1],ubuffer[3]))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_hwc_set_palette(ubuffer[0], (void*)gbuffer, ubuffer[2], ubuffer[3]);
    		break;


    //----video----
    	case DISP_CMD_VIDEO_START:
    		ret = bsp_disp_video_start(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_VIDEO_STOP:
    		ret = bsp_disp_video_stop(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_VIDEO_SET_FB:
    	{
    	    __disp_video_fb_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_video_fb_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
    		ret = bsp_disp_video_set_fb(ubuffer[0], ubuffer[1], &para);
    		break;
        }

        case DISP_CMD_VIDEO_GET_FRAME_ID:
            ret = bsp_disp_video_get_frame_id(ubuffer[0], ubuffer[1]);
    		break;

        case DISP_CMD_VIDEO_GET_DIT_INFO:
        {
            __disp_dit_info_t para;

            ret = bsp_disp_video_get_dit_info(ubuffer[0], ubuffer[1],&para);
    		if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_dit_info_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    //----lcd----
    	case DISP_CMD_LCD_ON:
    		ret = DRV_lcd_open(ubuffer[0]);
    		output_type = DISP_OUTPUT_TYPE_LCD;
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_LCD;
            }
    		break;

    	case DISP_CMD_LCD_OFF:
    		ret = DRV_lcd_close(ubuffer[0]);
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
            }
    		break;

    	case DISP_CMD_LCD_SET_BRIGHTNESS:
    		ret = bsp_disp_lcd_set_bright(ubuffer[0], ubuffer[1], 0);
    		break;

    	case DISP_CMD_LCD_GET_BRIGHTNESS:
    		ret = bsp_disp_lcd_get_bright(ubuffer[0]);
    		break;

//    	case DISP_CMD_LCD_CPUIF_XY_SWITCH:
// 		ret = bsp_disp_lcd_xy_switch(ubuffer[0], ubuffer[1]);
  //  		break;

    	case DISP_CMD_LCD_SET_SRC:
    		ret = bsp_disp_lcd_set_src(ubuffer[0], (__disp_lcdc_src_t)ubuffer[1]);
    		break;

        case DISP_CMD_LCD_USER_DEFINED_FUNC:
            ret = bsp_disp_lcd_user_defined_func(ubuffer[0], ubuffer[1], ubuffer[2], ubuffer[3]);
            break;

    //----tv----
    	case DISP_CMD_TV_ON:
    		ret = bsp_disp_tv_open(ubuffer[0]);
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_TV;
            }
    		break;

    	case DISP_CMD_TV_OFF:
    		ret = bsp_disp_tv_close(ubuffer[0]);
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
            }
    		break;

    	case DISP_CMD_TV_SET_MODE:
    		ret = bsp_disp_tv_set_mode(ubuffer[0], (__disp_tv_mode_t)ubuffer[1]);
    		break;

    	case DISP_CMD_TV_GET_MODE:
    		ret = bsp_disp_tv_get_mode(ubuffer[0]);
    		break;

    	case DISP_CMD_TV_AUTOCHECK_ON:
    		ret = bsp_disp_tv_auto_check_enable(ubuffer[0]);
    		break;

    	case DISP_CMD_TV_AUTOCHECK_OFF:
    		ret = bsp_disp_tv_auto_check_disable(ubuffer[0]);
    		break;

    	case DISP_CMD_TV_GET_INTERFACE:
    	    if(suspend_status != 0)
    	    {
    	        ret = DISP_TV_NONE;
    	    }
    	    else
    	    {
    		    ret = bsp_disp_tv_get_interface(ubuffer[0]);
            }
    		break;

    	case DISP_CMD_TV_SET_SRC:
    		ret = bsp_disp_tv_set_src(ubuffer[0], (__disp_lcdc_src_t)ubuffer[1]);
    		break;

        case DISP_CMD_TV_GET_DAC_STATUS:
            if(suspend_status != 0)
            {
                ret = 0;
            }
            else
            {
                ret =  bsp_disp_tv_get_dac_status(ubuffer[0], ubuffer[1]);
            }
            break;

        case DISP_CMD_TV_SET_DAC_SOURCE:
            ret =  bsp_disp_tv_set_dac_source(ubuffer[0], ubuffer[1], (__disp_tv_dac_source)ubuffer[2]);
            break;

        case DISP_CMD_TV_GET_DAC_SOURCE:
            ret =  bsp_disp_tv_get_dac_source(ubuffer[0], ubuffer[1]);
            break;

    //----hdmi----
    	case DISP_CMD_HDMI_ON:
    		ret = bsp_disp_hdmi_open(ubuffer[0]);
    		output_type = DISP_OUTPUT_TYPE_HDMI;
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_HDMI;
            }
    		break;

    	case DISP_CMD_HDMI_OFF:
    		ret = bsp_disp_hdmi_close(ubuffer[0]);
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
            }
    		break;

    	case DISP_CMD_HDMI_SET_MODE:
    		ret = bsp_disp_hdmi_set_mode(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_HDMI_GET_MODE:
    		ret = bsp_disp_hdmi_get_mode(ubuffer[0]);
    		break;

    	case DISP_CMD_HDMI_GET_HPD_STATUS:
    	    if(suspend_status != 0)
    	    {
    	        ret = 0;
    	    }
    	    else
    	    {
    	        ret = bsp_disp_hdmi_get_hpd_status(ubuffer[0]);
    	    }
    		break;

    	case DISP_CMD_HDMI_SUPPORT_MODE:
    		ret = bsp_disp_hdmi_check_support_mode(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_HDMI_SET_SRC:
    		ret = bsp_disp_hdmi_set_src(ubuffer[0], (__disp_lcdc_src_t)ubuffer[1]);
    		break;

    //----vga----
    	case DISP_CMD_VGA_ON:
    		ret = bsp_disp_vga_open(ubuffer[0]);
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_VGA;
            }
    		break;

    	case DISP_CMD_VGA_OFF:
    		ret = bsp_disp_vga_close(ubuffer[0]);
            if(suspend_status != 0)
            {
                suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
            }
    		break;

    	case DISP_CMD_VGA_SET_MODE:
    		ret = bsp_disp_vga_set_mode(ubuffer[0], (__disp_vga_mode_t)ubuffer[1]);
    		break;

    	case DISP_CMD_VGA_GET_MODE:
    		ret = bsp_disp_vga_get_mode(ubuffer[0]);
    		break;

    	case DISP_CMD_VGA_SET_SRC:
    		ret = bsp_disp_vga_set_src(ubuffer[0], (__disp_lcdc_src_t)ubuffer[1]);
    		break;

    //----sprite----
    /*
    	case DISP_CMD_SPRITE_OPEN:
    		ret = bsp_disp_sprite_open(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_CLOSE:
    		ret = bsp_disp_sprite_close(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_SET_FORMAT:
    		ret = bsp_disp_sprite_set_format(ubuffer[0], (__disp_pixel_fmt_t)ubuffer[1], (__disp_pixel_seq_t)ubuffer[2]);
    		break;

    	case DISP_CMD_SPRITE_GLOBAL_ALPHA_ENABLE:
    		ret = bsp_disp_sprite_alpha_enable(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_GLOBAL_ALPHA_DISABLE:
    		ret = bsp_disp_sprite_alpha_disable(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_ENABLE:
    		ret = bsp_disp_sprite_get_alpha_enable(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_SET_GLOBAL_ALPHA_VALUE:
    		ret = bsp_disp_sprite_set_alpha_vale(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_VALUE:
    		ret = bsp_disp_sprite_get_alpha_value(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_SET_ORDER:
    		ret = bsp_disp_sprite_set_order(ubuffer[0], ubuffer[1],ubuffer[2]);
    		break;

    	case DISP_CMD_SPRITE_GET_TOP_BLOCK:
    		ret = bsp_disp_sprite_get_top_block(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_GET_BOTTOM_BLOCK:
    		ret = bsp_disp_sprite_get_bottom_block(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_SET_PALETTE_TBL:
            if((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0))
            {
                __wrn("para invalid in display ioctrl DISP_CMD_SPRITE_SET_PALETTE_TBL,buffer:0x%x, size:0x%x\n", (unsigned int)ubuffer[1], (unsigned int)ubuffer[3]);
                return -1;
            }
    		if(copy_from_user(gbuffer, (void __user *)ubuffer[1],ubuffer[3]))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
    		ret =  bsp_disp_sprite_set_palette_table(ubuffer[0], (__u32 * )gbuffer,ubuffer[2],ubuffer[3]);
    		break;

    	case DISP_CMD_SPRITE_GET_BLOCK_NUM:
    		ret = bsp_disp_sprite_get_block_number(ubuffer[0]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_REQUEST:
    	{
    	    __disp_sprite_block_para_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_sprite_block_para_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
    		ret = bsp_disp_sprite_block_request(ubuffer[0], &para);
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_RELEASE:
    		ret = bsp_disp_sprite_block_release(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_SET_SCREEN_WINDOW:
    	{
    	    __disp_rect_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
    		ret = bsp_disp_sprite_block_set_screen_win(ubuffer[0], ubuffer[1],&para);
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_GET_SCREEN_WINDOW:
    	{
    	    __disp_rect_t para;

    		ret = bsp_disp_sprite_block_get_srceen_win(ubuffer[0], ubuffer[1],&para);
    		if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_SET_SOURCE_WINDOW:
    	{
    	    __disp_rect_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
    		ret = bsp_disp_sprite_block_set_src_win(ubuffer[0], ubuffer[1],&para);
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_GET_SOURCE_WINDOW:
    	{
    	    __disp_rect_t para;

    		ret = bsp_disp_sprite_block_get_src_win(ubuffer[0], ubuffer[1],&para);
    		if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_rect_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_SET_FB:
    	{
    	    __disp_fb_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_fb_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
    		ret = bsp_disp_sprite_block_set_framebuffer(ubuffer[0], ubuffer[1],&para);
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_GET_FB:
    	{
    	    __disp_fb_t para;

    		ret = bsp_disp_sprite_block_get_framebufer(ubuffer[0], ubuffer[1],&para);
    		if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_fb_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_SET_TOP:
    		ret = bsp_disp_sprite_block_set_top(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_SET_BOTTOM:
    		ret = bsp_disp_sprite_block_set_bottom(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_GET_PREV_BLOCK:
    		ret = bsp_disp_sprite_block_get_pre_block(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_GET_NEXT_BLOCK:
    		ret = bsp_disp_sprite_block_get_next_block(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_GET_PRIO:
    		ret = bsp_disp_sprite_block_get_prio(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_OPEN:
    		ret = bsp_disp_sprite_block_open(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_CLOSE:
    		ret = bsp_disp_sprite_block_close(ubuffer[0], ubuffer[1]);
    		break;

    	case DISP_CMD_SPRITE_BLOCK_SET_PARA:
    	{
    	    __disp_sprite_block_para_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[2],sizeof(__disp_sprite_block_para_t)))
    		{
    		    __wrn("copy_from_user fail\n");
    			return  -EFAULT;
    		}
    		ret = bsp_disp_sprite_block_set_para(ubuffer[0], ubuffer[1],&para);
    		break;
        }

    	case DISP_CMD_SPRITE_BLOCK_GET_PARA:
    	{
    	    __disp_sprite_block_para_t para;

    		ret = bsp_disp_sprite_block_get_para(ubuffer[0], ubuffer[1],&para);
    		if(copy_to_user((void __user *)ubuffer[2],&para, sizeof(__disp_sprite_block_para_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
    		break;
        }
        */
#ifdef __LINUX_OSAL__
	//----framebuffer----
    	case DISP_CMD_FB_REQUEST:
    	{
    	    __disp_fb_create_para_t para;

    		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(__disp_fb_create_para_t)))
    		{
    		    __wrn("copy_from_user fail %d \n",__LINE__);
    			return  -EFAULT;
    		}
			ret = Display_Fb_Request(ubuffer[0], &para);
			break;
        }

		case DISP_CMD_FB_RELEASE:
			ret = Display_Fb_Release(ubuffer[0]);
			break;

	    case DISP_CMD_FB_GET_PARA:
	    {
    	    __disp_fb_create_para_t para;

			ret = Display_Fb_get_para(ubuffer[0], &para);
    		if(copy_to_user((void __user *)ubuffer[1],&para, sizeof(__disp_fb_create_para_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
			break;
        }

	    case DISP_CMD_GET_DISP_INIT_PARA:
	    {
    	    __disp_init_t para;

			ret = Display_get_disp_init_para(&para);
    		if(copy_to_user((void __user *)ubuffer[0],&para, sizeof(__disp_init_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
			break;
        }
//----for test----
		case DISP_CMD_MEM_REQUEST:
			ret =  disp_mem_request(ubuffer[0]);
			break;


		case DISP_CMD_MEM_RELASE:
			ret =  disp_mem_release(ubuffer[0]);
			break;

		case DISP_CMD_MEM_SELIDX:
			g_disp_mm_sel = ubuffer[0];
			break;

		case DISP_CMD_MEM_GETADR:
			ret = g_disp_mm[ubuffer[0]].mem_start;
			break;

		case DISP_CMD_MEM_GET_INFO:
		{
    	    __disp_mm_t para;

			ret = disp_mem_get_info(ubuffer[0], &para);
    		if(copy_to_user((void __user *)ubuffer[1],&para, sizeof(__disp_mm_t)))
    		{
    		    __wrn("copy_to_user fail\n");
    			return  -EFAULT;
    		}
			break;
        }
		case DISP_CMD_SUSPEND:
		{
		    pm_message_t state;

			ret = disp_suspend(0, state);
			break;
        }

		case DISP_CMD_RESUME:
			ret = disp_resume(0);
			break;
#endif
		case DISP_CMD_SET_EXIT_MODE:
	    	ret =  g_disp_drv.exit_mode = ubuffer[0];
			break;

		case DISP_CMD_LCD_CHECK_OPEN_FINISH:
			ret = DRV_lcd_check_open_finished(ubuffer[0]);
			break;

		case DISP_CMD_LCD_CHECK_CLOSE_FINISH:
			ret = DRV_lcd_check_close_finished(ubuffer[0]);
			break;

        case DISP_CMD_PRINT_REG:
            ret = bsp_disp_print_reg(1, ubuffer[0]);
            break;

		default:
		    break;
    }

	return ret;
}
Esempio n. 3
0
long disp_ioctl(void *hd, unsigned int cmd, void *arg)
{
	unsigned long karg[4];
	unsigned long ubuffer[4] = {0};
	s32 ret = 0;
	int num_screens = 2;

	num_screens = bsp_disp_feat_get_num_screens();

	if (copy_from_user((void*)karg,(void*)arg, 4*sizeof(unsigned long))) {
		__wrn("copy_from_user fail\n");
		return -1;
	}

	ubuffer[0] = *(unsigned long*)karg;
	ubuffer[1] = (*(unsigned long*)(karg+1));
	ubuffer[2] = (*(unsigned long*)(karg+2));
	ubuffer[3] = (*(unsigned long*)(karg+3));

	if(cmd < DISP_CMD_FB_REQUEST)	{
		if(ubuffer[0] >= num_screens) {
			__wrn("para err in disp_ioctl, cmd = 0x%x,screen id = %d\n", cmd, (int)ubuffer[0]);
			return -1;
		}
	}
	if(DISPLAY_DEEP_SLEEP == suspend_status) {
		__wrn("ioctl:%x fail when in suspend!\n", cmd);
		return -1;
	}

	if(cmd == disp_cmd_print) {
//		OSAL_PRINTF("cmd:0x%x,%ld,%ld\n",cmd, ubuffer[0], ubuffer[1]);
	}

	switch(cmd)	{
	//----disp global----
	case DISP_CMD_SET_BKCOLOR:
	{
		disp_color_info para;

		if(copy_from_user(&para, (void*)ubuffer[1],sizeof(disp_color_info)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = bsp_disp_set_back_color(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_GET_OUTPUT_TYPE:
		if(DISPLAY_NORMAL == suspend_status)	{
			ret =  bsp_disp_get_output_type(ubuffer[0]);
		}	else {
			ret = suspend_output_type[ubuffer[0]];
		}
		if(DISP_OUTPUT_TYPE_LCD == ret) {
			ret = bsp_disp_get_lcd_output_type(ubuffer[0]);
		}

		break;

	case DISP_CMD_GET_SCN_WIDTH:
		ret = bsp_disp_get_screen_width(ubuffer[0]);
		break;

	case DISP_CMD_GET_SCN_HEIGHT:
		ret = bsp_disp_get_screen_height(ubuffer[0]);
		break;

	case DISP_CMD_SHADOW_PROTECT:
		ret = bsp_disp_shadow_protect(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_VSYNC_EVENT_EN:
		ret = bsp_disp_vsync_event_enable(ubuffer[0], ubuffer[1]);
		break;

	//----layer----
	case DISP_CMD_LAYER_ENABLE:
		ret = bsp_disp_layer_enable(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_DISABLE:
		ret = bsp_disp_layer_disable(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LAYER_SET_INFO:
	{
		disp_layer_info para;

		if(copy_from_user(&para, (void*)ubuffer[2],sizeof(disp_layer_info))) {
			return  -1;
		}
		ret = bsp_disp_layer_set_info(ubuffer[0], ubuffer[1], &para);

		break;
	}

	case DISP_CMD_LAYER_GET_INFO:
	{
		disp_layer_info para;

		ret = bsp_disp_layer_get_info(ubuffer[0], ubuffer[1], &para);
		if(copy_to_user((void*)ubuffer[2],&para, sizeof(disp_layer_info))) {
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

	case DISP_CMD_LAYER_GET_FRAME_ID:
		ret = bsp_disp_layer_get_frame_id(ubuffer[0], ubuffer[1]);
		break;

	//----lcd----
	case DISP_CMD_LCD_ENABLE:
		ret = drv_lcd_enable(ubuffer[0]);
		suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_LCD;

		break;

	case DISP_CMD_LCD_DISABLE:
		ret = drv_lcd_disable(ubuffer[0]);
		suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
		break;

	case DISP_CMD_LCD_SET_BRIGHTNESS:
		ret = bsp_disp_lcd_set_bright(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_LCD_GET_BRIGHTNESS:
		ret = bsp_disp_lcd_get_bright(ubuffer[0]);
		break;

	case DISP_CMD_LCD_BACKLIGHT_ENABLE:
		if(DISPLAY_NORMAL == suspend_status) {
			ret = bsp_disp_lcd_backlight_enable(ubuffer[0]);
		}
		break;

	case DISP_CMD_LCD_BACKLIGHT_DISABLE:
		if(DISPLAY_NORMAL == suspend_status) {
			ret = bsp_disp_lcd_backlight_disable(ubuffer[0]);
		}
		break;

#if (defined CONFIG_ARCH_SUN9IW1P1)
	//----hdmi----
	case DISP_CMD_HDMI_ENABLE:
		ret = bsp_disp_hdmi_enable(ubuffer[0]);
		suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_HDMI;
		break;

	case DISP_CMD_HDMI_DISABLE:
		ret = bsp_disp_hdmi_disable(ubuffer[0]);
		suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
		break;

	case DISP_CMD_HDMI_SET_MODE:
		ret = bsp_disp_hdmi_set_mode(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_HDMI_GET_MODE:
		ret = bsp_disp_hdmi_get_mode(ubuffer[0]);
		break;

        case DISP_CMD_HDMI_SUPPORT_MODE:
		ret = bsp_disp_hdmi_check_support_mode(ubuffer[0], ubuffer[1]);
		break;
	case DISP_CMD_HDMI_GET_HPD_STATUS:
		ret = bsp_disp_hdmi_get_hpd_status(ubuffer[0]);
		break;

#endif
#if 0


	case DISP_CMD_HDMI_SUPPORT_MODE:
		ret = bsp_disp_hdmi_check_support_mode(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_HDMI_SET_SRC:
		ret = bsp_disp_hdmi_set_src(ubuffer[0], (disp_lcd_src)ubuffer[1]);
		break;

	//----framebuffer----
	case DISP_CMD_FB_REQUEST:
	{
		disp_fb_create_info para;

		if(copy_from_user(&para, (void __user *)ubuffer[1],sizeof(disp_fb_create_info))) {
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = Display_Fb_Request(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_FB_RELEASE:
	ret = Display_Fb_Release(ubuffer[0]);
	break;

	case DISP_CMD_FB_GET_PARA:
	{
		disp_fb_create_info para;

		ret = Display_Fb_get_para(ubuffer[0], &para);
		if(copy_to_user((void __user *)ubuffer[1],&para, sizeof(disp_fb_create_info))) {
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

	case DISP_CMD_GET_DISP_INIT_PARA:
	{
		disp_init_para para;

		ret = Display_get_disp_init_para(&para);
		if(copy_to_user((void __user *)ubuffer[0],&para, sizeof(disp_init_para)))	{
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

#endif
		//----enhance----
		case DISP_CMD_SET_BRIGHT:
		ret = bsp_disp_smcl_set_bright(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_BRIGHT:
		ret = bsp_disp_smcl_get_bright(ubuffer[0]);
		break;

	case DISP_CMD_SET_CONTRAST:
		ret = bsp_disp_smcl_set_contrast(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_CONTRAST:
		ret = bsp_disp_smcl_get_contrast(ubuffer[0]);
		break;

	case DISP_CMD_SET_SATURATION:
		ret = bsp_disp_smcl_set_saturation(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_SATURATION:
		ret = bsp_disp_smcl_get_saturation(ubuffer[0]);
		break;

	case DISP_CMD_SET_HUE:
		ret = bsp_disp_smcl_set_hue(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_HUE:
		ret = bsp_disp_smcl_get_hue(ubuffer[0]);
		break;

	case DISP_CMD_ENHANCE_ENABLE:
		ret = bsp_disp_smcl_enable(ubuffer[0]);
		break;

	case DISP_CMD_ENHANCE_DISABLE:
		ret = bsp_disp_smcl_disable(ubuffer[0]);
		break;

	case DISP_CMD_GET_ENHANCE_EN:
		ret = bsp_disp_smcl_is_enabled(ubuffer[0]);
		break;

	case DISP_CMD_SET_ENHANCE_MODE:
		ret = bsp_disp_smcl_set_mode(ubuffer[0], ubuffer[1]);
		break;

	case DISP_CMD_GET_ENHANCE_MODE:
		ret = bsp_disp_smcl_get_mode(ubuffer[0]);
		break;

	case DISP_CMD_SET_ENHANCE_WINDOW:
	{
		disp_window para;

		if(copy_from_user(&para, (void*)ubuffer[1],sizeof(disp_window))) {
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = bsp_disp_smcl_set_window(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_GET_ENHANCE_WINDOW:
	{
		disp_window para;

		ret = bsp_disp_smcl_get_window(ubuffer[0], &para);
		if(copy_to_user((void*)ubuffer[1],&para, sizeof(disp_window))) {
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

	case DISP_CMD_DRC_ENABLE:
		ret = bsp_disp_smbl_enable(ubuffer[0]);
		break;

	case DISP_CMD_DRC_DISABLE:
		ret = bsp_disp_smbl_disable(ubuffer[0]);
		break;

	case DISP_CMD_GET_DRC_EN:
		ret = bsp_disp_smbl_is_enabled(ubuffer[0]);
		break;

	case DISP_CMD_DRC_SET_WINDOW:
	{
		disp_window para;

		if(copy_from_user(&para, (void*)ubuffer[1],sizeof(disp_window))) {
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = bsp_disp_smbl_set_window(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_DRC_GET_WINDOW:
	{
		disp_window para;

		ret = bsp_disp_smbl_get_window(ubuffer[0], &para);
		if(copy_to_user((void*)ubuffer[1],&para, sizeof(disp_window))) {
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

#if defined(CONFIG_ARCH_SUN9IW1P1)
	//---- cursor ----
	case DISP_CMD_CURSOR_ENABLE:
		ret =  bsp_disp_cursor_enable(ubuffer[0]);
		break;

	case DISP_CMD_CURSOR_DISABLE:
		ret =  bsp_disp_cursor_disable(ubuffer[0]);
		break;

	case DISP_CMD_CURSOR_SET_POS:
	{
		disp_position para;

		if(copy_from_user(&para, (void*)ubuffer[1],sizeof(disp_position)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = bsp_disp_cursor_set_pos(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_CURSOR_GET_POS:
	{
		disp_position para;

		ret = bsp_disp_cursor_get_pos(ubuffer[0], &para);
		if(copy_to_user((void*)ubuffer[1],&para, sizeof(disp_position)))	{
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

	case DISP_CMD_CURSOR_SET_FB:
	{
		disp_cursor_fb para;

		if(copy_from_user(&para, (void*)ubuffer[1],sizeof(disp_cursor_fb)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = bsp_disp_cursor_set_fb(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_CURSOR_SET_PALETTE:
		if((ubuffer[1] == 0) || ((int)ubuffer[3] <= 0))	{
			__wrn("para invalid in display ioctrl DISP_CMD_HWC_SET_PALETTE_TABLE,buffer:0x%x, size:0x%x\n", (unsigned int)ubuffer[1], (unsigned int)ubuffer[3]);
			return -1;
		}
		if(copy_from_user(gbuffer, (void*)ubuffer[1],ubuffer[3]))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = bsp_disp_cursor_set_palette(ubuffer[0], (void*)gbuffer, ubuffer[2], ubuffer[3]);
		break;
#if 0
	//----for test----
	case DISP_CMD_MEM_REQUEST:
		ret =  disp_mem_request(ubuffer[0],ubuffer[1]);
		break;

	case DISP_CMD_MEM_RELEASE:
		ret =  disp_mem_release(ubuffer[0]);
		break;

	case DISP_CMD_MEM_SELIDX:
		g_disp_mm_sel = ubuffer[0];
		break;

	case DISP_CMD_MEM_GETADR:
		ret = g_disp_mm[ubuffer[0]].mem_start;
		break;

//	case DISP_CMD_PRINT_REG:
//		ret = bsp_disp_print_reg(1, ubuffer[0], 0);
//		break;
#endif
#endif

	case DISP_CMD_SET_EXIT_MODE:
        ret = g_disp_drv.exit_mode = ubuffer[0];
		break;

	case DISP_CMD_LCD_CHECK_OPEN_FINISH:
		ret = drv_lcd_check_open_finished(ubuffer[0]);
		break;

	case DISP_CMD_LCD_CHECK_CLOSE_FINISH:
		ret = drv_lcd_check_close_finished(ubuffer[0]);
		break;

#if defined(CONFIG_ARCH_TV)
	//----for tv ----
	case DISP_CMD_TV_ON:
#if defined(CONFIG_ARCH_SUN9IW1P1)
		ret = drv_lcd_enable(ubuffer[0]);
		suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_LCD;
#endif
		break;
	case DISP_CMD_TV_OFF:
#if defined(CONFIG_ARCH_SUN9IW1P1)
		ret = drv_lcd_disable(ubuffer[0]);
		suspend_output_type[ubuffer[0]] = DISP_OUTPUT_TYPE_NONE;
#endif
		break;
	case DISP_CMD_TV_GET_MODE:
#if defined(CONFIG_ARCH_SUN9IW1P1)
		ret = bsp_disp_lcd_get_tv_mode(ubuffer[0]);
#endif
		break;
	case DISP_CMD_TV_SET_MODE:
#if defined(CONFIG_ARCH_SUN9IW1P1)
		ret = bsp_disp_lcd_set_tv_mode(ubuffer[0], ubuffer[1]);
#endif
		break;
#endif //#if defined(CONFIG_ARCH_TV)

	default:
		break;
	}

  return ret;
}
Esempio n. 4
0
long disp_ioctl(void *hd, unsigned int cmd, void *arg)
{
	unsigned long karg[4];
	unsigned long ubuffer[4] = {0};
	s32 ret = 0;
	int num_screens = 2;
	struct disp_manager *mgr = NULL;
	struct disp_device *dispdev = NULL;
	struct disp_enhance *enhance = NULL;
	struct disp_smbl *smbl = NULL;
	struct disp_capture *cptr = NULL;

	num_screens = bsp_disp_feat_get_num_screens();

	if (copy_from_user((void*)karg,(void*)arg, 4*sizeof(unsigned long))) {
		__wrn("copy_from_user fail\n");
		return -1;
	}

	ubuffer[0] = *(unsigned long*)karg;
	ubuffer[1] = (*(unsigned long*)(karg+1));
	ubuffer[2] = (*(unsigned long*)(karg+2));
	ubuffer[3] = (*(unsigned long*)(karg+3));

	if(ubuffer[0] < num_screens)
		mgr = g_disp_drv.mgr[ubuffer[0]];
	if(mgr) {
		dispdev = mgr->device;
		enhance = mgr->enhance;
		smbl = mgr->smbl;
		cptr = mgr->cptr;
	}

	if(cmd < DISP_FB_REQUEST)	{
		if(ubuffer[0] >= num_screens) {
			__wrn("para err in disp_ioctl, cmd = 0x%x,screen id = %d\n", cmd, (int)ubuffer[0]);
			return -1;
		}
	}
	if(DISPLAY_DEEP_SLEEP == suspend_status) {
		__wrn("ioctl:%x fail when in suspend!\n", cmd);
		return -1;
	}

	if(cmd == disp_cmd_print) {
		//__wrn("cmd:0x%x,%ld,%ld\n",cmd, ubuffer[0], ubuffer[1]);
	}

	switch(cmd)	{
	//----disp global----
	case DISP_SET_BKCOLOR:
	{
		disp_color para;

		if(copy_from_user(&para, (void*)ubuffer[1],sizeof(disp_color)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		if(mgr && (mgr->set_back_color != NULL))
			ret = mgr->set_back_color(mgr, &para);
		break;
	}

	case DISP_GET_OUTPUT_TYPE:
	{
		if(mgr && mgr->device)
			ret = mgr->device->type;
		break;
	}

	case DISP_GET_SCN_WIDTH:
	{
		unsigned int width = 0,height = 0;
		if(mgr && mgr->device && mgr->device->get_resolution) {
			mgr->device->get_resolution(mgr->device, &width, &height);
		}
		ret = width;
		break;
	}

	case DISP_GET_SCN_HEIGHT:
	{
		unsigned int width = 0,height = 0;
		if(mgr && mgr->device && mgr->device->get_resolution) {
			mgr->device->get_resolution(mgr->device, &width, &height);
		}
		ret = height;
		break;
	}

	case DISP_VSYNC_EVENT_EN:
	{
		ret = bsp_disp_vsync_event_enable(ubuffer[0], ubuffer[1]);
		break;
	}

	case DISP_SHADOW_PROTECT:
	{
		ret = bsp_disp_shadow_protect(ubuffer[0], ubuffer[1]);
		break;
	}

	case DISP_BLANK:
	{
		if(ubuffer[1]) {
			if(dispdev && dispdev->disable)
				ret = dispdev->disable(dispdev);
		} else {
			if(dispdev && dispdev->enable)
				ret = dispdev->enable(dispdev);
		}
		break;
	}

	case DISP_DEVICE_SWITCH:
	{
		if(ubuffer[1] == (unsigned long)DISP_OUTPUT_TYPE_LCD)
			ret = drv_lcd_enable(ubuffer[0]);
		else
			ret = bsp_disp_device_switch(ubuffer[0], (disp_output_type)ubuffer[1], (disp_tv_mode)ubuffer[2]);
		break;
	}

	//----layer----
	case DISP_LAYER_SET_CONFIG:
	{
		disp_layer_config para;

		if(copy_from_user(&para, (void *)ubuffer[1],sizeof(disp_layer_config)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		if(mgr && mgr->set_layer_config)
			ret = mgr->set_layer_config(mgr, &para, ubuffer[2]);
		break;
	}

	case DISP_LAYER_GET_CONFIG:
	{
		disp_layer_config para;

		if(copy_from_user(&para, (void *)ubuffer[1],sizeof(disp_layer_config)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		if(mgr && mgr->get_layer_config)
			ret = mgr->get_layer_config(mgr, &para, ubuffer[2]);
		if(copy_to_user(&para, (void *)ubuffer[1], sizeof(disp_layer_config)))	{
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

	//----lcd----
	case DISP_LCD_SET_BRIGHTNESS:
	{
		if(dispdev && (DISP_OUTPUT_TYPE_LCD == dispdev->type)) {
			ret = dispdev->set_bright(dispdev, ubuffer[1]);
		}
		break;
	}

	case DISP_LCD_GET_BRIGHTNESS:
	{
		if(dispdev && (DISP_OUTPUT_TYPE_LCD == dispdev->type)) {
			ret = dispdev->get_bright(dispdev);
		}
		break;
	}


	case DISP_HDMI_GET_HPD_STATUS:
		if(DISPLAY_NORMAL == suspend_status) {
			ret = bsp_disp_hdmi_get_hpd_status(ubuffer[0]);
		}	else {
			ret = 0;
		}
		break;

	case DISP_HDMI_SUPPORT_MODE:
		ret = bsp_disp_hdmi_check_support_mode(ubuffer[0], ubuffer[1]);
		break;

	case DISP_TV_GET_HPD_STATUS:
		if(DISPLAY_NORMAL == suspend_status) {
			ret = bsp_disp_tv_get_hpd_status(ubuffer[0]);
		}	else {
			ret = 0;
		}
		break;

	case DISP_HDMI_GET_EDID:
	{
		u8 *buf;
		u32 bytes = 1024;

		ret = 0;
		buf = (u8*)bsp_disp_hdmi_get_edid(ubuffer[0]);
		if(buf) {
			bytes = (ubuffer[2] > bytes)?bytes:ubuffer[2];
			if(copy_to_user(buf, (void *)ubuffer[1], bytes)) {
				__wrn("copy_to_user fail\n");
			} else {
				ret = bytes;
			}
		}

		break;
	}

#if 0
	case DISP_CMD_HDMI_SET_SRC:
		ret = bsp_disp_hdmi_set_src(ubuffer[0], (disp_lcd_src)ubuffer[1]);
		break;

	//----framebuffer----
	case DISP_CMD_FB_REQUEST:
	{
		disp_fb_create_info para;

		if(copy_from_user(&para, (void *)ubuffer[1],sizeof(disp_fb_create_info))) {
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		ret = Display_Fb_Request(ubuffer[0], &para);
		break;
	}

	case DISP_CMD_FB_RELEASE:
	ret = Display_Fb_Release(ubuffer[0]);
	break;

	case DISP_CMD_FB_GET_PARA:
	{
		disp_fb_create_info para;

		ret = Display_Fb_get_para(ubuffer[0], &para);
		if(copy_to_user((void *)ubuffer[1],&para, sizeof(disp_fb_create_info))) {
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

	case DISP_CMD_GET_DISP_INIT_PARA:
	{
		disp_init_para para;

		ret = Display_get_disp_init_para(&para);
		if(copy_to_user((void *)ubuffer[0],&para, sizeof(disp_init_para)))	{
			__wrn("copy_to_user fail\n");
			return  -1;
		}
		break;
	}

#endif
		//----enhance----
	case DISP_ENHANCE_ENABLE:
	{
		if(enhance && enhance->enable)
			ret = enhance->enable(enhance);
		break;
	}

	case DISP_ENHANCE_DISABLE:
	{
		if(enhance && enhance->disable)
			ret = enhance->disable(enhance);
		break;
	}

	//---smart backlight --
	case DISP_SMBL_ENABLE:
	{
		if(smbl && smbl->enable)
			ret = smbl->enable(smbl);
		break;
	}

	case DISP_SMBL_DISABLE:
	{
		if(smbl && smbl->disable)
			ret = smbl->disable(smbl);
		break;
	}

	case DISP_SMBL_SET_WINDOW:
	{
		disp_rect rect;

		if(copy_from_user(&rect, (void *)ubuffer[1],sizeof(disp_rect)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		if(smbl && smbl->set_window)
			ret = smbl->set_window(smbl, &rect);
		break;
	}

	//---capture --
	case DISP_CAPTURE_START:
	{
		if(cptr && cptr->start)
			ret = cptr->start(cptr);
		break;
	}

	case DISP_CAPTURE_STOP:
	{
		if(cptr && cptr->stop)
			ret = cptr->stop(cptr);
		break;
	}

	case DISP_CAPTURE_COMMIT:
	{
		disp_capture_info info;

		if(copy_from_user(&info, (void *)ubuffer[1],sizeof(disp_capture_info)))	{
			__wrn("copy_from_user fail\n");
			return  -1;
		}
		if(cptr && cptr->commmit)
			ret = cptr->commmit(cptr, &info);
		break;
	}

#if defined(CONFIG_ARCH_SUN9IW1P1)

#if 0
	//----for test----
	case DISP_CMD_MEM_REQUEST:
		ret =  disp_mem_request(ubuffer[0],ubuffer[1]);
		break;

	case DISP_CMD_MEM_RELEASE:
		ret =  disp_mem_release(ubuffer[0]);
		break;

	case DISP_CMD_MEM_SELIDX:
		g_disp_mm_sel = ubuffer[0];
		break;

	case DISP_CMD_MEM_GETADR:
		ret = g_disp_mm[ubuffer[0]].mem_start;
		break;

//	case DISP_CMD_PRINT_REG:
//		ret = bsp_disp_print_reg(1, ubuffer[0], 0);
//		break;
#endif
#endif

	case DISP_SET_EXIT_MODE:
        ret = g_disp_drv.exit_mode = ubuffer[0];
		break;

	case DISP_LCD_CHECK_OPEN_FINISH:
		ret = drv_lcd_check_open_finished(ubuffer[0]);
		break;

	case DISP_LCD_CHECK_CLOSE_FINISH:
		ret = drv_lcd_check_close_finished(ubuffer[0]);
		break;

	default:
		break;
	}

  return ret;
}