@tronlong_support 初始化驱动是用tft08006改的,之前在d1_h上验证过这个初始化驱动应该是可行的,我打印也发现确实有进入到初始化驱动里面。
现在大致猜测的问题是会不会是fb其实没有问题,因为lcd驱动其他地方出错导致lcd驱动提供给fb的起始地址就是0,然后fb这边也没有判断机制直接就用了,但具体问题可能出现在哪里还请大佬指教。
#include "jd9365da.h"
#include <linux/kernel.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, 10);
LCD_OPEN_FUNC(sel, lcd_panel_init, 10);
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 50);
LCD_OPEN_FUNC(sel, lcd_bl_open, 0);
return 0;
}
static s32 lcd_close_flow(u32 sel)
{
LCD_CLOSE_FUNC(sel, lcd_bl_close, 0);
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);
LCD_CLOSE_FUNC(sel, lcd_panel_exit, 200);
LCD_CLOSE_FUNC(sel, lcd_power_off, 500);
return 0;
}
static void lcd_power_on(u32 sel)
{
panel_reset(sel, 1);
sunxi_lcd_delay_ms(10);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(100);
panel_reset(sel, 1);
sunxi_lcd_delay_ms(20);
sunxi_lcd_pin_cfg(sel, 1);
}
static void lcd_power_off(u32 sel)
{
sunxi_lcd_pin_cfg(sel, 0);
sunxi_lcd_delay_ms(20);
panel_reset(sel, 0);
sunxi_lcd_delay_ms(5);
}
static void lcd_bl_open(u32 sel)
{
sunxi_lcd_pwm_enable(sel);
}
static void lcd_bl_close(u32 sel)
{
sunxi_lcd_pwm_disable(sel);
}
static void lcd_panel_init(u32 sel)
{
//u8 comid = 0x23;
sunxi_lcd_dsi_clk_enable(sel);
sunxi_lcd_delay_ms(100);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE0, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE1, 0x93);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE2, 0x65);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE3, 0xF8);
sunxi_lcd_dsi_gen_write_1para(sel, 0x80, 0x03);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE0, 0x01);
sunxi_lcd_dsi_gen_write_1para(sel, 0x00, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x01, 0x41);
sunxi_lcd_dsi_gen_write_1para(sel, 0x03, 0x10);
sunxi_lcd_dsi_gen_write_1para(sel, 0x04, 0x44);
sunxi_lcd_dsi_gen_write_1para(sel, 0x17, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x18, 0xD0);
sunxi_lcd_dsi_gen_write_1para(sel, 0x19, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1A, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1B, 0xD0);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1C, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x24, 0xFE);
sunxi_lcd_dsi_gen_write_1para(sel, 0x35, 0x26);
sunxi_lcd_dsi_gen_write_1para(sel, 0x37, 0x09);
sunxi_lcd_dsi_gen_write_1para(sel, 0x38, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x39, 0x08);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3A, 0x0A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3C, 0x78);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3D, 0xFF);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3E, 0xFF);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3F, 0xFF);
sunxi_lcd_dsi_gen_write_1para(sel, 0x40, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x41, 0x64);
sunxi_lcd_dsi_gen_write_1para(sel, 0x42, 0xC7);
sunxi_lcd_dsi_gen_write_1para(sel, 0x43, 0x18);
sunxi_lcd_dsi_gen_write_1para(sel, 0x44, 0x0B);
sunxi_lcd_dsi_gen_write_1para(sel, 0x45, 0x14);
sunxi_lcd_dsi_gen_write_1para(sel, 0x55, 0x02);
sunxi_lcd_dsi_gen_write_1para(sel, 0x57, 0x49);
sunxi_lcd_dsi_gen_write_1para(sel, 0x59, 0x0A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5A, 0x1B);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5B, 0x19);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5D, 0x7F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5E, 0x56);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5F, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0x60, 0x37);
sunxi_lcd_dsi_gen_write_1para(sel, 0x61, 0x33);
sunxi_lcd_dsi_gen_write_1para(sel, 0x62, 0x25);
sunxi_lcd_dsi_gen_write_1para(sel, 0x63, 0x2A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x64, 0x16);
sunxi_lcd_dsi_gen_write_1para(sel, 0x65, 0x30);
sunxi_lcd_dsi_gen_write_1para(sel, 0x66, 0x2F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x67, 0x32);
sunxi_lcd_dsi_gen_write_1para(sel, 0x68, 0x53);
sunxi_lcd_dsi_gen_write_1para(sel, 0x69, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6A, 0x4C);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6B, 0x40);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6C, 0x3D);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6D, 0x31);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6E, 0x20);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6F, 0x0F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x70, 0x7F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x71, 0x56);
sunxi_lcd_dsi_gen_write_1para(sel, 0x72, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0x73, 0x37);
sunxi_lcd_dsi_gen_write_1para(sel, 0x74, 0x33);
sunxi_lcd_dsi_gen_write_1para(sel, 0x75, 0x25);
sunxi_lcd_dsi_gen_write_1para(sel, 0x76, 0x2A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x77, 0x16);
sunxi_lcd_dsi_gen_write_1para(sel, 0x78, 0x30);
sunxi_lcd_dsi_gen_write_1para(sel, 0x79, 0x2F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x7A, 0x32);
sunxi_lcd_dsi_gen_write_1para(sel, 0x7B, 0x53);
sunxi_lcd_dsi_gen_write_1para(sel, 0x7C, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0x7D, 0x4C);
sunxi_lcd_dsi_gen_write_1para(sel, 0x7E, 0x40);
sunxi_lcd_dsi_gen_write_1para(sel, 0x7F, 0x3D);
sunxi_lcd_dsi_gen_write_1para(sel, 0x80, 0x31);
sunxi_lcd_dsi_gen_write_1para(sel, 0x81, 0x20);
sunxi_lcd_dsi_gen_write_1para(sel, 0x82, 0x0F);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE0, 0x02);
sunxi_lcd_dsi_gen_write_1para(sel, 0x00, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x01, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x02, 0x5E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x03, 0x5E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x04, 0x50);
sunxi_lcd_dsi_gen_write_1para(sel, 0x05, 0x48);
sunxi_lcd_dsi_gen_write_1para(sel, 0x06, 0x48);
sunxi_lcd_dsi_gen_write_1para(sel, 0x07, 0x4A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x08, 0x4A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x09, 0x44);
sunxi_lcd_dsi_gen_write_1para(sel, 0x0A, 0x44);
sunxi_lcd_dsi_gen_write_1para(sel, 0x0B, 0x46);
sunxi_lcd_dsi_gen_write_1para(sel, 0x0C, 0x46);
sunxi_lcd_dsi_gen_write_1para(sel, 0x0D, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x0E, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x0F, 0x57);
sunxi_lcd_dsi_gen_write_1para(sel, 0x10, 0x57);
sunxi_lcd_dsi_gen_write_1para(sel, 0x11, 0x77);
sunxi_lcd_dsi_gen_write_1para(sel, 0x12, 0x77);
sunxi_lcd_dsi_gen_write_1para(sel, 0x13, 0x40);
sunxi_lcd_dsi_gen_write_1para(sel, 0x14, 0x42);
sunxi_lcd_dsi_gen_write_1para(sel, 0x15, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x16, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x17, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x18, 0x5E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x19, 0x5E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1A, 0x50);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1B, 0x49);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1C, 0x49);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1D, 0x4B);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1E, 0x4B);
sunxi_lcd_dsi_gen_write_1para(sel, 0x1F, 0x45);
sunxi_lcd_dsi_gen_write_1para(sel, 0x20, 0x45);
sunxi_lcd_dsi_gen_write_1para(sel, 0x21, 0x47);
sunxi_lcd_dsi_gen_write_1para(sel, 0x22, 0x47);
sunxi_lcd_dsi_gen_write_1para(sel, 0x23, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x24, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x25, 0x57);
sunxi_lcd_dsi_gen_write_1para(sel, 0x26, 0x57);
sunxi_lcd_dsi_gen_write_1para(sel, 0x27, 0x77);
sunxi_lcd_dsi_gen_write_1para(sel, 0x28, 0x77);
sunxi_lcd_dsi_gen_write_1para(sel, 0x29, 0x41);
sunxi_lcd_dsi_gen_write_1para(sel, 0x2A, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0x2B, 0x5F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x2C, 0x1E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x2D, 0x1E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x2E, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x2F, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x30, 0x10);
sunxi_lcd_dsi_gen_write_1para(sel, 0x31, 0x07);
sunxi_lcd_dsi_gen_write_1para(sel, 0x32, 0x07);
sunxi_lcd_dsi_gen_write_1para(sel, 0x33, 0x05);
sunxi_lcd_dsi_gen_write_1para(sel, 0x34, 0x05);
sunxi_lcd_dsi_gen_write_1para(sel, 0x35, 0x0B);
sunxi_lcd_dsi_gen_write_1para(sel, 0x36, 0x0B);
sunxi_lcd_dsi_gen_write_1para(sel, 0x37, 0x09);
sunxi_lcd_dsi_gen_write_1para(sel, 0x38, 0x09);
sunxi_lcd_dsi_gen_write_1para(sel, 0x39, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3A, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3B, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3C, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3D, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3E, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x3F, 0x03);
sunxi_lcd_dsi_gen_write_1para(sel, 0x40, 0x01);
sunxi_lcd_dsi_gen_write_1para(sel, 0x41, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x42, 0x1E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x43, 0x1E);
sunxi_lcd_dsi_gen_write_1para(sel, 0x44, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x45, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x46, 0x10);
sunxi_lcd_dsi_gen_write_1para(sel, 0x47, 0x06);
sunxi_lcd_dsi_gen_write_1para(sel, 0x48, 0x06);
sunxi_lcd_dsi_gen_write_1para(sel, 0x49, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x4A, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x4B, 0x0A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x4C, 0x0A);
sunxi_lcd_dsi_gen_write_1para(sel, 0x4D, 0x08);
sunxi_lcd_dsi_gen_write_1para(sel, 0x4E, 0x08);
sunxi_lcd_dsi_gen_write_1para(sel, 0x4F, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x50, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x51, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x52, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x53, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x54, 0x17);
sunxi_lcd_dsi_gen_write_1para(sel, 0x55, 0x02);
sunxi_lcd_dsi_gen_write_1para(sel, 0x56, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x57, 0x1F);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE0, 0x02);
sunxi_lcd_dsi_gen_write_1para(sel, 0x58, 0x40);
sunxi_lcd_dsi_gen_write_1para(sel, 0x59, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5A, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5B, 0x30);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5C, 0x01);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5D, 0x30);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5E, 0x01);
sunxi_lcd_dsi_gen_write_1para(sel, 0x5F, 0x02);
sunxi_lcd_dsi_gen_write_1para(sel, 0x60, 0x30);
sunxi_lcd_dsi_gen_write_1para(sel, 0x61, 0x03);
sunxi_lcd_dsi_gen_write_1para(sel, 0x62, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x63, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x64, 0xA6);
sunxi_lcd_dsi_gen_write_1para(sel, 0x65, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0x66, 0x30);
sunxi_lcd_dsi_gen_write_1para(sel, 0x67, 0x73);
sunxi_lcd_dsi_gen_write_1para(sel, 0x68, 0x05);
sunxi_lcd_dsi_gen_write_1para(sel, 0x69, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6A, 0x7F);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6B, 0x08);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6C, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6D, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6E, 0x04);
sunxi_lcd_dsi_gen_write_1para(sel, 0x6F, 0x88);
sunxi_lcd_dsi_gen_write_1para(sel, 0x75, 0xD9);
sunxi_lcd_dsi_gen_write_1para(sel, 0x76, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x77, 0x33);
sunxi_lcd_dsi_gen_write_1para(sel, 0x78, 0x43);
sunxi_lcd_dsi_gen_write_1para(sel, 0xE0, 0x00);
sunxi_lcd_dsi_gen_write_1para(sel, 0x11, 0x00);
sunxi_lcd_delay_ms(129);
sunxi_lcd_dsi_gen_write_1para(sel, 0x29, 0x00);
sunxi_lcd_delay_ms(5);
sunxi_lcd_dsi_gen_write_1para(sel, 0x35, 0x00);
__wrn("[damon_lcd] lcd_panel_init\n");
}
static void lcd_panel_exit(u32 sel)
{
//sunxi_lcd_dsi_dcs_write_0para(sel, 0x10);
sunxi_lcd_delay_ms(80);
//sunxi_lcd_dsi_dcs_write_0para(sel, 0x28);
sunxi_lcd_delay_ms(50);
__wrn("[damon_lcd] lcd_panel_exit\n");
}
/*sel: 0:lcd0; 1:lcd1*/
static s32 lcd_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
return 0;
}
struct __lcd_panel jd9365da_panel = {
/* panel driver name, must mach the name of
* lcd_drv_name in sys_config.fex
*/
.name = "jd9365da",
.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,
},
};