Repository navigation
Apply the IPU7 camera's ISP tuning, fix its gain, range and exposure, harden PSYS pinning, and support Lunar Lake - #723
Conversation
…exposure The XPS 14 / 16 webcam looked soft and grainy because almost none of the image pipeline was tuned: - 0011: the graph asks for ISP tuning mode 4, which the OV08X40 tuning does not carry, so the generic AIC found no tunings and noise reduction, TNR and sharpening ran on library defaults. Fall back to the tuning's default ISP container. - 0010: AIQ emits the raw analog gain register code, which the in-tree ov08x40 driver halves, so the sensor ran at twice the gain AE and the ISP noise model assumed. - 0008: the HAL ignored the requested YUV range and always produced full-range frames that consumers decode as limited range. - 0009 + relay config: icamerasrc pinned auto exposure to 1/30 s; a new fps-range property lets AE lengthen frames in dim light, with gain capped at 27 dB.
Setting icamerasrc's new fps-range property to NULL, its own default, handed NULL to gst_camerasrc_parse_range, which crashed in strlen(). NULL now leaves the last range in effect, because the HAL has no way to drop a range once set. The value the relay sets goes through unchanged. The relay comment said AE raises gain past 27 dB once frames reach 15 fps, but gain-range becomes a hard ISO ceiling (manual_iso_max), so gain never goes past it. The 0008 message credited the sensor JSON's yuvColorRangeMode, which only the mock HAL reads. Co-Authored-By: Codex XHigh <noreply@openai.com>
|
Reviewed by Claude Opus 5.5 with a second opinion from Codex at xhigh, over two rounds, at 8aedb1a. CI is green on that head. What was checked. Every patch was read against the sources the PKGBUILD pins (ipu7-camera-hal b1f6ebe, icamerasrc 4fb31db, ipu7-camera-bins 403c67d) and against the in-tree
The camera itself was not driven. The image-quality results rest on the author's measurements on an XPS 16 DA16260. Pushed in 8aedb1a:
Open, for the author: the relay also drops Considered and left as is:
Codex's own findings were the NULL crash, the 0008 message and the leak. Where it agreed with points already written down, that agreement is not independent: it can read this session's working notes. Waiting on: a hardware confirmation from a maintainer other than the author, on an XPS 14 or 16, at 8aedb1a. The XPS 14 DA14260 is untested so far. This head's CI build installs directly: gh run download 36593789702 -R omacom/omarchy-pkgs -n intel-ipu7-camera-x86_64-08072c706ff914d3673d7439dbfe6b398dc2d13b
tar -xf packages.tar
sudo pacman -U intel-ipu7-camera-1.0.6-3-x86_64.pkg.tar.zstThen reboot and compare a call in a dim room and one in daylight against 1.0.6-2. — 🤖 Claude, posting on behalf of @spencerbull |
finalize never freed the string the fps-range setter allocates, so every icamerasrc element that had the property set leaked it. The other string properties leak the same way upstream and are left to an upstream fix for all of them. Co-Authored-By: Codex XHigh <noreply@openai.com>
|
Hi, i tested these changes on latest omarchy XPS 14 DA14260 at 4K resolution. The grain is gone in indoor low light conditions with these newer tunings. |
|
@HritwikSinghal thanks for testing! I'm doing some more tests to work to clean it up the tune in different lighting scenarios. |
|
Reviewed again by Claude Opus 5.5 at 802ad18, with Codex at xhigh on the new commit. CI is green on that head. Pushed in 802ad18: On hardware. This head's CI package ran on an XPS 16 DA16260 (7.2.5-4-omarchy) beside 1.0.6-2, both straight from icamerasrc with the relay stopped, and was then installed and streamed through
On the XPS 14 report, thanks @HritwikSinghal. At 4K the graph asks for ISP tuning mode 0, which the tuning does carry, so 0011 changes nothing there. What changes at 4K is the gain units, the range and the relay settings. In medium indoor light (AE at 6–9x and 33 ms), this build was not brighter than 1.0.6-2 at 4K:
Turning the gain fix off in the same light changed nothing, and at 1080p restoring What does differ is contrast and colour. Viewers stretch 1.0.6-2's full-range frames, which crushes blacks, clips whites and adds about 14% to chroma, so it looks punchier. This build is flatter and about 20% less saturated at 4K (35% at 1080p). Two things would pin it down: which app you viewed the camera in, and whether "overexposed" means too bright, or flat and pale. Waiting on: the tester's answer, and the author's tuning pass for brighter light, which is under way. — 🤖 Claude, posting on behalf of @spencerbull |
|
A colour check on 802ad18, measured by Claude Opus 5.5 on the XPS 16 DA16260. No second opinion ran on this measurement. The XPS 16 photographed a ColorChecker shown on a phone in its Natural (sRGB) screen mode, with exposure bracketed to match the MacBook shot. The MacBook reference is Notebookcheck's webcam photo of a physical ColorChecker taken with the MacBook Pro 14 (2021, 1080p); re-measured here, it gives their published ΔE of 11.2.
This build's tone curve matches the MacBook's, and its saturation is at least as high. A phone screen likely inflates chroma somewhat, so read it as "not weak" rather than as an exact figure. The flatter look against 1.0.6-2 is viewers no longer stretching its full-range frames, which crushed shadows and added about 14% chroma. That changes what my previous comment implied: @HritwikSinghal, the questions from before still stand: which app you viewed the camera in, and whether "overexposed" meant too bright, or flat and pale. — 🤖 Claude, posting on behalf of @spencerbull |
|
Hi, i captured the images using gnome snapshot camera app and viewed them on my laptop only (XPS 14 OLED, omarchy). here is the zip of images i took from both old and new tunings. https://send.bitwarden.com/#xh1mwXRC4UqW9rTVAHp8_Q/e40Q0ojuZzbNoa5sqFekJQ (the link is valid for 2 days). the password to access this is the full commit hash of Apply the Intel IPU7 camera's ISP tuning and fix its gain, range and exposure commit. the files are named like 'new_high.jpeg', meaning 'new' tunings in 'high' lighting conditions, and so on. |
(cherry picked from commit 5f1d001)
(cherry picked from commit 9ce97d9)
Use linux-omarchy-headers only for check(), avoiding Arch headers on installed Omarchy systems and matching the supported kernel build configuration. Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com> (cherry picked from commit d0d382c)
Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com> (cherry picked from commit eb37cc8)
|
@spencerbull a heads up! Linux kernel now carries this portion of the DKMS out-of-tree driver: The in-tree driver (already carries entries for Nova Lake sensor): Both of these will now conflict and the camera will no longer work. |
Intel's PSYS driver has two buffer-lifecycle bugs that this package does not fix: a GETBUF that is never mapped leaves the buffer owned by both the PSYS handle and the exported dma-buf, so closing the two is a use-after-free and a double free, and UNMAPBUF drops its mapping reference before clearing the attachment, racing a concurrent dma-buf release. Any account that can open /dev/ipu7-psys0 can reach both. Nothing but v4l2-relayd@ipu7, which runs as root, opens the node; applications use the v4l2loopback device. With the node at 0600 root:root the camera streams the same, so the video group and the seat user lose nothing and the bugs need root. GROUP and MODE are explicit so the upgrade's change event also tightens nodes on running machines. Co-Authored-By: Codex XHigh <noreply@openai.com>
linux-omarchy and linux-omarchy-bore build drivers/media/i2c/cvs in-tree (CONFIG_VIDEO_INTEL_CVS=m) and carry the same wake-IRQ fix as our 0007 (0542), plus the Nova Lake ACPI ID (0541) that our copy lacks. The DKMS module has the same name and installs under updates/, so on every 7.2+ kernel it displaced the kernel's signed module with an unsigned, older copy: on Nova Lake that copy cannot bind the CVS device and the camera fails, and any later fix in the kernel's driver would be masked. Krzysztof Wilczyński reported the conflict on omacom#723. Skipping the build only on kernels that carry the driver (BUILD_EXCLUSIVE_CONFIG) would have kept it for stock Arch kernels, but the pacman dkms hook reports every such skip as "exited 77", so every Omarchy kernel update would print a warning. A stock Arch kernel left installed as the fallback boot entry now has no camera. On upgrade the dkms hook removes intel-cvs and restores the kernel's original module. vision-drivers still covers kernels before 7.2.
linux-omarchy and linux-omarchy-bore build drivers/media/i2c/cvs in-tree (CONFIG_VIDEO_INTEL_CVS=m) and carry the same wake-IRQ fix as our 0007 (0542), plus the Nova Lake ACPI ID (0541) that our copy lacks. The DKMS module has the same name and installs under updates/, so on every 7.2+ kernel it displaced the kernel's signed module with an unsigned, older copy: on Nova Lake that copy cannot bind the CVS device and the camera fails, and any later fix in the kernel's driver would be masked. Krzysztof Wilczyński reported the conflict on omacom#723. Skipping the build only on kernels that carry the driver (BUILD_EXCLUSIVE_CONFIG) would have kept it for stock Arch kernels, but the pacman dkms hook reports every such skip as "exited 77", so every Omarchy kernel update would print a warning. A stock Arch kernel left installed as the fallback boot entry now has no camera. On upgrade the dkms hook removes intel-cvs and restores the kernel's original module. vision-drivers still covers kernels before 7.2.
|
Reviewed again by Claude Opus 5.5 at 63e9e03, with Codex at xhigh on the fold and on the two commits after it. CI is green on that head. @kwilczynski, thanks: agreed, and fixed in 63e9e03. Also on this head:
On hardware: the CI package of this head on an XPS 16 DA16260 (
Hot-reloading Found in review and confirmed against the source, not fixed here:
— 🤖 Claude, posting on behalf of @spencerbull |
…its frames
Two Panther Lake assumptions in this package break Lunar Lake boards, where it
is installed by the same hardware detection.
Build both HAL platforms. libcamhal picks its plugin by platform, and a Lunar
Lake machine asks for one that was never built:
CamHAL[ERR] HalAdaptor: load_camera_hal_library, failed to open library:
/usr/lib/libcamhal/plugins/ipu7x.so: No such file or directory
CamHAL[WAR] CameraParserInvoker: parseSensors: No sensors available
so the camera cannot work at all. The proprietary side of it is already
shipped -- libia_aic-ipu7x.so and the rest of that set come from
ipu7-camera-bins today; only the plugin the HAL loads was missing. Upstream
builds both platforms from one configure run and `make install` lays down
/etc/camera/ipu7x/ alongside ipu75xa, including the tuning this hardware
wants (OV08X40_BBG802N3_LNL.aiqb, gcss/OV08X40_BBG802N3_LNL.IPU7X.bin), so the
change is the IPU_VERSIONS list plus 0008, the ipu7x twin of 0006: the
"Intel CVS" pad formats that 1.0.6 added to the ipu75xa sensor config are
needed in the ipu7x one for the same reason, or link validation fails at
stream-on behind the Linux 7.2 bridge entity.
Pick the relay pipeline per board. v4l2-relayd-ipu7.conf rotates every frame
180 degrees, which is right where the sensor is mounted inverted and wrong
here: the sensor reports camera_sensor_rotation = 0 and camera_orientation =
Front, and the picture arrives upside down in every application. camera-init
now writes VIDEOSRC to /run based on the bridge ACPI id and the relay drop-in
reads it. Only INTC10DE takes the new path; INTC10E1, INTC10CF, INTC10E0 and
anything unrecognised keep the packaged pipeline byte for byte, and a boot
where camera-init did not run falls back to it as well.
Verified on a Dell Pro 14 Premium PA14250 (Lunar Lake, INTC10DE, OV08X40 +
HM1092) against intel-ipu7-camera 1.0.6-2 on linux-omarchy 7.2.5-3: with the
package's own intel-cvs DKMS the sensor joins the graph behind "Intel CVS",
the ipu7x plugin built from the pinned commit with 0005 and 0008 resolves
ov08x40-uf on CSI port 0, v4l2-relayd streams 30 fps to /dev/video50 and the
image is upright in a browser.
Note for reviewers: necessary but not sufficient on Lunar Lake. Three more
things this board needs are not in this PR: the sensor probe races the
bridge's runtime suspend (camera-init's `sleep 2` lands while the I2C bus is
still owned by the bridge firmware and ov08x40 reads its chip id as -110),
the in-tree cvs driver's quirk for the Synaptics SVP7500 (06cb:0701) hands
the privacy LED to the host so it never lights, and ipu-bridge before 7.3
does not know the HM1092 IR sensor. Details in omacom#366.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 9be51b4)
camera-videosrc-init wrote VIDEOSRC for every board, with a copy of the pipeline the relay config carried when it was written, and its file is read after /etc/v4l2-relayd.d/ipu7.conf. On Panther Lake that replaced this branch's fps-range, gain-range and color-range settings with the old sharpness=80 ev=-1 saturation=10 pipeline. It now writes nothing unless the board is Lunar Lake, and there it takes the packaged pipeline and drops only the rotation, so a later change to the relay config reaches both platforms. It also removes a file left by an earlier run, which camera-init's restart on resume would otherwise keep. The ipu7x CVS format patch becomes 0012: 0008 is already the YUV range patch.
camera-videosrc-init ran from camera-init.service and sourced /etc/v4l2-relayd.d/ipu7.conf as bash. A config that is valid for systemd but not for bash, such as an unquoted VIDEOSRC, made it fail and Lunar Lake fell back to the rotated pipeline; and because camera-init stays active, editing the config and restarting only the relay kept the override cached since boot. It now runs as the relay's ExecStartPre, where systemd hands it VIDEOSRC already parsed from the relay's own environment files, and writes the override quoted for systemd's parser. ExecStart re-reads the drop-in's EnvironmentFile and ExecStopPost removes it, so each start sees the current config. Co-Authored-By: Codex XHigh <noreply@openai.com>
The Lunar Lake tuning (OV08X40_BBG802N3_LNL.aiqb) carries the same CMC gain table as the Panther Lake one, 1x = code 256, and both platforms use the same in-tree ov08x40 driver, which takes 1x = 128. Without the shift a 4x request ran the Lunar Lake sensor at 8x, the mismatch 0010 fixes on Panther Lake. 0010 now sets analogGainCodeShift in the ipu7x sensor config as well. Co-Authored-By: Codex XHigh <noreply@openai.com>
systemd passes ExecStartPre the unit's environment files as they stand when that command starts, so the generator saw a /run override left behind by a crash or SIGKILL (anything that skipped ExecStopPost) and took its VIDEOSRC for the configured one: an edited /etc/v4l2-relayd.d/ipu7.conf would lose to the stale file. Removing the file in its own ExecStartPre first means the generator's environment is re-read without it. Co-Authored-By: Codex XHigh <noreply@openai.com>
|
Reviewed again by Claude Opus 5.5 at 9b87400. Codex at xhigh reviewed every commit since 63e9e03 and the 4K measurements below. CI is green on that head. #367 by @pkolbas is folded in, authorship kept. It builds the Lunar Lake HAL plugin, adds that plugin's CVS pad formats (now
On hardware: the CI package of this head on an XPS 16 DA16260 (Panther Lake).
New: stale frames at 4K, more often with this PR. When Intel's closed-source parameter adaptation fails for a frame, the first ISP stage (
Codex and I both read this as a documented 4K follow-up, not a reason to hold the PR, for these reasons:
Running such a frame with the latest good parameters is the HAL change to try. The cached parameters are shared buffers, though, so it needs care. The adaptation reports only Next: merging is the maintainer's call. The Lunar Lake confirmation on #367 doesn't block this PR, because without this change the package has no Lunar Lake HAL plugin at all. — 🤖 Claude, posting on behalf of @spencerbull |
e150d06 to
4e0b35b
Compare
|
All of my commits on this branch now use spencer@omarchy.org instead of spencer.bull@hey.com, and so do the Earlier comments cite the old SHAs:
— 🤖 Claude, posting on behalf of @spencerbull |
At the sensor's full 3856x2176 the ISP's output has a fixed, strictly periodic 4-pixel grid in flat and shadowed areas (confirmed by FFT, so not sensor noise). Viewers that scale the 4K loopback down only turn it into a 2-pixel period; Google Meet shows it even though it reports 1080p. The same sensor data comes out clean, with only random grain, when the ISP itself scales to 1080p. 1080p also avoids stale-frame motion trails: Omarchy found the HAL's parameter adaptation sometimes fails at 4K and serves an image about six frames old (10/10 runs at 4K vs 0/9 at 1080p, omacom/omarchy-pkgs#723), and that reproduces here. Resolution costs nothing above 720p because the sensor has one native mode and the ISP scales.
Problem
The Dell XPS 14 / 16 webcam (OV08X40 on IPU7.5, Panther Lake) is soft and grainy, and noticeably worse than the same laptop on Windows. Measured on an XPS 16 DA16260, the grain turned out to be four separate problems in our stack, not the sensor.
OV08X40_KAFE799.IPU75XA.bin) tags the 1080p video pipe with ISP tuning mode 4, but the tuning file (OV08X40_KAFE799_PTL.aiqb) only carriesDFLT,LMOD 1andLMOD 2.PipeLine::updateIspTuningModefails withFailed to update tuning 4, and the HAL carries on with mode 4 anyway.gaic_find_all_tunings(60001, 4)every frame and gets nothing back.init()defaults.enable = 0and all-zero weights: frame-to-frame noise equalled single-frame noise.0x3508register code (1x = 256).ov08x40driver takesV4L2_CID_ANALOGUE_GAINas half of that (1x = 128, max 1984) and clamps anything higher.analogue_gain = 1984, i.e. 15.5x on the sensor.color-range=reducedand always produced full-range (0-255) frames, which consumers decode as limited range: crushed shadows and clipped highlights.Change (intel-ipu7-camera 1.0.6-3)
DFLT) ISP container and configure the CB stages with mode 0, which is how the generic AIC indexes it. The generic AIC then finds 224 tunings for the video stream. Tunings that carry the requested mode are unchanged.analogGainCodeShiftsensor option that scales AIQ analog gain codes to the driver's units, set to 1 in theov08x40-uf.jsonof bothipu75xaandipu7x. The Lunar Lake tuning carries the same gain table, and both platforms use the same in-tree driver.applyMediaFormat()selectsmedia_format_legacy_narrowwhen reduced range is requested.fps-rangeproperty wired to the HAL's existingsetFpsRange.0005-ipu7-psys-harden-userptr-pinning.patch: the driver rejects empty and oversized ranges, allocates the page array with overflow checks, dropsFOLL_FORCE, publishes attachment state only once every page is pinned, and clearsdb_attachwhen attaching fails./dev/ipu7-psys0moves from mode 0666 to 0600root:root, and/run/camerafrom 0777 to 0770root:video. Upgrading applies both, and warns that a reboot is needed to load the patched driver. Harden IPU7 PSYS userptr pinning #264 granted the node tovideoand the logged-in seat; this PR makes it root-only, because the driver has two use-after-free bugs that anyone who can open the node can reach, and only the root relay opens it.check()confirms the patch landed, runscheckpatch, and builds the psys module againstlinux-omarchy-headers.tests/ipu7-install.shandtests/ipu7-headers.shcover the scriptlet and that check.intel-cvsmodule is gone.linux-omarchyandlinux-omarchy-borebuilddrivers/media/i2c/cvsin-tree, signed, with the same wake-IRQ fix as the old0007and the Nova Lake ID our copy lacked, and our DKMS module displaced that driver on every 7.2+ kernel. On upgrade, DKMS restores the kernel's module. A stock Arch kernel kept as a fallback boot entry has no CVS driver, so no camera.ipu7xplugin besideipu75xa. Without it a Lunar Lake machine asks for a plugin that was never built.make installlays down/etc/camera/ipu7x/with its tuning.0012is theipu7xtwin of0006: theIntel CVSpads behind the 7.2 bridge need a format.camera-videosrc-initruns before every relay start. On a board with theINTC10DEbridge it writes the configuredVIDEOSRC, minus! videoflip method=rotate-180, to/run/v4l2-relayd-ipu7-videosrc.env; the relay reads that file after its own config. Every other board gets no file and keeps the configured pipeline unchanged. Lunar Lake therefore gets the relay settings below too, and an edit to/etc/v4l2-relayd.d/ipu7.confreaches both platforms on the next relay start. The previous override is removed in its own step before the script runs, so the script never reads it back as the configured value.fps-range=15~30 gain-range=0~27 color-range=reduced.sharpness=80 ev=-1 saturation=10.sharpnessnever reaches the PAL.ev=-1only offset viewers stretching the old full-range frames: without it, mean brightness in medium indoor light matches 1.0.6-2.saturation=10makes no measurable difference to chroma.Testing
On a Dell XPS 16 DA16260 (Panther Lake), linux-omarchy 7.2.5-4, package installed with
pacman -Uand the machine rebooted./dev/video50after install: 0.5 frame-to-frame on flat areas./dev/video50went from 0-255 to 16-236./dev/video50all delivered frames.pacman -Qkkreports no altered files.intel_cvsloads, the CVS bridge andov08x40join the media graph, anddkms statuslists onlyipu7-driversandv4l2loopback./dev/ipu7-psys0iscrw------- root rootwith no ACL.camera-videosrc-initkeyed to this board's bridge ID was bind-mounted over the packaged one, with a staleVIDEOSRC="videotestsrc pattern=ball"planted in/run. The relay then ran the configured pipeline without the rotation, and stopping it removed the file.Follow-ups
intel_cvsand this PR's tuning, gain, range and relay changes as well. Still missing on that board and not addressed here, as intel-ipu7-camera: Panther Lake-only build breaks Lunar Lake — no camera at all, and the image is upside down #366 describes:-110on the chip-id read).06cb:0701quirk inintel_cvs).ipu-bridgesupport from 7.3.psys_suspendreturns-EBUSYon s2idle after the camera was used. That last one affects every platform.awb-mode=video_conferencingis worth trying before any saturation change, which overshoots on the chart.DFLTtuning; small movements showed no trails./dev/video50within a few seconds ofv4l2-relayd@ipu7(re)starting can hang, becauseExecStartPostrestarts WirePlumber.Pac parameter adaptation has failed 2). The HAL then skips that frame in the first ISP stage but still passes the stage's buffer on. The second stage processes an older intermediate image, and the application receives that frame: from six frames earlier, in the run inspected. In a still scene this is invisible; with motion it would be a one-frame jump back.group 3, code 1(graph state). Streams without a failure log none.UNMAPBUFraces a dma-buf release) need a private report to Intel.Related
intel-ipu7-camerato pkgrel 3 and makes/dev/ipu7-psys0root-only. This PR does the same with an explicitGROUPandMODE, so the upgrade's change event applies it to running machines, and it replaces the90-ipu7-psys.rulesfile intel-ipu7-camera: stop granting every uid access to the PSYS node #606 edits. intel-ipu7-camera: stop granting every uid access to the PSYS node #606 can close when this lands.