livedisplay: Migrate to ioctl()
Change-Id: I2039c94eb3239f2d88ab67076b52f58493d9b43e
This commit is contained in:
@@ -14,21 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "AntiFlickerService"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <fcntl.h>
|
||||
#include <livedisplay/oplus/AntiFlicker.h>
|
||||
|
||||
using ::android::base::ReadFileToString;
|
||||
using ::android::base::Trim;
|
||||
using ::android::base::WriteStringToFile;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const char* kDcDimmingPath = "/sys/kernel/oplus_display/dimlayer_bl_en";
|
||||
|
||||
} // anonymous namespace
|
||||
#include <oplus/oplus_display_panel.h>
|
||||
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
@@ -36,19 +24,16 @@ namespace livedisplay {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
AntiFlicker::AntiFlicker() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {}
|
||||
|
||||
Return<bool> AntiFlicker::isEnabled() {
|
||||
std::string tmp;
|
||||
int32_t contents = 0;
|
||||
|
||||
if (ReadFileToString(kDcDimmingPath, &tmp)) {
|
||||
contents = std::stoi(Trim(tmp));
|
||||
}
|
||||
|
||||
return contents > 0;
|
||||
unsigned int value;
|
||||
return ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_DIMLAYER_BL_EN, &value) == 0 && value > 0;
|
||||
}
|
||||
|
||||
Return<bool> AntiFlicker::setEnabled(bool enabled) {
|
||||
return WriteStringToFile(std::to_string(enabled), kDcDimmingPath, true);
|
||||
unsigned int value = enabled;
|
||||
return ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_DIMLAYER_BL_EN, &value) == 0;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
Reference in New Issue
Block a user