about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/hardware/video/webcam/ipu6.nix
blob: c2dbdc217bd60f400e6f0f02378ff7b4cbb4e600 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ config, lib, pkgs, ... }:
let

  inherit (lib) mkDefault mkEnableOption mkIf mkOption optional types;

  cfg = config.hardware.ipu6;

in
{

  options.hardware.ipu6 = {

    enable = mkEnableOption (lib.mdDoc "support for Intel IPU6/MIPI cameras");

    platform = mkOption {
      type = types.enum [ "ipu6" "ipu6ep" "ipu6epmtl" ];
      description = lib.mdDoc ''
        Choose the version for your hardware platform.

        Use `ipu6` for Tiger Lake, `ipu6ep` for Alder Lake or Raptor Lake,
        and `ipu6epmtl` for Meteor Lake.
      '';
    };

  };

  config = mkIf cfg.enable {

    boot.extraModulePackages = with config.boot.kernelPackages; [
      ipu6-drivers
    ];

    hardware.firmware = [ pkgs.ipu6-camera-bins ];

    services.udev.extraRules = ''
      SUBSYSTEM=="intel-ipu6-psys", MODE="0660", GROUP="video"
    '';

    services.v4l2-relayd.instances.ipu6 = {
      enable = mkDefault true;

      cardLabel = mkDefault "Intel MIPI Camera";

      extraPackages = with pkgs.gst_all_1; [ ]
        ++ optional (cfg.platform == "ipu6") icamerasrc-ipu6
        ++ optional (cfg.platform == "ipu6ep") icamerasrc-ipu6ep
        ++ optional (cfg.platform == "ipu6epmtl") icamerasrc-ipu6epmtl;

      input = {
        pipeline = "icamerasrc";
        format = mkIf (cfg.platform != "ipu6") (mkDefault "NV12");
      };
    };
  };
}