aboutsummaryrefslogtreecommitdiffci
path: root/root
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'root')
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-als (renamed from root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-power-button)2
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service3
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service12
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/wireupcameras.service10
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules4
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo7
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install31
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install5
-rwxr-xr-xroot/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh183
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/wireupcameras.sh32
-rw-r--r--root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te19
11 files changed, 249 insertions, 59 deletions
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-power-button b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-als
index 1b69eab..ae14928 100644
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-power-button
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-als
@@ -1,2 +1,2 @@
[org/gnome/settings-daemon/plugins/power]
-power-button-action='interactive'
+ambient-enabled=false
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service
index 2e3cf82..4ec7250 100644
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service
@@ -1,8 +1,9 @@
[Unit]
Description=HexagonRPC Service
+ConditionPathExists=/dev/fastrpc-adsp
[Service]
-ExecStart=/usr/local/bin/hexagonrpcd -f /dev/fastrpc-adsp-secure -s
+ExecStart=/usr/local/bin/hexagonrpcd -f /dev/fastrpc-adsp -d adsp -s
Restart=on-failure
[Install]
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service
new file mode 100644
index 0000000..5c83962
--- /dev/null
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Install Surface Pro 12in video codec firmware from a Windows partition
+ConditionPathExists=!/lib/firmware/qcom/x1p42100/Microsoft/Surface12/qcvss8380_pa.mbn
+After=local-fs.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/local/bin/surface-video-firmware.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/wireupcameras.service b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/wireupcameras.service
deleted file mode 100644
index 31eff6c..0000000
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/wireupcameras.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Wire up Surface Pro rear camera (media-ctl pipeline)
-
-[Service]
-Type=oneshot
-ExecStart=/usr/local/bin/wireupcameras.sh
-RemainAfterExit=yes
-
-[Install]
-WantedBy=multi-user.target
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules
index e6ddb1f..82051c5 100644
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules
@@ -1 +1,3 @@
-ACTION=="add|change", SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp-secure", ENV{ACCEL_MOUNT_MATRIX}="-1, 0, 0; 0, -1, 0; 0, 0, 1"
+ACTION=="add|change", SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp*", ENV{ACCEL_MOUNT_MATRIX}="-1, 0, 0; 0, -1, 0; 0, 0, 1"
+SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp*", ENV{IIO_SENSOR_PROXY_TYPE}+="ssc-accel"
+ACTION=="add", SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hexagonrpc.service"
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo
new file mode 100644
index 0000000..24fe9f3
--- /dev/null
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo
@@ -0,0 +1,7 @@
+[kernel-sp12in]
+name=kernel-sp12in for Fedora $releasever - $basearch
+baseurl=https://rpm.sayag.it/kernel-sp12in/fedora/$releasever/$basearch/
+enabled=1
+priority=1
+gpgcheck=0
+metadata_expire=6h
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install
index 2dadac5..7622406 100644
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install
@@ -8,23 +8,30 @@ KVER="$2"
DTB_NAME=x1p42100-microsoft-sp12in.dtb
DEST="/usr/lib/modules/${KVER}/dtb/qcom/${DTB_NAME}"
-# The master copy comes from kernel-surface: it builds the dtb in-tree from the
+# The master copies come from kernel-surface: it builds the dtb in-tree from the
# patched dts and installs it under /usr/lib/surface-dtb, deliberately outside
-# any /usr/lib/modules/<kver>, so it can be re-staged into any kernel installed
-# alongside it.
-SRC="/usr/lib/surface-dtb/${DTB_NAME}"
-[ -f "${SRC}" ] || SRC=""
+# any /usr/lib/modules/<kver>, so it can be re-staged into a kernel that ships
+# no device tree of its own -- a stock Fedora one.
+#
+# One directory per kernel version, because kernel-surface is installonly and
+# rpm will not let two installed releases own one unqualified path once the file
+# differs. They are all the same board, so the highest version is as good a
+# choice as any, and is the one most likely to carry recent fixes.
+SRC=$(ls -1 /usr/lib/surface-dtb/*/"${DTB_NAME}" 2>/dev/null | sort -V | tail -n1)
case "${COMMAND}" in
add)
- # No master and no dtb already in this kernel's tree means there is
- # nothing this board can boot with, so say so rather than failing
- # silently three steps later in the boot loader.
+ # kernel-surface ships its own dtb through dtbs_install, and that
+ # one is the release-matched copy. Leave it alone; the master is
+ # only for kernels that arrived without one.
+ if [ -f "${DEST}" ]; then
+ exit 0
+ fi
+ # Neither means there is nothing this board can boot with, so say
+ # so rather than failing silently three steps later in the boot
+ # loader.
if [ -z "${SRC}" ]; then
- if [ -f "${DEST}" ]; then
- exit 0
- fi
- echo "60-surface-dtb: no ${DTB_NAME} in /usr/lib/surface-dtb" >&2
+ echo "60-surface-dtb: no ${DTB_NAME} under /usr/lib/surface-dtb" >&2
exit 1
fi
mkdir -p "$(dirname ${DEST})"
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install
index f0314b0..65b8745 100644
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install
@@ -38,9 +38,10 @@ BOOT_ROOT="${KERNEL_INSTALL_BOOT_ROOT:-/boot}"
# (or was removed).
DTB_SRC="/usr/lib/modules/${KVER}/dtb/${DTB_REL}"
if [ ! -f "$DTB_SRC" ]; then
- DTB_SRC="/usr/lib/surface-dtb/$DTB_NAME"
+ # One directory per kernel version under here; see 60-surface-dtb.install.
+ DTB_SRC=$(ls -1 /usr/lib/surface-dtb/*/"$DTB_NAME" 2>/dev/null | sort -V | tail -n1)
fi
-[ -f "$DTB_SRC" ] || exit 0
+[ -n "$DTB_SRC" ] && [ -f "$DTB_SRC" ] || exit 0
# The boot loader reads the dtb from the boot filesystem, not the module tree
install -Dm644 "$DTB_SRC" "${BOOT_ROOT}/dtb-${KVER}/${DTB_REL}"
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh
new file mode 100755
index 0000000..35dfdf1
--- /dev/null
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh
@@ -0,0 +1,183 @@
+#!/bin/bash
+# Surface Pro 12" (Snapdragon X1P-42-100): install the video codec firmware.
+#
+# The iris video codec needs firmware TrustZone will accept. linux-firmware's
+# qcom/vpu/vpu30_p1_s7.mbn is the same codec signed with Qualcomm's SecTools
+# *test* key chain, which a retail Surface rejects:
+#
+# qcom-iris aa00000.video-codec: error -22 initializing firmware qcom/vpu/vpu30_p1_s7.mbn
+#
+# The production-signed build ships only inside Microsoft's Surface driver
+# package, which grants no redistribution right, so the image cannot carry it.
+# What it can do is copy it out of a Windows install the owner already has a
+# licence for, or out of a driver pack they downloaded themselves. This script
+# does the copying; it never fetches anything the caller did not ask for.
+#
+# Usage: surface-video-firmware.sh [-m MSI] [-u URL] [-n]
+#
+# (no options) look for a Windows partition on this machine and copy the
+# firmware out of its DriverStore. No network access.
+# -m MSI extract from a Surface driver pack already on disk
+# -u URL download a driver pack and extract from that
+# -n say what would happen, change nothing
+#
+# The driver pack is a ~500 MB MSI from
+#
+# https://www.microsoft.com/en-us/download/details.aspx?id=108199
+#
+# There is no stable direct link to hardcode: the Download Center hands out
+# per-session URLs and the file name carries the driver release, so -u takes
+# the URL the browser was given rather than guessing one that would rot.
+
+set -euo pipefail
+
+FW_DIR=/lib/firmware/qcom/x1p42100/Microsoft/Surface12
+BLOB=qcvss8380_pa.mbn
+DRIVERSTORE=Windows/System32/DriverStore/FileRepository
+PAGE=https://www.microsoft.com/en-us/download/details.aspx?id=108199
+
+msi=""
+url=""
+dry_run=false
+
+while getopts ':m:u:nh' opt; do
+ case "${opt}" in
+ m) msi=${OPTARG} ;;
+ u) url=${OPTARG} ;;
+ n) dry_run=true ;;
+ h) sed -n '2,31p' "${BASH_SOURCE[0]}"; exit 0 ;;
+ *) echo "unknown option -${OPTARG}" >&2; exit 2 ;;
+ esac
+done
+
+log() { printf 'surface-video-firmware: %s\n' "$*"; }
+die() { printf 'surface-video-firmware: %s\n' "$*" >&2; exit 1; }
+
+if [[ -f "${FW_DIR}/${BLOB}" ]]; then
+ log "${FW_DIR}/${BLOB} is already installed"
+ exit 0
+fi
+
+[[ ${EUID} -eq 0 ]] || die "must run as root"
+
+cleanup_dirs=()
+cleanup_mounts=()
+cleanup() {
+ local m d
+ for m in ${cleanup_mounts[@]+"${cleanup_mounts[@]}"}; do
+ mountpoint -q "${m}" && umount "${m}" || true
+ done
+ for d in ${cleanup_dirs[@]+"${cleanup_dirs[@]}"}; do
+ rm -rf "${d}" || true
+ done
+}
+trap cleanup EXIT
+
+install_blob() {
+ local src=$1
+ if [[ ${dry_run} == true ]]; then
+ log "would install ${src} as ${FW_DIR}/${BLOB}"
+ return 0
+ fi
+
+ install -Dm644 "${src}" "${FW_DIR}/${BLOB}"
+ log "installed ${FW_DIR}/${BLOB}"
+
+ # The driver only asks for its firmware while probing, so it has to be
+ # reloaded to pick this up. It refuses while a decode session holds it,
+ # which is why a failure here is only worth a note.
+ if lsmod | grep -q '^qcom_iris'; then
+ if modprobe -r qcom_iris 2>/dev/null && modprobe qcom_iris 2>/dev/null; then
+ log "reloaded qcom_iris"
+ else
+ log "could not reload qcom_iris; reboot to start using the firmware"
+ fi
+ fi
+}
+
+# Everything below hands find(1) the bare file name rather than a full path:
+# the DriverStore directory carries a per-build hash, and the layout inside an
+# extracted MSI is not documented anywhere worth trusting.
+find_blob() {
+ find "$1" -type f -name "${BLOB}" -print -quit 2>/dev/null
+}
+
+from_windows() {
+ local dev fstype part_mnt mnt found
+
+ while read -r dev fstype part_mnt; do
+ [[ ${fstype} == ntfs* ]] || continue
+
+ if [[ -n ${part_mnt} ]]; then
+ mnt=${part_mnt}
+ else
+ mnt=$(mktemp -d)
+ cleanup_dirs+=("${mnt}")
+ if ! mount -t ntfs3 -o ro,noatime "/dev/${dev}" "${mnt}" 2>/dev/null &&
+ ! mount -o ro,noatime "/dev/${dev}" "${mnt}" 2>/dev/null; then
+ log "/dev/${dev}: could not mount read-only, skipping"
+ log "/dev/${dev}: if Windows is hibernated, shut it down fully and retry"
+ continue
+ fi
+ cleanup_mounts+=("${mnt}")
+ fi
+
+ [[ -d "${mnt}/${DRIVERSTORE}" ]] || continue
+
+ found=$(find_blob "${mnt}/${DRIVERSTORE}")
+ if [[ -n ${found} ]]; then
+ log "found ${BLOB} on /dev/${dev}"
+ install_blob "${found}"
+ return 0
+ fi
+ log "/dev/${dev}: a Windows install, but no ${BLOB} in its DriverStore"
+ done < <(lsblk -rno NAME,FSTYPE,MOUNTPOINT)
+
+ return 1
+}
+
+from_msi() {
+ local pack=$1 work found
+
+ command -v msiextract >/dev/null || die "msiextract is missing; install msitools"
+
+ work=$(mktemp -d)
+ cleanup_dirs+=("${work}")
+
+ log "extracting ${pack}"
+ ( cd "${work}" && msiextract "${pack}" >/dev/null )
+
+ found=$(find_blob "${work}")
+ [[ -n ${found} ]] || die "no ${BLOB} inside ${pack}; is it the Surface Pro 12in driver pack?"
+
+ log "found ${BLOB} in the driver pack"
+ install_blob "${found}"
+}
+
+if [[ -n ${url} ]]; then
+ dl=$(mktemp -d)
+ cleanup_dirs+=("${dl}")
+ msi="${dl}/driverpack.msi"
+ log "downloading ${url}"
+ curl -fL --retry 3 --progress-bar -o "${msi}" "${url}"
+fi
+
+if [[ -n ${msi} ]]; then
+ [[ -f ${msi} ]] || die "${msi} does not exist"
+ from_msi "${msi}"
+ exit 0
+fi
+
+if from_windows; then
+ exit 0
+fi
+
+# Nothing found, and nothing was asked for. Not an error: most of the time this
+# is a machine with no Windows left on it, and the only thing left to do is say
+# how to finish the job by hand.
+log "no Windows install on this machine carries ${BLOB}"
+log "hardware video decode stays off until it is installed. To finish by hand:"
+log " 1. download the Surface Pro 12in driver pack (~500 MB) from"
+log " ${PAGE}"
+log " 2. sudo surface-video-firmware.sh -m /path/to/SurfacePro_12in_*.msi"
+exit 0
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/wireupcameras.sh b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/wireupcameras.sh
deleted file mode 100644
index 833a422..0000000
--- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/wireupcameras.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-set -e
-
-# Wait for /dev/media0 to appear (MSM VFE driver may need firmware to probe)
-# Timeout after 10 seconds to avoid infinite hangs on systems without camera hardware
-MAX_WAIT=10
-WAIT_COUNT=0
-while [ ! -e /dev/media0 ] && [ $WAIT_COUNT -lt $MAX_WAIT ]; do
- sleep 1
- WAIT_COUNT=$((WAIT_COUNT + 1))
-done
-
-if [ ! -e /dev/media0 ]; then
- echo "wireupcameras: /dev/media0 not found after ${MAX_WAIT}s, skipping" >&2
- exit 0
-fi
-
-SENSOR="ov13858 1-0010"
-
-# Tell each pad in the path what format to expect
-media-ctl -V "\"$SENSOR\":0[fmt:SGRBG10_1X10/4224x3136]"
-media-ctl -V '"msm_csiphy0":0[fmt:SGRBG10_1X10/4224x3136]'
-media-ctl -V '"msm_csiphy0":1[fmt:SGRBG10_1X10/4224x3136]'
-media-ctl -V '"msm_csid0":0[fmt:SGRBG10_1X10/4224x3136]'
-media-ctl -V '"msm_csid0":1[fmt:SGRBG10_1X10/4224x3136]'
-media-ctl -V '"msm_vfe0_rdi0":0[fmt:SGRBG10_1X10/4224x3136]'
-
-# Disable the OV02C10 path so it doesn't fight for csid0
-media-ctl -l '"msm_csiphy4":1->"msm_csid0":0[0]'
-
-# Enable the rear path
-media-ctl -l '"msm_csiphy0":1->"msm_csid0":0[1]'
diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te
new file mode 100644
index 0000000..b3be8fb
--- /dev/null
+++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te
@@ -0,0 +1,19 @@
+module iio-qipcrtr 1.0;
+
+# Fedora's policy grants iiosensorproxy_t no qipcrtr_socket permissions at
+# all: the class exists but nothing allows it, because upstream
+# iio-sensor-proxy talks to sensors over IIO and never needed QRTR. The SSC
+# backend libssc brings in here reaches the Qualcomm Sensor Core over the
+# QRTR bus (libssc probes AF_QIPCRTR first; the fastrpc/hexagonrpcd path is
+# what actually serves this board, but the probe alone gets the daemon
+# killed by "QRTR bus unavailable" + "No sensors" without these perms).
+#
+# Hand-written rather than audit2allow'd per-incident: create/bind/... is
+# the full client lifecycle, so a policy reload or libssc update cannot
+# surface a new denied perm one at a time.
+require {
+ type iiosensorproxy_t;
+ class qipcrtr_socket { create bind connect read write getattr setattr getopt setopt shutdown };
+}
+
+allow iiosensorproxy_t self:qipcrtr_socket { create bind connect read write getattr setattr getopt setopt shutdown };