【嵌入式开发】手把手教你4418/6818开发板屏幕修改

时间:2022-01-10 08:41:29

 

本文转自迅为: http://www.topeetboard.com

开发平台:iTOP-4418/6818开发板

 

4418&6818屏幕修改分别需要修改uboot和内核,首先是修改uboot

 

1.首先进入到android源码目录下:

【嵌入式开发】手把手教你4418/6818开发板屏幕修改

 

 

 

 

 

 

 

 

 

 

 

1

4418平台,需要修改uboot的文件是:u-boot/board/s5p4418/drone2/board.c,使用vi命令打开这个文件,屏幕的默认参数设置在49行到93行,如下图:

 【嵌入式开发】手把手教你4418/6818开发板屏幕修改

2

4418暂时支持9.7寸,7寸,4.3寸屏幕,他们的设置在该文件,如下图所示的地方:

 【嵌入式开发】手把手教你4418/6818开发板屏幕修改

3

上图中代码的功能,首先是从uboot的环境变量里面读取出当前使用的哪款屏幕,然后根据屏幕类型选择对应分支的设置。比如屏幕的宽,高,刷新率,如果用户使用其它的屏幕,需要在此处修改(需要根据自己屏幕的参数,修改图2中的那些默认变量)(6818的修改文件是:u-boot/board/s5p6818/dronel/board.c,方法同上)

 

2linux内核部分的修改:

首先是文件kernel/arch/arm/plat-s5p4418/topeet/include/cfg_main.h(6818对应的文件是:kernel/arch/arm/plat-s5p6818/topeet/include/cfg_main.h)

这个文件里定义里一组与屏幕相关的宏,如下所示:

/*------------------------------------------------------------------------------

 *      Display (DPC and MLC)

 */

/* Primary */

#define CFG_DISP_PRI_SCREEN_LAYER               0

#define CFG_DISP_PRI_SCREEN_RGB_FORMAT          MLC_RGBFMT_A8R8G8B8

#define CFG_DISP_PRI_SCREEN_PIXEL_BYTE          4

#define CFG_DISP_PRI_SCREEN_COLOR_KEY           0x090909

 

#define CFG_DISP_PRI_VIDEO_PRIORITY                             2       // 0, 1, 2, 3

#define CFG_DISP_PRI_BACK_GROUND_COLOR          0x000000

 

#define CFG_DISP_PRI_MLC_INTERLACE              CFALSE

 

#define CFG_DISP_PRI_LCD_WIDTH_MM                               154

#define CFG_DISP_PRI_LCD_HEIGHT_MM                              85

 

/* modify by cym 20150811 */

#if 0

#define CFG_DISP_PRI_RESOL_WIDTH                        1024    // X Resolution

#define CFG_DISP_PRI_RESOL_HEIGHT                               600     // Y Resolution

#else

#define CFG_DISP_PRI_RESOL_WIDTH                        800//1024    // X Resolution

#define CFG_DISP_PRI_RESOL_HEIGHT                               1280//768     // Y Resolution

#endif

/* end remove */

 

#define CFG_DISP_PRI_HSYNC_SYNC_WIDTH            20

#define CFG_DISP_PRI_HSYNC_BACK_PORCH           160

#define CFG_DISP_PRI_HSYNC_FRONT_PORCH          160

#define CFG_DISP_PRI_HSYNC_ACTIVE_HIGH          CTRUE

#define CFG_DISP_PRI_VSYNC_SYNC_WIDTH            3

#define CFG_DISP_PRI_VSYNC_BACK_PORCH            23

#define CFG_DISP_PRI_VSYNC_FRONT_PORCH           12

#define CFG_DISP_PRI_VSYNC_ACTIVE_HIGH          CTRUE

 

#define CFG_DISP_PRI_CLKGEN0_SOURCE             DPC_VCLK_SRC_PLL2

#define CFG_DISP_PRI_CLKGEN0_DIV                12 // even divide

#define CFG_DISP_PRI_CLKGEN0_DELAY              0

#define CFG_DISP_PRI_CLKGEN0_INVERT                             0

#define CFG_DISP_PRI_CLKGEN1_SOURCE             DPC_VCLK_SRC_VCLK2

#define CFG_DISP_PRI_CLKGEN1_DIV                1

#define CFG_DISP_PRI_CLKGEN1_DELAY              0

#define CFG_DISP_PRI_CLKGEN1_INVERT                             0

#define CFG_DISP_PRI_CLKSEL1_SELECT                             0

#define CFG_DISP_PRI_PADCLKSEL                  DPC_PADCLKSEL_VCLK      /* VCLK=CLKGEN1, VCLK12=CLKGEN0 */

 

#define CFG_DISP_PRI_PIXEL_CLOCK                                800000000/CFG_DISP_PRI_CLKGEN0_DIV

 

#define CFG_DISP_PRI_OUT_SWAPRB                                 CFALSE

#define CFG_DISP_PRI_OUT_FORMAT                 DPC_FORMAT_RGB888

#define CFG_DISP_PRI_OUT_YCORDER                DPC_YCORDER_CbYCrY

#define CFG_DISP_PRI_OUT_INTERLACE              CFALSE

#define CFG_DISP_PRI_OUT_INVERT_FIELD           CFALSE

#define CFG_DISP_LCD_MPY_TYPE                                           0

 

/*------------------------------------------------------------------------------

 *      LVDS

 */

/* modify by cym 20150811 */

#if 0

#define CFG_DISP_LVDS_LCD_FORMAT                LVDS_LCDFORMAT_VESA

#else

#define CFG_DISP_LVDS_LCD_FORMAT                LVDS_LCDFORMAT_JEIDA

#endif

/* end modify */

然后是文件:kernel/arch/arm/plat-s5p4418/topeet/device.c(6818对应的文件:kernel/arch/arm/plat-s5p6818/topeet/device.c)

在这个文件找到函数setup_width_height_param,如下:

/* add by cym 20151128 */

#if 1

static int __init setup_width_height_param(char *str)

{

        if (!strncasecmp("9.7", str, 3)) {

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

#if defined(CONFIG_TOUCHSCREEN_FT5X0X)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                ft5x0x_pdata.screen_max_x = 768;

                ft5x0x_pdata.screen_max_y = 1024;

#endif

 

#if defined (CONFIG_FB_NXP)

#if defined (CONFIG_FB0_NXP)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                fb0_plat_data.x_resol = 1024;

                fb0_plat_data.y_resol = 768;

#endif

#endif

        }

        else if(!strncasecmp("7.0", str, 3))

        {

#if defined(CONFIG_TOUCHSCREEN_FT5X0X)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                ft5x0x_pdata.screen_max_x = 800;

                ft5x0x_pdata.screen_max_y = 1280;

#endif

 

#if defined (CONFIG_FB_NXP)

#if defined (CONFIG_FB0_NXP)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                fb0_plat_data.x_resol = 800;

                fb0_plat_data.y_resol = 1280;

#endif

#endif

        }

 

/* add by cym 20160222 */

#if 1

        else if(!strncasecmp("4.3", str, 3))

        {

#if defined (CONFIG_FB_NXP)

#if defined (CONFIG_FB0_NXP)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                fb0_plat_data.x_resol = 480;

                fb0_plat_data.y_resol = 272;

#endif

#endif

        }

#endif

/* end add */

 

/* add by cym 20170810 */

#if 1

        else if(!strncasecmp("1024x600", str, 8))

        {

#if defined(CONFIG_TOUCHSCREEN_FT5X0X)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                ft5x0x_pdata.screen_max_x = 600;

                ft5x0x_pdata.screen_max_y = 1024;

 

                ft5x0x_i2c_bdi.irq = PB_PIO_IRQ(CFG_IO_TSC2007_TOUCH_PENDOWN_DETECT);

                ft5x0x_pdata.gpio_irq = CFG_IO_TSC2007_TOUCH_PENDOWN_DETECT;

 

                tsc2007_i2c_bdi.irq = NULL;//PB_PIO_IRQ(CFG_IO_TOUCH_PENDOWN_DETECT);

#endif

 

#if defined (CONFIG_FB_NXP)

#if defined (CONFIG_FB0_NXP)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                fb0_plat_data.x_resol = 1024;

                fb0_plat_data.y_resol = 600;

#endif

#endif

        }

#endif

/* end add */

 

/* add by cym 20161104 */

#if 1

        else if(!strncasecmp("hdmi", str, 3))

        {

                #if defined (CONFIG_FB_NXP)

#if defined (CONFIG_FB0_NXP)

                //printk("fun:%s, line = %d(lcdtype:%s)\n", __FUNCTION__, __LINE__, str);

                fb0_plat_data.x_resol = 1920;

                fb0_plat_data.y_resol = 1080;

#endif

#endif

        }

#endif

/* end add */

 

        //printk("fun:%s, line = %d\n", __FUNCTION__, __LINE__);

}

early_param("lcdtype", setup_width_height_param);

#endif

/* end add */

这个函数根据uboot传递过来的lcdtype选择对应屏幕的设置,这里主要是修改屏幕的分辨率,如果使用其它屏幕,修改对应的分辨率就可以了。

然后是文件:kernel/arch/arm/mach-s5p4418/dev-display.c(6818对应的文件:kernel/arch/arm/mach-s5p4418/dev-display.c)

同样在这个文件找到函数:setup_width_height_param,如下所示:

/* add by cym 20151128 */

#if 1

static int __init setup_width_height_param(char *str)

{

        if (!strncasecmp("9.7", str, 3)) {

#if defined (CONFIG_NXP_DISPLAY_LCD)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                __lcd_vsync.h_active_len = 1024;

                __lcd_vsync.v_active_len = 768;

                __lcd_vsync.clk_div_lv0 = 14;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_LVDS)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                __lvds_vsync.h_active_len = 1024;

                __lvds_vsync.v_active_len = 768;

                __lvds_vsync.clk_div_lv0 = 14;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_MIPI)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                __mipi_vsync.h_active_len = 1024;

                __mipi_vsync.v_active_len = 768;

                __mipi_vsync.clk_div_lv0 = 14;

#endif

#endif

        }

        else if(!strncasecmp("7.0", str, 3))

        {

#if defined (CONFIG_NXP_DISPLAY_LCD)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lcd_vsync.h_active_len = 800;

                 __lcd_vsync.v_active_len = 1280;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_LVDS)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lvds_vsync.h_active_len = 800;

                 __lvds_vsync.v_active_len = 1280;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_MIPI)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __mipi_vsync.h_active_len = 800;

                 __mipi_vsync.v_active_len = 1280;

#endif

#endif

        }

 

/* add by cym 20160222 */

#if 1

        else if(!strncasecmp("4.3", str, 3))

        {

#if defined (CONFIG_NXP_DISPLAY_LCD)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lcd_vsync.h_active_len = 480;

                 __lcd_vsync.v_active_len = 272;

 

                __lcd_vsync.clk_div_lv0 = 24;

                __lcd_vsync.clk_div_lv1 = 2;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_LVDS)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lvds_vsync.h_active_len = 480;

                 __lvds_vsync.v_active_len = 272;

 

                __lvds_vsync.clk_div_lv0 = 24;

                __lvds_vsync.clk_div_lv1 = 2;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_MIPI)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __mipi_vsync.h_active_len = 480;

                 __mipi_vsync.v_active_len = 272;

 

                 __mipi_vsync.clk_div_lv0 = 24;

                 __mipi_vsync.clk_div_lv1 = 2;

#endif

#endif

        }

#endif

/* end add */

 

/* add by cym 20170810 */

#if 1

        else if(!strncasecmp("1024x600", str, 8))

        {

#if defined (CONFIG_NXP_DISPLAY_LCD)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lcd_vsync.h_active_len = 1024;

                 __lcd_vsync.v_active_len = 600;

 

                //__lcd_vsync.clk_div_lv0 = 24;

                //__lcd_vsync.clk_div_lv1 = 2;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_LVDS)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lvds_vsync.h_active_len = 1024;

                 __lvds_vsync.v_active_len = 600;

 

                //__lvds_vsync.clk_div_lv0 = 24;

                //__lvds_vsync.clk_div_lv1 = 2;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_MIPI)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __mipi_vsync.h_active_len = 1024;

                 __mipi_vsync.v_active_len = 600;

 

                 //__mipi_vsync.clk_div_lv0 = 24;

                 //__mipi_vsync.clk_div_lv1 = 2;

#endif

#endif

        }

#endif

/* end add */

 

/* add by cym 20161104 */

#if 1

        else if(!strncasecmp("hdmi", str, 3))

        {

#if defined (CONFIG_NXP_DISPLAY_LCD)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lcd_vsync.h_active_len = 1920;

                 __lcd_vsync.v_active_len = 1080;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_LVDS)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __lvds_vsync.h_active_len = 1920;

                 __lvds_vsync.v_active_len = 1080;

#endif

#endif

 

#if defined (CONFIG_NXP_DISPLAY_MIPI)

#if defined(CFG_DISP_PRI_RESOL_WIDTH) && defined(CFG_DISP_PRI_RESOL_HEIGHT)

                 __mipi_vsync.h_active_len = 1920;

                 __mipi_vsync.v_active_len = 1080;

#endif

#endif

        }

#endif

/* end add */

 

        //printk("fun:%s, line = %d\n", __FUNCTION__, __LINE__);

}

early_param("lcdtype", setup_width_height_param);

#endif

/* end add */

这个函数根据uboot传递过来的lcdtype选择对应屏幕的设置,这里主要是修改屏幕的分辨率,刷新率,如果使用其它屏幕,修改对应的分辨率就可以了。

关于屏幕的设置主要就是修改上面的文件