Ejemplo n.º 1
0
def main():

    default_fan_config = '''#Fan Control Matrix. [<Temp in C>,<Fanspeed in %>]
speed_matrix:
- [0, 0]
- [30, 33]
- [45, 50]
- [60, 66]
- [65, 69]
- [70, 75]
- [75, 89]
- [80, 100]

# optional
# cards:  # can be any card returned from `ls /sys/class/drm | grep "^card[[:digit:]]$"`
# - card0
'''
    config = None
    for location in CONFIG_LOCATIONS:
        if os.path.isfile(location):
            config = load_config(location)
            break

    if config is None:
        logger.info(f'no config found, creating one in {CONFIG_LOCATIONS[-1]}')
        with open(CONFIG_LOCATIONS[-1], 'w') as f:
            f.write(default_fan_config)
            f.flush()

        config = load_config(CONFIG_LOCATIONS[-1])

    FanController(config).main()
Ejemplo n.º 2
0
    def main(self):
        logger.info(f'starting amdgpu-fan')
        speed_by_card = {}
        while True:
            for name, card in self._scanner.cards.items():
                current_speed = speed_by_card.get(name)
                # Reset current speed if it is off for more than 10%
                if current_speed is not None and abs(current_speed -
                                                     card.fan_speed) > 10:
                    current_speed = None

                temp = card.gpu_temp

                speed = max(0, int(self.curve.get_speed(int(temp))))
                if current_speed is not None and current_speed >= speed:
                    speed = max(
                        0,
                        int(self.curve.get_speed(int(temp) + self.temp_drop)))
                    if current_speed <= speed:
                        continue

                logger.debug(
                    f'{name}: Temp {temp}, Setting fan speed to: {speed}, fan speed: {card.fan_speed}, min: {card.fan_min}, max: {card.fan_max}'
                )

                card.set_fan_speed(speed)
                speed_by_card[name] = speed

            time.sleep(self._interval)
Ejemplo n.º 3
0
 def _verify_card(self):
     for endpoint in ('temp1_input', 'pwm1_max', 'pwm1_min', 'pwm1_enable',
                      'pwm1'):
         if endpoint not in self._endpoints:
             logger.info('skipping card: %s as its missing endpoint %s',
                         self._identifier, endpoint)
             raise FileNotFoundError
Ejemplo n.º 4
0
    def main(self):
        logger.info(f'starting amdgpu-fan')
        while True:
            for name, card in self._scanner.cards.items():
                temp = card.gpu_temp
                speed = int(self.curve.get_speed(int(temp)))
                if speed < 0:
                    speed = 0

                logger.debug(f'{name}: Temp {temp}, Setting fan speed to: {speed}, fan speed{card.fan_speed}, min:{card.fan_min}, max:{card.fan_max}')

                card.set_fan_speed(speed)
            time.sleep(self._frequency)
Ejemplo n.º 5
0
def main():
    config = None
    for location in CONFIG_LOCATIONS:
        if os.path.isfile(location):
            config = load_config(location)
            break

    if config is None:
        logger.info(f'no config found, creating one in {CONFIG_LOCATIONS[-1]}')
        with open(CONFIG_LOCATIONS[-1], 'w+') as f:
            f.write(yaml.dump(dict(speed_matrix=[[0, 0], [100, 100]])))
            f.flush()

    config = load_config(CONFIG_LOCATIONS[-1])

    FanController(config).main()