• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Copyright (C) 2011-2018 ARM or its affiliates
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19 
20 #include "acamera_firmware_config.h"
21 
22 
23 #if defined( ACAMERA_ISP_PROFILING ) && ( ACAMERA_ISP_PROFILING == 1 )
24 #include "system_profiler.h"
25 #include "acamera_profiler.h"
26 //#include "system_headers.h"
27 #include <linux/ktime.h>
28 //=============Controls===========================================================
29 
30 //================================================================================
time_diff(struct timespec start,struct timespec end)31 uint64_t time_diff( struct timespec start, struct timespec end )
32 {
33     struct timespec temp;
34     if ( ( end.tv_nsec - start.tv_nsec ) < 0 ) {
35         temp.tv_sec = end.tv_sec - start.tv_sec - 1;
36         temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
37     } else {
38         temp.tv_sec = end.tv_sec - start.tv_sec;
39         temp.tv_nsec = end.tv_nsec - start.tv_nsec;
40     }
41     return (uint64_t)temp.tv_sec * 1000000000 + temp.tv_nsec;
42 }
43 //=============Profiler functions (calling order:  profiler.scxml)================
44 
45 //-------------Platform depended functions----------------------------------------
cpu_get_freq(void)46 int32_t cpu_get_freq( void )
47 {
48     return 1000000000;
49 }
50 
51 static struct timespec start_clk;
52 static struct timespec start_isr_clk;
53 
cpu_start_clocks(void)54 void cpu_start_clocks( void )
55 {
56     start_clk = current_kernel_time();
57 }
58 
cpu_start_isr_clocks(void)59 void cpu_start_isr_clocks( void )
60 {
61     start_isr_clk = current_kernel_time();
62 }
63 
cpu_stop_clocks(void)64 uint64_t cpu_stop_clocks( void )
65 {
66     struct timespec end_clk;
67     end_clk = current_kernel_time();
68     return time_diff( start_clk, end_clk );
69 }
70 
cpu_stop_isr_clocks(void)71 uint64_t cpu_stop_isr_clocks( void )
72 {
73     struct timespec end_clk;
74     end_clk = current_kernel_time();
75     return time_diff( start_isr_clk, end_clk );
76 }
77 
cpu_init_profiler(void)78 void cpu_init_profiler( void )
79 {
80 }
81 //--------------------------------------------------------------------------------
82 
83 
84 //--------------------------------------------------------------------------------
85 //================================================================================
86 #endif //ACAMERA_ISP_PROFILING
87