Skip to content

Apply the IPU7 camera's ISP tuning, fix its gain, range and exposure, harden PSYS pinning, and support Lunar Lake - #723

Merged
spencerbull merged 15 commits into
omacom:masterfrom
spencerbull:ipu7-camera-image-quality
Oct 3, 2026
Merged

spencerbull merged 15 commits into
omacom:masterfrom
spencerbull:ipu7-camera-image-quality

Conversation

@spencerbull

@spencerbull spencerbull commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

  1. No ISP tuning reached the hardware. The static graph (OV08X40_KAFE799.IPU75XA.bin) tags the 1080p video pipe with ISP tuning mode 4, but the tuning file (OV08X40_KAFE799_PTL.aiqb) only carries DFLT, LMOD 1 and LMOD 2.
    • PipeLine::updateIspTuningMode fails with Failed to update tuning 4, and the HAL carries on with mode 4 anyway.
    • libia_aic's generic AIC then runs gaic_find_all_tunings(60001, 4) every frame and gets nothing back.
    • So noise reduction, TNR, sharpening and every other generically tuned kernel run on library init() defaults.
    • The TNR7 blend kernel was sent to the hardware with enable = 0 and all-zero weights: frame-to-frame noise equalled single-frame noise.
    • Intel's current HAL and graph have the same mismatch.
  2. The sensor ran at twice the analog gain AE assumed.
    • The tuning makes AIQ emit the raw 0x3508 register code (1x = 256).
    • The in-tree ov08x40 driver takes V4L2_CID_ANALOGUE_GAIN as half of that (1x = 128, max 1984) and clamps anything higher.
    • A 7.75x request read back as analogue_gain = 1984, i.e. 15.5x on the sensor.
  3. Wrong YUV range. The HAL ignored color-range=reduced and always produced full-range (0-255) frames, which consumers decode as limited range: crushed shadows and clipped highlights.
  4. Exposure capped at 1/30 s. icamerasrc turns the caps frame rate into an AE frame-time range of exactly [30, 30] fps. In a dim room AE ran 33 ms at 15.5x analog plus ~3x digital gain.

Change (intel-ipu7-camera 1.0.6-3)

  • 0011, HAL: when loading the graph's ISP tuning mode fails, as it does when the tuning file lacks that mode, reload the default (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.
  • 0010, HAL: new analogGainCodeShift sensor option that scales AIQ analog gain codes to the driver's units, set to 1 in the ov08x40-uf.json of both ipu75xa and ipu7x. The Lunar Lake tuning carries the same gain table, and both platforms use the same in-tree driver.
  • 0008, HAL: applyMediaFormat() selects media_format_legacy_narrow when reduced range is requested.
  • 0009, icamerasrc: new fps-range property wired to the HAL's existing setFpsRange.
  • PSYS userptr hardening, from Harden IPU7 PSYS userptr pinning #264 by @AFOliveira (four commits, authorship kept):
    • 0005-ipu7-psys-harden-userptr-pinning.patch: the driver rejects empty and oversized ranges, allocates the page array with overflow checks, drops FOLL_FORCE, publishes attachment state only once every page is pinned, and clears db_attach when attaching fails.
    • /dev/ipu7-psys0 moves from mode 0666 to 0600 root:root, and /run/camera from 0777 to 0770 root: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 to video and 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, runs checkpatch, and builds the psys module against linux-omarchy-headers. tests/ipu7-install.sh and tests/ipu7-headers.sh cover the scriptlet and that check.
  • Intel CVS driver: the DKMS intel-cvs module is gone. linux-omarchy and linux-omarchy-bore build drivers/media/i2c/cvs in-tree, signed, with the same wake-IRQ fix as the old 0007 and 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.
  • Lunar Lake, from intel-ipu7-camera: build the Lunar Lake HAL plugin and stop rotating its frames #367 by @pkolbas (one commit, authorship kept):
    • The HAL builds the ipu7x plugin beside ipu75xa. Without it a Lunar Lake machine asks for a plugin that was never built. make install lays down /etc/camera/ipu7x/ with its tuning.
    • 0012 is the ipu7x twin of 0006: the Intel CVS pads behind the 7.2 bridge need a format.
    • The Lunar Lake sensor is mounted upright, so the packaged 180° rotation turned its picture upside down. camera-videosrc-init runs before every relay start. On a board with the INTC10DE bridge it writes the configured VIDEOSRC, 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.conf reaches 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.
  • Relay config: fps-range=15~30 gain-range=0~27 color-range=reduced.
    • In dim light AE may lengthen frames down to 15 fps, and it never raises gain past 27 dB.
    • It returns to 30 fps when there is enough light.
    • I dropped sharpness=80 ev=-1 saturation=10. sharpness never reaches the PAL. ev=-1 only offset viewers stretching the old full-range frames: without it, mean brightness in medium indoor light matches 1.0.6-2. saturation=10 makes no measurable difference to chroma.

Testing

On a Dell XPS 16 DA16260 (Panther Lake), linux-omarchy 7.2.5-4, package installed with pacman -U and the machine rebooted.

  • ISP tuning: with 0011 the PAL receives 37 tuning records per frame instead of 20, including TNR7 blend/bc/ims. Back to back at the same exposure (66.7 ms, ISO 402), on a flat patch:
    • frame-to-frame noise 9.2 to 1.9
    • single-frame high-pass noise 12.5 to 6.2
    • Through /dev/video50 after install: 0.5 frame-to-frame on flat areas.
  • Gain: manual 4x / 8x / 15.5x sweep.
    • Before: brightness 77.5 / 130.6 / 136.4. 8x and 15.5x were the same clamped gain.
    • After: 37.8 / 69.3 / 134.6, linear.
    • The live control reads back half the old code.
  • Range: luma through /dev/video50 went from 0-255 to 16-236.
  • Exposure: in a dim room AE now runs 66 ms at ISO 402 instead of 33 ms at ISO 783-1116. After 0011 this still keeps visibly more detail than 30 fps at max gain.
  • Resource use: the relay uses ~20% of a core.
  • Stability:
    • Five open/close cycles of /dev/video50 all delivered frames.
    • The camera came up normally after a reboot into the new package.
    • pacman -Qkk reports no altered files.
  • CVS driver and PSYS node: after the upgrade and a reboot, the kernel's own intel_cvs loads, the CVS bridge and ov08x40 join the media graph, and dkms status lists only ipu7-drivers and v4l2loopback. /dev/ipu7-psys0 is crw------- root root with no ACL.
  • Board detection: this board gets no override, and the relay runs the packaged, rotated pipeline with an upright picture. To exercise the Lunar Lake branch, a copy of camera-videosrc-init keyed to this board's bridge ID was bind-mounted over the packaged one, with a stale VIDEOSRC="videotestsrc pattern=ball" planted in /run. The relay then ran the configured pipeline without the rotation, and stopping it removed the file.

Follow-ups

  • Lunar Lake on hardware: nobody here has a Lunar Lake laptop, so that platform is untested with this PR. @pkolbas verified intel-ipu7-camera: build the Lunar Lake HAL plugin and stop rotating its frames #367's original on a Dell Pro 14 Premium (PA14250) against 1.0.6-2 with the DKMS CVS module. Lunar Lake now gets the kernel's own intel_cvs and 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:
    • The sensor probe can race the bridge (-110 on the chip-id read).
    • The privacy LED never lights (the 06cb:0701 quirk in intel_cvs).
    • The HM1092 IR sensor needs ipu-bridge support from 7.3.
    • psys_suspend returns -EBUSY on s2idle after the camera was used. That last one affects every platform.
  • XPS 14 DA14260: tested at 4K by @HritwikSinghal: the grain is gone in low light, but the picture looks flatter than 1.0.6-2 in medium to bright light. At 4K the graph asks for ISP tuning mode 0, which the tuning carries, so 0011 changes nothing there.
  • Look under coloured light: on a ColorChecker at matched exposure, this build's tone curve and saturation match a MacBook Pro 14 webcam, so the flatter look against 1.0.6-2 is viewers no longer stretching full-range frames, not weak colour. Under coloured room light (pink or teal LEDs), auto white balance leaves whites and skin tinted. awb-mode=video_conferencing is worth trying before any saturation change, which overshoots on the chart.
  • Ghosting: fast motion needs a check (wave a hand on a call). TNR now runs with Intel's own DFLT tuning; small movements showed no trails.
  • Bright light: a daylight check would help. The gain fix matters most there, where the sensor used to run at double gain with half the exposure.
  • Relay startup race: pre-existing and not changed here. A client that opens /dev/video50 within a few seconds of v4l2-relayd@ipu7 (re)starting can hang, because ExecStartPost restarts WirePlumber.
  • Stale frames at 4K: sometimes Intel's closed-source parameter adaptation fails for a frame (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.
    • 1.0.6-2 does this too, mostly while AE ramps gain in the first second of a stream.
    • At 3840x2160 this PR makes it more common. Over 10 interleaved runs of 90 frames each in the same light, the number of streams with a failure went from 3 to 10, at about two failures per stream. The reduced range (0008) and the gain fix (0010) each raise the rate.
    • Most streams with a failure also log one PSYS firmware error, group 3, code 1 (graph state). Streams without a failure log none.
    • Every stream completed, and later streams and relay restarts were unaffected.
    • At 1080p, the packaged relay resolution, 9 runs had no failures. It was seen at 1080p earlier, under dim coloured LED light.
    • Running such a frame with the latest good parameters, instead of passing a stale buffer on, is the HAL change to try. The cached parameters are shared buffers, so the change needs care.
  • Upstream: 0008, 0010 and 0011 are general HAL bugs worth reporting to intel/ipu7-camera-hal. The PSYS driver's two use-after-free bugs (a buffer that is obtained but never mapped is freed twice; UNMAPBUF races a dma-buf release) need a private report to Intel.

Related

spencerbull and others added 2 commits September 29, 2026 08:44
…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>
@spencerbull

Copy link
Copy Markdown
Contributor Author

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 ov08x40 driver at v7.2.5. The premises hold wherever they can be checked away from the laptop:

  • 0011: decoded with the HAL's own graph reader, the pinned graph gives the 1080p video pipe (graph 100002, stream 60001) ISP tuning mode 4 on every node, and Intel's current graph still does. The aiqb's ISP group holds exactly DFLT (index 0), LMOD 1 and LMOD 2, and ia_lard.h accepts the DFLT tag as isp_mode_index. Overwriting operationMode holds for the life of the stream: each configure builds a fresh static graph, and a zoom change only swaps the kernel list, so the PTZ path hands AIC the same mode 0.
  • 0010: the driver writes ctrl->val << 1 to 0x3508 over 128–1984, and SensorHwCtrl::setAnalogGains is the only way analog gain reaches it.
  • 0008: the GStreamer and HAL range enums line up, and neither icamerasrc nor the relay's output pipeline relabels or converts the range.
  • 0009: an explicit fps-range overrides the caps frame rate in ParameterConvert, so AE gets a 33–67 ms frame-time window.

The camera itself was not driven. The image-quality results rest on the author's measurements on an XPS 16 DA16260.

Pushed in 8aedb1a:

  • Setting fps-range to NULL, its own default, crashed icamerasrc in strlen(): a build of the previous 0009 segfaulted on it and the fixed build does not. NULL now leaves the last range in effect, because the HAL has no way to drop one. The older gain-range and exp-time-range properties carry the same bug upstream and are left alone here.
  • The relay comment and this description said AE raises gain past 27 dB once frames reach 15 fps. gain-range is a hard ISO ceiling, so it never does. At the ceiling, 66.7 ms at 22.4x is within about a tenth of the old 33 ms at ~48x, so the darkest usable scene barely moves.
  • The 0008 message said the sensor JSON's yuvColorRangeMode is honoured. Only the mock HAL reads it.

Open, for the author: the relay also drops ev=-1 (a third of a stop darker, with this sensor's 1/3 EV step) and saturation=10, which does reach the PAL as manual_saturation. Only sharpness is explained. The other two are rendering choices that deserve a sentence, or restoring.

Considered and left as is:

  • 0011 selects mode 0 even if reloading DFLT fails. CCA initialises the ISP group to index 0, which is this tuning's DFLT container, and not falling back reproduces the bug being fixed. Whether a failed update leaves that state intact is inside the closed-source library, and the patch says so.
  • The linear-gamma and 2.2-curve tonemap branches in applyMediaFormat override the narrow format. icamerasrc never reaches them.
  • finalize never frees fps_range. It frees none of icamerasrc's string properties, so this is a few bytes per element lifetime, and it belongs in one upstream fix for all of them.

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.zst

Then 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>
@HritwikSinghal

HritwikSinghal commented Sep 29, 2026 •

Copy link
Copy Markdown

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.
But, in medium to high indoor lighting, the newer tunings look overexposed and images looked better with older tunings.

@spencerbull

Copy link
Copy Markdown
Contributor Author

@HritwikSinghal thanks for testing!

I'm doing some more tests to work to clean it up the tune in different lighting scenarios.

@spencerbull

Copy link
Copy Markdown
Contributor Author

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: finalize never freed the string the fps-range setter allocates. LeakSanitizer reported 18 bytes in 3 allocations from the setter across three elements before the change, and none after. Codex found no defect in the commit.

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 /dev/video50. Every fix shows up against 1.0.6-2:

  • 0011: at 1080p, 1.0.6-2 logs Failed to update tuning 4 and this build logs the fallback. In the same light, frame-to-frame noise on flat areas drops from about 3.0 to 0.4 and single-frame noise from 2.5 to 1.6, although this build runs slightly more gain (8.5x against 6.5–7x).
  • 0010: with exposure fixed at 10 ms, asking for 4x, 8x and 15.5x sets the sensor to 3.9x, 7.75x and 15x. 1.0.6-2 sets 7.75x, 15.5x and 15.5x.
  • 0008: luma through /dev/video50 spans 18–235, matching what the device advertises (Quantization: Limited Range). 1.0.6-2 fills 0–255 under the same label, so viewers stretch it: about 2% of pixels clip to white and up to 2% crush to black.
  • 0009: fps-range=15~15 gives 70 ms frames, and with gain capped at 4x, AE stretches frames to 70 ms rather than adding gain.
  • Relay: 150 frames and five open/close cycles through /dev/video50 on the installed package.

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:

  • mean 138 against 140 on a limited-range scale
  • 95th percentile 226 against 237
  • no pixels clipped, where 1.0.6-2 clips about 2%

Turning the gain fix off in the same light changed nothing, and at 1080p restoring ev=-1 made it darker than 1.0.6-2 (135 against 138–141).

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). saturation=10 makes no measurable difference, and around saturation=40 matches 1.0.6-2's chroma at 4K. That may be what reads as overexposed, but medium indoor light is as bright as this test got, so brighter scenes are still unmeasured.

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

@spencerbull

Copy link
Copy Markdown
Contributor Author

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.

ΔE2000 chroma vs truth skin patches C* greys L* (white → black)
truth 0 ×1.00 18 / 22 96 81 66 51 36 22
MacBook Pro 14 11.2 ×1.10 24 / 28 90 87 83 71 52 25
this build 12.8–16.1 ×1.32–1.37 29 / 29 94 89 81 71 51 24
this build + saturation=48 contrast=32 17.6 ×1.48 57 / 44 96 90 82 69 45 17

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: saturation≈40 does match 1.0.6-2's chroma, but that look was the range bug, and raising saturation or contrast overshoots the MacBook on the chart. What does make a room look off is coloured light. Under pink LEDs, auto white balance left whites magenta and skin magenta-grey; under a teal lamp, skin went blue. awb-mode=video_conferencing is untested but is the next thing to try.

@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

@HritwikSinghal

HritwikSinghal commented Sep 30, 2026 •

Copy link
Copy Markdown

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)
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 spencerbull changed the title Apply the Intel IPU7 camera's ISP tuning and fix its gain, range and exposure Apply the IPU7 camera's ISP tuning, fix its gain, range and exposure, and harden PSYS pinning Sep 30, 2026
@kwilczynski

Copy link
Copy Markdown
Member

@spencerbull a heads up!

Linux kernel now carries this portion of the DKMS out-of-tree driver:

https://github.com/spencerbull/omarchy-pkgs/blob/ipu7-camera-image-quality/pkgbuilds/intel-ipu7-camera/dkms-intel-cvs.conf

The in-tree driver (already carries entries for Nova Lake sensor):

filename:       /lib/modules/7.2.8-1-omarchy-bore/kernel/drivers/media/i2c/cvs/intel_cvs.ko.zst
license:        GPL
description:    Intel Vision Sensing Controller driver
author:         Miguel Vadillo <miguel.vadillo@intel.com>
import_ns:      INTEL_IPU_BRIDGE
license:        GPL
description:    CSI/V4L2 support for Intel Vision Sensing Controller
author:         Miguel Vadillo <miguel.vadillo@intel.com>
srcversion:     F6D34413508D5BA23B26E7C
alias:          acpi*:INTC10FA:*
alias:          acpi*:INTC10E1:*
alias:          acpi*:INTC10E0:*
alias:          acpi*:INTC10DE:*
depends:        ipu-bridge,videodev,mc,v4l2-async,v4l2-fwnode
intree:         Y
name:           intel_cvs
retpoline:      Y
vermagic:       7.2.8-1-omarchy-bore SMP preempt mod_unload 
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        51:F0:AF:AF:C0:F1:A4:3E:A6:37:E5:11:89:FF:5B:99:47:A2:DE:CD
sig_hashalgo:   sha512
signature:      30:65:02:30:40:E9:24:19:8F:58:1B:C7:D2:18:14:57:7E:DD:5E:34:
		00:0E:39:C3:05:ED:5A:75:DB:34:97:49:AB:60:E3:0F:1A:FC:57:16:
		AA:4E:7C:BC:91:E9:8C:5F:78:41:96:B9:02:31:00:AF:0A:48:C0:80:
		CE:46:BE:B4:C3:B7:28:0D:99:C8:BE:89:E3:AE:90:C0:B8:38:5B:70:
		90:E7:99:4D:9E:9A:D6:0E:AE:BF:AA:EF:4A:6E:69:BB:5A:5E:48:F5:
		A5:BF:7D

Both of these will now conflict and the camera will no longer work.

spencerbull and others added 2 commits October 2, 2026 12:28
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.
spencerbull added a commit to spencerbull/omarchy-pkgs that referenced this pull request Oct 2, 2026
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.
@spencerbull

Copy link
Copy Markdown
Contributor Author

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. linux-omarchy and -bore build intel_cvs in-tree (CONFIG_VIDEO_INTEL_CVS=m). Their 0542 makes the same change as our old 0007, and 0541 adds the Nova Lake ID our copy lacked. Our DKMS module had the same name and installed under updates/, so on every 7.2+ kernel it displaced the kernel's module with an older copy the kernel does not trust. The package no longer ships it: on upgrade the dkms hook removes it and DKMS restores the kernel's module. A stock Arch kernel left as a fallback boot entry has no CVS driver now, and so no camera.

Also on this head:

  • Harden IPU7 PSYS userptr pinning #264's four commits by @AFOliveira, folded in with authorship kept so the package bumps once.
  • f503eef makes /dev/ipu7-psys0 root-only (GROUP="root", MODE="0600") instead of Harden IPU7 PSYS userptr pinning #264's video plus seat. Intel's PSYS driver has two pre-existing use-after-free bugs: a buffer obtained with GETBUF but never mapped is freed twice when both fds close, and UNMAPBUF races a dma-buf release. Anyone who can open the node can reach them. The packaged camera route opens it only from the root relay, and the ISYS capture nodes were already root-only.

On hardware: the CI package of this head on an XPS 16 DA16260 (linux-omarchy 7.2.5-4), rebooted after install.

  • CVS driver: the kernel's own intel_cvs loads at boot untainted, the CVS bridge and ov08x40 join the media graph, and dkms status lists only ipu7-drivers and v4l2loopback.
  • Driver and permissions: the patched psys module is loaded, and /dev/ipu7-psys0 is crw------- root root with no ACL.
  • Streaming: 150 frames and five open/close cycles through /dev/video50 as the desktop user, plus direct HAL runs at 1080p and 4K with no HAL errors. No camera-related kernel warnings or errors appeared.
  • Image fixes: the 0011 fallback is logged, the sensor gets the gain AE asks for (4x → 3.88x, 8x → 7.75x, 15.5x → 15x), output is limited range, and fps-range or a gain cap stretches frames to 70 ms.
  • Noise: unchanged from the earlier build.

Hot-reloading intel_cvs and ov08x40 under a running IPU core made the sensor fail to probe ("no matching link frequencies"), and reloading the whole IPU stack left the ISYS unable to allocate buffers until a reboot. Nothing in the package does either, and camera-sleep-hook does not unload modules.

Found in review and confirmed against the source, not fixed here:

  • The two PSYS use-after-free bugs above. A private report to Intel is the next step.
  • When Intel's parameter adaptation fails for a frame, the HAL skips that frame's ISP stage rather than reusing the previous parameters. 1.0.6-2 does this at 4K too. With this PR it showed at 1080p in 14 of 32 runs under dim, coloured LED light, and in none of the runs since, in daylight and after the reboot. No visible effect has been measured; it is listed as a follow-up.

— 🤖 Claude, posting on behalf of @spencerbull

Kolbas and others added 5 commits October 2, 2026 13:44
…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>
@spencerbull spencerbull changed the title Apply the IPU7 camera's ISP tuning, fix its gain, range and exposure, and harden PSYS pinning Apply the IPU7 camera's ISP tuning, fix its gain, range and exposure, harden PSYS pinning, and support Lunar Lake Oct 2, 2026
@spencerbull

Copy link
Copy Markdown
Contributor Author

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 0012), and stops rotating the picture on Lunar Lake. The commits on top:

  • camera-videosrc-init writes an override only on boards with the INTC10DE bridge. The override is derived from the configured VIDEOSRC, so Lunar Lake keeps this PR's relay settings.
  • The script runs before every relay start, after a separate step that removes the previous override. Codex found that the script had been reading a leftover override back as the configured pipeline. 9b87400 fixes that; on hardware the bug reproduced before the fix and was gone after it.
  • 0010's gain shift now covers ipu7x too, because the Lunar Lake tuning has the same gain table.
  • intel-ipu7-camera: build the Lunar Lake HAL plugin and stop rotating its frames #367 can close when this lands. @pkolbas is asked there to confirm on their Lunar Lake laptop.

On hardware: the CI package of this head on an XPS 16 DA16260 (Panther Lake).

  • Install: 910 files, none altered. Both HAL plugins are installed, and the gain shift is in both sensor configs.
  • Panther Lake path: this board gets no override. With a stale one planted in /run, the relay ignored it and ran the packaged pipeline.
  • Lunar Lake path: exercised by bind-mounting a copy of the script keyed to this board's bridge ID, with a stale videotestsrc override planted. The relay ran the configured pipeline without the rotation, and stopping it removed the file. 7ca02c0 ran the stale videotestsrc instead.
  • Relay: 150 frames and five open/close cycles as the desktop user, with no kernel messages. A relay configured for 3840x2160 also serves frames.
  • Gain: a 4x request reads back analogue_gain: 496 (1x = 128).
  • 1080p: no HAL errors in 9 runs.

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 (lbff) skips it but passes its buffer on. The second stage (bbps) then processes an older intermediate image, and the application receives that frame. In the kept log, bbps processed sequence 16 right after lbff skipped 22, and again after it skipped 29. In a still scene this is invisible; with motion it would be a one-frame jump back. Most affected streams also log one PSYS firmware error, group 3, code 1 (graph state). Counts from 3840x2160 runs of 90 frames, interleaved in the same light, 10 runs each:

Variant Runs with a failure Failures PSYS errors
This PR as packaged 10 20 10
Default range, gain shift 7 13 6
Reduced range, no gain shift 9 16 7
Neither 3 6 2
1.0.6-2 user space 3 6 3

Codex and I both read this as a documented 4K follow-up, not a reason to hold the PR, for these reasons:

  • The packaged relay runs at 1080p, which is clean.
  • 1.0.6-2 does the same thing.
  • Every stream completed, and later streams were unaffected.
  • Reverting 0008 or 0010 would bring back the range and gain problems they fix.

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 ia_err_general, so why it fails is Intel's to answer. The PR body's Follow-ups section has the details.

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

@spencerbull
spencerbull force-pushed the ipu7-camera-image-quality branch from e150d06 to 4e0b35b Compare October 3, 2026 02:06
@spencerbull

Copy link
Copy Markdown
Contributor Author

All of my commits on this branch now use spencer@omarchy.org instead of spencer.bull@hey.com, and so do the From: lines of 0008–0011. Only the identities changed. Claude Opus 5.5 checked that every rewritten commit has the same tree and dates as before, and Afonso's and Kolbas's authorship is kept. No Codex review ran on this change, since it changes no code. The head reviewed above as 9b87400 is now 46742f9, and 4e0b35b on top of it changes only the four From: lines.

Earlier comments cite the old SHAs:

Was Now Commit
9b87400 46742f9 Remove the Lunar Lake override before the generator runs
7ca02c0 1f65730 Scale the Lunar Lake ov08x40's analog gain codes too
086cba3 f8216b9 Regenerate the Lunar Lake pipeline on every relay start
f46edf7 e00bd04 Derive the Lunar Lake relay pipeline from the packaged one
c8657ea 953262c intel-ipu7-camera: build the Lunar Lake HAL plugin and stop rotating its frames
63e9e03 f7d376c Drop the DKMS Intel CVS driver now that linux-omarchy ships it
f503eef 045e0a2 Restrict the IPU7 PSYS node to root
9cd5454 a4eacc5 Test IPU7 build-only headers and kernel-tree selection
d3dc782 f62d60a Check IPU7 against Omarchy headers without a runtime dependency
ddbea33 f62b4bd Avoid unverified IPU7 permission assurances
dc3f4a1 c11db62 Harden IPU7 PSYS userptr pinning
802ad18 bd8b1c0 Free fps-range when icamerasrc is destroyed
8aedb1a b0e511e Guard fps-range against NULL and correct two descriptions
dfe6ade 6381078 Apply the Intel IPU7 camera's ISP tuning and fix its gain, range and exposure

— 🤖 Claude, posting on behalf of @spencerbull

@spencerbull
spencerbull merged commit 97925fb into omacom:master Oct 3, 2026
6 checks passed
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Publish succeeded → live

Packages: intel-ipu7-camera (x86_64, PR artifact)

  • edge/x86_64: intel-ipu7-camera-1.0.6-3-x86_64

Commit 97925fb · run

cooparo added a commit to cooparo/nixos-hardware that referenced this pull request Nov 24, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants