$ show reticulatedpines/magiclantern_simplified
This repository is Magic Lantern Simplified, a firmware enhancement framework for Canon EOS DSLR and mirrorless cameras. It is an application that operates at the hardware level, providing advanced video and photography features (raw video recording, dual ISO, zebras, focus peaking, intervalometer, Lua scripting, etc.) by hooking into the camera's DryOS real-time operating system. The system is modular: core infrastructure (boot process, property system, GUI overlay, DMA abstraction, state machine spies) is in `src/`, while individual features are loadable modules in `modules/`. It also includes a significant reverse-engineering toolkit (platform constants, firmware decryption tools, Ghidra scripts) and host-side utilities (PTP control, MLV viewers, archive tools). While primarily an application, it has a strong research character due to the extensive embedded reverse engineering required to port to each camera model. The architecture is a hybrid of a monolithic base with dynamically loaded modules, communicating via callback registries and property handlers. The codebase shows high craftsmanship in areas like the EDMAC abstraction, state-object synchronization, and the callback system, but suffers from some platform-code duplication and fragile hardcoded addresses.
The LLM identified 4 files worth highlighting for reuse:
Provides an abstraction over Canon's internal state machine for LiveView, movie recording, and other modes. It hooks into state transitions using a generic spy mechanism (`stateobj_start_spy`, `stateobj_lv_spy`) that can be run before or after transitions. This component is self-contained, requires only a few platform-specific hooks defined in `state-object.h`, and can be extracted to synchronize application logic with a third-party state machine in embedded systems.
Implements a clean abstraction over Canon's EDMAC DMA engine, including register base address retrieval, channel management, and transfer size calculations. It handles multiple DMA channel types with separate read/write ports. The code is well-documented with register bitfields and is isolated from camera-specific logic, making it reusable as a DMA driver layer for any hardware with a similar channel-based DMA controller.
Provides a priority-ordered, semaphore-protected callback registration system. Callbacks are stored in an arena-allocated table with fixed slots, supporting add/remove and notification with a priority value. The design is compact, thread-safe (uses DryOS semaphores), and could be extracted as a generic callback or event handler framework for embedded real-time systems.
Contains optimized routines for YUV422 to RGB conversion (with optional scaling) and vice versa. The code handles various packed and planar formats, applies dithering, and uses integer arithmetic for performance. It is self-contained with no dependencies beyond standard types and headers, making it directly reusable as a standalone image format conversion library.