New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Surface book 2 camera not working #523
Comments
Hi @damianoognissanti, I don't have access to a Surface Book, so might need some help. Some early thoughts:
|
I am not sure, but I have since also tried to install Void Linux too to see if it worked there. There I had to compile the kernel from source and it worked (I tested both for version 6.0.15 as well as 6.1.3). |
Looking at module-ids-and-sensor-mappings the modules seem to be different even though the cameras use the same sensors. |
#537 just merged, which should make it a lot easier to create a specialisation for the Surface Book. Since I don't have access to a Surface Book, perhaps you (@damianoognissanti) would be interested in trying to create something like And then we can work on trying to troubleshoot that config. for your needs? |
I added Is there something else in NixOS' structure that makes it not work? |
I have tried to create a working config, but it just doesn't work. Now to an even stranger thing: I tried to install Linux Mint on the laptop and chose to install Ubuntu's OEMKernel (version 6.1.0) and with that the camera works. In NixOS the camera neither works with the standard 6.1.2 kernel (installed with Compiling also takes extremely long and I can't find how to replace the kernel config (so that I can use a localmodconfig when debugging). It's easy enough to add more kernel config options, but not to change config file or remove unneeded options (to decrease compile time). I almost feel like giving up at this point... |
Some more details on how to build kernels from source in nixos: https://blog.thalheim.io/2022/12/17/hacking-on-kernel-modules-in-nixos |
Correction, the OEM-kernel detects all cameras on Linux Mint, but they don't work unless the linux-surface kernel is installed. In NixOS they aren't even detected at all. I will look at he link you sent @Mic92. |
I've had a chance to look at the Camera Support page, and one thing that jumped for me out is that the IPU3 firmware may not be being correctly loaded:
This jumped out as I had to do something similar to get the Surface Go's camera working a few years ago. Is there anything in |
I tried to use
|
I am also running into this issue and can confirm @damianoognissanti's experience that it Just Works™ on Arch Linux with the patched linux-surface kernel, while it does not seem to work on NixOS with the same exact set of kernel patches. I noticed the same Looking at the difference between Arch's and Nix's Arch `dmesg | grep ipu3`
NixOS `dmesg | grep ipu3`
NixOS Surface-related config{ config, lib, pkgs, ... }:
let
unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
libcamera_0_0_3 = unstable.libcamera.overrideAttrs (oldAttrs: rec {
version = "0.0.3";
src = fetchGit {
url = "https://git.libcamera.org/libcamera/libcamera.git";
rev = "f66a5c447b65bce774a1bc2d01034f437bf764b5";
};
});
linuxFirmwareNonfree = fetchGit {
url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git";
rev = "2c27b0cb02f18c022d8378e0e1abaf8b7ae8188f";
};
in
{
imports = [
<nixos-hardware/microsoft/surface/surface-pro-intel>
];
microsoft-surface.surface-control.enable = true;
microsoft-surface.ipts.enable = true;
services.udev.packages = [ pkgs.iptsd ];
### Camera-related stuffs
# Install the IPU3 firmware from linux-firmware to the path mentioned in the linux-surface wiki
hardware.enableAllFirmware = true;
hardware.firmware = [
(pkgs.runCommandNoCC "firmware-ipu3" { } ''
mkdir -p $out/lib/firmware/intel/
cp ${linuxFirmwareNonfree}/intel/irci_irci_ecr-master_20161208_0213_20170112_1500.bin $out/lib/firmware/intel/ipu3-fw.bin
'')
];
boot.kernelParams = [
"intel_pstate=no_hwp"
"mem_sleep_default=deep"
"acpi_enforce_resources=lax"
];
environment.systemPackages = with pkgs; [
libcamera_0_0_3
];
} |
Another interesting finding: despite On Arch, the kernel module is available at Arch `lsmod | grep ipu3`
NixOS `lsmod | grep ipu3`
On Nix, the On Arch, the I'm guessing it's related to the kernel config option
I will fork the nixos-hardware repo, add |
I have forked the nixos-hardware repo, added |
I just realized all kernel configs in I have made a local copy of the |
Still doesn't work with the fixed prefix.nix. I also see that 5.19.17 had the correct config format (and that didn't work when I tried it in December). |
What I did for debugging was to git clone the repo to
to
Note that it's best if you have the entire |
Ugh, crap, that's likely a copy-paste typo on my part, from the And I updated the #534 PR. |
BTW: |
Thanks for pointing out I can clone the repo locally and modify it! That's significantly simpler then commit + push + update revision in my nixos config. I used the updated version without the Based on the way the hardened kernel adds structuredExtraConfig, I believe we need to move the extra kernel config from a patch directly to a After 1. stripping the I removed that line, and now nixos-rebuild is rebuilding both the kernel config and the kernel itself. I will report back later tonight whether this fixes the issue. |
FYI: My main difference is perhaps that I moved to Nix flakes about 1½ years ago, and recently started leveraging temporary flake-registry changes when testing |
Nope, |
Huzzah! I'm pleased to report that the cameras are working for me now with the changes here. I am prohibited by my employment contract from sending a PR to a project with CC0 licencing (hint, hint) All of the following are required:
|
Thanks for checking, @damianoognissanti !
Brilliant news, @leonm1 ! I have PRs for the If these fixes also work on that, I'm hoping to drop the |
Hmmm, there might be something fundamentally different about my set-up, asI simply couldn't get your new code structure to build, @leonm1. e.g. My NixOS set-up is based on release 22.11, and I build my system with Flakes, rather than Nix paths. I was getting about |
So, it seems that I changed that line in Will report back if it works in an hour. |
Wow, this is incredible! Good job!!! |
Wow! It's working!! I have pushed the changes to my fork. 😄
|
Additional info:
|
Oh, I have a custom This might be off topic, but I have uploaded it here. |
Oh sheesh! [...]
Nice! FYI: The If you'd like to mess with it, you'll have to select it with |
is this solved now? |
No; a few additional changes are required:
For the 6.1.6 kernel, that looks like this:
|
The kernels here still use Can this be fixed, please? And is there a possibility that a binary kernel could be cached in some way (like other software in the nix store) so that recompilation is not necessary when updating? |
Sorry for spamming, but the kernels get updated, but still use structuredExtraConfig instead of extraStructuredConfig, which means if I update the kernel the camera breaks if I don't manually fix it every time. https://github.com/NixOS/nixos-hardware/blob/master/microsoft/surface/common/kernel/linux-6.1.55/patches.nix And the option EDIT: It looked like it was fixed when I compiled the kernel (it looked like the patches were applied), but the camera won't work with the new kernel, so the patches aren't applied. |
As discussed here: NixOS#523 1) `structuredExtraConfig` is called `extraStructuredConfig` when using `kernelPatches` 2) STREAMING_MEDIA should be STAGING_MEDIA
I believe this issue is NixOS-specific since I got it working on Arch with the same laptop. I am not sure if this is an issue with the kernel of libcamera though, so please tell me if this is the wrong place to ask.
I have trouble with getting any of the cameras working on my Surface book 2 using NixOS.
I have tried the kernel version 6.0.11 with libcamera 0.0.1, 0.0.2 and 0.0.3 without success. I have also tried kernel version 5.19.17 with libcamera 0.0.3, but I get nothing.
Running
LIBCAMERA_LOG_LEVELS=*:0 cam --list
I getIf I run
dmesg | grep ov8865
I get these lines repeated over and over and over:Running
v4l2-ctl --list-devices
I getBut
ffplay /dev/video0
says:And the output is the same for the others too.
Running
guvcview
it saysno device found
andYou seem to have video devices installed. Do you want to try one?
but in the drop down there are four entries which all readIntel IPU3 CIO2
and none of them work.The text was updated successfully, but these errors were encountered: