  We develop a self-consistent approach to study the spectral properties of a
class of quantum mechanical operators by using the knowledge about monodromies
of $2\times 2$ linear systems (Riemann-Hilbert correspondence). Our technique
applies to a variety of problems, though in this paper we only analyse in
detail two examples. First we review the case of the (modified) Mathieu
operator, which corresponds to a certain linear system on the sphere and makes
contact with the Painlev\'e $\mathrm{III}_3$ equation. Then we extend the
analysis to the 2-particle elliptic Calogero-Moser operator, which corresponds
to a linear system on the torus. By using the Kiev formula for the
isomonodromic tau functions, we obtain the spectrum of such operators in terms
of self-dual Nekrasov functions ($\epsilon_1+\epsilon_2=0$). Through blowup
relations, we also find Nekrasov-Shatashvili type of quantizations
($\epsilon_2=0$).
  In the case of the torus with one regular singularity we obtain certain
results which are interesting by themselves. Namely, we derive blowup equations
(filling some gaps in the literature) and we relate them to the bilinear form
of the isomonodromic deformation equations. In addition, we extract the
$\epsilon_2\to 0$ limit of the blowup relations from the regularized action
functional and CFT arguments.
