Home | History | Annotate | Download | only in camera
      1 /*
      2  * Copyright (C) Texas Instruments - http://www.ti.com/
      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 #include "CameraHal.h"
     18 
     19 namespace android {
     20 
     21 const char CameraHal::PARAMS_DELIMITER []= ",";
     22 
     23 #if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS
     24 
     25 struct timeval CameraHal::ppm_start;
     26 
     27 #endif
     28 
     29 #if PPM_INSTRUMENTATION
     30 
     31 /**
     32    @brief PPM instrumentation
     33 
     34    Dumps the current time offset. The time reference point
     35    lies within the CameraHAL constructor.
     36 
     37    @param str - log message
     38    @return none
     39 
     40  */
     41 void CameraHal::PPM(const char* str){
     42     struct timeval ppm;
     43 
     44     gettimeofday(&ppm, NULL);
     45     ppm.tv_sec = ppm.tv_sec - ppm_start.tv_sec;
     46     ppm.tv_sec = ppm.tv_sec * 1000000;
     47     ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_start.tv_usec;
     48 
     49     ALOGD("PPM: %s :%ld.%ld ms", str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 ));
     50 }
     51 
     52 #elif PPM_INSTRUMENTATION_ABS
     53 
     54 /**
     55    @brief PPM instrumentation
     56 
     57    Dumps the current time offset. The time reference point
     58    lies within the CameraHAL constructor. This implemetation
     59    will also dump the abosolute timestamp, which is useful when
     60    post calculation is done with data coming from the upper
     61    layers (Camera application etc.)
     62 
     63    @param str - log message
     64    @return none
     65 
     66  */
     67 void CameraHal::PPM(const char* str){
     68     struct timeval ppm;
     69 
     70     unsigned long long elapsed, absolute;
     71     gettimeofday(&ppm, NULL);
     72     elapsed = ppm.tv_sec - ppm_start.tv_sec;
     73     elapsed *= 1000000;
     74     elapsed += ppm.tv_usec - ppm_start.tv_usec;
     75     absolute = ppm.tv_sec;
     76     absolute *= 1000;
     77     absolute += ppm.tv_usec /1000;
     78 
     79     ALOGD("PPM: %s :%llu.%llu ms : %llu ms", str, ( elapsed /1000 ), ( elapsed % 1000 ), absolute);
     80 }
     81 
     82 #endif
     83 
     84 #if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS
     85 
     86 /**
     87    @brief PPM instrumentation
     88 
     89    Calculates and dumps the elapsed time using 'ppm_first' as
     90    reference.
     91 
     92    @param str - log message
     93    @return none
     94 
     95  */
     96 void CameraHal::PPM(const char* str, struct timeval* ppm_first, ...){
     97     char temp_str[256];
     98     struct timeval ppm;
     99     unsigned long long absolute;
    100     va_list args;
    101 
    102     va_start(args, ppm_first);
    103     vsprintf(temp_str, str, args);
    104     gettimeofday(&ppm, NULL);
    105     absolute = ppm.tv_sec;
    106     absolute *= 1000;
    107     absolute += ppm.tv_usec /1000;
    108     ppm.tv_sec = ppm.tv_sec - ppm_first->tv_sec;
    109     ppm.tv_sec = ppm.tv_sec * 1000000;
    110     ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_first->tv_usec;
    111 
    112     ALOGD("PPM: %s :%ld.%ld ms :  %llu ms", temp_str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 ), absolute);
    113 
    114     va_end(args);
    115 }
    116 
    117 #endif
    118 
    119 };
    120 
    121 
    122