Skip to content

Commit bbfff6d

Browse files
committed
raspinfo: Improve display info output
Explicitly report kms/fkms/legacy and labwc/wwayfire/Xorg and generally tidy up
1 parent f3dea08 commit bbfff6d

File tree

1 file changed

+89
-69
lines changed

1 file changed

+89
-69
lines changed

raspinfo/raspinfo

Lines changed: 89 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,75 @@
88

99

1010
display_info_drm() {
11-
# If running X then can use xrandr, otherwise
12-
# dump the /sys/class entries for the displays
13-
if command -v xrandr > /dev/null &&
14-
DISPLAY=${DISPLAY:-:0} xrandr --listmonitors &>/dev/null;
15-
then
16-
echo "Running (F)KMS and X"
17-
echo
18-
19-
DISPLAY=${DISPLAY:-:0} xrandr --verbose
20-
else
21-
echo "Running (F)KMS, console"
22-
echo
23-
24-
for card in /sys/class/drm/card[0-9]-*;
25-
do
26-
echo $card
27-
28-
# if kmsprint isn't installed print basic mode info
29-
if ! command -v kmsprint > /dev/null; then
30-
if [ -f $card/modes ];
31-
then
32-
cat $card/modes
33-
else
34-
echo "No modes found"
35-
fi
36-
fi
37-
38-
if [ -f $card/edid ];
39-
then
40-
base64 $card/edid
41-
else
42-
echo "No EDID found"
43-
fi
44-
echo
45-
done
46-
fi
47-
4811
# kmsprint is more useful, but not always installed
49-
echo
5012
if command -v kmsprint > /dev/null; then
5113
kmsprint
5214
echo
5315
kmsprint -m
16+
echo
17+
kmsprint -p
5418
else
5519
echo "kmsprint is not installed. Install with: sudo apt install kms++-utils"
5620
fi
5721

5822
echo
5923

6024
# dump the /sys/class entries for the displays
25+
for card in /sys/class/drm/card[0-9]-*;
26+
do
27+
echo $card
28+
29+
if ! command -v kmsprint > /dev/null; then
30+
if [ -f $card/modes ];
31+
then
32+
cat $card/modes
33+
else
34+
echo "No modes found"
35+
fi
36+
echo
37+
fi
38+
39+
if [ -f $card/edid ];
40+
then
41+
base64 $card/edid
42+
else
43+
echo "No EDID found"
44+
fi
45+
echo
46+
done
47+
48+
# dump the /sys/kernel/debug entries for the displays
6149
cardfound=0
6250
for card in `seq 0 9`;
6351
do
6452
if sudo test -f "/sys/kernel/debug/dri/${card}/state";
6553
then
66-
for hdmi in 0 1;
67-
do
68-
if sudo test -f "/sys/kernel/debug/dri/${card}/hdmi${hdmi}_regs";
69-
then
70-
echo "HDMI${hdmi}: $(sudo cat /sys/kernel/debug/dri/$card/hdmi${hdmi}_regs | grep HOTPLUG)"
54+
for hdmi in 0 1;
55+
do
56+
if sudo test -f "/sys/kernel/debug/dri/${card}/hdmi${hdmi}_regs";
57+
then
58+
echo "HDMI${hdmi}: $(sudo cat /sys/kernel/debug/dri/$card/hdmi${hdmi}_regs | grep HOTPLUG)"
59+
fi
60+
done
61+
echo
62+
# dump the state if we don't have kmsprint
63+
if ! command -v kmsprint > /dev/null; then
64+
echo "/sys/kernel/debug/dri/$card/state:"
65+
sudo cat "/sys/kernel/debug/dri/$card/state"
66+
echo
7167
fi
72-
done
73-
echo
74-
echo "/sys/kernel/debug/dri/$card/state:"
75-
sudo cat "/sys/kernel/debug/dri/$card/state"
76-
echo
77-
cardfound=1
68+
cardfound=1
7869
fi
7970
done
8071
if [ "$cardfound" == "0" ];
8172
then
8273
echo "kms state not found"
74+
echo
8375
fi
84-
echo
85-
8676
}
8777

8878
display_info_legacy() {
8979
# Legacy mode
90-
echo "Running Legacy framebuffer"
91-
echo
92-
9380
for card in `seq 0 9`;
9481
do
9582
F="/dev/fb${card}"
@@ -100,31 +87,64 @@ display_info_legacy() {
10087
fi
10188
done
10289

103-
disps=`tvservice -l | awk '/Display Number/{print substr($3,1,1)}'`
90+
if command -v tvservice > /dev/null; then
91+
disps=`tvservice -l | awk '/Display Number/{print substr($3,1,1)}'`
10492

105-
tmp=$(mktemp)
93+
tmp=$(mktemp)
10694

107-
for display in $disps
108-
do
109-
echo
110-
echo "Display: " $display
95+
for display in $disps
96+
do
97+
echo
98+
echo "Display: " $display
11199

112-
tvservice -v $display -s
113-
tvservice -v $display -n
114-
tvservice -v $display -m CEA
115-
tvservice -v $display -m DMT
100+
tvservice -v $display -s
101+
tvservice -v $display -n
102+
tvservice -v $display -m CEA
103+
tvservice -v $display -m DMT
116104

117-
echo
118-
tvservice -v $display -d $tmp > /dev/null
119-
base64 $tmp
120-
done
105+
echo
106+
tvservice -v $display -d $tmp > /dev/null
107+
base64 $tmp
108+
echo
109+
done
121110

122-
rm $tmp
111+
rm $tmp
112+
else
113+
echo "tvservice not installed"
114+
fi
115+
116+
if pgrep Xorg > /dev/null &&
117+
command -v xrandr > /dev/null &&
118+
DISPLAY=${DISPLAY:-:0} xrandr --listmonitors &>/dev/null; then
119+
DISPLAY=${DISPLAY:-:0} xrandr --verbose
120+
echo
121+
fi
123122
}
124123

125124
display_info() {
126125
# Check if we are running a KMS/DRM system
127126

127+
if [ -f /proc/device-tree/soc/firmwarekms@*/status ] &&
128+
grep -q okay /proc/device-tree/soc/firmwarekms@*/status; then
129+
KMS=fkms
130+
elif [ -f /proc/device-tree/*/v3d@*/status ] &&
131+
grep -q okay /proc/device-tree/*/v3d@*/status; then
132+
KMS=kms
133+
else
134+
KMS=legacy
135+
fi
136+
137+
if pgrep labwc > /dev/null; then
138+
WIN=labwc
139+
elif pgrep wayfire > /dev/null; then
140+
WIN=wayfire
141+
elif pgrep Xorg > /dev/null; then
142+
WIN=Xorg
143+
else
144+
WIN=console
145+
fi
146+
echo "Using $WIN with $KMS"
147+
128148
if [ -d "/dev/dri" ];
129149
then
130150
display_info_drm

0 commit comments

Comments
 (0)