VESA CVT Standard - How to calculate video timings?
The X.org distribution includes the tool cvt, which is based on that spreadsheet.
It is implemented in hw/xfree86/utils/cvt/cvt.c and hw/xfree86/modes/xf86cvt.c.