Commit | Line | Data |
---|---|---|
c8b75bca EA |
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 | #include <drm/drmP.h> | |
14 | ||
15 | #include "vc4_drv.h" | |
16 | #include "vc4_regs.h" | |
17 | ||
c9be804c EA |
18 | struct vc4_debugfs_info_entry { |
19 | struct list_head link; | |
20 | struct drm_info_list info; | |
c8b75bca EA |
21 | }; |
22 | ||
c9be804c EA |
23 | /** |
24 | * Called at drm_dev_register() time on each of the minors registered | |
25 | * by the DRM device, to attach the debugfs files. | |
26 | */ | |
c8b75bca EA |
27 | int |
28 | vc4_debugfs_init(struct drm_minor *minor) | |
29 | { | |
6b5c029d | 30 | struct vc4_dev *vc4 = to_vc4_dev(minor->dev); |
c9be804c | 31 | struct vc4_debugfs_info_entry *entry; |
6b5c029d PK |
32 | struct dentry *dentry; |
33 | ||
34 | dentry = debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR, | |
35 | minor->debugfs_root, | |
36 | &vc4->load_tracker_enabled); | |
37 | if (!dentry) | |
38 | return -ENOMEM; | |
39 | ||
c9be804c EA |
40 | list_for_each_entry(entry, &vc4->debugfs_list, link) { |
41 | int ret = drm_debugfs_create_files(&entry->info, 1, | |
42 | minor->debugfs_root, minor); | |
43 | ||
44 | if (ret) | |
45 | return ret; | |
46 | } | |
47 | ||
48 | return 0; | |
49 | } | |
50 | ||
e31b97ef | 51 | static int vc4_debugfs_regset32(struct seq_file *m, void *unused) |
c9be804c EA |
52 | { |
53 | struct drm_info_node *node = (struct drm_info_node *)m->private; | |
54 | struct debugfs_regset32 *regset = node->info_ent->data; | |
55 | struct drm_printer p = drm_seq_file_printer(m); | |
56 | ||
57 | drm_print_regset32(&p, regset); | |
58 | ||
59 | return 0; | |
60 | } | |
61 | ||
62 | /** | |
63 | * Registers a debugfs file with a callback function for a vc4 component. | |
64 | * | |
65 | * This is like drm_debugfs_create_files(), but that can only be | |
66 | * called a given DRM minor, while the various VC4 components want to | |
67 | * register their debugfs files during the component bind process. We | |
68 | * track the request and delay it to be called on each minor during | |
69 | * vc4_debugfs_init(). | |
70 | */ | |
71 | void vc4_debugfs_add_file(struct drm_device *dev, | |
72 | const char *name, | |
73 | int (*show)(struct seq_file*, void*), | |
74 | void *data) | |
75 | { | |
76 | struct vc4_dev *vc4 = to_vc4_dev(dev); | |
77 | ||
78 | struct vc4_debugfs_info_entry *entry = | |
79 | devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL); | |
80 | ||
81 | if (!entry) | |
82 | return; | |
83 | ||
84 | entry->info.name = name; | |
85 | entry->info.show = show; | |
86 | entry->info.data = data; | |
87 | ||
88 | list_add(&entry->link, &vc4->debugfs_list); | |
89 | } | |
90 | ||
91 | void vc4_debugfs_add_regset32(struct drm_device *drm, | |
92 | const char *name, | |
93 | struct debugfs_regset32 *regset) | |
94 | { | |
95 | vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset); | |
c8b75bca | 96 | } |