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