blob: ead73e085834045f752d1cae1c00730a6cdc495d
1 | /* |
2 | * Copyright (C) 2011 The Android Open Source Project |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #define LOG_TAG "CameraHalCommon " |
18 | #include "CameraHal.h" |
19 | #ifdef AMLOGIC_VIRTUAL_CAMERA_SUPPORT |
20 | #include "VirtualCamHal.h" |
21 | #endif |
22 | |
23 | namespace android { |
24 | |
25 | const char CameraHal::PARAMS_DELIMITER []= ","; |
26 | |
27 | #if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS |
28 | |
29 | struct timeval CameraHal::ppm_start; |
30 | #ifdef AMLOGIC_VIRTUAL_CAMERA_SUPPORT |
31 | struct timeval VirtualCamHal::ppm_start; |
32 | #endif |
33 | |
34 | #endif |
35 | |
36 | #if PPM_INSTRUMENTATION |
37 | |
38 | /** |
39 | @brief PPM instrumentation |
40 | |
41 | Dumps the current time offset. The time reference point |
42 | lies within the CameraHAL constructor. |
43 | |
44 | @param str - log message |
45 | @return none |
46 | |
47 | */ |
48 | void CameraHal::PPM(const char* str){ |
49 | struct timeval ppm; |
50 | |
51 | gettimeofday(&ppm, NULL); |
52 | ppm.tv_sec = ppm.tv_sec - ppm_start.tv_sec; |
53 | ppm.tv_sec = ppm.tv_sec * 1000000; |
54 | ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_start.tv_usec; |
55 | |
56 | CAMHAL_LOGDB("PPM: %s :%ld.%ld ms", str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 )); |
57 | } |
58 | |
59 | #elif PPM_INSTRUMENTATION_ABS |
60 | |
61 | /** |
62 | @brief PPM instrumentation |
63 | |
64 | Dumps the current time offset. The time reference point |
65 | lies within the CameraHAL constructor. This implemetation |
66 | will also dump the abosolute timestamp, which is useful when |
67 | post calculation is done with data coming from the upper |
68 | layers (Camera application etc.) |
69 | |
70 | @param str - log message |
71 | @return none |
72 | |
73 | */ |
74 | void CameraHal::PPM(const char* str){ |
75 | struct timeval ppm; |
76 | |
77 | unsigned long long elapsed, absolute; |
78 | gettimeofday(&ppm, NULL); |
79 | elapsed = ppm.tv_sec - ppm_start.tv_sec; |
80 | elapsed *= 1000000; |
81 | elapsed += ppm.tv_usec - ppm_start.tv_usec; |
82 | absolute = ppm.tv_sec; |
83 | absolute *= 1000; |
84 | absolute += ppm.tv_usec /1000; |
85 | |
86 | CAMHAL_LOGDB("PPM: %s :%llu.%llu ms : %llu ms", |
87 | str, (elapsed/1000), (elapsed%1000), absolute); |
88 | } |
89 | |
90 | #endif |
91 | |
92 | #if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS |
93 | |
94 | /** |
95 | @brief PPM instrumentation |
96 | |
97 | Calculates and dumps the elapsed time using 'ppm_first' as |
98 | reference. |
99 | |
100 | @param str - log message |
101 | @return none |
102 | |
103 | */ |
104 | void CameraHal::PPM(const char* str, struct timeval* ppm_first, ...){ |
105 | char temp_str[256]; |
106 | struct timeval ppm; |
107 | unsigned long long absolute; |
108 | va_list args; |
109 | |
110 | va_start(args, ppm_first); |
111 | vsprintf(temp_str, str, args); |
112 | gettimeofday(&ppm, NULL); |
113 | absolute = ppm.tv_sec; |
114 | absolute *= 1000; |
115 | absolute += ppm.tv_usec /1000; |
116 | ppm.tv_sec = ppm.tv_sec - ppm_first->tv_sec; |
117 | ppm.tv_sec = ppm.tv_sec * 1000000; |
118 | ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_first->tv_usec; |
119 | |
120 | CAMHAL_LOGDB("PPM: %s :%ld.%ld ms : %llu ms", |
121 | temp_str, (ppm.tv_sec/1000), (ppm.tv_sec%1000), absolute); |
122 | |
123 | va_end(args); |
124 | } |
125 | |
126 | #endif |
127 | |
128 | }; |
129 | |
130 | |
131 |