Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 *  Copyright © 2014 Broadcom
 4 */
 5
 6#include <drm/drm_drv.h>
 7
 8#include <linux/seq_file.h>
 9#include <linux/circ_buf.h>
10#include <linux/ctype.h>
11#include <linux/debugfs.h>
12#include <linux/platform_device.h>
13
14#include "vc4_drv.h"
15#include "vc4_regs.h"
16
17/*
 
 
 
 
 
18 * Called at drm_dev_register() time on each of the minors registered
19 * by the DRM device, to attach the debugfs files.
20 */
21void
22vc4_debugfs_init(struct drm_minor *minor)
23{
24	struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
25	struct drm_device *drm = &vc4->base;
26
27	drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));
 
28
29	if (vc4->v3d) {
30		drm_WARN_ON(drm, vc4_bo_debugfs_init(minor));
31		drm_WARN_ON(drm, vc4_v3d_debugfs_init(minor));
 
 
 
32	}
 
 
33}
34
35static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
36{
37	struct drm_debugfs_entry *entry = m->private;
38	struct drm_device *drm = entry->dev;
39	struct debugfs_regset32 *regset = entry->file.data;
40	struct drm_printer p = drm_seq_file_printer(m);
41	int idx;
42
43	if (!drm_dev_enter(drm, &idx))
44		return -ENODEV;
45
46	drm_print_regset32(&p, regset);
47
48	drm_dev_exit(idx);
49
50	return 0;
51}
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53void vc4_debugfs_add_regset32(struct drm_device *drm,
54			      const char *name,
55			      struct debugfs_regset32 *regset)
56{
57	drm_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
58}
v5.4
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 *  Copyright © 2014 Broadcom
 4 */
 5
 
 
 6#include <linux/seq_file.h>
 7#include <linux/circ_buf.h>
 8#include <linux/ctype.h>
 9#include <linux/debugfs.h>
 
10
11#include "vc4_drv.h"
12#include "vc4_regs.h"
13
14struct vc4_debugfs_info_entry {
15	struct list_head link;
16	struct drm_info_list info;
17};
18
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 */
23int
24vc4_debugfs_init(struct drm_minor *minor)
25{
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		int ret = drm_debugfs_create_files(&entry->info, 1,
34						   minor->debugfs_root, minor);
35
36		if (ret)
37			return ret;
38	}
39
40	return 0;
41}
42
43static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
44{
45	struct drm_info_node *node = (struct drm_info_node *)m->private;
46	struct debugfs_regset32 *regset = node->info_ent->data;
 
47	struct drm_printer p = drm_seq_file_printer(m);
 
 
 
 
48
49	drm_print_regset32(&p, regset);
50
 
 
51	return 0;
52}
53
54/**
55 * Registers a debugfs file with a callback function for a vc4 component.
56 *
57 * This is like drm_debugfs_create_files(), but that can only be
58 * called a given DRM minor, while the various VC4 components want to
59 * register their debugfs files during the component bind process.  We
60 * track the request and delay it to be called on each minor during
61 * vc4_debugfs_init().
62 */
63void vc4_debugfs_add_file(struct drm_device *dev,
64			  const char *name,
65			  int (*show)(struct seq_file*, void*),
66			  void *data)
67{
68	struct vc4_dev *vc4 = to_vc4_dev(dev);
69
70	struct vc4_debugfs_info_entry *entry =
71		devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL);
72
73	if (!entry)
74		return;
75
76	entry->info.name = name;
77	entry->info.show = show;
78	entry->info.data = data;
79
80	list_add(&entry->link, &vc4->debugfs_list);
81}
82
83void vc4_debugfs_add_regset32(struct drm_device *drm,
84			      const char *name,
85			      struct debugfs_regset32 *regset)
86{
87	vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
88}