summaryrefstree
path: root/kernel/drivers/media/platform/exynos/camera/is-time.h
blob: a971e4b75aa7f2c6b31b1c902dc0cb561d35d9f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Samsung Exynos5 SoC series FIMC-IS driver
 *
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef IS_TIME_H
#define IS_TIME_H

#include <linux/time.h>
#include <linux/sched/clock.h>

#define MEASURE_TIME
#define MONITOR_TIME
#define MONITOR_TIMEOUT 5000 /* 5ms */
/* #define EXTERNAL_TIME */
/* #define INTERFACE_TIME */

#define INSTANCE_MASK   0x3

#define TM_FLITE_STR	0
#define TM_FLITE_END	1
#define TM_SHOT		2
#define TM_SHOT_D	3
#define TM_META_D	4
#define TM_MAX_INDEX	5

extern int debug_time_launch;
extern int debug_time_queue;
extern int debug_time_shot;

struct is_monitor {
	unsigned long long	time;
	bool			check;
};

struct is_time {
	u32 time_count;
	unsigned long long t_dq[10];
	unsigned long long t_dqq_max;
	unsigned long long t_dqq_tot;
	unsigned long long time1_max;
	unsigned long long time1_tot;
	unsigned long long time2_max;
	unsigned long long time2_tot;
	unsigned long long time3_max;
	unsigned long long time3_tot;
	unsigned long long time4_cur;
	unsigned long long time4_old;
	unsigned long long time4_tot;
};

struct is_interface_time {
	u32 cmd;
	u32 time_tot;
	u32 time_min;
	u32 time_max;
	u32 time_cnt;
};

enum is_time_launch {
	LAUNCH_DDK_LOAD,
	LAUNCH_PREPROC_LOAD,
	LAUNCH_SENSOR_INIT,
	LAUNCH_SENSOR_START,
	LAUNCH_FAST_AE,
	LAUNCH_TOTAL,
};

enum is_time_queue {
	TMQ_DQ,
	TMQ_QS,
	TMQ_QE,
	TMQ_END,
};

enum is_time_shot {
	TMS_Q,
	TMS_SHOT1,
	TMS_SHOT2,
	TMS_SDONE,
	TMS_DQ,
	TMS_END,
};

void TIME_STR(unsigned int index);
void TIME_END(unsigned int index, const char *name);
void is_jitter(u64 timestamp);
u64 is_get_timestamp(void);
u64 is_get_timestamp_boot(void);
#define PROGRAM_COUNT(count) monitor_point(group, count)
void monitor_point(void *group_data, u32 mpoint);

void monitor_time_shot(void *group_data, void *frame_data, u32 mpoint);
void monitor_time_queue(void *vctx_data, u32 mpoint);

#ifdef MEASURE_TIME
#ifdef MONITOR_TIME
void monitor_init(struct is_time *time);
#endif
#ifdef INTERFACE_TIME
void measure_init(struct is_interface_time *time, u32 cmd);
void measure_time(struct is_interface_time *time,
	u32 instance,
	u32 group,
	struct timeval *start,
	struct timeval *end);
#endif
#endif

#define TIME_LAUNCH_STR(p)				\
	do {						\
		if (unlikely(debug_time_launch))	\
			TIME_STR(p);			\
	} while (0)
#define TIME_LAUNCH_END(p)				\
	do {						\
		if (unlikely(debug_time_launch)) 	\
			TIME_END(p, #p);		\
	} while (0)

#define TIME_SHOT(point)					\
	do {							\
		if (debug_time_shot > 0)			\
			monitor_time_shot(group, frame, point);	\
	} while (0)

#define TIME_QUEUE(point)					\
	do {							\
		if (debug_time_queue > 0)			\
			monitor_time_queue(vctx, point);	\
	} while (0)

#endif