Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 1 | #include "fan_speed.hpp" |
| 2 | #include "hwmon.hpp" |
| 3 | #include "sysfs.hpp" |
Matt Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 4 | #include <experimental/filesystem> |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 5 | |
| 6 | namespace hwmon |
| 7 | { |
| 8 | |
| 9 | uint64_t FanSpeed::target(uint64_t value) |
| 10 | { |
| 11 | auto curValue = FanSpeedObject::target(); |
| 12 | |
| 13 | if (curValue != value) |
| 14 | { |
| 15 | //Write target out to sysfs |
Patrick Venture | 1e6324f | 2017-06-01 14:07:05 -0700 | [diff] [blame] | 16 | curValue = sysfs::writeSysfsWithCallout(value, |
| 17 | sysfsRoot, |
| 18 | instance, |
| 19 | type, |
| 20 | id, |
| 21 | entry::target); |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | return FanSpeedObject::target(value); |
| 25 | } |
| 26 | |
Matt Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 27 | |
| 28 | void FanSpeed::enable() |
| 29 | { |
| 30 | namespace fs = std::experimental::filesystem; |
| 31 | |
| 32 | auto path = sysfsRoot + "/" + instance; |
Patrick Venture | 1e6324f | 2017-06-01 14:07:05 -0700 | [diff] [blame] | 33 | auto fullPath = sysfs::make_sysfs_path(path, |
| 34 | type::pwm, |
| 35 | id, |
| 36 | entry::enable); |
Matt Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 37 | |
| 38 | if (fs::exists(fullPath)) |
| 39 | { |
| 40 | //This class always uses RPM mode |
Patrick Venture | 1e6324f | 2017-06-01 14:07:05 -0700 | [diff] [blame] | 41 | sysfs::writeSysfsWithCallout(enable::rpmMode, |
| 42 | sysfsRoot, |
| 43 | instance, |
| 44 | type::pwm, |
| 45 | id, |
| 46 | entry::enable); |
Matt Spinler | 0a8de64 | 2017-05-11 10:59:39 -0500 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
| 50 | |
Matthew Barth | 048ac87 | 2017-03-09 14:36:08 -0600 | [diff] [blame] | 51 | } // namespace hwmon |