dracut-systemd/dracut-initqueue: only start service if really needed
[dracut.git] / modules.d / 50drm / module-setup.sh
blob55a214ed997602989a491f4b290b45223aa6bf2a
1 #!/bin/bash
3 # called by dracut
4 check() {
5 return 255
8 # called by dracut
9 depends() {
10 return 0
13 # called by dracut
14 installkernel() {
15 local _modname
16 # Include KMS capable drm drivers
18 drm_module_filter() {
19 local _drm_drivers='drm_crtc_init'
20 local _ret
21 # subfunctions inherit following FDs
22 local _merge=8 _side2=9
23 function nmf1() {
24 local _fname _fcont
25 while read _fname || [ -n "$_fname" ]; do
26 case "$_fname" in
27 *.ko) _fcont="$(< $_fname)" ;;
28 *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
29 *.ko.xz) _fcont="$(xz -dc $_fname)" ;;
30 esac
31 [[ $_fcont =~ $_drm_drivers
32 && ! $_fcont =~ iw_handler_get_spy ]] \
33 && echo "$_fname"
34 done
36 function rotor() {
37 local _f1 _f2
38 while read _f1 || [ -n "$_f1" ]; do
39 echo "$_f1"
40 if read _f2; then
41 echo "$_f2" 1>&${_side2}
43 done | nmf1 1>&${_merge}
45 # Use two parallel streams to filter alternating modules.
46 set +x
47 eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
48 [[ $debug ]] && set -x
49 return 0
52 if [[ "$(uname -p)" == arm* ]]; then
53 # arm specific modules needed by drm
54 instmods \
55 "=drivers/gpu/drm/i2c" \
56 "=drivers/gpu/drm/panel" \
57 "=drivers/pwm" \
58 "=drivers/video/backlight" \
59 "=drivers/video/fbdev/omap2/displays-new" \
60 ${NULL}
63 instmods amdkfd hyperv_fb
65 for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
66 | drm_module_filter) ; do
67 # if the hardware is present, include module even if it is not currently loaded,
68 # as we could e.g. be in the installer; nokmsboot boot parameter will disable
69 # loading of the driver if needed
70 if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
71 | grep -qxf - /sys/bus/{pci/devices,soc/devices/soc?}/*/modalias 2>/dev/null; then
72 hostonly='' instmods $_modname
73 # if radeon.ko is installed, we want amdkfd also
74 if strstr "$_modname" radeon.ko; then
75 hostonly='' instmods amdkfd
77 continue
79 instmods $_modname
80 done