1 /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __QCAMERAPERF_H__ 31 #define __QCAMERAPERF_H__ 32 33 // System dependencies 34 #include <utils/List.h> 35 #include <utils/Mutex.h> 36 37 // Camera dependencies 38 #include "power.h" 39 40 typedef enum { 41 ALL_CORES_ONLINE = 0x7FE, 42 ALL_CPUS_PWR_CLPS_DIS = 0x101, 43 CPU0_MIN_FREQ_TURBO_MAX = 0x2FE, 44 CPU4_MIN_FREQ_TURBO_MAX = 0x1FFE, 45 }perf_lock_params_t; 46 47 /* Time related macros */ 48 #define ONE_SEC 1000 49 typedef int64_t nsecs_t; 50 #define NSEC_PER_SEC 1000000000LLU 51 52 using namespace android; 53 54 namespace qcamera { 55 56 class QCameraPerfLock { 57 public: 58 QCameraPerfLock(); 59 ~QCameraPerfLock(); 60 61 void lock_init(); 62 void lock_deinit(); 63 int32_t lock_rel(); 64 int32_t lock_acq(); 65 int32_t lock_acq_timed(int32_t timer_val); 66 int32_t lock_rel_timed(); 67 bool isTimerReset(); 68 void powerHintInternal(power_hint_t hint, bool enable); 69 void powerHint(power_hint_t hint, bool enable); isPerfLockTimedAcquired()70 bool isPerfLockTimedAcquired() { return (0 <= mPerfLockHandleTimed); } 71 72 private: 73 int32_t (*perf_lock_acq)(int, int, int[], int); 74 int32_t (*perf_lock_rel)(int); 75 void startTimer(uint32_t timer_val); 76 void resetTimer(); 77 void *mDlHandle; 78 uint32_t mPerfLockEnable; 79 Mutex mLock; 80 int32_t mPerfLockHandle; // Performance lock library handle 81 int32_t mPerfLockHandleTimed; // Performance lock library handle 82 power_module_t *m_pPowerModule; // power module Handle 83 power_hint_t mCurrentPowerHint; 84 bool mCurrentPowerHintEnable; 85 uint32_t mTimerSet; 86 uint32_t mPerfLockTimeout; 87 nsecs_t mStartTimeofLock; 88 List<power_hint_t> mActivePowerHints; // Active/enabled power hints list 89 }; 90 91 }; // namespace qcamera 92 93 #endif /* __QCAMREAPERF_H__ */ 94