power-mediatek: Run clang-format

Change-Id: I76ff3c8e6e541113d538d44a0b6810e3adfc445b
Signed-off-by: bengris32 <bengris32@protonmail.ch>
This commit is contained in:
bengris32
2023-10-26 22:39:41 +01:00
parent c6cb2c536d
commit 032a76561d
4 changed files with 19 additions and 19 deletions

1
.clang-format Symbolic link
View File

@@ -0,0 +1 @@
../../build/soong/scripts/system-clang-format

View File

@@ -16,11 +16,11 @@
#include <android-base/file.h> #include <android-base/file.h>
#endif #endif
#define DLSYM_GET_FUNCTION(func_ptr, handle, func_name) \ #define DLSYM_GET_FUNCTION(func_ptr, handle, func_name) \
func_ptr = (typeof(func_ptr))dlsym(handle, #func_name); \ func_ptr = (typeof(func_ptr))dlsym(handle, #func_name); \
if (func_ptr == NULL) { \ if (func_ptr == NULL) { \
LOG(ERROR) << "Could not locate symbol " #func_name "."; \ LOG(ERROR) << "Could not locate symbol " #func_name "."; \
abort(); \ abort(); \
} }
namespace aidl { namespace aidl {
@@ -57,7 +57,7 @@ Power::Power() {
mPerf->Init(1); mPerf->Init(1);
} }
Power::~Power() { } Power::~Power() {}
long long Power::calcTimespanUs(struct timespec start, struct timespec end) { long long Power::calcTimespanUs(struct timespec start, struct timespec end) {
long long diff_in_us = 0; long long diff_in_us = 0;
@@ -79,7 +79,7 @@ void Power::handleInteractionHint(int32_t targetDuration) {
if (targetDuration > durationMs) { if (targetDuration > durationMs) {
durationMs = (targetDuration > kMaxInteractiveDuration) ? kMaxInteractiveDuration durationMs = (targetDuration > kMaxInteractiveDuration) ? kMaxInteractiveDuration
: targetDuration; : targetDuration;
} }
clock_gettime(CLOCK_MONOTONIC, &currentInteractionTime); clock_gettime(CLOCK_MONOTONIC, &currentInteractionTime);
@@ -123,26 +123,24 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
#endif #endif
switch (type) { switch (type) {
#ifdef TAP_TO_WAKE_NODE #ifdef TAP_TO_WAKE_NODE
case Mode::DOUBLE_TAP_TO_WAKE: case Mode::DOUBLE_TAP_TO_WAKE: {
{
::android::base::WriteStringToFile(enabled ? "1" : "0", TAP_TO_WAKE_NODE, true); ::android::base::WriteStringToFile(enabled ? "1" : "0", TAP_TO_WAKE_NODE, true);
break; break;
} }
#endif #endif
case Mode::LAUNCH: case Mode::LAUNCH: {
{
if (mLaunchHandle > 0) { if (mLaunchHandle > 0) {
mPerf->LockRel(mLaunchHandle); mPerf->LockRel(mLaunchHandle);
mLaunchHandle = 0; mLaunchHandle = 0;
} }
if (enabled) { if (enabled) {
mLaunchHandle = mPerf->CusLockHint(MTKPOWER_HINT_LAUNCH, kLaunchBoostDuration, getpid()); mLaunchHandle =
mPerf->CusLockHint(MTKPOWER_HINT_LAUNCH, kLaunchBoostDuration, getpid());
} }
break; break;
} }
case Mode::INTERACTIVE: case Mode::INTERACTIVE: {
{
if (enabled) { if (enabled) {
// Device is now in an interactive state, // Device is now in an interactive state,
// resume all previously performing hints. // resume all previously performing hints.

View File

@@ -18,13 +18,13 @@ namespace power {
namespace impl { namespace impl {
namespace mediatek { namespace mediatek {
const int32_t kTouchBoostDuration = 25; /* ms */ const int32_t kTouchBoostDuration = 25; /* ms */
const int32_t kMinInteractiveDuration = 400; /* ms */ const int32_t kMinInteractiveDuration = 400; /* ms */
const int32_t kMaxInteractiveDuration = 5000; /* ms */ const int32_t kMaxInteractiveDuration = 5000; /* ms */
const int32_t kLaunchBoostDuration = 30000; /* ms */ const int32_t kLaunchBoostDuration = 30000; /* ms */
class Power : public BnPower { class Power : public BnPower {
public: public:
Power(); Power();
~Power(); ~Power();
ndk::ScopedAStatus setMode(Mode type, bool enabled) override; ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
@@ -36,11 +36,12 @@ public:
int64_t durationNanos, int64_t durationNanos,
std::shared_ptr<IPowerHintSession>* _aidl_return) override; std::shared_ptr<IPowerHintSession>* _aidl_return) override;
ndk::ScopedAStatus getHintSessionPreferredRate(int64_t* outNanoseconds) override; ndk::ScopedAStatus getHintSessionPreferredRate(int64_t* outNanoseconds) override;
private:
private:
static long long calcTimespanUs(struct timespec start, struct timespec end); static long long calcTimespanUs(struct timespec start, struct timespec end);
void handleInteractionHint(int32_t targetDuration); void handleInteractionHint(int32_t targetDuration);
libpowerhal_t *mPerf; libpowerhal_t* mPerf;
struct timespec mPreviousInteractionTime; struct timespec mPreviousInteractionTime;
int32_t mPreviousInteractionDuration; int32_t mPreviousInteractionDuration;

View File

@@ -16,7 +16,7 @@
#define NSINUS 1000L #define NSINUS 1000L
typedef struct libpowerhal_t { typedef struct libpowerhal_t {
void *perfLib; void* perfLib;
void (*Init)(int32_t); void (*Init)(int32_t);
void (*LockRel)(int32_t); void (*LockRel)(int32_t);
void (*UserScnDisableAll)(void); void (*UserScnDisableAll)(void);