-
-
Save notgne2/41ec4ce08982d42d803aac2dc485e27d to your computer and use it in GitHub Desktop.
{ | |
config, | |
pkgs, | |
lib, | |
inputs, | |
... | |
}: let | |
ipu6-camera-bin = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "ipu6-camera-bin"; | |
version = "main"; | |
src = pkgs.fetchFromGitHub { | |
owner = "intel"; | |
repo = "ipu6-camera-bins"; | |
rev = "main"; | |
sha256 = "sha256-XPT3dbV6Kl1/TEeiQESF4Q4s95hjtiv4VLlqlahQXqE="; | |
}; | |
installPhase = '' | |
mkdir $out | |
cp -r $src/ipu6ep/* $out | |
for pc in $out/lib/pkgconfig/*; do | |
substituteInPlace $pc \ | |
--replace "exec_prefix=/usr" "exec_prefix=\''${prefix}" \ | |
--replace "prefix=/usr" "prefix=$out" \ | |
--replace "libdir=/usr/lib" "libdir=$out/lib" \ | |
--replace "includedir=/usr/include" "includedir=$out/include" | |
done | |
''; | |
}; | |
ivsc-firmware = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "ivsc-firmware"; | |
version = "main"; | |
src = pkgs.fetchFromGitHub { | |
owner = "intel"; | |
repo = "ivsc-firmware"; | |
rev = "main"; | |
sha256 = "sha256-GuD1oTnDEs0HslJjXx26DkVQIe0eS+js4UoaTDa77ME="; | |
}; | |
installPhase = '' | |
mkdir -p $out/lib/firmware/vsc/soc_a1_prod | |
cp firmware/ivsc_pkg_ovti01a0_0.bin $out/lib/firmware/vsc/soc_a1_prod/ivsc_pkg_ovti01a0_0_a1_prod.bin | |
cp firmware/ivsc_skucfg_ovti01a0_0_1.bin $out/lib/firmware/vsc/soc_a1_prod/ivsc_skucfg_ovti01a0_0_1_a1_prod.bin | |
cp firmware/ivsc_fw.bin $out/lib/firmware/vsc/soc_a1_prod/ivsc_fw_a1_prod.bin | |
''; | |
}; | |
ipu6-camera-hal = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "ipu6-camera-hal"; | |
version = "main"; | |
src = pkgs.fetchFromGitHub { | |
owner = "intel"; | |
repo = "ipu6-camera-hal"; | |
rev = "main"; | |
sha256 = "sha256-dJvTZt85rt5/v2JXOsfbSY933qffyXW74L0nWdIlqug="; | |
}; | |
nativeBuildInputs = [cmake pkg-config]; | |
cmakeFlags = [ | |
"-DIPU_VER=ipu6ep" | |
"-DENABLE_VIRTUAL_IPU_PIPE=OFF" | |
"-DUSE_PG_LITE_PIPE=ON" | |
"-DUSE_STATIC_GRAPH=OFF" | |
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" | |
"-DCMAKE_INSTALL_LIBDIR=lib" | |
"-DCMAKE_INSTALL_INCLUDEDIR=include" | |
]; | |
buildInputs = [ | |
ipu6-camera-bin | |
expat.dev | |
libtool | |
]; | |
}; | |
icamerasrc = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "icamerasrc"; | |
version = "icamerasrc_slim_api"; | |
src = pkgs.fetchFromGitHub { | |
owner = "intel"; | |
repo = "icamerasrc"; | |
rev = "icamerasrc_slim_api"; | |
sha256 = "sha256-qlV363l4tUjUAa1LiZQq55byKpz1tLESKAXEmgiYHVo="; | |
}; | |
nativeBuildInputs = [automake autoconf autoreconfHook pkg-config]; | |
# gstreamer cannot otherwise be found | |
NIX_CFLAGS_COMPILE = "-I${gst_all_1.gst-plugins-base.dev}/include/gstreamer-1.0"; | |
CHROME_SLIM_CAMHAL = "ON"; | |
STRIP_VIRTUAL_CHANNEL_CAMHAL = "ON"; | |
buildInputs = [ | |
ipu6-camera-bin | |
ipu6-camera-hal | |
expat.dev | |
libtool | |
gst_all_1.gstreamer.dev | |
gst_all_1.gst-plugins-base.dev | |
libdrm.dev | |
]; | |
}; | |
ivsc-driver = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "ivsc-driver"; | |
version = "master"; | |
src = pkgs.fetchFromGitHub { | |
owner = "intel"; | |
repo = "ivsc-driver"; | |
rev = "master"; | |
sha256 = "sha256-Q7iyKw4WFSX42E4AtoW/zYRKpknWZSU66V5VPAx6AjA="; | |
}; | |
nativeBuildInputs = config.boot.kernelPackages.kernel.moduleBuildDependencies; | |
installTargets = ["modules_install"]; | |
makeFlags = | |
config.boot.kernelPackages.kernel.makeFlags | |
++ [ | |
"KERNELRELEASE=${config.boot.kernelPackages.kernel.modDirVersion}" | |
"KERNEL_SRC=${config.boot.kernelPackages.kernel.dev}/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/build" | |
"INSTALL_MOD_PATH=${placeholder "out"}" | |
]; | |
}; | |
ipu6-drivers = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "ipu6-drivers"; | |
version = "master"; | |
src = builtins.fetchGit { | |
url = "https://git.launchpad.net/~vicamo/+git/intel-ipu6-dkms"; | |
rev = "d44f973c27aa7dc77512f808ae84fda9846cdd4b"; | |
ref = "ubuntu/devel"; | |
}; | |
nativeBuildInputs = config.boot.kernelPackages.kernel.moduleBuildDependencies; | |
prePatch = '' | |
patches="$(echo debian/patches/*.patch)$(echo patches/*.patch)" | |
''; | |
installTargets = ["modules_install"]; | |
makeFlags = | |
config.boot.kernelPackages.kernel.makeFlags | |
++ [ | |
"KERNELRELEASE=${config.boot.kernelPackages.kernel.modDirVersion}" | |
"KERNEL_SRC=${config.boot.kernelPackages.kernel.dev}/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/build" | |
"INSTALL_MOD_PATH=${placeholder "out"}" | |
]; | |
}; | |
v4l2-relayd = with pkgs; | |
stdenv.mkDerivation rec { | |
pname = "v4l2-relayd"; | |
version = "main"; | |
src = pkgs.fetchFromGitLab { | |
owner = "vicamo"; | |
repo = "v4l2-relayd"; | |
rev = "main"; | |
sha256 = "sha256-3F1ySkGOGlSIPMi+p1NFip4wOsJ0gOdi08s9oQsZsG4="; | |
}; | |
nativeBuildInputs = [automake autoconf autoreconfHook pkg-config]; | |
preInstall = '' | |
mkdir -p $out/lib/systemd/system $out/etc | |
${pkgs.coreutils}/bin/cp -r $src/data/etc/* $out/etc | |
${pkgs.coreutils}/bin/cp -r $src/data/systemd/* $out/lib/systemd/system | |
''; | |
buildInputs = [ | |
gst_all_1.gstreamer.dev | |
gst_all_1.gst-plugins-base.dev | |
]; | |
}; | |
v4l2loopback = config.boot.kernelPackages.v4l2loopback.overrideAttrs (super: { | |
src = builtins.fetchGit { | |
url = "https://git.launchpad.net/ubuntu/+source/v4l2loopback"; | |
ref = "ubuntu/devel"; | |
rev = "b37d72d783e2605447858ab8bcdf80ddf5ea906a"; | |
}; | |
prePatch = '' | |
patches="$(echo debian/patches/*.patch)$(echo patches/*.patch)" | |
''; | |
}); | |
webcamName = "Stupid Webcam"; | |
in { | |
imports = [ | |
inputs.nixos-hardware.nixosModules.common-pc-ssd | |
inputs.nixos-hardware.nixosModules.common-pc-laptop | |
inputs.nixos-hardware.nixosModules.common-cpu-intel | |
]; | |
hardware.enableAllFirmware = true; | |
services.hardware.bolt.enable = true; | |
services.colord.enable = true; | |
services.fprintd.enable = true; | |
environment.etc.camera.source = "${ipu6-camera-hal}/share/defaults/etc/camera"; | |
systemd.services.v4l2-relayd = { | |
environment = { | |
GST_PLUGIN_SYSTEM_PATH_1_0 = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" (with pkgs.gst_all_1; [icamerasrc gstreamer gst-plugins-base gst-plugins-good]); | |
LD_LIBRARY_PATH = "${ipu6-camera-bin}/lib"; | |
}; | |
script = '' | |
export GST_DEBUG=2 | |
export DEVICE=$(grep -l -m1 -E "^${webcamName}$" /sys/devices/virtual/video4linux/*/name | cut -d/ -f6); | |
exec ${v4l2-relayd}/bin/v4l2-relayd \ | |
--debug \ | |
-i "icamerasrc" \ | |
-o "appsrc name=appsrc caps=video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! videoconvert ! video/x-raw,format=YUY2 ! v4l2sink name=v4l2sink device=/dev/$DEVICE" | |
''; | |
wantedBy = ["multi-user.target"]; | |
serviceConfig = { | |
User = "root"; | |
Group = "root"; | |
}; | |
}; | |
hardware.firmware = [ | |
ipu6-camera-bin | |
ivsc-firmware | |
]; | |
boot.extraModulePackages = [ | |
ipu6-drivers | |
ivsc-driver | |
v4l2loopback | |
]; | |
boot.kernelModules = [ | |
"v4l2loopback" | |
]; | |
boot.extraModprobeConfig = '' | |
options v4l2loopback exclusive_caps=1 card_label="${webcamName}" | |
''; | |
} |
Thanks a lot! Interestingly, you use volume at 8%, is there any reason for that? What happens if you put it 100%?
Also, if you can send me the output of dmesg and the configuration tab of pulseaudio (there are two modes) it would be helpful.
Oh thank you so much, I just realized that you sent me an email. Interesting, you also have the same "errors" as mine
Just realized you sent me dmesg via mail. Interesting to see that you also have the error sof_sdw sof_sdw: ASoC: Parent card not yet available, widget card binding deferred
:
$ cat dmesg.2024-03-07.log | rg -i "(audio|snd|sof)"
[ 0.047408] software IO TLB: area num 16.
[ 0.981880] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
[ 0.981881] software IO TLB: mapped [mem 0x00000000480cc000-0x000000004c0cc000] (64MB)
[ 3.335462] usb 1-1.3.4: Product: USB Audio
[ 12.927579] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
[ 12.927713] snd_hda_intel 0000:00:1f.3: SoundWire enabled on CannonLake+ platform, using SOF driver
[ 13.158365] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
[ 13.158594] sof-audio-pci-intel-tgl 0000:00:1f.3: SoundWire enabled on CannonLake+ platform, using SOF driver
[ 13.158607] sof-audio-pci-intel-tgl 0000:00:1f.3: enabling device (0000 -> 0002)
[ 13.158745] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100
[ 13.158819] sof-audio-pci-intel-tgl 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[ 13.169837] sof-audio-pci-intel-tgl 0000:00:1f.3: use msi interrupt mode
[ 13.185238] sof-audio-pci-intel-tgl 0000:00:1f.3: hda codecs found, mask 4
[ 13.199047] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware info: version 2:2:0-57864
[ 13.199050] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware: ABI 3:22:1 Kernel ABI 3:23:0
[ 13.199054] sof-audio-pci-intel-tgl 0000:00:1f.3: unknown sof_ext_man header type 3 size 0x30
[ 13.291867] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware info: version 2:2:0-57864
[ 13.291870] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware: ABI 3:22:1 Kernel ABI 3:23:0
[ 13.322341] sof-audio-pci-intel-tgl 0000:00:1f.3: Topology: ABI 3:22:1 Kernel ABI 3:23:0
[ 13.322431] sof_sdw sof_sdw: ASoC: Parent card not yet available, widget card binding deferred
[ 13.338662] sof_sdw sof_sdw: hda_dsp_hdmi_build_controls: no PCM in topology for HDMI converter 3
[ 13.357236] input: sof-soundwire HDMI/DP,pcm=5 as /devices/pci0000:00/0000:00:1f.3/sof_sdw/sound/card2/input23
[ 13.357261] input: sof-soundwire HDMI/DP,pcm=6 as /devices/pci0000:00/0000:00:1f.3/sof_sdw/sound/card2/input24
[ 13.357279] input: sof-soundwire HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:1f.3/sof_sdw/sound/card2/input25
[ 13.872286] usbcore: registered new interface driver snd-usb-audio
So it is a mystery, I have basically the same outputs/configuration/… still no working microphone. When I get back to the computer I'll try sudo alsactl init
to see if it changes anything, and double check if I've not muted the hardware of the microphone via some stupid key stokes…
Can I ask you one more favor, to give me a screenshot of your alsamixer
, after using F6
to select the right card? Sorry for all of this but it drives me crazy.
Ohhhh finally!! The solution is so simple sudo alsactl init
(module a simple bug here NixOS/nixpkgs#294170) Thank you soo much for your help, as it eliminated all questions related to softwares/kernel/…
Now, let's go to the webcam. First, it was working great with your code for browsers, thanks! (just, why is there a dummy webcam as well? It makes it hard to select the good one). But it is still not working for some softwares, like Cheese. Any idea how to get it working here?
Also, I wanted to ask about the comment "leave browsers here for sake of camera support" in the user-installed packages. Why is it working here and not outside?
Great your mic is finally working. The browser is the only application I need camera support so far. I tried to install the browsers my home-manager also. But that way camera support vanished.
Looks like cheese
would have the same issue on my laptop
[nix-shell:]$ cheese
(cheese:539286): Gdk-WARNING **: 09:16:52.061: Native Windows taller than 65535 pixels are not supported
** Message: 09:16:52.518: cheese-application.vala:222: Error during camera setup: No device found
(cheese:539286): cheese-CRITICAL **: 09:16:52.525: cheese_camera_device_get_name: assertion 'CHEESE_IS_CAMERA_DEVICE (device)' failed
(cheese:539286): GLib-CRITICAL **: 09:16:52.525: g_variant_new_string: assertion 'string != NULL' failed
(cheese:539286): GLib-CRITICAL **: 09:16:52.525: g_variant_ref_sink: assertion 'value != NULL' failed
(cheese:539286): GLib-GIO-CRITICAL **: 09:16:52.525: g_settings_schema_key_type_check: assertion 'value != NULL' failed
(cheese:539286): GLib-CRITICAL **: 09:16:52.525: g_variant_get_type_string: assertion 'value != NULL' failed
(cheese:539286): GLib-GIO-CRITICAL **: 09:16:52.525: g_settings_set_value: key 'camera' in 'org.gnome.Cheese' expects type 's', but a GVariant of type '(null)' was given
(cheese:539286): GLib-CRITICAL **: 09:16:52.525: g_variant_unref: assertion 'value != NULL' failed
** (cheese:539286): CRITICAL **: 09:16:52.525: cheese_preferences_dialog_setup_resolutions_for_device: assertion 'device != NULL' failed
(cheese:539286): Clutter-CRITICAL **: 09:17:25.786: Unable to create dummy onscreen: No foreign surface, and wl_shell unsupported by the compositor
Note that I needed sound.enable = true;
for this to persist across reboots (this runs alsactl store).
But that way camera support vanished.
oh, surprising
Cheese is for me the only application that I cannot get to work, irrespective of what I do. zoom/obs/firefox/chrome work, but not cheese.
Actually, I can get cheese to work if I run it as root, change in the preferences the app to select the good camera, and restart it. Not sure how to fix this as I get:
(cheese:13230): cheese-WARNING **: 15:47:35.995: stream error: can't negotiate buffers on port: ../src/gst/gstpipewiresrc.c(689): on_state_changed (): /GstCameraBin:camerabin/GstWrapperCameraBinSrc:camera_source/GstBin:bin36/GstPipeWireSrc:pipewiresrc1
I read this morning a notification of someone suggesting me this fix, with a link, but impossible to find it again!?
Seems like this is an upstream bug of cheese https://bugs.launchpad.net/ubuntu/+source/cheese/+bug/1978757
It's been a very long time since I last used this laptop, and have no idea how much of what I know or this Gist is still relevant. Are the current drivers able to automatically create a v4l2 device? Because if not, you might still need the v4l2-relayd stuff (create a virtual v4l2 device and automatically stream your webcam through it when an application wants to use it), unless everything has been updated to support whatever new protocol there is instead.
I do also remember the sudo alsactl init
thing, and think I ended up needing to run it every reboot but forgot to mention it.
Thanks for the answer. So the code of p-alik seems to be the minimal set of changes to apply. To avoid typing alsactl init, it seems like enabling sound.enable = true;
does a thing to preserve the setting.
Sorry I didn't mention sound.enable = true
before. :-(
@p-alik do you plan to submit your changes to https://github.com/NixOS/nixos-hardware? If yes, maybe add the sound.enable
line and a comment on alsactl init
(see also NixOS/nixpkgs#294170), and a line mentionning that cheese is broken due to an upstream bug. I also slightly improved your setting to hide the dummy camera (not even sure why it appears from the start) as it was confusing some softwares, see my changes here NixOS/nixpkgs#225743 (comment)
@p-alik do you plan to submit your changes to https://github.com/NixOS/nixos-hardware?
will do on coming weekend
I also slightly improved your setting to hide the dummy camera (not even sure why it appears from the start) as it was confusing some softwares, see my changes here NixOS/nixpkgs#225743 (comment)
Thanks
inxi -Fazy