According to the HifiBerry documentation, the input gain can be adjusted from -12dB to +32dB in 0.5dB steps. I was able to test that in Alsamixer.
However, Alsa can increase the gain up to +40dB which I don't understand how. Hifi uses PCM1863, which has a programmable gain of -12dB to +32dB. I don't know how Hifi can increase the gain more than that.
My main question is though, how I can program the gain in Python (or C++).