Files
nix-files/pkgs/additional/linux-armbian/default.nix

562 lines
29 KiB
Nix

{
fetchFromGitHub,
fetchurl,
lib,
buildLinux,
linux_latest,
linux-postmarketos-allwinner,
newScope,
sane-kernel-tools,
usePmosConfig ? true,
withNixpkgsConfig ? true,
withFullConfig ? true,
withModemPower ? false, #< TODO: fix so it applies
withMegousPatches ? true,
#VVV nixpkgs calls `.override` on the kernel to configure additional things, but we don't care about those things
...
}@args:
let
linux = linux_latest;
patches = import ./patches.nix { inherit fetchFromGitHub lib newScope; };
in
# buildLinux {
linux_latest.override {
# inherit (linux_latest) src version modDirVersion;
# inherit features randstructSeed structuredExtraConfig;
DTB = true; #< XXX: not sure if actually needed
autoModules = withFullConfig;
preferBuiltin = true;
enableCommonConfig = withNixpkgsConfig;
# kernelPatches = patches.megous.series ++
kernelPatches = lib.optionals (!withMegousPatches) [
{
# with this patch: dmesg | grep 'anx7688 0-0028: failed to parse connector from DT'
# i guess the anx7688 driver being proposed for upstream requires a different device tree
# than megi's version
name = "usb: typec: anx7688: Add driver for ANX7688 USB-C HDMI bridge";
patch = fetchurl {
# https://lore.kernel.org/lkml/ZhPM4XU8ttsFftBd@duo.ucw.cz/
name = "usb: typec: anx7688: Add driver for ANX7688 USB-C HDMI bridge";
url = "http://lore.kernel.org/lkml/ZhPM4XU8ttsFftBd@duo.ucw.cz/1-a.txt";
hash = "sha256-doJOtaJLvepgagkQH0oqzVR9VQY4ZbK/3gx4kKgKnLg=";
};
}
]
++ lib.optionals withMegousPatches (with patches.megous; [
# subset of megi patches.
# as you edit this, ensure:
# - front and back camera still work in megapixels/snapshot.
# - battery is still chargable (`cat /sys/class/power_supply/axp20x-battery/current-now` reports positive when plugged in)
# these ov5640 patches are necessary for EITHER camera to register (2024-09-15)
byName."media-ov5640-Experiment-Try-to-disable-denoising-sharpening"
byName."media-ov5640-Sleep-after-poweroff-to-ensure-next-poweron-is-not"
byName."media-ov5640-Don-t-powerup-the-sensor-during-driver-probe"
byName."media-ov5640-set-default-ae-target-lower"
byName."media-ov5640-Improve-error-reporting"
byName."media-ov5640-Implement-autofocus"
byName."media-ov5640-Improve-firmware-load-time"
byName."media-ov5640-Fix-focus-commands-blocking-until-complete"
byName."media-ov5640-Add-read-only-property-for-vblank"
byName."media-ov5640-use-pm_runtime_force_suspend-resume-for-system-sus"
byName."media-sun6i-csi-capture-Use-subdev-operation-to-access-bridge-f"
byName."media-sun6i-csi-subdev-Use-subdev-active-state-to-store-active-"
byName."media-sun6i-csi-merge-sun6i_csi_formats-and-sun6i_csi_formats_m"
byName."media-sun6i-csi-add-V4L2_CAP_IO_MC-capability"
byName."media-sun6i-csi-implement-vidioc_enum_framesizes"
byName."media-sun6i-csi-Add-multicamera-support-for-parallel-bus"
# byName."nfc-pn544-Add-support-for-VBAT-PVDD-regulators"
# byName."bluetooth-bcm-Restore-drive_rts_on_open-true-behavior-on-bcm207"
# byName."mmc-add-delay-after-power-class-selection"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-PN544-NFC-support"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-powerup-down-support-for-the-3G"
# byName."ARM-dts-sun8i-a83t-Add-cedrus-video-codec-support-to-A83T-untes"
# byName."ARM-dts-suni-a83t-Add-i2s0-pins"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-sound-support-via-AC100-codec"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-regulators-to-the-accelerometer"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-camera-sensors-HM5065-GC2145"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-flash-led-support"
byName."dt-bindings-input-gpio-vibrator-Don-t-require-enable-gpios"
byName."input-gpio-vibra-Allow-to-use-vcc-supply-alone-to-control-the-v"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Add-support-for-the-vibrator-motor"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Increase-voltage-on-the-vibrator"
# byName."dt-bindings-leds-Add-a-binding-for-AXP813-charger-led"
# byName."leds-axp20x-Support-charger-LED-on-AXP20x-like-PMICs"
# byName."ARM-dts-axp813-Add-charger-LED"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Enable-charging-LED"
# byName."MAINTAINERS-Add-entry-for-Himax-HM5065"
# byName."dt-bindings-media-Add-bindings-for-Himax-HM5065-camera-sensor"
# byName."hm5065-yaml-bindings-wip"
# i believe these gc2145 patches are required for either camera to register (?) (2024-09-15)
byName."media-hm5065-Add-subdev-driver-for-Himax-HM5065-camera-sensor" #< required for later patch to apply: media-gc2145-Galaxycore-camera-module-driver
# byName."media-i2c-gc2145-Move-upstream-driver-out-of-the-way" #< linux 6.11.0: doesn't apply
# byName."media-gc2145-Galaxycore-camera-module-driver"
# byName."media-gc2145-Added-BGGR-bayer-mode"
# byName."media-gc2145-Disable-debug-output"
# byName."media-gc2145-Add-PIXEL_RATE-HBLANK-and-VBLANK-controls"
# byName."media-gc2145-implement-system-suspend"
# byName."media-gc2145-fix-white-balance-colors"
# byName."media-i2c-gc2145-Parse-and-register-properties"
# byName."mailbox-Allow-to-run-mailbox-while-timekeeping-is-suspended"
# byName."ARM-sunxi-Add-experimental-suspend-to-memory-implementation-for"
# byName."ARM-sunxi-sunxi_cpu0_hotplug_support_set-is-not-supported-on-A8"
# byName."firmware-scpi-Add-support-for-sending-a-SCPI_CMD_SET_SYS_PWR_ST"
# byName."ARM-sunxi-Use-SCPI-to-send-suspend-message-to-SCP-on-A83T"
# byName."gnss-ubx-Send-soft-powerdown-message-on-suspend"
# byName."clk-sunxi-ng-Export-CLK_DRAM-for-devfreq"
# byName."ARM-dts-sun8i-a83t-Add-MBUS-node"
# byName."clk-sunxi-ng-Set-maximum-P-and-M-factors-to-1-for-H3-pll-cpux-c"
# byName."clk-sunxi-ng-Don-t-use-CPU-PLL-gating-and-CPUX-reparenting-to-H"
# byName."ARM-dts-sun8i-h3-Use-my-own-more-aggressive-OPPs-on-H3"
# byName."arm64-dts-sun50i-h5-Use-my-own-more-aggressive-OPPs-on-H5"
# byName."ARM-dts-sun8i-h3-orange-pi-pc-Increase-max-CPUX-voltage-to-1.4V"
# byName."ARM-dts-sun8i-a83t-Improve-CPU-OPP-tables-go-up-to-1.8GHz"
# byName."cpufreq-sun50i-Show-detected-CPU-bin-for-easier-debugging"
# byName."net-stmmac-sun8i-Use-devm_regulator_get-for-PHY-regulator"
# byName."net-stmmac-sun8i-Rename-PHY-regulator-variable-to-regulator_phy"
# byName."net-stmmac-sun8i-Add-support-for-enabling-a-regulator-for-PHY-I"
# byName."arm64-dts-allwinner-orange-pi-3-Enable-ethernet"
# byName."input-cyttsp4-De-obfuscate-platform-data-for-keys"
# byName."input-cyttsp4-Remove-useless-indirection-with-driver-platform-d"
# byName."input-cyttsp4-Remove-unused-enable_vkeys"
# byName."input-cyttsp4-De-obfuscate-MT-signals-setup-platform-data"
# byName."input-cyttsp4-Clear-the-ids-buffer-in-a-saner-way"
# byName."input-cyttsp4-ENOSYS-error-is-ok-when-powering-up"
# byName."input-cyttsp4-Faster-recovery-from-failed-wakeup-HACK"
# byName."input-cyttsp4-Use-i2c-spi-names-directly-in-the-driver"
# byName."input-cyttsp4-Port-the-driver-to-use-device-properties"
# byName."input-cyttsp4-Restart-on-wakeup-wakeup-by-I2C-read-doesn-t-work"
# byName."input-cyttsp4-Fix-warnings"
# byName."input-cyttsp4-Make-the-driver-not-hog-the-system-s-workqueue"
# byName."input-cyttsp4-Fix-probe-oops"
# byName."video-fbdev-eInk-display-driver-for-A13-based-PocketBooks"
# byName."regulator-Add-simple-driver-for-enabling-a-regulator-from-users"
# byName."regulator-tp65185x-Add-tp65185x-eInk-panel-regulator-driver"
# byName."regulator-tp65185-Add-hwmon-device-for-reading-temperature"
# byName."iio-adc-sun4i-gpadc-iio-Allow-to-use-sun5i-a13-gpadc-iio-from-D"
# byName."mtd-spi-nor-Add-vdd-regulator-support"
# byName."ARM-dts-sun5i-Add-soc-handle"
# byName."ARM-dts-sun5i-Add-PocketBook-Touch-Lux-3-display-ctp-support"
# byName."ARM-dts-sun5i-a13-pocketbook-touch-lux-3-Add-RTC-clock-cells"
byName."arm64-dts-sun50i-a64-pinephone-Add-front-back-cameras"
byName."arm64-dts-sun50i-a64-pinephone-Add-Type-C-support-for-all-PP-va"
byName."arm64-dts-sun50i-a64-pinephone-Add-modem-power-manager"
byName."arm64-dts-sun50i-a64-pinephone-Fix-BH-modem-manager-behavior"
byName."arm64-dts-sun50i-a64-pinephone-Add-detailed-OCV-to-capactiy-con"
byName."arm64-dts-sun50i-a64-pinephone-Shorten-post-power-on-delay-on-m"
byName."arm64-dts-sun50i-a64-pinephone-Add-mount-matrix-for-acceleromet"
byName."arm64-dts-sun50i-a64-pinephone-Add-support-for-Bluetooth-audio"
byName."arm64-dts-sun50i-a64-pinephone-Enable-internal-HMIC-bias"
byName."arm64-dts-sun50i-a64-pinephone-Add-support-for-modem-audio"
byName."arm64-dts-sun50i-a64-pinephone-Bump-I2C-frequency-to-400kHz"
byName."arm64-dts-sun50i-a64-pinephone-Add-interrupt-pin-for-WiFi"
byName."arm64-dts-sun50i-a64-pinephone-Power-off-the-touch-controller-i"
byName."arm64-dts-sun50i-a64-pinephone-Don-t-make-lradc-keys-a-wakeup-s"
byName."arm64-dts-sun50i-a64-pinephone-Set-minimum-backlight-duty-cycle"
byName."arm64-dts-sun50i-a64-pinephone-Add-supply-for-i2c-bus-to-anx768"
byName."arm64-dts-sun50i-a64-pinephone-Workaround-broken-HDMI-HPD-signa"
byName."arm64-dts-sun50i-a64-pinephone-Add-AF8133J-to-PinePhone"
byName."arm64-dts-sun50i-a64-pinephone-Add-mount-matrix-for-PinePhone-m"
byName."arm64-dts-sun50i-a64-pinephone-Add-support-for-Pinephone-keyboa"
byName."arm64-dts-sun50i-a64-pinephone-Enable-Pinephone-Keyboard-power-"
byName."arm64-dts-sun50i-a64-pinephone-Add-support-for-Pinephone-1.2-be"
byName."arm64-dts-sun50i-a64-pinephone-Add-power-supply-to-stk3311"
byName."arm64-dts-sun50i-a64-pinephone-Add-reboot-mode-driver"
byName."arm64-dts-sun50i-a64-pinephone-Use-newer-jack-detection-impleme"
byName."arm64-dts-sun50-a64-pinephone-Define-jack-pins-in-DT"
byName."dt-bindings-sound-Add-jack-type-property-to-sun8i-a33-codec"
byName."ASoC-sun8i-codec-Allow-the-jack-type-to-be-set-via-device-tree"
byName."ASoC-sun8i-codec-define-button-keycodes"
byName."ASoC-sun8i-codec-Add-debug-output-for-jack-detection"
byName."ASoC-sun8i-codec-Set-jack_type-from-DT-in-probe"
byName."ASoC-simple-card-Allow-to-define-pins-for-aux-jack-devices"
# some or all of these audio patches are relevant not (just) to the modem audio path,
# but are required for headphone and speaker output.
byName."clk-sunxi-ng-a64-Increase-PLL_AUDIO-base-frequency"
byName."dt-bindings-mfd-Add-codec-related-properties-to-AC100-PMIC"
byName."sound-soc-ac100-codec-Support-analog-part-of-X-Powers-AC100-cod"
byName."sound-soc-sun8i-codec-Add-support-for-digital-part-of-the-AC100"
byName."ASoC-ec25-New-codec-driver-for-the-EC25-modem"
# byName."ASOC-sun9i-hdmi-audio-Initial-implementation" #< linux 6.11: `error: initialization of 'void (*)(struct platform_device *)' from incompatible pointer type 'int (*)(struct platform_device *)'`
# byName."ARM-dts-sunxi-h3-h5-Add-hdmi-sound-card"
# byName."ARM-dts-sun8i-h3-Enable-hdmi-sound-card-on-boards-with-hdmi"
# byName."ARM-dts-sun8i-h2-plus-bananapi-m2-zero-Enable-HDMI-audio"
# byName."ARM-dts-sun8i-a83t-Add-hdmi-sound-card"
# byName."ARM-dts-sun8i-a83t-Enable-hdmi-sound-card-on-boards-with-hdmi"
# byName."ARM-dts-sun8i-r40-Add-hdmi-sound-card"
# byName."ARM-dts-sun8i-r40-bananapi-m2-ultra-Enable-HDMI-audio"
# byName."ARM-dts-sun8i-v40-bananapi-m2-berry-Enable-HDMI-audio"
# byName."arm64-dts-allwinner-h6-Add-hdmi-sound-card"
# byName."arm64-dts-allwinner-h6-Enable-hdmi-sound-card-on-boards-with-hd"
byName."arm64-dts-allwinner-a64-Add-hdmi-sound-card"
byName."arm64-dts-allwinner-a64-Enable-hdmi-sound-card-on-boards-with-h"
# byName."arm64-dts-allwinner-h5-Enable-hdmi-sound-card-on-boards-with-hd"
# byName."arm64-dts-sun50i-a64-Set-fifo-size-for-uarts"
# byName."ARM-dts-sun8i-a83t-Set-fifo-size-for-uarts"
# byName."Mark-some-slow-drivers-for-async-probe-with-PROBE_PREFER_ASYNCH"
# byName."arm64-xor-Select-32regs-without-benchmark-to-speed-up-boot"
# byName."clk-Implement-protected-clocks-for-all-OF-clock-providers"
# byName."Revert-clk-qcom-Support-protected-clocks-property"
# byName."ARM-dts-sunxi-a83t-Protect-SCP-clocks"
# byName."ARM-dts-sunxi-h3-h5-Protect-SCP-clocks"
# byName."arm64-dts-allwinner-a64-Protect-SCP-clocks"
# byName."arm64-dts-allwinner-h6-Protect-SCP-clocks"
byName."bus-sunxi-rsb-Always-check-register-address-validity"
byName."firmware-arm_scpi-Support-unidirectional-mailbox-channels"
# byName."ARM-dts-sunxi-a83t-Add-SCPI-protocol"
# byName."ARM-dts-sunxi-h3-h5-Add-SCPI-protocol"
# byName."arm64-dts-allwinner-a64-Add-SCPI-protocol"
# byName."arm64-dts-allwinner-h6-Add-SCPI-protocol"
# byName."ARM-dts-sun8i-a83t-tbs-a711-Give-Linux-more-privileges-over-SCP"
# byName."rtc-sun6i-Allow-RTC-wakeup-after-shutdown"
(if withModemPower then byName."misc-modem-power-Power-manager-for-modems" else { patch = null; })
# byName."ARM-dts-sun8i-a83t-Add-missing-GPU-trip-point"
# byName."arm64-dts-sun50i-h5-Add-missing-GPU-trip-point"
byName."arm64-dts-sun50i-a64-Add-missing-trip-points-for-GPU"
byName."arm64-dts-allwinner-a64-Fix-LRADC-compatible"
byName."ASoC-codec-es8316-DAC-Soft-Ramp-Rate-is-just-a-2-bit-control"
# byName."spi-rockchip-Fix-runtime-PM-and-other-issues"
# byName."spi-fixes"
byName."media-cedrus-Fix-failure-to-clean-up-hardware-on-probe-failure"
# byName."ASoC-rockchip-Fix-doubling-of-playback-speed-after-system-sleep"
byName."usb-musb-sunxi-Avoid-enabling-host-side-code-on-SoCs-where-it-s"
byName."arm64-dts-allwinner-Enforce-consistent-MMC-numbering"
byName."ARM-dts-sunxi-Add-aliases-for-MMC"
# byName."drm-rockchip-Fix-panic-on-reboot-when-DRM-device-fails-to-bind"
byName."usb-gadget-Fix-dangling-pointer-in-netdev-private-data" #< required for "Fix-for-usb-gadget-on-PP" to apply
byName."Fix-for-usb-gadget-on-PP"
# byName."mmc-dw-mmc-rockchip-fix-sdmmc-after-soft-reboot"
byName."Revert-drm-sun4i-lvds-Invert-the-LVDS-polarity"
byName."of-property-fw_devlink-Support-allwinner-sram-links"
# byName."arm64-dts-rockchip-rk356x-Fix-PCIe-register-map-and-ranges"
# byName."Fix-intptr_t-typedef"
# byName."mmc-sunxi-mmc-Remove-runtime-PM"
# byName."pci-Workaround-ITS-timeouts-on-poweroff-reboot-on-Orange-Pi-5-P"
# byName."usb-serial-option-add-reset_resume-callback-for-WWAN-devices"
# byName."media-rkisp1-Adapt-to-different-SoCs-having-different-size-limi"
# byName."media-ov5648-Fix-call-to-pm_runtime_set_suspended"
# byName."drm-rockchip-dw-mipi-dsi-rockchip-Fix-ISP1-PHY-initialization"
# byName."drm-rockchip-dw-mipi-dsi-rockchip-Restore-DPHY-config-on-resume"
# byName."bluetooth-h5-Don-t-re-initialize-rtl8723cs-on-resume"
# byName."drm-sun4i-Unify-sun8i_-_layer-structs"
# byName."drm-sun4i-Add-more-parameters-to-sunxi_engine-commit-callback"
# byName."drm-sun4i-Fix-layer-zpos-change-atomic-modesetting"
# byName."drm-sun4i-drm-Change-update_bits-to-write"
# byName."drm-sun4i-Mark-one-of-the-UI-planes-as-a-cursor-one"
# byName."drm-sun4i-Implement-gamma-correction"
# byName."drm-panel-st7703-Fix-xbd599-timings-to-make-refresh-rate-exactl"
# byName."drm-sun4i-Support-taking-over-display-pipeline-state-from-p-boo"
# byName."video-pwm_bl-Allow-to-change-lth_brightness-via-sysfs"
# byName."clk-sunxi-ng-sun50i-a64-Switch-parent-of-MIPI-DSI-to-periph0-1x"
byName."drm-sun4i-tcon-Support-keeping-dclk-rate-upon-ancestor-clock-ch"
byName."phy-allwinner-sun4i-usb-Add-support-for-usb_role_switch"
byName."regulator-axp20x-Add-support-for-vin-supply-for-drivevbus"
byName."regulator-axp20x-Turn-N_VBUSEN-to-input-on-x-powers-sense-vbus-"
byName."drm-bridge-dw-hdmi-Allow-to-accept-HPD-status-from-other-driver"
byName."drm-bridge-dw-hdmi-Report-HDMI-hotplug-events"
byName."usb-typec-anx7688-Add-driver-for-ANX7688-USB-C-HDMI-bridge"
byName."usb-typec-anx7688-Port-to-Linux-6.9"
byName."usb-typec-anx7688-Port-to-Linux-6.10"
byName."dt-bindings-axp20x-adc-allow-to-use-TS-pin-as-GPADC"
byName."iio-adc-axp20x_adc-allow-to-set-TS-pin-to-GPADC-mode"
byName."power-axp20x_battery-Allow-to-set-target-voltage-to-4.35V"
byName."power-supply-axp20x_battery-Add-support-for-reporting-OCV"
byName."regulator-axp20x-Enable-over-temperature-protection-and-16s-res"
byName."power-supply-axp20x_battery-Setup-thermal-regulation-experiment"
byName."power-supply-axp20x_battery-Fix-charging-done-detection"
byName."mfd-axp20x-Add-battery-IRQ-resources"
byName."power-supply-axp20x_battery-Send-uevents-for-status-changes"
byName."power-supply-axp20x_battery-Monitor-battery-health"
byName."power-supply-axp20x-usb-power-Change-Vbus-hold-voltage-to-4.5V"
byName."power-axp803-Add-interrupts-for-low-battery-power-condition"
byName."power-supply-axp20x-battery-Support-POWER_SUPPLY_PROP_CHARGE_BE"
byName."power-supply-axp20x-battery-Enable-poweron-by-RTC-alarm"
byName."power-supply-axp20x-battery-Add-support-for-POWER_SUPPLY_PROP_E"
byName."power-supply-Add-support-for-USB_BC_ENABLED-and-USB_DCP_INPUT_C"
byName."power-supply-axp20x-usb-power-Add-missing-interrupts"
# byName."sunxi-Use-dev_err_probe-to-handle-EPROBE_DEFER-errors"
# byName."thermal-sun8i-Be-loud-when-probe-fails"
# byName."i2c-mv64xxx-Don-t-make-a-fuss-when-pinctrl-recovery-state-is-no"
# byName."iio-st_sensors-Don-t-report-error-when-the-device-is-not-presen"
# byName."opp-core-Avoid-confusing-error-when-no-regulator-is-defined-in-"
# byName."rtc-Print-which-error-caused-RTC-read-failure"
# byName."arm64-dts-allwinner-a64-pinetab-add-front-camera"
# byName."arm64-allwinner-dts-a64-enable-K101-IM2BYL02-panel-for-PineTab"
# byName."arm64-dts-sun50i-a64-pinetab-Name-sound-card-PineTab"
# byName."arm64-dts-sun50i-a64-pinetab-Add-accelerometer"
# byName."arm64-dts-sun50i-a64-pinetab-enable-RTL8723CS-bluetooth"
byName."usb-typec-fusb302-Slightly-increase-wait-time-for-BC1.2-result"
byName."usb-typec-fusb302-Set-the-current-before-enabling-pullups"
byName."usb-typec-fusb302-Extend-debugging-interface-with-driver-state-"
byName."usb-typec-fusb302-Retry-reading-of-CC-pins-status-if-activity-i"
byName."usb-typec-fusb302-More-useful-of-logging-status-on-interrupt"
byName."usb-typec-fusb302-Update-VBUS-state-even-if-VBUS-interrupt-is-n"
byName."usb-typec-fusb302-Add-OF-extcon-support"
byName."usb-typec-fusb302-Fix-register-definitions"
byName."usb-typec-fusb302-Clear-interrupts-before-we-start-toggling"
# byName."usb-typec-typec-extcon-Add-typec-extcon-bridge-driver" #< one of these causes a build error in linux 6.11
# byName."usb-typec-typec-extcon-Enable-debugging-for-now"
# byName."usb-typec-typec-extcon-Allow-to-force-reset-on-each-mux-change"
byName."Revert-usb-typec-tcpm-unregister-existing-source-caps-before-re"
byName."usb-typec-altmodes-displayport-Respect-DP_CAP_RECEPTACLE-bit"
byName."usb-typec-tcpm-Unregister-altmodes-before-registering-new-ones"
byName."usb-typec-tcpm-Fix-PD-devices-capabilities-registration"
# byName."usb-typec-tcpm-Improve-logs"
# byName."Make-microbuttons-on-Orange-Pi-PC-and-PC-2-work-as-power-off-bu"
# byName."Add-support-for-my-private-Sapomat-device"
# byName."ARM-dts-sun8i-h3-orange-pi-one-Enable-all-gpio-header-UARTs"
# byName."mtd-spi-nor-Add-Alliance-memory-support"
# byName."Add-README.md-with-information-and-u-boot-patches"
# byName."Defconfigs-for-all-my-devices"
# byName."Update-defconfigs"
]) ++
lib.optionals withFullConfig [
# {
# name = "fix-compilation-specific-to-megi";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# ### BUILD FIXES, NOT SPECIFIC TO MY PREFERENCES
# #
# # disabling the sun5i_eink driver avoids this compilation error:
# # CC [M] drivers/video/fbdev/sun5i-eink-neon.o
# # aarch64-unknown-linux-gnu-gcc: error: unrecognized command line option '-mfloat-abi=softfp'
# # aarch64-unknown-linux-gnu-gcc: error: unrecognized command line option '-mfpu=neon'
# # make[3]: *** [../scripts/Makefile.build:289: drivers/video/fbdev/sun5i-eink-neon.o] Error 1
# FB_SUN5I_EINK = no;
# BES2600 = no; # fails to compile (implicit declaration of function 'ieee80211_tx_status'; did you mean 'ieee80211_tx_status_ni')
# # SUN8I_DE2_CCU = lib.mkForce module; #< want:y, got:M
# };
# }
# {
# name = "fix-no-display";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# ### RUNTIME FIXES AFTER <https://github.com/NixOS/nixpkgs/pull/298332>
# # pmOS kernel config is in pmaports repo:
# # - CONFIG_FB_SIMPLE=y
# # - CONFIG_DRM_SIMPLEDRM is unset
# # - CONFIG_SYSFB_SIMPLEFB is not referenced
# # these config values are speculative: could probably be made smaller
# FB_SIMPLE = lib.mkForce yes;
# DRM_SIMPLEDRM = lib.mkForce no; #< conflicts with FB_SIMPLE
# # SYSFB_SIMPLEFB = lib.mkForce no;
# # downgrade these from "yes" to "module", to match previous config.
# DRM = lib.mkForce module;
# };
# }
# {
# name = "enable-rtw88-wifi-drivers";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# # default nixpkgs/pmos config enables RTW88, but not RTW88_8723CS.
# # but the pinephone uses a 8723BS/8723CS chipset, so enable these
# # and anything else that could possibly be needed, since these things are tangled.
# # TODO: reduce this, this is surely more than i actually need
# # RTL8187_LEDS=y
# # RTLWIFI_DEBUG=y
# # RTL8180 = module;
# # RTL8187 = module;
# # RTL8188EE = module;
# # RTL8192CE = module;
# # RTL8192CU = module;
# # RTL8192C_COMMON = module;
# # RTL8192DE = module;
# # RTL8192D_COMMON = module;
# # RTL8192EE = module;
# # RTL8192SE = module;
# # RTL8723AE = module;
# # RTL8723BE = module;
# # RTL8723_COMMON = module;
# # RTL8821AE = module;
# # RTL8XXXU = module;
# # RTLBTCOEXIST = module;
# # RTLWIFI = module;
# # RTLWIFI_PCI = module;
# # RTLWIFI_USB = module;
# RTW88_8703B = module;
# RTW88_8723CS = module;
# RTW88_8723D = module;
# RTW88_8723DE = module;
# RTW88_8723DS = module;
# RTW88_8723DU = module;
# RTW88_8723X = module;
# RTW88_8821C = module;
# RTW88_8821CE = module;
# RTW88_8821CS = module;
# RTW88_8821CU = module;
# RTW88_8822BS = module;
# RTW88_8822BU = module;
# RTW88_8822CS = module;
# RTW88_8822CU = module;
# RTW88_SDIO = module;
# RTW88_USB = module;
# };
# }
# {
# # this could be enabled for *all* systems, but i'm not sure i really want that.
# name = "quality-of-life";
# patch = null;
# extraStructuredConfig = with lib.kernel; {
# # optimize for faster builds.
# # see <repo:kernel.org/linux:Documentation/admin-guide/quickly-build-trimmed-linux.rst>
# # note that several options can re-enable DEBUG_KERNEL (such as DEBUG_LIST)
# # DEBUG_KERNEL = lib.mkForce no; # option group which seems to just gate the other DEBUG_ opts?
# DEBUG_INFO = lib.mkForce no; # for gdb debugging (does it impact kernel stacktraces, too?)
# # DEBUG_INFO_NONE = lib.mkForce no;
# DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT = lib.mkForce no;
# # DEBUG_LIST = lib.mkForce no;
# # DEBUG_MISC = lib.mkForce no;
# # DEBUG_FS = no;
# DEBUG_INFO_BTF = lib.mkForce no; # BPF debug symbols. rec by <https://nixos.wiki/wiki/Linux_kernel#Too_high_ram_usage>
# # SCHED_DEBUG = lib.mkForce no; # determines /sys/kernel/debug/sched
# SUNRPC_DEBUG = lib.mkForce no;
# # shave 500ms off Pinephone boot time (dmesg | grep raid6)
# # - by default raid6 (on behalf of btrfs) will compute the fastest algorithms at boot.
# # - AFAICT, this only comes into effect if using raid (i don't).
# # - in any case, on moby, the fastest benchmark happens to be the default anyway.
# # - on lappy/servo/desko, the default is about 3% slower than the fastest. but they compute this in < 100ms.
# RAID6_PQ_BENCHMARK = lib.mkForce no;
# };
# }
] ++ lib.optionals (withMegousPatches && withModemPower) [
{
name = "enable-megi-modem-power";
patch = null;
extraStructuredConfig = with lib.kernel; {
# enable /sys/class/modem-power, a thing specific to Megi's kernel/patches
MODEM_POWER = module;
};
}
# ] ++ lib.optionals withNixpkgsConfig [
# {
# name = "nixpkgs-config";
# patch = null;
# extraStructuredConfig = linux_latest.commonStructuredConfig;
# }
] ++ lib.optionals usePmosConfig [
{
name = "postmarketos-config";
patch = null;
extraStructuredConfig = builtins.removeAttrs
(sane-kernel-tools.parseDefconfigStructuredNonempty linux-postmarketos-allwinner.defconfigStr)
([
# remove attrs which nixpkgs wants to set for itself, only because the kernel config options are so fucked that i can't figure out how to override things without breaking eval
# "RAID6_PQ_BENCHMARK"
# these options have changed since the version which pmos ships? or pmos just ships invalid values
# "repeated questions"
"NETFILTER_XT_TARGET_TPROXY"
"NETFILTER_XT_MATCH_HASHLIMIT"
"NETFILTER_XT_MATCH_SOCKET"
"IP_NF_MATCH_RPFILTER"
"CFG80211"
"MAC80211"
# "DRM_SUN4I"
# "DRM_SUN6I_DSI"
# "DRM_SUN8I_DW_HDMI"
# "DRM_SUN8I_MIXER"
"DRM_PANEL_FEIXIN_K101_IM2BA02"
"DRM_PANEL_FEIYANG_FY07024DI26A30D"
"DRM_PANEL_ILITEK_ILI9881C"
"DRM_PANEL_SITRONIX_ST7703"
"DRM_PANEL_SIMPLE" #< nixpkgs:m, pmos:y
] ++ lib.optionals withNixpkgsConfig [
"BINFMT_MISC"
# "DEFAULT_MMAP_MIN_ADDR"
"IP_NF_TARGET_REDIRECT"
"IP_PNP"
"LOGO"
"NLS_CODEPAGE_437" #< nixpkgs:m, pmos:y
"NLS_DEFAULT" #< nixpkgs:m, pmos:y
"NLS_ISO8859_1" #< nixpkgs:m, pmos:y
"NR_CPUS"
"CMA_SIZE_MBYTES"
"DEFAULT_MMAP_MIN_ADDR"
"PREEMPT"
"STANDALONE"
"TRANSPARENT_HUGEPAGE_ALWAYS"
"UEVENT_HELPER"
"USB_SERIAL"
"ZSMALLOC"
# "DRM_LIMA"
# "DRM_PANFROST"
# these options don't break build, but are nonsensical
"BASE_SMALL"
"BASE_FULL"
"CC_VERSION_TEXT"
"GCC_VERSION"
] ++ lib.optionals (withNixpkgsConfig && withFullConfig) [
# "STMMAC_ETH" #< autoModules:m, pmos:y
# "STMMAC_PLATFORM" #< autoModules:m, pmos:y
# "DWMAC_GENERIC" #< autoModules:m, pmos:y
# "DWMAC_SUNXI" #< autoModules:m, pmos:y
# "DWMAC_SUN8I" #< autoModules:m, pmos:y
"BLK_DEV_DM" #< autoModules:m, pmos:y
"VFIO" #< autoModules:m, pmos:y
]
);
}
] ++ lib.optionals (!usePmosConfig) [
{
name = "enable options for Pinephone";
patch = null;
extraStructuredConfig = with lib.kernel; {
# borrowed from postmarketOS, "to enable libcamera development"
# pmaports commit f18c7210ab
DMABUF_HEAPS = yes;
DMABUF_HEAPS_CMA = yes;
# borrowed from postmarketOS, speculatively, as i debug megapixels camera
# CMA_AREAS = "CMA allows to create CMA areas for particular purpose, mainly, used as device private area."
# "If unsure, leave the default value "8" in UMA and "20" in NUMA."
# - pinephone in mainline linux, postmarketOS, defaults to 7
# - nixos defaults to ... 19?
CMA_AREAS = freeform "7";
# DRM_ACCEL = lib.mkForce no;
# CMA_SIZE_MBYTES = lib.mkForce (freeform "256"); #< also available at boot time via `cma=256M` CLI
# #vvv aside from SUN50I_IOMMU, this is just upgrading modules to `y`
# DMA_SUN6I = yes;
SUN50I_IOMMU = yes;
# VIDEOBUF2_CORE = yes;
# VIDEOBUF2_V4L2 = yes;
# VIDEOBUF2_MEMOPS = yes;
# VIDEOBUF2_DMA_CONTIG = yes;
VIDEO_SUNXI = yes;
VIDEO_SUNXI_CEDRUS = yes;
# # VIDEO_SUNXI_CEDRUS = module; #< implied by VIDEO_SUNXI
# #^^^ this isn't enough to get camera working
MFD_SUN6I_PRCM = yes;
# # DRM = lib.mkForce yes; #< upgrade from module to builtin
# DEFAULT_MMAP_MIN_ADDR = lib.mkForce (freeform "4096");
# STANDALONE = lib.mkForce no;
# PREEMPT = lib.mkForce yes;
# TRANSPARENT_HUGEPAGE_ALWAYS = lib.mkForce yes;
# ZSMALLOC = lib.mkForce no;
# UEVENT_HELPER = lib.mkForce yes;
# USB_SERIAL = lib.mkForce module;
# ZSWAP = lib.mkForce no;
# # ZPOOL = lib.mkForce no;
# see: <https://gitlab.com/postmarketOS/pmaports/-/merge_requests/5541/>
# UDMABUF = yes; #< not needed (nixos default)
};
}
];
passthru = {
inherit patches;
};
}