I am trying to explain this.

When at 36 bits there is roughly 12 bits per color of gamma however the lower 4 bits are lost. So you only shift out the upper 8 bits of gamma leaving you with 256 linear steps. When you are at 12 bits there is roughly 4 bits per color of gamma (the upper 4 of 12 bits), however the lower 2 bits are lost. So you only shift out the upper 2 bits of gamma leaving you with 4 linear steps.

Therefore it would be: (This would explain why you use PWM bits in multiples of 3)

(bits / 3) - roundup(bits / 9)

36 bits - means 8 real bits

12 bits - means 2 real bits

9 bits - means 1 real bit

Assuming you care about the most significant bits and use BCM this means your gamma error is:

36 bits - 15/4095 (Refresh 280Hz)

12 bits - 1023/4095 (Refresh 900Hz)

9 bits - 2047/4095 (Refresh 1446Hz ???)

Now when I do the math for the serial clock I find that you must be ignoring the lower 4 and 10 bits respectively. I am guessing there is some kind of S-PWM like trick used here.

The max theoretical for 15.73MHz serial would around 3.8kHz using around 11 bits per color for 1 frame per second. (Aka 99.95 gamma accuracy.) Using 30 frames per second would drop this down to 7 bits per color. (Aka 99.2 gamma accuracy.)

Dropping the refresh rate on non-PWM drivers would improve gamma accuracy. For example 1.9kHz using 8 bits per color using 30 frames per second would be possible. (Aka 99.8 gamma accuracy.) For 1 frame per second you could get 12 bits per color. (Aka 99.98 gamma accuracy…worth it? This is why the PWM based LED drivers only really get used on high density panels for bigger displays seen up close.)

Looking at your numbers you support 75 percent gamma accuracy for 12 bits at 1 frame per second. For 30 frames per second you would get less than one bit per color or no gamma accuracy? It does not even work?

However for 36 bits you have 99.6 percent gamma accuracy at 1 frame per second. For 30 frames per second you would get around 3 bits per color or around 87.5 percent gamma accuracy?

Note the accuracy numbers are very high due to rebasing the ranges. The min bits contribute little and since they may not be sent the contribute nothing to range. Therefore they cannot be included. Gamma expresses nonlinear mapping onto linear mapping. BCM is linear mapping trick for expressing PWM steps which is also linear division.

Note this is different from what the Pi library does. It does something different for different reasons. Time works different in that code base. So rebasing the ranges works a little different, and this decreases brightness/gamma accuracy. It does not support S-PWM so refresh rates are tightly coupled to gamma accuracy.

Note color depth and gamma accuracy are not the same. Using less gamma bits lowers color depth. It is not linear and depends on gamma correction mapping. Note there is a limit the LEDs color depth expression, if I am not mistaken.

Am I in the ballpark at least? LOL