22
22
# all distro base images. The required tools, and the packages they
23
23
# reside in Debian based distros, are:
24
24
# - dash: 'sh' (minimal bourne shell)
25
- # - coreutils: 'seq', 'cat', 'echo'
25
+ # - coreutils: 'seq', 'cat', 'echo', 'id'
26
26
# - sed: 'sed'
27
27
#
28
28
# But they are also provided by 'busybox' and 'toybox' tool sets.
@@ -35,6 +35,9 @@ usage ()
35
35
echo " on standard output, or added to given command line. If device index"
36
36
echo " N is given, provides name of Nth available (Intel GPU) render device."
37
37
echo
38
+ echo " With no arguments, outputs Intel GPU render devices count from sysfs,"
39
+ echo " and how many of them are writable in devfs."
40
+ echo
38
41
echo " Usage:"
39
42
echo " $name <device index>"
40
43
echo " $name [device index] <media program> [other options] <GPU selection option>"
@@ -48,8 +51,29 @@ usage ()
48
51
exit 1
49
52
}
50
53
54
+ intel=" 0x8086"
51
55
if [ $# -eq 0 ]; then
52
- usage " no arguments given"
56
+ syscount=0
57
+ devcount=0
58
+ for i in $( seq 128 255) ; do
59
+ devfile=" /dev/dri/renderD$i "
60
+ sysfile=" /sys/class/drm/renderD$i /device/vendor"
61
+ if [ ! -r " $sysfile " ]; then
62
+ continue
63
+ fi
64
+ vendor=$( cat " $sysfile " )
65
+ if [ " $vendor " != " $intel " ]; then
66
+ continue
67
+ fi
68
+ syscount=$(( syscount+ 1 ))
69
+ if [ -w " $devfile " ]; then
70
+ devcount=$(( devcount+ 1 ))
71
+ fi
72
+ done
73
+ echo " $syscount Intel GPU render device(s) listed in sysfs, $devcount writable one(s) in devfs:"
74
+ ls -l /dev/dri/
75
+ echo " User: $( id) "
76
+ exit 0
53
77
fi
54
78
55
79
# determine required GPU index
66
90
visible=0
67
91
68
92
vendor=" "
69
- intel=" 0x8086"
70
93
# find host index "i" for Nth visible Intel GPU device
71
94
for i in $( seq 128 255) ; do
72
95
if [ -w " /dev/dri/renderD$i " ]; then
0 commit comments