forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/vc4/vc4_debugfs.c
....@@ -1,40 +1,83 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * 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.
74 */
85
96 #include <linux/seq_file.h>
107 #include <linux/circ_buf.h>
118 #include <linux/ctype.h>
129 #include <linux/debugfs.h>
13
-#include <drm/drmP.h>
1410
1511 #include "vc4_drv.h"
1612 #include "vc4_regs.h"
1713
18
-static const struct drm_info_list vc4_debugfs_list[] = {
19
- {"bo_stats", vc4_bo_stats_debugfs, 0},
20
- {"dpi_regs", vc4_dpi_debugfs_regs, 0},
21
- {"dsi1_regs", vc4_dsi_debugfs_regs, 0, (void *)(uintptr_t)1},
22
- {"hdmi_regs", vc4_hdmi_debugfs_regs, 0},
23
- {"vec_regs", vc4_vec_debugfs_regs, 0},
24
- {"txp_regs", vc4_txp_debugfs_regs, 0},
25
- {"hvs_regs", vc4_hvs_debugfs_regs, 0},
26
- {"crtc0_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)0},
27
- {"crtc1_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)1},
28
- {"crtc2_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)2},
29
- {"v3d_ident", vc4_v3d_debugfs_ident, 0},
30
- {"v3d_regs", vc4_v3d_debugfs_regs, 0},
14
+struct vc4_debugfs_info_entry {
15
+ struct list_head link;
16
+ struct drm_info_list info;
3117 };
3218
33
-#define VC4_DEBUGFS_ENTRIES ARRAY_SIZE(vc4_debugfs_list)
34
-
35
-int
19
+/**
20
+ * Called at drm_dev_register() time on each of the minors registered
21
+ * by the DRM device, to attach the debugfs files.
22
+ */
23
+void
3624 vc4_debugfs_init(struct drm_minor *minor)
3725 {
38
- return drm_debugfs_create_files(vc4_debugfs_list, VC4_DEBUGFS_ENTRIES,
39
- minor->debugfs_root, minor);
26
+ struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
27
+ struct vc4_debugfs_info_entry *entry;
28
+
29
+ debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
30
+ minor->debugfs_root, &vc4->load_tracker_enabled);
31
+
32
+ list_for_each_entry(entry, &vc4->debugfs_list, link) {
33
+ drm_debugfs_create_files(&entry->info, 1,
34
+ minor->debugfs_root, minor);
35
+ }
36
+}
37
+
38
+static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
39
+{
40
+ struct drm_info_node *node = (struct drm_info_node *)m->private;
41
+ struct debugfs_regset32 *regset = node->info_ent->data;
42
+ struct drm_printer p = drm_seq_file_printer(m);
43
+
44
+ drm_print_regset32(&p, regset);
45
+
46
+ return 0;
47
+}
48
+
49
+/**
50
+ * Registers a debugfs file with a callback function for a vc4 component.
51
+ *
52
+ * This is like drm_debugfs_create_files(), but that can only be
53
+ * called a given DRM minor, while the various VC4 components want to
54
+ * register their debugfs files during the component bind process. We
55
+ * track the request and delay it to be called on each minor during
56
+ * vc4_debugfs_init().
57
+ */
58
+void vc4_debugfs_add_file(struct drm_device *dev,
59
+ const char *name,
60
+ int (*show)(struct seq_file*, void*),
61
+ void *data)
62
+{
63
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
64
+
65
+ struct vc4_debugfs_info_entry *entry =
66
+ devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL);
67
+
68
+ if (!entry)
69
+ return;
70
+
71
+ entry->info.name = name;
72
+ entry->info.show = show;
73
+ entry->info.data = data;
74
+
75
+ list_add(&entry->link, &vc4->debugfs_list);
76
+}
77
+
78
+void vc4_debugfs_add_regset32(struct drm_device *drm,
79
+ const char *name,
80
+ struct debugfs_regset32 *regset)
81
+{
82
+ vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
4083 }