I spent a bit more time looking at this.
The only think I think is a must-have before checking in is to ensure MD for pre-digic 6 cameras is not broken. I've attached an updated patch that uses two completely separate implementations of md_detect_motion. Tested OK on G7X and SX160.
The updated patch also cleans up some trailing whitespace that caused extra noise in the histogram diff, removes the unneeded vid_get_bitmap_active_palette from G7X.
I tested the histogram R G B displays using the same test page I used for MD, seems OK.
I would prefer the unrelated OSD rotate fix be checked in separately.
Other thoughts (nothing that needs to be addressed before checking in)
direct access to things like bitmap_buffer[active_buffer_index] in gui_draw.c concern me a bit, because the logic required to get the current buffer could easily change in future cameras. Wrapping in a lib.c function lets ports handle that, at the cost of function call overhead.
An alternate approach would be to have a CHDK variable that is only updated at defined points: e.g. before every gui redraw, and/or every kbd_task iteration. The canon firmware swapping buffers in the middle of a gui_redraw could cause some parts to be drawn on the "wrong" buffer, but I'm not sure how bad it would be in practice. A better solution would be to find a way to hooked into something that gets called when the canon firmware actually swaps buffers. Being able to use the current buffer directly without any index etc could provide a slight performance benefit.
platform dependent #defines in module code are proliferating, specifically the font size stuff. This technically OK if it only depends on THUMB_FW, but it's going to be easy to forget and accidentally make a change that makes the modules no longer platform independent.
register is almost certainly ignored by the compiler, and if it's not, is very likely to do more harm than good (I know existing code uses it too).
Using THUMB_FW to represent both the instruction set and display architecture also seems likely to bite us in the future. I have ideas about this, but it's probably a topic for another post.
- The CHDK boot logo doesn't display correctly, the bitmap part is unscaled and misplaced. Should be fixable.
A simple workaround would be to just disable the logo and have the text only splash screen.
jog dial control in the OSD editor is added, should be documented.