Skip to content

v4l2: use bounded ISP frame rates and report accepted settings - #343

Open
vrilutza wants to merge 1 commit into
patjak:masterfrom
vrilutza:frame-rate-units
Open

vrilutza wants to merge 1 commit into
patjak:masterfrom
vrilutza:frame-rate-units

Conversation

@vrilutza

@vrilutza vrilutza commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

The cached frametime is an interval in milliseconds, while the ISP frame-rate commands take a rate in units of 1/256 fps. Multiplying the interval by 256 reverses the request: 40 ms becomes 40 fps instead of 25 fps. A constant G_PARM answer also fails to describe a changed setting.

Store the accepted rate directly in ISP units and use it in the firmware commands and G_PARM. Convert V4L2 fractions with 64-bit arithmetic, clamp to 2–30 fps, and use exactly 30 fps for the default and zero-interval requests. This replaces the previous millisecond representation, which rounded a nominal 30 fps request to a reported 30.303 fps and could overflow while converting large fractions.

Serialize S_PARM against queue streaming. Return EBUSY without changing the cached setting during capture, because these commands currently take effect at channel start. Reporting an accepted setting must not imply a live hardware change that was never applied.

Extracted-function regressions cover high-rate clamping, zero requests, large fractions, and an unchanged cache after a rejected live update. In the previously tested combined series, requested 5, 15 and 30 fps were delivered at approximately 5.01, 15.04 and 30.09 fps; a request for 50 fps was reported as 30 and delivered at approximately 30.08. A live update was rejected with EBUSY.

This corrects S_PARM, G_PARM and the firmware rate commands. ENUM_FRAMEINTERVALS still advertises the existing 30 fps entry; expanding rate discovery is not implemented here. #344 depends on this complete correction, including the default and reporting behavior.

Validation scope: this individual rebased branch builds against Linux 7.1.13+deb14-amd64 with W=1; the two existing compiler warnings remain. The complete nine-topic series previously passed 57/57 streaming-inclusive v4l2-compliance checks on MacBookPro14,1. Its final source tree is unchanged by the commit-message rewrite. The combined hardware tests are not nine separate hardware certifications, and no new module reload or hardware test was performed for this publication.

Revision: 2e15787ca98e49bf85d57ca68eceb7429044ed93.

@vrilutza vrilutza changed the title Send the frame rate in the units the ISP expects isp: send the frame rate in the units the ISP expects Sep 14, 2026
The cached frametime is an interval in milliseconds, but the ISP expects
a rate in units of 1/256 fps. Multiplying the interval by 256 reverses
the request: 40 ms becomes 40 fps rather than 25 fps. G_PARM meanwhile
reports a constant 30 fps even when another rate is requested.

Store the rate in ISP units and use it for both firmware commands and
G_PARM. Convert V4L2 fractions with 64-bit arithmetic, clamp to 2--30
fps, and use exactly 30 fps for the initial value and zero-interval
requests. This avoids millisecond truncation and overflow in large
fractions.

Serialize S_PARM with queue streaming and return EBUSY without changing
the cached rate during capture: the commands take effect at channel
start. G_PARM reports the accepted setting, rather than promising a live
change that the hardware has not received.

Based-on: patjak#343
vrilutza added a commit to vrilutza/facetimehd that referenced this pull request Sep 17, 2026
Setting equal minimum and maximum frame rates limits automatic exposure
to one frame period. In dim light this prevents the firmware from
gathering more light through a longer exposure.

Expose EXPOSURE_AUTO_PRIORITY and the automatic exposure mode supported
by the firmware. When priority is enabled, allow the minimum rate to
drop to 5 fps, or keep the requested rate if it is already lower. Keep
the maximum at the requested rate, and update the cached priority only
after the firmware accepts the command.

Priority defaults to disabled. Enabling it trades frame rate for longer
exposure; it does not force the camera to run at 5 fps in all lighting.
This change requires the complete frame-rate correction from PR patjak#343.

Based-on: patjak#344
@vrilutza vrilutza changed the title isp: send the frame rate in the units the ISP expects v4l2: use bounded ISP frame rates and report accepted settings Sep 17, 2026
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.

1 participant