summaryrefslogtreecommitdiffstats
path: root/fan_pwm.hpp
blob: 7aa2a7546a56f1ffcbec6ea35286dfe879d54b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include "hwmonio.hpp"
#include "interface.hpp"
#include "sysfs.hpp"

#include <memory>

namespace hwmon
{

/**
 * @class FanPwm
 * @brief Target fan pwm control implementation
 * @details Derived FanPwmObject type that writes the target value to sysfs
 * which in turn sets the fan speed to that target value
 */
class FanPwm : public FanPwmObject
{
  public:
    /**
     * @brief Constructs FanPwm Object
     *
     * @param[in] io - HwmonIO
     * @param[in] devPath - The /sys/devices sysfs path
     * @param[in] id - The hwmon id
     * @param[in] bus - Dbus bus object
     * @param[in] objPath - Dbus object path
     * @param[in] defer - Dbus object registration defer
     */
    FanPwm(std::unique_ptr<hwmonio::HwmonIOInterface> io,
           const std::string& devPath, const std::string& id,
           sdbusplus::bus::bus& bus, const char* objPath, bool defer,
           uint64_t target) :
        FanPwmObject(bus, objPath, defer),
        _id(id), _ioAccess(std::move(io)), _devPath(devPath)
    {
        FanPwmObject::target(target);
    }

    /**
     * @brief Set the value of target
     *
     * @return Value of target
     */
    uint64_t target(uint64_t value) override;

  private:
    /** @brief hwmon type */
    static constexpr auto _type = "pwm";
    /** @brief hwmon id */
    std::string _id;
    /** @brief Hwmon sysfs access. */
    std::unique_ptr<hwmonio::HwmonIOInterface> _ioAccess;
    /** @brief Physical device path. */
    std::string _devPath;
};

} // namespace hwmon
OpenPOWER on IntegriCloud