• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <android/hardware/power/1.1/IPower.h>
39 
40 using namespace android;
41 using android::hardware::power::V1_1::IPower;
42 using android::hardware::power::V1_0::PowerHint;
43 using ::android::hardware::Return;
44 using ::android::hardware::Void;
45 
46 typedef enum {
47     ALL_CORES_ONLINE = 0x7FE,
48     ALL_CPUS_PWR_CLPS_DIS = 0x101,
49     CPU0_MIN_FREQ_TURBO_MAX = 0x2FE,
50     CPU4_MIN_FREQ_TURBO_MAX = 0x1FFE,
51 }perf_lock_params_t;
52 
53 /* Time related macros */
54 #define ONE_SEC 1000
55 typedef int64_t nsecs_t;
56 #define NSEC_PER_SEC 1000000000LLU
57 
58 using namespace android;
59 
60 namespace qcamera {
61 
62 class QCameraPerfLock {
63 public:
64     QCameraPerfLock();
65     ~QCameraPerfLock();
66 
67     void    lock_init();
68     void    lock_deinit();
69     int32_t lock_rel();
70     int32_t lock_acq();
71     int32_t lock_acq_timed(int32_t timer_val);
72     int32_t lock_rel_timed();
73     bool    isTimerReset();
74     void    powerHintInternal(PowerHint hint, bool enable);
75     void    powerHint(PowerHint hint, bool enable);
76 
77 private:
78     int32_t        (*perf_lock_acq)(int, int, int[], int);
79     int32_t        (*perf_lock_rel)(int);
80     void            startTimer(uint32_t timer_val);
81     void            resetTimer();
82     void           *mDlHandle;
83     uint32_t        mPerfLockEnable;
84     Mutex           mLock;
85     int32_t         mPerfLockHandle;        // Performance lock library handle
86     int32_t         mPerfLockHandleTimed;   // Performance lock library handle
87     sp<IPower>      mPowerHal;
88     PowerHint       mCurrentPowerHint;
89     bool            mCurrentPowerHintEnable;
90     uint32_t        mTimerSet;
91     uint32_t        mPerfLockTimeout;
92     nsecs_t         mStartTimeofLock;
93     List<PowerHint> mActivePowerHints;   // Active/enabled power hints list
94 };
95 
96 }; // namespace qcamera
97 
98 #endif /* __QCAMREAPERF_H__ */
99