summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 483d0e2b843a97f1d26b4417966536405c2125df (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Maintainer: Vasiliy Stelmachenok <ventureo@yandex.ru>
#
# Integration of the nvidia-patch from keylase.
#
# This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
# You can read more about it here: https://github.com/keylase/nvidia-patch
#
# Note: Even if you do not enable this option, the package will still install nvidia-patch
# and you can accept it at any time using the corresponding commands: nvidia-patch-nvenc and nvidia-patch-fbc.
#
# WARNING: In extreme cases, this can damage the NVENC and NvFBC libraries.
_nvidia_patch=

# This setting has a setting option for NVIDIA PowerMizer power management technology, and it is used by default even if you have not configured it.
#
# This technology supports two modes of frequency management: Adaptive Strategy and Static Strategy.
# Adaptive frequency management is used by default by the driver, and implies that if the GPU is not tasked, it is in power saving mode.
# If the GPU power becomes necessary, then it increases it to the required performance level.
# In other words, it jumps between performance levels. Within this technology, there are three levels (also called modes):
# 1 (0x1 bit) - Maximum performance
# 2 (0x2 bit) - Balance between performance and power saving
# 3 (0x3 bit) - Powersaving
# You can fix the frequencies at a certain performance level only with a static strategy.
# Now that we have the theory sorted out, you can choose what you want depending on your configuration:
#
# Possible values:
# 1 - Static strategy with maximum performance for AC operation and maximum power savings for the battery
# 2 - Static strategy with maximum performance for AC operation, but an adaptive strategy for battery operation.
# 3 - Adaptive strategy for AC operation, but static strategy with maximum power saving for the battery.
#
# Note: Setting up the PowerMizer circuitry is not overclocking the GPU and assumes safe use for your hardware.
# However, you can reassign the behavior of the power scheme through the Xorg option "RegistryDwords".
#
# Refrences: https://wins911.blogspot.com/2012/06/etcx11xorg.html
_powermizer_scheme=

# Enforces applying a certain performance level
# (see description of _powermizer_scheme option above for details),
# while activating some GPU overclocking possibilities, such as:
# controlling GPU fan speed via nvidia-settings.
#
# Possible values:
# 1 - Force a balance between performance and powersaving
# 2 - Force max performnace (recommended for gaming)
#
# These settings apply to all power sources,
# and cannot be configured for each one individually
# as _powermizer_scheme does.
#
# Warning: Works only for laptops.
_override_max_perf=

pkgname=nvidia-tweaks
pkgdesc="A collection of tweaks and improvements to the NVIDIA driver"
pkgver=545
pkgrel=2
license=('custom')
url='https://github.com/ventureoo/nvidia-tweaks'
depends=('NVIDIA-MODULE' 'nvidia-utils')
optdepends=('nvlax-git: alternative nvidia-patch')
arch=('any')
source=('nvidia.conf'
        'nvidia-tweaks.hook'
        'nvidia-patch.install'
        'nvidia-patch.remove'
        '60-nvidia.rules'
        'https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch-fbc.sh'
        'https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch.sh')
sha256sums=('dd5b97c6f69ef6ab6924cad95708a461650f314d45eefe21fd2ff5d9739a2a03'
            '91735d5de62355634c76183ba1128efb5edd96a1b5fedd970c2f2739bb203391'
            '81464bfeda86b9683a6f739a1cec1a2fe37717af5480671be70fe43f51fba420'
            'b4bde9eecd90fc9498a8d47c7bb7edfe877ae64ea9e7069c405710a76c749144'
            '003134e231827381adb83f5e6adad416d394ea4a6b66757fd643872e65fde056'
            'SKIP'
            'SKIP')

prepare() {
    registrydwords='EnableBrightnessControl=1'
    if [ ! -z $_powermizer_scheme ] && [ -z $_override_max_perf ]; then
        echo "You have selected the powermizer scheme: $_powermizer_scheme"
        echo "If you don't like it in time you can change it with the Xorg "RegistryDwords" option (in the bit value)"
        echo "or rebuild it with the new value."
        if [ "$_powermizer_scheme" = "1" ]; then
            registrydwords+=';PowerMizerEnable=0x1;PerfLevelSrc=0x2222;PowerMizerDefault=0x3;PowerMizerDefaultAC=0x1'
        elif [ "$_powermizer_scheme" = "2" ]; then
            registrydwords+=';PowerMizerEnable=0x1;PerfLevelSrc=0x3322;PowerMizerDefaultAC=0x1'
        elif [ "$_powermizer_scheme" = "3" ]; then
            registrydwords+=';PowerMizerEnable=0x1;PerfLevelSrc=0x2233;PowerMizerDefault=0x3'
	else
            echo "You have selected the wrong powermizer scheme, please reread the option description in PKGBUILD."
        fi
    fi

    if [ ! -z $_override_max_perf ] && [ -z $_powermizer_scheme ]; then
        echo "You have selected the forced performance level: $_override_max_perf"
        echo "If you don't like it in time you can change it with the Xorg "OverrideMaxPerf" option (in the bit value)"
        echo "or rebuild it with the new value."
        if [ "$_override_max_perf" = "1" ]; then
	    registrydwords+=';OverrideMaxPerf=0x2'
        elif [ "$_override_max_perf" = "2" ]; then
	    registrydwords+=';OverrideMaxPerf=0x3'
        else
            echo "You selected the wrong value for the performance level forcing. Please reread the option description in PKGBUILD."
        fi
    fi

    sed -i "s/__REGISTRYDWORDS/\"${registrydwords}\"/" "${srcdir}/nvidia.conf"
}

package() {
    install -Dm644 nvidia.conf "${pkgdir}/usr/lib/modprobe.d/90-${pkgname}.conf"
    install -Dm644 nvidia-tweaks.hook -t "${pkgdir}/usr/share/libalpm/hooks"
    install -Dm755 patch.sh "${pkgdir}/usr/bin/nvidia-patch-nvenc"
    install -Dm755 patch-fbc.sh "${pkgdir}/usr/bin/nvidia-patch-fbc"

    if [ ! -z $_nvidia_patch ]; then
      install -Dm644 nvidia-patch.install "${pkgdir}/usr/share/libalpm/hooks/nvidia-patch-install.hook"
      install -Dm644 nvidia-patch.remove "${pkgdir}/usr/share/libalpm/hooks/nvidia-patch-remove.hook"
    fi

    # udev rules for node presence and runtime PM
    install -Dm644 60-nvidia.rules "${pkgdir}/usr/lib/udev/rules.d/71-nvidia.rules"
}