light: support more backlight paths
* I2C address for the panel regulator driver depends on the device and DSI port the display is connected on. Add more backlight paths to support different hardware configurations. Also add path for legacy rpi_backlight driver to make testing easier.
This commit is contained in:
@@ -15,9 +15,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define LOG_TAG "android.hardware.light-service.rpi"
|
||||||
|
|
||||||
#include "Lights.h"
|
#include "Lights.h"
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/logging.h>
|
||||||
|
|
||||||
using ::android::base::ReadFileToString;
|
using ::android::base::ReadFileToString;
|
||||||
using ::android::base::WriteStringToFile;
|
using ::android::base::WriteStringToFile;
|
||||||
@@ -26,8 +29,13 @@ namespace aidl::android::hardware::light {
|
|||||||
|
|
||||||
static const uint32_t defaultMaxBrightness = 255;
|
static const uint32_t defaultMaxBrightness = 255;
|
||||||
|
|
||||||
static const std::string backlightBrightnessPath = "/sys/class/backlight/11-0045/brightness";
|
static const std::string backlightBasePath = "/sys/class/backlight/";
|
||||||
static const std::string backlightMaxBrightnessPath = "/sys/class/backlight/11-0045/max_brightness";
|
|
||||||
|
static const std::string backlightPaths[] = {
|
||||||
|
"10-0045",
|
||||||
|
"11-0045",
|
||||||
|
"rpi_backlight",
|
||||||
|
};
|
||||||
|
|
||||||
static const std::vector<HwLight> availableLights = {
|
static const std::vector<HwLight> availableLights = {
|
||||||
{.id = (int)LightType::BACKLIGHT, .type = LightType::BACKLIGHT, .ordinal = 0}
|
{.id = (int)LightType::BACKLIGHT, .type = LightType::BACKLIGHT, .ordinal = 0}
|
||||||
@@ -36,10 +44,15 @@ static const std::vector<HwLight> availableLights = {
|
|||||||
Lights::Lights() {
|
Lights::Lights() {
|
||||||
maxBrightness = defaultMaxBrightness;
|
maxBrightness = defaultMaxBrightness;
|
||||||
|
|
||||||
|
for (auto &path : backlightPaths) {
|
||||||
|
std::string backlightMaxBrightnessPath = backlightBasePath + path + "/max_brightness";
|
||||||
if (!access(backlightMaxBrightnessPath.c_str(), R_OK)) {
|
if (!access(backlightMaxBrightnessPath.c_str(), R_OK)) {
|
||||||
std::string maxBrightnessValue;
|
std::string maxBrightnessValue;
|
||||||
if (ReadFileToString(backlightMaxBrightnessPath, &maxBrightnessValue)) {
|
if (ReadFileToString(backlightMaxBrightnessPath, &maxBrightnessValue)) {
|
||||||
maxBrightness = std::stoi(maxBrightnessValue);
|
maxBrightness = std::stoi(maxBrightnessValue);
|
||||||
|
LOG(INFO) << backlightMaxBrightnessPath << " = " << maxBrightnessValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,8 +63,12 @@ ndk::ScopedAStatus Lights::setLightState(int id, const HwLightState& state) {
|
|||||||
|
|
||||||
switch (light.type) {
|
switch (light.type) {
|
||||||
case LightType::BACKLIGHT:
|
case LightType::BACKLIGHT:
|
||||||
|
for (auto &path : backlightPaths) {
|
||||||
|
std::string backlightBrightnessPath = backlightBasePath + path + "/brightness";
|
||||||
if (!access(backlightBrightnessPath.c_str(), W_OK)) {
|
if (!access(backlightBrightnessPath.c_str(), W_OK)) {
|
||||||
WriteStringToFile(brightness, backlightBrightnessPath);
|
WriteStringToFile(brightness, backlightBrightnessPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@@ -1,8 +1,16 @@
|
|||||||
on early-boot
|
on early-boot
|
||||||
|
chown system system /sys/class/backlight/10-0045/brightness
|
||||||
|
chown system system /sys/class/backlight/10-0045/max_brightness
|
||||||
chown system system /sys/class/backlight/11-0045/brightness
|
chown system system /sys/class/backlight/11-0045/brightness
|
||||||
chown system system /sys/class/backlight/11-0045/max_brightness
|
chown system system /sys/class/backlight/11-0045/max_brightness
|
||||||
|
chown system system /sys/class/backlight/rpi_backlight/brightness
|
||||||
|
chown system system /sys/class/backlight/rpi_backlight/max_brightness
|
||||||
|
chmod 660 /sys/class/backlight/10-0045/brightness
|
||||||
|
chmod 440 /sys/class/backlight/10-0045/max_brightness
|
||||||
chmod 660 /sys/class/backlight/11-0045/brightness
|
chmod 660 /sys/class/backlight/11-0045/brightness
|
||||||
chmod 440 /sys/class/backlight/11-0045/max_brightness
|
chmod 440 /sys/class/backlight/11-0045/max_brightness
|
||||||
|
chmod 660 /sys/class/backlight/rpi_backlight/brightness
|
||||||
|
chmod 440 /sys/class/backlight/rpi_backlight/max_brightness
|
||||||
|
|
||||||
service vendor.light-rpi /apex/com.android.hardware.light.rpi5/bin/hw/android.hardware.light-service.rpi
|
service vendor.light-rpi /apex/com.android.hardware.light.rpi5/bin/hw/android.hardware.light-service.rpi
|
||||||
class hal
|
class hal
|
||||||
|
@@ -7,8 +7,12 @@ genfscon sysfs /devices/platform/axi/1002000000.v3d u:object_r:sysfs_gpu:s0
|
|||||||
genfscon sysfs /devices/platform/axi/axi:gpu u:object_r:sysfs_gpu:s0
|
genfscon sysfs /devices/platform/axi/axi:gpu u:object_r:sysfs_gpu:s0
|
||||||
|
|
||||||
# Lights
|
# Lights
|
||||||
|
genfscon sysfs /class/backlight/10-0045/brightness u:object_r:sysfs_leds:s0
|
||||||
|
genfscon sysfs /class/backlight/10-0045/max_brightness u:object_r:sysfs_leds:s0
|
||||||
genfscon sysfs /class/backlight/11-0045/brightness u:object_r:sysfs_leds:s0
|
genfscon sysfs /class/backlight/11-0045/brightness u:object_r:sysfs_leds:s0
|
||||||
genfscon sysfs /class/backlight/11-0045/max_brightness u:object_r:sysfs_leds:s0
|
genfscon sysfs /class/backlight/11-0045/max_brightness u:object_r:sysfs_leds:s0
|
||||||
|
genfscon sysfs /class/backlight/rpi_backlight/brightness u:object_r:sysfs_leds:s0
|
||||||
|
genfscon sysfs /class/backlight/rpi_backlight/max_brightness u:object_r:sysfs_leds:s0
|
||||||
|
|
||||||
# Serial number
|
# Serial number
|
||||||
genfscon sysfs /firmware/devicetree/base/serial-number u:object_r:sysfs_dt_firmware_android:s0
|
genfscon sysfs /firmware/devicetree/base/serial-number u:object_r:sysfs_dt_firmware_android:s0
|
||||||
|
Reference in New Issue
Block a user