微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > android MTK驱动背光唤醒流程

android MTK驱动背光唤醒流程

时间:10-02 整理:3721RD 点击:

     在标准的android驱动中,睡眠唤醒流程非常清晰,能够较方便的更改LCD唤醒时间和led背光的点亮时间,但是也很容易出现问题,比如说闪屏,唤醒慢!

     出现闪屏有两个原因

1、 开背光时间在唤醒lcd前!

2、 开背光时间在唤醒lcd后,但是没有等lcd刷屏就点亮背光!

我按照标准驱动流程去分析mtk的做法


他的video最初的注册位置是

Mediatek kernel drivers video  mtkfb.c 里面

入口函数


module_init(mtkfb_init);


在 函数int __init mtkfb_init(void)  中有这样一句

register_early_suspend(&mtkfb_early_suspend_handler);

是注册睡眠机制函数

只要注册这里 就是把 mtkfb_early_suspend_handler  下面的结构体里面的函数


.suspend = mtkfb_early_suspend,

.resume = mtkfb_late_resume,

睡眠、唤醒交给系统来管理

他的调用顺序和

.level = EARLY_SUSPEND_LEVEL_DISABLE_FB,    这个值有关系



去找找背光的驱动

module_init(mt65xx_leds_init);  背光入口函数


在mt65xx_leds_init中注册平台类设备

ret = platform_driver_register(&mt65xx_leds_driver);


他函数注册信息是

static struct platform_driver mt65xx_leds_driver = {

.driver = {

.name = "leds-mt65xx",

.owner = THIS_MODULE,

},

.probe = mt65xx_leds_probe,

.remove = mt65xx_leds_remove,

//.suspend = mt65xx_leds_suspend,

.shutdown   = mt65xx_leds_shutdown,

};


我们也可以再  手机adb  shell里面查找到相关的信息

/sys/bus/platform/devices/leds-mt65xx

/sys/devices/platform/leds-mt65xx

但是没有找到这里的设置路径?奇怪!那背光灯设置是在什么地方呢?

在mt65xx_leds_probe  函数中

有这样一条代码

g_leds_data->cdev.brightness_set = mt65xx_led_set;

难道是 直接给上层节点直接设置?

继续跟代码

仔细分析 代码 mt65xx_leds_probe函数

if(strcmp(g_leds_data->cdev.name,"lcd-backlight") == 0)

{

rc = device_create_file(g_leds_data->cdev.dev, &dev_attr_duty);

            if(rc)

            {

                LEDS_DEBUG("[LED]device_create_file duty fail!\n");

            }


            rc = device_create_file(g_leds_data->cdev.dev, &dev_attr_div);

            if(rc)

            {

                LEDS_DEBUG("[LED]device_create_file duty fail!\n");

            }

            rc = device_create_file(g_leds_data->cdev.dev, &dev_attr_frequency);

            if(rc)

            {

                LEDS_DEBUG("[LED]device_create_file duty fail!\n");

            }


    rc = device_create_file(g_leds_data->cdev.dev, &dev_attr_pwm_register);

            if(rc)

            {

                LEDS_DEBUG("[LED]device_create_file duty fail!\n");

            }

bl_setting = &g_leds_data->cust;

}

建立了节点   之后呢?

不得不佩服mtk弄个鸟东西搞这么复杂


进入

/sys/devices/platform/leds-mt65xx/leds/lcd-backlight/

发现有

Brightness

用这种可以设置背光灯亮度

echo 255 > brightness

Brightness   这东西在哪里来的?

在代码  kernel drivers  leds  led-class.c

里面有subsys_initcall(leds_init);

用 subsys_initcall

有这样代码


static struct device_attribute led_class_attrs[] = {

__ATTR(brightness, 0644, led_brightness_show, led_brightness_store),

__ATTR(max_brightness, 0444, led_max_brightness_show, NULL),

#ifdef CONFIG_LEDS_TRIGGERS

__ATTR(trigger, 0644, led_trigger_show, led_trigger_store),

#endif

__ATTR_NULL,

};


生成了brightness节点

上层直接调用……


为什么?

打log发现   在resume  lcd后就会调用brightness  写值


他没有用

.level = EARLY_SUSPEND_LEVEL_DISABLE_FB, 这个来管理


优点

不会有我开始说的那两种bug,什么时候点亮lcd是由上层控制,上层去判断有没有刷屏!

流程已经写死,只要开发者不破坏此模式就不会有bug


缺点

破坏了源代码的流程,已经完全是一体,真正出现问题比较难改!


关于上层怎么去判断什么时候去点亮背光 ,这个问题,现在还没跟,以后有时间慢慢跟,不过做驱动,跟到这里已经可以满足驱动的要求了!


这个有用 学习了

如果用late_resume 好像也比较难同步 不好控制

学习了,怎么没有收藏帖子的选项哦。

学习了,谢谢

哈哈,长姿势了

非常感谢分享!

不错,学习了

小编有没有遇到按下power 键,灭屏比较慢的情况?log如下:  屏是oled的屏,感觉按下按键多次调用了设置背光的进程:
952.773038]<0> (0)[711:Thread-57][LED]Set Backlight directly 76 at time 65277
[  952.773947]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:305
[  952.796292]<0> (0)[711:Thread-57][LED]Set Backlight directly 72 at time 65279
[  952.798879]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:289
[  952.830803]<1> (1)[711:Thread-57][LED]Set Backlight directly 62 at time 65283
[  952.831711]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:249
[  952.850550]<1> (1)[711:Thread-57][LED]Set Backlight directly 58 at time 65285
[  952.851457]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:233
[  952.869214]Mali<1>: mali_pmm_utilization_handler: GPU utilization=1
[  952.872954]<1> (1)[711:Thread-57][LED]Set Backlight directly 55 at time 65287
[  952.873861]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:221
[  952.890889]<1> (1)[711:Thread-57][LED]Set Backlight directly 51 at time 65289
[  952.899638]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:205
[  952.922652]<0> (0)[711:Thread-57][LED]Set Backlight directly 44 at time 65292
[  952.923559]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:177
[  952.940540]<1> (1)[711:Thread-57][LED]Set Backlight directly 40 at time 65294
[  952.941446]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:160
[  952.961382]<0> (0)[711:Thread-57][LED]Set Backlight directly 37 at time 65296
[  952.962639]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:148
[  952.982489]<0> (0)[711:Thread-57][LED]Set Backlight directly 30 at time 65298
[  952.983412]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:120
[  953.001272]<1> (1)[711:Thread-57][LED]Set Backlight directly 26 at time 65300
[  953.002195]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:104
[  953.021465]<0> (0)[711:Thread-57][LED]Set Backlight directly 23 at time 65302
[  953.022388]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:92
[  953.041194]<1> (1)[711:Thread-57][LED]Set Backlight directly 19 at time 65304
[  953.042116]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:76
[  953.061329]<0> (0)[711:Thread-57][LED]Set Backlight directly 16 at time 65306
[  953.062250]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:64
[  953.069225]Mali<1>: mali_pmm_utilization_handler: GPU utilization=0
[  953.081223]<1> (1)[711:Thread-57][LED]Set Backlight directly 12 at time 65308
[  953.082145]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:48
[  953.101477]<0> (0)[711:Thread-57][LED]Set Backlight directly 8 at time 65310
[  953.102469]<0> (0)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:32
[  953.122143]<1> (1)[711:Thread-57][LED]Set Backlight directly 5 at time 65312
[  953.123057]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:20
[  953.141084]<1> (1)[711:Thread-57][LED]Set Backlight directly 1 at time 65314
[  953.141994]<1> (1)[711:Thread-57]mt65xx_leds_set_cust: set brightness, name:lcd-backlight, mode:5, level:4
[  953.162089]<1> (1)[674owerManagerSer][HIB/PM][state_store]entry (3)
[  953.162958]<1>-(1)[674:PowerManagerSer][Ker_PM][request_suspend_state]sleep (0->3) at 953163851133 (2010-01-01 15:00:29.369744770 UTC)
[  953.164480]<1>-(1)[674:PowerManagerSer][Ker_PM][request_suspend_state]sys_sync_work_queue early_sys_sync_work
[  953.165780]<1>-(1)[674:PowerManagerSer][Ker_PM][request_suspend_state]suspend_work_queue early_suspend_work

牛B
    分析得还是很好的!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top