19331ab78SPatrick Venture #pragma once 29331ab78SPatrick Venture 375e56c67SPatrick Venture #include "hwmonio.hpp" 49331ab78SPatrick Venture #include "interface.hpp" 59331ab78SPatrick Venture #include "sysfs.hpp" 69331ab78SPatrick Venture 7043d3230SPatrick Venture #include <memory> 8043d3230SPatrick Venture 99331ab78SPatrick Venture namespace hwmon 109331ab78SPatrick Venture { 119331ab78SPatrick Venture 129331ab78SPatrick Venture /** 139331ab78SPatrick Venture * @class FanPwm 149331ab78SPatrick Venture * @brief Target fan pwm control implementation 159331ab78SPatrick Venture * @details Derived FanPwmObject type that writes the target value to sysfs 169331ab78SPatrick Venture * which in turn sets the fan speed to that target value 179331ab78SPatrick Venture */ 189331ab78SPatrick Venture class FanPwm : public FanPwmObject 199331ab78SPatrick Venture { 209331ab78SPatrick Venture public: 219331ab78SPatrick Venture /** 229331ab78SPatrick Venture * @brief Constructs FanPwm Object 239331ab78SPatrick Venture * 2450552377SPatrick Venture * @param[in] io - HwmonIO 259331ab78SPatrick Venture * @param[in] devPath - The /sys/devices sysfs path 269331ab78SPatrick Venture * @param[in] id - The hwmon id 279331ab78SPatrick Venture * @param[in] bus - Dbus bus object 289331ab78SPatrick Venture * @param[in] objPath - Dbus object path 299331ab78SPatrick Venture * @param[in] defer - Dbus object registration defer 309331ab78SPatrick Venture */ FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io,const std::string & devPath,const std::string & id,sdbusplus::bus_t & bus,const char * objPath,bool defer,uint64_t target)3150552377SPatrick Venture FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io, 32043d3230SPatrick Venture const std::string& devPath, const std::string& id, 33*ad6043f6SPatrick Williams sdbusplus::bus_t& bus, const char* objPath, bool defer, 34043d3230SPatrick Venture uint64_t target) : 35d273b1e0SPatrick Williams FanPwmObject(bus, objPath, 36d273b1e0SPatrick Williams defer ? FanPwmObject::action::emit_no_signals 37d273b1e0SPatrick Williams : FanPwmObject::action::emit_object_added), 382511c09bSPatrick Venture _id(id), _ioAccess(std::move(io)), _devPath(devPath) 399331ab78SPatrick Venture { 409331ab78SPatrick Venture FanPwmObject::target(target); 419331ab78SPatrick Venture } 429331ab78SPatrick Venture 439331ab78SPatrick Venture /** 449331ab78SPatrick Venture * @brief Set the value of target 459331ab78SPatrick Venture * 469331ab78SPatrick Venture * @return Value of target 479331ab78SPatrick Venture */ 489331ab78SPatrick Venture uint64_t target(uint64_t value) override; 499331ab78SPatrick Venture 509331ab78SPatrick Venture private: 519331ab78SPatrick Venture /** @brief hwmon type */ 522511c09bSPatrick Venture static constexpr auto _type = "pwm"; 539331ab78SPatrick Venture /** @brief hwmon id */ 542511c09bSPatrick Venture std::string _id; 559331ab78SPatrick Venture /** @brief Hwmon sysfs access. */ 562511c09bSPatrick Venture std::unique_ptr<hwmonio::HwmonIOInterface> _ioAccess; 579331ab78SPatrick Venture /** @brief Physical device path. */ 582511c09bSPatrick Venture std::string _devPath; 599331ab78SPatrick Venture }; 609331ab78SPatrick Venture 619331ab78SPatrick Venture } // namespace hwmon 62