From 6c01b6c84fff553672dc4c098eb62161e64597c7 Mon Sep 17 00:00:00 2001 From: danling Date: Fri, 16 Mar 2012 15:54:10 +0800 Subject: [PATCH] disp_sun4i: 1, lcd saturation set to 57 as default; 2, modify csc; 3, add lcd config for ainol_aurota/mid9742 in menuconfig; 4, modify hdmi avi packet for hd; 5, support deinterlace; --- drivers/video/Kconfig | 18 + drivers/video/sun4i/disp/de_bsp/de/disp_de.c | 49 +- .../video/sun4i/disp/de_bsp/de/disp_display.h | 3 + .../video/sun4i/disp/de_bsp/de/disp_layer.c | 2 +- drivers/video/sun4i/disp/de_bsp/de/disp_lcd.c | 28 +- .../video/sun4i/disp/de_bsp/de/disp_scaler.c | 2 +- .../video/sun4i/disp/de_bsp/de/disp_video.c | 5 - .../video/sun4i/disp/de_bsp/de/ebios/de_be.c | 523 ++++++++++++++---- .../video/sun4i/disp/de_bsp/de/ebios/de_fe.c | 111 ++-- .../video/sun4i/disp/de_bsp/de/ebios/de_fe.h | 34 +- .../sun4i/disp/de_bsp/de/ebios/ebios_de.h | 4 +- drivers/video/sun4i/disp/dev_disp.c | 30 +- drivers/video/sun4i/disp/dev_fb.c | 64 ++- drivers/video/sun4i/hdmi/aw/hdmi_core.c | 82 +-- drivers/video/sun4i/lcd/Makefile | 13 +- .../video/sun4i/lcd/lcd_bak/ainol_aurota.c | 348 ++++++++++++ drivers/video/sun4i/lcd/lcd_bak/mid9742.c | 348 ++++++++++++ drivers/video/sun4i/lcd/lcd_panel_cfg.h | 8 + 18 files changed, 1392 insertions(+), 280 deletions(-) mode change 100755 => 100644 drivers/video/Kconfig mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/disp_de.c mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/disp_display.h mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/disp_layer.c mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/disp_scaler.c mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/disp_video.c mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/ebios/de_be.c mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.c mode change 100755 => 100644 drivers/video/sun4i/disp/de_bsp/de/ebios/ebios_de.h mode change 100755 => 100644 drivers/video/sun4i/disp/dev_disp.c mode change 100755 => 100644 drivers/video/sun4i/disp/dev_fb.c mode change 100755 => 100644 drivers/video/sun4i/hdmi/aw/hdmi_core.c create mode 100644 drivers/video/sun4i/lcd/lcd_bak/ainol_aurota.c create mode 100644 drivers/video/sun4i/lcd/lcd_bak/mid9742.c mode change 100755 => 100644 drivers/video/sun4i/lcd/lcd_panel_cfg.h diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig old mode 100755 new mode 100644 index 382c8901308282..f0a6a5498b37b6 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -292,6 +292,24 @@ config LYCHEE_LCD_SUN4I ---help--- default m +choice + prompt "Choice LCD" + depends on LYCHEE_LCD_SUN4I + +config LYCHEE_LCD_DEFAULT + bool "lcd_default" + select LCD_DEFAULT + +config LYCHEE_LCD_MID9742 + bool "lcd_mid9742" + select LCD_MID9742 + +config LYCHEE_LCD_AINOL_AUROTA + bool "ainol_aurota" + select LCD_AINOL_AUROTA + +endchoice + config LYCHEE_HDMI_SUN4I tristate "HDMI Driver Support(sun4i)" depends on ARCH_SUN4I diff --git a/drivers/video/sun4i/disp/de_bsp/de/disp_de.c b/drivers/video/sun4i/disp/de_bsp/de/disp_de.c old mode 100755 new mode 100644 index ad326d9096e5b2..9f5114f93629ce --- a/drivers/video/sun4i/disp/de_bsp/de/disp_de.c +++ b/drivers/video/sun4i/disp/de_bsp/de/disp_de.c @@ -36,7 +36,6 @@ __s32 Image_init(__u32 sel) DE_BE_Reg_Init(sel); BSP_disp_sprite_init(sel); - BSP_disp_set_output_csc(sel, DISP_OUTPUT_TYPE_LCD); Image_open(sel); @@ -76,7 +75,8 @@ __s32 Image_close(__u32 sel) __s32 BSP_disp_set_bright(__u32 sel, __u32 bright) { gdisp.screen[sel].bright = bright; - DE_BE_Set_Enhance(sel, gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); + DE_BE_Set_Enhance_ex(sel, gdisp.screen[sel].out_csc, gdisp.screen[sel].out_color_range, gdisp.screen[sel].enhance_en, + gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); return DIS_SUCCESS; } @@ -89,7 +89,8 @@ __s32 BSP_disp_get_bright(__u32 sel) __s32 BSP_disp_set_contrast(__u32 sel, __u32 contrast) { gdisp.screen[sel].contrast = contrast; - DE_BE_Set_Enhance(sel, gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); + DE_BE_Set_Enhance_ex(sel, gdisp.screen[sel].out_csc, gdisp.screen[sel].out_color_range, gdisp.screen[sel].enhance_en, + gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); return DIS_SUCCESS; } @@ -102,7 +103,8 @@ __s32 BSP_disp_get_contrast(__u32 sel) __s32 BSP_disp_set_saturation(__u32 sel, __u32 saturation) { gdisp.screen[sel].saturation = saturation; - DE_BE_Set_Enhance(sel, gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); + DE_BE_Set_Enhance_ex(sel, gdisp.screen[sel].out_csc, gdisp.screen[sel].out_color_range, gdisp.screen[sel].enhance_en, + gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); return DIS_SUCCESS; } @@ -115,7 +117,8 @@ __s32 BSP_disp_get_saturation(__u32 sel) __s32 BSP_disp_set_hue(__u32 sel, __u32 hue) { gdisp.screen[sel].hue = hue; - DE_BE_Set_Enhance(sel, gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); + DE_BE_Set_Enhance_ex(sel, gdisp.screen[sel].out_csc, gdisp.screen[sel].out_color_range, gdisp.screen[sel].enhance_en, + gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); return DIS_SUCCESS; } @@ -127,9 +130,11 @@ __s32 BSP_disp_get_hue(__u32 sel) __s32 BSP_disp_enhance_enable(__u32 sel, __bool enable) { - DE_BE_enhance_enable(sel, enable); gdisp.screen[sel].enhance_en = enable; + DE_BE_Set_Enhance_ex(sel, gdisp.screen[sel].out_csc, gdisp.screen[sel].out_color_range, gdisp.screen[sel].enhance_en, + gdisp.screen[sel].bright, gdisp.screen[sel].contrast, gdisp.screen[sel].saturation, gdisp.screen[sel].hue); + return DIS_SUCCESS; } @@ -152,7 +157,14 @@ __s32 BSP_disp_set_screen_size(__u32 sel, __disp_rectsz_t * size) __s32 BSP_disp_set_output_csc(__u32 sel, __disp_output_type_t type) { __disp_color_range_t out_color_range = DISP_COLOR_RANGE_0_255; - __bool bout_yuv = FALSE; + __u32 out_csc = 0; + __u32 enhance_en, bright, contrast, saturation, hue; + + enhance_en = gdisp.screen[sel].enhance_en; + bright = gdisp.screen[sel].bright; + contrast = gdisp.screen[sel].contrast; + saturation = gdisp.screen[sel].saturation; + hue = gdisp.screen[sel].hue; if(type == DISP_OUTPUT_TYPE_HDMI) { @@ -174,12 +186,26 @@ __s32 BSP_disp_set_output_csc(__u32 sel, __disp_output_type_t type) } else if(type == DISP_OUTPUT_TYPE_TV) { - bout_yuv = TRUE; + out_csc = 1; + } + + else if(type == DISP_OUTPUT_TYPE_LCD) + { + if(enhance_en == 0) + { + enhance_en = 1; + + bright = 50; + contrast = 50; + saturation = 57; + hue = 50; + } } - - DE_BE_Output_Cfg_Csc_Coeff(sel, bout_yuv, out_color_range); - gdisp.screen[sel].bout_yuv = bout_yuv; + gdisp.screen[sel].out_color_range = out_color_range; + gdisp.screen[sel].out_csc = out_csc; + + DE_BE_Set_Enhance_ex(sel, gdisp.screen[sel].out_csc, gdisp.screen[sel].out_color_range, enhance_en, bright, contrast, saturation, hue); return DIS_SUCCESS; } @@ -243,6 +269,7 @@ __s32 Disp_set_out_interlace(__u32 sel) DE_BE_Set_Outitl_enable(sel, gdisp.screen[sel].b_out_interlace); BSP_disp_cfg_finish(sel); + return DIS_SUCCESS; } diff --git a/drivers/video/sun4i/disp/de_bsp/de/disp_display.h b/drivers/video/sun4i/disp/de_bsp/de/disp_display.h old mode 100755 new mode 100644 index a196d76bdae3a4..eefef2830fe1a3 --- a/drivers/video/sun4i/disp/de_bsp/de/disp_display.h +++ b/drivers/video/sun4i/disp/de_bsp/de/disp_display.h @@ -84,6 +84,8 @@ typedef struct __bool lcd_io_used[28]; user_gpio_set_t lcd_io[28]; + + __u32 init_bright; }__disp_lcd_cfg_t; typedef struct @@ -125,6 +127,7 @@ typedef struct __u32 lcd_bright; __disp_color_range_t out_color_range; + __u32 out_csc; __disp_lcd_cfg_t lcd_cfg; __hdle gpio_hdl[4]; diff --git a/drivers/video/sun4i/disp/de_bsp/de/disp_layer.c b/drivers/video/sun4i/disp/de_bsp/de/disp_layer.c old mode 100755 new mode 100644 index a08df9a7fa9a27..37d81ac3f025f9 --- a/drivers/video/sun4i/disp/de_bsp/de/disp_layer.c +++ b/drivers/video/sun4i/disp/de_bsp/de/disp_layer.c @@ -992,7 +992,7 @@ __s32 BSP_disp_layer_set_para(__u32 sel, __u32 hid,__disp_layer_info_t *player) layer_fb.offset_y = player->src_win.y; bpp = DE_BE_Format_To_Bpp(sel, layer_fb.format); - size = (player->fb.size.width * layer_man->para.src_win.height * bpp + 7)/8; + size = (player->fb.size.width * player->scn_win.height * bpp + 7)/8; OSAL_CacheRangeFlush((void *)player->fb.addr[0], size,CACHE_CLEAN_FLUSH_D_CACHE_REGION); DE_BE_Layer_Set_Framebuffer(sel, hid,&layer_fb); } diff --git a/drivers/video/sun4i/disp/de_bsp/de/disp_lcd.c b/drivers/video/sun4i/disp/de_bsp/de/disp_lcd.c index 8885e2b429505d..899d055205ed63 100644 --- a/drivers/video/sun4i/disp/de_bsp/de/disp_lcd.c +++ b/drivers/video/sun4i/disp/de_bsp/de/disp_lcd.c @@ -579,7 +579,7 @@ void LCD_get_sys_config(__u32 sel, __disp_lcd_cfg_t *lcd_cfg) "lcdd23", "lcdclk", "lcdde", "lcdhsync", "lcdvsync"}; user_gpio_set_t *gpio_info; int value = 1; - char primary_key[20]; + char primary_key[20], sub_name[20]; int i = 0; int ret; @@ -671,7 +671,6 @@ void LCD_get_sys_config(__u32 sel, __disp_lcd_cfg_t *lcd_cfg) //lcd_gpio for(i=0; i<4; i++) { - char sub_name[20]; sprintf(sub_name, "lcd_gpio_%d", i); gpio_info = &(lcd_cfg->lcd_gpio[i]); @@ -705,6 +704,27 @@ void LCD_get_sys_config(__u32 sel, __disp_lcd_cfg_t *lcd_cfg) lcd_cfg->lcd_io_used[i]= 1; } } + +//init_bright + sprintf(primary_key, "disp_init"); + sprintf(sub_name, "lcd%d_bright", sel); + + ret = OSAL_Script_FetchParser_Data(primary_key, sub_name, &value, 1); + if(ret < 0) + { + DE_INF("%s.%s not exit\n", primary_key,sub_name); + lcd_cfg->init_bright = 197; + } + else + { + DE_INF("%s.%s = %d\n", primary_key,sub_name, value); + if(value > 256) + { + value = 256; + } + lcd_cfg->init_bright = value; + } + } void LCD_delay_ms(__u32 ms) @@ -1266,11 +1286,11 @@ __s32 Disp_lcdc_init(__u32 sel) pwm_info.period_ns = 1000000 / gpanel_info[sel].lcd_pwm_freq; if(gpanel_info[sel].lcd_pwm_pol == 0) { - pwm_info.duty_ns = (192 * pwm_info.period_ns) / 256; + pwm_info.duty_ns = (gdisp.screen[sel].lcd_cfg.init_bright * pwm_info.period_ns) / 256; } else { - pwm_info.duty_ns = ((256 - 192) * pwm_info.period_ns) / 256; + pwm_info.duty_ns = ((256 - gdisp.screen[sel].lcd_cfg.init_bright) * pwm_info.period_ns) / 256; } pwm_set_para(gpanel_info[sel].lcd_pwm_ch, &pwm_info); } diff --git a/drivers/video/sun4i/disp/de_bsp/de/disp_scaler.c b/drivers/video/sun4i/disp/de_bsp/de/disp_scaler.c old mode 100755 new mode 100644 index 700298a483ece0..94a26a13ed2efb --- a/drivers/video/sun4i/disp/de_bsp/de/disp_scaler.c +++ b/drivers/video/sun4i/disp/de_bsp/de/disp_scaler.c @@ -279,7 +279,7 @@ __s32 Scaler_event_proc(void *parg) DE_SCAL_ClearINT(sel,fe_intflags); DE_BE_ClearINT(sel,be_intflags); - DE_INF("scaler %d interrupt, scal_int_status:0x%x!\n", sel, fe_intflags); + //DE_INF("scaler %d interrupt, scal_int_status:0x%x!\n", sel, fe_intflags); if(be_intflags & DE_IMG_REG_LOAD_FINISH) { diff --git a/drivers/video/sun4i/disp/de_bsp/de/disp_video.c b/drivers/video/sun4i/disp/de_bsp/de/disp_video.c old mode 100755 new mode 100644 index def7072965be81..cb54ead15710f3 --- a/drivers/video/sun4i/disp/de_bsp/de/disp_video.c +++ b/drivers/video/sun4i/disp/de_bsp/de/disp_video.c @@ -208,12 +208,7 @@ static __inline __s32 Hal_Set_Frame(__u32 sel, __u32 tcon_index, __u32 id) g_video[sel][id].tempdiff_en = FALSE; } g_video[sel][id].diagintp_en = TRUE; - - g_video[sel][id].fetch_field = FALSE;//todo - g_video[sel][id].fetch_bot = 0;//todo - g_video[sel][id].dit_mode = DIT_MODE_MAF_BOB;//todo g_video[sel][id].tempdiff_en = FALSE;//todo - g_video[sel][id].diagintp_en = FALSE;//todo } else { diff --git a/drivers/video/sun4i/disp/de_bsp/de/ebios/de_be.c b/drivers/video/sun4i/disp/de_bsp/de/ebios/de_be.c old mode 100755 new mode 100644 index 8e369c9dbed0ad..60f624e786afba --- a/drivers/video/sun4i/disp/de_bsp/de/ebios/de_be.c +++ b/drivers/video/sun4i/disp/de_bsp/de/ebios/de_be.c @@ -56,21 +56,21 @@ __u32 csc_tab[192] = __u32 image_enhance_tab[224] = { - //csc convert table - 0x00000107,0x00000204,0x00000064,0x00004000,0xffffff69,0xfffffed7,0x000001c1,0x00020000, - 0x000001c1,0xfffffe88,0xffffffb8,0x00020000,0x00000000,0x00000000,0x00000000,0x00000400, - 0x000004a7,0x00000000,0x00000662,0xfffc845b,0x000004a7,0xfffffe70,0xfffffcc0,0x00021df3, - 0x000004a7,0x00000812,0x00000000,0xfffbac4a,0x00000000,0x00000000,0x00000000,0x00000400, - - 0x000000bb,0x00000274,0x0000003f,0x00004000,0xffffff99,0xfffffea6,0x000001c1,0x00020000, - 0x000001c1,0xfffffe68,0xffffffd8,0x00020000,0x00000000,0x00000000,0x00000000,0x00000400, - 0x000004a7,0x00000000,0x0000072c,0xfffc1f7d,0x000004a7,0xffffff26,0xfffffdde,0x000133f7, - 0x000004a7,0x00000875,0x00000000,0xfffb7aa0,0x00000000,0x00000000,0x00000000,0x00000400, - - 0x00000132,0x00000258,0x00000075,0x00000000,0xffffff54,0xfffffead,0x00000200,0x00020000, - 0x00000200,0xfffffe54,0xffffffad,0x00020000,0x00000000,0x00000000,0x00000000,0x00000400, - 0x00000400,0x00000000,0x0000059b,0xfffd3213,0x00000400,0xfffffe9f,0xfffffd25,0x00021ec5, - 0x00000400,0x00000715,0x00000000,0xfffc7540,0x00000000,0x00000000,0x00000000,0x00000400, + //bt601(CONSTANT and COEFFICIENT in 12bit fraction) + 0x0000041D,0x00000810,0x00000191,0x00010000,0xFFFFFDA2,0xFFFFFB58,0x00000706,0x00080000, + 0x00000706,0xFFFFFA1D,0xFFFFFEDD,0x00080000,0x00000000,0x00000000,0x00000000,0x00001000, + 0x000012A0,0x00000000,0x00001989,0xFFF21168,0x000012A0,0xFFFFF9BE,0xFFFFF2FE,0x000877CF, + 0x000012A0,0x0000204A,0x00000000,0xFFEEB127,0x00000000,0x00000000,0x00000000,0x00001000, + //bt709(CONSTANT and COEFFICIENT in 12bit fraction) + 0x000002EE,0x000009D3,0x000000FE,0x00010000,0xfffffe62,0xfffffA98,0x00000706,0x00080000, + 0x00000706,0xfffff99E,0xffffff5C,0x00080000,0x00000000,0x00000000,0x00000000,0x00001000, + 0x000012A0,0x00000000,0x00001CB0,0xFFF07DF4,0x000012A0,0xfffffC98,0xfffff775,0x0004CFDF, + 0x000012A0,0x000021D7,0x00000000,0xFFEDEA7F,0x00000000,0x00000000,0x00000000,0x00001000, + //YCC(CONSTANT and COEFFICIENT in 12bit fraction) + 0x000004C8,0x00000963,0x000001D5,0x00000000,0xFFFFFD4D,0xFFFFFAB3,0x00000800,0x00080000, + 0x00000800,0xFFFFF94F,0xFFFFFEB2,0x00080000,0x00000000,0x00000000,0x00000000,0x00001000, + 0x00001000,0x00000000,0x0000166F,0xFFF4C84B,0x00001000,0xFFFFFA78,0xFFFFF491,0x00087B16, + 0x00001000,0x00001C56,0x00000000,0xFFF1D4FE,0x00000000,0x00000000,0x00000000,0x00001000, //sin table 0xffffffbd,0xffffffbf,0xffffffc1,0xffffffc2,0xffffffc4,0xffffffc6,0xffffffc8,0xffffffca, 0xffffffcc,0xffffffce,0xffffffd1,0xffffffd3,0xffffffd5,0xffffffd7,0xffffffd9,0xffffffdb, @@ -328,6 +328,240 @@ __u32 fir_tab[1792] = 0x0b0a0603,0x00090c0d,0x0b0a0603,0x00090c0d,0x0c090602,0x00090c0e,0x0c090602,0x00090c0e, }; +//smooth for video +__u32 fir_tab_video[1792] = { + 0x00053704,0x00063703,0x00073702,0x00093601,0x000b3500,0x000c3400,0x000e3200,0x000f3100, + 0x00112f00,0x00132d00,0x00152b00,0x00162a00,0x00182800,0x001a2600,0x001c2400,0x001e2200, + 0x00202000,0x00211f00,0x00231d00,0x00251b00,0x00271900,0x00291700,0x002a1600,0x002c1400, + 0x002e1200,0x00301000,0x00310f00,0x00330d00,0x00340c00,0x01350a00,0x02360800,0x03360700, + + 0x00053704,0x00063703,0x00073702,0x00093601,0x000b3500,0x000c3400,0x000e3200,0x000f3100, + 0x00112f00,0x00132d00,0x00152b00,0x00162a00,0x00182800,0x001a2600,0x001c2400,0x001e2200, + 0x00202000,0x00211f00,0x00231d00,0x00251b00,0x00271900,0x00291700,0x002a1600,0x002c1400, + 0x002e1200,0x00301000,0x00310f00,0x00330d00,0x00340c00,0x01350a00,0x02360800,0x03360700, + + 0x00053704,0x00063703,0x00073702,0x00093601,0x000b3500,0x000c3400,0x000e3200,0x000f3100, + 0x00112f00,0x00132d00,0x00152b00,0x00162a00,0x00182800,0x001a2600,0x001c2400,0x001e2200, + 0x00202000,0x00211f00,0x00231d00,0x00251b00,0x00271900,0x00291700,0x002a1600,0x002c1400, + 0x002e1200,0x00301000,0x00310f00,0x00330d00,0x00340c00,0x01350a00,0x02360800,0x03360700, + 0x00083008,0x00093007,0x000b3005,0x000d2f04,0x000e2f03,0x00102e02,0x00112e01,0x00132d00, + 0x00142c00,0x00152b00,0x00172900,0x00182800,0x001a2600,0x001b2500,0x001d2300,0x001e2200, + 0x00202000,0x00211f00,0x00221e00,0x00241c00,0x00251b00,0x00271900,0x00281800,0x002a1600, + 0x002b1500,0x002d1300,0x012d1200,0x022e1000,0x032e0f00,0x042f0d00,0x052f0c00,0x072f0a00, + 0x000b2a0b,0x000d2a09,0x000e2a08,0x000f2a07,0x00102a06,0x00122905,0x00132904,0x00142903, + 0x00162802,0x00172702,0x00182701,0x001a2600,0x001b2500,0x001c2400,0x001d2300,0x001e2200, + 0x00202000,0x00211f00,0x00221e00,0x00231d00,0x00241c00,0x00261a00,0x01261900,0x02271700, + 0x02281600,0x03281500,0x04291300,0x05291200,0x06291100,0x072a0f00,0x082a0e00,0x092a0d00, + 0x000d270c,0x000f260b,0x0010260a,0x00112609,0x00122608,0x00122608,0x00132607,0x00152506, + 0x00162505,0x00172504,0x00192403,0x00192403,0x001b2302,0x001d2201,0x001d2201,0x001f2100, + 0x00202000,0x00211f00,0x01211e00,0x01221d00,0x02221c00,0x03231a00,0x03241900,0x04241800, + 0x05241700,0x06251500,0x07251400,0x08251300,0x08261200,0x09261100,0x0a261000,0x0b260f00, + 0x000e240e,0x000f240d,0x0010240c,0x0012230b,0x0013230a,0x0013230a,0x00142309,0x00152308, + 0x00162307,0x00182206,0x00182206,0x00192205,0x001b2104,0x001c2103,0x001d2003,0x011e1f02, + 0x021e1e02,0x021f1e01,0x03201d00,0x03211c00,0x04211b00,0x05211a00,0x06211900,0x06221800, + 0x07221700,0x08221600,0x09221500,0x0a221400,0x0a231300,0x0b231200,0x0c231100,0x0d231000, + 0x0010210f,0x0011210e,0x0012210d,0x0012210d,0x0013210c,0x0014210b,0x0015210a,0x0015210a, + 0x00162109,0x00182008,0x00182008,0x01191f07,0x011a1f06,0x021b1e05,0x021b1e05,0x031c1d04, + 0x031d1d03,0x041d1c03,0x051e1b02,0x051e1b02,0x061f1a01,0x071f1901,0x07201801,0x08201800, + 0x09201700,0x0a201600,0x0a211500,0x0b211400,0x0c211300,0x0d201300,0x0d211200,0x0e211100, + 0x00102010,0x0011200f,0x0012200e,0x0012200e,0x0013200d,0x00151f0c,0x00151f0c,0x01151f0b, + 0x01161e0b,0x01171e0a,0x02171e09,0x02181d09,0x03191d07,0x03191c08,0x041a1c06,0x041a1c06, + 0x051b1b05,0x061b1b04,0x061c1a04,0x071c1904,0x071d1903,0x081d1803,0x091d1802,0x091e1702, + 0x0a1e1602,0x0b1e1601,0x0c1f1500,0x0c1f1500,0x0d1f1400,0x0e1f1300,0x0e201200,0x0f1f1200, + 0x00111e11,0x00121e10,0x00131e0f,0x00131e0f,0x01131e0e,0x01141d0e,0x02151d0c,0x02151d0c, + 0x02161d0b,0x03161c0b,0x03171c0a,0x04171c09,0x04181b09,0x05181b08,0x05191b07,0x06191a07, + 0x061a1a06,0x071a1906,0x071b1905,0x081b1805,0x091b1804,0x091c1704,0x0a1c1703,0x0a1c1604, + 0x0b1d1602,0x0c1d1502,0x0c1d1502,0x0d1d1402,0x0e1d1401,0x0e1e1301,0x0f1e1300,0x101e1200, + 0x02121b11,0x02121b11,0x02131b10,0x03131b0f,0x03131b0f,0x04141a0e,0x04141a0e,0x04151a0d, + 0x05151a0c,0x05151a0c,0x0616190b,0x0616190b,0x0616190b,0x0716190a,0x0717180a,0x08171809, + 0x08181808,0x09181708,0x09181708,0x0a181707,0x0a191607,0x0b191606,0x0b191606,0x0c1a1505, + 0x0c1a1505,0x0d1a1504,0x0d1a1405,0x0e1a1404,0x0f1a1403,0x0f1b1303,0x101b1302,0x101b1203, + 0x04121911,0x04121911,0x05121910,0x05121910,0x0513190f,0x0613180f,0x0614180e,0x0614180e, + 0x0714180d,0x0714180d,0x0715180c,0x0815170c,0x0815170c,0x0915170b,0x0915170b,0x0916160b, + 0x0a16160a,0x0a16160a,0x0b161609,0x0b161609,0x0b171509,0x0c171508,0x0c181507,0x0d171507, + 0x0d181407,0x0e181406,0x0e181406,0x0f181306,0x0f191305,0x10181305,0x10181305,0x10191205, + 0x06111811,0x06121711,0x06121711,0x06131710,0x0713170f,0x0713170f,0x0713170f,0x0813170e, + 0x0813170e,0x0814160e,0x0914160d,0x0914160d,0x0914160d,0x0a14160c,0x0a14160c,0x0a15150c, + 0x0b15150b,0x0b15150b,0x0c15150a,0x0c15150a,0x0c16140a,0x0d161409,0x0d161409,0x0d161409, + 0x0e161408,0x0e171308,0x0f171307,0x0f171307,0x0f171307,0x10171306,0x10171207,0x11171206, + 0x07121611,0x07121611,0x08121610,0x08121610,0x0813160f,0x0813160f,0x0912160f,0x0913160e, + 0x0913150f,0x0a13150e,0x0a14150d,0x0a14150d,0x0a14150d,0x0b13150d,0x0b14150c,0x0b14150c, + 0x0c14140c,0x0c15140b,0x0c15140b,0x0d14140b,0x0d15140a,0x0d15140a,0x0d15140a,0x0e15130a, + 0x0e15130a,0x0e161309,0x0f151309,0x0f161308,0x0f161308,0x10161208,0x10161208,0x10161208, + 0x0b111410,0x0b111410,0x0b111410,0x0b111410,0x0b121310,0x0b121310,0x0c12130f,0x0c12130f, + 0x0c12130f,0x0c12130f,0x0c12130f,0x0c12130f,0x0d12130e,0x0d12130e,0x0d12130e,0x0d12130e, + 0x0d13130d,0x0e12130d,0x0e13120d,0x0e13120d,0x0e13120d,0x0e13120d,0x0e13120d,0x0f13120c, + 0x0f13120c,0x0f13120c,0x0f13120c,0x0f13120c,0x1013120b,0x1013120b,0x1013120b,0x1014110b, + 0x0c111310,0x0c111211,0x0d111210,0x0d111210,0x0d111210,0x0d111210,0x0d111210,0x0d111210, + 0x0d111210,0x0d12120f,0x0d12120f,0x0e11120f,0x0e11120f,0x0e11120f,0x0e12120e,0x0e12120e, + 0x0e12120e,0x0e12120e,0x0e12120e,0x0f11120e,0x0f11120e,0x0f11120e,0x0f12120d,0x0f12120d, + 0x0f12110e,0x0f12110e,0x0f12110e,0x0f12110e,0x1012110d,0x1012110d,0x1012110d,0x1012110d, + + 0x36050000,0x00000005,0x36030000,0x00000007,0x36020000,0x00000008,0x36010000,0x00000009, + 0x35000000,0x0000000b,0x33000000,0x0000000d,0x32000000,0x0000000e,0x30000000,0x00000010, + 0x2e000000,0x00000012,0x2d000000,0x00000013,0x2b000000,0x00000015,0x29000000,0x00000017, + 0x27000000,0x00000019,0x26000000,0x0000001a,0x24000000,0x0000001c,0x22000000,0x0000001e, + 0x20000000,0x00000020,0x1e000000,0x00000022,0x1c000000,0x00000024,0x1a000000,0x00000026, + 0x19000000,0x00000027,0x17000000,0x00000029,0x15000000,0x0000002b,0x13000000,0x0000002d, + 0x12000000,0x0000002e,0x10000000,0x00000030,0x0e000000,0x00000032,0x0d000000,0x00000033, + 0x0b000000,0x00000035,0x09000000,0x00000136,0x08000000,0x00000236,0x06000000,0x00000337, + + 0x36050000,0x00000005,0x36030000,0x00000007,0x36020000,0x00000008,0x36010000,0x00000009, + 0x35000000,0x0000000b,0x33000000,0x0000000d,0x32000000,0x0000000e,0x30000000,0x00000010, + 0x2e000000,0x00000012,0x2d000000,0x00000013,0x2b000000,0x00000015,0x29000000,0x00000017, + 0x27000000,0x00000019,0x26000000,0x0000001a,0x24000000,0x0000001c,0x22000000,0x0000001e, + 0x20000000,0x00000020,0x1e000000,0x00000022,0x1c000000,0x00000024,0x1a000000,0x00000026, + 0x19000000,0x00000027,0x17000000,0x00000029,0x15000000,0x0000002b,0x13000000,0x0000002d, + 0x12000000,0x0000002e,0x10000000,0x00000030,0x0e000000,0x00000032,0x0d000000,0x00000033, + 0x0b000000,0x00000035,0x09000000,0x00000136,0x08000000,0x00000236,0x06000000,0x00000337, + + 0x36050000,0x00000005,0x36030000,0x00000007,0x36020000,0x00000008,0x36010000,0x00000009, + 0x35000000,0x0000000b,0x33000000,0x0000000d,0x32000000,0x0000000e,0x30000000,0x00000010, + 0x2e000000,0x00000012,0x2d000000,0x00000013,0x2b000000,0x00000015,0x29000000,0x00000017, + 0x27000000,0x00000019,0x26000000,0x0000001a,0x24000000,0x0000001c,0x22000000,0x0000001e, + 0x20000000,0x00000020,0x1e000000,0x00000022,0x1c000000,0x00000024,0x1a000000,0x00000026, + 0x19000000,0x00000027,0x17000000,0x00000029,0x15000000,0x0000002b,0x13000000,0x0000002d, + 0x12000000,0x0000002e,0x10000000,0x00000030,0x0e000000,0x00000032,0x0d000000,0x00000033, + 0x0b000000,0x00000035,0x09000000,0x00000136,0x08000000,0x00000236,0x06000000,0x00000337, + + 0x2f080000,0x00000009,0x2f070000,0x0000000a,0x2f060000,0x0000000b,0x2e050000,0x0000000d, + 0x2e040000,0x0000000e,0x2d030000,0x00000010,0x2d020000,0x00000011,0x2c010000,0x00000013, + 0x2c000000,0x00000014,0x2a000000,0x00000016,0x29000000,0x00000017,0x27000000,0x00000019, + 0x26000000,0x0000001a,0x24000000,0x0000001c,0x23000000,0x0000001d,0x21000000,0x0000001f, + 0x20000000,0x00000020,0x1f000000,0x00000021,0x1d000000,0x00000023,0x1c000000,0x00000024, + 0x1a000000,0x00000026,0x19000000,0x00000027,0x17000000,0x00000029,0x16000000,0x0000002a, + 0x14000000,0x0000002c,0x13000000,0x0000012c,0x11000000,0x0000022d,0x0f000000,0x0000032e, + 0x0e000000,0x0000042e,0x0c000000,0x0000052f,0x0b000000,0x0000062f,0x0a000000,0x0000072f, + 0x2a0b0000,0x0000000b,0x2a0a0000,0x0000000c,0x2a090000,0x0000000d,0x29080000,0x0000000f, + 0x29070000,0x00000010,0x29060000,0x00000011,0x28050000,0x00000013,0x28040000,0x00000014, + 0x27030000,0x00000016,0x27020000,0x00000017,0x26010000,0x00000019,0x25010000,0x0000001a, + 0x25000000,0x0000001b,0x24000000,0x0000001c,0x22000000,0x0000001e,0x21000000,0x0000001f, + 0x20000000,0x00000020,0x1f000000,0x00000021,0x1e000000,0x00000022,0x1c000000,0x00000024, + 0x1b000000,0x00000025,0x19000000,0x00000126,0x18000000,0x00000127,0x17000000,0x00000227, + 0x15000000,0x00000328,0x14000000,0x00000428,0x12000000,0x00000529,0x11000000,0x00000629, + 0x10000000,0x00000729,0x0e000000,0x0000082a,0x0d000000,0x0000092a,0x0c000000,0x00000a2a, + 0x260d0000,0x0000000d,0x260c0000,0x0000000e,0x260b0000,0x0000000f,0x260a0000,0x00000010, + 0x26090000,0x00000011,0x25080000,0x00000013,0x25070000,0x00000014,0x25060000,0x00000015, + 0x24050000,0x00000017,0x24050000,0x00000017,0x23040000,0x00000019,0x23030000,0x0000001a, + 0x23020000,0x0000001b,0x22020000,0x0000001c,0x21010000,0x0000001e,0x20010000,0x0000001f, + 0x20000000,0x00000020,0x1e000000,0x00000121,0x1e000000,0x00000121,0x1c000000,0x00000222, + 0x1b000000,0x00000223,0x1a000000,0x00000323,0x18000000,0x00000424,0x17000000,0x00000524, + 0x16000000,0x00000525,0x15000000,0x00000625,0x14000000,0x00000725,0x13000000,0x00000825, + 0x11000000,0x00000926,0x10000000,0x00000a26,0x0f000000,0x00000b26,0x0e000000,0x00000c26, + 0x230e0000,0x0000000f,0x230e0000,0x0000000f,0x230d0000,0x00000010,0x230c0000,0x00000011, + 0x230b0000,0x00000012,0x230a0000,0x00000013,0x22090000,0x00000015,0x22080000,0x00000016, + 0x22080000,0x00000016,0x22070000,0x00000017,0x21060000,0x00000019,0x21050000,0x0000001a, + 0x20050000,0x0000001b,0x20040000,0x0000001c,0x1f030000,0x0000011d,0x1f030000,0x0000011d, + 0x1e020000,0x0000021e,0x1d010000,0x0000031f,0x1c010000,0x00000320,0x1b000000,0x00000421, + 0x1a000000,0x00000521,0x1a000000,0x00000521,0x18000000,0x00000622,0x17000000,0x00000722, + 0x16000000,0x00000822,0x15000000,0x00000823,0x14000000,0x00000923,0x13000000,0x00000a23, + 0x12000000,0x00000b23,0x11000000,0x00000c23,0x10000000,0x00000d23,0x0f000000,0x00000e23, + 0x20100000,0x00000010,0x210f0000,0x00000010,0x210e0000,0x00000011,0x210d0000,0x00000012, + 0x210c0000,0x00000013,0x200c0000,0x00000014,0x200b0000,0x00000015,0x200a0000,0x00000016, + 0x20090000,0x00000017,0x20090000,0x00000017,0x1f080000,0x00000118,0x1f070000,0x00000119, + 0x1e060000,0x0000021a,0x1e060000,0x0000021a,0x1d050000,0x0000031b,0x1d040000,0x0000031c, + 0x1c040000,0x0000041c,0x1b030000,0x0000041e,0x1b030000,0x0000051d,0x1a020000,0x0000061e, + 0x19020000,0x0000061f,0x19010000,0x0000071f,0x18010000,0x0000081f,0x17000000,0x00000920, + 0x16000000,0x00000921,0x16000000,0x00000a20,0x15000000,0x00000b20,0x13000000,0x00000c21, + 0x13000000,0x00000c21,0x12000000,0x00000d21,0x11000000,0x00000e21,0x10000000,0x00000f21, + 0x1f100000,0x00000011,0x1f100000,0x00000011,0x1f0f0000,0x00000012,0x1f0e0000,0x00000013, + 0x1f0e0000,0x00000013,0x1f0d0000,0x00000014,0x1e0c0000,0x00000115,0x1e0b0000,0x00000116, + 0x1e0b0000,0x00000116,0x1d0a0000,0x00000217,0x1d090000,0x00000218,0x1c090000,0x00000318, + 0x1c080000,0x00000319,0x1c070000,0x00000419,0x1c070000,0x00000419,0x1b060000,0x0000051a, + 0x1b050000,0x0000051b,0x1a050000,0x0000061b,0x19040000,0x0000071c,0x19040000,0x0000071c, + 0x18030000,0x0000081d,0x17030000,0x0000091d,0x17020000,0x0000091e,0x16020000,0x00000a1e, + 0x16010000,0x00000b1e,0x15010000,0x00000b1f,0x14010000,0x00000c1f,0x14000000,0x00000d1f, + 0x13000000,0x00000e1f,0x13000000,0x00000e1f,0x12000000,0x00000f1f,0x11000000,0x0000101f, + 0x1e110000,0x00000011,0x1e100000,0x00000012,0x1d100000,0x00000112,0x1d0f0000,0x00000113, + 0x1d0e0000,0x00000114,0x1c0e0000,0x00000214,0x1d0d0000,0x00000214,0x1c0c0000,0x00000216, + 0x1c0c0000,0x00000315,0x1c0b0000,0x00000316,0x1b0a0000,0x00000417,0x1b0a0000,0x00000417, + 0x1b090000,0x00000517,0x1a080000,0x00000519,0x1a080000,0x00000618,0x1a070000,0x00000619, + 0x19070000,0x00000719,0x19060000,0x0000071a,0x18060000,0x0000081a,0x18050000,0x0000081b, + 0x17050000,0x0000091b,0x17040000,0x00000a1b,0x16040000,0x00000a1c,0x16030000,0x00000b1c, + 0x15030000,0x00000c1c,0x15020000,0x00000c1d,0x14020000,0x00000d1d,0x13020000,0x00000e1d, + 0x13010000,0x00000e1e,0x13010000,0x00000f1d,0x11010000,0x0000101e,0x12000000,0x0000101e, + 0x1a110200,0x00000211,0x1a100200,0x00000311,0x19100200,0x00000312,0x1a0f0100,0x00000313, + 0x190f0100,0x00000413,0x1a0e0100,0x00000413,0x1a0e0000,0x00000414,0x190d0000,0x00000515, + 0x190d0000,0x00000515,0x190c0000,0x00000615,0x190c0000,0x00000615,0x180b0000,0x00000716, + 0x180b0000,0x00000716,0x180a0000,0x00000717,0x170a0000,0x00000817,0x18090000,0x00000817, + 0x17090000,0x00000917,0x17080000,0x00000918,0x16080000,0x00000a18,0x16070000,0x00000a19, + 0x16070000,0x00000b18,0x15070000,0x00000b19,0x15060000,0x00000c19,0x15060000,0x00000c19, + 0x15050000,0x00000d19,0x14050000,0x00000d1a,0x14040000,0x00000e1a,0x13040000,0x00010e1a, + 0x12040000,0x00010f1a,0x12030000,0x00010f1b,0x11030000,0x0002101a,0x11030000,0x0002101a, + 0x17100400,0x00000411,0x17100400,0x00000411,0x17100300,0x00000511,0x170f0300,0x00000512, + 0x170f0300,0x00000512,0x170e0300,0x00000612,0x170e0200,0x00000613,0x160e0200,0x00000713, + 0x170d0200,0x00000713,0x160d0200,0x00000714,0x160d0100,0x00000814,0x160c0100,0x00000815, + 0x150c0100,0x00000915,0x160b0100,0x00000915,0x160b0000,0x00000916,0x160b0000,0x00000a15, + 0x160a0000,0x00000a16,0x150a0000,0x00000b16,0x15090000,0x00000b17,0x15090000,0x00010b16, + 0x14090000,0x00010c16,0x14080000,0x00010c17,0x13080000,0x00010d17,0x13070000,0x00020d17, + 0x13070000,0x00020d17,0x12070000,0x00020e17,0x13060000,0x00020e17,0x12060000,0x00030e17, + 0x12050000,0x00030f17,0x11050000,0x00030f18,0x11050000,0x00031017,0x11040000,0x00041017, + 0x14100600,0x00000610,0x15100500,0x00000610,0x150f0500,0x00000611,0x150f0500,0x00000611, + 0x150f0400,0x00000711,0x150e0400,0x00000712,0x150e0400,0x00000712,0x140e0400,0x00000812, + 0x150d0300,0x00000813,0x150d0300,0x00000813,0x140d0300,0x00000913,0x150c0300,0x00000913, + 0x140c0200,0x00010914,0x140c0200,0x00010a13,0x140b0200,0x00010a14,0x140b0200,0x00010a14, + 0x140b0100,0x00010b14,0x140a0100,0x00020b14,0x130a0100,0x00020b15,0x130a0100,0x00020c14, + 0x13090100,0x00020c15,0x13090000,0x00030c15,0x12090000,0x00030d15,0x12080000,0x00030d16, + 0x12080000,0x00030d16,0x11080000,0x00040e15,0x12070000,0x00040e15,0x11070000,0x00040e16, + 0x11070000,0x00040f15,0x11060000,0x00050f15,0x10060000,0x00050f16,0x10060000,0x00051015, + 0x140f0700,0x0000070f,0x140f0600,0x00000710,0x140f0600,0x00000710,0x130f0600,0x00000711, + 0x130e0600,0x00010810,0x130e0500,0x00010811,0x130e0500,0x00010811,0x120e0500,0x00010911, + 0x130d0500,0x00010911,0x130d0400,0x00010912,0x130d0400,0x00020911,0x130c0400,0x00020a11, + 0x120c0400,0x00020a12,0x130c0300,0x00020a12,0x120c0300,0x00020b12,0x120b0300,0x00030b12, + 0x120b0300,0x00030b12,0x120b0300,0x00030b12,0x120b0200,0x00030c12,0x120a0200,0x00030c13, + 0x110a0200,0x00040c13,0x110a0200,0x00040c13,0x11090200,0x00040d13,0x11090100,0x00040d14, + 0x11090100,0x00050d13,0x10090100,0x00050e13,0x11080100,0x00050e13,0x10080100,0x00050e14, + 0x10080100,0x00060e13,0x10070000,0x00060f14,0x10070000,0x00060f14,0x10070000,0x00060f14, + 0x120f0701,0x0001070f,0x120e0701,0x0001080f,0x120e0701,0x0001080f,0x120e0701,0x0001080f, + 0x120e0600,0x00020810,0x110e0600,0x00020910,0x120d0600,0x00020910,0x120d0600,0x00020910, + 0x120d0600,0x00020910,0x120d0500,0x00020a10,0x110d0500,0x00030a10,0x110c0500,0x00030a11, + 0x110c0500,0x00030a11,0x110c0400,0x00030a12,0x110c0400,0x00030b11,0x110b0400,0x00040b11, + 0x110b0400,0x00040b11,0x110b0400,0x00040b11,0x110b0300,0x00040c11,0x110a0300,0x00040c12, + 0x110a0300,0x00050c11,0x100a0300,0x00050c12,0x0f0a0300,0x00050d12,0x100a0200,0x00050d12, + 0x10090200,0x00060d12,0x10090200,0x00060d12,0x0f090200,0x00060e12,0x0f090200,0x00060e12, + 0x10080200,0x00060e12,0x0f080100,0x00070e13,0x0f080100,0x00070e13,0x0f080100,0x00070f12, + 0x100e0802,0x0002080e,0x100e0802,0x0002080e,0x110e0702,0x0002080e,0x110d0702,0x0002080f, + 0x100d0701,0x0003090f,0x100d0701,0x0003090f,0x100d0701,0x0003090f,0x100d0601,0x00030910, + 0x100d0601,0x00030a0f,0x100c0601,0x00030a10,0x100c0601,0x00040a0f,0x100c0601,0x00040a0f, + 0x100c0500,0x00040a11,0x100c0500,0x00040b10,0x100c0500,0x00040b10,0x100b0500,0x00040b11, + 0x100b0500,0x00050b10,0x100b0500,0x00050b10,0x100b0400,0x00050c10,0x100b0400,0x00050c10, + 0x100a0400,0x00050c11,0x100a0400,0x00060c10,0x0f0a0400,0x00060c11,0x0f0a0300,0x00060d11, + 0x0f0a0300,0x00060d11,0x0f090300,0x00070d11,0x0f090300,0x00070d11,0x0f090300,0x00070d11, + 0x0e090300,0x00070e11,0x0f090200,0x00070e11,0x0f080200,0x00080e11,0x0f080200,0x00080e11, + 0x0f0d0803,0x0003080e,0x0f0d0803,0x0003080e,0x0f0d0802,0x0003090e,0x0f0d0802,0x0003090e, + 0x0f0d0702,0x0003090f,0x0f0d0702,0x0003090f,0x0f0d0702,0x0004090e,0x0f0c0702,0x0004090f, + 0x0f0c0702,0x00040a0e,0x0f0c0702,0x00040a0e,0x0f0c0601,0x00040a10,0x0f0c0601,0x00040a10, + 0x0f0c0601,0x00050a0f,0x0e0c0601,0x00050b0f,0x0f0b0601,0x00050b0f,0x0f0b0601,0x00050b0f, + 0x0f0b0501,0x00050b10,0x0f0b0501,0x00060b0f,0x0f0b0501,0x00060b0f,0x0f0b0500,0x00060c0f, + 0x0f0b0500,0x00060c0f,0x0f0a0500,0x00060c10,0x0f0a0400,0x00070c10,0x0f0a0400,0x00070c10, + 0x0e0a0400,0x00070d10,0x0e0a0400,0x00070d10,0x0e0a0400,0x00070d10,0x0e090400,0x00080d10, + 0x0e090300,0x00080d11,0x0e090300,0x00080d11,0x0e090300,0x00080e10,0x0e090300,0x00080e10, + 0x0f0d0803,0x0003080e,0x0e0d0803,0x0004090d,0x0e0d0803,0x0004090d,0x0e0d0803,0x0004090d, + 0x0f0c0803,0x0004090d,0x0f0c0803,0x0004090d,0x0f0c0703,0x0004090e,0x0e0c0703,0x00040a0e, + 0x0e0c0702,0x00050a0e,0x0e0c0702,0x00050a0e,0x0e0c0702,0x00050a0e,0x0e0c0702,0x00050a0e, + 0x0e0b0702,0x00050a0f,0x0e0b0602,0x00050a10,0x0e0b0602,0x00060b0e,0x0e0b0602,0x00060b0e, + 0x0e0b0601,0x00060b0f,0x0e0b0601,0x00060b0f,0x0e0b0601,0x00060b0f,0x0e0b0501,0x00060b10, + 0x0e0a0501,0x00070c0f,0x0e0a0501,0x00070c0f,0x0e0a0501,0x00070c0f,0x0e0a0501,0x00070c0f, + 0x0e0a0501,0x00070c0f,0x0d0a0501,0x00080c0f,0x0e0a0400,0x00080d0f,0x0e0a0400,0x00080d0f, + 0x0e090400,0x00080d10,0x0e090400,0x00080d10,0x0e090400,0x00080d10,0x0e090400,0x00090d0f, + 0x0c0c0905,0x0005090c,0x0d0c0904,0x0005090c,0x0d0c0804,0x0005090d,0x0d0c0804,0x0005090d, + 0x0d0c0804,0x0005090d,0x0d0c0804,0x0005090d,0x0d0c0804,0x0005090d,0x0d0b0804,0x00050a0d, + 0x0c0b0804,0x00060a0d,0x0c0b0804,0x00060a0d,0x0d0b0703,0x00060a0e,0x0d0b0703,0x00060a0e, + 0x0d0b0703,0x00060a0e,0x0d0b0703,0x00060a0e,0x0d0b0703,0x00060a0e,0x0c0b0703,0x00070b0d, + 0x0c0b0703,0x00070b0d,0x0c0b0703,0x00070b0d,0x0d0b0603,0x00070b0d,0x0d0a0602,0x00070b0f, + 0x0d0a0602,0x00070b0f,0x0d0a0602,0x00070b0f,0x0d0a0602,0x00080b0e,0x0c0a0602,0x00080c0e, + 0x0c0a0602,0x00080c0e,0x0c0a0602,0x00080c0e,0x0c0a0602,0x00080c0e,0x0d0a0502,0x00080c0e, + 0x0c0a0502,0x00090c0e,0x0d090501,0x00090c0f,0x0d090501,0x00090c0f,0x0d090501,0x00090d0e, + 0x0c0b0905,0x0005090d,0x0c0b0905,0x0006090c,0x0c0b0905,0x0006090c,0x0c0b0905,0x0006090c, + 0x0c0b0805,0x0006090d,0x0c0b0805,0x0006090d,0x0c0b0805,0x0006090d,0x0c0b0805,0x00060a0c, + 0x0c0b0805,0x00060a0c,0x0c0b0804,0x00060a0d,0x0c0b0804,0x00070a0c,0x0c0b0804,0x00070a0c, + 0x0c0b0804,0x00070a0c,0x0c0b0804,0x00070a0c,0x0c0b0704,0x00070a0d,0x0c0b0704,0x00070a0d, + 0x0c0a0704,0x00070a0e,0x0c0a0704,0x00070b0d,0x0c0a0704,0x00070b0d,0x0c0a0703,0x00080b0d, + 0x0c0a0703,0x00080b0d,0x0c0a0703,0x00080b0d,0x0c0a0703,0x00080b0d,0x0c0a0703,0x00080b0d, + 0x0c0a0603,0x00080b0e,0x0c0a0603,0x00080b0e,0x0c0a0603,0x00090b0d,0x0b0a0603,0x00090c0d, + 0x0b0a0603,0x00090c0d,0x0b0a0603,0x00090c0d,0x0c090602,0x00090c0e,0x0c090602,0x00090c0e +}; + __s32 DE_Set_Reg_Base(__u32 sel, __u32 address) { image_reg_base[sel] = address; @@ -559,10 +793,9 @@ __s32 DE_BE_Sprite_Set_Palette_Table(__u32 sel, __u32 address, __u32 offset, __u return 0; } -//brightness -100~100 -//contrast -100~100 -//saturaion -100~100 -__s32 DE_BE_Set_Enhance(__u8 sel,__u32 brightness, __u32 contrast, __u32 saturaion, __u32 hue) +//out_csc: 0:rgb, 1:yuv for tv, 2:yuv for hdmi +//out_color_range: 0:16~255, 1:0~255, 2:16~235 +__s32 DE_BE_Set_Enhance_ex(__u8 sel, __u32 out_csc, __u32 out_color_range, __u32 enhance_en, __u32 brightness, __u32 contrast, __u32 saturaion, __u32 hue) { __s32 i_bright; __s32 i_contrast; @@ -571,15 +804,15 @@ __s32 DE_BE_Set_Enhance(__u8 sel,__u32 brightness, __u32 contrast, __u32 saturai __scal_matrix4x4 matrixEn; __scal_matrix4x4 matrixconv, *ptmatrix; __scal_matrix4x4 matrixresult; - __s32 *pt; - __u32 i; + __s64 *pt; __s32 sinv, cosv; //sin_tab: 7 bit fractional - + __s32 i; + __scal_matrix4x4 tmpcoeff; brightness = brightness>100?100:(brightness<0?0:brightness); contrast = contrast>100?100:(contrast<0?0:contrast); saturaion = saturaion>100?100:(saturaion<0?0:saturaion); - + i_bright = (__s32)(brightness*64/100); i_saturaion = (__s32)(saturaion*64/100); i_contrast = (__s32)(contrast*64/100); @@ -587,7 +820,8 @@ __s32 DE_BE_Set_Enhance(__u8 sel,__u32 brightness, __u32 contrast, __u32 saturai sinv = image_enhance_tab[8*12 + (i_hue&0x3f)]; cosv = image_enhance_tab[8*12 + 8*8 + (i_hue&0x3f)]; - + + //calculate enhance matrix matrixEn.x00 = i_contrast << 5; matrixEn.x01 = 0; matrixEn.x02 = 0; @@ -605,47 +839,167 @@ __s32 DE_BE_Set_Enhance(__u8 sel,__u32 brightness, __u32 contrast, __u32 saturai matrixEn.x32 = 0; matrixEn.x33 = 1024; - ptmatrix = (__scal_matrix4x4 *)((__u32)image_enhance_tab + (1<<7)); - iDE_SCAL_Matrix_Mul(matrixEn, *ptmatrix, &matrixconv); - ptmatrix = (__scal_matrix4x4 *)((__u32)image_enhance_tab + (1<<7) + 0x40); - iDE_SCAL_Matrix_Mul(*ptmatrix, matrixconv, &matrixconv); - - matrixresult.x00 = matrixconv.x01; matrixresult.x01 = matrixconv.x00; - matrixresult.x02 = matrixconv.x02; matrixresult.x03 = matrixconv.x03; - matrixresult.x10 = matrixconv.x11; matrixresult.x11 = matrixconv.x10; - matrixresult.x12 = matrixconv.x12; matrixresult.x13 = matrixconv.x13; - matrixresult.x20 = matrixconv.x21; matrixresult.x21 = matrixconv.x20; - matrixresult.x22 = matrixconv.x22; matrixresult.x23 = matrixconv.x23; - matrixresult.x30 = matrixconv.x31; matrixresult.x31 = matrixconv.x30; - matrixresult.x32 = matrixconv.x32; matrixresult.x33 = matrixconv.x33; - + if(out_csc == 0) { //RGB output + if(enhance_en == 1) { + for (i=0; i<16; i++) { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + 0x20 + i) <<32 ) >>32; //bt709 rgb2yuv coeff + // *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + i) <<32 ) >>32; //bt601 rgb2yuv coeff + // *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + 0x40 + i) <<32 ) >>32; //YCC rgb2yuv coeff + } + + ptmatrix = &tmpcoeff; + + //convolution of enhance matrix and rgb2yuv matrix + iDE_SCAL_Matrix_Mul(matrixEn, *ptmatrix, &matrixconv); + + for(i=0; i<16; i++) { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + 0x30 + i) <<32)>>32; //bt709 yuv2rgb coeff + // *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + 0x10 + i) <<32)>>32; //bt601 yuv2rgb coeff + // *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + 0x50 + i) <<32)>>32; //YCC yuv2rgb coeff + } + + ptmatrix = &tmpcoeff; + + //convert to RGB + iDE_SCAL_Matrix_Mul(*ptmatrix, matrixconv, &matrixconv); + + //rearrange CSC coeff + matrixresult.x00 = (matrixconv.x00+8)/16; matrixresult.x01 = (matrixconv.x01+8)/16; + matrixresult.x02 = (matrixconv.x02+8)/16; matrixresult.x03 = (matrixconv.x03+512)/1024; + matrixresult.x10 = (matrixconv.x10+8)/16; matrixresult.x11 = (matrixconv.x11+8)/16; + matrixresult.x12 = (matrixconv.x12+8)/16; matrixresult.x13 = (matrixconv.x13+512)/1024; + matrixresult.x20 = (matrixconv.x20+8)/16; matrixresult.x21 = (matrixconv.x21+8)/16; + matrixresult.x22 = (matrixconv.x22+8)/16; matrixresult.x23 = (matrixconv.x23+512)/1024; + matrixresult.x30 = (matrixconv.x30+8)/16; matrixresult.x31 = (matrixconv.x31+8)/16; + matrixresult.x32 = (matrixconv.x32+8)/16; matrixresult.x33 = (matrixconv.x33+512)/1024; + } else { + matrixresult.x00 = 0x400; matrixresult.x01 = 0; + matrixresult.x02 = 0; matrixresult.x03 = 0; + matrixresult.x10 = 0; matrixresult.x11 = 0x400; + matrixresult.x12 = 0; matrixresult.x13 = 0; + matrixresult.x20 = 0; matrixresult.x21 = 0; + matrixresult.x22 = 0x400; matrixresult.x23 = 0; + matrixresult.x30 = 0; matrixresult.x31 = 0; + matrixresult.x32 = 0; matrixresult.x33 = 0x400; + } + + //OUTPUT RANGE MODIFY + ptmatrix = &matrixresult; + + if (out_color_range == DISP_COLOR_RANGE_16_255) { + matrixconv.x00 = 0x03c4; matrixconv.x01 = 0x0000; + matrixconv.x02 = 0x0000; matrixconv.x03 = 0x0100; + matrixconv.x10 = 0x0000; matrixconv.x11 = 0x03c4; + matrixconv.x12 = 0x0000; matrixconv.x13 = 0x0100; + matrixconv.x20 = 0x0000; matrixconv.x21 = 0x0000; + matrixconv.x22 = 0x03c4; matrixconv.x23 = 0x0100; + matrixconv.x30 = 0x0000; matrixconv.x31 = 0x0000; + matrixconv.x32 = 0x0000; matrixconv.x33 = 0x0100; + } else if (out_color_range == DISP_COLOR_RANGE_16_235) { + matrixconv.x00 = 0x0370; matrixconv.x01 = 0x0000; + matrixconv.x02 = 0x0000; matrixconv.x03 = 0x0100; + matrixconv.x10 = 0x0000; matrixconv.x11 = 0x0370; + matrixconv.x12 = 0x0000; matrixconv.x13 = 0x0100; + matrixconv.x20 = 0x0000; matrixconv.x21 = 0x0000; + matrixconv.x22 = 0x0370; matrixconv.x23 = 0x0100; + } else { //DISP_COLOR_RANGE_0_255 + matrixconv.x00 = 0x0400; matrixconv.x01 = 0x0000; + matrixconv.x02 = 0x0000; matrixconv.x03 = 0x0000; + matrixconv.x10 = 0x0000; matrixconv.x11 = 0x0400; + matrixconv.x12 = 0x0000; matrixconv.x13 = 0x0000; + matrixconv.x20 = 0x0000; matrixconv.x21 = 0x0000; + matrixconv.x22 = 0x0400; matrixconv.x23 = 0x0000; + } + + iDE_SCAL_Matrix_Mul(matrixconv, *ptmatrix, &matrixresult); + + matrixresult.x00 = matrixresult.x00; matrixresult.x01 = matrixresult.x01; + matrixresult.x02 = matrixresult.x02; matrixresult.x03 = matrixresult.x03 + 8; + matrixresult.x10 = matrixresult.x10; matrixresult.x11 = matrixresult.x11; + matrixresult.x12 = matrixresult.x12; matrixresult.x13 = matrixresult.x13 + 8; + matrixresult.x20 = matrixresult.x20; matrixresult.x21 = matrixresult.x21; + matrixresult.x22 = matrixresult.x22; matrixresult.x23 = matrixresult.x23 + 8; + } else if (out_csc == 1) { //YUV for tv(range 16-235) + for (i=0; i<16; i++) { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + i) <<32)>>32; //bt601 rgb2yuv coeff + } + + if (enhance_en == 1) { + //convolution of enhance matrix and rgb2yuv matrix + + ptmatrix = &tmpcoeff; + + iDE_SCAL_Matrix_Mul(matrixEn, *ptmatrix, &matrixconv); + + matrixresult.x00 = matrixconv.x00/4; matrixresult.x01 = matrixconv.x01/4; + matrixresult.x02 = matrixconv.x02/4; matrixresult.x03 = matrixconv.x03/256 + 8; + matrixresult.x10 = matrixconv.x10/4; matrixresult.x11 = matrixconv.x11/4; + matrixresult.x12 = matrixconv.x12/4; matrixresult.x13 = matrixconv.x13/256 + 8; + matrixresult.x20 = matrixconv.x20/4; matrixresult.x21 = matrixconv.x21/4; + matrixresult.x22 = matrixconv.x22/4; matrixresult.x23 = matrixconv.x23/256 + 8; + } else { + matrixresult.x00 = tmpcoeff.x00/4; matrixresult.x01 = tmpcoeff.x01/4; + matrixresult.x02 = tmpcoeff.x02/4; matrixresult.x03 = tmpcoeff.x03/256 + 8; + matrixresult.x10 = tmpcoeff.x10/4; matrixresult.x11 = tmpcoeff.x11/4; + matrixresult.x12 = tmpcoeff.x12/4; matrixresult.x13 = tmpcoeff.x13/256 + 8; + matrixresult.x20 = tmpcoeff.x20/4; matrixresult.x21 = tmpcoeff.x21/4; + matrixresult.x22 = tmpcoeff.x22/4; matrixresult.x23 = tmpcoeff.x23/256 + 8; + } + } else { //if(out_csc == 2)//YUV for HDMI(range 16-235) + for(i=0; i<16; i++) { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + i) <<32)>>32; //bt601 rgb2yuv coeff + } + + if(enhance_en == 1) { + //convolution of enhance matrix and rgb2yuv matrix + + ptmatrix = &tmpcoeff; + + iDE_SCAL_Matrix_Mul(matrixEn, *ptmatrix, &matrixconv); + + matrixresult.x00 = matrixconv.x20/4; matrixresult.x01 = matrixconv.x21/4; + matrixresult.x02 = matrixconv.x22/4; matrixresult.x03 = matrixconv.x23/256 + 8; + matrixresult.x10 = matrixconv.x00/4; matrixresult.x11 = matrixconv.x01/4; + matrixresult.x12 = matrixconv.x02/4; matrixresult.x13 = matrixconv.x03/256 + 8; + matrixresult.x20 = matrixconv.x10/4; matrixresult.x21 = matrixconv.x11/4; + matrixresult.x22 = matrixconv.x12/4; matrixresult.x23 = matrixconv.x13/256 + 8; + } else { + matrixresult.x00 = tmpcoeff.x20/4; matrixresult.x01 = tmpcoeff.x21/4; + matrixresult.x02 = tmpcoeff.x22/4; matrixresult.x03 = tmpcoeff.x23/256 + 8; + matrixresult.x10 = tmpcoeff.x00/4; matrixresult.x11 = tmpcoeff.x01/4; + matrixresult.x12 = tmpcoeff.x02/4; matrixresult.x13 = tmpcoeff.x03/256 + 8; + matrixresult.x20 = tmpcoeff.x10/4; matrixresult.x21 = tmpcoeff.x11/4; + matrixresult.x22 = tmpcoeff.x12/4; matrixresult.x23 = tmpcoeff.x13/256 + 8; + } + } - //data bit convert, 1 bit sign, 2 bit integer, 10 bits fractrional for coefficient; 1 bit sign,9 bit integer, 4 bit fractional for constant //range limited iDE_SCAL_Csc_Lmt(&matrixresult.x00, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x01, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x02, -8191, 8191, 0, 16383); - iDE_SCAL_Csc_Lmt(&matrixresult.x03, -16383, 16383, 6, 32767); + iDE_SCAL_Csc_Lmt(&matrixresult.x03, -16383, 16383, 0, 32767); iDE_SCAL_Csc_Lmt(&matrixresult.x10, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x11, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x12, -8191, 8191, 0, 16383); - iDE_SCAL_Csc_Lmt(&matrixresult.x13, -16383, 16383, 6, 32767); + iDE_SCAL_Csc_Lmt(&matrixresult.x13, -16383, 16383, 0, 32767); iDE_SCAL_Csc_Lmt(&matrixresult.x20, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x21, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x22, -8191, 8191, 0, 16383); - iDE_SCAL_Csc_Lmt(&matrixresult.x23, -16383, 16383, 6, 32767); - - //write csc register - pt = &(matrixresult.x00); + iDE_SCAL_Csc_Lmt(&matrixresult.x23, -16383, 16383, 0, 32767); + + //write csc register + pt = (__s64*)&(matrixresult.x00); for(i=0;i<4;i++) { - DE_BE_WUINT32(sel, DE_BE_OUT_COLOR_G_COEFF_OFF+ 4*i, *(pt + i)); - DE_BE_WUINT32(sel, DE_BE_OUT_COLOR_R_COEFF_OFF+ 4*i, *(pt + 4 + i)); - DE_BE_WUINT32(sel, DE_BE_OUT_COLOR_B_COEFF_OFF+ 4*i, *(pt + 8 + i)); + DE_BE_WUINT32(sel, DE_BE_OUT_COLOR_R_COEFF_OFF+ 4*i, (__u32 )(*(pt + i))); + DE_BE_WUINT32(sel, DE_BE_OUT_COLOR_G_COEFF_OFF+ 4*i, (__u32 )(*(pt + 4 + i))); + DE_BE_WUINT32(sel, DE_BE_OUT_COLOR_B_COEFF_OFF+ 4*i, (__u32 )(*(pt + 8 + i))); } - - return 0; + + DE_BE_enhance_enable(sel, 1); + + return 0; } __s32 DE_BE_enhance_enable(__u32 sel, __bool enable) @@ -662,78 +1016,9 @@ __s32 DE_BE_deflicker_enable(__u32 sel, __bool enable) return 0; } - -__s32 DE_BE_output_csc_enable(__u32 sel, __bool enable) -{ - DE_BE_WUINT32(sel, DE_BE_MODE_CTL_OFF,(DE_BE_RUINT32(sel, DE_BE_MODE_CTL_OFF)&(~(1<<5))) | (enable<<5)); - - return 0; -} - __s32 DE_BE_Set_Outitl_enable(__u32 sel, __bool enable) { DE_BE_WUINT32(sel, DE_BE_MODE_CTL_OFF,(DE_BE_RUINT32(sel, DE_BE_MODE_CTL_OFF)&(~(1<<28))) | (enable<<28)); - - return 0; -} - -__s32 DE_BE_Output_Cfg_Csc_Coeff(__u32 sel, __bool bout_yuv, __u32 out_color_range) -{ - if(bout_yuv) - { - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 0) & 0x0000ffff) | (0x0274<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 4) & 0x0000ffff) | (0x00bb<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 8) & 0x0000ffff) | (0x003f<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_CONSTANT_OFF , (DE_BE_RUINT32(sel, DE_BE_YG_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 0) & 0x0000ffff) | (0x1ea5<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 4) & 0x0000ffff) | (0x1f98<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 8) & 0x0000ffff) | (0x01c1<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_CONSTANT_OFF, (DE_BE_RUINT32(sel, DE_BE_UR_CONSTANT_OFF) & 0x0000ffff) | (0x0800<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 0) & 0x0000ffff) | (0x1e67<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 4) & 0x0000ffff) | (0x01c1<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 8) & 0x0000ffff) | (0x1fd7<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_CONSTANT_OFF, (DE_BE_RUINT32(sel, DE_BE_VB_CONSTANT_OFF) & 0x0000ffff) | (0x0800<<16)); - DE_BE_output_csc_enable(sel, 1); - } - else - { - if(out_color_range == DISP_COLOR_RANGE_16_255) - { - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 0) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 4) & 0x0000ffff) | (0x03c4<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 8) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_CONSTANT_OFF , (DE_BE_RUINT32(sel, DE_BE_YG_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 0) & 0x0000ffff) | (0x03c4<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 4) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 8) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_CONSTANT_OFF, (DE_BE_RUINT32(sel, DE_BE_UR_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 0) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 4) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 8) & 0x0000ffff) | (0x03c4<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_CONSTANT_OFF, (DE_BE_RUINT32(sel, DE_BE_VB_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_output_csc_enable(sel, 1); - } - else if(out_color_range == DISP_COLOR_RANGE_16_235) - { - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 0) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 4) & 0x0000ffff) | (0x0370<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_YG_COEFF_OFF + 8) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_YG_CONSTANT_OFF , (DE_BE_RUINT32(sel, DE_BE_YG_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 0) & 0x0000ffff) | (0x0370<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 4) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_UR_COEFF_OFF + 8) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_UR_CONSTANT_OFF, (DE_BE_RUINT32(sel, DE_BE_UR_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 0, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 0) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 4, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 4) & 0x0000ffff) | (0x0000<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_COEFF_OFF + 8, (DE_BE_RUINT32(sel, DE_BE_VB_COEFF_OFF + 8) & 0x0000ffff) | (0x0370<<16)); - DE_BE_WUINT32(sel, DE_BE_VB_CONSTANT_OFF, (DE_BE_RUINT32(sel, DE_BE_VB_CONSTANT_OFF) & 0x0000ffff) | (0x0100<<16)); - DE_BE_output_csc_enable(sel, 1); - } - else - { - DE_BE_output_csc_enable(sel, 0); - } - } return 0; } diff --git a/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.c b/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.c old mode 100755 new mode 100644 index 5151518807fb2e..ef2982974b9b8a --- a/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.c +++ b/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.c @@ -1367,7 +1367,7 @@ __s32 iDE_SCAL_Matrix_Mul(__scal_matrix4x4 in1, __scal_matrix4x4 in2, __scal_mat //********************************************************************************************* -// function : iDE_SCAL_Csc_Lmt(__s32 *value, __s32 min, __s32 max, __s32 shift, __s32 validbit) +// function : iDE_SCAL_Csc_Lmt(__s64 *value, __s32 min, __s32 max, __s32 shift, __s32 validbit) // description : csc coefficient and constant limited // parameters : // value @@ -1375,9 +1375,9 @@ __s32 iDE_SCAL_Matrix_Mul(__scal_matrix4x4 in1, __scal_matrix4x4 in2, __scal_mat // return : // success //*********************************************************************************************** -__s32 iDE_SCAL_Csc_Lmt(__s32 *value, __s32 min, __s32 max, __s32 shift, __s32 validbit) +__s32 iDE_SCAL_Csc_Lmt(__s64 *value, __s32 min, __s32 max, __s32 shift, __s32 validbit) { - __s32 tmp; + __s64 tmp; tmp = (*value)>>shift; if(tmp < min) *value = min & validbit; @@ -1389,7 +1389,6 @@ __s32 iDE_SCAL_Csc_Lmt(__s32 *value, __s32 min, __s32 max, __s32 shift, __s32 va return 0; } - //********************************************************************************************* // function : DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u8 out_csc_mode, __u8 incs, __u8 outcs, // __s32 bright, __s32 contrast, __s32 saturaion, __s32 hue, @@ -1424,8 +1423,8 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u8 out_csc_mode { __scal_matrix4x4 matrixEn; __scal_matrix4x4 matrixconv, *ptmatrix; - __scal_matrix4x4 matrixresult; - __s32 *pt; + __scal_matrix4x4 matrixresult, tmpcoeff; + __s64 *pt; __u32 i; __s32 sinv, cosv; //sin_tab: 7 bit fractional @@ -1436,7 +1435,7 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u8 out_csc_mode sinv = image_enhance_tab[8*12 + (hue&0x3f)]; cosv = image_enhance_tab[8*12 + 8*8 + (hue&0x3f)]; - + matrixEn.x00 = contrast << 5; matrixEn.x01 = 0; matrixEn.x02 = 0; @@ -1456,46 +1455,75 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u8 out_csc_mode if((incs == 0) && (outcs == 0)) //rgb to rgb { - ptmatrix = (__scal_matrix4x4 *)((__u32)image_enhance_tab + (in_csc_mode<<7) + 0x40); + for(i=0; i<16; i++) + { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + (in_csc_mode<<5) + i) <<32)>>32; //RGB2YUV + + } + + ptmatrix = &tmpcoeff; + + //convolution of enhance matrix and rgb2yuv matrix iDE_SCAL_Matrix_Mul(matrixEn, *ptmatrix, &matrixconv); - ptmatrix = (__scal_matrix4x4 *)((__u32)image_enhance_tab + (in_csc_mode<<7)); + + for(i=0; i<16; i++) + { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + (in_csc_mode<<5) + 0x10 + i) <<32)>>32; //YUV2RGB + } + + ptmatrix = &tmpcoeff; + + //convert to RGB iDE_SCAL_Matrix_Mul(*ptmatrix, matrixconv, &matrixconv); - matrixresult.x00 = matrixconv.x11; matrixresult.x01 = matrixconv.x10; - matrixresult.x02 = matrixconv.x12; matrixresult.x03 = matrixconv.x13; - matrixresult.x10 = matrixconv.x01; matrixresult.x11 = matrixconv.x00; - matrixresult.x12 = matrixconv.x02; matrixresult.x13 = matrixconv.x03; - matrixresult.x20 = matrixconv.x21; matrixresult.x21 = matrixconv.x20; - matrixresult.x22 = matrixconv.x22; matrixresult.x23 = matrixconv.x23; - matrixresult.x30 = matrixconv.x31; matrixresult.x31 = matrixconv.x30; - matrixresult.x32 = matrixconv.x32; matrixresult.x33 = matrixconv.x33; - + + matrixresult.x00 = (matrixconv.x11+8)/16; matrixresult.x01 = (matrixconv.x10+8)/16; + matrixresult.x02 = (matrixconv.x12+8)/16; matrixresult.x03 = (matrixconv.x13+512)/1024; + matrixresult.x10 = (matrixconv.x01+8)/16; matrixresult.x11 = (matrixconv.x00+8)/16; + matrixresult.x12 = (matrixconv.x02+8)/16; matrixresult.x13 = (matrixconv.x03+512)/1024; + matrixresult.x20 = (matrixconv.x21+8)/16; matrixresult.x21 = (matrixconv.x20+8)/16; + matrixresult.x22 = (matrixconv.x22+8)/16; matrixresult.x23 = (matrixconv.x23+512)/1024; + matrixresult.x30 = (matrixconv.x31+8)/16; matrixresult.x31 = (matrixconv.x30+8)/16; + matrixresult.x32 = (matrixconv.x32+8)/16; matrixresult.x33 = (matrixconv.x33+8)/16; + } else if((incs == 1) && (outcs == 0)) //yuv to rgb { - ptmatrix = (__scal_matrix4x4 *)((__u32)image_enhance_tab + (in_csc_mode<<7) + 0x40); + for(i=0; i<16; i++) + { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + (in_csc_mode<<5) + 0x10 + i) <<32)>>32; //YUV2RGB + } + + ptmatrix = &tmpcoeff; + iDE_SCAL_Matrix_Mul(*ptmatrix, matrixEn, &matrixconv); - matrixresult.x00 = matrixconv.x10; matrixresult.x01 = matrixconv.x11; - matrixresult.x02 = matrixconv.x12; matrixresult.x03 = matrixconv.x13; - matrixresult.x10 = matrixconv.x00; matrixresult.x11 = matrixconv.x01; - matrixresult.x12 = matrixconv.x02; matrixresult.x13 = matrixconv.x03; - matrixresult.x20 = matrixconv.x20; matrixresult.x21 = matrixconv.x21; - matrixresult.x22 = matrixconv.x22; matrixresult.x23 = matrixconv.x23; - matrixresult.x30 = matrixconv.x30; matrixresult.x31 = matrixconv.x31; - matrixresult.x32 = matrixconv.x32; matrixresult.x33 = matrixconv.x33; - + matrixresult.x00 = matrixconv.x10/4; matrixresult.x01 = matrixconv.x11/4; + matrixresult.x02 = matrixconv.x12/4; matrixresult.x03 = matrixconv.x13/256; + matrixresult.x10 = matrixconv.x00/4; matrixresult.x11 = matrixconv.x01/4; + matrixresult.x12 = matrixconv.x02/4; matrixresult.x13 = matrixconv.x03/256; + matrixresult.x20 = matrixconv.x20/4; matrixresult.x21 = matrixconv.x21/4; + matrixresult.x22 = matrixconv.x22/4; matrixresult.x23 = matrixconv.x23/256; + matrixresult.x30 = matrixconv.x30/4; matrixresult.x31 = matrixconv.x31/4; + matrixresult.x32 = matrixconv.x32/4; matrixresult.x33 = matrixconv.x33/4; + } else if((incs == 0) && (outcs == 1)) //rgb to yuv { - ptmatrix = (__scal_matrix4x4 *)((__u32)image_enhance_tab + (in_csc_mode<<7)); + for(i=0; i<16; i++) + { + *((__s64 *)(&tmpcoeff.x00) + i) = ((__s64)*(image_enhance_tab + (in_csc_mode<<5) + i) <<32)>>32; //RGB2YUV + } + + ptmatrix = &tmpcoeff; + iDE_SCAL_Matrix_Mul(matrixEn, *ptmatrix, &matrixconv); - matrixresult.x00 = matrixconv.x01; matrixresult.x01 = matrixconv.x00; - matrixresult.x02 = matrixconv.x02; matrixresult.x03 = matrixconv.x03; - matrixresult.x10 = matrixconv.x11; matrixresult.x11 = matrixconv.x10; - matrixresult.x12 = matrixconv.x12; matrixresult.x13 = matrixconv.x13; - matrixresult.x20 = matrixconv.x21; matrixresult.x21 = matrixconv.x20; - matrixresult.x22 = matrixconv.x22; matrixresult.x23 = matrixconv.x23; - matrixresult.x30 = matrixconv.x31; matrixresult.x31 = matrixconv.x30; - matrixresult.x32 = matrixconv.x32; matrixresult.x33 = matrixconv.x33; + matrixresult.x00 = matrixconv.x01/4; matrixresult.x01 = matrixconv.x00/4; + matrixresult.x02 = matrixconv.x02/4; matrixresult.x03 = matrixconv.x03/256; + matrixresult.x10 = matrixconv.x11/4; matrixresult.x11 = matrixconv.x10/4; + matrixresult.x12 = matrixconv.x12/4; matrixresult.x13 = matrixconv.x13/256; + matrixresult.x20 = matrixconv.x21/4; matrixresult.x21 = matrixconv.x20/4; + matrixresult.x22 = matrixconv.x22/4; matrixresult.x23 = matrixconv.x23/256; + matrixresult.x30 = matrixconv.x31/4; matrixresult.x31 = matrixconv.x30/4; + matrixresult.x32 = matrixconv.x32/4; matrixresult.x33 = matrixconv.x33/4; } else //yuv to yuv { @@ -1507,18 +1535,18 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u8 out_csc_mode iDE_SCAL_Csc_Lmt(&matrixresult.x00, -4095, 4095, 0, 8191); iDE_SCAL_Csc_Lmt(&matrixresult.x01, -4095, 4095, 0, 8191); iDE_SCAL_Csc_Lmt(&matrixresult.x02, -4095, 4095, 0, 8191); - iDE_SCAL_Csc_Lmt(&matrixresult.x03, -8191, 8191, 6, 16383); + iDE_SCAL_Csc_Lmt(&matrixresult.x03, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x10, -4095, 4095, 0, 8191); iDE_SCAL_Csc_Lmt(&matrixresult.x11, -4095, 4095, 0, 8191); iDE_SCAL_Csc_Lmt(&matrixresult.x12, -4095, 4095, 0, 8191); - iDE_SCAL_Csc_Lmt(&matrixresult.x13, -8191, 8191, 6, 16383); + iDE_SCAL_Csc_Lmt(&matrixresult.x13, -8191, 8191, 0, 16383); iDE_SCAL_Csc_Lmt(&matrixresult.x20, -4095, 4095, 0, 8191); iDE_SCAL_Csc_Lmt(&matrixresult.x21, -4095, 4095, 0, 8191); iDE_SCAL_Csc_Lmt(&matrixresult.x22, -4095, 4095, 0, 8191); - iDE_SCAL_Csc_Lmt(&matrixresult.x23, -8191, 8191, 6, 16383); + iDE_SCAL_Csc_Lmt(&matrixresult.x23, -8191, 8191, 0, 16383); //write csc register - pt = &(matrixresult.x00); + pt = (__s64 *)&(matrixresult.x00); for(i=0; i<4; i++) { scal_dev[sel]->csc_coef[i].dwval = *(pt + i); @@ -1531,7 +1559,6 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u8 out_csc_mode return 0; } - //********************************************************************************************* // function : DE_SCAL_Get_3D_In_Single_Size( __scal_3d_inmode_t inmode, __scal_src_size_t *fullsize,__scal_src_size_t *singlesize) // description : get single image size according to 3D inmode and full size diff --git a/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.h b/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.h index 7d05c8a1fa025e..03a3058bc45171 100644 --- a/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.h +++ b/drivers/video/sun4i/disp/de_bsp/de/ebios/de_fe.h @@ -1508,25 +1508,25 @@ typedef struct __DE_SCAL_DEV typedef struct __SCAL_MATRIX4X4 { - __s32 x00; - __s32 x01; - __s32 x02; - __s32 x03; - __s32 x10; - __s32 x11; - __s32 x12; - __s32 x13; - __s32 x20; - __s32 x21; - __s32 x22; - __s32 x23; - __s32 x30; - __s32 x31; - __s32 x32; - __s32 x33; + __s64 x00; + __s64 x01; + __s64 x02; + __s64 x03; + __s64 x10; + __s64 x11; + __s64 x12; + __s64 x13; + __s64 x20; + __s64 x21; + __s64 x22; + __s64 x23; + __s64 x30; + __s64 x31; + __s64 x32; + __s64 x33; }__scal_matrix4x4; extern __s32 iDE_SCAL_Matrix_Mul(__scal_matrix4x4 in1, __scal_matrix4x4 in2, __scal_matrix4x4 *result); -extern __s32 iDE_SCAL_Csc_Lmt(__s32 *value, __s32 min, __s32 max, __s32 shift, __s32 validbit); +extern __s32 iDE_SCAL_Csc_Lmt(__s64 *value, __s32 min, __s32 max, __s32 shift, __s32 validbit); #endif diff --git a/drivers/video/sun4i/disp/de_bsp/de/ebios/ebios_de.h b/drivers/video/sun4i/disp/de_bsp/de/ebios/ebios_de.h old mode 100755 new mode 100644 index 3a408e42131d51..c36b30d6351b29 --- a/drivers/video/sun4i/disp/de_bsp/de/ebios/ebios_de.h +++ b/drivers/video/sun4i/disp/de_bsp/de/ebios/ebios_de.h @@ -355,15 +355,13 @@ __s32 DE_BE_Sprite_Block_Set_fb(__u32 sel, __u8 blk_idx,__u32 addr, __u32 line_w __s32 DE_BE_Sprite_Block_Set_Next_Id(__u32 sel, __u8 blk_idx,__u8 next_blk_id); __s32 DE_BE_Sprite_Set_Palette_Table(__u32 sel, __u32 address, __u32 offset, __u32 size); __s32 DE_BE_Set_Enhance(__u8 sel,__u32 brightness, __u32 contrast, __u32 saturaion, __u32 hue); +__s32 DE_BE_Set_Enhance_ex(__u8 sel, __u32 out_csc, __u32 out_color_range, __u32 enhance_en, __u32 brightness, __u32 contrast, __u32 saturaion, __u32 hue); __s32 DE_BE_enhance_enable(__u32 sel, __bool enable); __s32 DE_BE_set_display_size(__u32 sel, __u32 width, __u32 height); __s32 DE_BE_get_display_width(__u32 sel); __s32 DE_BE_get_display_height(__u32 sel); __s32 DE_BE_deflicker_enable(__u32 sel, __bool enable); -__s32 DE_BE_output_csc_enable(__u32 sel, __bool enable); __s32 DE_BE_Set_Outitl_enable(__u32 sel, __bool enable); -__s32 DE_BE_Output_Cfg_Csc_Coeff(__u32 sel, __bool bout_yuv, __u32 out_color_range); -//__s32 DE_BE_Output_Cfg_Csc_Coeff(__u32 sel, __u8 cs_mode); __s32 DE_BE_Format_To_Bpp(__u32 sel, __u8 format); __u32 DE_BE_Offset_To_Addr(__u32 src_addr,__u32 width,__u32 x,__u32 y,__u32 bpp); __u32 DE_BE_Addr_To_Offset(__u32 src_addr,__u32 off_addr,__u32 width,__u32 bpp,__disp_pos_t *pos); diff --git a/drivers/video/sun4i/disp/dev_disp.c b/drivers/video/sun4i/disp/dev_disp.c old mode 100755 new mode 100644 index 1a27d8ce9f50d5..b94003e6f4600e --- a/drivers/video/sun4i/disp/dev_disp.c +++ b/drivers/video/sun4i/disp/dev_disp.c @@ -622,7 +622,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { if((ubuffer[0] != 0) && (ubuffer[0] != 1)) { - __wrn("para err in disp_ioctl, screen id = %d\n", (int)ubuffer[0]); + __wrn("para err in disp_ioctl, cmd = 0x%x,screen id = %d\n", cmd, (int)ubuffer[0]); return -1; } } @@ -650,6 +650,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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], ¶); @@ -662,6 +663,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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], ¶); @@ -676,6 +678,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } 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]); @@ -690,6 +693,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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; @@ -834,7 +838,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = BSP_disp_layer_get_framebuffer(ubuffer[0], ubuffer[1], ¶); if(copy_to_user((void __user *)ubuffer[2], ¶,sizeof(__disp_fb_t))) { - __wrn("copy_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -861,7 +865,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -888,7 +892,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -915,7 +919,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1121,7 +1125,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = BSP_disp_hwc_get_pos(ubuffer[0], ¶); if(copy_to_user((void __user *)ubuffer[1],¶, sizeof(__disp_pos_t))) { - __wrn("copy_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1188,7 +1192,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1481,7 +1485,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1507,7 +1511,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1533,7 +1537,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1587,7 +1591,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1618,7 +1622,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = Display_Fb_get_para(ubuffer[0], ¶); if(copy_to_user((void __user *)ubuffer[1],¶, sizeof(__disp_fb_create_para_t))) { - __wrn("copy_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; @@ -1631,7 +1635,7 @@ long disp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = Display_get_disp_init_para(¶); if(copy_to_user((void __user *)ubuffer[0],¶, sizeof(__disp_init_t))) { - __wrn("copy_from_user fail\n"); + __wrn("copy_to_user fail\n"); return -EFAULT; } break; diff --git a/drivers/video/sun4i/disp/dev_fb.c b/drivers/video/sun4i/disp/dev_fb.c old mode 100755 new mode 100644 index cfba27e09d3ac1..76c5bf49d10a68 --- a/drivers/video/sun4i/disp/dev_fb.c +++ b/drivers/video/sun4i/disp/dev_fb.c @@ -769,6 +769,36 @@ static int Fb_release(struct fb_info *info, int user) return 0; } + +static int Fb_wait_for_vsync(struct fb_info *info) +{ + unsigned long count; + __u32 sel = 0; + int ret; + + for(sel = 0; sel < 2; sel++) + { + if(((sel==0) && (g_fbi.fb_mode[info->node] != FB_MODE_SCREEN1)) + || ((sel==1) && (g_fbi.fb_mode[info->node] != FB_MODE_SCREEN0))) + { + if(BSP_disp_get_output_type(sel) == DISP_OUTPUT_TYPE_NONE) + { + return 0; + } + + count = g_fbi.wait_count[sel]; + ret = wait_event_interruptible_timeout(g_fbi.wait[sel], count != g_fbi.wait_count[sel], msecs_to_jiffies(50)); + if (ret == 0) + { + __inf("timeout\n"); + return -ETIMEDOUT; + } + } + } + + return 0; +} + static int Fb_pan_display(struct fb_var_screeninfo *var,struct fb_info *info) { __u32 sel = 0; @@ -828,6 +858,9 @@ static int Fb_pan_display(struct fb_var_screeninfo *var,struct fb_info *info) } } } + + Fb_wait_for_vsync(info); + return 0; } @@ -989,35 +1022,6 @@ static int Fb_cursor(struct fb_info *info, struct fb_cursor *cursor) return 0; } -static int Fb_wait_for_vsync(struct fb_info *info) -{ - unsigned long count; - __u32 sel = 0; - int ret; - - for(sel = 0; sel < 2; sel++) - { - if(((sel==0) && (g_fbi.fb_mode[info->node] != FB_MODE_SCREEN1)) - || ((sel==1) && (g_fbi.fb_mode[info->node] != FB_MODE_SCREEN0))) - { - if(BSP_disp_get_output_type(sel) == DISP_OUTPUT_TYPE_NONE) - { - return 0; - } - - count = g_fbi.wait_count[sel]; - ret = wait_event_interruptible_timeout(g_fbi.wait[sel], count != g_fbi.wait_count[sel], msecs_to_jiffies(50)); - if (ret == 0) - { - __inf("timeout\n"); - return -ETIMEDOUT; - } - } - } - - return 0; -} - __s32 DRV_disp_int_process(__u32 sel) { g_fbi.wait_count[sel]++; @@ -1095,7 +1099,7 @@ static int Fb_ioctl(struct fb_info *info, unsigned int cmd,unsigned long arg) case FBIO_WAITFORVSYNC: { - ret = Fb_wait_for_vsync(info); + //ret = Fb_wait_for_vsync(info); break; } diff --git a/drivers/video/sun4i/hdmi/aw/hdmi_core.c b/drivers/video/sun4i/hdmi/aw/hdmi_core.c old mode 100755 new mode 100644 index 4ca00197b96a3f..1f4fe256b0af88 --- a/drivers/video/sun4i/hdmi/aw/hdmi_core.c +++ b/drivers/video/sun4i/hdmi/aw/hdmi_core.c @@ -126,7 +126,7 @@ __s32 hdmi_main_task_loop(void) (1<<25)+ (0<<24)+ (0<<23)+ (4<<20)+ (7<<17)+ (15<<12)+ (7<<8)+ (0x0f<<4)+(8<<0) ); HDMI_WUINT32(0x200,0xfe800000); //txen enable - HDMI_WUINT32(0x204,0x00D8C850); //ckss = 1 + HDMI_WUINT32(0x204,0x00D8C860); //ckss = 1 HDMI_WUINT32(0x20c, 0 << 21); @@ -263,12 +263,12 @@ __s32 get_audio_info(__s32 sample_rate) __s32 video_config(__s32 vic) { - __s32 i, clk_div,reg_val; + __s32 vic_tab, clk_div,reg_val; __inf("video_config, vic:%d\n", vic); - i = get_video_info(vic); - if( i == -1) + vic_tab = get_video_info(vic); + if( vic_tab == -1) return 0; else video_mode = vic; @@ -291,38 +291,36 @@ __s32 video_config(__s32 vic) if( (vic == HDMI1440_480I) || (vic == HDMI1440_576I) ) //need to use repeation { - HDMI_WUINT16(0x014,(video_timing[i].INPUTX<<1) -1); //active H - HDMI_WUINT16(0x018,(video_timing[i].HBP<<1) -1); //active HBP - HDMI_WUINT16(0x01c,(video_timing[i].HFP<<1) -1); //active HFP - HDMI_WUINT16(0x020,(video_timing[i].HPSW<<1) -1); //active HSPW + HDMI_WUINT16(0x014,(video_timing[vic_tab].INPUTX<<1) -1); //active H + HDMI_WUINT16(0x018,(video_timing[vic_tab].HBP<<1) -1); //active HBP + HDMI_WUINT16(0x01c,(video_timing[vic_tab].HFP<<1) -1); //active HFP + HDMI_WUINT16(0x020,(video_timing[vic_tab].HPSW<<1) -1); //active HSPW } else { - HDMI_WUINT16(0x014,(video_timing[i].INPUTX<<0) -1); //active H - HDMI_WUINT16(0x018,(video_timing[i].HBP<<0) -1); //active HBP - HDMI_WUINT16(0x01c,(video_timing[i].HFP<<0) -1); //active HFP - HDMI_WUINT16(0x020,(video_timing[i].HPSW<<0) -1); //active HSPW + HDMI_WUINT16(0x014,(video_timing[vic_tab].INPUTX<<0) -1); //active H + HDMI_WUINT16(0x018,(video_timing[vic_tab].HBP<<0) -1); //active HBP + HDMI_WUINT16(0x01c,(video_timing[vic_tab].HFP<<0) -1); //active HFP + HDMI_WUINT16(0x020,(video_timing[vic_tab].HPSW<<0) -1); //active HSPW } if( ( vic == HDMI1080P_24_3D_FP) || (vic == HDMI720P_50_3D_FP ) || (vic == HDMI720P_60_3D_FP ) ) { - //HDMI_WUINT16(0x016,video_timing[i].INPUTY + 45 -1); //active V - HDMI_WUINT16(0x016,video_timing[i].INPUTY + video_timing[i].VBP + video_timing[i].VFP -1); //active V + HDMI_WUINT16(0x016,video_timing[vic_tab].INPUTY + video_timing[vic_tab].VBP + video_timing[vic_tab].VFP -1); //active V }else { - HDMI_WUINT16(0x016,video_timing[i].INPUTY -1); //active V + HDMI_WUINT16(0x016,video_timing[vic_tab].INPUTY -1); //active V } - HDMI_WUINT16(0x01a,video_timing[i].VBP -1); //active VBP - HDMI_WUINT16(0x01e,video_timing[i].VFP -1); //active VFP - HDMI_WUINT16(0x022,video_timing[i].VPSW -1); //active VSPW + HDMI_WUINT16(0x01a,video_timing[vic_tab].VBP -1); //active VBP + HDMI_WUINT16(0x01e,video_timing[vic_tab].VFP -1); //active VFP + HDMI_WUINT16(0x022,video_timing[vic_tab].VPSW -1); //active VSPW - if( (vic == HDMI1440_480I) || (vic == HDMI1440_576I) || - (vic == HDMI480P) || (vic == HDMI576P) ) + if( video_timing[vic_tab].PCLK < 74250000) //SD format { HDMI_WUINT16(0x024,0x00 ); //Vsync/Hsync pol } - else + else //HD format { HDMI_WUINT16(0x024,0x03 ); //Vsync/Hsync pol } @@ -334,12 +332,18 @@ __s32 video_config(__s32 vic) HDMI_WUINT8 (0x080,0x82); HDMI_WUINT8 (0x081,0x02); HDMI_WUINT8 (0x082,0x0d); - HDMI_WUINT8 (0x083,0xF7); - HDMI_WUINT8 (0x084,0x1E); - HDMI_WUINT8 (0x085,0x58); + HDMI_WUINT8 (0x083,0x00); + HDMI_WUINT8 (0x084,0x50); + if( video_timing[vic_tab].PCLK < 74250000) //SD format + { + HDMI_WUINT8 (0x085,0x58); //4:3 601 + }else //HD format + { + HDMI_WUINT8 (0x085,0xa8); //16:9 709 + } HDMI_WUINT8 (0x086,0x00); - HDMI_WUINT8 (0x087,video_timing[i].VIC ); - HDMI_WUINT8 (0x088,video_timing[i].AVI_PR); + HDMI_WUINT8 (0x087,video_timing[vic_tab].VIC ); + HDMI_WUINT8 (0x088,video_timing[vic_tab].AVI_PR); HDMI_WUINT8 (0x089,0x00); HDMI_WUINT8 (0x08a,0x00); HDMI_WUINT8 (0x08b,0x00); @@ -349,12 +353,26 @@ __s32 video_config(__s32 vic) HDMI_WUINT8 (0x08f,0x00); HDMI_WUINT8 (0x090,0x00); - reg_val = 0x82 + 0x02 + 0x0d + 0x1E + 0x58 + - video_timing[i].VIC + video_timing[i].AVI_PR; + reg_val = HDMI_RUINT8(0x080) + + HDMI_RUINT8(0x081) + + HDMI_RUINT8(0x082) + + HDMI_RUINT8(0x084) + + HDMI_RUINT8(0x085) + + HDMI_RUINT8(0x086) + + HDMI_RUINT8(0x087) + + HDMI_RUINT8(0x088) + + HDMI_RUINT8(0x089) + + HDMI_RUINT8(0x08a) + + HDMI_RUINT8(0x08b) + + HDMI_RUINT8(0x08c) + + HDMI_RUINT8(0x08d) + + HDMI_RUINT8(0x08e) + + HDMI_RUINT8(0x08f) + + HDMI_RUINT8(0x090); reg_val = reg_val & 0xff; if(reg_val != 0) reg_val = 0x100 - reg_val; - HDMI_WUINT8 (0x083,reg_val); + HDMI_WUINT8 (0x083,reg_val); //checksum //gcp packet HDMI_WUINT32(0x0e0,0x00000003); HDMI_WUINT32(0x0e4,0x00000000); @@ -402,12 +420,12 @@ __s32 video_config(__s32 vic) //hdmi pll setting if( (vic == HDMI1440_480I) || (vic == HDMI1440_576I)) { - clk_div = hdmi_clk/video_timing[i].PCLK; + clk_div = hdmi_clk/video_timing[vic_tab].PCLK; clk_div /= 2; } else { - clk_div = hdmi_clk/video_timing[i].PCLK; + clk_div = hdmi_clk/video_timing[vic_tab].PCLK; } clk_div &= 0x0f; HDMI_WUINT32(0x208,(1<<31)+ (1<<30)+ (1<<29)+ (3<<27)+ (0<<26)+ @@ -415,7 +433,7 @@ __s32 video_config(__s32 vic) (15<<12)+ (7<<8)+ (clk_div<<4)+(8<<0) ); // tx driver setting HDMI_WUINT32(0x200,0xfe800000); //txen enable - HDMI_WUINT32(0x204,0x00D8C850); //ckss = 1 + HDMI_WUINT32(0x204,0x00D8C860); //ckss = 1 HDMI_WUINT32(0x20c, hdmi_pll << 21); diff --git a/drivers/video/sun4i/lcd/Makefile b/drivers/video/sun4i/lcd/Makefile index 986869acd2a8f1..d6e904df68964d 100644 --- a/drivers/video/sun4i/lcd/Makefile +++ b/drivers/video/sun4i/lcd/Makefile @@ -1,4 +1,13 @@ obj-$(CONFIG_LYCHEE_LCD_SUN4I) += lcd.o -lcd-objs := dev_lcd.o lcd0_panel_cfg.o lcd1_panel_cfg.o - +lcd-objs := dev_lcd.o +ifeq ($(CONFIG_LYCHEE_LCD_MID9742),y) + lcd-objs += lcd_bak/mid9742.o +else +ifeq ($(CONFIG_LYCHEE_LCD_AINOL_AUROTA),y) + lcd-objs += lcd_bak/ainol_aurota.o +else + lcd-objs += lcd0_panel_cfg.o +endif +endif +lcd-objs += lcd1_panel_cfg.o diff --git a/drivers/video/sun4i/lcd/lcd_bak/ainol_aurota.c b/drivers/video/sun4i/lcd/lcd_bak/ainol_aurota.c new file mode 100644 index 00000000000000..3093de9dd17c09 --- /dev/null +++ b/drivers/video/sun4i/lcd/lcd_bak/ainol_aurota.c @@ -0,0 +1,348 @@ +/* + * drivers/video/sun4i/lcd/lcd_bak/ainol_aurota.c + * + * (C) Copyright 2007-2012 + * Allwinner Technology Co., Ltd. + * Danling + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include "../lcd_panel_cfg.h" + +//delete this line if you want to use the lcd para define in sys_config1.fex +//#define LCD_PARA_USE_CONFIG + +//----------------------------------snake add------------------------- +#define CMD_WIRTE_DELAY 2 +#undef SPI_DATA_PRINT +static __s32 lcd_spi_cs = 0; +static __s32 lcd_spi_clk = 0; +static __s32 lcd_spi_mosi = 0; +static __s32 lcd_spi_used = 0; +static __s32 lcd_spi_module = -1; + +void LCD_SPI_Init(__u32 sel) +{ + if( SCRIPT_PARSER_OK != OSAL_Script_FetchParser_Data("lcd_spi_para", "lcd_spi_used", &lcd_spi_used, 1) ){ + __inf("LCD SPI doesn't use.\n"); + return; + } + if (0 == lcd_spi_used){ + __inf("LCD SPI doesn't use.\n"); + return; + } + if( SCRIPT_PARSER_OK != OSAL_Script_FetchParser_Data("lcd_spi_para", "lcd_spi_module", &lcd_spi_module, 1) ){ + __wrn("There is no LCD SPI module input.\n"); + return; + } + + lcd_spi_cs = OSAL_GPIO_Request_Ex("lcd_spi_para", "lcd_spi_cs"); + if(!lcd_spi_cs) { + __wrn("request gpio lcd_spi_cs error.\n"); + goto ERR1; + } + lcd_spi_clk = OSAL_GPIO_Request_Ex("lcd_spi_para", "lcd_spi_clk"); + if(!lcd_spi_clk) { + __wrn("request gpio lcd_spi_clk error.\n"); + goto ERR2; + } + lcd_spi_mosi = OSAL_GPIO_Request_Ex("lcd_spi_para", "lcd_spi_mosi"); + if(!lcd_spi_mosi) { + __wrn("request gpio lcd_spi_mosi error.\n"); + goto ERR3; + } + return; + +#ifdef SPI_DATA_PRINT + __inf("release GPIO src : lcd_spi_mosi\n"); +#endif + OSAL_GPIO_Release(lcd_spi_mosi, 2); +ERR3: +#ifdef SPI_DATA_PRINT + __inf("release GPIO src : lcd_spi_clk\n"); +#endif + OSAL_GPIO_Release(lcd_spi_clk, 2); +ERR2: +#ifdef SPI_DATA_PRINT + __inf("release GPIO src : lcd_spi_cs\n"); +#endif + OSAL_GPIO_Release(lcd_spi_cs, 2); +ERR1: + return; +} + +void LCD_SPI_Write(__u32 sel) +{ + int i = 0, j = 0, offset = 0, bit_val = 0, ret = 0; + u16 data[9] = { // module 0 data + 0x0029, //reset + 0x0025, //standby + 0x0840, //enable normally black + 0x0430, //enable FRC/dither + 0x385f, //enter test mode(1) + 0x3ca4, //enter test mode(2) + 0x3409, //enable SDRRS, enlarge OE width + 0x4041, //adopt 2 line / 1 dot + //wait 100ms + 0x00ad, //display on + }; +#ifdef SPI_DATA_PRINT + __inf("============ start LCD SPI data write, module = %d============\n", lcd_spi_module); +#endif + switch(lcd_spi_module) + { + case 0: // rili 7inch + { + for(i = 0; i < 8; i++) { + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_cs, 0, "lcd_spi_cs"); +#ifdef SPI_DATA_PRINT + __inf("write data[%d]:", i); +#endif + for(j = 0; j < 16; j++) { + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_clk, 0, "lcd_spi_clk"); + offset = 15 - j; + bit_val = (0x0001 & (data[i]>>offset)); + ret = OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_mosi, bit_val, "lcd_spi_mosi"); +#ifdef SPI_DATA_PRINT + if(ret == 0) + __inf("%d-", bit_val); + else + __inf("write[bit:%d]ERR", j); +#endif + LCD_delay_us(CMD_WIRTE_DELAY); + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_clk, 1, "lcd_spi_clk"); + LCD_delay_us(CMD_WIRTE_DELAY); + } +#ifdef SPI_DATA_PRINT + __inf("\n"); +#endif + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_cs, 1, "lcd_spi_cs"); + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_clk, 1, "lcd_spi_clk"); + LCD_delay_us(CMD_WIRTE_DELAY); + } + LCD_delay_ms(50); + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_cs, 0, "lcd_spi_cs"); +#ifdef SPI_DATA_PRINT + __inf("write data[8]:"); +#endif + for(j = 0; j < 16; j++) { + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_clk, 0, "lcd_spi_clk"); + offset = 15 - j; + bit_val = (0x0001 & (data[i]>>offset)); + ret = OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_mosi, bit_val, "lcd_spi_mosi"); +#ifdef SPI_DATA_PRINT + if(ret == 0) + __inf("%d-", bit_val); + else + __inf("write[bit:%d]ERR", j); +#endif + LCD_delay_us(CMD_WIRTE_DELAY); + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_clk, 1, "lcd_spi_clk"); + LCD_delay_us(CMD_WIRTE_DELAY); + } +#ifdef SPI_DATA_PRINT + __inf("\n"); +#endif + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_cs, 1, "lcd_spi_cs"); + OSAL_GPIO_DevWRITE_ONEPIN_DATA(lcd_spi_clk, 1, "lcd_spi_clk"); + LCD_delay_us(CMD_WIRTE_DELAY); +#ifdef SPI_DATA_PRINT + __inf("========== LCD SPI data translation finished ===========\n"); +#endif + break; + } + default: + { +#ifdef SPI_DATA_PRINT + __inf("%s Unknow lcd_spi_module\n", __func__); +#endif + break; + } + } +} + +void LCD_SPI_Dinit(__u32 sel) +{ + +#ifdef SPI_DATA_PRINT + __inf("release GPIO src : lcd_spi_mosi\n"); +#endif + if (lcd_spi_mosi){ + OSAL_GPIO_Release(lcd_spi_mosi, 2); + } +#ifdef SPI_DATA_PRINT + __inf("release GPIO src : lcd_spi_clk\n"); +#endif + if (lcd_spi_clk){ + OSAL_GPIO_Release(lcd_spi_clk, 2); + } +#ifdef SPI_DATA_PRINT + __inf("release GPIO src : lcd_spi_cs\n"); +#endif + if (lcd_spi_cs){ + OSAL_GPIO_Release(lcd_spi_cs, 2); + } +} +//----------------------------------------------------------------------- + +#ifdef LCD_PARA_USE_CONFIG +static __u8 g_gamma_tbl[][2] = +{ +//{input value, corrected value} + {0, 0}, + {15, 15}, + {30, 30}, + {45, 45}, + {60, 60}, + {75, 75}, + {90, 90}, + {105, 105}, + {120, 120}, + {135, 135}, + {150, 150}, + {165, 165}, + {180, 180}, + {195, 195}, + {210, 210}, + {225, 225}, + {240, 240}, + {255, 255}, +}; + +static void LCD_cfg_panel_info(__panel_para_t * info) +{ + __u32 i = 0, j=0; + + memset(info,0,sizeof(__panel_para_t)); + + info->lcd_x = 800; + info->lcd_y = 480; + info->lcd_dclk_freq = 33; //MHz + + info->lcd_pwm_not_used = 0; + info->lcd_pwm_ch = 0; + info->lcd_pwm_freq = 10000; //Hz + info->lcd_pwm_pol = 0; + + info->lcd_if = 0; //0:hv(sync+de); 1:8080; 2:ttl; 3:lvds + + info->lcd_hbp = 215; //hsync back porch + info->lcd_ht = 1055; //hsync total cycle + info->lcd_hv_hspw = 0; //hsync plus width + info->lcd_vbp = 34; //vsync back porch + info->lcd_vt = 2 * 525; //vysnc total cycle *2 + info->lcd_hv_vspw = 0; //vysnc plus width + + info->lcd_hv_if = 0; //0:hv parallel 1:hv serial + info->lcd_hv_smode = 0; //0:RGB888 1:CCIR656 + info->lcd_hv_s888_if = 0; //serial RGB format + info->lcd_hv_syuv_if = 0; //serial YUV format + + info->lcd_cpu_if = 0; //0:18bit 4:16bit + info->lcd_frm = 0; //0: disable; 1: enable rgb666 dither; 2:enable rgb656 dither + + info->lcd_lvds_ch = 0; //0:single channel; 1:dual channel + info->lcd_lvds_mode = 0; //0:NS mode; 1:JEIDA mode + info->lcd_lvds_bitwidth = 0; //0:24bit; 1:18bit + info->lcd_lvds_io_cross = 0; //0:normal; 1:pn cross + + info->lcd_io_cfg0 = 0x10000000; + + info->lcd_gamma_correction_en = 0; + if(info->lcd_gamma_correction_en) + { + __u32 items = sizeof(g_gamma_tbl)/2; + + for(i=0; ilcd_gamma_tbl[g_gamma_tbl[i][0] + j] = (value<<16) + (value<<8) + value; + //__inf("----gamma %d, %d\n", g_gamma_tbl[i][0] + j, value); + } + } + info->lcd_gamma_tbl[255] = (g_gamma_tbl[items-1][1]<<16) + (g_gamma_tbl[items-1][1]<<8) + g_gamma_tbl[items-1][1]; + //__inf("----gamma 255, %d\n", g_gamma_tbl[items-1][1]); + } +} +#endif + +static __s32 LCD_open_flow(__u32 sel) +{ + LCD_OPEN_FUNC(sel, LCD_power_on, 50); //open lcd power, and delay 50ms + LCD_OPEN_FUNC(sel, LCD_SPI_Init, 20); //request and init gpio, and delay 20ms + LCD_OPEN_FUNC(sel, LCD_SPI_Write, 10); //use gpio to config lcd module to the work mode, and delay 10ms + LCD_OPEN_FUNC(sel, TCON_open, 500); //open lcd controller, and delay 500ms + LCD_OPEN_FUNC(sel, LCD_bl_open, 0); //open lcd backlight, and delay 0ms + + return 0; +} + +static __s32 LCD_close_flow(__u32 sel) +{ + LCD_CLOSE_FUNC(sel, LCD_bl_close, 0); //close lcd backlight, and delay 0ms + LCD_CLOSE_FUNC(sel, TCON_close, 0); //close lcd controller, and delay 0ms + LCD_CLOSE_FUNC(sel, LCD_SPI_Dinit, 0); //release gpio, and delay 0ms + LCD_CLOSE_FUNC(sel, LCD_power_off, 1000); //close lcd power, and delay 1000ms + + return 0; +} + +static void LCD_power_on(__u32 sel) +{ + LCD_POWER_EN(sel, 1);//config lcd_power pin to open lcd power +} + +static void LCD_power_off(__u32 sel) +{ + LCD_POWER_EN(sel, 0);//config lcd_power pin to close lcd power +} + +static void LCD_bl_open(__u32 sel) +{ + LCD_PWM_EN(sel, 1);//open pwm module + LCD_BL_EN(sel, 1);//config lcd_bl_en pin to open lcd backlight +} + +static void LCD_bl_close(__u32 sel) +{ + LCD_BL_EN(sel, 0);//config lcd_bl_en pin to close lcd backlight + LCD_PWM_EN(sel, 0);//close pwm module +} + +//sel: 0:lcd0; 1:lcd1 +static __s32 LCD_user_defined_func(__u32 sel, __u32 para1, __u32 para2, __u32 para3) +{ + return 0; +} + +void LCD_get_panel_funs_0(__lcd_panel_fun_t * fun) +{ +#ifdef LCD_PARA_USE_CONFIG + fun->cfg_panel_info = LCD_cfg_panel_info;//delete this line if you want to use the lcd para define in sys_config1.fex +#endif + fun->cfg_open_flow = LCD_open_flow; + fun->cfg_close_flow = LCD_close_flow; + fun->lcd_user_defined_func = LCD_user_defined_func; +} + diff --git a/drivers/video/sun4i/lcd/lcd_bak/mid9742.c b/drivers/video/sun4i/lcd/lcd_bak/mid9742.c new file mode 100644 index 00000000000000..5457d44d56be0f --- /dev/null +++ b/drivers/video/sun4i/lcd/lcd_bak/mid9742.c @@ -0,0 +1,348 @@ +/* + * drivers/video/sun4i/lcd/lcd_bak/mid9742.c + * + * (C) Copyright 2007-2012 + * Allwinner Technology Co., Ltd. + * Danling + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include "../lcd_panel_cfg.h" + +//delete this line if you want to use the lcd para define in sys_config1.fex +//#define LCD_PARA_USE_CONFIG + +//----------------------------------snake add------------------------- +#define CMD_WIRTE_DELAY 2 +#undef SPI_DATA_PRINT +static __s32 lcd_spi_cs = 0; +static __s32 lcd_spi_clk = 0; +static __s32 lcd_spi_mosi = 0; +static __s32 lcd_spi_used = 0; +static __s32 lcd_spi_module = -1; + +void LCD_SPI_Init(__u32 sel) +{ + if( SCRIPT_PARSER_OK != script_parser_fetch("lcd_spi_para", "lcd_spi_used", &lcd_spi_used, 1) ){ + printk("LCD SPI doesn't use.\n"); + return; + } + if (0 == lcd_spi_used){ + printk("LCD SPI doesn't use.\n"); + return; + } + if( SCRIPT_PARSER_OK != script_parser_fetch("lcd_spi_para", "lcd_spi_module", &lcd_spi_module, 1) ){ + pr_err("There is no LCD SPI module input.\n"); + return; + } + + lcd_spi_cs = gpio_request_ex("lcd_spi_para", "lcd_spi_cs"); + if(!lcd_spi_cs) { + pr_err("request gpio lcd_spi_cs error.\n"); + goto ERR1; + } + lcd_spi_clk = gpio_request_ex("lcd_spi_para", "lcd_spi_clk"); + if(!lcd_spi_clk) { + pr_err("request gpio lcd_spi_clk error.\n"); + goto ERR2; + } + lcd_spi_mosi = gpio_request_ex("lcd_spi_para", "lcd_spi_mosi"); + if(!lcd_spi_mosi) { + pr_err("request gpio lcd_spi_mosi error.\n"); + goto ERR3; + } + return; + +#ifdef SPI_DATA_PRINT + printk("release GPIO src : lcd_spi_mosi\n"); +#endif + gpio_release(lcd_spi_mosi, 2); +ERR3: +#ifdef SPI_DATA_PRINT + printk("release GPIO src : lcd_spi_clk\n"); +#endif + gpio_release(lcd_spi_clk, 2); +ERR2: +#ifdef SPI_DATA_PRINT + printk("release GPIO src : lcd_spi_cs\n"); +#endif + gpio_release(lcd_spi_cs, 2); +ERR1: + return; +} + +void LCD_SPI_Write(__u32 sel) +{ + int i = 0, j = 0, offset = 0, bit_val = 0, ret = 0; + u16 data[9] = { // module 0 data + 0x0029, //reset + 0x0025, //standby + 0x0840, //enable normally black + 0x0430, //enable FRC/dither + 0x385f, //enter test mode(1) + 0x3ca4, //enter test mode(2) + 0x3409, //enable SDRRS, enlarge OE width + 0x4041, //adopt 2 line / 1 dot + //wait 100ms + 0x00ad, //display on + }; +#ifdef SPI_DATA_PRINT + printk("============ start LCD SPI data write, module = %d============\n", lcd_spi_module); +#endif + switch(lcd_spi_module) + { + case 0: // rili 7inch + { + for(i = 0; i < 8; i++) { + gpio_write_one_pin_value(lcd_spi_cs, 0, "lcd_spi_cs"); +#ifdef SPI_DATA_PRINT + printk("write data[%d]:", i); +#endif + for(j = 0; j < 16; j++) { + gpio_write_one_pin_value(lcd_spi_clk, 0, "lcd_spi_clk"); + offset = 15 - j; + bit_val = (0x0001 & (data[i]>>offset)); + ret = gpio_write_one_pin_value(lcd_spi_mosi, bit_val, "lcd_spi_mosi"); +#ifdef SPI_DATA_PRINT + if(ret == 0) + printk("%d-", bit_val); + else + printk("write[bit:%d]ERR", j); +#endif + udelay(CMD_WIRTE_DELAY); + gpio_write_one_pin_value(lcd_spi_clk, 1, "lcd_spi_clk"); + udelay(CMD_WIRTE_DELAY); + } +#ifdef SPI_DATA_PRINT + printk("\n"); +#endif + gpio_write_one_pin_value(lcd_spi_cs, 1, "lcd_spi_cs"); + gpio_write_one_pin_value(lcd_spi_clk, 1, "lcd_spi_clk"); + udelay(CMD_WIRTE_DELAY); + } + mdelay(50); + gpio_write_one_pin_value(lcd_spi_cs, 0, "lcd_spi_cs"); +#ifdef SPI_DATA_PRINT + printk("write data[8]:"); +#endif + for(j = 0; j < 16; j++) { + gpio_write_one_pin_value(lcd_spi_clk, 0, "lcd_spi_clk"); + offset = 15 - j; + bit_val = (0x0001 & (data[i]>>offset)); + ret = gpio_write_one_pin_value(lcd_spi_mosi, bit_val, "lcd_spi_mosi"); +#ifdef SPI_DATA_PRINT + if(ret == 0) + printk("%d-", bit_val); + else + printk("write[bit:%d]ERR", j); +#endif + udelay(CMD_WIRTE_DELAY); + gpio_write_one_pin_value(lcd_spi_clk, 1, "lcd_spi_clk"); + udelay(CMD_WIRTE_DELAY); + } +#ifdef SPI_DATA_PRINT + printk("\n"); +#endif + gpio_write_one_pin_value(lcd_spi_cs, 1, "lcd_spi_cs"); + gpio_write_one_pin_value(lcd_spi_clk, 1, "lcd_spi_clk"); + udelay(CMD_WIRTE_DELAY); +#ifdef SPI_DATA_PRINT + printk("========== LCD SPI data translation finished ===========\n"); +#endif + break; + } + default: + { +#ifdef SPI_DATA_PRINT + printk("%s Unknow lcd_spi_module\n", __func__); +#endif + break; + } + } +} + +void LCD_SPI_Dinit(__u32 sel) +{ + +#ifdef SPI_DATA_PRINT + printk("release GPIO src : lcd_spi_mosi\n"); +#endif + if (lcd_spi_mosi){ + gpio_release(lcd_spi_mosi, 2); + } +#ifdef SPI_DATA_PRINT + printk("release GPIO src : lcd_spi_clk\n"); +#endif + if (lcd_spi_clk){ + gpio_release(lcd_spi_clk, 2); + } +#ifdef SPI_DATA_PRINT + printk("release GPIO src : lcd_spi_cs\n"); +#endif + if (lcd_spi_cs){ + gpio_release(lcd_spi_cs, 2); + } +} +//----------------------------------------------------------------------- + +#ifdef LCD_PARA_USE_CONFIG +static __u8 g_gamma_tbl[][2] = +{ +//{input value, corrected value} + {0, 0}, + {15, 15}, + {30, 30}, + {45, 45}, + {60, 60}, + {75, 75}, + {90, 90}, + {105, 105}, + {120, 120}, + {135, 135}, + {150, 150}, + {165, 165}, + {180, 180}, + {195, 195}, + {210, 210}, + {225, 225}, + {240, 240}, + {255, 255}, +}; + +static void LCD_cfg_panel_info(__panel_para_t * info) +{ + __u32 i = 0, j=0; + + memset(info,0,sizeof(__panel_para_t)); + + info->lcd_x = 800; + info->lcd_y = 480; + info->lcd_dclk_freq = 33; //MHz + + info->lcd_pwm_not_used = 0; + info->lcd_pwm_ch = 0; + info->lcd_pwm_freq = 10000; //Hz + info->lcd_pwm_pol = 0; + + info->lcd_if = 0; //0:hv(sync+de); 1:8080; 2:ttl; 3:lvds + + info->lcd_hbp = 215; //hsync back porch + info->lcd_ht = 1055; //hsync total cycle + info->lcd_hv_hspw = 0; //hsync plus width + info->lcd_vbp = 34; //vsync back porch + info->lcd_vt = 2 * 525; //vysnc total cycle *2 + info->lcd_hv_vspw = 0; //vysnc plus width + + info->lcd_hv_if = 0; //0:hv parallel 1:hv serial + info->lcd_hv_smode = 0; //0:RGB888 1:CCIR656 + info->lcd_hv_s888_if = 0; //serial RGB format + info->lcd_hv_syuv_if = 0; //serial YUV format + + info->lcd_cpu_if = 0; //0:18bit 4:16bit + info->lcd_frm = 0; //0: disable; 1: enable rgb666 dither; 2:enable rgb656 dither + + info->lcd_lvds_ch = 0; //0:single channel; 1:dual channel + info->lcd_lvds_mode = 0; //0:NS mode; 1:JEIDA mode + info->lcd_lvds_bitwidth = 0; //0:24bit; 1:18bit + info->lcd_lvds_io_cross = 0; //0:normal; 1:pn cross + + info->lcd_io_cfg0 = 0x10000000; + + info->lcd_gamma_correction_en = 0; + if(info->lcd_gamma_correction_en) + { + __u32 items = sizeof(g_gamma_tbl)/2; + + for(i=0; ilcd_gamma_tbl[g_gamma_tbl[i][0] + j] = (value<<16) + (value<<8) + value; + //__inf("----gamma %d, %d\n", g_gamma_tbl[i][0] + j, value); + } + } + info->lcd_gamma_tbl[255] = (g_gamma_tbl[items-1][1]<<16) + (g_gamma_tbl[items-1][1]<<8) + g_gamma_tbl[items-1][1]; + //__inf("----gamma 255, %d\n", g_gamma_tbl[items-1][1]); + } +} +#endif + +static __s32 LCD_open_flow(__u32 sel) +{ + LCD_OPEN_FUNC(sel, LCD_power_on, 50); //open lcd power, and delay 50ms + LCD_OPEN_FUNC(sel, LCD_SPI_Init, 20); //request and init gpio, and delay 20ms + LCD_OPEN_FUNC(sel, LCD_SPI_Write, 10); //use gpio to config lcd module to the work mode, and delay 10ms + LCD_OPEN_FUNC(sel, TCON_open, 500); //open lcd controller, and delay 500ms + LCD_OPEN_FUNC(sel, LCD_bl_open, 0); //open lcd backlight, and delay 0ms + + return 0; +} + +static __s32 LCD_close_flow(__u32 sel) +{ + LCD_CLOSE_FUNC(sel, LCD_bl_close, 0); //close lcd backlight, and delay 0ms + LCD_CLOSE_FUNC(sel, TCON_close, 0); //close lcd controller, and delay 0ms + LCD_CLOSE_FUNC(sel, LCD_SPI_Dinit, 0); //release gpio, and delay 0ms + LCD_CLOSE_FUNC(sel, LCD_power_off, 1000); //close lcd power, and delay 1000ms + + return 0; +} + +static void LCD_power_on(__u32 sel) +{ + LCD_POWER_EN(sel, 1);//config lcd_power pin to open lcd power +} + +static void LCD_power_off(__u32 sel) +{ + LCD_POWER_EN(sel, 0);//config lcd_power pin to close lcd power +} + +static void LCD_bl_open(__u32 sel) +{ + LCD_PWM_EN(sel, 1);//open pwm module + LCD_BL_EN(sel, 1);//config lcd_bl_en pin to open lcd backlight +} + +static void LCD_bl_close(__u32 sel) +{ + LCD_BL_EN(sel, 0);//config lcd_bl_en pin to close lcd backlight + LCD_PWM_EN(sel, 0);//close pwm module +} + +//sel: 0:lcd0; 1:lcd1 +static __s32 LCD_user_defined_func(__u32 sel, __u32 para1, __u32 para2, __u32 para3) +{ + return 0; +} + +void LCD_get_panel_funs_0(__lcd_panel_fun_t * fun) +{ +#ifdef LCD_PARA_USE_CONFIG + fun->cfg_panel_info = LCD_cfg_panel_info;//delete this line if you want to use the lcd para define in sys_config1.fex +#endif + fun->cfg_open_flow = LCD_open_flow; + fun->cfg_close_flow = LCD_close_flow; + fun->lcd_user_defined_func = LCD_user_defined_func; +} + diff --git a/drivers/video/sun4i/lcd/lcd_panel_cfg.h b/drivers/video/sun4i/lcd/lcd_panel_cfg.h old mode 100755 new mode 100644 index 0ef140aa929fc4..c2c74987164651 --- a/drivers/video/sun4i/lcd/lcd_panel_cfg.h +++ b/drivers/video/sun4i/lcd/lcd_panel_cfg.h @@ -63,6 +63,14 @@ extern __s32 pwm_get_para(__u32 channel, __pwm_info_t * pwm_info); #define OSAL_Script_FetchParser_Data script_parser_fetch #define OSAL_GPIO_Request gpio_request #define OSAL_GPIO_Release gpio_release +#define OSAL_GPIO_Request_Ex gpio_request_ex +#define OSAL_GPIO_DevGetAllPins_Status gpio_get_all_pin_status +#define OSAL_GPIO_DevGetONEPins_Status gpio_get_one_pin_status +#define OSAL_GPIO_DevSetONEPin_Status gpio_set_one_pin_status +#define OSAL_GPIO_DevSetONEPIN_IO_STATUS gpio_set_one_pin_io_status +#define OSAL_GPIO_DevSetONEPIN_PULL_STATUS gpio_set_one_pin_pull +#define OSAL_GPIO_DevREAD_ONEPIN_DATA gpio_read_one_pin_value +#define OSAL_GPIO_DevWRITE_ONEPIN_DATA gpio_write_one_pin_value #define BIT0 0x00000001 #define BIT1 0x00000002