pinwheel: Fix webcam breaking after resume from hibernation

Hibernation powers off the Lattice USBIO bridge that the ov08x40
sensor and Intel CVS sit behind. usbio has no reset_resume callback,
so on restore the USB core unbinds and rebinds it, which re-creates
the sensor and CVS I2C clients. The new clients lack the fwnode graph
that ipu-bridge built at boot, and ipu-bridge never rebuilds it, so
the camera stays dead until a cold boot.

Patch usbio to redo the bridge handshake in reset_resume instead of
being rebound, and patch gpio-usbio to restore its pin configuration
and output values after such a reset. Both are built from the kernel
source and installed under updates/, sharing the build recipe with
the patched ipu6-isys module.
This commit is contained in:
Alexander Heldt committed 2026-11-17 10:36:46 +01:00
1 parent c8b2340d14
commit c40dec90bd
2 files changed
+388 -34

No files matched your search

+68 -34
View File
@@ -7,46 +7,77 @@
let
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
ipu6-isys = pkgs.stdenv.mkDerivation {
mkPatchedModules =
{
pname,
srcPaths,
dir,
patches,
postPatch,
}:
pkgs.stdenv.mkDerivation {
inherit pname patches postPatch;
inherit (kernel) version;
__structuredAttrs = true;
nativeBuildInputs = kernel.moduleBuildDependencies;
unpackPhase = ''
tar -xf ${kernel.src} --strip-components=1 --wildcards \
${lib.escapeShellArgs (map (path: "*/${path}") srcPaths)}
'';
makeFlags = kernelModuleMakeFlags ++ [
"KERNELRELEASE=${kernel.modDirVersion}"
];
installFlags = [
"DEPMOD=true"
"INSTALL_MOD_PATH=${placeholder "out"}"
];
buildPhase = ''
runHook preBuild
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/${dir} "''${makeFlags[@]}"
runHook postBuild
'';
installPhase = ''
runHook preInstall
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/${dir} modules_install \
"''${makeFlags[@]}" "''${installFlags[@]}"
runHook postInstall
'';
};
ipu6-isys = mkPatchedModules {
pname = "ipu6-isys";
inherit (kernel) version;
__structuredAttrs = true;
srcPaths = [ "drivers/media/pci/intel/ipu6/*" ];
dir = "drivers/media/pci/intel/ipu6";
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
nativeBuildInputs = kernel.moduleBuildDependencies;
unpackPhase = ''
tar -xf ${kernel.src} --strip-components=1 --wildcards '*/drivers/media/pci/intel/ipu6/*'
'';
postPatch = ''
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
'';
};
makeFlags = kernelModuleMakeFlags ++ [
"KERNELRELEASE=${kernel.modDirVersion}"
usbio = mkPatchedModules {
pname = "usbio";
srcPaths = [
"drivers/usb/misc/usbio.c"
"drivers/gpio/gpio-usbio.c"
"include/linux/usb/usbio.h"
];
installFlags = [
"DEPMOD=true"
"INSTALL_MOD_PATH=${placeholder "out"}"
];
buildPhase = ''
runHook preBuild
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/drivers/media/pci/intel/ipu6 "''${makeFlags[@]}"
runHook postBuild
'';
installPhase = ''
runHook preInstall
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
M=$(pwd)/drivers/media/pci/intel/ipu6 modules_install \
"''${makeFlags[@]}" "''${installFlags[@]}"
runHook postInstall
dir = "usbio";
patches = [ ./usbio-reset-resume.patch ];
postPatch = ''
mkdir -p usbio/include/linux/usb
cp drivers/usb/misc/usbio.c drivers/gpio/gpio-usbio.c usbio/
cp include/linux/usb/usbio.h usbio/include/linux/usb/
echo 'LINUXINCLUDE := -I$(src)/include $(LINUXINCLUDE)' > usbio/Kbuild
echo 'obj-m += usbio.o gpio-usbio.o' >> usbio/Kbuild
'';
};
in
@@ -79,7 +110,10 @@ in
})
];
boot.extraModulePackages = [ ipu6-isys ];
boot.extraModulePackages = [
ipu6-isys
usbio
];
hardware.ipu6 = {
enable = true;