[全志T113]:ST7701 86屏幕驱动
添加屏幕驱动流程
1.添加驱动源码
如果要添加lcd驱动,添加位置如下:
/home/ubuntu/Tina-Linux/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2
2.配置kconfig和Makefile
同时配置目录下的Kconfig与Makefile,文件路径分别如下:
/home/ubuntu/Tina-Linux/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd/Kconfig
/home/ubuntu/Tina-Linux/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/Makefile
2.1 kconfig
config LCD_SUPPORT_ST7701_86
bool "LCD support ST7701_86 panel"
default y
---help---
If you want to support ST7701_86 panel for display driver, select it.

2.2 Makefile
disp-$(CONFIG_LCD_SUPPORT_ST7701_86) += lcd/st7701_86.o

2.3 built-in.a
这个文件需要添加我们刚才编译完的.o文件
lcd/st7701_86.o/

3.修改panels.c和panels.h
/home/ubuntu/Tina-Linux/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd/panels.c
/home/ubuntu/Tina-Linux/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd/panels.h
#ifdef CONFIG_LCD_SUPPORT_ST7701_86
extern struct __lcd_panel st7701_86_panel;
#endif


4.修改dts
&lcd0 {
/* part 1 */
lcd_used = <1>;
lcd_driver_name = "st7701_86";
lcd_backlight = <255>;
/* part 2 */
lcd_if = <0>;
lcd_hv_if = <0>;
/* part 3 */
lcd_x = <480>;
lcd_y = <480>;
lcd_width = <71>;
lcd_height = <71>;
lcd_dclk_freq = <16>;
lcd_hbp = <20>;
lcd_ht = <526>;
lcd_hspw = <6>;
lcd_vbp = <10>;
lcd_vt = <510>;
lcd_vspw = <4>;
lcd_pwm_used = <1>;
lcd_pwm_ch = <7>;
lcd_pwm_freq = <5000>;
lcd_pwm_pol = <0>;
/* part 5 */
lcd_frm = <1>;
lcd_io_phase = <0x0000>;
lcd_gamma_en = <0>;
lcd_cmap_en = <0>;
lcd_hv_clk_phase = <0>;
lcd_hv_sync_polarity= <0>;
// reset
lcd_gpio_0 = <&pio PB 4 GPIO_ACTIVE_HIGH>;
// cs
lcd_gpio_1 = <&pio PB 7 GPIO_ACTIVE_HIGH>;
// sda
lcd_gpio_2 = <&pio PB 5 GPIO_ACTIVE_HIGH>;
// sck
lcd_gpio_3 = <&pio PB 6 GPIO_ACTIVE_HIGH>;
//bl
lcd_bl_en = <&pio PD 22 GPIO_ACTIVE_HIGH>;
/* part 6 */
lcd_power = "vcc-lcd";
lcd_pin_power = "vcc-pd";
pinctrl-0 = <&rgb18_pins_a>;
pinctrl-1 = <&rgb18_pins_b>;
};
&disp {
disp_init_enable = <1>;
disp_mode = <0>;
screen0_output_type = <1>;
screen0_output_mode = <4>;
screen1_output_type = <3>;
screen1_output_mode = <10>;
screen1_output_format = <0>;
screen1_output_bits = <0>;
screen1_output_eotf = <4>;
screen1_output_cs = <257>;
screen1_output_dvi_hdmi = <2>;
screen1_output_range = <2>;
screen1_output_scan = <0>;
screen1_output_aspect_ratio = <8>;
dev0_output_type = <1>;
dev0_output_mode = <4>;
dev0_screen_id = <0>;
dev0_do_hpd = <0>;
dev1_output_type = <4>;
dev1_output_mode = <10>;
dev1_screen_id = <1>;
dev1_do_hpd = <1>;
def_output_dev = <0>;
hdmi_mode_check = <1>;
fb0_format = <0>;
fb0_width = <0>;
fb0_height = <0>;
fb1_format = <0>;
fb1_width = <0>;
fb1_height = <0>;
chn_cfg_mode = <1>;
disp_para_zone = <1>;
/*VCC-LCD*/
/* dc1sw-supply = <®_pio3_3>;*/
/*VCC-DSI*/
/* eldo3-supply = <®_eldo3>;*/
/*VCC-PD*/
/* dcdc1-supply = <®_pio3_3>;*/
};
5.测试
root@TinaLinux:/# cat /dev/urandom > /dev/fb0
root@TinaLinux:/# echo 8 > /sys/class/disp/disp/attr/colorbar

6.驱动文件
驱动文件参考繁花cloud提供的sdk
st7701_86.c
/*
* drivers/video/fbdev/sunxi/disp2/disp/lcd/st7701_86/st7701_86.c
*
* Copyright (c) 2007-2018 Allwinnertech Co., Ltd.
* Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*
[lcd0]
lcd_used = 1
lcd_driver_name = "st7701_86"
lcd_x = 480
lcd_y = 480
lcd_width = 71
lcd_height = 71
lcd_dclk_freq = 30
lcd_pwm_used = 1
lcd_pwm_ch = 8
lcd_pwm_freq = 50000
lcd_pwm_pol = 0
lcd_pwm_max_limit = 255
lcd_hbp = 120
;10 + 20 + 10 + 240*3 = 760 real set 1000
lcd_ht = 850
lcd_hspw = 2
lcd_vbp = 13
lcd_vt = 373
lcd_vspw = 2
lcd_frm = 1
lcd_if = 0
lcd_hv_if = 8
lcd_hv_clk_phase = 0
lcd_hv_sync_polarity = 0
lcd_hv_srgb_seq = 0
lcd_io_phase = 0x0000
lcd_gamma_en = 0
lcd_bright_curve_en = 1
lcd_cmap_en = 0
lcd_rb_swap = 0
deu_mode = 0
lcdgamma4iep = 22
smart_color = 90
;lcd_bl_en = port:PB03<1><0><default><1>
lcd_power = "vcc-lcd"
lcd_pin_power = "vcc-pd"
;reset
lcd_gpio_0 = port:PD09<1><0><default><1>
;cs
lcd_gpio_1 = port:PD10<1><0><default><0>
;sda
lcd_gpio_2 = port:PD13<1><0><default><0>
;sck
lcd_gpio_3 = port:PD12<1><0><default><0>
lcdd5 = port:PD03<2><0><2><default>
lcdd6 = port:PD04<2><0><2><default>
lcdd7 = port:PD05<2><0><2><default>
lcdd10 = port:PD06<2><0><2><default>
lcdd11 = port:PD07<2><0><2><default>
lcdd12 = port:PD08<2><0><2><default>
lcdclk = port:PD18<2><0><3><default>
lcdde = port:PD19<2><0><3><default>
lcdhsync = port:PD20<2><0><3><default>
lcdvsync = port:PD21<2><0><3><default>
[lcd0_suspend]
lcdd5 = port:PD03<7><0><2><default>
lcdd6 = port:PD04<7><0><2><default>
lcdd7 = port:PD05<7><0><2><default>
lcdd10 = port:PD06<7><0><2><default>
lcdd11 = port:PD07<7><0><2><default>
lcdd12 = port:PD08<7><0><2><default>
lcdclk = port:PD18<7><0><3><default>
lcdde = port:PD19<7><0><3><default>
lcdhsync = port:PD20<7><0><3><default>
lcdvsync = port:PD21<7><0><3><default>
*/
#include "st7701_86.h"
#define spi_scl_1 sunxi_lcd_gpio_set_value(0, 3, 1)
#define spi_scl_0 sunxi_lcd_gpio_set_value(0, 3, 0)
#define spi_sdi_1 sunxi_lcd_gpio_set_value(0, 2, 1)
#define spi_sdi_0 sunxi_lcd_gpio_set_value(0, 2, 0)
#define spi_cs_1 sunxi_lcd_gpio_set_value(0, 1, 1)
#define spi_cs_0 sunxi_lcd_gpio_set_value(0, 1, 0)
static void lcd_panel_st7701_86_init(void);
static void LCD_power_on(u32 sel);
static void LCD_power_off(u32 sel);
static void LCD_bl_open(u32 sel);
static void LCD_bl_close(u32 sel);
static void LCD_panel_init(u32 sel);
static void LCD_panel_exit(u32 sel);
static void LCD_cfg_panel_info(struct panel_extend_para *info)
{
u32 i = 0, j = 0;
u32 items;
u8 lcd_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},
};
u32 lcd_cmap_tbl[2][3][4] = {
{
{
LCD_CMAP_G0, LCD_CMAP_B1, LCD_CMAP_G2, LCD_CMAP_B3},
{
LCD_CMAP_B0, LCD_CMAP_R1, LCD_CMAP_B2, LCD_CMAP_R3},
{
LCD_CMAP_R0, LCD_CMAP_G1, LCD_CMAP_R2, LCD_CMAP_G3},
},
{
{

博客介绍了全志T113的ST7701 86屏幕驱动添加流程,包括添加驱动源码、配置kconfig和Makefile、修改panels.c和panels.h、修改dts、进行测试等步骤,还提及驱动文件可参考繁花cloud提供的sdk。

2万+

被折叠的 条评论
为什么被折叠?



