赞
踩
设备进行EMI静电测试时,LCD显示屏异常之后不能恢复,需要在软件上检测LCD是否处于工作状态,如果没有处于工作状态,则需要重启LCD。
参照SDK docs/Common/DISPLAY路径下的Rockchip_DRM_Panel_Porting_Guide_V1.6_20190228.pdf》文档,其中3.4章节提到了如何判断MIPI-DSI外设有正常工作?瑞芯微也为此申请了专利。
drivers/gpu/drm/drm_mipi_dsi.c
kernel/include/drm/drm_mipi_dsi.h
提供了对 MIPI-DSI 外设通信的相关 API。
支持 DCS 标准 MIPI_DCS_GET_POWER_MODE(0x0A)命令的外设,可以通过读取 power_mode 来判断,函数mipi_dsi_dcs_get_power_mode() - query the display module's current power mode。mode=0x08 说 明 设 备 目 前 是 OFF 状 态,mode=0x9c,说明设备目前是 ON 状态。
驱动说明文档<rockchip_drm_integration_helper-zh.pdf>
- # echo off > /sys/class/drm/card0-DSI-1/status
- # echo on > /sys/class/drm/card0-DSI-1/status
修改驱动,启动时获取power_mode
..\x3566_linux_v1.2.0\kernel\drivers\gpu\drm\panel\panel-simple.c文件,在static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)函数中增加读取液晶状态的函数:
- static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
- {
- struct panel_simple *panel;
- struct device *dev = &dsi->dev;
- const struct panel_desc_dsi *desc;
- struct panel_desc_dsi *d;
- const struct of_device_id *id;
- int err;
- u8 mode;
-
- id = of_match_node(dsi_of_match, dsi->dev.of_node);
- if (!id)
- return -ENODEV;
- dev_info(dev, "panel_simple_dsi_probe\n");
-
- if (!id->data) {
- d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL);
- if (!d)
- return -ENOMEM;
-
- err = panel_simple_dsi_of_get_desc_data(dev, d);
- if (err) {
- dev_err(dev, "failed to get desc data: %d\n", err);
- return err;
- }
- }
-
- desc = id->data ? id->data : d;
-
- err = panel_simple_probe(&dsi->dev, &desc->desc);
- if (err < 0)
- return err;
-
- panel = dev_get_drvdata(dev);
- panel->dsi = dsi;
-
- dsi->mode_flags = desc->flags;
- dsi->format = desc->format;
- dsi->lanes = desc->lanes;
-
- ++ /* user add begin */
- ++ if(dsi)
- ++ {
- ++ err = mipi_dsi_dcs_get_power_mode( dsi, &mode);
- ++ dev_info( dev, "get_power_mode err=%d, mode=%02x\n", err, mode );
- ++ }
- ++ /* user add end */
-
- err = mipi_dsi_attach(dsi);
- if (err) {
- struct panel_simple *panel = dev_get_drvdata(&dsi->dev);
- drm_panel_remove(&panel->base);
- }
-
-
- return err;
- }
启动时没有连接屏幕,打印如下:
- [root@RK356X:/]# dmesg | grep get_power_mode
- [ 0.267272] panel-simple-dsi fe060000.dsi.0: get_power_mode err=-110, mode=02
启动时连接了屏幕,打印如下:
- [root@RK356X:/]# dmesg | grep get_power_mode
- [ 0.268318] panel-simple-dsi fe060000.dsi.0: get_power_mode err=0, mode=9c
在panel-simple.c文件中增加一个内核线程函数,每5s读取一次power_mode:
- static int kthread_checkLCDstatus_func(void * data)
- {
- struct mipi_dsi_device *dsi = (struct mipi_dsi_device *)data;
- int err;
- u8 mode;
-
- while (!kthread_should_stop())
- {
- err = mipi_dsi_dcs_get_power_mode( dsi, &mode);
- dev_info( &dsi->dev, "get_power_mode err=%d, mode=%02x\n", err, mode );
- msleep(5000);
- }
-
- return 0;
- }
在panel_simple_dsi_probe()函数中创建并运行checkLCDstatus_kthread线程:
- static struct task_struct *checkLCDstatus_kthread = NULL;
-
-
- static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
- {
- struct panel_simple *panel;
- struct device *dev = &dsi->dev;
- const struct panel_desc_dsi *desc;
- struct panel_desc_dsi *d;
- const struct of_device_id *id;
- int err;
- u8 mode;
-
- id = of_match_node(dsi_of_match, dsi->dev.of_node);
- if (!id)
- return -ENODEV;
-
- if (!id->data) {
- d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL);
- if (!d)
- return -ENOMEM;
-
- err = panel_simple_dsi_of_get_desc_data(dev, d);
- if (err) {
- dev_err(dev, "failed to get desc data: %d\n", err);
- return err;
- }
- }
-
- desc = id->data ? id->data : d;
-
- err = panel_simple_probe(&dsi->dev, &desc->desc);
- if (err < 0)
- return err;
-
- panel = dev_get_drvdata(dev);
- panel->dsi = dsi;
-
- dsi->mode_flags = desc->flags;
- dsi->format = desc->format;
- dsi->lanes = desc->lanes;
-
- ++ /* user add begin */
- ++ if(dsi)
- ++ {
- ++ err = mipi_dsi_dcs_get_power_mode( dsi, &mode);
- ++ dev_info( dev, "get_power_mode err=%d, mode=%02x\n", err, mode );
-
- ++ checkLCDstatus_kthread = kthread_run(kthread_checkLCDstatus_func, dsi, "test_task");
- ++ }
- ++ /* user add end */
-
- err = mipi_dsi_attach(dsi);
- if (err) {
- struct panel_simple *panel = dev_get_drvdata(&dsi->dev);
- drm_panel_remove(&panel->base);
- }
-
- return err;
- }
设备运行过程中,手动复位触发LCD复位,读取的mode重9c变为了08,日志如下:
- [ 118.415228] kthread is running
- [ 118.418300] panel-simple-dsi fe060000.dsi.0: get_power_mode err=0, mode=9c
- [ 123.535187] kthread is running
- [ 123.541131] panel-simple-dsi fe060000.dsi.0: get_power_mode err=0, mode=9c
- [ 128.655245] kthread is running
- [ 128.664003] panel-simple-dsi fe060000.dsi.0: get_power_mode err=0, mode=08
- [ 133.775156] kthread is running
- [ 133.786790] panel-simple-dsi fe060000.dsi.0: get_power_mode err=0, mode=08
本应该只重启LCD即可,但没有合适的方法,所以直接重启系统,修改kthread_checkLCDstatus_func()函数:
- static int kthread_checkLCDstatus_func(void * data)
- {
- struct mipi_dsi_device *dsi = (struct mipi_dsi_device *)data;
- int err;
- u8 mode;
-
- while (!kthread_should_stop())
- {
- err = mipi_dsi_dcs_get_power_mode( dsi, &mode);
- dev_info( &dsi->dev, "get_power_mode err=%d, mode=%02x\n", err, mode );
- msleep(5000);
-
- printk("panel-simple restart kernel\n");
- kernel_restart(NULL); //linux kernel restart.
- }
-
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。