Learn about LCD screen backlight adjustment with the android 4.0.3 source code together with cainiao

Source: Internet
Author: User

At noon on Saturday, I still came to the company and didn't intend to come. Now, let's solve some of the problems left over from the last time, let's sum up the pwm LCD Backlight for Android. The backlight of Android is controlled by PWM wave. Different voltage values are obtained through different duty cycles, so that the brightness of the LCD is different. Specifically, it controls the voltage value.

To adjust the backlight on the android layer, you must prepare the underlying driver. The first is the backlight. the Linux driver model is ready, and you only need to select it.

Graphics support under Device

 

Select the backlight.

 

We also need to prepare the PWM driver for the corresponding platform. After preparing the driver, we will be OK. Then, a node is generated:

/sys/class/backlight/pwm-backlight/brightness

As long

echo 100 >  /sys/class/backlight/pwm-backlight/brightness    echo 50 >  /sys/class/backlight/pwm-backlight/brightness

If the backlight changes, the driver is OK. You can also use the oscilloscope to check whether the PWM pin has been changed.

If it fails, continue to debug the underlying driver. The next step is to go to Android.


For backlight, the android code mainly includes:

Frameworks/base/services/jni/com_android_server_LightsService.cppFrameworks/base/services/java/com/android/server/LightsServer.java

Here we don't need to pay too much attention. porting to Android is mainly about the hardware abstraction layer. The Java layer will call the JNI layer, and the JNI layer will be adjusted to the corresponding hardware abstraction layer, the hardware abstraction layer continues to call the underlying driver. Well, let's look at the hardware abstraction layer of the LCD backlight.

Lights. C on different platforms is placed in different places. For example, if you are a Samsung tuna platform

In/device/Samsung/tuna/liblights/lights. C.

#define LOG_TAG "lights"#include <cutils/log.h>#include <stdint.h>#include <string.h>#include <errno.h>#include <fcntl.h>#include <pthread.h>#include <sys/ioctl.h>#include <sys/types.h>#include 

 

This code is mainly modified

char const *const LCD_FILE = "/sys/class/backlight/s6e8aa0/brightness";

In fact, the backlight is to open this node and write data into it. Therefore, you need to change this node to the node on your own platform.

Here we change

char const *const LCD_FILE = "/sys/class/backlight/pwm-backlight/brightness";

 

As

char const *const LED_FILE = "/dev/an30259a_leds";

This should be the node that prompts the light, regardless of him. Then, under mm, we get a lights. Default. So, and replace this. So.

There is also a permission issue. To open this node, you need permissions. Then you can add the permissions in init. XXX. RC.

chown system system /sys/class/backlight/pwm-backlight/brightness

 

OK. In this way, the android UI that adjusts the screen brightness can control the backlight of the LCD.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.