43typedef enum : uint8_t {
58typedef enum : uint32_t {
69typedef enum : uint8_t {
77typedef enum : uint16_t {
146 while (offset < length) {
147 const ssize_t written =
write(fd, &bytes[offset], length - offset);
148 if ((written < 0) && (errno == EINTR)) {
154 offset += (size_t)written;
184 }
while (value != 0U);
185 while (digits > 0U) {
187 out[offset] = reverse[digits];
215 out[offset++] =
'\n';
219 out[offset++] =
'\n';
223 out[offset++] =
'\n';
229 if ((px ==
nullptr) || (path ==
nullptr)) {
232 if ((w == 0U) || (h == 0U)) {
235 if ((
size_t)w > (SIZE_MAX / (
size_t)h)) {
245 const size_t pixels = (size_t)w * (
size_t)h;
247 size_t consumed = 0U;
248 while (ok && (consumed < pixels)) {
249 size_t batch = pixels - consumed;
253 for (
size_t i = 0U; i < batch; ++i) {
259 const int closed = close(fd);
265 if ((r ==
nullptr) || (path ==
nullptr)) {
#define O_CLOEXEC
Zero fallback when the host lacks close-on-exec open flags.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_viewer_rgb565_mask_t
Channel masks used to unpack an RGB565 word.
@ k_rgb565_b5_mask
5-bit blue field mask.
@ k_rgb565_r5_mask
5-bit red field mask.
@ k_rgb565_g6_mask
6-bit green field mask.
ra8_err_t ra8_viewer_write_ppm565(const uint16_t *px, uint32_t w, uint32_t h, const char *path)
Write arbitrary caller-owned RGB565 pixels as binary PPM.
ra8_viewer_ppm_io_t
Bounded buffers used by the descriptor-backed PPM publisher.
@ k_ppm_header_bytes
Complete P6 header capacity.
@ k_ppm_chunk_bytes
Conversion buffer capacity in bytes.
@ k_ppm_file_mode
Host output mode before process mask.
@ k_ppm_decimal_radix
Decimal numeric base.
@ k_ppm_chunk_pixels
Pixels converted before each write.
@ k_ppm_u32_digits
Decimal digits in UINT32_MAX.
uint16_t ra8_viewer_pack565(uint8_t rr, uint8_t gg, uint8_t bb)
Pack 8-bit RGB channels into one RGB565 word.
static RA8_INTERNAL bool internal_write_all(int fd, const uint8_t *bytes, size_t length)
Write exactly length bytes to one owned host descriptor.
ra8_err_t ra8_viewer_dump_ppm(const ra8_viewer_reader_t *r, const char *path)
Write the current fixed framebuffer as binary PPM.
ra8_viewer_rgb565_shift_t
Field positions and channel-width conversions for RGB565 packing.
@ k_rgb565_g_shift
Green field position in the 16-bit word.
@ k_rgb565_g6_fill
6->8 low-bit replication shift (green).
@ k_rgb565_r_shift
Red field position in the 16-bit word.
@ k_rgb565_r5_drop
8->5-bit reduction for red/blue.
@ k_rgb565_hi_shift
High-byte position of a little-endian pixel.
@ k_rgb565_g6_drop
8->6-bit reduction for green.
@ k_rgb565_r5_fill
5->8 low-bit replication shift (red/blue).
static RA8_INTERNAL size_t internal_ppm_header(char out[k_ppm_header_bytes], uint32_t width, uint32_t height)
Build the locale-independent binary-PPM header for width x height.
uint16_t ra8_viewer_pack565_le_pair(uint8_t lo, uint8_t hi)
Reassemble one little-endian RGB565 word.
static RA8_INTERNAL size_t internal_append_u32(char out[k_ppm_header_bytes], size_t offset, uint32_t value)
Append one unsigned decimal value to a fixed PPM header.
static RA8_INTERNAL void internal_unpack565(uint16_t px, uint8_t rgb[k_ppm_channels])
Expand one RGB565 word into three 8-bit channels.
ra8_viewer_ppm_t
Layout constants of the binary portable-pixmap (P6) output.
@ k_ppm_idx_r
Red byte index within a P6 pixel.
@ k_ppm_channels
Bytes per P6 pixel (R, G, B).
@ k_ppm_idx_b
Blue byte index within a P6 pixel.
@ k_ppm_idx_g
Green byte index within a P6 pixel.
Caller-owned host JOF/comic reader and RGB565 render surface.
@ k_ra8_viewer_fb_height
Framebuffer height in pixels.
@ k_ra8_viewer_fb_width
Framebuffer width in pixels.
struct ra8_viewer_reader ra8_viewer_reader_t
Opaque state bound inside caller-owned workspace.
Cross-translation-unit state for the bounded JOF/comic viewer.
uint16_t * fb
Fixed headless framebuffer.