• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7     * Redistributions of source code must retain the above copyright
8       notice, this list of conditions and the following disclaimer.
9     * Redistributions in binary form must reproduce the above
10       copyright notice, this list of conditions and the following
11       disclaimer in the documentation and/or other materials provided
12       with the distribution.
13     * Neither the name of The Linux Foundation nor the names of its
14       contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16 
17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef __HWC_DISPLAY_PRIMARY_H__
31 #define __HWC_DISPLAY_PRIMARY_H__
32 
33 #include <string>
34 
35 #include "cpuhint.h"
36 #include "hwc_display.h"
37 
38 namespace sdm {
39 
40 class HWCDisplayPrimary : public HWCDisplay {
41  public:
42   enum {
43     SET_METADATA_DYN_REFRESH_RATE,
44     SET_BINDER_DYN_REFRESH_RATE,
45     SET_DISPLAY_MODE,
46     SET_QDCM_SOLID_FILL_INFO,
47     UNSET_QDCM_SOLID_FILL_INFO,
48     SET_QDCM_SOLID_FILL_RECT,
49   };
50 
51   static int Create(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
52                     HWCCallbacks *callbacks, qService::QService *qservice,
53                     HWCDisplay **hwc_display);
54   static void Destroy(HWCDisplay *hwc_display);
55   virtual int Init();
56   virtual HWC2::Error Validate(uint32_t *out_num_types, uint32_t *out_num_requests);
57   virtual HWC2::Error Present(int32_t *out_retire_fence);
58   virtual HWC2::Error GetColorModes(uint32_t *out_num_modes, android_color_mode_t *out_modes);
59   virtual HWC2::Error SetColorMode(android_color_mode_t mode);
60   virtual HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint);
61   virtual int Perform(uint32_t operation, ...);
62   virtual void SetSecureDisplay(bool secure_display_active);
63   virtual DisplayError Refresh();
64   virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
65   virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type);
66   virtual int FrameCaptureAsync(const BufferInfo &output_buffer_info, bool post_processed);
GetFrameCaptureStatus()67   virtual int GetFrameCaptureStatus() { return frame_capture_status_; }
68   virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending);
69 
70  private:
71   HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
72                     HWCCallbacks *callbacks, qService::QService *qservice);
73   void SetMetaDataRefreshRateFlag(bool enable);
74   virtual DisplayError SetDisplayMode(uint32_t mode);
75   virtual DisplayError DisablePartialUpdateOneFrame();
76   void ProcessBootAnimCompleted(void);
77   void SetQDCMSolidFillInfo(bool enable, uint32_t color);
78   void ToggleCPUHint(bool set);
79   void ForceRefreshRate(uint32_t refresh_rate);
80   uint32_t GetOptimalRefreshRate(bool one_updating_layer);
81   void HandleFrameOutput();
82   void HandleFrameCapture();
83   void HandleFrameDump();
84   DisplayError SetMixerResolution(uint32_t width, uint32_t height);
85   DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
86 
87   BufferAllocator *buffer_allocator_ = nullptr;
88   CPUHint *cpu_hint_ = nullptr;
89   bool handle_idle_timeout_ = false;
90 
91   // Primary output buffer configuration
92   LayerBuffer output_buffer_ = {};
93   bool post_processed_output_ = false;
94 
95   // Members for 1 frame capture in a client provided buffer
96   bool frame_capture_buffer_queued_ = false;
97   int frame_capture_status_ = -EAGAIN;
98 
99   // Members for N frame output dump to file
100   bool dump_output_to_file_ = false;
101   BufferInfo output_buffer_info_ = {};
102   void *output_buffer_base_ = nullptr;
103 };
104 
105 }  // namespace sdm
106 
107 #endif  // __HWC_DISPLAY_PRIMARY_H__
108