power: Turn on/off display in SDM439

PowerHAL writes to a sysfs node when it gets display on/off
notification.

Change-Id: I90acbef41cc01d7712cbb23765f3d278cb3ee637
This commit is contained in:
Deevana Murthy Bandaru
2018-07-23 15:11:37 +05:30
parent a0a371993e
commit c6a9d5fa38

View File

@@ -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 <fcntl.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <unistd.h>
#define LOG_TAG "QTI PowerHAL"
#include <utils/Log.h>
@@ -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;
}