blob: aa71b9e9dc6bda558dc10bd655006c71f0466549 [file] [log] [blame]
Patrick Venture9331ab72018-01-29 09:48:47 -08001#pragma once
2
Patrick Venture75e56c62018-04-20 18:10:15 -07003#include "hwmonio.hpp"
Patrick Venture9331ab72018-01-29 09:48:47 -08004#include "interface.hpp"
5#include "sysfs.hpp"
6
Patrick Venture043d3232018-08-31 10:10:53 -07007#include <memory>
8
Patrick Venture9331ab72018-01-29 09:48:47 -08009namespace 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 */
18class FanPwm : public FanPwmObject
19{
Patrick Venture043d3232018-08-31 10:10:53 -070020 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 Venture50552372018-06-07 10:53:56 -070031 FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io,
Patrick Venture043d3232018-08-31 10:10:53 -070032 const std::string& devPath, const std::string& id,
Patrick Williamsad6043f2022-07-22 19:26:56 -050033 sdbusplus::bus_t& bus, const char* objPath, bool defer,
Patrick Venture043d3232018-08-31 10:10:53 -070034 uint64_t target) :
Patrick Williamsd273b1e2022-03-30 21:55:44 -050035 FanPwmObject(bus, objPath,
36 defer ? FanPwmObject::action::emit_no_signals
37 : FanPwmObject::action::emit_object_added),
Patrick Venture2511c092018-12-19 14:31:29 -080038 _id(id), _ioAccess(std::move(io)), _devPath(devPath)
Patrick Venture043d3232018-08-31 10:10:53 -070039 {
40 FanPwmObject::target(target);
41 }
Patrick Venture9331ab72018-01-29 09:48:47 -080042
Patrick Venture043d3232018-08-31 10:10:53 -070043 /**
44 * @brief Set the value of target
45 *
46 * @return Value of target
47 */
48 uint64_t target(uint64_t value) override;
Patrick Venture9331ab72018-01-29 09:48:47 -080049
Patrick Venture043d3232018-08-31 10:10:53 -070050 private:
51 /** @brief hwmon type */
Patrick Venture2511c092018-12-19 14:31:29 -080052 static constexpr auto _type = "pwm";
Patrick Venture043d3232018-08-31 10:10:53 -070053 /** @brief hwmon id */
Patrick Venture2511c092018-12-19 14:31:29 -080054 std::string _id;
Patrick Venture043d3232018-08-31 10:10:53 -070055 /** @brief Hwmon sysfs access. */
Patrick Venture2511c092018-12-19 14:31:29 -080056 std::unique_ptr<hwmonio::HwmonIOInterface> _ioAccess;
Patrick Venture043d3232018-08-31 10:10:53 -070057 /** @brief Physical device path. */
Patrick Venture2511c092018-12-19 14:31:29 -080058 std::string _devPath;
Patrick Venture9331ab72018-01-29 09:48:47 -080059};
60
61} // namespace hwmon