Skip to content

Commit

Permalink
power: Spring cleanup
Browse files Browse the repository at this point in the history
* Cleanup SoC specific files:
 - Fix code spacing and indentation
 - Remove dead code
 - Remove useless comments
 - Remove useless logs
 - Make code uniform between the files so it's easier to diff
 - Use declared enums when possible for power hints

Change-Id: Ie1378c94c53b33299927c5eb1bfc19f1a42b8743
  • Loading branch information
mikeNG committed May 25, 2018
1 parent 50a6e28 commit 47636f6
Show file tree
Hide file tree
Showing 14 changed files with 383 additions and 461 deletions.
266 changes: 128 additions & 138 deletions power-660.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
* Copyright (C) 2018 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -52,8 +53,6 @@

static int video_encode_hint_sent;

static void process_video_encode_hint(void *metadata);

/**
* If target is SDM630:
* return true
Expand All @@ -72,183 +71,174 @@ static bool is_target_SDM630(void)
return is_SDM630;
}

int power_hint_override(power_hint_t hint, void *data)
{

switch(hint) {
case POWER_HINT_VSYNC:
break;
case POWER_HINT_VIDEO_ENCODE:
{
process_video_encode_hint(data);
return HINT_HANDLED;
}
default:
break;
}
return HINT_NONE;
}

int set_interactive_override(int on)
static void process_video_encode_hint(void *metadata)
{
char governor[80];
int resource_values[20];
int num_resources;
struct video_encode_metadata_t video_encode_metadata;

ALOGI("Got set_interactive hint");

if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_HANDLED;
return;
}
}
}
}

if (!on) {
/* Display off. */
if (!metadata) {
return;
}

/* Initialize encode metadata struct fields. */
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;

if (parse_video_encode_metadata((char *)metadata,
&video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}

if (video_encode_metadata.state == 1) {
if (is_interactive_governor(governor)) {
/*
1. CPUfreq params
- hispeed freq for big - 1113Mhz
- go hispeed load for big - 95
- above_hispeed_delay for big - 40ms
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
if(is_target_SDM630()){
int res[] = { 0x41414000, 0x459,
0x41410000, 0x5F,
0x41400000, 0x4,
0x41820000, 0xA };
if (is_target_SDM630()) {
/*
1. CPUfreq params
- hispeed freq for big - 1113Mhz
- go hispeed load for big - 95
- above_hispeed_delay for big - 40ms
- target loads - 95
- nr_run - 5
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
int res[] = {
HISPEED_FREQ_BIG, 0x459,
GO_HISPEED_LOAD_BIG, 0x5F,
ABOVE_HISPEED_DELAY_BIG, 0x4,
TARGET_LOADS_BIG, 0x5F,
SCHED_IDLE_NR_RUN, 0X5,
CPUBW_HWMON_SAMPLE_MS, 0xA
};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
num_resources = ARRAY_SIZE(res);
}
/*
1. CPUfreq params
- hispeed freq for little - 902Mhz
- go hispeed load for little - 95
- above_hispeed_delay for little - 40ms
2. BusDCVS V2 params
- Sample_ms of 10ms
3. Sched group upmigrate - 500
*/
else{
int res[] = { 0x41414100, 0x386,
0x41410100, 0x5F,
0x41400100, 0x4,
0x41820000, 0xA,
0x40C54000, 0x1F4};
} else {
/*
1. CPUfreq params
- hispeed freq for little - 902Mhz
- go hispeed load for little - 95
- above_hispeed_delay for little - 40ms
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
int res[] = {
HISPEED_FREQ_LITTLE, 0x386,
GO_HISPEED_LOAD_LITTLE, 0x5F,
ABOVE_HISPEED_DELAY_LITTLE, 0x4,
CPUBW_HWMON_SAMPLE_MS, 0xA
};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
num_resources = ARRAY_SIZE(res);

}
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, num_resources);
if (!video_encode_hint_sent) {
perform_hint_action(video_encode_metadata.hint_id,
resource_values, num_resources);
video_encode_hint_sent = 1;
}
}
} else {
/* Display on. */
} else if (video_encode_metadata.state == 0) {
if (is_interactive_governor(governor)) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
}
}
return HINT_HANDLED;
}

int power_hint_override(power_hint_t hint, void *data)
{
switch (hint) {
case POWER_HINT_VSYNC:
break;
case POWER_HINT_VIDEO_ENCODE:
process_video_encode_hint(data);
return HINT_HANDLED;
default:
break;
}
return HINT_NONE;
}

/* Video Encode Hint */
static void process_video_encode_hint(void *metadata)
int set_interactive_override(int on)
{
char governor[80];
int resource_values[20];
int num_resources;
struct video_encode_metadata_t video_encode_metadata;

ALOGI("Got process_video_encode_hint");

if (get_scaling_governor_check_cores(governor,
sizeof(governor),CPU0) == -1) {
if (get_scaling_governor_check_cores(governor,
sizeof(governor),CPU1) == -1) {
if (get_scaling_governor_check_cores(governor,
sizeof(governor),CPU2) == -1) {
if (get_scaling_governor_check_cores(governor,
sizeof(governor),CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
// return HINT_HANDLED;
}
}
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_NONE;
}
}
}

/* Initialize encode metadata struct fields. */
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;

if (metadata) {
if (parse_video_encode_metadata((char *)metadata,
&video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}
} else {
return;
}

if (video_encode_metadata.state == 1) {
if (!on) {
/* Display off. */
if (is_interactive_governor(governor)) {
/*
1. CPUfreq params
- hispeed freq for big - 1113Mhz
- go hispeed load for big - 95
- above_hispeed_delay for big - 40ms
- target loads - 95
- nr_run - 5
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
if(is_target_SDM630()){
int res[] = { 0x41414000, 0x459,
0x41410000, 0x5F,
0x41400000, 0x4,
0x41420000, 0x5F,
0x40C2C000, 0X5,
0x41820000, 0xA};
if (is_target_SDM630()) {
/*
1. CPUfreq params
- hispeed freq for big - 1113Mhz
- go hispeed load for big - 95
- above_hispeed_delay for big - 40ms
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
int res[] = {
HISPEED_FREQ_BIG, 0x459,
GO_HISPEED_LOAD_BIG, 0x5F,
ABOVE_HISPEED_DELAY_BIG, 0x4,
CPUBW_HWMON_SAMPLE_MS, 0xA
};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
num_resources = ARRAY_SIZE(res);

}
/*
1. CPUfreq params
- hispeed freq for little - 902Mhz
- go hispeed load for little - 95
- above_hispeed_delay for little - 40ms
2. BusDCVS V2 params
- Sample_ms of 10ms
*/
else{
int res[] = { 0x41414100, 0x386,
0x41410100, 0x5F,
0x41400100, 0x4,
0x41820000, 0xA};
} else {
/*
1. CPUfreq params
- hispeed freq for little - 902Mhz
- go hispeed load for little - 95
- above_hispeed_delay for little - 40ms
2. BusDCVS V2 params
- Sample_ms of 10ms
3. Sched group upmigrate - 500
*/
int res[] = {
HISPEED_FREQ_LITTLE, 0x386,
GO_HISPEED_LOAD_LITTLE, 0x5F,
ABOVE_HISPEED_DELAY_LITTLE, 0x4,
CPUBW_HWMON_SAMPLE_MS, 0xA,
SCHED_GROUP_UP_MIGRATE, 0x1F4
};
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
num_resources = ARRAY_SIZE(res);

}
if (!video_encode_hint_sent) {
perform_hint_action(video_encode_metadata.hint_id,
resource_values, num_resources);
video_encode_hint_sent = 1;
}
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, num_resources);
}
} else if (video_encode_metadata.state == 0) {
} else {
/* Display on. */
if (is_interactive_governor(governor)) {
undo_hint_action(video_encode_metadata.hint_id);
video_encode_hint_sent = 0;
undo_hint_action(DISPLAY_STATE_HINT_ID);
}
}
return;
return HINT_HANDLED;
}
Loading

0 comments on commit 47636f6

Please sign in to comment.