lol

Merge pull request #164185 from alexshpilkin/calibration

facetimehd: support sensor calibration files

authored by

Graham Christensen and committed by
GitHub
f0010947 a7caefa4

+82 -2
+4 -1
nixos/modules/hardware/all-firmware.nix
··· 85 85 b43Firmware_6_30_163_46 86 86 b43FirmwareCutter 87 87 xow_dongle-firmware 88 - ] ++ optional pkgs.stdenv.hostPlatform.isx86 facetimehd-firmware; 88 + ] ++ optionals pkgs.stdenv.hostPlatform.isx86 [ 89 + facetimehd-calibration 90 + facetimehd-firmware 91 + ]; 89 92 }) 90 93 (mkIf cfg.wirelessRegulatoryDatabase { 91 94 hardware.firmware = [ pkgs.wireless-regdb ];
+14 -1
nixos/modules/hardware/video/webcam/facetimehd.nix
··· 14 14 15 15 options.hardware.facetimehd.enable = mkEnableOption "facetimehd kernel module"; 16 16 17 + options.hardware.facetimehd.withCalibration = mkOption { 18 + default = false; 19 + example = true; 20 + type = types.bool; 21 + description = '' 22 + Whether to include sensor calibration files for facetimehd. 23 + This makes colors look much better but is experimental, see 24 + <link xlink:href="https://github.com/patjak/facetimehd/wiki/Extracting-the-sensor-calibration-files"/> 25 + for details. 26 + ''; 27 + }; 28 + 17 29 config = mkIf cfg.enable { 18 30 19 31 boot.kernelModules = [ "facetimehd" ]; ··· 22 34 23 35 boot.extraModulePackages = [ kernelPackages.facetimehd ]; 24 36 25 - hardware.firmware = [ pkgs.facetimehd-firmware ]; 37 + hardware.firmware = [ pkgs.facetimehd-firmware ] 38 + ++ optional cfg.withCalibration pkgs.facetimehd-calibration; 26 39 27 40 # unload module during suspend/hibernate as it crashes the whole system 28 41 powerManagement.powerDownCommands = ''
+62
pkgs/os-specific/linux/firmware/facetimehd-calibration/default.nix
··· 1 + { lib, stdenv, fetchurl, unrar-wrapper, pkgs }: 2 + 3 + let 4 + 5 + version = "5.1.5769"; 6 + 7 + 8 + # Described on https://github.com/patjak/facetimehd/wiki/Extracting-the-sensor-calibration-files 9 + 10 + # From the wiki page, range extracted with binwalk: 11 + zipUrl = "https://download.info.apple.com/Mac_OS_X/031-30890-20150812-ea191174-4130-11e5-a125-930911ba098f/bootcamp${version}.zip"; 12 + zipRange = "2338085-3492508"; # the whole download is 518MB, this deflate stream is 1.2MB 13 + 14 + # CRC and length from the ZIP entry header (not strictly necessary, but makes it extract cleanly): 15 + gzFooter = ''\x51\x1f\x86\x78\xcf\x5b\x12\x00''; 16 + 17 + # Also from the wiki page: 18 + calibrationFiles = [ 19 + { file = "1771_01XX.dat"; offset = "1644880"; size = "19040"; } 20 + { file = "1871_01XX.dat"; offset = "1606800"; size = "19040"; } 21 + { file = "1874_01XX.dat"; offset = "1625840"; size = "19040"; } 22 + { file = "9112_01XX.dat"; offset = "1663920"; size = "33060"; } 23 + ]; 24 + 25 + in 26 + 27 + stdenv.mkDerivation { 28 + 29 + pname = "facetimehd-calibration"; 30 + inherit version; 31 + src = fetchurl { 32 + url = zipUrl; 33 + sha256 = "1dzyv457fp6d8ly29sivqn6llwj5ydygx7p8kzvdnsp11zvid2xi"; 34 + curlOpts = "-r ${zipRange}"; 35 + }; 36 + 37 + dontUnpack = true; 38 + dontInstall = true; 39 + 40 + buildInputs = [ unrar-wrapper ]; 41 + 42 + buildPhase = '' 43 + { printf '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00' 44 + cat $src 45 + printf '${gzFooter}' 46 + } | zcat > AppleCamera64.exe 47 + unrar x AppleCamera64.exe AppleCamera.sys 48 + 49 + mkdir -p $out/lib/firmware/facetimehd 50 + '' + lib.concatMapStrings ({file, offset, size}: '' 51 + dd bs=1 skip=${offset} count=${size} if=AppleCamera.sys of=$out/lib/firmware/facetimehd/${file} 52 + '') calibrationFiles; 53 + 54 + meta = with lib; { 55 + description = "facetimehd calibration"; 56 + homepage = "https://support.apple.com/kb/DL1837"; 57 + license = licenses.unfree; 58 + maintainers = with maintainers; [ womfoo grahamc ]; 59 + platforms = [ "i686-linux" "x86_64-linux" ]; 60 + }; 61 + 62 + }
+2
pkgs/top-level/all-packages.nix
··· 22907 22907 22908 22908 extrace = callPackage ../os-specific/linux/extrace { }; 22909 22909 22910 + facetimehd-calibration = callPackage ../os-specific/linux/firmware/facetimehd-calibration { }; 22911 + 22910 22912 facetimehd-firmware = callPackage ../os-specific/linux/firmware/facetimehd-firmware { }; 22911 22913 22912 22914 fatrace = callPackage ../os-specific/linux/fatrace { };