summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMekala Natarajan <mekalan@codeaurora.org>2013-06-19 15:45:45 -0700
committerIliyan Malchev <malchev@google.com>2013-06-21 09:36:17 -0700
commit66e5ad149393a5875253cb7db290f9731d1f3c7a (patch)
tree4c405d1d9873ccd74ee2a0ea6bbc7a05e7087970
parent66e45020bb429934f874c748e495acc032040c8b (diff)
downloadpower-66e5ad149393a5875253cb7db290f9731d1f3c7a.tar.gz
Disable sync on thread migration feature for video encode/decode and display on/off cases
Bug: 9325608 Change-Id: I43cb1691365220fbd88c89af6a6b3394564101d5
-rwxr-xr-xAndroid.mk4
-rw-r--r--power.c90
2 files changed, 85 insertions, 9 deletions
diff --git a/Android.mk b/Android.mk
index 4ae6ae2..908c863 100755
--- a/Android.mk
+++ b/Android.mk
@@ -8,7 +8,9 @@ include $(CLEAR_VARS)
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_SHARED_LIBRARIES := liblog libcutils libdl
-LOCAL_SRC_FILES := power.c
+LOCAL_SRC_FILES := \
+ power.c \
+
LOCAL_MODULE:= power.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/power.c b/power.c
index a4569a5..b5dff04 100644
--- a/power.c
+++ b/power.c
@@ -27,30 +27,88 @@
#include <hardware/hardware.h>
#include <hardware/power.h>
-#define TOUCHBOOST_SOCKET "/dev/socket/mpdecision/touchboost"
+
+#define STATE_ON "state=1"
+#define STATE_OFF "state=0"
+
+#define BOOST_SOCKET "/dev/socket/mpdecision/boost"
static int client_sockfd;
static struct sockaddr_un client_addr;
+static int last_state = -1;
+
+static void socket_init()
+{
+ if (!client_sockfd) {
+ client_sockfd = socket(PF_UNIX, SOCK_DGRAM, 0);
+ if (client_sockfd < 0) {
+ ALOGE("%s: failed to open: %s", __func__, strerror(errno));
+ return;
+ }
+ memset(&client_addr, 0, sizeof(struct sockaddr_un));
+ client_addr.sun_family = AF_UNIX;
+ snprintf(client_addr.sun_path, UNIX_PATH_MAX, BOOST_SOCKET);
+ }
+}
static void power_init(struct power_module *module)
{
ALOGI("%s", __func__);
- client_sockfd = socket(PF_UNIX, SOCK_DGRAM, 0);
+ socket_init();
+}
+
+static void sync_thread(int off)
+{
+ int rc;
+
+ if (client_sockfd < 0) {
+ ALOGE("%s: boost socket not created", __func__);
+ return;
+ }
+
+ if (!off) {
+ rc = sendto(client_sockfd, "2", 1, 0, (const struct sockaddr *)&client_addr, sizeof(struct sockaddr_un));
+ } else {
+ rc = sendto(client_sockfd, "3", 1, 0, (const struct sockaddr *)&client_addr, sizeof(struct sockaddr_un));
+ }
+
+ if (rc < 0) {
+ ALOGE("%s: failed to send: %s", __func__, strerror(errno));
+ }
+}
+
+static void process_video_encode_hint(void *metadata)
+{
+
+ socket_init();
+
if (client_sockfd < 0) {
- ALOGE("%s: failed to open: %s", __func__, strerror(errno));
+ ALOGE("%s: boost socket not created", __func__);
return;
}
- memset(&client_addr, 0, sizeof(struct sockaddr_un));
- client_addr.sun_family = AF_UNIX;
- snprintf(client_addr.sun_path, UNIX_PATH_MAX, TOUCHBOOST_SOCKET);
+
+ if (metadata) {
+ if (!strncmp(metadata, STATE_ON, sizeof(STATE_ON))) {
+ /* Video encode started */
+ sync_thread(1);
+ } else if (!strncmp(metadata, STATE_OFF, sizeof(STATE_OFF))) {
+ /* Video encode stopped */
+ sync_thread(0);
+ } else
+ return;
+ } else {
+ return;
+ }
+
}
+
static void touch_boost()
{
int rc;
if (client_sockfd < 0) {
- ALOGE("%s: touchboost socket not created", __func__);
+ ALOGE("%s: boost socket not created", __func__);
return;
}
@@ -62,9 +120,22 @@ static void touch_boost()
static void power_set_interactive(struct power_module *module, int on)
{
+ if (last_state == -1) {
+ last_state = on;
+ } else {
+ if (last_state == on)
+ return;
+ else
+ last_state = on;
+ }
+
ALOGV("%s %s", __func__, (on ? "ON" : "OFF"));
- if (on)
+ if (on) {
+ sync_thread(0);
touch_boost();
+ } else {
+ sync_thread(1);
+ }
}
static void power_hint(struct power_module *module, power_hint_t hint,
@@ -79,6 +150,9 @@ static void power_hint(struct power_module *module, power_hint_t hint,
ALOGV("POWER_HINT_VSYNC %s", (data ? "ON" : "OFF"));
break;
#endif
+ case POWER_HINT_VIDEO_ENCODE:
+ process_video_encode_hint(data);
+ break;
default:
break;
}