Skip to content

Instantly share code, notes, and snippets.

@parthibx24
Last active May 2, 2019 12:40
Show Gist options
  • Save parthibx24/982d79e1f7e5f6936a88b3ac74b994a7 to your computer and use it in GitHub Desktop.
Save parthibx24/982d79e1f7e5f6936a88b3ac74b994a7 to your computer and use it in GitHub Desktop.
Collection of Mediatek LCM drivers. Some of them are reverse engineered and some are adapted/optimized from existing sources.
Symphony V75 (Wiko v2800):
- jd9161_fwvga_dsi_vdo_dj
- ili9806e_fwvga_dsi_vdo_zgd
Walton Primo NF2 (Vsun V060):
- hx8394d_bld_cmi
- hx8394f_bld_cmi
- ili9881c_dj_hsd
Cubot NOTE S:
- xc_rm68200_dsi_vdo_hd720
MicroMax Q354(esky6580_we_c_m\q354_80m):
- jd9161ba_ivo_tn_wvga (Not-Tested)
- st7701_fwvga_dsi_vdo_cpt (Not-Tested)
below,
/**
* Version 19.221
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "xc_rm68200_dsi_vdo_hd720"
#define LCM_VERSION "19.221" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x8000)
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/**
* REGFLAG_DELAY, used to trigger MDELAY,
* REGFLAG_END_OF_TABLE, used to mark the end of LCM_setting_table.
* their values dosen't matter until they,
* match with any LCM_setting_table->cmd.
*/
#define REGFLAG_DELAY (0xFF)
#define REGFLAG_END_OF_TABLE (0xDD)
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) print(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[2];
};
static struct LCM_setting_table lcm_initialization_setting[] =
{
{0xFE,1,{0x01}},
{0x00,1,{0x0A}},
{0x24,1,{0xC0}},
{0x25,1,{0x53}},
{0x26,1,{0x00}},
{0x27,1,{0x0A}},
{0x29,1,{0x0A}},
{0x2B,1,{0xE5}},
{0x16,1,{0x52}},
{0x2F,1,{0x44}},
{0x34,1,{0x45}},
{0x1B,1,{0x00}},
{0x12,1,{0x08}},
{0x1A,1,{0x06}},
{0x52,1,{0x8A}},
{0x53,1,{0x00}},
{0x54,1,{0x8A}},
{0x55,1,{0x00}},
{0x5F,1,{0x12}},
{0xFE,1,{0x03}},
{0x01,1,{0x14}},
{0x02,1,{0x01}},
{0x03,1,{0x00}},
{0x04,1,{0x00}},
{0x05,1,{0x00}},
{0x06,1,{0x00}},
{0x07,1,{0x05}},
{0x08,1,{0x14}},
{0x09,1,{0x06}},
{0x0A,1,{0x00}},
{0x0B,1,{0x00}},
{0x0C,1,{0x00}},
{0x0D,1,{0x00}},
{0x0E,1,{0x0A}},
{0x0F,1,{0x0B}},
{0x10,1,{0x0C}},
{0x11,1,{0x0D}},
{0x12,1,{0x00}},
{0x13,1,{0x7D}},
{0x14,1,{0x00}},
{0x15,1,{0xC5}},
{0x16,1,{0x08}},
{0x17,1,{0x0E}},
{0x18,1,{0x0F}},
{0x19,1,{0x10}},
{0x1A,1,{0x11}},
{0x1B,1,{0x00}},
{0x1C,1,{0x7D}},
{0x1D,1,{0x00}},
{0x1E,1,{0x85}},
{0x1F,1,{0x08}},
{0x20,1,{0x00}},
{0x21,1,{0x00}},
{0x22,1,{0x0A}},
{0x23,1,{0x10}},
{0x24,1,{0x12}},
{0x25,1,{0x2D}},
{0x26,1,{0x00}},
{0x27,1,{0x14}},
{0x28,1,{0x16}},
{0x29,1,{0x2D}},
{0x2A,1,{0x00}},
{0x2B,1,{0x00}},
{0x2C,1,{0x00}},
{0x2D,1,{0x00}},
{0x2E,1,{0x00}},
{0x2F,1,{0x00}},
{0x30,1,{0x00}},
{0x31,1,{0x00}},
{0x32,1,{0x00}},
{0x33,1,{0x00}},
{0x34,1,{0x00}},
{0x35,1,{0x00}},
{0x36,1,{0x00}},
{0x37,1,{0x00}},
{0x38,1,{0x00}},
{0x39,1,{0x00}},
{0x3A,1,{0x00}},
{0x3B,1,{0x00}},
{0x3C,1,{0x00}},
{0x3D,1,{0x00}},
{0x3E,1,{0x00}},
{0x3F,1,{0x00}},
{0x40,1,{0x00}},
{0x41,1,{0x00}},
{0x42,1,{0x00}},
{0x43,1,{0x00}},
{0x44,1,{0x00}},
{0x45,1,{0x00}},
{0x46,1,{0x00}},
{0x47,1,{0x00}},
{0x48,1,{0x00}},
{0x49,1,{0x00}},
{0x4A,1,{0x00}},
{0x4B,1,{0x00}},
{0x4C,1,{0x00}},
{0x4D,1,{0x00}},
{0x4E,1,{0x00}},
{0x4F,1,{0x00}},
{0x50,1,{0x00}},
{0x51,1,{0x00}},
{0x52,1,{0x00}},
{0x53,1,{0x00}},
{0x54,1,{0x00}},
{0x55,1,{0x00}},
{0x56,1,{0x00}},
{0x57,1,{0x00}},
{0x58,1,{0x00}},
{0x59,1,{0x00}},
{0x5A,1,{0x00}},
{0x5B,1,{0x00}},
{0x5C,1,{0x00}},
{0x5D,1,{0x00}},
{0x5E,1,{0x00}},
{0x5F,1,{0x00}},
{0x60,1,{0x00}},
{0x61,1,{0x00}},
{0x62,1,{0x00}},
{0x63,1,{0x00}},
{0x64,1,{0x00}},
{0x65,1,{0x00}},
{0x66,1,{0x00}},
{0x67,1,{0x00}},
{0x68,1,{0x00}},
{0x69,1,{0x00}},
{0x6A,1,{0x00}},
{0x6B,1,{0x00}},
{0x6C,1,{0x00}},
{0x6D,1,{0x00}},
{0x6E,1,{0x00}},
{0x6F,1,{0x00}},
{0x70,1,{0x00}},
{0x71,1,{0x00}},
{0x72,1,{0x00}},
{0x73,1,{0x00}},
{0x74,1,{0x00}},
{0x75,1,{0x00}},
{0x76,1,{0x00}},
{0x77,1,{0x00}},
{0x78,1,{0x00}},
{0x79,1,{0x00}},
{0x7A,1,{0x00}},
{0x7B,1,{0x00}},
{0x7C,1,{0x00}},
{0x7D,1,{0x00}},
{0x7E,1,{0x8B}},
{0x7F,1,{0x09}},
{0x80,1,{0x0F}},
{0x81,1,{0x0D}},
{0x82,1,{0x05}},
{0x83,1,{0x07}},
{0x84,1,{0x3F}},
{0x85,1,{0x3F}},
{0x86,1,{0x3F}},
{0x87,1,{0x3F}},
{0x88,1,{0x3F}},
{0x89,1,{0x3F}},
{0x8A,1,{0x3F}},
{0x8B,1,{0x3F}},
{0x8C,1,{0x3F}},
{0x8D,1,{0x3F}},
{0x8E,1,{0x3F}},
{0x8F,1,{0x3F}},
{0x90,1,{0x3F}},
{0x91,1,{0x01}},
{0x92,1,{0x1C}},
{0x93,1,{0x1D}},
{0x94,1,{0x1D}},
{0x95,1,{0x1C}},
{0x96,1,{0x00}},
{0x97,1,{0x3F}},
{0x98,1,{0x3F}},
{0x99,1,{0x3F}},
{0x9A,1,{0x3F}},
{0x9B,1,{0x3F}},
{0x9C,1,{0x3F}},
{0x9D,1,{0x3F}},
{0x9E,1,{0x3F}},
{0x9F,1,{0x3F}},
{0xA0,1,{0x3F}},
{0xA2,1,{0x3F}},
{0xA3,1,{0x3F}},
{0xA4,1,{0x3F}},
{0xA5,1,{0x06}},
{0xA6,1,{0x04}},
{0xA7,1,{0x0C}},
{0xA9,1,{0x0E}},
{0xAA,1,{0x08}},
{0xAB,1,{0x0A}},
{0xAC,1,{0x07}},
{0xAD,1,{0x05}},
{0xAE,1,{0x0D}},
{0xAF,1,{0x0F}},
{0xB0,1,{0x09}},
{0xB1,1,{0x8B}},
{0xB2,1,{0x3F}},
{0xB3,1,{0x3F}},
{0xB4,1,{0x3F}},
{0xB5,1,{0x3F}},
{0xB6,1,{0x3F}},
{0xB7,1,{0x3F}},
{0xB8,1,{0x3F}},
{0xB9,1,{0x3F}},
{0xBA,1,{0x3F}},
{0xBB,1,{0x3F}},
{0xBC,1,{0x3F}},
{0xBD,1,{0x3F}},
{0xBE,1,{0x3F}},
{0xBF,1,{0x00}},
{0xC0,1,{0x1D}},
{0xC1,1,{0x1C}},
{0xC2,1,{0x1C}},
{0xC3,1,{0x1D}},
{0xC4,1,{0x01}},
{0xC5,1,{0x3F}},
{0xC6,1,{0x3F}},
{0xC7,1,{0x3F}},
{0xC8,1,{0x3F}},
{0xC9,1,{0x3F}},
{0xCA,1,{0x3F}},
{0xCB,1,{0x3F}},
{0xCC,1,{0x3F}},
{0xCD,1,{0x3F}},
{0xCE,1,{0x3F}},
{0xCF,1,{0x3F}},
{0xD0,1,{0x3F}},
{0xD1,1,{0x3F}},
{0xD2,1,{0x0A}},
{0xD3,1,{0x08}},
{0xD4,1,{0x0E}},
{0xD5,1,{0x0C}},
{0xD6,1,{0x04}},
{0xD7,1,{0x06}},
{0xDC,1,{0x02}},
{0xDE,1,{0x11}},
{0xFE,1,{0x0E}},
{0x1B,1,{0x00}},
{0x1C,1,{0x00}},
{0x01,1,{0x75}},
{0xFE,1,{0x04}},
{0x60,1,{0x00}},
{0x61,1,{0x19}},
{0x62,1,{0x1D}},
{0x63,1,{0x10}},
{0x64,1,{0x07}},
{0x65,1,{0x14}},
{0x66,1,{0x0E}},
{0x67,1,{0x0A}},
{0x68,1,{0x16}},
{0x69,1,{0x0C}},
{0x6A,1,{0x0D}},
{0x6B,1,{0x08}},
{0x6C,1,{0x0F}},
{0x6D,1,{0x0F}},
{0x6E,1,{0x0A}},
{0x6F,1,{0x00}},
{0x70,1,{0x00}},
{0x71,1,{0x19}},
{0x72,1,{0x1D}},
{0x73,1,{0x10}},
{0x74,1,{0x07}},
{0x75,1,{0x14}},
{0x76,1,{0x0E}},
{0x77,1,{0x0A}},
{0x78,1,{0x16}},
{0x79,1,{0x0C}},
{0x7A,1,{0x0D}},
{0x7B,1,{0x08}},
{0x7C,1,{0x0F}},
{0x7D,1,{0x0F}},
{0x7E,1,{0x0A}},
{0x7F,1,{0x00}},
{0xFE,1,{0x00}},
{0x11,0,{}},
{REGFLAG_DELAY,120,{}},
{0x29,0,{}},
{REGFLAG_DELAY,20,{}},
{REGFLAG_END_OF_TABLE, 0, {}}
};
static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
{
int i;
for(i = 0; i < count; i++)
{
switch (table[i].cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(table[i].cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->type = 2;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.mode = 1;
params->dsi.PS = 2;
params->dsi.LANE_NUM = 3;
params->dsi.packet_size = 256;
params->dsi.PLL_CLOCK = 244;
params->dsi.intermediat_buffer_num = 0;
params->dsi.noncont_clock = 1;
params->dsi.noncont_clock_period = 1;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.data_format.format = 2;
params->dsi.horizontal_sync_active = 8;
params->dsi.horizontal_backporch = 16;
params->dsi.horizontal_frontporch = 16;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 12;
params->dsi.vertical_frontporch = 16;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dbi.te_mode = 0;
params->dbi.te_edge_polarity = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 1;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9Cu;
}
static void lcm_init(void)
{
LCM_LOGD("y");
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);
SET_RESET_PIN(1);
MDELAY(120);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static unsigned int lcm_compare_id(void)
{
unsigned int data_array[16];
unsigned int id = 0;
unsigned char buffer[3];
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
data_array[0] = 0x33700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, buffer, 3);
id = (buffer[0] << 8) | buffer[1];
LCM_LOGD("Synced id is 0x%2x", id);
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
unsigned int data_array[16];
data_array[0] = 0x11500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(100);
data_array[0] = 0x280500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(50);
data_array[0] = 0x100500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(50);
data_array[0] = 0x14F1500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(50);
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
}
/* Get LCM Driver Hooks */
LCM_DRIVER xc_rm68200_dsi_vdo_hd720_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version 19.52
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "jd9161ba_ivo_tn_wvga" "_lcm_drv"
#define LCM_VERSION "19.52-Not-Tested" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x9161)
#define FRAME_WIDTH (480)
#define FRAME_HEIGHT (854)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/**
* REGFLAG_DELAY, used to trigger MDELAY,
* REGFLAG_END_OF_TABLE, used to mark the end of LCM_setting_table.
* their values dosen't matter until they,
* match with any LCM_setting_table->cmd.
*/
#define REGFLAG_DELAY (0xFF)
#define REGFLAG_END_OF_TABLE (0xDD)
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) print(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[2];
};
static struct LCM_setting_table lcm_initialization_setting[] =
{
{0xBF,3,{0x91,0x61,0xF2}},
{0xB3,2,{0x00,0x8A}},
{0xB4,2,{0x00,0x8A}},
{0xB8,6,{0x00,0xAB,0x01,0x00,0xAB,0x01}},
{0xBA,3,{0x3E,0x23,0x04}},
{0xC3,1,{0x02}},
{0xC4,2,{0x30,0x6A}},
{0xC7,9,{0x00,0x01,0x31,0x0A,0x6A,0x2A,0x13,0xA5,0xA5}},
{0xC8,38,{0x7F,0x7B,0x73,0x68,0x5A,0x40,0x38,0x1C,0x34,0x33,0x35,0x58,0x4C,0x5D,0x56,0x5D,0x58,0x51,0x48,0x7F,0x7B,0x73,0x68,0x5A,0x40,0x38,0x1C,0x34,0x33,0x35,0x58,0x4C,0x5D,0x56,0x5D,0x58,0x51,0x48}},
{0xD4,16,{0x1F,0x1F,0x1F,0x03,0x01,0x05,0x07,0x09,0x0B,0x11,0x13,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD5,16,{0x1F,0x1F,0x1F,0x02,0x00,0x04,0x06,0x08,0x0A,0x10,0x12,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD6,16,{0x1F,0x1F,0x1F,0x10,0x12,0x04,0x0A,0x08,0x06,0x02,0x00,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD7,16,{0x1F,0x1F,0x1F,0x11,0x13,0x05,0x0B,0x09,0x07,0x03,0x01,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD8,20,{0x20,0x00,0x00,0x30,0x03,0x30,0x01,0x02,0x30,0x01,0x02,0x06,0x70,0x73,0x5D,0x72,0x06,0x38,0x70,0x08}},
{0xD9,19,{0x00,0x0A,0x0A,0x88,0x00,0x00,0x06,0x7B,0x00,0x80,0x00,0x3B,0x33,0x1F,0x00,0x00,0x00,0x06,0x70}},
{0x35,0,{}},
{0xBE,1,{0x01}},
{0xCC,10,{0x34,0x20,0x38,0x60,0x11,0x91,0x00,0x40,0x00,0x00}},
{0xBE,1,{0x00}},
{0x11,0,{}},
{REGFLAG_DELAY,120,{}},
{0x29,0,{}},
{REGFLAG_DELAY,10,{}},
{REGFLAG_END_OF_TABLE, 0, {}}
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00}},
{REGFLAG_DELAY, 20, {}},
{0x10, 1, {0x00}},
{REGFLAG_DELAY, 120, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
{
int i;
for(i = 0; i < count; i++)
{
switch (table[i].cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(table[i].cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->type = 2;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.mode = 1;
params->dsi.PS = 2;
params->dsi.LANE_NUM = 2;
params->dsi.PLL_CLOCK = 170;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.data_format.format = 2;
params->dsi.horizontal_sync_active = 10;
params->dsi.horizontal_backporch = 10;
params->dsi.horizontal_frontporch = 10;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 6;
params->dsi.vertical_frontporch = 6;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 1;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9Cu;
}
static void lcm_init(void)
{
SET_RESET_PIN(1);
MDELAY(5);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(120);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static unsigned int lcm_compare_id(void)
{
unsigned int data_array[16];
unsigned int id = 0;
unsigned char buffer[3];
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);
SET_RESET_PIN(1);
MDELAY(50);
data_array[0] = 0x43902;
data_array[1] = 0xF26191BF;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x33700;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(50);
read_reg_v2(0x04, buffer, 3);
id = (buffer[0] << 8) | buffer[1];
LCM_LOGD("Synced id is 0x%2x", id);
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
SET_RESET_PIN(0);
MDELAY(20);
SET_RESET_PIN(1);
MDELAY(20);
push_table(lcm_deep_sleep_mode_in_setting,
sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
}
/* Get LCM Driver Hooks */
LCM_DRIVER jd9161ba_ivo_tn_wvga_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version 19.52
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "st7701_fwvga_dsi_vdo_cpt" "_lcm_drv"
#define LCM_VERSION "19.52-Not-Tested" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x9807)
#define FRAME_WIDTH (480)
#define FRAME_HEIGHT (854)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/**
* REGFLAG_DELAY, used to trigger MDELAY,
* REGFLAG_END_OF_TABLE, used to mark the end of LCM_setting_table.
* their values dosen't matter until they,
* match with any LCM_setting_table->cmd.
*/
#define REGFLAG_DELAY (0xFF)
#define REGFLAG_END_OF_TABLE (0xDD)
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) printf(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[2];
};
static struct LCM_setting_table lcm_initialization_setting[] =
{
{0x11,0,{}},
{REGFLAG_DELAY,120,{}},
{0x29,0,{}},
{REGFLAG_DELAY,120,{}},
{REGFLAG_END_OF_TABLE, 0, {}}
{0x28,1,{0x00}},
{REGFLAG_DELAY,20,{}},,
{0x10,1,{0x00}},
{REGFLAG_DELAY,120,{}},
{REGFLAG_END_OF_TABLE, 0, {}}
{0x28,0,{}},
{0x10,0,{}},
{REGFLAG_DELAY,120,{}},
{REGFLAG_END_OF_TABLE, 0, {}}
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
{0x28, 1, {0x00}},
{REGFLAG_DELAY, 50, {}},
{0x10, 1, {0x00}},
{REGFLAG_DELAY, 120, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
{
int i;
for(i = 0; i < count; i++)
{
switch (table[i].cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(table[i].cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->type = 2;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.mode = 2;
params->dsi.PS = 2;
params->dsi.LANE_NUM = 2;
params->dsi.PLL_CLOCK = 200;
params->dsi.packet_size = 256;
params->dsi.HS_PRPR = 3;
params->dsi.LPX = 3;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.data_format.format = 2;
params->dsi.intermediat_buffer_num = 2;
params->dsi.horizontal_sync_active = 50;
params->dsi.horizontal_backporch = 60;
params->dsi.horizontal_frontporch = 100;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.vertical_sync_active = 8;
params->dsi.vertical_backporch = 18;
params->dsi.vertical_frontporch = 16;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.lcm_ext_te_enable = 1;
params->dbi.te_mode = 1;
params->dbi.te_edge_polarity = 0;
params->dsi.esd_check_enable = 1;
//params->dsi.customization_esd_check_enable = 1;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9Cu;
}
static void lcm_init(void)
{
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);
SET_RESET_PIN(1);
MDELAY(120);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static unsigned int lcm_compare_id(void)
{
unsigned int data_array[16];
unsigned int id = 0;
unsigned char buffer[3];
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
data_array[0] = 0x13700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x00, buffer, 3);
id = (buffer[0] << 8) | buffer[1];
LCM_LOGD("Synced id is 0x%2x", id);
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
SET_RESET_PIN(0);
MDELAY(50);
SET_RESET_PIN(1);
MDELAY(50);
push_table(lcm_deep_sleep_mode_in_setting,
sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
}
/* Get LCM Driver Hooks */
LCM_DRIVER st7701_fwvga_dsi_vdo_cpt_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version 19.221
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "hx8394d_bld_cmi"
#define LCM_VERSION "19.221" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x83940D)
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) print(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->type = 2;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.mode = 2;
params->dsi.data_format.format = 2;
params->dsi.intermediat_buffer_num = 2;
params->dsi.PS = 2;
params->dsi.LANE_NUM = 3;
params->dsi.packet_size = 256;
params->dsi.PLL_CLOCK = 264;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.ssc_range = 0;
params->dsi.horizontal_sync_active = 50;
params->dsi.horizontal_backporch = 50;
params->dsi.horizontal_frontporch = 50;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.vertical_sync_active = 2;
params->dsi.vertical_backporch = 5;
params->dsi.vertical_frontporch = 9;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dbi.te_mode = 0;
params->dbi.te_edge_polarity = 0;
}
static void init_hx8394d_lcm_registers(void)
{
unsigned int data_array[16];
data_array[0] = 0x43902;
data_array[1] = 0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x33902;
data_array[1] = 0x8372BA;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x103902;
data_array[1] = 0x11116CB1;
data_array[2] = 0xF1110434;
data_array[3] = 0x239EE280;
data_array[4] = 0x58D2C080;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(1);
data_array[0] = 0xC3902;
data_array[1] = 0x564C0B2;
data_array[2] = 0x81C3207;
data_array[3] = 0x4D1C08;
dsi_set_cmdq(data_array, 4, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0x7BC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x43902;
data_array[1] = 0x10E41BF;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0xD3902;
data_array[1] = 0x3FF00B4;
data_array[2] = 0x35A035A;
data_array[3] = 0x16A015A;
data_array[4] = 0x6A;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(1);
data_array[0] = 0x1F3902;
data_array[1] = 0xD3;
data_array[2] = 0x100740;
data_array[3] = 0x1032;
data_array[4] = 0x4153200;
data_array[5] = 0x15320405;
data_array[6] = 0x37270528;
data_array[7] = 0x370B0033;
data_array[8] = 0x70710;
dsi_set_cmdq(data_array, 9, 1);
MDELAY(1);
data_array[0] = 0x2D3902;
data_array[1] = 0x181818D5;
data_array[2] = 0x18181818;
data_array[3] = 0x18181818;
data_array[4] = 0x25181818;
data_array[5] = 0x18262724;
data_array[6] = 0x1040518;
data_array[7] = 0x3060700;
data_array[8] = 0x47424302;
data_array[9] = 0x41444546;
data_array[10] = 0x23202140;
data_array[11] = 0x18181822;
data_array[12] = 0x18;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0x9CC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x33902;
data_array[1] = 0x1430C0;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x33902;
data_array[1] = 0x3D3DB6;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x2B3902;
data_array[1] = 0x211A05E0;
data_array[2] = 0x303F3735;
data_array[3] = 0xC0A074A;
data_array[4] = 0x17151017;
data_array[5] = 0x11061514;
data_array[6] = 0x17051714;
data_array[7] = 0x3F39381B;
data_array[8] = 0xB074F2D;
data_array[9] = 0x120F180D;
data_array[10] = 0xB131214;
data_array[11] = 0x191716;
dsi_set_cmdq(data_array, 12, 1);
MDELAY(1);
data_array[0] = 0x53902;
data_array[1] = 0x40C000C7;
data_array[2] = 0xC0;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(1);
data_array[0] = 0x110500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(150);
data_array[0] = 0x290500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(20);
};
static void lcm_init(void)
{
LCM_LOGD("Starting LCM Initialization!");
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(20);
SET_RESET_PIN(1);
MDELAY(120);
init_hx8394d_lcm_registers();
}
static unsigned int lcm_compare_id(void)
{
unsigned int data_array[16];
unsigned int id = 0;
unsigned char buffer[3];
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(120);
data_array[0] = 0x43902;
data_array[1] = 0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x33700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, buffer, 3);
id = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
LCM_LOGD("Synced id is 0x%2x", id);
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
unsigned int data_array[16];
LCM_LOGD("Using dsi_set_cmdq v1!");
// Display Off
data_array[0] = 0x00280500;
dsi_set_cmdq(data_array, 1, 1);
// Sleep In
data_array[0] = 0x00100500;
dsi_set_cmdq(data_array, 1, 1);
/**
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
*/
}
/* Get LCM Driver Hooks */
LCM_DRIVER hx8394d_bld_cmi_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version 19.221
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "hx8394f_bld_cmi"
#define LCM_VERSION "19.221" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x83940F)
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) print(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->dsi.LANE_NUM = 3;
params->dsi.packet_size = 256;
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 12;
params->dsi.vertical_frontporch = 15;
params->dsi.PLL_CLOCK = 264;
params->type = 2;
params->dsi.mode = 2;
params->dsi.data_format.format = 2;
params->dsi.intermediat_buffer_num = 2;
params->dsi.PS = 2;
params->width = 720;
params->dsi.horizontal_active_pixel = 720;
params->height = 1280;
params->dsi.vertical_active_line = 1280;
params->dbi.te_mode = 0;
params->dbi.te_edge_polarity = 0;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.ssc_range = 0;
params->dsi.horizontal_sync_active = 50;
params->dsi.horizontal_backporch = 50;
params->dsi.horizontal_frontporch = 50;
}
static void init_hx8394f_lcm_registers(void)
{
unsigned int data_array[16];
data_array[0] = 0x43902;
data_array[1] = 0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x73902;
data_array[1] = 0x680362BA;
data_array[2] = 0xC0B26B;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(1);
data_array[0] = 0xB3902;
data_array[1] = 0x721248B1;
data_array[2] = 0xB1543309;
data_array[3] = 0x2F6B31;
dsi_set_cmdq(data_array, 4, 1);
MDELAY(1);
data_array[0] = 0x73902;
data_array[1] = 0x648000B2;
data_array[2] = 0x2F0D0E;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(1);
data_array[0] = 0x163902;
data_array[1] = 0x737473B4;
data_array[2] = 0x1747374;
data_array[3] = 0x75860C;
data_array[4] = 0x7374733F;
data_array[5] = 0x1747374;
data_array[6] = 0x860C;
dsi_set_cmdq(data_array, 7, 1);
MDELAY(1);
data_array[0] = 0x33902;
data_array[1] = 0x6262B6;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x223902;
data_array[1] = 0x70000D3;
data_array[2] = 0x10074007;
data_array[3] = 0x8100800;
data_array[4] = 0x15540800;
data_array[5] = 0x20E050E;
data_array[6] = 0x6050615;
data_array[7] = 0xA0A4447;
data_array[8] = 0x707104B;
data_array[9] = 0x400E;
dsi_set_cmdq(data_array, 10, 1);
MDELAY(1);
data_array[0] = 0x2D3902;
data_array[1] = 0x1B1A1AD5;
data_array[2] = 0x201001B;
data_array[3] = 0x6050403;
data_array[4] = 0xA090807;
data_array[5] = 0x1825240B;
data_array[7] = (0x1818 << 16) | 0x1818;
data_array[6] = 0x18272618;
data_array[8] = (0x1818 << 16) | 0x1818;
data_array[9] = (0x1818 << 16) | 0x1818;
data_array[10] = 0x20181818;
data_array[11] = 0x18181821;
data_array[12] = 0x18;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0] = 0x2D3902;
data_array[1] = 0x1B1A1AD6;
data_array[2] = 0x90A0B1B;
data_array[3] = 0x5060708;
data_array[4] = 0x1020304;
data_array[5] = 0x18202100;
data_array[6] = 0x18262718;
data_array[7] = 0x18181818;
data_array[8] = 0x18181818;
data_array[9] = 0x18181818;
data_array[10] = 0x25181818;
data_array[11] = 0x18181824;
data_array[12] = 0x18;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0] = 0x3B3902;
data_array[1] = 0xE0300E0;
data_array[2] = 0x1F1B1714;
data_array[3] = 0x6453401F;
data_array[4] = 0x88836F64;
data_array[5] = 0x9297968A;
data_array[6] = 0x5255AD9E;
data_array[7] = 0x605B5955;
data_array[8] = 0x3007F64;
data_array[9] = 0x1B16130D;
data_array[10] = 0x53401F1F;
data_array[11] = 0x836F6464;
data_array[12] = 0x97968A88;
data_array[13] = 0x55AD9E92;
data_array[14] = 0x5B595552;
data_array[15] = 0x7F6460;
dsi_set_cmdq(data_array, 16, 1);
MDELAY(1);
data_array[0] = 0x33902;
data_array[1] = 0x311FC0;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0xBCC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0x2D4;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0x2BD;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0xD3902;
data_array[1] = 0xFFFFFFD8;
data_array[2] = 0xFFFFFFFF;
data_array[3] = 0xFFFFFFFF;
data_array[4] = 0xFF;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0xBD;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0xBD;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0x1BD;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x23902;
data_array[1] = 0xB1;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[1] = 0xBD;
data_array[0] = 0x23902;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0] = 0x83902;
data_array[1] = 0x508140BF;
data_array[2] = 0x1FC1A00;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(1);
data_array[0] = 0x110500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(150);
data_array[0] = 0x290500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(20);
};
static void lcm_init(void)
{
LCM_LOGD("Starting LCM Initialization!");
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(20);
init_hx8394f_lcm_registers();
}
static unsigned int lcm_compare_id(void)
{
unsigned int data_array[16];
unsigned int id = 0;
unsigned char buffer[3];
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(120);
data_array[0] = 0x43902;
data_array[1] = 0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
data_array[0] = 0x33700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, buffer, 3);
id = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
LCM_LOGD("Synced id is 0x%2x", id);
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
unsigned int data_array[16];
LCM_LOGD("Using dsi_set_cmdq v1!");
// Display Off
data_array[0] = 0x00280500;
dsi_set_cmdq(data_array, 1, 1);
// Sleep In
data_array[0] = 0x00100500;
dsi_set_cmdq(data_array, 1, 1);
/**
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
*/
}
/* Get LCM Driver Hooks */
LCM_DRIVER hx8394f_bld_cmi_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version 19.222
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "ili9881c_dj_hsd"
#define LCM_VERSION "19.222" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x0)
#define FRAME_WIDTH (720)
#define FRAME_HEIGHT (1280)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/**
* REGFLAG_DELAY, used to trigger MDELAY,
* REGFLAG_END_OF_TABLE, used to mark the end of LCM_setting_table.
* their values dosen't matter until they,
* match with any LCM_setting_table->cmd.
*/
#define REGFLAG_DELAY (0x300)
#define REGFLAG_END_OF_TABLE (0x301)
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) print(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[5];
};
static struct LCM_setting_table lcm_initialization_setting[] =
{
{0xFF,3,{0x98,0x81,0x03}},
{0x01,1,{0x00}},
{0x02,1,{0x00}},
{0x03,1,{0x72}},
{0x04,1,{0x00}},
{0x05,1,{0x00}},
{0x06,1,{0x09}},
{0x07,1,{0x00}},
{0x08,1,{0x00}},
{0x09,1,{0x00}},
{0x0A,1,{0x00}},
{0x0B,1,{0x00}},
{0x0C,1,{0x00}},
{0x0D,1,{0x00}},
{0x0E,1,{0x00}},
{0x0F,1,{0x00}},
{0x10,1,{0x00}},
{0x11,1,{0x00}},
{0x12,1,{0x00}},
{0x13,1,{0x00}},
{0x14,1,{0x00}},
{0x15,1,{0x00}},
{0x16,1,{0x00}},
{0x17,1,{0x00}},
{0x18,1,{0x00}},
{0x19,1,{0x00}},
{0x1A,1,{0x00}},
{0x1B,1,{0x00}},
{0x1C,1,{0x00}},
{0x1D,1,{0x00}},
{0x1E,1,{0x40}},
{0x1F,1,{0x80}},
{0x20,1,{0x05}},
{0x21,1,{0x02}},
{0x22,1,{0x00}},
{0x23,1,{0x00}},
{0x24,1,{0x00}},
{0x25,1,{0x00}},
{0x26,1,{0x00}},
{0x27,1,{0x00}},
{0x28,1,{0x33}},
{0x29,1,{0x02}},
{0x2A,1,{0x00}},
{0x2B,1,{0x00}},
{0x2C,1,{0x00}},
{0x2D,1,{0x00}},
{0x2E,1,{0x00}},
{0x2F,1,{0x00}},
{0x30,1,{0x00}},
{0x31,1,{0x00}},
{0x32,1,{0x00}},
{0x33,1,{0x00}},
{0x34,1,{0x04}},
{0x35,1,{0x00}},
{0x36,1,{0x00}},
{0x37,1,{0x00}},
{0x38,1,{0x3C}},
{0x39,1,{0x00}},
{0x3A,1,{0x00}},
{0x3B,1,{0x00}},
{0x3C,1,{0x00}},
{0x3D,1,{0x00}},
{0x3E,1,{0x00}},
{0x3F,1,{0x00}},
{0x40,1,{0x00}},
{0x41,1,{0x00}},
{0x42,1,{0x00}},
{0x43,1,{0x00}},
{0x44,1,{0x00}},
{0x50,1,{0x10}},
{0x51,1,{0x32}},
{0x52,1,{0x54}},
{0x53,1,{0x76}},
{0x54,1,{0x98}},
{0x55,1,{0xBA}},
{0x56,1,{0x10}},
{0x57,1,{0x32}},
{0x58,1,{0x54}},
{0x59,1,{0x76}},
{0x5A,1,{0x98}},
{0x5B,1,{0xBA}},
{0x5C,1,{0xDC}},
{0x5D,1,{0xFE}},
{0x5E,1,{0x00}},
{0x5F,1,{0x0E}},
{0x60,1,{0x0F}},
{0x61,1,{0x0C}},
{0x62,1,{0x0D}},
{0x63,1,{0x06}},
{0x64,1,{0x07}},
{0x65,1,{0x02}},
{0x66,1,{0x02}},
{0x67,1,{0x02}},
{0x68,1,{0x02}},
{0x69,1,{0x01}},
{0x6A,1,{0x00}},
{0x6B,1,{0x02}},
{0x6C,1,{0x15}},
{0x6D,1,{0x14}},
{0x6E,1,{0x02}},
{0x6F,1,{0x02}},
{0x70,1,{0x02}},
{0x71,1,{0x02}},
{0x72,1,{0x02}},
{0x73,1,{0x02}},
{0x74,1,{0x02}},
{0x75,1,{0x0E}},
{0x76,1,{0x0F}},
{0x77,1,{0x0C}},
{0x78,1,{0x0D}},
{0x79,1,{0x06}},
{0x7A,1,{0x07}},
{0x7B,1,{0x02}},
{0x7C,1,{0x02}},
{0x7D,1,{0x02}},
{0x7E,1,{0x02}},
{0x7F,1,{0x01}},
{0x80,1,{0x00}},
{0x81,1,{0x02}},
{0x82,1,{0x14}},
{0x83,1,{0x15}},
{0x84,1,{0x02}},
{0x85,1,{0x02}},
{0x86,1,{0x02}},
{0x87,1,{0x02}},
{0x88,1,{0x02}},
{0x89,1,{0x02}},
{0x8A,1,{0x02}},
{0xFF,3,{0x98,0x81,0x04}},
{0x00,1,{0x00}},
{0x6C,1,{0x15}},
{0x6E,1,{0x2A}},
{0x6F,1,{0x33}},
{0x3A,1,{0x94}},
{0x8D,1,{0x14}},
{0x87,1,{0xBA}},
{0x26,1,{0x76}},
{0xB2,1,{0xD1}},
{0xB5,1,{0x06}},
{0xFF,3,{0x98,0x81,0x01}},
{0x22,1,{0x0A}},
{0x31,1,{0x00}},
{0x40,1,{0x53}},
{0x53,1,{0x70}},
{0x55,1,{0x8F}},
{0x50,1,{0xBF}},
{0x51,1,{0xBF}},
{0x60,1,{0x21}},
{0xA0,1,{0x08}},
{0xA1,1,{0x18}},
{0xA2,1,{0x25}},
{0xA3,1,{0x11}},
{0xA4,1,{0x15}},
{0xA5,1,{0x28}},
{0xA6,1,{0x1B}},
{0xA7,1,{0x1D}},
{0xA8,1,{0x81}},
{0xA9,1,{0x1C}},
{0xAA,1,{0x28}},
{0xAB,1,{0x70}},
{0xAC,1,{0x1C}},
{0xAD,1,{0x1A}},
{0xAE,1,{0x4D}},
{0xAF,1,{0x22}},
{0xB0,1,{0x28}},
{0xB1,1,{0x4D}},
{0xB2,1,{0x5E}},
{0xB3,1,{0x39}},
{0xC0,1,{0x08}},
{0xC1,1,{0x18}},
{0xC2,1,{0x25}},
{0xC3,1,{0x11}},
{0xC4,1,{0x15}},
{0xC5,1,{0x28}},
{0xC6,1,{0x1B}},
{0xC7,1,{0x1D}},
{0xC8,1,{0x81}},
{0xC9,1,{0x1C}},
{0xCA,1,{0x28}},
{0xCB,1,{0x70}},
{0xCC,1,{0x1C}},
{0xCD,1,{0x1A}},
{0xCE,1,{0x4D}},
{0xCF,1,{0x22}},
{0xD0,1,{0x28}},
{0xD1,1,{0x4D}},
{0xD2,1,{0x5E}},
{0xD3,1,{0x39}},
{0xFF,3,{0x98,0x81,0x00}},
{0x11,1,{0x00}},
{REGFLAG_DELAY,120,{}},
{0x29,1,{0x00}},
{REGFLAG_DELAY,10,{}},
{REGFLAG_END_OF_TABLE,0,{}},
}
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] =
{
// Sleep Mode On
// Display off sequence
{0x28, 1, {0x00}},
{REGFLAG_DELAY, 20, {}},
// Sleep Mode On
{0x10, 1, {0x00}},
{REGFLAG_DELAY, 120, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
{
int i;
for(i = 0; i < count; i++)
{
switch (table[i].cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(table[i].cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->dsi.LANE_NUM = 3;
params->dsi.packet_size = 256;
params->dsi.vertical_sync_active = 4;
params->dsi.horizontal_sync_active = 10;
params->type = 2;
params->dsi.PLL_CLOCK = 240;
params->dsi.mode = 2;
params->dsi.data_format.format = 2;
params->dsi.intermediat_buffer_num = 2;
params->dsi.PS = 2;
params->width = FRAME_WIDTH;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dbi.te_mode = 0;
params->dbi.te_edge_polarity = 0;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.ssc_range = 0;
params->dsi.vertical_backporch = 20;
params->dsi.vertical_frontporch = 20;
params->dsi.horizontal_backporch = 60;
params->dsi.horizontal_frontporch = 60;
}
static void lcm_init(void)
{
LCM_LOGD("Starting LCM Initialization!");
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(20);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static unsigned int lcm_compare_id(void)
{
return 1;
}
static void lcm_suspend(void)
{
push_table(lcm_deep_sleep_mode_in_setting,
sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
/**
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
*/
}
/* Get LCM Driver Hooks */
LCM_DRIVER ili9881c_dj_hsd_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version Initial
* Copyright (c) 2015,
* MediaTek Inc <mediatek.com>
* Copyright (C) 2017,
* WIKO S.A.S <wikogeek.com>
*
* Version 19.417
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "ili9806e_fwvga_dsi_vdo_zgd"
#define LCM_VERSION "19.417" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x9806)
#define FRAME_WIDTH (480)
#define FRAME_HEIGHT (854)
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/**
* REGFLAG_DELAY, used to trigger MDELAY,
* REGFLAG_END_OF_TABLE, used to mark the end of LCM_setting_table.
* their values dosen't matter until they,
* match with any LCM_setting_table->cmd.
*/
#define REGFLAG_DELAY (0xFF)
#define REGFLAG_END_OF_TABLE (0xDD)
#define LCM_DBG_TAG "[LCM]"
#ifdef BUILD_LK
#define LCM_LOGD(str, args...) print(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#else
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
struct LCM_setting_table {
unsigned char cmd;
unsigned char count;
unsigned char para_list[5];
};
static struct LCM_setting_table lcm_initialization_setting[] =
{
{0xFF,5,{0xFF,0x98,0x06,0x04,0x01}},
{0x08,1,{0X10}},
{0x21,1,{0X01}},
{0x30,1,{0X01}},
{0x31,1,{0X00}},
{0x50,1,{0X50}},
{0x51,1,{0X50}},
{0x60,1,{0X07}},
{0x61,1,{0X00}},
{0x62,1,{0X07}},
{0x63,1,{0X00}},
{0x40,1,{0X18}},
{0x41,1,{0X64}},
{0x42,1,{0X03}},
{0x43,1,{0X0A}},
{0x44,1,{0X06}},
{0x46,1,{0X55}},
{0x47,1,{0X55}},
// {0x52,1,{0X00}},
{0x53,1,{0X52}},
{0x57,1,{0X50}},
// {0xFF,5,{0xFF,0x98,0x06,0x04,0x01}},
{0xA0,1,{0X00}},
{0xA1,1,{0X08}},
{0xA2,1,{0X12}}, // 0X1E
{0xA3,1,{0X12}},
{0xA4,1,{0X0A}},
{0xA5,1,{0X1A}},
{0xA6,1,{0X0D}},
{0xA7,1,{0X09}},
{0xA8,1,{0X04}},
{0xA9,1,{0X0A}},
{0xAA,1,{0X07}},
{0xAB,1,{0X04}},
{0xAC,1,{0X0C}},
{0xAD,1,{0X2D}}, // 0X2F
{0xAE,1,{0X29}},
{0xAF,1,{0X00}},
{0xC0,1,{0X00}},
{0xC1,1,{0X02}},
{0xC2,1,{0X09}}, // 0X18
{0xC3,1,{0X0F}},
{0xC4,1,{0X06}},
{0xC5,1,{0X15}},
{0xC6,1,{0X06}},
{0xC7,1,{0X08}},
{0xC8,1,{0X04}},
{0xC9,1,{0X07}},
{0xCA,1,{0X06}},
{0xCB,1,{0X03}},
{0xCC,1,{0X0C}},
{0xCD,1,{0X2C}}, // 0X1E
{0xCE,1,{0X26}},
{0xCF,1,{0X00}},
{0xFF,5,{0xFF,0x98,0x06,0x04,0x06}},
{0x00,1,{0X21}},
{0x01,1,{0X06}},
{0x02,1,{0XA0}},
{0x03,1,{0X02}},
{0x04,1,{0X01}},
{0x05,1,{0X01}},
{0x06,1,{0X80}},
{0x07,1,{0X03}},
{0x08,1,{0X06}},
{0x09,1,{0X80}},
{0x0A,1,{0X00}},
{0x0B,1,{0X00}},
{0x0C,1,{0X20}},
{0x0D,1,{0X20}},
{0x0E,1,{0X09}},
{0x0F,1,{0X00}},
{0x10,1,{0XFF}},
{0x11,1,{0XE0}},
{0x12,1,{0X00}},
{0x13,1,{0X00}},
{0x14,1,{0X00}},
{0x15,1,{0XC0}},
{0x16,1,{0X08}},
{0x17,1,{0X00}},
{0x18,1,{0X00}},
{0x19,1,{0X00}},
{0x1A,1,{0X00}},
{0x1B,1,{0X00}},
{0x1C,1,{0X00}},
{0x1D,1,{0X00}},
{0x20,1,{0X01}},
{0x21,1,{0X23}},
{0x22,1,{0X45}},
{0x23,1,{0X67}},
{0x24,1,{0X01}},
{0x25,1,{0X23}},
{0x26,1,{0X45}},
{0x27,1,{0X67}},
{0x30,1,{0X12}},
{0x31,1,{0X22}},
{0x32,1,{0X22}},
{0x33,1,{0X22}},
{0x34,1,{0X87}},
{0x35,1,{0X96}},
{0x36,1,{0XAA}},
{0x37,1,{0XDB}},
{0x38,1,{0XCC}},
{0x39,1,{0XBD}},
{0x3A,1,{0X78}},
{0x3B,1,{0X69}},
{0x3C,1,{0X22}},
{0x3D,1,{0X22}},
{0x3E,1,{0X22}},
{0x3F,1,{0X22}},
{0x40,1,{0X22}},
{0x52,1,{0X10}},
{0x53,1,{0X10}},
{0x54,1,{0X13}},
{0xFF,5,{0xFF,0x98,0x06,0x04,0x07}},
{0x02,1,{0X77}},
{0x06,1,{0X13}},
{0xE1,1,{0X79}},
{0x17,1,{0X22}},
{0xB3,1,{0X10}},
{0x26,1,{0XB2}},
// Change to Page 0
{0xFF,5,{0xFF,0x98,0x06,0x04,0x00}},
// TE on
{0x35,1,{0x00}},
// Sleep-Out
{0x11,1,{0x00}},
{REGFLAG_DELAY, 150, {}},
// Display On
{0x29,1,{0x00}},
{REGFLAG_DELAY, 10, {}},
/** Note
Strongly recommend not to set Sleep out / Display On here. That will cause messed frame to be shown as later the backlight is on.
Setting ending by predefined flag */
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] =
{
// Sleep Mode On
// Display off sequence
{0x28, 1, {0x00}},
{REGFLAG_DELAY, 50, {}},
// Sleep Mode On
{0x10, 1, {0x00}},
{REGFLAG_DELAY, 20, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static struct LCM_setting_table lcm_compare_id_setting[] =
{
{0xD3, 3, {0xFF, 0x83, 0x79}},
{REGFLAG_DELAY, 10, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
{
int i;
for(i = 0; i < count; i++)
{
switch (table[i].cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(table[i].cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
memset(params, 0, sizeof(LCM_PARAMS));
params->type = 2;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = 61.63;
params->physical_height = 109.65;
// enable tearing-free
// params->dbi.te_mode = LCM_DBI_TE_MODE_VSYNC_ONLY;
params->dbi.te_mode = 0;
// params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
params->dsi.mode = SYNC_PULSE_VDO_MODE;
// DSI
/* Command mode setting */
params->dsi.LANE_NUM = LCM_TWO_LANE;
// The following defined the fomat for data coming from LCD engine.
params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
// Highly depends on LCD driver capability.
// Not support in MT6573
params->dsi.packet_size = 256;
// Video mode setting
params->dsi.intermediat_buffer_num = 2;
params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
params->dsi.word_count = FRAME_WIDTH * 3;
params->dsi.vertical_sync_active = 5;
params->dsi.vertical_backporch = 8;
params->dsi.vertical_frontporch = 8;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 8;
params->dsi.horizontal_backporch = 50;
params->dsi.horizontal_frontporch = 46;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.compatibility_for_nvk = 0;
params->dsi.ssc_disable = 1;
params->dsi.ssc_range = 6;
params->dsi.PLL_CLOCK = 176;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 0;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
}
static void lcm_init(void)
{
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(25);
SET_RESET_PIN(1);
MDELAY(120);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static unsigned int lcm_compare_id(void)
{
unsigned int data_array[16];
unsigned int id = 0;
unsigned char data[3];
unsigned char buffer[3];
// Do reset here
SET_RESET_PIN(1);
MDELAY(2);
SET_RESET_PIN(0);
MDELAY(25);
SET_RESET_PIN(1);
MDELAY(120);
data_array[0] = 0x00063902;
data_array[1] = 0x0698ffff;
data_array[2] = 0x00000104;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(10);
data_array[0] = 0x00023700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x00, buffer[0], 1);
MDELAY(2);
read_reg_v2(0x01, buffer[1], 1);
MDELAY(2);
read_reg_v2(0x02, buffer[2], 1);
id = (buffer[0] << 8) | buffer[1];
LCM_LOGD("Synced id is 0x%2x", id);
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
MDELAY(60); // 60ms for ps function zx
SET_RESET_PIN(0);
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
}
/* Get LCM Driver Hooks */
LCM_DRIVER ili9806e_fwvga_dsi_vdo_zgd_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
/**
* Version Initial
* Copyright (c) 2015,
* MediaTek Inc <mediatek.com>
* Copyright (C) 2017,
* WIKO S.A.S <wikogeek.com>
*
* Version 19.417
* Copyright (C) 2019,
* parthibx24 <e.inxpired@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0+
*/
#include "lcm_drv.h"
/* Local Constants */
#define LCM_NAME "jd9161_fwvga_dsi_vdo_dj"
#define LCM_VERSION "19.417" /* YEAR+"."+MONTH+DATE */
#define LCM_ID (0x9161)
#define FRAME_WIDTH (480)
#define FRAME_HEIGHT (854)
#define AUXADC_LCM_VOLTAGE_CHANNEL 12
#define AUXADC_ADC_FDD_RF_PARAMS_DYNAMIC_CUSTOM_CH_CHANNEL 1
#define MIN_VOLTAGE (1000)
#define MAX_VOLTAGE (1800)
/**
* REGFLAG_DELAY, used to trigger MDELAY,
* REGFLAG_END_OF_TABLE, used to mark the end of LCM_setting_table.
* their values dosen't matter until they,
* match with any LCM_setting_table->cmd.
*/
#define REGFLAG_DELAY (0xFE)
#define REGFLAG_END_OF_TABLE (0xDD) /* END OF REGISTERS MARKER */
/* Local Variables */
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* Local Debug Variables */
#define LCM_DBG_TAG "[LCM]"
#define LCM_LOGD(str, args...) pr_info(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#ifdef BUILD_LK
#undef LCM_LOGD
#define LCM_LOGD(str, args...) printf(LCM_DBG_TAG "[%s][%s] " str, LCM_NAME, __func__, ##args)
#endif
/* Local Functions */
#define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
extern int IMM_GetOneChannelValue(int dwChannel, int data[4], int* rawdata);
/* LCM Driver Implementations */
static LCM_UTIL_FUNCS lcm_util = { 0 };
struct LCM_setting_table {
unsigned cmd;
unsigned char count;
unsigned char para_list[64];
};
static struct LCM_setting_table lcm_initialization_setting[] =
{
{0xBF, 3, {0x91,0x61,0xF2}},
{0xB8, 6, {0x00,0xA7,0x00,0x00,0xA7,0x00}},
{0xBA, 3, {0x34,0x23,0x00}},
{0xC3, 1, {0x04}},
{0xC4, 2, {0x30,0x6A}},
{0xC7, 9, {0x00,0x01,0x32,0x05,0x65,0x2A,0x1B,0xA5,0xA5}},
{0xC8, 38, {0x7C,0x5C,0x3F,0x36,0x39,0x2F,0x33,0x19,0x33,0x34,0x39,0x5E,0x53,0x65,0x5E,0x66,0x61,0x57,0x48,0x7C,0x5C,0x3F,0x36,0x39,0x2F,0x33,0x19,0x33,0x34,0x39,0x5E,0x53,0x65,0x5E,0x66,0x61,0x57,0x48}},
{0xD4, 16, {0x1F,0x1E,0x05,0x07,0x01,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD5, 16, {0x1F,0x1E,0x04,0x06,0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD6, 16, {0x1F,0x1F,0x04,0x06,0x00,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD7, 16, {0x1F,0x1F,0x05,0x07,0x01,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}},
{0xD8, 20, {0x20,0x00,0x00,0x10,0x03,0x20,0x01,0x02,0x00,0x01,0x02,0x5F,0x5F,0x00,0x00,0x32,0x04,0x5F,0x5F,0x08}},
{0xD9, 19, {0x00,0x0A,0x0A,0x88,0x00,0x00,0x06,0x7B,0x00,0x00,0x00,0x3B,0x2F,0x1F,0x00,0x00,0x00,0x03,0x7B}},
{0xBE, 1, {0x01}},
{0xCC, 10, {0x34,0x20,0x38,0x60,0x11,0x91,0x00,0x40,0x00,0x00}},
{0xBE, 1, {0x00}},
{0x35, 1, {0x00}},
{0x11, 1, {0x00}},
{REGFLAG_DELAY, 120, {}},
{0x29, 1, {0x00}},
{REGFLAG_DELAY, 50, {}},
{0xBF, 3, {0x09,0xB1,0x7F}},
{REGFLAG_END_OF_TABLE, 0, {}}
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
// Sleep Mode On
// Display off sequence
{0x28, 1, {0x00}},
{REGFLAG_DELAY, 10, {}},
// Sleep Mode On
{0x10, 1, {0x00}},
{REGFLAG_DELAY, 120, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
{
int i;
for(i = 0; i < count; i++)
{
switch (table[i].cmd) {
case REGFLAG_DELAY :
MDELAY(table[i].count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(table[i].cmd, table[i].count, table[i].para_list, force_update);
}
}
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params) {
memset(params, 0, sizeof(LCM_PARAMS));
params->type = 2;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->physical_width = 61.63;
params->physical_height = 109.65;
params->dsi.mode = 1;
params->dsi.PS = 2;
params->dsi.LANE_NUM = 2;
params->dsi.packet_size = 256;
params->dsi.word_count = FRAME_WIDTH * 3;
params->dsi.PLL_CLOCK = 170;
params->dsi.intermediat_buffer_num = 2;
params->dsi.compatibility_for_nvk = 0;
params->dsi.data_format.color_order = 0;
params->dsi.data_format.trans_seq = 0;
params->dsi.data_format.padding = 0;
params->dsi.data_format.format = 2;
params->dsi.ssc_disable = 1;
params->dsi.ssc_range = 6;
params->dsi.horizontal_sync_active = 20;
params->dsi.horizontal_backporch = 20;
params->dsi.horizontal_frontporch = 20;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 6;
params->dsi.vertical_frontporch = 6;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dbi.te_mode = 0;
// params->dbi.te_edge_polarity = 0;
params->dsi.esd_check_enable = 1;
params->dsi.customization_esd_check_enable = 1;
params->dsi.lcm_esd_check_table[0].cmd = 0x0A;
params->dsi.lcm_esd_check_table[0].count = 1;
params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
}
static void lcm_init(void)
{
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(120);
push_table(lcm_initialization_setting,
sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
static unsigned int lcm_compare_id(void) {
unsigned int data_array[16];
unsigned int id = 0;
unsigned char buffer[3];
SET_RESET_PIN(1);
MDELAY(2);
SET_RESET_PIN(0);
MDELAY(25);
SET_RESET_PIN(1);
MDELAY(120);
data_array[0] = 0x00063902;
data_array[1] = 0x0698ffff;
data_array[2] = 0x00000104;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(10);
data_array[0] = 0x00023700;
dsi_set_cmdq(data_array, 1, 1);
/* 0xDA -> 0x91, 0xDB -> 0x61, 0xDC -> ? */
read_reg_v2(0xDA, buffer, 3);
id = (buffer[0] << 8) | buffer[1];
LCM_LOGD("Synced id is 0x%2x", id);
#ifdef AUXADC_LCM_VOLTAGE_CHANNEL
{
int err = 0;
int data[4] = {0,0,0,0};
int rawdata = 0;
int lcm_voltage = 0;
err = IMM_GetOneChannelValue(AUXADC_LCM_VOLTAGE_CHANNEL, data, &rawdata);
if(err < 0) {
LCM_LOGD("[adc_uboot]: get data error\n");
return 0;
}
lcm_voltage = data[0] * 1000 + data[1] * 10;
LCM_LOGD("[adc_uboot]: lcm_vol = %d\n", lcm_voltage);
return ((LCM_ID == id) && (lcm_voltage < MAX_VOLTAGE) && (lcm_voltage > MIN_VOLTAGE)) ? 1 : 0;
}
#endif
return (LCM_ID == id) ? 1 : 0;
}
static void lcm_suspend(void)
{
push_table(lcm_deep_sleep_mode_in_setting,
sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
SET_RESET_PIN(1);
SET_RESET_PIN(0);
MDELAY(50);
SET_RESET_PIN(1);
MDELAY(120);
// For debuging lcm_compare_id
if(lcm_compare_id())
LCM_LOGD("yay! lcm id is correct.");
}
/* Get LCM Driver Hooks */
LCM_DRIVER jd9161_fwvga_dsi_vdo_dj_lcm_drv =
{
.name = LCM_NAME,
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_init,
.compare_id = lcm_compare_id,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment