From 160e7e12d7dcf8013f8ce9b3143d7b823764c813 Mon Sep 17 00:00:00 2001 From: louib Date: Sat, 25 Mar 2023 19:38:01 -0400 Subject: [PATCH] feat: add backlight support for rpi4 --- raspberry-pi/4/backlight.nix | 50 ++++++++++++++++++++++++++++++++++++ raspberry-pi/4/default.nix | 4 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 raspberry-pi/4/backlight.nix diff --git a/raspberry-pi/4/backlight.nix b/raspberry-pi/4/backlight.nix new file mode 100644 index 0000000..f871421 --- /dev/null +++ b/raspberry-pi/4/backlight.nix @@ -0,0 +1,50 @@ +{ config, lib, ... }: + +let + cfg = config.hardware.raspberry-pi."4".backlight; +in +{ + options.hardware = { + raspberry-pi."4".backlight = { + enable = lib.mkEnableOption '' + Enable the backlight support for the Raspberry Pi official Touch Display + ''; + }; + }; + + config = lib.mkIf cfg.enable { + hardware.deviceTree = { + overlays = [ + # This overlay was originally taken from: + # https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/boot/dts/overlays/rpi-backlight-overlay.dts + # The only modification made was to change the compatible field to bcm2711 + { + name = "rpi-backlight-overlay"; + dtsText = '' + /* + * Devicetree overlay for mailbox-driven Raspberry Pi DSI Display + * backlight controller + */ + /dts-v1/; + /plugin/; + + / { + compatible = "brcm,bcm2711"; + + fragment@0 { + target-path = "/"; + __overlay__ { + rpi_backlight: rpi_backlight { + compatible = "raspberrypi,rpi-backlight"; + firmware = <&firmware>; + status = "okay"; + }; + }; + }; + }; + ''; + } + ]; + }; + }; +} diff --git a/raspberry-pi/4/default.nix b/raspberry-pi/4/default.nix index 6c5b1ba..ab399f7 100644 --- a/raspberry-pi/4/default.nix +++ b/raspberry-pi/4/default.nix @@ -1,8 +1,9 @@ -{ lib, pkgs, ...}: +{ lib, pkgs, ... }: { imports = [ ./audio.nix + ./backlight.nix ./cpu-revision.nix ./dwc2.nix ./i2c.nix @@ -22,6 +23,7 @@ "vc4" "pcie_brcmstb" # required for the pcie bus to work "reset-raspberrypi" # required for vl805 firmware to load + "rpi_backlight" # required for backlight support ]; loader = {