LCD Backlight 的分析

一、backlight cannot work (STE Riogrande Platform)
1. ADB Command: /sys/class/leds/lcd-backlight/brightness ,实际路径/sys/devices/i2c-0/2-0040/leds/lcd-backlight
    echo 0 > brightness \n
    echo 100 >brightness
    cat brightness
2. Check system/core/rootdir/init.rc 关于lcd-backlight的权限是否设置正确
3. Check LCD_BACKLIGHT driver: /kernel/drivers/leds/leds-as3677.c (wrong: ./drivers/leds/leds-lm3530.c, 和./arch/arm/mach-ux500/leds-lotus.c)
4. Check PDP schematic(Circuit_Diagram_1243-3693_4_2.pdf),LCD backlight 的供电 BMU_DCDC_OUT,发现 Keypad_backlight和LCD backlight共用 一路电源,而实际Lotus的硬件设计是没有Keypad_backlight的,估计会彼此有影响。导致LCD backlight的控制不正常。
5. Check /kernel/arch/arm/configs/semc_lotus_defconfig, 定义了 CONFIG_LEDS_AS3677
6. Check /kernel/drivers/leds/leds-as3677.c, LCD backlight电源供电芯片 的驱动
7. Check Lightsensor 初始的设置, ./device/semc/riogrande_pdp/files/hw_config.sh, hw_config.sh 设置了部分硬件设备的初始状态。 hw_config.sh会在projectname.mk中拷贝到system/etc,然后在init进程中分析执行init.semc.rc,从而完成硬件的初始化
8. Check Lightseneor 是否调整为自动背光,用ADB 查看/sys/devices/i2c-0/0-0040/leds/lcd-backlight/als/enable (mogami平台), /sys/devices/platform/nmk-i2c.2/i2c-2/2-0040/(Rio Grande平台)
[
开机阶段 外围硬件参数设置: 只是针对mogami平台
    1). mogami.mk 中如下设置把 文件拷贝到system
        PRODUCT_COPY_FILES += \
            device/semc/$(TARGET_PRODUCT)/files/hw_config.sh:system/etc/hw_config.sh \
            device/semc/$(TARGET_PRODUCT)/files/pre_hw_config.sh:system/etc/pre_hw_config.sh

    2). init.mogami.rc中 启动设置/dev/block/vold/179:33 /mnt/usbdisk vfat rw,
        service hw_config /system/bin/sh /system/etc/hw_config.sh
            user root
            oneshot
]
9. ADB /dev/block, /proc/partitions, /proc/mounts, df 可查看分块信息
10. 用 adb root 首先获取adb root权限(root权限重新启动 adb的守护进程),然后就可以adb remount, 从而可以自由操作系统文件了。
11. Android 不同partition 之间不能 移动文件,会出现Cross-device link错误, 比较好的方法是通过 /sdcard 来中转移动。
12.每天代码更新编译连接
http://android-ci-platform.sonyericsson.net/view/CM/job/daily_build_ginger-ste-dev/379/artifact/result-dir/
13.更新s1boot 和重新创建 ta, 重新flash,手机可以启动了,但system crash.
14.修改AS3677 chip(LCD backlight的供电),设置固定的curr1或curr6回路。
15. 修改 待机时间 frameworks/base/services/java/com/android/server/PowerManagerService.java
    private static final int DEFAULT_SCREEN_OFF_TIMEOUT = 15000;
然后查找DEFAULT_SCREEN_OFF_TIMEOUT ,系统读取该值得地方,直接赋值即可; 实际上所有setting的default value都保存在frameworks/base/packages/SettingsProvider/res/values/defaults.xml
另外还可以直接修改其数据库文件,如下
    adb shell
    cd /data/data/com.android.providers.settings/databases
    sqlite3 settings.db
    select * from system where name = 'screen_off_timeout';//; 很重要,必须有
    update system set value='-1' where name='screen_off_timeout';
或者     sqlite3 /data/data/com.android.providers.settings/databases/settings.db  "UPDATE system SET value='-1' WHERE name = 'screen_off_timeout'";
    sqlite3 /data/data/com.android.providers.settings/databases/settings.db  "SELECT * FROM system  WHERE name = 'screen_off_timeout'";
    对其数据库操作的代码位于/frameworks/base/packages/settingprovider/src/com/android/providers/settings/databasehelper.java;
17. [JAVA APP层] 位于/packages/apps/Settings/src/com/android/settings, 其中BrightnessPreference.java 有函数setBrightness(int brightness)-->power.setBacklightBrightness(brightness);
18. [JAVA Framework层 ManagerService]frameworks/base/services/java/com/android/server/PowerManagerService.java,中有函数setBacklightBrightness-->mLcdLight.setBrightness(brightness); mLcdLight会在init()函数中赋值mLcdLight = lights.getLight(LightsService.LIGHT_ID_BACKLIGHT);
19. [JAVA Framework层Service] framework/base/services/java/com/android/server/lightsservice.java 中( LightsService.Light).setBrightness-->setLightLocked-->setLight_native
20. [JAVA Framework层Native] frameworks/base/services/jni/com_android_server_lightsservice.cpp 中有init_native--> hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const**)&module)-->load(id, path, module);其中path指向lights.st-ericsson.so;和setLight_native
21. [HAL 层]/vendor/semc/hardware/lights/lights_core.c; 中函数leds_core_init-->get_link_table
22. [HAL 层]/vendor/semc/hardware/lights/hw/as3677.c中有as3677_set函数-->set_simple-->write_int
23. [HAL 层]/vendor/semc/hardware/lights/utils.c中有函数write_int-->write_str-->write_to_path-->write
24. [HAL 层]/vendor/semc/hardware/lights/illumination_service.c; 会被编译成BUILD_EXECUTABLE,可执行程序会最终放在 手机/system/bin/illumination_service; 利用init.st-ericsson.rc 中service illumination /system/bin/illumination_service 启动,其中的main函数会一直读取文件 #define soc_path "/data/lightservice.soc"的内容,通过该读写文件进行数据传递
25. [HAL 层]/vendor/semc/hardware/lights/lights_module.c; 中函数open_lights会设置好set_light(该函数会向文件/data/lightservice.soc 写入内容)
26. [HAL 层]在vendor/semc/hardware/lights/Android.mk中,有Build HW lib module部分,把lights_module.c编译成LOCAL_MODULE := $(SEMC_CFG_LIGHTS_MODULE_NAME),其中SEMC_CFG_LIGHTS_MODULE_NAME在device/semc/lotus/lotus_cfg.mk中定义为SEMC_CFG_LIGHTS_MODULE_NAME := lights.st-ericsson,所以最后Build 的HW lib module 位于手机/system/lib/hw/lights.st-ericsson.so;
27. [HAL 层]HAL 是如何被调用的 hardware/libhardware/include/hardware/hardware.h [中注释 Every hardware module must have a data structure named HAL_MODULE_INFO_SYM and the fields of this data structure must begin with hw_module_t],还定义了#define HAL_MODULE_INFO_SYM HMI
28. [HAL 层]hardware/libhardware/hardware.c中有函数hw_get_module(const char *id, const struct hw_module_t **module),负责得到对应的硬件模块,其中 id 是关键,通过id 会找到对应的hw module, 例如 backlight 的id 是#define LIGHTS_HARDWARE_MODULE_ID "lights" 在/hardware/libhardware/include/hardware/lights.h被定义,hw_get_module函数会在com_android_server_lightservice.cpp中调用
29. [HAL 层]/device/semc/lotus/lights/leds.c 中as3677_led as3677_lcd,并且定义了关联到"/sys/bus/i2c/drivers/as3677/2-0040" ,还关联了as3677_set函数, 这些都靠get_link_table 初始化
30. [Kernel 层]关于backlight的kernel driver在 kernel/drivers/leds/leds-as3677.c --> as3677_set_led_brightness 和led-class.c-->led_class_attrs[]
31. User Space如何调用到kernel Space, 比如操作 /sys/class/leds/lcd-backlight/brightness,用户空间可以直接写入该文件值,然后产生系统调用的软中断(0x80)exception: ret_fast_syscall(asm)->sys_write->vfs_write->sysfs_write_file->dev_attr_store->led_brightness_store->as3677_set_led_brightness

 

 

 

二、Backlight 的ASL不起作用,基于ICS版本-->LCD 亮度不够(STE Riogrande Platform)
1. 查看 寄存器的值 /sys/class/leds/lcd-backlight/device/debug, ALS_control的寄存器值没有变化(0x01,表示打开ALS)。
2. 用I2C工具,读写通过I2C操作的寄存器
    a. ls /sys/class/leds/lcd-backlight/device/driver,查看到2-0040 (I2C Bus-addrss)
    b. adb push i2ctest /system/bin; #chmod 777 /system/bin/i2ctest
    c. #i2ctest -b 2 -a 0x40 -w 0x94 0x00 ;disable ALS,
    d. #i2ctest -b 2 -a 0x40 -w 0x94 0x01 ;enable ALS,
    e. check ALS_control的值,#cat /sys/class/leds/lcd-backlight/device/debug
3. [HAL 层]updated@device/semc/lotus/lights/leds.c 该函数会设置als_group,正常逻辑应该是 当设置als功能时才需要设置als_group. 变量static struct as367x_light_curve lcb_bl_curves 定义了不同的亮度区间对应设置不同的als_group参数。 update-->as3677_set_light_curve-->写入/sys/bus/i2c/drivers/as3677/2-0040/als_group1-->[Kernel 层]as3677_als_group_n_store@kernel/drivers/leds/leds-as3677.c;
4. 在as3677_platform_data as3677_pdata@/kernel/arch/arm/maNone - no ambient light sensor controlch-ux500/leds-lotus.c 中设置了背光限流
5. 测试 关掉ALS功能-->ALS_curr12_group 94: 0x00(None - no ambient light sensor control);可以改变LCD的背光-->设置Curr1_current 09: 0xff的值[0x0,0xff],从Lotus的schematic可以看到LCD的backlight电源用的是curr1 这一路cathode。
6. 在手机上 /sys/bus/i2c/drivers/as3677/2-0040 下可以获取当前Backlight的状态,如 als_on,als_group1等;路径/sys/bus/i2c/drivers/as3677/2-0040/leds/lcd-backlight 是user space 操作驱动的sys fs.
7. 谁调用的update@device/semc/lotus/lights/leds.c?  首先set_led@vendor/semc/hardware/lights/lights_core.c这个函数会在main@vendor/semc/hardware/lights/illumination_service.c, 然后在vendor/semc/hardware/lights/lights_core.c中函数set_led->set_led_locked或led_set_theme->led_set_state->apply_swled_state???->set_swled_interfaces[ight_state_t const *state转化成hw_st->brightness]->set_intf_state->set_hw_state->hwled_updated->set_hw_led->api->updated[update@device/semc/lotus/lights/leds.c] 然后执行api->set[as3677_set@vendor/semc/hardware/lights/hw/as3677.c] ;


你可能感兴趣的:(sqlite,service,Module,System,Lotus,structure)