The hal layer modifies the screen brightness

Platform: rk3568
System: Android11
​​My board has two screens, and the backlight is not controlled by the same PWM, so I need to modify the upper layer to add the brightness adjustment of the other screen. The following code location in light_aidl/Lights.cpp:

 
 const char* getDriverPath(LightType type) {
    
    
     switch (type) {
    
    
         case LightType::BACKLIGHT:
             return "/sys/class/backlight/backlight/brightness";
         case LightType::BUTTONS:
             return "/sys/class/leds/button-backlight/brightness";
         case LightType::BATTERY:
         case LightType::NOTIFICATIONS:
         case LightType::ATTENTION:
             return "/sys/class/leds";
         case LightType::BLUETOOTH:
         case LightType::WIFI:
         case LightType::MICROPHONE:
         case LightType::KEYBOARD:
         default:
             return "/not_supported";
     }
 }
 
 static int setLightFromType(LightType type, const HwLightState& state) {
    
    
     int err = 0;
     switch (type) {
    
    
         case LightType::BACKLIGHT:
         case LightType::BUTTONS: {
    
    
             int brightness = state2brightbess(state);
             err = write_int(getDriverPath(type), brightness);      

It is clear from the above that the value of brightness is modified in the setLightFromType function, so I added the following modification:

diff --git a/Lights.cpp b/Lights.cpp
index 4fadbc6..159a74b 100644
--- a/Lights.cpp
+++ b/Lights.cpp
@@ -78,6 +78,7 @@ static int setLightFromType(LightType type, const HwLightState& state) {
    
    
         case LightType::BACKLIGHT:
         case LightType::BUTTONS: {
    
    
             int brightness = state2brightbess(state);
+                       write_int("/sys/class/backlight/backlight1/brightness", brightness); 
             err = write_int(getDriverPath(type), brightness);
             break;
         }

After the modification, it was found that the adjustment of the brightness still did not take effect, so logcat -b all was used to view the log information:

01-03 11:05:31.503   652   652 D ViewRootImpl[NavigationBar0]: updatePointerIcon called with position out of bounds
01-03 11:05:31.698   442   497 V DisplayPowerController: Brightness [0.0354389] reason changing to: 'temporary', previous reason: 'manual'.
01-03 11:05:31.703   300   300 E RockchipLights: write_int() failed to open /sys/class/backlight/backlight1/brightness:Permission denied
01-03 11:05:31.703   652   652 I sysui_multi_action: [757,218,758,4,759,13]
01-03 11:05:31.709   442   497 V DisplayPowerController: Brightness [0.047966387] reason changing to: 'manual', previous reason: 'temporary'.

From the above log information, it can be seen that it is a permission problem, so it is easy to handle, so add the following changes in the device/rockchip/common directory:

diff --git a/init.rk30board.rc b/init.rk30board.rc
index cf913d1..6e8048b 100755
--- a/init.rk30board.rc
+++ b/init.rk30board.rc
@@ -125,6 +125,7 @@ on boot
     # backlight
     chown system system /sys/class/backlight/rk28_bl/brightness
     chown system system /sys/class/backlight/backlight/brightness
+    chown system system /sys/class/backlight/backlight1/brightness

Finally problem solved

Guess you like

Origin blog.csdn.net/weixin_68294039/article/details/128537523