Embodiments of the present disclosure are directed to a method and apparatus for calibration of gyro sensors by using magnetic sensor measurements and background computation during normal product operation. In one embodiment, magnetic sensor measurements are used to adjust gyro gain by comparing measured magnetic vector orientation with its expected orientation computed from gyro integration. The background process constantly compares this discrepancy for various values of gyro gain and selects the one that minimizes such error on average. In one embodiment, device orientation obtained by gyro integration is improved by using magnetic sensor measurements.