summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorcarrothu2022-05-13 19:28:49 +0000
committercarrothu2022-05-13 19:28:49 +0000
commit2c399676b5ca500d132772e5793421677dc81c17 (patch)
tree763e7c4249f08edc86c9ab2bd91a22d0054b5392
parent5d46b3fe28d933541cce7762c197d08e478607eb (diff)
downloadaur-2c399676b5ca500d132772e5793421677dc81c17.tar.gz
enhace the the compatibility
-rw-r--r--.SRCINFO7
-rw-r--r--PKGBUILD7
-rwxr-xr-xintelpwm28
-rw-r--r--intelpwm.conf11
-rw-r--r--intelpwm.install4
5 files changed, 34 insertions, 23 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 66206d46957b..9c78caedb19f 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = intelpwm
pkgdesc = PWM frequency setting on Intel HD Graphics with modprobe.d
- pkgver = 1.0
+ pkgver = 1.1
pkgrel = 1
url = https://127001.me/post/eliminate-backlight-flicker-with-i915/
install = intelpwm.install
@@ -12,8 +12,7 @@ pkgbase = intelpwm
source = intelpwm
source = intelpwm.conf
sha256sums = f25b883744dbe177d0ec7efaca17ffb288f4a7994e819883f299c90c27295f85
- sha256sums = 51f14a522767ff4c803ac1149980715714966356e36ed1e92cf61110a35bf784
- sha256sums = 7fefe55b66278e97eaca2fdf0aad125720cd00c95069dc38ef02ae1ee4e846b0
+ sha256sums = 3c17d61d623086f05cadfb28eea2d0915942509527b5d4e67ffa309ee13304b7
+ sha256sums = e16a943287e3104dc8869651f00f75281abf78dd20e3e601404f8bd4f7bbbdc5
pkgname = intelpwm
-
diff --git a/PKGBUILD b/PKGBUILD
index 602566171176..f67cb8444d46 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,8 @@
+#Maintainer: carrothu <hrxcn@126.com>
#Maintainer: Nikita Tarasov <nikatar@disroot.org>
pkgname=intelpwm
-pkgver=1.0
+pkgver=1.1
pkgrel=1
pkgdesc="PWM frequency setting on Intel HD Graphics with modprobe.d"
arch=(x86_64)
@@ -15,14 +16,14 @@ source=(i915-pwm.conf intelpwm intelpwm.conf)
sha256sums=('f25b883744dbe177d0ec7efaca17ffb288f4a7994e819883f299c90c27295f85'
'3c17d61d623086f05cadfb28eea2d0915942509527b5d4e67ffa309ee13304b7'
- '4e56f0b32355b268cc942aa67ce3297f70bdba95c8556e42b3ff3c595ab0e88a')
+ 'e16a943287e3104dc8869651f00f75281abf78dd20e3e601404f8bd4f7bbbdc5')
build() {
true
}
package() {
- msg "Installing..."
+ echo "Installing..."
install -D -m644 "${srcdir}/i915-pwm.conf" "${pkgdir}/etc/modprobe.d/i915-pwm.conf"
install -D -m644 "${srcdir}/intelpwm.conf" "${pkgdir}/etc/intelpwm.conf"
install -D -m744 "${srcdir}/intelpwm" "${pkgdir}/usr/bin/intelpwm"
diff --git a/intelpwm b/intelpwm
index 35fc6ac16f63..2b843cbb2ed5 100755
--- a/intelpwm
+++ b/intelpwm
@@ -1,16 +1,24 @@
#!/usr/bin/env bash
-CONFIG=/etc/intelpwm.conf
-if [ ! -f "$CONFIG" ]; then
- echo "$CONFIG not found"
- exit 1
+
+source /etc/intelpwm.conf 1>/dev/null 2>&1 || >&2 echo "WARN: /etc/intelpwm.conf does not exit"
+
+
+if [ -z "$FREQ" ]; then
+ >&2 echo "ERROR: FREQ is not defined. Specify in /etc/intelpwm.conf or in environment"
+ exit 1
fi
-source $CONFIG
+function reg_read() {
+ # this assumes fixed position of the value in intel_reg output
+ # so far this has been the case though
+ intel_reg read "$1" | cut -c51-60
+}
-RAW_DATA="$(intel_reg read ${REGISTER})"
-CYCLE="${RAW_DATA:56:4}"
-HEX=$(printf "0x%08x" $((1000000*0x7d/128/FREQ)))
+PCH_FREQ="$(reg_read ${PCH_RAWCLK_FREQ_REG})"
+BLC_CTL2="$(reg_read ${BLC_PWM_PCH_CTL2_REG})"
+CYCLE="${BLC_CTL2:6:4}"
+HEX=$(printf "0x%08x" $((1000000*PCH_FREQ/128/FREQ)))
PERIOD="${HEX:6:9}"
-intel_reg write "${REGISTER}" "0x${PERIOD}${CYCLE}"
-
+>&2 echo "Writing 0x${PERIOD}${CYCLE} to register ${BLC_PWM_PCH_CTL2_REG}"
+intel_reg write "${BLC_PWM_PCH_CTL2_REG}" "0x${PERIOD}${CYCLE}"
diff --git a/intelpwm.conf b/intelpwm.conf
index 49ac300f45c3..dd75e7421ad1 100644
--- a/intelpwm.conf
+++ b/intelpwm.conf
@@ -1,6 +1,9 @@
-# FREQ is the PWM frequency in Hz. In most cases 1000Hz is the maximum. Be careful and see the documentation for your hardware! Tested on Thinkpad X230
-# For other details see http://devbraindom.blogspot.com/2013/03/eliminate-led-screen-flicker-with-intel.html
+# backlight PWM frequency in Hz
+FREQ=800
-REGISTER=0xc8254
-FREQ=860
+# intelpwm reads PCH frequency from this register
+PCH_RAWCLK_FREQ_REG=0xc6204
+
+# intelpwm modifies 4 upper bytes of this register
+BLC_PWM_PCH_CTL2_REG=0xc8254
diff --git a/intelpwm.install b/intelpwm.install
index 1620ab8e3c0a..c915fe92173d 100644
--- a/intelpwm.install
+++ b/intelpwm.install
@@ -1,8 +1,8 @@
post_install() {
echo "PWM frequency settings on Intel HD Graphics with modprobe.d"
- echo "Default PWM frequency is 860Hz. In most cases 1000Hz is the maximum. Be careful and see the documentation for your hardware! Tested on Thinkapd X230"
+ echo "Default PWM frequency is 800Hz. Be careful and see the documentation for your hardware! Use at your owm risk."
echo "Edit /etc/intelpwm.conf to suit your needs"
- echo "Visit http://devbraindom.blogspot.com/2013/03/eliminate-led-screen-flicker-with-intel.html for more details"
+ echo "Visit https://127001.me/post/eliminate-backlight-flicker-with-i915/"
}