get_statistics as mentioned. Then grab the mean() from it.
As for the gain_db. No, the point of making it db was to allow you to pass anything and then the method internally limits things. You can look at the OV5640 camera driver if you want to reverse engineer what the max would be.