def calc_hmax(reg_dict, mlx75027, speed=800):
    """
    Calculate the HMAX value given the MIPI readout speed.

    Parameters
    ----------
    reg_dict : dict
        The dictionary that contains all the register information
    mlx75027 : bool
        Set to True if using the MLX75027 sensor, False if using the MLX75026 sensor.
    speed : int, optional
        The speed of the MIPI readout in Mbps

    Returns
    ----------
    hmax : int
        The value of the hmax registers, used a lot for the timing calculations

    """
    speed_list = [300, 600, 704, 800, 960]
    ind = speed_list.index(speed)

    if reg_dict["OUTPUT_MODE"][2] == 4:
        # We are outputting A & B
        if reg_dict["DATA_LANE_CONFIG"][2] == 1:
            # 4 Lane speed
            if mlx75027:
                hmax_vec = [0x0E60, 0x0744, 0x0636, 0x057A, 0x0514]
            else:
                hmax_vec = [0x0860, 0x0444, 0x03A8, 0x033A, 0x02B6]
            hmax = hmax_vec[ind]
        else:
            # 2 Lane speed
            if mlx75027:
                hmax_vec = [0x1CC0, 0x0E88, 0x0C6C, 0x0AF4, 0x0A28]
            else:
                hmax_vec = [0x0E80, 0x0754, 0x0644, 0x0586, 0x0514]
            hmax = hmax_vec[ind]
    else:
        # We are in normal mode
        if reg_dict["DATA_LANE_CONFIG"][2] == 1:
            # 4 Lane speed
            if mlx75027:
                hmax_vec = [0x0860, 0x0444, 0x03A8, 0x033A, 0x02B6]
            else:
                hmax_vec = [0x0560, 0x02C4, 0x02B6, 0x02B6, 0x02B6]
            hmax = hmax_vec[ind]
        else:
            # 2 Lane speed
            if mlx75027:
                hmax_vec = [0x0E60, 0x0744, 0x0636, 0x057A, 0x0514]
            else:
                hmax_vec = [0x0878, 0x0450, 0x03B2, 0x0344, 0x02BE]
            hmax = hmax_vec[ind]
    return hmax