Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 3 | #include "hwmonio.hpp" |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 4 | #include "interface.hpp" |
| 5 | #include "sysfs.hpp" |
| 6 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 7 | #include <memory> |
| 8 | |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 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 | { |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 20 | public: |
| 21 | /** |
| 22 | * @brief Constructs FanPwm Object |
| 23 | * |
| 24 | * @param[in] io - HwmonIO |
| 25 | * @param[in] devPath - The /sys/devices sysfs path |
| 26 | * @param[in] id - The hwmon id |
| 27 | * @param[in] bus - Dbus bus object |
| 28 | * @param[in] objPath - Dbus object path |
| 29 | * @param[in] defer - Dbus object registration defer |
| 30 | */ |
Patrick Venture | 5055237 | 2018-06-07 10:53:56 -0700 | [diff] [blame] | 31 | FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io, |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 32 | const std::string& devPath, const std::string& id, |
Patrick Williams | ad6043f | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 33 | sdbusplus::bus_t& bus, const char* objPath, bool defer, |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 34 | uint64_t target) : |
Patrick Williams | d273b1e | 2022-03-30 21:55:44 -0500 | [diff] [blame] | 35 | FanPwmObject(bus, objPath, |
| 36 | defer ? FanPwmObject::action::emit_no_signals |
| 37 | : FanPwmObject::action::emit_object_added), |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 38 | _id(id), _ioAccess(std::move(io)), _devPath(devPath) |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 39 | { |
| 40 | FanPwmObject::target(target); |
| 41 | } |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 42 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 43 | /** |
| 44 | * @brief Set the value of target |
| 45 | * |
| 46 | * @return Value of target |
| 47 | */ |
| 48 | uint64_t target(uint64_t value) override; |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 49 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 50 | private: |
| 51 | /** @brief hwmon type */ |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 52 | static constexpr auto _type = "pwm"; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 53 | /** @brief hwmon id */ |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 54 | std::string _id; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 55 | /** @brief Hwmon sysfs access. */ |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 56 | std::unique_ptr<hwmonio::HwmonIOInterface> _ioAccess; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 57 | /** @brief Physical device path. */ |
Patrick Venture | 2511c09 | 2018-12-19 14:31:29 -0800 | [diff] [blame] | 58 | std::string _devPath; |
Patrick Venture | 9331ab7 | 2018-01-29 09:48:47 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace hwmon |