]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/gpu/drm/vc4/vc4_debugfs.c
drm/vc4: drop use of drmP.h
[linux.git] / drivers / gpu / drm / vc4 / vc4_debugfs.c
1 /*
2  *  Copyright © 2014 Broadcom
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #include <linux/seq_file.h>
10 #include <linux/circ_buf.h>
11 #include <linux/ctype.h>
12 #include <linux/debugfs.h>
13
14 #include "vc4_drv.h"
15 #include "vc4_regs.h"
16
17 struct vc4_debugfs_info_entry {
18         struct list_head link;
19         struct drm_info_list info;
20 };
21
22 /**
23  * Called at drm_dev_register() time on each of the minors registered
24  * by the DRM device, to attach the debugfs files.
25  */
26 int
27 vc4_debugfs_init(struct drm_minor *minor)
28 {
29         struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
30         struct vc4_debugfs_info_entry *entry;
31
32         debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
33                             minor->debugfs_root, &vc4->load_tracker_enabled);
34
35         list_for_each_entry(entry, &vc4->debugfs_list, link) {
36                 int ret = drm_debugfs_create_files(&entry->info, 1,
37                                                    minor->debugfs_root, minor);
38
39                 if (ret)
40                         return ret;
41         }
42
43         return 0;
44 }
45
46 static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
47 {
48         struct drm_info_node *node = (struct drm_info_node *)m->private;
49         struct debugfs_regset32 *regset = node->info_ent->data;
50         struct drm_printer p = drm_seq_file_printer(m);
51
52         drm_print_regset32(&p, regset);
53
54         return 0;
55 }
56
57 /**
58  * Registers a debugfs file with a callback function for a vc4 component.
59  *
60  * This is like drm_debugfs_create_files(), but that can only be
61  * called a given DRM minor, while the various VC4 components want to
62  * register their debugfs files during the component bind process.  We
63  * track the request and delay it to be called on each minor during
64  * vc4_debugfs_init().
65  */
66 void vc4_debugfs_add_file(struct drm_device *dev,
67                           const char *name,
68                           int (*show)(struct seq_file*, void*),
69                           void *data)
70 {
71         struct vc4_dev *vc4 = to_vc4_dev(dev);
72
73         struct vc4_debugfs_info_entry *entry =
74                 devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL);
75
76         if (!entry)
77                 return;
78
79         entry->info.name = name;
80         entry->info.show = show;
81         entry->info.data = data;
82
83         list_add(&entry->link, &vc4->debugfs_list);
84 }
85
86 void vc4_debugfs_add_regset32(struct drm_device *drm,
87                               const char *name,
88                               struct debugfs_regset32 *regset)
89 {
90         vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
91 }