xref: /openbmc/linux/include/drm/drm_debugfs.h (revision 2f164822)
1 /*
2  * Internal Header for the Direct Rendering Manager
3  *
4  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6  * Copyright (c) 2009-2010, Code Aurora Forum.
7  * All rights reserved.
8  *
9  * Author: Rickard E. (Rik) Faith <faith@valinux.com>
10  * Author: Gareth Hughes <gareth@valinux.com>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice (including the next
20  * paragraph) shall be included in all copies or substantial portions of the
21  * Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29  * OTHER DEALINGS IN THE SOFTWARE.
30  */
31 
32 #ifndef _DRM_DEBUGFS_H_
33 #define _DRM_DEBUGFS_H_
34 
35 #include <linux/types.h>
36 #include <linux/seq_file.h>
37 /**
38  * struct drm_info_list - debugfs info list entry
39  *
40  * This structure represents a debugfs file to be created by the drm
41  * core.
42  */
43 struct drm_info_list {
44 	/** @name: file name */
45 	const char *name;
46 	/**
47 	 * @show:
48 	 *
49 	 * Show callback. &seq_file->private will be set to the &struct
50 	 * drm_info_node corresponding to the instance of this info on a given
51 	 * &struct drm_minor.
52 	 */
53 	int (*show)(struct seq_file*, void*);
54 	/** @driver_features: Required driver features for this entry */
55 	u32 driver_features;
56 	/** @data: Driver-private data, should not be device-specific. */
57 	void *data;
58 };
59 
60 /**
61  * struct drm_info_node - Per-minor debugfs node structure
62  *
63  * This structure represents a debugfs file, as an instantiation of a &struct
64  * drm_info_list on a &struct drm_minor.
65  *
66  * FIXME:
67  *
68  * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
69  * both the render and the primary nodes, but that's how this has organically
70  * grown. It should probably be fixed, with a compatibility link, if needed.
71  */
72 struct drm_info_node {
73 	/** @minor: &struct drm_minor for this node. */
74 	struct drm_minor *minor;
75 	/** @info_ent: template for this node. */
76 	const struct drm_info_list *info_ent;
77 	/* private: */
78 	struct list_head list;
79 	struct dentry *dent;
80 };
81 
82 /**
83  * struct drm_debugfs_info - debugfs info list entry
84  *
85  * This structure represents a debugfs file to be created by the drm
86  * core.
87  */
88 struct drm_debugfs_info {
89 	/** @name: File name */
90 	const char *name;
91 
92 	/**
93 	 * @show:
94 	 *
95 	 * Show callback. &seq_file->private will be set to the &struct
96 	 * drm_debugfs_entry corresponding to the instance of this info
97 	 * on a given &struct drm_device.
98 	 */
99 	int (*show)(struct seq_file*, void*);
100 
101 	/** @driver_features: Required driver features for this entry. */
102 	u32 driver_features;
103 
104 	/** @data: Driver-private data, should not be device-specific. */
105 	void *data;
106 };
107 
108 /**
109  * struct drm_debugfs_entry - Per-device debugfs node structure
110  *
111  * This structure represents a debugfs file, as an instantiation of a &struct
112  * drm_debugfs_info on a &struct drm_device.
113  */
114 struct drm_debugfs_entry {
115 	/** @dev: &struct drm_device for this node. */
116 	struct drm_device *dev;
117 
118 	/** @file: Template for this node. */
119 	struct drm_debugfs_info file;
120 
121 	/** @list: Linked list of all device nodes. */
122 	struct list_head list;
123 };
124 
125 #if defined(CONFIG_DEBUG_FS)
126 void drm_debugfs_create_files(const struct drm_info_list *files,
127 			      int count, struct dentry *root,
128 			      struct drm_minor *minor);
129 int drm_debugfs_remove_files(const struct drm_info_list *files,
130 			     int count, struct drm_minor *minor);
131 
132 void drm_debugfs_add_file(struct drm_device *dev, const char *name,
133 			  int (*show)(struct seq_file*, void*), void *data);
134 
135 void drm_debugfs_add_files(struct drm_device *dev,
136 			   const struct drm_debugfs_info *files, int count);
137 #else
138 static inline void drm_debugfs_create_files(const struct drm_info_list *files,
139 					    int count, struct dentry *root,
140 					    struct drm_minor *minor)
141 {}
142 
143 static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
144 					   int count, struct drm_minor *minor)
145 {
146 	return 0;
147 }
148 
149 static inline void drm_debugfs_add_file(struct drm_device *dev, const char *name,
150 					int (*show)(struct seq_file*, void*),
151 					void *data)
152 {}
153 
154 static inline void drm_debugfs_add_files(struct drm_device *dev,
155 					 const struct drm_debugfs_info *files,
156 					 int count)
157 {}
158 #endif
159 
160 #endif /* _DRM_DEBUGFS_H_ */
161