From c6a9d5fa38c7560d3b9f9d08a43458faf555e29b Mon Sep 17 00:00:00 2001 From: Deevana Murthy Bandaru Date: Mon, 23 Jul 2018 15:11:37 +0530 Subject: power: Turn on/off display in SDM439 PowerHAL writes to a sysfs node when it gets display on/off notification. Change-Id: I90acbef41cc01d7712cbb23765f3d278cb3ee637 --- power-8952.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/power-8952.c b/power-8952.c index 8a87c27..9e9765a 100644 --- a/power-8952.c +++ b/power-8952.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2015,2018 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -36,6 +36,7 @@ #include #include #include +#include #define LOG_TAG "QTI PowerHAL" #include @@ -53,6 +54,8 @@ static int display_hint_sent; static int video_encode_hint_sent; static void process_video_encode_hint(void *metadata); +static int display_fd; +#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr" int power_hint_override(struct power_module *module, power_hint_t hint, void *data) @@ -75,7 +78,13 @@ int set_interactive_override(struct power_module *module, int on) char governor[80]; char tmp_str[NODE_MAX]; struct video_encode_metadata_t video_encode_metadata; - int rc; + int rc = 0; + + static const char *display_on = "1"; + static const char *display_off = "0"; + char err_buf[80]; + static int init_interactive_hint = 0; + static int set_i_count = 0; ALOGI("Got set_interactive hint"); @@ -115,6 +124,40 @@ int set_interactive_override(struct power_module *module, int on) } } saved_interactive_mode = !!on; + + set_i_count ++; + ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count); + + if (init_interactive_hint == 0) + { + //First time the display is turned off + display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR)); + if (display_fd < 0) { + strerror_r(errno,err_buf,sizeof(err_buf)); + ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf); + return HINT_HANDLED; + } + else + init_interactive_hint = 1; + } + else + if (!on ) { + /* Display off. */ + rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off))); + if (rc < 0) { + strerror_r(errno,err_buf,sizeof(err_buf)); + ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf); + } + } + else { + /* Display on */ + rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on))); + if (rc < 0) { + strerror_r(errno,err_buf,sizeof(err_buf)); + ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf); + } + } + return HINT_HANDLED; } -- cgit v1.2.3