Skip to content

Commit

Permalink
composer:set perf-hint for large composition cycle
Browse files Browse the repository at this point in the history
-- disabled by default, enable using property
   vendor.display.enable_perf_hint_large_comp_cycle

Change-Id: I3b62ebb96e03547249d7536b430aedc9f9d5ae9f
  • Loading branch information
Bipin Kumar committed Sep 18, 2020
1 parent 833d70d commit 3a809b5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
14 changes: 10 additions & 4 deletions composer/cpuhint.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, The Linux Foundataion. All rights reserved.
/* Copyright (c) 2015, 2020, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -49,15 +49,15 @@ DisplayError CPUHint::Init(HWCDebugHandler *debug_handler) {
debug_handler->GetProperty(PERF_HINT_WINDOW_PROP, &pre_enable_window);
if (pre_enable_window <= 0) {
DLOGI("Invalid CPU Hint Pre-enable Window %d", pre_enable_window);
return kErrorNotSupported;
}

DLOGI("CPU Hint Pre-enable Window %d", pre_enable_window);
pre_enable_window_ = pre_enable_window;

if (vendor_ext_lib_.Open(path)) {
if (!vendor_ext_lib_.Sym("perf_lock_acq", reinterpret_cast<void **>(&fn_lock_acquire_)) ||
!vendor_ext_lib_.Sym("perf_lock_rel", reinterpret_cast<void **>(&fn_lock_release_))) {
!vendor_ext_lib_.Sym("perf_lock_rel", reinterpret_cast<void **>(&fn_lock_release_)) ||
!vendor_ext_lib_.Sym("perf_hint", reinterpret_cast<void **>(&fn_perf_hint_))) {
DLOGW("Failed to load symbols for Vendor Extension Library");
return kErrorNotSupported;
}
Expand All @@ -67,7 +67,7 @@ DisplayError CPUHint::Init(HWCDebugHandler *debug_handler) {
DLOGW("Failed to open %s : %s", path, vendor_ext_lib_.Error());
}

return kErrorNone;
return enabled_ ? kErrorNone : kErrorNotSupported;
}

void CPUHint::Set() {
Expand Down Expand Up @@ -105,4 +105,10 @@ void CPUHint::Reset() {
lock_acquired_ = false;
}

void CPUHint::ReqHints(int hint) {
if(enabled_ && hint > 0) {
fn_perf_hint_(hint, NULL, 0, 0);
}
}

} // namespace sdm
4 changes: 3 additions & 1 deletion composer/cpuhint.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, The Linux Foundataion. All rights reserved.
/* Copyright (c) 2015, 2020, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -42,6 +42,7 @@ class CPUHint {
DisplayError Init(HWCDebugHandler *debug_handler);
void Set();
void Reset();
void ReqHints(int hint);

private:
enum { HINT = 0x4501 /* 45-display layer hint, 01-Enable */ };
Expand All @@ -54,6 +55,7 @@ class CPUHint {
DynLib vendor_ext_lib_;
int (*fn_lock_acquire_)(int handle, int duration, int *hints, int num_args) = NULL;
int (*fn_lock_release_)(int value) = NULL;
int (*fn_perf_hint_)(int hint, const char *pkg, int duration, int type) = NULL;
};

} // namespace sdm
Expand Down
24 changes: 23 additions & 1 deletion composer/hwc_display_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ int HWCDisplayBuiltIn::Init() {
DLOGI("Window rect : [%f %f %f %f]", window_rect_.left, window_rect_.top,
window_rect_.right, window_rect_.bottom);
}

HWCDebugHandler::Get()->GetProperty(PERF_HINT_WINDOW_PROP, &perf_hint_window_);
HWCDebugHandler::Get()->GetProperty(ENABLE_PERF_HINT_LARGE_COMP_CYCLE,
&perf_hint_large_comp_cycle_);

return status;
}

Expand Down Expand Up @@ -247,6 +252,7 @@ HWC2::Error HWCDisplayBuiltIn::Validate(uint32_t *out_num_types, uint32_t *out_n
}

status = PrepareLayerStack(out_num_types, out_num_requests);
SetCpuPerfHintLargeCompCycle();
pending_commit_ = true;
return status;
}
Expand Down Expand Up @@ -719,7 +725,7 @@ void HWCDisplayBuiltIn::SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &
}

void HWCDisplayBuiltIn::ToggleCPUHint(bool set) {
if (!cpu_hint_) {
if (!cpu_hint_ || !perf_hint_window_) {
return;
}

Expand Down Expand Up @@ -1445,4 +1451,20 @@ int HWCDisplayBuiltIn::PostInit() {
return 0;
}

void HWCDisplayBuiltIn::SetCpuPerfHintLargeCompCycle() {
if (!cpu_hint_ || !perf_hint_large_comp_cycle_) {
DLOGV_IF(kTagResources, "cpu_hint_ not initialized or perty not set");
return;
}

for (auto hwc_layer : layer_set_) {
Layer *layer = hwc_layer->GetSDMLayer();
if (layer->composition == kCompositionGPU) {
DLOGV_IF(kTagResources, "Set perf hint for large comp cycle");
cpu_hint_->ReqHints(kPerfHintLargeCompCycle);
break;
}
}
}

} // namespace sdm
4 changes: 4 additions & 0 deletions composer/hwc_display_builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ class HWCDisplayBuiltIn : public HWCDisplay, public SyncTask<LayerStitchTaskCode
bool AllocateStitchBuffer();
void CacheAvrStatus();
void PostCommitStitchLayers();
void SetCpuPerfHintLargeCompCycle();

// SyncTask methods.
void OnTask(const LayerStitchTaskCode &task_code,
SyncTask<LayerStitchTaskCode>::TaskContext *task_context);

const int kPerfHintLargeCompCycle = 0x00001097;
BufferAllocator *buffer_allocator_ = nullptr;
CPUHint *cpu_hint_ = nullptr;
CWBClient cwb_client_ = kCWBClientNone;
Expand Down Expand Up @@ -213,6 +215,8 @@ class HWCDisplayBuiltIn : public HWCDisplay, public SyncTask<LayerStitchTaskCode
std::mutex sampling_mutex;
bool api_sampling_vote = false;
bool vndservice_sampling_vote = false;
int perf_hint_window_ = 0;
int perf_hint_large_comp_cycle_ = 0;
};

} // namespace sdm
Expand Down
3 changes: 3 additions & 0 deletions include/display_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
// SPR
#define ENABLE_SPR DISPLAY_PROP("enable_spr")

// PERF hint properties
#define ENABLE_PERF_HINT_LARGE_COMP_CYCLE DISPLAY_PROP("enable_perf_hint_large_comp_cycle")

// Add all vendor.display properties above

#define DISABLE_UBWC_PROP GRALLOC_PROP("disable_ubwc")
Expand Down
2 changes: 2 additions & 0 deletions init/init.qti.display_boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ case "$target" in
"shima")
# Set property for shima
setprop vendor.display.target.version 2
setprop vendor.display.enable_perf_hint_large_comp_cycle 1
;;
"holi")
# Set property for holi
setprop vendor.display.disable_offline_rotator 0
setprop vendor.display.disable_rotator_ubwc 1
setprop vendor.display.enable_perf_hint_large_comp_cycle 1
;;
esac

0 comments on commit 3a809b5

Please sign in to comment.