Files
chandra/docs/handset.md
T
nandi 52b42890d6
CI / test (push) Canceled after 0s
Camera: C ISP pipeline, contrast autofocus, and VFR video
- 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
2026-11-28 19:25:43 -08:00

60 lines
7.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Handset & Touch Support
Chandra includes KMS/libinput/compositor adaptations tailored for mainline Linux smartphones (verified on OnePlus 6T `oneplus,fajita` at `1080x2340`).
## Display Scaling (`CHANDRA_SCALE`)
- Integer scaling lives in [`compositor/kms/kms_stub.c`](../compositor/kms/kms_stub.c).
- Setting `CHANDRA_SCALE=N` (or the default automatic `2x` scaling on dense portrait phone panels such as `1080x2340`) runs the compositor at a legible `540x1170` logical resolution while presenting `Nx` nearest pixels to hardware dumb buffers and cursor planes.
## Icon Desktop & Compact Panel
- **Icon desktop default:** Portrait handset layouts prioritize the touch-friendly icon desktop launcher aesthetic.
- **Compact panel layout:** Panel items (`launcher`, `dock`, `session-settings`, `network`, `battery`, `clock-digital`, `screenshot`) size compactly so all controls fit cleanly within `540px` portrait width without clipping, with fuel-gauge support (e.g. `bq27411-0`).
## Touch Input & On-Screen Keyboard
- **Long-press right-click:** In [`compositor/kms/kms_stub.c`](../compositor/kms/kms_stub.c), a stationary touch held for `500 ms` converts to a synthetic right-click (`BTN_RIGHT`) via a `timerfd`, allowing context menus and secondary actions without a mouse.
- **Built-in OSK:** [`compositor/host/osk.mbt`](../compositor/host/osk.mbt) provides a 5-row virtual keyboard that opens automatically when Wayland text input (`zwp_text_input_v3`) gains focus and can also be toggled manually from the bottom-right **`KB`** pill.
## Display Rotation, Flip, and Auto-Rotate
- **4-way transform (`0°`, `90° CW`, `180°`, `270° CW`):** Handled end-to-end across [`compositor/kms/kms_stub.c`](../compositor/kms/kms_stub.c), [`wit/host/display.wit`](../wit/host/display.wit), [`wasmhost/bin/display.mbt`](../wasmhost/bin/display.mbt), and the compositor event loop (`CHANDRA_ROTATE` sets the initial orientation). Both scanout rows and libinput touch/pointer coordinates transform to match the active orientation.
- **Touch `Rot` pill:** Sitting left of the `KB` pill in [`compositor/host/osk.mbt`](../compositor/host/osk.mbt):
- **Tap:** rotate `90°` clockwise (`0 -> 90 -> 180 -> 270 -> 0`).
- **Long-press / right-click:** flip `180°` (`0 <-> 180`, `90 <-> 270`).
- **CLI control:** `chandra-ctl rotate [cw|ccw|flip|0|90|180|270|status]` queries or changes rotation live (`0` portrait, `90` / `270` landscape, `180` inverted).
- **Sensor auto-rotate:** When running on the DRM backend (`chandra-session`) with `monitor-sensor` (`iio-sensor-proxy`) installed, [`session/chandra-auto-rotate`](../session/chandra-auto-rotate) runs inside the active `seat0` session and applies orientation change events (`normal -> 0`, `right-up -> 90`, `bottom-up -> 180`, `left-up -> 270`) without fighting manual `Rot` taps while stationary. Set `CHANDRA_AUTO_ROTATE=0` in the session environment to disable auto-rotate.
## Client-Side Window Controls (Chromium / GTK)
- [`compositor/wayland/server.mbt`](../compositor/wayland/server.mbt) emits `xdg_toplevel.wm_capabilities` (`window_menu`, `maximize`, `fullscreen`, `minimize`) for `xdg_wm_base` v5+ clients so client-decorated apps expose Maximize alongside Close.
- On GTK/Chromium setups where GNOME defaults (`org.gnome.desktop.wm.preferences button-layout`) omit maximize/minimize (e.g. `'appmenu:close'`), configure GTK and `gsettings`:
- `~/.config/gtk-3.0/settings.ini` and `~/.config/gtk-4.0/settings.ini`: `gtk-decoration-layout=:minimize,maximize,close`
- `gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'`
## Keyring Unlock
- [`session/chandra-session`](../session/chandra-session) starts `gnome-keyring-daemon --start --components=secrets` and unlocks an unencrypted default `login.keyring` at login over D-Bus (`org.freedesktop.Secret.Service.Unlock`) so apps such as Chromium store credentials without blocking prompts.
## Power Button & Brightness
- **Power key blank/wake:** Pressing `KEY_POWER` (`116`) in [`compositor/host/compositor.mbt`](../compositor/host/compositor.mbt) toggles manual screen blanking (`DPMS` off/on + touch cancellation in [`compositor/kms/kms_stub.c`](../compositor/kms/kms_stub.c)) while ignoring stray touches during blanking. Also controllable via `chandra-ctl screen [on|off|toggle|status]`. (Set `HandlePowerKey=ignore` in `/etc/systemd/logind.conf.d/` so `logind` does not power off immediately.)
- **Settings Brightness slider:** [`compositor/shell/backlight.mbt`](../compositor/shell/backlight.mbt) reads `/sys/class/backlight/` (`ae94000.dsi.0`, `CHANDRA_BACKLIGHT` override) and writes changes via sysfs or `org.freedesktop.login1.Session.SetBrightness`. When a backlight device exists, **Settings > Power > Brightness** shows a `-` / slider / `+` control (`5%..100%`), also accessible via `chandra-ctl brightness [PCT|status]`.
## Face Unlock (`libcamera`)
- On phones whose MIPI sensors (`imx371`, `imx519`, `imx376`) require `libcamera` SoftISP rather than raw V4L2 nodes, [`face/chandra-face`](../face/chandra-face) supports `libcamera:<camera-id>` entries via `python-libcamera` and applies `libcamera.properties.Rotation`. [`face/install.py`](../face/install.py) supports `--system-python` to run with system `python-opencv` + `python-numpy` on `aarch64`, and [`face/polkit-agent-helper.conf`](../face/polkit-agent-helper.conf) grants `char-video4linux`, `char-media`, and `char-dma_heap` access to polkit's helper sandbox.
## Camera App (`chandra-camera`)
- [`camera/chandra-camera`](../camera/chandra-camera), [`camera/chandra-camera-ui.c`](../camera/chandra-camera-ui.c), and [`camera/chandra-camera-isp.c`](../camera/chandra-camera-isp.c) provide a native GTK3/Cairo Wayland camera app with a C/OpenMP Quad-Bayer ISP library (`libchandra-camera-isp.so`) installed via [`session/install.py`](../session/install.py) with its desktop launcher and icon (`Camera`).
- Supports multi-sensor `libcamera` discovery and live switching (`Back · imx519`, `Front · imx371`, `Back 2 · imx376` on OnePlus 6T, with automatic V4L2 fallback on desktops), sensor orientation transform + front-camera mirror preview, `libcamera` SoftISP CCM tuning (`camera/ipa/simple/*.yaml`), VCM contrast autofocus with tap-to-focus (`lc898217xc`), Photo mode (`HD` instant / `Full` high-resolution `StillCapture` or 3-frame raw burst merge on Quad-Bayer, `0`/`3s`/`10s` self-timer, 3×3 rule-of-thirds grid) saving JPEGs to `~/Pictures/Camera`, Video mode recording exact-PTS VFR H.264 MP4s (`MatroskaI420Muxer` + `ffmpeg`) to `~/Videos/Camera`, an in-app photo gallery viewer, rear flash/torch LED control (`/sys/class/leds/white:flash`) through `org.freedesktop.login1.Session.SetBrightness`, and hardware volume-button or `Space`/`Return` shutter control.
## Remote Control Over Tailscale (`chandra-remote`)
- [`remote/chandra-remote.c`](../remote/chandra-remote.c) provides a zero-overhead shared-memory framebuffer mirror (`fb.shm` in [`wasmhost/bin/raster_stub.c`](../wasmhost/bin/raster_stub.c)) feeding both:
- **VNC (RFB 3.8, port `5900`)** with Tight-JPEG (`libturbojpeg`), Zlib, Raw, dynamic rotation resize (`ExtendedDesktopSize`), clipboard sync, and 1:1 pointer/touch/keyboard input (tested for Android **AVNC**).
- **Mobile Web UI / PWA (HTTP + WebSocket, port `6080`)** with 1:1 touch gestures (tap, drag, long-press right-click, two-finger scroll/right-click), optional trackpad mode, Android keyboard bridge, live rotation/brightness/OLED-off toggles, and adaptive JPEG streaming.
- By default (`~/.config/chandra/remote.conf`), `bind=tailscale`, `bind_loopback=1`, and `auth=none`, binding strictly to the Tailscale `100.64.0.0/10` interface + `127.0.0.1` so any device on the same Tailscale tailnet can connect directly with zero password prompt (`http://<tailscale-dns>:6080/` or `<tailscale-dns>:5900`), even while the handset's physical OLED screen is turned off (`chandra-ctl screen off`). Run `chandra-remote status` to inspect endpoints or `chandra-remote passwd [PASS|--none]` to configure optional password auth.