-It can be done by reading which preset was selected in sd_uhs module + if the patch is on (we need to restart the camera after selecting a preset).
-Also we need to read registers in one case:
If the user selected 160 MHz then restarted the camera, at this time 160 MHz values would be applied the patch would be active, but if the user changed the preset to something like 192 MHz without restarting the camera, the patch would stays on with 160 MHz registers, if we just read selected preset in sd_uhs it won't be correct because it's not applied yet,
we can put variable which set its value once after applying OC depending on selected OC preset in the overclocking function, but probably relying on reading registers is better?
By reading registers we can also detect 48 MHz switch (21 MB/s drop) if the preset wasn't stable using certain SD card.
Or maybe there's a Canon API?
There is Canon API but only with the included clock speed settings, e.g. on 700D 0x32230 address contains selected SD preset:
16 MHz = 0x1
24 MHz = 0x2
48 MHz = 0x3
96 MHz = 0x4
We don't change this in our overclocking function (it stays 0x4), probably we can define some values for us after applying OC preset like:
160 MHz = 0x10
192 MHz = 0x11
240 MHz = 0x12
We need to make sure if 0x32230 won't change back to 0x4, and if using not defined values won't trigger some Canon code.
So, it's actually possible to implement OC frequency detection, there are many ways,
best one IMO is
reading from registers.
@names_are_hard
Here is official
sd_uhs.c code from a1ex, it contains brute-forcing code and other stuff, you need to apply OC manually, we don't use this version in our builds.
The one which we use can be found
here, basically a simplified version which support and works across all DIGIC 5 models (I still need to make some little changes to make it up to date, will do it soon).