qr_mode function

Determine the required mode