1 /* Copyright (c) 2016, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are
5  * met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above
9  *       copyright notice, this list of conditions and the following
10  *       disclaimer in the documentation and/or other materials provided
11  *       with the distribution.
12  *     * Neither the name of The Linux Foundation nor the names of its
13  *       contributors may be used to endorse or promote products derived
14  *       from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef __CAMSCOPE_PACKET_TYPE_H__
31 #define __CAMSCOPE_PACKET_TYPE_H__
32 
33 #include <stdint.h>
34 #include <time.h>
35 
36 #define CAMSCOPE_OFF_FLAG 0x00000000
37 #define CAMSCOPE_ON_FLAG 0xFFFFFFFF
38 #define CAMSCOPE_OFF_MASK 0x00000000
39 #define CAMSCOPE_KPI_MASK 0x00000001
40 #define CAMSCOPE_KPI_DBG_MASK 0x00000002
41 #define CAMSCOPE_ALWAYS_ON_MASK 0xFFFFFFFF
42 
43 extern volatile uint32_t kpi_camscope_flags;
44 extern volatile uint32_t kpi_camscope_frame_count;
45 
46 typedef enum {
47     CAMSCOPE_SECTION_MMCAMERA,
48     CAMSCOPE_SECTION_HAL,
49     CAMSCOPE_SECTION_JPEG,
50     CAMSCOPE_SECTION_SIZE,
51 } camscope_section_type;
52 
53 typedef enum {
54     CAMSCOPE_BASE,
55     CAMSCOPE_SOFTWARE_BASE,
56     CAMSCOPE_SYNC_BEGIN,
57     CAMSCOPE_SYNC_END,
58     CAMSCOPE_ASYNC_BEGIN,
59     CAMSCOPE_ASYNC_END,
60     CAMSCOPE_SYNC_EVENT,
61     CAMSCOPE_ASYNC_EVENT,
62     CAMSCOPE_RESERVED = 0xFFFFFFFF
63 } camscope_packet_type;
64 
65 typedef enum {
66     CAMSCOPE_MCT_SOF,
67     CAMSCOPE_MCT_SUP_PARAMS,
68     CAMSCOPE_MCT_SPEC_EVT,
69     CAMSCOPE_MCT_BUS_PROC,
70     CAMSCOPE_AFD,
71     CAMSCOPE_ASD,
72     CAMSCOPE_AEC,
73     CAMSCOPE_AWB,
74     CAMSCOPE_AF,
75     CAMSCOPE_CPP,
76     CAMSCOPE_CPP_CAPTURE,
77     CAMSCOPE_CPP_CLK_REQ,
78     CAMSCOPE_CPP_HOLDING,
79     CAMSCOPE_CPP_HW_ON,
80     CAMSCOPE_SNAPSHOT,
81     CAMSCOPE_ISP_HW_UPDATE,
82     CAMSCOPE_JPEG,
83     CAMSCOPE_FACEPROC,
84     CAMSCOPE_SENSOR_PROCESS,
85     CAMSCOPE_FD_NUM_DETECTED,
86     CAMSCOPE_CAM_ALLOC,
87     CAMSCOPE_IFACE_STREAMON_FWD,
88     CAMSCOPE_IFACE_STREAMON_THREAD,
89     CAMSCOPE_IFACE_STREAMOFF_FWD,
90     CAMSCOPE_IFACE_STREAMOFF_THREAD,
91     CAMSCOPE_IFACE_CFG_ISP,
92     CAMSCOPE_IFACE_HW_CFG,
93     CAMSCOPE_IFACE_CREATE_AXI_HW,
94     CAMSCOPE_IFACE_CFG_AXI_HW,
95     CAMSCOPE_IFACE_STREAMON,
96     CAMSCOPE_IFACE_STREAMOFF,
97     CAMSCOPE_AF_START,
98     CAMSCOPE_AF_SET,
99     CAMSCOPE_IS,
100     CAMSCOPE_ISP_STREAMON,
101     CAMSCOPE_ISP_STREAMOFF,
102     CAMSCOPE_ISP_SET_STRM_CFG,
103     CAMSCOPE_VFE_HW_UPDATE,
104     CAMSCOPE_ISP_STREAMON_FWD,
105     CAMSCOPE_SENSOR_SD_OPEN,
106     CAMSCOPE_SENSOR_START_SESSION,
107     CAMSCOPE_SENSOR_SET_RESOLUTION,
108     CAMSCOPE_SENSOR_SET_STRM_CFG,
109     CAMSCOPE_SENSOR_CFG_PDAF,
110     CAMSCOPE_SENSOR_LOAD_CHROMATIX,
111     CAMSCOPE_SENSOR_START_STREAM,
112     CAMSCOPE_SENSOR_SET_FPS,
113     CAMSCOPE_SENSOR_STREAMOFF,
114     CAMSCOPE_WNR,
115     CAMSCOPE_WNR_MEMCPY,
116     CAMSCOPE_PPROC_STREAMOFF,
117     CAMSCOPE_CPP_STREAMON,
118     CAMSCOPE_CAC,
119     CAMSCOPE_CPP_CREATE_HW_FRAME,
120     CAMSCOPE_CPP_SET_STRM_CFG,
121     CAMSCOPE_MCT_START_SESSION,
122     CAMSCOPE_MCT_STOP_SESSION,
123     CAMSCOPE_IMGLIB_STREAMON,
124     CAMSCOPE_MCT_CREATE_BUF,
125     CAMSCOPE_HAL1_START_PREVIEW,
126     CAMSCOPE_HAL1_STOP_PREVIEW,
127     CAMSCOPE_HAL1_TAKE_PICTURE,
128     CAMSCOPE_HAL1_CLOSECAMERA,
129     CAMSCOPE_HAL1_OPENCAMERA,
130     CAMSCOPE_HAL1_STARTPREVIEW,
131     CAMSCOPE_HAL1_STOPPREVIEW,
132     CAMSCOPE_HAL1_CAPTURE_CH_CB,
133     CAMSCOPE_HAL1_PREVIEW_STRM_CB,
134     CAMSCOPE_HAL3_SNAPSHOT,
135     CAMSCOPE_HAL3_GETSTREAMBUFS,
136     CAMSCOPE_HAL3_OPENCAMERA,
137     CAMSCOPE_HAL3_CLOSECAMERA,
138     CAMSCOPE_HAL3_FLUSH,
139     CAMSCOPE_HAL1_ZSL_CH_CB,
140     CAMSCOPE_HAL1_PP_CH_CB,
141     CAMSCOPE_HAL1_SYNC_STRM_CB,
142     CAMSCOPE_HAL1_NODIS_PREVIEW_STRMCB,
143     CAMSCOPE_HAL1_RDI_MODE_STRM_CB,
144     CAMSCOPE_HAL1_POSTVIEW_STRM_CB,
145     CAMSCOPE_HAL1_VIDEO_STRM_CB,
146     CAMSCOPE_HAL1_SNAPSHOT_CH_CB,
147     CAMSCOPE_HAL1_RAW_STRM_CB,
148     CAMSCOPE_HAL1_RAW_CH_CB,
149     CAMSCOPE_HAL1_PREVIEW_RAW_STRM_CB,
150     CAMSCOPE_HAL1_SNAPSHOT_RAW_STRM_CB,
151     CAMSCOPE_HAL1_METADATA_STRM_CB,
152     CAMSCOPE_HAL1_REPROC_STRM_CB,
153     CAMSCOPE_HAL1_CB_STRM_CB,
154     CAMSCOPE_HAL1_SET_PREVIEW_WINDOW,
155     CAMSCOPE_HAL1_SET_CALLBACKS,
156     CAMSCOPE_HAL1_ENABLE_MSG_TYPE,
157     CAMSCOPE_HAL1_DISABLE_MSG_TYPE,
158     CAMSCOPE_HAL1_MSG_TYPE_ENABLED,
159     CAMSCOPE_HAL1_PREPARE_PREVIEW,
160     CAMSCOPE_HAL1_PREVIEW_ENABLED,
161     CAMSCOPE_HAL1_RESTART_START_PREVIEW,
162     CAMSCOPE_HAL1_RESTART_STOP_PREVIEW,
163     CAMSCOPE_HAL1_PRE_START_RECORDING,
164     CAMSCOPE_HAL1_START_RECORDING,
165     CAMSCOPE_HAL1_STOP_RECORDING,
166     CAMSCOPE_HAL1_RECORDING_ENABLED,
167     CAMSCOPE_HAL1_REL_REC_FRAME,
168     CAMSCOPE_HAL1_CANCEL_AF,
169     CAMSCOPE_HAL1_PRE_TAKE_PICTURE,
170     CAMSCOPE_HAL1_CANCEL_PICTURE,
171     CAMSCOPE_HAL1_SET_PARAMETERS,
172     CAMSCOPE_HAL1_STOP_AFTER_SET_PARAMS,
173     CAMSCOPE_HAL1_COMMIT_PARAMS,
174     CAMSCOPE_HAL1_RESTART_AFTER_SET_PARAMS,
175     CAMSCOPE_HAL1_GET_PARAMETERS,
176     CAMSCOPE_HAL1_PUT_PARAMETERS,
177     CAMSCOPE_HAL1_SEND_COMMAND,
178     CAMSCOPE_HAL1_SEND_COMMAND_RESTART,
179     CAMSCOPE_HAL1_RELEASE,
180     CAMSCOPE_HAL1_REGISTER_FACE_IMAGE,
181     CAMSCOPE_HAL1_PREPARE_SNAPSHOT,
182     CAMSCOPE_HAL1_QCAMERA2HWI,
183     CAMSCOPE_HAL1_INIT_CAP,
184     CAMSCOPE_HAL1_GET_CAP,
185     CAMSCOPE_HAL1_PREPAREPREVIEW,
186     CAMSCOPE_HAL1_PREPARE_HW_FOR_SNAPSHOT,
187     CAMSCOPE_HAL3_INIT,
188     CAMSCOPE_HAL3_CFG_STRMS,
189     CAMSCOPE_HAL3_CFG_STRMS_PERF_LKD,
190     CAMSCOPE_HAL3_HANDLE_BATCH_METADATA,
191     CAMSCOPE_HAL3_HANDLE_METADATA_LKD,
192     CAMSCOPE_HAL3_HANDLE_IN_BUF_LKD,
193     CAMSCOPE_HAL3_HANDLE_BUF_LKD,
194     CAMSCOPE_HAL3_PROC_CAP_REQ,
195     CAMSCOPE_HAL3_FLUSH_PREF,
196     CAMSCOPE_HAL3_GET_CAM_INFO,
197     CAMSCOPE_HAL3_DYN_UPDATE_META_STRM_INFO,
198     CAMSCOPE_HAL3_CH_START,
199     CAMSCOPE_HAL3_CH_STOP,
200     CAMSCOPE_HAL3_CH_FLUSH,
201     CAMSCOPE_HAL3_PROC_CH_STRM_CB,
202     CAMSCOPE_HAL3_PROC_CH_REG_BUF,
203     CAMSCOPE_HAL3_PROC_CH_REPROC_CB,
204     CAMSCOPE_HAL3_REG_CH_INIT,
205     CAMSCOPE_HAL3_REG_CH_REQ,
206     CAMSCOPE_HAL3_METADATA_CH_INIT,
207     CAMSCOPE_HAL3_RAW_CH_STRM_CB,
208     CAMSCOPE_HAL3_YUV_CH_INIT,
209     CAMSCOPE_HAL3_YUV_CH_STRM_CB,
210     CAMSCOPE_HAL3_PIC_CH_JPEG_EVT_HANDLE,
211     CAMSCOPE_HAL3_PIC_CH_REQ,
212     CAMSCOPE_HAL3_PIC_CH_DATA_NOTIFY_CB,
213     CAMSCOPE_HAL3_PIC_CH_STRM_CB,
214     CAMSCOPE_HAL3_REPROC_CH_REG_BUF,
215     CAMSCOPE_HAL3_REPROC_CH_START,
216     CAMSCOPE_HAL3_REPROC_CH_STOP,
217     CAMSCOPE_HAL3_PPROC_INIT,
218     CAMSCOPE_HAL3_PPROC_INIT_JPEG,
219     CAMSCOPE_HAL3_PPROC_REL_JPEG_JOB_DATA,
220     CAMSCOPE_HAL3_PPROC_REL_PP_JOB_DATA,
221     CAMSCOPE_HAL3_PPROC_ENCODEDATA,
222     CAMSCOPE_HAL3_PREVIEW_STRM_CB,
223     CAMSCOPE_HAL3_STOP_PREVIEW,
224     CAMSCOPE_HAL3_CAPTURE_CH_CB,
225     CAMSCOPE_EVENT_NAME_SIZE
226 } camscope_event_name;
227 
228 extern const char * camscope_atrace_names[CAMSCOPE_EVENT_NAME_SIZE];
229 
230 typedef struct {
231     uint32_t packet_type;
232     uint32_t size;
233 } camscope_base;
234 
235 typedef struct {
236     camscope_base base;
237     struct timeval timestamp;
238     int32_t thread_id;
239     uint32_t event_name;
240 } camscope_sw_base;
241 
242 typedef struct {
243     camscope_sw_base sw_base;
244     uint32_t frame_id;
245 } camscope_timing;
246 
247 typedef struct {
248     camscope_sw_base sw_base;
249     struct timeval in_timestamp;
250     struct timeval out_timestamp;
251     uint32_t frame_id;
252 } camscope_in_out_timing;
253 
254 void camscope_base_log(uint32_t camscope_section,
255                        uint32_t camscope_enable_mask,
256                        uint32_t packet_type);
257 
258 void camscope_sw_base_log(uint32_t camscope_section,
259                           uint32_t camscope_enable_mask, uint32_t packet_type,
260                           uint32_t event_name);
261 
262 void camscope_timing_log(uint32_t camscope_section,
263                          uint32_t camscope_enable_mask, uint32_t packet_type,
264                          uint32_t event_name, uint32_t frame_id);
265 
266 void camscope_in_out_timing_log(uint32_t camscope_section,
267                                 uint32_t camscope_enable_mask,
268                                 uint32_t packet_type, uint32_t event_name,
269                                 struct timeval in_timestamp,
270                                 struct timeval out_timestamp,
271                                 uint32_t frame_id);
272 
273 #endif /* __CAMSCOPE_PACKET_TYPE_H__ */
274