在移植中,可能会使用不同的屏幕,也可能由于结构限制,导致只能使用一部分屏幕,比如160128的屏幕,只能使用150128,这时候就需要修改屏幕可用区域了。
配置步骤
1. 配置驱动文件
kernel/drivers/video/sprdfb/lcd/lcd_st7735s_spi.c
这是我们项目中用到的驱动文件
static struct panel_spec lcd_st7735s_spi_spec = { .width = 150, //160->150 .height = 128, .bpp = 2, .fps = 50, .type = SPRDFB_PANEL_TYPE_SPI, .direction = LCD_DIRECT_NORMAL, .info = { .spi = &lcd_st7735s_spi_info }, .ops = &lcd_st7735s_spi_operations, .suspend_mode = SEND_SLEEP_CMD, };
u-boot/drivers/video/sprdfb/lcd/lcd_st7735s_spi.c
struct panel_spec lcd_st7735s_spi_spec = { .width = 150, //160->150 .height = 128, .fps = 50, .type = SPRDFB_PANEL_TYPE_SPI, .direction = LCD_DIRECT_NORMAL, .info = { .spi = &lcd_st7735s_spi_info }, .ops = &lcd_st7735s_spi_operations, };
kernel/drivers/video/sprdfb/sprdfb_spi_intf.c
static struct spi_transfer sprdfb_refresh_xfer = { .len = 150*128*2, //160->150 .gpio_cd_level = 0x81, .bits_per_word = 32, };
配置DTS
kernel/arch/arm/boot/dts/sprd-scx35l_sp9820w_6c10.dts
//framebuffer的预留内存大小=宽*高 /* memory reserved for fb */ /memreserve/ 0x8FF9C000 0x3C000; /* 128*160*4*3, 4K alignment*/ /* memory reserved for ION */ /memreserve/ 0x8FFD8000 0x28000; /* 128*160*4*2, 4K alignment*/
总共要预留两块内存,前面表示起始地址,后面表示预留 大小,大小是怎么计算的不太清楚,比如43和42是什么意思 不知道。
别外该DTS文件中有两处还需要改:
fb0: fb@20800000 { compatible = "sprd,sprdfb"; reg = <0x20800000 0x1000>,<0x21800000 0x1000>; interrupts = <0 46 0x0>,<0 48 0x0>, <0 49 0x0>; clock-names = "dispc_clk_parent", "dispc_dbi_clk_parent", "dispc_dpi_clk_parent", "dispc_emc_clk_parent", "dispc_clk", "dispc_dbi_clk", "dispc_dpi_clk", "dispc_emc_clk", "fb_spi_clock", "fb_spi_clock_parent"; clocks = <&clk_256m>, <&clk_256m>, <&clk_384m>, <&clk_aon_apb>, <&clk_dispc0>, <&clk_dispc0_dbi>, <&clk_di spc0_dpi>, <&clk_disp_emc>, <&clk_spi2>, <&ext_26m>; clock-src = <256000000 256000000 384000000>; dpi_clk_div = <7>; sprd,fb_use_reservemem; sprd,fb_mem = <0x8FF9C000 0x3C000>; //与fb预留大小一致 sprd,fb_display_size = <150 128>; //160->150 }; sprd,ion-heap@3 { reg = <3>; /* overlay */ reg-names = "ion_heap_carveout_overlay"; sprd,ion-heap-type = <2>; /* carveout */ sprd,ion-heap-mem = <0x8FFD8000 0x28000>; //与ION预留大小一致 };