Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 3 | #include <xyz/openbmc_project/Led/Physical/server.hpp> |
| 4 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 5 | #include <set> |
Andrew Geissler | d02c3cb | 2020-05-16 10:28:02 -0500 | [diff] [blame] | 6 | #include <string> |
Patrick Williams | f204403 | 2022-03-17 05:12:30 -0500 | [diff] [blame] | 7 | #include <unordered_map> |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 8 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 9 | namespace phosphor |
| 10 | { |
| 11 | namespace led |
| 12 | { |
| 13 | /** @namespace Layout |
| 14 | * @brief Depicts the LED and their mappings and group actions |
| 15 | */ |
| 16 | namespace Layout |
| 17 | { |
Patrick Williams | ed80e88 | 2022-03-17 05:03:51 -0500 | [diff] [blame] | 18 | |
| 19 | using Action = sdbusplus::xyz::openbmc_project::Led::server::Physical::Action; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 20 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 21 | /** @brief Name of the LED and it's proposed action. |
| 22 | * This structure is supplied as configuration at build time |
| 23 | */ |
| 24 | struct LedAction |
| 25 | { |
| 26 | std::string name; |
| 27 | Action action; |
| 28 | uint8_t dutyOn; |
| 29 | uint16_t period; |
| 30 | Action priority; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 31 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 32 | // Order LEDs such that same LEDs are grouped next to |
| 33 | // each other and the same LEDs are in priority order |
| 34 | // with the highest priority coming first |
| 35 | bool operator<(const LedAction& right) const |
| 36 | { |
| 37 | if (name == right.name) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 38 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 39 | if (action == right.action) |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 40 | { |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 41 | return false; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 42 | } |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 43 | else if (action == priority) |
| 44 | { |
| 45 | return true; |
| 46 | } |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 47 | } |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 48 | return name < right.name; |
| 49 | } |
| 50 | }; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 51 | } // namespace Layout |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 52 | |
| 53 | using ActionSet = std::set<Layout::LedAction>; |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 54 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 55 | } // namespace led |
| 56 | } // namespace phosphor |