• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * include/trace/events/meson_atrace.h
3  *
4  * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  */
17 
18 /*
19  * This file enables ftrace logging in a way that
20  * atrace/systrace would understand
21  * without any custom javascript change in chromium-trace
22  */
23 #ifndef LINUX_AMLOGIC_POWER_DOMAIN_H
24 #define LINUX_AMLOGIC_POWER_DOMAIN_H
25 #undef TRACE_SYSTEM
26 #define TRACE_SYSTEM meson_atrace
27 
28 #if !defined(TRACE_MESON_BASE_H) || defined(TRACE_HEADER_MULTI_READ)
29 #define TRACE_MESON_BASE_H
30 
31 #include <linux/tracepoint.h>
32 
33 #define KERNEL_ATRACE_COUNTER 0
34 #define KERNEL_ATRACE_BEGIN 1
35 #define KERNEL_ATRACE_END 2
36 #define KERNEL_ATRACE_ASYNC_BEGIN 3
37 #define KERNEL_ATRACE_ASYNC_END 4
38 
39 #if !defined(TRACE_HEADER_MULTI_READ)
40 
41 enum {
42     KERNEL_ATRACE_TAG_VIDEO,
43     KERNEL_ATRACE_TAG_CODEC_MM,
44     KERNEL_ATRACE_TAG_VDEC,
45     KERNEL_ATRACE_TAG_TSYNC,
46     KERNEL_ATRACE_TAG_IONVIDEO,
47     KERNEL_ATRACE_TAG_AMLVIDEO,
48     KERNEL_ATRACE_TAG_VIDEO_COMPOSER,
49     KERNEL_ATRACE_TAG_V4L2,
50     KERNEL_ATRACE_TAG_MAX = 64,
51     KERNEL_ATRACE_TAG_ALL
52 };
53 
54 #endif
55 
56 #define print_flags_header(flags)                                                                                      \
57     __print_flags(flags, "", {(1UL << KERNEL_ATRACE_COUNTER), "C"}, {(1UL << KERNEL_ATRACE_BEGIN), "B"},               \
58                   {(1UL << KERNEL_ATRACE_END), "E"}, {(1UL << KERNEL_ATRACE_ASYNC_BEGIN), "S"},                        \
59                   {(1UL << KERNEL_ATRACE_ASYNC_END), "F"})
60 
61 #define print_flags_delim(flags)                                                                                       \
62     __print_flags(flags, "", {(1UL << KERNEL_ATRACE_COUNTER), "|1|"}, {(1UL << KERNEL_ATRACE_BEGIN), "|1|"},           \
63                   {(1UL << KERNEL_ATRACE_END), ""}, {(1UL << KERNEL_ATRACE_ASYNC_BEGIN), "|1|"},                       \
64                   {(1UL << KERNEL_ATRACE_ASYNC_END), "|1|"})
65 
66 TRACE_EVENT(tracing_mark_write,
67 
68             TP_PROTO(const char *name, unsigned int flags, unsigned int value),
69 
70             TP_ARGS(name, flags, value),
71 
72             TP_STRUCT__entry(__string(name, name) __field(unsigned int, flags) __field(unsigned int, value)),
73 
74             TP_fast_assign(__assign_str(name, name); __entry->flags = flags; __entry->value = value;),
75 
76             TP_printk("%s%s%s|%u", print_flags_header(__entry->flags), print_flags_delim(__entry->flags),
77                       __get_str(name), __entry->value));
78 
79 #ifdef CONFIG_AMLOGIC_DEBUG_ATRACE
80 void meson_atrace(int tag, const char *name, unsigned int flags, unsigned int value);
81 
82 #define ATRACE_COUNTER(name, value) meson_atrace(KERNEL_ATRACE_TAG, name, (1 << KERNEL_ATRACE_COUNTER), value)
83 #define ATRACE_BEGIN(name) meson_atrace(KERNEL_ATRACE_TAG, name, (1 << KERNEL_ATRACE_BEGIN), 0)
84 #define ATRACE_END() meson_atrace(KERNEL_ATRACE_TAG, "", (1 << KERNEL_ATRACE_END), 1)
85 #define ATRACE_ASYNC_BEGIN(name, cookie) meson_atrace(KERNEL_ATRACE_TAG, name, (1 << KERNEL_ATRACE_ASYNC_BEGIN), cookie)
86 #define ATRACE_ASYNC_END(name, cookie) meson_atrace(KERNEL_ATRACE_TAG, name, (1 << KERNEL_ATRACE_ASYNC_END), cookie)
87 #else
88 #define ATRACE_COUNTER(name, value)
89 #define ATRACE_BEGIN(name)
90 #define ATRACE_END(name)
91 #define ATRACE_ASYNC_BEGIN(name, cookie)
92 #define ATRACE_ASYNC_END(name, cookie)
93 #endif
94 
95 #endif /* _TRACE_MESON_BASE_H_ */
96 #endif
97 
98 /* This part must be outside protection */
99 #include <trace/define_trace.h>
100