1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-19 04:02:10 +00:00

Merge pull request #164185 from alexshpilkin/calibration

facetimehd: support sensor calibration files
This commit is contained in:
Graham Christensen 2022-04-29 15:53:30 -04:00 committed by GitHub
commit f00109472a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 2 deletions

View file

@ -85,7 +85,10 @@ in {
b43Firmware_6_30_163_46
b43FirmwareCutter
xow_dongle-firmware
] ++ optional pkgs.stdenv.hostPlatform.isx86 facetimehd-firmware;
] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
facetimehd-calibration
facetimehd-firmware
];
})
(mkIf cfg.wirelessRegulatoryDatabase {
hardware.firmware = [ pkgs.wireless-regdb ];

View file

@ -14,6 +14,18 @@ in
options.hardware.facetimehd.enable = mkEnableOption "facetimehd kernel module";
options.hardware.facetimehd.withCalibration = mkOption {
default = false;
example = true;
type = types.bool;
description = ''
Whether to include sensor calibration files for facetimehd.
This makes colors look much better but is experimental, see
<link xlink:href="https://github.com/patjak/facetimehd/wiki/Extracting-the-sensor-calibration-files"/>
for details.
'';
};
config = mkIf cfg.enable {
boot.kernelModules = [ "facetimehd" ];
@ -22,7 +34,8 @@ in
boot.extraModulePackages = [ kernelPackages.facetimehd ];
hardware.firmware = [ pkgs.facetimehd-firmware ];
hardware.firmware = [ pkgs.facetimehd-firmware ]
++ optional cfg.withCalibration pkgs.facetimehd-calibration;
# unload module during suspend/hibernate as it crashes the whole system
powerManagement.powerDownCommands = ''

View file

@ -0,0 +1,62 @@
{ lib, stdenv, fetchurl, unrar-wrapper, pkgs }:
let
version = "5.1.5769";
# Described on https://github.com/patjak/facetimehd/wiki/Extracting-the-sensor-calibration-files
# From the wiki page, range extracted with binwalk:
zipUrl = "https://download.info.apple.com/Mac_OS_X/031-30890-20150812-ea191174-4130-11e5-a125-930911ba098f/bootcamp${version}.zip";
zipRange = "2338085-3492508"; # the whole download is 518MB, this deflate stream is 1.2MB
# CRC and length from the ZIP entry header (not strictly necessary, but makes it extract cleanly):
gzFooter = ''\x51\x1f\x86\x78\xcf\x5b\x12\x00'';
# Also from the wiki page:
calibrationFiles = [
{ file = "1771_01XX.dat"; offset = "1644880"; size = "19040"; }
{ file = "1871_01XX.dat"; offset = "1606800"; size = "19040"; }
{ file = "1874_01XX.dat"; offset = "1625840"; size = "19040"; }
{ file = "9112_01XX.dat"; offset = "1663920"; size = "33060"; }
];
in
stdenv.mkDerivation {
pname = "facetimehd-calibration";
inherit version;
src = fetchurl {
url = zipUrl;
sha256 = "1dzyv457fp6d8ly29sivqn6llwj5ydygx7p8kzvdnsp11zvid2xi";
curlOpts = "-r ${zipRange}";
};
dontUnpack = true;
dontInstall = true;
buildInputs = [ unrar-wrapper ];
buildPhase = ''
{ printf '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00'
cat $src
printf '${gzFooter}'
} | zcat > AppleCamera64.exe
unrar x AppleCamera64.exe AppleCamera.sys
mkdir -p $out/lib/firmware/facetimehd
'' + lib.concatMapStrings ({file, offset, size}: ''
dd bs=1 skip=${offset} count=${size} if=AppleCamera.sys of=$out/lib/firmware/facetimehd/${file}
'') calibrationFiles;
meta = with lib; {
description = "facetimehd calibration";
homepage = "https://support.apple.com/kb/DL1837";
license = licenses.unfree;
maintainers = with maintainers; [ womfoo grahamc ];
platforms = [ "i686-linux" "x86_64-linux" ];
};
}

View file

@ -22907,6 +22907,8 @@ with pkgs;
extrace = callPackage ../os-specific/linux/extrace { };
facetimehd-calibration = callPackage ../os-specific/linux/firmware/facetimehd-calibration { };
facetimehd-firmware = callPackage ../os-specific/linux/firmware/facetimehd-firmware { };
fatrace = callPackage ../os-specific/linux/fatrace { };