#ifndef CHANDRA_FB_SHM_H #define CHANDRA_FB_SHM_H #include #include #define CHANDRA_FB_MAGIC 0x43484642u /* "CHFB" */ #define CHANDRA_FB_VERSION 1u #define CHANDRA_FB_HDR_BYTES 4096u /* Fits up to 3840x2160x4 (~33.2 MiB); sparse tmpfs only backs written pages. */ #define CHANDRA_FB_SLOT_BYTES (34u * 1024u * 1024u) #define CHANDRA_FB_TOTAL_BYTES (CHANDRA_FB_HDR_BYTES + 2u * CHANDRA_FB_SLOT_BYTES) typedef struct { uint32_t magic; uint32_t version; uint32_t slot_bytes; uint32_t active_slot; /* 0 or 1, atomic release/acquire */ uint32_t width; /* logical width of active_slot */ uint32_t height; /* logical height of active_slot */ int32_t dmg_x0; /* bounding box damaged on last publish */ int32_t dmg_y0; int32_t dmg_x1; int32_t dmg_y1; uint64_t seq; /* monotonic frame counter, atomic release/acquire */ uint64_t frame_ms; /* CLOCK_MONOTONIC ms when published */ uint64_t consumer_ping_ms; /* CLOCK_MONOTONIC ms kept fresh by chandra-remote */ } ChandraFbHeader; static inline uint8_t *chandra_fb_slot_ptr(void *base, uint32_t slot, uint32_t slot_bytes) { return (uint8_t *)base + CHANDRA_FB_HDR_BYTES + (size_t)(slot & 1u) * (size_t)slot_bytes; } #endif /* CHANDRA_FB_SHM_H */