概述
对于LCM驱动移植,一般分为三部曲:
1、硬件IO口配置;
2、确保LCM背光能够正常点亮;
3、LCM驱动移植;
硬件电路:
1、GPIO配置
打开 mediatekdctDrvGen.exe
选择 mediatekcustomxiaoxikerneldctdctcodegen.dws 配置文件
配置LCM PWM引脚、RST复位引脚、DISP_PWM引脚和LCM电源控制引脚
2、背光灯
编译烧录后启动系统,验证LCM背光是否能正常点亮,否则无法继续调试LCD;
3、LCM驱动移植(以ili9806e为例)
(1)、在mediatekcustomcommonkernellcm目录下创建ili9806目录,将驱动文件拷贝到驱动文件ili9806.c到新创建的目录中;代码自动将lcm软链接到mediatekcustomcommonlk和mediatekcustomcommonuboot目录,因此无需拷贝驱动文件到lk和uboot中;
(2)、修改mediatekcustomcommonkernellcmmt65xx_lcm_list.c, 在lcm_driver_list 数组中增加:
extern LCM_DRIVER ili9806e_lcm_drv;
#if defined(ILI9806)
&ili9806e_lcm_drv, //就是ili9488.c中的LCM_DRIVER结构
#endif
(3)、打开mediatekconfigprjProjectConfig.mk修改:
BUILD_LK=yes
CUSTOM_KERNEL_LCM=ili9806 //对应lcm目录驱动的子目录名
CUSTOM_LK_LCM=ili9806 //对应lcm目录驱动的子目录名
CUSTOM_UBOOT_LCM=ili9806 //对应lcm目录驱动的子目录名
LCM_WIDTH=480
LCM_HEIGHT=800
系统编译的时候,编译器会根据CUSTOM_KERNEL_LCM、CUSTOM_LK_LCM、CUSTOM_UBOOT_LCM找到mediatekcustomcommonkernellcmili9806目录,拷贝mediatekcustomoutprokernellcm目录,参与系统的编译,所以对于驱动文件名有没命名要求;lk和uboot同理;
注:系统此时也会产生ILI9806的环境变量,这就是mt65xx_lcm_list.c中的 #if defined(ILI9806) 可以进行预编译处理;
4、LCM驱动简要解析
LCM_DRIVER结构表示一个LCM对象,里边包含LCM各项参数;
- LCM_DRIVER ili9806e_drv =
- {
- .name = "ili9806e_txd_dsi_cmd_sp13_lcm_drv",
- .set_util_funcs = lcm_set_util_funcs,
- .get_params = lcm_get_params,
- .init = lcm_init,
- .suspend = lcm_suspend,
- .resume = lcm_resume,
- .compare_id = lcm_compare_id,
- };
以上函数接口是为MTK框架中的几个重要接口;
/* 获取设备的LCM_DRIVER结构 */
- 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 = LCM_TYPE_DSI;
- params->width = FRAME_WIDTH;
- params->height = FRAME_HEIGHT;
-
-
- params->dbi.te_mode = LCM_DBI_TE_MODE_DISABLED;
- params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
-
- #if (LCM_DSI_CMD_MODE)
- params->dsi.mode = CMD_MODE;
- #else
- params->dsi.mode = SYNC_PULSE_VDO_MODE;
- #endif
-
-
-
- params->dsi.LANE_NUM = LCM_TWO_LANE;
-
- 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;
-
-
-
- params->dsi.packet_size = 256;
-
-
- params->dsi.intermediat_buffer_num = 0;
-
- params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
- params->dsi.word_count = 480 * 3;
-
- params->dsi.vertical_sync_active = 4;
- params->dsi.vertical_backporch = 16;
- params->dsi.vertical_frontporch = 20;
- params->dsi.vertical_active_line = FRAME_HEIGHT;
-
- params->dsi.horizontal_sync_active = 10;
- params->dsi.horizontal_backporch = 50;
- params->dsi.horizontal_frontporch = 60;
- params->dsi.horizontal_active_pixel = FRAME_WIDTH;
-
- params->dsi.PLL_CLOCK= 200;
- }
//复位引脚
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v))) //这里就会直接使用GPIO_LCD_RST硬引脚
//延时函数
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
/* 数据传输接口 */
//long packet 操作接口
#define dsi_set_cmdq_V3(para_tbl, size, force_update) lcm_util.dsi_set_cmdq_V3(para_tbl, size, force_update) //para_tbl:LCM_setting_table结构, size:大小, force_update:强制更新标志
#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppare, force_update) //cmd:命令, count:大小, ppara:参数,force_update:强制更新标志
//short packet 操作接口
#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
//读写寄存器等操作
#define write_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, bytes_nums)
#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
/* 初始化参数及函数接口 */
- static struct LCM_setting_table lcm_initialization_setting[] = {
-
- {0xFF, 5,{0xFF,0x98,0x06,0x04,0x01}},
- {0x08, 1, {0x10}},
- {0x21, 1, {0x01}},
- {0x30, 1, {0x02}},
- {0x31, 1, {0x02}},
- {0x40, 1, {0x16}},
- {0x41, 1, {0x22}},
- ......
- {0x53, 1, {0x1A}},
- {0xFF, 5,{0xFF,0x98,0x06,0x04,0x07}},
- {0x17, 1, {0x12}},
- {0x02, 1, {0x77}},
- {0xFF, 5,{0xFF,0x98,0x06,0x04,0x00}},
- {0x35,1, {0x00}},
- {0x36,1, {0x03}},
- {0x11, 1, {0x00}},
- {REGFLAG_DELAY, 120, {}},
- {0x29, 1, {0x00}},
- {REGFLAG_DELAY, 50, {}},
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
-
- 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 void lcm_suspend(void)
- {
- #ifdef BUILD_LK
- printf("%s, ALS/PS bbbbbbbbbbbbbbb n", __func__);
- #else
- printk("%s, ALS/PS bbbbbbbbbbbbbb n", __func__);
- #endif
-
- push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
- SET_RESET_PIN(0);
- MDELAY(20);
- SET_RESET_PIN(1);
- MDELAY(50);
- }
因为lcm驱动被映射到lk层,在lk层只能使用printf进行调试,但在kernel层中只能printk进行打印调试,所以可以使用宏进行BUILD_LK区分;
挂起的机制一般有两种:简单睡眠或深度睡眠;
简单睡眠:设备还处于工作状态,可以被唤醒,但是此时也会存在待机功耗等问题;
深度睡眠:设备处于休眠状态,基本处于不工作状态,因此无法被唤醒;
一般程序设计都是使用深度睡眠,在唤醒时进行重新初始化;
/* 设备恢复 */
- static void lcm_resume(void)
- {
- lcm_init();
-
- }
重新初始化设备
/* 设备id匹配 */
- static unsigned int lcm_compare_id()
- {
- unsigned int array[4];
- unsigned char buffer[4] = {0,0,0,0};
- unsigned char id_high=0;
- unsigned char id_low=0;
- unsigned char id_low0=0;
- unsigned int id=0;
-
-
- SET_RESET_PIN(1);
- MDELAY(10);
- SET_RESET_PIN(0);
- MDELAY(10);
- SET_RESET_PIN(1);
- MDELAY(200);
-
-
- array[0]=0x00063902;
- array[1]=0x0698ffff;
- array[2]=0x00000104;
- dsi_set_cmdq(array, 3, 1);
-
- array[0] = 0x00043700;
- dsi_set_cmdq(array, 1, 1);
- MDELAY(10);
- read_reg_v2(0x00, buffer, 4);
- id_high = buffer[0];
-
- array[0] = 0x00043700;
- dsi_set_cmdq(array, 1, 1);
- MDELAY(10);
- read_reg_v2(0x01, buffer, 4);
- id_low = buffer[0];
-
- array[0] = 0x00043700;
- dsi_set_cmdq(array, 1, 1);
- MDELAY(10);
- read_reg_v2(0x02, buffer, 4);
- id_low0 = buffer[0];
-
- id = (id_high<<16) | (id_low<<8)|id_low0;
-
- #ifdef BUILD_LK
- printf("ILI9806e:id2=%x.n",id);
- printf("ILI9806e:id4=%x.n",id_high);
- printf("ILI9806e:id5=%x.n",id_low);
- printf("ILI9806e:id5=%x.n",id_low0);
- #else
- printk("ILI9806e:id=%x.n",id);
- printk("ILI9806e:id_high=%x.n",id_high);
- printk("ILI9806e:id_low=%x.n",id_low);
- printk("ILI9806e:id_low=%x.n",id_low0);
- #endif
-
- return (0x980604 == id) ? 1 : 0;
- }
数据编写格式是遵循MIPI协议进行编写的 注:如果系统只配置一个lcm设备,lcm_compare_id接口不会调用,只有系统存在多个设备的是才会调用该接口进行匹配;
最后
以上就是怕孤单小霸王为你收集整理的MTK平台LCM驱动移植 对于LCM驱动移植,一般分为三部曲: 1、硬件IO口配置; 2、确保LCM背光能够正常点亮; 3、LCM驱动移植; 硬件电路: 1、GPIO配置 打开 mediatek\dct\DrvGen.exe 选择 mediatek\custom\xiaoxi\kernel\dct\dct\codegen.dws 配置文件 配置LCM PWM引脚、RST复位引脚、DISP_PWM引脚和LCM电源控制引脚 的全部内容,希望文章能够帮你解决MTK平台LCM驱动移植 对于LCM驱动移植,一般分为三部曲: 1、硬件IO口配置; 2、确保LCM背光能够正常点亮; 3、LCM驱动移植; 硬件电路: 1、GPIO配置 打开 mediatek\dct\DrvGen.exe 选择 mediatek\custom\xiaoxi\kernel\dct\dct\codegen.dws 配置文件 配置LCM PWM引脚、RST复位引脚、DISP_PWM引脚和LCM电源控制引脚 所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复