summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAceLan Kao <[email protected]>2017-05-10 09:54:08 +0800
committerAceLan Kao <[email protected]>2017-05-10 19:39:47 +0800
commit86c3548d103ff5966366788220796de629be9230 (patch)
tree88ffcc6de59220c6d97cb11b3a60b7ddf09e5230
parent9ac78b69ddca15c7ba3f86791eb03eee3318db89 (diff)
Fix the skip disabled backlight device
Only raw backlight devices have the "enabled" file under device directory. So the commit 5c0d35c skip the disabled backlight device affects all type of backlight device is wrong, it will drop out all other type of backlight device except raw backlight interfaces. To fix this, we just need to check the enabled file for raw backlight interfaces. Changes V2: 1. Declare isRawBacklightEnabled() as a static function 2. Using QFile constructor to pass the file path 3. Declare "QByteArray buffer" when it's really needed below 4. Remove "bool result", and just return true/false directly 5. Adding curly brackets to if statement Signed-off-by: AceLan Kao <[email protected]>
-rw-r--r--daemon/backends/upower/backlighthelper.cpp31
-rw-r--r--daemon/backends/upower/backlighthelper.h5
2 files changed, 24 insertions, 12 deletions
diff --git a/daemon/backends/upower/backlighthelper.cpp b/daemon/backends/upower/backlighthelper.cpp
index e0eb6c4..5b133c8 100644
--- a/daemon/backends/upower/backlighthelper.cpp
+++ b/daemon/backends/upower/backlighthelper.cpp
@@ -63,6 +63,22 @@ void BacklightHelper::init()
m_isSupported = true;
}
+bool BacklightHelper::isRawBacklightEnabled(const QString &interface)
+{
+ QFile file(BACKLIGHT_SYSFS_PATH + interface + "/device/enabled");
+
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ return false;
+ }
+
+ QByteArray buffer = file.readLine().trimmed();
+ if (buffer == "enabled") {
+ return true;
+ }
+
+ return false;
+}
+
void BacklightHelper::initUsingBacklightType()
{
QDir backlightDir(BACKLIGHT_SYSFS_PATH);
@@ -76,17 +92,6 @@ void BacklightHelper::initUsingBacklightType()
QStringList firmware, platform, raw, leds;
Q_FOREACH(const QString & interface, interfaces) {
- file.setFileName(BACKLIGHT_SYSFS_PATH + interface + "/device/enabled");
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- continue;
- }
-
- buffer = file.readLine().trimmed();
- file.close();
- if (buffer == "disabled") {
- continue;
- }
-
file.setFileName(BACKLIGHT_SYSFS_PATH + interface + "/type");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
continue;
@@ -98,7 +103,9 @@ void BacklightHelper::initUsingBacklightType()
} else if(buffer == "platform") {
platform.append(interface);
} else if (buffer == "raw") {
- raw.append(interface);
+ if (isRawBacklightEnabled(interface)) {
+ raw.append(interface);
+ }
} else {
qCWarning(POWERDEVIL) << "Interface type not handled" << buffer;
}
diff --git a/daemon/backends/upower/backlighthelper.h b/daemon/backends/upower/backlighthelper.h
index 1382dd0..1d8fa33 100644
--- a/daemon/backends/upower/backlighthelper.h
+++ b/daemon/backends/upower/backlighthelper.h
@@ -52,6 +52,11 @@ private:
*/
void initUsingSysctl();
+ /**
+ * Check for a raw backlight interface if it's enabled by drm driver
+ */
+ static bool isRawBacklightEnabled(const QString &interface);
+
bool m_isSupported = false;
QString m_dirname;
QString m_sysctlDevice;