RDK Documentation (Open Sourced RDK Components)
productTraits.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 pwrMgrProductTraits
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) {return false;};
110  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const {return false;}
111  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) {return false;}
112  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) {return false;}
113  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const {return prev_state;}
114  virtual void sync_display_ports_with_reboot_reason(reboot_type_t type) {};
115 
116 
117  };
118 
120  {
121  public:
122  ux_controller_tv_eu(unsigned int in_id, const std::string &in_name);
123  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
124  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
125  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
126  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
127  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
128  };
129 
131  {
132  public:
133  ux_controller_stb_eu(unsigned int in_id, const std::string &in_name);
134  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
135  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
136  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
137  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
138  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
139  };
140 
142  {
143  public:
144  ux_controller_tv(unsigned int in_id, const std::string &in_name);
145  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
146  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
147  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
148  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
149  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
150  virtual void sync_display_ports_with_reboot_reason(reboot_type_t type) override;
151  };
152 
154  {
155  public:
156  ux_controller_stb(unsigned int in_id, const std::string &in_name);
157  virtual bool applyPowerStateChangeConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
158  virtual bool applyPreRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) const override;
159  virtual bool applyPreMaintenanceRebootConfig(IARM_Bus_PWRMgr_PowerState_t current_state) override;
160  virtual bool applyPostRebootConfig(IARM_Bus_PWRMgr_PowerState_t new_state, IARM_Bus_PWRMgr_PowerState_t prev_state) override;
161  virtual IARM_Bus_PWRMgr_PowerState_t getPreferredPostRebootPowerState(IARM_Bus_PWRMgr_PowerState_t prev_state) const override;
162  };
163 }
164 #endif
pwrMgrProductTraits::ux_controller
Definition: productTraits.h:72
pwrMgrProductTraits::ux_controller_tv
Definition: productTraits.h:141
pwrMgrProductTraits::ux_controller_stb
Definition: productTraits.h:153
pwrMgrProductTraits::ux_controller_stb_eu
Definition: productTraits.h:130
pwrMgrProductTraits::ux_controller_tv_eu
Definition: productTraits.h:119
libIBus.h
RDK IARM-Bus API Declarations.