static int disp_resume(struct platform_device *pdev) { #ifndef CONFIG_HAS_EARLYSUSPEND int i = 0; __inf("disp_resume call\n"); BSP_disp_clk_on(3); for (i = 0; i < 2; i++) { if (suspend_output_type[i] == DISP_OUTPUT_TYPE_LCD) DRV_lcd_open(i); else if (suspend_output_type[i] == DISP_OUTPUT_TYPE_TV) BSP_disp_tv_open(i); else if (suspend_output_type[i] == DISP_OUTPUT_TYPE_VGA) BSP_disp_vga_open(i); else if (suspend_output_type[i] == DISP_OUTPUT_TYPE_HDMI) BSP_disp_hdmi_open(i); } #else BSP_disp_clk_on(1); #endif suspend_status &= (~2); return 0; }
void backlight_late_resume(struct early_suspend *h) { int i = 0; printk("display late resume enter: %s\n", __func__); BSP_disp_clk_on(2); for(i=0; i<2; i++) { if(output_type[i] == DISP_OUTPUT_TYPE_LCD) { DRV_lcd_open(i); } else if(output_type[i] == DISP_OUTPUT_TYPE_TV) { BSP_disp_tv_open(i); } else if(output_type[i] == DISP_OUTPUT_TYPE_VGA) { BSP_disp_vga_open(i); } else if(output_type[i] == DISP_OUTPUT_TYPE_HDMI) { BSP_disp_hdmi_open(i); } } suspend_status &= (~1); printk("display late resume done: %s\n", __func__); }
int disp_resume(struct platform_device *pdev) { int i = 0; __msg("disp_resume call\n"); BSP_disp_clk_on(); for(i=0; i<2; i++) { if(output_type[i] == DISP_OUTPUT_TYPE_LCD) { DRV_lcd_open(i); } else if(output_type[i] == DISP_OUTPUT_TYPE_TV) { BSP_disp_tv_open(i); } else if(output_type[i] == DISP_OUTPUT_TYPE_VGA) { BSP_disp_vga_open(i); } else if(output_type[i] == DISP_OUTPUT_TYPE_HDMI) { BSP_disp_hdmi_open(i); } } return 0; }
void backlight_late_resume(struct early_suspend *h) { int i = 0; printk("==display late resume enter\n"); BSP_disp_clk_on(2); for(i=0; i<2; i++) { if(suspend_output_type[i] == DISP_OUTPUT_TYPE_LCD) { __lcd_flow_t *flow; if(2 == suspend_prestep)//late resume from resume { flow =BSP_disp_lcd_get_open_flow(i); while(flow->cur_step != (flow->func_num-1))//open flow is finished accept the last one { __u32 timeout = 10*HZ/1000; set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(timeout); } disp_lcd_open_late(i); } else if(0 == suspend_prestep)//late resume from early suspend { DRV_lcd_open(i); } jiffies_late_resume = jiffies; //printk("==jiffies_resume:%ld, late_resume:%ld\n", jiffies_resume, jiffies_late_resume); } else if(suspend_output_type[i] == DISP_OUTPUT_TYPE_TV) { BSP_disp_tv_open(i); } else if(suspend_output_type[i] == DISP_OUTPUT_TYPE_VGA) { BSP_disp_vga_open(i); } else if(suspend_output_type[i] == DISP_OUTPUT_TYPE_HDMI) { BSP_disp_hdmi_open(i); } } suspend_status &= (~1); suspend_prestep = 3; }
int disp_resume(struct platform_device *pdev) { int i = 0; #ifndef CONFIG_HAS_EARLYSUSPEND BSP_disp_clk_on(3); for(i=0; i<2; i++) { if(suspend_output_type[i] == DISP_OUTPUT_TYPE_LCD) { DRV_lcd_open(i); } else if(suspend_output_type[i] == DISP_OUTPUT_TYPE_TV) { BSP_disp_tv_open(i); } else if(suspend_output_type[i] == DISP_OUTPUT_TYPE_VGA) { BSP_disp_vga_open(i); } else if(suspend_output_type[i] == DISP_OUTPUT_TYPE_HDMI) { BSP_disp_hdmi_open(i); } } #else BSP_disp_clk_on(1); jiffies_resume = jiffies; for(i=0; i<2; i++) { if(suspend_output_type[i] == DISP_OUTPUT_TYPE_LCD) { disp_lcd_open_flow_init_status(i); disp_lcd_open_timer(i);//start lcd open flow } } #endif suspend_status &= (~2); suspend_prestep = 2; return 0; }
static ssize_t disp_lcd_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int err; unsigned long val; err = strict_strtoul(buf, 10, &val); if (err) { printk("Invalid size\n"); return err; } if((val==0)) { DRV_lcd_close(sel); }else { bsp_disp_hdmi_close(sel); DRV_lcd_open(sel); } return count; }
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(¶, (void __user *)ubuffer[1], sizeof(__disp_color_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = BSP_disp_set_bk_color(ubuffer[0], ¶); break; } case DISP_CMD_SET_COLORKEY: { __disp_colorkey_t para; if (copy_from_user(¶, (void __user *)ubuffer[1], sizeof(__disp_colorkey_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = BSP_disp_set_color_key(ubuffer[0], ¶); 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(¶, (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, ¶); break; } case DISP_CMD_DRC_SET_WINDOW: { __disp_rect_t para; if (copy_from_user(¶, (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, ¶); 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(¶, (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], ¶); //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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); //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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); //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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); //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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (void __user *)ubuffer[2], sizeof(__disp_scaler_para_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = BSP_disp_scaler_start(ubuffer[1], ¶); 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(¶, (void __user *)ubuffer[1], sizeof(__disp_pos_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = BSP_disp_hwc_set_pos(ubuffer[0], ¶); break; } case DISP_CMD_HWC_GET_POS: { __disp_pos_t para; ret = BSP_disp_hwc_get_pos(ubuffer[0], ¶); if (copy_to_user((void __user *)ubuffer[1], ¶, 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(¶, (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], ¶); 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(¶, (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], ¶); 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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); 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(¶, (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], ¶); 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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); 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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); break; } case DISP_CMD_SPRITE_BLOCK_GET_FB: { __disp_fb_t para; ret = BSP_disp_sprite_block_get_framebufer(ubuffer[0], ubuffer[1], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); 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], ¶); if (copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (void __user *)ubuffer[1], sizeof(__disp_fb_create_para_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = Display_Fb_Request(ubuffer[0], ¶); 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], ¶); if (copy_to_user((void __user *)ubuffer[1], ¶, 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(¶); if (copy_to_user((void __user *)ubuffer[0], ¶, 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; }
__s32 Fb_Init(__u32 from) { __s32 i; __bool need_open_hdmi = 0; __disp_fb_create_para_t fb_para = { .primary_screen_id = 0, }; __inf("Fb_Init:%d\n", from); if (from == 0) { /* call from lcd driver */ #ifdef CONFIG_FB_SUNXI_RESERVED_MEM __inf("fbmem: fb_start=%lu, fb_size=%lu\n", fb_start, fb_size); disp_create_heap((unsigned long)(__va(fb_start)), fb_size); #endif for (i = 0; i < SUNXI_MAX_FB; i++) { g_fbi.fbinfo[i] = framebuffer_alloc(0, g_fbi.dev); g_fbi.fbinfo[i]->fbops = &dispfb_ops; g_fbi.fbinfo[i]->flags = 0; g_fbi.fbinfo[i]->device = g_fbi.dev; g_fbi.fbinfo[i]->par = &g_fbi; g_fbi.fbinfo[i]->var.xoffset = 0; g_fbi.fbinfo[i]->var.yoffset = 0; g_fbi.fbinfo[i]->var.xres = 800; g_fbi.fbinfo[i]->var.yres = 480; g_fbi.fbinfo[i]->var.xres_virtual = 800; g_fbi.fbinfo[i]->var.yres_virtual = 480 * 2; g_fbi.fbinfo[i]->var.nonstd = 0; g_fbi.fbinfo[i]->var.grayscale = 0; g_fbi.fbinfo[i]->var.bits_per_pixel = 32; g_fbi.fbinfo[i]->var.transp.length = 8; g_fbi.fbinfo[i]->var.red.length = 8; g_fbi.fbinfo[i]->var.green.length = 8; g_fbi.fbinfo[i]->var.blue.length = 8; g_fbi.fbinfo[i]->var.transp.offset = 24; g_fbi.fbinfo[i]->var.red.offset = 16; g_fbi.fbinfo[i]->var.green.offset = 8; g_fbi.fbinfo[i]->var.blue.offset = 0; g_fbi.fbinfo[i]->var.activate = FB_ACTIVATE_FORCE; g_fbi.fbinfo[i]->fix.type = FB_TYPE_PACKED_PIXELS; g_fbi.fbinfo[i]->fix.type_aux = 0; g_fbi.fbinfo[i]->fix.visual = FB_VISUAL_TRUECOLOR; g_fbi.fbinfo[i]->fix.xpanstep = 1; g_fbi.fbinfo[i]->fix.ypanstep = 1; g_fbi.fbinfo[i]->fix.ywrapstep = 0; g_fbi.fbinfo[i]->fix.accel = FB_ACCEL_NONE; g_fbi.fbinfo[i]->fix.line_length = g_fbi.fbinfo[i]->var.xres_virtual * 4; g_fbi.fbinfo[i]->fix.smem_len = g_fbi.fbinfo[i]->fix.line_length * g_fbi.fbinfo[i]->var.yres_virtual * 2; g_fbi.fbinfo[i]->screen_base = NULL; g_fbi.fbinfo[i]->pseudo_palette = g_fbi.pseudo_palette[i]; g_fbi.fbinfo[i]->fix.smem_start = 0x0; g_fbi.fbinfo[i]->fix.mmio_start = 0; g_fbi.fbinfo[i]->fix.mmio_len = 0; if (fb_alloc_cmap(&g_fbi.fbinfo[i]->cmap, 256, 1) < 0) return -ENOMEM; } parser_disp_init_para(&(g_fbi.disp_init)); } if (g_fbi.disp_init.b_init) { __u32 sel = 0; for (sel = 0; sel < 2; sel++) { if (((sel == 0) && (g_fbi.disp_init.disp_mode != DISP_INIT_MODE_SCREEN1)) || ((sel == 1) && (g_fbi.disp_init.disp_mode != DISP_INIT_MODE_SCREEN0))) { if (g_fbi.disp_init.output_type[sel] == DISP_OUTPUT_TYPE_HDMI) need_open_hdmi = 1; } } } if (need_open_hdmi == 1 && from == 0) /* it is called from lcd driver, but hdmi need to be opened */ return 0; else if (need_open_hdmi == 0 && from == 1) /* it is called from hdmi driver, but hdmi need not be opened */ return 0; if (g_fbi.disp_init.b_init) { __u32 fb_num = 0, sel = 0; for (sel = 0; sel < 2; sel++) { if (((sel == 0) && (g_fbi.disp_init.disp_mode != DISP_INIT_MODE_SCREEN1)) || ((sel == 1) && (g_fbi.disp_init.disp_mode != DISP_INIT_MODE_SCREEN0))) { if (g_fbi.disp_init.output_type[sel] == DISP_OUTPUT_TYPE_LCD) { DRV_lcd_open(sel); } else if (g_fbi.disp_init.output_type[sel] == DISP_OUTPUT_TYPE_TV) { BSP_disp_tv_set_mode(sel, g_fbi.disp_init. tv_mode[sel]); BSP_disp_tv_open(sel); } else if (g_fbi.disp_init.output_type[sel] == DISP_OUTPUT_TYPE_HDMI) { BSP_disp_hdmi_set_mode(sel, g_fbi.disp_init. tv_mode[sel]); BSP_disp_hdmi_open(sel); } else if (g_fbi.disp_init.output_type[sel] == DISP_OUTPUT_TYPE_VGA) { BSP_disp_vga_set_mode(sel, g_fbi.disp_init. vga_mode[sel]); BSP_disp_vga_open(sel); } } } fb_num = (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_TWO_DIFF_SCREEN) ? 2 : 1; for (i = 0; i < fb_num; i++) { __u32 screen_id = i; disp_fb_to_var(g_fbi.disp_init.format[i], g_fbi.disp_init.seq[i], g_fbi.disp_init.br_swap[i], &(g_fbi.fbinfo[i]->var)); if (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_SCREEN1) screen_id = 1; fb_para.buffer_num = g_fbi.disp_init.buffer_num[i]; fb_para.width = BSP_disp_get_screen_width(screen_id); fb_para.height = BSP_disp_get_screen_height(screen_id); fb_para.output_width = BSP_disp_get_screen_width(screen_id); fb_para.output_height = BSP_disp_get_screen_height(screen_id); fb_para.mode = (g_fbi.disp_init.scaler_mode[i] == 0) ? DISP_LAYER_WORK_MODE_NORMAL : DISP_LAYER_WORK_MODE_SCALER; if (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_SCREEN0) { fb_para.fb_mode = FB_MODE_SCREEN0; } else if (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_SCREEN1) { fb_para.fb_mode = FB_MODE_SCREEN1; } else if (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_TWO_DIFF_SCREEN) { if (i == 0) fb_para.fb_mode = FB_MODE_SCREEN0; else fb_para.fb_mode = FB_MODE_SCREEN1; } else if (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_TWO_SAME_SCREEN) { fb_para.fb_mode = FB_MODE_DUAL_SAME_SCREEN_TB; fb_para.height *= 2; fb_para.output_height *= 2; } else if (g_fbi.disp_init.disp_mode == DISP_INIT_MODE_TWO_DIFF_SCREEN_SAME_CONTENTS) { fb_para.fb_mode = FB_MODE_DUAL_DIFF_SCREEN_SAME_CONTENTS; fb_para.output_width = BSP_disp_get_screen_width(fb_para. primary_screen_id); fb_para.output_height = BSP_disp_get_screen_height(fb_para. primary_screen_id); fb_para.aux_output_width = BSP_disp_get_screen_width(1 - fb_para. primary_screen_id); fb_para.aux_output_height = BSP_disp_get_screen_height(1 - fb_para. primary_screen_id); } Display_Fb_Request(i, &fb_para); #if 0 fb_draw_colorbar((__u32)g_fbi.fbinfo[i]->screen_base, fb_para.width, fb_para.height * fb_para.buffer_num, &(g_fbi.fbinfo[i]->var)); #endif } for (i = 0; i < SUNXI_MAX_FB; i++) /* Register framebuffers after they are initialized */ register_framebuffer(g_fbi.fbinfo[i]); if (g_fbi.disp_init.scaler_mode[0]) BSP_disp_print_reg(0, DISP_REG_SCALER0); if (g_fbi.disp_init.scaler_mode[1]) BSP_disp_print_reg(0, DISP_REG_SCALER1); if (g_fbi.disp_init.disp_mode != DISP_INIT_MODE_SCREEN1) { BSP_disp_print_reg(0, DISP_REG_IMAGE0); BSP_disp_print_reg(0, DISP_REG_LCDC0); if ((g_fbi.disp_init.output_type[0] == DISP_OUTPUT_TYPE_TV) || (g_fbi.disp_init.output_type[0] == DISP_OUTPUT_TYPE_VGA)) BSP_disp_print_reg(0, DISP_REG_TVEC0); } if (g_fbi.disp_init.disp_mode != DISP_INIT_MODE_SCREEN0) { BSP_disp_print_reg(0, DISP_REG_IMAGE1); BSP_disp_print_reg(0, DISP_REG_LCDC1); if ((g_fbi.disp_init.output_type[1] == DISP_OUTPUT_TYPE_TV) || (g_fbi.disp_init.output_type[1] == DISP_OUTPUT_TYPE_VGA)) BSP_disp_print_reg(0, DISP_REG_TVEC1); } BSP_disp_print_reg(0, DISP_REG_CCMU); BSP_disp_print_reg(0, DISP_REG_PWM); BSP_disp_print_reg(0, DISP_REG_PIOC); } __inf("Fb_Init: END\n"); return 0; } EXPORT_SYMBOL(Fb_Init); __s32 Fb_Exit(void) { __u8 fb_id = 0; for (fb_id = 0; fb_id < SUNXI_MAX_FB; fb_id++) { if (g_fbi.fbinfo[fb_id] == NULL) continue; Display_Fb_Release(fb_id); unregister_framebuffer(g_fbi.fbinfo[fb_id]); framebuffer_release(g_fbi.fbinfo[fb_id]); g_fbi.fbinfo[fb_id] = NULL; } return 0; }
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(¶, (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], ¶); break; } case DISP_CMD_SET_COLORKEY: { __disp_colorkey_t para; if(copy_from_user(¶, (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], ¶); 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(¶, (void __user *)ubuffer[1],sizeof(__disp_rect_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = bsp_disp_cmu_set_window(ubuffer[0], ¶); break; } case DISP_CMD_GET_ENHANCE_WINDOW: { __disp_rect_t para; ret = bsp_disp_cmu_get_window(ubuffer[0], ¶); if(copy_to_user((void __user *)ubuffer[1],¶, 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(¶, (void __user *)ubuffer[1],sizeof(__disp_rect_t))) { __wrn("copy_from_user fail\n"); return -EFAULT; } ret = bsp_disp_drc_set_window(ubuffer[0], ¶); break; } case DISP_CMD_DRC_GET_WINDOW: { __disp_rect_t para; ret = bsp_disp_drc_get_window(ubuffer[0], ¶); if(copy_to_user((void __user *)ubuffer[1], ¶,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(¶, (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], ¶); //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], ¶); if(copy_to_user((void __user *)ubuffer[2], ¶,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(¶, (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], ¶); //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], ¶); if(copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); //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], ¶); if(copy_to_user((void __user *)ubuffer[2], ¶, 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(¶, (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], ¶); //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], ¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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], ¶); break; } case DISP_CMD_LAYER_GET_ENHANCE_WINDOW: { __disp_rect_t para; ret = bsp_disp_cmu_layer_get_window(ubuffer[0], ubuffer[1], ¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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], ¶); break; } case DISP_CMD_LAYER_VPP_GET_WINDOW: { __disp_rect_t para; ret = bsp_disp_deu_get_window(ubuffer[0], ubuffer[1], ¶); if(copy_to_user((void __user *)ubuffer[2], ¶,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(¶, (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],¶); break; } case DISP_CMD_SCALER_EXECUTE_EX: { __disp_scaler_para_t para; if(copy_from_user(¶, (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],¶); 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(¶, (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], ¶); break; } case DISP_CMD_HWC_GET_POS: { __disp_pos_t para; ret = bsp_disp_hwc_get_pos(ubuffer[0], ¶); if(copy_to_user((void __user *)ubuffer[1],¶, 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(¶, (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], ¶); 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(¶, (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], ¶); 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],¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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], ¶); 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(¶, (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],¶); 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],¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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],¶); 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],¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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],¶); break; } case DISP_CMD_SPRITE_BLOCK_GET_FB: { __disp_fb_t para; ret = bsp_disp_sprite_block_get_framebufer(ubuffer[0], ubuffer[1],¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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],¶); 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],¶); if(copy_to_user((void __user *)ubuffer[2],¶, 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(¶, (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], ¶); 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], ¶); if(copy_to_user((void __user *)ubuffer[1],¶, 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(¶); if(copy_to_user((void __user *)ubuffer[0],¶, 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], ¶); if(copy_to_user((void __user *)ubuffer[1],¶, 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; }
__s32 drv_disp_init(void) { __disp_bsp_init_para para; sunxi_pwm_init(); debug("====display init =====\n"); memset(¶, 0, sizeof(__disp_bsp_init_para)); #if (!defined CONFIG_ARCH_SUN7IW1P1) para.reg_base[DISP_MOD_BE0] = SUNXI_DE_BE0_BASE; para.reg_size[DISP_MOD_BE0] = 0x9fc; para.reg_base[DISP_MOD_BE1] = SUNXI_DE_BE1_BASE; para.reg_size[DISP_MOD_BE1] = 0x9fc; para.reg_base[DISP_MOD_FE0] = SUNXI_DE_FE0_BASE; para.reg_size[DISP_MOD_FE0] = 0x22c; para.reg_base[DISP_MOD_FE1] = SUNXI_DE_FE1_BASE; para.reg_size[DISP_MOD_FE1] = 0x22c; para.reg_base[DISP_MOD_LCD0] = SUNXI_LCD0_BASE; para.reg_size[DISP_MOD_LCD0] = 0x3fc; para.reg_base[DISP_MOD_LCD1] = SUNXI_LCD1_BASE; para.reg_size[DISP_MOD_LCD1] = 0x3fc; para.reg_base[DISP_MOD_CCMU] = SUNXI_CCM_BASE; para.reg_size[DISP_MOD_CCMU] = 0x2dc; para.reg_base[DISP_MOD_PIOC] = SUNXI_PIO_BASE; para.reg_size[DISP_MOD_PIOC] = 0x27c; para.reg_base[DISP_MOD_PWM] = SUNXI_PWM_BASE; para.reg_size[DISP_MOD_PWM] = 0x3c; para.reg_base[DISP_MOD_DEU0] = SUNXI_DE_DEU0_BASE; para.reg_size[DISP_MOD_DEU0] = 0x60; para.reg_base[DISP_MOD_DEU1] = SUNXI_DE_DEU1_BASE; para.reg_size[DISP_MOD_DEU1] = 0x60; para.reg_base[DISP_MOD_CMU0] = SUNXI_DE_BE0_BASE; para.reg_size[DISP_MOD_CMU0] = 0xfc; para.reg_base[DISP_MOD_CMU1] = SUNXI_DE_BE1_BASE; para.reg_size[DISP_MOD_CMU1] = 0xfc; para.reg_base[DISP_MOD_DRC0] = SUNXI_DE_DRC0_BASE; para.reg_size[DISP_MOD_DRC0] = 0xfc; para.reg_base[DISP_MOD_DRC1] = SUNXI_DE_DRC1_BASE; para.reg_size[DISP_MOD_DRC1] = 0xfc; para.reg_base[DISP_MOD_DSI0] = SUNXI_MIPI_DSI0_BASE; para.reg_size[DISP_MOD_DSI0] = 0x2fc; para.reg_base[DISP_MOD_DSI0_DPHY] = SUNXI_MIPI_DSI0_DPHY_BASE; para.reg_size[DISP_MOD_DSI0_DPHY] = 0xfc; para.reg_base[DISP_MOD_HDMI] = SUNXI_HDMI_BASE; para.reg_size[DISP_MOD_HDMI] = 0x58c; para.irq[DISP_MOD_BE0] = AW_IRQ_DEBE0; para.irq[DISP_MOD_BE1] = AW_IRQ_DEBE1; para.irq[DISP_MOD_FE0] = AW_IRQ_DEFE0; para.irq[DISP_MOD_FE1] = AW_IRQ_DEFE1; para.irq[DISP_MOD_DRC0] = AW_IRQ_DRC01; para.irq[DISP_MOD_DRC1] = AW_IRQ_DEU01; para.irq[DISP_MOD_LCD0] = AW_IRQ_LCD0; para.irq[DISP_MOD_LCD1] = AW_IRQ_LCD1; para.irq[DISP_MOD_DSI0] = AW_IRQ_MIPIDSI; #else para.reg_base[DISP_MOD_BE0] = SUNXI_DE_BE0_BASE; para.reg_size[DISP_MOD_BE0] = 0x5ff; para.reg_base[DISP_MOD_BE1] = SUNXI_DE_BE1_BASE; para.reg_size[DISP_MOD_BE1] = 0x5ff; para.reg_base[DISP_MOD_FE0] = SUNXI_DE_FE0_BASE; para.reg_size[DISP_MOD_FE0] = 0xa18; para.reg_base[DISP_MOD_FE1] = SUNXI_DE_FE1_BASE; para.reg_size[DISP_MOD_FE1] = 0xa18; para.reg_base[DISP_MOD_LCD0] = SUNXI_LCD0_BASE; para.reg_size[DISP_MOD_LCD0] = 0x800; para.reg_base[DISP_MOD_LCD1] = SUNXI_LCD1_BASE; para.reg_size[DISP_MOD_LCD1] = 0x800; para.reg_base[DISP_MOD_CCMU] = SUNXI_CCM_BASE; para.reg_size[DISP_MOD_CCMU] = 0x2dc; para.reg_base[DISP_MOD_PIOC] = SUNXI_PIO_BASE; para.reg_size[DISP_MOD_PIOC] = 0x27c; para.reg_base[DISP_MOD_PWM] = SUNXI_PWM_BASE; para.reg_size[DISP_MOD_PWM] = 0x3c; para.reg_base[DISP_MOD_HDMI] = SUNXI_HDMI_BASE; para.reg_size[DISP_MOD_HDMI] = 0x580; para.reg_base[DISP_MOD_TVE0] = SUNXI_TVE0_BASE; para.reg_size[DISP_MOD_TVE0] = 0x20c; para.irq[DISP_MOD_BE0] = AW_IRQ_DEBE0; para.irq[DISP_MOD_BE1] = AW_IRQ_DEBE1; para.irq[DISP_MOD_FE0] = AW_IRQ_DEFE0; para.irq[DISP_MOD_FE1] = AW_IRQ_DEFE1; para.irq[DISP_MOD_LCD0] = AW_IRQ_LCD0; para.irq[DISP_MOD_LCD1] = AW_IRQ_LCD1; #endif para.disp_int_process = disp_int_process; #if ((defined CONFIG_SUN6I) || (defined CONFIG_ARCH_SUN8IW1P1) || (defined CONFIG_ARCH_SUN7IW1P1)) para.hdmi_open = DRV_hdmi_open; para.hdmi_close = DRV_hdmi_close; para.hdmi_set_mode = DRV_hdmi_set_display_mode; para.hdmi_mode_support = DRV_hdmi_mode_support; para.hdmi_get_HPD_status = DRV_hdmi_get_HPD_status; para.hdmi_set_pll = DRV_hdmi_set_pll; #endif //para.hdmi_get_disp_func = disp_get_hdmi_func; memset(&g_disp_drv, 0, sizeof(__disp_drv_t)); bsp_disp_init(¶); #if ((defined CONFIG_SUN6I) || (defined CONFIG_ARCH_SUN8IW1P1) || (defined CONFIG_ARCH_SUN7IW1P1)) Hdmi_set_reg_base(0x01c16000); Hdmi_hal_init(); #endif bsp_disp_open(); lcd_init(); #if 0 if(0) { __disp_color_t bk_color; printf("====DRV_lcd_open before ====\n"); DRV_lcd_open(0); printf("====DRV_lcd_open after ====\n"); bsp_disp_print_reg(1, DISP_MOD_PIOC); bsp_disp_print_reg(1, DISP_MOD_PWM); bsp_disp_print_reg(1, DISP_MOD_CCMU); bsp_disp_print_reg(1, DISP_MOD_LCD0); bsp_disp_lcd_set_src(0,DISP_LCDC_SRC_WHITE); printf("====lcd_white_src ====\n"); __msdelay(1000); *(__u32*)0x1c0c0f4 = 0xffff; bsp_disp_print_reg(1, DISP_MOD_LCD0); //bsp_disp_lcd_set_src(0,DISP_LCDC_SRC_BLACK); //printf("====lcd_black_src ====\n"); //__msdelay(1000); bsp_disp_print_reg(1, DISP_MOD_LCD0); bsp_disp_lcd_set_src(0,DISP_LCDC_SRC_DE_CH1); printf("====lcd_ch1_src ====\n"); __msdelay(1000); bk_color.red = 0xff; bk_color.green = 0x00; bk_color.blue = 0x00; bsp_disp_set_bk_color(0,&bk_color); printf("==== red bk color ====\n"); __msdelay(1000); return 0; bk_color.red = 0x00; bk_color.green = 0xff; bk_color.blue = 0x00; bsp_disp_set_bk_color(0,&bk_color); printf("==== red green color ====\n"); __msdelay(1000); bk_color.red = 0x00; bk_color.green = 0x00; bk_color.blue = 0xff; bsp_disp_set_bk_color(0,&bk_color); printf("==== red bk color ====\n"); __msdelay(1000); } printf("====display init end ====\n"); #endif printf("DRV_DISP_Init: opened\n"); display_opens = 1; return 0; }
__s32 drv_disp_standby(__u32 cmd, void *pArg) { __s32 ret; __s32 timedly = 5000; __s32 check_time = timedly/DELAY_ONCE_TIME; if(cmd == BOOT_MOD_ENTER_STANDBY) { if(output_type == DISP_OUTPUT_TYPE_HDMI) { DRV_hdmi_close(); } else { DRV_lcd_close(0); } do { ret = DRV_lcd_check_close_finished(0); if(ret == 1) { break; } else if(ret == -1) { return -1; } __msdelay(DELAY_ONCE_TIME); check_time --; if(check_time <= 0) { return -1; } } while(1); bsp_disp_clk_off(3); return 0; } else if(cmd == BOOT_MOD_EXIT_STANDBY) { bsp_disp_clk_on(3); if(output_type == DISP_OUTPUT_TYPE_HDMI) { DRV_hdmi_open(); } else { DRV_lcd_open(0); } do { ret = DRV_lcd_check_open_finished(0); if(ret == 1) { break; } else if(ret == -1) { return -1; } __msdelay(DELAY_ONCE_TIME); check_time --; if(check_time <= 0) { return -1; } } while(1); return 0; } return -1; }
__s32 DRV_DE_Standby(__u32 cmd, void *pArg) { __s32 ret; __s32 timedly = 5000; __s32 check_time = timedly/DELAY_ONCE_TIME; if(cmd == EGON2_MOD_ENTER_STANDBY) { DRV_lcd_close(0); do { ret = DRV_lcd_check_close_finished(0); if(ret == 1) { break; } else if(ret == -1) { return -1; } wBoot_timer_delay(DELAY_ONCE_TIME); check_time --; if(check_time <= 0) { return -1; } } while(1); BSP_disp_clk_off(3); return 0; } else if(cmd == EGON2_MOD_EXIT_STANDBY) { BSP_disp_clk_on(3); DRV_lcd_open(0); do { ret = DRV_lcd_check_open_finished(0); if(ret == 1) { break; } else if(ret == -1) { return -1; } wBoot_timer_delay(DELAY_ONCE_TIME); check_time --; if(check_time <= 0) { return -1; } } while(1); return 0; } return -1; }
/* **************************************************************************************************** * * DRV_DE_IOCTRL * * Description: 驱动提供的io操作函数,通常用于扩展操作 * * * Parameters: mid: 模块编号,驱动编写者可以不用关心 * cmd: 驱动提供的操作命令 * aux: 用户传进的整型参数 * pbuffer: 用户传进的指针型参数 * * Return value: * 0 * -1 **************************************************************************************************** */ __s32 DRV_DE_IOCTRL(__u32 hd, __u32 cmd, __s32 aux, void *pbuffer) { __u32 para0=0, para1=0, para2=0; if(pbuffer != NULL) { para0 = *((__u32*)pbuffer); para1 = *((__u32*)((__u32)pbuffer+4)); para2 = *((__u32*)((__u32)pbuffer+8)); } switch(cmd) { //----disp global---- case DISP_CMD_SET_BKCOLOR: return BSP_disp_set_bk_color(aux, (__disp_color_t*)para0); case DISP_CMD_SET_COLORKEY: return BSP_disp_set_color_key(aux, (__disp_colorkey_t *)para0); case DISP_CMD_SET_PALETTE_TBL: return BSP_disp_set_palette_table(aux, (__u32 *)para0, para1, para2); case DISP_CMD_GET_PALETTE_TBL: return BSP_disp_get_palette_table(aux, (__u32 *)para0, para1, para2); case DISP_CMD_START_CMD_CACHE: return BSP_disp_cmd_cache(aux); case DISP_CMD_EXECUTE_CMD_AND_STOP_CACHE: return BSP_disp_cmd_submit(aux); case DISP_CMD_GET_OUTPUT_TYPE: return BSP_disp_get_output_type(aux); case DISP_CMD_SCN_GET_WIDTH: return BSP_disp_get_screen_width(aux); case DISP_CMD_SCN_GET_HEIGHT: return BSP_disp_get_screen_height(aux); case DISP_CMD_SET_EXIT_MODE: return DRV_set_exit_mode(aux); case DISP_CMD_SET_GAMMA_TABLE: return BSP_disp_set_gamma_table(aux, (__u32 *)para0, para1); case DISP_CMD_GAMMA_CORRECTION_ON: return BSP_disp_gamma_correction_enable(aux); case DISP_CMD_GAMMA_CORRECTION_OFF: return BSP_disp_gamma_correction_disable(aux); //----layer---- case DISP_CMD_LAYER_REQUEST: return BSP_disp_layer_request(aux, (__disp_layer_work_mode_t)para0); case DISP_CMD_LAYER_RELEASE: return BSP_disp_layer_release(aux, para0); case DISP_CMD_LAYER_OPEN: return BSP_disp_layer_open(aux, para0); case DISP_CMD_LAYER_CLOSE: return BSP_disp_layer_close(aux, para0); case DISP_CMD_LAYER_SET_FB: return BSP_disp_layer_set_framebuffer(aux, para0, (__disp_fb_t*)para1); case DISP_CMD_LAYER_GET_FB: return BSP_disp_layer_get_framebuffer(aux, para0, (__disp_fb_t*)para1); case DISP_CMD_LAYER_SET_SRC_WINDOW: return BSP_disp_layer_set_src_window(aux,para0, (__disp_rect_t*)para1); case DISP_CMD_LAYER_GET_SRC_WINDOW: return BSP_disp_layer_get_src_window(aux,para0, (__disp_rect_t*)para1); case DISP_CMD_LAYER_SET_SCN_WINDOW: return BSP_disp_layer_set_screen_window(aux,para0, (__disp_rect_t*)para1); case DISP_CMD_LAYER_GET_SCN_WINDOW: return BSP_disp_layer_get_screen_window(aux,para0, (__disp_rect_t*)para1); case DISP_CMD_LAYER_SET_PARA: return BSP_disp_layer_set_para(aux, para0, (__disp_layer_info_t *)para1); case DISP_CMD_LAYER_GET_PARA: return BSP_disp_layer_get_para(aux, para0, (__disp_layer_info_t *)para1); case DISP_CMD_LAYER_TOP: return BSP_disp_layer_set_top(aux, para0); case DISP_CMD_LAYER_BOTTOM: return BSP_disp_layer_set_bottom(aux, para0); case DISP_CMD_LAYER_ALPHA_ON: return BSP_disp_layer_alpha_enable(aux, para0, 1); case DISP_CMD_LAYER_ALPHA_OFF: return BSP_disp_layer_alpha_enable(aux, para0, 0); case DISP_CMD_LAYER_SET_ALPHA_VALUE: return BSP_disp_layer_set_alpha_value(aux, para0, para1); case DISP_CMD_LAYER_CK_ON: return BSP_disp_layer_colorkey_enable(aux, para0, 1); case DISP_CMD_LAYER_CK_OFF: return BSP_disp_layer_colorkey_enable(aux, para0, 0); case DISP_CMD_LAYER_SET_PIPE: return BSP_disp_layer_set_pipe(aux, para0, para1); case DISP_CMD_LAYER_GET_ALPHA_VALUE: return BSP_disp_layer_get_alpha_value(aux, para0); case DISP_CMD_LAYER_GET_ALPHA_EN: return BSP_disp_layer_get_alpha_enable(aux, para0); case DISP_CMD_LAYER_GET_CK_EN: return BSP_disp_layer_get_colorkey_enable(aux, para0); case DISP_CMD_LAYER_GET_PRIO: return BSP_disp_layer_get_piro(aux, para0); case DISP_CMD_LAYER_GET_PIPE: return BSP_disp_layer_get_pipe(aux, para0); case DISP_CMD_LAYER_SET_SMOOTH: return BSP_disp_layer_set_smooth(aux, para0,(__disp_video_smooth_t) para1); case DISP_CMD_LAYER_GET_SMOOTH: return BSP_disp_layer_get_smooth(aux, para0); //----scaler---- case DISP_CMD_SCALER_REQUEST: return BSP_disp_scaler_request(); case DISP_CMD_SCALER_RELEASE: return BSP_disp_scaler_release(para0); case DISP_CMD_SCALER_EXECUTE: return BSP_disp_scaler_start(para0,(__disp_scaler_para_t *)para1); //----hwc---- case DISP_CMD_HWC_OPEN: return BSP_disp_hwc_enable(aux, 1); case DISP_CMD_HWC_CLOSE: return BSP_disp_hwc_enable(aux, 0); case DISP_CMD_HWC_SET_POS: return BSP_disp_hwc_set_pos(aux, (__disp_pos_t*)para0); case DISP_CMD_HWC_GET_POS: return BSP_disp_hwc_get_pos(aux, (__disp_pos_t *)para0); case DISP_CMD_HWC_SET_FB: return BSP_disp_hwc_set_framebuffer(aux, (__disp_hwc_pattern_t *)para0); case DISP_CMD_HWC_SET_PALETTE_TABLE: return BSP_disp_hwc_set_palette(aux, (void*)para0, para1, para2); //----video---- case DISP_CMD_VIDEO_START: return BSP_disp_video_start(aux, para0); case DISP_CMD_VIDEO_STOP: return BSP_disp_video_stop(aux, para0); case DISP_CMD_VIDEO_SET_FB: return BSP_disp_video_set_fb(aux, para0, (__disp_video_fb_t *)para1); case DISP_CMD_VIDEO_GET_FRAME_ID: return BSP_disp_video_get_frame_id(aux, para0); case DISP_CMD_VIDEO_GET_DIT_INFO: return BSP_disp_video_get_dit_info(aux, para0,(__disp_dit_info_t *)para1); //----lcd---- case DISP_CMD_LCD_ON: return DRV_lcd_open(aux); case DISP_CMD_LCD_OFF: return DRV_lcd_close(aux); case DISP_CMD_LCD_SET_BRIGHTNESS: return BSP_disp_lcd_set_bright(aux, para0); case DISP_CMD_LCD_GET_BRIGHTNESS: return BSP_disp_lcd_get_bright(aux); case DISP_CMD_LCD_CPUIF_XY_SWITCH: return BSP_disp_lcd_xy_switch(aux, para0); case DISP_CMD_LCD_SET_SRC: return BSP_disp_lcd_set_src(aux, (__disp_lcdc_src_t)para0); case DISP_CMD_LCD_CHECK_OPEN_FINISH: return DRV_lcd_check_open_finished(aux); case DISP_CMD_LCD_CHECK_CLOSE_FINISH: return DRV_lcd_check_close_finished(aux); //----tv---- case DISP_CMD_TV_ON: return BSP_disp_tv_open(aux); case DISP_CMD_TV_OFF: return BSP_disp_tv_close(aux); case DISP_CMD_TV_SET_MODE: return BSP_disp_tv_set_mode(aux, (__disp_tv_mode_t)para0); case DISP_CMD_TV_GET_MODE: return BSP_disp_tv_get_mode(aux); case DISP_CMD_TV_AUTOCHECK_ON: return BSP_disp_tv_auto_check_enable(aux); case DISP_CMD_TV_AUTOCHECK_OFF: return BSP_disp_tv_auto_check_disable(aux); case DISP_CMD_TV_GET_INTERFACE: return BSP_disp_tv_get_interface(aux); case DISP_CMD_TV_SET_SRC: return BSP_disp_tv_set_src(aux, (__disp_lcdc_src_t)para0); case DISP_CMD_TV_GET_DAC_STATUS: return BSP_disp_tv_get_dac_status(aux, para0); case DISP_CMD_TV_SET_DAC_SOURCE: return BSP_disp_tv_set_dac_source(aux, para0, (__disp_tv_dac_source)para1); case DISP_CMD_TV_GET_DAC_SOURCE: return BSP_disp_tv_get_dac_source(aux, para0); //----hdmi---- case DISP_CMD_HDMI_ON: return BSP_disp_hdmi_open(aux); case DISP_CMD_HDMI_OFF: return BSP_disp_hdmi_close(aux); case DISP_CMD_HDMI_SET_MODE: return BSP_disp_hdmi_set_mode(aux, (__disp_tv_mode_t)para0); case DISP_CMD_HDMI_GET_MODE: return BSP_disp_hdmi_get_mode(aux); case DISP_CMD_HDMI_GET_HPD_STATUS: return BSP_disp_hdmi_get_hpd_status(aux); case DISP_CMD_HDMI_SUPPORT_MODE: return BSP_disp_hdmi_check_support_mode(aux, para0); case DISP_CMD_HDMI_SET_SRC: return BSP_disp_hdmi_set_src(aux, (__disp_lcdc_src_t)para0); //----vga---- case DISP_CMD_VGA_ON: return BSP_disp_vga_open(aux); case DISP_CMD_VGA_OFF: return BSP_disp_vga_close(aux); case DISP_CMD_VGA_SET_MODE: return BSP_disp_vga_set_mode(aux, (__disp_vga_mode_t)para0); case DISP_CMD_VGA_GET_MODE: return BSP_disp_vga_get_mode(aux); case DISP_CMD_VGA_SET_SRC: return BSP_disp_vga_set_src(aux, (__disp_lcdc_src_t)para0); //----sprite---- case DISP_CMD_SPRITE_OPEN: return BSP_disp_sprite_open(aux); case DISP_CMD_SPRITE_CLOSE: return BSP_disp_sprite_close(aux); case DISP_CMD_SPRITE_SET_FORMAT: return BSP_disp_sprite_set_format(aux, (__disp_pixel_fmt_t)para0, (__disp_pixel_seq_t)para1); case DISP_CMD_SPRITE_GLOBAL_ALPHA_ENABLE: return BSP_disp_sprite_alpha_enable(aux); case DISP_CMD_SPRITE_GLOBAL_ALPHA_DISABLE: return BSP_disp_sprite_alpha_disable(aux); case DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_ENABLE: return BSP_disp_sprite_get_alpha_enable(aux); case DISP_CMD_SPRITE_SET_GLOBAL_ALPHA_VALUE: return BSP_disp_sprite_set_alpha_vale(aux, para0); case DISP_CMD_SPRITE_GET_GLOBAL_ALPHA_VALUE: return BSP_disp_sprite_get_alpha_value(aux); case DISP_CMD_SPRITE_SET_ORDER: return BSP_disp_sprite_set_order(aux, para0,para1); case DISP_CMD_SPRITE_GET_TOP_BLOCK: return BSP_disp_sprite_get_top_block(aux); case DISP_CMD_SPRITE_GET_BOTTOM_BLOCK: return BSP_disp_sprite_get_bottom_block(aux); case DISP_CMD_SPRITE_SET_PALETTE_TBL: return BSP_disp_sprite_set_palette_table(aux, (__u32 * )para0,para1,para2); case DISP_CMD_SPRITE_GET_BLOCK_NUM: return BSP_disp_sprite_get_block_number(aux); case DISP_CMD_SPRITE_BLOCK_REQUEST: return BSP_disp_sprite_block_request(aux, (__disp_sprite_block_para_t*)para0); case DISP_CMD_SPRITE_BLOCK_RELEASE: return BSP_disp_sprite_block_release(aux, para0); case DISP_CMD_SPRITE_BLOCK_SET_SCREEN_WINDOW: return BSP_disp_sprite_block_set_screen_win(aux, para0,(__disp_rect_t *)para1); case DISP_CMD_SPRITE_BLOCK_GET_SCREEN_WINDOW: return BSP_disp_sprite_block_get_srceen_win(aux, para0,(__disp_rect_t *)para1); case DISP_CMD_SPRITE_BLOCK_SET_SOURCE_WINDOW: return BSP_disp_sprite_block_set_src_win(aux, para0,(__disp_rect_t *)para1); case DISP_CMD_SPRITE_BLOCK_GET_SOURCE_WINDOW: return BSP_disp_sprite_block_get_src_win(aux, para0,(__disp_rect_t *)para1); case DISP_CMD_SPRITE_BLOCK_SET_FB: return BSP_disp_sprite_block_set_framebuffer(aux, para0,(__disp_fb_t *)para1); case DISP_CMD_SPRITE_BLOCK_GET_FB: return BSP_disp_sprite_block_get_framebufer(aux, para0,(__disp_fb_t *)para1); case DISP_CMD_SPRITE_BLOCK_SET_TOP: return BSP_disp_sprite_block_set_top(aux, para0); case DISP_CMD_SPRITE_BLOCK_SET_BOTTOM: return BSP_disp_sprite_block_set_bottom(aux, para0); case DISP_CMD_SPRITE_BLOCK_GET_PREV_BLOCK: return BSP_disp_sprite_block_get_pre_block(aux, para0); case DISP_CMD_SPRITE_BLOCK_GET_NEXT_BLOCK: return BSP_disp_sprite_block_get_next_block(aux, para0); case DISP_CMD_SPRITE_BLOCK_GET_PRIO: return BSP_disp_sprite_block_get_prio(aux, para0); case DISP_CMD_SPRITE_BLOCK_OPEN: return BSP_disp_sprite_block_open(aux, para0); case DISP_CMD_SPRITE_BLOCK_CLOSE: return BSP_disp_sprite_block_close(aux, para0); case DISP_CMD_SPRITE_BLOCK_SET_PARA: return BSP_disp_sprite_block_set_para(aux, para0,(__disp_sprite_block_para_t*)para1); case DISP_CMD_SPRITE_BLOCK_GET_PARA: return BSP_disp_sprite_block_get_para(aux, para0,(__disp_sprite_block_para_t*)para1); default: __wrn("not supported display cmd:%x\n",cmd); return eGON2_FAIL; } }