3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-02-12 10:15:54 +00:00
Brooklyn/drivers/gpu/drm/vc4/vc4_debugfs.c

81 lines
1.8 KiB
C
Raw Normal View History

2022-04-02 18:12:00 +05:00
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright © 2014 Broadcom
*/
2022-09-13 23:14:27 +05:00
#include <drm/drm_drv.h>
2022-04-02 18:12:00 +05:00
#include <linux/seq_file.h>
#include <linux/circ_buf.h>
#include <linux/ctype.h>
#include <linux/debugfs.h>
#include <linux/platform_device.h>
#include "vc4_drv.h"
#include "vc4_regs.h"
/*
* Called at drm_dev_register() time on each of the minors registered
* by the DRM device, to attach the debugfs files.
*/
void
vc4_debugfs_init(struct drm_minor *minor)
{
struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
2022-09-13 23:14:27 +05:00
struct drm_device *drm = &vc4->base;
2022-04-02 18:12:00 +05:00
2022-09-13 23:14:27 +05:00
drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));
2022-04-02 18:12:00 +05:00
2022-09-13 23:14:27 +05:00
if (vc4->v3d) {
drm_WARN_ON(drm, vc4_bo_debugfs_init(minor));
drm_WARN_ON(drm, vc4_v3d_debugfs_init(minor));
2022-04-02 18:12:00 +05:00
}
}
static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
{
struct drm_info_node *node = (struct drm_info_node *)m->private;
2022-09-13 23:14:27 +05:00
struct drm_device *drm = node->minor->dev;
2022-04-02 18:12:00 +05:00
struct debugfs_regset32 *regset = node->info_ent->data;
struct drm_printer p = drm_seq_file_printer(m);
2022-09-13 23:14:27 +05:00
int idx;
if (!drm_dev_enter(drm, &idx))
return -ENODEV;
2022-04-02 18:12:00 +05:00
drm_print_regset32(&p, regset);
2022-09-13 23:14:27 +05:00
drm_dev_exit(idx);
2022-04-02 18:12:00 +05:00
return 0;
}
2022-09-13 23:14:27 +05:00
int vc4_debugfs_add_file(struct drm_minor *minor,
const char *name,
int (*show)(struct seq_file*, void*),
void *data)
2022-04-02 18:12:00 +05:00
{
2022-09-13 23:14:27 +05:00
struct drm_device *dev = minor->dev;
struct dentry *root = minor->debugfs_root;
struct drm_info_list *file;
2022-04-02 18:12:00 +05:00
2022-09-13 23:14:27 +05:00
file = drmm_kzalloc(dev, sizeof(*file), GFP_KERNEL);
if (!file)
return -ENOMEM;
2022-04-02 18:12:00 +05:00
2022-09-13 23:14:27 +05:00
file->name = name;
file->show = show;
file->data = data;
2022-04-02 18:12:00 +05:00
2022-09-13 23:14:27 +05:00
drm_debugfs_create_files(file, 1, root, minor);
2022-04-02 18:12:00 +05:00
2022-09-13 23:14:27 +05:00
return 0;
2022-04-02 18:12:00 +05:00
}
2022-09-13 23:14:27 +05:00
int vc4_debugfs_add_regset32(struct drm_minor *minor,
const char *name,
struct debugfs_regset32 *regset)
2022-04-02 18:12:00 +05:00
{
2022-09-13 23:14:27 +05:00
return vc4_debugfs_add_file(minor, name, vc4_debugfs_regset32, regset);
2022-04-02 18:12:00 +05:00
}