summaryrefslogtreecommitdiffstats
path: root/modules.d/50drm/module-setup.sh
blob: 1fb386778c806a29589b9f28b64b49e6529d88cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash

# called by dracut
check() {
    return 255
}

# called by dracut
depends() {
    return 0
}

# called by dracut
installkernel() {
    # Include KMS capable drm drivers

    if [[ ${DRACUT_ARCH:-$(uname -m)} == arm* || ${DRACUT_ARCH:-$(uname -m)} == aarch64 ]]; then
        # arm/aarch64 specific modules needed by drm
        instmods \
            "=drivers/gpu/drm/i2c" \
            "=drivers/gpu/drm/panel" \
            "=drivers/gpu/drm/bridge" \
            "=drivers/video/backlight"
    fi

    instmods amdkfd hyperv_fb "=drivers/pwm"

    # if the hardware is present, include module even if it is not currently loaded,
    # as we could e.g. be in the installer; nokmsboot boot parameter will disable
    # loading of the driver if needed
    if [[ $hostonly ]]; then
        local i modlink modname

        for i in /sys/bus/{pci/devices,platform/devices,virtio/devices,soc/devices/soc?,vmbus/devices}/*/modalias; do
            [[ -e $i ]] || continue
            [[ -n $(< "$i") ]] || continue
            # shellcheck disable=SC2046
            if hostonly="" dracut_instmods --silent -s "drm_crtc_init|drm_dev_register|drm_encoder_init" -S "iw_handler_get_spy" $(< "$i"); then
                if strstr "$(modinfo -F filename $(< "$i") 2> /dev/null)" radeon.ko; then
                    hostonly='' instmods amdkfd
                fi
            fi
        done
        # if there is a privacy screen then its driver must be loaded before the
        # kms driver will bind, otherwise its probe() will return -EPROBE_DEFER
        # note privacy screens always register, even with e.g. nokmsboot
        for i in /sys/class/drm/privacy_screen-*/device/driver/module; do
            [[ -L $i ]] || continue
            modlink=$(readlink "$i")
            modname=$(basename "$modlink")
            instmods "$modname"
        done
    else
        dracut_instmods -o -s "drm_crtc_init|drm_dev_register|drm_encoder_init" "=drivers/gpu/drm" "=drivers/staging"
        # also include privacy screen providers (see above comment)
        # atm all providers live under drivers/platform/x86
        dracut_instmods -o -s "drm_privacy_screen_register" "=drivers/platform/x86"
    fi
}