V853 vision开发板,更改为st7701s 2 plane显示,出现错误
-
![替代文字]( 图片地址)
显示屏驱动文件如下:
/* drivers/video/sunxi/disp2/disp/lcd/ST7796S.c
*- Copyright (c) 2017 Allwinnertech Co., Ltd.
- Author: zhengxiaobin zhengxiaobin@allwinnertech.com
- he0801a-068 panel driver
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
[lcd0]
- lcd_used = 1
- lcd_driver_name = "st7701s"
- lcd_bl_0_percent = 0
- lcd_bl_40_percent = 23
- lcd_bl_100_percent = 100
- lcd_backlight = 88
- lcd_if = 4
- lcd_x = 480
- lcd_y = 640
- lcd_width = 36
- lcd_height = 65
- lcd_dclk_freq = 25
- lcd_pwm_used = 1
- lcd_pwm_ch = 8
- lcd_pwm_freq = 50000
- lcd_pwm_pol = 1
- lcd_pwm_max_limit = 255
- lcd_hbp = 70
- lcd_ht = 615
- lcd_hspw = 8
- lcd_vbp = 30
- lcd_vt = 690
- lcd_vspw = 10
- lcd_dsi_if = 0
- lcd_dsi_lane = 2
- lcd_dsi_format = 0
- lcd_dsi_te = 0
- lcd_dsi_eotp = 0
- lcd_frm = 0
- lcd_io_phase = 0x0000
- lcd_hv_clk_phase = 0
- lcd_hv_sync_polarity= 0
- lcd_gamma_en = 0
- lcd_bright_curve_en = 0
- lcd_cmap_en = 0
- lcdgamma4iep = 22
- ;lcd_bl_en = port:PD09<1><0><default><1>
- lcd_power = "vcc-lcd"
- lcd_pin_power = "vcc18-dsi"
- lcd_pin_power1 = "vcc-pd"
- ;reset
- lcd_gpio_0 = port:PD09<1><0><default><1>
*/
// written by Miller 2024-4-1
#include "st7701s.h"
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);#define panel_reset(sel, val) sunxi_lcd_gpio_set_value(sel, 0, val)
static void lcd_cfg_panel_info(struct panel_extend_para *info)
{
u32 i = 0, j = 0;
u32 items;
u8 lcd_gamma_tbl[][2] = {
{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}, }, { {LCD_CMAP_B3, LCD_CMAP_G2, LCD_CMAP_B1, LCD_CMAP_G0}, {LCD_CMAP_R3, LCD_CMAP_B2, LCD_CMAP_R1, LCD_CMAP_B0}, {LCD_CMAP_G3, LCD_CMAP_R2, LCD_CMAP_G1, LCD_CMAP_R0}, }, }; items = sizeof(lcd_gamma_tbl) / 2; for (i = 0; i < items - 1; i++) { u32 num = lcd_gamma_tbl[i + 1][0] - lcd_gamma_tbl[i][0]; for (j = 0; j < num; j++) { u32 value = 0; value = lcd_gamma_tbl[i][1] + ((lcd_gamma_tbl[i + 1][1] - lcd_gamma_tbl[i][1]) * j) / num; info->lcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] = (value << 16) + (value << 8) + value; } } info->lcd_gamma_tbl[255] = (lcd_gamma_tbl[items - 1][1] << 16) + (lcd_gamma_tbl[items - 1][1] << 8) + lcd_gamma_tbl[items - 1][1]; memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));
}
static s32 lcd_open_flow(u32 sel)
{
LCD_OPEN_FUNC(sel, lcd_power_on, 0);
LCD_OPEN_FUNC(sel, lcd_panel_init, 120); //miller change 10-->120
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 10);
LCD_OPEN_FUNC(sel, lcd_bl_open, 200); //miller change 0--200
return 0;
}static s32 lcd_close_flow(u32 sel)
{
LCD_CLOSE_FUNC(sel, lcd_bl_close, 0);
LCD_CLOSE_FUNC(sel, lcd_panel_exit, 10);
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);
LCD_CLOSE_FUNC(sel, lcd_power_off, 0);return 0;
}
static void lcd_power_on(u32 sel)
{
sunxi_lcd_pin_cfg(sel, 1);
sunxi_lcd_power_enable(sel, 0);
// sunxi_lcd_power_enable(sel, 1);
sunxi_lcd_delay_ms(40); //Miller change 10--->40/* reset lcd by gpio */ panel_reset(sel, 1); sunxi_lcd_delay_ms(5); //Miller change 1--->5 panel_reset(sel, 0); sunxi_lcd_delay_ms(30); //Miller change 1--->30 panel_reset(sel, 1); sunxi_lcd_delay_ms(10);
}
static void lcd_power_off(u32 sel)
{
sunxi_lcd_pin_cfg(sel, 0);
sunxi_lcd_delay_ms(1);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(1);
sunxi_lcd_power_disable(sel, 0);
}static void lcd_bl_open(u32 sel)
{
sunxi_lcd_pwm_enable(sel);
sunxi_lcd_backlight_enable(sel);
}static void lcd_bl_close(u32 sel)
{
sunxi_lcd_backlight_disable(sel);
sunxi_lcd_pwm_disable(sel);
}#define REGFLAG_DELAY 0XFE
#define REGFLAG_END_OF_TABLE 0xFC /* END OF REGISTERS MARKER */struct LCM_setting_table {
u8 cmd;
u32 count;
u8 para_list[18];
};static struct LCM_setting_table lcm_initialization_setting[] = {
{0x11, 1, {0x00} }, //miller turns off sleep
{REGFLAG_DELAY, 60, {} },{0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x13} },//miller add {0xef, 1, {0x08} }, //Miller add {0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x10} }, //Miller 这里采用第二个0xFF {0xc0, 2, {0x63, 0x00} }, //Miller change 0x4f-->0x63 {0xc1, 2, {0x0A, 0x0C} }, //Miller change 07 02 -->0a 0c {0xc2, 2, {0x31, 0x08} }, //miller 31 05 --> 31 08 {0xcc, 1, {0x18} }, //miller 10 -->18 {0xb0, 16, {0x00, 0x08, 0x10, 0x0E, 0x11, 0x07, 0x08, 0x08, 0x08, 0x25, 0x04, 0x12, 0x0F, 0x2C, 0x30, 0x1F} },//Miller change {0xb1, 16, {0x00, 0x11, 0x18, 0x0c, 0x10, 0x05, 0x07, 0x09, 0x08, 0x24, 0x04, 0x11, 0x10, 0x2B, 0x30, 0x1F} }, {0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x11} }, {0xb0, 1, {0x4D} },//Miller 0x53-->0x4D {0xb1, 1, {0x39} },// Miller 0x60-->0x39 {0xb2, 1, {0x87} },//miller 0x07--> 0x87 {0xb3, 1, {0x80} },//miller 0x08-->0x80 {0xb5, 1, {0x47} },//miller 0x49-->0x47 {0xb7, 1, {0x8A} },//miller 85--> 8A {0xb8, 1, {0x20} },//miller 21---20 {0xb9, 2, {0x10, 0x13} },//miller {0xc0, 1, {0x09} }, //miller add {0xc1, 1, {0x78} }, {0xc2, 1, {0x78} },// miller add //{REGFLAG_DELAY, 50, {} }, //miller delete {0xd0, 1, {0x88} }, {REGFLAG_DELAY, 100, {} }, // miller add {0xe0, 3, {0x00, 0x00, 0x02} }, {0xe1, 11, {0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20} }, //miller {0xe2, 13, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },//miller {0xe3, 4, {0x00, 0x00, 0x33, 0x00} },//miller {0xe4, 2, {0x22, 0x00} },//miller {0xe5, 16, {0x04, 0x34, 0xaa, 0xaa, 0x06, 0x34, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },//miller {0xe6, 4, {0x00, 0x00, 0x43, 0x00} }, //miller {0xe7, 2, {0x22, 0x00} }, //miller {0xe8, 16, {0x05, 0x35, 0xaa, 0xaa, 0x07, 0x35, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },//miller {0xeb, 7, {0x02, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00} },//miller {0xec, 2, {0x00, 0x00} },//miller {0xed, 16, {0xfa, 0x46, 0x0c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb1, 0x44, 0xbf} },//miller {0xef, 6, {0x10, 0x0d, 0x04, 0x08, 0x3f, 0x1f} }, //Miller {0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x13} }, //miller //{REGFLAG_DELAY, 50, {} },//miller delete {0xe8, 2, {0x00, 0x0e} }, //miller add {0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x00} }, //miller add {0x11, 1, {0x00} }, //miller add {REGFLAG_DELAY, 120, {} },//miller add {0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x13} }, //miller add {0xe8, 2, {0x00, 0x0c} }, //miller add {REGFLAG_DELAY, 10, {} },//miller add {0xe8, 2, {0x00, 0x00} }, //miller add {0xff, 5, {0x77, 0x01, 0x00, 0x00, 0x00} }, //miller add {0x29, 1, {0x00} }, {REGFLAG_DELAY, 20, {} },//miller add {REGFLAG_END_OF_TABLE, 0x00, {} }
};
static void lcd_panel_init(u32 sel)
{
u32 i = 0;sunxi_lcd_dsi_clk_enable(sel); sunxi_lcd_delay_ms(10); for (i = 0;; i++) { if (lcm_initialization_setting[i].cmd == REGFLAG_END_OF_TABLE) break; else if (lcm_initialization_setting[i].cmd == REGFLAG_DELAY) sunxi_lcd_delay_ms(lcm_initialization_setting[i].count); else { dsi_dcs_wr(0, lcm_initialization_setting[i].cmd, lcm_initialization_setting[i].para_list, lcm_initialization_setting[i].count); } }
}
static void lcd_panel_exit(u32 sel)
{
sunxi_lcd_dsi_dcs_write_0para(sel, 0x28);
sunxi_lcd_delay_ms(10);
sunxi_lcd_dsi_dcs_write_0para(sel, 0x10);
sunxi_lcd_delay_ms(10);
}/sel: 0:lcd0; 1:lcd1/
static s32 lcd_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
return 0;
}struct __lcd_panel st7701s_panel = {
/* panel driver name, must mach the name of
* lcd_drv_name in sys_config.fex
*/
.name = "st7701s",
.func = {
.cfg_panel_info = lcd_cfg_panel_info,
.cfg_open_flow = lcd_open_flow,
.cfg_close_flow = lcd_close_flow,
.lcd_user_defined_func = lcd_user_defined_func,
},
};dts 改动如下
&lcd0{base_config_start = <1>; lcd_used = <1>; lcd_driver_name = "st7701s"; lcd_bl_0_percent = <0>; lcd_bl_40_percent = <23>; lcd_bl_100_percent = <100>; lcd_backlight = <150>; lcd_if = <4>; lcd_x = <800>; lcd_y = <480>; lcd_width = <94>; lcd_height = <56>; lcd_dclk_freq = <24>; //HT*VT*fps lcd_pwm_used = <1>; lcd_pwm_ch = <9>; lcd_pwm_freq = <50000>; lcd_pwm_pol = <0>; // 0 active high lcd_pwm_max_limit = <255>; lcd_hbp = <86>; lcd_ht = <966>; lcd_hspw = <6>; lcd_vbp = <36>; lcd_vt = <546>; lcd_vspw = <6>; lcd_dsi_if = <0>; lcd_dsi_lane = <2>; lcd_dsi_format = <0>; //RGB888 lcd_dsi_te = <0>; lcd_dsi_eotp = <0>; lcd_frm = <0>; lcd_io_phase = <0x0000>; lcd_hv_clk_phase = <0>; lcd_hv_sync_polarity= <0>; lcd_gamma_en = <0>; lcd_bright_curve_en = <0>; lcd_cmap_en = <0>; lcdgamma4iep = <22>; lcd_gpio_0 = <&pio PD 19 1 0 3 1>; lcd_gpio_1 = <&pio PD 20 1 0 3 1>; pinctrl-0 = <&dsi2lane_pins_a>; pinctrl-1 = <&dsi2lane_pins_b>; base_config_end = <1>;
};
&pio{
dsi2lane_pins_a: dsi2lane@0 {
allwinner,pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6";
allwinner,pname = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6";
allwinner,function = "dsi";
allwinner,muxsel = <5>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};dsi2lane_pins_b: dsi2lane@1 { allwinner,pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6"; allwinner,pname = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6"; allwinner,function = "io_disabled"; allwinner,muxsel = <0xf>; allwinner,drive = <1>; allwinner,pull = <0>; };
};
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号