Esempio n. 1
0
def get_status():
    status = dict()

    status_str, _, _ = run_cmd(tvservice_path + ' -s')
    if 'DMT' in status_str:
        status['group'] = 'DMT'
    elif 'CEA' in status_str:
        status['group'] = 'CEA'
    else:
        logger.error('status parsing error')
        return

    status['mode'] = int(status_str.split('(')[1].split(')')[0].strip())
    status['full_range'] = 'RGB full' in status_str

    status['overscan'] = not (
        get_config_value('disable_overscan') == 1 and
        get_config_value('overscan_top') == 0 and
        get_config_value('overscan_bottom') == 0 and
        get_config_value('overscan_left') == 0 and
        get_config_value('overscan_right') == 0
    )

    res, hz = status_str.split(',')[1].split('@')
    status['resolution'] = res.strip()
    status['hz'] = float(hz.strip()[:-2])

    return status
Esempio n. 2
0
def read_hdmi_mode():
    group_int = get_config_value('hdmi_group')
    if group_int == 1:
        group_name = 'CEA'
    else:
        group_name = 'DMT'

    mode = int(get_config_value('hdmi_mode'))
    return group_name, mode
Esempio n. 3
0
    def current_setting(self):
        # The initial button defaults to zero (above) if the user has
        # selected a different frequency
        freq = get_config_value('arm_freq')

        for mode in self._board_clocking['modes']:
            if self._board_clocking['values'][mode]['arm_freq'] == freq:
                self.initial_button = self._board_clocking['modes'].index(mode)
Esempio n. 4
0
    def current_setting(self):
        # The initial button defaults to zero (above) if the user has
        # selected a different frequency
        freq = get_config_value('arm_freq')

        for mode in self._board_clocking['modes']:
            if self._board_clocking['values'][mode]['arm_freq'] == freq:
                self.initial_button = self._board_clocking['modes'].index(mode)
Esempio n. 5
0
def set_unflashed_sk_resolution():
    """
    Set the resolution globally for a screen that has corrupted EDID data.
    These are specific to the Kano screens.

    Returns:
        bool - Whether or not changes were made and a reboot is required.
    """
    hdmi_group = 2
    hdmi_mode = 28

    changes_required = (get_config_value('hdmi_group') != hdmi_group
                        or get_config_value('hdmi_mode') != hdmi_mode)
    if changes_required:
        set_config_value('hdmi_group', hdmi_group)
        set_config_value('hdmi_mode', hdmi_mode)

    return changes_required
Esempio n. 6
0
def match_overclock_value(is_pi2):
    """ which overlock gui setting matches our current set of values?"""
    curr = {}
    for key in CLOCK_KEYS:
        curr[key] = get_config_value(key)

    for row in CLOCK_MODES[is_pi2]['values']:
        if values_equal(CLOCK_MODES[is_pi2]['values'][row], curr):
            return row
    return None
Esempio n. 7
0
def set_unflashed_sk_resolution():
    """
    Set the resolution globally for a screen that has corrupted EDID data.
    These are specific to the Kano screens.

    Returns:
        bool - Whether or not changes were made and a reboot is required.
    """
    hdmi_group = 2
    hdmi_mode = 28

    changes_required = (
        get_config_value('hdmi_group') != hdmi_group or
        get_config_value('hdmi_mode') != hdmi_mode
    )
    if changes_required:
        set_config_value('hdmi_group', hdmi_group)
        set_config_value('hdmi_mode', hdmi_mode)

    return changes_required
Esempio n. 8
0
def match_overclock_value(board_name):
    """ which overlock gui setting matches our current set of values?"""
    curr = {}
    for key in CLOCK_KEYS:
        curr[key] = get_config_value(key)

    board = get_board_props(board_name)

    if not board:
        logger.error("Could not get overclocking settings for board")
        return

    values = board.CLOCKING['values']

    for row in values:
        if values_equal(values[row], curr):
            return row
    return None
Esempio n. 9
0
def match_overclock_value(board_name):
    """ which overlock gui setting matches our current set of values?"""
    curr = {}
    for key in CLOCK_KEYS:
        curr[key] = get_config_value(key)

    board = get_board_props(board_name)

    if not board:
        logger.error("Could not get overclocking settings for board")
        return

    values = board.CLOCKING['values']

    for row in values:
        if values_equal(values[row], curr):
            return row
    return None
Esempio n. 10
0
def get_matching_board_profile():
    curr = {}
    for key in CLOCK_KEYS:
        curr[key] = get_config_value(key)

    def does_board_match(board):
        values = board.CLOCKING['values']

        for oc_setting in values.itervalues():
            if values_equal(oc_setting, curr):
                return True

        return False

    for board_key in BOARD_PROPERTIES.iterkeys():
        board_props = get_board_props(board_key)

        if does_board_match(board_props):
            logger.debug("Matched the board {} with the current settings"
                         .format(board_key))
            return get_board_property(board_key, 'cpu_profile')

    return False
Esempio n. 11
0
def get_matching_board_profile():
    curr = {}
    for key in CLOCK_KEYS:
        curr[key] = get_config_value(key)

    def does_board_match(board):
        values = board.CLOCKING['values']

        for oc_setting in values.itervalues():
            if values_equal(oc_setting, curr):
                return True

        return False

    for board_key in BOARD_PROPERTIES.iterkeys():
        board_props = get_board_props(board_key)

        if does_board_match(board_props):
            logger.debug(
                "Matched the board {} with the current settings".format(
                    board_key))
            return get_board_property(board_key, 'cpu_profile')

    return False
Esempio n. 12
0
def get_screen_value(key, fallback=True):
    monitor_edid_filter = Filter.get_edid_filter(get_edid_name())
    return get_config_value(key,
                            config_filter=monitor_edid_filter,
                            fallback=fallback)
Esempio n. 13
0
        def test_read(configs):
            # Test all read methods
            # Check the result of the read against the 'written' config set.

            which = random.randint(0, 3)
            present = random.randint(0, 1) == 1
            if which == 0:
                # test get_config_value

                key = choose_key(present, configs['written'].values)

                # test case when key is present and not present

                v = boot_config.get_config_value(key)
                print "testing get_config_value({}) => {}".format(key, v)

                if present:
                    self.assertEqual(v, configs['written'].values[key])
                else:
                    self.assertEqual(v, 0)

            elif which == 1:
                # test get_config_comment

                # test case when key is present and not present
                key = choose_key(present, configs['written'].comment_values)
                if present:
                    correct = random.randint(0, 1)
                    value = configs['written'].comment_values[key]
                    if not correct:
                        value = value + '_wrong'
                else:
                    correct = False
                    value = str(random.randint(0, 10))

                v = boot_config.get_config_comment(key, value)
                print "testing get_config_comment({},{}) => {}".format(
                    key, value, v)

                # get_config comment
                self.assertTrue(v == (present and correct))

            elif which == 2:
                # test has_config_comment

                # test case when key is present and not present
                key = choose_key(present, configs['written'].comment_values)

                v = boot_config.has_config_comment(key)
                print "testing has_config_comment({}) => {}".format(key, v)

                self.assertTrue(v == present)

            elif which == 3:
                # test copy_to

                print "testing safe_mode_config_backup"
                boot_config.safe_mode_backup_config()

                # enable testing of restore
                self.backup_config_exists = True

                configs['backup'] = read_config(
                    boot_config.boot_config_safemode_backup_path)

                self.assertTrue(compare(configs['backup'], configs['written']))

            # after a read, state should be at least locked.
            self.assertTrue(boot_config._trans().state >= 1)

            # after a read, config should be unmodified
            after_read = read_config()

            self.assertTrue(compare(configs['current'], after_read))
            self.assertTrue(is_locked())
Esempio n. 14
0
def backup_overclock_values(backup_config):
    backup_config.ensure_exists()
    for key in CLOCK_KEYS:
        backup_config.set_value(key, get_config_value(key))
Esempio n. 15
0
def is_overscan():
    top = get_config_value('overscan_top')
    bottom = get_config_value('overscan_bottom')
    left = get_config_value('overscan_left')
    right = get_config_value('overscan_right')
    return (top or bottom or left or right)
Esempio n. 16
0
def get_screen_value(key, fallback=True):
    monitor_edid_filter = Filter.get_edid_filter(get_edid_name())
    return get_config_value(
        key, config_filter=monitor_edid_filter, fallback=fallback
    )
        def test_read(configs):
            # Test all read methods
            # Check the result of the read against the 'written' config set.

            which = random.randint(0, 3)
            present = random.randint(0, 1) == 1
            if which == 0:
                # test get_config_value

                key = choose_key(present, configs['written'].values)

                # test case when key is present and not present

                v = boot_config.get_config_value(key)
                print "testing get_config_value({}) => {}".format(key, v)

                if present:
                    self.assertEqual(v, configs['written'].values[key])
                else:
                    self.assertEqual(v, 0)

            elif which == 1:
                # test get_config_comment

                # test case when key is present and not present
                key = choose_key(present, configs['written'].comment_values)
                if present:
                    correct = random.randint(0, 1)
                    value = configs['written'].comment_values[key]
                    if not correct:
                        value = value + '_wrong'
                else:
                    correct = False
                    value = str(random.randint(0, 10))

                v = boot_config.get_config_comment(key, value)
                print "testing get_config_comment({},{}) => {}".format(key, value, v)

                # get_config comment
                self.assertTrue(v == (present and correct))

            elif which == 2:
                # test has_config_comment

                # test case when key is present and not present
                key = choose_key(present, configs['written'].comment_values)

                v = boot_config.has_config_comment(key)
                print "testing has_config_comment({}) => {}".format(key, v)

                self.assertTrue(v == present)

            elif which == 3:
                # test copy_to

                print "testing safe_mode_config_backup"
                boot_config.safe_mode_backup_config()

                # enable testing of restore
                self.backup_config_exists = True

                configs['backup'] = read_config(boot_config.boot_config_safemode_backup_path)

                self.assertTrue(compare(configs['backup'], configs['written']))

            # after a read, state should be at least locked.
            self.assertTrue(boot_config._trans().state >= 1)

            # after a read, config should be unmodified
            after_read = read_config()

            self.assertTrue(compare(configs['current'], after_read))
            self.assertTrue(is_locked())
Esempio n. 18
0
    def __init__(self, win):
        # Show the Display brand and model
        self.model = get_model()
        info_message = ' (Changing this requires a reboot)'

        # And the current display resolution
        try:
            current_resolution = get_status()['resolution']
            info_message += '\n\nCurrent resolution: {}'.format(current_resolution)
        except:
            pass

        Template.__init__(
            self,
            "Display",
            self.model + info_message,
            "APPLY CHANGES"
        )

        self.win = win
        self.win.set_main_widget(self)

        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        self.kano_button.connect("button-release-event", self.apply_changes)
        self.kano_button.connect("key-release-event", self.apply_changes)

        horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=40)
        horizontal_container.set_valign(Gtk.Align.CENTER)

        # HDMI mode combo box
        self.mode_combo = KanoComboBox(max_display_items=7)
        self.mode_combo.connect("changed", self.on_mode_changed)

        # Fill list of modes
        modes = list_supported_modes()
        self.mode_combo.append("auto")
        if modes:
            for v in modes:
                self.mode_combo.append(v)

        horizontal_container.pack_start(self.mode_combo, False, False, 0)
        self.mode_combo.props.valign = Gtk.Align.CENTER

        # Select the current setting in the dropdown list
        saved_group, saved_mode = read_hdmi_mode()
        active_item = find_matching_mode(modes, saved_group, saved_mode)
        self.mode_combo.set_selected_item_index(active_item)
        self.init_item = active_item
        self.mode_index = active_item
        # Overscan button
        overscan_button = OrangeButton("Overscan")
        horizontal_container.pack_end(overscan_button, False, False, 0)
        overscan_button.connect("button-release-event", self.go_to_overscan)

        self.box.pack_start(horizontal_container, False, False, 0)

        # Create Flip 180 checkbox 
        flip_button = Gtk.CheckButton("Flip Screen")
        flip_button.set_can_focus(False)
        flip_button.props.valign = Gtk.Align.CENTER
        flip_button.set_active(get_config_value("display_rotate") == 2)
        flip_button.connect("clicked", self.flip)

        self.box.pack_start(flip_button, False, False, 0)
        self.kano_button.set_sensitive(False)

        # Add apply changes button under the main settings content
        self.win.show_all()
Esempio n. 19
0
def backup_overclock_values(backup_config):
    backup_config.ensure_exists()
    for key in CLOCK_KEYS:
        backup_config.set_value(key, get_config_value(key))