1 /* Copyright (c) 2015, The Linux Foundataion. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of The Linux Foundation nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29 
30 #ifndef __COLOR_MANAGER_H__
31 #define __COLOR_MANAGER_H__
32 
33 #include <stdlib.h>
34 #include <core/sdm_types.h>
35 #include <utils/locker.h>
36 #include <private/color_interface.h>
37 #include <utils/debug.h>
38 #include "hw_interface.h"
39 
40 namespace sdm {
41 
42 /*
43  * ColorManager proxy to maintain necessary information to interact with underlying color service.
44  * Each display object has its own proxy.
45  */
46 class ColorManagerProxy {
47  public:
48   static DisplayError Init(const HWResourceInfo &hw_res_info);
49   static void Deinit();
50 
51   /* Create ColorManagerProxy for this display object, following things need to be happening
52    * 1. Instantiates concrete ColorInerface implementation.
53    * 2. Pass all display object specific informations into it.
54    * 3. Populate necessary resources.
55    * 4. Need get panel name for hw_panel_info_.
56    */
57   static ColorManagerProxy *CreateColorManagerProxy(DisplayType type, HWInterface *hw_intf,
58                                                     const HWDisplayAttributes &attribute,
59                                                     const HWPanelInfo &panel_info);
60 
61   /* need reverse the effect of CreateColorManagerProxy. */
62   ~ColorManagerProxy();
63 
64   DisplayError ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload,
65                                     PPDisplayAPIPayload *out_payload,
66                                     PPPendingParams *pending_action);
67   DisplayError ApplyDefaultDisplayMode();
68   bool NeedsPartialUpdateDisable();
69   DisplayError Commit();
70 
71  protected:
ColorManagerProxy()72   ColorManagerProxy() {}
73   ColorManagerProxy(DisplayType type, HWInterface *intf, const HWDisplayAttributes &attr,
74                     const HWPanelInfo &info);
75 
76  private:
77   static void *color_lib_;
78   static CreateColorInterface create_intf_;
79   static DestroyColorInterface destroy_intf_;
80   static HWResourceInfo hw_res_info_;
81 
82   DisplayType device_type_;
83   PPHWAttributes pp_hw_attributes_;
84   HWInterface *hw_intf_;
85   ColorInterface *color_intf_;
86   PPFeaturesConfig pp_features_;
87 };
88 
89 }  // namespace sdm
90 
91 #endif  // __COLOR_MANAGER_H__
92