tools/displaytop: Series to add Display Top tool
v2 cover tools/displaytop: Series to add Display Top tool
This patch series introduces the Display Top tool — a terminal-based monitoring utility focused on the display pipeline.
Display Top reads real-time display metrics from debugfs, DPCD registers, and ftrace logs to help developers and testers analyze display behavior, bottlenecks, and event sequences.
The series adds:
- A curses-based terminal UI tool
- A debugfs entry to expose display pipeline stats
- DPCD register read integration
- Basic ftrace parsing support
- Provides the ability to dump data for all of the above features
v2:
- Rebased the patch series on top of the latest IGT
- Fixed coding style and formatting improvements
Adith Narein T (4):
tools/displaytop: Add Display Top - a terminal-based display pipeline
monitor
tools/displaytop: Add Display debugfs entry for display top tools/displaytop: Add DPCD register read support tools/displaytop: Add ftrace support to Display Top
tools/displaytop/README.md | 81 + tools/displaytop/data/dpcd.json | 4661 +++++++++++++++++ tools/displaytop/include/data.h | 53 + tools/displaytop/include/display.h | 55 + tools/displaytop/include/log.h | 49 + tools/displaytop/include/node.h | 127 + tools/displaytop/include/populate.h | 41 + tools/displaytop/include/utils.h | 136 + tools/displaytop/meson.build | 118 + tools/displaytop/src/data.c | 43 + tools/displaytop/src/display.c | 418 ++ tools/displaytop/src/display_DPCD.c | 252 + tools/displaytop/src/display_configuration.c | 803 +++ tools/displaytop/src/display_debugfs.c | 124 + tools/displaytop/src/display_dump.c | 199 + tools/displaytop/src/display_dump_tracing.c | 133 + tools/displaytop/src/display_filter_tracing.c | 305 ++ tools/displaytop/src/display_ftrace.c | 98 + tools/displaytop/src/display_live_tracing.c | 115 + tools/displaytop/src/display_search_bar.c | 268 + tools/displaytop/src/display_summary.c | 279 + tools/displaytop/src/log.c | 81 + tools/displaytop/src/main.c | 64 + tools/displaytop/src/node.c | 128 + tools/displaytop/src/populate.c | 35 + tools/displaytop/src/populate_DPCD.c | 233 + .../displaytop/src/populate_display_config.c | 271 + .../displaytop/src/populate_display_debugfs.c | 96 + tools/displaytop/src/populate_ftrace.c | 71 + tools/displaytop/src/utils.c | 163 + tools/displaytop/src/utils_cli.c | 65 + tools/displaytop/src/utils_display.c | 195 + tools/displaytop/src/utils_driver.c | 186 + tools/displaytop/src/utils_drm.c | 579 ++ tools/displaytop/src/utils_registers.c | 88 + tools/displaytop/src/utils_search.c | 43 + tools/displaytop/src/utils_trace.c | 61 + tools/meson.build | 1 + 38 files changed, 10718 insertions(+) create mode 100644 tools/displaytop/README.md create mode 100644 tools/displaytop/data/dpcd.json create mode 100644 tools/displaytop/include/data.h create mode 100644 tools/displaytop/include/display.h create mode 100644 tools/displaytop/include/log.h create mode 100644 tools/displaytop/include/node.h create mode 100644 tools/displaytop/include/populate.h create mode 100644 tools/displaytop/include/utils.h create mode 100644 tools/displaytop/meson.build create mode 100644 tools/displaytop/src/data.c create mode 100644 tools/displaytop/src/display.c create mode 100644 tools/displaytop/src/display_DPCD.c create mode 100644 tools/displaytop/src/display_configuration.c create mode 100644 tools/displaytop/src/display_debugfs.c create mode 100644 tools/displaytop/src/display_dump.c create mode 100644 tools/displaytop/src/display_dump_tracing.c create mode 100644 tools/displaytop/src/display_filter_tracing.c create mode 100644 tools/displaytop/src/display_ftrace.c create mode 100644 tools/displaytop/src/display_live_tracing.c create mode 100644 tools/displaytop/src/display_search_bar.c create mode 100644 tools/displaytop/src/display_summary.c create mode 100644 tools/displaytop/src/log.c create mode 100644 tools/displaytop/src/main.c create mode 100644 tools/displaytop/src/node.c create mode 100644 tools/displaytop/src/populate.c create mode 100644 tools/displaytop/src/populate_DPCD.c create mode 100644 tools/displaytop/src/populate_display_config.c create mode 100644 tools/displaytop/src/populate_display_debugfs.c create mode 100644 tools/displaytop/src/populate_ftrace.c create mode 100644 tools/displaytop/src/utils.c create mode 100644 tools/displaytop/src/utils_cli.c create mode 100644 tools/displaytop/src/utils_display.c create mode 100644 tools/displaytop/src/utils_driver.c create mode 100644 tools/displaytop/src/utils_drm.c create mode 100644 tools/displaytop/src/utils_registers.c create mode 100644 tools/displaytop/src/utils_search.c create mode 100644 tools/displaytop/src/utils_trace.c
Signature · 1 line
2.34.1
PATCH v2 1/4 tools/displaytop: Add Display Top - a terminal-based display pipeline monitor
From: Adith Narein T <[email protected]>
This patch introduces displaytop, a terminal-based tool designed for monitoring and debugging the display pipeline in real time. The initial feature focuses on providing detailed display configuration information, including:
- CRTCs
- Connectors
- Encoders
- Planes
- Framebuffers
These components are presented in an organized format using a terminal UI built with ncurses, giving developers and validation engineers a fast and accessible way to inspect the current state of the display system.
--- tools/displaytop/README.md | 77 ++ tools/displaytop/include/data.h | 38 + tools/displaytop/include/display.h | 47 + tools/displaytop/include/log.h | 49 ++ tools/displaytop/include/node.h | 127 +++ tools/displaytop/include/populate.h | 38 + tools/displaytop/include/utils.h | 125 +++ tools/displaytop/meson.build | 100 +++ tools/displaytop/src/data.c | 30 + tools/displaytop/src/display.c | 418 +++++++++ tools/displaytop/src/display_configuration.c | 803 ++++++++++++++++++ tools/displaytop/src/display_dump.c | 199 +++++ tools/displaytop/src/display_search_bar.c | 268 ++++++ tools/displaytop/src/display_summary.c | 279 ++++++ tools/displaytop/src/log.c | 81 ++ tools/displaytop/src/main.c | 64 ++ tools/displaytop/src/node.c | 128 +++ tools/displaytop/src/populate.c | 32 + .../displaytop/src/populate_display_config.c | 271 ++++++ tools/displaytop/src/utils.c | 95 +++ tools/displaytop/src/utils_cli.c | 65 ++ tools/displaytop/src/utils_display.c | 195 +++++ tools/displaytop/src/utils_driver.c | 170 ++++ tools/displaytop/src/utils_drm.c | 579 +++++++++++++ tools/displaytop/src/utils_search.c | 43 + tools/meson.build | 1 + 26 files changed, 4322 insertions(+) create mode 100644 tools/displaytop/README.md create mode 100644 tools/displaytop/include/data.h create mode 100644 tools/displaytop/include/display.h create mode 100644 tools/displaytop/include/log.h create mode 100644 tools/displaytop/include/node.h create mode 100644 tools/displaytop/include/populate.h create mode 100644 tools/displaytop/include/utils.h create mode 100644 tools/displaytop/meson.build create mode 100644 tools/displaytop/src/data.c create mode 100644 tools/displaytop/src/display.c create mode 100644 tools/displaytop/src/display_configuration.c create mode 100644 tools/displaytop/src/display_dump.c create mode 100644 tools/displaytop/src/display_search_bar.c create mode 100644 tools/displaytop/src/display_summary.c create mode 100644 tools/displaytop/src/log.c create mode 100644 tools/displaytop/src/main.c create mode 100644 tools/displaytop/src/node.c create mode 100644 tools/displaytop/src/populate.c create mode 100644 tools/displaytop/src/populate_display_config.c create mode 100644 tools/displaytop/src/utils.c create mode 100644 tools/displaytop/src/utils_cli.c create mode 100644 tools/displaytop/src/utils_display.c create mode 100644 tools/displaytop/src/utils_driver.c create mode 100644 tools/displaytop/src/utils_drm.c create mode 100644 tools/displaytop/src/utils_search.c
tools/displaytop/README.md new file +77 -0
@@ -0,0 +1,77 @@ +# **DisplayTop** + +A terminal-based tool for monitoring and debugging the display pipeline. + +## **Features** + +- Terminal UI using `ncurses` +- Dump feature for all the menus +- Real-time display Configuration + +--- + +## **Quick Start** + +To run DisplayTop as part of the IGT GPU Tools: + +1. Build IGT as usual. +2. Navigate to the build directory: + + ```bash + cd build/tools/displaytop + ``` +3. Run the tool with root privileges: + + ```bash + sudo ./displaytop + ``` + +> **Note:** Running without `sudo` will disable certain features due to insufficient permissions. + +--- + +## **Building as a Standalone Project** + +DisplayTop can also be built independently of the full IGT suite. + +### Steps: + +1. In the displaytop directory, open `meson.build` and **uncomment** the following block at the top: + + ```meson + # This block must be UNCOMMENTED when building DisplayTop as a standalone project + project('displaytop', 'c', + version: '1.0', + default_options: ['warning_level=2', 'c_std=c11'] + ) + cc = meson.get_compiler('c') + ``` + +2. Build the project: + + ```bash + meson build + ninja -C build + ``` + +3. Run the tool: + + ```bash + sudo ./build/displaytop + ``` + +> **Important:** If you're building DisplayTop **as part of IGT**, **comment out** the block above in `meson.build`. + +--- + +Build igt-gpu-tools as normal and then go to `build/tools/displaytop` and run sudo `./displaytop`. +Note: Running the tool without sudo will result in loss of some features being disabled. + +--- + +## Logs & Dumps + +The log for the display top tool and the dumps initiated by the user are +stored in the `/tmp` folder as `displaytop.log` and `/displaytop_dump` respectively. + +---
tools/displaytop/include/data.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef DATA_H +#define DATA_H + +#include "node.h" + +extern struct Node *root;/* shared throughout the program */ + +#define DUMP_DIR "/tmp/displaytop_dump" + +#define DRM_DIR "/dev/dri/" +#define DRM_PRIMARY_PREFIX "card" +#define DRM_RENDER_PREFIX "renderD" + +#endif
tools/displaytop/include/display.h new file +47 -0
47 lines not on this page · raw message
tools/displaytop/include/log.h new file +49 -0
49 lines not on this page · raw message
tools/displaytop/include/node.h new file +127 -0
127 lines not on this page · raw message
tools/displaytop/include/populate.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef POPULATE_H +#define POPULATE_H + +#include "node.h" +#include "data.h" +#include "utils.h" +#include "utils.h" +#include "display.h" + +void populate_data (void ); + +void initialize_display_config (void ); + +#endif
tools/displaytop/include/utils.h new file +125 -0
125 lines not on this page · raw message
tools/displaytop/meson.build new file +100 -0
100 lines not on this page · raw message
tools/displaytop/src/data.c new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "data.h" +#include "display.h" + +/* This file holds all the global variables that are being used in the tool */ + +struct Node *root;
tools/displaytop/src/display.c new file +418 -0
418 lines not on this page · raw message
tools/displaytop/src/display_configuration.c new file +803 -0
803 lines not on this page · raw message
tools/displaytop/src/display_dump.c new file +199 -0
199 lines not on this page · raw message
tools/displaytop/src/display_search_bar.c new file +268 -0
268 lines not on this page · raw message
tools/displaytop/src/display_summary.c new file +279 -0
279 lines not on this page · raw message
tools/displaytop/src/log.c new file +81 -0
81 lines not on this page · raw message
tools/displaytop/src/main.c new file +64 -0
64 lines not on this page · raw message
tools/displaytop/src/node.c new file +128 -0
128 lines not on this page · raw message
tools/displaytop/src/populate.c new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "data.h" +#include "populate.h" + +void populate_data (void ) +{ + root =create_node ("Display Top" , display_summary,NULL ); +initialize_display_config (); +}
tools/displaytop/src/populate_display_config.c new file +271 -0
97 lines not on this page · raw message
tools/displaytop/src/utils.c new file +95 -0
95 lines not on this page · raw message
tools/displaytop/src/utils_cli.c new file +65 -0
65 lines not on this page · raw message
tools/displaytop/src/utils_display.c new file +195 -0
195 lines not on this page · raw message
tools/displaytop/src/utils_driver.c new file +170 -0
170 lines not on this page · raw message
tools/displaytop/src/utils_drm.c new file +579 -0
579 lines not on this page · raw message
tools/displaytop/src/utils_search.c new file +43 -0
43 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH i-g-t v2 1/4] tools/displaytop: Add Display Top - a terminal-based display pipeline monitor
Hi Pranay,
Quoted 117 lines · Pranay Samala
From: Adith Narein T <[email protected]>
This patch introduces
displaytop, a terminal-based tool designed for monitoring and debugging the display pipeline in real time. The initial feature focuses on providing detailed display configuration information, including:- CRTCs
- Connectors
- Encoders
- Planes
- FramebuffersThese components are presented in an organized format using a terminal UI built with
ncurses, giving developers and validation engineers a fast and accessible way to inspect the current state of the display system.Signed-off-by Pranay Samala <[email protected]>Signed-off-by Adith Narein T <[email protected]>Co-authored-by Pranay Samala <[email protected]>--- tools/displaytop/README.md | 77 ++ tools/displaytop/include/data.h | 38 + tools/displaytop/include/display.h | 47 + tools/displaytop/include/log.h | 49 ++ tools/displaytop/include/node.h | 127 +++ tools/displaytop/include/populate.h | 38 + tools/displaytop/include/utils.h | 125 +++ tools/displaytop/meson.build | 100 +++ tools/displaytop/src/data.c | 30 + tools/displaytop/src/display.c | 418 +++++++++ tools/displaytop/src/display_configuration.c | 803 ++++++++++++++++++ tools/displaytop/src/display_dump.c | 199 +++++ tools/displaytop/src/display_search_bar.c | 268 ++++++ tools/displaytop/src/display_summary.c | 279 ++++++ tools/displaytop/src/log.c | 81 ++ tools/displaytop/src/main.c | 64 ++ tools/displaytop/src/node.c | 128 +++ tools/displaytop/src/populate.c | 32 + .../displaytop/src/populate_display_config.c | 271 ++++++ tools/displaytop/src/utils.c | 95 +++ tools/displaytop/src/utils_cli.c | 65 ++ tools/displaytop/src/utils_display.c | 195 +++++ tools/displaytop/src/utils_driver.c | 170 ++++ tools/displaytop/src/utils_drm.c | 579 +++++++++++++ tools/displaytop/src/utils_search.c | 43 + tools/meson.build | 1 + 26 files changed, 4322 insertions(+)create mode 100644
tools/displaytop/README.md
create mode 100644tools/displaytop/include/data.hcreate mode 100644tools/displaytop/include/display.hcreate mode 100644tools/displaytop/include/log.hcreate mode 100644tools/displaytop/include/node.hcreate mode 100644tools/displaytop/include/populate.hcreate mode 100644tools/displaytop/include/utils.hcreate mode 100644tools/displaytop/meson.build
create mode 100644tools/displaytop/src/data.c
create mode 100644tools/displaytop/src/display.ccreate mode 100644tools/displaytop/src/display_configuration.ccreate mode 100644tools/displaytop/src/display_dump.ccreate mode 100644tools/displaytop/src/display_search_bar.ccreate mode 100644tools/displaytop/src/display_summary.ccreate mode 100644tools/displaytop/src/log.c
create mode 100644tools/displaytop/src/main.c
create mode 100644tools/displaytop/src/node.c
create mode 100644tools/displaytop/src/populate.ccreate mode 100644tools/displaytop/src/populate_display_config.ccreate mode 100644tools/displaytop/src/utils.c
create mode 100644tools/displaytop/src/utils_cli.ccreate mode 100644tools/displaytop/src/utils_display.ccreate mode 100644tools/displaytop/src/utils_driver.ccreate mode 100644tools/displaytop/src/utils_drm.ccreate mode 100644tools/displaytop/src/utils_search.ctools/displaytop/README.md new file +37
-0@@ -0,0 +1,77 @@ +# **DisplayTop** + +A terminal-based tool for monitoring and debugging the display pipeline. + +## **Features** + +- Terminal UI using `ncurses` +- Dump feature for all the menus +- Real-time display Configuration + +--- + +## **Quick Start** + +To run DisplayTop as part of the IGT GPU Tools: + +1. Build IGT as usual. +2. Navigate to the build directory: + + ```bash + cd build/tools/displaytop + ``` +3. Run the tool with root privileges: + + ```bash + sudo ./displaytop + ``` + +> **Note:** Running without `sudo` will disable certain features due to insufficient permissions. + +--- + +## **Building as a Standalone Project** + +DisplayTop can also be built independently of the full IGT suite. + +### Steps:
tools/displaytop/README.md line 47
Quoted 10 lines
tools/displaytop/README.md new file +10
-0+ +1. In the displaytop directory, open `meson.build` and **uncomment** the following block at the top: + + ```meson + # This block must be UNCOMMENTED when building DisplayTop as a standalone project + project('displaytop', 'c', + version: '1.0', + default_options: ['warning_level=2', 'c_std=c11'] + ) + cc = meson.get_compiler('c')
Please check if this is possible/required as this will block reuse of igt_helpers.
Quoted 48 lines
tools/displaytop/README.md new file +30
-0+ ``` + +2. Build the project: + + ```bash + meson build + ninja -C build + ``` + +3. Run the tool: + + ```bash + sudo ./build/displaytop + ``` + +> **Important:** If you're building DisplayTop **as part of IGT**, **comment out** the block above in `meson.build`. + +--- + +Build igt-gpu-tools as normal and then go to `build/tools/displaytop` and run sudo `./displaytop`. +Note: Running the tool without sudo will result in loss of some features being disabled. + +--- + +## Logs & Dumps + +The log for the display top tool and the dumps initiated by the user are +stored in the `/tmp` folder as `displaytop.log` and `/displaytop_dump` respectively. + +---tools/displaytop/include/data.h new file +12
-0@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next
tools/displaytop/include/data.h line 22
Quoted 10 lines
tools/displaytop/include/data.h new file +10
-0+* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE.
Please use the latest license format on all files.
Quoted 2,603 lines
tools/displaytop/include/data.h new file +16
-0+*/ + +#ifndef DATA_H +#define DATA_H + +#include "node.h" + +extern struct Node *root;/* shared throughout the program */ + +#define DUMP_DIR "/tmp/displaytop_dump" + +#define DRM_DIR "/dev/dri/" +#define DRM_PRIMARY_PREFIX "card" +#define DRM_RENDER_PREFIX "renderD" + +#endif tools/displaytop/include/display.h new file +47
-0@@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef DISPLAY_H +#define DISPLAY_H + +#include "log.h" +#include "node.h" +#include "utils.h" + +void display_win (WINDOW * win,struct Node *node); + +struct Node *display_search_bar (struct Node *head); +void display_dump_menu (struct Node *head); + +void display_crtc (WINDOW *pad,struct Node *node,int *content_line); +void display_plane (WINDOW *pad,struct Node *node,int *content_line); +void display_encoder (WINDOW *pad,struct Node *node,int *content_line); +void display_formats (WINDOW *pad,struct Node *node,int *content_line); +void display_connector (WINDOW *pad,struct Node *node,int *content_line); +void display_informats (WINDOW *pad,struct Node *node,int *content_line); +void display_framebuffer (WINDOW *pad,struct Node *node,int *content_line); + +void display_summary (WINDOW *pad,struct Node *node,int *content_line); + +#endif tools/displaytop/include/log.h new file +49
-0@@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef LOG_H +#define LOG_H + +#include <stdio.h> +#include <stdarg.h> +#include <time.h> + +#define LOG_FILE "/tmp/displaytop.log" + +enum LogLevel { +LOG_INFO , +LOG_WARNING , +LOG_ERROR +}; + +#ifndef __gnu_printf +#define __gnu_printf (format_idx, first_arg) __attribute__((format(gnu_printf, format_idx, first_arg))) +#endif + +void init_log_system (void ); +void close_log_system (void ); + +void log_message(int level, const char *format, ...) __gnu_printf(2, 3); + +#endif tools/displaytop/include/node.h new file +127
-0@@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef NODE_H +#define NODE_H + +#include <string.h> +#include <stdlib.h> +#include <ncurses.h> + +/** +* @struct Node +* @brief Represents a node in a tree structure. +* +* This structure is used to represent a node in a tree, where each node can have a name, +* a display function, a parent node, and an array of child nodes. +* +* @var Node::name +* A character array to store the name of the node. The name can be up to 49 characters long, +* with the 50th character reserved for the null terminator. +* +* @var Node::display_function +* A pointer to a function that takes a WINDOW pointer and a variable number of arguments, +* and returns an integer. This function is used to display the node. +* +* @var Node::parent +* A pointer to the parent node. If the node is the root, this will be NULL. +* +* @var Node::children +* A pointer to an array of child nodes. If the node has no children, this will be NULL. +* +* @var Node::children_size +* An integer representing the number of children the node has. +*/ +struct Node { +char name[50 ]; +void (*display_function)(WINDOW *win,struct Node *self,int *state); +struct Node *parent; +struct Node *children; +int children_size; +}; + +/** +* @brief Creates a new node with the given name, display function, and parent. +* +* This function allocates memory for a new node, initializes its name, display function, +* parent, and sets its children to NULL and children_size to 0. +* +* @param name The name of the node. +* @param display_function A pointer to the display function associated with the node. +* @param parent A pointer to the parent node. +* @return A pointer to the newly created node. +*/ +struct Node *create_node (const char *name, +void (*display_function)(WINDOW *win,struct Node *self,int *state), +struct Node *parent); + +/** +* @brief Adds a child node to the specified parent node. +* +* This function reallocates memory for the parent's children array to accommodate the new child, +* assigns the child to the next available position in the array, and increments the children_size. +* +* @param parent A pointer to the parent node. +* @param child A pointer to the child node to be added. +*/ +void add_child (struct Node *parent,struct Node *child); + +/** +* @brief Frees the memory allocated for the tree recursively. +* +* This function recursively frees the memory allocated for the children of the given root node, +* then frees the memory allocated for the children array and the root node itself. +* +* @param root A pointer to the root node of the tree. +*/ +void free_tree (struct Node *root); + +/** +* @brief Prints the path from the given node. +* +* This function takes a pointer to a Node structure and prints the path +* associated with that node. The exact format and details of the path +* are dependent on the implementation of the Node structure and the +* printPath function. +* +* @param node A pointer to the Node whose path is to be printed. +*/ +void print_path (struct Node *node); + +/** +* @brief Gets the path from the given node. +* +* This function takes a pointer to a Node structure and returns the path +* associated with that node. The exact format and details of the path +* are dependent on the implementation of the Node structure and the +* getPath function. +* +* @param node A pointer to the Node whose path is to be returned. +* @return A string representing the path of the node. +*/ +char *get_path (struct Node *node); + +void count_nodes (struct Node *node,int *count); + +#endif tools/displaytop/include/populate.h new file +38
-0@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef POPULATE_H +#define POPULATE_H + +#include "node.h" +#include "data.h" +#include "utils.h" +#include "utils.h" +#include "display.h" + +void populate_data (void ); + +void initialize_display_config (void ); + +#endif tools/displaytop/include/utils.h new file +125
-0@@ -0,0 +1,125 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef UTILS_H +#define UTILS_H +#include <time.h> +#include <math.h> +#include <string.h> + +#include <error.h> +#include <errno.h> + +#include <fcntl.h> +#include <ctype.h> +#include <limits.h> +#include <libgen.h> + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> + +#include <dirent.h> +#include <unistd.h> +#include <ncurses.h> +#include <sys/wait.h> + +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <sys/types.h> + +#include <xf86drm.h> +#include <drm/drm.h> +#include <xf86drmMode.h> +#include <drm/drm_mode.h> +#include <drm/i915_drm.h> +#include <drm/drm_fourcc.h> + +#include "log.h" +#include "node.h" +#include "data.h" +#include "display.h" + +extern int drm_fd; + +#ifndef __printf +#define __printf (format_idx, first_arg) __attribute__((format(printf, format_idx, first_arg))) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + +/* utils_cli.c */ +void handle_cli_args (int argc,char *argv[]); + +/* utils_driver.c*/ +void check_and_load_driver (void ); + +/* utils_display.c */ +void set_string (char *dest,const char *src,size_t size); +int check_size_change (WINDOW *win,int *height,int *width); + +void single_file_dump (struct Node *node,const char *file_path,bool single); +void search_nodes (struct Node *root,const char *search_input,struct Node *results); + +void print_bold_text(WINDOW *win, int line, int col, const char *text, ...) + __printf(4, 5); + +void print_dim_text(WINDOW *win, int line, int col, const char *text, ...) + __printf(4, 5); + +void print_red_text(WINDOW *win, int line, int col, const char *text, ...) + __printf(4, 5); + +void print_green_text(WINDOW *win, int line, int col, const char *text, ...) + __printf(4, 5); + +void draw_header (WINDOW *win,int win_width,const char *title,const char *helper); +void render_progress_bar (WINDOW *win,int current,int total); + +void print_wrapped_text (WINDOW *pad,int *line,int start,int size,const char *text, +bool enclose_with_pipe); + +/* utils.c*/ +void ensure_dump_directory (void ); +void strip_whitespace (char *str); +char *read_file (const char *filename); + +char *get_file_path (const char *filename); + +/* utils_drm.c */ +char *find_drm_device (bool primary); +void open_primary_drm_device (void ); +void close_primary_drm_device (void ); + +const char *get_drm_object_type_name (uint32_t object_type); +const char *get_format_str (uint32_t format); +const char *get_basic_modifier_str (uint64_t modifier); +const char *get_connector_type_name (uint32_t connector_type); +const char *get_encoder_type_name (uint32_t encoder_type); + +#endif tools/displaytop/meson.build new file +100
-0@@ -0,0 +1,100 @@ +# Meson build definition for DisplayTop tool + +# This block of code must be UNCOMMENTED when building displaytop as a standalone project +# project('displaytop', 'c', +# version: '1.0', +# default_options: ['warning_level=2', 'c_std=c11'] +# ) +# cc = meson.get_compiler('c') + +# Compiler flags +cflags = [ + '-Wall', '-Wextra', + '-Iinclude', '-I/usr/include/libdrm', '-I/usr/local/include', + '-DMESON_SOURCE_ROOT="' + meson.source_root() + '"' +] + +# Include directories +inc_dirs = include_directories( + 'include', + '/usr/include/libdrm', + '/usr/local/include' +) + +libdrm_dep = dependency('libdrm', required: true) +ncurses_dep = dependency('ncurses', required: false) +menu_dep = dependency('menu', required: false) +form_dep = dependency('form', required: false) +panel_dep = dependency('panel', required: false) + +have_displaytop = ncurses_dep.found() and menu_dep.found() and form_dep.found() and panel_dep.found() + +if have_displaytop + message('All dependencies found. Building displaytop.') + + deps = [ + libdrm_dep, + ncurses_dep, + menu_dep, + form_dep, + panel_dep, + ] + # Source files + source = files( + 'src/data.c', + 'src/display.c', + 'src/display_configuration.c', + 'src/display_dump.c', + 'src/display_search_bar.c', + 'src/display_summary.c', + 'src/log.c', + 'src/main.c', + 'src/node.c', + 'src/populate.c', + 'src/populate_display_config.c', + 'src/utils.c', + 'src/utils_cli.c', + 'src/utils_display.c', + 'src/utils_driver.c', + 'src/utils_drm.c', + 'src/utils_search.c', + ) + + if meson.is_subproject() + # SUBPROJECT MODE + # This block is used when the project is included as a subproject + # inside a larger Meson-based project (via subproject('displaytop')) + + # Define a static library + displaytop_lib = static_library( + 'displaytop', source, + c_args: cflags, + include_directories: inc_dirs, + dependencies: deps, + ) + + # Declare the dependency so parent projects can link to this + displaytop_dep = declare_dependency( + link_with: displaytop_lib, + include_directories: inc_dirs, + dependencies: deps, + ) + + else + # STANDALONE MODE + # This block builds and installs the executable when run independently. + # If you’re including this as a subproject in another Meson build, + # COMMENT OUT the `project()` line at the top and this `else` block. + + executable( + 'displaytop', source, + install: true, + c_args: cflags, + include_directories: inc_dirs, + dependencies: deps, + ) + endif + +else + message('Skipping displaytop: missing required optional dependencies.') +endiftools/displaytop/src/data.c new file +30
-0@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "data.h" +#include "display.h" + +/* This file holds all the global variables that are being used in the tool */ + +struct Node *root;tools/displaytop/src/display.c new file +418
-0@@ -0,0 +1,418 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "display.h" +#include "data.h" +#include "utils.h" + +static int display_exit_menu (void ) +{ +int height =8 , width =40 ; +int starty = (LINES - height) /2 ; +int startx = (COLS - width) /2 ; +int ch; +const char *message ="Are you sure you want to quit?" ; + +WINDOW *overlay =newwin (LINES ,COLS ,0 ,0 ); +WINDOW *confirm_win =newwin (height, width, starty, startx); + +wbkgd (overlay,COLOR_PAIR (0 )); +wclear (overlay); +wrefresh (overlay); + +wbkgd (confirm_win,COLOR_PAIR (2 )); +box (confirm_win,0 ,0 ); + +mvwprintw (confirm_win,2 , (width -strlen (message)) /2 ,"%s" , message); + +wattron (confirm_win,A_REVERSE ); +mvwprintw (confirm_win,4 , width /2 -5 ,"[Y]es" ); +mvwprintw (confirm_win,4 , width /2 +2 ,"[N]o" ); +wattroff (confirm_win,A_REVERSE ); + +wrefresh (confirm_win); + +while ((ch =wgetch (confirm_win))) { +if (ch =='y' || ch =='Y' ) { +delwin (confirm_win); +delwin (overlay); +return 1 ; + }else if (ch =='n' || ch =='N' || ch ==27 ) { +delwin (confirm_win); +delwin (overlay); +return 0 ; + } + } + +delwin (confirm_win); +delwin (overlay); +return 0 ; +} + +static void display_help_menu (void ) +{ +int row =2 ; +const char *title =" Help " ; +WINDOW *help_win =newwin (LINES ,COLS ,0 ,0 ); + +wbkgd (help_win,COLOR_PAIR (6 )); +wclear (help_win); +box (help_win,0 ,0 ); + +mvwprintw (help_win,0 , (COLS -strlen (title)) /2 ,"%s" , title); + +print_bold_text (help_win, row++,4 ,"Key Bindings:" ); + row++; +print_bold_text (help_win, row,6 ,"[Q]" ); +mvwprintw (help_win, row++,18 ,"- Quit the application with a confirmation prompt." ); +print_bold_text (help_win, row,6 ,"[H]" ); +mvwprintw (help_win, row++,18 ,"- Open the help menu to view key bindings and descriptions." ); +print_bold_text (help_win, row,6 ,"[UP/DOWN]" ); +mvwprintw (help_win, row++,18 ,"- Navigate through menu items or scroll content." ); +print_bold_text (help_win, row,6 ,"[TAB]" ); +mvwprintw (help_win, row++,18 ,"- Toggle focus between the menu and display content." ); +print_bold_text (help_win, row,6 ,"[ENTER]" ); +mvwprintw (help_win, row++,18 ,"- Select a menu item or confirm an action." ); +print_bold_text (help_win, row,6 ,"[ESC]" ); +mvwprintw (help_win, row++,18 ,"- Go back, cancel an action, or exit the application." ); +print_bold_text (help_win, row,6 ,"[S]" ); +mvwprintw (help_win, row++,18 ,"- Search for specific items in the menu." ); +print_bold_text (help_win, row,6 ,"[P]" ); +mvwprintw (help_win, row++,18 ,"- Save the current page's content to a file." ); +print_bold_text (help_win, row,6 ,"[D]" ); +mvwprintw (help_win, row++,18 ,"- Save all nested content starting from the current menu." ); +print_bold_text (help_win, row,6 ,"[R]" ); +mvwprintw (help_win, row++,18 ,"- Refresh the display to show recent updates." ); + + row++; +mvwprintw (help_win, row++,4 ,"Press any key to return..." ); + +wrefresh (help_win); +wgetch (help_win); + +delwin (help_win); +} + +void display_win (WINDOW *win,struct Node *node) +{ +struct Node *head = node; + +int is_running; +int highlighted_index =0 ; + +bool focus_on_menu = true; +bool refresh = true; + +int win_height, win_width; + +int content_height; +int content_y_start; + +int mpx; +int menu_pad_pos; +int menu_pad_width; +int menu_pad_height; +WINDOW *menu_pad =NULL ; + +int dpx; +int display_pad_pos; +int display_pad_width; +int display_pad_height; +WINDOW *display_pad =NULL ; + +const char *path =get_path (head); +const char *status_text ="[TAB] Switch Focus [S] Search [ESC] Back [R] Refresh [H] Help" ; + +int count, ch; + +while (1 ) { +wclear (win); +box (win,0 ,0 ); +wbkgd (win,COLOR_PAIR (2 )); +getmaxyx (win, win_height, win_width); + +if (!head->display_function && head->children_size ==0 ) { +mvwprintw (win,4 ,2 ,"It's so Empty at %s :(" , head->name); +mvwprintw (win,8 ,2 ,"Press 'e' to go back." ); +wrefresh (win); + } + + is_running =1 ; +log_message (LOG_INFO ,"Displaying %s" , head->name); + +while (is_running) { +if (check_size_change (win, &win_height, &win_width) ==1 || refresh) { +log_message (LOG_INFO ,"Window size changed. Refreshing display." ); + refresh = false; + + content_height = win_height -6 ; + content_y_start =4 ; + + mpx =1 ; + menu_pad_pos =0 ; + menu_pad_height = head->children_size > content_height ? + head->children_size +5 : content_height; + menu_pad_width = (int )((win_width -3 ) *0.3 ); + + dpx = menu_pad_width +2 ; + display_pad_pos =0 ; + display_pad_height =1000 ; + display_pad_width = win_width -3 - menu_pad_width; + +if (menu_pad) { +delwin (menu_pad); + menu_pad =NULL ; + } + + menu_pad =newpad (menu_pad_height, menu_pad_width); +prefresh (menu_pad, menu_pad_pos,0 , content_y_start,1 , + content_height + content_y_start -1 , menu_pad_width +1 ); + +if (head->display_function) { +if (display_pad) { +delwin (display_pad); + display_pad =NULL ; + } + + count = display_pad_height; + display_pad =newpad (display_pad_height, display_pad_width); + + head->display_function (display_pad, head, &count); + +if (count ==0 ) { +log_message (LOG_INFO ,"Exiting %s" , head->name); +if (head && head->parent) { + head = head->parent; + focus_on_menu = true; + highlighted_index =0 ; + display_pad_pos =0 ; + is_running =0 ; + }else { +return ; + } +continue ; + } + +if (count < display_pad_height) + display_pad_height = count +5 ; + +prefresh (display_pad, display_pad_pos,0 , content_y_start, + dpx, content_height + content_y_start -1 , +2 + menu_pad_width + display_pad_width); + } + +wclear (win); +box (win,0 ,0 ); + path =get_path (head); +draw_header (win, win_width, path, status_text); +mvwvline (win,3 , menu_pad_width +1 ,ACS_VLINE , win_height -4 ); +wrefresh (win); + } + +if (head->display_function) { +if (display_pad_pos >0 ) +print_bold_text (win,3 , menu_pad_width +2 ,"..." ); +else +mvwprintw (win,3 , menu_pad_width +2 ," " ); +if (display_pad_pos < display_pad_height - content_height) +print_bold_text (win, content_height + content_y_start, + menu_pad_width +2 ,"..." ); +else +mvwprintw (win, content_height + content_y_start, + menu_pad_width +2 ," " ); +print_dim_text (win,3 , win_width -15 ,"%d lines" , + display_pad_height); +prefresh (display_pad, display_pad_pos,0 , content_y_start, dpx, + content_height + content_y_start -1 , +2 + menu_pad_width + display_pad_width); + } + +if (focus_on_menu) { +print_bold_text (win,3 , win_width -5 ," " ); +wattron (win,A_REVERSE ); +print_bold_text (win,3 , menu_pad_width -3 ,"***" ); +wattroff (win,A_REVERSE ); + }else { +print_bold_text (win,3 , menu_pad_width -3 ," " ); +wattron (win,A_REVERSE ); +print_bold_text (win,3 , win_width -5 ,"***" ); +wattroff (win,A_REVERSE ); + } + +if (head->children_size >0 ) { +if (!head->display_function) + focus_on_menu = true; +print_dim_text (win,3 , menu_pad_width -15 ,"%d Menus" , + head->children_size); +for (int i =0 ; i < head->children_size; ++i) { +if (highlighted_index == i && focus_on_menu) +wattron (menu_pad,A_REVERSE ); +mvwprintw (menu_pad, i,1 ,"%d. %s" , i +1 , + head->children[i].name); +wattroff (menu_pad,A_REVERSE ); + } + } + +if (highlighted_index == head->children_size && focus_on_menu) +wattron (menu_pad,A_REVERSE ); + +if (head->parent) +print_dim_text (menu_pad, head->children_size,1 ,"Go Back" ); +else +print_dim_text (menu_pad, head->children_size,1 ,"Exit" ); + +wattroff (menu_pad,A_REVERSE ); + +prefresh (menu_pad, menu_pad_pos,0 , content_y_start, mpx, + content_height + content_y_start -1 , menu_pad_width +1 ); + + ch =wgetch (win); +switch (ch) { +case KEY_UP : +if (!focus_on_menu && display_pad_pos >0 ) { + display_pad_pos--; + }else if (focus_on_menu) { +if (highlighted_index ==0 ) { + highlighted_index = head->children_size; + menu_pad_pos = menu_pad_height - content_height; + }else { + highlighted_index--; +if (highlighted_index > + menu_pad_height - content_height) + menu_pad_pos = + menu_pad_height - content_height; +else + menu_pad_pos--; + } + } +break ; +case KEY_DOWN : +if (!focus_on_menu && + display_pad_pos < display_pad_height - content_height) { + display_pad_pos++; + }else if (focus_on_menu) { +if (highlighted_index == head->children_size) { + highlighted_index =0 ; + menu_pad_pos =0 ; + }else { + highlighted_index++; +if (highlighted_index > + menu_pad_height - content_height) + menu_pad_pos = + menu_pad_height - content_height; +else + menu_pad_pos++; + } + } +break ; +case 's' : +case 'S' : +log_message (LOG_INFO ,"Searching %s" , head->name); + head =display_search_bar (head); + refresh = true; +break ; +case 'p' : +case 'P' : +single_file_dump (head,DUMP_DIR , true); + refresh = true; +break ; +case 'd' : +case 'D' : +display_dump_menu (head); + refresh = true; +break ; +case 'h' : +case 'H' : +display_help_menu (); + refresh = true; +break ; +case 'q' : +case 'Q' : +if (display_exit_menu ()) { +log_message (LOG_INFO ,"Exiting DisplayTop" ); +return ; + } + refresh = true; +break ; +case 27 : +log_message (LOG_INFO ,"Exiting %s" , head->name); +if (head && head->parent) { + head = head->parent; + focus_on_menu = true; + highlighted_index =0 ; + display_pad_pos =0 ; + is_running =0 ; + }else if (display_exit_menu ()) { +log_message (LOG_INFO ,"Exiting DisplayTop" ); +return ; + } + refresh = true; +break ; +case 'r' : +case 'R' : +log_message (LOG_INFO ,"Refreshing %s" , head->name); + refresh = true; +break ; +case '\n' : +if (focus_on_menu && head) { +if (highlighted_index >=0 && + highlighted_index < head->children_size) { + head = &head->children[highlighted_index]; + highlighted_index =0 ; + display_pad_pos =0 ; + is_running =0 ; + refresh = true; + }else if (highlighted_index == head->children_size) { +if (head && head->parent) { + head = head->parent; + focus_on_menu = true; + highlighted_index =0 ; + display_pad_pos =0 ; + is_running =0 ; + }else if (display_exit_menu ()) { +log_message (LOG_INFO ,"Exiting DisplayTop" ); +return ; + } + refresh = true; + } + } +break ; +case '\t' : + focus_on_menu = !focus_on_menu; +break ; + } + } + + refresh = true; +if (display_pad) { +delwin (display_pad); + display_pad =NULL ; + } + +if (menu_pad) { +delwin (menu_pad); + menu_pad =NULL ; + } + } +}tools/displaytop/src/display_configuration.c new file +803
-0@@ -0,0 +1,803 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "display.h" +#include "utils.h" + +void display_crtc (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModeRes *resources =NULL ; +drmModeObjectProperties *props =NULL ; +drmModePlaneRes *plane_resources =NULL ; +drmModeCrtc *crtc =NULL ; +int crtc_index =-1 ; +char *endptr; + +if (drm_fd <0 ) { +print_red_text (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + resources =drmModeGetResources (drm_fd); +if (!resources) { +print_red_text (pad, line++,1 ,"Failed to get DRM resources\n" ); + goto err; + } + + crtc_index =strtol (node->name +4 , &endptr,10 ); +if (*endptr !='\0' || crtc_index <0 || crtc_index >= resources->count_crtcs) { +print_red_text (pad, line++,1 ,"Invalid CRTC name: %s\n" , node->name); +drmModeFreeResources (resources); + goto err; + } + + crtc =drmModeGetCrtc (drm_fd, resources->crtcs[crtc_index]); +if (!crtc) { +print_red_text (pad, line++,1 ,"Failed to get CRTC %d\n" , crtc_index); +drmModeFreeResources (resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"CRTC ID: %d" , crtc->crtc_id); +mvwprintw (pad, line++,1 ,"Framebuffer ID: %d" , crtc->buffer_id); +mvwprintw (pad, line++,1 ,"Position(X, Y): (%d, %d)" , crtc->x, crtc->y); +mvwprintw (pad, line++,1 ,"Mode: " ); +if (crtc->mode_valid) +print_green_text (pad,-1 ,-1 ,"VALID" ); +else +print_red_text (pad,-1 ,-1 ,"INVALID" ); + +if (crtc->mode_valid) { +drmModeModeInfo *mode = &crtc->mode; + +mvwprintw (pad, line++,3 ,"Name: %s" , mode->name); +mvwprintw (pad, line++,3 ,"Resolution: %dx%d" , mode->hdisplay, mode->vdisplay); +mvwprintw (pad, line++,3 ,"Refresh Rate: %.2f Hz" , + mode->clock / (float )(mode->htotal * mode->vtotal)); +mvwprintw (pad, line++,3 ,"Type: 0x%x" , mode->type); +mvwprintw (pad, line++,3 ,"Flags: 0x%x" , mode->flags); + } + +mvwprintw (pad, line++,1 ,"Gamma size: %u" , crtc->gamma_size); + + props =drmModeObjectGetProperties (drm_fd, crtc->crtc_id,DRM_MODE_OBJECT_CRTC ); +if (!props) { +print_red_text (pad, line++,1 ,"Failed to get properties for CRTC %u\n" , + crtc->crtc_id); +drmModeFreeCrtc (crtc); +drmModeFreeResources (resources); + goto err; + } + + plane_resources =drmModeGetPlaneResources (drm_fd); +if (!plane_resources) { +print_red_text (pad, line++,3 ,"Failed to get plane resources" ); +return ; + } + + line++; +mvwprintw (pad, line++,1 ,"Possible Planes for CRTC %d:" , crtc->crtc_id); + line++; + +wattron (pad,A_DIM ); +for (size_t i =0 ; i < plane_resources->count_planes; i++) { +drmModePlane *plane =drmModeGetPlane (drm_fd, plane_resources->planes[i]); + +if (plane) { +if (plane->possible_crtcs & (1 << crtc_index)) { +mvwprintw (pad, line++,3 ,"Plane %ld: ID %d, %s" , + i, plane->plane_id, + plane->crtc_id ?"Active" :"Inactive" ); + } +drmModeFreePlane (plane); + }else { +print_red_text (pad, line++,3 ,"Plane %ld: Failed to get plane" , i); + } + } +wattroff (pad,A_DIM ); +drmModeFreePlaneResources (plane_resources); + + line++; +mvwprintw (pad, line++,1 ,"Properties for CRTC %u:" , crtc->crtc_id); + line++; + +wattron (pad,A_DIM ); +for (uint32_t i =0 ; i < props->count_props; i++) { +drmModePropertyPtr prop =drmModeGetProperty (drm_fd, props->props[i]); + +if (prop) { +uint64_t value = props->prop_values[i]; +int remaining_width =getmaxx (pad) -getcurx (pad); +char value_str[256 ] = {0 }; + +const char *immutability = (prop->flags &DRM_MODE_PROP_IMMUTABLE ) ? +" immutable" :"" ; +const char *atomicity = (prop->flags &DRM_MODE_PROP_ATOMIC ) ? +" atomic" :" " ; + +if (prop->flags &DRM_MODE_PROP_BLOB ) { +snprintf (value_str,sizeof (value_str),"blob = %lu" , value); + }else if (prop->flags &DRM_MODE_PROP_ENUM ) { +snprintf (value_str,sizeof (value_str),"enum (" ); +for (int j =0 ; j < prop->count_enums; j++) { +if (j >0 ) +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +", " ); +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +"%s" , prop->enums[j].name); + } +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +") = %s" , prop->enums[value].name); + }else if (prop->flags &DRM_MODE_PROP_RANGE ) { +snprintf (value_str,sizeof (value_str),"range [%lu, %lu] = %lu" , + prop->values[0 ], prop->values[1 ], value); + }else if (prop->flags &DRM_MODE_PROP_OBJECT ) { +snprintf (value_str,sizeof (value_str),"object %s = %lu" , +get_drm_object_type_name (prop->values[0 ]), value); + }else { +snprintf (value_str,sizeof (value_str),"%lu" , value); + } + +wattroff (pad,A_DIM ); +mvwprintw (pad, line++,2 ,"%d. %s" , i, prop->name); +wattron (pad,A_DIM ); +wprintw (pad,"%s%s: " , immutability, atomicity); + +if ((int )strlen (value_str) > remaining_width) { +char truncated_value[remaining_width +1 ]; + +strncpy (truncated_value, value_str, remaining_width); + truncated_value[remaining_width] ='\0' ; +wprintw (pad,"%s" , truncated_value); +mvwprintw (pad, line++,2 ,"%s" , value_str + remaining_width); + }else { +wprintw (pad,"%s" , value_str); + } + +drmModeFreeProperty (prop); + } + } +wattroff (pad,A_DIM ); + +drmModeFreeObjectProperties (props); + +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +drmModeFreeCrtc (crtc); +drmModeFreeResources (resources); +return ; + +err: +wrefresh (pad); +wgetch (pad); +} + +void display_connector (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModeRes *resources =NULL ; +drmModeConnector *connector =NULL ; +int connector_index =-1 ; +char *endptr; + +if (drm_fd <0 ) { +print_red_text (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + resources =drmModeGetResources (drm_fd); +if (!resources) { +print_red_text (pad, line++,1 ,"Failed to get DRM resources\n" ); + goto err; + } + + connector_index =strtol (node->name +9 , &endptr,10 ); + +if (*endptr !='\0' || connector_index <0 || + connector_index >= resources->count_connectors) { +mvwprintw (pad, line++,1 ,"Invalid Connector name: %s\n" , node->name); +drmModeFreeResources (resources); + goto err; + } + + connector =drmModeGetConnector (drm_fd, resources->connectors[connector_index]); +if (!connector) { +mvwprintw (pad, line++,1 ,"Failed to get Connector %d\n" , connector_index); +drmModeFreeResources (resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"Connector ID: %d" , connector->connector_id); +mvwprintw (pad, line++,1 ,"No. of Encoders: %d" , connector->count_encoders); +mvwprintw (pad, line++,1 ,"Encoder ID: %d" , connector->encoder_id); + + line++; +mvwprintw (pad, line++,1 ,"Possible Encoders: " ); +for (int i =0 ; i < connector->count_encoders; i++) +mvwprintw (pad, line++,3 ,"Encoder %d: %d" , i, connector->encoders[i]); + + line++; +mvwprintw (pad, line++,1 ,"Connection: " ); +if (connector->connection ==DRM_MODE_CONNECTED ) +print_green_text (pad,-1 ,-1 ,"Connected" ); +else +print_red_text (pad,-1 ,-1 ,"Disconnected" ); + + line++; +mvwprintw (pad, line++,1 ,"Connector Type: %s" , +get_connector_type_name (connector->connector_type)); +mvwprintw (pad, line++,1 ,"Connector Type ID: %d" , connector->connector_type_id); + +mvwprintw (pad, line++,1 ,"Subpixel Order: %d" , connector->subpixel); +mvwprintw (pad, line++,1 ,"MM Height: %d" , connector->mmHeight); +mvwprintw (pad, line++,1 ,"MM Width: %d" , connector->mmWidth); + +mvwprintw (pad, line++,1 ,"Modes: %d" , connector->count_modes); +wattron (pad,A_DIM ); + + line++; +for (int i =0 ; i < connector->count_modes; i++) + +if (connector->modes && i < connector->count_modes) { +const drmModeModeInfo *mode = &connector->modes[i]; + +const char *preferred = (mode->type &DRM_MODE_TYPE_PREFERRED ) ? +" preferred" :"" ; +const char *driver = (mode->type &DRM_MODE_TYPE_DRIVER ) ?" driver" :"" ; +const char *phsync = (mode->flags &DRM_MODE_FLAG_PHSYNC ) ?" phsync" : +" nhsync" ; +const char *pvsync = (mode->flags &DRM_MODE_FLAG_PVSYNC ) ?" pvsync" : +" nvsync" ; +const char *interlace = (mode->flags &DRM_MODE_FLAG_INTERLACE ) ? +" interlace" :"" ; + +double ratio = (double )mode->hdisplay / mode->vdisplay; +double refresh_rate =0.0 ; +const char *aspect_ratio =NULL ; + +if (mode->vrefresh >0 ) + refresh_rate = mode->vrefresh; +else if (mode->clock >0 && mode->vtotal >0 ) + refresh_rate = (double )(mode->clock *1000 ) / + (mode->htotal * mode->vtotal); + +if (fabs (ratio -16.0 /9.0 ) <0.01 ) + aspect_ratio =" 16:9" ; +else if (fabs (ratio -4.0 /3.0 ) <0.01 ) + aspect_ratio =" 4:3" ; +else + aspect_ratio ="" ; + +mvwprintw (pad, line++,2 ,"%ux%u @%.2f%s%s%s%s%s%s" , + mode->hdisplay, mode->vdisplay, refresh_rate, + driver, preferred, phsync, pvsync, interlace, aspect_ratio); + } + +wattroff (pad,A_DIM ); + +mvwprintw (pad, line++,1 ,"No. of Properties: %d" , connector->count_props); + +wattron (pad,A_DIM ); +for (int i =0 ; i < connector->count_props; i++) { +drmModePropertyPtr prop =drmModeGetProperty (drm_fd, connector->props[i]); + +if (prop) { +char value_str[256 ] = {0 }; +uint64_t value = connector->prop_values[i]; +int remaining_width =getmaxx (pad) -getcurx (pad); +const char *atomicity = (prop->flags &DRM_MODE_PROP_ATOMIC ) ? +" atomic" :" " ; +const char *immutability = (prop->flags &DRM_MODE_PROP_IMMUTABLE ) ? +" immutable" :"" ; + +if (prop->flags &DRM_MODE_PROP_BLOB ) { +snprintf (value_str,sizeof (value_str),"blob = %lu" , value); + }else if (prop->flags &DRM_MODE_PROP_ENUM ) { +snprintf (value_str,sizeof (value_str),"enum (" ); +for (int j =0 ; j < prop->count_enums; j++) { +if (j >0 ) +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +", " ); +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +"%s" , prop->enums[j].name); + } +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +") = %s" , prop->enums[value].name); + }else if (prop->flags &DRM_MODE_PROP_RANGE ) { +snprintf (value_str,sizeof (value_str),"range [%lu, %lu] = %lu" , + prop->values[0 ], prop->values[1 ], value); + }else if (prop->flags &DRM_MODE_PROP_OBJECT ) { +snprintf (value_str,sizeof (value_str),"object %s = %lu" , +get_drm_object_type_name (prop->values[0 ]), value); + }else { +snprintf (value_str,sizeof (value_str),"%lu" , value); + } + +wattroff (pad,A_DIM ); +mvwprintw (pad, line++,2 ,"%d. %s" , i, prop->name); +wattron (pad,A_DIM ); +wprintw (pad,"%s%s: " , immutability, atomicity); + +if ((int )strlen (value_str) > remaining_width) { +char truncated_value[remaining_width +1 ]; + +strncpy (truncated_value, value_str, remaining_width); + truncated_value[remaining_width] ='\0' ; +wprintw (pad,"%s" , truncated_value); +mvwprintw (pad, line++,2 ,"%s" , value_str + remaining_width); + }else { +wprintw (pad,"%s" , value_str); + } + +drmModeFreeProperty (prop); + } + } +wattroff (pad,A_DIM ); + +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +drmModeFreeConnector (connector); +drmModeFreeResources (resources); +return ; + +err: +wrefresh (pad); +wgetch (pad); +} + +void display_encoder (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModeRes *resources =NULL ; +drmModeEncoder *encoder =NULL ; +int encoder_id =-1 ; +char *endptr; + +if (drm_fd <0 ) { +mvwprintw (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + resources =drmModeGetResources (drm_fd); +if (!resources) { +mvwprintw (pad, line++,1 ,"Failed to get DRM resources\n" ); + goto err; + } + + encoder_id =strtol (node->name +7 , &endptr,10 ); +if (*endptr !='\0' || encoder_id <0 || encoder_id >= resources->count_encoders) { +mvwprintw (pad, line++,1 ,"Invalid Encoder name: %s\n" , node->name); +drmModeFreeResources (resources); + goto err; + } + + encoder =drmModeGetEncoder (drm_fd, resources->encoders[encoder_id]); +if (!encoder) { +mvwprintw (pad, line++,1 ,"Failed to get Encoder %d\n" , encoder_id); +drmModeFreeResources (resources); + goto err; + } + + line++; +mvwprintw (pad, line++,1 ,"Encoder Type: " ); +if (encoder->encoder_type ==DRM_MODE_ENCODER_NONE ) +print_red_text (pad,-1 ,-1 ,"NONE" ); +else +print_bold_text (pad,-1 ,-1 ,"%s" ,get_encoder_type_name (encoder->encoder_type)); + line++; + +mvwprintw (pad, line++,1 ,"Encoder ID: %d" , encoder->encoder_id); +mvwprintw (pad, line++,1 ,"CRTC ID: %d" , encoder->crtc_id); +mvwprintw (pad, line++,1 ,"Possible CRTCs: %d" , encoder->possible_crtcs); +mvwprintw (pad, line++,1 ,"Possible Clones: %d" , encoder->possible_clones); + +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +drmModeFreeEncoder (encoder); +drmModeFreeResources (resources); +return ; + +err: +wrefresh (pad); +wgetch (pad); +} + +void display_framebuffer (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModeRes *resources =NULL ; +drmModeFB *fb =NULL ; +int framebuffer_id =-1 ; +char *endptr; + +if (drm_fd <0 ) { +mvwprintw (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + resources =drmModeGetResources (drm_fd); +if (!resources) { +mvwprintw (pad, line++,1 ,"Failed to get DRM resources\n" ); + goto err; + } + + framebuffer_id =strtol (node->name +11 , &endptr,10 ); +if (*endptr !='\0' || framebuffer_id <0 || framebuffer_id >= resources->count_fbs) { +mvwprintw (pad, line++,1 ,"Invalid Framebuffer name: %s\n" , node->name); +drmModeFreeResources (resources); + goto err; + } + + fb =drmModeGetFB (drm_fd, resources->fbs[framebuffer_id]); +if (!fb) { +mvwprintw (pad, line++,1 ,"Failed to get Framebuffer %d\n" , framebuffer_id); +drmModeFreeResources (resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"Framebuffer ID: %d" , fb->fb_id); +mvwprintw (pad, line++,1 ,"Width: %d" , fb->width); +mvwprintw (pad, line++,1 ,"Height: %d" , fb->height); +mvwprintw (pad, line++,1 ,"Pitch: %d" , fb->pitch); +mvwprintw (pad, line++,1 ,"BPP: %d" , fb->bpp); +mvwprintw (pad, line++,1 ,"Depth: %d" , fb->depth); +mvwprintw (pad, line++,1 ,"Handle: %d" , fb->handle); + +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +drmModeFreeFB (fb); +drmModeFreeResources (resources); +return ; + +err: +wrefresh (pad); +wgetch (pad); +} + +void display_plane (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModePlaneRes *plane_resources =NULL ; +drmModePlane *plane =NULL ; +int plane_index =-1 ; +char *endptr; +drmModeObjectProperties *props =NULL ; + +if (drm_fd <0 ) { +mvwprintw (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + plane_resources =drmModeGetPlaneResources (drm_fd); +if (!plane_resources) { +mvwprintw (pad, line++,1 ,"Failed to get DRM plane resources\n" ); + goto err; + } + + plane_index =strtol (node->name +5 , &endptr,10 ); +if (*endptr !='\0' || plane_index <0 || + plane_index >= (int )plane_resources->count_planes) { +mvwprintw (pad, line++,1 ,"Invalid Plane name: %s\n" , node->name); +drmModeFreePlaneResources (plane_resources); + goto err; + } + + plane =drmModeGetPlane (drm_fd, plane_resources->planes[plane_index]); +if (!plane) { +mvwprintw (pad, line++,1 ,"Failed to get Plane %d\n" , plane_index); +drmModeFreePlaneResources (plane_resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"Plane Index: %d" , plane_index); +mvwprintw (pad, line++,1 ,"Plane ID: %d" , plane->plane_id); +mvwprintw (pad, line++,1 ,"CRTC ID: %d" , plane->crtc_id); +mvwprintw (pad, line++,1 ,"Framebuffer ID: %d" , plane->fb_id); +mvwprintw (pad, line++,1 ,"Possible CRTCs: %d" , plane->possible_crtcs); +mvwprintw (pad, line++,1 ,"Gamma size: %u" , plane->gamma_size); +mvwprintw (pad, line++,1 ,"CRTC Position: (%d, %d)" , plane->crtc_x, plane->crtc_y); + +mvwprintw (pad, line++,1 ,"Possible CRTC IDs: " ); +for (int i =0 ; i <32 ; i++) { +if (plane->possible_crtcs & (1 << i)) +mvwprintw (pad, line++,3 ,"CRTC %d" , i); + } + line++; + +mvwprintw (pad, line++,1 ,"Number of formats: %u" , plane->count_formats); + line++; + + props =drmModeObjectGetProperties (drm_fd, plane->plane_id,DRM_MODE_OBJECT_PLANE ); +if (!props) { +mvwprintw (pad, line++,1 ,"Failed to get properties for Plane %u\n" , + plane->plane_id); +drmModeFreePlane (plane); +drmModeFreePlaneResources (plane_resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"Properties for Plane %u:" , plane->plane_id); + line++; + +for (uint32_t i =0 ; i < props->count_props; i++) { +drmModePropertyPtr prop =drmModeGetProperty (drm_fd, props->props[i]); + +if (prop) { +char value_str[256 ] = {0 }; +uint64_t value = props->prop_values[i]; +int remaining_width =getmaxx (pad) -getcurx (pad); +const char *immutability = (prop->flags &DRM_MODE_PROP_IMMUTABLE ) ? +" immutable" :"" ; +const char *atomicity = (prop->flags &DRM_MODE_PROP_ATOMIC ) ? +" atomic" :" " ; + +if (prop->flags &DRM_MODE_PROP_BLOB ) { +snprintf (value_str,sizeof (value_str),"blob = %lu" , value); + }else if (prop->flags &DRM_MODE_PROP_ENUM ) { +snprintf (value_str,sizeof (value_str),"enum (" ); +for (int j =0 ; j < prop->count_enums; j++) { +if (j >0 ) +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +", " ); +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str), +"%s" , prop->enums[j].name); + } +snprintf (value_str +strlen (value_str), +sizeof (value_str) -strlen (value_str),") = %s" , + prop->enums[value].name); + }else if (prop->flags &DRM_MODE_PROP_RANGE ) { +snprintf (value_str,sizeof (value_str),"range [%lu, %lu] = %lu" , + prop->values[0 ], prop->values[1 ], value); + }else if (prop->flags &DRM_MODE_PROP_OBJECT ) { +snprintf (value_str,sizeof (value_str),"object %s = %lu" , +get_drm_object_type_name (prop->values[0 ]), value); + }else { +snprintf (value_str,sizeof (value_str),"%lu" , value); + } + +wattroff (pad,A_DIM ); +mvwprintw (pad, line++,2 ,"%d. %s" , i, prop->name); +wattron (pad,A_DIM ); +wprintw (pad,"%s%s: " , immutability, atomicity); + +if ((int )strlen (value_str) > remaining_width) { +char truncated_value[remaining_width +1 ]; + +strncpy (truncated_value, value_str, remaining_width); + truncated_value[remaining_width] ='\0' ; +wprintw (pad,"%s" , truncated_value); +mvwprintw (pad, line++,2 ,"%s" , value_str + remaining_width); + }else { +wprintw (pad,"%s" , value_str); + } + +drmModeFreeProperty (prop); + } + } + +drmModeFreeObjectProperties (props); + +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +drmModeFreePlane (plane); +drmModeFreePlaneResources (plane_resources); +return ; + +err: +wrefresh (pad); +wgetch (pad); +} + +void display_informats (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModePlaneRes *plane_resources =NULL ; +drmModePlane *plane =NULL ; +drmModeObjectProperties *props =NULL ; +int plane_index =-1 ; + +if (drm_fd <0 ) { +mvwprintw (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + plane_resources =drmModeGetPlaneResources (drm_fd); +if (!plane_resources) { +mvwprintw (pad, line++,1 ,"Failed to get DRM plane resources\n" ); + goto err; + } + +if (strncmp (node->name,"IN_FORMATS" ,10 ) ==0 ) { +char *endptr; + + plane_index =strtol (node->name +10 , &endptr,10 ); +if (*endptr !='\0' || plane_index <0 || + plane_index >= (int )plane_resources->count_planes) { +mvwprintw (pad, line++,1 ,"Invalid Plane Index: %s\n" , node->name); +drmModeFreePlaneResources (plane_resources); + goto err; + } + }else { +mvwprintw (pad, line++,1 ,"Invalid format for node->name: %s\n" , node->name); +drmModeFreePlaneResources (plane_resources); + goto err; + } + + plane =drmModeGetPlane (drm_fd, plane_resources->planes[plane_index]); +if (!plane) { +mvwprintw (pad, line++,1 ,"Failed to get Plane %d\n" , plane_index); +drmModeFreePlaneResources (plane_resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"Plane Index: %d" , plane_index); +mvwprintw (pad, line++,1 ,"Plane ID: %d" , plane->plane_id); + + props =drmModeObjectGetProperties (drm_fd, plane->plane_id,DRM_MODE_OBJECT_PLANE ); +if (!props) { +mvwprintw (pad, line++,1 ,"Failed to get properties for Plane %u\n" , + plane->plane_id); +drmModeFreePlane (plane); +drmModeFreePlaneResources (plane_resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"IN_FORMATS for Plane %u:" , plane->plane_id); + line++; + +for (uint32_t i =0 ; i < props->count_props; i++) { +drmModePropertyPtr prop =drmModeGetProperty (drm_fd, props->props[i]); + +if (prop) { +uint64_t value = props->prop_values[i]; + +if (prop->flags &DRM_MODE_PROP_BLOB &&strcmp (prop->name, +"IN_FORMATS" ) ==0 ) { +drmModePropertyBlobRes *blob =drmModeGetPropertyBlob (drm_fd, + value); +struct drm_format_modifier_blob *data =NULL ; +uint32_t *fmts =NULL ; +struct drm_format_modifier *mods =NULL ; + +if (!blob) { +log_message (LOG_ERROR ,"drmModeGetPropertyBlob" ); +return ; + } + + data = blob->data; + + fmts = (uint32_t *)((char *)data + data->formats_offset); + mods = (struct drm_format_modifier *)((char *)data + + data->modifiers_offset); + +for (uint32_t j =0 ; j < data->count_modifiers; j++) { +mvwprintw (pad, line++,1 ,"Modifier %u: %s" , j, +get_basic_modifier_str (mods[j].modifier)); +mvwprintw (pad, line++,3 ,"Formats: " ); +wattron (pad,A_DIM ); +for (uint32_t k =0 ; k < data->count_formats; k++) { +if (mods[j].formats & (1ULL << k)) +mvwprintw (pad, line++,5 ,"%s (0x%08x)" , +get_format_str (fmts[k]), fmts[k]); + } +wattroff (pad,A_DIM ); + } +drmModeFreePropertyBlob (blob); + } + } + } +drmModeFreeObjectProperties (props); +drmModeFreePlane (plane); +drmModeFreePlaneResources (plane_resources); +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +return ; + +err: +wrefresh (pad); +} + +void display_formats (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +drmModePlaneRes *plane_resources =NULL ; +drmModePlane *plane =NULL ; +int plane_index =-1 ; + +if (drm_fd <0 ) { +mvwprintw (pad, line++,1 ,"Failed to open DRM Device!\n" ); + goto err; + } + + plane_resources =drmModeGetPlaneResources (drm_fd); +if (!plane_resources) { +mvwprintw (pad, line++,1 ,"Failed to get DRM plane resources\n" ); + goto err; + } + +if (strncmp (node->name,"FORMATS" ,7 ) ==0 ) { +char *endptr; + + plane_index =strtol (node->name +7 , &endptr,10 ); +if (*endptr !='\0' || plane_index <0 || + plane_index >= (int )plane_resources->count_planes) { +mvwprintw (pad, line++,1 ,"Invalid Plane Index: %s\n" , node->name); +drmModeFreePlaneResources (plane_resources); + goto err; + } + }else { +mvwprintw (pad, line++,1 ,"Invalid format for node->name: %s\n" , node->name); +drmModeFreePlaneResources (plane_resources); + goto err; + } + + plane =drmModeGetPlane (drm_fd, plane_resources->planes[plane_index]); +if (!plane) { +mvwprintw (pad, line++,1 ,"Failed to get Plane %d\n" , plane_index); +drmModeFreePlaneResources (plane_resources); + goto err; + } + +mvwprintw (pad, line++,1 ,"Plane ID: %d" , plane->plane_id); + + line++; +mvwprintw (pad, line++,1 ,"No. of Plane formats %u:" , plane->count_formats); + line++; + +if (plane->count_formats >0 ) { +wattron (pad,A_DIM ); +for (uint32_t i =0 ; i < plane->count_formats; i++) +mvwprintw (pad, line++,3 ,"%s (0x%08x)" , +get_format_str (plane->formats[i]), + plane->formats[i]); + line++; +wattroff (pad,A_DIM ); + } + +drmModeFreePlane (plane); +drmModeFreePlaneResources (plane_resources); + +mvwprintw (pad, ++line,1 ,"Press 'e' to go back." ); + + *content_line = line; +return ; + +err: +wrefresh (pad); +}tools/displaytop/src/display_dump.c new file +199
-0@@ -0,0 +1,199 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "node.h" +#include "utils.h" + +void single_file_dump (struct Node *node,const char *filePath,bool single) +{ +time_t now; +struct tm *t; +char dump_file_path[512 ]; +FILE *file; +const int padHeight =1000 ; +const int padWidth =200 ; +WINDOW *virtualWin; +int line =0 ; +char buffer[padWidth +1 ]; + +if (!node || node->name[0 ] =='\0' || !node->display_function) { +log_message (LOG_ERROR ,"Invalid node provided for dumping" ); +return ; + } + + now =time (NULL ); + t =localtime (&now); + +if (single) { +snprintf (dump_file_path,sizeof (dump_file_path),"%s/%s_%04d-%02d-%02d-%02d.%02d.%02d.txt" , + filePath, node->name, t->tm_year +1900 , t->tm_mon +1 , t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + }else { +snprintf (dump_file_path,sizeof (dump_file_path),"%s/%s.txt" , filePath, node->name); + } + + file =fopen (dump_file_path,"w" ); +if (!file) { +log_message (LOG_ERROR ,"Failed to open file: %s" , dump_file_path); +return ; + } +chmod (dump_file_path,0777 ); + + virtualWin =newwin (padHeight, padWidth,0 ,0 ); +if (!virtualWin) { +log_message (LOG_ERROR ,"Failed to create virtual window" ); +fclose (file); +return ; + } + + node->display_function (virtualWin, node, &line); + +fprintf (file,"Dump Time: %04d-%02d-%02d %02d:%02d:%02d\n\n" , + t->tm_year +1900 , t->tm_mon +1 , t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + +for (int y =0 ; y < line; ++y) { +wmove (virtualWin, y,0 ); +winnstr (virtualWin, buffer, padWidth); + buffer[padWidth] ='\0' ; +fprintf (file,"%s\n" , buffer); + } + +log_message (LOG_INFO ,"Dumped node '%s' to %s" , node->name, dump_file_path); + +delwin (virtualWin); +fclose (file); +} + +static void recursive_dump_with_progress (struct Node *node,const char *parentDir, +int *current_count,int total_count,WINDOW *progress_win) +{ +char nodeDir[512 ]; +bool hasChildren; +time_t now; +struct tm *t; + +if (!node) +return ; + + hasChildren = (node->children_size >0 ); + +if (hasChildren) { + now =time (NULL ); + t =localtime (&now); + +snprintf (nodeDir,sizeof (nodeDir),"%s/%s(%04d-%02d-%02d-%02d.%02d.%02d)" , + parentDir, node->name, t->tm_year +1900 , t->tm_mon +1 , t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + +if (mkdir (nodeDir,0777 ) ==-1 && errno !=EEXIST ) { +log_message (LOG_ERROR ,"Error creating directory %s: %s" , nodeDir, +strerror (errno)); +return ; + } + (*current_count)++; + }else { +snprintf (nodeDir,sizeof (nodeDir),"%s" , parentDir); + } + +if (node->display_function) { +single_file_dump (node, nodeDir, false); + (*current_count)++; + } + +render_progress_bar (progress_win, *current_count, total_count); + +for (int i =0 ; i < node->children_size; ++i) +recursive_dump_with_progress (&node->children[i], nodeDir, + current_count, total_count, progress_win); +} + +void display_dump_menu (struct Node *head) +{ +int total_nodes; +int winHeight, winWidth; +WINDOW *win; +int line; +int input; +int current_count; + +if (!head) { +log_message (LOG_ERROR ,"Head node is NULL, cannot dump." ); +return ; + } + + total_nodes =0 ; +count_nodes (head, &total_nodes); + +if (total_nodes ==0 ) { +log_message (LOG_INFO ,"No nodes found to dump." ); +return ; + } + +getmaxyx (stdscr, winHeight, winWidth); + + win =newwin (winHeight, winWidth,0 ,0 ); +wbkgd (win,COLOR_PAIR (6 )); +box (win,0 ,0 ); + +draw_header (win, winWidth,"DUMP MENU" ,"Press ESC to exit" ); + + line =4 ; +wattron (win,A_BOLD ); +mvwprintw (win, line++,2 ,"You are about to dump %d nodes into files." , total_nodes); + line++; +mvwprintw (win, line++,2 ,"Dumping menus under the path: %s" , head->name); + line++; +wattroff (win,A_BOLD ); +mvwprintw (win, line++,2 ,"Proceed with dump? (y to confirm, ESC to cancel)" ); +wrefresh (win); + + input =wgetch (win); +if (input !='y' && input !='Y' ) { +delwin (win); +return ; + } + +log_message (LOG_INFO ,"Starting dump from node: %s" , head->name); + +if (mkdir (DUMP_DIR ,0777 ) ==-1 && errno !=EEXIST ) { +log_message (LOG_ERROR ,"Failed to create dump directory: %s" ,strerror (errno)); +delwin (win); +return ; + } + + line++; +mvwprintw (win, line++,2 ,"Progress:" ); +wrefresh (win); + + current_count =0 ; +recursive_dump_with_progress (head,DUMP_DIR , ¤t_count, total_nodes, win); + +mvwprintw (win, line +2 ,2 ,"Dumping is over. Press any key to go back." ); +wrefresh (win); +getch (); + +delwin (win); +endwin (); +}tools/displaytop/src/display_search_bar.c new file +268
-0@@ -0,0 +1,268 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include <form.h> + +#include "display.h" +#include "utils.h" + +/** +* @brief Constructs a search path from a given node to the head node. +* +* This function constructs a search path string from the given node to the head node. +* The path is constructed by traversing from the given node up to the head node, +* appending each node's name to the path string, separated by " > ". +* +* @param node Pointer to the starting node. +* @param head Pointer to the head node until which path is required. +* @return A dynamically allocated string representing the search path. +* The caller is responsible for freeing the allocated memory. +* Returns NULL if either node or head is NULL. +*/ +static char *construct_search_path (struct Node *node,struct Node *head) +{ +char buffer[1024 ]; +char temp[1024 ]; +char *path; +struct Node *current; + +if (!node || !head) +return NULL ; + + buffer[0 ] ='\0' ; + path =NULL ; + current = node; + +while (current &&strcmp (current->name, head->name) !=0 ) { +if (snprintf (temp,sizeof (temp),"%s%s%s" , current->name, buffer[0 ] ? +" > " :"" , buffer) >= (int )sizeof (temp)) { +log_message (LOG_ERROR ,"Path string truncated: %s%s%s" , + current->name, buffer[0 ] ?" > " :"" , buffer); +return NULL ; + } +strncpy (buffer, temp,sizeof (buffer) -1 ); + buffer[sizeof (buffer) -1 ] ='\0' ; + current = current->parent; + } + + path = (char *)malloc (strlen (buffer) +1 ); +if (path) +strcpy (path, buffer); + +return path; +} + +/** +* @brief Displays the children of a given node in a new window. +* +* This function displays the children of a given node in a new window. +* The user can navigate through the children using the arrow keys and select a +* child by pressing Enter. +* The function returns the selected child node. +* +* @param node Pointer to the node whose children are to be displayed. +* @param head Pointer to the head node (current location in DisplayTop). +* @return Pointer to the selected child node. +* Returns NULL if either node or node->children is NULL. +*/ +static struct Node *display_children (struct Node *node,struct Node *head) +{ +int rows, cols; +int line; +int pad_pos; +int highlighted_index; +int ch; +WINDOW *pad; + +if (!node || !node->children) +return NULL ; + +getmaxyx (stdscr, rows, cols); + + line =0 ; + pad_pos =0 ; + highlighted_index =0 ; + pad =newpad (100 , cols -2 ); + +if (!pad) +return NULL ; + +wbkgd (pad,COLOR_PAIR (6 )); + +if (node->children_size >0 ) { + line++; + +for (int i =0 ; i < node->children_size; ++i) { +if (highlighted_index == i) +wattron (pad,A_REVERSE ); + +mvwprintw (pad, line + i,1 ,"%d. %s - %s" , i +1 , node->children[i].name, +construct_search_path (&node->children[i], head)); +wattroff (pad,A_REVERSE ); + } +prefresh (pad, pad_pos,0 ,8 ,1 , rows -2 , cols -2 ); + } + +while ((ch =getch ()) !=27 ) { +if (pad_pos >0 ) +mvwprintw (pad,0 , cols -5 ,"..." ); +else +mvwprintw (pad,0 , cols -5 ," " ); + +if (pad_pos < node->children_size - (rows -8 )) +mvwprintw (pad, rows -1 , cols -5 ,"..." ); +else +mvwprintw (pad, rows -1 , cols -5 ," " ); + +switch (ch) { +case KEY_UP : +if (highlighted_index >0 ) { + highlighted_index--; + pad_pos = (highlighted_index < pad_pos) ? highlighted_index : + pad_pos; + } +break ; +case KEY_DOWN : +if (highlighted_index < node->children_size -1 ) { + highlighted_index++; + pad_pos = (highlighted_index >= pad_pos + rows -8 ) ? + highlighted_index - rows +8 : pad_pos; + } +break ; +case '\n' : +delwin (pad); +return &node->children[highlighted_index]; +default : +break ; + } + +for (int i =0 ; i < node->children_size; ++i) { +if (highlighted_index == i) +wattron (pad,A_REVERSE ); + +mvwprintw (pad, line + i,1 ,"%d. %s - %s" , i +1 , node->children[i].name, +construct_search_path (&node->children[i], head)); +wattroff (pad,A_REVERSE ); + } +prefresh (pad, pad_pos,0 ,8 ,1 , rows -2 , cols -2 ); + } + +delwin (pad); +return head; +} + +struct Node *display_search_bar (struct Node *head) +{ +int rows, cols; +WINDOW *win; +FIELD * fields[2 ]; +FORM *form; +char input_buffer[256 ]; +int ch, pos; +struct Node *results; +struct Node *result; + +memset (input_buffer,0 ,sizeof (input_buffer)); + pos =0 ; + +getmaxyx (stdscr, rows, cols); + win =newwin (rows, cols,0 ,0 ); +wbkgd (win,COLOR_PAIR (6 )); +keypad (win, TRUE); +box (win,0 ,0 ); + +print_bold_text (win,1 ,1 ,"Search Menu" ); +mvwprintw (win,1 , (cols -strlen ("Searching under: %s" )) /2 ,"Searching under: %s" , + head->name); +mvwprintw (win,1 , cols -strlen ("Press 'Esc' to exit " ) -1 ,"Press 'Esc' to exit" ); +mvwhline (win,2 ,1 ,0 , cols -2 ); +mvwhline (win,6 ,1 ,0 , cols -2 ); + + fields[0 ] =new_field (1 , cols -4 ,1 ,1 ,0 ,0 ); + fields[1 ] =NULL ; + +set_field_back (fields[0 ],A_UNDERLINE ); +field_opts_off (fields[0 ],O_AUTOSKIP ); + + form =new_form (fields); +set_form_win (form, win); +set_form_sub (form,derwin (win,3 , cols -2 ,3 ,1 )); + +wbkgd (form_sub (form),COLOR_PAIR (7 )); +box (form_sub (form),0 ,0 ); +post_form (form); +wrefresh (win); + +while ((ch =getch ()) !=27 ) { +switch (ch) { +case KEY_BACKSPACE : +case 127 : +case 8 : +if (pos >0 ) { + pos--; + input_buffer[pos] ='\0' ; +form_driver (form,REQ_DEL_PREV ); + } +break ; +case '\n' : +if (pos >0 ) { + results =create_node ("Search Results" ,NULL ,NULL ); +search_nodes (head, input_buffer, results); +if (results->children_size !=0 ) { +unpost_form (form); +print_bold_text (win,7 ,2 ,"%d hits" , + results->children_size); +wrefresh (win); + result =display_children (results, head); +free_form (form); +free_field (fields[0 ]); +delwin (win); +endwin (); +return result; + } +print_bold_text (win,7 ,2 ,"No results found" ); + } +break ; +default : +if (pos < (int )(sizeof (input_buffer) -1 )) { + input_buffer[pos++] = ch; + input_buffer[pos] ='\0' ; +form_driver (form, ch); + } +break ; + } +wrefresh (win); + } + +unpost_form (form); +wrefresh (win); + +getch (); +free_form (form); +free_field (fields[0 ]); +delwin (win); +endwin (); + +return head; +}tools/displaytop/src/display_summary.c new file +279
-0@@ -0,0 +1,279 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "display.h" +#include "utils.h" + +#define MAX_WIDTH getmaxx(pad) +#define MAX_ENCODERS_PER_ROW ((MAX_WIDTH - 11) / 8) + +static void display_encoders (WINDOW *pad,drmModeRes *resources,int *line) +{ +int col_width =6 ; +int max_per_row =MAX_ENCODERS_PER_ROW ; +int start, end, i; +drmModeEncoder *encoder; + +wattron (pad,A_BOLD ); +mvwprintw (pad, (*line)++,1 ,"Encoders - %d" , resources->count_encoders); +wattroff (pad,A_BOLD ); + +for (start =0 ; start < resources->count_encoders; start += max_per_row) { + end = (start + max_per_row < resources->count_encoders) ? + (start + max_per_row) : resources->count_encoders; + +mvwprintw (pad, (*line)++,2 ,"Encoder ID |" ); +for (i = start; i < end; i++) { + encoder =drmModeGetEncoder (drm_fd, resources->encoders[i]); +if (encoder) { +mvwprintw (pad, (*line) -1 ,14 + ((i - start) * (col_width +1 )), +"%*d" , col_width, encoder->encoder_id); +wprintw (pad,"|" ); +drmModeFreeEncoder (encoder); + }else { +mvwprintw (pad, (*line) -1 ,14 + ((i - start) * (col_width +1 )), +"%*s" , col_width,"N/A" ); +wprintw (pad,"|" ); + } + } + +mvwprintw (pad, (*line)++,2 ,"Type |" ); +for (i = start; i < end; i++) { + encoder =drmModeGetEncoder (drm_fd, resources->encoders[i]); +if (encoder) { +mvwprintw (pad, (*line) -1 ,14 + ((i - start) * (col_width +1 )), +"%*s" , col_width, +get_encoder_type_name (encoder->encoder_type)); +wprintw (pad,"|" ); +drmModeFreeEncoder (encoder); + }else { +mvwprintw (pad, (*line) -1 ,14 + ((i - start) * (col_width +1 )), +"%*s" , col_width,"N/A" ); +wprintw (pad,"|" ); + } + } + +mvwprintw (pad, (*line)++,2 ,"CRTC ID |" ); +for (i = start; i < end; i++) { + encoder =drmModeGetEncoder (drm_fd, resources->encoders[i]); +if (encoder) { +if (encoder->crtc_id !=0 ) { +wattron (pad,A_BOLD |COLOR_PAIR (2 )); +mvwprintw (pad, (*line) -1 , +14 + ((i - start) * (col_width +1 )),"%*d" , + col_width, encoder->crtc_id); +wattroff (pad,A_BOLD |COLOR_PAIR (2 )); +wprintw (pad,"|" ); + }else { +mvwprintw (pad, (*line) -1 , +14 + ((i - start) * (col_width +1 )),"%*d" , + col_width, encoder->crtc_id); +wprintw (pad,"|" ); + } +drmModeFreeEncoder (encoder); + }else { +mvwprintw (pad, (*line) -1 ,14 + ((i - start) * (col_width +1 )), +"%*s" , col_width,"N/A" ); +wprintw (pad,"|" ); + } + } + (*line) +=1 ; + } +} + +void display_summary (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +int col_width; +drmModeRes *resources =NULL ; +drmModeCrtc *crtc =NULL ; +drmVersionPtr version =NULL ; +uint64_t value; +drmDevicePtr devices[8 ]; +int device_count; + +wclear (pad); + +print_bold_text (pad, line++,1 ,"%s Summary" , node->name); + line++; + +print_dim_text (pad, line++,1 ,"Fetching details for card: %s" ,find_drm_device (true)); + line++; + +if (drm_fd <0 ) { +mvwprintw (pad, line++,2 ,"Failed to open DRM Device!\n" ); + goto error; + } + + resources =drmModeGetResources (drm_fd); + +if (!resources) { +mvwprintw (pad, line++,2 ,"Failed to get DRM resources\n" ); + goto error; + } + +wattron (pad,A_BOLD ); +mvwprintw (pad, line++,1 ,"CRTCs - %d" , resources->count_crtcs); +wattroff (pad,A_BOLD ); + + col_width =10 ; +mvwprintw (pad, line++,2 ,"CRTC ID |" ); +for (int i =0 ; i < resources->count_crtcs; i++) { + crtc =drmModeGetCrtc (drm_fd, resources->crtcs[i]); + +if (crtc) { +if (crtc->mode_valid) { +wattron (pad,A_BOLD |COLOR_PAIR (2 )); +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*d" , + col_width, crtc->crtc_id); +wattroff (pad,A_BOLD |COLOR_PAIR (2 )); +wprintw (pad,"|" ); + }else { +wattron (pad,A_BOLD |COLOR_PAIR (3 )); +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*d" , + col_width, crtc->crtc_id); +wattroff (pad,A_BOLD |COLOR_PAIR (3 )); +wprintw (pad,"|" ); + } +drmModeFreeCrtc (crtc); + }else { +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*s|" , + col_width,"N/A" ); + } + } + line++; + +wattron (pad,A_BOLD ); +mvwprintw (pad, line++,1 ,"Connectors - %d" , resources->count_connectors); +wattroff (pad,A_BOLD ); + + col_width =10 ; +mvwprintw (pad, line++,2 ,"Connectors|" ); +for (int i =0 ; i < resources->count_connectors; i++) { +drmModeConnector *connector =drmModeGetConnector (drm_fd, resources->connectors[i]); + +if (connector) { +if (connector->connection ==DRM_MODE_CONNECTED ) { +wattron (pad,A_BOLD |COLOR_PAIR (2 )); +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*d" , + col_width, connector->connector_id); +wattroff (pad,A_BOLD |COLOR_PAIR (2 )); +wprintw (pad,"|" ); + }else { +wattron (pad,A_BOLD |COLOR_PAIR (3 )); +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*d" , + col_width, connector->connector_id); +wattroff (pad,A_BOLD |COLOR_PAIR (3 )); +wprintw (pad,"|" ); + } +drmModeFreeConnector (connector); + }else { +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*s|" , + col_width,"N/A" ); + } + } + +mvwprintw (pad, line++,2 ,"Type |" ); +for (int i =0 ; i < resources->count_connectors; i++) { +drmModeConnector *connector =drmModeGetConnector (drm_fd, resources->connectors[i]); + +if (connector) { +const char *type_name =get_connector_type_name (connector->connector_type); + +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*s|" , col_width, + type_name); +drmModeFreeConnector (connector); + }else { +mvwprintw (pad, line -1 ,13 + (i * (col_width +1 )),"%*s|" , col_width, +"N/A" ); + } + } + line++; + +display_encoders (pad, resources, &line); + + version =drmGetVersion (drm_fd); +if (version) { +wattron (pad,A_BOLD ); +mvwprintw (pad, line++,1 ,"DRM Driver: %s" , version->name); +wattroff (pad,A_BOLD ); +drmFreeVersion (version); + }else { +mvwprintw (pad, line++,2 ,"Failed to get DRM version" ); + } + +drmGetCap (drm_fd,DRM_CAP_TIMESTAMP_MONOTONIC , &value); +mvwprintw (pad, line++,2 ,"DRM_CAP_TIMESTAMP_MONOTONIC: %lu" , value); + +drmGetCap (drm_fd,DRM_CAP_CRTC_IN_VBLANK_EVENT , &value); +mvwprintw (pad, line++,2 ,"DRM_CAP_CRTC_IN_VBLANK_EVENT: %lu" , value); + +drmGetCap (drm_fd,DRM_CAP_ASYNC_PAGE_FLIP , &value); +mvwprintw (pad, line++,2 ,"DRM_CAP_ASYNC_PAGE_FLIP: %lu" , value); + +drmGetCap (drm_fd,DRM_CLIENT_CAP_ATOMIC , &value); +mvwprintw (pad, line++,2 ,"DRM_CLIENT_CAP_ATOMIC: %lu" , value); + +drmGetCap (drm_fd,DRM_CAP_ADDFB2_MODIFIERS , &value); +mvwprintw (pad, line++,2 ,"DRM_CAP_ADDFB2_MODIFIERS: %lu" , value); + line++; + + device_count =drmGetDevices2 (0 , devices,8 ); +if (device_count <0 ) { +mvwprintw (pad, line++,2 ,"Failed to get DRM devices" ); + }else { +for (int i =0 ; i < device_count; i++) { +if (devices[i]->available_nodes & (1 <<DRM_NODE_PRIMARY )) { +char available_nodes[256 ] ="" ; + +wattron (pad,A_BOLD ); +mvwprintw (pad, line++,1 ,"Device: PCI %04x:%04x" , + devices[i]->deviceinfo.pci->vendor_id, + devices[i]->deviceinfo.pci->device_id); +wattroff (pad,A_BOLD ); + +if (devices[i]->available_nodes & (1 <<DRM_NODE_PRIMARY )) +strcat (available_nodes,"primary, " ); +if (devices[i]->available_nodes & (1 <<DRM_NODE_RENDER )) +strcat (available_nodes,"render, " ); +if (strlen (available_nodes) >0 ) + available_nodes[strlen (available_nodes) -2 ] ='\0' ; +mvwprintw (pad, line++,2 ,"Available nodes: %s" , available_nodes); + } + } +drmFreeDevices (devices, device_count); + } + +drmModeFreeResources (resources); + + *content_line = line; +return ; + +error: +if (resources) +drmModeFreeResources (resources); + +wrefresh (pad); + *content_line = line; +}tools/displaytop/src/log.c new file +26
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "log.h" +
tools/displaytop/src/log.c line 36
Quoted 10 lines
tools/displaytop/src/log.c new file +10
-0+static FILE *log_file; + +void init_log_system (void ) +{ + log_file =fopen (LOG_FILE ,"a" ); +if (!log_file) +fprintf (stderr,"Failed to open log file: %s\n" ,LOG_FILE ); +} + +void log_message (int level,const char *format, ...)
Please check if the log messages can be replaced with IGT standard logging.
tools/displaytop/src/utils_driver.c
Quoted 1,105 lines
tools/displaytop/src/log.c new file +45
-0+{ +time_t now; +struct tm *t; +char time_str[20 ]; +const char *level_str; +va_list args; + +if (!log_file) +return ; + + now =time (NULL ); + t =localtime (&now); +strftime (time_str,sizeof (time_str),"%Y-%m-%d %H:%M:%S" , t); + +switch (level) { +case LOG_INFO : + level_str ="INFO" ; +break ; +case LOG_WARNING : + level_str ="WARNING" ; +break ; +case LOG_ERROR : + level_str ="ERROR" ; +break ; +default : + level_str ="UNKNOWN" ; +break ; + } + +va_start (args, format); +fprintf (log_file,"[%s] [%s] " , time_str, level_str); +vfprintf (log_file, format, args); +fprintf (log_file,"\n" ); +va_end (args); + +fflush (log_file); +} + +void close_log_system (void ) +{ +if (log_file) { +fclose (log_file); + log_file =NULL ; + } +}tools/displaytop/src/main.c new file +64
-0@@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include <ncurses.h> +#include <menu.h> +#include "node.h" +#include "data.h" +#include "display.h" +#include "populate.h" +#include "utils.h" + +int main (int argc,char *argv[]) +{ +handle_cli_args (argc, argv); + +init_log_system (); + +initscr (); +cbreak (); +noecho (); +start_color (); +set_escdelay (0 ); +keypad (stdscr, TRUE); + +init_pair (1 ,COLOR_WHITE ,COLOR_BLACK ); +init_pair (2 ,COLOR_GREEN ,COLOR_BLACK ); +init_pair (3 ,COLOR_RED ,COLOR_BLACK ); +init_pair (4 ,COLOR_BLACK ,COLOR_GREEN ); +init_pair (5 ,COLOR_BLACK ,COLOR_RED ); +init_pair (6 ,COLOR_BLUE ,COLOR_BLACK ); +init_pair (7 ,COLOR_BLACK ,COLOR_BLUE ); + +check_and_load_driver (); +open_primary_drm_device (); +populate_data (); +display_win (stdscr, root); + +endwin (); +close_primary_drm_device (); +close_log_system (); + +return 0 ; +}tools/displaytop/src/node.c new file +128
-0@@ -0,0 +1,128 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "node.h" + +struct Node *create_node (const char *name, +void (*display_function)(WINDOW *,struct Node *,int *), +struct Node *parent) +{ +struct Node *new_node = (struct Node *)malloc (sizeof (struct Node )); + +strncpy (new_node->name, name,sizeof (new_node->name) -1 ); + new_node->name[sizeof (new_node->name) -1 ] ='\0' ; + new_node->display_function = display_function; + new_node->parent = parent; + new_node->children =NULL ; + new_node->children_size =0 ; +return new_node; +} + +void add_child (struct Node *parent,struct Node *child) +{ + parent->children = (struct Node *)realloc (parent->children, +sizeof (struct Node ) * (parent->children_size +1 )); + parent->children[parent->children_size] = *child; + parent->children_size++; +} + +void free_tree (struct Node *root) +{ +int i; + +if (!root) +return ; + +for (i =0 ; i < root->children_size; i++) +free_tree (&root->children[i]); +free (root->children); +free (root); +} + +void print_path (struct Node *node) +{ +if (node->parent) { +print_path (node->parent); +printw (" > %s" , node->name); + }else { +printw ("%s" , node->name); + } +} + +char *get_path (struct Node *node) +{ +size_t path_size; +struct Node *current; +char *path; +char *new_path; + +if (!node) +return NULL ; + + path_size =1 ; + current = node; +while (current) { + path_size +=strlen (current->name) +3 ; + current = current->parent; + } + + path = (char *)malloc (path_size); +if (!path) +return NULL ; + path[0 ] ='\0' ; + + current = node; +while (current) { + new_path = (char *)malloc (strlen (current->name) +strlen (path) +4 ); +if (!new_path) { +free (path); +return NULL ; + } + +if (path[0 ] =='\0' ) +snprintf (new_path,strlen (current->name) +1 ,"%s" , current->name); +else +snprintf (new_path,strlen (current->name) +strlen (path) +4 ,"%s > %s" , + current->name, path); + +free (path); + path = new_path; + current = current->parent; + } + +return path; +} + +void count_nodes (struct Node *node,int *count) +{ +int i; + +if (!node) +return ; + + (*count)++; + +for (i =0 ; i < node->children_size; i++) +count_nodes (&node->children[i], count); +}tools/displaytop/src/populate.c new file +32
-0@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "data.h" +#include "populate.h" + +void populate_data (void ) +{ + root =create_node ("Display Top" , display_summary,NULL ); +initialize_display_config (); +}tools/displaytop/src/populate_display_config.c new file +271
-0@@ -0,0 +1,271 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "populate.h" + +int create_crtc_nodes (drmModeRes *resources,struct Node *parent_node,int filter); +static int create_connector_nodes (drmModeRes *resources,struct Node *parent_node,int filter); +static int create_encoder_nodes (drmModeRes *resources,struct Node *parent_node,int filter); +static int create_framebuffer_nodes (drmModeRes *resources,struct Node *parent_node,int filter); +static int create_plane_nodes (struct Node *parent_node,int filter); + +int create_crtc_nodes (drmModeRes *resources,struct Node *parent_node,int filter) +{ +int crtc_count; +int i; +char crtc_name[10 ]; +struct Node *crtc_node; +drmModeCrtc *crtc; + + crtc_count = resources->count_crtcs; +log_message (LOG_INFO ,"Creating CRTC nodes" ); + +for (i =0 ; i < crtc_count; ++i) { +if (filter !=-1 && i != filter) +continue ; + +snprintf (crtc_name,sizeof (crtc_name),"CRTC%d" , i %100 ); + crtc_node =create_node (crtc_name, display_crtc, parent_node); + + crtc =drmModeGetCrtc (drm_fd, resources->crtcs[i]); +if (!crtc) { +log_message (LOG_ERROR ,"drmModeGetCrtc failed for CRTC %d" , i %100 ); +drmModeFreeResources (resources); +return 0 ; + } + +create_plane_nodes (crtc_node, i); +create_encoder_nodes (resources, crtc_node, i); +create_connector_nodes (resources, crtc_node, i); + +add_child (parent_node, crtc_node); + +drmModeFreeCrtc (crtc); + } + +return crtc_count; +} + +int create_connector_nodes (drmModeRes *resources,struct Node *parent_node,int filter) +{ +int connector_count; +int i; +char connector_name[15 ]; +struct Node *connector_node; + + connector_count = resources->count_connectors; +log_message (LOG_INFO ,"Creating Connector nodes" ); + +for (i =0 ; i < connector_count; ++i) { +if (filter !=-1 && i != filter) +continue ; + +snprintf (connector_name,sizeof (connector_name),"Connector%d" , i %100 ); + connector_node =create_node (connector_name, display_connector, parent_node); +add_child (parent_node, connector_node); + } + +return connector_count; +} + +int create_encoder_nodes (drmModeRes *resources,struct Node *parent_node,int filter) +{ +int encoder_count; +int i; +char encoder_name[15 ]; +struct Node *encoder_node;Lines of this file are not shown. View the raw message.
tools/displaytop/src/utils_cli.c new file +65
-0Lines of this file are not shown. View the raw message.
tools/displaytop/src/utils_display.c new file +195
-0Lines of this file are not shown. View the raw message.
tools/displaytop/src/utils_driver.c new file +162
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Can this and related driver load functions be reused from similar functions in lib/igt_kmod.c?
tools/displaytop/src/utils_drm.c
Quoted 507 lines
tools/displaytop/src/utils_driver.c new file +8
-0Lines of this file are not shown. View the raw message.
tools/displaytop/src/utils_drm.c new file +493
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Most if not all of the string conversion helpers in this file should already have equivalent functions in IGT lib already. Please check if they can be reused.
Also, please check if this patch can be split logically into multiple patches. Currently its doing lots of things in a single patch.
Regards,Karthik.B.S
Quoted 144 lines
tools/displaytop/src/utils_drm.c new file +86
-0Lines of this file are not shown. View the raw message.
tools/displaytop/src/utils_search.c new file +43
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [PATCH i-g-t v2 1/4] tools/displaytop: Add Display Top - a terminal-based display pipeline monitor
Hi Karthik,
Quoted 26 lines · Karthik B S
Hi Pranay,
Quoted 23 lines · Pranay Samala
From: Adith Narein T <[email protected]>
This patch introduces
displaytop, a terminal-based tool designed for monitoring and debugging the display pipeline in real time. The initial feature focuses on providing detailed display configuration information, including:- CRTCs
- Connectors
- Encoders
- Planes
- FramebuffersThese components are presented in an organized format using a terminal UI built with
ncurses, giving developers and validation engineers a fast and accessible way to inspect the current state of the display system.Signed-off-by Pranay Samala <[email protected]>Signed-off-by Adith Narein T <[email protected]>Co-authored-by Pranay Samala <[email protected]>--- tools/displaytop/README.md | 77 ++ tools/displaytop/include/data.h | 38 +
[cut]
Quoted 4 lines
Quoted 4 lines
+---
tools/displaytop/include/data.h new file +0
-0
Quoted 8 lines
tools/displaytop/include/data.h line 5
Quoted 8 lines
tools/displaytop/include/data.h new file +5
-0@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a
Remove these lines starting from 'Permission', they are replaced by SPDX. See some other recent source file.
Regards,
Kamil
Quoted 20 lines
Quoted 7 lines
tools/displaytop/include/data.h new file +7
-0+* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next tools/displaytop/include/data.h line 22
Quoted 10 lines
tools/displaytop/include/data.h new file +10
-0+* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. Please use the latest license format on all files.
Quoted 2 lines
tools/displaytop/include/data.h new file +2
-0+*/ +
[cut]
PATCH v2 2/4 tools/displaytop: Add Display debugfs entry for display top
In reply to Pranay SamalaFrom: Adith Narein T <[email protected]>
This patch adds support for reading the Display debugfs entry to fetch display pipeline information used in the Display Top tool.
--- tools/displaytop/README.md | 1 + tools/displaytop/include/data.h | 2 + tools/displaytop/include/display.h | 2 + tools/displaytop/include/populate.h | 1 + tools/displaytop/include/utils.h | 2 + tools/displaytop/meson.build | 7 + tools/displaytop/src/display_debugfs.c | 124 ++++++++++++++++++ tools/displaytop/src/populate.c | 1 + .../displaytop/src/populate_display_debugfs.c | 96 ++++++++++++++ tools/displaytop/src/utils_driver.c | 16 +++ 10 files changed, 252 insertions(+) create mode 100644 tools/displaytop/src/display_debugfs.c create mode 100644 tools/displaytop/src/populate_display_debugfs.c
tools/displaytop/README.md +1 -0
@@ -7,6 +7,7 @@ A terminal-based tool for monitoring and debugging the display pipeline. - Terminal UI using `ncurses` - Dump feature for all the menus - Real-time display Configuration +- view Live Display Debugfs in a terminal ui ---
tools/displaytop/include/data.h +2 -0
@@ -35,4 +35,6 @@ extern struct Node *root; /* shared throughout the program */#define DRM_PRIMARY_PREFIX "card"#define DRM_RENDER_PREFIX "renderD" +#define DEBUGFS_DRI_PATH "/sys/kernel/debug/dri" +#endif
tools/displaytop/include/display.h +2 -0
@@ -44,4 +44,6 @@ void display_framebuffer(WINDOW *pad, struct Node *node, int *content_line);void display_summary (WINDOW *pad,struct Node *node,int *content_line); +void display_debugfs_file (WINDOW *pad,struct Node *node,int *content_line); +#endif
tools/displaytop/include/populate.h +1 -0
@@ -34,5 +34,6 @@void populate_data (void );void initialize_display_config (void ); +void initialize_display_debugfs (void );#endif
tools/displaytop/include/utils.h +2 -0
@@ -122,4 +122,6 @@ const char *get_basic_modifier_str(uint64_t modifier);const char *get_connector_type_name (uint32_t connector_type);const char *get_encoder_type_name (uint32_t encoder_type); +char *find_debugfs_dir (int drm_fd); +#endif
tools/displaytop/meson.build +7 -0
@@ -38,6 +38,11 @@ if have_displaytop menu_dep, form_dep, panel_dep, + igt_deps, + lib_igt_perf, + lib_igt_drm_clients, + lib_igt_drm_fdinfo, + lib_igt_profiling, ] # Source files source = files(
@@ -58,6 +63,8 @@ if have_displaytop 'src/utils_driver.c', 'src/utils_drm.c', 'src/utils_search.c', + 'src/populate_display_debugfs.c', + 'src/display_debugfs.c', ) if meson.is_subproject()
tools/displaytop/src/display_debugfs.c new file +124 -0
124 lines not on this page · raw message
tools/displaytop/src/populate.c +1 -0
@@ -29,4 +29,5 @@ void populate_data(void) { root =create_node ("Display Top" , display_summary,NULL );initialize_display_config (); +initialize_display_debugfs (); }
tools/displaytop/src/populate_display_debugfs.c new file +96 -0
96 lines not on this page · raw message
tools/displaytop/src/utils_driver.c +16 -0
@@ -23,6 +23,7 @@*/ #include "utils.h" +#include "igt_debugfs.h" static int is_driver_loaded (const char *driver) {
@@ -168,3 +169,18 @@ void check_and_load_driver(void)else show_driver_menu (); } + +char *find_debugfs_dir (int fd) +{ +char *path =malloc (PATH_MAX ); + +if (!path) +return 0 ; + +if (!igt_debugfs_path (fd, path,PATH_MAX )) { +free (path); +return 0 ; + } + +return path; +}
Signature · 1 line
2.34.1
Re: [PATCH i-g-t v2 2/4] tools/displaytop: Add Display debugfs entry for display top
Hi Pranay,
Quoted 146 lines · Pranay Samala
From: Adith Narein T <[email protected]>
This patch adds support for reading the Display debugfs entry to fetch display pipeline information used in the Display Top tool.
Signed-off-by Pranay Samala <[email protected]>Signed-off-by Adith Narein T <[email protected]>Co-authored-by Pranay Samala <[email protected]>--- tools/displaytop/README.md | 1 + tools/displaytop/include/data.h | 2 + tools/displaytop/include/display.h | 2 + tools/displaytop/include/populate.h | 1 + tools/displaytop/include/utils.h | 2 + tools/displaytop/meson.build | 7 + tools/displaytop/src/display_debugfs.c | 124 ++++++++++++++++++ tools/displaytop/src/populate.c | 1 + .../displaytop/src/populate_display_debugfs.c | 96 ++++++++++++++ tools/displaytop/src/utils_driver.c | 16 +++ 10 files changed, 252 insertions(+)create mode 100644
tools/displaytop/src/display_debugfs.ccreate mode 100644tools/displaytop/src/populate_display_debugfs.ctools/displaytop/README.md +1
-0@@ -7,6 +7,7 @@ A terminal-based tool for monitoring and debugging the display pipeline. - Terminal UI using `ncurses` - Dump feature for all the menus - Real-time display Configuration +- view Live Display Debugfs in a terminal ui ---tools/displaytop/include/data.h +2
-0@@ -35,4 +35,6 @@ extern struct Node *root; /* shared throughout the program */#define DRM_PRIMARY_PREFIX "card"#define DRM_RENDER_PREFIX "renderD" +#define DEBUGFS_DRI_PATH "/sys/kernel/debug/dri" +#endif tools/displaytop/include/display.h +2
-0@@ -44,4 +44,6 @@ void display_framebuffer(WINDOW *pad, struct Node *node, int *content_line);void display_summary (WINDOW *pad,struct Node *node,int *content_line); +void display_debugfs_file (WINDOW *pad,struct Node *node,int *content_line); +#endif tools/displaytop/include/populate.h +1
-0@@ -34,5 +34,6 @@void populate_data (void );void initialize_display_config (void ); +void initialize_display_debugfs (void );#endif tools/displaytop/include/utils.h +2
-0@@ -122,4 +122,6 @@ const char *get_basic_modifier_str(uint64_t modifier);const char *get_connector_type_name (uint32_t connector_type);const char *get_encoder_type_name (uint32_t encoder_type); +char *find_debugfs_dir (int drm_fd); +#endif tools/displaytop/meson.build +7
-0@@ -38,6 +38,11 @@ if have_displaytop menu_dep, form_dep, panel_dep, + igt_deps, + lib_igt_perf, + lib_igt_drm_clients, + lib_igt_drm_fdinfo, + lib_igt_profiling, ] # Source files source = files(@@ -58,6 +63,8 @@ if have_displaytop 'src/utils_driver.c', 'src/utils_drm.c', 'src/utils_search.c', + 'src/populate_display_debugfs.c', + 'src/display_debugfs.c', ) if meson.is_subproject()tools/displaytop/src/display_debugfs.c new file +36
-0@@ -0,0 +1,124 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "display.h" +#include "utils.h" +#include <stdio.h> +#include <stdlib.h> +#include "igt.h" + +/** +* /docs +* build_full_path - Constructs the full filesystem path for a given node in the debugfs tree. +* @node: Pointer to the Node structure for which the path is to be built. +* @full_path: Buffer to store the resulting full path as a null-terminated string. +* @size: Size of the @full_path buffer.
tools/displaytop/src/display_debugfs.c line 46
Quoted 10 lines
tools/displaytop/src/display_debugfs.c new file +10
-0+* +* This function traverses the parent hierarchy of the given node, collecting +* each node's name (excluding a trailing '*' if present), and constructs the +* relative path from the root node named "Display Debugfs" down to the given node. +* The resulting path is prefixed with the debugfs directory path (as returned by +* find_debugfs_dir()) and stored in @full_path. +* +* The function ensures that the constructed path does not exceed the provided buffer size. +*/ +static void build_full_path (struct Node *node,char *full_path,size_t size)
We should be already doing this in few of the existing tests. Can those helpers be reused here?
Regards,Karthik.B.S
Quoted 221 lines
tools/displaytop/src/display_debugfs.c new file +78
-0+{ +int i; +int depth =0 ; +char segments[20 ][256 ]; +char relative_path[1024 ] = {0 }; + +while (node && node->parent &&strcmp (node->name,"Display Debugfs" ) !=0 ) { +char *name = node->name; +size_t name_len =strlen (name); + +if (name_len >0 && name[name_len -1 ] =='*' ) +snprintf (segments[depth],sizeof (segments[depth]),"%.*s" , + (int )(name_len -1 ), name); +else +snprintf (segments[depth],sizeof (segments[depth]),"%s" , name); + + depth++; + node = node->parent; + } + +for (i = depth -1 ; i >=0 ; i--) { +strncat (relative_path,"/" ,sizeof (relative_path) -strlen (relative_path) -1 ); +strncat (relative_path, segments[i], +sizeof (relative_path) -strlen (relative_path) -1 ); + } + +snprintf (full_path, size,"%s%s" ,find_debugfs_dir (drm_fd), relative_path); +} + +void display_debugfs_file (WINDOW *pad,struct Node *node,int *content_line) +{ +int line =0 ; +int max_x =getmaxx (pad) -4 ; +int start, break_point; + +FILE *file; +char temp[1024 ]; +char buffer[1024 ]; +char full_file_path[1024 ] = {0 }; + +build_full_path (node, full_file_path,sizeof (full_file_path)); + + file =fopen (full_file_path,"r" ); +if (!file) { +print_red_text (pad, line++,1 ,"Error opening file: %s" , full_file_path); + *content_line = line; +return ; + } + +while (fgets (buffer,sizeof (buffer), file)) { + buffer[strcspn (buffer,"\n" )] ='\0' ; + + start =0 ; +while (start < (int )strlen (buffer)) { + break_point = start + max_x; +if (break_point < (int )strlen (buffer)) { +while (break_point > start && !isspace (buffer[break_point])) + break_point--; +if (break_point == start) + break_point = start + max_x; + }else { + break_point =strlen (buffer); + } + +strncpy (temp, buffer + start, break_point - start); + temp[break_point - start] ='\0' ; + +mvwprintw (pad, line++,2 ,"%s" , temp); + start = (buffer[break_point] ==' ' ) ? break_point +1 : break_point; + } + } + + line++; +mvwprintw (pad, line++,2 ,"-----------------EOF-------------------" ); + + *content_line = line; +fclose (file); +}tools/displaytop/src/populate.c +1
-0@@ -29,4 +29,5 @@ void populate_data(void) { root =create_node ("Display Top" , display_summary,NULL );initialize_display_config (); +initialize_display_debugfs (); }tools/displaytop/src/populate_display_debugfs.c new file +96
-0@@ -0,0 +1,96 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "populate.h" +#include "utils.h" +#include <stdlib.h> +#include <stdio.h> +#include "igt.h" + +static void populate_debugfs_recursive (struct Node *parent,const char *currentPath) +{ +DIR *dir; +struct dirent *entry; +char full_path[1024 ]; +char dir_name_with_asterisk[1024 ]; +struct stat pathStat; +struct Node *fileNode; +struct Node *dirNode; + + dir =opendir (currentPath); +if (!dir) { +log_message (LOG_ERROR ,"Failed to open directory: %s" , currentPath); +return ; + } + +while ((entry =readdir (dir)) !=NULL ) { +if (strcmp (entry->d_name,"." ) ==0 ||strcmp (entry->d_name,".." ) ==0 ) +continue ; + +snprintf (full_path,sizeof (full_path),"%s/%s" , currentPath, entry->d_name); + +if (stat (full_path, &pathStat) ==-1 ) { +log_message (LOG_WARNING ,"Could not stat path: %s" , full_path); +continue ; + } + +if (S_ISREG (pathStat.st_mode)) { + fileNode =create_node (entry->d_name, display_debugfs_file, parent); +add_child (parent, fileNode); + }else if (S_ISDIR (pathStat.st_mode)) { +snprintf (dir_name_with_asterisk,sizeof (dir_name_with_asterisk),"%s*" , + entry->d_name); + dirNode =create_node (dir_name_with_asterisk,NULL , parent); +populate_debugfs_recursive (dirNode, full_path); +add_child (parent, dirNode); + } + } + +closedir (dir); +} + +static void populate_debugfs (struct Node *parent) +{ +char *selected_path =find_debugfs_dir (drm_fd); + +if (!selected_path) +return ; + +populate_debugfs_recursive (parent, selected_path); +free (selected_path); +} + +void initialize_display_debugfs (void ) +{ +struct Node *display_debugfs; + + display_debugfs =create_node ("Display Debugfs" ,NULL , root); +populate_debugfs (display_debugfs); + +if (display_debugfs->children_size ==0 ) { +free (display_debugfs); +return ; + } +add_child (root, display_debugfs); +}tools/displaytop/src/utils_driver.c +16
-0@@ -23,6 +23,7 @@*/ #include "utils.h" +#include "igt_debugfs.h" static int is_driver_loaded (const char *driver) {@@ -168,3 +169,18 @@ void check_and_load_driver(void)else show_driver_menu (); } + +char *find_debugfs_dir (int fd) +{ +char *path =malloc (PATH_MAX ); + +if (!path) +return 0 ; + +if (!igt_debugfs_path (fd, path,PATH_MAX )) { +free (path); +return 0 ; + } + +return path; +}
PATCH v2 3/4 tools/displaytop: Add DPCD register read support
In reply to Pranay SamalaFrom: Adith Narein T <[email protected]>
This patch introduces DPCD (DisplayPort Configuration Data) register read support to the DisplayTop tool. It allows users to inspect the state of connected DisplayPort sinks via a terminal-based UI.
The implementation uses the DRM subsystem’s drm_dp.h header to provide official DPCD register addresses and bitfield definitions. This ensures accurate decoding and interpretation of register contents.
Features included in this patch:
- DPCD register dump per connected DisplayPort output
- Bitfield parsing and labeling using drm_dp.h macros
--- tools/displaytop/README.md | 1 + tools/displaytop/data/dpcd.json | 4661 ++++++++++++++++++++++++ tools/displaytop/include/data.h | 12 + tools/displaytop/include/display.h | 1 + tools/displaytop/include/populate.h | 1 + tools/displaytop/include/utils.h | 7 +- tools/displaytop/meson.build | 7 +- tools/displaytop/src/data.c | 13 + tools/displaytop/src/display_DPCD.c | 252 ++ tools/displaytop/src/populate.c | 1 + tools/displaytop/src/populate_DPCD.c | 233 ++ tools/displaytop/src/utils.c | 68 + tools/displaytop/src/utils_registers.c | 88 + 13 files changed, 5343 insertions(+), 2 deletions(-) create mode 100644 tools/displaytop/data/dpcd.json create mode 100644 tools/displaytop/src/display_DPCD.c create mode 100644 tools/displaytop/src/populate_DPCD.c create mode 100644 tools/displaytop/src/utils_registers.c
tools/displaytop/README.md +1 -0
@@ -8,6 +8,7 @@ A terminal-based tool for monitoring and debugging the display pipeline. - Dump feature for all the menus - Real-time display Configuration - view Live Display Debugfs in a terminal ui +- Read & view DPCD register value & bitfield information ---
tools/displaytop/data/dpcd.json new file +4661 -0
2,993 lines not on this page · raw message
tools/displaytop/src/display_DPCD.c new file +252 -0
252 lines not on this page · raw message
tools/displaytop/src/populate_DPCD.c new file +233 -0
233 lines not on this page · raw message
tools/displaytop/src/utils.c +68 -0
68 lines not on this page · raw message
tools/displaytop/src/utils_registers.c new file +88 -0
88 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH i-g-t v2 3/4] tools/displaytop: Add DPCD register read support
Hi Pranay,
The dpcd.json is good to add, but for the dpcd read and write part we already have dpcd_reg tool. Can those functions be reused here?
Regards,Karthik.B.S
Quoted 5,526 lines · Pranay Samala
From: Adith Narein T <[email protected]>
This patch introduces DPCD (DisplayPort Configuration Data) register read support to the DisplayTop tool. It allows users to inspect the state of connected DisplayPort sinks via a terminal-based UI.
The implementation uses the DRM subsystem’s
drm_dp.hheader to provide official DPCD register addresses and bitfield definitions. This ensures accurate decoding and interpretation of register contents.Features included in this patch:
- DPCD register dump per connected DisplayPort output
- Bitfield parsing and labeling usingdrm_dp.hmacrosSigned-off-by Pranay Samala <[email protected]>Signed-off-by Adith Narein T <[email protected]>Co-authored-by Pranay Samala <[email protected]>--- tools/displaytop/README.md | 1 + tools/displaytop/data/dpcd.json | 4661 ++++++++++++++++++++++++ tools/displaytop/include/data.h | 12 + tools/displaytop/include/display.h | 1 + tools/displaytop/include/populate.h | 1 + tools/displaytop/include/utils.h | 7 +- tools/displaytop/meson.build | 7 +- tools/displaytop/src/data.c | 13 + tools/displaytop/src/display_DPCD.c | 252 ++ tools/displaytop/src/populate.c | 1 + tools/displaytop/src/populate_DPCD.c | 233 ++ tools/displaytop/src/utils.c | 68 + tools/displaytop/src/utils_registers.c | 88 + 13 files changed, 5343 insertions(+), 2 deletions(-)create mode 100644
tools/displaytop/data/dpcd.jsoncreate mode 100644tools/displaytop/src/display_DPCD.ccreate mode 100644tools/displaytop/src/populate_DPCD.ccreate mode 100644tools/displaytop/src/utils_registers.ctools/displaytop/README.md +1
-0@@ -8,6 +8,7 @@ A terminal-based tool for monitoring and debugging the display pipeline. - Dump feature for all the menus - Real-time display Configuration - view Live Display Debugfs in a terminal ui +- Read & view DPCD register value & bitfield information ---tools/displaytop/data/dpcd.json new file +4661
-0@@ -0,0 +1,4661 @@ +{ + "DP_DPCD": { + "DP_DPCD_REV": { + "address": "0x000", + "bitfields": [ + { + "name": "DP_DPCD_REV_10", + "value": "0x10" + }, + { + "name": "DP_DPCD_REV_11", + "value": "0x11" + }, + { + "name": "DP_DPCD_REV_12", + "value": "0x12" + }, + { + "name": "DP_DPCD_REV_13", + "value": "0x13" + }, + { + "name": "DP_DPCD_REV_14", + "value": "0x14" + } + ] + }, + "DP_DPCD_MAX_ADD": { + "address": "0xfffff" + } + }, + "DP_MAX": { + "DP_MAX_LINK_RATE": { + "address": "0x001" + }, + "DP_MAX_LANE_COUNT": { + "address": "0x002", + "bitfields": [ + { + "name": "DP_MAX_LANE_COUNT_MASK", + "value": "0x1f" + }, + { + "name": "DP_TPS3_SUPPORTED", + "value": "(1 << 6) /* 1.2 */" + }, + { + "name": "DP_ENHANCED_FRAME_CAP", + "value": "(1 << 7)" + } + ] + }, + "DP_MAX_DOWNSPREAD": { + "address": "0x003", + "bitfields": [ + { + "name": "DP_MAX_DOWNSPREAD_0_5", + "value": "(1 << 0)" + }, + { + "name": "DP_STREAM_REGENERATION_STATUS_CAP", + "value": "(1 << 1) /* 2.0 */" + }, + { + "name": "DP_NO_AUX_HANDSHAKE_LINK_TRAINING", + "value": "(1 << 6)" + }, + { + "name": "DP_TPS4_SUPPORTED", + "value": "(1 << 7)" + } + ] + }, + "DP_MAX_DOWNSTREAM_PORTS": { + "address": "0x10" + }, + "DP_MAX_LINK_RATE_PHY_REPEATER": { + "address": "0xf0001" + }, + "DP_MAX_LANE_COUNT_PHY_REPEATER": { + "address": "0xf0004" + } + }, + "DP_NORP": { + "address": "0x004" + }, + "DP_DOWNSTREAMPORT_PRESENT": { + "address": "0x005", + "bitfields": [ + { + "name": "DP_DWN_STRM_PORT_PRESENT", + "value": "(1 << 0)" + }, + { + "name": "DP_DWN_STRM_PORT_TYPE_MASK", + "value": "0x06" + }, + { + "name": "DP_DWN_STRM_PORT_TYPE_DP", + "value": "(0 << 1)" + }, + { + "name": "DP_DWN_STRM_PORT_TYPE_ANALOG", + "value": "(1 << 1)" + }, + { + "name": "DP_DWN_STRM_PORT_TYPE_TMDS", + "value": "(2 << 1)" + }, + { + "name": "DP_DWN_STRM_PORT_TYPE_OTHER", + "value": "(3 << 1)" + }, + { + "name": "DP_FORMAT_CONVERSION", + "value": "(1 << 3)" + }, + { + "name": "DP_DETAILED_CAP_INFO_AVAILABLE", + "value": "(1 << 4) /* DPI */" + } + ] + }, + "DP_MAIN": { + "DP_MAIN_LINK_CHANNEL_CODING": { + "address": "0x006", + "bitfields": [ + { + "name": "DP_CAP_ANSI_8B10B", + "value": "(1 << 0)" + }, + { + "name": "DP_CAP_ANSI_128B132B", + "value": "(1 << 1) /* 2.0 */" + } + ] + }, + "DP_MAIN_LINK_CHANNEL_CODING_SET": { + "address": "0x108", + "bitfields": [ + { + "name": "DP_SET_ANSI_8B10B", + "value": "(1 << 0)" + }, + { + "name": "DP_SET_ANSI_128B132B", + "value": "(1 << 1)" + } + ] + }, + "DP_MAIN_LINK_CHANNEL_CODING_PHY_REPEATER": { + "address": "0xf0006", + "bitfields": [ + { + "name": "DP_PHY_REPEATER_128B132B_SUPPORTED", + "value": "(1 << 0)" + } + ] + } + }, + "DP_DOWN_STREAM_PORT_COUNT": { + "address": "0x007", + "bitfields": [ + { + "name": "DP_PORT_COUNT_MASK", + "value": "0x0f" + }, + { + "name": "DP_MSA_TIMING_PAR_IGNORED", + "value": "(1 << 6) /* eDP */" + }, + { + "name": "DP_OUI_SUPPORT", + "value": "(1 << 7)" + } + ] + }, + "DP_RECEIVE": { + "DP_RECEIVE_PORT_0_CAP_0": { + "address": "0x008", + "bitfields": [ + { + "name": "DP_LOCAL_EDID_PRESENT", + "value": "(1 << 1)" + }, + { + "name": "DP_ASSOCIATED_TO_PRECEDING_PORT", + "value": "(1 << 2)" + }, + { + "name": "DP_HBLANK_EXPANSION_CAPABLE", + "value": "(1 << 3)" + } + ] + }, + "DP_RECEIVE_PORT_0_BUFFER_SIZE": { + "address": "0x009" + }, + "DP_RECEIVE_PORT_1_CAP_0": { + "address": "0x00a" + }, + "DP_RECEIVE_PORT_1_BUFFER_SIZE": { + "address": "0x00b" + } + }, + "DP_I2C": { + "DP_I2C_SPEED_CAP": { + "address": "0x00c", + "bitfields": [ + { + "name": "DP_I2C_SPEED_1K", + "value": "0x01" + }, + { + "name": "DP_I2C_SPEED_5K", + "value": "0x02" + }, + { + "name": "DP_I2C_SPEED_10K", + "value": "0x04" + }, + { + "name": "DP_I2C_SPEED_100K", + "value": "0x08" + }, + { + "name": "DP_I2C_SPEED_400K", + "value": "0x10" + }, + { + "name": "DP_I2C_SPEED_1M", + "value": "0x20" + } + ] + }, + "DP_I2C_SPEED_CONTROL_STATUS": { + "address": "0x109" + } + }, + "DP_EDP": { + "DP_EDP_CONFIGURATION_CAP": { + "address": "0x00d", + "bitfields": [ + { + "name": "DP_ALTERNATE_SCRAMBLER_RESET_CAP", + "value": "(1 << 0)" + }, + { + "name": "DP_FRAMING_CHANGE_CAP", + "value": "(1 << 1)" + }, + { + "name": "DP_DPCD_DISPLAY_CONTROL_CAPABLE", + "value": "(1 << 3) /* edp v1.2 or higher */" + } + ] + }, + "DP_EDP_CONFIGURATION_SET": { + "address": "0x10a", + "bitfields": [ + { + "name": "DP_ALTERNATE_SCRAMBLER_RESET_ENABLE", + "value": "(1 << 0)" + }, + { + "name": "DP_FRAMING_CHANGE_ENABLE", + "value": "(1 << 1)" + }, + { + "name": "DP_PANEL_SELF_TEST_ENABLE", + "value": "(1 << 7)" + } + ] + }, + "DP_EDP_DPCD_REV": { + "address": "0x700", + "bitfields": [ + { + "name": "DP_EDP_11", + "value": "0x00" + }, + { + "name": "DP_EDP_12", + "value": "0x01" + }, + { + "name": "DP_EDP_13", + "value": "0x02" + }, + { + "name": "DP_EDP_14", + "value": "0x03" + }, + { + "name": "DP_EDP_14a", + "value": "0x04 /* eDP 1.4a */" + }, + { + "name": "DP_EDP_14b", + "value": "0x05 /* eDP 1.4b */" + }, + { + "name": "DP_EDP_15", + "value": "0x06 /* eDP 1.5 */" + } + ] + }, + "DP_EDP_GENERAL_CAP_1": { + "address": "0x701", + "bitfields": [ + { + "name": "DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP", + "value": "(1 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_PIN_ENABLE_CAP", + "value": "(1 << 1)" + }, + { + "name": "DP_EDP_BACKLIGHT_AUX_ENABLE_CAP", + "value": "(1 << 2)" + }, + { + "name": "DP_EDP_PANEL_SELF_TEST_PIN_ENABLE_CAP", + "value": "(1 << 3)" + }, + { + "name": "DP_EDP_PANEL_SELF_TEST_AUX_ENABLE_CAP", + "value": "(1 << 4)" + }, + { + "name": "DP_EDP_FRC_ENABLE_CAP", + "value": "(1 << 5)" + }, + { + "name": "DP_EDP_COLOR_ENGINE_CAP", + "value": "(1 << 6)" + }, + { + "name": "DP_EDP_SET_POWER_CAP", + "value": "(1 << 7)" + } + ] + }, + "DP_EDP_BACKLIGHT_ADJUSTMENT_CAP": { + "address": "0x702", + "bitfields": [ + { + "name": "DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP", + "value": "(1 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP", + "value": "(1 << 1)" + }, + { + "name": "DP_EDP_BACKLIGHT_BRIGHTNESS_BYTE_COUNT", + "value": "(1 << 2)" + }, + { + "name": "DP_EDP_BACKLIGHT_AUX_PWM_PRODUCT_CAP", + "value": "(1 << 3)" + }, + { + "name": "DP_EDP_BACKLIGHT_FREQ_PWM_PIN_PASSTHRU_CAP", + "value": "(1 << 4)" + }, + { + "name": "DP_EDP_BACKLIGHT_FREQ_AUX_SET_CAP", + "value": "(1 << 5)" + }, + { + "name": "DP_EDP_DYNAMIC_BACKLIGHT_CAP", + "value": "(1 << 6)" + }, + { + "name": "DP_EDP_VBLANK_BACKLIGHT_UPDATE_CAP", + "value": "(1 << 7)" + } + ] + }, + "DP_EDP_GENERAL_CAP_2": { + "address": "0x703", + "bitfields": [ + { + "name": "DP_EDP_OVERDRIVE_ENGINE_ENABLED", + "value": "(1 << 0)" + }, + { + "name": "DP_EDP_PANEL_LUMINANCE_CONTROL_CAPABLE", + "value": "(1 << 4)" + } + ] + }, + "DP_EDP_GENERAL_CAP_3": { + "address": "0x704", + "bitfields": [ + { + "name": "DP_EDP_X_REGION_CAP_MASK", + "value": "(0xf << 0)" + }, + { + "name": "DP_EDP_X_REGION_CAP_SHIFT", + "value": "0" + }, + { + "name": "DP_EDP_Y_REGION_CAP_MASK", + "value": "(0xf << 4)" + }, + { + "name": "DP_EDP_Y_REGION_CAP_SHIFT", + "value": "4" + } + ] + }, + "DP_EDP_DISPLAY_CONTROL_REGISTER": { + "address": "0x720", + "bitfields": [ + { + "name": "DP_EDP_BACKLIGHT_ENABLE", + "value": "(1 << 0)" + }, + { + "name": "DP_EDP_BLACK_VIDEO_ENABLE", + "value": "(1 << 1)" + }, + { + "name": "DP_EDP_FRC_ENABLE", + "value": "(1 << 2)" + }, + { + "name": "DP_EDP_COLOR_ENGINE_ENABLE", + "value": "(1 << 3)" + }, + { + "name": "DP_EDP_VBLANK_BACKLIGHT_UPDATE_ENABLE", + "value": "(1 << 7)" + } + ] + }, + "DP_EDP_BACKLIGHT_MODE_SET_REGISTER": { + "address": "0x721", + "bitfields": [ + { + "name": "DP_EDP_BACKLIGHT_CONTROL_MODE_MASK", + "value": "(3 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_CONTROL_MODE_PWM", + "value": "(0 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET", + "value": "(1 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD", + "value": "(2 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_CONTROL_MODE_PRODUCT", + "value": "(3 << 0)" + }, + { + "name": "DP_EDP_BACKLIGHT_FREQ_PWM_PIN_PASSTHRU_ENABLE", + "value": "(1 << 2)" + }, + { + "name": "DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE", + "value": "(1 << 3)" + }, + { + "name": "DP_EDP_DYNAMIC_BACKLIGHT_ENABLE", + "value": "(1 << 4)" + }, + { + "name": "DP_EDP_REGIONAL_BACKLIGHT_ENABLE", + "value": "(1 << 5)" + }, + { + "name": "DP_EDP_UPDATE_REGION_BRIGHTNESS", + "value": "(1 << 6) /* eDP 1.4 */" + }, + { + "name": "DP_EDP_PANEL_LUMINANCE_CONTROL_ENABLE", + "value": "(1 << 7)" + } + ] + }, + "DP_EDP_BACKLIGHT_BRIGHTNESS_MSB": { + "address": "0x722" + }, + "DP_EDP_BACKLIGHT_BRIGHTNESS_LSB": { + "address": "0x723" + }, + "DP_EDP_PWMGEN_BIT_COUNT": { + "address": "0x724" + }, + "DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN": { + "address": "0x725" + }, + "DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX": { + "address": "0x726", + "bitfields": [ + { + "name": "DP_EDP_PWMGEN_BIT_COUNT_MASK", + "value": "(0x1f << 0)" + } + ] + }, + "DP_EDP_BACKLIGHT_CONTROL_STATUS": { + "address": "0x727" + }, + "DP_EDP_BACKLIGHT_FREQ_SET": { + "address": "0x728", + "bitfields": [ + { + "name": "DP_EDP_BACKLIGHT_FREQ_BASE_KHZ", + "value": "27000" + } + ] + }, + "DP_EDP_BACKLIGHT_FREQ_CAP_MIN_MSB": { + "address": "0x72a" + }, + "DP_EDP_BACKLIGHT_FREQ_CAP_MIN_MID": { + "address": "0x72b" + }, + "DP_EDP_BACKLIGHT_FREQ_CAP_MIN_LSB": { + "address": "0x72c" + }, + "DP_EDP_BACKLIGHT_FREQ_CAP_MAX_MSB": { + "address": "0x72d" + }, + "DP_EDP_BACKLIGHT_FREQ_CAP_MAX_MID": { + "address": "0x72e" + }, + "DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB": { + "address": "0x72f" + }, + "DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET": { + "address": "0x732" + }, + "DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET": { + "address": "0x733" + }, + "DP_EDP_PANEL_TARGET_LUMINANCE_VALUE": { + "address": "0x734" + }, + "DP_EDP_REGIONAL_BACKLIGHT_BASE": { + "address": "0x740" + }, + "DP_EDP_REGIONAL_BACKLIGHT_0": { + "address": "0x741" + }, + "DP_EDP_MSO_LINK_CAPABILITIES": { + "address": "0x7a4", + "bitfields": [ + { + "name": "DP_EDP_MSO_NUMBER_OF_LINKS_MASK", + "value": "(7 << 0)" + }, + { + "name": "DP_EDP_MSO_NUMBER_OF_LINKS_SHIFT", + "value": "0" + }, + { + "name": "DP_EDP_MSO_INDEPENDENT_LINK_BIT", + "value": "(1 << 3)" + } + ] + } + }, + "DP_TRAINING": { + "DP_TRAINING_AUX_RD_INTERVAL": { + "address": "0x00e", + "bitfields": [ + { + "name": "DP_TRAINING_AUX_RD_MASK", + "value": "0x7F /* DP 1.3 */" + }, + { + "name": "DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT", + "value": "(1 << 7) /* DP 1.3 */" + } + ] + }, + "DP_TRAINING_PATTERN_SET": { + "address": "0x102", + "bitfields": [ + { + "name": "DP_TRAINING_PATTERN_DISABLE", + "value": "0" + }, + { + "name": "DP_TRAINING_PATTERN_1", + "value": "1" + }, + { + "name": "DP_TRAINING_PATTERN_2", + "value": "2" + }, + { + "name": "DP_TRAINING_PATTERN_2_CDS", + "value": "3\t /* 2.0 E11 */" + }, + { + "name": "DP_TRAINING_PATTERN_3", + "value": "3\t /* 1.2 */" + }, + { + "name": "DP_TRAINING_PATTERN_4", + "value": "7 /* 1.4 */" + }, + { + "name": "DP_TRAINING_PATTERN_MASK", + "value": "0x3" + }, + { + "name": "DP_TRAINING_PATTERN_MASK_1_4", + "value": "0xf" + }, + { + "name": "DP_LINK_QUAL_PATTERN_11_DISABLE", + "value": "(0 << 2)" + }, + { + "name": "DP_LINK_QUAL_PATTERN_11_D10_2", + "value": "(1 << 2)" + }, + { + "name": "DP_LINK_QUAL_PATTERN_11_ERROR_RATE", + "value": "(2 << 2)" + }, + { + "name": "DP_LINK_QUAL_PATTERN_11_PRBS7", + "value": "(3 << 2)" + }, + { + "name": "DP_LINK_QUAL_PATTERN_11_MASK", + "value": "(3 << 2)" + }, + { + "name": "DP_RECOVERED_CLOCK_OUT_EN", + "value": "(1 << 4)" + }, + { + "name": "DP_LINK_SCRAMBLING_DISABLE", + "value": "(1 << 5)" + }, + { + "name": "DP_SYMBOL_ERROR_COUNT_BOTH", + "value": "(0 << 6)" + }, + { + "name": "DP_SYMBOL_ERROR_COUNT_DISPARITY", + "value": "(1 << 6)" + }, + { + "name": "DP_SYMBOL_ERROR_COUNT_SYMBOL", + "value": "(2 << 6)" + }, + { + "name": "DP_SYMBOL_ERROR_COUNT_MASK", + "value": "(3 << 6)" + } + ] + }, + "DP_TRAINING_LANE0_SET": { + "address": "0x103" + }, + "DP_TRAINING_LANE1_SET": { + "address": "0x104" + }, + "DP_TRAINING_LANE2_SET": { + "address": "0x105" + }, + "DP_TRAINING_LANE3_SET": { + "address": "0x106", + "bitfields": [ + { + "name": "DP_TRAIN_VOLTAGE_SWING_MASK", + "value": "0x3" + }, + { + "name": "DP_TRAIN_VOLTAGE_SWING_SHIFT", + "value": "0" + }, + { + "name": "DP_TRAIN_MAX_SWING_REACHED", + "value": "(1 << 2)" + }, + { + "name": "DP_TRAIN_VOLTAGE_SWING_LEVEL_0", + "value": "(0 << 0)" + }, + { + "name": "DP_TRAIN_VOLTAGE_SWING_LEVEL_1", + "value": "(1 << 0)" + }, + { + "name": "DP_TRAIN_VOLTAGE_SWING_LEVEL_2", + "value": "(2 << 0)" + }, + { + "name": "DP_TRAIN_VOLTAGE_SWING_LEVEL_3", + "value": "(3 << 0)" + }, + { + "name": "DP_TRAIN_PRE_EMPHASIS_MASK", + "value": "(3 << 3)" + }, + { + "name": "DP_TRAIN_PRE_EMPH_LEVEL_0", + "value": "(0 << 3)" + }, + { + "name": "DP_TRAIN_PRE_EMPH_LEVEL_1", + "value": "(1 << 3)" + }, + { + "name": "DP_TRAIN_PRE_EMPH_LEVEL_2", + "value": "(2 << 3)" + }, + { + "name": "DP_TRAIN_PRE_EMPH_LEVEL_3", + "value": "(3 << 3)" + }, + { + "name": "DP_TRAIN_PRE_EMPHASIS_SHIFT", + "value": "3" + }, + { + "name": "DP_TRAIN_MAX_PRE_EMPHASIS_REACHED", + "value": "(1 << 5)" + }, + { + "name": "DP_TX_FFE_PRESET_VALUE_MASK", + "value": "(0xf << 0) /* 2.0 128b/132b Link Layer */" + } + ] + }, + "DP_TRAINING_LANE0_1_SET2": { + "address": "0x10f" + }, + "DP_TRAINING_LANE2_3_SET2": { + "address": "0x110", + "bitfields": [ + { + "name": "DP_LANE02_POST_CURSOR2_SET_MASK", + "value": "(3 << 0)" + }, + { + "name": "DP_LANE02_MAX_POST_CURSOR2_REACHED", + "value": "(1 << 2)" + }, + { + "name": "DP_LANE13_POST_CURSOR2_SET_MASK", + "value": "(3 << 4)" + }, + { + "name": "DP_LANE13_MAX_POST_CURSOR2_REACHED", + "value": "(1 << 6)" + } + ] + }, + "DP_TRAINING_PATTERN_SET_PHY_REPEATER1": { + "address": "0xf0010" + }, + "DP_TRAINING_LANE0_SET_PHY_REPEATER1": { + "address": "0xf0011" + }, + "DP_TRAINING_LANE1_SET_PHY_REPEATER1": { + "address": "0xf0012" + }, + "DP_TRAINING_LANE2_SET_PHY_REPEATER1": { + "address": "0xf0013" + }, + "DP_TRAINING_LANE3_SET_PHY_REPEATER1": { + "address": "0xf0014" + }, + "DP_TRAINING_AUX_RD_INTERVAL_PHY_REPEATER1": { + "address": "0xf0020" + } + }, + "DP_ADAPTER": { + "DP_ADAPTER_CAP": { + "address": "0x00f", + "bitfields": [ + { + "name": "DP_FORCE_LOAD_SENSE_CAP", + "value": "(1 << 0)" + }, + { + "name": "DP_ALTERNATE_I2C_PATTERN_CAP", + "value": "(1 << 1)" + } + ] + }, + "DP_ADAPTER_CTRL": { + "address": "0x1a0", + "bitfields": [ + { + "name": "DP_ADAPTER_CTRL_FORCE_LOAD_SENSE", + "value": "(1 << 0)" + } + ] + } + }, + "DP_SUPPORTED_LINK_RATES": { + "address": "0x010", + "bitfields": [ + { + "name": "DP_MAX_SUPPORTED_RATES", + "value": "8\t /* 16-bit little-endian */" + } + ] + }, + "DP_FAUX_CAP": { + "address": "0x020", + "bitfields": [ + { + "name": "DP_FAUX_CAP_1", + "value": "(1 << 0)" + } + ] + }, + "DP_SINK": { + "DP_SINK_VIDEO_FALLBACK_FORMATS": { + "address": "0x020", + "bitfields": [ + { + "name": "DP_FALLBACK_1024x768_60HZ_24BPP", + "value": "(1 << 0)" + }, + { + "name": "DP_FALLBACK_1280x720_60HZ_24BPP", + "value": "(1 << 1)" + }, + { + "name": "DP_FALLBACK_1920x1080_60HZ_24BPP", + "value": "(1 << 2)" + } + ] + }, + "DP_SINK_DEVICE_AUX_FRAME_SYNC_CAP": { + "address": "0x02f", + "bitfields": [ + { + "name": "DP_AUX_FRAME_SYNC_CAP", + "value": "(1 << 0)" + } + ] + }, + "DP_SINK_DEVICE_AUX_FRAME_SYNC_CONF": { + "address": "0x117", + "bitfields": [ + { + "name": "DP_AUX_FRAME_SYNC_ENABLE", + "value": "(1 << 0)" + }, + { + "name": "DP_IRQ_HPD_ENABLE", + "value": "(1 << 1)" + } + ] + }, + "DP_SINK_COUNT": { + "address": "0x200", + "bitfields": [ + { + "name": "DP_SINK_CP_READY", + "value": "(1 << 6)" + } + ] + }, + "DP_SINK_STATUS": { + "address": "0x205", + "bitfields": [ + { + "name": "DP_RECEIVE_PORT_0_STATUS", + "value": "(1 << 0)" + }, + { + "name": "DP_RECEIVE_PORT_1_STATUS", + "value": "(1 << 1)" + }, + { + "name": "DP_STREAM_REGENERATION_STATUS", + "value": "(1 << 2) /* 2.0 */" + }, + { + "name": "DP_INTRA_HOP_AUX_REPLY_INDICATION", + "value": "(1 << 3) /* 2.0 */" + } + ] + }, + "DP_SINK_OUI": { + "address": "0x400" + }, + "DP_SINK_COUNT_ESI": { + "address": "0x2002" + }, + "DP_SINK_STATUS_ESI": { + "address": "0x200f" + }, + "DP_SINK_DEVICE_PR_AND_FRAME_LOCK_STATUS": { + "address": "0x2022", + "bitfields": [ + { + "name": "DP_SINK_DEVICE_PANEL_REPLAY_STATUS_MASK", + "value": "(7 << 0)" + }, + { + "name": "DP_SINK_FRAME_LOCKED_SHIFT", + "value": "3" + }, + { + "name": "DP_SINK_FRAME_LOCKED_MASK", + "value": "(3 << 3)" + }, + { + "name": "DP_SINK_FRAME_LOCKED_STATUS_VALID_SHIFT", + "value": "5" + }, + { + "name": "DP_SINK_FRAME_LOCKED_STATUS_VALID_MASK", + "value": "(1 << 5)" + } + ] + }, + "DP_SINK_EVENT_NOTIFY": { + "address": "0x30" + } + }, + "DP_MSTM": { + "DP_MSTM_CAP": { + "address": "0x021", + "bitfields": [ + { + "name": "DP_MST_CAP", + "value": "(1 << 0)" + }, + { + "name": "DP_SINGLE_STREAM_SIDEBAND_MSG", + "value": "(1 << 1) /* 2.0 */" + } + ] + }, + "DP_MSTM_CTRL": { + "address": "0x111", + "bitfields": [ + { + "name": "DP_MST_EN", + "value": "(1 << 0)" + }, + { + "name": "DP_UP_REQ_EN", + "value": "(1 << 1)" + }, + { + "name": "DP_UPSTREAM_IS_SRC", + "value": "(1 << 2)" + } + ] + } + }, + "DP_NUMBER_OF_AUDIO_ENDPOINTS": { + "address": "0x022" + }, + "DP_AV_GRANULARITY": { + "address": "0x023", + "bitfields": [ + { + "name": "DP_AG_FACTOR_MASK", + "value": "(0xf << 0)" + }, + { + "name": "DP_AG_FACTOR_3MS", + "value": "(0 << 0)" + }, + { + "name": "DP_AG_FACTOR_2MS", + "value": "(1 << 0)" + }, + { + "name": "DP_AG_FACTOR_1MS", + "value": "(2 << 0)" + }, + { + "name": "DP_AG_FACTOR_500US", + "value": "(3 << 0)" + }, + { + "name": "DP_AG_FACTOR_200US", + "value": "(4 << 0)" + }, + { + "name": "DP_AG_FACTOR_100US", + "value": "(5 << 0)" + }, + { + "name": "DP_AG_FACTOR_10US", + "value": "(6 << 0)" + }, + { + "name": "DP_AG_FACTOR_1US", + "value": "(7 << 0)" + }, + { + "name": "DP_VG_FACTOR_MASK", + "value": "(0xf << 4)" + }, + { + "name": "DP_VG_FACTOR_3MS", + "value": "(0 << 4)" + }, + { + "name": "DP_VG_FACTOR_2MS", + "value": "(1 << 4)" + }, + { + "name": "DP_VG_FACTOR_1MS", + "value": "(2 << 4)" + }, + { + "name": "DP_VG_FACTOR_500US", + "value": "(3 << 4)" + }, + { + "name": "DP_VG_FACTOR_200US", + "value": "(4 << 4)" + }, + { + "name": "DP_VG_FACTOR_100US", + "value": "(5 << 4)" + } + ] + }, + "DP_AUD": { + "DP_AUD_DEC_LAT0": { + "address": "0x024" + }, + "DP_AUD_DEC_LAT1": { + "address": "0x025" + }, + "DP_AUD_PP_LAT0": { + "address": "0x026" + }, + "DP_AUD_PP_LAT1": { + "address": "0x027" + }, + "DP_AUD_DEL_INS0": { + "address": "0x02b" + }, + "DP_AUD_DEL_INS1": { + "address": "0x02c" + }, + "DP_AUD_DEL_INS2": { + "address": "0x02d" + } + }, + "DP_VID": { + "DP_VID_INTER_LAT": { + "address": "0x028" + }, + "DP_VID_PROG_LAT": { + "address": "0x029" + } + }, + "DP_REP_LAT": { + "address": "0x02a" + }, + "DP_RECEIVER": { + "DP_RECEIVER_ALPM_CAP": { + "address": "0x02e", + "bitfields": [ + { + "name": "DP_ALPM_CAP", + "value": "(1 << 0)" + }, + { + "name": "DP_ALPM_PM_STATE_2A_SUPPORT", + "value": "(1 << 1) /* eDP 1.5 */" + }, + { + "name": "DP_ALPM_AUX_LESS_CAP", + "value": "(1 << 2) /* eDP 1.5 */" + } + ] + }, + "DP_RECEIVER_ALPM_CONFIG": { + "address": "0x116", + "bitfields": [ + { + "name": "DP_ALPM_ENABLE", + "value": "(1 << 0)" + }, + { + "name": "DP_ALPM_LOCK_ERROR_IRQ_HPD_ENABLE", + "value": "(1 << 1) /* eDP 1.5 */" + }, + { + "name": "DP_ALPM_MODE_AUX_LESS", + "value": "(1 << 2) /* eDP 1.5 */" + } + ] + }, + "DP_RECEIVER_ALPM_STATUS": { + "address": "0x200b", + "bitfields": [ + { + "name": "DP_ALPM_LOCK_TIMEOUT_ERROR", + "value": "(1 << 0)" + } + ] + }, + "DP_RECEIVER_CAP_SIZE": { + "address": "0xf" + } + }, + "DP_GUID": { + "address": "0x030" + }, + "DP_DSC": { + "DP_DSC_SUPPORT": { + "address": "0x060", + "bitfields": [ + { + "name": "DP_DSC_DECOMPRESSION_IS_SUPPORTED", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_PASSTHROUGH_IS_SUPPORTED", + "value": "(1 << 1)" + }, + { + "name": "DP_DSC_DYNAMIC_PPS_UPDATE_SUPPORT_COMP_TO_COMP", + "value": "(1 << 2)" + }, + { + "name": "DP_DSC_DYNAMIC_PPS_UPDATE_SUPPORT_UNCOMP_TO_COMP", + "value": "(1 << 3)" + } + ] + }, + "DP_DSC_REV": { + "address": "0x061", + "bitfields": [ + { + "name": "DP_DSC_MAJOR_MASK", + "value": "(0xf << 0)" + }, + { + "name": "DP_DSC_MINOR_MASK", + "value": "(0xf << 4)" + }, + { + "name": "DP_DSC_MAJOR_SHIFT", + "value": "0" + }, + { + "name": "DP_DSC_MINOR_SHIFT", + "value": "4" + } + ] + }, + "DP_DSC_RC_BUF_BLK_SIZE": { + "address": "0x062", + "bitfields": [ + { + "name": "DP_DSC_RC_BUF_BLK_SIZE_1", + "value": "0x0" + }, + { + "name": "DP_DSC_RC_BUF_BLK_SIZE_4", + "value": "0x1" + }, + { + "name": "DP_DSC_RC_BUF_BLK_SIZE_16", + "value": "0x2" + }, + { + "name": "DP_DSC_RC_BUF_BLK_SIZE_64", + "value": "0x3" + } + ] + }, + "DP_DSC_RC_BUF_SIZE": { + "address": "0x063" + }, + "DP_DSC_SLICE_CAP_1": { + "address": "0x064", + "bitfields": [ + { + "name": "DP_DSC_1_PER_DP_DSC_SINK", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_2_PER_DP_DSC_SINK", + "value": "(1 << 1)" + }, + { + "name": "DP_DSC_4_PER_DP_DSC_SINK", + "value": "(1 << 3)" + }, + { + "name": "DP_DSC_6_PER_DP_DSC_SINK", + "value": "(1 << 4)" + }, + { + "name": "DP_DSC_8_PER_DP_DSC_SINK", + "value": "(1 << 5)" + }, + { + "name": "DP_DSC_10_PER_DP_DSC_SINK", + "value": "(1 << 6)" + }, + { + "name": "DP_DSC_12_PER_DP_DSC_SINK", + "value": "(1 << 7)" + } + ] + }, + "DP_DSC_LINE_BUF_BIT_DEPTH": { + "address": "0x065", + "bitfields": [ + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_MASK", + "value": "(0xf << 0)" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_9", + "value": "0x0" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_10", + "value": "0x1" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_11", + "value": "0x2" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_12", + "value": "0x3" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_13", + "value": "0x4" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_14", + "value": "0x5" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_15", + "value": "0x6" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_16", + "value": "0x7" + }, + { + "name": "DP_DSC_LINE_BUF_BIT_DEPTH_8", + "value": "0x8" + } + ] + }, + "DP_DSC_BLK_PREDICTION_SUPPORT": { + "address": "0x066", + "bitfields": [ + { + "name": "DP_DSC_BLK_PREDICTION_IS_SUPPORTED", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_RGB_COLOR_CONV_BYPASS_SUPPORT", + "value": "(1 << 1)" + } + ] + }, + "DP_DSC_MAX_BITS_PER_PIXEL_LOW": { + "address": "0x067" + }, + "DP_DSC_MAX_BITS_PER_PIXEL_HI": { + "address": "0x068", + "bitfields": [ + { + "name": "DP_DSC_MAX_BITS_PER_PIXEL_HI_MASK", + "value": "(0x3 << 0)" + }, + { + "name": "DP_DSC_MAX_BPP_DELTA_VERSION_MASK", + "value": "(0x3 << 5)\t/* eDP 1.5 & DP 2.0 */" + }, + { + "name": "DP_DSC_MAX_BPP_DELTA_AVAILABILITY", + "value": "(1 << 7)\t/* eDP 1.5 & DP 2.0 */" + } + ] + }, + "DP_DSC_DEC_COLOR_FORMAT_CAP": { + "address": "0x069", + "bitfields": [ + { + "name": "DP_DSC_RGB", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_YCbCr444", + "value": "(1 << 1)" + }, + { + "name": "DP_DSC_YCbCr422_Simple", + "value": "(1 << 2)" + }, + { + "name": "DP_DSC_YCbCr422_Native", + "value": "(1 << 3)" + }, + { + "name": "DP_DSC_YCbCr420_Native", + "value": "(1 << 4)" + } + ] + }, + "DP_DSC_DEC_COLOR_DEPTH_CAP": { + "address": "0x06A", + "bitfields": [ + { + "name": "DP_DSC_8_BPC", + "value": "(1 << 1)" + }, + { + "name": "DP_DSC_10_BPC", + "value": "(1 << 2)" + }, + { + "name": "DP_DSC_12_BPC", + "value": "(1 << 3)" + } + ] + }, + "DP_DSC_PEAK_THROUGHPUT": { + "address": "0x06B", + "bitfields": [ + { + "name": "DP_DSC_THROUGHPUT_MODE_0_MASK", + "value": "(0xf << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_SHIFT", + "value": "0" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_UNSUPPORTED", + "value": "0" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_340", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_400", + "value": "(2 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_450", + "value": "(3 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_500", + "value": "(4 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_550", + "value": "(5 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_600", + "value": "(6 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_650", + "value": "(7 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_700", + "value": "(8 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_750", + "value": "(9 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_800", + "value": "(10 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_850", + "value": "(11 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_900", + "value": "(12 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_950", + "value": "(13 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_1000", + "value": "(14 << 0)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_0_170", + "value": "(15 << 0) /* 1.4a */" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_MASK", + "value": "(0xf << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_SHIFT", + "value": "4" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_UNSUPPORTED", + "value": "0" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_340", + "value": "(1 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_400", + "value": "(2 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_450", + "value": "(3 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_500", + "value": "(4 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_550", + "value": "(5 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_600", + "value": "(6 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_650", + "value": "(7 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_700", + "value": "(8 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_750", + "value": "(9 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_800", + "value": "(10 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_850", + "value": "(11 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_900", + "value": "(12 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_950", + "value": "(13 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_1000", + "value": "(14 << 4)" + }, + { + "name": "DP_DSC_THROUGHPUT_MODE_1_170", + "value": "(15 << 4)" + } + ] + }, + "DP_DSC_MAX_SLICE_WIDTH": { + "address": "0x06C", + "bitfields": [ + { + "name": "DP_DSC_MIN_SLICE_WIDTH_VALUE", + "value": "2560" + }, + { + "name": "DP_DSC_SLICE_WIDTH_MULTIPLIER", + "value": "320" + } + ] + }, + "DP_DSC_SLICE_CAP_2": { + "address": "0x06D", + "bitfields": [ + { + "name": "DP_DSC_16_PER_DP_DSC_SINK", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_20_PER_DP_DSC_SINK", + "value": "(1 << 1)" + }, + { + "name": "DP_DSC_24_PER_DP_DSC_SINK", + "value": "(1 << 2)" + } + ] + }, + "DP_DSC_BITS_PER_PIXEL_INC": { + "address": "0x06F", + "bitfields": [ + { + "name": "DP_DSC_RGB_YCbCr444_MAX_BPP_DELTA_MASK", + "value": "0x1f" + }, + { + "name": "DP_DSC_RGB_YCbCr420_MAX_BPP_DELTA_MASK", + "value": "0xe0" + }, + { + "name": "DP_DSC_BITS_PER_PIXEL_1_16", + "value": "0x0" + }, + { + "name": "DP_DSC_BITS_PER_PIXEL_1_8", + "value": "0x1" + }, + { + "name": "DP_DSC_BITS_PER_PIXEL_1_4", + "value": "0x2" + }, + { + "name": "DP_DSC_BITS_PER_PIXEL_1_2", + "value": "0x3" + }, + { + "name": "DP_DSC_BITS_PER_PIXEL_1_1", + "value": "0x4" + } + ] + }, + "DP_DSC_BRANCH_OVERALL_THROUGHPUT_0": { + "address": "0x0a0" + }, + "DP_DSC_BRANCH_OVERALL_THROUGHPUT_1": { + "address": "0x0a1" + }, + "DP_DSC_BRANCH_MAX_LINE_WIDTH": { + "address": "0x0a2" + }, + "DP_DSC_ENABLE": { + "address": "0x160", + "bitfields": [ + { + "name": "DP_DECOMPRESSION_EN", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_PASSTHROUGH_EN", + "value": "(1 << 1)" + } + ] + }, + "DP_DSC_CONFIGURATION": { + "address": "0x161" + }, + "DP_DSC_SUPPORT_AND_DSC_DECODER_COUNT": { + "address": "0x2260", + "bitfields": [ + { + "name": "DP_DSC_DECODER_COUNT_MASK", + "value": "(0b111 << 5)" + }, + { + "name": "DP_DSC_DECODER_COUNT_SHIFT", + "value": "5" + } + ] + }, + "DP_DSC_MAX_SLICE_COUNT_AND_AGGREGATION_0": { + "address": "0x2270", + "bitfields": [ + { + "name": "DP_DSC_DECODER_0_MAXIMUM_SLICE_COUNT_MASK", + "value": "(1 << 0)" + }, + { + "name": "DP_DSC_DECODER_0_AGGREGATION_SUPPORT_MASK", + "value": "(0b111 << 1)" + }, + { + "name": "DP_DSC_DECODER_0_AGGREGATION_SUPPORT_SHIFT", + "value": "1" + } + ] + }, + "DP_DSC_RECEIVER_CAP_SIZE": { + "address": "0x10", + "bitfields": [ + { + "name": "EDP_PSR_RECEIVER_CAP_SIZE", + "value": "2" + }, + { + "name": "EDP_DISPLAY_CTL_CAP_SIZE", + "value": "5" + }, + { + "name": "DP_LTTPR_COMMON_CAP_SIZE", + "value": "8" + }, + { + "name": "DP_LTTPR_PHY_CAP_SIZE", + "value": "3" + } + ] + } + }, + "DP_PSR": { + "DP_PSR_SUPPORT": { + "address": "0x070", + "bitfields": [ + { + "name": "DP_PSR_IS_SUPPORTED", + "value": "1" + }, + { + "name": "DP_PSR2_IS_SUPPORTED", + "value": "2\t /* eDP 1.4 */" + }, + { + "name": "DP_PSR2_WITH_Y_COORD_IS_SUPPORTED", + "value": "3\t /* eDP 1.4a */" + }, + { + "name": "DP_PSR2_WITH_Y_COORD_ET_SUPPORTED", + "value": "4\t /* eDP 1.5, adopted eDP 1.4b SCR */" + } + ] + }, + "DP_PSR_CAPS": { + "address": "0x071", + "bitfields": [ + { + "name": "DP_PSR_NO_TRAIN_ON_EXIT", + "value": "1" + }, + { + "name": "DP_PSR_SETUP_TIME_330", + "value": "(0 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_275", + "value": "(1 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_220", + "value": "(2 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_165", + "value": "(3 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_110", + "value": "(4 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_55", + "value": "(5 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_0", + "value": "(6 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_MASK", + "value": "(7 << 1)" + }, + { + "name": "DP_PSR_SETUP_TIME_SHIFT", + "value": "1" + }, + { + "name": "DP_PSR2_SU_Y_COORDINATE_REQUIRED", + "value": "(1 << 4) /* eDP 1.4a */" + }, + { + "name": "DP_PSR2_SU_GRANULARITY_REQUIRED", + "value": "(1 << 5) /* eDP 1.4b */" + }, + { + "name": "DP_PSR2_SU_AUX_FRAME_SYNC_NOT_NEEDED", + "value": "(1 << 6)/* eDP 1.5, adopted eDP 1.4b SCR */" + } + ] + }, + "DP_PSR_EN_CFG": { + "address": "0x170", + "bitfields": [ + { + "name": "DP_PSR_ENABLE", + "value": "BIT(0)" + }, + { + "name": "DP_PSR_MAIN_LINK_ACTIVE", + "value": "BIT(1)" + }, + { + "name": "DP_PSR_CRC_VERIFICATION", + "value": "BIT(2)" + }, + { + "name": "DP_PSR_FRAME_CAPTURE", + "value": "BIT(3)" + }, + { + "name": "DP_PSR_SU_REGION_SCANLINE_CAPTURE", + "value": "BIT(4) /* eDP 1.4a */" + }, + { + "name": "DP_PSR_IRQ_HPD_WITH_CRC_ERRORS", + "value": "BIT(5) /* eDP 1.4a */" + }, + { + "name": "DP_PSR_ENABLE_PSR2", + "value": "BIT(6) /* eDP 1.4a */" + }, + { + "name": "DP_PSR_ENABLE_SU_REGION_ET", + "value": "BIT(7) /* eDP 1.5 */" + } + ] + }, + "DP_PSR_ERROR_STATUS": { + "address": "0x2006", + "bitfields": [ + { + "name": "DP_PSR_LINK_CRC_ERROR", + "value": "(1 << 0)" + }, + { + "name": "DP_PSR_RFB_STORAGE_ERROR", + "value": "(1 << 1)" + }, + { + "name": "DP_PSR_VSC_SDP_UNCORRECTABLE_ERROR", + "value": "(1 << 2) /* eDP 1.4 */" + } + ] + }, + "DP_PSR_ESI": { + "address": "0x2007", + "bitfields": [ + { + "name": "DP_PSR_CAPS_CHANGE", + "value": "(1 << 0)" + } + ] + }, + "DP_PSR_STATUS": { + "address": "0x2008", + "bitfields": [ + { + "name": "DP_PSR_SINK_INACTIVE", + "value": "0" + }, + { + "name": "DP_PSR_SINK_ACTIVE_SRC_SYNCED", + "value": "1" + }, + { + "name": "DP_PSR_SINK_ACTIVE_RFB", + "value": "2" + }, + { + "name": "DP_PSR_SINK_ACTIVE_SINK_SYNCED", + "value": "3" + }, + { + "name": "DP_PSR_SINK_ACTIVE_RESYNC", + "value": "4" + }, + { + "name": "DP_PSR_SINK_INTERNAL_ERROR", + "value": "7" + }, + { + "name": "DP_PSR_SINK_STATE_MASK", + "value": "0x07" + } + ] + } + }, + "DP_PSR2": { + "DP_PSR2_SU_X_GRANULARITY": { + "address": "0x072" + }, + "DP_PSR2_SU_Y_GRANULARITY": { + "address": "0x074" + } + }, + "DP_DOWNSTREAM_PORT_0": { + "address": "0x80", + "bitfields": [ + { + "name": "DP_DS_PORT_TYPE_MASK", + "value": "(7 << 0)" + }, + { + "name": "DP_DS_PORT_TYPE_DP", + "value": "0" + }, + { + "name": "DP_DS_PORT_TYPE_VGA", + "value": "1" + }, + { + "name": "DP_DS_PORT_TYPE_DVI", + "value": "2" + }, + { + "name": "DP_DS_PORT_TYPE_HDMI", + "value": "3" + }, + { + "name": "DP_DS_PORT_TYPE_NON_EDID", + "value": "4" + }, + { + "name": "DP_DS_PORT_TYPE_DP_DUALMODE", + "value": "5" + }, + { + "name": "DP_DS_PORT_TYPE_WIRELESS", + "value": "6" + }, + { + "name": "DP_DS_PORT_HPD", + "value": "(1 << 3)" + }, + { + "name": "DP_DS_NON_EDID_MASK", + "value": "(0xf << 4)" + }, + { + "name": "DP_DS_NON_EDID_720x480i_60", + "value": "(1 << 4)" + }, + { + "name": "DP_DS_NON_EDID_720x480i_50", + "value": "(2 << 4)" + }, + { + "name": "DP_DS_NON_EDID_1920x1080i_60", + "value": "(3 << 4)" + }, + { + "name": "DP_DS_NON_EDID_1920x1080i_50", + "value": "(4 << 4)" + }, + { + "name": "DP_DS_NON_EDID_1280x720_60", + "value": "(5 << 4)" + }, + { + "name": "DP_DS_NON_EDID_1280x720_50", + "value": "(7 << 4)" + }, + { + "name": "DP_DS_MAX_BPC_MASK", + "value": "(3 << 0)" + }, + { + "name": "DP_DS_8BPC", + "value": "0" + }, + { + "name": "DP_DS_10BPC", + "value": "1" + }, + { + "name": "DP_DS_12BPC", + "value": "2" + }, + { + "name": "DP_DS_16BPC", + "value": "3" + }, + { + "name": "DP_PCON_MAX_FRL_BW", + "value": "(7 << 2)" + }, + { + "name": "DP_PCON_MAX_0GBPS", + "value": "(0 << 2)" + }, + { + "name": "DP_PCON_MAX_9GBPS", + "value": "(1 << 2)" + }, + { + "name": "DP_PCON_MAX_18GBPS", + "value": "(2 << 2)" + }, + { + "name": "DP_PCON_MAX_24GBPS", + "value": "(3 << 2)" + }, + { + "name": "DP_PCON_MAX_32GBPS", + "value": "(4 << 2)" + }, + { + "name": "DP_PCON_MAX_40GBPS", + "value": "(5 << 2)" + }, + { + "name": "DP_PCON_MAX_48GBPS", + "value": "(6 << 2)" + }, + { + "name": "DP_PCON_SOURCE_CTL_MODE", + "value": "(1 << 5)" + }, + { + "name": "DP_DS_DVI_DUAL_LINK", + "value": "(1 << 1)" + }, + { + "name": "DP_DS_DVI_HIGH_COLOR_DEPTH", + "value": "(1 << 2)" + }, + { + "name": "DP_DS_HDMI_FRAME_SEQ_TO_FRAME_PACK", + "value": "(1 << 0)" + }, + { + "name": "DP_DS_HDMI_YCBCR422_PASS_THROUGH", + "value": "(1 << 1)" + }, + { + "name": "DP_DS_HDMI_YCBCR420_PASS_THROUGH", + "value": "(1 << 2)" + }, + { + "name": "DP_DS_HDMI_YCBCR444_TO_422_CONV", + "value": "(1 << 3)" + }, + { + "name": "DP_DS_HDMI_YCBCR444_TO_420_CONV", + "value": "(1 << 4)" + }, + { + "name": "DP_DS_HDMI_BT601_RGB_YCBCR_CONV", + "value": "(1 << 5)" + }, + { + "name": "DP_DS_HDMI_BT709_RGB_YCBCR_CONV", + "value": "(1 << 6)" + }, + { + "name": "DP_DS_HDMI_BT2020_RGB_YCBCR_CONV", + "value": "(1 << 7)" + } + ] + }, + "DP_FEC": { + "DP_FEC_CAPABILITY": { + "address": "0x090", + "bitfields": [ + { + "name": "DP_FEC_CAPABLE", + "value": "(1 << 0)" + }, + { + "name": "DP_FEC_UNCORR_BLK_ERROR_COUNT_CAP", + "value": "(1 << 1)" + }, + { + "name": "DP_FEC_CORR_BLK_ERROR_COUNT_CAP", + "value": "(1 << 2)" + }, + { + "name": "DP_FEC_BIT_ERROR_COUNT_CAP", + "value": "(1 << 3)" + } + ] + }, + "DP_FEC_CAPABILITY_1": { + "address": "0x091" + }, + "DP_FEC_CONFIGURATION": { + "address": "0x120", + "bitfields": [ + { + "name": "DP_FEC_READY", + "value": "(1 << 0)" + }, + { + "name": "DP_FEC_ERR_COUNT_SEL_MASK", + "value": "(7 << 1)" + }, + { + "name": "DP_FEC_ERR_COUNT_DIS", + "value": "(0 << 1)" + }, + { + "name": "DP_FEC_UNCORR_BLK_ERROR_COUNT", + "value": "(1 << 1)" + }, + { + "name": "DP_FEC_CORR_BLK_ERROR_COUNT", + "value": "(2 << 1)" + }, + { + "name": "DP_FEC_BIT_ERROR_COUNT", + "value": "(3 << 1)" + }, + { + "name": "DP_FEC_LANE_SELECT_MASK", + "value": "(3 << 4)" + }, + { + "name": "DP_FEC_LANE_0_SELECT", + "value": "(0 << 4)" + }, + { + "name": "DP_FEC_LANE_1_SELECT", + "value": "(1 << 4)" + }, + { + "name": "DP_FEC_LANE_2_SELECT", + "value": "(2 << 4)" + }, + { + "name": "DP_FEC_LANE_3_SELECT", + "value": "(3 << 4)" + } + ] + }, + "DP_FEC_STATUS": { + "address": "0x280", + "bitfields": [ + { + "name": "DP_FEC_DECODE_EN_DETECTED", + "value": "(1 << 0)" + }, + { + "name": "DP_FEC_DECODE_DIS_DETECTED", + "value": "(1 << 1)" + } + ] + }, + "DP_FEC_ERROR_COUNT_LSB": { + "address": "0x0281" + }, + "DP_FEC_ERROR_COUNT_MSB": { + "address": "0x0282", + "bitfields": [ + { + "name": "DP_FEC_ERROR_COUNT_MASK", + "value": "0x7F" + }, + { + "name": "DP_FEC_ERR_COUNT_VALID", + "value": "(1 << 7)" + } + ] + }, + "DP_FEC_STATUS_PHY_REPEATER1": { + "address": "0xf0290" + }, + "DP_FEC_ERROR_COUNT_PHY_REPEATER1": { + "address": "0xf0291" + }, + "DP_FEC_CAPABILITY_PHY_REPEATER1": { + "address": "0xf0294" + } + }, + "DP_PCON": { + "DP_PCON_DSC_ENCODER_CAP_SIZE": { + "address": "0xD" + }, + "DP_PCON_DSC_ENCODER": { + "address": "0x092", + "bitfields": [ + { + "name": "DP_PCON_DSC_ENCODER_SUPPORTED", + "value": "(1 << 0)" + }, + { + "name": "DP_PCON_DSC_PPS_ENC_OVERRIDE", + "value": "(1 << 1)" + } + ] + }, + "DP_PCON_DSC_VERSION": { + "address": "0x093", + "bitfields": [ + { + "name": "DP_PCON_DSC_MAJOR_MASK", + "value": "(0xF << 0)" + }, + { + "name": "DP_PCON_DSC_MINOR_MASK", + "value": "(0xF << 4)" + }, + { + "name": "DP_PCON_DSC_MAJOR_SHIFT", + "value": "0" + }, + { + "name": "DP_PCON_DSC_MINOR_SHIFT", + "value": "4" + } + ] + }, + "DP_PCON_DSC_RC_BUF_BLK_INFO": { + "address": "0x094", + "bitfields": [ + { + "name": "DP_PCON_DSC_RC_BUF_BLK_SIZE", + "value": "(0x3 << 0)" + }, + { + "name": "DP_PCON_DSC_RC_BUF_BLK_1KB", + "value": "0" + }, + { + "name": "DP_PCON_DSC_RC_BUF_BLK_4KB", + "value": "1" + }, + { + "name": "DP_PCON_DSC_RC_BUF_BLK_16KB", + "value": "2" + }, + { + "name": "DP_PCON_DSC_RC_BUF_BLK_64KB", + "value": "3" + } + ] + }, + "DP_PCON_DSC_RC_BUF_SIZE": { + "address": "0x095" + }, + "DP_PCON_DSC_SLICE_CAP_1": { + "address": "0x096", + "bitfields": [ + { + "name": "DP_PCON_DSC_1_PER_DSC_ENC", + "value": "(0x1 << 0)" + }, + { + "name": "DP_PCON_DSC_2_PER_DSC_ENC", + "value": "(0x1 << 1)" + }, + { + "name": "DP_PCON_DSC_4_PER_DSC_ENC", + "value": "(0x1 << 3)" + }, + { + "name": "DP_PCON_DSC_6_PER_DSC_ENC", + "value": "(0x1 << 4)" + }, + { + "name": "DP_PCON_DSC_8_PER_DSC_ENC", + "value": "(0x1 << 5)" + }, + { + "name": "DP_PCON_DSC_10_PER_DSC_ENC", + "value": "(0x1 << 6)" + }, + { + "name": "DP_PCON_DSC_12_PER_DSC_ENC", + "value": "(0x1 << 7)" + } + ] + }, + "DP_PCON_DSC_BUF_BIT_DEPTH": { + "address": "0x097", + "bitfields": [ + { + "name": "DP_PCON_DSC_BIT_DEPTH_MASK", + "value": "(0xF << 0)" + }, + { + "name": "DP_PCON_DSC_DEPTH_9_BITS", + "value": "0" + }, + { + "name": "DP_PCON_DSC_DEPTH_10_BITS", + "value": "1" + }, + { + "name": "DP_PCON_DSC_DEPTH_11_BITS", + "value": "2" + }, + { + "name": "DP_PCON_DSC_DEPTH_12_BITS", + "value": "3" + }, + { + "name": "DP_PCON_DSC_DEPTH_13_BITS", + "value": "4" + }, + { + "name": "DP_PCON_DSC_DEPTH_14_BITS", + "value": "5" + }, + { + "name": "DP_PCON_DSC_DEPTH_15_BITS", + "value": "6" + }, + { + "name": "DP_PCON_DSC_DEPTH_16_BITS", + "value": "7" + }, + { + "name": "DP_PCON_DSC_DEPTH_8_BITS", + "value": "8" + } + ] + }, + "DP_PCON_DSC_BLOCK_PREDICTION": { + "address": "0x098", + "bitfields": [ + { + "name": "DP_PCON_DSC_BLOCK_PRED_SUPPORT", + "value": "(0x1 << 0)" + } + ] + }, + "DP_PCON_DSC_ENC_COLOR_FMT_CAP": { + "address": "0x099", + "bitfields": [ + { + "name": "DP_PCON_DSC_ENC_RGB", + "value": "(0x1 << 0)" + }, + { + "name": "DP_PCON_DSC_ENC_YUV444", + "value": "(0x1 << 1)" + }, + { + "name": "DP_PCON_DSC_ENC_YUV422_S", + "value": "(0x1 << 2)" + }, + { + "name": "DP_PCON_DSC_ENC_YUV422_N", + "value": "(0x1 << 3)" + }, + { + "name": "DP_PCON_DSC_ENC_YUV420_N", + "value": "(0x1 << 4)" + } + ] + }, + "DP_PCON_DSC_ENC_COLOR_DEPTH_CAP": { + "address": "0x09A", + "bitfields": [ + { + "name": "DP_PCON_DSC_ENC_8BPC", + "value": "(0x1 << 1)" + }, + { + "name": "DP_PCON_DSC_ENC_10BPC", + "value": "(0x1 << 2)" + }, + { + "name": "DP_PCON_DSC_ENC_12BPC", + "value": "(0x1 << 3)" + } + ] + }, + "DP_PCON_DSC_MAX_SLICE_WIDTH": { + "address": "0x09B" + }, + "DP_PCON_DSC_SLICE_CAP_2": { + "address": "0x09C", + "bitfields": [ + { + "name": "DP_PCON_DSC_16_PER_DSC_ENC", + "value": "(0x1 << 0)" + }, + { + "name": "DP_PCON_DSC_20_PER_DSC_ENC", + "value": "(0x1 << 1)" + }, + { + "name": "DP_PCON_DSC_24_PER_DSC_ENC", + "value": "(0x1 << 2)" + } + ] + }, + "DP_PCON_DSC_BPP_INCR": { + "address": "0x09E", + "bitfields": [ + { + "name": "DP_PCON_DSC_BPP_INCR_MASK", + "value": "(0x7 << 0)" + }, + { + "name": "DP_PCON_DSC_ONE_16TH_BPP", + "value": "0" + }, + { + "name": "DP_PCON_DSC_ONE_8TH_BPP", + "value": "1" + }, + { + "name": "DP_PCON_DSC_ONE_4TH_BPP", + "value": "2" + }, + { + "name": "DP_PCON_DSC_ONE_HALF_BPP", + "value": "3" + }, + { + "name": "DP_PCON_DSC_ONE_BPP", + "value": "4" + } + ] + }, + "DP_PCON_HDMI_LINK_CONFIG_1": { + "address": "0x305A", + "bitfields": [ + { + "name": "DP_PCON_ENABLE_MAX_FRL_BW", + "value": "(7 << 0)" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_0GBPS", + "value": "0" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_9GBPS", + "value": "1" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_18GBPS", + "value": "2" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_24GBPS", + "value": "3" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_32GBPS", + "value": "4" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_40GBPS", + "value": "5" + }, + { + "name": "DP_PCON_ENABLE_MAX_BW_48GBPS", + "value": "6" + }, + { + "name": "DP_PCON_ENABLE_SOURCE_CTL_MODE", + "value": "(1 << 3)" + }, + { + "name": "DP_PCON_ENABLE_CONCURRENT_LINK", + "value": "(1 << 4)" + }, + { + "name": "DP_PCON_ENABLE_SEQUENTIAL_LINK", + "value": "(0 << 4)" + }, + { + "name": "DP_PCON_ENABLE_LINK_FRL_MODE", + "value": "(1 << 5)" + }, + { + "name": "DP_PCON_ENABLE_HPD_READY", + "value": "(1 << 6)" + }, + { + "name": "DP_PCON_ENABLE_HDMI_LINK", + "value": "(1 << 7)" + } + ] + }, + "DP_PCON_HDMI_LINK_CONFIG_2": { + "address": "0x305B", + "bitfields": [ + { + "name": "DP_PCON_MAX_LINK_BW_MASK", + "value": "(0x3F << 0)" + }, + { + "name": "DP_PCON_FRL_BW_MASK_9GBPS", + "value": "(1 << 0)" + }, + { + "name": "DP_PCON_FRL_BW_MASK_18GBPS", + "value": "(1 << 1)" + }, + { + "name": "DP_PCON_FRL_BW_MASK_24GBPS", + "value": "(1 << 2)" + }, + { + "name": "DP_PCON_FRL_BW_MASK_32GBPS", + "value": "(1 << 3)" + }, + { + "name": "DP_PCON_FRL_BW_MASK_40GBPS", + "value": "(1 << 4)" + }, + { + "name": "DP_PCON_FRL_BW_MASK_48GBPS", + "value": "(1 << 5)" + }, + { + "name": "DP_PCON_FRL_LINK_TRAIN_EXTENDED", + "value": "(1 << 6)" + }, + { + "name": "DP_PCON_FRL_LINK_TRAIN_NORMAL", + "value": "(0 << 6)" + } + ] + }, + "DP_PCON_HDMI_TX_LINK_STATUS": { + "address": "0x303B", + "bitfields": [ + { + "name": "DP_PCON_HDMI_TX_LINK_ACTIVE", + "value": "(1 << 0)" + }, + { + "name": "DP_PCON_FRL_READY", + "value": "(1 << 1)" + } + ] + }, + "DP_PCON_HDMI_POST_FRL_STATUS": { + "address": "0x3036", + "bitfields": [ + { + "name": "DP_PCON_HDMI_LINK_MODE", + "value": "(1 << 0)" + }, + { + "name": "DP_PCON_HDMI_MODE_TMDS", + "value": "0" + }, + { + "name": "DP_PCON_HDMI_MODE_FRL", + "value": "1" + }, + { + "name": "DP_PCON_HDMI_FRL_TRAINED_BW", + "value": "(0x3F << 1)" + }, + { + "name": "DP_PCON_FRL_TRAINED_BW_9GBPS", + "value": "(1 << 1)" + }, + { + "name": "DP_PCON_FRL_TRAINED_BW_18GBPS", + "value": "(1 << 2)" + }, + { + "name": "DP_PCON_FRL_TRAINED_BW_24GBPS", + "value": "(1 << 3)" + }, + { + "name": "DP_PCON_FRL_TRAINED_BW_32GBPS", + "value": "(1 << 4)" + }, + { + "name": "DP_PCON_FRL_TRAINED_BW_40GBPS", + "value": "(1 << 5)" + }, + { + "name": "DP_PCON_FRL_TRAINED_BW_48GBPS", + "value": "(1 << 6)" + } + ] + }, + "DP_PCON_HDMI_ERROR_STATUS_LN0": { + "address": "0x3037" + }, + "DP_PCON_HDMI_ERROR_STATUS_LN1": { + "address": "0x3038" + }, + "DP_PCON_HDMI_ERROR_STATUS_LN2": { + "address": "0x3039" + }, + "DP_PCON_HDMI_ERROR_STATUS_LN3": { + "address": "0x303A", + "bitfields": [ + { + "name": "DP_PCON_HDMI_ERROR_COUNT_MASK", + "value": "(0x7 << 0)" + }, + { + "name": "DP_PCON_HDMI_ERROR_COUNT_THREE_PLUS", + "value": "(1 << 0)" + }, + { + "name": "DP_PCON_HDMI_ERROR_COUNT_TEN_PLUS", + "value": "(1 << 1)" + }, + { + "name": "DP_PCON_HDMI_ERROR_COUNT_HUNDRED_PLUS", + "value": "(1 << 2)" + } + ] + }, + "DP_PCON_HDMI_PPS_OVERRIDE_BASE": { + "address": "0x3100" + }, + "DP_PCON_HDMI_PPS_OVRD_SLICE_HEIGHT": { + "address": "0x3180" + }, + "DP_PCON_HDMI_PPS_OVRD_SLICE_WIDTH": { + "address": "0x3182" + }, + "DP_PCON_HDMI_PPS_OVRD_BPP": { + "address": "0x3184" + } + }, + "DP_DFP_CAPABILITY_EXTENSION_SUPPORT": { + "address": "0x0a3" + }, + "DP_PANEL": { + "DP_PANEL_REPLAY_CAP": { + "address": "0x0b0", + "bitfields": [ + { + "name": "DP_PANEL_REPLAY_SUPPORT", + "value": "(1 << 0)" + }, + { + "name": "DP_PANEL_REPLAY_SU_SUPPORT", + "value": "(1 << 1)" + }, + { + "name": "DP_PANEL_REPLAY_EARLY_TRANSPORT_SUPPORT", + "value": "(1 << 2) /* eDP 1.5 */" + } + ] + }, + "DP_PANEL_PANEL_REPLAY_CAPABILITY": { + "address": "0xb1", + "bitfields": [ + { + "name": "DP_PANEL_PANEL_REPLAY_SU_GRANULARITY_REQUIRED", + "value": "(1 << 5)" + } + ] + }, + "DP_PANEL_PANEL_REPLAY_X_GRANULARITY": { + "address": "0xb2" + }, + "DP_PANEL_PANEL_REPLAY_Y_GRANULARITY": { + "address": "0xb4" + }, + "DP_PANEL_REPLAY_ERROR_STATUS": { + "address": "0x2020", + "bitfields": [ + { + "name": "DP_PANEL_REPLAY_LINK_CRC_ERROR", + "value": "(1 << 0)" + }, + { + "name": "DP_PANEL_REPLAY_RFB_STORAGE_ERROR", + "value": "(1 << 1)" + }, + { + "name": "DP_PANEL_REPLAY_VSC_SDP_UNCORRECTABLE_ERROR", + "value": "(1 << 2)" + } + ] + } + }, + "DP_LINK": { + "DP_LINK_BW_SET": { + "address": "0x100", + "bitfields": [ + { + "name": "DP_LINK_RATE_TABLE", + "value": "0x00 /* eDP 1.4 */" + }, + { + "name": "DP_LINK_BW_1_62", + "value": "0x06" + }, + { + "name": "DP_LINK_BW_2_7", + "value": "0x0a" + }, + { + "name": "DP_LINK_BW_5_4", + "value": "0x14 /* 1.2 */" + }, + { + "name": "DP_LINK_BW_8_1", + "value": "0x1e /* 1.4 */" + }, + { + "name": "DP_LINK_BW_10", + "value": "0x01 /* 2.0 128b/132b Link Layer */" + }, + { + "name": "DP_LINK_BW_13_5", + "value": "0x04 /* 2.0 128b/132b Link Layer */" + }, + { + "name": "DP_LINK_BW_20", + "value": "0x02 /* 2.0 128b/132b Link Layer */" + } + ] + }, + "DP_LINK_QUAL_LANE0_SET": { + "address": "0x10b" + }, + "DP_LINK_QUAL_LANE1_SET": { + "address": "0x10c" + }, + "DP_LINK_QUAL_LANE2_SET": { + "address": "0x10d" + }, + "DP_LINK_QUAL_LANE3_SET": { + "address": "0x10e", + "bitfields": [ + { + "name": "DP_LINK_QUAL_PATTERN_DISABLE", + "value": "0" + }, + { + "name": "DP_LINK_QUAL_PATTERN_D10_2", + "value": "1" + }, + { + "name": "DP_LINK_QUAL_PATTERN_ERROR_RATE", + "value": "2" + }, + { + "name": "DP_LINK_QUAL_PATTERN_PRBS7", + "value": "3" + }, + { + "name": "DP_LINK_QUAL_PATTERN_80BIT_CUSTOM", + "value": "4" + }, + { + "name": "DP_LINK_QUAL_PATTERN_CP2520_PAT_1", + "value": "5" + }, + { + "name": "DP_LINK_QUAL_PATTERN_CP2520_PAT_2", + "value": "6" + }, + { + "name": "DP_LINK_QUAL_PATTERN_CP2520_PAT_3", + "value": "7" + }, + { + "name": "DP_LINK_QUAL_PATTERN_128B132B_TPS1", + "value": "0x08" + }, + { + "name": "DP_LINK_QUAL_PATTERN_128B132B_TPS2", + "value": "0x10" + }, + { + "name": "DP_LINK_QUAL_PATTERN_PRSBS9", + "value": "0x18" + }, + { + "name": "DP_LINK_QUAL_PATTERN_PRSBS11", + "value": "0x20" + }, + { + "name": "DP_LINK_QUAL_PATTERN_PRSBS15", + "value": "0x28" + }, + { + "name": "DP_LINK_QUAL_PATTERN_PRSBS23", + "value": "0x30" + }, + { + "name": "DP_LINK_QUAL_PATTERN_PRSBS31", + "value": "0x38" + }, + { + "name": "DP_LINK_QUAL_PATTERN_CUSTOM", + "value": "0x40" + }, + { + "name": "DP_LINK_QUAL_PATTERN_SQUARE", + "value": "0x48" + }, + { + "name": "DP_LINK_QUAL_PATTERN_SQUARE_PRESHOOT_DISABLED", + "value": "0x49" + }, + { + "name": "DP_LINK_QUAL_PATTERN_SQUARE_DEEMPHASIS_DISABLED", + "value": "0x4a" + }, + { + "name": "DP_LINK_QUAL_PATTERN_SQUARE_PRESHOOT_DEEMPHASIS_DISABLED", + "value": "0x4b" + } + ] + }, + "DP_LINK_RATE_SET": { + "address": "0x115", + "bitfields": [ + { + "name": "DP_LINK_RATE_SET_SHIFT", + "value": "0" + }, + { + "name": "DP_LINK_RATE_SET_MASK", + "value": "(7 << 0)" + } + ] + }, + "DP_LINK_SERVICE_IRQ_VECTOR_ESI0": { + "address": "0x2005", + "bitfields": [ + { + "name": "RX_CAP_CHANGED", + "value": "(1 << 0)" + }, + { + "name": "LINK_STATUS_CHANGED", + "value": "(1 << 1)" + }, + { + "name": "STREAM_STATUS_CHANGED", + "value": "(1 << 2)" + }, + { + "name": "HDMI_LINK_STATUS_CHANGED", + "value": "(1 << 3)" + }, + { + "name": "CONNECTED_OFF_ENTRY_REQUESTED", + "value": "(1 << 4)" + }, + { + "name": "DP_TUNNELING_IRQ", + "value": "(1 << 5)" + } + ] + }, + "DP_LINK_ADDRESS": { + "address": "0x01" + }, + "DP_LINK_CONSTANT_N_VALUE": { + "address": "0x8000", + "bitfields": [ + { + "name": "DP_LINK_STATUS_SIZE", + "value": "6" + } + ] + } + }, + "DP_LANE": { + "DP_LANE_COUNT_SET": { + "address": "0x101", + "bitfields": [ + { + "name": "DP_LANE_COUNT_MASK", + "value": "0x0f" + }, + { + "name": "DP_LANE_COUNT_ENHANCED_FRAME_EN", + "value": "(1 << 7)" + } + ] + }, + "DP_LANE_ALIGN_STATUS_UPDATED": { + "address": "0x204", + "bitfields": [ + { + "name": "DP_INTERLANE_ALIGN_DONE", + "value": "(1 << 0)" + }, + { + "name": "DP_128B132B_DPRX_EQ_INTERLANE_ALIGN_DONE", + "value": "(1 << 2) /* 2.0 E11 */" + }, + { + "name": "DP_128B132B_DPRX_CDS_INTERLANE_ALIGN_DONE", + "value": "(1 << 3) /* 2.0 E11 */" + }, + { + "name": "DP_128B132B_LT_FAILED", + "value": "(1 << 4) /* 2.0 E11 */" + }, + { + "name": "DP_DOWNSTREAM_PORT_STATUS_CHANGED", + "value": "(1 << 6)" + }, + { + "name": "DP_LINK_STATUS_UPDATED", + "value": "(1 << 7)" + } + ] + }, + "DP_LANE_ALIGN_STATUS_UPDATED_ESI": { + "address": "0x200e" + }, + "DP_LANE_ALIGN_STATUS_UPDATED_PHY_REPEATER1": { + "address": "0xf0032" + } + }, + "DP_DOWNSPREAD_CTRL": { + "address": "0x107", + "bitfields": [ + { + "name": "DP_SPREAD_AMP_0_5", + "value": "(1 << 4)" + }, + { + "name": "DP_FIXED_VTOTAL_AS_SDP_EN_IN_PR_ACTIVE", + "value": "(1 << 6)" + }, + { + "name": "DP_MSA_TIMING_PAR_IGNORE_EN", + "value": "(1 << 7) /* eDP */" + } + ] + }, + "DP_AUDIO": { + "DP_AUDIO_DELAY0": { + "address": "0x112" + }, + "DP_AUDIO_DELAY1": { + "address": "0x113" + }, + "DP_AUDIO_DELAY2": { + "address": "0x114" + } + }, + "DP_UPSTREAM_DEVICE_DP_PWR_NEED": { + "address": "0x118", + "bitfields": [ + { + "name": "DP_PWR_NOT_NEEDED", + "value": "(1 << 0)" + } + ] + }, + "DP_EXTENDED": { + "DP_EXTENDED_DPRX_SLEEP_WAKE_TIMEOUT_GRANT": { + "address": "0x119", + "bitfields": [ + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_GRANTED", + "value": "(1 << 0)" + } + ] + }, + "DP_EXTENDED_DPRX_SLEEP_WAKE_TIMEOUT_REQUEST": { + "address": "0x2211", + "bitfields": [ + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_MASK", + "value": "0xff" + }, + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_1_MS", + "value": "0x00" + }, + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_20_MS", + "value": "0x01" + }, + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_40_MS", + "value": "0x02" + }, + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_60_MS", + "value": "0x03" + }, + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_80_MS", + "value": "0x04" + }, + { + "name": "DP_DPRX_SLEEP_WAKE_TIMEOUT_PERIOD_100_MS", + "value": "0x05" + } + ] + } + }, + "DP_SDP": { + "DP_SDP_ERROR_DETECTION_CONFIGURATION": { + "address": "0x121", + "bitfields": [ + { + "name": "DP_SDP_CRC16_128B132B_EN", + "value": "BIT(0)" + } + ] + }, + "DP_SDP_AUDIO_TIMESTAMP": { + "address": "0x01" + }, + "DP_SDP_AUDIO_STREAM": { + "address": "0x02" + }, + "DP_SDP_EXTENSION": { + "address": "0x04" + }, + "DP_SDP_AUDIO_COPYMANAGEMENT": { + "address": "0x05" + }, + "DP_SDP_ISRC": { + "address": "0x06" + }, + "DP_SDP_VSC": { + "address": "0x07" + }, + "DP_SDP_ADAPTIVE_SYNC": { + "address": "0x22" + }, + "DP_SDP_PPS": { + "address": "0x10" + }, + "DP_SDP_VSC_EXT_VESA": { + "address": "0x20" + }, + "DP_SDP_VSC_EXT_CEA": { + "address": "0x21" + }, + "DP_SDP_AUDIO_INFOFRAME_HB2": { + "address": "0x1b" + }, + "DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1": { + "address": "0x7F", + "bitfields": [ + { + "name": "EDP_VSC_PSR_STATE_ACTIVE", + "value": "(1<<0)" + }, + { + "name": "EDP_VSC_PSR_UPDATE_RFB", + "value": "(1<<1)" + }, + { + "name": "EDP_VSC_PSR_CRC_VALUES_VALID", + "value": "(1<<2)" + } + ] + } + }, + "DP_BRANCH": { + "DP_BRANCH_DEVICE_CTRL": { + "address": "0x1a1", + "bitfields": [ + { + "name": "DP_BRANCH_DEVICE_IRQ_HPD", + "value": "(1 << 0)" + } + ] + }, + "DP_BRANCH_OUI": { + "address": "0x500" + }, + "DP_BRANCH_ID": { + "address": "0x503" + }, + "DP_BRANCH_REVISION_START": { + "address": "0x509"Lines of this file are not shown. View the raw message.
tools/displaytop/src/display_DPCD.c new file +252
-0Lines of this file are not shown. View the raw message.
tools/displaytop/src/populate_DPCD.c new file +233
-0Lines of this file are not shown. View the raw message.
tools/displaytop/src/utils_registers.c new file +88
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH v2 4/4 tools/displaytop: Add ftrace support to Display Top
In reply to Pranay SamalaFrom: Adith Narein T <[email protected]>
This patch adds support for live tracing using ftrace in the DisplayTop tool. It enables real-time monitoring with options for filtering, dumping, and clearing the trace data.
Key features introduced:
- Live ftrace output visualization within the terminal UI
- Filter trace logs by register address for focused debugging
- Dump current trace buffer to a file for offline analysis
- Clear trace buffer on demand via the UI
--- tools/displaytop/README.md | 2 + tools/displaytop/include/data.h | 1 + tools/displaytop/include/display.h | 5 + tools/displaytop/include/populate.h | 1 + tools/displaytop/include/utils.h | 4 + tools/displaytop/meson.build | 6 + tools/displaytop/src/display_dump_tracing.c | 133 ++++++++ tools/displaytop/src/display_filter_tracing.c | 305 ++++++++++++++++++ tools/displaytop/src/display_ftrace.c | 98 ++++++ tools/displaytop/src/display_live_tracing.c | 115 +++++++ tools/displaytop/src/populate.c | 1 + tools/displaytop/src/populate_ftrace.c | 71 ++++ tools/displaytop/src/utils_trace.c | 61 ++++ 13 files changed, 803 insertions(+) create mode 100644 tools/displaytop/src/display_dump_tracing.c create mode 100644 tools/displaytop/src/display_filter_tracing.c create mode 100644 tools/displaytop/src/display_ftrace.c create mode 100644 tools/displaytop/src/display_live_tracing.c create mode 100644 tools/displaytop/src/populate_ftrace.c create mode 100644 tools/displaytop/src/utils_trace.c
tools/displaytop/README.md +2 -0
@@ -9,6 +9,8 @@ A terminal-based tool for monitoring and debugging the display pipeline. - Real-time display Configuration - view Live Display Debugfs in a terminal ui - Read & view DPCD register value & bitfield information +- Formatted Live trace using Ftrace +- filter the formatted ftrace by register address/range ---
tools/displaytop/include/data.h +1 -0
@@ -48,5 +48,6 @@ struct DP_mapping {struct DP_mapping **get_dp_mapping_storage (void );int *get_dp_mapping_count_ptr (void ); +#define TRACE_PATH "/sys/kernel/debug/tracing/trace"#endif
tools/displaytop/include/display.h +5 -0
@@ -46,5 +46,10 @@ void display_summary(WINDOW *pad, struct Node *node, int *content_line);void display_debugfs_file (WINDOW *pad,struct Node *node,int *content_line);void display_dpcd (WINDOW *pad,struct Node *node,int *content_line); +void display_ftrace_options (WINDOW *pad,struct Node *node,int *content_line); +void display_live_tracing (WINDOW *pad,struct Node *node,int *content_line); +void display_dump_tracing (WINDOW *pad,struct Node *node,int *content_line); +void display_filter_tracing (WINDOW *pad,struct Node *node,int *content_line); +void display_clear_ftrace (WINDOW *pad,struct Node *node,int *content_line);#endif
tools/displaytop/include/populate.h +1 -0
@@ -36,5 +36,6 @@ void populate_data(void);void initialize_display_config (void );void initialize_display_debugfs (void );void initialize_DPCD (void ); +void initialize_ftrace (void );#endif
tools/displaytop/include/utils.h +4 -0
@@ -128,5 +128,9 @@ char *find_debugfs_dir(int drm_fd);int read_dpcd_registers (const char *aux_path,unsigned char *buffer,size_t size,uint64_t offset);uint64_t parse_hex_address (const char *hex_str); +/* utils_trace.c */ +void free_cache (void ); +int clear_ftrace (void ); +void ensure_tracing_on (void );#endif
tools/displaytop/meson.build +6 -0
@@ -70,6 +70,12 @@ if have_displaytop 'src/display_DPCD.c', 'src/populate_DPCD.c', 'src/utils_registers.c', + 'src/utils_trace.c', + 'src/populate_ftrace.c', + 'src/display_ftrace.c', + 'src/display_live_tracing.c', + 'src/display_dump_tracing.c', + 'src/display_filter_tracing.c', ) if meson.is_subproject()
tools/displaytop/src/display_dump_tracing.c new file +133 -0
133 lines not on this page · raw message
tools/displaytop/src/display_filter_tracing.c new file +305 -0
305 lines not on this page · raw message
tools/displaytop/src/display_ftrace.c new file +98 -0
98 lines not on this page · raw message
tools/displaytop/src/display_live_tracing.c new file +115 -0
115 lines not on this page · raw message
tools/displaytop/src/populate.c +1 -0
@@ -31,4 +31,5 @@ void populate_data(void)initialize_display_config ();initialize_display_debugfs ();initialize_DPCD (); +initialize_ftrace (); }
tools/displaytop/src/populate_ftrace.c new file +71 -0
71 lines not on this page · raw message
tools/displaytop/src/utils_trace.c new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.34.1