文章目录
1、环境介绍
硬件:小智 T113 板卡
软件:原厂 Tina5.0 SDK v1.2(Buildroot)
2、前言
本文主要记录 T113 板卡适配 MIPI DSI 接口的长条屏(FL7707)。

3、T113 MIPI DSI 资源
T113 只有 1 个 MIPI DSI 接口,最多支持 4 lanes,分辨率最高支持 1920×1200@60fps ,像素格式支持 RGB888、RGB666、RGB666 loosely packed、RGB565。
4、原理图查看
如下为 MIPI DSI 屏幕原理图:

- MIPI_LCD_RST:PD20
如下为背光部分原理图:

- LCD_PWM:PD22(PWM7)
如下图为触摸部分原理图:

- TP_INT:PE5
- TP_SDA:PE1(twi1)
- TP_SCL:PE0(twi1)
- TP_RST:PE4
5、U-Boot 驱动移植
U-Boot 和内核都需要完成对屏幕的适配,包括驱动、设备树。驱动文件来自小智学长提供:https://x509p6c8to.feishu.cn/docx/VGcbddyRpoVO4px2oKDcOFcSn0b,但直接编译会报错,后文展示的驱动是根据报错修改过的,主要就是一些结构体定义。
5.1、添加 fl7707 驱动文件
cd <sdk>/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd
touch fl7707n_mipi.c
touch fl7707n_mipi.h
/* fl7707n_mipi.c */
/* drivers/video/sunxi/disp2/disp/lcd/fl7707n_mipi.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.
*
*/
#include "fl7707n_mipi.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(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)
{
printk("=====================lcd_open_flow\n");
LCD_OPEN_FUNC(sel, lcd_power_on, 100);
LCD_OPEN_FUNC(sel, lcd_panel_init, 120);
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 120);
LCD_OPEN_FUNC(sel, lcd_bl_open, 0);
return 0;
}
static s32 lcd_close_flow(u32 sel)
{
printk("=====================lcd_close_flow\n");
LCD_CLOSE_FUNC(sel, lcd_bl_close, 0);
LCD_CLOSE_FUNC(sel, lcd_panel_exit, 200);
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);
LCD_CLOSE_FUNC(sel, lcd_power_off, 500);
return 0;
}
static void lcd_power_on(u32 sel)
{
printk("=====================lcd_power_on\n");
sunxi_lcd_pin_cfg(sel, 1);
sunxi_lcd_power_enable(sel, 0);
// sunxi_lcd_power_enable(sel, 1);
sunxi_lcd_delay_ms(50);
/* reset lcd by gpio */
panel_reset(sel, 1);
sunxi_lcd_delay_ms(5);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(10);
panel_reset(sel, 1);
sunxi_lcd_delay_ms(120);
sunxi_lcd_delay_ms(10);
}
static void lcd_power_off(u32 sel)
{
printk("=====================lcd_power_off\n");
sunxi_lcd_pin_cfg(sel, 0);
sunxi_lcd_delay_ms(20);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(5);
sunxi_lcd_power_disable(sel, 0);
}
static void lcd_bl_open(u32 sel)
{
printk("=====================lcd_bl_open\n");
sunxi_lcd_pwm_enable(sel);
sunxi_lcd_backlight_enable(sel);
}
static void lcd_bl_close(u32 sel)
{
printk("=====================lcd_bl_close\n");
sunxi_lcd_backlight_disable(sel);
sunxi_lcd_pwm_disable(sel);
}
#define REGFLAG_DELAY 0XFC
#define REGFLAG_END_OF_TABLE 0xFD /* END OF REGISTERS MARKER */
struct LCM_setting_table {
u8 cmd;
u32 count;
u8 para_list[100];
};
static struct LCM_setting_table lcm_initialization_setting[] = {
{0xB9, 3, {0xF1,0x12,0x87} },
{0xB2, 3, {0x64,0x05,0x78} },
{0xB3, 10, {0x10,0x10,0x28,0x28,0x03,0xFF,0x00,0x00,0x00,0x00} },
{0xB4, 1, {0x80} },
{0xB5, 2, {0x0D,0x0D} },
{0xB6, 2, {0x4F,0x4F} },
{0xB8, 4, {0x26,0x22,0xF0,0x13} },
{0xBA, 27, {0x33,0x81,0x05,0xF9,0x0E,0x0E,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x25,0x00,0x91,0x0A,0x00,0x00,0x01,0x4F,0x01,0x00,0x00,0x37} },
{0xBC, 1, {0x47} },
{0xBF, 5, {0x02,0x10,0x00,0x80,0x04} },
{0xC0, 9, {0x73,0x73,0x50,0x50,0x00,0x00,0x12,0x73,0x00} },
{0xC1, 17, {0x54,0x00,0x32,0x32,0x99,0xE4,0x77,0x77,0xCC,0xCC,0xFF,0xFF,0x11,0x11,0x00,0x00,0x32} },
{0xC7, 12, {0x10,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,0xED,0xC5,0x00,0xA5} },
{0xC8, 4, {0x10,0x40,0x1E,0x03} },
{0xCC, 1, {0x0B} },
{0xE0, 34, {0x00,0x0B,0x12,0x29,0x3C,0x3F,0x47,0x3D,0x06,0x0C,0x0D,0x12,0x13,0x11,0x13,0x13,0x1B,0x00,0x0B,0x12,0x29,0x3C,0x3F,0x47,0x3D,0x06,0x0C,0x0D,0x12,0x13,0x11,0x13,0x13,0x1B} },
{0xE1, 7, {0x11,0x11,0x91,0x00,0x00,0x00,0x00} },
{0xE3, 14, {0x07,0x07,0x0B,0x0B,0x0B,0x0B,0x00,0x00,0x00,0x00,0xFF,0x04,0xC0,0x10} },
{0xE9, 63, {0xC8,0x10,0x0A,0x10,0x0D,0x80,0x38,0x12,0x31,0x23,0x4F,0x86,0x80,0x38,0x47,0x08,0x00,0x00,0x4F,0x00,0x00,0x04,0x00,0x00,0x4F,0x00,0x00,0x04,0x94,0xA3,0xF8,0x18,0x13,0x57,0x88,0x88,0x88,0x88,0x88,0x94,0xA2,0xF8,0x08,0x02,0x46,0x88,0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x01,0x00,0x80,0x38,0x00,0x00,0x00,0x00,0x00,0x00} },
{0xEA, 61, {0x00,0x1A,0x00,0x00,0x00,0x00,0x01,0x0A,0x41,0x01,0x02,0x00,0x94,0xA0,0x8F,0x28,0x64,0x20,0x88,0x88,0x88,0x88,0x88,0x94,0xA1,0x8F,0x38,0x75,0x31,0x88,0x88,0x88,0x88,0x88,0x23,0x00,0x00,0x00,0xD3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0xAA,0x00,0x00,0x40,0x80,0x38,0x40,0x80,0x38,0x00} },
{0xEF, 3, {0xFF,0xFF,0x01} },
{0x11, 0, {} },
{REGFLAG_DELAY, REGFLAG_DELAY, {250} },
{0x29, 0, {} },
{REGFLAG_DELAY, REGFLAG_DELAY, {50} },
{REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {} }
};
static void lcd_panel_init(u32 sel)
{
u32 i = 0;
sunxi_lcd_dsi_clk_enable(sel);
sunxi_lcd_delay_ms(100);
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(80);
sunxi_lcd_dsi_dcs_write_0para(sel, 0x10);
sunxi_lcd_delay_ms(50);
}
/*sel: 0:lcd0; 1:lcd1*/
static s32 lcd_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
return 0;
}
__lcd_panel_t fl7707n_mipi_panel = {
/* panel driver name, must mach the name of
* lcd_drv_name in sys_config.fex
*/
.name = "fl7707n_mipi",
.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,
},
};
/* fl7707n_mipi.h */
#ifndef _FL7707N_MIPI_H
#define _FL7707N_MIPI_H
#include "panels.h"
extern __lcd_panel_t fl7707n_mipi_panel;
extern s32 bsp_disp_get_panel_info(u32 screen_id, disp_panel_para *info);
#endif /*End of file*/
5.2、修改 Makefile
vi <sdk>/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/Makefile
disp-$(CONFIG_LCD_SUPPORT_FL7707N_MIPI) += lcd/fl7707n_mipi.o

5.3、修改 Kconfig
vi <sdk>/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd/Kconfig
config LCD_SUPPORT_FL7707N_MIPI
bool "LCD support FL7707N_MIPI panel"
default n
help
If you want to support FL7707N_MIPI panel for display driver, select it.

6、U-Boot Menuconfig 配置
CONFIG_LCD_SUPPORT_FL7707N_MIPI=y
7、U-Boot 设备树配置
&lcd0 {
lcd_used = <1>; // 启用lcd
lcd_driver_name = "fl7707n_mipi";// lcd 驱动名称
lcd_backlight = <50>;
lcd_if = <4>; // 0:rgb 4:dsi
lcd_x = <280>; // 像素宽度
lcd_y = <1424>; // 像素高度
lcd_width = <33>; // 屏幕物理宽度,单位 mm
lcd_height = <170>; // 屏幕物理高度,单位 mm
lcd_dclk_freq = <63>; // 屏幕时钟,单位 MHz lcd_ht * lcd_vt * 60
lcd_pwm_used = <1>; // 启用背光 PWM
lcd_pwm_ch = <7>; // 使用 PWM 通道 7
lcd_pwm_freq = <10000>; // PWM 频率,单位 Hz
lcd_pwm_pol = <0>; // 背光 PWM 的极性
lcd_pwm_max_limit = <255>;
lcd_hbp = <90>; // hsync back porch(pixel) + hsync plus width(pixel);
lcd_ht = <850>; // hsync total cycle(pixel)
lcd_hspw = <30>; // hsync plus width(pixel)
lcd_vbp = <18>; // vsync back porch(line) + vysnc plus width(line)
lcd_vt = <1457>; // vsync total cycle(line)
lcd_vspw = <3>; // vsync plus width(pixel)
lcd_dsi_lane = <4>;
lcd_dsi_if = <0>;
lcd_dsi_format = <0>;
lcd_dsi_te = <0>;
lcd_frm = <0>;
lcd_io_phase = <0>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
deu_mode = <0>;
lcdgamma4iep = <22>;
smart_color = <90>;
lcd_gpio_0 = <&pio PD 20 GPIO_ACTIVE_HIGH>;// lcd reset
pinctrl-0 = <&dsi4lane_pins_a>;
pinctrl-1 = <&dsi4lane_pins_b>;
};
8、内核驱动移植
8.1、添加 fl7707 驱动文件
cd <sdk>/kernel/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd
touch fl7707n_mipi.c
touch fl7707n_mipi.h
/* fl7707n_mipi.c */
/* drivers/video/sunxi/disp2/disp/lcd/fl7707n_mipi.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.
*
*/
#include "fl7707n_mipi.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)
{
printk("=====================lcd_open_flow\n");
LCD_OPEN_FUNC(sel, lcd_power_on, 100);
LCD_OPEN_FUNC(sel, lcd_panel_init, 120);
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 120);
LCD_OPEN_FUNC(sel, lcd_bl_open, 0);
return 0;
}
static s32 lcd_close_flow(u32 sel)
{
printk("=====================lcd_close_flow\n");
LCD_CLOSE_FUNC(sel, lcd_bl_close, 0);
LCD_CLOSE_FUNC(sel, lcd_panel_exit, 200);
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);
LCD_CLOSE_FUNC(sel, lcd_power_off, 500);
return 0;
}
static void lcd_power_on(u32 sel)
{
printk("=====================lcd_power_on\n");
sunxi_lcd_pin_cfg(sel, 1);
sunxi_lcd_power_enable(sel, 0);
// sunxi_lcd_power_enable(sel, 1);
sunxi_lcd_delay_ms(50);
/* reset lcd by gpio */
panel_reset(sel, 1);
sunxi_lcd_delay_ms(5);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(10);
panel_reset(sel, 1);
sunxi_lcd_delay_ms(120);
sunxi_lcd_delay_ms(10);
}
static void lcd_power_off(u32 sel)
{
printk("=====================lcd_power_off\n");
sunxi_lcd_pin_cfg(sel, 0);
sunxi_lcd_delay_ms(20);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(5);
sunxi_lcd_power_disable(sel, 0);
}
static void lcd_bl_open(u32 sel)
{
printk("=====================lcd_bl_open\n");
sunxi_lcd_pwm_enable(sel);
sunxi_lcd_backlight_enable(sel);
}
static void lcd_bl_close(u32 sel)
{
printk("=====================lcd_bl_close\n");
sunxi_lcd_backlight_disable(sel);
sunxi_lcd_pwm_disable(sel);
}
#define REGFLAG_DELAY 0XFC
#define REGFLAG_END_OF_TABLE 0xFD /* END OF REGISTERS MARKER */
struct LCM_setting_table {
u8 cmd;
u32 count;
u8 para_list[100];
};
static struct LCM_setting_table lcm_initialization_setting[] = {
{0xB9, 3, {0xF1,0x12,0x87} },
{0xB2, 3, {0x64,0x05,0x78} },
{0xB3, 10, {0x10,0x10,0x28,0x28,0x03,0xFF,0x00,0x00,0x00,0x00} },
{0xB4, 1, {0x80} },
{0xB5, 2, {0x0D,0x0D} },
{0xB6, 2, {0x4F,0x4F} },
{0xB8, 4, {0x26,0x22,0xF0,0x13} },
{0xBA, 27, {0x33,0x81,0x05,0xF9,0x0E,0x0E,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x25,0x00,0x91,0x0A,0x00,0x00,0x01,0x4F,0x01,0x00,0x00,0x37} },
{0xBC, 1, {0x47} },
{0xBF, 5, {0x02,0x10,0x00,0x80,0x04} },
{0xC0, 9, {0x73,0x73,0x50,0x50,0x00,0x00,0x12,0x73,0x00} },
{0xC1, 17, {0x54,0x00,0x32,0x32,0x99,0xE4,0x77,0x77,0xCC,0xCC,0xFF,0xFF,0x11,0x11,0x00,0x00,0x32} },
{0xC7, 12, {0x10,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,0xED,0xC5,0x00,0xA5} },
{0xC8, 4, {0x10,0x40,0x1E,0x03} },
{0xCC, 1, {0x0B} },
{0xE0, 34, {0x00,0x0B,0x12,0x29,0x3C,0x3F,0x47,0x3D,0x06,0x0C,0x0D,0x12,0x13,0x11,0x13,0x13,0x1B,0x00,0x0B,0x12,0x29,0x3C,0x3F,0x47,0x3D,0x06,0x0C,0x0D,0x12,0x13,0x11,0x13,0x13,0x1B} },
{0xE1, 7, {0x11,0x11,0x91,0x00,0x00,0x00,0x00} },
{0xE3, 14, {0x07,0x07,0x0B,0x0B,0x0B,0x0B,0x00,0x00,0x00,0x00,0xFF,0x04,0xC0,0x10} },
{0xE9, 63, {0xC8,0x10,0x0A,0x10,0x0D,0x80,0x38,0x12,0x31,0x23,0x4F,0x86,0x80,0x38,0x47,0x08,0x00,0x00,0x4F,0x00,0x00,0x04,0x00,0x00,0x4F,0x00,0x00,0x04,0x94,0xA3,0xF8,0x18,0x13,0x57,0x88,0x88,0x88,0x88,0x88,0x94,0xA2,0xF8,0x08,0x02,0x46,0x88,0x88,0x88,0x88,0x88,0x00,0x00,0x00,0x01,0x00,0x80,0x38,0x00,0x00,0x00,0x00,0x00,0x00} },
{0xEA, 61, {0x00,0x1A,0x00,0x00,0x00,0x00,0x01,0x0A,0x41,0x01,0x02,0x00,0x94,0xA0,0x8F,0x28,0x64,0x20,0x88,0x88,0x88,0x88,0x88,0x94,0xA1,0x8F,0x38,0x75,0x31,0x88,0x88,0x88,0x88,0x88,0x23,0x00,0x00,0x00,0xD3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0xAA,0x00,0x00,0x40,0x80,0x38,0x40,0x80,0x38,0x00} },
{0xEF, 3, {0xFF,0xFF,0x01} },
{0x11, 0, {} },
{REGFLAG_DELAY, REGFLAG_DELAY, {250} },
{0x29, 0, {} },
{REGFLAG_DELAY, REGFLAG_DELAY, {50} },
{REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {} }
};
static void lcd_panel_init(u32 sel)
{
u32 i = 0;
sunxi_lcd_dsi_clk_enable(sel);
sunxi_lcd_delay_ms(100);
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(80);
sunxi_lcd_dsi_dcs_write_0para(sel, 0x10);
sunxi_lcd_delay_ms(50);
}
/*sel: 0:lcd0; 1:lcd1*/
static s32 lcd_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
return 0;
}
struct __lcd_panel fl7707n_mipi_panel = {
/* panel driver name, must mach the name of
* lcd_drv_name in sys_config.fex
*/
.name = "fl7707n_mipi",
.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,
},
};
/* fl7707n_mipi.h */
#ifndef _FL7707N_MIPI_H
#define _FL7707N_MIPI_H
#include "panels.h"
extern struct __lcd_panel fl7707n_mipi_panel;
extern s32 bsp_disp_get_panel_info(u32 screen_id, struct disp_panel_para *info);
#endif /*End of file*/
8.2、修改 Makefile
vi <sdk>/kernel/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/Makefile
disp-$(CONFIG_LCD_SUPPORT_FL7707N_MIPI) += lcd/fl7707n_mipi.o

8.3、修改 Kconfig
vi <sdk>/kernel/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd/Kconfig
config LCD_SUPPORT_FL7707N_MIPI
bool "LCD support fl7707n_mipi panel"
default n
---help---
If you want to support fl7707n_mipi panel for display driver, select it.

9、内核配置
# 触摸
CONFIG_TOUCHSCREEN_GT9XXNEW_TS=y
# 屏幕
CONFIG_LCD_SUPPORT_FL7707N_MIPI=y
# 背光
CONFIG_BACKLIGHT_CLASS_DEVICE=y
CONFIG_BACKLIGHT_PWM=y
CONFIG_BACKLIGHT_GPIO=y
10、内核设备树配置
10.1、屏幕
&lcd0 {
lcd_used = <1>; // 启用lcd
lcd_driver_name = "fl7707n_mipi";// lcd 驱动名称
lcd_backlight = <50>;
lcd_if = <4>; // 0:rgb 4:dsi
lcd_x = <280>; // 像素宽度
lcd_y = <1424>; // 像素高度
lcd_width = <33>; // 屏幕物理宽度,单位 mm
lcd_height = <170>; // 屏幕物理高度,单位 mm
lcd_dclk_freq = <63>; // 屏幕时钟,单位 MHz lcd_ht * lcd_vt * 60
lcd_pwm_used = <1>; // 启用背光 PWM
lcd_pwm_ch = <7>; // 使用 PWM 通道 7
lcd_pwm_freq = <10000>; // PWM 频率,单位 Hz
lcd_pwm_pol = <0>; // 背光 PWM 的极性
lcd_pwm_max_limit = <255>;
lcd_hbp = <90>; // hsync back porch(pixel) + hsync plus width(pixel);
lcd_ht = <850>; // hsync total cycle(pixel)
lcd_hspw = <30>; // hsync plus width(pixel)
lcd_vbp = <18>; // vsync back porch(line) + vysnc plus width(line)
lcd_vt = <1457>; // vsync total cycle(line)
lcd_vspw = <3>; // vsync plus width(pixel)
lcd_dsi_lane = <4>;
lcd_dsi_if = <0>;
lcd_dsi_format = <0>;
lcd_dsi_te = <0>;
lcd_frm = <0>;
lcd_io_phase = <0>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
deu_mode = <0>;
lcdgamma4iep = <22>;
smart_color = <90>;
lcd_gpio_0 = <&pio PD 20 GPIO_ACTIVE_HIGH>;// lcd reset
pinctrl-0 = <&dsi4lane_pins_a>;
pinctrl-1 = <&dsi4lane_pins_b>;
};
10.2、背光
/ {
backlight: backlight {
compatible = "pwm-backlight";
pwms = <&pwm 7 10000 0>;
pwm-names = "backlight";
brightness-levels = <
0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31
32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47
48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63
64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87
88 89 90 91 92 93 94 95
96 97 98 99 100 101 102 103
104 105 106 107 108 109 110 111
112 113 114 115 116 117 118 119
120 121 122 123 124 125 126 127
128 129 130 131 132 133 134 135
136 137 138 139 140 141 142 143
144 145 146 147 148 149 150 151
152 153 154 155 156 157 158 159
160 161 162 163 164 165 166 167
168 169 170 171 172 173 174 175
176 177 178 179 180 181 182 183
184 185 186 187 188 189 190 191
192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207
208 209 210 211 212 213 214 215
216 217 218 219 220 221 222 223
224 225 226 227 228 229 230 231
232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247
248 249 250 251 252 253 254 255
>;
default-brightness-level = <200>;
status = "okay";
};
}
&pio {
...
pwm7_pin_a: pwm7@0 {
pins = "PD22";
function = "pwm7";
drive-strength = <10>;
bias-pull-up;
};
pwm7_pin_b: pwm7@1 {
pins = "PD22";
function = "gpio_in";
};
...
};
&pwm7 {
pinctrl-names = "active", "sleep";
pinctrl-0 = <&pwm7_pin_a>;
pinctrl-1 = <&pwm7_pin_b>;
status = "okay";
};
10.3、触摸
&pio {
...
twi1_pins_a: twi1@0 {
pins = "PE0", "PE1";
function = "twi1";
drive-strength = <10>;
};
twi1_pins_b: twi1@1 {
pins = "PE0", "PE1";
function = "gpio_in";
};
/*
csi0_pins_a: csi0@0 {
pins = "PE2", "PE4", "PE5",
"PE6", "PE7", "PE8", "PE9", "PE10", "PE11";
function = "ncsi0";
drive-strength = <10>;
};
csi0_pins_b: csi0@1 {
pins = "PE2", "PE4", "PE5",
"PE6", "PE7", "PE8", "PE9", "PE10", "PE11";
function = "io_disabled";
drive-strength = <10>;
};
*/
...
};
&twi1 {
clock-frequency = <400000>;
pinctrl-0 = <&twi1_pins_a>;
pinctrl-1 = <&twi1_pins_b>;
pinctrl-names = "default", "sleep";
status = "okay";
ctp@14 {
compatible = "allwinner,goodix";
device_type = "ctp";
reg = <0x14>;
status = "okay";
ctp_name = "gt9xxnew_ts";
ctp_twi_id = <0x1>;
ctp_twi_addr = <0x14>;
ctp_screen_max_x = <0x3C0>;
ctp_screen_max_y = <0x140>;
ctp_revert_x_flag = <0x0>;
ctp_revert_y_flag = <0x0>;
ctp_exchange_x_y_flag = <0x0>;
ctp_int_port = <&pio PE 5 GPIO_ACTIVE_HIGH>;
ctp_wakeup = <&pio PE 4 GPIO_ACTIVE_HIGH>;
/*ctp-supply = <®_aldo2>;*/
/*ctp_power_ldo = <®_aldo2>;*/
/*ctp_power_ldo_vol = <3300>;*/
};
};
11、测试验证
11.1、背光
查看当前背光:
cat /sys/class/backlight/backlight/brightness
调整背光:
# 亮度值 xxx = 0~255
echo xxx > /sys/class/backlight/backlight/brightness
11.2、显示
花屏测试:
cat /dev/urandom > /dev/fb0

彩条测试:
cat /dev/zero > /dev/fb0
echo 8 > /sys/class/disp/disp/attr/colorbar

11.3、触摸
查看触摸设备:
cat /proc/bus/input/devices

查看触摸原始数据:
hexdump /dev/input/event5

12、Logo 显示
logo 图片路径位于,替换后直接重新打包镜像即可:
<sdk>/device/config/chips/t113/configs/xiaozhi/bootlogo.bmp
- 图片格式须为 .bmp 格式,24位图
- 图片像素尺寸不得大于屏幕像素尺寸

13、参考文章
略。
14、总结
本文主要记录了 T113 下的 MIPI DSI 屏幕适配(fl7707)。
212

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



