amdgpu_fan 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/environment.rb +1 -0
- data/lib/amdgpu_fan/cli.rb +4 -4
- data/lib/amdgpu_fan/connector.rb +0 -1
- data/lib/amdgpu_fan/mixin/fan.rb +0 -1
- data/lib/amdgpu_fan/mixin/sys_write.rb +1 -2
- data/lib/amdgpu_fan/pci.rb +62 -0
- data/lib/amdgpu_fan/service.rb +35 -7
- data/lib/amdgpu_fan/stat_set.rb +1 -1
- data/lib/amdgpu_fan/version.rb +1 -1
- data/lib/amdgpu_fan/watcher.rb +2 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a499ce52639612b25843b04c3497c7c36f23f3a960d0946b7dc2e249e9a18874
|
4
|
+
data.tar.gz: fa87ca342988d97a91773b1272829a3b825b88dbd65420d6abd26fed8d97ac92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06b3bd73191b39da57ac9c14e7ada8fa2cf1a069e8401f45af10eab6ede0bf79a5ebd2f80ba5c464e60f960e24d11783cf20d698c640a38e36c80846b305772e
|
7
|
+
data.tar.gz: 794e28fd6ae71a898b1e897a0fd612add4585e901ece8bc3928e62de9d8245107767848352fe7203d4aa5b6ec60c4e78b28523cc0c893d4d0bcb2f67fdd52044
|
data/README.md
CHANGED
@@ -93,7 +93,7 @@ And now the watch is ended.
|
|
93
93
|
|
94
94
|
- [Ruby](https://www.ruby-lang.org) with [Bundler](https://bundler.io)
|
95
95
|
- [Thor](http://whatisthor.com/) (installed with `bundle install`)
|
96
|
-
-
|
96
|
+
- Internet connection - Device info is retrieved from https://pci-ids.ucw.cz/
|
97
97
|
|
98
98
|
## Building a binary
|
99
99
|
|
data/config/environment.rb
CHANGED
@@ -10,5 +10,6 @@ require_relative '../lib/amdgpu_fan/mixin/sys_write'
|
|
10
10
|
|
11
11
|
require_relative '../lib/amdgpu_fan/service'
|
12
12
|
require_relative '../lib/amdgpu_fan/cli'
|
13
|
+
require_relative '../lib/amdgpu_fan/pci'
|
13
14
|
require_relative '../lib/amdgpu_fan/stat_set'
|
14
15
|
require_relative '../lib/amdgpu_fan/watcher'
|
data/lib/amdgpu_fan/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module AmdgpuFan
|
|
7
7
|
class Cli < Thor
|
8
8
|
include CliOutputFormat
|
9
9
|
|
10
|
-
ICONS = YAML.
|
10
|
+
ICONS = YAML.safe_load(File.read(File.join(__dir__, '../../config/icons.yml')))
|
11
11
|
.transform_keys(&:to_sym).freeze
|
12
12
|
WATCH_FIELD_SEPARATOR = ' | '
|
13
13
|
|
@@ -57,13 +57,13 @@ module AmdgpuFan
|
|
57
57
|
def status(option = nil)
|
58
58
|
puts radeon_logo if option == '--logo'
|
59
59
|
puts ICONS[:gpu] + ' GPU:'.ljust(9) + amdgpu_service.name,
|
60
|
-
ICONS[:vbios]+ ' vBIOS:'.ljust(9) + amdgpu_service.vbios_version,
|
61
|
-
ICONS[:display]
|
60
|
+
ICONS[:vbios] + ' vBIOS:'.ljust(9) + amdgpu_service.vbios_version,
|
61
|
+
ICONS[:display] + ' Displays:' + amdgpu_service.display_names.join(', '),
|
62
62
|
ICONS[:clock] + ' Clocks:'.ljust(9) + clock_status,
|
63
63
|
ICONS[:memory] + ' Memory:'.ljust(9) + mem_total_mibibyes,
|
64
64
|
ICONS[:fan] + ' Fan:'.ljust(9) + fan_status,
|
65
65
|
ICONS[:temp] + ' Temp:'.ljust(9) + "#{amdgpu_service.temperature}°C",
|
66
|
-
ICONS[:power] + ' Power:'.ljust(9) +
|
66
|
+
ICONS[:power] + ' Power:'.ljust(9) + "#{amdgpu_service.profile_mode} profile in " \
|
67
67
|
"#{amdgpu_service.power_dpm_state} mode using " \
|
68
68
|
"#{amdgpu_service.power_draw} / #{amdgpu_service.power_max} Watts "\
|
69
69
|
"(#{amdgpu_service.power_draw_percent}%)",
|
data/lib/amdgpu_fan/connector.rb
CHANGED
data/lib/amdgpu_fan/mixin/fan.rb
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
module AmdgpuFan
|
4
4
|
# A mixin to help with writing to system files
|
5
5
|
module SysWrite
|
6
|
-
|
7
6
|
private
|
8
7
|
|
9
8
|
##
|
10
|
-
# Write to a system file with elevated priviledges.
|
9
|
+
# Write to a system file with elevated priviledges.
|
11
10
|
def sudo_write(file_path, value)
|
12
11
|
`echo "#{value}" | sudo tee #{file_path}`
|
13
12
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module AmdgpuFan
|
6
|
+
## PCI
|
7
|
+
#
|
8
|
+
# Retrieve device information from PCI IDs.
|
9
|
+
# https://pci-ids.ucw.cz/
|
10
|
+
#
|
11
|
+
class PCI
|
12
|
+
TMP_FILE = '/tmp/pci.ids.txt'
|
13
|
+
URL = 'https://pci-ids.ucw.cz/v2.2/pci.ids'
|
14
|
+
|
15
|
+
##
|
16
|
+
# Return the device name if available
|
17
|
+
#
|
18
|
+
def self.device_name(vendor_id, device_id, subdevice_id)
|
19
|
+
device = info.dig vendor_id, :devices, device_id
|
20
|
+
|
21
|
+
device.dig(subdevice_id, :name) || device[:name]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.vendor_name(vendor_id)
|
25
|
+
info.dig vendor_id, :name
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.info
|
29
|
+
current_vendor_id = nil
|
30
|
+
current_device_id = nil
|
31
|
+
|
32
|
+
@info = raw.each_line.with_object({}) do |line, hash|
|
33
|
+
next if line.empty? || line.start_with?('#')
|
34
|
+
|
35
|
+
if line[0] =~ /(\d|[a-z])/
|
36
|
+
# Vendor line
|
37
|
+
current_vendor_id = line.split(' ').first.to_i(16)
|
38
|
+
vendor_name = line.split(' ').last.strip
|
39
|
+
hash[current_vendor_id] = { name: vendor_name, devices: {} }
|
40
|
+
elsif line[0..1] =~ /\t\w/
|
41
|
+
# Device line
|
42
|
+
current_device_id = line.split(' ').first.to_i(16)
|
43
|
+
device_name = line.split(' ').last.strip
|
44
|
+
hash[current_vendor_id][:devices][current_device_id] = { name: device_name }
|
45
|
+
elsif line[0..2] =~ /\t\t\w/
|
46
|
+
# Subvendor line
|
47
|
+
subvendor_id = line.split(' ').first.to_i(16)
|
48
|
+
subdevice_id = line.split(' ')[1].to_i(16)
|
49
|
+
subdevice_name = line.split(' ')[1].strip
|
50
|
+
hash[current_vendor_id][:devices][current_device_id][subdevice_id] =
|
51
|
+
{ name: subdevice_name }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.raw
|
57
|
+
File.write(TMP_FILE, Net::HTTP.get(URI(URL))) unless File.exist?(TMP_FILE)
|
58
|
+
|
59
|
+
@raw ||= File.read(TMP_FILE)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/amdgpu_fan/service.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'mixin/fan'
|
|
4
4
|
require_relative 'mixin/sys_write'
|
5
5
|
|
6
6
|
require_relative 'connector'
|
7
|
+
require_relative 'pci'
|
7
8
|
|
8
9
|
module AmdgpuFan
|
9
10
|
## AmdgpuService
|
@@ -45,10 +46,16 @@ module AmdgpuFan
|
|
45
46
|
FAN_MODES[File.read(fan_mode_file).strip] || 'unknown'
|
46
47
|
end
|
47
48
|
|
49
|
+
##
|
50
|
+
# Set the fan mode to auto or manual.
|
51
|
+
#
|
48
52
|
def fan_mode=(mode)
|
49
53
|
sudo_write fan_mode_file, FAN_MODES.key(mode.to_s)
|
50
54
|
end
|
51
55
|
|
56
|
+
##
|
57
|
+
# Set the fan speed to a percentage if <= 100 or a raw value
|
58
|
+
#
|
52
59
|
def fan_speed=(value)
|
53
60
|
if valid_fan_percent_speed?(value)
|
54
61
|
new_raw = (value.to_f / 100 * fan_raw_speeds(:max).to_i).round
|
@@ -67,20 +74,37 @@ module AmdgpuFan
|
|
67
74
|
(fan_speed_raw.to_f / fan_raw_speeds(:max).to_i * 100).round
|
68
75
|
end
|
69
76
|
|
77
|
+
##
|
78
|
+
# Return the fan speed in revolutions per minute
|
79
|
+
#
|
70
80
|
def fan_speed_rpm
|
71
81
|
File.read(fan_file(:input)).strip
|
72
82
|
end
|
73
83
|
|
84
|
+
##
|
85
|
+
# Return the current memory clock speed.
|
86
|
+
#
|
74
87
|
def memory_clock
|
75
88
|
clock_from_pp_file "#{base_card_dir}/pp_dpm_mclk"
|
76
89
|
end
|
77
90
|
|
91
|
+
##
|
92
|
+
# Return the total memory on the card in bytes
|
93
|
+
#
|
78
94
|
def memory_total
|
79
95
|
File.read("#{base_card_dir}/mem_info_vram_total").to_i
|
80
96
|
end
|
81
97
|
|
98
|
+
def model_id
|
99
|
+
@model_id ||= File.read(File.join(base_card_dir, '/subsystem_device')).gsub(/\A0x/, '').upcase
|
100
|
+
end
|
101
|
+
|
82
102
|
def name
|
83
|
-
|
103
|
+
return 'Unknown' unless PCI.vendor_name(vendor_id)
|
104
|
+
|
105
|
+
[PCI.vendor_name(vendor_id),
|
106
|
+
PCI.device_name(vendor_id, device_id, subdevice_id) || 'unknown']
|
107
|
+
.join(' ')
|
84
108
|
end
|
85
109
|
|
86
110
|
def power_dpm_state
|
@@ -138,12 +162,8 @@ module AmdgpuFan
|
|
138
162
|
File.read(file).slice(/\w+(?= \*)/)
|
139
163
|
end
|
140
164
|
|
141
|
-
def
|
142
|
-
@
|
143
|
-
end
|
144
|
-
|
145
|
-
def lspci_subsystem
|
146
|
-
@lspci_subsystem ||= `lspci -v -s #{gpu_pci_id} | grep "Subsystem:"`
|
165
|
+
def device_id
|
166
|
+
@device_id ||= File.read(File.join(base_card_dir, 'device')).to_i(16)
|
147
167
|
end
|
148
168
|
|
149
169
|
def power_avg_file
|
@@ -154,8 +174,16 @@ module AmdgpuFan
|
|
154
174
|
(raw_string.strip.to_f / 1_000_000).round(2)
|
155
175
|
end
|
156
176
|
|
177
|
+
def subdevice_id
|
178
|
+
@subdevice_id ||= File.read(File.join(base_card_dir, 'subsystem_device')).to_i(16)
|
179
|
+
end
|
180
|
+
|
157
181
|
def temperature_file
|
158
182
|
@temperature_file ||= Dir.glob("#{base_card_dir}/**/temp1_input").first
|
159
183
|
end
|
184
|
+
|
185
|
+
def vendor_id
|
186
|
+
@vendor_id ||= File.read(File.join(base_card_dir, 'vendor')).to_i(16)
|
187
|
+
end
|
160
188
|
end
|
161
189
|
end
|
data/lib/amdgpu_fan/stat_set.rb
CHANGED
data/lib/amdgpu_fan/version.rb
CHANGED
data/lib/amdgpu_fan/watcher.rb
CHANGED
@@ -47,8 +47,8 @@ module AmdgpuFan
|
|
47
47
|
|
48
48
|
stat_set.min = stat_set.now if stat_set.now < stat_set.min
|
49
49
|
stat_set.avg =
|
50
|
-
|
51
|
-
|
50
|
+
((stat_set.now + stat_set.avg * (num_measurements - 1)) / num_measurements.to_f)
|
51
|
+
.round(1)
|
52
52
|
stat_set.max = stat_set.now if stat_set.now > stat_set.max
|
53
53
|
end
|
54
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amdgpu_fan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McCormack
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/amdgpu_fan/mixin/cli_output_format.rb
|
70
70
|
- lib/amdgpu_fan/mixin/fan.rb
|
71
71
|
- lib/amdgpu_fan/mixin/sys_write.rb
|
72
|
+
- lib/amdgpu_fan/pci.rb
|
72
73
|
- lib/amdgpu_fan/service.rb
|
73
74
|
- lib/amdgpu_fan/stat_set.rb
|
74
75
|
- lib/amdgpu_fan/version.rb
|
@@ -77,7 +78,7 @@ homepage: https://github.com/HarlemSquirrel/amdgpu-fan-rb
|
|
77
78
|
licenses:
|
78
79
|
- MIT
|
79
80
|
metadata: {}
|
80
|
-
post_install_message:
|
81
|
+
post_install_message:
|
81
82
|
rdoc_options: []
|
82
83
|
require_paths:
|
83
84
|
- lib
|
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
96
|
rubygems_version: 3.1.2
|
96
|
-
signing_key:
|
97
|
+
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: A CLI to view and set fan speeds for AMD graphics cards running on the open
|
99
100
|
source amdgpu Linux driver
|