Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 5055237 | 2018-06-07 10:53:56 -0700 | [diff] [blame] | 3 | #include <memory> |
| 4 | |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 5 | #include "hwmonio.hpp" |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 6 | #include "interface.hpp" |
| 7 | #include "sysfs.hpp" |
| 8 | |
| 9 | namespace hwmon |
| 10 | { |
| 11 | |
| 12 | /** |
| 13 | * @class FanPwm |
| 14 | * @brief Target fan pwm control implementation |
| 15 | * @details Derived FanPwmObject type that writes the target value to sysfs |
| 16 | * which in turn sets the fan speed to that target value |
| 17 | */ |
| 18 | class FanPwm : public FanPwmObject |
| 19 | { |
| 20 | public: |
| 21 | |
| 22 | /** |
| 23 | * @brief Constructs FanPwm Object |
| 24 | * |
Patrick Venture | 5055237 | 2018-06-07 10:53:56 -0700 | [diff] [blame] | 25 | * @param[in] io - HwmonIO |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 26 | * @param[in] devPath - The /sys/devices sysfs path |
| 27 | * @param[in] id - The hwmon id |
| 28 | * @param[in] bus - Dbus bus object |
| 29 | * @param[in] objPath - Dbus object path |
| 30 | * @param[in] defer - Dbus object registration defer |
| 31 | */ |
Patrick Venture | 5055237 | 2018-06-07 10:53:56 -0700 | [diff] [blame] | 32 | FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io, |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 33 | const std::string& devPath, |
| 34 | const std::string& id, |
| 35 | sdbusplus::bus::bus& bus, |
| 36 | const char* objPath, |
| 37 | bool defer, |
| 38 | uint64_t target) : FanPwmObject(bus, objPath, defer), |
| 39 | id(id), |
Patrick Venture | 5055237 | 2018-06-07 10:53:56 -0700 | [diff] [blame] | 40 | ioAccess(std::move(io)), |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 41 | devPath(devPath) |
| 42 | { |
| 43 | FanPwmObject::target(target); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @brief Set the value of target |
| 48 | * |
| 49 | * @return Value of target |
| 50 | */ |
| 51 | uint64_t target(uint64_t value) override; |
| 52 | |
| 53 | private: |
| 54 | /** @brief hwmon type */ |
| 55 | static constexpr auto type = "pwm"; |
| 56 | /** @brief hwmon id */ |
| 57 | std::string id; |
| 58 | /** @brief Hwmon sysfs access. */ |
Patrick Venture | 5055237 | 2018-06-07 10:53:56 -0700 | [diff] [blame] | 59 | std::unique_ptr<hwmonio::HwmonIOInterface> ioAccess; |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 60 | /** @brief Physical device path. */ |
| 61 | std::string devPath; |
| 62 | }; |
| 63 | |
| 64 | } // namespace hwmon |
| 65 | |