RDK Documentation (Open Sourced RDK Components)
dsMgrProductTraitsHandler.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2021 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef _PRODUCT_TRAITS_
21 #define _PRODUCT_TRAITS_
22 #include <string>
23 #include <mutex>
24 #include "mfrTypes.h"
25 #include "libIBus.h"
26 #include "libIBusDaemon.h" //Need both the above to use type IARM_Bus_PWRMgr_PowerState_t
27 
28 namespace dsMgrProductTraits
29 {
30 typedef enum
31 {
32  /******* Important note! **********
33  * Do NOT disturb or rearrange existing enums defined in productProfileId_t. Always add new profiles just above PROFILE_MAX or havoc will ensue.
34  * The enums mapped here are passed as POWERMGR_PRODUCT_PROFILE_ID=<insert number> with the build configuration, which is how the various platforms
35  * choose user experience profiles applicable to them.
36  */
37  DEFAULT_STB_PROFILE = 0,
38  DEFAULT_TV_PROFILE,
39  DEFAULT_STB_PROFILE_EUROPE,
40  DEFAULT_TV_PROFILE_EUROPE,
41  PROFILE_MAX
42 } productProfileId_t;
43 
44 typedef enum
45 {
46  DEVICE_TYPE_STB = 0,
47  DEVICE_TYPE_TV,
48  DEVICE_TYPE_MAX
49 } deviceType_t;
50 
51 typedef enum
52 {
53  POWER_MODE_ON = 0,
54  POWER_MODE_LIGHT_SLEEP,
55  POWER_MODE_LAST_KNOWN,
56  POWER_MODE_UNSPECIFIED,
57  POWER_MODE_MAX
58 } powerModeTrait_t;
59 
60 enum class reboot_type_t { HARD, SOFT, UNAVAILABLE};
61 
62 /*
63  ux_controller or 'user experience controller' is in charge of maintaining and applying the user experience attributes owned by power manager.
64  That means attributes like this:
65  * Preferred power mode when the device reboots.
66  * power LED configuration when device is in standby and ON modes.
67  * Support for silent reboot (suppressing flash screen, power LED etc) when executing a maintenance reboot.
68  * and more.
69 
70  User experiences will vary among the various product classes. The various derivates of ux_controller class will represent each such specialiation.
71 */
73 {
74 protected:
75  unsigned int id;
76  std::string name;
77  deviceType_t deviceType;
78  bool invalidateAsyncBootloaderPattern;
79  bool firstPowerTransitionComplete;
80  mutable std::mutex mutex;
81 
82  bool enableMultiColourLedSupport;
83 
84  bool ledEnabledInStandby;
85  int ledColorInStandby;
86 
87  bool ledEnabledInOnState;
88  int ledColorInOnState;
89 
90  powerModeTrait_t preferedPowerModeOnReboot;
91  bool enableSilentRebootSupport;
92 
93  static ux_controller * singleton;
94 
95  void initialize_safe_defaults();
96  void sync_power_led_with_power_state(IARM_Bus_PWRMgr_PowerState_t state) const;
97  inline void sync_display_ports_with_power_state(IARM_Bus_PWRMgr_PowerState_t state) const;
98  bool _set_bootloader_pattern(mfrBlPattern_t pattern) const;
99  void _set_bootloader_pattern_async(mfrBlPattern_t pattern) const;
100  bool set_bootloader_pattern(mfrBlPattern_t pattern);
101  bool set_bootloader_pattern_fault_tolerant(mfrBlPattern_t pattern);
102 
103 public:
104  static bool initialize_ux_controller(unsigned int profile_id); //Not thread-safe
105  static ux_controller * get_instance(); //Not thread-safe
106  ux_controller(unsigned int in_id, const std::string &in_name, deviceType_t in_device_type);
107  virtual ~ux_controller() {}
108 
109  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) {
110  return false;
111  };
112  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const {
113  return false;
114  }
115  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) {
116  return false;
117  }
118  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) {
119  return false;
120  }
121  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const {
122  return prev_state;
123  }
124  virtual void sync_display_ports_with_reboot_reason(reboot_type_t type) {};
125 
126 
127 };
128 
130 {
131 public:
132  ux_controller_tv_eu(unsigned int in_id, const std::string &in_name);
133  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
134  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
135  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
136  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
137  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
138 };
139 
141 {
142 public:
143  ux_controller_stb_eu(unsigned int in_id, const std::string &in_name);
144  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
145  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
146  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
147  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
148  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
149 };
150 
152 {
153 public:
154  ux_controller_tv(unsigned int in_id, const std::string &in_name);
155  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
156  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
157  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
158  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
159  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
160  virtual void sync_display_ports_with_reboot_reason(reboot_type_t type) override;
161 };
162 
164 {
165 public:
166  ux_controller_stb(unsigned int in_id, const std::string &in_name);
167  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
168  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
169  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
170  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
171  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
172 };
173 }
174 #endif
dsMgrProductTraits::ux_controller_tv_eu
Definition: dsMgrProductTraitsHandler.h:129
dsMgrProductTraits::ux_controller
Definition: dsMgrProductTraitsHandler.h:72
libIBus.h
RDK IARM-Bus API Declarations.
dsMgrProductTraits::ux_controller_stb_eu
Definition: dsMgrProductTraitsHandler.h:140
dsMgrProductTraits::ux_controller_tv
Definition: dsMgrProductTraitsHandler.h:151
dsMgrProductTraits::ux_controller_stb
Definition: dsMgrProductTraitsHandler.h:163