| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Copyright 2022 Collabora Ltd. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef TRACE_H |
| 7 |
#define TRACE_H |
| 8 |
|
| 9 |
#include "v4l2-tracer-common.h" |
| 10 |
#include "trace-gen.h" |
| 11 |
|
| 12 |
struct buffer_trace { |
| 13 |
int fd; |
| 14 |
__u32 type; |
| 15 |
__u32 index; |
| 16 |
__u32 offset; |
| 17 |
__u32 bytesused; |
| 18 |
long display_order; |
| 19 |
unsigned long address; |
| 20 |
}; |
| 21 |
|
| 22 |
struct h264_info { |
| 23 |
int pic_order_cnt_lsb; |
| 24 |
int max_pic_order_cnt_lsb; |
| 25 |
}; |
| 26 |
|
| 27 |
struct trace_context { |
| 28 |
__u32 elems; |
| 29 |
__u32 width; |
| 30 |
__u32 height; |
| 31 |
FILE *trace_file; |
| 32 |
__u32 pixelformat; |
| 33 |
std::string media_device; |
| 34 |
__u32 compression_format; |
| 35 |
union { |
| 36 |
struct h264_info h264; |
| 37 |
} fmt; |
| 38 |
std::string trace_filename; |
| 39 |
std::list<long> decode_order; |
| 40 |
std::list<struct buffer_trace> buffers; |
| 41 |
std::unordered_map<int, std::string> devices; /* key:fd, value: path of the device */ |
| 42 |
}; |
| 43 |
|
| 44 |
void trace_open(int fd, const char *path, int oflag, mode_t mode, bool is_open64); |
| 45 |
void trace_mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off, unsigned long buf_address, bool is_mmap64); |
| 46 |
void trace_mem(int fd, __u32 offset, __u32 type, int index, __u32 bytesused, unsigned long start); |
| 47 |
void trace_mem_encoded(int fd, __u32 offset); |
| 48 |
void trace_mem_decoded(void); |
| 49 |
json_object *trace_ioctl_args(unsigned long cmd, void *arg); |
| 50 |
|
| 51 |
bool is_video_or_media_device(const char *path); |
| 52 |
void add_device(int fd, std::string path); |
| 53 |
std::string get_device(int fd); |
| 54 |
void print_devices(void); |
| 55 |
bool buffer_in_trace_context(int fd, __u32 offset = 0); |
| 56 |
__u32 get_buffer_type_trace(int fd, __u32 offset = 0); |
| 57 |
int get_buffer_index_trace(int fd, __u32 offset); |
| 58 |
long get_buffer_bytesused_trace(int fd, __u32 offset); |
| 59 |
void set_buffer_address_trace(int fd, __u32 offset, unsigned long address); |
| 60 |
unsigned long get_buffer_address_trace(int fd, __u32 offset); |
| 61 |
bool buffer_is_mapped(unsigned long buffer_address); |
| 62 |
unsigned get_expected_length_trace(void); |
| 63 |
void s_ext_ctrls_setup(struct v4l2_ext_controls *ext_controls); |
| 64 |
void qbuf_setup(struct v4l2_buffer *buf); |
| 65 |
void dqbuf_setup(struct v4l2_buffer *buf); |
| 66 |
void streamoff_cleanup(v4l2_buf_type buf_type); |
| 67 |
void g_fmt_setup_trace(struct v4l2_format *format); |
| 68 |
void s_fmt_setup(struct v4l2_format *format); |
| 69 |
void expbuf_setup(struct v4l2_exportbuffer *export_buffer); |
| 70 |
void querybuf_setup(int fd, struct v4l2_buffer *buf); |
| 71 |
void query_ext_ctrl_setup(int fd, struct v4l2_query_ext_ctrl *ptr); |
| 72 |
void write_json_object_to_json_file(json_object *jobj); |
| 73 |
void close_json_file(void); |
| 74 |
|
| 75 |
#endif |