Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: fan control #1227

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vvvrrooomm
Copy link
Contributor

@vvvrrooomm vvvrrooomm commented Aug 16, 2020

This adds two new functions: fan mode and fan speed
Functionality as observed on BLADE_EARLY_2020_BASE:
fan speed can only vary between 0x2b - 0x36, the value seems to be RPM/100

struct razer_report report = get_razer_report(0x0d, 0x02, 0x04);
report.arguments[0] = 0x00; //frame_id: fixed value
report.arguments[1] = fan_id; //maybe fans can be set separately by id?
report.arguments[2] = 0x00; // unknown observed: 0x00
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument is for power mode of the CPU,
0 - balanced
1 - gaming
2 - creator
4 - custom
with 4 goes CPU boost and GPU boost power

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx! added now

@z3ntu
Copy link
Member

z3ntu commented Sep 26, 2020

Can you please remove the non fan-speed changes from this PR (and potentially put them into a separate PR)? Also generally I'm not comfortable with copying the raw frames from the moon effect into openrazer.

@vvvrrooomm vvvrrooomm force-pushed the feature/fan_control branch 2 times, most recently from 6bdae45 to e526e5b Compare December 18, 2020 11:51
@vvvrrooomm
Copy link
Contributor Author

vvvrrooomm commented Dec 18, 2020

Can you please remove the non fan-speed changes from this PR (and potentially put them into a separate PR)?

yes, sorry for that, late night branching and such.

Also generally I'm not comfortable with copying the raw frames from the moon effect into openrazer.

that was expected, just difficult to have a showcase for the extended_custom_frame feature. I'll take this comment over to the PR #1222

Copy link
Member

@z3ntu z3ntu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of comments, thanks for the update

driver/razerkbd_driver.c Outdated Show resolved Hide resolved
driver/razerkbd_driver.c Outdated Show resolved Hide resolved
driver/razerkbd_driver.c Outdated Show resolved Hide resolved
.bumpversion.cfg Outdated Show resolved Hide resolved
@z3ntu
Copy link
Member

z3ntu commented Jan 17, 2021

I've squashed the commits and fixed up a few things now.

Question: do you think this functionality is available on all these devices?
RAZER_BLADE_2018_BASE
RAZER_BLADE_STEALTH_2019
RAZER_BLADE_STEALTH_LATE_2019
RAZER_BLADE_STEALTH_EARLY_2020
RAZER_BLADE_STEALTH_LATE_2020
RAZER_BLADE_2019_BASE
RAZER_BLADE_EARLY_2020_BASE

If yes we should also add the fan methods to the daemon for these devices. If not, then we need to adjust razerkbd_driver.c

@vvvrrooomm
Copy link
Contributor Author

vvvrrooomm commented Jan 19, 2021

I've squashed the commits and fixed up a few things now.

Question: do you think this functionality is available on all these devices?
RAZER_BLADE_2018_BASE
RAZER_BLADE_STEALTH_2019
RAZER_BLADE_STEALTH_LATE_2019
RAZER_BLADE_STEALTH_EARLY_2020
RAZER_BLADE_STEALTH_LATE_2020
RAZER_BLADE_2019_BASE
RAZER_BLADE_EARLY_2020_BASE

If yes we should also add the fan methods to the daemon for these devices. If not, then we need to adjust razerkbd_driver.c

I assume it is since the other features are identical but I have not way of knowing or testing

@z3ntu
Copy link
Member

z3ntu commented Feb 27, 2021

Then please add the methods in the daemon for these devices as well. If it doesn't work on some of those we can remove it in another release.

@LinuxDonald
Copy link

@vvvrrooomm are you still on this pr?

merger

add game_mode

satisfy auto-generate-script

read support for fan_speed & fan_mode

rework interface: each fan has his own files now

fan control: fix python dbus interface after rework

fan speed rework python interface

fan speed: fix python interface, getter read-only, right amount of bytes

fan speed: remove debug output from driver, fixup output format

fan speed: fix kernel driver bug: duplicate sys files were created

fan speed:kernel interface consistent is [byte]

fan_speed: satisfy script after change of kernel driver

* change cfg
* enhance script to accept digits in sys files

fan_speed: do not use format-strings

WIP: DO NOT PUSH: new local version

fan_speeed: convert sysfs interfcae to binary mode

fan_control: add defaults

spaces anf formatting

fix: accidentally activate effect for RAZER_BLADE_EARLY_2020_BASE

update fake_driver after fix RAZER_BLADE_EARLY_2020_BASE fx

fixes from review

fixup
lah7 added a commit to polychromatic/polychromatic that referenced this pull request Jan 3, 2022
Feature added in openrazer/openrazer#1227.

Based on original pull requests #275 and #301.

Co-authored-by: Martin Haaß <vvvrrooomm@gmail.com>
@lah7 lah7 linked an issue Jan 3, 2022 that may be closed by this pull request
Copy link
Member

@lah7 lah7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon request of a user, I was updating a stale pull request polychromatic/polychromatic#301 to implement a frontend for testing. However, I found the API in its current state difficult to work with and propose some amendments.

device.fx.fan_mode(mode_automatic, game_mode_balanced)

elif effect == 'fan_speed':
result = device.fx.fan_speed()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is outdated, it's now device.get_fan_speed(<fan_id>) when testing under fake driver conditions. Same with other get/set functions.

mode_manual = 0x01
mode_automatic = 0x01

game_mode_balanced = 0x00
Copy link
Member

@lah7 lah7 Jan 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems each interface to the API needs to "know" these exact bytes rather then passing an integer/object. May we "hardcode" them into the Python library and/or daemon so they can be validated?

For example, the reactive has a time and needs to be one of REACTIVE_ values.

def get_fan_mode(self, fan_id):
"""
get fan mode
:return fan_id: might change fans separately if more than one available (ususally 0x00)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function like get_fan_count() to return an int of how many fans are present would be useful.

Currently, there's no way to know how many fans are present for a device. The API so far is too dynamic that it could cause a FileNotFoundError trying a fan_id too high (like 3)

"""
get fan speed
:return fan_speed: speed in RPM/100
Values appear to be RPM/100, observed were 0x2b - 0x36, i.e. 4300RPM - 5400RPM
Copy link
Member

@lah7 lah7 Jan 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dealing with bytes for scripts/apps seems too low level for higher level API usage. Please may we have the daemon convert them to an int to get/set a RPM value?

Plus, please could we add a variable for the min/max RPM values? Hardcoding the value should be fine, until it's known a laptop could spin faster then 5400 RPM, or less then 4300 RPM.

1 - gaming
2 - creator
4 - custom
with 4 goes CPU boost and GPU boost power
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 4 - custom mean exactly? Does this set the laptop for maximum CPU/GPU performance? Would 4 - turbo or 4 - max make more sense name wise?

Seems a bit confusing to me having both fans and CPU governors mixed into one. Unless the fans make different sounds depending on which one is selected?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 4 on https://github.com/rnd-ash/razer-laptop-control you can set CPU und GPU seperatly from each other.

Copy link
Member

@lah7 lah7 Jan 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it work in this context (fan_id, fan_mode, game_mode)? Is fan 1 = CPU and fan 2 = GPU? Does this control the CPU/GPU frequency of that component or only the noise profile?

Still unclear with 4's purpose. Please could you show screenshots from Synapse of how these options work? 📸

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ausgeglichen = balanced
Ersteller = creator more cpu performence
Gaming = gaming more gpu performence
4 custom only exists on linux can setup for both max performence

Razer

set fan mode
:param fan_id: might change fans separately if more than one available (ususally 0x00)
:param fan_mode: 0x00: automatic 0x01: manual
:param game_mode: This argument is for power mode of the CPU,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth validating this field, so it's not too dynamic that bad/unknown data could be sent (6 for instance).

For example, the reactive has a time and needs to be one of REACTIVE_ values.

@LinuxDonald
Copy link

Maybe the Infos can be found in this project: https://github.com/rnd-ash/razer-laptop-control

@LinuxDonald
Copy link

Razer Blade 15 Base (Early 2021) Infos from Synapse Windows
Min RPM=4200
Max RPM=5400

I know that the Laptop have two fans one CPU and one GPU.
If you need more infos i would like to help :)

@LinuxDonald
Copy link

fan_id is wrong its 0x01 and 0x02

sys/devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.2/0003:1532:026F.0009  dir  heavy_check_mark
country device_serial driver fan_1_speed fan_2_speed hidraw kbd_layout matrix_effect_breath matrix_effect_reactive matrix_effect_static power subsystem uevent
device_mode device_type fan_1_mode fan_2_mode firmware_version input matrix_brightness matrix_effect_none matrix_effect_spectrum modalias report_descriptor test version

@wastrachan
Copy link
Contributor

I hope somebody would be willing to take another look at this at some point-- fan control would be a game changer for linux on balde devices. If I knew anything about drivers, I'd be in here trying to help.

@phush0
Copy link

phush0 commented Jul 14, 2023

I can take a look at this. I am the current maintainer of the razer-laptop-control. Python is not my strong side...

@wastrachan
Copy link
Contributor

I can take a look at this. I am the current maintainer of the razer-laptop-control. Python is not my strong side...

I'm happy to try to help with any Python stuff if the driver itself is in good shape. That's definitly more in my comfort zone.

@z3ntu
Copy link
Member

z3ntu commented Jul 16, 2023

There some something posted in #892 (comment), just linking so it's not hidden forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Adding support for changing fan speed
6 participants