xref: /OK3568_Linux_fs/kernel/drivers/video/rockchip/rga3/include/rga_debugger.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) Rockchip Electronics Co., Ltd.
4  *
5  * Author:
6  *	Cerf Yu <cerf.yu@rock-chips.com>
7  *	Huang Lee <Putin.li@rock-chips.com>
8  */
9 
10 #ifndef _RGA_DEBUGGER_H_
11 #define _RGA_DEBUGGER_H_
12 
13 #include "rga_drv.h"
14 
15 #ifdef CONFIG_ROCKCHIP_RGA_DEBUGGER
16 
17 extern int RGA_DEBUG_REG;
18 extern int RGA_DEBUG_MSG;
19 extern int RGA_DEBUG_TIME;
20 extern int RGA_DEBUG_INT_FLAG;
21 extern int RGA_DEBUG_MM;
22 extern int RGA_DEBUG_CHECK_MODE;
23 extern int RGA_DEBUG_NONUSE;
24 extern int RGA_DEBUG_DUMP_IMAGE;
25 
26 #define DEBUGGER_EN(name) (unlikely(RGA_DEBUG_##name ? true : false))
27 
28 /*
29  * struct rga_debugger - RGA debugger information
30  *
31  * This structure represents a debugger to be created by the rga driver
32  * or core.
33  */
34 struct rga_debugger {
35 #ifdef CONFIG_ROCKCHIP_RGA_DEBUG_FS
36 	/* Directory of debugfs file */
37 	struct dentry *debugfs_dir;
38 	struct list_head debugfs_entry_list;
39 	struct mutex debugfs_lock;
40 #endif
41 
42 #ifdef CONFIG_ROCKCHIP_RGA_PROC_FS
43 	/* Directory of procfs file */
44 	struct proc_dir_entry *procfs_dir;
45 	struct list_head procfs_entry_list;
46 	struct mutex procfs_lock;
47 #endif
48 };
49 
50 /*
51  * struct rga_debugger_list - debugfs/procfs info list entry
52  *
53  * This structure represents a debugfs/procfs file to be created by the rga
54  * driver or core.
55  */
56 struct rga_debugger_list {
57 	/* File name */
58 	const char *name;
59 	/*
60 	 * Show callback. &seq_file->private will be set to the &struct
61 	 * rga_debugger_node corresponding to the instance of this info
62 	 * on a given &struct rga_debugger.
63 	 */
64 	int (*show)(struct seq_file *seq, void *data);
65 	/*
66 	 * Write callback. &seq_file->private will be set to the &struct
67 	 * rga_debugger_node corresponding to the instance of this info
68 	 * on a given &struct rga_debugger.
69 	 */
70 	ssize_t (*write)(struct file *file, const char __user *ubuf,
71 		size_t len, loff_t *offp);
72 	/* Procfs/Debugfs private data. */
73 	void *data;
74 };
75 
76 /*
77  * struct rga_debugger_node - Nodes for debugfs/procfs
78  *
79  * This structure represents each instance of procfs/debugfs created from the
80  * template.
81  */
82 struct rga_debugger_node {
83 	struct rga_debugger *debugger;
84 
85 	/* template for this node. */
86 	const struct rga_debugger_list *info_ent;
87 
88 	/* Each Procfs/Debugfs file. */
89 #ifdef CONFIG_ROCKCHIP_RGA_DEBUG_FS
90 	struct dentry *dent;
91 #endif
92 
93 #ifdef CONFIG_ROCKCHIP_RGA_PROC_FS
94 	struct proc_dir_entry *pent;
95 #endif
96 
97 	struct list_head list;
98 };
99 
100 #ifdef CONFIG_ROCKCHIP_RGA_DEBUG_FS
101 int rga_debugfs_init(void);
102 int rga_debugfs_remove(void);
103 #else
rga_debugfs_remove(void)104 static inline int rga_debugfs_remove(void)
105 {
106 	return 0;
107 }
rga_debugfs_init(void)108 static inline int rga_debugfs_init(void)
109 {
110 	return 0;
111 }
112 #endif /* #ifdef CONFIG_ROCKCHIP_RGA_DEBUG_FS */
113 
114 #ifdef CONFIG_ROCKCHIP_RGA_PROC_FS
115 int rga_procfs_remove(void);
116 int rga_procfs_init(void);
117 #else
rga_procfs_remove(void)118 static inline int rga_procfs_remove(void)
119 {
120 	return 0;
121 }
rga_procfs_init(void)122 static inline int rga_procfs_init(void)
123 {
124 	return 0;
125 }
126 #endif /* #ifdef CONFIG_ROCKCHIP_RGA_PROC_FS */
127 
128 #else
129 
130 #define DEBUGGER_EN(name) (unlikely(false))
131 
132 #endif /* #ifdef CONFIG_ROCKCHIP_RGA_DEBUGGER */
133 
134 void rga_cmd_print_debug_info(struct rga_req *req);
135 void rga_request_task_debug_info(struct seq_file *m, struct rga_req *req);
136 #ifdef CONFIG_NO_GKI
137 void rga_dump_job_image(struct rga_job *dump_job);
138 #else
rga_dump_job_image(struct rga_job * dump_job)139 static inline void rga_dump_job_image(struct rga_job *dump_job)
140 {
141 }
142 #endif /* #ifdef CONFIG_NO_GKI */
143 
144 #endif /* #ifndef _RGA_DEBUGGER_H_ */
145 
146