Camera: C ISP pipeline, contrast autofocus, and VFR video
CI / test (push) Canceled after 0s

- Add chandra-camera-isp.c (C/OpenMP) for Quad-Bayer unpack, CCM, and tone mapping, with a NumPy fallback when it is not built
- Add non-blocking contrast-detection VCM autofocus, with lens subdev discovery on the sensor's I2C bus
- Tune Quad-Bayer AE: a video-mode vblank cap, damped steps, and full analog gain before extending blanking
- Record variable-frame-rate video through a streaming Matroska muxer, and count dropped frames
- Ship libcamera IPA tuning files for imx376, imx519, and uncalibrated sensors
- Map camera buffers by fd and sync them with dma-buf ioctls
This commit is contained in:
nandi committed 2026-11-28 19:25:43 -08:00
1 parent 851c39d827
commit 52b42890d6
34 files changed
+2851 -364

No files matched your search

+40
View File
@@ -69,6 +69,40 @@ fn rasterise(slot : Int, cp : Int, size : Int, embolden : Bool) -> @renderer.Gly
}
}
///|
let loaded : FixedArray[Bool] = FixedArray::make(4, false)
///|
fn pick_slot(bold : Bool, mono : Bool) -> Int {
let has_mono = loaded[0]
let has_sans = loaded[2]
if !has_mono && !has_sans {
return -1
}
let has_bold = has_mono && loaded[1]
if mono && has_mono {
if bold && has_bold {
1
} else {
0
}
} else if has_sans {
2
} else {
0
}
}
///| Whether the face used for (`bold`, `mono`) has a glyph for `cp`.
pub fn has_glyph(cp : Int, bold : Bool, mono : Bool) -> Bool {
let slot = pick_slot(bold, mono)
if slot < 0 {
false
} else {
b_has_glyph(slot, cp)
}
}
///| Install Allo Variable (UI text, falling back to Adwaita Sans) and Adwaita Mono (code) as the renderer's
/// faces. Returns false (keeping the bitmap font) when no face can be found.
/// Slots: 0 mono, 1 mono bold, 2 sans. Sans is a variable font whose bold
@@ -77,9 +111,15 @@ pub fn install() -> Bool {
let has_mono = load_first(0, regular_paths)
let has_sans = load_first(2, sans_paths)
if !has_mono && !has_sans {
loaded[0] = false
loaded[1] = false
loaded[2] = false
return false
}
let has_bold = has_mono && load_first(1, bold_paths)
loaded[0] = has_mono
loaded[1] = has_bold
loaded[2] = has_sans
@renderer.set_glyph_source(fn(cp, size, bold, mono) {
if mono && has_mono {
if bold && has_bold {
+8
View File
@@ -24,6 +24,9 @@ extern "C" fn c_font_bitmap(
buf : Bytes,
) = "mp_font_bitmap"
///|
extern "C" fn c_font_has_glyph(slot : Int, cp : Int) -> Int = "mp_font_has_glyph"
///|
fn utf8(s : String) -> Bytes {
let out : Array[Byte] = []
@@ -68,3 +71,8 @@ fn b_glyph(slot : Int, cp : Int, size : Int) -> RawGlyph {
}
{ w, h, xoff: info[2], yoff: info[3], advance: info[4], coverage: buf }
}
///| Whether `slot` has a glyph for `cp` (not `.notdef`).
fn b_has_glyph(slot : Int, cp : Int) -> Bool {
c_font_has_glyph(slot, cp) != 0
}
+7
View File
@@ -61,3 +61,10 @@ void mp_font_bitmap(int32_t slot, int32_t cp, int32_t size, int32_t w, int32_t h
if (w <= 0 || h <= 0 || Moonbit_array_length(buf) < w * h) return;
stbtt_MakeGlyphBitmap(fi, (unsigned char *)buf, w, h, w, scale, scale, stbtt_FindGlyphIndex(fi, cp));
}
/* 1 when `slot` has a glyph for code point `cp` (not .notdef), 0 otherwise. */
MOONBIT_FFI_EXPORT
int32_t mp_font_has_glyph(int32_t slot, int32_t cp) {
if (slot < 0 || slot >= MAX_SLOTS || !font_data[slot]) return 0;
return stbtt_FindGlyphIndex(&fonts[slot], cp) != 0 ? 1 : 0;
}
+39
View File
@@ -22,3 +22,42 @@ fn b_glyph(slot : Int, cp : Int, size : Int) -> RawGlyph {
coverage: Bytes::from_fixedarray(g.coverage),
}
}
///| Cached `.notdef` glyph (cp 0 at 16 px) per slot for wasm glyph-presence checks.
let wasm_notdef : Map[Int, RawGlyph] = {}
///| Cached `b_has_glyph` results keyed by `slot * 0x110000 + cp`.
let wasm_has_cache : Map[Int, Bool] = {}
///|
fn raw_glyph_eq(a : RawGlyph, b : RawGlyph) -> Bool {
a.w == b.w &&
a.h == b.h &&
a.xoff == b.xoff &&
a.yoff == b.yoff &&
a.advance == b.advance &&
a.coverage == b.coverage
}
///| Whether `slot` has a glyph for `cp` (not `.notdef`).
fn b_has_glyph(slot : Int, cp : Int) -> Bool {
if cp >= 0x1F000 {
return false
}
let key = slot * 0x110000 + cp
match wasm_has_cache.get(key) {
Some(v) => return v
None => ()
}
let notdef = match wasm_notdef.get(slot) {
Some(g) => g
None => {
let g = b_glyph(slot, 0, 16)
wasm_notdef.set(slot, g)
g
}
}
let has = !raw_glyph_eq(b_glyph(slot, cp, 16), notdef)
wasm_has_cache.set(key, has)
has
}