I'm thinking that the current system of storing camera specific settings in 'include/camera.h' for all cameras needs to be revised.
While this probably worked well when there were a handful of cameras, with the number of supported cameras in CHDK today, it's getting a bit cumbersome.
Personally, I find it difficult to find the right section if I need to check and/or modify a setting - as new cameras are added or settings are changed the location in the file where my cameras are stored changes, so I have to keep searching for them again. In addition the camera.h files across CHDK, CHDK-DE and SDM are all different, with the cameras being listed in different orders, and with different settings in some cases. Synchronising changes across the various incarnations of CHDK is a difficult process.
I am proposing that each of the camera specific settings be moved into a separate 'platform_camera.h' file, in the platform/XXX directory for each camera. The 'include/camera.h' file would contain the default values for each setting, along with the documentation on the purpose and usage of each setting.
At the end of the include/camera.h file there would be a line:
#include "platform_camera.h"
which would then load the camera specific settings for the current camera version being compiled.
In order for this to work the compiler needs to know how to find the correct platform_camera.h file. The easiest way to do this is to modify the makefile.inc file by changing the line:
CFLAGS+=-I$(topdir)include $(PLFLAGS) $(CPPFLAGS)
to
CFLAGS+=-I$(topdir)include -I$(topdir)platform/$(PLATFORM) $(PLFLAGS) $(CPPFLAGS)
This will add the platform/XXX (for camera XXX) to the search path that the compiler uses to find the header (.h) files. The compiler will then automatically use the correct file.
Appropriate comments should be added to include/camera.h and each platform_camera.h file on the purpose of the files and how to go about adding new settings (e.g. place the default value with documentation in camera.h, and override values in platform_camera.h, using #undef and #define).
This change could be done gradually by replacing the existing final error message in camera.h with the #include line above. Over time cameras could be moved to individual platform_camera.h files.
However I think a better approach would be to write a program (possibly a perl or php script) to take the existing camera.h and create all the platform_camera.h files automatically, then re-write camera.h with just the defaults and #include line. Once this is done the resulting patch can be applied to the main CHDK code trunk in one change, ensuring all cameras now use the new system and with the correct values - this eliminates any potential human error arising from manually migrating cameras to platform_camera.h files.
This program could also be used on CHDK-DE and SDM as well as CHDK so that all three can be converted to this model. Ultimately comparing and synching camera settings across the CHDK variants will be lot easier and, in my view, adding new cameras will be easier as well.
I'd appreciate any feedback on this idea (both for and against).
If there's enough support I'll start working on the conversion program and CHDK patch.
Regards,
Phil.