drm/bridge: move bridges_show logic from drm_debugfs.c

In preparation to expose more info about bridges in debugfs, which will
require more insight into drm_bridge data structures, move the bridges_show
code to drm_bridge.c.

Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250226-drm-debugfs-show-all-bridges-v8-1-bb511cc49d83@bootlin.com
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
This commit is contained in:
Luca Ceresoli 2025-02-26 22:23:52 +01:00 committed by Louis Chauvet
parent 6374a1005f
commit 9497c5a0f7
No known key found for this signature in database
GPG key ID: 20AD2EC65B102CE2
3 changed files with 45 additions and 37 deletions

View file

@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/media-bus-format.h>
#include <linux/module.h>
@ -1300,6 +1301,47 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np)
EXPORT_SYMBOL(of_drm_find_bridge);
#endif
static int encoder_bridges_show(struct seq_file *m, void *data)
{
struct drm_encoder *encoder = m->private;
struct drm_printer p = drm_seq_file_printer(m);
struct drm_bridge *bridge;
unsigned int idx = 0;
drm_for_each_bridge_in_chain(encoder, bridge) {
drm_printf(&p, "bridge[%u]: %ps\n", idx++, bridge->funcs);
drm_printf(&p, "\ttype: [%d] %s\n",
bridge->type,
drm_get_connector_type_name(bridge->type));
if (bridge->of_node)
drm_printf(&p, "\tOF: %pOFfc\n", bridge->of_node);
drm_printf(&p, "\tops: [0x%x]", bridge->ops);
if (bridge->ops & DRM_BRIDGE_OP_DETECT)
drm_puts(&p, " detect");
if (bridge->ops & DRM_BRIDGE_OP_EDID)
drm_puts(&p, " edid");
if (bridge->ops & DRM_BRIDGE_OP_HPD)
drm_puts(&p, " hpd");
if (bridge->ops & DRM_BRIDGE_OP_MODES)
drm_puts(&p, " modes");
if (bridge->ops & DRM_BRIDGE_OP_HDMI)
drm_puts(&p, " hdmi");
drm_puts(&p, "\n");
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(encoder_bridges);
void drm_bridge_debugfs_encoder_params(struct dentry *root,
struct drm_encoder *encoder)
{
/* bridges list */
debugfs_create_file("bridges", 0444, root, encoder, &encoder_bridges_fops);
}
MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>");
MODULE_DESCRIPTION("DRM bridge infrastructure");
MODULE_LICENSE("GPL and additional rights");

View file

@ -740,40 +740,6 @@ void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
crtc->debugfs_entry = NULL;
}
static int bridges_show(struct seq_file *m, void *data)
{
struct drm_encoder *encoder = m->private;
struct drm_printer p = drm_seq_file_printer(m);
struct drm_bridge *bridge;
unsigned int idx = 0;
drm_for_each_bridge_in_chain(encoder, bridge) {
drm_printf(&p, "bridge[%u]: %ps\n", idx++, bridge->funcs);
drm_printf(&p, "\ttype: [%d] %s\n",
bridge->type,
drm_get_connector_type_name(bridge->type));
if (bridge->of_node)
drm_printf(&p, "\tOF: %pOFfc\n", bridge->of_node);
drm_printf(&p, "\tops: [0x%x]", bridge->ops);
if (bridge->ops & DRM_BRIDGE_OP_DETECT)
drm_puts(&p, " detect");
if (bridge->ops & DRM_BRIDGE_OP_EDID)
drm_puts(&p, " edid");
if (bridge->ops & DRM_BRIDGE_OP_HPD)
drm_puts(&p, " hpd");
if (bridge->ops & DRM_BRIDGE_OP_MODES)
drm_puts(&p, " modes");
if (bridge->ops & DRM_BRIDGE_OP_HDMI)
drm_puts(&p, " hdmi");
drm_puts(&p, "\n");
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(bridges);
void drm_debugfs_encoder_add(struct drm_encoder *encoder)
{
struct drm_minor *minor = encoder->dev->primary;
@ -789,9 +755,7 @@ void drm_debugfs_encoder_add(struct drm_encoder *encoder)
encoder->debugfs_entry = root;
/* bridges list */
debugfs_create_file("bridges", 0444, root, encoder,
&bridges_fops);
drm_bridge_debugfs_encoder_params(root, encoder);
if (encoder->funcs && encoder->funcs->debugfs_init)
encoder->funcs->debugfs_init(encoder, root);

View file

@ -1108,4 +1108,6 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,
}
#endif
void drm_bridge_debugfs_encoder_params(struct dentry *root, struct drm_encoder *encoder);
#endif