2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.hardware.facetimehd;
|
|
|
|
|
|
|
|
kernelPackages = config.boot.kernelPackages;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
options.hardware.facetimehd.enable = mkEnableOption (lib.mdDoc "facetimehd kernel module");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
options.hardware.facetimehd.withCalibration = mkOption {
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-27 09:35:20 +00:00
|
|
|
Whether to include sensor calibration files for facetimehd.
|
|
|
|
This makes colors look much better but is experimental, see
|
2022-08-12 12:06:08 +00:00
|
|
|
<https://github.com/patjak/facetimehd/wiki/Extracting-the-sensor-calibration-files>
|
2022-04-27 09:35:20 +00:00
|
|
|
for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
boot.kernelModules = [ "facetimehd" ];
|
|
|
|
|
|
|
|
boot.blacklistedKernelModules = [ "bdc_pci" ];
|
|
|
|
|
|
|
|
boot.extraModulePackages = [ kernelPackages.facetimehd ];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
hardware.firmware = [ pkgs.facetimehd-firmware ]
|
|
|
|
++ optional cfg.withCalibration pkgs.facetimehd-calibration;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# unload module during suspend/hibernate as it crashes the whole system
|
|
|
|
powerManagement.powerDownCommands = ''
|
|
|
|
${pkgs.kmod}/bin/lsmod | ${pkgs.gnugrep}/bin/grep -q "^facetimehd" && ${pkgs.kmod}/bin/rmmod -f -v facetimehd
|
|
|
|
'';
|
|
|
|
|
|
|
|
# and load it back on resume
|
|
|
|
powerManagement.resumeCommands = ''
|
|
|
|
${pkgs.kmod}/bin/modprobe -v facetimehd
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|